From 47b81a83dea5cc651e5d115b6bac4079b6c95d41 Mon Sep 17 00:00:00 2001 From: Thomas Fussell Date: Thu, 19 Nov 2015 22:54:54 -0500 Subject: [PATCH] start moving all implementations to source files --- AUTHORS.md | 9 + LICENCE.md | 23 ++ TODO.md | 23 ++ include/xlnt/cell/cell.hpp | 34 +-- include/xlnt/cell/cell_reference.hpp | 84 ++---- include/xlnt/cell/cell_type.hpp | 49 ++++ include/xlnt/cell/comment.hpp | 25 +- include/xlnt/cell/types.hpp | 102 ++++---- include/xlnt/charts/axis.hpp | 33 +++ include/xlnt/charts/bar_chart.hpp | 33 +++ include/xlnt/charts/chart.hpp | 33 +++ include/xlnt/charts/error_bar.hpp | 33 +++ include/xlnt/charts/graph_chart.hpp | 33 +++ include/xlnt/charts/legend.hpp | 33 +++ include/xlnt/charts/line_chart.hpp | 33 +++ include/xlnt/charts/pie_chart.hpp | 33 +++ include/xlnt/charts/scatter_chart.hpp | 33 +++ include/xlnt/charts/series.hpp | 33 +++ include/xlnt/drawing/drawing.hpp | 4 +- .../xlnt/formula/excel_tokenizer_parser.txt | 61 +++++ include/xlnt/formula/known_formulae.hpp | 33 +++ include/xlnt/formula/tokenizer.hpp | 28 +- include/xlnt/formula/translator.hpp | 25 +- include/xlnt/packaging/default_type.hpp | 48 ++++ .../xlnt/packaging/document_properties.hpp | 7 +- include/xlnt/packaging/manifest.hpp | 91 +++---- include/xlnt/packaging/override_type.hpp | 48 ++++ include/xlnt/packaging/relationship.hpp | 4 +- include/xlnt/packaging/zip_file.hpp | 24 +- .../xlnt/serialization/comment_serializer.hpp | 5 +- include/xlnt/serialization/encoding.hpp | 24 +- .../xlnt/serialization/excel_serializer.hpp | 5 +- .../serialization/manifest_serializer.hpp | 25 +- .../serialization/relationship_serializer.hpp | 25 +- .../shared_strings_serializer.hpp | 4 +- .../xlnt/serialization/style_serializer.hpp | 5 +- .../xlnt/serialization/theme_serializer.hpp | 4 +- .../serialization/workbook_serializer.hpp | 4 +- .../serialization/worksheet_serializer.hpp | 5 +- include/xlnt/serialization/xml_document.hpp | 24 +- include/xlnt/serialization/xml_node.hpp | 24 +- include/xlnt/serialization/xml_serializer.hpp | 24 +- include/xlnt/styles/alignment.hpp | 5 +- include/xlnt/styles/border.hpp | 7 +- include/xlnt/styles/color.hpp | 5 +- include/xlnt/styles/fill.hpp | 5 +- include/xlnt/styles/font.hpp | 7 +- include/xlnt/styles/named_style.hpp | 5 +- include/xlnt/styles/number_format.hpp | 4 +- include/xlnt/styles/protection.hpp | 5 +- include/xlnt/styles/side.hpp | 5 +- include/xlnt/styles/style.hpp | 5 +- include/xlnt/utils/attribute_error.hpp | 41 +++ include/xlnt/utils/calendar.hpp | 39 +++ .../xlnt/utils/cell_coordinates_exception.hpp | 44 ++++ .../utils/column_string_index_exception.hpp | 41 +++ include/xlnt/utils/data_type_exception.hpp | 41 +++ include/xlnt/utils/date.hpp | 69 +++++ include/xlnt/utils/datetime.hpp | 108 +------- include/xlnt/utils/exceptions.hpp | 124 +-------- include/xlnt/utils/hash_combine.hpp | 30 ++- .../xlnt/utils/illegal_character_error.hpp | 42 +++ include/xlnt/utils/invalid_file_exception.hpp | 42 +++ include/xlnt/utils/missing_number_format.hpp | 41 +++ include/xlnt/utils/named_range_exception.hpp | 41 +++ .../utils/read_only_workbook_exception.hpp | 41 +++ include/xlnt/utils/sheet_title_exception.hpp | 42 +++ include/xlnt/utils/time.hpp | 65 +++++ include/xlnt/utils/timedelta.hpp | 53 ++++ include/xlnt/utils/value_error.hpp | 39 +++ include/xlnt/workbook/document_security.hpp | 5 +- include/xlnt/workbook/external_book.hpp | 27 +- include/xlnt/workbook/named_range.hpp | 28 +- include/xlnt/workbook/theme.hpp | 24 +- include/xlnt/workbook/workbook.hpp | 5 +- include/xlnt/worksheet/cell_vector.hpp | 44 ++-- include/xlnt/worksheet/column_properties.hpp | 4 +- include/xlnt/worksheet/footer.hpp | 50 ++++ include/xlnt/worksheet/header.hpp | 50 ++++ include/xlnt/worksheet/header_footer.hpp | 63 +++++ include/xlnt/worksheet/major_order.hpp | 24 +- include/xlnt/worksheet/orientation.hpp | 36 +++ include/xlnt/worksheet/page_break.hpp | 37 +++ include/xlnt/worksheet/page_margins.hpp | 85 ++----- include/xlnt/worksheet/page_setup.hpp | 193 ++++---------- include/xlnt/worksheet/pane.hpp | 5 +- include/xlnt/worksheet/paper_size.hpp | 45 ++++ include/xlnt/worksheet/range.hpp | 5 +- include/xlnt/worksheet/range_reference.hpp | 5 +- include/xlnt/worksheet/row_properties.hpp | 4 +- include/xlnt/worksheet/selection.hpp | 4 +- include/xlnt/worksheet/sheet_protection.hpp | 25 +- include/xlnt/worksheet/sheet_state.hpp | 37 +++ include/xlnt/worksheet/sheet_view.hpp | 5 +- include/xlnt/worksheet/worksheet.hpp | 223 +--------------- .../xlnt/worksheet/worksheet_properties.hpp | 4 +- include/xlnt/xlnt.hpp | 8 +- include/xlnt/xlnt_config.hpp | 2 +- requirements.txt | 3 + source/cell/cell.cpp | 8 + source/cell/cell_reference.cpp | 75 ++++++ source/cell/tests/test_cell.hpp | 3 + source/cell/types.cpp | 240 ++++++++++++++++++ source/detail/cell_impl.hpp | 2 +- source/detail/worksheet_impl.hpp | 2 +- source/detail/xml_node_impl.hpp | 2 + source/packaging/default_type.cpp | 35 +++ source/packaging/manifest.cpp | 53 +--- source/packaging/override_type.cpp | 37 +++ source/packaging/override_type.hpp | 14 + source/serialization/tests/test_write.hpp | 2 +- .../tests/test_write_workbook.hpp | 4 +- source/serialization/workbook_serializer.cpp | 2 +- source/serialization/worksheet_serializer.cpp | 2 +- source/utils/date.cpp | 94 +++++++ source/utils/datetime.cpp | 171 +------------ source/utils/exceptions.cpp | 14 +- source/utils/time.cpp | 83 ++++++ source/utils/timedelta.cpp | 32 +++ source/worksheet/cell_vector.cpp | 114 +++++++++ source/worksheet/page_margins.cpp | 80 ++++++ source/worksheet/page_setup.cpp | 157 ++++++++++++ source/worksheet/range.cpp | 94 ------- source/worksheet/tests/test_worksheet.hpp | 4 +- source/worksheet/worksheet.cpp | 9 +- 125 files changed, 3321 insertions(+), 1288 deletions(-) create mode 100644 AUTHORS.md create mode 100644 LICENCE.md create mode 100644 TODO.md create mode 100644 include/xlnt/cell/cell_type.hpp create mode 100644 include/xlnt/formula/excel_tokenizer_parser.txt create mode 100644 include/xlnt/packaging/default_type.hpp create mode 100644 include/xlnt/packaging/override_type.hpp create mode 100644 include/xlnt/utils/attribute_error.hpp create mode 100644 include/xlnt/utils/calendar.hpp create mode 100644 include/xlnt/utils/cell_coordinates_exception.hpp create mode 100644 include/xlnt/utils/column_string_index_exception.hpp create mode 100644 include/xlnt/utils/data_type_exception.hpp create mode 100644 include/xlnt/utils/date.hpp create mode 100644 include/xlnt/utils/illegal_character_error.hpp create mode 100644 include/xlnt/utils/invalid_file_exception.hpp create mode 100644 include/xlnt/utils/missing_number_format.hpp create mode 100644 include/xlnt/utils/named_range_exception.hpp create mode 100644 include/xlnt/utils/read_only_workbook_exception.hpp create mode 100644 include/xlnt/utils/sheet_title_exception.hpp create mode 100644 include/xlnt/utils/time.hpp create mode 100644 include/xlnt/utils/timedelta.hpp create mode 100644 include/xlnt/utils/value_error.hpp create mode 100644 include/xlnt/worksheet/footer.hpp create mode 100644 include/xlnt/worksheet/header.hpp create mode 100644 include/xlnt/worksheet/header_footer.hpp create mode 100644 include/xlnt/worksheet/orientation.hpp create mode 100644 include/xlnt/worksheet/page_break.hpp create mode 100644 include/xlnt/worksheet/paper_size.hpp create mode 100644 include/xlnt/worksheet/sheet_state.hpp create mode 100644 requirements.txt create mode 100644 source/packaging/default_type.cpp create mode 100644 source/packaging/override_type.cpp create mode 100644 source/packaging/override_type.hpp create mode 100644 source/utils/date.cpp create mode 100644 source/utils/time.cpp create mode 100644 source/utils/timedelta.cpp create mode 100644 source/worksheet/cell_vector.cpp create mode 100644 source/worksheet/page_margins.cpp create mode 100644 source/worksheet/page_setup.cpp diff --git a/AUTHORS.md b/AUTHORS.md new file mode 100644 index 00000000..1a6ad098 --- /dev/null +++ b/AUTHORS.md @@ -0,0 +1,9 @@ +This project was started by Thomas Fussell. + +It was initially inspired by the openpyxl library: https://openpyxl.readthedocs.org + +Thanks to everyone who has contributed to this project (in alphabetical order): + +* Malvineous + +Project logo designed by Thomas Fussell. \ No newline at end of file diff --git a/LICENCE.md b/LICENCE.md new file mode 100644 index 00000000..602d8def --- /dev/null +++ b/LICENCE.md @@ -0,0 +1,23 @@ +This software is under the MIT Licence +====================================== + +Copyright (c) 2014-2015 Thomas Fussell + +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, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/TODO.md b/TODO.md new file mode 100644 index 00000000..2eff49df --- /dev/null +++ b/TODO.md @@ -0,0 +1,23 @@ +For release: +Move all method definitions out of headers. +Clean up iterators in workbook, worksheet, cell_vector, range. +One class per header. +Set up Coveralls. +Synchronize tests for workbook, worksheet, cell, core_properties, manifest, relationship, stylesheet, number_format, format_rule, tokenizer. +Synchronize samples. +Summarize what works and what doesn't. +Finish documenting all header files. +Port benchmarks. +Clean up CMake scripts. +Release 0.9.0 for Windows (static 32-bit, dll 32-bit, static 64-bit, dll 32-bit), Ubuntu 14.04 64-bit (static, shared), OSX 10.11 (static, dylib, framework). +XML wrappers aren't very pretty, improve them? +100% test coverage. + +Then: +Implement conditional formatting. +Implement charts. +Implement chartsheets. +Implement drawing. +Implement formula evaluation? +Implement pivot tables. +Implement XML validation. \ No newline at end of file diff --git a/include/xlnt/cell/cell.hpp b/include/xlnt/cell/cell.hpp index 09039d4b..94d31017 100644 --- a/include/xlnt/cell/cell.hpp +++ b/include/xlnt/cell/cell.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -27,10 +27,10 @@ #include #include +#include +#include #include -#include "xlnt_config.hpp" - namespace xlnt { enum class calendar; @@ -65,25 +65,8 @@ namespace detail { struct cell_impl; } class XLNT_CLASS cell { public: - /// - /// Enumerates the possible types a cell can be determined by it's current value. - /// - enum class type - { - /// no value. note: this is different from an empty string value or 0 numeric value - null, - /// number - numeric, - /// string - string, - /// value is a formula - formula, - /// value is a known error code such as \#VALUE! - error, - /// value is TRUE or FALSE - boolean - }; - + using type = cell_type; + /// /// Return a map of error strings such as \#DIV/0! and their associated indices. /// @@ -392,16 +375,13 @@ public: /// Convenience function for writing cell to an ostream. /// Uses cell::to_string() internally. /// - friend XLNT_FUNCTION std::ostream &operator<<(std::ostream &stream, const xlnt::cell &cell) - { - return stream << cell.to_string(); - } + friend XLNT_FUNCTION std::ostream &operator<<(std::ostream &stream, const xlnt::cell &cell); private: // make these friends so they can use the private constructor + friend class style; friend class worksheet; friend struct detail::cell_impl; - friend class style; /// /// Private constructor to create a cell from its implementation. diff --git a/include/xlnt/cell/cell_reference.hpp b/include/xlnt/cell/cell_reference.hpp index 7142530d..9cdc46a1 100644 --- a/include/xlnt/cell/cell_reference.hpp +++ b/include/xlnt/cell/cell_reference.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -26,10 +26,9 @@ #include #include +#include #include -#include "xlnt_config.hpp" - namespace xlnt { class cell_reference; @@ -65,8 +64,8 @@ class XLNT_CLASS cell_reference /// if column part or row part are prefixed by a dollar-sign indicating they /// are absolute, otherwise false. /// - static std::pair split_reference(const std::string &reference_string, bool &absolute_column, - bool &absolute_row); + static std::pair split_reference(const std::string &reference_string, + bool &absolute_column, bool &absolute_row); // constructors @@ -118,36 +117,24 @@ class XLNT_CLASS cell_reference /// /// Return true if the reference refers to an absolute column, otherwise false. /// - bool column_absolute() const - { - return absolute_column_; - } + bool column_absolute() const; /// /// Make this reference have an absolute column if absolute_column is true, /// otherwise not absolute. /// - void column_absolute(bool absolute_column) - { - absolute_column_ = absolute_column; - } + void column_absolute(bool absolute_column); /// /// Return true if the reference refers to an absolute row, otherwise false. /// - bool row_absolute() const - { - return absolute_row_; - } + bool row_absolute() const; /// /// Make this reference have an absolute row if absolute_row is true, /// otherwise not absolute. /// - void row_absolute(bool absolute_row) - { - absolute_row_ = absolute_row; - } + void row_absolute(bool absolute_row); // getters/setters @@ -155,50 +142,32 @@ class XLNT_CLASS cell_reference /// Return a string that identifies the column of this reference /// (e.g. second column from left is "B") /// - column_t get_column() const - { - return column_; - } + column_t get_column() const; /// /// Set the column of this reference from a string that identifies a particular column. /// - void set_column(const std::string &column_string) - { - column_ = column_t(column_string); - } + void set_column(const std::string &column_string); /// /// Return a 1-indexed numeric index of the column of this reference. /// - column_t get_column_index() const - { - return column_; - } + column_t get_column_index() const; /// /// Set the column of this reference from a 1-indexed number that identifies a particular column. /// - void set_column_index(column_t column) - { - column_ = column; - } + void set_column_index(column_t column); /// /// Return a 1-indexed numeric index of the row of this reference. /// - row_t get_row() const - { - return row_; - } + row_t get_row() const; /// /// Set the row of this reference from a 1-indexed number that identifies a particular row. /// - void set_row(row_t row) - { - row_ = row; - } + void set_row(row_t row); /// /// Return a cell_reference offset from this cell_reference by @@ -237,46 +206,31 @@ class XLNT_CLASS cell_reference /// Construct a cell_reference from reference_string and return the result /// of their comparison. /// - bool operator==(const std::string &reference_string) const - { - return *this == cell_reference(reference_string); - } + bool operator==(const std::string &reference_string) const; /// /// Construct a cell_reference from reference_string and return the result /// of their comparison. /// - bool operator==(const char *reference_string) const - { - return *this == std::string(reference_string); - } + bool operator==(const char *reference_string) const; /// /// Return true if this reference is not identical to comparand including /// in absoluteness of column and row. /// - bool operator!=(const cell_reference &comparand) const - { - return !(*this == comparand); - } + bool operator!=(const cell_reference &comparand) const; /// /// Construct a cell_reference from reference_string and return the result /// of their comparison. /// - bool operator!=(const std::string &reference_string) const - { - return *this != cell_reference(reference_string); - } + bool operator!=(const std::string &reference_string) const; /// /// Construct a cell_reference from reference_string and return the result /// of their comparison. /// - bool operator!=(const char *reference_string) const - { - return *this != std::string(reference_string); - } + bool operator!=(const char *reference_string) const; //TODO: are these useful? maybe get rid of them bool operator<(const cell_reference &other); diff --git a/include/xlnt/cell/cell_type.hpp b/include/xlnt/cell/cell_type.hpp new file mode 100644 index 00000000..0123f6ca --- /dev/null +++ b/include/xlnt/cell/cell_type.hpp @@ -0,0 +1,49 @@ +// Copyright (c) 2014-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 + +namespace xlnt { + +/// +/// Enumerates the possible types a cell can be determined by it's current value. +/// +enum class XLNT_CLASS cell_type +{ + /// no value. note: this is different from an empty string value or 0 numeric value + null, + /// number + numeric, + /// string + string, + /// value is a formula + formula, + /// value is a known error code such as \#VALUE! + error, + /// value is TRUE or FALSE + boolean +}; + +} // namespace xlnt diff --git a/include/xlnt/cell/comment.hpp b/include/xlnt/cell/comment.hpp index dc3365a1..9ae5fdef 100644 --- a/include/xlnt/cell/comment.hpp +++ b/include/xlnt/cell/comment.hpp @@ -1,8 +1,31 @@ +// Copyright (c) 2014-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 "xlnt_config.hpp" +#include namespace xlnt { diff --git a/include/xlnt/cell/types.hpp b/include/xlnt/cell/types.hpp index 01aa13b3..a0120f40 100644 --- a/include/xlnt/cell/types.hpp +++ b/include/xlnt/cell/types.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -26,7 +26,7 @@ #include #include -#include "xlnt_config.hpp" +#include // We might want to change these types for various optimizations in the future // so use typedefs. @@ -71,241 +71,237 @@ public: /// /// Default column_t is the first (left-most) column. /// - column_t() : index(1) {} + column_t(); /// /// Construct a column from a number. /// - column_t(index_t column_index) : index(column_index) {} + column_t(index_t column_index); /// /// Construct a column from a string. /// - explicit column_t(const std::string &column_string) : index(column_index_from_string(column_string)) {} + explicit column_t(const std::string &column_string); /// /// Construct a column from a string. /// - explicit column_t(const char *column_string) : column_t(std::string(column_string)) {} + explicit column_t(const char *column_string); /// /// Copy constructor /// - column_t(const column_t &other) : column_t(other.index) {} + column_t(const column_t &other); /// /// Move constructor /// - column_t(column_t &&other) { swap(*this, other); } + column_t(column_t &&other); /// /// Return a string representation of this column index. /// - std::string column_string() const { return column_string_from_index(index); } + std::string column_string() const; /// /// Set this column to be the same as rhs's and return reference to self. /// - column_t &operator=(column_t rhs) { swap(*this, rhs); return *this; } + column_t &operator=(column_t rhs); /// /// Set this column to be equal to rhs and return reference to self. /// - column_t &operator=(const std::string &rhs) { return *this = column_t(rhs); } + column_t &operator=(const std::string &rhs); /// /// Set this column to be equal to rhs and return reference to self. /// - column_t &operator=(const char *rhs) { return *this = column_t(rhs); } + column_t &operator=(const char *rhs); /// /// Return true if this column refers to the same column as other. /// - bool operator==(const column_t &other) const { return index == other.index; } + bool operator==(const column_t &other) const; /// /// Return true if this column doesn't refer to the same column as other. /// - bool operator!=(const column_t &other) const { return !(*this == other); } + bool operator!=(const column_t &other) const; /// /// Return true if this column refers to the same column as other. /// - bool operator==(int other) const { return *this == column_t(other); } + bool operator==(int other) const; /// /// Return true if this column refers to the same column as other. /// - bool operator==(index_t other) const { return *this == column_t(other); } + bool operator==(index_t other) const; /// /// Return true if this column refers to the same column as other. /// - bool operator==(const std::string &other) const { return *this == column_t(other); } + bool operator==(const std::string &other) const; /// /// Return true if this column refers to the same column as other. /// - bool operator==(const char *other) const { return *this == column_t(other); } + bool operator==(const char *other) const; /// /// Return true if this column doesn't refer to the same column as other. /// - bool operator!=(int other) const { return !(*this == other); } + bool operator!=(int other) const; /// /// Return true if this column doesn't refer to the same column as other. /// - bool operator!=(index_t other) const { return !(*this == other); } + bool operator!=(index_t other) const; /// /// Return true if this column doesn't refer to the same column as other. /// - bool operator!=(const std::string &other) const { return !(*this == other); } + bool operator!=(const std::string &other) const; /// /// Return true if this column doesn't refer to the same column as other. /// - bool operator!=(const char *other) const { return !(*this == other); } + bool operator!=(const char *other) const; /// /// Return true if other is to the right of this column. /// - bool operator>(const column_t &other) const { return index > other.index; } + bool operator>(const column_t &other) const; /// /// Return true if other is to the right of or equal to this column. /// - bool operator>=(const column_t &other) const { return index >= other.index; } + bool operator>=(const column_t &other) const; /// /// Return true if other is to the left of this column. /// - bool operator<(const column_t &other) const { return index < other.index; } + bool operator<(const column_t &other) const; /// /// Return true if other is to the left of or equal to this column. /// - bool operator<=(const column_t &other) const { return index <= other.index; } + bool operator<=(const column_t &other) const; /// /// Return true if other is to the right of this column. /// - bool operator>(const column_t::index_t &other) const { return index > other; } + bool operator>(const column_t::index_t &other) const; /// /// Return true if other is to the right of or equal to this column. /// - bool operator>=(const column_t::index_t &other) const { return index >= other; } + bool operator>=(const column_t::index_t &other) const; /// /// Return true if other is to the left of this column. /// - bool operator<(const column_t::index_t &other) const { return index < other; } + bool operator<(const column_t::index_t &other) const; /// /// Return true if other is to the left of or equal to this column. /// - bool operator<=(const column_t::index_t &other) const { return index <= other; } + bool operator<=(const column_t::index_t &other) const; /// /// Pre-increment this column, making it point to the column one to the right. /// - column_t &operator++() { index++; return *this; } + column_t &operator++(); /// /// Pre-deccrement this column, making it point to the column one to the left. /// - column_t &operator--() { index--; return *this; } + column_t &operator--(); /// /// Post-increment this column, making it point to the column one to the right and returning the old column. /// - column_t operator++(int) { column_t copy(index); ++(*this); return copy; } + column_t operator++(int); /// /// Post-decrement this column, making it point to the column one to the left and returning the old column. /// - column_t operator--(int) { column_t copy(index); --(*this); return copy; } + column_t operator--(int); /// /// Return the result of adding rhs to this column. /// - column_t operator+(const column_t &rhs) { column_t copy(*this); copy.index += rhs.index; return copy; } + column_t operator+(const column_t &rhs); /// /// Return the result of adding rhs to this column. /// - column_t operator-(const column_t &rhs) { column_t copy(*this); copy.index -= rhs.index; return copy; } + column_t operator-(const column_t &rhs); /// /// Return the result of adding rhs to this column. /// - column_t operator*(const column_t &rhs) { column_t copy(*this); copy.index *= rhs.index; return copy; } + column_t operator*(const column_t &rhs); /// /// Return the result of adding rhs to this column. /// - column_t operator/(const column_t &rhs) { column_t copy(*this); copy.index /= rhs.index; return copy; } + column_t operator/(const column_t &rhs); /// /// Return the result of adding rhs to this column. /// - column_t operator%(const column_t &rhs) { column_t copy(*this); copy.index %= rhs.index; return copy; } + column_t operator%(const column_t &rhs); /// /// Add rhs to this column and return a reference to this column. /// - column_t &operator+=(const column_t &rhs) { return *this = (*this + rhs); } + column_t &operator+=(const column_t &rhs); /// /// Subtrac rhs from this column and return a reference to this column. /// - column_t &operator-=(const column_t &rhs) { return *this = (*this - rhs); } + column_t &operator-=(const column_t &rhs); /// /// Multiply this column by rhs and return a reference to this column. /// - column_t &operator*=(const column_t &rhs) { return *this = (*this * rhs); } + column_t &operator*=(const column_t &rhs); /// /// Divide this column by rhs and return a reference to this column. /// - column_t &operator/=(const column_t &rhs) { return *this = (*this / rhs); } + column_t &operator/=(const column_t &rhs); /// /// Mod this column by rhs and return a reference to this column. /// - column_t &operator%=(const column_t &rhs) { return *this = (*this % rhs); } + column_t &operator%=(const column_t &rhs); /// /// Return true if other is to the right of this column. /// - friend bool operator>(const column_t::index_t &left, const column_t &right) { return column_t(left) > right; } + friend bool operator>(const column_t::index_t &left, const column_t &right); /// /// Return true if other is to the right of or equal to this column. /// - friend bool operator>=(const column_t::index_t &left, const column_t &right) { return column_t(left) >= right; } + friend bool operator>=(const column_t::index_t &left, const column_t &right); /// /// Return true if other is to the left of this column. /// - friend bool operator<(const column_t::index_t &left, const column_t &right) { return column_t(left) < right; } + friend bool operator<(const column_t::index_t &left, const column_t &right); /// /// Return true if other is to the left of or equal to this column. /// - friend bool operator<=(const column_t::index_t &left, const column_t &right) { return column_t(left) <= right; } + friend bool operator<=(const column_t::index_t &left, const column_t &right); /// /// Swap the columns that left and right refer to. /// - friend void swap(column_t &left, column_t &right) - { - using std::swap; - swap(left.index, right.index); - } + friend void swap(column_t &left, column_t &right); /// /// Internal numeric value of this column index. diff --git a/include/xlnt/charts/axis.hpp b/include/xlnt/charts/axis.hpp index e69de29b..16c7d47c 100644 --- a/include/xlnt/charts/axis.hpp +++ b/include/xlnt/charts/axis.hpp @@ -0,0 +1,33 @@ +// Copyright (c) 2014-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 + +namespace xlnt { + +class XLNT_CLASS axis { +}; + +} // namespace xlnt diff --git a/include/xlnt/charts/bar_chart.hpp b/include/xlnt/charts/bar_chart.hpp index e69de29b..bc45a08f 100644 --- a/include/xlnt/charts/bar_chart.hpp +++ b/include/xlnt/charts/bar_chart.hpp @@ -0,0 +1,33 @@ +// Copyright (c) 2014-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 + +namespace xlnt { + +class XLNT_CLASS bar_chart { +}; + +} // namespace xlnt diff --git a/include/xlnt/charts/chart.hpp b/include/xlnt/charts/chart.hpp index e69de29b..412f40fb 100644 --- a/include/xlnt/charts/chart.hpp +++ b/include/xlnt/charts/chart.hpp @@ -0,0 +1,33 @@ +// Copyright (c) 2014-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 + +namespace xlnt { + +class XLNT_CLASS chart { +}; + +} // namespace xlnt diff --git a/include/xlnt/charts/error_bar.hpp b/include/xlnt/charts/error_bar.hpp index e69de29b..ac79228d 100644 --- a/include/xlnt/charts/error_bar.hpp +++ b/include/xlnt/charts/error_bar.hpp @@ -0,0 +1,33 @@ +// Copyright (c) 2014-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 + +namespace xlnt { + +class XLNT_CLASS error_bar { +}; + +} // namespace xlnt diff --git a/include/xlnt/charts/graph_chart.hpp b/include/xlnt/charts/graph_chart.hpp index e69de29b..48bd4ea9 100644 --- a/include/xlnt/charts/graph_chart.hpp +++ b/include/xlnt/charts/graph_chart.hpp @@ -0,0 +1,33 @@ +// Copyright (c) 2014-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 + +namespace xlnt { + +class XLNT_CLASS graph_chart { +}; + +} // namespace xlnt diff --git a/include/xlnt/charts/legend.hpp b/include/xlnt/charts/legend.hpp index e69de29b..97460872 100644 --- a/include/xlnt/charts/legend.hpp +++ b/include/xlnt/charts/legend.hpp @@ -0,0 +1,33 @@ +// Copyright (c) 2014-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 + +namespace xlnt { + +class XLNT_CLASS legend { +}; + +} // namespace xlnt diff --git a/include/xlnt/charts/line_chart.hpp b/include/xlnt/charts/line_chart.hpp index e69de29b..c36f3c5c 100644 --- a/include/xlnt/charts/line_chart.hpp +++ b/include/xlnt/charts/line_chart.hpp @@ -0,0 +1,33 @@ +// Copyright (c) 2014-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 + +namespace xlnt { + +class XLNT_CLASS line_chart { +}; + +} // namespace xlnt diff --git a/include/xlnt/charts/pie_chart.hpp b/include/xlnt/charts/pie_chart.hpp index e69de29b..1dd9f864 100644 --- a/include/xlnt/charts/pie_chart.hpp +++ b/include/xlnt/charts/pie_chart.hpp @@ -0,0 +1,33 @@ +// Copyright (c) 2014-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 + +namespace xlnt { + +class XLNT_CLASS pie_chart { +}; + +} // namespace xlnt diff --git a/include/xlnt/charts/scatter_chart.hpp b/include/xlnt/charts/scatter_chart.hpp index e69de29b..15bb74d9 100644 --- a/include/xlnt/charts/scatter_chart.hpp +++ b/include/xlnt/charts/scatter_chart.hpp @@ -0,0 +1,33 @@ +// Copyright (c) 2014-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 + +namespace xlnt { + +class XLNT_CLASS scatter_chart { +}; + +} // namespace xlnt diff --git a/include/xlnt/charts/series.hpp b/include/xlnt/charts/series.hpp index e69de29b..4a75e635 100644 --- a/include/xlnt/charts/series.hpp +++ b/include/xlnt/charts/series.hpp @@ -0,0 +1,33 @@ +// Copyright (c) 2014-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 + +namespace xlnt { + +class XLNT_CLASS series { +}; + +} // namespace xlnt diff --git a/include/xlnt/drawing/drawing.hpp b/include/xlnt/drawing/drawing.hpp index b2453c96..29eb8572 100644 --- a/include/xlnt/drawing/drawing.hpp +++ b/include/xlnt/drawing/drawing.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ // @author: see AUTHORS file #pragma once -#include "xlnt_config.hpp" +#include namespace xlnt { diff --git a/include/xlnt/formula/excel_tokenizer_parser.txt b/include/xlnt/formula/excel_tokenizer_parser.txt new file mode 100644 index 00000000..91b4cb3a --- /dev/null +++ b/include/xlnt/formula/excel_tokenizer_parser.txt @@ -0,0 +1,61 @@ +From ewbachtal@ewbi.com Fri Apr 3 11:00:25 2015 +Date: Fri, 3 Apr 2015 07:58:55 -0700 +From: Eric W. Bachtal +To: 'Paul Harrington' +Subject: RE: [pycel] re-license the parser/tokenizer under a license suitable for incorporation into openpyxl (#11) (fwd) + +Hi Paul, + +I can't speak for Dirk's wishes regarding his Python implementation, but I'm +fine with my original JavaScript or C# Excel formula parser code being +released with a BSD/MIT license, as long as proper attribution is provided +and there's a clear indication that the software is provided "as is", +without warranty of any kind. + +Good luck! + +ewb + +425 241 2505 + + +-----Original Message----- +From: Paul Harrington [mailto:phrrngtn@panix.com] +Sent: Friday, April 3, 2015 7:19 AM +To: info@ewbi.com +Subject: Re: [pycel] re-license the parser/tokenizer under a license +suitable for incorporation into openpyxl (#11) (fwd) + + + +Hi, I was wondering if you would be OK with the parser (specifically the +Python implementation) being released with an BSD/MIT license? + +thanks for the implementation! + +pjjH + + + + +---------- Forwarded message ---------- +Date: Fri, 03 Apr 2015 06:26:39 -0700 +From: Dirk Gorissen +Reply-To: dgorissen/pycel + + +To: dgorissen/pycel +Cc: Paul Harrington +Subject: Re: [pycel] re-license the parser/tokenizer under a license +suitable + for incorporation into openpyxl (#11) + +I did not write the tokenizing/parser code and don't hold the copyright to +it. +Eric did and I just applied a small patch and integrated it. See the header +of tokenizer.py. + +--- +Reply to this email directly or view it on GitHub: +https://github.com/dgorissen/pycel/issues/11#issuecomment-89287122 diff --git a/include/xlnt/formula/known_formulae.hpp b/include/xlnt/formula/known_formulae.hpp index e69de29b..5ab18817 100644 --- a/include/xlnt/formula/known_formulae.hpp +++ b/include/xlnt/formula/known_formulae.hpp @@ -0,0 +1,33 @@ +// Copyright (c) 2014-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 + +namespace xlnt { + +class XLNT_CLASS known_formulae { +}; + +} // namespace xlnt diff --git a/include/xlnt/formula/tokenizer.hpp b/include/xlnt/formula/tokenizer.hpp index d064246c..28826810 100644 --- a/include/xlnt/formula/tokenizer.hpp +++ b/include/xlnt/formula/tokenizer.hpp @@ -1,11 +1,33 @@ +// Copyright (c) 2014-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 "xlnt_config.hpp" +#include namespace xlnt { -class XLNT_CLASS tokenizer -{ +class XLNT_CLASS tokenizer { }; } // namespace xlnt diff --git a/include/xlnt/formula/translator.hpp b/include/xlnt/formula/translator.hpp index 122ab771..e06797de 100644 --- a/include/xlnt/formula/translator.hpp +++ b/include/xlnt/formula/translator.hpp @@ -1,9 +1,32 @@ +// Copyright (c) 2014-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 "xlnt_config.hpp" +#include namespace xlnt { diff --git a/include/xlnt/packaging/default_type.hpp b/include/xlnt/packaging/default_type.hpp new file mode 100644 index 00000000..64347503 --- /dev/null +++ b/include/xlnt/packaging/default_type.hpp @@ -0,0 +1,48 @@ +// Copyright (c) 2014-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 + +namespace xlnt { + +class XLNT_CLASS default_type +{ + public: + default_type(); + default_type(const std::string &extension, const std::string &content_type); + default_type(const default_type &other); + default_type &operator=(const default_type &other); + + std::string get_extension() const; + std::string get_content_type() const; + + private: + std::string extension_; + std::string content_type_; +}; + +} // namespace xlnt diff --git a/include/xlnt/packaging/document_properties.hpp b/include/xlnt/packaging/document_properties.hpp index 2b1bf484..2373cf13 100644 --- a/include/xlnt/packaging/document_properties.hpp +++ b/include/xlnt/packaging/document_properties.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,10 +25,9 @@ #include +#include #include -#include "xlnt_config.hpp" - namespace xlnt { /// @@ -36,7 +35,7 @@ namespace xlnt { /// class XLNT_CLASS document_properties { - public: +public: document_properties(); std::string creator; diff --git a/include/xlnt/packaging/manifest.hpp b/include/xlnt/packaging/manifest.hpp index 3ae4db9a..4dae1035 100644 --- a/include/xlnt/packaging/manifest.hpp +++ b/include/xlnt/packaging/manifest.hpp @@ -1,76 +1,49 @@ +// Copyright (c) 2014-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 "xlnt_config.hpp" +#include +#include +#include namespace xlnt { -class XLNT_CLASS default_type -{ - public: - default_type(); - default_type(const std::string &extension, const std::string &content_type); - default_type(const default_type &other); - default_type &operator=(const default_type &other); - - std::string get_extension() const - { - return extension_; - } - std::string get_content_type() const - { - return content_type_; - } - - private: - std::string extension_; - std::string content_type_; -}; - -class XLNT_CLASS override_type -{ - public: - override_type(); - override_type(const std::string &extension, const std::string &content_type); - override_type(const override_type &other); - override_type &operator=(const override_type &other); - - std::string get_part_name() const - { - return part_name_; - } - std::string get_content_type() const - { - return content_type_; - } - - private: - std::string part_name_; - std::string content_type_; -}; - class XLNT_CLASS manifest { public: - void add_default_type(const std::string &extension, const std::string &content_type); - void add_override_type(const std::string &part_name, const std::string &content_type); - - const std::vector &get_default_types() const - { - return default_types_; - } - const std::vector &get_override_types() const - { - return override_types_; - } - bool has_default_type(const std::string &extension) const; - bool has_override_type(const std::string &part_name) const; - std::string get_default_type(const std::string &extension) const; + const std::vector &get_default_types() const; + void add_default_type(const std::string &extension, const std::string &content_type); + + bool has_override_type(const std::string &part_name) const; std::string get_override_type(const std::string &part_name) const; + const std::vector &get_override_types() const; + void add_override_type(const std::string &part_name, const std::string &content_type); private: std::vector default_types_; diff --git a/include/xlnt/packaging/override_type.hpp b/include/xlnt/packaging/override_type.hpp new file mode 100644 index 00000000..7aeb89a0 --- /dev/null +++ b/include/xlnt/packaging/override_type.hpp @@ -0,0 +1,48 @@ +// Copyright (c) 2014-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 + +namespace xlnt { + +class XLNT_CLASS override_type +{ + public: + override_type(); + override_type(const std::string &extension, const std::string &content_type); + override_type(const override_type &other); + override_type &operator=(const override_type &other); + + std::string get_part_name() const; + std::string get_content_type() const; + + private: + std::string part_name_; + std::string content_type_; +}; + +} // namespace xlnt diff --git a/include/xlnt/packaging/relationship.hpp b/include/xlnt/packaging/relationship.hpp index 40205ea0..8562025b 100644 --- a/include/xlnt/packaging/relationship.hpp +++ b/include/xlnt/packaging/relationship.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -32,7 +32,7 @@ namespace xlnt { /// /// Specifies whether the target of a relationship is inside or outside the Package. /// -enum class target_mode +enum class XLNT_CLASS target_mode { /// /// The relationship references a part that is inside the package. diff --git a/include/xlnt/packaging/zip_file.hpp b/include/xlnt/packaging/zip_file.hpp index 4b223362..8374ffd4 100644 --- a/include/xlnt/packaging/zip_file.hpp +++ b/include/xlnt/packaging/zip_file.hpp @@ -1,3 +1,25 @@ +// Copyright (c) 2014-2015 Thomas Fussell +// +// 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 @@ -7,7 +29,7 @@ #include #include -#include "xlnt_config.hpp" +#include // Note: this comes from https://github.com/tfussell/miniz-cpp diff --git a/include/xlnt/serialization/comment_serializer.hpp b/include/xlnt/serialization/comment_serializer.hpp index 41367007..7c6509a5 100644 --- a/include/xlnt/serialization/comment_serializer.hpp +++ b/include/xlnt/serialization/comment_serializer.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,11 +25,10 @@ #include +#include #include #include -#include "xlnt_config.hpp" - namespace xlnt { class xml_document; diff --git a/include/xlnt/serialization/encoding.hpp b/include/xlnt/serialization/encoding.hpp index 62053729..1204fae6 100644 --- a/include/xlnt/serialization/encoding.hpp +++ b/include/xlnt/serialization/encoding.hpp @@ -1,6 +1,28 @@ +// Copyright (c) 2014-2015 Thomas Fussell +// +// 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 "xlnt_config.hpp" +#include namespace xlnt { diff --git a/include/xlnt/serialization/excel_serializer.hpp b/include/xlnt/serialization/excel_serializer.hpp index dec5ff30..296defbd 100644 --- a/include/xlnt/serialization/excel_serializer.hpp +++ b/include/xlnt/serialization/excel_serializer.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -28,10 +28,9 @@ #include #include +#include #include -#include "xlnt_config.hpp" - namespace xlnt { class workbook; diff --git a/include/xlnt/serialization/manifest_serializer.hpp b/include/xlnt/serialization/manifest_serializer.hpp index 7297b634..bad062cc 100644 --- a/include/xlnt/serialization/manifest_serializer.hpp +++ b/include/xlnt/serialization/manifest_serializer.hpp @@ -1,8 +1,31 @@ +// Copyright (c) 2014-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 "xlnt_config.hpp" +#include namespace xlnt { diff --git a/include/xlnt/serialization/relationship_serializer.hpp b/include/xlnt/serialization/relationship_serializer.hpp index a2740fe4..c95b1775 100644 --- a/include/xlnt/serialization/relationship_serializer.hpp +++ b/include/xlnt/serialization/relationship_serializer.hpp @@ -1,9 +1,32 @@ +// Copyright (c) 2014-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 "xlnt_config.hpp" +#include namespace xlnt { diff --git a/include/xlnt/serialization/shared_strings_serializer.hpp b/include/xlnt/serialization/shared_strings_serializer.hpp index cb14142b..a23d56ef 100644 --- a/include/xlnt/serialization/shared_strings_serializer.hpp +++ b/include/xlnt/serialization/shared_strings_serializer.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,7 +26,7 @@ #include #include -#include "xlnt_config.hpp" +#include namespace xlnt { diff --git a/include/xlnt/serialization/style_serializer.hpp b/include/xlnt/serialization/style_serializer.hpp index 8ab5b3dc..fc118dab 100644 --- a/include/xlnt/serialization/style_serializer.hpp +++ b/include/xlnt/serialization/style_serializer.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -27,10 +27,9 @@ #include #include +#include #include -#include "xlnt_config.hpp" - namespace xlnt { class alignment; diff --git a/include/xlnt/serialization/theme_serializer.hpp b/include/xlnt/serialization/theme_serializer.hpp index 53118823..33ba0989 100644 --- a/include/xlnt/serialization/theme_serializer.hpp +++ b/include/xlnt/serialization/theme_serializer.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,7 +25,7 @@ #include -#include "xlnt_config.hpp" +#include namespace xlnt { diff --git a/include/xlnt/serialization/workbook_serializer.hpp b/include/xlnt/serialization/workbook_serializer.hpp index 2e2475f3..cdf11efa 100644 --- a/include/xlnt/serialization/workbook_serializer.hpp +++ b/include/xlnt/serialization/workbook_serializer.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,7 +26,7 @@ #include #include -#include "xlnt_config.hpp" +#include namespace xlnt { diff --git a/include/xlnt/serialization/worksheet_serializer.hpp b/include/xlnt/serialization/worksheet_serializer.hpp index 35d008a5..2971c039 100644 --- a/include/xlnt/serialization/worksheet_serializer.hpp +++ b/include/xlnt/serialization/worksheet_serializer.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,10 +26,9 @@ #include #include +#include #include -#include "xlnt_config.hpp" - namespace xlnt { class relationship; diff --git a/include/xlnt/serialization/xml_document.hpp b/include/xlnt/serialization/xml_document.hpp index 3c9902e6..8c964a7a 100644 --- a/include/xlnt/serialization/xml_document.hpp +++ b/include/xlnt/serialization/xml_document.hpp @@ -1,10 +1,32 @@ +// Copyright (c) 2014-2015 Thomas Fussell +// +// 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 "xlnt_config.hpp" +#include namespace xlnt { namespace detail { struct xml_document_impl; } diff --git a/include/xlnt/serialization/xml_node.hpp b/include/xlnt/serialization/xml_node.hpp index 09e54115..bd5369fe 100644 --- a/include/xlnt/serialization/xml_node.hpp +++ b/include/xlnt/serialization/xml_node.hpp @@ -1,10 +1,32 @@ +// Copyright (c) 2014-2015 Thomas Fussell +// +// 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 "xlnt_config.hpp" +#include namespace xlnt { namespace detail { struct xml_node_impl; } diff --git a/include/xlnt/serialization/xml_serializer.hpp b/include/xlnt/serialization/xml_serializer.hpp index 80615a57..a455c641 100644 --- a/include/xlnt/serialization/xml_serializer.hpp +++ b/include/xlnt/serialization/xml_serializer.hpp @@ -1,8 +1,30 @@ +// Copyright (c) 2014-2015 Thomas Fussell +// +// 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 "xlnt_config.hpp" +#include namespace xlnt { diff --git a/include/xlnt/styles/alignment.hpp b/include/xlnt/styles/alignment.hpp index 51f3f4d9..3fa3bfb2 100644 --- a/include/xlnt/styles/alignment.hpp +++ b/include/xlnt/styles/alignment.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,10 +23,9 @@ // @author: see AUTHORS file #pragma once +#include #include -#include "xlnt_config.hpp" - namespace xlnt { /// diff --git a/include/xlnt/styles/border.hpp b/include/xlnt/styles/border.hpp index 233e2715..9195c520 100644 --- a/include/xlnt/styles/border.hpp +++ b/include/xlnt/styles/border.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -26,10 +26,9 @@ #include #include -#include +#include #include - -#include "xlnt_config.hpp" +#include namespace xlnt { diff --git a/include/xlnt/styles/color.hpp b/include/xlnt/styles/color.hpp index 90d6cbdd..371132a4 100644 --- a/include/xlnt/styles/color.hpp +++ b/include/xlnt/styles/color.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,10 +25,9 @@ #include +#include #include -#include "xlnt_config.hpp" - namespace xlnt { class XLNT_CLASS color diff --git a/include/xlnt/styles/fill.hpp b/include/xlnt/styles/fill.hpp index 8914fbe0..e03eca1d 100644 --- a/include/xlnt/styles/fill.hpp +++ b/include/xlnt/styles/fill.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,11 +23,10 @@ // @author: see AUTHORS file #pragma once +#include #include #include -#include "xlnt_config.hpp" - namespace xlnt { class XLNT_CLASS fill diff --git a/include/xlnt/styles/font.hpp b/include/xlnt/styles/font.hpp index f6dbd483..9b6ba67a 100644 --- a/include/xlnt/styles/font.hpp +++ b/include/xlnt/styles/font.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,10 +25,9 @@ #include -#include +#include #include - -#include "xlnt_config.hpp" +#include namespace xlnt { diff --git a/include/xlnt/styles/named_style.hpp b/include/xlnt/styles/named_style.hpp index c108b67c..d1279645 100644 --- a/include/xlnt/styles/named_style.hpp +++ b/include/xlnt/styles/named_style.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,10 +23,9 @@ // @author: see AUTHORS file #pragma once +#include #include -#include "xlnt_config.hpp" - namespace xlnt { class XLNT_CLASS named_style diff --git a/include/xlnt/styles/number_format.hpp b/include/xlnt/styles/number_format.hpp index 8c8ea3cd..f86df863 100644 --- a/include/xlnt/styles/number_format.hpp +++ b/include/xlnt/styles/number_format.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -27,7 +27,7 @@ #include #include -#include "xlnt_config.hpp" +#include namespace xlnt { diff --git a/include/xlnt/styles/protection.hpp b/include/xlnt/styles/protection.hpp index 007b8d08..3d9826e5 100644 --- a/include/xlnt/styles/protection.hpp +++ b/include/xlnt/styles/protection.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,10 +25,9 @@ #include +#include #include -#include "xlnt_config.hpp" - namespace xlnt { class XLNT_CLASS protection diff --git a/include/xlnt/styles/side.hpp b/include/xlnt/styles/side.hpp index 63cd8ee7..f4a66757 100644 --- a/include/xlnt/styles/side.hpp +++ b/include/xlnt/styles/side.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,10 +25,9 @@ #include +#include #include -#include "xlnt_config.hpp" - namespace xlnt { enum class XLNT_CLASS border_style diff --git a/include/xlnt/styles/style.hpp b/include/xlnt/styles/style.hpp index f2e43868..64a90413 100644 --- a/include/xlnt/styles/style.hpp +++ b/include/xlnt/styles/style.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,6 +23,7 @@ // @author: see AUTHORS file #pragma once +#include #include #include #include @@ -30,8 +31,6 @@ #include #include -#include "xlnt_config.hpp" - namespace xlnt { class workbook; diff --git a/include/xlnt/utils/attribute_error.hpp b/include/xlnt/utils/attribute_error.hpp new file mode 100644 index 00000000..4d4877b6 --- /dev/null +++ b/include/xlnt/utils/attribute_error.hpp @@ -0,0 +1,41 @@ +// Copyright (c) 2014-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 + +namespace xlnt { + +/// +/// Error when an attribute value is invalid. +/// +class XLNT_CLASS attribute_error : public std::runtime_error +{ +public: + attribute_error(); +}; + +} // namespace xlnt diff --git a/include/xlnt/utils/calendar.hpp b/include/xlnt/utils/calendar.hpp new file mode 100644 index 00000000..a499b9a5 --- /dev/null +++ b/include/xlnt/utils/calendar.hpp @@ -0,0 +1,39 @@ +// Copyright (c) 2014-2015 Thomas Fussell +// +// 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 + +namespace xlnt { + +/// +/// An enumeration of possible base dates. +/// Dates in Excel are stored as days since this base date. +/// +enum class XLNT_CLASS calendar +{ + windows_1900, + mac_1904 +}; + +} // namespace xlnt diff --git a/include/xlnt/utils/cell_coordinates_exception.hpp b/include/xlnt/utils/cell_coordinates_exception.hpp new file mode 100644 index 00000000..9f362d76 --- /dev/null +++ b/include/xlnt/utils/cell_coordinates_exception.hpp @@ -0,0 +1,44 @@ +// Copyright (c) 2014-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 { + +/// +/// Error for converting between numeric and A1-style cell references. +/// +class XLNT_CLASS cell_coordinates_exception : public std::runtime_error +{ + public: + cell_coordinates_exception(column_t column, row_t row); + cell_coordinates_exception(const std::string &coord_string); +}; + +} // namespace xlnt diff --git a/include/xlnt/utils/column_string_index_exception.hpp b/include/xlnt/utils/column_string_index_exception.hpp new file mode 100644 index 00000000..90130309 --- /dev/null +++ b/include/xlnt/utils/column_string_index_exception.hpp @@ -0,0 +1,41 @@ +// Copyright (c) 2014-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 + +namespace xlnt { + +/// +/// Error for bad column names in A1-style cell references. +/// +class XLNT_CLASS column_string_index_exception : public std::runtime_error +{ + public: + column_string_index_exception(); +}; + +} // namespace xlnt diff --git a/include/xlnt/utils/data_type_exception.hpp b/include/xlnt/utils/data_type_exception.hpp new file mode 100644 index 00000000..418fa39e --- /dev/null +++ b/include/xlnt/utils/data_type_exception.hpp @@ -0,0 +1,41 @@ +// Copyright (c) 2014-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 + +namespace xlnt { + +/// +/// Error for any data type inconsistencies. +/// +class XLNT_CLASS data_type_exception : public std::runtime_error +{ +public: + data_type_exception(); +}; + +} // namespace xlnt diff --git a/include/xlnt/utils/date.hpp b/include/xlnt/utils/date.hpp new file mode 100644 index 00000000..9d90b28d --- /dev/null +++ b/include/xlnt/utils/date.hpp @@ -0,0 +1,69 @@ +// Copyright (c) 2014-2015 Thomas Fussell +// +// 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 + +namespace xlnt { + +/// +/// A date is a specific day specified in terms of a year, month, and day. +/// It can also be initialized as a number of days since a base date +/// using date::from_number. +/// +struct XLNT_CLASS date +{ + /// + /// Return the current date according to the system time. + /// + static date today(); + + /// + /// Return a date by adding days_since_base_year to base_date. + /// This includes leap years. + /// + static date from_number(int days_since_base_year, calendar base_date); + + date(int year_, int month_, int day_) : year(year_), month(month_), day(day_) + { + } + + /// + /// Return the number of days between this date and base_date. + /// + int to_number(calendar base_date) const; + + /// + /// Return true if this date is equal to comparand. + /// + bool operator==(const date &comparand) const; + + int year; + int month; + int day; +}; + +} // namespace xlnt diff --git a/include/xlnt/utils/datetime.hpp b/include/xlnt/utils/datetime.hpp index cb090fb1..e2248ba8 100644 --- a/include/xlnt/utils/datetime.hpp +++ b/include/xlnt/utils/datetime.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -24,91 +24,11 @@ #include -#include "xlnt_config.hpp" +#include +#include namespace xlnt { -/// -/// An enumeration of possible base dates. -/// Dates in Excel are stored as days since this base date. -/// -enum class XLNT_CLASS calendar -{ - windows_1900, - mac_1904 -}; - -/// -/// A date is a specific day specified in terms of a year, month, and day. -/// It can also be initialized as a number of days since a base date -/// using date::from_number. -/// -struct XLNT_CLASS date -{ - /// - /// Return the current date according to the system time. - /// - static date today(); - - /// - /// Return a date by adding days_since_base_year to base_date. - /// This includes leap years. - /// - static date from_number(int days_since_base_year, calendar base_date); - - date(int year_, int month_, int day_) : year(year_), month(month_), day(day_) - { - } - - /// - /// Return the number of days between this date and base_date. - /// - int to_number(calendar base_date) const; - - /// - /// Return true if this date is equal to comparand. - /// - bool operator==(const date &comparand) const; - - int year; - int month; - int day; -}; - -/// -/// A time is a specific time of the day specified in terms of an hour, -/// minute, second, and microsecond (0-999999). -/// It can also be initialized as a fraction of a day using time::from_number. -/// -struct XLNT_CLASS time -{ - /// - /// Return the current time according to the system time. - /// - static time now(); - - /// - /// Return a time from a number representing a fraction of a day. - /// The integer part of number will be ignored. - /// 0.5 would return time(12, 0, 0, 0) or noon, halfway through the day. - /// - static time from_number(long double number); - - explicit time(int hour_ = 0, int minute_ = 0, int second_ = 0, int microsecond_ = 0) - : hour(hour_), minute(minute_), second(second_), microsecond(microsecond_) - { - } - explicit time(const std::string &time_string); - - long double to_number() const; - bool operator==(const time &comparand) const; - - int hour; - int minute; - int second; - int microsecond; -}; - struct XLNT_CLASS datetime { /// @@ -156,26 +76,4 @@ struct XLNT_CLASS datetime int microsecond; }; -/// -/// Represents a span of time between two datetimes. This is -/// not fully supported yet. -/// -struct XLNT_CLASS timedelta -{ - static timedelta from_number(long double number); - - timedelta(int days_, int hours_, int minutes_ = 0, int seconds_ = 0, int microseconds_ = 0) - : days(days_), hours(hours_), minutes(minutes_), seconds(seconds_), microseconds(microseconds_) - { - } - - double to_number() const; - - int days; - int hours; - int minutes; - int seconds; - int microseconds; -}; - } // namespace xlnt diff --git a/include/xlnt/utils/exceptions.hpp b/include/xlnt/utils/exceptions.hpp index 6166291d..a790e0cc 100644 --- a/include/xlnt/utils/exceptions.hpp +++ b/include/xlnt/utils/exceptions.hpp @@ -1,4 +1,5 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-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 @@ -22,113 +23,14 @@ // @author: see AUTHORS file #pragma once -#include -#include - -#include - -#include "xlnt_config.hpp" - -namespace xlnt { - -/// -/// Error for converting between numeric and A1-style cell references. -/// -class XLNT_CLASS cell_coordinates_exception : public std::runtime_error -{ - public: - cell_coordinates_exception(column_t column, row_t row); - cell_coordinates_exception(const std::string &coord_string); -}; - -/// -/// The data submitted which cannot be used directly in Excel files. It -/// must be removed or escaped. -/// -class XLNT_CLASS illegal_character_error : public std::runtime_error -{ - public: - illegal_character_error(char c); -}; - -/// -/// Error for bad column names in A1-style cell references. -/// -class XLNT_CLASS column_string_index_exception : public std::runtime_error -{ - public: - column_string_index_exception(); -}; - -/// -/// Error for any data type inconsistencies. -/// -class XLNT_CLASS data_type_exception : public std::runtime_error -{ - public: - data_type_exception(); -}; - -/// -/// Error for badly formatted named ranges. -/// -class XLNT_CLASS named_range_exception : public std::runtime_error -{ - public: - named_range_exception(); -}; - -/// -/// Error for bad sheet names. -/// -class XLNT_CLASS sheet_title_exception : public std::runtime_error -{ - public: - sheet_title_exception(const std::string &title); -}; - -/// -/// Error for trying to open a non-ooxml file. -/// -class XLNT_CLASS invalid_file_exception : public std::runtime_error -{ - public: - invalid_file_exception(const std::string &filename); -}; - -/// -/// Error for trying to modify a read-only workbook. -/// -class XLNT_CLASS read_only_workbook_exception : public std::runtime_error -{ - public: - read_only_workbook_exception(); -}; - -/// -/// Error when a references number format is not in the stylesheet. -/// -class XLNT_CLASS missing_number_format : public std::runtime_error -{ - public: - missing_number_format(); -}; - -/// -/// Error when an attribute value is invalid. -/// -class XLNT_CLASS attribute_error : public std::runtime_error -{ - public: - attribute_error(); -}; - -class XLNT_CLASS value_error : public std::runtime_error -{ - public: - value_error() : std::runtime_error("") - { - } -}; - -} // namespace xlnt +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/include/xlnt/utils/hash_combine.hpp b/include/xlnt/utils/hash_combine.hpp index ce7579a7..e8ae0933 100644 --- a/include/xlnt/utils/hash_combine.hpp +++ b/include/xlnt/utils/hash_combine.hpp @@ -1,8 +1,36 @@ +// Copyright 2005-2014 Daniel James. +// Boost Software License - Version 1.0 - August 17th, 2003 +// +// Permission is hereby granted, free of charge, to any person or organization +// obtaining a copy of the software and accompanying documentation covered by +// this license (the "Software") to use, reproduce, display, distribute, +// execute, and transmit the Software, and to prepare derivative works of the +// Software, and to permit third-parties to whom the Software is furnished to +// do so, all subject to the following: +// +// The copyright notices in the Software and this entire statement, including +// the above license grant, this restriction and the following disclaimer, +// must be included in all copies of the Software, in whole or in part, and +// all derivative works of the Software, unless such copies or derivative +// works are solely in the form of machine-executable object code generated by +// a source language processor. +// +// 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT +// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// +// Based on Peter Dimov's proposal +// http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf +// issue 6.18. #pragma once #include -#include "xlnt_config.hpp" +#include namespace xlnt { diff --git a/include/xlnt/utils/illegal_character_error.hpp b/include/xlnt/utils/illegal_character_error.hpp new file mode 100644 index 00000000..61c2dd2e --- /dev/null +++ b/include/xlnt/utils/illegal_character_error.hpp @@ -0,0 +1,42 @@ +// Copyright (c) 2014-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 + +namespace xlnt { + +/// +/// The data submitted which cannot be used directly in Excel files. It +/// must be removed or escaped. +/// +class XLNT_CLASS illegal_character_error : public std::runtime_error +{ +public: + illegal_character_error(char c); +}; + +} // namespace xlnt diff --git a/include/xlnt/utils/invalid_file_exception.hpp b/include/xlnt/utils/invalid_file_exception.hpp new file mode 100644 index 00000000..458fe4a1 --- /dev/null +++ b/include/xlnt/utils/invalid_file_exception.hpp @@ -0,0 +1,42 @@ +// Copyright (c) 2014-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 + +namespace xlnt { + +/// +/// Error for trying to open a non-ooxml file. +/// +class XLNT_CLASS invalid_file_exception : public std::runtime_error +{ + public: + invalid_file_exception(const std::string &filename); +}; + +} // namespace xlnt diff --git a/include/xlnt/utils/missing_number_format.hpp b/include/xlnt/utils/missing_number_format.hpp new file mode 100644 index 00000000..fa043f3a --- /dev/null +++ b/include/xlnt/utils/missing_number_format.hpp @@ -0,0 +1,41 @@ +// Copyright (c) 2014-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 + +namespace xlnt { + +/// +/// Error when a references number format is not in the stylesheet. +/// +class XLNT_CLASS missing_number_format : public std::runtime_error +{ +public: + missing_number_format(); +}; + +} // namespace xlnt diff --git a/include/xlnt/utils/named_range_exception.hpp b/include/xlnt/utils/named_range_exception.hpp new file mode 100644 index 00000000..8417844f --- /dev/null +++ b/include/xlnt/utils/named_range_exception.hpp @@ -0,0 +1,41 @@ +// Copyright (c) 2014-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 + +namespace xlnt { + +/// +/// Error for badly formatted named ranges. +/// +class XLNT_CLASS named_range_exception : public std::runtime_error +{ + public: + named_range_exception(); +}; + +} // namespace xlnt diff --git a/include/xlnt/utils/read_only_workbook_exception.hpp b/include/xlnt/utils/read_only_workbook_exception.hpp new file mode 100644 index 00000000..4aaf0f60 --- /dev/null +++ b/include/xlnt/utils/read_only_workbook_exception.hpp @@ -0,0 +1,41 @@ +// Copyright (c) 2014-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 + +namespace xlnt { + +/// +/// Error for trying to modify a read-only workbook. +/// +class XLNT_CLASS read_only_workbook_exception : public std::runtime_error +{ + public: + read_only_workbook_exception(); +}; + +} // namespace xlnt diff --git a/include/xlnt/utils/sheet_title_exception.hpp b/include/xlnt/utils/sheet_title_exception.hpp new file mode 100644 index 00000000..498d2701 --- /dev/null +++ b/include/xlnt/utils/sheet_title_exception.hpp @@ -0,0 +1,42 @@ +// Copyright (c) 2014-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 + +namespace xlnt { + +/// +/// Error for bad sheet names. +/// +class XLNT_CLASS sheet_title_exception : public std::runtime_error +{ + public: + sheet_title_exception(const std::string &title); +}; + +} // namespace xlnt diff --git a/include/xlnt/utils/time.hpp b/include/xlnt/utils/time.hpp new file mode 100644 index 00000000..5e130602 --- /dev/null +++ b/include/xlnt/utils/time.hpp @@ -0,0 +1,65 @@ +// Copyright (c) 2014-2015 Thomas Fussell +// +// 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 + +namespace xlnt { + +/// +/// A time is a specific time of the day specified in terms of an hour, +/// minute, second, and microsecond (0-999999). +/// It can also be initialized as a fraction of a day using time::from_number. +/// +struct XLNT_CLASS time +{ + /// + /// Return the current time according to the system time. + /// + static time now(); + + /// + /// Return a time from a number representing a fraction of a day. + /// The integer part of number will be ignored. + /// 0.5 would return time(12, 0, 0, 0) or noon, halfway through the day. + /// + static time from_number(long double number); + + explicit time(int hour_ = 0, int minute_ = 0, int second_ = 0, int microsecond_ = 0) + : hour(hour_), minute(minute_), second(second_), microsecond(microsecond_) + { + } + explicit time(const std::string &time_string); + + long double to_number() const; + bool operator==(const time &comparand) const; + + int hour; + int minute; + int second; + int microsecond; +}; + +} // namespace xlnt diff --git a/include/xlnt/utils/timedelta.hpp b/include/xlnt/utils/timedelta.hpp new file mode 100644 index 00000000..79462084 --- /dev/null +++ b/include/xlnt/utils/timedelta.hpp @@ -0,0 +1,53 @@ +// Copyright (c) 2014-2015 Thomas Fussell +// +// 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 + +namespace xlnt { + +/// +/// Represents a span of time between two datetimes. This is +/// not fully supported yet. +/// +struct XLNT_CLASS timedelta +{ + static timedelta from_number(long double number); + + timedelta(int days_, int hours_, int minutes_ = 0, int seconds_ = 0, int microseconds_ = 0) + : days(days_), hours(hours_), minutes(minutes_), seconds(seconds_), microseconds(microseconds_) + { + } + + double to_number() const; + + int days; + int hours; + int minutes; + int seconds; + int microseconds; +}; + +} // namespace xlnt diff --git a/include/xlnt/utils/value_error.hpp b/include/xlnt/utils/value_error.hpp new file mode 100644 index 00000000..17e97228 --- /dev/null +++ b/include/xlnt/utils/value_error.hpp @@ -0,0 +1,39 @@ +// Copyright (c) 2014-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 + +namespace xlnt { + +class XLNT_CLASS value_error : public std::runtime_error +{ +public: + value_error(); +}; + +} // namespace xlnt diff --git a/include/xlnt/workbook/document_security.hpp b/include/xlnt/workbook/document_security.hpp index c668367c..0293b476 100644 --- a/include/xlnt/workbook/document_security.hpp +++ b/include/xlnt/workbook/document_security.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,7 +25,7 @@ #include -#include "xlnt_config.hpp" +#include namespace xlnt { @@ -40,6 +40,7 @@ class XLNT_CLASS document_security bool lock_revision; bool lock_structure; bool lock_windows; + std::string revision_password; std::string workbook_password; }; diff --git a/include/xlnt/workbook/external_book.hpp b/include/xlnt/workbook/external_book.hpp index f0d4e20e..e5ea3017 100644 --- a/include/xlnt/workbook/external_book.hpp +++ b/include/xlnt/workbook/external_book.hpp @@ -1,6 +1,29 @@ +// Copyright (c) 2014-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 "xlnt_config.hpp" +#include namespace xlnt { @@ -8,4 +31,4 @@ class XLNT_CLASS external_book { }; -} +} // namespace xlnt diff --git a/include/xlnt/workbook/named_range.hpp b/include/xlnt/workbook/named_range.hpp index 18e8d067..023915f3 100644 --- a/include/xlnt/workbook/named_range.hpp +++ b/include/xlnt/workbook/named_range.hpp @@ -1,9 +1,32 @@ +// Copyright (c) 2014-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 "xlnt_config.hpp" +#include namespace xlnt { @@ -36,4 +59,5 @@ class XLNT_CLASS named_range std::string name_; std::vector targets_; }; -} + +} // namespace xlnt diff --git a/include/xlnt/workbook/theme.hpp b/include/xlnt/workbook/theme.hpp index 4fd5dbad..5c6885e5 100644 --- a/include/xlnt/workbook/theme.hpp +++ b/include/xlnt/workbook/theme.hpp @@ -1,6 +1,28 @@ +// Copyright (c) 2014-2015 Thomas Fussell +// +// 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 "xlnt_config.hpp" +#include namespace xlnt { diff --git a/include/xlnt/workbook/workbook.hpp b/include/xlnt/workbook/workbook.hpp index 5c31847f..81f561df 100644 --- a/include/xlnt/workbook/workbook.hpp +++ b/include/xlnt/workbook/workbook.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -29,10 +29,9 @@ #include #include +#include #include -#include "xlnt_config.hpp" - namespace xlnt { class alignment; diff --git a/include/xlnt/worksheet/cell_vector.hpp b/include/xlnt/worksheet/cell_vector.hpp index 03e20282..3cad0559 100644 --- a/include/xlnt/worksheet/cell_vector.hpp +++ b/include/xlnt/worksheet/cell_vector.hpp @@ -1,14 +1,35 @@ +// Copyright (c) 2014-2015 Thomas Fussell +// +// 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 #include +#include #include -#include "xlnt_config.hpp" - namespace xlnt { class cell; @@ -117,24 +138,15 @@ class XLNT_CLASS cell_vector const cell get_cell(std::size_t column_index) const; - std::size_t length() const - { - return num_cells(); - } + std::size_t length() const; iterator begin(); iterator end(); - const_iterator begin() const - { - return cbegin(); - } - const_iterator end() const - { - return cend(); - } - + const_iterator begin() const; const_iterator cbegin() const; + + const_iterator end() const; const_iterator cend() const; private: diff --git a/include/xlnt/worksheet/column_properties.hpp b/include/xlnt/worksheet/column_properties.hpp index 70cc1fee..d5b09b0c 100644 --- a/include/xlnt/worksheet/column_properties.hpp +++ b/include/xlnt/worksheet/column_properties.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ // @author: see AUTHORS file #pragma once -#include "xlnt_config.hpp" +#include namespace xlnt { diff --git a/include/xlnt/worksheet/footer.hpp b/include/xlnt/worksheet/footer.hpp new file mode 100644 index 00000000..90b67ca3 --- /dev/null +++ b/include/xlnt/worksheet/footer.hpp @@ -0,0 +1,50 @@ +#pragma once + +#include +#include + +#include + +namespace xlnt { + +/// +/// Worksheet footer +/// +class XLNT_CLASS footer +{ + public: + footer(); + void set_text(const std::string &text) + { + default_ = false; + text_ = text; + } + void set_font_name(const std::string &font_name) + { + default_ = false; + font_name_ = font_name; + } + void set_font_size(std::size_t font_size) + { + default_ = false; + font_size_ = font_size; + } + void set_font_color(const std::string &font_color) + { + default_ = false; + font_color_ = font_color; + } + bool is_default() const + { + return default_; + } + + private: + bool default_; + std::string text_; + std::string font_name_; + std::size_t font_size_; + std::string font_color_; +}; + +} // namespace xlnt diff --git a/include/xlnt/worksheet/header.hpp b/include/xlnt/worksheet/header.hpp new file mode 100644 index 00000000..60c3246e --- /dev/null +++ b/include/xlnt/worksheet/header.hpp @@ -0,0 +1,50 @@ +#pragma once + +#include +#include + +#include + +namespace xlnt { + +/// +/// Worksheet header +/// +class XLNT_CLASS header +{ + public: + header(); + void set_text(const std::string &text) + { + default_ = false; + text_ = text; + } + void set_font_name(const std::string &font_name) + { + default_ = false; + font_name_ = font_name; + } + void set_font_size(std::size_t font_size) + { + default_ = false; + font_size_ = font_size; + } + void set_font_color(const std::string &font_color) + { + default_ = false; + font_color_ = font_color; + } + bool is_default() const + { + return default_; + } + + private: + bool default_; + std::string text_; + std::string font_name_; + std::size_t font_size_; + std::string font_color_; +}; + +} // namespace xlnt diff --git a/include/xlnt/worksheet/header_footer.hpp b/include/xlnt/worksheet/header_footer.hpp new file mode 100644 index 00000000..c5b031fe --- /dev/null +++ b/include/xlnt/worksheet/header_footer.hpp @@ -0,0 +1,63 @@ +#pragma once + +#include +#include + +#include +#include +#include + +namespace xlnt { + +/// +/// Worksheet header and footer +/// +class XLNT_CLASS header_footer +{ + public: + header_footer(); + + header &get_left_header() + { + return left_header_; + } + header &get_center_header() + { + return center_header_; + } + header &get_right_header() + { + return right_header_; + } + footer &get_left_footer() + { + return left_footer_; + } + footer &get_center_footer() + { + return center_footer_; + } + footer &get_right_footer() + { + return right_footer_; + } + + bool is_default_header() const + { + return left_header_.is_default() && center_header_.is_default() && right_header_.is_default(); + } + bool is_default_footer() const + { + return left_footer_.is_default() && center_footer_.is_default() && right_footer_.is_default(); + } + bool is_default() const + { + return is_default_header() && is_default_footer(); + } + + private: + header left_header_, right_header_, center_header_; + footer left_footer_, right_footer_, center_footer_; +}; + +} // namespace xlnt diff --git a/include/xlnt/worksheet/major_order.hpp b/include/xlnt/worksheet/major_order.hpp index 8eaf04fa..745b2e13 100644 --- a/include/xlnt/worksheet/major_order.hpp +++ b/include/xlnt/worksheet/major_order.hpp @@ -1,6 +1,28 @@ +// Copyright (c) 2014-2015 Thomas Fussell +// +// 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 "xlnt_config.hpp" +#include namespace xlnt { diff --git a/include/xlnt/worksheet/orientation.hpp b/include/xlnt/worksheet/orientation.hpp new file mode 100644 index 00000000..9c26600d --- /dev/null +++ b/include/xlnt/worksheet/orientation.hpp @@ -0,0 +1,36 @@ +// Copyright (c) 2014-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 + +namespace xlnt { + +enum class XLNT_CLASS orientation +{ + portrait, + landscape +}; + +} // namepsace xlnt diff --git a/include/xlnt/worksheet/page_break.hpp b/include/xlnt/worksheet/page_break.hpp new file mode 100644 index 00000000..8283df70 --- /dev/null +++ b/include/xlnt/worksheet/page_break.hpp @@ -0,0 +1,37 @@ +// Copyright (c) 2014-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 + +namespace xlnt { + +enum class XLNT_CLASS page_break +{ + none = 0, + row = 1, + column = 2 +}; + +} // namepsace xlnt diff --git a/include/xlnt/worksheet/page_margins.hpp b/include/xlnt/worksheet/page_margins.hpp index f4277180..5a9243db 100644 --- a/include/xlnt/worksheet/page_margins.hpp +++ b/include/xlnt/worksheet/page_margins.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,75 +23,34 @@ // @author: see AUTHORS file #pragma once -#include "xlnt_config.hpp" +#include namespace xlnt { class XLNT_CLASS page_margins { public: - page_margins() : default_(true), top_(0), left_(0), bottom_(0), right_(0), header_(0), footer_(0) - { - } + page_margins(); - bool is_default() const - { - return default_; - } - double get_top() const - { - return top_; - } - void set_top(double top) - { - default_ = false; - top_ = top; - } - double get_left() const - { - return left_; - } - void set_left(double left) - { - default_ = false; - left_ = left; - } - double get_bottom() const - { - return bottom_; - } - void set_bottom(double bottom) - { - default_ = false; - bottom_ = bottom; - } - double get_right() const - { - return right_; - } - void set_right(double right) - { - default_ = false; - right_ = right; - } - double get_header() const - { - return header_; - } - void set_header(double header) - { - default_ = false; - header_ = header; - } - double get_footer() const - { - return footer_; - } - void set_footer(double footer) - { - default_ = false; - footer_ = footer; - } + bool is_default() const; + + double get_top() const; + void set_top(double top); + + double get_left() const; + void set_left(double left); + + double get_bottom() const; + void set_bottom(double bottom); + + double get_right() const; + void set_right(double right); + + double get_header() const; + void set_header(double header); + + double get_footer() const; + void set_footer(double footer); private: bool default_; diff --git a/include/xlnt/worksheet/page_setup.hpp b/include/xlnt/worksheet/page_setup.hpp index cc80b986..edeeb0b5 100644 --- a/include/xlnt/worksheet/page_setup.hpp +++ b/include/xlnt/worksheet/page_setup.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,155 +23,60 @@ // @author: see AUTHORS file #pragma once -#include "xlnt_config.hpp" +#include +#include +#include +#include +#include namespace xlnt { struct XLNT_CLASS page_setup { - enum class page_break - { - none = 0, - row = 1, - column = 2 - }; - - enum class sheet_state - { - visible, - hidden, - very_hidden - }; - - enum class paper_size - { - letter = 1, - letter_small = 2, - tabloid = 3, - ledger = 4, - legal = 5, - statement = 6, - executive = 7, - a3 = 8, - a4 = 9, - a4_small = 10, - a5 = 11 - }; - - enum class orientation - { - portrait, - landscape - }; - public: - page_setup() - : default_(true), - break_(page_break::none), - sheet_state_(sheet_state::visible), - paper_size_(paper_size::letter), - orientation_(orientation::portrait), - fit_to_page_(false), - fit_to_height_(false), - fit_to_width_(false), - horizontal_centered_(false), - vertical_centered_(false), - scale_(1) - { - } - bool is_default() const - { - return default_; - } - page_break get_break() const - { - return break_; - } - void set_break(page_break b) - { - default_ = false; - break_ = b; - } - sheet_state get_sheet_state() const - { - return sheet_state_; - } - void set_sheet_state(sheet_state sheet_state) - { - sheet_state_ = sheet_state; - } - paper_size get_paper_size() const - { - return paper_size_; - } - void set_paper_size(paper_size paper_size) - { - default_ = false; - paper_size_ = paper_size; - } - orientation get_orientation() const - { - return orientation_; - } - void set_orientation(orientation orientation) - { - default_ = false; - orientation_ = orientation; - } - bool fit_to_page() const - { - return fit_to_page_; - } - void set_fit_to_page(bool fit_to_page) - { - default_ = false; - fit_to_page_ = fit_to_page; - } - bool fit_to_height() const - { - return fit_to_height_; - } - void set_fit_to_height(bool fit_to_height) - { - default_ = false; - fit_to_height_ = fit_to_height; - } - bool fit_to_width() const - { - return fit_to_width_; - } - void set_fit_to_width(bool fit_to_width) - { - default_ = false; - fit_to_width_ = fit_to_width; - } - void set_horizontal_centered(bool horizontal_centered) - { - default_ = false; - horizontal_centered_ = horizontal_centered; - } - bool get_horizontal_centered() const - { - return horizontal_centered_; - } - void set_vertical_centered(bool vertical_centered) - { - default_ = false; - vertical_centered_ = vertical_centered; - } - bool get_vertical_centered() const - { - return vertical_centered_; - } - void set_scale(double scale) - { - default_ = false; - scale_ = scale; - } - double get_scale() const - { - return scale_; - } + page_setup(); + + bool is_default() const; + + page_break get_break() const; + + void set_break(page_break b); + + sheet_state get_sheet_state() const; + + void set_sheet_state(sheet_state sheet_state); + + paper_size get_paper_size() const; + + void set_paper_size(paper_size paper_size); + + orientation get_orientation() const; + + void set_orientation(orientation orientation); + + bool fit_to_page() const; + + void set_fit_to_page(bool fit_to_page); + + bool fit_to_height() const; + + void set_fit_to_height(bool fit_to_height); + + bool fit_to_width() const; + + void set_fit_to_width(bool fit_to_width); + + void set_horizontal_centered(bool horizontal_centered); + + bool get_horizontal_centered() const; + + void set_vertical_centered(bool vertical_centered); + + bool get_vertical_centered() const; + + void set_scale(double scale); + + double get_scale() const; private: bool default_; diff --git a/include/xlnt/worksheet/pane.hpp b/include/xlnt/worksheet/pane.hpp index 544b5e1c..5bd705f1 100644 --- a/include/xlnt/worksheet/pane.hpp +++ b/include/xlnt/worksheet/pane.hpp @@ -1,4 +1,5 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-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 @@ -22,7 +23,7 @@ // @author: see AUTHORS file #pragma once -#include "xlnt_config.hpp" +#include namespace xlnt { diff --git a/include/xlnt/worksheet/paper_size.hpp b/include/xlnt/worksheet/paper_size.hpp new file mode 100644 index 00000000..448761ca --- /dev/null +++ b/include/xlnt/worksheet/paper_size.hpp @@ -0,0 +1,45 @@ +// Copyright (c) 2014-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 + +namespace xlnt { + +enum class XLNT_CLASS paper_size +{ + letter = 1, + letter_small = 2, + tabloid = 3, + ledger = 4, + legal = 5, + statement = 6, + executive = 7, + a3 = 8, + a4 = 9, + a4_small = 10, + a5 = 11 +}; + +} // namepsace xlnt diff --git a/include/xlnt/worksheet/range.hpp b/include/xlnt/worksheet/range.hpp index b3578754..e1b06c08 100644 --- a/include/xlnt/worksheet/range.hpp +++ b/include/xlnt/worksheet/range.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -27,13 +27,12 @@ #include #include +#include #include #include #include #include -#include "xlnt_config.hpp" - namespace xlnt { class XLNT_CLASS range diff --git a/include/xlnt/worksheet/range_reference.hpp b/include/xlnt/worksheet/range_reference.hpp index cf92ecb4..39cde98e 100644 --- a/include/xlnt/worksheet/range_reference.hpp +++ b/include/xlnt/worksheet/range_reference.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -22,10 +22,9 @@ // @author: see AUTHORS file #pragma once +#include #include -#include "xlnt_config.hpp" - namespace xlnt { class XLNT_CLASS range_reference diff --git a/include/xlnt/worksheet/row_properties.hpp b/include/xlnt/worksheet/row_properties.hpp index 619526f3..e940a1ad 100644 --- a/include/xlnt/worksheet/row_properties.hpp +++ b/include/xlnt/worksheet/row_properties.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ // @author: see AUTHORS file #pragma once -#include "xlnt_config.hpp" +#include namespace xlnt { diff --git a/include/xlnt/worksheet/selection.hpp b/include/xlnt/worksheet/selection.hpp index 736dc943..b567360d 100644 --- a/include/xlnt/worksheet/selection.hpp +++ b/include/xlnt/worksheet/selection.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -22,7 +22,7 @@ // @author: see AUTHORS file #pragma once -#include "xlnt_config.hpp" +#include namespace xlnt { diff --git a/include/xlnt/worksheet/sheet_protection.hpp b/include/xlnt/worksheet/sheet_protection.hpp index 3ea0b073..552c0165 100644 --- a/include/xlnt/worksheet/sheet_protection.hpp +++ b/include/xlnt/worksheet/sheet_protection.hpp @@ -1,8 +1,31 @@ +// Copyright (c) 2014-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 "xlnt_config.hpp" +#include namespace xlnt { diff --git a/include/xlnt/worksheet/sheet_state.hpp b/include/xlnt/worksheet/sheet_state.hpp new file mode 100644 index 00000000..423ea03e --- /dev/null +++ b/include/xlnt/worksheet/sheet_state.hpp @@ -0,0 +1,37 @@ +// Copyright (c) 2014-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 + +namespace xlnt { + +enum class XLNT_CLASS sheet_state +{ + visible, + hidden, + very_hidden +}; + +} // namepsace xlnt diff --git a/include/xlnt/worksheet/sheet_view.hpp b/include/xlnt/worksheet/sheet_view.hpp index a17d2b7a..c4577bc5 100644 --- a/include/xlnt/worksheet/sheet_view.hpp +++ b/include/xlnt/worksheet/sheet_view.hpp @@ -1,4 +1,5 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-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 @@ -22,7 +23,7 @@ // @author: see AUTHORS file #pragma once -#include "xlnt_config.hpp" +#include namespace xlnt { diff --git a/include/xlnt/worksheet/worksheet.hpp b/include/xlnt/worksheet/worksheet.hpp index c0cfae3e..17ff223d 100644 --- a/include/xlnt/worksheet/worksheet.hpp +++ b/include/xlnt/worksheet/worksheet.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -29,12 +29,13 @@ #include #include +#include #include #include +#include +#include #include -#include "xlnt_config.hpp" - namespace xlnt { class cell; @@ -51,216 +52,6 @@ struct date; namespace detail { struct worksheet_impl; } -/// -/// Worksheet header -/// -class XLNT_CLASS header -{ - public: - header(); - void set_text(const std::string &text) - { - default_ = false; - text_ = text; - } - void set_font_name(const std::string &font_name) - { - default_ = false; - font_name_ = font_name; - } - void set_font_size(std::size_t font_size) - { - default_ = false; - font_size_ = font_size; - } - void set_font_color(const std::string &font_color) - { - default_ = false; - font_color_ = font_color; - } - bool is_default() const - { - return default_; - } - - private: - bool default_; - std::string text_; - std::string font_name_; - std::size_t font_size_; - std::string font_color_; -}; - -/// -/// Worksheet footer -/// -class XLNT_CLASS footer -{ - public: - footer(); - void set_text(const std::string &text) - { - default_ = false; - text_ = text; - } - void set_font_name(const std::string &font_name) - { - default_ = false; - font_name_ = font_name; - } - void set_font_size(std::size_t font_size) - { - default_ = false; - font_size_ = font_size; - } - void set_font_color(const std::string &font_color) - { - default_ = false; - font_color_ = font_color; - } - bool is_default() const - { - return default_; - } - - private: - bool default_; - std::string text_; - std::string font_name_; - std::size_t font_size_; - std::string font_color_; -}; - -/// -/// Worksheet header and footer -/// -class XLNT_CLASS header_footer -{ - public: - header_footer(); - - header &get_left_header() - { - return left_header_; - } - header &get_center_header() - { - return center_header_; - } - header &get_right_header() - { - return right_header_; - } - footer &get_left_footer() - { - return left_footer_; - } - footer &get_center_footer() - { - return center_footer_; - } - footer &get_right_footer() - { - return right_footer_; - } - - bool is_default_header() const - { - return left_header_.is_default() && center_header_.is_default() && right_header_.is_default(); - } - bool is_default_footer() const - { - return left_footer_.is_default() && center_footer_.is_default() && right_footer_.is_default(); - } - bool is_default() const - { - return is_default_header() && is_default_footer(); - } - - private: - header left_header_, right_header_, center_header_; - footer left_footer_, right_footer_, center_footer_; -}; - -/// -/// Worksheet margins -/// -struct XLNT_CLASS margins -{ - public: - margins() : default_(true), top_(0), left_(0), bottom_(0), right_(0), header_(0), footer_(0) - { - } - - bool is_default() const - { - return default_; - } - double get_top() const - { - return top_; - } - void set_top(double top) - { - default_ = false; - top_ = top; - } - double get_left() const - { - return left_; - } - void set_left(double left) - { - default_ = false; - left_ = left; - } - double get_bottom() const - { - return bottom_; - } - void set_bottom(double bottom) - { - default_ = false; - bottom_ = bottom; - } - double get_right() const - { - return right_; - } - void set_right(double right) - { - default_ = false; - right_ = right; - } - double get_header() const - { - return header_; - } - void set_header(double header) - { - default_ = false; - header_ = header; - } - double get_footer() const - { - return footer_; - } - void set_footer(double footer) - { - default_ = false; - footer_ = footer; - } - - private: - bool default_; - double top_; - double left_; - double bottom_; - double right_; - double header_; - double footer_; -}; - /// /// A worksheet is a 2D array of cells. /// @@ -380,8 +171,8 @@ class XLNT_CLASS worksheet // page page_setup &get_page_setup(); const page_setup &get_page_setup() const; - margins &get_page_margins(); - const margins &get_page_margins() const; + page_margins &get_page_margins(); + const page_margins &get_page_margins() const; // auto filter range_reference get_auto_filter() const; @@ -405,7 +196,7 @@ class XLNT_CLASS worksheet std::vector get_formula_attributes() const; - void set_sheet_state(page_setup::sheet_state state); + void set_sheet_state(sheet_state state); private: friend class workbook; diff --git a/include/xlnt/worksheet/worksheet_properties.hpp b/include/xlnt/worksheet/worksheet_properties.hpp index bca58299..c54b2108 100644 --- a/include/xlnt/worksheet/worksheet_properties.hpp +++ b/include/xlnt/worksheet/worksheet_properties.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // Copyright (c) 2010-2015 openpyxl // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -23,7 +23,7 @@ // @author: see AUTHORS file #pragma once -#include "xlnt_config.hpp" +#include namespace xlnt { diff --git a/include/xlnt/xlnt.hpp b/include/xlnt/xlnt.hpp index 2f990c3c..d8b72340 100644 --- a/include/xlnt/xlnt.hpp +++ b/include/xlnt/xlnt.hpp @@ -1,5 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell -// Copyright (c) 2010-2015 openpyxl +// Copyright (c) 2014-2015 Thomas Fussell // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal @@ -23,10 +22,7 @@ // @author: see AUTHORS file #pragma once -#include - -#include "xlnt_config.hpp" - +#include #include #include #include diff --git a/include/xlnt/xlnt_config.hpp b/include/xlnt/xlnt_config.hpp index ee53f807..aa4869a0 100644 --- a/include/xlnt/xlnt_config.hpp +++ b/include/xlnt/xlnt_config.hpp @@ -1,4 +1,4 @@ -// Copyright (c) 2015 Thomas Fussell +// Copyright (c) 2014-2015 Thomas Fussell // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..998b6e76 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +miniz>=1.15_r4 +pugixml>=1.6 +cxxtest>=4.4 \ No newline at end of file diff --git a/source/cell/cell.cpp b/source/cell/cell.cpp index 703854ff..0bc4421e 100644 --- a/source/cell/cell.cpp +++ b/source/cell/cell.cpp @@ -8,7 +8,10 @@ #include #include #include +#include #include +#include +#include #include #include #include @@ -1478,4 +1481,9 @@ calendar cell::get_base_date() const return get_parent().get_parent().get_properties().excel_base_date; } +std::ostream &operator<<(std::ostream &stream, const xlnt::cell &cell) +{ + return stream << cell.to_string(); +} + } // namespace xlnt diff --git a/source/cell/cell_reference.cpp b/source/cell/cell_reference.cpp index b59a91ad..48fa2d99 100644 --- a/source/cell/cell_reference.cpp +++ b/source/cell/cell_reference.cpp @@ -158,6 +158,81 @@ std::pair cell_reference::split_reference(const std::string return { column_string, std::stoi(row_string) }; } +bool cell_reference::column_absolute() const +{ + return absolute_column_; +} + +void cell_reference::column_absolute(bool absolute_column) +{ + absolute_column_ = absolute_column; +} + +bool cell_reference::row_absolute() const +{ + return absolute_row_; +} + +void cell_reference::row_absolute(bool absolute_row) +{ + absolute_row_ = absolute_row; +} + +column_t cell_reference::get_column() const +{ + return column_; +} + +void cell_reference::set_column(const std::string &column_string) +{ + column_ = column_t(column_string); +} + +column_t cell_reference::get_column_index() const +{ + return column_; +} + +void cell_reference::set_column_index(column_t column) +{ + column_ = column; +} + +row_t cell_reference::get_row() const +{ + return row_; +} + +void cell_reference::set_row(row_t row) +{ + row_ = row; +} + +bool cell_reference::operator==(const std::string &reference_string) const +{ + return *this == cell_reference(reference_string); +} + +bool cell_reference::operator==(const char *reference_string) const +{ + return *this == std::string(reference_string); +} + +bool cell_reference::operator!=(const cell_reference &comparand) const +{ + return !(*this == comparand); +} + +bool cell_reference::operator!=(const std::string &reference_string) const +{ + return *this != cell_reference(reference_string); +} + +bool cell_reference::operator!=(const char *reference_string) const +{ + return *this != std::string(reference_string); +} + cell_reference cell_reference::make_offset(int column_offset, int row_offset) const { //TODO: check for overflow/underflow diff --git a/source/cell/tests/test_cell.hpp b/source/cell/tests/test_cell.hpp index 46f46ba0..0dd0655b 100644 --- a/source/cell/tests/test_cell.hpp +++ b/source/cell/tests/test_cell.hpp @@ -13,7 +13,10 @@ #include #include #include +#include #include +#include +#include #include #include #include diff --git a/source/cell/types.cpp b/source/cell/types.cpp index 4e211839..c5d0af5f 100644 --- a/source/cell/types.cpp +++ b/source/cell/types.cpp @@ -68,6 +68,246 @@ std::string column_t::column_string_from_index(column_t::index_t column_index) return column_letter; } + +/// +/// Default column_t is the first (left-most) column. +/// +column_t::column_t() : index(1) {} + +/// +/// Construct a column from a number. +/// +column_t::column_t(index_t column_index) : index(column_index) {} + +/// +/// Construct a column from a string. +/// +column_t::column_t(const std::string &column_string) : index(column_index_from_string(column_string)) {} + +/// +/// Construct a column from a string. +/// +column_t::column_t(const char *column_string) : column_t(std::string(column_string)) {} + +/// +/// Copy constructor +/// +column_t::column_t(const column_t &other) : column_t(other.index) {} + +/// +/// Move constructor +/// +column_t::column_t(column_t &&other) { swap(*this, other); } + +/// +/// Return a string representation of this column index. +/// +std::string column_t::column_string() const { return column_string_from_index(index); } + +/// +/// Set this column to be the same as rhs's and return reference to self. +/// +column_t &column_t::operator=(column_t rhs) { swap(*this, rhs); return *this; } + +/// +/// Set this column to be equal to rhs and return reference to self. +/// +column_t &column_t::operator=(const std::string &rhs) { return *this = column_t(rhs); } + +/// +/// Set this column to be equal to rhs and return reference to self. +/// +column_t &column_t::operator=(const char *rhs) { return *this = column_t(rhs); } + +/// +/// Return true if this column refers to the same column as other. +/// +bool column_t::operator==(const column_t &other) const { return index == other.index; } + +/// +/// Return true if this column doesn't refer to the same column as other. +/// +bool column_t::operator!=(const column_t &other) const { return !(*this == other); } + +/// +/// Return true if this column refers to the same column as other. +/// +bool column_t::operator==(int other) const { return *this == column_t(other); } + +/// +/// Return true if this column refers to the same column as other. +/// +bool column_t::operator==(index_t other) const { return *this == column_t(other); } + +/// +/// Return true if this column refers to the same column as other. +/// +bool column_t::operator==(const std::string &other) const { return *this == column_t(other); } + +/// +/// Return true if this column refers to the same column as other. +/// +bool column_t::operator==(const char *other) const { return *this == column_t(other); } + +/// +/// Return true if this column doesn't refer to the same column as other. +/// +bool column_t::operator!=(int other) const { return !(*this == other); } + +/// +/// Return true if this column doesn't refer to the same column as other. +/// +bool column_t::operator!=(index_t other) const { return !(*this == other); } + +/// +/// Return true if this column doesn't refer to the same column as other. +/// +bool column_t::operator!=(const std::string &other) const { return !(*this == other); } + +/// +/// Return true if this column doesn't refer to the same column as other. +/// +bool column_t::operator!=(const char *other) const { return !(*this == other); } + +/// +/// Return true if other is to the right of this column. +/// +bool column_t::operator>(const column_t &other) const { return index > other.index; } + +/// +/// Return true if other is to the right of or equal to this column. +/// +bool column_t::operator>=(const column_t &other) const { return index >= other.index; } + +/// +/// Return true if other is to the left of this column. +/// +bool column_t::operator<(const column_t &other) const { return index < other.index; } + +/// +/// Return true if other is to the left of or equal to this column. +/// +bool column_t::operator<=(const column_t &other) const { return index <= other.index; } + +/// +/// Return true if other is to the right of this column. +/// +bool column_t::operator>(const column_t::index_t &other) const { return index > other; } + +/// +/// Return true if other is to the right of or equal to this column. +/// +bool column_t::operator>=(const column_t::index_t &other) const { return index >= other; } + +/// +/// Return true if other is to the left of this column. +/// +bool column_t::operator<(const column_t::index_t &other) const { return index < other; } + +/// +/// Return true if other is to the left of or equal to this column. +/// +bool column_t::operator<=(const column_t::index_t &other) const { return index <= other; } + +/// +/// Pre-increment this column, making it point to the column one to the right. +/// +column_t &column_t::operator++() { index++; return *this; } + +/// +/// Pre-deccrement this column, making it point to the column one to the left. +/// +column_t &column_t::operator--() { index--; return *this; } + +/// +/// Post-increment this column, making it point to the column one to the right and returning the old column. +/// +column_t column_t::operator++(int) { column_t copy(index); ++(*this); return copy; } + +/// +/// Post-decrement this column, making it point to the column one to the left and returning the old column. +/// +column_t column_t::operator--(int) { column_t copy(index); --(*this); return copy; } + +/// +/// Return the result of adding rhs to this column. +/// +column_t column_t::operator+(const column_t &rhs) { column_t copy(*this); copy.index += rhs.index; return copy; } + +/// +/// Return the result of adding rhs to this column. +/// +column_t column_t::operator-(const column_t &rhs) { column_t copy(*this); copy.index -= rhs.index; return copy; } + +/// +/// Return the result of adding rhs to this column. +/// +column_t column_t::operator*(const column_t &rhs) { column_t copy(*this); copy.index *= rhs.index; return copy; } + +/// +/// Return the result of adding rhs to this column. +/// +column_t column_t::operator/(const column_t &rhs) { column_t copy(*this); copy.index /= rhs.index; return copy; } + +/// +/// Return the result of adding rhs to this column. +/// +column_t column_t::operator%(const column_t &rhs) { column_t copy(*this); copy.index %= rhs.index; return copy; } + +/// +/// Add rhs to this column and return a reference to this column. +/// +column_t &column_t::operator+=(const column_t &rhs) { return *this = (*this + rhs); } + +/// +/// Subtrac rhs from this column and return a reference to this column. +/// +column_t &column_t::operator-=(const column_t &rhs) { return *this = (*this - rhs); } + +/// +/// Multiply this column by rhs and return a reference to this column. +/// +column_t &column_t::operator*=(const column_t &rhs) { return *this = (*this * rhs); } + +/// +/// Divide this column by rhs and return a reference to this column. +/// +column_t &column_t::operator/=(const column_t &rhs) { return *this = (*this / rhs); } + +/// +/// Mod this column by rhs and return a reference to this column. +/// +column_t &column_t::operator%=(const column_t &rhs) { return *this = (*this % rhs); } + +/// +/// Return true if other is to the right of this column. +/// +bool operator>(const column_t::index_t &left, const column_t &right) { return column_t(left) > right; } + +/// +/// Return true if other is to the right of or equal to this column. +/// +bool operator>=(const column_t::index_t &left, const column_t &right) { return column_t(left) >= right; } + +/// +/// Return true if other is to the left of this column. +/// +bool operator<(const column_t::index_t &left, const column_t &right) { return column_t(left) < right; } + +/// +/// Return true if other is to the left of or equal to this column. +/// +bool operator<=(const column_t::index_t &left, const column_t &right) { return column_t(left) <= right; } + +/// +/// Swap the columns that left and right refer to. +/// +void swap(column_t &left, column_t &right) +{ + using std::swap; + swap(left.index, right.index); +} + std::size_t column_hash::operator()(const column_t &k) const { static std::hash hasher; diff --git a/source/detail/cell_impl.hpp b/source/detail/cell_impl.hpp index 846bf3e5..5e2e63d6 100644 --- a/source/detail/cell_impl.hpp +++ b/source/detail/cell_impl.hpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include diff --git a/source/detail/worksheet_impl.hpp b/source/detail/worksheet_impl.hpp index 0e6d84b0..7ae33de3 100644 --- a/source/detail/worksheet_impl.hpp +++ b/source/detail/worksheet_impl.hpp @@ -65,7 +65,7 @@ struct worksheet_impl std::vector relationships_; page_setup page_setup_; range_reference auto_filter_; - margins page_margins_; + page_margins page_margins_; std::vector merged_cells_; std::unordered_map named_ranges_; std::size_t comment_count_; diff --git a/source/detail/xml_node_impl.hpp b/source/detail/xml_node_impl.hpp index e0d9cc08..0c36a2a3 100644 --- a/source/detail/xml_node_impl.hpp +++ b/source/detail/xml_node_impl.hpp @@ -10,9 +10,11 @@ struct xml_node_impl xml_node_impl() { } + explicit xml_node_impl(pugi::xml_node n) : node(n) { } + pugi::xml_node node; }; diff --git a/source/packaging/default_type.cpp b/source/packaging/default_type.cpp new file mode 100644 index 00000000..99d73edd --- /dev/null +++ b/source/packaging/default_type.cpp @@ -0,0 +1,35 @@ +#include + +namespace xlnt { + +default_type::default_type() +{ +} + +default_type::default_type(const std::string &extension, const std::string &content_type) + : extension_(extension), content_type_(content_type) +{ +} + +default_type::default_type(const default_type &other) : extension_(other.extension_), content_type_(other.content_type_) +{ +} + +default_type &default_type::operator=(const default_type &other) +{ + extension_ = other.extension_; + content_type_ = other.content_type_; + + return *this; +} + +std::string default_type::get_extension() const +{ + return extension_; +} +std::string default_type::get_content_type() const +{ + return content_type_; +} + +} // namespace xlnt diff --git a/source/packaging/manifest.cpp b/source/packaging/manifest.cpp index e8c0f0b0..a9935cd1 100644 --- a/source/packaging/manifest.cpp +++ b/source/packaging/manifest.cpp @@ -28,49 +28,6 @@ bool match_path(const std::string &path, const std::string &comparand) namespace xlnt { -default_type::default_type() -{ -} - -default_type::default_type(const std::string &extension, const std::string &content_type) - : extension_(extension), content_type_(content_type) -{ -} - -default_type::default_type(const default_type &other) : extension_(other.extension_), content_type_(other.content_type_) -{ -} - -default_type &default_type::operator=(const default_type &other) -{ - extension_ = other.extension_; - content_type_ = other.content_type_; - - return *this; -} - -override_type::override_type() -{ -} - -override_type::override_type(const std::string &part_name, const std::string &content_type) - : part_name_(part_name), content_type_(content_type) -{ -} - -override_type::override_type(const override_type &other) - : part_name_(other.part_name_), content_type_(other.content_type_) -{ -} - -override_type &override_type::operator=(const override_type &other) -{ - part_name_ = other.part_name_; - content_type_ = other.content_type_; - - return *this; -} - bool manifest::has_default_type(const std::string &extension) const { return std::find_if(default_types_.begin(), default_types_.end(), @@ -122,4 +79,14 @@ std::string manifest::get_override_type(const std::string &part_name) const return match->get_content_type(); } +const std::vector &manifest::get_default_types() const +{ + return default_types_; +} + +const std::vector &manifest::get_override_types() const +{ + return override_types_; +} + } // namespace xlnt diff --git a/source/packaging/override_type.cpp b/source/packaging/override_type.cpp new file mode 100644 index 00000000..f5868cbf --- /dev/null +++ b/source/packaging/override_type.cpp @@ -0,0 +1,37 @@ +#include + +namespace xlnt { + +override_type::override_type() +{ +} + +override_type::override_type(const std::string &part_name, const std::string &content_type) + : part_name_(part_name), content_type_(content_type) +{ +} + +override_type::override_type(const override_type &other) + : part_name_(other.part_name_), content_type_(other.content_type_) +{ +} + +override_type &override_type::operator=(const override_type &other) +{ + part_name_ = other.part_name_; + content_type_ = other.content_type_; + + return *this; +} + +std::string override_type::get_part_name() const +{ + return part_name_; +} + +std::string override_type::get_content_type() const +{ + return content_type_; +} + +} // namespace xlnt diff --git a/source/packaging/override_type.hpp b/source/packaging/override_type.hpp new file mode 100644 index 00000000..b73d5f54 --- /dev/null +++ b/source/packaging/override_type.hpp @@ -0,0 +1,14 @@ +// +// override_type.hpp +// xlnt +// +// Created by Thomas Fussell on 11/18/15. +// +// + +#ifndef override_type_hpp +#define override_type_hpp + +#include + +#endif /* override_type_hpp */ diff --git a/source/serialization/tests/test_write.hpp b/source/serialization/tests/test_write.hpp index c74b97d1..becedac3 100644 --- a/source/serialization/tests/test_write.hpp +++ b/source/serialization/tests/test_write.hpp @@ -91,7 +91,7 @@ public: void test_write_hidden_worksheet() { auto ws = wb_.create_sheet(); - ws.get_page_setup().set_sheet_state(xlnt::page_setup::sheet_state::hidden); + ws.get_page_setup().set_sheet_state(xlnt::sheet_state::hidden); ws.get_cell("F42").set_value("hello"); xlnt::worksheet_serializer serializer(ws); diff --git a/source/serialization/tests/test_write_workbook.hpp b/source/serialization/tests/test_write_workbook.hpp index ecb7d73f..f4dade69 100644 --- a/source/serialization/tests/test_write_workbook.hpp +++ b/source/serialization/tests/test_write_workbook.hpp @@ -29,7 +29,7 @@ public: { xlnt::workbook wb; auto ws = wb.create_sheet(); - ws.set_sheet_state(xlnt::page_setup::sheet_state::hidden); + ws.set_sheet_state(xlnt::sheet_state::hidden); wb.create_sheet(); xlnt::workbook_serializer serializer(wb); @@ -60,7 +60,7 @@ public: { xlnt::workbook wb; auto ws = wb.get_active_sheet(); - ws.set_sheet_state(xlnt::page_setup::sheet_state::hidden); + ws.set_sheet_state(xlnt::sheet_state::hidden); xlnt::workbook_serializer serializer(wb); diff --git a/source/serialization/workbook_serializer.cpp b/source/serialization/workbook_serializer.cpp index 6494c9e5..a318617e 100644 --- a/source/serialization/workbook_serializer.cpp +++ b/source/serialization/workbook_serializer.cpp @@ -161,7 +161,7 @@ xml_document workbook_serializer::write_workbook() const for (auto ws : workbook_) { - if (ws.get_page_setup().get_sheet_state() == xlnt::page_setup::sheet_state::visible) + if (ws.get_page_setup().get_sheet_state() == sheet_state::visible) { num_visible++; } diff --git a/source/serialization/worksheet_serializer.cpp b/source/serialization/worksheet_serializer.cpp index 0075686b..6efb5097 100644 --- a/source/serialization/worksheet_serializer.cpp +++ b/source/serialization/worksheet_serializer.cpp @@ -568,7 +568,7 @@ xml_document worksheet_serializer::write_worksheet() const auto page_setup_node = root_node.add_child("pageSetup"); std::string orientation_string = - sheet_.get_page_setup().get_orientation() == page_setup::orientation::landscape ? "landscape" : "portrait"; + sheet_.get_page_setup().get_orientation() == orientation::landscape ? "landscape" : "portrait"; page_setup_node.add_attribute("orientation", orientation_string); page_setup_node.add_attribute("paperSize", std::to_string(static_cast(sheet_.get_page_setup().get_paper_size()))); diff --git a/source/utils/date.cpp b/source/utils/date.cpp new file mode 100644 index 00000000..24568e9d --- /dev/null +++ b/source/utils/date.cpp @@ -0,0 +1,94 @@ +#include +#include + +#include + +namespace { + +std::tm safe_localtime(std::time_t raw_time) +{ +#ifdef _MSC_VER + std::tm result; + localtime_s(&result, &raw_time); + + return result; +#else + return *localtime(&raw_time); +#endif +} + +} // namespace + +namespace xlnt { + +date date::from_number(int days_since_base_year, calendar base_date) +{ + date result(0, 0, 0); + + if (base_date == calendar::mac_1904) + { + days_since_base_year += 1462; + } + + if (days_since_base_year == 60) + { + result.day = 29; + result.month = 2; + result.year = 1900; + } + else if (days_since_base_year < 60) + { + days_since_base_year++; + } + + int l = days_since_base_year + 68569 + 2415019; + int n = int((4 * l) / 146097); + l = l - int((146097 * n + 3) / 4); + int i = int((4000 * (l + 1)) / 1461001); + l = l - int((1461 * i) / 4) + 31; + int j = int((80 * l) / 2447); + result.day = l - int((2447 * j) / 80); + l = int(j / 11); + result.month = j + 2 - (12 * l); + result.year = 100 * (n - 49) + i + l; + + return result; +} + +bool date::operator==(const date &comparand) const +{ + return year == comparand.year && month == comparand.month && day == comparand.day; +} + +int date::to_number(calendar base_date) const +{ + if (day == 29 && month == 2 && year == 1900) + { + return 60; + } + + int days_since_1900 = int((1461 * (year + 4800 + int((month - 14) / 12))) / 4) + + int((367 * (month - 2 - 12 * ((month - 14) / 12))) / 12) - + int((3 * (int((year + 4900 + int((month - 14) / 12)) / 100))) / 4) + day - 2415019 - 32075; + + if (days_since_1900 <= 60) + { + days_since_1900--; + } + + if (base_date == calendar::mac_1904) + { + return days_since_1900 - 1462; + } + + return days_since_1900; +} + +date date::today() +{ + std::tm now = safe_localtime(std::time(0)); + + return date(1900 + now.tm_year, now.tm_mon + 1, now.tm_mday); +} + +} // namespace xlnt diff --git a/source/utils/datetime.cpp b/source/utils/datetime.cpp index ac986edb..8287d1f0 100644 --- a/source/utils/datetime.cpp +++ b/source/utils/datetime.cpp @@ -2,6 +2,8 @@ #include #include +#include +#include namespace { @@ -21,78 +23,6 @@ std::tm safe_localtime(std::time_t raw_time) namespace xlnt { -time time::from_number(long double raw_time) -{ - time result; - - double integer_part; - double fractional_part = std::modf((double)raw_time, &integer_part); - - fractional_part *= 24; - result.hour = (int)fractional_part; - fractional_part = 60 * (fractional_part - result.hour); - result.minute = (int)fractional_part; - fractional_part = 60 * (fractional_part - result.minute); - result.second = (int)fractional_part; - fractional_part = 1000000 * (fractional_part - result.second); - result.microsecond = (int)fractional_part; - - if (result.microsecond == 999999 && fractional_part - result.microsecond > 0.5) - { - result.microsecond = 0; - result.second += 1; - - if (result.second == 60) - { - result.second = 0; - result.minute += 1; - - //TODO: too much nesting - if (result.minute == 60) - { - result.minute = 0; - result.hour += 1; - } - } - } - - return result; -} - -date date::from_number(int days_since_base_year, calendar base_date) -{ - date result(0, 0, 0); - - if (base_date == calendar::mac_1904) - { - days_since_base_year += 1462; - } - - if (days_since_base_year == 60) - { - result.day = 29; - result.month = 2; - result.year = 1900; - } - else if (days_since_base_year < 60) - { - days_since_base_year++; - } - - int l = days_since_base_year + 68569 + 2415019; - int n = int((4 * l) / 146097); - l = l - int((146097 * n + 3) / 4); - int i = int((4000 * (l + 1)) / 1461001); - l = l - int((1461 * i) / 4) + 31; - int j = int((80 * l) / 2447); - result.day = l - int((2447 * j) / 80); - l = int(j / 11); - result.month = j + 2 - (12 * l); - result.year = 100 * (n - 49) + i + l; - - return result; -} - datetime datetime::from_number(long double raw_time, calendar base_date) { auto date_part = date::from_number((int)raw_time, base_date); @@ -102,78 +32,12 @@ datetime datetime::from_number(long double raw_time, calendar base_date) time_part.microsecond); } -bool date::operator==(const date &comparand) const -{ - return year == comparand.year && month == comparand.month && day == comparand.day; -} - -bool time::operator==(const time &comparand) const -{ - return hour == comparand.hour && minute == comparand.minute && second == comparand.second && - microsecond == comparand.microsecond; -} - bool datetime::operator==(const datetime &comparand) const { return year == comparand.year && month == comparand.month && day == comparand.day && hour == comparand.hour && minute == comparand.minute && second == comparand.second && microsecond == comparand.microsecond; } -time::time(const std::string &time_string) : hour(0), minute(0), second(0), microsecond(0) -{ - std::string remaining = time_string; - auto colon_index = remaining.find(':'); - hour = std::stoi(remaining.substr(0, colon_index)); - remaining = remaining.substr(colon_index + 1); - colon_index = remaining.find(':'); - minute = std::stoi(remaining.substr(0, colon_index)); - colon_index = remaining.find(':'); - - if (colon_index != std::string::npos) - { - remaining = remaining.substr(colon_index + 1); - second = std::stoi(remaining); - } -} - -long double time::to_number() const -{ - std::uint64_t microseconds = static_cast(microsecond); - microseconds += static_cast(second * 1e6); - microseconds += static_cast(minute * 1e6 * 60); - auto microseconds_per_hour = static_cast(1e6) * 60 * 60; - microseconds += static_cast(hour) * microseconds_per_hour; - auto number = microseconds / (24.0L * microseconds_per_hour); - auto hundred_billion = static_cast(1e9) * 100; - number = std::floor(number * hundred_billion + 0.5L) / hundred_billion; - - return number; -} - -int date::to_number(calendar base_date) const -{ - if (day == 29 && month == 2 && year == 1900) - { - return 60; - } - - int days_since_1900 = int((1461 * (year + 4800 + int((month - 14) / 12))) / 4) + - int((367 * (month - 2 - 12 * ((month - 14) / 12))) / 12) - - int((3 * (int((year + 4900 + int((month - 14) / 12)) / 100))) / 4) + day - 2415019 - 32075; - - if (days_since_1900 <= 60) - { - days_since_1900--; - } - - if (base_date == calendar::mac_1904) - { - return days_since_1900 - 1462; - } - - return days_since_1900; -} - long double datetime::to_number(calendar base_date) const { return date(year, month, day).to_number(base_date) + time(hour, minute, second, microsecond).to_number(); @@ -185,13 +49,6 @@ std::string datetime::to_string(xlnt::calendar /*base_date*/) const ":" + std::to_string(minute) + ":" + std::to_string(second) + ":" + std::to_string(microsecond); } -date date::today() -{ - std::tm now = safe_localtime(std::time(0)); - - return date(1900 + now.tm_year, now.tm_mon + 1, now.tm_mday); -} - datetime datetime::now() { std::tm now = safe_localtime(std::time(0)); @@ -199,28 +56,4 @@ datetime datetime::now() return datetime(1900 + now.tm_year, now.tm_mon + 1, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec); } -double timedelta::to_number() const -{ - return days + hours / 24.0; -} - -timedelta timedelta::from_number(long double number) -{ - int days = static_cast(number); - number -= days; - number *= 24; - int hours = static_cast(number); - number -= hours; - number *= 60; - int minutes = static_cast(number); - number -= minutes; - number *= 60; - int seconds = static_cast(number); - number -= seconds; - number *= 1000000; - int microseconds = static_cast(number + 0.5); - - return timedelta(days, hours, minutes, seconds, microseconds); -} - } // namespace xlnt diff --git a/source/utils/exceptions.cpp b/source/utils/exceptions.cpp index 27ce002b..5045c86c 100644 --- a/source/utils/exceptions.cpp +++ b/source/utils/exceptions.cpp @@ -7,15 +7,18 @@ sheet_title_exception::sheet_title_exception(const std::string &title) { } -column_string_index_exception::column_string_index_exception() : std::runtime_error("") +column_string_index_exception::column_string_index_exception() + : std::runtime_error("column string index exception") { } -data_type_exception::data_type_exception() : std::runtime_error("") +data_type_exception::data_type_exception() + : std::runtime_error("data type exception") { } -attribute_error::attribute_error() : std::runtime_error("") +attribute_error::attribute_error() + : std::runtime_error("attribute error") { } @@ -45,4 +48,9 @@ illegal_character_error::illegal_character_error(char c) { } +value_error::value_error() + : std::runtime_error("value error") +{ +} + } // namespace xlnt diff --git a/source/utils/time.cpp b/source/utils/time.cpp new file mode 100644 index 00000000..8753390b --- /dev/null +++ b/source/utils/time.cpp @@ -0,0 +1,83 @@ +#include +#include + +#include + +namespace xlnt { + +time time::from_number(long double raw_time) +{ + time result; + + double integer_part; + double fractional_part = std::modf((double)raw_time, &integer_part); + + fractional_part *= 24; + result.hour = (int)fractional_part; + fractional_part = 60 * (fractional_part - result.hour); + result.minute = (int)fractional_part; + fractional_part = 60 * (fractional_part - result.minute); + result.second = (int)fractional_part; + fractional_part = 1000000 * (fractional_part - result.second); + result.microsecond = (int)fractional_part; + + if (result.microsecond == 999999 && fractional_part - result.microsecond > 0.5) + { + result.microsecond = 0; + result.second += 1; + + if (result.second == 60) + { + result.second = 0; + result.minute += 1; + + //TODO: too much nesting + if (result.minute == 60) + { + result.minute = 0; + result.hour += 1; + } + } + } + + return result; +} + +bool time::operator==(const time &comparand) const +{ + return hour == comparand.hour && minute == comparand.minute && second == comparand.second && + microsecond == comparand.microsecond; +} + +time::time(const std::string &time_string) : hour(0), minute(0), second(0), microsecond(0) +{ + std::string remaining = time_string; + auto colon_index = remaining.find(':'); + hour = std::stoi(remaining.substr(0, colon_index)); + remaining = remaining.substr(colon_index + 1); + colon_index = remaining.find(':'); + minute = std::stoi(remaining.substr(0, colon_index)); + colon_index = remaining.find(':'); + + if (colon_index != std::string::npos) + { + remaining = remaining.substr(colon_index + 1); + second = std::stoi(remaining); + } +} + +long double time::to_number() const +{ + std::uint64_t microseconds = static_cast(microsecond); + microseconds += static_cast(second * 1e6); + microseconds += static_cast(minute * 1e6 * 60); + auto microseconds_per_hour = static_cast(1e6) * 60 * 60; + microseconds += static_cast(hour) * microseconds_per_hour; + auto number = microseconds / (24.0L * microseconds_per_hour); + auto hundred_billion = static_cast(1e9) * 100; + number = std::floor(number * hundred_billion + 0.5L) / hundred_billion; + + return number; +} + +} // namespace xlnt diff --git a/source/utils/timedelta.cpp b/source/utils/timedelta.cpp new file mode 100644 index 00000000..ddcc976a --- /dev/null +++ b/source/utils/timedelta.cpp @@ -0,0 +1,32 @@ +#include +#include + +#include + +namespace xlnt { + +double timedelta::to_number() const +{ + return days + hours / 24.0; +} + +timedelta timedelta::from_number(long double number) +{ + int days = static_cast(number); + number -= days; + number *= 24; + int hours = static_cast(number); + number -= hours; + number *= 60; + int minutes = static_cast(number); + number -= minutes; + number *= 60; + int seconds = static_cast(number); + number -= seconds; + number *= 1000000; + int microseconds = static_cast(number + 0.5); + + return timedelta(days, hours, minutes, seconds, microseconds); +} + +} // namespace xlnt diff --git a/source/worksheet/cell_vector.cpp b/source/worksheet/cell_vector.cpp new file mode 100644 index 00000000..6f76220b --- /dev/null +++ b/source/worksheet/cell_vector.cpp @@ -0,0 +1,114 @@ +#include +#include + +namespace xlnt { + +template <> +cell cell_vector::iterator::operator*() +{ + return ws_[current_cell_]; +} + +cell_vector::iterator cell_vector::begin() +{ + return iterator(ws_, ref_.get_top_left(), order_); +} + +cell_vector::iterator cell_vector::end() +{ + if (order_ == major_order::row) + { + auto past_end = ref_.get_bottom_right(); + past_end.set_column_index(past_end.get_column_index() + 1); + return iterator(ws_, past_end, order_); + } + + auto past_end = ref_.get_bottom_right(); + past_end.set_row(past_end.get_row() + 1); + return iterator(ws_, past_end, order_); +} + +cell_vector::const_iterator cell_vector::cbegin() const +{ + return const_iterator(ws_, ref_.get_top_left(), order_); +} + +cell_vector::const_iterator cell_vector::cend() const +{ + if (order_ == major_order::row) + { + auto past_end = ref_.get_bottom_right(); + past_end.set_column_index(past_end.get_column_index() + 1); + return const_iterator(ws_, past_end, order_); + } + + auto past_end = ref_.get_bottom_right(); + past_end.set_row(past_end.get_row() + 1); + return const_iterator(ws_, past_end, order_); +} + +cell cell_vector::operator[](std::size_t cell_index) +{ + return get_cell(cell_index); +} + +std::size_t cell_vector::num_cells() const +{ + if (order_ == major_order::row) + { + return ref_.get_width() + 1; + } + + return ref_.get_height() + 1; +} + +cell_vector::cell_vector(worksheet ws, const range_reference &reference, major_order order) + : ws_(ws), ref_(reference), order_(order) +{ +} + +cell cell_vector::front() +{ + if (order_ == major_order::row) + { + return get_cell(ref_.get_top_left().get_column().index); + } + + return get_cell(ref_.get_top_left().get_row()); +} + +cell cell_vector::back() +{ + if (order_ == major_order::row) + { + return get_cell(ref_.get_bottom_right().get_column().index); + } + + return get_cell(ref_.get_top_left().get_row()); +} + +cell cell_vector::get_cell(std::size_t index) +{ + if (order_ == major_order::row) + { + return ws_.get_cell(ref_.get_top_left().make_offset((int)index, 0)); + } + + return ws_.get_cell(ref_.get_top_left().make_offset(0, (int)index)); +} + +std::size_t cell_vector::length() const +{ + return num_cells(); +} + +cell_vector::const_iterator cell_vector::begin() const +{ + return cbegin(); +} +cell_vector::const_iterator cell_vector::end() const +{ + return cend(); +} + +} // namespace xlnt diff --git a/source/worksheet/page_margins.cpp b/source/worksheet/page_margins.cpp new file mode 100644 index 00000000..9af94396 --- /dev/null +++ b/source/worksheet/page_margins.cpp @@ -0,0 +1,80 @@ +#include + +namespace xlnt { + +page_margins::page_margins() : default_(true), top_(0), left_(0), bottom_(0), right_(0), header_(0), footer_(0) +{ +} + +bool page_margins::is_default() const +{ + return default_; +} + +double page_margins::get_top() const +{ + return top_; +} + +void page_margins::set_top(double top) +{ + default_ = false; + top_ = top; +} + +double page_margins::get_left() const +{ + return left_; +} + +void page_margins::set_left(double left) +{ + default_ = false; + left_ = left; +} + +double page_margins::get_bottom() const +{ + return bottom_; +} + +void page_margins::set_bottom(double bottom) +{ + default_ = false; + bottom_ = bottom; +} + +double page_margins::get_right() const +{ + return right_; +} + +void page_margins::set_right(double right) +{ + default_ = false; + right_ = right; +} + +double page_margins::get_header() const +{ + return header_; +} + +void page_margins::set_header(double header) +{ + default_ = false; + header_ = header; +} + +double page_margins::get_footer() const +{ + return footer_; +} + +void page_margins::set_footer(double footer) +{ + default_ = false; + footer_ = footer; +} + +} // namespace xlnt diff --git a/source/worksheet/page_setup.cpp b/source/worksheet/page_setup.cpp new file mode 100644 index 00000000..8898b01e --- /dev/null +++ b/source/worksheet/page_setup.cpp @@ -0,0 +1,157 @@ +// Copyright (c) 2014-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 +#include + +namespace xlnt { + +page_setup::page_setup() + : default_(true), + break_(page_break::none), + sheet_state_(sheet_state::visible), + paper_size_(paper_size::letter), + orientation_(orientation::portrait), + fit_to_page_(false), + fit_to_height_(false), + fit_to_width_(false), + horizontal_centered_(false), + vertical_centered_(false), + scale_(1) +{ +} + +bool page_setup::is_default() const +{ + return default_; +} + +page_break page_setup::get_break() const +{ + return break_; +} + +void page_setup::set_break(page_break b) +{ + default_ = false; + break_ = b; +} + +sheet_state page_setup::get_sheet_state() const +{ + return sheet_state_; +} + +void page_setup::set_sheet_state(sheet_state sheet_state) +{ + sheet_state_ = sheet_state; +} + +paper_size page_setup::get_paper_size() const +{ + return paper_size_; +} + +void page_setup::set_paper_size(paper_size paper_size) +{ + default_ = false; + paper_size_ = paper_size; +} + +orientation page_setup::get_orientation() const +{ + return orientation_; +} + +void page_setup::set_orientation(orientation orientation) +{ + default_ = false; + orientation_ = orientation; +} + +bool page_setup::fit_to_page() const +{ + return fit_to_page_; +} + +void page_setup::set_fit_to_page(bool fit_to_page) +{ + default_ = false; + fit_to_page_ = fit_to_page; +} + +bool page_setup::fit_to_height() const +{ + return fit_to_height_; +} + +void page_setup::set_fit_to_height(bool fit_to_height) +{ + default_ = false; + fit_to_height_ = fit_to_height; +} + +bool page_setup::fit_to_width() const +{ + return fit_to_width_; +} + +void page_setup::set_fit_to_width(bool fit_to_width) +{ + default_ = false; + fit_to_width_ = fit_to_width; +} + +void page_setup::set_horizontal_centered(bool horizontal_centered) +{ + default_ = false; + horizontal_centered_ = horizontal_centered; +} + +bool page_setup::get_horizontal_centered() const +{ + return horizontal_centered_; +} + +void page_setup::set_vertical_centered(bool vertical_centered) +{ + default_ = false; + vertical_centered_ = vertical_centered; +} + +bool page_setup::get_vertical_centered() const +{ + return vertical_centered_; +} + +void page_setup::set_scale(double scale) +{ + default_ = false; + scale_ = scale; +} + +double page_setup::get_scale() const +{ + return scale_; +} + +} // namespace xlnt diff --git a/source/worksheet/range.cpp b/source/worksheet/range.cpp index 2b1e5186..490443e2 100644 --- a/source/worksheet/range.cpp +++ b/source/worksheet/range.cpp @@ -5,100 +5,6 @@ namespace xlnt { -template <> -cell cell_vector::iterator::operator*() -{ - return ws_[current_cell_]; -} - -cell_vector::iterator cell_vector::begin() -{ - return iterator(ws_, ref_.get_top_left(), order_); -} - -cell_vector::iterator cell_vector::end() -{ - if (order_ == major_order::row) - { - auto past_end = ref_.get_bottom_right(); - past_end.set_column_index(past_end.get_column_index() + 1); - return iterator(ws_, past_end, order_); - } - - auto past_end = ref_.get_bottom_right(); - past_end.set_row(past_end.get_row() + 1); - return iterator(ws_, past_end, order_); -} - -cell_vector::const_iterator cell_vector::cbegin() const -{ - return const_iterator(ws_, ref_.get_top_left(), order_); -} - -cell_vector::const_iterator cell_vector::cend() const -{ - if (order_ == major_order::row) - { - auto past_end = ref_.get_bottom_right(); - past_end.set_column_index(past_end.get_column_index() + 1); - return const_iterator(ws_, past_end, order_); - } - - auto past_end = ref_.get_bottom_right(); - past_end.set_row(past_end.get_row() + 1); - return const_iterator(ws_, past_end, order_); -} - -cell cell_vector::operator[](std::size_t cell_index) -{ - return get_cell(cell_index); -} - -std::size_t cell_vector::num_cells() const -{ - if (order_ == major_order::row) - { - return ref_.get_width() + 1; - } - - return ref_.get_height() + 1; -} - -cell_vector::cell_vector(worksheet ws, const range_reference &reference, major_order order) - : ws_(ws), ref_(reference), order_(order) -{ -} - -cell cell_vector::front() -{ - if (order_ == major_order::row) - { - return get_cell(ref_.get_top_left().get_column().index); - } - - return get_cell(ref_.get_top_left().get_row()); -} - -cell cell_vector::back() -{ - if (order_ == major_order::row) - { - return get_cell(ref_.get_bottom_right().get_column().index); - } - - return get_cell(ref_.get_top_left().get_row()); -} - -cell cell_vector::get_cell(std::size_t index) -{ - if (order_ == major_order::row) - { - return ws_.get_cell(ref_.get_top_left().make_offset((int)index, 0)); - } - - return ws_.get_cell(ref_.get_top_left().make_offset(0, (int)index)); -} - range::range(worksheet ws, const range_reference &reference, major_order order) : ws_(ws), ref_(reference), order_(order) { diff --git a/source/worksheet/tests/test_worksheet.hpp b/source/worksheet/tests/test_worksheet.hpp index 3e809da5..6cef96c1 100644 --- a/source/worksheet/tests/test_worksheet.hpp +++ b/source/worksheet/tests/test_worksheet.hpp @@ -822,8 +822,8 @@ public: { xlnt::worksheet ws(wb_); - ws.get_page_setup().set_orientation(xlnt::page_setup::orientation::landscape); - ws.get_page_setup().set_paper_size(xlnt::page_setup::paper_size::tabloid); + ws.get_page_setup().set_orientation(xlnt::orientation::landscape); + ws.get_page_setup().set_paper_size(xlnt::paper_size::tabloid); ws.get_page_setup().set_fit_to_page(true); ws.get_page_setup().set_fit_to_height(false); ws.get_page_setup().set_fit_to_width(true); diff --git a/source/worksheet/worksheet.cpp b/source/worksheet/worksheet.cpp index f9c794ab..cf4258cb 100644 --- a/source/worksheet/worksheet.cpp +++ b/source/worksheet/worksheet.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -81,12 +82,12 @@ std::vector worksheet::get_merged_ranges() const return d_->merged_cells_; } -margins &worksheet::get_page_margins() +page_margins &worksheet::get_page_margins() { return d_->page_margins_; } -const margins &worksheet::get_page_margins() const +const page_margins &worksheet::get_page_margins() const { return d_->page_margins_; } @@ -486,7 +487,7 @@ void worksheet::append(const std::vector &cells) { xlnt::cell_reference next(1, get_next_row()); - for (auto cell : cells) + for (const auto &cell : cells) { get_cell(next).set_value(cell); next.set_column_index(next.get_column_index() + 1); @@ -730,7 +731,7 @@ cell_reference worksheet::get_point_pos(const std::pair &point) const return get_point_pos(point.first, point.second); } -void worksheet::set_sheet_state(page_setup::sheet_state state) +void worksheet::set_sheet_state(sheet_state state) { get_page_setup().set_sheet_state(state); }