diff --git a/.gitmodules b/.gitmodules index 11d5dc74..bc868ff8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,3 +10,6 @@ [submodule "third-party/utfcpp"] path = third-party/utfcpp url = https://github.com/nemtrif/utfcpp +[submodule "third-party/Optional"] + path = third-party/Optional + url = https://github.com/akrzemi1/Optional diff --git a/README.md b/README.md index ec5bb2aa..340275a0 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,6 @@ [![Coveralls Coverage Status](https://coveralls.io/repos/tfussell/xlnt/badge.svg?branch=master&service=github)](https://coveralls.io/github/tfussell/xlnt?branch=master) [![ReadTheDocs Documentation Status](https://readthedocs.org/projects/xlnt/badge/?version=latest)](http://xlnt.readthedocs.org/en/latest/?badge=latest) [![License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](http://opensource.org/licenses/MIT) -[![Github Releases](https://img.shields.io/github/release/tfussell/xlnt.svg)](https://github.com/tfussell/xlnt/releases) -[![Github Issues](https://img.shields.io/github/issues/tfussell/xlnt.svg)](http://github.com/tfussell/xlnt/issues) ## Introduction xlnt is a C++14 library for reading, writing, and modifying XLSX files as described in [ECMA 376](http://www.ecma-international.org/publications/standards/Ecma-376.htm). The API is based on [openpyxl](https://bitbucket.org/openpyxl/openpyxl), a Python library to read/write Excel 2007 xlsx/xlsm files, and ultimately on [PHPExcel](https://github.com/PHPOffice/PHPExcel), pure PHP library for reading and writing spreadsheet files upon which openpyxl was based. This project is still very much a work in progress, but the core development work is complete. @@ -16,10 +14,11 @@ xlnt is a C++14 library for reading, writing, and modifying XLSX files as descri Including xlnt in your project ```c++ // with -std=c++14 -Ixlnt/include -Lxlnt/lib -lxlnt +// can also use the generated "xlnt.pc" in ./build directory with pkg-config to get these flags #include ``` -Creating a new spreadsheet and saving it +Creating a new spreadsheet and saving it as book1.xlsx ```c++ xlnt::workbook wb; xlnt::worksheet ws = wb.get_active_sheet(); @@ -31,12 +30,12 @@ ws.freeze_panes("B2"); wb.save("book1.xlsx"); ``` -Opening an existing spreadsheet and printing all rows +Opening an existing spreadsheet, book2.xlsx, and printing all cells ```c++ xlnt::workbook wb2; wb2.load("book2.xlsx"); -// no need to use references, iterators are only wrappers around pointers to memory in the workbook +// no need to use references, "cell", "range", and "worksheet" classes are only wrappers around pointers to memory in the workbook for(auto row : wb2["sheet2"].rows()) { for(auto cell : row) @@ -47,26 +46,35 @@ for(auto row : wb2["sheet2"].rows()) ``` ## Building -xlnt is regularly built and passes all 200+ tests in GCC 4.8.2, VS2015, and Clang (using Apple LLVM 7.0). +xlnt uses continous integration and passes all 200+ tests in GCC 4.9, VS2015, and Clang (using Apple LLVM 7.0). -Build configurations for Visual Studio 2015, GNU Make, and Xcode can be created using [cmake](https://cmake.org/) and the cmake scripts in the project's cmake directory. To make this process easier, two python scripts are provided, configure and clean. configure will create build workspaces using the system's default cmake generator or the generator name provided as its first argument. Resulting build files can be found in the created directory "./build". The clean script simply removes ./bin, ./lib, and ./build directories. For Windows, two batch files, configure.bat and clean.bat, are wrappers around the correspnding scripts for convenience (can be double-clicked from Explorer). +Build configurations for Visual Studio 2015, GNU Make, and Xcode can be created using [cmake](https://cmake.org/) and the cmake scripts in the project's cmake directory. To make this process easier, two python scripts are provided, configure and clean. configure will create build workspaces using the system's default cmake generator or the generator name provided as its first argument (more information on generators can be found [here](https://cmake.org/cmake/help/v3.3/manual/cmake-generators.7.html)). Resulting build files can be found in the created directory "./build". The clean script simply removes ./bin, ./lib, and ./build directories. For Windows, two batch files, configure.bat and clean.bat, are wrappers around the correspnding scripts for convenience (can be double-clicked from Explorer). -Example Build: +Example Build (shared library by default): ```bash ./configure cd build make ``` +Example Build, static library with tests: +```bash +./configure --enable-static --disable-shared --enable-tests +cd build +make +``` + ## Dependencies -xlnt uses the following libraries, which are included in the source tree (pugixml and cxxtest as [git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules#Cloning-a-Project-with-Submodules)) for convenience: +xlnt uses the following libraries, which are included in the source tree (all but miniz as [git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules#Cloning-a-Project-with-Submodules)) for convenience: - [miniz v1.15_r4](https://code.google.com/p/miniz/) (public domain/unlicense) - [pugixml v1.6](http://pugixml.org/) (MIT license) +- [Optional](https://github.com/akrzemi1/Optional) (Boost Software License, Version 1.0) +- [utfcpp v2.3.4](http://utfcpp.sourceforge.net/) (Boost Software License, Version 1.0) - [cxxtest v4.4](http://cxxtest.com/) (LGPLv3 license [only used for testing, separate from main library assembly]) ## Documentation -Full documentation can be found on [Read The Docs](http://xlnt.readthedocs.org/en/latest/). +More extensive documentation with examples can be found on [Read The Docs](http://xlnt.readthedocs.org/en/latest/). ## License xlnt is currently released to the public for free under the terms of the MIT License: diff --git a/cmake/xlnt.cmake b/cmake/xlnt.cmake index e5e5129a..1e932cae 100644 --- a/cmake/xlnt.cmake +++ b/cmake/xlnt.cmake @@ -30,6 +30,7 @@ include_directories(../source) include_directories(../third-party/miniz) include_directories(../third-party/pugixml/src) include_directories(../third-party/utfcpp/source) +include_directories(../third-party/Optional) FILE(GLOB ROOT_HEADERS ../include/xlnt/*.hpp) FILE(GLOB CELL_HEADERS ../include/xlnt/cell/*.hpp) diff --git a/include/xlnt/packaging/zip_file.hpp b/include/xlnt/packaging/zip_file.hpp index 8374ffd4..a01ba838 100644 --- a/include/xlnt/packaging/zip_file.hpp +++ b/include/xlnt/packaging/zip_file.hpp @@ -139,10 +139,7 @@ class XLNT_CLASS zip_file void writestr(const std::string &arcname, const std::string &bytes); void writestr(const zip_info &arcname, const std::string &bytes); - std::string get_filename() const - { - return filename_; - } + std::string get_filename() const; std::string comment; diff --git a/include/xlnt/styles/alignment.hpp b/include/xlnt/styles/alignment.hpp index 8c62012a..e1ded688 100644 --- a/include/xlnt/styles/alignment.hpp +++ b/include/xlnt/styles/alignment.hpp @@ -27,15 +27,16 @@ #include #include #include +#include namespace xlnt { /// /// Alignment options for use in styles. /// -class XLNT_CLASS alignment +class XLNT_CLASS alignment : public hashable { - public: +public: bool get_wrap_text() const; void set_wrap_text(bool wrap_text); @@ -51,12 +52,11 @@ class XLNT_CLASS alignment vertical_alignment get_vertical() const; void set_vertical(vertical_alignment vertical); + +protected: + std::string to_hash_string() const override; - bool operator==(const alignment &other) const; - - std::size_t hash() const; - - private: +private: horizontal_alignment horizontal_ = horizontal_alignment::none; vertical_alignment vertical_ = vertical_alignment::none; int text_rotation_ = 0; diff --git a/include/xlnt/styles/border.hpp b/include/xlnt/styles/border.hpp index 21da4a18..378630d3 100644 --- a/include/xlnt/styles/border.hpp +++ b/include/xlnt/styles/border.hpp @@ -25,50 +25,61 @@ #include #include +#include #include #include #include -#include +#include namespace xlnt { /// /// Describes the border style of a particular cell. /// -class XLNT_CLASS border +class XLNT_CLASS border : public hashable { - public: +public: static border default_border(); + + std::experimental::optional &get_start(); + const std::experimental::optional &get_start() const; + std::experimental::optional &get_end(); + const std::experimental::optional &get_end() const; + std::experimental::optional &get_left(); + const std::experimental::optional &get_left() const; + std::experimental::optional &get_right(); + const std::experimental::optional &get_right() const; + std::experimental::optional &get_top(); + const std::experimental::optional &get_top() const; + std::experimental::optional &get_bottom(); + const std::experimental::optional &get_bottom() const; + std::experimental::optional &get_diagonal(); + const std::experimental::optional &get_diagonal() const; + std::experimental::optional &get_vertical(); + const std::experimental::optional &get_vertical() const; + std::experimental::optional &get_horizontal(); + const std::experimental::optional &get_horizontal() const; - bool start_assigned = false; - side start; - bool end_assigned = false; - side end; - bool left_assigned = false; - side left; - bool right_assigned = false; - side right; - bool top_assigned = false; - side top; - bool bottom_assigned = false; - side bottom; - bool diagonal_assigned = false; - side diagonal; - bool vertical_assigned = false; - side vertical; - bool horizontal_assigned = false; - side horizontal; +protected: + std::string to_hash_string() const override; + +private: + std::experimental::optional start_; + std::experimental::optional end_; + std::experimental::optional left_; + std::experimental::optional right_; + std::experimental::optional top_; + std::experimental::optional bottom_; + std::experimental::optional diagonal_; + std::experimental::optional vertical_; + std::experimental::optional horizontal_; - bool outline = false; - bool diagonal_up = false; - bool diagonal_down = false; + bool outline_ = false; + bool diagonal_up_ = false; + bool diagonal_down_ = false; diagonal_direction diagonal_direction_ = diagonal_direction::none; - - bool operator==(const border &other) const; - - std::size_t hash() const; }; } // namespace xlnt diff --git a/include/xlnt/styles/named_style.hpp b/include/xlnt/styles/border_style.hpp similarity index 76% rename from include/xlnt/styles/named_style.hpp rename to include/xlnt/styles/border_style.hpp index 6666df5c..9aaf603c 100644 --- a/include/xlnt/styles/named_style.hpp +++ b/include/xlnt/styles/border_style.hpp @@ -24,28 +24,25 @@ #pragma once #include -#include namespace xlnt { -/// -/// A named style is simply a style that can be referred to by name rather than by index. -/// -class XLNT_CLASS named_style +enum class XLNT_CLASS border_style { - public: - named_style(); - - std::size_t hash() const; - - bool operator==(const named_style &other) const - { - return style_.hash() == other.style_.hash(); - } - - private: - std::string name_; - style style_; + none, + dashdot, + dashdotdot, + dashed, + dotted, + double_, + hair, + medium, + mediumdashdot, + mediumdashdotdot, + mediumdashed, + slantdashdot, + thick, + thin }; } // namespace xlnt diff --git a/include/xlnt/styles/color.hpp b/include/xlnt/styles/color.hpp index 774f901d..932625b1 100644 --- a/include/xlnt/styles/color.hpp +++ b/include/xlnt/styles/color.hpp @@ -26,14 +26,14 @@ #include #include -#include +#include namespace xlnt { /// /// Colors can be applied to many parts of a cell's style. /// -class XLNT_CLASS color +class XLNT_CLASS color : public hashable { public: /// @@ -58,103 +58,32 @@ public: static const color yellow(); static const color darkyellow(); - color() - { - } + color(); - color(type t, std::size_t v) : type_(t), index_(v) - { - } + color(type t, std::size_t v); + + color(type t, const std::string &v); - color(type t, const std::string &v) : type_(t), rgb_string_(v) - { - } + void set_auto(std::size_t auto_index); - void set_auto(std::size_t auto_index) - { - type_ = type::auto_; - index_ = auto_index; - } + void set_index(std::size_t index); - void set_index(std::size_t index) - { - type_ = type::indexed; - index_ = index; - } + void set_theme(std::size_t theme); - void set_theme(std::size_t theme) - { - type_ = type::theme; - index_ = theme; - } + type get_type() const; - type get_type() const - { - return type_; - } + std::size_t get_auto() const; - std::size_t get_auto() const - { - if (type_ != type::auto_) - { - throw std::runtime_error("not auto color"); - } + std::size_t get_index() const; - return index_; - } + std::size_t get_theme() const; - std::size_t get_index() const - { - if (type_ != type::indexed) - { - throw std::runtime_error("not indexed color"); - } + std::string get_rgb_string() const; + +protected: + std::string to_hash_string() const override; - return index_; - } - - std::size_t get_theme() const - { - if (type_ != type::theme) - { - throw std::runtime_error("not theme color"); - } - - return index_; - } - - std::string get_rgb_string() const - { - if (type_ != type::rgb) - { - throw std::runtime_error("not rgb color"); - } - - return rgb_string_; - } - - std::size_t hash() const - { - auto seed = static_cast(type_); - - if (type_ != type::rgb) - { - hash_combine(seed, index_); - } - else - { - hash_combine(seed, rgb_string_); - } - - return seed; - } - - bool operator==(const color &other) const - { - return hash() == other.hash(); - } - - private: +private: type type_ = type::indexed; std::size_t index_ = 0; std::string rgb_string_; diff --git a/include/xlnt/styles/fill.hpp b/include/xlnt/styles/fill.hpp index cdef1932..d504d1da 100644 --- a/include/xlnt/styles/fill.hpp +++ b/include/xlnt/styles/fill.hpp @@ -23,16 +23,17 @@ // @author: see AUTHORS file #pragma once +#include + #include #include -#include namespace xlnt { /// /// Describes the fill style of a particular cell. /// -class XLNT_CLASS fill +class XLNT_CLASS fill : public hashable { public: enum class type @@ -72,266 +73,60 @@ class XLNT_CLASS fill mediumgray, }; - type get_type() const - { - return type_; - } - void set_type(type t) - { - type_ = t; - } + type get_type() const; + + void set_type(type t); - std::string get_pattern_type_string() const - { - if (type_ != type::pattern) - { - throw std::runtime_error("not pattern fill"); - } + std::string get_pattern_type_string() const; + + std::string get_gradient_type_string() const; - switch (pattern_type_) - { - case pattern_type::none: - return "none"; - case pattern_type::solid: - return "solid"; - case pattern_type::darkdown: - return "darkdown"; - case pattern_type::darkgray: - return "darkgray"; - case pattern_type::darkgrid: - return "darkgrid"; - case pattern_type::darkhorizontal: - return "darkhorizontal"; - case pattern_type::darktrellis: - return "darktrellis"; - case pattern_type::darkup: - return "darkup"; - case pattern_type::darkvertical: - return "darkvertical"; - case pattern_type::gray0625: - return "gray0625"; - case pattern_type::gray125: - return "gray125"; - case pattern_type::lightdown: - return "lightdown"; - case pattern_type::lightgray: - return "lightgray"; - case pattern_type::lightgrid: - return "lightgrid"; - case pattern_type::lighthorizontal: - return "lighthorizontal"; - case pattern_type::lighttrellis: - return "lighttrellis"; - case pattern_type::lightup: - return "lightup"; - case pattern_type::lightvertical: - return "lightvertical"; - case pattern_type::mediumgray: - return "mediumgray"; - default: - throw std::runtime_error("invalid type"); - } - } + pattern_type get_pattern_type() const; - std::string get_gradient_type_string() const - { - if (type_ != type::gradient) - { - throw std::runtime_error("not gradient fill"); - } + void set_pattern_type(pattern_type t); - switch (gradient_type_) - { - case gradient_type::linear: - return "linear"; - case gradient_type::path: - return "path"; - default: - throw std::runtime_error("invalid type"); - } - } + void set_gradient_type(gradient_type t); - pattern_type get_pattern_type() const - { - return pattern_type_; - } + std::experimental::optional &get_foreground_color(); + + const std::experimental::optional &get_foreground_color() const; + + std::experimental::optional &get_background_color(); - void set_pattern_type(pattern_type t) - { - type_ = type::pattern; - pattern_type_ = t; - } + const std::experimental::optional &get_background_color() const; + + std::experimental::optional &get_start_color(); + + const std::experimental::optional &get_start_color() const; + + std::experimental::optional &get_end_color(); - void set_gradient_type(gradient_type t) - { - type_ = type::gradient; - gradient_type_ = t; - } + const std::experimental::optional &get_end_color() const; - void set_start_color(const color &c) - { - start_color_ = c; - start_color_assigned_ = true; - } + void set_rotation(double rotation); - void set_end_color(const color &c) - { - end_color_ = c; - end_color_assigned_ = true; - } + double get_rotation() const; + + double get_gradient_left() const; - void set_foreground_color(const color &c) - { - foreground_color_ = c; - foreground_color_assigned_ = true; - } + double get_gradient_right() const; + + double get_gradient_top() const; + + double get_gradient_bottom() const; + +protected: + std::string to_hash_string() const override; - void set_background_color(const color &c) - { - background_color_ = c; - background_color_assigned_ = true; - } - - color get_foreground_color() const - { - return foreground_color_; - } - - color get_background_color() const - { - return background_color_; - } - - bool has_foreground_color() const - { - return foreground_color_assigned_; - } - - bool has_background_color() const - { - return background_color_assigned_; - } - - bool operator==(const fill &other) const - { - return hash() == other.hash(); - } - - void set_rotation(double rotation) - { - rotation_ = rotation; - } - - double get_rotation() const - { - return rotation_; - } - - std::size_t hash() const - { - auto seed = static_cast(type_); - - if (type_ == type::pattern) - { - hash_combine(seed, static_cast(pattern_type_)); - hash_combine(seed, foreground_color_assigned_); - - if (foreground_color_assigned_) - { - hash_combine(seed, static_cast(foreground_color_.get_type())); - - switch (foreground_color_.get_type()) - { - case color::type::auto_: - hash_combine(seed, static_cast(foreground_color_.get_auto())); - break; - case color::type::indexed: - hash_combine(seed, static_cast(foreground_color_.get_index())); - break; - case color::type::theme: - hash_combine(seed, static_cast(foreground_color_.get_theme())); - break; - case color::type::rgb: - break; - } - } - - hash_combine(seed, background_color_assigned_); - - if (background_color_assigned_) - { - hash_combine(seed, static_cast(background_color_.get_type())); - - switch (foreground_color_.get_type()) - { - case color::type::auto_: - hash_combine(seed, static_cast(background_color_.get_auto())); - break; - case color::type::indexed: - hash_combine(seed, static_cast(background_color_.get_index())); - break; - case color::type::theme: - hash_combine(seed, static_cast(background_color_.get_theme())); - break; - case color::type::rgb: - break; - } - } - } - else if (type_ == type::gradient) - { - hash_combine(seed, static_cast(gradient_type_)); - - if (gradient_type_ == gradient_type::path) - { - hash_combine(seed, gradient_path_left_); - hash_combine(seed, gradient_path_right_); - hash_combine(seed, gradient_path_top_); - hash_combine(seed, gradient_path_bottom_); - } - else if (gradient_type_ == gradient_type::linear) - { - hash_combine(seed, rotation_); - } - } - else if (type_ == type::solid) - { - // hash_combine(seed, static_cast()); - } - - return seed; - } - - double get_gradient_left() const - { - return gradient_path_left_; - } - double get_gradient_right() const - { - return gradient_path_right_; - } - double get_gradient_top() const - { - return gradient_path_top_; - } - double get_gradient_bottom() const - { - return gradient_path_bottom_; - } - - private: +private: type type_ = type::none; pattern_type pattern_type_; gradient_type gradient_type_; double rotation_ = 0; - bool foreground_color_assigned_ = false; - color foreground_color_ = color::black(); - bool background_color_assigned_ = false; - color background_color_ = color::white(); - bool start_color_assigned_ = false; - color start_color_ = color::white(); - bool end_color_assigned_ = false; - color end_color_ = color::black(); + std::experimental::optional foreground_color_ = color::black(); + std::experimental::optional background_color_ = color::white(); + std::experimental::optional start_color_ = color::white(); + std::experimental::optional end_color_ = color::black(); double gradient_path_left_ = 0; double gradient_path_right_ = 0; double gradient_path_top_ = 0; diff --git a/include/xlnt/styles/font.hpp b/include/xlnt/styles/font.hpp index 4b07c8fb..eeebd90c 100644 --- a/include/xlnt/styles/font.hpp +++ b/include/xlnt/styles/font.hpp @@ -36,7 +36,7 @@ class style; /// /// Describes the font style of a particular cell. /// -class XLNT_CLASS font +class XLNT_CLASS font : public hashable { public: enum class underline_style @@ -48,130 +48,48 @@ class XLNT_CLASS font single_accounting }; - void set_bold(bool bold) - { - bold_ = bold; - } + void set_bold(bool bold); - bool is_bold() const - { - return bold_; - } + bool is_bold() const; - void set_italic(bool italic) - { - italic_ = italic; - } + void set_italic(bool italic); - bool is_italic() const - { - return italic_; - } + bool is_italic() const; - void set_strikethrough(bool strikethrough) - { - strikethrough_ = strikethrough; - } + void set_strikethrough(bool strikethrough); - bool is_strikethrough() const - { - return strikethrough_; - } + bool is_strikethrough() const; - void set_underline(underline_style new_underline) - { - underline_ = new_underline; - } + void set_underline(underline_style new_underline); - bool is_underline() const - { - return underline_ != underline_style::none; - } + bool is_underline() const; - underline_style get_underline() const - { - return underline_; - } + underline_style get_underline() const; - void set_size(std::size_t size) - { - size_ = size; - } + void set_size(std::size_t size); - std::size_t get_size() const - { - return size_; - } + std::size_t get_size() const; - void set_name(const std::string &name) - { - name_ = name; - } - std::string get_name() const - { - return name_; - } - - void set_color(color c) - { - color_ = c; - } + void set_name(const std::string &name); - void set_family(std::size_t family) - { - has_family_ = true; - family_ = family; - } + std::string get_name() const; + + void set_color(color c); - void set_scheme(const std::string &scheme) - { - has_scheme_ = true; - scheme_ = scheme; - } - - color get_color() const - { - return color_; - } - - bool has_family() const - { - return has_family_; - } + void set_family(std::size_t family); - std::size_t get_family() const - { - return family_; - } + void set_scheme(const std::string &scheme); - bool has_scheme() const - { - return has_scheme_; - } + color get_color() const; - std::size_t hash() const - { - std::size_t seed = 0; + bool has_family() const; + + std::size_t get_family() const; - hash_combine(seed, bold_); - hash_combine(seed, italic_); - hash_combine(seed, superscript_); - hash_combine(seed, subscript_); - hash_combine(seed, strikethrough_); - hash_combine(seed, name_); - hash_combine(seed, size_); - hash_combine(seed, static_cast(underline_)); - hash_combine(seed, color_.hash()); - hash_combine(seed, family_); - hash_combine(seed, scheme_); - - return seed; - } - - bool operator==(const font &other) const - { - return hash() == other.hash(); - } + bool has_scheme() const; + +protected: + std::string to_hash_string() const override; private: friend class style; diff --git a/include/xlnt/styles/number_format.hpp b/include/xlnt/styles/number_format.hpp index 3017a48a..a389cfa5 100644 --- a/include/xlnt/styles/number_format.hpp +++ b/include/xlnt/styles/number_format.hpp @@ -24,10 +24,9 @@ #pragma once #include -#include -#include #include +#include namespace xlnt { @@ -36,9 +35,9 @@ enum class calendar; /// /// Describes the number formatting applied to text and numbers within a certain cell. /// -class XLNT_CLASS number_format +class XLNT_CLASS number_format : public hashable { - public: +public: static const number_format general(); static const number_format text(); static const number_format number(); @@ -90,17 +89,16 @@ class XLNT_CLASS number_format void set_id(std::size_t id); std::size_t get_id() const; - - std::size_t hash() const; std::string format(const std::string &text) const; std::string format(long double number, calendar base_date) const; bool is_date_format() const; + +protected: + std::string to_hash_string() const override; - bool operator==(const number_format &other) const; - - private: +private: bool id_set_; std::size_t id_; std::string format_string_; diff --git a/include/xlnt/styles/protection.hpp b/include/xlnt/styles/protection.hpp index c3829681..d6cf06b1 100644 --- a/include/xlnt/styles/protection.hpp +++ b/include/xlnt/styles/protection.hpp @@ -26,14 +26,14 @@ #include #include -#include +#include namespace xlnt { /// /// Describes the protection style of a particular cell. /// -class XLNT_CLASS protection +class XLNT_CLASS protection : public hashable { public: enum class type @@ -46,30 +46,13 @@ class XLNT_CLASS protection protection(); protection(type locked); - void set_locked(type locked_type) - { - locked_ = locked_type; - } + void set_locked(type locked_type); + void set_hidden(type hidden_type); + +protected: + std::string to_hash_string() const override; - void set_hidden(type hidden_type) - { - hidden_ = hidden_type; - } - - bool operator==(const protection &other) const - { - return hash() == other.hash(); - } - - std::size_t hash() const - { - std::size_t seed = static_cast(locked_); - hash_combine(seed, static_cast(hidden_)); - - return seed; - } - - private: +private: type locked_; type hidden_; }; diff --git a/include/xlnt/styles/side.hpp b/include/xlnt/styles/side.hpp index 2ae7015e..09b97a10 100644 --- a/include/xlnt/styles/side.hpp +++ b/include/xlnt/styles/side.hpp @@ -24,101 +24,37 @@ #pragma once #include +#include #include +#include #include +#include namespace xlnt { -enum class XLNT_CLASS border_style -{ - none, - dashdot, - dashdotdot, - dashed, - dotted, - double_, - hair, - medium, - mediumdashdot, - mediumdashdotdot, - mediumdashed, - slantdashdot, - thick, - thin -}; - /// /// Describes the one of the sides of a border of a particular cell. /// -class XLNT_CLASS side +class XLNT_CLASS side : public hashable { public: side(); - std::size_t hash() const - { - std::size_t seed = 0; + std::experimental::optional &get_border_style(); + + const std::experimental::optional &get_border_style() const; - hash_combine(seed, style_assigned_); + std::experimental::optional &get_color(); + + const std::experimental::optional &get_color() const; - if (style_assigned_) - { - hash_combine(seed, static_cast(style_)); - } - - hash_combine(seed, color_assigned_); - - if (color_assigned_) - { - hash_combine(seed, color_.hash()); - } - - return seed; - } - - border_style get_style() const - { - return style_; - } - - color get_color() const - { - return color_; - } - - bool is_style_assigned() const - { - return style_assigned_; - } - - bool is_color_assigned() const - { - return color_assigned_; - } - - bool operator==(const side &other) const - { - return other.style_ == style_ && color_ == other.color_; - } - - void set_border_style(border_style bs) - { - style_assigned_ = true; - style_ = bs; - } - - void set_color(color new_color) - { - color_assigned_ = true; - color_ = new_color; - } - - private: - bool style_assigned_ = false; - border_style style_ = border_style::none; - bool color_assigned_ = false; - color color_ = color::black(); +protected: + std::string to_hash_string() const override; + +private: + std::experimental::optional border_style_; + std::experimental::optional color_; }; } // namespace xlnt diff --git a/include/xlnt/styles/style.hpp b/include/xlnt/styles/style.hpp index 0c62f90e..a6a8c38b 100644 --- a/include/xlnt/styles/style.hpp +++ b/include/xlnt/styles/style.hpp @@ -38,9 +38,9 @@ class workbook; /// /// Describes the entirety of the styling of a particular cell. /// -class XLNT_CLASS style +class XLNT_CLASS style : public hashable { - public: +public: style(); style(const style &other); style &operator=(const style &other); @@ -56,59 +56,23 @@ class XLNT_CLASS style bool pivot_button() const; bool quote_prefix() const; - std::size_t get_id() const - { - return id_; - } + std::size_t get_id() const; + std::size_t get_fill_id() const; + std::size_t get_font_id() const; + std::size_t get_border_id() const; + std::size_t get_number_format_id() const; - std::size_t get_fill_id() const - { - return fill_id_; - } - std::size_t get_font_id() const - { - return font_id_; - } - std::size_t get_border_id() const - { - return border_id_; - } - std::size_t get_number_format_id() const - { - return number_format_id_; - } + void apply_alignment(bool apply); + void apply_border(bool apply); + void apply_fill(bool apply); + void apply_font(bool apply); + void apply_number_format(bool apply); + void apply_protection(bool apply); + +protected: + std::string to_hash_string() const override; - void apply_alignment(bool apply) - { - alignment_apply_ = apply; - } - void apply_border(bool apply) - { - border_apply_ = apply; - } - void apply_fill(bool apply) - { - fill_apply_ = apply; - } - void apply_font(bool apply) - { - font_apply_ = apply; - } - void apply_number_format(bool apply) - { - number_format_apply_ = apply; - } - void apply_protection(bool apply) - { - protection_apply_ = apply; - } - - bool operator==(const style &other) const - { - return hash() == other.hash(); - } - - private: +private: friend class style_serializer; friend class workbook; diff --git a/include/xlnt/utils/date.hpp b/include/xlnt/utils/date.hpp index 9d90b28d..dfefad40 100644 --- a/include/xlnt/utils/date.hpp +++ b/include/xlnt/utils/date.hpp @@ -47,9 +47,7 @@ struct XLNT_CLASS date /// 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_) - { - } + date(int year_, int month_, int day_); /// /// Return the number of days between this date and base_date. diff --git a/include/xlnt/utils/datetime.hpp b/include/xlnt/utils/datetime.hpp index e26eb8a2..5437d963 100644 --- a/include/xlnt/utils/datetime.hpp +++ b/include/xlnt/utils/datetime.hpp @@ -43,10 +43,7 @@ struct XLNT_CLASS datetime /// Return the current date and time according to the system time. /// This is equivalent to datetime::now(). /// - static datetime today() - { - return now(); - } + static datetime today(); /// /// Return a datetime from number by converting the integer part into @@ -55,16 +52,7 @@ struct XLNT_CLASS datetime /// static datetime from_number(long double number, calendar base_date); - datetime(int year_, int month_, int day_, int hour_ = 0, int minute_ = 0, int second_ = 0, int microsecond_ = 0) - : year(year_), - month(month_), - day(day_), - hour(hour_), - minute(minute_), - second(second_), - microsecond(microsecond_) - { - } + datetime(int year_, int month_, int day_, int hour_ = 0, int minute_ = 0, int second_ = 0, int microsecond_ = 0); std::string to_string(calendar base_date) const; long double to_number(calendar base_date) const; diff --git a/include/xlnt/utils/hashable.hpp b/include/xlnt/utils/hashable.hpp new file mode 100644 index 00000000..b0c65b66 --- /dev/null +++ b/include/xlnt/utils/hashable.hpp @@ -0,0 +1,40 @@ +// 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 { + +class hashable +{ +public: + std::size_t hash() const; + bool operator==(const hashable &other) const; + +protected: + virtual std::string to_hash_string() const = 0; +}; + +} // namespace \ No newline at end of file diff --git a/include/xlnt/utils/time.hpp b/include/xlnt/utils/time.hpp index 5e130602..ddc478cf 100644 --- a/include/xlnt/utils/time.hpp +++ b/include/xlnt/utils/time.hpp @@ -47,10 +47,7 @@ struct XLNT_CLASS time /// 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(int hour_ = 0, int minute_ = 0, int second_ = 0, int microsecond_ = 0); explicit time(const std::string &time_string); long double to_number() const; diff --git a/include/xlnt/utils/utf8string.hpp b/include/xlnt/utils/utf8string.hpp index 87601005..9267edf6 100644 --- a/include/xlnt/utils/utf8string.hpp +++ b/include/xlnt/utils/utf8string.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 #include #include #include diff --git a/include/xlnt/workbook/named_range.hpp b/include/xlnt/workbook/named_range.hpp index 798301d5..0216a679 100644 --- a/include/xlnt/workbook/named_range.hpp +++ b/include/xlnt/workbook/named_range.hpp @@ -49,14 +49,8 @@ class XLNT_CLASS named_range named_range(const named_range &other); named_range(const std::string &name, const std::vector &targets); - std::string get_name() const - { - return name_; - } - const std::vector &get_targets() const - { - return targets_; - } + std::string get_name() const; + const std::vector &get_targets() const; named_range &operator=(const named_range &other); diff --git a/include/xlnt/worksheet/footer.hpp b/include/xlnt/worksheet/footer.hpp index 69cdebdb..8b98a8b4 100644 --- a/include/xlnt/worksheet/footer.hpp +++ b/include/xlnt/worksheet/footer.hpp @@ -1,3 +1,26 @@ +// 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 diff --git a/include/xlnt/worksheet/header.hpp b/include/xlnt/worksheet/header.hpp index c43d1ed1..9b1a100b 100644 --- a/include/xlnt/worksheet/header.hpp +++ b/include/xlnt/worksheet/header.hpp @@ -1,3 +1,26 @@ +// 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 diff --git a/include/xlnt/worksheet/header_footer.hpp b/include/xlnt/worksheet/header_footer.hpp index 0cc35081..e19b63eb 100644 --- a/include/xlnt/worksheet/header_footer.hpp +++ b/include/xlnt/worksheet/header_footer.hpp @@ -1,3 +1,26 @@ +// 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 @@ -17,43 +40,17 @@ 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_; - } + header &get_left_header(); + header &get_center_header(); + header &get_right_header(); + + footer &get_left_footer(); + footer &get_center_footer(); + footer &get_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(); - } + bool is_default_header() const; + bool is_default_footer() const; + bool is_default() const; private: header left_header_, right_header_, center_header_; diff --git a/include/xlnt/worksheet/range_iterator_2d.hpp b/include/xlnt/worksheet/range_iterator_2d.hpp index 0d39ad1a..d35f331c 100644 --- a/include/xlnt/worksheet/range_iterator_2d.hpp +++ b/include/xlnt/worksheet/range_iterator_2d.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 diff --git a/include/xlnt/xlnt.hpp b/include/xlnt/xlnt.hpp index 74c0e80d..4661c60a 100644 --- a/include/xlnt/xlnt.hpp +++ b/include/xlnt/xlnt.hpp @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include diff --git a/source/cell/cell.cpp b/source/cell/cell.cpp index 668becbc..15c4e67c 100644 --- a/source/cell/cell.cpp +++ b/source/cell/cell.cpp @@ -1,3 +1,26 @@ +// 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 #include diff --git a/source/cell/cell_reference.cpp b/source/cell/cell_reference.cpp index 48fa2d99..5fd0f688 100644 --- a/source/cell/cell_reference.cpp +++ b/source/cell/cell_reference.cpp @@ -1,3 +1,26 @@ +// 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 #include diff --git a/source/cell/comment.cpp b/source/cell/comment.cpp index 2801e2ff..34a263b0 100644 --- a/source/cell/comment.cpp +++ b/source/cell/comment.cpp @@ -1,3 +1,26 @@ +// 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 #include diff --git a/source/cell/index_types.cpp b/source/cell/index_types.cpp index 7dbc8c1d..5721729c 100644 --- a/source/cell/index_types.cpp +++ b/source/cell/index_types.cpp @@ -1,3 +1,26 @@ +// 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 #include diff --git a/source/detail/cell_impl.cpp b/source/detail/cell_impl.cpp index ed60b3fe..a494df1b 100644 --- a/source/detail/cell_impl.cpp +++ b/source/detail/cell_impl.cpp @@ -1,8 +1,101 @@ +// 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 #include "cell_impl.hpp" #include "comment_impl.hpp" +namespace { + +std::pair cast_numeric(const std::string &s) +{ + const char *str = s.c_str(); + char *str_end = nullptr; + auto result = std::strtold(str, &str_end); + if (str_end != str + s.size()) return { false, 0 }; + return { true, result }; +} + +std::pair cast_percentage(const std::string &s) +{ + if (s.back() == '%') + { + auto number = cast_numeric(s.substr(0, s.size() - 1)); + + if (number.first) + { + return { true, number.second / 100 }; + } + } + + return { false, 0 }; +} + +std::pair cast_time(const std::string &s) +{ + xlnt::time result; + + try + { + auto last_colon = s.find_last_of(':'); + if (last_colon == std::string::npos) return { false, result }; + double seconds = std::stod(s.substr(last_colon + 1)); + result.second = static_cast(seconds); + result.microsecond = static_cast((seconds - static_cast(result.second)) * 1e6); + + auto first_colon = s.find_first_of(':'); + + if (first_colon == last_colon) + { + auto decimal_pos = s.find('.'); + if (decimal_pos != std::string::npos) + { + result.minute = std::stoi(s.substr(0, first_colon)); + } + else + { + result.hour = std::stoi(s.substr(0, first_colon)); + result.minute = result.second; + result.second = 0; + } + } + else + { + result.hour = std::stoi(s.substr(0, first_colon)); + result.minute = std::stoi(s.substr(first_colon + 1, last_colon - first_colon - 1)); + } + } + catch (std::invalid_argument) + { + return { false, result }; + } + + return { true, result }; +} + +} // namespace + namespace xlnt { namespace detail { diff --git a/source/detail/cell_impl.hpp b/source/detail/cell_impl.hpp index bf5cb31d..933e2619 100644 --- a/source/detail/cell_impl.hpp +++ b/source/detail/cell_impl.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 @@ -12,76 +34,6 @@ #include "comment_impl.hpp" -namespace { - -std::pair cast_numeric(const std::string &s) -{ - const char *str = s.c_str(); - char *str_end = nullptr; - auto result = std::strtold(str, &str_end); - if (str_end != str + s.size()) return { false, 0 }; - return { true, result }; -} - -std::pair cast_percentage(const std::string &s) -{ - if (s.back() == '%') - { - auto number = cast_numeric(s.substr(0, s.size() - 1)); - - if (number.first) - { - return { true, number.second / 100 }; - } - } - - return { false, 0 }; -} - -std::pair cast_time(const std::string &s) -{ - xlnt::time result; - - try - { - auto last_colon = s.find_last_of(':'); - if (last_colon == std::string::npos) return { false, result }; - double seconds = std::stod(s.substr(last_colon + 1)); - result.second = static_cast(seconds); - result.microsecond = static_cast((seconds - static_cast(result.second)) * 1e6); - - auto first_colon = s.find_first_of(':'); - - if (first_colon == last_colon) - { - auto decimal_pos = s.find('.'); - if (decimal_pos != std::string::npos) - { - result.minute = std::stoi(s.substr(0, first_colon)); - } - else - { - result.hour = std::stoi(s.substr(0, first_colon)); - result.minute = result.second; - result.second = 0; - } - } - else - { - result.hour = std::stoi(s.substr(0, first_colon)); - result.minute = std::stoi(s.substr(first_colon + 1, last_colon - first_colon - 1)); - } - } - catch (std::invalid_argument) - { - return { false, result }; - } - - return { true, result }; -} - -} // namespace - namespace xlnt { class style; diff --git a/source/detail/comment_impl.cpp b/source/detail/comment_impl.cpp index d87f38ea..0772ce31 100644 --- a/source/detail/comment_impl.cpp +++ b/source/detail/comment_impl.cpp @@ -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 #include "comment_impl.hpp" namespace xlnt { diff --git a/source/detail/comment_impl.hpp b/source/detail/comment_impl.hpp index 1c762502..f4b3e302 100644 --- a/source/detail/comment_impl.hpp +++ b/source/detail/comment_impl.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 diff --git a/source/detail/constants.cpp b/source/detail/constants.cpp index 016ec52f..7c72246f 100644 --- a/source/detail/constants.cpp +++ b/source/detail/constants.cpp @@ -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 #include #include diff --git a/source/detail/constants.hpp b/source/detail/constants.hpp index 5eb27c47..9c91476a 100644 --- a/source/detail/constants.hpp +++ b/source/detail/constants.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 diff --git a/source/detail/include_pugixml.hpp b/source/detail/include_pugixml.hpp index aa7e7b1e..bedd7da7 100644 --- a/source/detail/include_pugixml.hpp +++ b/source/detail/include_pugixml.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 /// diff --git a/source/detail/include_windows.hpp b/source/detail/include_windows.hpp index 61d173a5..e504b362 100644 --- a/source/detail/include_windows.hpp +++ b/source/detail/include_windows.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 #ifdef _MSC_VER diff --git a/source/detail/workbook_impl.hpp b/source/detail/workbook_impl.hpp index 6cbf6816..9a018e5d 100644 --- a/source/detail/workbook_impl.hpp +++ b/source/detail/workbook_impl.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 diff --git a/source/detail/worksheet_impl.hpp b/source/detail/worksheet_impl.hpp index 7ae33de3..71b6f7d6 100644 --- a/source/detail/worksheet_impl.hpp +++ b/source/detail/worksheet_impl.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 #include #include #include diff --git a/source/detail/xml_document_impl.hpp b/source/detail/xml_document_impl.hpp index b1f84085..8c50f101 100644 --- a/source/detail/xml_document_impl.hpp +++ b/source/detail/xml_document_impl.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 diff --git a/source/detail/xml_node_impl.hpp b/source/detail/xml_node_impl.hpp index 0c36a2a3..47875f14 100644 --- a/source/detail/xml_node_impl.hpp +++ b/source/detail/xml_node_impl.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 diff --git a/source/drawing/drawing.cpp b/source/drawing/drawing.cpp index 73f08ef3..8c96bbb6 100644 --- a/source/drawing/drawing.cpp +++ b/source/drawing/drawing.cpp @@ -1,3 +1,26 @@ +// 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 { diff --git a/source/packaging/default_type.cpp b/source/packaging/default_type.cpp index 99d73edd..54c39ed2 100644 --- a/source/packaging/default_type.cpp +++ b/source/packaging/default_type.cpp @@ -1,3 +1,26 @@ +// 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 { diff --git a/source/packaging/document_properties.cpp b/source/packaging/document_properties.cpp index 37187085..149ff33e 100644 --- a/source/packaging/document_properties.cpp +++ b/source/packaging/document_properties.cpp @@ -1,3 +1,26 @@ +// 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 { diff --git a/source/packaging/manifest.cpp b/source/packaging/manifest.cpp index a9935cd1..1d4ad4f0 100644 --- a/source/packaging/manifest.cpp +++ b/source/packaging/manifest.cpp @@ -1,3 +1,26 @@ +// 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 #include diff --git a/source/packaging/override_type.cpp b/source/packaging/override_type.cpp index f5868cbf..e12b0758 100644 --- a/source/packaging/override_type.cpp +++ b/source/packaging/override_type.cpp @@ -1,3 +1,26 @@ +// 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 { diff --git a/source/packaging/relationship.cpp b/source/packaging/relationship.cpp index f48555f4..8ddeaa24 100644 --- a/source/packaging/relationship.cpp +++ b/source/packaging/relationship.cpp @@ -1,3 +1,26 @@ +// 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 { diff --git a/source/packaging/zip_file.cpp b/source/packaging/zip_file.cpp index 850558e0..0d2d2109 100644 --- a/source/packaging/zip_file.cpp +++ b/source/packaging/zip_file.cpp @@ -1,3 +1,26 @@ +// 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 #include #include @@ -744,4 +767,9 @@ std::pair zip_file::testzip() return { true, "" }; } +std::string zip_file::get_filename() const +{ + return filename_; +} + } // namespace xlnt diff --git a/source/serialization/comment_serializer.cpp b/source/serialization/comment_serializer.cpp index d36cd54a..a71c4e0b 100644 --- a/source/serialization/comment_serializer.cpp +++ b/source/serialization/comment_serializer.cpp @@ -1,3 +1,26 @@ +// 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 { diff --git a/source/serialization/excel_serializer.cpp b/source/serialization/excel_serializer.cpp index f9efe52b..db638cce 100644 --- a/source/serialization/excel_serializer.cpp +++ b/source/serialization/excel_serializer.cpp @@ -1,3 +1,26 @@ +// 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 #include diff --git a/source/serialization/manifest_serializer.cpp b/source/serialization/manifest_serializer.cpp index e2cd53bf..8f040837 100644 --- a/source/serialization/manifest_serializer.cpp +++ b/source/serialization/manifest_serializer.cpp @@ -1,3 +1,26 @@ +// 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 #include #include diff --git a/source/serialization/relationship_serializer.cpp b/source/serialization/relationship_serializer.cpp index b548d9f6..75eb9181 100644 --- a/source/serialization/relationship_serializer.cpp +++ b/source/serialization/relationship_serializer.cpp @@ -1,3 +1,26 @@ +// 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 #include diff --git a/source/serialization/shared_strings_serializer.cpp b/source/serialization/shared_strings_serializer.cpp index 76cd30da..80c3a96f 100644 --- a/source/serialization/shared_strings_serializer.cpp +++ b/source/serialization/shared_strings_serializer.cpp @@ -1,3 +1,26 @@ +// 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 #include #include diff --git a/source/serialization/style_serializer.cpp b/source/serialization/style_serializer.cpp index 8a312504..fed02684 100644 --- a/source/serialization/style_serializer.cpp +++ b/source/serialization/style_serializer.cpp @@ -1,3 +1,26 @@ +// 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 #include #include @@ -420,12 +443,12 @@ fill style_serializer::read_fill(const xml_node &fill_node) if (pattern_fill_node.has_child("bgColor")) { - new_fill.set_background_color(read_color(pattern_fill_node.get_child("bgColor"))); + new_fill.get_background_color() = read_color(pattern_fill_node.get_child("bgColor")); } if (pattern_fill_node.has_child("fgColor")) { - new_fill.set_foreground_color(read_color(pattern_fill_node.get_child("fgColor"))); + new_fill.get_foreground_color() = read_color(pattern_fill_node.get_child("fgColor")); } } @@ -438,12 +461,12 @@ side style_serializer::read_side(const xml_node &side_node) if (side_node.has_attribute("style")) { - new_side.set_border_style(border_style_from_string(side_node.get_attribute("style"))); + new_side.get_border_style() = border_style_from_string(side_node.get_attribute("style")); } if (side_node.has_child("color")) { - new_side.set_color(read_color(side_node.get_child("color"))); + new_side.get_color() = read_color(side_node.get_child("color")); } return new_side; @@ -465,56 +488,47 @@ border style_serializer::read_border(const xml_node &border_node) if (border_node.has_child("start")) { - new_border.start_assigned = true; - new_border.start = read_side(border_node.get_child("start")); + new_border.get_start() = read_side(border_node.get_child("start")); } if (border_node.has_child("end")) { - new_border.end_assigned = true; - new_border.end = read_side(border_node.get_child("end")); + new_border.get_end() = read_side(border_node.get_child("end")); } if (border_node.has_child("left")) { - new_border.left_assigned = true; - new_border.left = read_side(border_node.get_child("left")); + new_border.get_left() = read_side(border_node.get_child("left")); } if (border_node.has_child("right")) { - new_border.right_assigned = true; - new_border.right = read_side(border_node.get_child("right")); + new_border.get_right() = read_side(border_node.get_child("right")); } if (border_node.has_child("top")) { - new_border.top_assigned = true; - new_border.top = read_side(border_node.get_child("top")); + new_border.get_top() = read_side(border_node.get_child("top")); } if (border_node.has_child("bottom")) { - new_border.bottom_assigned = true; - new_border.bottom = read_side(border_node.get_child("bottom")); + new_border.get_bottom() = read_side(border_node.get_child("bottom")); } if (border_node.has_child("diagonal")) { - new_border.diagonal_assigned = true; - new_border.diagonal = read_side(border_node.get_child("diagonal")); + new_border.get_diagonal() = read_side(border_node.get_child("diagonal")); } if (border_node.has_child("vertical")) { - new_border.vertical_assigned = true; - new_border.vertical = read_side(border_node.get_child("vertical")); + new_border.get_vertical() = read_side(border_node.get_child("vertical")); } if (border_node.has_child("horizontal")) { - new_border.horizontal_assigned = true; - new_border.horizontal = read_side(border_node.get_child("horizontal")); + new_border.get_horizontal() = read_side(border_node.get_child("horizontal")); } return new_border; @@ -667,40 +681,40 @@ xml_document style_serializer::write_stylesheet() const auto type_string = fill_.get_pattern_type_string(); pattern_fill_node.add_attribute("patternType", type_string); - if (fill_.has_foreground_color()) + if (fill_.get_foreground_color()) { auto fg_color_node = pattern_fill_node.add_child("fgColor"); - switch (fill_.get_foreground_color().get_type()) + switch (fill_.get_foreground_color()->get_type()) { case color::type::auto_: - fg_color_node.add_attribute("auto", std::to_string(fill_.get_foreground_color().get_auto())); + fg_color_node.add_attribute("auto", std::to_string(fill_.get_foreground_color()->get_auto())); break; case color::type::theme: - fg_color_node.add_attribute("theme", std::to_string(fill_.get_foreground_color().get_theme())); + fg_color_node.add_attribute("theme", std::to_string(fill_.get_foreground_color()->get_theme())); break; case color::type::indexed: - fg_color_node.add_attribute("indexed", std::to_string(fill_.get_foreground_color().get_index())); + fg_color_node.add_attribute("indexed", std::to_string(fill_.get_foreground_color()->get_index())); break; default: throw std::runtime_error("bad type"); } } - if (fill_.has_background_color()) + if (fill_.get_background_color()) { auto bg_color_node = pattern_fill_node.add_child("bgColor"); - switch (fill_.get_background_color().get_type()) + switch (fill_.get_background_color()->get_type()) { case color::type::auto_: - bg_color_node.add_attribute("auto", std::to_string(fill_.get_background_color().get_auto())); + bg_color_node.add_attribute("auto", std::to_string(fill_.get_background_color()->get_auto())); break; case color::type::theme: - bg_color_node.add_attribute("theme", std::to_string(fill_.get_background_color().get_theme())); + bg_color_node.add_attribute("theme", std::to_string(fill_.get_background_color()->get_theme())); break; case color::type::indexed: - bg_color_node.add_attribute("indexed", std::to_string(fill_.get_background_color().get_index())); + bg_color_node.add_attribute("indexed", std::to_string(fill_.get_background_color()->get_index())); break; default: throw std::runtime_error("bad type"); @@ -744,32 +758,32 @@ xml_document style_serializer::write_stylesheet() const { auto border_node = borders_node.add_child("border"); - std::vector> sides; - sides.push_back(std::make_tuple("start", border_.start, border_.start_assigned)); - sides.push_back(std::make_tuple("end", border_.end, border_.end_assigned)); - sides.push_back(std::make_tuple("left", border_.left, border_.left_assigned)); - sides.push_back(std::make_tuple("right", border_.right, border_.right_assigned)); - sides.push_back(std::make_tuple("top", border_.top, border_.top_assigned)); - sides.push_back(std::make_tuple("bottom", border_.bottom, border_.bottom_assigned)); - sides.push_back(std::make_tuple("diagonal", border_.diagonal, border_.diagonal_assigned)); - sides.push_back(std::make_tuple("vertical", border_.vertical, border_.vertical_assigned)); - sides.push_back(std::make_tuple("horizontal", border_.horizontal, border_.horizontal_assigned)); + std::vector>> sides; + + sides.push_back(std::make_tuple("start", border_.get_start())); + sides.push_back(std::make_tuple("end", border_.get_end())); + sides.push_back(std::make_tuple("left", border_.get_left())); + sides.push_back(std::make_tuple("right", border_.get_right())); + sides.push_back(std::make_tuple("top", border_.get_top())); + sides.push_back(std::make_tuple("bottom", border_.get_bottom())); + sides.push_back(std::make_tuple("diagonal", border_.get_diagonal())); + sides.push_back(std::make_tuple("vertical", border_.get_vertical())); + sides.push_back(std::make_tuple("horizontal", border_.get_horizontal())); for (const auto &side_tuple : sides) { - std::string name = std::get<0>(side_tuple); - const side side_ = std::get<1>(side_tuple); - bool assigned = std::get<2>(side_tuple); + std::string current_name = std::get<0>(side_tuple); + const auto current_side = std::get<1>(side_tuple); - if (assigned) + if (current_side) { - auto side_node = border_node.add_child(name); + auto side_node = border_node.add_child(current_name); - if (side_.is_style_assigned()) + if (current_side->get_border_style()) { std::string style_string; - switch (side_.get_style()) + switch (*current_side->get_border_style()) { case border_style::none: style_string = "none"; @@ -820,17 +834,17 @@ xml_document style_serializer::write_stylesheet() const side_node.add_attribute("style", style_string); } - if (side_.is_color_assigned()) + if (current_side->get_color()) { auto color_node = side_node.add_child("color"); - if (side_.get_color().get_type() == color::type::indexed) + if (current_side->get_color()->get_type() == color::type::indexed) { - color_node.add_attribute("indexed", std::to_string(side_.get_color().get_index())); + color_node.add_attribute("indexed", std::to_string(current_side->get_color()->get_index())); } - else if (side_.get_color().get_type() == color::type::theme) + else if (current_side->get_color()->get_type() == color::type::theme) { - color_node.add_attribute("theme", std::to_string(side_.get_color().get_theme())); + color_node.add_attribute("theme", std::to_string(current_side->get_color()->get_theme())); } else { diff --git a/source/serialization/theme_serializer.cpp b/source/serialization/theme_serializer.cpp index 20b34e8c..e408ad7f 100644 --- a/source/serialization/theme_serializer.cpp +++ b/source/serialization/theme_serializer.cpp @@ -1,3 +1,26 @@ +// 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 #include #include diff --git a/source/serialization/workbook_serializer.cpp b/source/serialization/workbook_serializer.cpp index a318617e..76627a2f 100644 --- a/source/serialization/workbook_serializer.cpp +++ b/source/serialization/workbook_serializer.cpp @@ -1,3 +1,26 @@ +// 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 #include diff --git a/source/serialization/worksheet_serializer.cpp b/source/serialization/worksheet_serializer.cpp index 6efb5097..68e010f5 100644 --- a/source/serialization/worksheet_serializer.cpp +++ b/source/serialization/worksheet_serializer.cpp @@ -1,3 +1,26 @@ +// 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 #include #include diff --git a/source/serialization/xml_document.cpp b/source/serialization/xml_document.cpp index 893c1dda..f048d9fd 100644 --- a/source/serialization/xml_document.cpp +++ b/source/serialization/xml_document.cpp @@ -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 #include #include #include diff --git a/source/serialization/xml_node.cpp b/source/serialization/xml_node.cpp index 318befe2..1efd59b1 100644 --- a/source/serialization/xml_node.cpp +++ b/source/serialization/xml_node.cpp @@ -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 #include #include diff --git a/source/serialization/xml_serializer.cpp b/source/serialization/xml_serializer.cpp index bc12e5a7..63b6eb16 100644 --- a/source/serialization/xml_serializer.cpp +++ b/source/serialization/xml_serializer.cpp @@ -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 #include #include diff --git a/source/styles/alignment.cpp b/source/styles/alignment.cpp index bc9cb3d7..83c2eaf6 100644 --- a/source/styles/alignment.cpp +++ b/source/styles/alignment.cpp @@ -66,21 +66,18 @@ void alignment::set_vertical(vertical_alignment vertical) vertical_ = vertical; } -bool alignment::operator==(const alignment &other) const +std::string alignment::to_hash_string() const { - return hash() == other.hash(); -} + std::string hash_string; -std::size_t alignment::hash() const -{ - std::size_t seed = 0; - hash_combine(seed, wrap_text_); - hash_combine(seed, shrink_to_fit_); - hash_combine(seed, static_cast(horizontal_)); - hash_combine(seed, static_cast(vertical_)); - hash_combine(seed, text_rotation_); - hash_combine(seed, indent_); - return seed; + hash_string.append(wrap_text_ ? "1" : "0"); + hash_string.append(shrink_to_fit_ ? "1" : "0"); + hash_string.append(std::to_string(static_cast(horizontal_))); + hash_string.append(std::to_string(static_cast(vertical_))); + hash_string.append(std::to_string(text_rotation_)); + hash_string.append(std::to_string(indent_)); + + return hash_string; } } // namespace xlnt diff --git a/source/styles/border.cpp b/source/styles/border.cpp index 21275d22..8f10a6fb 100644 --- a/source/styles/border.cpp +++ b/source/styles/border.cpp @@ -1,36 +1,152 @@ +// 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 { -bool border::operator==(const border &other) const +std::experimental::optional &border::get_start() { - return hash() == other.hash(); + return start_; } -std::size_t border::hash() const +const std::experimental::optional &border::get_start() const { - std::size_t seed = 0; + return start_; +} - hash_combine(seed, start_assigned); - if (start_assigned) hash_combine(seed, start.hash()); - hash_combine(seed, end_assigned); - if (end_assigned) hash_combine(seed, end.hash()); - hash_combine(seed, left_assigned); - if (left_assigned) hash_combine(seed, left.hash()); - hash_combine(seed, right_assigned); - if (right_assigned) hash_combine(seed, right.hash()); - hash_combine(seed, top_assigned); - if (top_assigned) hash_combine(seed, top.hash()); - hash_combine(seed, bottom_assigned); - if (bottom_assigned) hash_combine(seed, bottom.hash()); - hash_combine(seed, diagonal_assigned); - if (diagonal_assigned) hash_combine(seed, diagonal.hash()); - hash_combine(seed, vertical_assigned); - if (vertical_assigned) hash_combine(seed, vertical.hash()); - hash_combine(seed, horizontal_assigned); - if (horizontal_assigned) hash_combine(seed, horizontal.hash()); +std::experimental::optional &border::get_end() +{ + return end_; +} - return seed; +const std::experimental::optional &border::get_end() const +{ + return end_; +} + +std::experimental::optional &border::get_left() +{ + return left_; +} + +const std::experimental::optional &border::get_left() const +{ + return left_; +} + +std::experimental::optional &border::get_right() +{ + return right_; +} + +const std::experimental::optional &border::get_right() const +{ + return right_; +} + +std::experimental::optional &border::get_top() +{ + return top_; +} + +const std::experimental::optional &border::get_top() const +{ + return top_; +} + +std::experimental::optional &border::get_bottom() +{ + return bottom_; +} + +const std::experimental::optional &border::get_bottom() const +{ + return bottom_; +} + +std::experimental::optional &border::get_diagonal() +{ + return diagonal_; +} + +const std::experimental::optional &border::get_diagonal() const +{ + return diagonal_; +} + +std::experimental::optional &border::get_vertical() +{ + return vertical_; +} + +const std::experimental::optional &border::get_vertical() const +{ + return vertical_; +} + +std::experimental::optional &border::get_horizontal() +{ + return horizontal_; +} + +const std::experimental::optional &border::get_horizontal() const +{ + return horizontal_; +} + +std::string border::to_hash_string() const +{ + std::string hash_string; + + hash_string.append(start_ ? "1" : "0"); + if (start_) hash_string.append(std::to_string(start_->hash())); + + hash_string.append(end_ ? "1" : "0"); + if (end_) hash_string.append(std::to_string(end_->hash())); + + hash_string.append(left_ ? "1" : "0"); + if (left_) hash_string.append(std::to_string(left_->hash())); + + hash_string.append(right_ ? "1" : "0"); + if (right_) hash_string.append(std::to_string(right_->hash())); + + hash_string.append(top_ ? "1" : "0"); + if (top_) hash_string.append(std::to_string(top_->hash())); + + hash_string.append(bottom_ ? "1" : "0"); + if (bottom_) hash_string.append(std::to_string(bottom_->hash())); + + hash_string.append(diagonal_ ? "1" : "0"); + if (diagonal_) hash_string.append(std::to_string(diagonal_->hash())); + + hash_string.append(vertical_ ? "1" : "0"); + if (vertical_) hash_string.append(std::to_string(vertical_->hash())); + + hash_string.append(horizontal_ ? "1" : "0"); + if (horizontal_) hash_string.append(std::to_string(horizontal_->hash())); + + return hash_string; } } // namespace xlnt diff --git a/source/styles/borders.cpp b/source/styles/borders.cpp deleted file mode 100644 index 8a78c42e..00000000 --- a/source/styles/borders.cpp +++ /dev/null @@ -1,10 +0,0 @@ - -#include - -namespace xlnt { - -side::side() -{ -} - -} // namespace xlnt diff --git a/source/styles/color.cpp b/source/styles/color.cpp new file mode 100644 index 00000000..4189d647 --- /dev/null +++ b/source/styles/color.cpp @@ -0,0 +1,122 @@ +// 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 { + +color::color() +{ +} + +color::color(type t, std::size_t v) : type_(t), index_(v) +{ +} + +color::color(type t, const std::string &v) : type_(t), rgb_string_(v) +{ +} + +void color::set_auto(std::size_t auto_index) +{ + type_ = type::auto_; + index_ = auto_index; +} + +void color::set_index(std::size_t index) +{ + type_ = type::indexed; + index_ = index; +} + +void color::set_theme(std::size_t theme) +{ + type_ = type::theme; + index_ = theme; +} + +color::type color::get_type() const +{ + return type_; +} + +std::size_t color::get_auto() const +{ + if (type_ != type::auto_) + { + throw std::runtime_error("not auto color"); + } + + return index_; +} + +std::size_t color::get_index() const +{ + if (type_ != type::indexed) + { + throw std::runtime_error("not indexed color"); + } + + return index_; +} + +std::size_t color::get_theme() const +{ + if (type_ != type::theme) + { + throw std::runtime_error("not theme color"); + } + + return index_; +} + +std::string color::get_rgb_string() const +{ + if (type_ != type::rgb) + { + throw std::runtime_error("not rgb color"); + } + + return rgb_string_; +} + +std::string color::to_hash_string() const +{ + std::string hash_string = "color"; + + hash_string.append(std::to_string(static_cast(type_))); + + if (type_ != type::rgb) + { + hash_string.append(std::to_string(index_)); + } + else + { + hash_string.append(rgb_string_); + } + + return hash_string; +} + +} // namespace xlnt \ No newline at end of file diff --git a/source/styles/fill.cpp b/source/styles/fill.cpp new file mode 100644 index 00000000..10a3541b --- /dev/null +++ b/source/styles/fill.cpp @@ -0,0 +1,265 @@ +// 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 { + +fill::type fill::get_type() const +{ + return type_; +} + +void fill::set_type(type t) +{ + type_ = t; +} + +std::string fill::get_pattern_type_string() const +{ + if (type_ != type::pattern) + { + throw std::runtime_error("not pattern fill"); + } + + switch (pattern_type_) + { + case pattern_type::none: + return "none"; + case pattern_type::solid: + return "solid"; + case pattern_type::darkdown: + return "darkdown"; + case pattern_type::darkgray: + return "darkgray"; + case pattern_type::darkgrid: + return "darkgrid"; + case pattern_type::darkhorizontal: + return "darkhorizontal"; + case pattern_type::darktrellis: + return "darktrellis"; + case pattern_type::darkup: + return "darkup"; + case pattern_type::darkvertical: + return "darkvertical"; + case pattern_type::gray0625: + return "gray0625"; + case pattern_type::gray125: + return "gray125"; + case pattern_type::lightdown: + return "lightdown"; + case pattern_type::lightgray: + return "lightgray"; + case pattern_type::lightgrid: + return "lightgrid"; + case pattern_type::lighthorizontal: + return "lighthorizontal"; + case pattern_type::lighttrellis: + return "lighttrellis"; + case pattern_type::lightup: + return "lightup"; + case pattern_type::lightvertical: + return "lightvertical"; + case pattern_type::mediumgray: + return "mediumgray"; + default: + throw std::runtime_error("invalid type"); + } +} + +std::string fill::get_gradient_type_string() const +{ + if (type_ != type::gradient) + { + throw std::runtime_error("not gradient fill"); + } + + switch (gradient_type_) + { + case gradient_type::linear: + return "linear"; + case gradient_type::path: + return "path"; + default: + throw std::runtime_error("invalid type"); + } +} + +fill::pattern_type fill::get_pattern_type() const +{ + return pattern_type_; +} + +void fill::set_pattern_type(pattern_type t) +{ + type_ = type::pattern; + pattern_type_ = t; +} + +void fill::set_gradient_type(gradient_type t) +{ + type_ = type::gradient; + gradient_type_ = t; +} + +std::experimental::optional &fill::get_foreground_color() +{ + return foreground_color_; +} + +const std::experimental::optional &fill::get_foreground_color() const +{ + return foreground_color_; +} + +std::experimental::optional &fill::get_background_color() +{ + return background_color_; +} + +const std::experimental::optional &fill::get_background_color() const +{ + return background_color_; +} + +std::experimental::optional &fill::get_start_color() +{ + return start_color_; +} + +const std::experimental::optional &fill::get_start_color() const +{ + return start_color_; +} + +std::experimental::optional &fill::get_end_color() +{ + return end_color_; +} + +const std::experimental::optional &fill::get_end_color() const +{ + return end_color_; +} + +void fill::set_rotation(double rotation) +{ + rotation_ = rotation; +} + +double fill::get_rotation() const +{ + return rotation_; +} + +std::string fill::to_hash_string() const +{ + std::string hash_string = "fill"; + + hash_string.append(std::to_string(static_cast(type_))); + + switch (type_) + { + case type::pattern: + { + hash_string.append(std::to_string(static_cast(pattern_type_))); + + hash_string.append(background_color_ ? "1" : "0"); + + if (background_color_) + { + hash_string.append(std::to_string(background_color_->hash())); + } + + hash_string.append(background_color_ ? "1" : "0"); + + if (background_color_) + { + hash_string.append(std::to_string(background_color_->hash())); + } + + break; + } + case type::gradient: + { + hash_string.append(std::to_string(static_cast(gradient_type_))); + + if (gradient_type_ == gradient_type::path) + { + hash_string.append(std::to_string(gradient_path_left_)); + hash_string.append(std::to_string(gradient_path_right_)); + hash_string.append(std::to_string(gradient_path_top_)); + hash_string.append(std::to_string(gradient_path_bottom_)); + } + else if (gradient_type_ == gradient_type::linear) + { + hash_string.append(std::to_string(rotation_)); + } + + hash_string.append(start_color_ ? "1" : "0"); + + if (start_color_) + { + hash_string.append(std::to_string(start_color_->hash())); + } + + hash_string.append(end_color_ ? "1" : "0"); + + if (start_color_) + { + hash_string.append(std::to_string(background_color_->hash())); + } + + break; + } + default: + { + break; + } + } // switch (type_) + + return hash_string; +} + +double fill::get_gradient_left() const +{ + return gradient_path_left_; +} + +double fill::get_gradient_right() const +{ + return gradient_path_right_; +} + +double fill::get_gradient_top() const +{ + return gradient_path_top_; +} + +double fill::get_gradient_bottom() const +{ + return gradient_path_bottom_; +} + +} // namespace xlnt diff --git a/source/styles/font.cpp b/source/styles/font.cpp new file mode 100644 index 00000000..dcdfa500 --- /dev/null +++ b/source/styles/font.cpp @@ -0,0 +1,149 @@ +// 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 { + +void font::set_bold(bool bold) +{ + bold_ = bold; +} + +bool font::is_bold() const +{ + return bold_; +} + +void font::set_italic(bool italic) +{ + italic_ = italic; +} + +bool font::is_italic() const +{ + return italic_; +} + +void font::set_strikethrough(bool strikethrough) +{ + strikethrough_ = strikethrough; +} + +bool font::is_strikethrough() const +{ + return strikethrough_; +} + +void font::set_underline(underline_style new_underline) +{ + underline_ = new_underline; +} + +bool font::is_underline() const +{ + return underline_ != underline_style::none; +} + +font::underline_style font::get_underline() const +{ + return underline_; +} + +void font::set_size(std::size_t size) +{ + size_ = size; +} + +std::size_t font::get_size() const +{ + return size_; +} + +void font::set_name(const std::string &name) +{ + name_ = name; +} +std::string font::get_name() const +{ + return name_; +} + +void font::set_color(color c) +{ + color_ = c; +} + +void font::set_family(std::size_t family) +{ + has_family_ = true; + family_ = family; +} + +void font::set_scheme(const std::string &scheme) +{ + has_scheme_ = true; + scheme_ = scheme; +} + +color font::get_color() const +{ + return color_; +} + +bool font::has_family() const +{ + return has_family_; +} + +std::size_t font::get_family() const +{ + return family_; +} + +bool font::has_scheme() const +{ + return has_scheme_; +} + +std::string font::to_hash_string() const +{ + std::string hash_string = "font"; + + hash_string.append(std::to_string(bold_)); + hash_string.append(std::to_string(italic_)); + hash_string.append(std::to_string(superscript_)); + hash_string.append(std::to_string(subscript_)); + hash_string.append(std::to_string(strikethrough_)); + hash_string.append(name_); + hash_string.append(std::to_string(size_)); + hash_string.append(std::to_string(static_cast(underline_))); + hash_string.append(std::to_string(color_.hash())); + hash_string.append(std::to_string(family_)); + hash_string.append(scheme_); + + return hash_string; +} + +} // namespace xlnt diff --git a/source/styles/number_format.cpp b/source/styles/number_format.cpp index 8bbd5c8d..481b68e4 100644 --- a/source/styles/number_format.cpp +++ b/source/styles/number_format.cpp @@ -1,6 +1,30 @@ +// 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 #include -#include +#include +#include #include #include @@ -1067,12 +1091,14 @@ std::string number_format::get_format_string() const return format_string_; } -std::size_t number_format::hash() const +std::string number_format::to_hash_string() const { - std::size_t seed = id_; - hash_combine(seed, format_string_); + std::string hash_string("number_format"); + + hash_string.append(std::to_string(id_)); + hash_string.append(format_string_); - return seed; + return hash_string; } @@ -1149,9 +1175,4 @@ std::string number_format::format(long double number, calendar base_date) const return format_number(number, format_string_, base_date); } -bool number_format::operator==(const number_format &other) const -{ - return hash() == other.hash(); -} - } // namespace xlnt diff --git a/source/styles/protection.cpp b/source/styles/protection.cpp index ccf80af4..52db11e0 100644 --- a/source/styles/protection.cpp +++ b/source/styles/protection.cpp @@ -1,4 +1,28 @@ +// 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 +#include namespace xlnt { @@ -10,4 +34,24 @@ protection::protection(type t) : locked_(t), hidden_(type::unprotected) { } +void protection::set_locked(type locked_type) +{ + locked_ = locked_type; +} + +void protection::set_hidden(type hidden_type) +{ + hidden_ = hidden_type; +} + +std::string protection::to_hash_string() const +{ + std::string hash_string = "protection"; + + hash_string.append(std::to_string(static_cast(locked_))); + hash_string.append(std::to_string(static_cast(hidden_))); + + return hash_string; +} + } // namespace xlnt diff --git a/source/styles/side.cpp b/source/styles/side.cpp new file mode 100644 index 00000000..f9280877 --- /dev/null +++ b/source/styles/side.cpp @@ -0,0 +1,73 @@ +// 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 { + +side::side() +{ +} + +std::string side::to_hash_string() const +{ + std::string hash_string; + + hash_string.append(border_style_ ? "1" : "0"); + + if(border_style_) + { + hash_string.append(std::to_string(static_cast(*border_style_))); + } + + hash_string.append(color_ ? "1" : "0"); + + if(color_) + { + hash_string.append(std::to_string(color_->hash())); + } + + return hash_string; +} + +std::experimental::optional &side::get_border_style() +{ + return border_style_; +} + +const std::experimental::optional &side::get_border_style() const +{ + return border_style_; +} + +std::experimental::optional &side::get_color() +{ + return color_; +} + +const std::experimental::optional &side::get_color() const +{ + return color_; +} + +} // namespace xlnt diff --git a/source/styles/style.cpp b/source/styles/style.cpp index 1d81c7e6..f1632ad1 100644 --- a/source/styles/style.cpp +++ b/source/styles/style.cpp @@ -1,3 +1,26 @@ +// 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 #include #include @@ -91,29 +114,29 @@ style &style::operator=(const style &other) return *this; } -std::size_t style::hash() const +std::string style::to_hash_string() const { - std::size_t seed = 0; + std::string hash_string("style"); + + hash_string.append(std::to_string(alignment_apply_)); + hash_string.append(alignment_apply_ ? std::to_string(alignment_.hash()) : " "); - hash_combine(seed, alignment_apply_); - hash_combine(seed, alignment_apply_ ? alignment_.hash() : 0); + hash_string.append(std::to_string(border_apply_)); + hash_string.append(border_apply_ ? std::to_string(border_id_) : " "); - hash_combine(seed, border_apply_); - hash_combine(seed, border_apply_ ? border_id_ : 0); + hash_string.append(std::to_string(font_apply_)); + hash_string.append(font_apply_ ? std::to_string(font_id_) : " "); - hash_combine(seed, font_apply_); - hash_combine(seed, font_apply_ ? font_id_ : 0); + hash_string.append(std::to_string(fill_apply_)); + hash_string.append(fill_apply_ ? std::to_string(fill_id_) : " "); - hash_combine(seed, fill_apply_); - hash_combine(seed, fill_apply_ ? fill_id_ : 0); + hash_string.append(std::to_string(number_format_apply_)); + hash_string.append(number_format_apply_ ? std::to_string(number_format_id_) : " "); - hash_combine(seed, number_format_apply_); - hash_combine(seed, number_format_apply_ ? number_format_id_ : 0); + hash_string.append(std::to_string(protection_apply_)); + hash_string.append(protection_apply_ ? std::to_string(protection_.hash()) : " "); - hash_combine(seed, protection_apply_); - hash_combine(seed, protection_apply_ ? get_protection().hash() : 0); - - return seed; + return hash_string; } const number_format style::get_number_format() const @@ -156,4 +179,59 @@ bool style::quote_prefix() const return quote_prefix_; } +std::size_t style::get_id() const +{ + return id_; +} + +std::size_t style::get_fill_id() const +{ + return fill_id_; +} + +std::size_t style::get_font_id() const +{ + return font_id_; +} + +std::size_t style::get_border_id() const +{ + return border_id_; +} + +std::size_t style::get_number_format_id() const +{ + return number_format_id_; +} + +void style::apply_alignment(bool apply) +{ + alignment_apply_ = apply; +} + +void style::apply_border(bool apply) +{ + border_apply_ = apply; +} + +void style::apply_fill(bool apply) +{ + fill_apply_ = apply; +} + +void style::apply_font(bool apply) +{ + font_apply_ = apply; +} + +void style::apply_number_format(bool apply) +{ + number_format_apply_ = apply; +} + +void style::apply_protection(bool apply) +{ + protection_apply_ = apply; +} + } // namespace xlnt diff --git a/source/utils/date.cpp b/source/utils/date.cpp index 24568e9d..f6119e4b 100644 --- a/source/utils/date.cpp +++ b/source/utils/date.cpp @@ -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 #include #include @@ -21,6 +43,10 @@ std::tm safe_localtime(std::time_t raw_time) namespace xlnt { +date::date(int year_, int month_, int day_) : year(year_), month(month_), day(day_) +{ +} + date date::from_number(int days_since_base_year, calendar base_date) { date result(0, 0, 0); diff --git a/source/utils/datetime.cpp b/source/utils/datetime.cpp index 8287d1f0..19737e07 100644 --- a/source/utils/datetime.cpp +++ b/source/utils/datetime.cpp @@ -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 #include #include @@ -56,4 +78,20 @@ 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); } +datetime datetime::today() +{ + return now(); +} + +datetime::datetime(int year_, int month_, int day_, int hour_, int minute_, int second_, int microsecond_) + : year(year_), + month(month_), + day(day_), + hour(hour_), + minute(minute_), + second(second_), + microsecond(microsecond_) +{ +} + } // namespace xlnt diff --git a/source/utils/exceptions.cpp b/source/utils/exceptions.cpp index bb372b72..b5986a4e 100644 --- a/source/utils/exceptions.cpp +++ b/source/utils/exceptions.cpp @@ -1,3 +1,26 @@ +// 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 { diff --git a/source/utils/hashable.cpp b/source/utils/hashable.cpp new file mode 100644 index 00000000..70ab7306 --- /dev/null +++ b/source/utils/hashable.cpp @@ -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 +#include + +namespace xlnt { + +std::size_t hashable::hash() const +{ + static std::hash hasher; + return hasher.operator()(to_hash_string()); +} + +bool hashable::operator==(const xlnt::hashable &other) const +{ + return hash() == other.hash(); +} + +} // namespace xlnt diff --git a/source/utils/time.cpp b/source/utils/time.cpp index 8753390b..e12262b0 100644 --- a/source/utils/time.cpp +++ b/source/utils/time.cpp @@ -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 #include #include @@ -43,6 +65,11 @@ time time::from_number(long double raw_time) return result; } +time::time(int hour_, int minute_, int second_, int microsecond_) + : hour(hour_), minute(minute_), second(second_), microsecond(microsecond_) +{ +} + bool time::operator==(const time &comparand) const { return hour == comparand.hour && minute == comparand.minute && second == comparand.second && diff --git a/source/utils/timedelta.cpp b/source/utils/timedelta.cpp index df1a205c..95b3bbcd 100644 --- a/source/utils/timedelta.cpp +++ b/source/utils/timedelta.cpp @@ -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 #include #include diff --git a/source/utils/utf8string.cpp b/source/utils/utf8string.cpp index ad012a15..4309bc70 100644 --- a/source/utils/utf8string.cpp +++ b/source/utils/utf8string.cpp @@ -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 #include namespace xlnt { diff --git a/source/workbook/named_range.cpp b/source/workbook/named_range.cpp index 2fa5b9a2..a48f796e 100644 --- a/source/workbook/named_range.cpp +++ b/source/workbook/named_range.cpp @@ -1,4 +1,26 @@ - +// 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 #include #include @@ -36,6 +58,16 @@ std::vector split_string(const std::string &string, char delim) namespace xlnt { +std::string named_range::get_name() const +{ + return name_; +} + +const std::vector &named_range::get_targets() const +{ + return targets_; +} + std::vector> split_named_range(const std::string &named_range_string) { std::vector> final; diff --git a/source/workbook/workbook.cpp b/source/workbook/workbook.cpp index 4dc200cd..b566e596 100644 --- a/source/workbook/workbook.cpp +++ b/source/workbook/workbook.cpp @@ -1,3 +1,26 @@ +// 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 #include #include diff --git a/source/worksheet/cell_vector.cpp b/source/worksheet/cell_vector.cpp index a724ceec..dda33c46 100644 --- a/source/worksheet/cell_vector.cpp +++ b/source/worksheet/cell_vector.cpp @@ -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 #include #include diff --git a/source/worksheet/footer.cpp b/source/worksheet/footer.cpp index 31716bab..c83aa4a4 100644 --- a/source/worksheet/footer.cpp +++ b/source/worksheet/footer.cpp @@ -1,3 +1,26 @@ +// 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 { diff --git a/source/worksheet/header.cpp b/source/worksheet/header.cpp index 413f9630..bc4ea804 100644 --- a/source/worksheet/header.cpp +++ b/source/worksheet/header.cpp @@ -1,3 +1,26 @@ +// 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 { diff --git a/source/worksheet/header_footer.cpp b/source/worksheet/header_footer.cpp new file mode 100644 index 00000000..5ec0a057 --- /dev/null +++ b/source/worksheet/header_footer.cpp @@ -0,0 +1,66 @@ +// 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 { + +header &header_footer::get_left_header() +{ + return left_header_; +} +header &header_footer::get_center_header() +{ + return center_header_; +} +header &header_footer::get_right_header() +{ + return right_header_; +} +footer &header_footer::get_left_footer() +{ + return left_footer_; +} +footer &header_footer::get_center_footer() +{ + return center_footer_; +} +footer &header_footer::get_right_footer() +{ + return right_footer_; +} + +bool header_footer::is_default_header() const +{ + return left_header_.is_default() && center_header_.is_default() && right_header_.is_default(); +} +bool header_footer::is_default_footer() const +{ + return left_footer_.is_default() && center_footer_.is_default() && right_footer_.is_default(); +} +bool header_footer::is_default() const +{ + return is_default_header() && is_default_footer(); +} + +} // namespace xlnt \ No newline at end of file diff --git a/source/worksheet/page_margins.cpp b/source/worksheet/page_margins.cpp index 9af94396..ff066a6e 100644 --- a/source/worksheet/page_margins.cpp +++ b/source/worksheet/page_margins.cpp @@ -1,3 +1,26 @@ +// 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 { diff --git a/source/worksheet/range.cpp b/source/worksheet/range.cpp index 753015a1..dab84972 100644 --- a/source/worksheet/range.cpp +++ b/source/worksheet/range.cpp @@ -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 #include #include #include diff --git a/source/worksheet/range_reference.cpp b/source/worksheet/range_reference.cpp index 547cd14a..1e7dca1a 100644 --- a/source/worksheet/range_reference.cpp +++ b/source/worksheet/range_reference.cpp @@ -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 #include #include diff --git a/source/worksheet/sheet_protection.cpp b/source/worksheet/sheet_protection.cpp index ce4c64c6..8e86c5fa 100644 --- a/source/worksheet/sheet_protection.cpp +++ b/source/worksheet/sheet_protection.cpp @@ -1,3 +1,26 @@ +// 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 #include #include diff --git a/source/worksheet/worksheet.cpp b/source/worksheet/worksheet.cpp index d4f7450b..a8c8196a 100644 --- a/source/worksheet/worksheet.cpp +++ b/source/worksheet/worksheet.cpp @@ -1,3 +1,26 @@ +// 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 #include diff --git a/third-party/Optional b/third-party/Optional new file mode 160000 index 00000000..bd25a1ba --- /dev/null +++ b/third-party/Optional @@ -0,0 +1 @@ +Subproject commit bd25a1baef048fc5d358927718d367e3f821963e