mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
improve property handling, comment serialization
This commit is contained in:
parent
9535f94e38
commit
0db50a7b15
@ -56,10 +56,13 @@ struct workbook_impl
|
|||||||
shared_strings_(other.shared_strings_),
|
shared_strings_(other.shared_strings_),
|
||||||
stylesheet_(other.stylesheet_),
|
stylesheet_(other.stylesheet_),
|
||||||
manifest_(other.manifest_),
|
manifest_(other.manifest_),
|
||||||
theme_(other.theme_),
|
theme_(other.theme_),
|
||||||
view_(other.view_),
|
core_properties_(other.core_properties_),
|
||||||
code_name_(other.code_name_),
|
extended_properties_(other.extended_properties_),
|
||||||
file_version_(other.file_version_)
|
custom_properties_(other.custom_properties_),
|
||||||
|
view_(other.view_),
|
||||||
|
code_name_(other.code_name_),
|
||||||
|
file_version_(other.file_version_)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,6 +81,10 @@ struct workbook_impl
|
|||||||
code_name_ = other.code_name_;
|
code_name_ = other.code_name_;
|
||||||
file_version_ = other.file_version_;
|
file_version_ = other.file_version_;
|
||||||
|
|
||||||
|
core_properties_ = other.core_properties_;
|
||||||
|
extended_properties_ = other.extended_properties_;
|
||||||
|
custom_properties_ = other.custom_properties_;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,6 +331,8 @@ void xlsx_producer::write_core_properties(const relationship &/*rel*/)
|
|||||||
auto core_properties = source_.core_properties();
|
auto core_properties = source_.core_properties();
|
||||||
std::unordered_map<std::string, std::string> namespaces;
|
std::unordered_map<std::string, std::string> namespaces;
|
||||||
|
|
||||||
|
write_namespace(constants::ns("core-properties"), "cp");
|
||||||
|
|
||||||
for (const auto &prop : core_properties)
|
for (const auto &prop : core_properties)
|
||||||
{
|
{
|
||||||
for (const auto &ns : core_property_namespace(prop))
|
for (const auto &ns : core_property_namespace(prop))
|
||||||
@ -525,11 +527,6 @@ void xlsx_producer::write_workbook(const relationship &rel)
|
|||||||
|
|
||||||
write_start_element(xmlns, "sheets");
|
write_start_element(xmlns, "sheets");
|
||||||
|
|
||||||
if (any_defined_names)
|
|
||||||
{
|
|
||||||
write_element(xmlns, "definedNames", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma clang diagnostic push
|
#pragma clang diagnostic push
|
||||||
#pragma clang diagnostic ignored "-Wrange-loop-analysis"
|
#pragma clang diagnostic ignored "-Wrange-loop-analysis"
|
||||||
for (const auto ws : source_)
|
for (const auto ws : source_)
|
||||||
@ -547,26 +544,25 @@ void xlsx_producer::write_workbook(const relationship &rel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
write_attribute(xml::qname(xmlns_r, "id"), sheet_rel_id);
|
write_attribute(xml::qname(xmlns_r, "id"), sheet_rel_id);
|
||||||
|
|
||||||
if (ws.has_auto_filter())
|
|
||||||
{
|
|
||||||
write_start_element(xmlns, "definedName");
|
|
||||||
|
|
||||||
write_attribute("name", "_xlnm._FilterDatabase");
|
|
||||||
write_attribute("hidden", write_bool(true));
|
|
||||||
write_attribute("localSheetId", "0");
|
|
||||||
write_characters(
|
|
||||||
"'" + ws.title() + "'!" + range_reference::make_absolute(ws.auto_filter()).to_string());
|
|
||||||
|
|
||||||
write_end_element(xmlns, "definedName");
|
|
||||||
}
|
|
||||||
|
|
||||||
write_end_element(xmlns, "sheet");
|
write_end_element(xmlns, "sheet");
|
||||||
}
|
}
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
|
|
||||||
write_end_element(xmlns, "sheets");
|
write_end_element(xmlns, "sheets");
|
||||||
|
|
||||||
|
if (any_defined_names)
|
||||||
|
{
|
||||||
|
write_start_element(xmlns, "definedNames");
|
||||||
|
/*
|
||||||
|
write_attribute("name", "_xlnm._FilterDatabase");
|
||||||
|
write_attribute("hidden", write_bool(true));
|
||||||
|
write_attribute("localSheetId", "0");
|
||||||
|
write_characters("'" + ws.title() + "'!" +
|
||||||
|
range_reference::make_absolute(ws.auto_filter()).to_string());
|
||||||
|
*/
|
||||||
|
write_end_element(xmlns, "definedNames");
|
||||||
|
}
|
||||||
|
|
||||||
if (source_.has_calculation_properties())
|
if (source_.has_calculation_properties())
|
||||||
{
|
{
|
||||||
write_start_element(xmlns, "calcPr");
|
write_start_element(xmlns, "calcPr");
|
||||||
@ -709,6 +705,14 @@ void xlsx_producer::write_workbook(const relationship &rel)
|
|||||||
void xlsx_producer::write_calculation_chain(const relationship & /*rel*/)
|
void xlsx_producer::write_calculation_chain(const relationship & /*rel*/)
|
||||||
{
|
{
|
||||||
write_start_element(constants::ns("spreadsheetml"), "calcChain");
|
write_start_element(constants::ns("spreadsheetml"), "calcChain");
|
||||||
|
write_namespace(constants::ns("spreadsheetml"), "");
|
||||||
|
/*
|
||||||
|
write_start_element(constants::ns("spreadsheetml"), "c");
|
||||||
|
write_attribute("r", "B2");
|
||||||
|
write_attribute("i", "1");
|
||||||
|
write_attribute("l", "1");
|
||||||
|
write_end_element(constants::ns("spreadsheetml"), "c");
|
||||||
|
*/
|
||||||
write_end_element(constants::ns("spreadsheetml"), "calcChain");
|
write_end_element(constants::ns("spreadsheetml"), "calcChain");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2835,10 +2839,10 @@ void xlsx_producer::write_vml_drawings(const relationship &rel, worksheet ws, co
|
|||||||
std::vector<std::pair<std::string, std::string>> style;
|
std::vector<std::pair<std::string, std::string>> style;
|
||||||
|
|
||||||
style.push_back({"position", "absolute"});
|
style.push_back({"position", "absolute"});
|
||||||
style.push_back({"margin-left", std::to_string(comment.left())});
|
style.push_back({"margin-left", std::to_string(comment.left()) + "pt"});
|
||||||
style.push_back({"margin-top", std::to_string(comment.top())});
|
style.push_back({"margin-top", std::to_string(comment.top()) + "pt"});
|
||||||
style.push_back({"width", std::to_string(comment.width())});
|
style.push_back({"width", std::to_string(comment.width()) + "pt"});
|
||||||
style.push_back({"height", std::to_string(comment.height())});
|
style.push_back({"height", std::to_string(comment.height()) + "pt"});
|
||||||
style.push_back({"z-index", std::to_string(comment_index + 1)});
|
style.push_back({"z-index", std::to_string(comment_index + 1)});
|
||||||
style.push_back({"visibility", comment.visible() ? "visible" : "hidden"});
|
style.push_back({"visibility", comment.visible() ? "visible" : "hidden"});
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public:
|
|||||||
return xml_helper::xlsx_archives_match(source_decrypted, destination);
|
return xml_helper::xlsx_archives_match(source_decrypted, destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_round_trip_empty_excel_rw()
|
void test_round_trip_rw()
|
||||||
{
|
{
|
||||||
const auto files = std::vector<std::string>
|
const auto files = std::vector<std::string>
|
||||||
{
|
{
|
||||||
@ -64,7 +64,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_round_trip_empty_excel_rw_encrypted()
|
void test_round_trip_rw_encrypted()
|
||||||
{
|
{
|
||||||
const auto files = std::vector<std::string>
|
const auto files = std::vector<std::string>
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user