From 23e552d92122e2927c69d88ed9881968d481efe4 Mon Sep 17 00:00:00 2001 From: andiwand Date: Sun, 10 Dec 2023 17:50:02 +0100 Subject: [PATCH] fix ods --- src/odr/internal/odf/odf_spreadsheet.cpp | 19 +++++++++++++------ src/odr/internal/odf/odf_spreadsheet.hpp | 1 + .../spreadsheet/ooxml_spreadsheet_element.cpp | 8 ++++---- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/odr/internal/odf/odf_spreadsheet.cpp b/src/odr/internal/odf/odf_spreadsheet.cpp index e734f2ce..990d35cf 100644 --- a/src/odr/internal/odf/odf_spreadsheet.cpp +++ b/src/odr/internal/odf/odf_spreadsheet.cpp @@ -108,17 +108,24 @@ pugi::xml_node Sheet::row_(std::uint32_t row) const { return {}; } +pugi::xml_node Sheet::cell_(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)) { + const auto &cells = row_it->second.cells; + if (auto cell_it = util::map::lookup_greater_than(cells, column); + cell_it != std::end(cells)) { + return cell_it->second; + } + } + return {}; +} + common::ResolvedStyle Sheet::cell_style_(const abstract::Document *document, std::uint32_t column, std::uint32_t row) const { - auto it = m_cells.find({column, row}); - if (it == std::end(m_cells)) { - return common::ResolvedStyle(); - } - const char *style_name = nullptr; - auto cell_node = it->second->m_node; + auto cell_node = cell_(column, row); if (auto attr = cell_node.attribute("table:style-name")) { style_name = attr.value(); } diff --git a/src/odr/internal/odf/odf_spreadsheet.hpp b/src/odr/internal/odf/odf_spreadsheet.hpp index dd7e29df..81f3bc6c 100644 --- a/src/odr/internal/odf/odf_spreadsheet.hpp +++ b/src/odr/internal/odf/odf_spreadsheet.hpp @@ -66,6 +66,7 @@ class Sheet final : public Element, public abstract::Sheet { pugi::xml_node column_(std::uint32_t) const; pugi::xml_node row_(std::uint32_t) const; + pugi::xml_node cell_(std::uint32_t column, std::uint32_t row) const; common::ResolvedStyle cell_style_(const abstract::Document *, std::uint32_t column, diff --git a/src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_element.cpp b/src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_element.cpp index 5c80b7b1..74a8122e 100644 --- a/src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_element.cpp +++ b/src/odr/internal/ooxml/spreadsheet/ooxml_spreadsheet_element.cpp @@ -101,18 +101,18 @@ TableStyle Sheet::style(const abstract::Document *) const { } TableColumnStyle Sheet::column_style(const abstract::Document *, - std::uint32_t column) const { + std::uint32_t /*column*/) const { return TableColumnStyle(); // TODO } TableRowStyle Sheet::row_style(const abstract::Document *, - std::uint32_t row) const { + std::uint32_t /*row*/) const { return TableRowStyle(); // TODO } TableCellStyle Sheet::cell_style(const abstract::Document *, - std::uint32_t column, - std::uint32_t row) const { + std::uint32_t /*column*/, + std::uint32_t /*row*/) const { return TableCellStyle(); // TODO }