diff --git a/source/detail/xlsx_producer.cpp b/source/detail/xlsx_producer.cpp index 27fff391..e4b5d877 100644 --- a/source/detail/xlsx_producer.cpp +++ b/source/detail/xlsx_producer.cpp @@ -193,7 +193,7 @@ void xlsx_producer::write_content_types() write_end_element(xmlns, "Types"); } -void xlsx_producer::write_property(const std::string &name, const variant &value, const std::string &ns, bool custom) +void xlsx_producer::write_property(const std::string &name, const variant &value, const std::string &ns, bool custom, std::size_t pid) { if (custom) { @@ -214,27 +214,41 @@ void xlsx_producer::write_property(const std::string &name, const variant &value if (custom) { write_attribute("fmtid", "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}"); - write_attribute("pid", 2); + write_attribute("pid", pid); + write_start_element(constants::ns("vt"), "bool"); } write_characters(write_bool(value.get())); + + if (custom) + { + write_end_element(constants::ns("vt"), "bool"); + } + break; case variant::type::i4: if (custom) { write_attribute("fmtid", "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}"); - write_attribute("pid", 2); + write_attribute("pid", pid); + write_start_element(constants::ns("vt"), "i4"); } write_characters(value.get()); + + if (custom) + { + write_end_element(constants::ns("vt"), "i4"); + } + break; case variant::type::lpstr: if (custom) { write_attribute("fmtid", "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}"); - write_attribute("pid", 2); + write_attribute("pid", pid); write_start_element(constants::ns("vt"), "lpwstr"); } @@ -332,7 +346,7 @@ void xlsx_producer::write_core_properties(const relationship &/*rel*/) for (const auto &prop : core_properties) { write_property(to_string(prop), source_.core_property(prop), - core_property_namespace(prop).front().first, false); + core_property_namespace(prop).front().first, false, 0); } write_end_element(constants::ns("core-properties"), "coreProperties"); @@ -352,7 +366,7 @@ void xlsx_producer::write_extended_properties(const relationship &/*rel*/) for (const auto &prop : source_.extended_properties()) { write_property(to_string(prop), source_.extended_property(prop), - constants::ns("extended-properties"), false); + constants::ns("extended-properties"), false, 0); } write_end_element(constants::ns("extended-properties"), "Properties"); @@ -364,10 +378,12 @@ void xlsx_producer::write_custom_properties(const relationship &/*rel*/) write_namespace(constants::ns("custom-properties"), ""); write_namespace(constants::ns("vt"), "vt"); + auto pid = std::size_t(2); // why does this start at 2? + for (const auto &prop : source_.custom_properties()) { write_property(prop, source_.custom_property(prop), - constants::ns("custom-properties"), true); + constants::ns("custom-properties"), true, pid++); } write_end_element(constants::ns("custom-properties"), "Properties"); diff --git a/source/detail/xlsx_producer.hpp b/source/detail/xlsx_producer.hpp index 992f6e6b..dd77c8af 100644 --- a/source/detail/xlsx_producer.hpp +++ b/source/detail/xlsx_producer.hpp @@ -71,7 +71,7 @@ private: // Package Parts void write_content_types(); - void write_property(const std::string &name, const variant &value, const std::string &ns, bool custom); + void write_property(const std::string &name, const variant &value, const std::string &ns, bool custom, std::size_t pid); void write_core_properties(const relationship &rel); void write_extended_properties(const relationship &rel); void write_custom_properties(const relationship &rel); diff --git a/tests/data/15_basic_comments.xlsx b/tests/data/10_comments_hyperlinks_formulae.xlsx similarity index 100% rename from tests/data/15_basic_comments.xlsx rename to tests/data/10_comments_hyperlinks_formulae.xlsx diff --git a/tests/data/18_headers_and_footers.xlsx b/tests/data/11_print_settings.xlsx similarity index 100% rename from tests/data/18_headers_and_footers.xlsx rename to tests/data/11_print_settings.xlsx diff --git a/tests/data/19_row_and_col_properties.xlsx b/tests/data/12_advanced_properties.xlsx similarity index 100% rename from tests/data/19_row_and_col_properties.xlsx rename to tests/data/12_advanced_properties.xlsx diff --git a/tests/data/17_with_hyperlink.xlsx b/tests/data/17_with_hyperlink.xlsx deleted file mode 100644 index b45e444a..00000000 Binary files a/tests/data/17_with_hyperlink.xlsx and /dev/null differ diff --git a/tests/data/1_blank.xlsx b/tests/data/1_blank.xlsx deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/data/7_presentation.xlsx b/tests/data/1_powerpoint_presentation.xlsx similarity index 100% rename from tests/data/7_presentation.xlsx rename to tests/data/1_powerpoint_presentation.xlsx diff --git a/tests/data/20_page_breaks.xlsx b/tests/data/20_page_breaks.xlsx deleted file mode 100644 index b4eb6f28..00000000 Binary files a/tests/data/20_page_breaks.xlsx and /dev/null differ diff --git a/tests/data/21_custom_properties.xlsx b/tests/data/21_custom_properties.xlsx deleted file mode 100644 index a46a01f5..00000000 Binary files a/tests/data/21_custom_properties.xlsx and /dev/null differ diff --git a/tests/data/22_formulae.xlsx b/tests/data/22_formulae.xlsx deleted file mode 100644 index e450aec0..00000000 Binary files a/tests/data/22_formulae.xlsx and /dev/null differ diff --git a/tests/data/8_minimal.xlsx b/tests/data/2_minimal.xlsx similarity index 100% rename from tests/data/8_minimal.xlsx rename to tests/data/2_minimal.xlsx diff --git a/tests/data/2_text.xlsx b/tests/data/2_text.xlsx deleted file mode 100644 index be394c40..00000000 --- a/tests/data/2_text.xlsx +++ /dev/null @@ -1 +0,0 @@ -not-empty \ No newline at end of file diff --git a/tests/data/9_default-excel.xlsx b/tests/data/3_default.xlsx similarity index 100% rename from tests/data/9_default-excel.xlsx rename to tests/data/3_default.xlsx diff --git a/tests/data/3_empty-zip.xlsx b/tests/data/3_empty-zip.xlsx deleted file mode 100644 index 15cb0ecb..00000000 Binary files a/tests/data/3_empty-zip.xlsx and /dev/null differ diff --git a/tests/data/10_all_styles.xlsx b/tests/data/4_every_style.xlsx similarity index 100% rename from tests/data/10_all_styles.xlsx rename to tests/data/4_every_style.xlsx diff --git a/tests/data/4_not-package.xlsx b/tests/data/4_not-package.xlsx deleted file mode 100644 index 909c7b62..00000000 Binary files a/tests/data/4_not-package.xlsx and /dev/null differ diff --git a/tests/data/11_encrypted_excel_2016.xlsx b/tests/data/5_encrypted_agile.xlsx similarity index 100% rename from tests/data/11_encrypted_excel_2016.xlsx rename to tests/data/5_encrypted_agile.xlsx diff --git a/tests/data/5_visio.xlsx b/tests/data/5_visio.xlsx deleted file mode 100644 index 32b6589e..00000000 Binary files a/tests/data/5_visio.xlsx and /dev/null differ diff --git a/tests/data/6_document.xlsx b/tests/data/6_document.xlsx deleted file mode 100644 index 2d846668..00000000 Binary files a/tests/data/6_document.xlsx and /dev/null differ diff --git a/tests/data/12_encrypted_libre_office.xlsx b/tests/data/6_encrypted_libre.xlsx similarity index 100% rename from tests/data/12_encrypted_libre_office.xlsx rename to tests/data/6_encrypted_libre.xlsx diff --git a/tests/data/13_encrypted_excel_2007.xlsx b/tests/data/7_encrypted_standard.xlsx similarity index 100% rename from tests/data/13_encrypted_excel_2007.xlsx rename to tests/data/7_encrypted_standard.xlsx diff --git a/tests/data/14_encrypted_numbers.xlsx b/tests/data/8_encrypted_numbers.xlsx similarity index 100% rename from tests/data/14_encrypted_numbers.xlsx rename to tests/data/8_encrypted_numbers.xlsx diff --git a/tests/data/16_unicode_Λ.xlsx b/tests/data/9_unicode_filename_Λ.xlsx similarity index 100% rename from tests/data/16_unicode_Λ.xlsx rename to tests/data/9_unicode_filename_Λ.xlsx