wxMaxima
Loading...
Searching...
No Matches
private_structure.h
Go to the documentation of this file.
1
2// Name: private_structure.h
3// Purpose: Internal bookkeeping for tagged PDF (structure tree)
4// Author: wxPdfDocument contributors
5// Created: 2026-11-23
6// Licence: wxWindows licence
8
10
11#ifndef _PDF_PRIVATE_STRUCTURE_H_
12#define _PDF_PRIVATE_STRUCTURE_H_
13
14#include <map>
15#include <vector>
16
17#include "wx/pdfstructure.h"
18
21{
22public:
24 struct Kid
25 {
27 int m_page;
28 int m_mcid;
29 };
30
32 : m_tag(tag), m_parent(parent), m_objId(0), m_fileSpecObjId(0)
33 {
34 }
35
37 {
38 for (size_t j = 0; j < m_kids.size(); ++j)
39 {
40 delete m_kids[j].m_element;
41 }
42 }
43
46 {
47 Kid kid = { child, 0, 0 };
48 m_kids.push_back(kid);
49 }
50
52 void AddMarkedContent(int page, int mcid)
53 {
54 Kid kid = { NULL, page, mcid };
55 m_kids.push_back(kid);
56 }
57
59 int GetFirstPage() const
60 {
61 for (size_t j = 0; j < m_kids.size(); ++j)
62 {
63 if (m_kids[j].m_element == NULL)
64 {
65 return m_kids[j].m_page;
66 }
67 }
68 return 0;
69 }
70
73 std::vector<Kid> m_kids;
74 int m_objId;
76
77private:
79 wxPdfStructElement& operator=(const wxPdfStructElement&);
80};
81
83
101{
102public:
105 {
110 };
111
114 {
115 m_root = new wxPdfStructElement(wxPdfTag(wxS("Document")), NULL);
117 }
118
120 {
121 delete m_root;
122 }
123
125 int GetDepth() const
126 {
127 int depth = 0;
128 for (const wxPdfStructElement* e = m_current; e != m_root; e = e->m_parent)
129 {
130 ++depth;
131 }
132 return depth;
133 }
134
136 int NewMcid(int page)
137 {
138 std::vector<wxPdfStructElement*>& seqs = m_parentTree[page];
139 int mcid = (int) seqs.size();
140 seqs.push_back(m_current);
141 m_current->AddMarkedContent(page, mcid);
142 return mcid;
143 }
144
150
152 std::map<int, std::vector<wxPdfStructElement*> > m_parentTree;
153
154private:
156 wxPdfTaggingState& operator=(const wxPdfTaggingState&);
157};
158
159#endif
One node of the structure tree (internal)
Definition: private_structure.h:21
int GetFirstPage() const
Page number of the first marked-content sequence of this element itself, 0 if none.
Definition: private_structure.h:59
std::vector< Kid > m_kids
kids in logical (reading) order
Definition: private_structure.h:73
void AddMarkedContent(int page, int mcid)
Append a marked-content sequence.
Definition: private_structure.h:52
wxPdfStructElement * m_parent
parent element, NULL for the root
Definition: private_structure.h:72
void AddChild(wxPdfStructElement *child)
Append a child element (takes ownership)
Definition: private_structure.h:45
wxPdfTag m_tag
properties of the element
Definition: private_structure.h:71
int m_objId
PDF object number, assigned when writing.
Definition: private_structure.h:74
int m_fileSpecObjId
object number of the MathML file specification, 0 if none
Definition: private_structure.h:75
Description of a logical structure element ("tag") of a tagged PDF document.
Definition: pdfstructure.h:80
State of the tagging machinery of one document (internal)
Definition: private_structure.h:101
int m_paginationDepth
‍0 while page header or footer is written
Definition: private_structure.h:149
wxPdfStructElement * m_current
innermost open element
Definition: private_structure.h:146
int NewMcid(int page)
Register a new marked-content sequence for the current element on a page; returns its MCID.
Definition: private_structure.h:136
wxPdfStructElement * m_root
implicit Document element
Definition: private_structure.h:145
int m_artifactDepth
nesting depth of BeginArtifact()
Definition: private_structure.h:148
int GetDepth() const
Number of open structure elements (excluding the implicit Document root)
Definition: private_structure.h:125
MarkedContent m_open
currently open marked-content sequence
Definition: private_structure.h:147
std::map< int, std::vector< wxPdfStructElement * > > m_parentTree
For each page (1-based) the structure element of each MCID (index = MCID)
Definition: private_structure.h:152
MarkedContent
Kind of the marked-content sequence currently open on the page.
Definition: private_structure.h:105
@ MC_NONE
nothing open; the next content opens a sequence
Definition: private_structure.h:106
@ MC_SUSPENDED
no sequence open, and none must be opened (end of page)
Definition: private_structure.h:109
@ MC_ARTIFACT
artifact
Definition: private_structure.h:108
@ MC_CONTENT
content of a structure element
Definition: private_structure.h:107
Description of structure elements for tagged (accessible) PDF.
A kid of a structure element: either a child element or a marked-content sequence.
Definition: private_structure.h:25
int m_page
page number (1-based) of the marked-content sequence
Definition: private_structure.h:27
int m_mcid
marked-content identifier on that page
Definition: private_structure.h:28
wxPdfStructElement * m_element
child element, or NULL for a marked-content reference
Definition: private_structure.h:26