3#ifndef PDFSDK_CXX_STRUCT_TREE_H_INCLUDED_
4#define PDFSDK_CXX_STRUCT_TREE_H_INCLUDED_
11#include "forward_declarations.h"
56 explicit operator bool() const noexcept {
return static_cast<bool>(m_obj); }
88 void SetID(std::string_view
id);
381 friend class StructTreeRoot;
426 explicit operator bool() const noexcept {
return static_cast<bool>(m_obj); }
567#include "struct_tree_impl.inl"
Represents an element of the content array.
Definition element.h:29
Represents a PDF object.
Definition object.h:25
Represents a leaf node (Page Object).
Definition page.h:20
A structure element in a document's logical structure (tag) tree.
Definition struct_tree.h:30
void RemoveAttrObj(const Object &attrObj)
Removes the given attribute object (and its revision) from the element.
void SetID(std::string_view id)
Sets the element identifier (the /ID entry) and updates the document's ID tree so the element can be ...
int GetAttrObjRevision(size_t index) const
Gets the revision number that the attribute object at index applies to.
Object GetKidMCStmOwn(size_t index) const
Gets the object owning the marked content's content stream.
void SetAltText(std::wstring_view altText)
Sets the alternate description used by assistive technology (the /Alt entry).
void AddClass(PDAtom name)
Adds a class name to the element, applying it to the element's current revision number....
void IncrementRevision()
Increments the element's revision number. Attribute objects and classes added afterwards are associat...
Object GetKidMCStm(size_t index) const
Gets the content stream containing the marked-content kid at index.
void SetLanguage(std::wstring_view lang)
Sets the natural language of the element's content (the /Lang entry, e.g. L"en-US").
int GetKidMCID(size_t index) const
Gets the marked-content identifier of the kid at index.
bool IsDetached() const
Checks if the element is detached from a structure tree.
size_t GetNumKids() const
Gets the number of kids (the /K entry).
Object GetPdfObject() const
Gets the PDF object backing this structure element.
int GetClassRevision(size_t index) const
Gets the revision number that the class at index applies to.
StructTreeElement GetKidElement(size_t index) const
Gets the structure element kid at index.
void SetTitle(std::wstring_view title)
Sets the human-readable title (the /T entry).
PDAtom GetClass(size_t index) const
Gets the class name at index.
void InsertAttrObj(size_t index, const Object &attrObj)
Associates an attribute object with the element at index, applying it to the element's current revisi...
Object GetAttrObj(size_t index) const
Gets the attribute object at index.
std::wstring GetLanguage() const
Gets the natural language (the /Lang entry).
void InsertKidOBJR(size_t index, const Page &page, const Object &object)
Associates a whole object (e.g. an annotation) with the element as an object-reference kid at index,...
size_t GetNumAttrObjs() const
Gets the number of attribute objects associated with the element (the /A entry).
std::wstring GetAltText() const
Gets the alternate description (the /Alt entry).
std::wstring GetActualText() const
Gets the replacement text (the /ActualText entry).
std::wstring GetTitle() const
Gets the title (the /T entry).
void SetActualText(std::wstring_view actualText)
Sets the replacement text for the element's content (the /ActualText entry).
Object GetKidOBJRObject(size_t index) const
Gets the object referenced by the object-reference kid at index.
int GetRevision() const
Gets the element's revision number (the /R entry).
PDAtom GetType() const
Gets the structure type (the /S entry).
StructTreeElement GetParent() const
Gets the parent structure element.
void RemoveClass(PDAtom name)
Removes a class name (and its revision) from the element.
void RemoveKid(size_t index)
Removes the kid at index, keeping the document consistent.
void InsertKidMCID(size_t index, const Page &page, int mcid, const Object &stm=Object(), const Object &stmOwn=Object())
Inserts a reference to marked content that already carries mcid as a kid at index.
std::string GetID() const
Gets the element identifier (the /ID entry).
bool Equals(const StructTreeElement &rhs) const noexcept
Compares two elements for identity (same backing object).
StructTreeElement() noexcept=default
Constructs an empty (null) element.
void SetType(PDAtom type)
Sets the structure type - the /S entry (a standard type such as P or H1, or a custom type resolved th...
size_t GetNumClasses() const
Gets the number of class names associated with the element (the /C entry).
Page GetKidMCPage(size_t index) const
Gets the page containing the marked-content kid at index.
void InsertKidElement(size_t index, const StructTreeElement &kid)
Inserts an existing structure element as a kid at index and sets its parent to this element....
PDStructTreeKidType GetKidType(size_t index) const
Gets the kind of the kid at index so the matching typed accessor (GetKidElement, GetKidMC*,...
void InsertKidMC(size_t index, const Page &page, const Element &mc, const Object &stm=Object(), const Object &stmOwn=Object())
Tags a previously-untagged marked-content sequence and inserts it as a kid at index.
Page GetKidOBJRPage(size_t index) const
Gets the page associated with the object-reference kid at index.
static StructTreeElement CreateFromPdfObject(const Object &object)
Wraps an existing structure element dictionary.
The root of a document's logical structure (tag) tree.
Definition struct_tree.h:400
PDAtom RoleMapGet(PDAtom from) const
Gets the standard structure type that from maps to.
StructTreeRoot() noexcept=default
Constructs an empty (null) root.
void RemoveKid(size_t index)
Detaches the top-level kid at index: it is unlinked from the root and its parent link is cleared,...
void ClassMapRemoveAll()
Removes the entire class map.
size_t ClassMapGetNumAttrObjs(PDAtom name) const
Gets the number of attribute objects mapped to class name in the class map.
StructTreeElement GetMCIDParent(const Page &page, int mcid) const
Finds the structure element that owns the given marked-content identifier.
Object GetPdfObject() const
Gets the PDF object backing this structure tree root.
StructTreeElement FindElementByID(std::string_view id) const
Finds a structure element by its identifier via the document's ID tree.
StructTreeElement CreateElement(PDAtom type)
Creates a new, detached structure element of the given type, owned by the same document....
void RoleMapPut(PDAtom from, PDAtom to)
Maps a custom role from to a standard structure type to, so elements typed from are treated as to.
void InsertKid(size_t index, const StructTreeElement &element)
Inserts a structure element as a top-level kid at index and sets its parent to the root....
size_t GetNumKids() const
Gets the number of top-level kids.
Object ClassMapGetAttrObj(PDAtom name, size_t index) const
Gets the attribute object at index mapped to class name.
void ClassMapRemoveClass(PDAtom name)
Removes class name (and all its attribute objects) from the class map.
StructTreeElement GetMCParent(const Page &page, const Element &mc) const
Finds the structure element that owns the given marked content, via the parent tree.
static StructTreeRoot CreateFromPdfObject(const Object &object)
Wraps an existing structure tree root dictionary.
StructTreeElement GetKid(size_t index) const
Gets the top-level structure element at index.
void ClassMapRemoveAttrObj(PDAtom name, const Object &attrObj)
Removes the given attribute object from class name.
bool Equals(const StructTreeRoot &rhs) const noexcept
Compares two roots for identity (same backing object).
void ClassMapInsertAttrObj(PDAtom name, size_t index, const Object &attrObj)
Maps an attribute object to class name at index in the class map.
StructTreeElement GetObjectParent(const Object &object) const
Finds the structure element that owns the given object (e.g. an annotation).
void RoleMapRemove(PDAtom from)
Removes the role mapping for from.