diff --git a/build/cmake/build-osx.sh b/build/cmake/build-osx.sh index 57fabcae..c1c565c4 100755 --- a/build/cmake/build-osx.sh +++ b/build/cmake/build-osx.sh @@ -7,5 +7,5 @@ fi mkdir build cd build -cmake .. +cmake -G "Unix Makefiles" .. make diff --git a/build/cmake/xlnt/CMakeLists.txt b/build/cmake/xlnt/CMakeLists.txt index 5284a473..2a72bd28 100644 --- a/build/cmake/xlnt/CMakeLists.txt +++ b/build/cmake/xlnt/CMakeLists.txt @@ -5,7 +5,7 @@ include_directories(../../../source) include_directories(../../../third-party/miniz) include_directories(../../../third-party/pugixml/src) -FILE(GLOB SOURCES ../../../source/*/*.cpp) +FILE(GLOB SOURCES ../../../source/*/* ../../../include/xlnt/*/*.hpp ../../../include/xlnt/*.hpp) FILE(GLOB DETAIL_SOURCES ../../../source/detail/*.cpp) add_library(xlnt STATIC ${SOURCES} ${DETAIL_SOURCES} ../../../third-party/pugixml/src/pugixml.cpp ../../../third-party/miniz/miniz.c) diff --git a/include/xlnt/styles/fill.hpp b/include/xlnt/styles/fill.hpp index cfde640a..831c6f38 100644 --- a/include/xlnt/styles/fill.hpp +++ b/include/xlnt/styles/fill.hpp @@ -201,6 +201,65 @@ public: 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; + } + } + + 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; + } + } + } + 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; diff --git a/samples/sample1.xlsx b/samples/sample1.xlsx index 2b37bd14..12da556a 100644 Binary files a/samples/sample1.xlsx and b/samples/sample1.xlsx differ diff --git a/source/reader/style_reader.cpp b/source/reader/style_reader.cpp index b70ee959..640da5cc 100644 --- a/source/reader/style_reader.cpp +++ b/source/reader/style_reader.cpp @@ -280,6 +280,14 @@ void style_reader::read_fills(pugi::xml_node fills_node) { new_fill.set_background_color(color(color::type::indexed, bg_color_node.attribute("indexed").as_ullong())); } + else if(bg_color_node.attribute("auto") != nullptr) + { + new_fill.set_background_color(color(color::type::auto_, bg_color_node.attribute("auto").as_ullong())); + } + else if(bg_color_node.attribute("theme") != nullptr) + { + new_fill.set_background_color(color(color::type::theme, bg_color_node.attribute("theme").as_ullong())); + } } auto fg_color_node = pattern_fill_node.child("fgColor"); @@ -290,6 +298,14 @@ void style_reader::read_fills(pugi::xml_node fills_node) { new_fill.set_foreground_color(color(color::type::indexed, fg_color_node.attribute("indexed").as_ullong())); } + else if(fg_color_node.attribute("auto") != nullptr) + { + new_fill.set_foreground_color(color(color::type::auto_, fg_color_node.attribute("auto").as_ullong())); + } + else if(fg_color_node.attribute("theme") != nullptr) + { + new_fill.set_foreground_color(color(color::type::theme, fg_color_node.attribute("theme").as_ullong())); + } } } diff --git a/source/workbook/workbook.cpp b/source/workbook/workbook.cpp index e3997df4..7d378895 100644 --- a/source/workbook/workbook.cpp +++ b/source/workbook/workbook.cpp @@ -298,8 +298,16 @@ void workbook::remove_sheet(worksheet ws) { throw std::runtime_error("worksheet not owned by this workbook"); } - + auto sheet_filename = "xl/worksheets/sheet" + std::to_string(d_->worksheets_.size()) + ".xml"; + auto rel_iter = std::find_if(d_->relationships_.begin(), d_->relationships_.end(), [=](relationship &r) { return r.get_target_uri() == sheet_filename; }); + + if(rel_iter == d_->relationships_.end()) + { + throw std::runtime_error("no matching rel found"); + } + + d_->relationships_.erase(rel_iter); d_->worksheets_.erase(match_iter); } diff --git a/source/writer/excel_writer.cpp b/source/writer/excel_writer.cpp index a38e5a69..80d5b66c 100644 --- a/source/writer/excel_writer.cpp +++ b/source/writer/excel_writer.cpp @@ -108,14 +108,21 @@ void excel_writer::write_chartsheets(zip_file &/*archive*/) void excel_writer::write_worksheets(zip_file &archive, const std::vector &shared_strings) { - for(auto relationship : wb_.get_relationships()) + std::size_t index = 0; + + for(auto ws : wb_) { - if(relationship.get_type() == relationship::type::worksheet) + for(auto relationship : wb_.get_relationships()) { - auto sheet_index = workbook::index_from_ws_filename(relationship.get_target_uri()); - auto ws = wb_.get_sheet_by_index(sheet_index); - archive.writestr(relationship.get_target_uri(), write_worksheet(ws, shared_strings)); + if(relationship.get_type() == relationship::type::worksheet && + workbook::index_from_ws_filename(relationship.get_target_uri()) == index) + { + archive.writestr(relationship.get_target_uri(), write_worksheet(ws, shared_strings)); + break; + } } + + index++; } } diff --git a/source/writer/style_writer.cpp b/source/writer/style_writer.cpp index e313ef68..fe58f3cb 100644 --- a/source/writer/style_writer.cpp +++ b/source/writer/style_writer.cpp @@ -356,6 +356,8 @@ std::string style_writer::write_table() const "ff000000", "ffaaaaaa", "ffbdc0bf", + "ffdbdbdb", + "ffbdc0bf", "ffdbdbdb" };