Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
andiwand committed Nov 27, 2023
1 parent 9221ecb commit d5e9883
Show file tree
Hide file tree
Showing 16 changed files with 70 additions and 92 deletions.
10 changes: 0 additions & 10 deletions src/odr/document_element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 0 additions & 3 deletions src/odr/internal/abstract/document_element.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 0 additions & 5 deletions src/odr/internal/odf/odf_document.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
#include <odr/internal/odf/odf_document.hpp>

#include <odr/exceptions.hpp>
#include <odr/file.hpp>

#include <odr/internal/abstract/filesystem.hpp>
#include <odr/internal/common/file.hpp>
#include <odr/internal/common/path.hpp>
#include <odr/internal/odf/odf_document.hpp>
#include <odr/internal/odf/odf_element.hpp>
#include <odr/internal/odf/odf_parser.hpp>
#include <odr/internal/odf/odf_style.hpp>
#include <odr/internal/util/xml_util.hpp>
#include <odr/internal/zip/zip_archive.hpp>

Expand Down
13 changes: 0 additions & 13 deletions src/odr/internal/odf/odf_element.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
#include <odr/internal/odf/odf_element.hpp>

#include <odr/file.hpp>
#include <odr/style.hpp>

#include <odr/internal/abstract/document.hpp>
#include <odr/internal/abstract/filesystem.hpp>
#include <odr/internal/common/document_element.hpp>
#include <odr/internal/common/style.hpp>
#include <odr/internal/common/table_cursor.hpp>
#include <odr/internal/odf/odf_document.hpp>
#include <odr/internal/util/string_util.hpp>
Expand All @@ -15,7 +11,6 @@
#include <pugixml.hpp>

#include <cstring>
#include <functional>
#include <optional>
#include <string>

Expand Down Expand Up @@ -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;
}
Expand Down
5 changes: 0 additions & 5 deletions src/odr/internal/odf/odf_element.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/odr/internal/odf/odf_file.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <odr/internal/odf/odf_file.hpp>

#include <odr/exceptions.hpp>
#include <odr/file.hpp>

#include <odr/internal/abstract/filesystem.hpp>
#include <odr/internal/odf/odf_crypto.hpp>
Expand Down
2 changes: 0 additions & 2 deletions src/odr/internal/odf/odf_meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@

#include <odr/internal/abstract/file.hpp>
#include <odr/internal/abstract/filesystem.hpp>
#include <odr/internal/common/path.hpp>
#include <odr/internal/util/map_util.hpp>
#include <odr/internal/util/stream_util.hpp>
#include <odr/internal/util/xml_util.hpp>

#include <pugixml.hpp>

#include <algorithm>
#include <unordered_map>
#include <utility>

Expand Down
6 changes: 4 additions & 2 deletions src/odr/internal/odf/odf_parser.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include <functional>
#include <odr/internal/odf/odf_element.hpp>
#include <odr/internal/odf/odf_parser.hpp>

#include <odr/internal/odf/odf_element.hpp>
#include <odr/internal/odf/odf_spreadsheet.hpp>

#include <functional>
#include <unordered_map>

namespace odr::internal::odf {
Expand Down
69 changes: 64 additions & 5 deletions src/odr/internal/odf/odf_spreadsheet.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,70 @@
#include <cstring>
#include <odr/internal/common/table_cursor.hpp>
#include <odr/internal/odf/odf_spreadsheet.hpp>

#include <odr/internal/common/table_cursor.hpp>
#include <odr/internal/util/map_util.hpp>

#include <cstring>
#include <stdexcept>

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) {}

Expand Down Expand Up @@ -143,7 +202,7 @@ std::tuple<odf::Element *, pugi::xml_node> odf::parse_element_tree<odf::Sheet>(
const auto columns_repeated =
column_node.attribute("table:number-columns-repeated").as_uint(1);

auto [column, _] = parse_element_tree<TableColumn>(column_node, store);
auto [column, _] = parse_element_tree<SheetColumn>(column_node, store);

sheet.init_column(cursor.column(), columns_repeated, column);

Expand All @@ -157,7 +216,7 @@ std::tuple<odf::Element *, pugi::xml_node> odf::parse_element_tree<odf::Sheet>(
const auto rows_repeated =
row_node.attribute("table:number-rows-repeated").as_uint(1);

auto [row, _] = parse_element_tree<TableRow>(row_node, store);
auto [row, _] = parse_element_tree<SheetRow>(row_node, store);

sheet.init_row(cursor.row(), rows_repeated, row);

Expand All @@ -169,7 +228,7 @@ std::tuple<odf::Element *, pugi::xml_node> odf::parse_element_tree<odf::Sheet>(
const auto rowspan =
cell_node.attribute("table:number-rows-spanned").as_uint(1);

auto [cell, _] = parse_element_tree<TableCell>(cell_node, store);
auto [cell, _] = parse_element_tree<SheetCell>(cell_node, store);

sheet.init_cell(cursor.column(), cursor.row(), columns_repeated,
rows_repeated, cell);
Expand Down
9 changes: 2 additions & 7 deletions src/odr/internal/odf/odf_style.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
#include <cstring>
#include <odr/internal/common/style.hpp>
#include <odr/internal/odf/odf_parser.hpp>
#include <odr/internal/odf/odf_style.hpp>

#include <odr/quantity.hpp>
#include <odr/style.hpp>
#include <odr/internal/odf/odf_parser.hpp>

#include <odr/internal/common/style.hpp>
#include <pugixml.hpp>

#include <cstring>
#include <pugixml.hpp>
#include <unordered_map>
#include <utility>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 0 additions & 8 deletions src/odr/internal/ooxml/text/ooxml_text_element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 0 additions & 4 deletions src/odr/internal/ooxml/text/ooxml_text_element.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d5e9883

Please sign in to comment.