diff --git a/src/odr/document_element.cpp b/src/odr/document_element.cpp index cf7ae623..9f26e5c7 100644 --- a/src/odr/document_element.cpp +++ b/src/odr/document_element.cpp @@ -10,8 +10,15 @@ namespace odr { Element::Element() = default; Element::Element(const internal::abstract::Document *document, - internal::abstract::Element *element) - : m_document{document}, m_element{element} {} + internal::abstract::Element *element, + ElementIdentifier elementId) + : m_document{document}, m_element{element}, m_elementId{elementId} {} + +Element::Element( + const internal::abstract::Document *document, + std::pair element) + : m_document{document}, m_element{element.first}, m_elementId{ + element.second} {} bool Element::operator==(const Element &rhs) const { return m_element == rhs.m_element; @@ -53,49 +60,69 @@ Element Element::next_sibling() const { : Element(); } -TextRoot Element::text_root() const { return {m_document, m_element}; } +TextRoot Element::text_root() const { + return {m_document, m_element, m_elementId}; +} -Slide Element::slide() const { return {m_document, m_element}; } +Slide Element::slide() const { return {m_document, m_element, m_elementId}; } -Sheet Element::sheet() const { return {m_document, m_element}; } +Sheet Element::sheet() const { return {m_document, m_element, m_elementId}; } -Page Element::page() const { return {m_document, m_element}; } +Page Element::page() const { return {m_document, m_element, m_elementId}; } -MasterPage Element::master_page() const { return {m_document, m_element}; } +MasterPage Element::master_page() const { + return {m_document, m_element, m_elementId}; +} -LineBreak Element::line_break() const { return {m_document, m_element}; } +LineBreak Element::line_break() const { + return {m_document, m_element, m_elementId}; +} -Paragraph Element::paragraph() const { return {m_document, m_element}; } +Paragraph Element::paragraph() const { + return {m_document, m_element, m_elementId}; +} -Span Element::span() const { return {m_document, m_element}; } +Span Element::span() const { return {m_document, m_element, m_elementId}; } -Text Element::text() const { return {m_document, m_element}; } +Text Element::text() const { return {m_document, m_element, m_elementId}; } -Link Element::link() const { return {m_document, m_element}; } +Link Element::link() const { return {m_document, m_element, m_elementId}; } -Bookmark Element::bookmark() const { return {m_document, m_element}; } +Bookmark Element::bookmark() const { + return {m_document, m_element, m_elementId}; +} -ListItem Element::list_item() const { return {m_document, m_element}; } +ListItem Element::list_item() const { + return {m_document, m_element, m_elementId}; +} -Table Element::table() const { return {m_document, m_element}; } +Table Element::table() const { return {m_document, m_element, m_elementId}; } -TableColumn Element::table_column() const { return {m_document, m_element}; } +TableColumn Element::table_column() const { + return {m_document, m_element, m_elementId}; +} -TableRow Element::table_row() const { return {m_document, m_element}; } +TableRow Element::table_row() const { + return {m_document, m_element, m_elementId}; +} -TableCell Element::table_cell() const { return {m_document, m_element}; } +TableCell Element::table_cell() const { + return {m_document, m_element, m_elementId}; +} -Frame Element::frame() const { return {m_document, m_element}; } +Frame Element::frame() const { return {m_document, m_element, m_elementId}; } -Rect Element::rect() const { return {m_document, m_element}; } +Rect Element::rect() const { return {m_document, m_element, m_elementId}; } -Line Element::line() const { return {m_document, m_element}; } +Line Element::line() const { return {m_document, m_element, m_elementId}; } -Circle Element::circle() const { return {m_document, m_element}; } +Circle Element::circle() const { return {m_document, m_element, m_elementId}; } -CustomShape Element::custom_shape() const { return {m_document, m_element}; } +CustomShape Element::custom_shape() const { + return {m_document, m_element, m_elementId}; +} -Image Element::image() const { return {m_document, m_element}; } +Image Element::image() const { return {m_document, m_element, m_elementId}; } ElementIterator Element::begin() const { return m_element @@ -109,8 +136,15 @@ ElementIterator Element::end() const { return {}; } ElementIterator::ElementIterator() = default; ElementIterator::ElementIterator(const internal::abstract::Document *document, - internal::abstract::Element *element) - : m_document{document}, m_element{element} {} + internal::abstract::Element *element, + ElementIdentifier elementId) + : m_document{document}, m_element{element}, m_elementId{elementId} {} + +ElementIterator::ElementIterator( + const internal::abstract::Document *document, + std::pair element) + : m_document{document}, m_element{element.first}, m_elementId{ + element.second} {} bool ElementIterator::operator==(const ElementIterator &rhs) const { return m_elementId == rhs.m_elementId; @@ -121,12 +155,14 @@ bool ElementIterator::operator!=(const ElementIterator &rhs) const { } ElementIterator::reference ElementIterator::operator*() const { - return Element(m_document, m_element); + return Element(m_document, m_element, m_elementId); } ElementIterator &ElementIterator::operator++() { if (m_element != nullptr) { - m_element = m_element->next_sibling(m_document, m_elementId); + auto element = m_element->next_sibling(m_document, m_elementId); + m_element = element.first; + m_elementId = element.second; } return *this; } @@ -193,27 +229,31 @@ TableDimensions Sheet::content(std::optional range) const { TableColumn Sheet::column(std::uint32_t column) const { return m_element ? TableColumn(m_document, - m_element->column(m_document, m_elementId, column)) + m_element->column(m_document, m_elementId, column), + 0) // TODO : TableColumn(); } TableRow Sheet::row(std::uint32_t row) const { - return m_element ? TableRow(m_document, - m_element->row(m_document, m_elementId, row)) - : TableRow(); + return m_element + ? TableRow(m_document, + m_element->row(m_document, m_elementId, row), 0) // TODO + : TableRow(); } TableCell Sheet::cell(std::uint32_t column, std::uint32_t row) const { return m_element ? TableCell(m_document, - m_element->cell(m_document, m_elementId, column, row)) + m_element->cell(m_document, m_elementId, column, row), + 0) // TODO : TableCell(); } ElementRange Sheet::shapes() const { return m_element ? ElementRange(ElementIterator( - m_document, m_element->first_shape(m_document, m_elementId))) + m_document, m_element->first_shape(m_document, m_elementId), + 0)) // TODO : ElementRange(); } diff --git a/src/odr/document_element.hpp b/src/odr/document_element.hpp index 95d1dc35..33ebfe33 100644 --- a/src/odr/document_element.hpp +++ b/src/odr/document_element.hpp @@ -128,8 +128,10 @@ enum class ValueType { class Element { public: Element(); - Element(const internal::abstract::Document *document, - internal::abstract::Element *element); + Element(const internal::abstract::Document *, internal::abstract::Element *, + ElementIdentifier); + Element(const internal::abstract::Document *, + std::pair); bool operator==(const Element &rhs) const; bool operator!=(const Element &rhs) const; @@ -184,8 +186,10 @@ class ElementIterator { using iterator_category = std::forward_iterator_tag; ElementIterator(); - ElementIterator(const internal::abstract::Document *document, - internal::abstract::Element *element); + ElementIterator(const internal::abstract::Document *, + internal::abstract::Element *, ElementIdentifier); + ElementIterator(const internal::abstract::Document *, + std::pair); bool operator==(const ElementIterator &rhs) const; bool operator!=(const ElementIterator &rhs) const; @@ -204,11 +208,23 @@ class ElementIterator { template class TypedElement : public Element { public: TypedElement() = default; - TypedElement(const internal::abstract::Document *document, T *element) + + TypedElement(const internal::abstract::Document *document, T *element, + ElementIdentifier elementId) + : Element(document, element, elementId), m_element{element} {} + TypedElement(const internal::abstract::Document *document, + std::pair element) : Element(document, element), m_element{element} {} + TypedElement(const internal::abstract::Document *document, - internal::abstract::Element *element) - : TypedElement(document, dynamic_cast(element)) {} + internal::abstract::Element *element, + ElementIdentifier elementId) + : TypedElement(document, dynamic_cast(element), elementId) {} + TypedElement( + const internal::abstract::Document *document, + std::pair element) + : TypedElement(document, dynamic_cast(element.first), + element.second) {} protected: T *m_element{nullptr}; diff --git a/src/odr/internal/abstract/document.hpp b/src/odr/internal/abstract/document.hpp index 52924aab..7a79fb97 100644 --- a/src/odr/internal/abstract/document.hpp +++ b/src/odr/internal/abstract/document.hpp @@ -1,6 +1,8 @@ #ifndef ODR_INTERNAL_ABSTRACT_DOCUMENT_H #define ODR_INTERNAL_ABSTRACT_DOCUMENT_H +#include + #include namespace odr { @@ -46,7 +48,8 @@ class Document { files() const noexcept = 0; /// \return cursor to the root element of the document. - [[nodiscard]] virtual Element *root_element() const = 0; + [[nodiscard]] virtual std::pair + root_element() const = 0; }; } // namespace odr::internal::abstract diff --git a/src/odr/internal/abstract/document_element.hpp b/src/odr/internal/abstract/document_element.hpp index 8e0c6269..d9fcc3bb 100644 --- a/src/odr/internal/abstract/document_element.hpp +++ b/src/odr/internal/abstract/document_element.hpp @@ -33,16 +33,16 @@ class Element { [[nodiscard]] virtual ElementType type(const Document *, ElementIdentifier) const = 0; - [[nodiscard]] virtual Element *parent(const Document *, - ElementIdentifier) const = 0; - [[nodiscard]] virtual Element *first_child(const Document *, - ElementIdentifier) const = 0; - [[nodiscard]] virtual Element *last_child(const Document *, - ElementIdentifier) const = 0; - [[nodiscard]] virtual Element *previous_sibling(const Document *, - ElementIdentifier) const = 0; - [[nodiscard]] virtual Element *next_sibling(const Document *, - ElementIdentifier) const = 0; + [[nodiscard]] virtual std::pair + parent(const Document *, ElementIdentifier) const = 0; + [[nodiscard]] virtual std::pair + first_child(const Document *, ElementIdentifier) const = 0; + [[nodiscard]] virtual std::pair + last_child(const Document *, ElementIdentifier) const = 0; + [[nodiscard]] virtual std::pair + previous_sibling(const Document *, ElementIdentifier) const = 0; + [[nodiscard]] virtual std::pair + next_sibling(const Document *, ElementIdentifier) const = 0; }; class TextRoot : public virtual Element { @@ -55,7 +55,7 @@ class TextRoot : public virtual Element { [[nodiscard]] virtual PageLayout page_layout(const Document *, ElementIdentifier) const = 0; - [[nodiscard]] virtual MasterPage * + [[nodiscard]] virtual std::pair first_master_page(const Document *, ElementIdentifier) const = 0; }; @@ -69,8 +69,8 @@ class Slide : public virtual Element { [[nodiscard]] virtual PageLayout page_layout(const Document *, ElementIdentifier) const = 0; - [[nodiscard]] virtual MasterPage *master_page(const Document *, - ElementIdentifier) const = 0; + [[nodiscard]] virtual std::pair + master_page(const Document *, ElementIdentifier) const = 0; [[nodiscard]] virtual std::string name(const Document *, ElementIdentifier) const = 0; @@ -117,8 +117,8 @@ class Page : public virtual Element { [[nodiscard]] virtual PageLayout page_layout(const Document *, ElementIdentifier) const = 0; - [[nodiscard]] virtual MasterPage *master_page(const Document *, - ElementIdentifier) const = 0; + [[nodiscard]] virtual std::pair + master_page(const Document *, ElementIdentifier) const = 0; [[nodiscard]] virtual std::string name(const Document *, ElementIdentifier) const = 0; @@ -229,10 +229,10 @@ class Table : public virtual Element { [[nodiscard]] virtual TableDimensions dimensions(const Document *, ElementIdentifier) const = 0; - [[nodiscard]] virtual Element *first_column(const Document *, - ElementIdentifier) const = 0; - [[nodiscard]] virtual Element *first_row(const Document *, - ElementIdentifier) const = 0; + [[nodiscard]] virtual std::pair + first_column(const Document *, ElementIdentifier) const = 0; + [[nodiscard]] virtual std::pair + first_row(const Document *, ElementIdentifier) const = 0; [[nodiscard]] virtual TableStyle style(const Document *, ElementIdentifier) const = 0; @@ -404,8 +404,8 @@ class SheetColumn : public virtual Element { return ElementType::table_column; } - [[nodiscard]] virtual TableColumnStyle - style(const Document *, ElementIdentifier, ColumnIndex) const = 0; + [[nodiscard]] virtual TableColumnStyle style(const Document *, + ColumnIndex) const = 0; }; class SheetRow : public virtual Element { @@ -415,7 +415,7 @@ class SheetRow : public virtual Element { return ElementType::table_row; } - [[nodiscard]] virtual TableRowStyle style(const Document *, ElementIdentifier, + [[nodiscard]] virtual TableRowStyle style(const Document *, RowIndex) const = 0; }; @@ -426,16 +426,15 @@ class SheetCell : public virtual Element { return ElementType::table_cell; } - [[nodiscard]] virtual bool covered(const Document *, ElementIdentifier, - ColumnIndex, RowIndex) const = 0; - [[nodiscard]] virtual TableDimensions - span(const Document *, ElementIdentifier, ColumnIndex, RowIndex) const = 0; - [[nodiscard]] virtual ValueType value_type(const Document *, - ElementIdentifier, ColumnIndex, + [[nodiscard]] virtual bool covered(const Document *, ColumnIndex, + RowIndex) const = 0; + [[nodiscard]] virtual TableDimensions span(const Document *, ColumnIndex, + RowIndex) const = 0; + [[nodiscard]] virtual ValueType value_type(const Document *, ColumnIndex, RowIndex) const = 0; - [[nodiscard]] virtual TableCellStyle - style(const Document *, ElementIdentifier, ColumnIndex, RowIndex) const = 0; + [[nodiscard]] virtual TableCellStyle style(const Document *, ColumnIndex, + RowIndex) const = 0; }; } // namespace odr::internal::abstract diff --git a/src/odr/internal/common/document_element.cpp b/src/odr/internal/common/document_element.cpp index 7103fb83..faf822f2 100644 --- a/src/odr/internal/common/document_element.cpp +++ b/src/odr/internal/common/document_element.cpp @@ -10,28 +10,29 @@ Element::Element(pugi::xml_node node) : m_node{node} { } } -Element *Element::parent(const abstract::Document *, ElementIdentifier) const { - return m_parent; +std::pair +Element::parent(const abstract::Document *, ElementIdentifier) const { + return {m_parent, 0}; // TODO } -Element *Element::first_child(const abstract::Document *, - ElementIdentifier) const { - return m_first_child; +std::pair +Element::first_child(const abstract::Document *, ElementIdentifier) const { + return {m_first_child, 0}; // TODO } -Element *Element::last_child(const abstract::Document *, - ElementIdentifier) const { - return m_last_child; +std::pair +Element::last_child(const abstract::Document *, ElementIdentifier) const { + return {m_last_child, 0}; // TODO } -Element *Element::previous_sibling(const abstract::Document *, - ElementIdentifier) const { - return m_previous_sibling; +std::pair +Element::previous_sibling(const abstract::Document *, ElementIdentifier) const { + return {m_previous_sibling, 0}; // TODO } -Element *Element::next_sibling(const abstract::Document *, - ElementIdentifier) const { - return m_next_sibling; +std::pair +Element::next_sibling(const abstract::Document *, ElementIdentifier) const { + return {m_next_sibling, 0}; } void Element::init_append_child(Element *element) { @@ -47,23 +48,24 @@ void Element::init_append_child(Element *element) { Table::Table(pugi::xml_node node) : Element(node) {} -Element *Table::first_child(const abstract::Document *, - ElementIdentifier) const { +std::pair +Table::first_child(const abstract::Document *, ElementIdentifier) const { return {}; } -Element *Table::last_child(const abstract::Document *, - ElementIdentifier) const { +std::pair +Table::last_child(const abstract::Document *, ElementIdentifier) const { return {}; } -Element *Table::first_column(const abstract::Document *, - ElementIdentifier) const { - return m_first_column; +std::pair +Table::first_column(const abstract::Document *, ElementIdentifier) const { + return {m_first_column, 0}; // TODO } -Element *Table::first_row(const abstract::Document *, ElementIdentifier) const { - return m_first_child; +std::pair +Table::first_row(const abstract::Document *, ElementIdentifier) const { + return {m_first_child, 0}; // TODO } void Table::init_append_column(Element *element) { diff --git a/src/odr/internal/common/document_element.hpp b/src/odr/internal/common/document_element.hpp index 9497864a..fb305c02 100644 --- a/src/odr/internal/common/document_element.hpp +++ b/src/odr/internal/common/document_element.hpp @@ -15,16 +15,17 @@ class Element : public virtual abstract::Element { public: explicit Element(const pugi::xml_node node); - [[nodiscard]] Element *parent(const abstract::Document *, - ElementIdentifier) const override; - [[nodiscard]] Element *first_child(const abstract::Document *, - ElementIdentifier) const override; - [[nodiscard]] Element *last_child(const abstract::Document *, - ElementIdentifier) const override; - [[nodiscard]] Element *previous_sibling(const abstract::Document *, - ElementIdentifier) const override; - [[nodiscard]] Element *next_sibling(const abstract::Document *, - ElementIdentifier) const override; + [[nodiscard]] std::pair + parent(const abstract::Document *, ElementIdentifier) const override; + [[nodiscard]] std::pair + first_child(const abstract::Document *, ElementIdentifier) const override; + [[nodiscard]] std::pair + last_child(const abstract::Document *, ElementIdentifier) const override; + [[nodiscard]] std::pair + previous_sibling(const abstract::Document *, + ElementIdentifier) const override; + [[nodiscard]] std::pair + next_sibling(const abstract::Document *, ElementIdentifier) const override; void init_append_child(Element *element); @@ -43,14 +44,15 @@ class Table : public virtual Element, public abstract::Table { public: explicit Table(const pugi::xml_node node); - [[nodiscard]] Element *first_child(const abstract::Document *, - ElementIdentifier) const final; - [[nodiscard]] Element *last_child(const abstract::Document *, - ElementIdentifier) const final; + [[nodiscard]] std::pair + first_child(const abstract::Document *, ElementIdentifier) const final; + [[nodiscard]] std::pair + last_child(const abstract::Document *, ElementIdentifier) const final; - Element *first_column(const abstract::Document *, - ElementIdentifier) const final; - Element *first_row(const abstract::Document *, ElementIdentifier) const final; + std::pair + first_column(const abstract::Document *, ElementIdentifier) const final; + std::pair + first_row(const abstract::Document *, ElementIdentifier) const final; void init_append_column(Element *element); void init_append_row(Element *element); diff --git a/src/odr/internal/odf/odf_document.cpp b/src/odr/internal/odf/odf_document.cpp index 41980052..f8573d4b 100644 --- a/src/odr/internal/odf/odf_document.cpp +++ b/src/odr/internal/odf/odf_document.cpp @@ -106,6 +106,9 @@ std::shared_ptr Document::files() const noexcept { return m_filesystem; } -abstract::Element *Document::root_element() const { return m_root_element; } +std::pair +Document::root_element() const { + return {m_root_element, 0}; // TODO +} } // namespace odr::internal::odf diff --git a/src/odr/internal/odf/odf_document.hpp b/src/odr/internal/odf/odf_document.hpp index 73976b84..5a48896c 100644 --- a/src/odr/internal/odf/odf_document.hpp +++ b/src/odr/internal/odf/odf_document.hpp @@ -36,7 +36,8 @@ class Document : public abstract::Document { [[nodiscard]] std::shared_ptr files() const noexcept final; - [[nodiscard]] abstract::Element *root_element() const final; + [[nodiscard]] std::pair + root_element() const final; protected: FileType m_file_type; diff --git a/src/odr/internal/odf/odf_element.cpp b/src/odr/internal/odf/odf_element.cpp index ed7e7b0e..5d29ba79 100644 --- a/src/odr/internal/odf/odf_element.cpp +++ b/src/odr/internal/odf/odf_element.cpp @@ -78,17 +78,18 @@ ElementType TextRoot::type(const abstract::Document *, PageLayout TextRoot::page_layout(const abstract::Document *document, ElementIdentifier elementId) const { - if (auto master_page = this->first_master_page(document, elementId)) { + if (auto master_page = dynamic_cast( + this->first_master_page(document, elementId).first)) { return master_page->page_layout(document, elementId); } return {}; } -abstract::MasterPage * +std::pair TextRoot::first_master_page(const abstract::Document *document, ElementIdentifier) const { if (auto first_master_page = style_(document)->first_master_page()) { - return first_master_page; + return {first_master_page, 0}; // TODO } return {}; } @@ -114,16 +115,19 @@ Slide::Slide(pugi::xml_node node) : common::Element(node), Element(node) {} PageLayout Slide::page_layout(const abstract::Document *document, ElementIdentifier elementId) const { - if (auto master_page = this->master_page(document, elementId)) { + if (auto master_page = dynamic_cast( + this->master_page(document, elementId).first)) { return master_page->page_layout(document, elementId); } return {}; } -abstract::MasterPage *Slide::master_page(const abstract::Document *document, - ElementIdentifier) const { +std::pair +Slide::master_page(const abstract::Document *document, + ElementIdentifier) const { if (auto master_page_name_attr = m_node.attribute("draw:master-page-name")) { - return style_(document)->master_page(master_page_name_attr.value()); + return {style_(document)->master_page(master_page_name_attr.value()), + 0}; // TODO } return {}; } @@ -136,16 +140,18 @@ Page::Page(pugi::xml_node node) : common::Element(node), Element(node) {} PageLayout Page::page_layout(const abstract::Document *document, ElementIdentifier elementId) const { - if (auto master_page = this->master_page(document, elementId)) { + if (auto master_page = dynamic_cast( + this->master_page(document, elementId).first)) { return master_page->page_layout(document, elementId); } return {}; } -abstract::MasterPage *Page::master_page(const abstract::Document *document, - ElementIdentifier) const { +std::pair +Page::master_page(const abstract::Document *document, ElementIdentifier) const { if (auto master_page_name_attr = m_node.attribute("draw:master-page-name")) { - return style_(document)->master_page(master_page_name_attr.value()); + return {style_(document)->master_page(master_page_name_attr.value()), + 0}; // TODO } return {}; } diff --git a/src/odr/internal/odf/odf_element.hpp b/src/odr/internal/odf/odf_element.hpp index 4680571a..42a36918 100644 --- a/src/odr/internal/odf/odf_element.hpp +++ b/src/odr/internal/odf/odf_element.hpp @@ -59,7 +59,7 @@ class TextRoot final : public Root, public abstract::TextRoot { [[nodiscard]] PageLayout page_layout(const abstract::Document *, ElementIdentifier) const final; - [[nodiscard]] abstract::MasterPage * + [[nodiscard]] std::pair first_master_page(const abstract::Document *, ElementIdentifier) const final; }; @@ -88,7 +88,7 @@ class Slide final : public Element, public abstract::Slide { [[nodiscard]] PageLayout page_layout(const abstract::Document *, ElementIdentifier) const final; - [[nodiscard]] abstract::MasterPage * + [[nodiscard]] std::pair master_page(const abstract::Document *, ElementIdentifier) const final; [[nodiscard]] std::string name(const abstract::Document *, @@ -102,7 +102,7 @@ class Page final : public Element, public abstract::Page { [[nodiscard]] PageLayout page_layout(const abstract::Document *, ElementIdentifier) const final; - [[nodiscard]] abstract::MasterPage * + [[nodiscard]] std::pair master_page(const abstract::Document *, ElementIdentifier) const final; [[nodiscard]] std::string name(const abstract::Document *, diff --git a/src/odr/internal/ooxml/presentation/ooxml_presentation_document.cpp b/src/odr/internal/ooxml/presentation/ooxml_presentation_document.cpp index e23fa5b3..24439369 100644 --- a/src/odr/internal/ooxml/presentation/ooxml_presentation_document.cpp +++ b/src/odr/internal/ooxml/presentation/ooxml_presentation_document.cpp @@ -50,6 +50,9 @@ std::shared_ptr Document::files() const noexcept { return m_filesystem; } -abstract::Element *Document::root_element() const { return m_root_element; } +std::pair +Document::root_element() const { + return {m_root_element, 0}; // TODO +} } // namespace odr::internal::ooxml::presentation diff --git a/src/odr/internal/ooxml/presentation/ooxml_presentation_document.hpp b/src/odr/internal/ooxml/presentation/ooxml_presentation_document.hpp index a8600bea..5652d7dc 100644 --- a/src/odr/internal/ooxml/presentation/ooxml_presentation_document.hpp +++ b/src/odr/internal/ooxml/presentation/ooxml_presentation_document.hpp @@ -24,7 +24,8 @@ class Document final : public abstract::Document { [[nodiscard]] std::shared_ptr files() const noexcept final; - [[nodiscard]] abstract::Element *root_element() const final; + [[nodiscard]] std::pair + root_element() const final; private: std::shared_ptr m_filesystem; diff --git a/src/odr/internal/ooxml/presentation/ooxml_presentation_element.cpp b/src/odr/internal/ooxml/presentation/ooxml_presentation_element.cpp index ba5ab2e8..a3d64eb5 100644 --- a/src/odr/internal/ooxml/presentation/ooxml_presentation_element.cpp +++ b/src/odr/internal/ooxml/presentation/ooxml_presentation_element.cpp @@ -41,8 +41,8 @@ PageLayout Slide::page_layout(const abstract::Document *, return {}; // TODO } -abstract::MasterPage *Slide::master_page(const abstract::Document *, - ElementIdentifier) const { +std::pair +Slide::master_page(const abstract::Document *, ElementIdentifier) const { return {}; // TODO } @@ -111,13 +111,14 @@ TableDimensions TableElement::dimensions(const abstract::Document *, return {}; // TODO } -abstract::Element *TableElement::first_column(const abstract::Document *, - ElementIdentifier) const { +std::pair +TableElement::first_column(const abstract::Document *, + ElementIdentifier) const { return {}; // TODO } -abstract::Element *TableElement::first_row(const abstract::Document *, - ElementIdentifier) const { +std::pair +TableElement::first_row(const abstract::Document *, ElementIdentifier) const { return {}; // TODO } diff --git a/src/odr/internal/ooxml/presentation/ooxml_presentation_element.hpp b/src/odr/internal/ooxml/presentation/ooxml_presentation_element.hpp index d5615d14..b3645a92 100644 --- a/src/odr/internal/ooxml/presentation/ooxml_presentation_element.hpp +++ b/src/odr/internal/ooxml/presentation/ooxml_presentation_element.hpp @@ -46,7 +46,7 @@ class Slide final : public Element, public abstract::Slide { [[nodiscard]] PageLayout page_layout(const abstract::Document *, ElementIdentifier) const final; - [[nodiscard]] abstract::MasterPage * + [[nodiscard]] std::pair master_page(const abstract::Document *, ElementIdentifier) const final; [[nodiscard]] std::string name(const abstract::Document *, @@ -102,11 +102,11 @@ class TableElement : public Element, public abstract::Table { [[nodiscard]] TableDimensions dimensions(const abstract::Document *, ElementIdentifier) const final; - [[nodiscard]] abstract::Element *first_column(const abstract::Document *, - ElementIdentifier) const final; + [[nodiscard]] std::pair + first_column(const abstract::Document *, ElementIdentifier) const final; - [[nodiscard]] abstract::Element *first_row(const abstract::Document *, - ElementIdentifier) const final; + [[nodiscard]] std::pair + first_row(const abstract::Document *, ElementIdentifier) const final; [[nodiscard]] TableStyle style(const abstract::Document *, ElementIdentifier) const final; diff --git a/src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_document.cpp b/src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_document.cpp index 0a35d74e..34407f7d 100644 --- a/src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_document.cpp +++ b/src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_document.cpp @@ -80,6 +80,9 @@ std::shared_ptr Document::files() const noexcept { return m_filesystem; } -abstract::Element *Document::root_element() const { return m_root_element; } +std::pair +Document::root_element() const { + return {m_root_element, 0}; // TODO +} } // namespace odr::internal::ooxml::spreadsheet diff --git a/src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_document.hpp b/src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_document.hpp index 552cbca8..3bae1a53 100644 --- a/src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_document.hpp +++ b/src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_document.hpp @@ -36,7 +36,8 @@ class Document final : public abstract::Document { [[nodiscard]] std::shared_ptr files() const noexcept final; - [[nodiscard]] abstract::Element *root_element() const final; + [[nodiscard]] std::pair + root_element() const final; private: struct Sheet final { diff --git a/src/odr/internal/ooxml/text/ooxml_text_document.cpp b/src/odr/internal/ooxml/text/ooxml_text_document.cpp index d2b7ae21..f0a0ac34 100644 --- a/src/odr/internal/ooxml/text/ooxml_text_document.cpp +++ b/src/odr/internal/ooxml/text/ooxml_text_document.cpp @@ -82,6 +82,9 @@ std::shared_ptr Document::files() const noexcept { return m_filesystem; } -abstract::Element *Document::root_element() const { return m_root_element; } +std::pair +Document::root_element() const { + return {m_root_element, 0}; // TODO +} } // namespace odr::internal::ooxml::text diff --git a/src/odr/internal/ooxml/text/ooxml_text_document.hpp b/src/odr/internal/ooxml/text/ooxml_text_document.hpp index f603e21c..95695b63 100644 --- a/src/odr/internal/ooxml/text/ooxml_text_document.hpp +++ b/src/odr/internal/ooxml/text/ooxml_text_document.hpp @@ -36,7 +36,8 @@ class Document final : public abstract::Document { [[nodiscard]] std::shared_ptr files() const noexcept final; - [[nodiscard]] abstract::Element *root_element() const final; + [[nodiscard]] std::pair + root_element() const final; private: std::shared_ptr m_filesystem; diff --git a/src/odr/internal/ooxml/text/ooxml_text_element.cpp b/src/odr/internal/ooxml/text/ooxml_text_element.cpp index 1c6fa4e6..24eac737 100644 --- a/src/odr/internal/ooxml/text/ooxml_text_element.cpp +++ b/src/odr/internal/ooxml/text/ooxml_text_element.cpp @@ -62,9 +62,9 @@ PageLayout Root::page_layout(const abstract::Document *, return {}; // TODO } -abstract::MasterPage *Root::first_master_page(const abstract::Document *, - ElementIdentifier) const { - return nullptr; // TODO +std::pair +Root::first_master_page(const abstract::Document *, ElementIdentifier) const { + return {}; // TODO } Paragraph::Paragraph(pugi::xml_node node) diff --git a/src/odr/internal/ooxml/text/ooxml_text_element.hpp b/src/odr/internal/ooxml/text/ooxml_text_element.hpp index fd744eb9..9889ba62 100644 --- a/src/odr/internal/ooxml/text/ooxml_text_element.hpp +++ b/src/odr/internal/ooxml/text/ooxml_text_element.hpp @@ -51,7 +51,7 @@ class Root final : public Element, public abstract::TextRoot { [[nodiscard]] PageLayout page_layout(const abstract::Document *, ElementIdentifier) const final; - [[nodiscard]] abstract::MasterPage * + [[nodiscard]] std::pair first_master_page(const abstract::Document *, ElementIdentifier) const final; };