From ca6dea8cbc600851a8a30cb1f624f2b502e8314e Mon Sep 17 00:00:00 2001 From: Thomas Fussell Date: Sun, 6 Mar 2016 10:39:50 +0800 Subject: [PATCH] update workbook tests --- include/xlnt/utils/exceptions.hpp | 1 + include/xlnt/utils/key_error.hpp | 41 ++++++ include/xlnt/workbook/workbook.hpp | 3 + include/xlnt/worksheet/worksheet.hpp | 2 + source/detail/workbook_impl.hpp | 3 + source/utils/exceptions.cpp | 10 ++ source/workbook/tests/test_workbook.hpp | 176 +++++++++++------------- source/workbook/workbook.cpp | 38 +++-- source/worksheet/worksheet.cpp | 48 ++++++- 9 files changed, 213 insertions(+), 109 deletions(-) create mode 100644 include/xlnt/utils/key_error.hpp diff --git a/include/xlnt/utils/exceptions.hpp b/include/xlnt/utils/exceptions.hpp index 25303da9..bff33038 100644 --- a/include/xlnt/utils/exceptions.hpp +++ b/include/xlnt/utils/exceptions.hpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include diff --git a/include/xlnt/utils/key_error.hpp b/include/xlnt/utils/key_error.hpp new file mode 100644 index 00000000..a757a5a2 --- /dev/null +++ b/include/xlnt/utils/key_error.hpp @@ -0,0 +1,41 @@ +// Copyright (c) 2014-2016 Thomas Fussell +// Copyright (c) 2010-2015 openpyxl +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, WRISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE +// +// @license: http://www.opensource.org/licenses/mit-license.php +// @author: see AUTHORS file +#pragma once + +#include + +#include + +namespace xlnt { + +/// +/// key_error +/// +class XLNT_CLASS key_error : public std::runtime_error +{ +public: + key_error(); +}; + +} // namespace xlnt diff --git a/include/xlnt/workbook/workbook.hpp b/include/xlnt/workbook/workbook.hpp index 9b5fde92..9ba429ca 100644 --- a/include/xlnt/workbook/workbook.hpp +++ b/include/xlnt/workbook/workbook.hpp @@ -92,6 +92,9 @@ public: bool get_data_only() const; void set_data_only(bool data_only); + + bool get_read_only() const; + void set_read_only(bool read_only); // create worksheet create_sheet(); diff --git a/include/xlnt/worksheet/worksheet.hpp b/include/xlnt/worksheet/worksheet.hpp index 2024cdf4..3761831a 100644 --- a/include/xlnt/worksheet/worksheet.hpp +++ b/include/xlnt/worksheet/worksheet.hpp @@ -175,6 +175,8 @@ public: const range operator[](const std::string &range_string) const; range operator()(const cell_reference &top_left, const cell_reference &bottom_right); const range operator()(const cell_reference &top_left, const cell_reference &bottom_right) const; + + bool compare(const worksheet &other, bool reference) const; // page page_setup &get_page_setup(); diff --git a/source/detail/workbook_impl.hpp b/source/detail/workbook_impl.hpp index af14665c..5f732f79 100644 --- a/source/detail/workbook_impl.hpp +++ b/source/detail/workbook_impl.hpp @@ -42,6 +42,7 @@ struct workbook_impl properties_(other.properties_), guess_types_(other.guess_types_), data_only_(other.data_only_), + read_only_(other.read_only_), styles_(other.styles_), colors_(other.colors_), borders_(other.borders_), @@ -69,6 +70,7 @@ struct workbook_impl properties_ = other.properties_; guess_types_ = other.guess_types_; data_only_ = other.data_only_; + read_only_ = other.read_only_; styles_ = other.styles_; borders_ = other.borders_; fills_ = other.fills_; @@ -91,6 +93,7 @@ struct workbook_impl bool guess_types_; bool data_only_; + bool read_only_; std::vector