From fd865782a8d38d98a06c39a52513c1d6a5af659f Mon Sep 17 00:00:00 2001 From: "Elena.Subbotina" Date: Sat, 4 Mar 2023 20:03:14 +0300 Subject: [PATCH] fix bug #60339 --- .../DocFormatLib/Windows/DocFormatLib.vcxproj | 4 +- OdfFile/Common/odf_elements_type.h | 4 +- OdfFile/Projects/Windows/OdfFormatW.vcxproj | 2 +- OdfFile/Projects/Windows/cpcommon.vcxproj | 4 +- OdfFile/Projects/Windows/cpodf.vcxproj | 4 +- OdfFile/Projects/Windows/cpxml.vcxproj | 4 +- .../Projects/Windows/formulasconvert.vcxproj | 4 +- .../Reader/Converter/xlsx_tablecontext.cpp | 4 +- OdfFile/Reader/Converter/xlsx_tablecontext.h | 2 +- OdfFile/Reader/Format/number_style.cpp | 19 ++++++-- OdfFile/Reader/Format/number_style.h | 47 ++++++++++++++++--- OdfFile/Reader/Format/styles.cpp | 2 +- OdfFile/Reader/Format/table.cpp | 5 +- OdfFile/Reader/Format/table.h | 10 ++++ .../Reader/Format/table_database_ranges.cpp | 2 +- OdfFile/Writer/Format/number_style.cpp | 24 ++++++++++ OdfFile/Writer/Format/number_style.h | 15 ++++++ 17 files changed, 129 insertions(+), 27 deletions(-) diff --git a/MsBinaryFile/Projects/DocFormatLib/Windows/DocFormatLib.vcxproj b/MsBinaryFile/Projects/DocFormatLib/Windows/DocFormatLib.vcxproj index 9b68add93a..432b699750 100644 --- a/MsBinaryFile/Projects/DocFormatLib/Windows/DocFormatLib.vcxproj +++ b/MsBinaryFile/Projects/DocFormatLib/Windows/DocFormatLib.vcxproj @@ -80,8 +80,8 @@ $(SolutionDir)$(Configuration)\ $(Configuration)\ - ..\..\..\Common\3dParty\boost\build\win_32\include;$(VC_IncludePath);$(WindowsSDK_IncludePath); - ..\..\..\Common\3dParty\boost\build\win_32\lib;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 + ..\..\..\..\Common\3dParty\boost\build\win_32\include;$(VC_IncludePath);$(WindowsSDK_IncludePath); + ..\..\..\..\Common\3dParty\boost\build\win_32\lib;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 $(SolutionDir)$(Platform)\$(Configuration)\ diff --git a/OdfFile/Common/odf_elements_type.h b/OdfFile/Common/odf_elements_type.h index a8048f7fa7..b940b9eee9 100644 --- a/OdfFile/Common/odf_elements_type.h +++ b/OdfFile/Common/odf_elements_type.h @@ -577,7 +577,9 @@ enum ElementType typeNumberEmbeddedText, typeNumberScientificNumber, typeNumberFraction, - typeNumberCurrencyStyle, + typeNumberBoolean, + typeNumberBooleanStyle, + typeNumberCurrencyStyle, typeNumberCurrencySymbol, typeNumberTextContent, typeNumberTextStyle, diff --git a/OdfFile/Projects/Windows/OdfFormatW.vcxproj b/OdfFile/Projects/Windows/OdfFormatW.vcxproj index 98da76624d..96390a65d6 100644 --- a/OdfFile/Projects/Windows/OdfFormatW.vcxproj +++ b/OdfFile/Projects/Windows/OdfFormatW.vcxproj @@ -273,7 +273,7 @@ $(Configuration)\ $(Configuration)\ - ..\..\..\Common\3dParty\boost\build\win_32\include;$(VC_IncludePath);$(WindowsSDK_IncludePath); + ..\..\..\Common\3dParty\boost\build\win_32\include;..\..\Common;$(VC_IncludePath);$(WindowsSDK_IncludePath); ..\..\..\Common\3dParty\boost\build\win_32\lib;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 diff --git a/OdfFile/Projects/Windows/cpcommon.vcxproj b/OdfFile/Projects/Windows/cpcommon.vcxproj index 001dc0021f..66028cf7a9 100644 --- a/OdfFile/Projects/Windows/cpcommon.vcxproj +++ b/OdfFile/Projects/Windows/cpcommon.vcxproj @@ -82,8 +82,8 @@ $(Configuration)\ $(Configuration)\ - ..\..\Common\3dParty\boost\build\win_32\include;$(VC_IncludePath);$(WindowsSDK_IncludePath); - ..\..\Common\3dParty\boost\build\win_32\lib;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 + ..\..\..\Common\3dParty\boost\build\win_32\include;$(VC_IncludePath);$(WindowsSDK_IncludePath); + ..\..\..\Common\3dParty\boost\build\win_32\lib;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 $(Platform)\$(Configuration)\ diff --git a/OdfFile/Projects/Windows/cpodf.vcxproj b/OdfFile/Projects/Windows/cpodf.vcxproj index 5fe5321e09..847eb44ca9 100644 --- a/OdfFile/Projects/Windows/cpodf.vcxproj +++ b/OdfFile/Projects/Windows/cpodf.vcxproj @@ -82,8 +82,8 @@ $(Configuration)\ $(Configuration)\ - ..\..\Common\3dParty\boost\build\win_32\include;$(VC_IncludePath);$(WindowsSDK_IncludePath); - ..\..\Common\3dParty\boost\build\win_32\lib;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 + ..\..\..\Common\3dParty\boost\build\win_32\include;..\..\Common;$(VC_IncludePath);$(WindowsSDK_IncludePath); + ..\..\..\Common\3dParty\boost\build\win_32\lib;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 $(Platform)\$(Configuration)\ diff --git a/OdfFile/Projects/Windows/cpxml.vcxproj b/OdfFile/Projects/Windows/cpxml.vcxproj index 20b1497045..67f4b42b08 100644 --- a/OdfFile/Projects/Windows/cpxml.vcxproj +++ b/OdfFile/Projects/Windows/cpxml.vcxproj @@ -99,8 +99,8 @@ $(Configuration)\ $(Configuration)\ - ..\..\Common\3dParty\boost\build\win_32\include;$(VC_IncludePath);$(WindowsSDK_IncludePath); - ..\..\Common\3dParty\boost\build\win_32\lib;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 + ..\..\..\Common\3dParty\boost\build\win_32\include;$(VC_IncludePath);$(WindowsSDK_IncludePath); + ..\..\..\Common\3dParty\boost\build\win_32\lib;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 $(Platform)\$(Configuration)\ diff --git a/OdfFile/Projects/Windows/formulasconvert.vcxproj b/OdfFile/Projects/Windows/formulasconvert.vcxproj index 2b588dbd9f..b8b6f20616 100644 --- a/OdfFile/Projects/Windows/formulasconvert.vcxproj +++ b/OdfFile/Projects/Windows/formulasconvert.vcxproj @@ -88,8 +88,8 @@ $(Configuration)\ $(Configuration)\ - ..\..\Common\3dParty\boost\build\win_32\include;$(VC_IncludePath);$(WindowsSDK_IncludePath); - ..\..\Common\3dParty\boost\build\win_32\lib;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 + ..\..\..\Common\3dParty\boost\build\win_32\include;..\..\Common;$(VC_IncludePath);$(WindowsSDK_IncludePath); + ..\..\..\Common\3dParty\boost\build\win_32\lib;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86 $(Platform)\$(Configuration)\ diff --git a/OdfFile/Reader/Converter/xlsx_tablecontext.cpp b/OdfFile/Reader/Converter/xlsx_tablecontext.cpp index b9ab45cf38..080f99cbd3 100644 --- a/OdfFile/Reader/Converter/xlsx_tablecontext.cpp +++ b/OdfFile/Reader/Converter/xlsx_tablecontext.cpp @@ -59,7 +59,7 @@ xlsx_table_state_ptr xlsx_table_context::state() return xlsx_table_state_ptr(); } -bool xlsx_table_context::start_database_range(const std::wstring & name, const std::wstring & ref) +bool xlsx_table_context::start_database_range(const std::wstring & name, const std::wstring & ref, bool bNamedRangeOnly) { formulasconvert::odf2oox_converter convert; std::wstring oox_ref = convert.convert_named_ref(ref); @@ -101,7 +101,7 @@ bool xlsx_table_context::start_database_range(const std::wstring & name, const s xlsx_data_ranges_.push_back(xlsx_data_range_ptr(new xlsx_data_range())); - if (/*name.find(L"__Anonymous_Sheet_DB__") != std::wstring::npos ||*/ col1 == col2) + if (/*name.find(L"__Anonymous_Sheet_DB__") != std::wstring::npos ||*/ col1 == col2 || bNamedRangeOnly) {//check range in pivots xlsx_data_ranges_.back()->bTablePart = false; } diff --git a/OdfFile/Reader/Converter/xlsx_tablecontext.h b/OdfFile/Reader/Converter/xlsx_tablecontext.h index d4867023ad..37f8933fd6 100644 --- a/OdfFile/Reader/Converter/xlsx_tablecontext.h +++ b/OdfFile/Reader/Converter/xlsx_tablecontext.h @@ -117,7 +117,7 @@ public: void dump_rels_hyperlinks (rels & Rels); void dump_rels_ole_objects (rels & Rels); - bool start_database_range(const std::wstring &table_name, const std::wstring &ref); + bool start_database_range(const std::wstring &table_name, const std::wstring &ref, bool bNamedRangeOnly); void set_database_orientation (bool val); void set_database_header (bool val); void set_database_filter (bool val); diff --git a/OdfFile/Reader/Format/number_style.cpp b/OdfFile/Reader/Format/number_style.cpp index 849e3a99e7..90c5b9ef11 100644 --- a/OdfFile/Reader/Format/number_style.cpp +++ b/OdfFile/Reader/Format/number_style.cpp @@ -201,14 +201,18 @@ void number_style_base::add_child_element( xml::sax * Reader, const std::wstring CP_CREATE_ELEMENT(content_); } } - +//------------------------------------------------------------------- // number:number-style -////////////////////////////////////////////////////////////////////////////////////////////////// const wchar_t * number_number_style::ns = L"number"; const wchar_t * number_number_style::name = L"number-style"; +//------------------------------------------------------------------- +// number:boolean-style +const wchar_t * number_boolean_style::ns = L"number"; +const wchar_t * number_boolean_style::name = L"boolean-style"; + +//------------------------------------------------------------------- // number:text -////////////////////////////////////////////////////////////////////////////////////////////////// const wchar_t * number_text::ns = L"number"; const wchar_t * number_text::name = L"text"; @@ -747,6 +751,15 @@ void number_am_pm::oox_convert(oox::num_format_context & Context) strm << L"AM/PM"; } +// number:boolean +////////////////////////////////////////////////////////////////////////////////////////////////// +const wchar_t * number_boolean::ns = L"number"; +const wchar_t * number_boolean::name = L"boolean"; + +void number_boolean::oox_convert(oox::num_format_context & Context) +{ + Context.type(odf_types::office_value_type::Boolean); +} // number:fraction ////////////////////////////////////////////////////////////////////////////////////////////////// const wchar_t * number_fraction::ns = L"number"; diff --git a/OdfFile/Reader/Format/number_style.h b/OdfFile/Reader/Format/number_style.h index febcb71ba5..a9ac992e9c 100644 --- a/OdfFile/Reader/Format/number_style.h +++ b/OdfFile/Reader/Format/number_style.h @@ -78,12 +78,26 @@ public: CPDOCCORE_DEFINE_VISITABLE(); CPDOCCORE_OFFICE_DOCUMENT_IMPL_NAME_FUNCS_; - }; - CP_REGISTER_OFFICE_ELEMENT2(number_number_style); -// number:currency-style +// number:boolean-style +class number_boolean_style : public number_style_base +{ +public: + static const wchar_t * ns; + static const wchar_t * name; + + static const xml::NodeType xml_type = xml::typeElement; + static const ElementType type = typeNumberBooleanStyle; + + CPDOCCORE_DEFINE_VISITABLE(); + CPDOCCORE_OFFICE_DOCUMENT_IMPL_NAME_FUNCS_; + +}; +CP_REGISTER_OFFICE_ELEMENT2(number_boolean_style); + +// number:currency-style class number_currency_style : public number_style_base { public: @@ -97,7 +111,6 @@ public: CPDOCCORE_OFFICE_DOCUMENT_IMPL_NAME_FUNCS_; }; - CP_REGISTER_OFFICE_ELEMENT2(number_currency_style); // number:text-style @@ -645,10 +658,32 @@ private: _CP_OPT(int) number_denominator_value_; _CP_OPT(int) number_min_numerator_digits_; _CP_OPT(int) number_min_denominator_digits_; - }; - CP_REGISTER_OFFICE_ELEMENT2(number_fraction); +// number:boolean +class number_boolean : public number_element +{ +public: + static const wchar_t * ns; + static const wchar_t * name; + + static const xml::NodeType xml_type = xml::typeElement; + static const ElementType type = typeNumberBoolean; + + CPDOCCORE_DEFINE_VISITABLE(); + CPDOCCORE_OFFICE_DOCUMENT_IMPL_NAME_FUNCS_; + + virtual void oox_convert(oox::num_format_context & Context); + +private: + virtual void add_attributes(const xml::attributes_wc_ptr & Attributes) {} + virtual void add_child_element(xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) {} + virtual void add_text(const std::wstring & Text) {} + virtual void add_space(const std::wstring & Text) {} + + +}; +CP_REGISTER_OFFICE_ELEMENT2(number_boolean); } } diff --git a/OdfFile/Reader/Format/styles.cpp b/OdfFile/Reader/Format/styles.cpp index e96d14ff12..d599047b6f 100644 --- a/OdfFile/Reader/Format/styles.cpp +++ b/OdfFile/Reader/Format/styles.cpp @@ -632,7 +632,7 @@ void styles::add_child_element( xml::sax * Reader, const std::wstring & Ns, cons CP_CHECK_NAME(L"number", L"date-style") || CP_CHECK_NAME(L"number", L"time-style") || CP_CHECK_NAME(L"number", L"text-style") || - CP_CHECK_NAME(L"number", L"number-boolean-style") + CP_CHECK_NAME(L"number", L"boolean-style") ) { CP_CREATE_ELEMENT_SIMPLE(number_styles_); diff --git a/OdfFile/Reader/Format/table.cpp b/OdfFile/Reader/Format/table.cpp index dda123e5f4..36e36c7a10 100644 --- a/OdfFile/Reader/Format/table.cpp +++ b/OdfFile/Reader/Format/table.cpp @@ -137,7 +137,10 @@ void table_table_source::add_child_element( xml::sax * Reader, const std::wstrin } ////////////////////////////////////////////////////////////////////////////////////////////////// // table:table-protection -const wchar_t * table_table_protection::ns = L"loext"; //?? table odf 1.3 +const wchar_t * loext_table_protection::ns = L"loext"; +const wchar_t * loext_table_protection::name = L"table-protection"; + +const wchar_t * table_table_protection::ns = L"table"; const wchar_t * table_table_protection::name = L"table-protection"; void table_table_protection::add_attributes( const xml::attributes_wc_ptr & Attributes ) diff --git a/OdfFile/Reader/Format/table.h b/OdfFile/Reader/Format/table.h index 79a0e4e600..963ff9f7b3 100644 --- a/OdfFile/Reader/Format/table.h +++ b/OdfFile/Reader/Format/table.h @@ -647,6 +647,16 @@ public: //_CP_OPT(bool) format_cells; }; CP_REGISTER_OFFICE_ELEMENT2(table_table_protection); +//---------------------------------------------------------- +class loext_table_protection : public table_table_protection +{ +public: + static const wchar_t * ns; + static const wchar_t * name; + static const xml::NodeType xml_type = xml::typeElement; + static const ElementType type = typeTableTableProtection; +}; +CP_REGISTER_OFFICE_ELEMENT2(loext_table_protection); //-------------------------------------------------------------------------------------------- class table_table : public office_element_impl { diff --git a/OdfFile/Reader/Format/table_database_ranges.cpp b/OdfFile/Reader/Format/table_database_ranges.cpp index 5229914a7c..30a062eee6 100644 --- a/OdfFile/Reader/Format/table_database_ranges.cpp +++ b/OdfFile/Reader/Format/table_database_ranges.cpp @@ -102,7 +102,7 @@ void table_database_range::xlsx_convert(oox::xlsx_conversion_context & Context) pFind->second++; } - if (Context.get_table_context().start_database_range(name, *table_target_range_address_)) + if (Context.get_table_context().start_database_range(name, *table_target_range_address_, content_.empty())) { if (table_display_filter_buttons_) Context.get_table_context().set_database_filter(table_display_filter_buttons_->get()); diff --git a/OdfFile/Writer/Format/number_style.cpp b/OdfFile/Writer/Format/number_style.cpp index d289c91f00..a6106fca64 100644 --- a/OdfFile/Writer/Format/number_style.cpp +++ b/OdfFile/Writer/Format/number_style.cpp @@ -345,6 +345,30 @@ void number_currency_style::serialize(std::wostream & strm) } } } +// number:boolean-style +////////////////////////////////////////////////////////////////////////////////////////////////// +const wchar_t * number_boolean_style::ns = L"number"; +const wchar_t * number_boolean_style::name = L"boolean-style"; + +void number_boolean_style::create_child_element(const std::wstring & Ns, const std::wstring & Name) +{ + number_style_base::create_child_element(Ns, Name, getContext()); +} +void number_boolean_style::add_child_element(const office_element_ptr & child) +{ + number_style_base::add_child_element(child); +} +void number_boolean_style::serialize(std::wostream & strm) +{ + CP_XML_WRITER(strm) + { + CP_XML_NODE_SIMPLE() + { + number_style_base::serialize(CP_GET_XML_NODE()); //attr + number_style_base::serialize(CP_XML_STREAM()); //nodes + } + } +} // number:text-content ////////////////////////////////////////////////////////////////////////////////////////////////// const wchar_t * number_text_content::ns = L"number"; diff --git a/OdfFile/Writer/Format/number_style.h b/OdfFile/Writer/Format/number_style.h index 2c2864e951..14f547b314 100644 --- a/OdfFile/Writer/Format/number_style.h +++ b/OdfFile/Writer/Format/number_style.h @@ -94,6 +94,21 @@ public: virtual void serialize(std::wostream & strm); }; CP_REGISTER_OFFICE_ELEMENT2(number_currency_style) +//------------------------------------------------------------------------------------------------------ +class number_boolean_style : public office_element_impl, number_style_base +{ +public: + virtual void create_child_element(const std::wstring & Ns, const std::wstring & Name); + virtual void add_child_element(const office_element_ptr & child); + + static const wchar_t * ns; + static const wchar_t * name; + + static const ElementType type = typeNumberBooleanStyle; + + virtual void serialize(std::wostream & strm); +}; +CP_REGISTER_OFFICE_ELEMENT2(number_boolean_style) //------------------------------------------------------------------------------------------------------ class number_text_style : public office_element_impl, public number_style_base