From 8ba7535fc88bb505452cd412aff36b64991f4c0f Mon Sep 17 00:00:00 2001 From: Elena Subbotina Date: Tue, 29 Apr 2025 16:42:02 +0300 Subject: [PATCH] fix bug #74281 --- OdfFile/Common/odf_elements_type.h | 1 + OdfFile/Reader/Format/office_body.cpp | 3 +- OdfFile/Reader/Format/office_drawing.cpp | 112 +------------------- OdfFile/Reader/Format/office_drawing.h | 41 +++---- OdfFile/Reader/Format/office_presentation.h | 1 - 5 files changed, 17 insertions(+), 141 deletions(-) diff --git a/OdfFile/Common/odf_elements_type.h b/OdfFile/Common/odf_elements_type.h index cc0aa85cd9..e133c5bc0d 100644 --- a/OdfFile/Common/odf_elements_type.h +++ b/OdfFile/Common/odf_elements_type.h @@ -576,6 +576,7 @@ enum ElementType typeOfficeScript, typeOfficePresentation, typeOfficeDrawing, + typeOfficeGraphics, typeOfficeChart, typeOfficeEventListeners, diff --git a/OdfFile/Reader/Format/office_body.cpp b/OdfFile/Reader/Format/office_body.cpp index 4b57d6636d..da84fd915a 100644 --- a/OdfFile/Reader/Format/office_body.cpp +++ b/OdfFile/Reader/Format/office_body.cpp @@ -76,7 +76,8 @@ void office_body::add_child_element( xml::sax * Reader, const std::wstring & Ns, (L"chart" == Name) || (L"drawing" == Name) || (L"image" == Name) || - (L"database" == Name))) + (L"database" == Name) || + (L"graphics" == Name))) { CP_CREATE_ELEMENT(content_); } diff --git a/OdfFile/Reader/Format/office_drawing.cpp b/OdfFile/Reader/Format/office_drawing.cpp index 572e074a73..412ceeb55d 100644 --- a/OdfFile/Reader/Format/office_drawing.cpp +++ b/OdfFile/Reader/Format/office_drawing.cpp @@ -46,115 +46,7 @@ namespace odf_reader { const wchar_t* office_drawing::ns = L"office"; const wchar_t* office_drawing::name = L"drawing"; -void office_drawing::add_child_element(xml::sax* Reader, const std::wstring& Ns, const std::wstring& Name) -{ - if CP_CHECK_NAME(L"draw", L"page") - { - CP_CREATE_ELEMENT(pages_); - } - else if CP_CHECK_NAME(L"table", L"tracked-changes") - { - CP_CREATE_ELEMENT(tracked_changes_); - } - else if CP_CHECK_NAME(L"table", L"content-validations") - { - CP_CREATE_ELEMENT(content_validations_); - } - else if CP_CHECK_NAME(L"presentation", L"footer-decl") - { - CP_CREATE_ELEMENT(footer_decls_); - } - else if CP_CHECK_NAME(L"presentation", L"date-time-decl") - { - CP_CREATE_ELEMENT(date_time_decls_); - } - else if CP_CHECK_NAME(L"text", L"user-field-decls") - { - CP_CREATE_ELEMENT(user_fields_); - } - else if CP_CHECK_NAME(L"text", L"sequence-decls") - { - CP_CREATE_ELEMENT(sequences_); - } - else if CP_CHECK_NAME(L"text", L"variable-decls") - { - CP_CREATE_ELEMENT(variables_); - } -} - -void office_drawing::add_text(const std::wstring& Text) -{ -} - -void office_drawing::add_attributes(const xml::attributes_wc_ptr& Attributes) -{ -} - -void office_drawing::docx_convert(oox::docx_conversion_context& Context) -{ - Context.start_office_text(); - _CP_LOG << L"[info][docx] process pages (" << pages_.size() << L" elmements)" << std::endl; - - for (size_t i = 0; i < pages_.size(); i++) - { - pages_[i]->docx_convert(Context); - } - Context.end_office_text(); -} - -void office_drawing::xlsx_convert(oox::xlsx_conversion_context& Context) -{ - Context.start_office_spreadsheet(this); - _CP_LOG << L"[info][xlsx] process pages (" << pages_.size() << L" elmements)" << std::endl; - - for (size_t i = 0; i < pages_.size(); i++) - { - pages_[i]->xlsx_convert(Context); - } - Context.end_office_spreadsheet(); -} - -void office_drawing::pptx_convert(oox::pptx_conversion_context& Context) -{ - Context.start_office_presentation(); - - _CP_LOG << L"[info][pptx] process pages(" << pages_.size() << L" elmements)" << std::endl; - - for (size_t i = 0; i < footer_decls_.size(); i++) - { - presentation_footer_decl* style = dynamic_cast(footer_decls_[i].get()); - - if (!style) - continue; - - std::wstring style_name_ = L"footer:" + style->presentation_name_.get_value_or(L""); - Context.root()->odf_context().drawStyles().add(style_name_, footer_decls_[i]); - } - for (size_t i = 0; i < date_time_decls_.size(); i++) - { - presentation_date_time_decl* style = dynamic_cast(date_time_decls_[i].get()); - - if (!style) - continue; - - std::wstring style_name_ = L"datetime:" + style->presentation_name_.get_value_or(L""); - Context.root()->odf_context().drawStyles().add(style_name_, date_time_decls_[i]); - } - if (user_fields_) - user_fields_->pptx_convert(Context); - - if (variables_) - variables_->pptx_convert(Context); - - if (sequences_) - sequences_->pptx_convert(Context); - - for (size_t i = 0; i < pages_.size(); i++) - { - pages_[i]->pptx_convert(Context); - } - Context.end_office_presentation(); -} - +const wchar_t* office_graphics::ns = L"office"; +const wchar_t* office_graphics::name = L"graphics"; } } diff --git a/OdfFile/Reader/Format/office_drawing.h b/OdfFile/Reader/Format/office_drawing.h index cb76f595b0..d4cdb3d68c 100644 --- a/OdfFile/Reader/Format/office_drawing.h +++ b/OdfFile/Reader/Format/office_drawing.h @@ -33,47 +33,30 @@ #include -#include "office_elements.h" -#include "office_elements_create.h" +#include "office_presentation.h" namespace cpdoccore { namespace odf_reader { -class office_drawing : public office_element_impl +class office_drawing : public office_presentation { public: static const wchar_t* ns; static const wchar_t* name; static const xml::NodeType xml_type = xml::typeElement; static const ElementType type = typeOfficeDrawing; - CPDOCCORE_DEFINE_VISITABLE(); - - virtual void docx_convert(oox::docx_conversion_context& Context); - virtual void xlsx_convert(oox::xlsx_conversion_context& Context); - virtual void pptx_convert(oox::pptx_conversion_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); - -public: - - office_element_ptr tracked_changes_; - office_element_ptr content_validations_; - - office_element_ptr_array date_time_decls_; - office_element_ptr_array footer_decls_; - - office_element_ptr_array pages_; - - office_element_ptr user_fields_; - office_element_ptr variables_; - office_element_ptr sequences_; - }; - CP_REGISTER_OFFICE_ELEMENT2(office_drawing); +class office_graphics : public office_presentation +{ +public: + static const wchar_t* ns; + static const wchar_t* name; + static const xml::NodeType xml_type = xml::typeElement; + static const ElementType type = typeOfficeGraphics; +}; +CP_REGISTER_OFFICE_ELEMENT2(office_graphics); + } // namespace odf_reader } // namespace cpdoccore diff --git a/OdfFile/Reader/Format/office_presentation.h b/OdfFile/Reader/Format/office_presentation.h index f3a0b929c5..aefa21b41d 100644 --- a/OdfFile/Reader/Format/office_presentation.h +++ b/OdfFile/Reader/Format/office_presentation.h @@ -75,7 +75,6 @@ public: office_element_ptr sequences_; }; - CP_REGISTER_OFFICE_ELEMENT2(office_presentation); }