From d5e988313ae8df53d625d68e1350d51fe3576c5b Mon Sep 17 00:00:00 2001 From: andiwand Date: Tue, 28 Nov 2023 00:54:50 +0100 Subject: [PATCH] minor --- src/odr/document_element.cpp | 10 --- .../internal/abstract/document_element.hpp | 3 - src/odr/internal/odf/odf_document.cpp | 5 -- src/odr/internal/odf/odf_element.cpp | 13 ---- src/odr/internal/odf/odf_element.hpp | 5 -- src/odr/internal/odf/odf_file.cpp | 1 - src/odr/internal/odf/odf_meta.cpp | 2 - src/odr/internal/odf/odf_parser.cpp | 6 +- src/odr/internal/odf/odf_spreadsheet.cpp | 69 +++++++++++++++++-- src/odr/internal/odf/odf_style.cpp | 9 +-- .../ooxml_presentation_element.cpp | 8 --- .../ooxml_presentation_element.hpp | 5 -- .../spreadsheet/ooxml_spreadsheet_element.cpp | 10 --- .../spreadsheet/ooxml_spreadsheet_element.hpp | 4 -- .../ooxml/text/ooxml_text_element.cpp | 8 --- .../ooxml/text/ooxml_text_element.hpp | 4 -- 16 files changed, 70 insertions(+), 92 deletions(-) diff --git a/src/odr/document_element.cpp b/src/odr/document_element.cpp index 6651dd56..c4c333ea 100644 --- a/src/odr/document_element.cpp +++ b/src/odr/document_element.cpp @@ -292,16 +292,6 @@ TableRowStyle TableRow::style() const { return m_element ? m_element->style(m_document) : TableRowStyle(); } -TableColumn TableCell::column() const { - return m_element ? TableColumn(m_document, m_element->column(m_document)) - : TableColumn(); -} - -TableRow TableCell::row() const { - return m_element ? TableRow(m_document, m_element->row(m_document)) - : TableRow(); -} - bool TableCell::covered() const { return m_element && m_element->covered(m_document); } diff --git a/src/odr/internal/abstract/document_element.hpp b/src/odr/internal/abstract/document_element.hpp index 40536506..0fefc9f1 100644 --- a/src/odr/internal/abstract/document_element.hpp +++ b/src/odr/internal/abstract/document_element.hpp @@ -230,9 +230,6 @@ class TableCell : public virtual Element { return ElementType::table_cell; } - [[nodiscard]] virtual Element *column(const Document *document) const = 0; - [[nodiscard]] virtual Element *row(const Document *document) const = 0; - [[nodiscard]] virtual bool covered(const Document *document) const = 0; [[nodiscard]] virtual TableDimensions span(const Document *document) const = 0; diff --git a/src/odr/internal/odf/odf_document.cpp b/src/odr/internal/odf/odf_document.cpp index 4dcdc4d3..41980052 100644 --- a/src/odr/internal/odf/odf_document.cpp +++ b/src/odr/internal/odf/odf_document.cpp @@ -1,15 +1,10 @@ #include #include -#include #include #include -#include -#include -#include #include -#include #include #include diff --git a/src/odr/internal/odf/odf_element.cpp b/src/odr/internal/odf/odf_element.cpp index bced3084..7f6c0e9f 100644 --- a/src/odr/internal/odf/odf_element.cpp +++ b/src/odr/internal/odf/odf_element.cpp @@ -1,12 +1,8 @@ #include #include -#include -#include #include -#include -#include #include #include #include @@ -15,7 +11,6 @@ #include #include -#include #include #include @@ -313,14 +308,6 @@ TableRowStyle TableRow::style(const abstract::Document *document) const { TableCell::TableCell(pugi::xml_node node) : common::Element(node), Element(node) {} -abstract::Element *TableCell::column(const abstract::Document *) const { - return nullptr; -} - -abstract::Element *TableCell::row(const abstract::Document *) const { - return nullptr; -} - bool TableCell::covered(const abstract::Document *) const { return std::strcmp(m_node.name(), "table:covered-table-cell") == 0; } diff --git a/src/odr/internal/odf/odf_element.hpp b/src/odr/internal/odf/odf_element.hpp index 718e0257..d90dde40 100644 --- a/src/odr/internal/odf/odf_element.hpp +++ b/src/odr/internal/odf/odf_element.hpp @@ -205,11 +205,6 @@ class TableCell final : public Element, public abstract::TableCell { public: explicit TableCell(pugi::xml_node node); - [[nodiscard]] abstract::Element * - column(const abstract::Document *document) const final; - [[nodiscard]] abstract::Element * - row(const abstract::Document *document) const final; - [[nodiscard]] bool covered(const abstract::Document *document) const final; [[nodiscard]] TableDimensions diff --git a/src/odr/internal/odf/odf_file.cpp b/src/odr/internal/odf/odf_file.cpp index 867559c8..12cf46f9 100644 --- a/src/odr/internal/odf/odf_file.cpp +++ b/src/odr/internal/odf/odf_file.cpp @@ -1,7 +1,6 @@ #include #include -#include #include #include diff --git a/src/odr/internal/odf/odf_meta.cpp b/src/odr/internal/odf/odf_meta.cpp index 89cfe993..36e80a15 100644 --- a/src/odr/internal/odf/odf_meta.cpp +++ b/src/odr/internal/odf/odf_meta.cpp @@ -5,14 +5,12 @@ #include #include -#include #include #include #include #include -#include #include #include diff --git a/src/odr/internal/odf/odf_parser.cpp b/src/odr/internal/odf/odf_parser.cpp index a1cd917f..9d76914c 100644 --- a/src/odr/internal/odf/odf_parser.cpp +++ b/src/odr/internal/odf/odf_parser.cpp @@ -1,7 +1,9 @@ -#include -#include #include + +#include #include + +#include #include namespace odr::internal::odf { diff --git a/src/odr/internal/odf/odf_spreadsheet.cpp b/src/odr/internal/odf/odf_spreadsheet.cpp index 2f3067dd..86756e4b 100644 --- a/src/odr/internal/odf/odf_spreadsheet.cpp +++ b/src/odr/internal/odf/odf_spreadsheet.cpp @@ -1,11 +1,70 @@ -#include -#include #include + +#include #include + +#include #include namespace odr::internal::odf { +namespace { + +class SheetColumn final : public Element, public abstract::TableColumn { +public: + explicit SheetColumn(pugi::xml_node node) + : common::Element(node), Element(node) {} + + [[nodiscard]] TableColumnStyle + style(const abstract::Document *document) const final { + return partial_style(document).table_column_style; + } +}; + +class SheetRow final : public Element, public abstract::TableRow { +public: + explicit SheetRow(pugi::xml_node node) + : common::Element(node), Element(node) {} + + [[nodiscard]] TableRowStyle + style(const abstract::Document *document) const final { + return partial_style(document).table_row_style; + } +}; + +class SheetCell final : public Element, public abstract::TableCell { +public: + explicit SheetCell(pugi::xml_node node) + : common::Element(node), Element(node) {} + + [[nodiscard]] bool + covered(const abstract::Document * /*document*/) const final { + return std::strcmp(m_node.name(), "table:covered-table-cell") == 0; + } + + [[nodiscard]] TableDimensions + span(const abstract::Document * /*document*/) const final { + return {m_node.attribute("table:number-rows-spanned").as_uint(1), + m_node.attribute("table:number-columns-spanned").as_uint(1)}; + } + + [[nodiscard]] ValueType + value_type(const abstract::Document * /*document*/) const final { + auto value_type = m_node.attribute("office:value-type").value(); + if (std::strcmp("float", value_type) == 0) { + return ValueType::float_number; + } + return ValueType::string; + } + + [[nodiscard]] TableCellStyle + style(const abstract::Document *document) const final { + return partial_style(document).table_cell_style; + } +}; + +} // namespace + SpreadsheetRoot::SpreadsheetRoot(pugi::xml_node node) : common::Element(node), Root(node) {} @@ -143,7 +202,7 @@ 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(column_node, store); sheet.init_column(cursor.column(), columns_repeated, column); @@ -157,7 +216,7 @@ 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(row_node, store); sheet.init_row(cursor.row(), rows_repeated, row); @@ -169,7 +228,7 @@ 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(cell_node, store); sheet.init_cell(cursor.column(), cursor.row(), columns_repeated, rows_repeated, cell); diff --git a/src/odr/internal/odf/odf_style.cpp b/src/odr/internal/odf/odf_style.cpp index eb8fcc83..43882599 100644 --- a/src/odr/internal/odf/odf_style.cpp +++ b/src/odr/internal/odf/odf_style.cpp @@ -1,15 +1,10 @@ -#include -#include -#include #include -#include -#include +#include -#include +#include #include -#include #include #include diff --git a/src/odr/internal/ooxml/presentation/ooxml_presentation_element.cpp b/src/odr/internal/ooxml/presentation/ooxml_presentation_element.cpp index dd7f7117..3b015f9a 100644 --- a/src/odr/internal/ooxml/presentation/ooxml_presentation_element.cpp +++ b/src/odr/internal/ooxml/presentation/ooxml_presentation_element.cpp @@ -124,14 +124,6 @@ TableRowStyle TableRow::style(const abstract::Document *document) const { return partial_style(document).table_row_style; } -abstract::Element *TableCell::column(const abstract::Document *) const { - return {}; // TODO -} - -abstract::Element *TableCell::row(const abstract::Document *) const { - return {}; // TODO -} - bool TableCell::covered(const abstract::Document *) const { return false; } TableDimensions TableCell::span(const abstract::Document *) const { diff --git a/src/odr/internal/ooxml/presentation/ooxml_presentation_element.hpp b/src/odr/internal/ooxml/presentation/ooxml_presentation_element.hpp index ff26426d..32ebc45c 100644 --- a/src/odr/internal/ooxml/presentation/ooxml_presentation_element.hpp +++ b/src/odr/internal/ooxml/presentation/ooxml_presentation_element.hpp @@ -129,11 +129,6 @@ class TableCell final : public Element, public abstract::TableCell { public: using Element::Element; - [[nodiscard]] abstract::Element * - column(const abstract::Document *document) const final; - [[nodiscard]] abstract::Element * - row(const abstract::Document *document) const final; - [[nodiscard]] bool covered(const abstract::Document *document) const final; [[nodiscard]] TableDimensions diff --git a/src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_element.cpp b/src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_element.cpp index e9d972f9..b1ffd5a8 100644 --- a/src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_element.cpp +++ b/src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_element.cpp @@ -140,16 +140,6 @@ TableRowStyle TableRow::style(const abstract::Document * /*document*/) const { return result; } -abstract::Element * -TableCell::column(const abstract::Document * /*document*/) const { - return nullptr; // TODO -} - -abstract::Element * -TableCell::row(const abstract::Document * /*document*/) const { - return nullptr; // TODO -} - bool TableCell::covered(const abstract::Document * /*document*/) const { return false; // TODO } diff --git a/src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_element.hpp b/src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_element.hpp index cea67a5c..79fbcaff 100644 --- a/src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_element.hpp +++ b/src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_element.hpp @@ -109,10 +109,6 @@ class TableCell final : public Element, public abstract::TableCell { public: using Element::Element; - [[nodiscard]] abstract::Element * - column(const abstract::Document *) const final; - [[nodiscard]] abstract::Element *row(const abstract::Document *) const final; - [[nodiscard]] bool covered(const abstract::Document *) const final; [[nodiscard]] TableDimensions span(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 1852a1cc..be6fc129 100644 --- a/src/odr/internal/ooxml/text/ooxml_text_element.cpp +++ b/src/odr/internal/ooxml/text/ooxml_text_element.cpp @@ -229,14 +229,6 @@ TableRowStyle TableRow::style(const abstract::Document *document) const { TableCell::TableCell(pugi::xml_node node) : common::Element(node), Element(node) {} -abstract::Element *TableCell::column(const abstract::Document *) const { - return nullptr; // TODO -} - -abstract::Element *TableCell::row(const abstract::Document *) const { - return nullptr; // TODO -} - bool TableCell::covered(const abstract::Document *) const { return false; } TableDimensions TableCell::span(const abstract::Document *) const { diff --git a/src/odr/internal/ooxml/text/ooxml_text_element.hpp b/src/odr/internal/ooxml/text/ooxml_text_element.hpp index b36cf2e4..0520d5cf 100644 --- a/src/odr/internal/ooxml/text/ooxml_text_element.hpp +++ b/src/odr/internal/ooxml/text/ooxml_text_element.hpp @@ -154,10 +154,6 @@ class TableCell final : public Element, public abstract::TableCell { public: explicit TableCell(pugi::xml_node node); - [[nodiscard]] abstract::Element * - column(const abstract::Document *) const final; - [[nodiscard]] abstract::Element *row(const abstract::Document *) const final; - [[nodiscard]] bool covered(const abstract::Document *) const final; [[nodiscard]] TableDimensions span(const abstract::Document *) const final;