From 9696ccec112100c8f8bb40f7ab343a4f76d83e71 Mon Sep 17 00:00:00 2001 From: andiwand Date: Mon, 4 Dec 2023 10:46:35 +0100 Subject: [PATCH] tmp --- CMakeLists.txt | 1 - src/odr/document_element.cpp | 59 ++++--- src/odr/document_element.hpp | 21 ++- .../internal/abstract/document_element.hpp | 65 +------- src/odr/internal/abstract/sheet_element.hpp | 76 +++++++++ src/odr/internal/common/document_element.hpp | 4 - src/odr/internal/html/css_writer.cpp | 3 - src/odr/internal/html/css_writer.hpp | 13 -- src/odr/internal/html/document_element.cpp | 59 +++---- src/odr/internal/odf/odf_document.cpp | 8 +- src/odr/internal/odf/odf_element.cpp | 6 +- src/odr/internal/odf/odf_element.hpp | 4 +- src/odr/internal/odf/odf_parser.cpp | 70 ++++----- src/odr/internal/odf/odf_parser.hpp | 47 +++--- src/odr/internal/odf/odf_spreadsheet.cpp | 145 +++++++++++------- src/odr/internal/odf/odf_spreadsheet.hpp | 61 +++++--- src/odr/internal/odf/odf_style.cpp | 9 +- src/odr/internal/odf/odf_style.hpp | 6 +- .../ooxml_presentation_element.cpp | 6 +- .../ooxml_presentation_element.hpp | 4 +- .../spreadsheet/ooxml_spreadsheet_element.cpp | 55 ++++--- .../spreadsheet/ooxml_spreadsheet_element.hpp | 35 +++-- .../ooxml/text/ooxml_text_element.cpp | 6 +- .../ooxml/text/ooxml_text_element.hpp | 4 +- 24 files changed, 432 insertions(+), 335 deletions(-) create mode 100644 src/odr/internal/abstract/sheet_element.hpp delete mode 100644 src/odr/internal/html/css_writer.cpp delete mode 100644 src/odr/internal/html/css_writer.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index f3eabfec1..bc46131ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,7 +110,6 @@ add_library(odr "src/odr/internal/csv/csv_util.cpp" "src/odr/internal/html/common.cpp" - "src/odr/internal/html/css_writer.cpp" "src/odr/internal/html/document.cpp" "src/odr/internal/html/document_style.cpp" "src/odr/internal/html/document_element.cpp" diff --git a/src/odr/document_element.cpp b/src/odr/document_element.cpp index b06a0bff3..c9809b3f9 100644 --- a/src/odr/document_element.cpp +++ b/src/odr/document_element.cpp @@ -4,6 +4,7 @@ #include #include +#include namespace odr { @@ -181,21 +182,12 @@ TableDimensions Sheet::content(std::optional range) const { return exists_() ? m_element->content(m_document, range) : TableDimensions(); } -TableColumn Sheet::column(std::uint32_t column) const { - return exists_() - ? TableColumn(m_document, m_element->column(m_document, column)) - : TableColumn(); -} - -TableRow Sheet::row(std::uint32_t row) const { - return exists_() ? TableRow(m_document, m_element->row(m_document, row)) - : TableRow(); -} - -TableCell Sheet::cell(std::uint32_t column, std::uint32_t row) const { - return exists_() - ? TableCell(m_document, m_element->cell(m_document, column, row)) - : TableCell(); +ElementRange Sheet::cell_elements(std::uint32_t column, + std::uint32_t row) const { + return exists_() ? ElementRange(ElementIterator(m_document, + m_element->first_cell_element( + m_document, column, row))) + : ElementRange(); } ElementRange Sheet::shapes() const { @@ -208,6 +200,35 @@ TableStyle Sheet::style() const { return exists_() ? m_element->style(m_document) : TableStyle(); } +TableColumnStyle Sheet::column_style(std::uint32_t column) const { + return exists_() ? m_element->column_style(m_document, column) + : TableColumnStyle(); +} + +TableRowStyle Sheet::row_style(std::uint32_t row) const { + return exists_() ? m_element->row_style(m_document, row) : TableRowStyle(); +} + +TableCellStyle Sheet::cell_style(std::uint32_t column, + std::uint32_t row) const { + return exists_() ? m_element->cell_style(m_document, column, row) + : TableCellStyle(); +} + +bool Sheet::is_covered(std::uint32_t column, std::uint32_t row) const { + return exists_() ? m_element->is_covered(m_document, column, row) : false; +} + +TableDimensions Sheet::span(std::uint32_t column, std::uint32_t row) const { + return exists_() ? m_element->span(m_document, column, row) + : TableDimensions(); +} + +ValueType Sheet::value_type(std::uint32_t column, std::uint32_t row) const { + return exists_() ? m_element->value_type(m_document, column, row) + : ValueType::unknown; +} + std::string Page::name() const { return exists_() ? m_element->name(m_document) : ""; } @@ -295,8 +316,8 @@ TableRowStyle TableRow::style() const { return exists_() ? m_element->style(m_document) : TableRowStyle(); } -bool TableCell::covered() const { - return exists_() && m_element->covered(m_document); +bool TableCell::is_covered() const { + return exists_() && m_element->is_covered(m_document); } TableDimensions TableCell::span() const { @@ -423,8 +444,8 @@ GraphicStyle CustomShape::style() const { return exists_() ? m_element->style(m_document) : GraphicStyle(); } -bool Image::internal() const { - return exists_() && m_element->internal(m_document); +bool Image::is_internal() const { + return exists_() && m_element->is_internal(m_document); } std::optional Image::file() const { diff --git a/src/odr/document_element.hpp b/src/odr/document_element.hpp index 99bcb1ef7..0f2073fe1 100644 --- a/src/odr/document_element.hpp +++ b/src/odr/document_element.hpp @@ -118,6 +118,7 @@ enum class AnchorType { }; enum class ValueType { + unknown, string, float_number, }; @@ -260,13 +261,21 @@ class Sheet final : public TypedElement { [[nodiscard]] TableDimensions content(std::optional range) const; - [[nodiscard]] TableColumn column(std::uint32_t column) const; - [[nodiscard]] TableRow row(std::uint32_t row) const; - [[nodiscard]] TableCell cell(std::uint32_t column, std::uint32_t row) const; - + [[nodiscard]] ElementRange cell_elements(std::uint32_t column, + std::uint32_t row) const; [[nodiscard]] ElementRange shapes() const; [[nodiscard]] TableStyle style() const; + [[nodiscard]] TableColumnStyle column_style(std::uint32_t column) const; + [[nodiscard]] TableRowStyle row_style(std::uint32_t row) const; + [[nodiscard]] TableCellStyle cell_style(std::uint32_t column, + std::uint32_t row) const; + + [[nodiscard]] bool is_covered(std::uint32_t column, std::uint32_t row) const; + [[nodiscard]] TableDimensions span(std::uint32_t column, + std::uint32_t row) const; + [[nodiscard]] ValueType value_type(std::uint32_t column, + std::uint32_t row) const; }; class Page final : public TypedElement { @@ -373,7 +382,7 @@ class TableCell final : public TypedElement { [[nodiscard]] TableColumn column() const; [[nodiscard]] TableRow row() const; - [[nodiscard]] bool covered() const; + [[nodiscard]] bool is_covered() const; [[nodiscard]] TableDimensions span() const; [[nodiscard]] ValueType value_type() const; @@ -446,7 +455,7 @@ class Image final : public TypedElement { public: using TypedElement::TypedElement; - [[nodiscard]] bool internal() const; + [[nodiscard]] bool is_internal() const; [[nodiscard]] std::optional file() const; [[nodiscard]] std::string href() const; }; diff --git a/src/odr/internal/abstract/document_element.hpp b/src/odr/internal/abstract/document_element.hpp index 2af8badc2..a820325af 100644 --- a/src/odr/internal/abstract/document_element.hpp +++ b/src/odr/internal/abstract/document_element.hpp @@ -67,30 +67,6 @@ class Slide : public virtual Element { [[nodiscard]] virtual std::string name(const Document *) const = 0; }; -class Sheet : public virtual Element { -public: - [[nodiscard]] ElementType type(const Document *) const override { - return ElementType::sheet; - } - - [[nodiscard]] virtual std::string name(const Document *) const = 0; - - [[nodiscard]] virtual TableDimensions dimensions(const Document *) const = 0; - [[nodiscard]] virtual TableDimensions - content(const Document *, std::optional range) const = 0; - - [[nodiscard]] virtual Element *column(const Document *, - std::uint32_t column) const = 0; - [[nodiscard]] virtual Element *row(const Document *, - std::uint32_t row) const = 0; - [[nodiscard]] virtual Element *cell(const Document *, std::uint32_t column, - std::uint32_t row) const = 0; - - [[nodiscard]] virtual Element *first_shape(const Document *) const = 0; - - [[nodiscard]] virtual TableStyle style(const Document *) const = 0; -}; - class Page : public virtual Element { public: [[nodiscard]] ElementType type(const Document *) const override { @@ -218,7 +194,7 @@ class TableCell : public virtual Element { return ElementType::table_cell; } - [[nodiscard]] virtual bool covered(const Document *) const = 0; + [[nodiscard]] virtual bool is_covered(const Document *) const = 0; [[nodiscard]] virtual TableDimensions span(const Document *) const = 0; [[nodiscard]] virtual ValueType value_type(const Document *) const = 0; @@ -310,49 +286,12 @@ class Image : public virtual Element { return ElementType::image; } - [[nodiscard]] virtual bool internal(const Document *) const = 0; + [[nodiscard]] virtual bool is_internal(const Document *) const = 0; [[nodiscard]] virtual std::optional file(const Document *) const = 0; [[nodiscard]] virtual std::string href(const Document *) const = 0; }; -class SheetColumn : public virtual Element { -public: - [[nodiscard]] ElementType type(const Document *) const override { - return ElementType::table_column; - } - - [[nodiscard]] virtual TableColumnStyle style(const Document *, - std::uint32_t column) const = 0; -}; - -class SheetRow : public virtual Element { -public: - [[nodiscard]] ElementType type(const Document *) const override { - return ElementType::table_row; - } - - [[nodiscard]] virtual TableRowStyle style(const Document *) const = 0; -}; - -class SheetCell : public virtual Element { -public: - [[nodiscard]] ElementType type(const Document *) const override { - return ElementType::table_cell; - } - - [[nodiscard]] virtual bool covered(const Document *, std::uint32_t column, - std::uint32_t row) const = 0; - [[nodiscard]] virtual TableDimensions - span(const Document *, std::uint32_t column, std::uint32_t row) const = 0; - [[nodiscard]] virtual ValueType value_type(const Document *, - std::uint32_t column, - std::uint32_t row) const = 0; - - [[nodiscard]] virtual TableCellStyle - style(const Document *, std::uint32_t column, std::uint32_t row) const = 0; -}; - } // namespace odr::internal::abstract #endif // ODR_INTERNAL_ABSTRACT_DOCUMENT_ELEMENT_H diff --git a/src/odr/internal/abstract/sheet_element.hpp b/src/odr/internal/abstract/sheet_element.hpp new file mode 100644 index 000000000..3185f41ac --- /dev/null +++ b/src/odr/internal/abstract/sheet_element.hpp @@ -0,0 +1,76 @@ +#ifndef ODR_INTERNAL_ABSTRACT_SHEET_ELEMENT_H +#define ODR_INTERNAL_ABSTRACT_SHEET_ELEMENT_H + +#include + +namespace odr::internal::abstract { +class SheetColumn; +class SheetRow; +class SheetCell; + +class Sheet : public virtual Element { +public: + [[nodiscard]] ElementType type(const Document *) const override { + return ElementType::sheet; + } + + [[nodiscard]] virtual std::string name(const Document *) const = 0; + + [[nodiscard]] virtual TableDimensions dimensions(const Document *) const = 0; + [[nodiscard]] virtual TableDimensions + content(const Document *, std::optional range) const = 0; + + [[nodiscard]] virtual SheetColumn *column(const Document *, + std::uint32_t column) const = 0; + [[nodiscard]] virtual SheetRow *row(const Document *, + std::uint32_t row) const = 0; + [[nodiscard]] virtual SheetCell *cell(const Document *, std::uint32_t column, + std::uint32_t row) const = 0; + + [[nodiscard]] virtual Element *first_shape(const Document *) const = 0; +}; + +class SheetColumn : public virtual Element { +public: + [[nodiscard]] ElementType type(const Document *) const override { + return ElementType::table_column; + } + + [[nodiscard]] virtual TableColumnStyle style(const Document *, const Sheet *, + std::uint32_t column) const = 0; +}; + +class SheetRow : public virtual Element { +public: + [[nodiscard]] ElementType type(const Document *) const override { + return ElementType::table_row; + } + + [[nodiscard]] virtual TableRowStyle style(const Document *, const Sheet *, + std::uint32_t row) const = 0; +}; + +class SheetCell : public virtual Element { +public: + [[nodiscard]] ElementType type(const Document *) const override { + return ElementType::table_cell; + } + + [[nodiscard]] virtual bool is_covered(const Document *, const Sheet *, + std::uint32_t column, + std::uint32_t row) const = 0; + [[nodiscard]] virtual TableDimensions span(const Document *, const Sheet *, + std::uint32_t column, + std::uint32_t row) const = 0; + [[nodiscard]] virtual ValueType value_type(const Document *, const Sheet *, + std::uint32_t column, + std::uint32_t row) const = 0; + + [[nodiscard]] virtual TableCellStyle style(const Document *, const Sheet *, + std::uint32_t column, + std::uint32_t row) const = 0; +}; + +} // namespace odr::internal::abstract + +#endif // ODR_INTERNAL_ABSTRACT_SHEET_ELEMENT_H diff --git a/src/odr/internal/common/document_element.hpp b/src/odr/internal/common/document_element.hpp index daac1346d..a80def5a2 100644 --- a/src/odr/internal/common/document_element.hpp +++ b/src/odr/internal/common/document_element.hpp @@ -58,10 +58,6 @@ class Table : public virtual Element, public abstract::Table { Element *m_last_column{}; }; -class Sheet : public virtual Element, public abstract::Sheet { -public: -}; - } // namespace odr::internal::common #endif // ODR_INTERNAL_COMMON_DOCUMENT_ELEMENT_H diff --git a/src/odr/internal/html/css_writer.cpp b/src/odr/internal/html/css_writer.cpp deleted file mode 100644 index 3ac4b7ba4..000000000 --- a/src/odr/internal/html/css_writer.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include - -namespace odr::internal::html {} diff --git a/src/odr/internal/html/css_writer.hpp b/src/odr/internal/html/css_writer.hpp deleted file mode 100644 index 670f8373b..000000000 --- a/src/odr/internal/html/css_writer.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef ODR_INTERNAL_HTML_CSS_WRITER_H -#define ODR_INTERNAL_HTML_CSS_WRITER_H - -namespace odr::internal::html { - -class CssWriter { -public: -private: -}; - -} // namespace odr::internal::html - -#endif // ODR_INTERNAL_HTML_CSS_WRITER_H diff --git a/src/odr/internal/html/document_element.cpp b/src/odr/internal/html/document_element.cpp index 367b68b4b..801d6954c 100644 --- a/src/odr/internal/html/document_element.cpp +++ b/src/odr/internal/html/document_element.cpp @@ -104,11 +104,11 @@ void html::translate_sheet(Element element, std::ostream &out, for (std::uint32_t column_index = 0; column_index < end_column; ++column_index) { - auto table_column = sheet.column(column_index); + auto table_column_style = sheet.column_style(column_index); out << ""; } @@ -127,8 +127,7 @@ void html::translate_sheet(Element element, std::ostream &out, } for (std::uint32_t row_index = 0; row_index < end_row; ++row_index) { - auto table_row = sheet.row(row_index); - auto table_row_style = table_row.style(); + auto table_row_style = sheet.row_style(row_index); out << " 1) { - out << " rowspan=\"" << cell_span.rows << "\""; - } - if (cell_span.columns > 1) { - out << " colspan=\"" << cell_span.columns << "\""; - } - out << optional_style_attribute(translate_table_cell_style(cell_style)); - if (table_cell.value_type() == ValueType::float_number) { - out << " class=\"odr-value-type-float\""; - } - out << ">"; - if ((row_index == 0) && (column_index == 0)) { - for (auto shape : sheet.shapes()) { - translate_element(shape, out, config); - } + out << " 1) { + out << " rowspan=\"" << cell_span.rows << "\""; + } + if (cell_span.columns > 1) { + out << " colspan=\"" << cell_span.columns << "\""; + } + out << optional_style_attribute(translate_table_cell_style(cell_style)); + if (cell_value_type == ValueType::float_number) { + out << " class=\"odr-value-type-float\""; + } + out << ">"; + if ((row_index == 0) && (column_index == 0)) { + for (auto shape : sheet.shapes()) { + translate_element(shape, out, config); } - translate_children(table_cell.children(), out, config); - out << ""; } + translate_children(cell_elements, out, config); + out << ""; } out << ""; @@ -335,7 +338,7 @@ void html::translate_table(Element element, std::ostream &out, for (auto cell : table_row.children()) { auto table_cell = cell.table_cell(); - if (!table_cell.covered()) { + if (!table_cell.is_covered()) { auto cell_span = table_cell.span(); out << "files()) { return false; @@ -449,7 +449,7 @@ bool Image::internal(const abstract::Document *document) const { std::optional Image::file(const abstract::Document *document) const { auto doc = document_(document); - if (!doc || !internal(document)) { + if (!doc || !is_internal(document)) { return {}; } return File(doc->files()->open(href(document))); diff --git a/src/odr/internal/odf/odf_element.hpp b/src/odr/internal/odf/odf_element.hpp index 5a7c63037..f7f35c8ca 100644 --- a/src/odr/internal/odf/odf_element.hpp +++ b/src/odr/internal/odf/odf_element.hpp @@ -191,7 +191,7 @@ class TableCell final : public Element, public abstract::TableCell { public: using Element::Element; - [[nodiscard]] bool covered(const abstract::Document *) const final; + [[nodiscard]] bool is_covered(const abstract::Document *) const final; [[nodiscard]] TableDimensions span(const abstract::Document *) const final; @@ -275,7 +275,7 @@ class Image final : public Element, public abstract::Image { public: using Element::Element; - [[nodiscard]] bool internal(const abstract::Document *) const final; + [[nodiscard]] bool is_internal(const abstract::Document *) const final; [[nodiscard]] std::optional file(const abstract::Document *) const final; diff --git a/src/odr/internal/odf/odf_parser.cpp b/src/odr/internal/odf/odf_parser.cpp index b1ced48ce..1947f5c9e 100644 --- a/src/odr/internal/odf/odf_parser.cpp +++ b/src/odr/internal/odf/odf_parser.cpp @@ -3,7 +3,6 @@ #include #include -#include #include namespace odr::internal::odf { @@ -36,23 +35,15 @@ bool is_text_node(const pugi::xml_node node) { namespace odr::internal { -odf::Element *odf::parse_tree(pugi::xml_node node, - std::vector> &store) { - auto [root, _] = parse_any_element_tree(node, store); +odf::Element *odf::parse_tree(Document &document, pugi::xml_node node) { + auto [root, _] = parse_any_element_tree(document, node); return root; } -std::tuple>> -odf::parse_tree(pugi::xml_node node) { - std::vector> store; - auto root = parse_tree(node, store); - return std::make_tuple(root, std::move(store)); -} - -void odf::parse_element_children(Element *element, pugi::xml_node node, - std::vector> &store) { +void odf::parse_element_children(Document &document, Element *element, + pugi::xml_node node) { for (auto child_node = node.first_child(); child_node;) { - auto [child, next_sibling] = parse_any_element_tree(child_node, store); + auto [child, next_sibling] = parse_any_element_tree(document, child_node); if (child == nullptr) { child_node = child_node.next_sibling(); } else { @@ -62,33 +53,33 @@ void odf::parse_element_children(Element *element, pugi::xml_node node, } } -void odf::parse_element_children(PresentationRoot *element, pugi::xml_node node, - std::vector> &store) { +void odf::parse_element_children(Document &document, PresentationRoot *element, + pugi::xml_node node) { for (auto child_node : node.children("draw:page")) { - auto [child, _] = parse_element_tree(child_node, store); + auto [child, _] = parse_element_tree(document, child_node); element->append_child_(child); } } -void odf::parse_element_children(SpreadsheetRoot *element, pugi::xml_node node, - std::vector> &store) { +void odf::parse_element_children(Document &document, SpreadsheetRoot *element, + pugi::xml_node node) { for (auto child_node : node.children("table:table")) { - auto [child, _] = parse_element_tree(child_node, store); + auto [child, _] = parse_element_tree(document, child_node); element->append_child_(child); } } -void odf::parse_element_children(DrawingRoot *element, pugi::xml_node node, - std::vector> &store) { +void odf::parse_element_children(Document &document, DrawingRoot *element, + pugi::xml_node node) { for (auto child_node : node.children("draw:page")) { - auto [child, _] = parse_element_tree(child_node, store); + auto [child, _] = parse_element_tree(document, child_node); element->append_child_(child); } } template <> -std::tuple odf::parse_element_tree( - pugi::xml_node first, std::vector> &store) { +std::tuple +odf::parse_element_tree(Document &document, pugi::xml_node first) { if (!first) { return std::make_tuple(nullptr, pugi::xml_node()); } @@ -99,21 +90,21 @@ std::tuple odf::parse_element_tree( auto element_unique = std::make_unique(first, last); auto element = element_unique.get(); - store.push_back(std::move(element_unique)); + document.register_element_(std::move(element_unique)); return std::make_tuple(element, last.next_sibling()); } template <> -std::tuple odf::parse_element_tree( - pugi::xml_node node, std::vector> &store) { +std::tuple +odf::parse_element_tree(Document &document, pugi::xml_node node) { if (!node) { return std::make_tuple(nullptr, pugi::xml_node()); } auto table_unique = std::make_unique(node); auto table = table_unique.get(); - store.push_back(std::move(table_unique)); + document.register_element_(std::move(table_unique)); // TODO inflate table first? @@ -122,14 +113,14 @@ std::tuple odf::parse_element_tree( i < column_node.attribute("table:number-columns-repeated").as_uint(1); ++i) { // TODO mark as repeated - auto [column, _] = parse_element_tree(column_node, store); + auto [column, _] = parse_element_tree(document, column_node); table->append_column_(column); } } for (auto row_node : node.children("table:table-row")) { // TODO log warning if repeated - auto [row, _] = parse_element_tree(row_node, store); + auto [row, _] = parse_element_tree(document, row_node); table->append_row_(row); } @@ -138,19 +129,19 @@ std::tuple odf::parse_element_tree( template <> std::tuple -odf::parse_element_tree( - pugi::xml_node node, std::vector> &store) { +odf::parse_element_tree(Document &document, + pugi::xml_node node) { if (!node) { return std::make_tuple(nullptr, pugi::xml_node()); } auto table_row_unique = std::make_unique(node); auto table_row = table_row_unique.get(); - store.push_back(std::move(table_row_unique)); + document.register_element_(std::move(table_row_unique)); for (auto cell_node : node.children()) { // TODO log warning if repeated - auto [cell, _] = parse_any_element_tree(cell_node, store); + auto [cell, _] = parse_any_element_tree(document, cell_node); table_row->append_child_(cell); } @@ -158,10 +149,9 @@ odf::parse_element_tree( } std::tuple -odf::parse_any_element_tree(pugi::xml_node node, - std::vector> &store) { +odf::parse_any_element_tree(Document &document, pugi::xml_node node) { using Parser = std::function( - pugi::xml_node node, std::vector> & store)>; + Document & document, pugi::xml_node node)>; using List = DefaultElement; using Group = DefaultElement; @@ -211,12 +201,12 @@ odf::parse_any_element_tree(pugi::xml_node node, {"style:master-page", parse_element_tree}}; if (node.type() == pugi::xml_node_type::node_pcdata) { - return parse_element_tree(node, store); + return parse_element_tree(document, node); } if (auto constructor_it = parser_table.find(node.name()); constructor_it != std::end(parser_table)) { - return constructor_it->second(node, store); + return constructor_it->second(document, node); } return std::make_tuple(nullptr, pugi::xml_node()); diff --git a/src/odr/internal/odf/odf_parser.hpp b/src/odr/internal/odf/odf_parser.hpp index 17fe07c48..b84ff821e 100644 --- a/src/odr/internal/odf/odf_parser.hpp +++ b/src/odr/internal/odf/odf_parser.hpp @@ -1,6 +1,8 @@ #ifndef ODR_INTERNAL_ODF_PARSER_H #define ODR_INTERNAL_ODF_PARSER_H +#include + #include #include #include @@ -16,53 +18,44 @@ class Text; class Table; class TableRow; -Element *parse_tree(pugi::xml_node node, - std::vector> &store); - -std::tuple>> -parse_tree(pugi::xml_node node); +Element *parse_tree(Document &document, pugi::xml_node node); template -std::tuple -parse_element_tree(pugi::xml_node node, - std::vector> &store) { +std::tuple parse_element_tree(Document &document, + pugi::xml_node node) { if (!node) { return std::make_tuple(nullptr, pugi::xml_node()); } auto element_unique = std::make_unique(node); auto element = element_unique.get(); - store.push_back(std::move(element_unique)); + document.register_element_(std::move(element_unique)); - parse_element_children(element, node, store); + parse_element_children(document, element, node); return std::make_tuple(element, node.next_sibling()); } template <> std::tuple -parse_element_tree(pugi::xml_node first, - std::vector> &store); +parse_element_tree(Document &document, pugi::xml_node first); template <> std::tuple -parse_element_tree
(pugi::xml_node node, - std::vector> &store); +parse_element_tree
(Document &document, pugi::xml_node node); template <> std::tuple -parse_element_tree(pugi::xml_node node, - std::vector> &store); +parse_element_tree(Document &document, pugi::xml_node node); std::tuple -parse_any_element_tree(pugi::xml_node node, - std::vector> &store); - -void parse_element_children(Element *element, pugi::xml_node node, - std::vector> &store); -void parse_element_children(PresentationRoot *element, pugi::xml_node node, - std::vector> &store); -void parse_element_children(SpreadsheetRoot *element, pugi::xml_node node, - std::vector> &store); -void parse_element_children(DrawingRoot *element, pugi::xml_node node, - std::vector> &store); +parse_any_element_tree(Document &document, pugi::xml_node node); + +void parse_element_children(Document &document, Element *element, + pugi::xml_node node); +void parse_element_children(Document &document, PresentationRoot *element, + pugi::xml_node node); +void parse_element_children(Document &document, SpreadsheetRoot *element, + pugi::xml_node node); +void parse_element_children(Document &document, DrawingRoot *element, + pugi::xml_node node); } // namespace odr::internal::odf diff --git a/src/odr/internal/odf/odf_spreadsheet.cpp b/src/odr/internal/odf/odf_spreadsheet.cpp index c7c4089a0..ca31ed313 100644 --- a/src/odr/internal/odf/odf_spreadsheet.cpp +++ b/src/odr/internal/odf/odf_spreadsheet.cpp @@ -12,7 +12,7 @@ namespace { class SheetColumn final : public Element, public abstract::TableColumn { public: - explicit SheetColumn(pugi::xml_node node) : Element(node) {} + using Element::Element; [[nodiscard]] TableColumnStyle style(const abstract::Document *document) const final { @@ -22,7 +22,7 @@ class SheetColumn final : public Element, public abstract::TableColumn { class SheetRow final : public Element, public abstract::TableRow { public: - explicit SheetRow(pugi::xml_node node) : Element(node) {} + using Element::Element; [[nodiscard]] TableRowStyle style(const abstract::Document *document) const final { @@ -32,9 +32,9 @@ class SheetRow final : public Element, public abstract::TableRow { class SheetCell final : public Element, public abstract::TableCell { public: - explicit SheetCell(pugi::xml_node node) : Element(node) {} + using Element::Element; - [[nodiscard]] bool covered(const abstract::Document *) const final { + [[nodiscard]] bool is_covered(const abstract::Document *) const final { return std::strcmp(m_node.name(), "table:covered-table-cell") == 0; } @@ -59,10 +59,6 @@ class SheetCell final : public Element, public abstract::TableCell { } // namespace -SpreadsheetRoot::SpreadsheetRoot(pugi::xml_node node) : Root(node) {} - -Sheet::Sheet(pugi::xml_node node) : Element(node) {} - std::string Sheet::name(const abstract::Document *) const { return m_node.attribute("table:name").value(); } @@ -104,8 +100,79 @@ Sheet::content(const abstract::Document *, return result; } -abstract::Element *Sheet::column(const abstract::Document *, - std::uint32_t column) const { +abstract::Element *Sheet::first_cell_element(const abstract::Document *document, + std::uint32_t column, + std::uint32_t row) const { + auto cell = cell_(document, column, row); + if (cell == nullptr) { + return nullptr; + } + return cell->first_child(document); +} + +abstract::Element *Sheet::first_shape(const abstract::Document *) const { + return m_first_shape; +} + +TableStyle Sheet::style(const abstract::Document *document) const { + return partial_style(document).table_style; +} + +TableColumnStyle Sheet::column_style(const abstract::Document *, + std::uint32_t /*column*/) const { + return TableColumnStyle(); // TODO +} + +TableRowStyle Sheet::row_style(const abstract::Document *, + std::uint32_t /*row*/) const { + return TableRowStyle(); // TODO +} + +TableCellStyle Sheet::cell_style(const abstract::Document *, + std::uint32_t /*column*/, + std::uint32_t /*row*/) const { + return TableCellStyle(); // TODO +} + +bool Sheet::is_covered(const abstract::Document *, std::uint32_t /*column*/, + std::uint32_t /*row*/) const { + return false; // TODO +} + +TableDimensions Sheet::span(const abstract::Document *, + std::uint32_t /*column*/, + std::uint32_t /*row*/) const { + return TableDimensions(); // TODO +} + +ValueType Sheet::value_type(const abstract::Document *, + std::uint32_t /*column*/, + std::uint32_t /*row*/) const { + return ValueType::unknown; // TODO +} + +void Sheet::init_column_(std::uint32_t column, std::uint32_t repeated, + Element *element) { + m_columns[column + repeated] = element; +} + +void Sheet::init_row_(std::uint32_t row, std::uint32_t repeated, + Element *element) { + m_rows[row + repeated].element = element; +} + +void Sheet::init_cell_(std::uint32_t column, std::uint32_t row, + std::uint32_t columns_repeated, + std::uint32_t rows_repeated, Element *element) { + m_rows[row + rows_repeated].cells[column + columns_repeated] = element; +} + +void Sheet::init_dimensions_(TableDimensions dimensions) { + m_dimensions = dimensions; +} + +abstract::Element *Sheet::column_(const abstract::Document *, + std::uint32_t column) const { if (auto it = util::map::lookup_greater_than(m_columns, column); it != std::end(m_columns)) { return it->second; @@ -113,8 +180,8 @@ abstract::Element *Sheet::column(const abstract::Document *, return nullptr; } -abstract::Element *Sheet::row(const abstract::Document *, - std::uint32_t row) const { +abstract::Element *Sheet::row_(const abstract::Document *, + std::uint32_t row) const { if (auto it = util::map::lookup_greater_than(m_rows, row); it != std::end(m_rows)) { return it->second.element; @@ -122,8 +189,8 @@ abstract::Element *Sheet::row(const abstract::Document *, return nullptr; } -abstract::Element *Sheet::cell(const abstract::Document *, std::uint32_t column, - std::uint32_t row) const { +abstract::Element *Sheet::cell_(const abstract::Document *, + std::uint32_t column, std::uint32_t row) const { if (auto row_it = util::map::lookup_greater_than(m_rows, row); row_it != std::end(m_rows)) { auto &cells = row_it->second.cells; @@ -136,48 +203,20 @@ abstract::Element *Sheet::cell(const abstract::Document *, std::uint32_t column, return nullptr; } -abstract::Element *Sheet::first_shape(const abstract::Document *) const { - return m_first_shape; -} - -TableStyle Sheet::style(const abstract::Document *document) const { - return partial_style(document).table_style; -} - -void Sheet::init_column(std::uint32_t column, std::uint32_t repeated, - Element *element) { - m_columns[column + repeated] = element; -} - -void Sheet::init_row(std::uint32_t row, std::uint32_t repeated, - Element *element) { - m_rows[row + repeated].element = element; -} - -void Sheet::init_cell(std::uint32_t column, std::uint32_t row, - std::uint32_t columns_repeated, - std::uint32_t rows_repeated, Element *element) { - m_rows[row + rows_repeated].cells[column + columns_repeated] = element; -} - -void Sheet::init_dimensions(TableDimensions dimensions) { - m_dimensions = dimensions; -} - } // namespace odr::internal::odf namespace odr::internal { template <> -std::tuple odf::parse_element_tree( - pugi::xml_node node, std::vector> &store) { +std::tuple +odf::parse_element_tree(Document &document, pugi::xml_node node) { if (!node) { return std::make_tuple(nullptr, pugi::xml_node()); } auto sheet_unique = std::make_unique(node); auto &sheet = *sheet_unique; - store.push_back(std::move(sheet_unique)); + document.register_element_(std::move(sheet_unique)); TableDimensions dimensions; common::TableCursor cursor; @@ -186,9 +225,9 @@ std::tuple odf::parse_element_tree( const auto columns_repeated = column_node.attribute("table:number-columns-repeated").as_uint(1); - auto [column, _] = parse_element_tree(column_node, store); + auto [column, _] = parse_element_tree(document, column_node); - sheet.init_column(cursor.column(), columns_repeated, column); + sheet.init_column_(cursor.column(), columns_repeated, column); cursor.add_column(columns_repeated); } @@ -200,9 +239,9 @@ std::tuple odf::parse_element_tree( const auto rows_repeated = row_node.attribute("table:number-rows-repeated").as_uint(1); - auto [row, _] = parse_element_tree(row_node, store); + auto [row, _] = parse_element_tree(document, row_node); - sheet.init_row(cursor.row(), rows_repeated, row); + sheet.init_row_(cursor.row(), rows_repeated, row); for (auto cell_node : row_node.children("table:table-cell")) { const auto columns_repeated = @@ -212,10 +251,10 @@ std::tuple odf::parse_element_tree( const auto rowspan = cell_node.attribute("table:number-rows-spanned").as_uint(1); - auto [cell, _] = parse_element_tree(cell_node, store); + auto [cell, _] = parse_element_tree(document, cell_node); - sheet.init_cell(cursor.column(), cursor.row(), columns_repeated, - rows_repeated, cell); + sheet.init_cell_(cursor.column(), cursor.row(), columns_repeated, + rows_repeated, cell); cursor.add_cell(colspan, rowspan, columns_repeated); } @@ -225,7 +264,7 @@ std::tuple odf::parse_element_tree( dimensions.rows = cursor.row(); - sheet.init_dimensions(dimensions); + sheet.init_dimensions_(dimensions); // TODO shapes diff --git a/src/odr/internal/odf/odf_spreadsheet.hpp b/src/odr/internal/odf/odf_spreadsheet.hpp index 44bd2ffc6..b05362bf9 100644 --- a/src/odr/internal/odf/odf_spreadsheet.hpp +++ b/src/odr/internal/odf/odf_spreadsheet.hpp @@ -21,12 +21,12 @@ class Document; class SpreadsheetRoot final : public Root { public: - explicit SpreadsheetRoot(pugi::xml_node node); + using Root::Root; }; class Sheet final : public Element, public common::Sheet { public: - explicit Sheet(pugi::xml_node node); + using Element::Element; [[nodiscard]] std::string name(const abstract::Document *) const final; @@ -37,26 +37,46 @@ class Sheet final : public Element, public common::Sheet { content(const abstract::Document *, const std::optional range) const final; - [[nodiscard]] abstract::Element *column(const abstract::Document *, - std::uint32_t column) const final; - [[nodiscard]] abstract::Element *row(const abstract::Document *, - std::uint32_t row) const final; - [[nodiscard]] abstract::Element *cell(const abstract::Document *, - std::uint32_t column, - std::uint32_t row) const final; - + [[nodiscard]] abstract::Element * + first_cell_element(const abstract::Document *, std::uint32_t column, + std::uint32_t row) const final; [[nodiscard]] abstract::Element * first_shape(const abstract::Document *) const final; [[nodiscard]] TableStyle style(const abstract::Document *) const final; - - void init_column(std::uint32_t column, std::uint32_t repeated, - Element *element); - void init_row(std::uint32_t row, std::uint32_t repeated, Element *element); - void init_cell(std::uint32_t column, std::uint32_t row, - std::uint32_t columns_repeated, std::uint32_t rows_repeated, - Element *element); - void init_dimensions(TableDimensions dimensions); + [[nodiscard]] TableColumnStyle column_style(const abstract::Document *, + std::uint32_t column) const final; + [[nodiscard]] TableRowStyle row_style(const abstract::Document *, + std::uint32_t row) const final; + [[nodiscard]] TableCellStyle cell_style(const abstract::Document *, + std::uint32_t column, + std::uint32_t row) const final; + + [[nodiscard]] bool is_covered(const abstract::Document *, + std::uint32_t column, + std::uint32_t row) const final; + [[nodiscard]] TableDimensions span(const abstract::Document *, + std::uint32_t column, + std::uint32_t row) const final; + [[nodiscard]] ValueType value_type(const abstract::Document *, + std::uint32_t column, + std::uint32_t row) const final; + + void init_column_(std::uint32_t column, std::uint32_t repeated, + Element *element); + void init_row_(std::uint32_t row, std::uint32_t repeated, Element *element); + void init_cell_(std::uint32_t column, std::uint32_t row, + std::uint32_t columns_repeated, std::uint32_t rows_repeated, + Element *element); + void init_dimensions_(TableDimensions dimensions); + + [[nodiscard]] abstract::Element *column_(const abstract::Document *, + std::uint32_t column) const; + [[nodiscard]] abstract::Element *row_(const abstract::Document *, + std::uint32_t row) const; + [[nodiscard]] abstract::Element *cell_(const abstract::Document *, + std::uint32_t column, + std::uint32_t row) const; private: struct Row { @@ -73,9 +93,8 @@ class Sheet final : public Element, public common::Sheet { }; template <> -std::tuple -parse_element_tree(pugi::xml_node node, - std::vector> &store); +std::tuple +parse_element_tree(Document &document, pugi::xml_node node); } // namespace odr::internal::odf diff --git a/src/odr/internal/odf/odf_style.cpp b/src/odr/internal/odf/odf_style.cpp index f59542df2..8c03a5c31 100644 --- a/src/odr/internal/odf/odf_style.cpp +++ b/src/odr/internal/odf/odf_style.cpp @@ -445,11 +445,12 @@ void Style::resolve_graphic_style_(pugi::xml_node node, GraphicStyle &result) { StyleRegistry::StyleRegistry() = default; -StyleRegistry::StyleRegistry(const pugi::xml_node content_root, +StyleRegistry::StyleRegistry(Document &document, + const pugi::xml_node content_root, const pugi::xml_node styles_root) { generate_indices_(content_root, styles_root); generate_styles_(); - generate_master_pages_(); + generate_master_pages_(document); } void StyleRegistry::generate_indices_(const pugi::xml_node content_root, @@ -534,10 +535,10 @@ Style *StyleRegistry::generate_style_(const std::string &name, return style.get(); } -void StyleRegistry::generate_master_pages_() { +void StyleRegistry::generate_master_pages_(Document &document) { for (auto &&e : m_index_master_page) { m_master_page_elements[e.first] = - dynamic_cast(parse_tree(e.second, m_elements)); + dynamic_cast(parse_tree(document, e.second)); } if (m_first_master_page) { diff --git a/src/odr/internal/odf/odf_style.hpp b/src/odr/internal/odf/odf_style.hpp index 815f1cafe..6fc561fa4 100644 --- a/src/odr/internal/odf/odf_style.hpp +++ b/src/odr/internal/odf/odf_style.hpp @@ -70,7 +70,8 @@ class Style final { class StyleRegistry final { public: StyleRegistry(); - StyleRegistry(pugi::xml_node content_root, pugi::xml_node styles_root); + StyleRegistry(Document &document, pugi::xml_node content_root, + pugi::xml_node styles_root); [[nodiscard]] Style *style(const char *name) const; @@ -94,7 +95,6 @@ class StyleRegistry final { std::unordered_map> m_default_styles; std::unordered_map> m_styles; - std::vector> m_elements; std::unordered_map m_master_page_elements; MasterPage *m_first_master_page_element{}; @@ -106,7 +106,7 @@ class StyleRegistry final { Style *generate_default_style_(const std::string &name, pugi::xml_node node); Style *generate_style_(const std::string &name, pugi::xml_node node); - void generate_master_pages_(); + void generate_master_pages_(Document &); }; } // namespace odr::internal::odf diff --git a/src/odr/internal/ooxml/presentation/ooxml_presentation_element.cpp b/src/odr/internal/ooxml/presentation/ooxml_presentation_element.cpp index 66405bff7..27f11be7c 100644 --- a/src/odr/internal/ooxml/presentation/ooxml_presentation_element.cpp +++ b/src/odr/internal/ooxml/presentation/ooxml_presentation_element.cpp @@ -135,7 +135,7 @@ TableRowStyle TableRow::style(const abstract::Document *document) const { return partial_style(document).table_row_style; } -bool TableCell::covered(const abstract::Document *) const { return false; } +bool TableCell::is_covered(const abstract::Document *) const { return false; } TableDimensions TableCell::span(const abstract::Document *) const { return {1, 1}; // TODO @@ -197,7 +197,9 @@ GraphicStyle Frame::style(const abstract::Document *) const { return {}; // TODO } -bool ImageElement::internal(const abstract::Document *) const { return false; } +bool ImageElement::is_internal(const abstract::Document *) const { + return false; +} std::optional ImageElement::file(const abstract::Document *) 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 4967303e4..6b23b0b3a 100644 --- a/src/odr/internal/ooxml/presentation/ooxml_presentation_element.hpp +++ b/src/odr/internal/ooxml/presentation/ooxml_presentation_element.hpp @@ -125,7 +125,7 @@ class TableCell final : public Element, public abstract::TableCell { public: using Element::Element; - [[nodiscard]] bool covered(const abstract::Document *) const final; + [[nodiscard]] bool is_covered(const abstract::Document *) const final; [[nodiscard]] TableDimensions span(const abstract::Document *) const final; @@ -159,7 +159,7 @@ class ImageElement final : public Element, public abstract::Image { public: using Element::Element; - [[nodiscard]] bool internal(const abstract::Document *) const final; + [[nodiscard]] bool is_internal(const abstract::Document *) const final; [[nodiscard]] std::optional file(const abstract::Document *) const final; diff --git a/src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_element.cpp b/src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_element.cpp index 3dc8311ed..873c5a255 100644 --- a/src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_element.cpp +++ b/src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_element.cpp @@ -65,10 +65,6 @@ Element::shared_strings_(const abstract::Document *document) { return document_(document)->m_shared_strings; } -ElementType Sheet::type(const abstract::Document *) const { - return ElementType::sheet; -} - std::string Sheet::name(const abstract::Document *) const { return m_node.attribute("name").value(); } @@ -90,28 +86,51 @@ TableDimensions Sheet::content(const abstract::Document *document, return dimensions(document); // TODO } -abstract::Element *Sheet::column(const abstract::Document *, - std::uint32_t /*column*/) const { +abstract::Element *Sheet::first_cell_element(const abstract::Document *, + std::uint32_t /*column*/, + std::uint32_t /*row*/) const { return nullptr; // TODO } -abstract::Element *Sheet::row(const abstract::Document *, - std::uint32_t /*row*/) const { +abstract::Element *Sheet::first_shape(const abstract::Document *) const { return nullptr; // TODO } -abstract::Element *Sheet::cell(const abstract::Document *, - std::uint32_t /*column*/, +TableStyle Sheet::style(const abstract::Document *document) const { + return partial_style(document).table_style; +} + +TableColumnStyle Sheet::column_style(const abstract::Document *, + std::uint32_t /*column*/) const { + return {}; // TODO +} + +TableRowStyle Sheet::row_style(const abstract::Document *, std::uint32_t /*row*/) const { - return nullptr; // TODO + return {}; // TODO } -abstract::Element *Sheet::first_shape(const abstract::Document *) const { - return nullptr; // TODO +TableCellStyle Sheet::cell_style(const abstract::Document *, + std::uint32_t /*column*/, + std::uint32_t /*row*/) const { + return {}; // TODO } -TableStyle Sheet::style(const abstract::Document *document) const { - return partial_style(document).table_style; +bool Sheet::is_covered(const abstract::Document *, std::uint32_t /*column*/, + std::uint32_t /*row*/) const { + return false; // TODO +} + +TableDimensions Sheet::span(const abstract::Document *, + std::uint32_t /*column*/, + std::uint32_t /*row*/) const { + return TableDimensions(); // TODO +} + +ValueType Sheet::value_type(const abstract::Document *, + std::uint32_t /*column*/, + std::uint32_t /*row*/) const { + return ValueType::unknown; // TODO } pugi::xml_node Sheet::sheet_node_(const abstract::Document *document) const { @@ -148,7 +167,7 @@ TableRowStyle TableRow::style(const abstract::Document *) const { return result; } -bool TableCell::covered(const abstract::Document *) const { +bool TableCell::is_covered(const abstract::Document *) const { return false; // TODO } @@ -262,7 +281,7 @@ std::optional Frame::z_index(const abstract::Document *) const { GraphicStyle Frame::style(const abstract::Document *) const { return {}; } -bool ImageElement::internal(const abstract::Document *document) const { +bool ImageElement::is_internal(const abstract::Document *document) const { auto doc = document_(document); if (!doc || !doc->files()) { return false; @@ -277,7 +296,7 @@ bool ImageElement::internal(const abstract::Document *document) const { std::optional ImageElement::file(const abstract::Document *document) const { auto doc = document_(document); - if (!doc || !internal(document)) { + if (!doc || !is_internal(document)) { return {}; } return File(doc->files()->open(href(document))); diff --git a/src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_element.hpp b/src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_element.hpp index ffe92f013..e0a6f5c24 100644 --- a/src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_element.hpp +++ b/src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_element.hpp @@ -54,29 +54,38 @@ class Sheet final : public Element, public abstract::Sheet { public: using Element::Element; - [[nodiscard]] ElementType type(const abstract::Document *) const final; - [[nodiscard]] std::string name(const abstract::Document *) const final; [[nodiscard]] TableDimensions dimensions(const abstract::Document *) const final; - [[nodiscard]] TableDimensions content(const abstract::Document *, std::optional) const final; - [[nodiscard]] abstract::Element *column(const abstract::Document *, - std::uint32_t column) const final; - [[nodiscard]] abstract::Element *row(const abstract::Document *, - std::uint32_t row) const final; - [[nodiscard]] abstract::Element *cell(const abstract::Document *, - std::uint32_t column, - std::uint32_t row) const final; - + [[nodiscard]] abstract::Element * + first_cell_element(const abstract::Document *, std::uint32_t column, + std::uint32_t row) const final; [[nodiscard]] abstract::Element * first_shape(const abstract::Document *) const final; [[nodiscard]] TableStyle style(const abstract::Document *) const final; + [[nodiscard]] TableColumnStyle column_style(const abstract::Document *, + std::uint32_t column) const final; + [[nodiscard]] TableRowStyle row_style(const abstract::Document *, + std::uint32_t row) const final; + [[nodiscard]] TableCellStyle cell_style(const abstract::Document *, + std::uint32_t column, + std::uint32_t row) const final; + + [[nodiscard]] bool is_covered(const abstract::Document *, + std::uint32_t column, + std::uint32_t row) const final; + [[nodiscard]] TableDimensions span(const abstract::Document *, + std::uint32_t column, + std::uint32_t row) const final; + [[nodiscard]] ValueType value_type(const abstract::Document *, + std::uint32_t column, + std::uint32_t row) const final; private: pugi::xml_node sheet_node_(const abstract::Document *) const; @@ -105,7 +114,7 @@ class TableCell final : public Element, public abstract::TableCell { public: using Element::Element; - [[nodiscard]] bool covered(const abstract::Document *) const final; + [[nodiscard]] bool is_covered(const abstract::Document *) const final; [[nodiscard]] TableDimensions span(const abstract::Document *) const final; @@ -165,7 +174,7 @@ class ImageElement final : public Element, public abstract::Image { public: using Element::Element; - [[nodiscard]] bool internal(const abstract::Document *) const final; + [[nodiscard]] bool is_internal(const abstract::Document *) const final; [[nodiscard]] std::optional file(const abstract::Document *) const final; diff --git a/src/odr/internal/ooxml/text/ooxml_text_element.cpp b/src/odr/internal/ooxml/text/ooxml_text_element.cpp index 7d6cca0a4..451a50795 100644 --- a/src/odr/internal/ooxml/text/ooxml_text_element.cpp +++ b/src/odr/internal/ooxml/text/ooxml_text_element.cpp @@ -207,7 +207,7 @@ TableRowStyle TableRow::style(const abstract::Document *document) const { return style_(document)->partial_table_row_style(m_node).table_row_style; } -bool TableCell::covered(const abstract::Document *) const { return false; } +bool TableCell::is_covered(const abstract::Document *) const { return false; } TableDimensions TableCell::span(const abstract::Document *) const { return {1, 1}; @@ -269,7 +269,7 @@ pugi::xml_node Frame::inner_node_(const abstract::Document *) const { return {}; } -bool Image::internal(const abstract::Document *document) const { +bool Image::is_internal(const abstract::Document *document) const { auto doc = document_(document); if (!doc || !doc->files()) { return false; @@ -283,7 +283,7 @@ bool Image::internal(const abstract::Document *document) const { std::optional Image::file(const abstract::Document *document) const { auto doc = document_(document); - if (!doc || !internal(document)) { + if (!doc || !is_internal(document)) { return {}; } return File(doc->files()->open(href(document))); diff --git a/src/odr/internal/ooxml/text/ooxml_text_element.hpp b/src/odr/internal/ooxml/text/ooxml_text_element.hpp index dba5fa2fc..ead43d5d2 100644 --- a/src/odr/internal/ooxml/text/ooxml_text_element.hpp +++ b/src/odr/internal/ooxml/text/ooxml_text_element.hpp @@ -151,7 +151,7 @@ class TableCell final : public Element, public abstract::TableCell { public: using Element::Element; - [[nodiscard]] bool covered(const abstract::Document *) const final; + [[nodiscard]] bool is_covered(const abstract::Document *) const final; [[nodiscard]] TableDimensions span(const abstract::Document *) const final; @@ -188,7 +188,7 @@ class Image final : public Element, public abstract::Image { public: using Element::Element; - [[nodiscard]] bool internal(const abstract::Document *) const final; + [[nodiscard]] bool is_internal(const abstract::Document *) const final; [[nodiscard]] std::optional file(const abstract::Document *) const final;