From 24fbb75a9e0b3b4fc3dbd10e49b8dcff2383a13c Mon Sep 17 00:00:00 2001 From: Thomas Fussell Date: Thu, 24 Jul 2014 17:31:46 -0400 Subject: [PATCH] fix some things --- include/xlnt/cell/cell.hpp | 8 +- include/xlnt/cell/cell_reference.hpp | 2 + include/xlnt/common/relationship.hpp | 23 ++- include/xlnt/reader/reader.hpp | 11 +- include/xlnt/workbook/workbook.hpp | 75 +++++----- include/xlnt/worksheet/worksheet.hpp | 2 + source/cell.cpp | 148 +++++++++++-------- source/cell_reference.cpp | 10 ++ source/detail/cell_impl.hpp | 1 + source/detail/workbook_impl.hpp | 16 ++- source/number_format.cpp | 14 +- source/range.cpp | 2 +- source/reader.cpp | 204 +++++++++++++++++++++------ source/relationship.cpp | 4 +- source/workbook.cpp | 29 +++- source/worksheet.cpp | 14 +- source/writer.cpp | 30 +++- tests/runner-autogen.cpp | 140 +++++++++--------- tests/test_cell.hpp | 26 ++-- tests/test_read.hpp | 168 +++++++++++++++++++--- tests/test_worksheet.hpp | 29 +++- tests/test_write.hpp | 8 +- 22 files changed, 689 insertions(+), 275 deletions(-) diff --git a/include/xlnt/cell/cell.hpp b/include/xlnt/cell/cell.hpp index 0a18eee1..a14544ec 100644 --- a/include/xlnt/cell/cell.hpp +++ b/include/xlnt/cell/cell.hpp @@ -77,7 +77,6 @@ public: null, numeric, string, - formula, boolean, error }; @@ -97,7 +96,7 @@ public: std::string get_column() const; row_t get_row() const; - std::string to_string() const; + std::string to_string() const; void set_explicit_value(const std::string &value, type data_type); void set_explicit_value(int value, type data_type); @@ -131,9 +130,12 @@ public: void set_comment(comment &comment); void set_comment(comment &&comment); void clear_comment(); + bool has_comment() const; std::string get_formula() const; void set_formula(const std::string &formula); + void clear_formula(); + bool has_formula() const; std::string get_error() const; void set_error(const std::string &error); @@ -179,6 +181,8 @@ public: friend bool operator==(const date &comparand, const cell &cell); friend bool operator==(const time &comparand, const cell &cell); friend bool operator==(const datetime &comparand, const cell &cell); + + friend bool operator<(cell left, cell right); private: friend class worksheet; diff --git a/include/xlnt/cell/cell_reference.hpp b/include/xlnt/cell/cell_reference.hpp index 37711caa..dc090c77 100644 --- a/include/xlnt/cell/cell_reference.hpp +++ b/include/xlnt/cell/cell_reference.hpp @@ -101,6 +101,8 @@ public: bool operator!=(const std::string &reference_string) const { return *this != cell_reference(reference_string); } bool operator!=(const char *reference_string) const { return *this != std::string(reference_string); } + friend bool operator<(const cell_reference &left, const cell_reference &right); + private: column_t column_index_; row_t row_index_; diff --git a/include/xlnt/common/relationship.hpp b/include/xlnt/common/relationship.hpp index 06112f45..5c4994b8 100644 --- a/include/xlnt/common/relationship.hpp +++ b/include/xlnt/common/relationship.hpp @@ -54,12 +54,14 @@ public: hyperlink, drawing, worksheet, + chartsheet, shared_strings, styles, theme, extended_properties, core_properties, - office_document + office_document, + custom_xml }; static type type_from_string(const std::string &type_string) @@ -96,6 +98,14 @@ public: { return type::hyperlink; } + else if(type_string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet") + { + return type::chartsheet; + } + else if(type_string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml") + { + return type::custom_xml; + } return type::invalid; } @@ -112,6 +122,8 @@ public: case type::styles: return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"; case type::theme: return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"; case type::hyperlink: return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"; + case type::chartsheet: return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet"; + case type::custom_xml: return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml"; default: return "??"; } } @@ -142,6 +154,15 @@ public: type get_type() const { return type_; } std::string get_type_string() const { return type_to_string(type_); } + + friend bool operator==(const relationship &left, const relationship &right) + { + return left.type_ == right.type_ + && left.id_ == right.id_ + && left.source_uri_ == right.source_uri_ + && left.target_uri_ == right.target_uri_ + && left.target_mode_ == right.target_mode_; + } private: type type_; diff --git a/include/xlnt/reader/reader.hpp b/include/xlnt/reader/reader.hpp index e8c463ef..1fb3e685 100644 --- a/include/xlnt/reader/reader.hpp +++ b/include/xlnt/reader/reader.hpp @@ -30,16 +30,20 @@ namespace xlnt { +class document_properties; class relationship; +class style; class workbook; class worksheet; -class document_properties; class zip_file; class reader { public: - static std::vector read_relationships(const std::string &content); + static const std::string CentralDirectorySignature; + static std::string repair_central_directory(const std::string &original); + static void fast_parse(worksheet ws, std::istream &xml_source, const std::vector &shared_string, const std::vector