From 21b3d366d6f80a5fc0537d15de1eb0c113ea3e7a Mon Sep 17 00:00:00 2001 From: Thomas Fussell Date: Tue, 20 Oct 2015 23:30:10 -0400 Subject: [PATCH] change some things --- build/genie/genie.lua | 1 + include/xlnt/cell/cell.hpp | 4 +- include/xlnt/cell/comment.hpp | 2 + .../writer.hpp => formula/known_formulae.hpp} | 0 include/xlnt/formula/tokenizer.hpp | 7 + include/xlnt/formula/translate.hpp | 33 ++ include/xlnt/reader/excel_reader.hpp | 13 +- include/xlnt/reader/reader.hpp | 59 --- include/xlnt/reader/shared_strings_reader.hpp | 36 ++ include/xlnt/reader/style_reader.hpp | 21 +- include/xlnt/reader/workbook_reader.hpp | 17 +- include/xlnt/reader/worksheet_reader.hpp | 16 +- .../xlnt/styles/{borders.hpp => border.hpp} | 35 +- include/xlnt/styles/fill.hpp | 13 - include/xlnt/styles/gradient_fill.hpp | 39 ++ include/xlnt/styles/named_style.hpp | 90 ++++ include/xlnt/styles/pattern_fill.hpp | 43 ++ .../chart_reader.hpp => styles/side.hpp} | 58 +-- include/xlnt/styles/style.hpp | 2 +- include/xlnt/workbook/external_book.hpp | 9 + include/xlnt/worksheet/column_properties.hpp | 16 +- .../theme_reader.hpp => worksheet/pane.hpp} | 4 +- include/xlnt/worksheet/row_properties.hpp | 16 +- .../selection.hpp} | 6 +- .../sheet_view.hpp} | 6 +- .../worksheet_properties.hpp} | 4 +- ...g_writer.hpp => shared_strings_writer.hpp} | 0 include/xlnt/xlnt.hpp | 21 +- source/{ => cell}/cell.cpp | 0 source/{ => cell}/cell_reference.cpp | 0 source/{ => cell}/comment.cpp | 0 source/{ => common}/datetime.cpp | 0 source/{ => common}/exceptions.cpp | 0 source/{ => common}/relationship.cpp | 0 source/{ => common}/string_table.cpp | 0 source/{ => common}/zip_file.cpp | 0 source/{ => detail}/constants.cpp | 0 source/{ => detail}/constants.hpp | 0 source/{ => drawing}/drawing.cpp | 0 source/reader.cpp | 476 ------------------ source/reader/excel_reader.cpp | 67 +++ source/reader/shared_strings_reader.cpp | 29 ++ source/reader/workbook_reader.cpp | 238 +++++++++ source/{ => styles}/borders.cpp | 2 +- source/{ => styles}/number_format.cpp | 0 source/{ => styles}/protection.cpp | 0 source/{ => styles}/style.cpp | 0 source/{ => workbook}/document_properties.cpp | 0 source/{ => workbook}/named_range.cpp | 0 source/{ => workbook}/workbook.cpp | 17 +- source/workbook_reader.cpp | 22 - source/{ => worksheet}/range.cpp | 0 source/{ => worksheet}/range_reference.cpp | 0 source/{ => worksheet}/sheet_protection.cpp | 0 source/{ => worksheet}/worksheet.cpp | 0 source/worksheet/worksheet_reader.cpp | 186 +++++++ source/{ => writer}/manifest_writer.cpp | 0 source/{ => writer}/relationship_writer.cpp | 0 source/{ => writer}/style_writer.cpp | 17 +- source/{ => writer}/workbook_writer.cpp | 0 source/{ => writer}/worksheet_writer.cpp | 2 +- tests/test_cell.hpp | 21 +- tests/test_props.hpp | 9 +- tests/test_read.hpp | 64 +-- 64 files changed, 961 insertions(+), 760 deletions(-) rename include/xlnt/{writer/writer.hpp => formula/known_formulae.hpp} (100%) create mode 100644 include/xlnt/formula/tokenizer.hpp create mode 100644 include/xlnt/formula/translate.hpp delete mode 100644 include/xlnt/reader/reader.hpp create mode 100644 include/xlnt/reader/shared_strings_reader.hpp rename include/xlnt/styles/{borders.hpp => border.hpp} (79%) create mode 100644 include/xlnt/styles/gradient_fill.hpp create mode 100644 include/xlnt/styles/named_style.hpp create mode 100644 include/xlnt/styles/pattern_fill.hpp rename include/xlnt/{reader/chart_reader.hpp => styles/side.hpp} (71%) create mode 100644 include/xlnt/workbook/external_book.hpp rename include/xlnt/{reader/theme_reader.hpp => worksheet/pane.hpp} (95%) rename include/xlnt/{reader/string_reader.hpp => worksheet/selection.hpp} (95%) rename include/xlnt/{reader/drawing_reader.hpp => worksheet/sheet_view.hpp} (95%) rename include/xlnt/{writer/drawing_writer.hpp => worksheet/worksheet_properties.hpp} (97%) rename include/xlnt/writer/{string_writer.hpp => shared_strings_writer.hpp} (100%) rename source/{ => cell}/cell.cpp (100%) rename source/{ => cell}/cell_reference.cpp (100%) rename source/{ => cell}/comment.cpp (100%) rename source/{ => common}/datetime.cpp (100%) rename source/{ => common}/exceptions.cpp (100%) rename source/{ => common}/relationship.cpp (100%) rename source/{ => common}/string_table.cpp (100%) rename source/{ => common}/zip_file.cpp (100%) rename source/{ => detail}/constants.cpp (100%) rename source/{ => detail}/constants.hpp (100%) rename source/{ => drawing}/drawing.cpp (100%) delete mode 100644 source/reader.cpp create mode 100644 source/reader/excel_reader.cpp create mode 100644 source/reader/shared_strings_reader.cpp create mode 100644 source/reader/workbook_reader.cpp rename source/{ => styles}/borders.cpp (77%) rename source/{ => styles}/number_format.cpp (100%) rename source/{ => styles}/protection.cpp (100%) rename source/{ => styles}/style.cpp (100%) rename source/{ => workbook}/document_properties.cpp (100%) rename source/{ => workbook}/named_range.cpp (100%) rename source/{ => workbook}/workbook.cpp (97%) delete mode 100644 source/workbook_reader.cpp rename source/{ => worksheet}/range.cpp (100%) rename source/{ => worksheet}/range_reference.cpp (100%) rename source/{ => worksheet}/sheet_protection.cpp (100%) rename source/{ => worksheet}/worksheet.cpp (100%) create mode 100644 source/worksheet/worksheet_reader.cpp rename source/{ => writer}/manifest_writer.cpp (100%) rename source/{ => writer}/relationship_writer.cpp (100%) rename source/{ => writer}/style_writer.cpp (93%) rename source/{ => writer}/workbook_writer.cpp (100%) rename source/{ => writer}/worksheet_writer.cpp (99%) diff --git a/build/genie/genie.lua b/build/genie/genie.lua index 39766d16..2f4eb827 100644 --- a/build/genie/genie.lua +++ b/build/genie/genie.lua @@ -37,6 +37,7 @@ project "xlnt" targetdir "../../lib/" includedirs { "../../include", + "../../source", "../../third-party/miniz", "../../third-party/pugixml/src" } diff --git a/include/xlnt/cell/cell.hpp b/include/xlnt/cell/cell.hpp index f81e9081..134faacd 100644 --- a/include/xlnt/cell/cell.hpp +++ b/include/xlnt/cell/cell.hpp @@ -44,8 +44,10 @@ struct datetime; struct time; struct timedelta; -namespace detail { +namespace detail { + struct cell_impl; + } // namespace detail /// diff --git a/include/xlnt/cell/comment.hpp b/include/xlnt/cell/comment.hpp index d001fd9a..9dd09ac2 100644 --- a/include/xlnt/cell/comment.hpp +++ b/include/xlnt/cell/comment.hpp @@ -7,7 +7,9 @@ namespace xlnt { class cell; namespace detail { + struct comment_impl; + } // namespace detail /// diff --git a/include/xlnt/writer/writer.hpp b/include/xlnt/formula/known_formulae.hpp similarity index 100% rename from include/xlnt/writer/writer.hpp rename to include/xlnt/formula/known_formulae.hpp diff --git a/include/xlnt/formula/tokenizer.hpp b/include/xlnt/formula/tokenizer.hpp new file mode 100644 index 00000000..957fd157 --- /dev/null +++ b/include/xlnt/formula/tokenizer.hpp @@ -0,0 +1,7 @@ +namespace xlnt { + +class tokenizer { + +}; + +} // namespace xlnt diff --git a/include/xlnt/formula/translate.hpp b/include/xlnt/formula/translate.hpp new file mode 100644 index 00000000..78e40614 --- /dev/null +++ b/include/xlnt/formula/translate.hpp @@ -0,0 +1,33 @@ +#include +#include + +namespace xlnt { + +class cell_reference; +class tokenizer; + +class translator +{ + translator(const std::string &formula, const cell_reference &ref); + + std::vector get_tokens(); + + static std::string translate_row(const std::string &row_str, int row_delta); + static std::string translate_col(const std::string &col_str, col_delta); + + std::pair strip_ws_name(const std::string &range_str); + + void translate_range(const range_reference &range_ref); + void translate_formula(const cell_reference &dest); + +private: + const std::string ROW_RANGE_RE; + const std::string COL_RANGE_RE; + const std::string CELL_REF_RE; + + std::string formula_; + cell_reference reference_; + tokenizer tokenizer_; +}; + +} // namespace xlnt diff --git a/include/xlnt/reader/excel_reader.hpp b/include/xlnt/reader/excel_reader.hpp index df3192a1..02769a37 100644 --- a/include/xlnt/reader/excel_reader.hpp +++ b/include/xlnt/reader/excel_reader.hpp @@ -23,11 +23,16 @@ // @author: see AUTHORS file #pragma once +#include +#include + namespace xlnt { + +class workbook; -class excel_reader -{ - -}; +std::string CentralDirectorySignature(); +std::string repair_central_directory(const std::string &original); +workbook load_workbook(const std::string &filename, bool guess_types = false, bool data_only = false); +workbook load_workbook(const std::vector &bytes, bool guess_types = false, bool data_only = false); } // namespace xlnt diff --git a/include/xlnt/reader/reader.hpp b/include/xlnt/reader/reader.hpp deleted file mode 100644 index 001dd855..00000000 --- a/include/xlnt/reader/reader.hpp +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) 2015 Thomas Fussell -// Copyright (c) 2010-2015 openpyxl -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, WRISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE -// -// @license: http://www.opensource.org/licenses/mit-license.php -// @author: see AUTHORS file -#pragma once - -#include -#include -#include -#include - -namespace xlnt { - -class document_properties; -class relationship; -class style; -class workbook; -class worksheet; -class zip_file; - -class reader -{ -public: - 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