diff --git a/include/xlnt/cell/cell.hpp b/include/xlnt/cell/cell.hpp index 630753d2..0f678161 100644 --- a/include/xlnt/cell/cell.hpp +++ b/include/xlnt/cell/cell.hpp @@ -27,15 +27,20 @@ #include #include -#include "../styles/style.hpp" -#include "../common/types.hpp" +#include namespace xlnt { enum class calendar; - + +class alignment; +class border; class cell_reference; class comment; +class fill; +class font; +class number_format; +class protection; class relationship; class worksheet; @@ -62,6 +67,9 @@ struct cell_impl; class cell { public: + /// + /// Enumerates the possible types a cell can be determined by it's current value. + /// enum class type { null, @@ -72,14 +80,38 @@ public: boolean }; - static const std::unordered_map ErrorCodes; + /// + /// Return a map of error strings such as #DIV/0! and their associated indices. + /// + static const std::unordered_map error_codes(); + //TODO: Should it be possible to construct and use a cell without a parent worksheet? + //(cont'd) If so, it would need to be responsible for allocating and deleting its PIMPL. + + /// + /// Construct a null cell without a parent. + /// Most methods will throw an exception if this cell is not further initialized. + /// cell(); - cell(worksheet worksheet, const cell_reference &reference); + + /// + /// Construct a cell in worksheet, sheet, at the given reference location (e.g. A1). + /// + cell(worksheet sheet, const cell_reference &reference); + + /// + /// This constructor, provided for convenience, is equivalent to calling: + /// cell c(sheet, reference); + /// c.set_value(initial_value); + /// template - cell(worksheet worksheet, const cell_reference &reference, const T &initial_value); + cell(worksheet sheet, const cell_reference &reference, const T &initial_value); // value + + /// + /// Return true if value has been set and has not been cleared using cell::clear_value(). + /// bool has_value() const; template @@ -93,10 +125,18 @@ public: type get_data_type() const; void set_data_type(type t); - // characteristics + // properties + + /// + /// There's no reason to keep a cell which has no value and is not a placeholder. + /// Return true if this cell has no value, style, isn't merged, etc. + /// bool garbage_collectible() const; + + /// + /// Return true iff this cell's number format matches a date format. + /// bool is_date() const; - std::size_t get_xf_index() const; // position cell_reference get_reference() const; @@ -176,6 +216,7 @@ public: bool operator==(const cell &comparand) const; bool operator==(std::nullptr_t) const; + // friend operators, so we can put cell on either side of comparisons with other types friend bool operator==(std::nullptr_t, const cell &cell); friend bool operator<(cell left, cell right); @@ -188,6 +229,10 @@ private: detail::cell_impl *d_; }; +/// +/// Convenience function for writing cell to an ostream. +/// Uses cell::to_string() internally. +/// inline std::ostream &operator<<(std::ostream &stream, const xlnt::cell &cell) { return stream << cell.to_string(); diff --git a/include/xlnt/reader/comment_reader.hpp b/include/xlnt/reader/comment_reader.hpp deleted file mode 100644 index 91a0bf1b..00000000 --- a/include/xlnt/reader/comment_reader.hpp +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2015 Thomas Fussell -// Copyright (c) 2010-2015 openpyxl -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, WRISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE -// -// @license: http://www.opensource.org/licenses/mit-license.php -// @author: see AUTHORS file -#pragma once - -namespace xlnt { - -class comment_reader -{ - -}; - -} // namespace xlnt diff --git a/include/xlnt/reader/style_reader.hpp b/include/xlnt/reader/style_reader.hpp deleted file mode 100644 index 329c2e03..00000000 --- a/include/xlnt/reader/style_reader.hpp +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (c) 2015 Thomas Fussell -// Copyright (c) 2010-2015 openpyxl -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, WRISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE -// -// @license: http://www.opensource.org/licenses/mit-license.php -// @author: see AUTHORS file -#pragma once - -#include -#include -#include - -#include "xlnt/workbook/workbook.hpp" - -namespace pugi { -class xml_node; -} // namespace pugi - -namespace xlnt { - -class border; -class fill; -class font; -class named_style; -class number_format; -class style; -class zip_file; - -class style_reader -{ -public: - style_reader(workbook &wb); - - void read_styles(zip_file &archive); - - const std::vector