mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
fix worksheet reordering on save
This commit is contained in:
parent
ea46558d2c
commit
0efb3d2f97
|
@ -7,5 +7,5 @@ fi
|
|||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
cmake -G "Unix Makefiles" ..
|
||||
make
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -201,6 +201,65 @@ public:
|
|||
if(type_ == type::pattern)
|
||||
{
|
||||
hash_combine(seed, static_cast<std::size_t>(pattern_type_));
|
||||
hash_combine(seed, foreground_color_assigned_);
|
||||
|
||||
if(foreground_color_assigned_)
|
||||
{
|
||||
hash_combine(seed, static_cast<std::size_t>(foreground_color_.get_type()));
|
||||
|
||||
switch(foreground_color_.get_type())
|
||||
{
|
||||
case color::type::auto_:
|
||||
hash_combine(seed, static_cast<std::size_t>(foreground_color_.get_auto()));
|
||||
break;
|
||||
case color::type::indexed:
|
||||
hash_combine(seed, static_cast<std::size_t>(foreground_color_.get_index()));
|
||||
break;
|
||||
case color::type::theme:
|
||||
hash_combine(seed, static_cast<std::size_t>(foreground_color_.get_theme()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
hash_combine(seed, background_color_assigned_);
|
||||
|
||||
if(background_color_assigned_)
|
||||
{
|
||||
hash_combine(seed, static_cast<std::size_t>(background_color_.get_type()));
|
||||
|
||||
switch(foreground_color_.get_type())
|
||||
{
|
||||
case color::type::auto_:
|
||||
hash_combine(seed, static_cast<std::size_t>(background_color_.get_auto()));
|
||||
break;
|
||||
case color::type::indexed:
|
||||
hash_combine(seed, static_cast<std::size_t>(background_color_.get_index()));
|
||||
break;
|
||||
case color::type::theme:
|
||||
hash_combine(seed, static_cast<std::size_t>(background_color_.get_theme()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(type_ == type::gradient)
|
||||
{
|
||||
hash_combine(seed, static_cast<std::size_t>(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<std::size_t>());
|
||||
}
|
||||
|
||||
return seed;
|
||||
|
|
Binary file not shown.
|
@ -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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -108,14 +108,21 @@ void excel_writer::write_chartsheets(zip_file &/*archive*/)
|
|||
|
||||
void excel_writer::write_worksheets(zip_file &archive, const std::vector<std::string> &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++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -356,6 +356,8 @@ std::string style_writer::write_table() const
|
|||
"ff000000",
|
||||
"ffaaaaaa",
|
||||
"ffbdc0bf",
|
||||
"ffdbdbdb",
|
||||
"ffbdc0bf",
|
||||
"ffdbdbdb"
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user