diff --git a/ASCOfficeOdfFile/include/common/readdocelement.h b/ASCOfficeOdfFile/include/common/readdocelement.h index 1b0ed09ea6..d61a0eb8f8 100644 --- a/ASCOfficeOdfFile/include/common/readdocelement.h +++ b/ASCOfficeOdfFile/include/common/readdocelement.h @@ -37,41 +37,38 @@ namespace cpdoccore { -namespace xml { + namespace xml { -class sax; + class sax; + class attributes; -class attributes; + typedef attributes attributes_wc; + typedef shared_ptr< attributes_wc >::Type attributes_wc_ptr; -typedef attributes attributes_wc; + } + namespace common + { -typedef shared_ptr< attributes_wc >::Type attributes_wc_ptr; + // Базовый класс для элемента, который может быть прочитан sax-reader -ом + // Для каждого элемента будут вызваны методы + // add_attributes, add_child_element, add_text как колбеки для чтения соответствующих данных -} - -namespace common { - -// Базовый класс для элемента, который может быть прочитан sax-reader -ом -// Для каждого элемента будут вызваны методы -// add_attributes, add_child_element, add_text как колбеки для чтения соответствующих данных - -class read_doc_element -{ -public: - bool read_sax( xml::sax * Reader); - virtual ~read_doc_element() = 0; - - virtual void add_child_element ( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) = 0; -private: - virtual void add_attributes (const xml::attributes_wc_ptr & Attributes) = 0; - virtual void add_text (const std::wstring & Text) = 0; - virtual void add_space (const std::wstring & Text) = 0; - -}; - -inline read_doc_element::~read_doc_element() -{ -} - -} + class read_doc_element + { + public: + bool read_sax( xml::sax * Reader); + virtual ~read_doc_element() = 0; + + virtual void add_child_element ( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) = 0; + virtual void add_attributes (const xml::attributes_wc_ptr & Attributes) = 0; + private: + virtual void add_text (const std::wstring & Text) = 0; + virtual void add_space (const std::wstring & Text) = 0; + }; + + inline read_doc_element::~read_doc_element() + { + } + + } } diff --git a/ASCOfficeOdfFile/include/odf/odf_elements_type.h b/ASCOfficeOdfFile/include/odf/odf_elements_type.h index 60c60d4775..77e0fdf3f3 100644 --- a/ASCOfficeOdfFile/include/odf/odf_elements_type.h +++ b/ASCOfficeOdfFile/include/odf/odf_elements_type.h @@ -282,6 +282,7 @@ enum ElementType typeStylePageLayout, typeStyleMap, + typeStylePageMaster, // openoffice xml 1.0 typeTableTemplate, typeTableTemplateElement, @@ -347,6 +348,7 @@ enum ElementType typeTableTableRowNoGroup, typeTableTableSource, typeTableTableProtection, + typeTableSubTable, //openoffice xml 1.0 typeTableDataPilotTables, typeTableDataPilotTable, diff --git a/ASCOfficeOdfFile/src/ConvertOO2OOX.cpp b/ASCOfficeOdfFile/src/ConvertOO2OOX.cpp index 345d4cb697..77b99facf7 100644 --- a/ASCOfficeOdfFile/src/ConvertOO2OOX.cpp +++ b/ASCOfficeOdfFile/src/ConvertOO2OOX.cpp @@ -115,9 +115,11 @@ _UINT32 ConvertODF2OOXml(const std::wstring & srcPath, const std::wstring & dstP nResult = ConvertOdt2Docx(inputOdf, dstPath, fontsPath); break; case 2: + case 5: nResult = ConvertOds2Xlsx(inputOdf, dstPath, fontsPath); break; case 3: + case 6: nResult = ConvertOdp2Pptx(inputOdf, dstPath, fontsPath); break; } diff --git a/ASCOfficeOdfFile/src/docx/docx_conversion_context.h b/ASCOfficeOdfFile/src/docx/docx_conversion_context.h index ec9e2495b1..34ad385c69 100644 --- a/ASCOfficeOdfFile/src/docx/docx_conversion_context.h +++ b/ASCOfficeOdfFile/src/docx/docx_conversion_context.h @@ -227,7 +227,7 @@ public: std::wstring & get_text_stream_frame() { - if (frames_.size()>0) + if (false == frames_.empty()) return frames_.back().text_content; else return zero_string_; @@ -235,7 +235,7 @@ public: bool & get_use_image_replace() { bool res = false; - if (!frames_.empty()) return frames_.back().use_image_replace; + if (false == frames_.empty()) return frames_.back().use_image_replace; else throw; } @@ -245,11 +245,11 @@ public: } void clear_stream_shape() { - shape_text_content_=L""; + shape_text_content_ = L""; } void clear_stream_frame() { - if (!frames_.empty()) + if (false == frames_.empty()) frames_.back().text_content.clear(); } void stop_shape() @@ -276,7 +276,7 @@ public: int get_current_frame_id() const { - if (!frames_.empty()) return frames_.back().id; + if (false == frames_.empty()) return frames_.back().id; else return 0; } bool in_group() { return !groups_.empty(); } @@ -287,7 +287,7 @@ public: odf_reader::draw_frame * get_current_frame() const { - if (!frames_.empty()) return frames_.back().ptr; + if (false == frames_.empty()) return frames_.back().ptr; else return NULL; } odf_reader::draw_shape * get_current_shape() const { return current_shape_; } diff --git a/ASCOfficeOdfFile/src/docx/oox_chart_axis.cpp b/ASCOfficeOdfFile/src/docx/oox_chart_axis.cpp index 38f7f76418..dafac7c981 100644 --- a/ASCOfficeOdfFile/src/docx/oox_chart_axis.cpp +++ b/ASCOfficeOdfFile/src/docx/oox_chart_axis.cpp @@ -183,13 +183,13 @@ void oox_axis_content::oox_serialize_content(std::wostream & _Wostream) CP_XML_NODE(L"c:axPos") { if (content_.dimension_ == L"x") - CP_XML_ATTR(L"val",L"b");// "b" | "l" | "r" | "t"// == bottom left right top + CP_XML_ATTR(L"val", L"b");// "b" | "l" | "r" | "t"// == bottom left right top if (content_.dimension_ == L"y") - CP_XML_ATTR(L"val",L"l");// "b" | "l" | "r" | "t"// == bottom left right top + CP_XML_ATTR(L"val", L"l");// "b" | "l" | "r" | "t"// == bottom left right top } //oox_serialize_ln(_Wostream, content_.graphic_properties_); - _CP_OPT(std::wstring) strNumFormat, strPercentFormat; + _CP_OPT(std::wstring) strNumFormat, strPercentFormat, strAxisType; _CP_OPT(bool) bLinkData; _CP_OPT(int) nTypeFormat; @@ -197,6 +197,7 @@ void oox_axis_content::oox_serialize_content(std::wostream & _Wostream) odf_reader::GetProperty(content_.properties_, L"percentage_num_format", strPercentFormat); odf_reader::GetProperty(content_.properties_, L"data-label-number", nTypeFormat); odf_reader::GetProperty(content_.properties_, L"link-data-style-to-source", bLinkData); + odf_reader::GetProperty(content_.properties_, L"axis-type", strAxisType); std::wstring formatCode; if ((nTypeFormat) && (*nTypeFormat == 2) && strPercentFormat) @@ -213,7 +214,7 @@ void oox_axis_content::oox_serialize_content(std::wostream & _Wostream) CP_XML_NODE(L"c:numFmt") { CP_XML_ATTR(L"formatCode", formatCode); - CP_XML_ATTR(L"sourceLinked", bLinkData.get_value_or(true)); + CP_XML_ATTR(L"sourceLinked", bLinkData.get_value_or(strAxisType ? false : true)); } } diff --git a/ASCOfficeOdfFile/src/docx/oox_chart_series.cpp b/ASCOfficeOdfFile/src/docx/oox_chart_series.cpp index fd4bf8a4f5..4530551b58 100644 --- a/ASCOfficeOdfFile/src/docx/oox_chart_series.cpp +++ b/ASCOfficeOdfFile/src/docx/oox_chart_series.cpp @@ -152,7 +152,7 @@ void oox_chart_series::parse_properties() if (false == formatCode.empty()) { if (!data_labels_) data_labels_ = oox_data_labels(); - data_labels_->set_formatCode(formatCode, bLinkData.get_value_or(true)); + data_labels_->set_formatCode(formatCode, bLinkData.get_value_or(false)); } odf_reader::GetProperty(content_.properties_, L"label-position", intVal); if (intVal && labelPosEnabled_) diff --git a/ASCOfficeOdfFile/src/odf/chart_build_oox.cpp b/ASCOfficeOdfFile/src/odf/chart_build_oox.cpp index 3bb4d6b022..6f63f589f0 100644 --- a/ASCOfficeOdfFile/src/odf/chart_build_oox.cpp +++ b/ASCOfficeOdfFile/src/odf/chart_build_oox.cpp @@ -106,15 +106,23 @@ void object_odf_context::set_style_name(std::wstring const & val) { style_name_ = val; } -void object_odf_context::start_axis(std::wstring const & dimensionName, std::wstring const & name, std::wstring const & styleName) +void object_odf_context::start_axis(std::wstring const & dimension, std::wstring const & name, std::wstring const & styleName) { in_axis_ = true; axis ax; - ax.dimension_ = dimensionName; + ax.dimension_ = dimension; ax.chart_name_ = name; ax.style_name_ = styleName; + if (ax.dimension_.empty()) + { + if (std::wstring::npos != ax.chart_name_.find(L"primary-")) + { + ax.dimension_ = ax.chart_name_.substr(8); + } + } + axises_.push_back(ax); } @@ -451,7 +459,7 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context) } std::wstring formatCode = L"General"; - _CP_OPT(std::wstring) strNumFormat, strPercentFormat; + _CP_OPT(std::wstring) strNumFormat, strPercentFormat, strAxisType; _CP_OPT(int) nTypeFormat; _CP_OPT(bool) bLinkData; @@ -459,6 +467,7 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context) odf_reader::GetProperty(series_[i].properties_, L"percentage_num_format", strPercentFormat); odf_reader::GetProperty(series_[i].properties_, L"link-data-style-to-source", bLinkData); odf_reader::GetProperty(series_[i].properties_, L"data-label-number", nTypeFormat); + odf_reader::GetProperty(series_[i].properties_, L"axis-type", strAxisType); if ((nTypeFormat) && (*nTypeFormat == 2) && strPercentFormat) { @@ -480,11 +489,11 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context) if (last_set_class == chart_class::bubble) { //bubble(x) if (!bPivotChart_) - current->set_formula_series(4, domain_cell_range_adress_, formatCode, bLinkData.get_value_or(true)); + current->set_formula_series(4, domain_cell_range_adress_, formatCode, bLinkData.get_value_or(strAxisType ? false : true)); current->set_values_series (4, domain_cash); //y if (!bPivotChart_) - current->set_formula_series(3, series_[i].cell_range_address_, formatCode, bLinkData.get_value_or(true)); + current->set_formula_series(3, series_[i].cell_range_address_, formatCode, bLinkData.get_value_or(strAxisType ? false : true)); current->set_values_series (3, cell_cash); } else @@ -492,14 +501,14 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context) if (false == domain_cash.empty() || false == cash_values.empty()) { if (!bPivotChart_) - current->set_formula_series(2, domain_cell_range_adress_, formatCode, bLinkData.get_value_or(true)); + current->set_formula_series(2, domain_cell_range_adress_, formatCode, bLinkData.get_value_or(strAxisType ? false : true)); current->set_values_series (2, domain_cash); } //y if (false == cell_cash.empty() || false == cash_values.empty()) { if (!bPivotChart_) - current->set_formula_series(3, series_[i].cell_range_address_, formatCode, bLinkData.get_value_or(true)); + current->set_formula_series(3, series_[i].cell_range_address_, formatCode, bLinkData.get_value_or(strAxisType ? false : true)); current->set_values_series (3, cell_cash); } } @@ -507,7 +516,7 @@ void object_odf_context::oox_convert(oox::oox_chart_context & chart_context) else { //common if (!bPivotChart_) - current->set_formula_series(1, series_[i].cell_range_address_, formatCode, bLinkData.get_value_or(true)); + current->set_formula_series(1, series_[i].cell_range_address_, formatCode, bLinkData.get_value_or(strAxisType ? false : true)); current->set_values_series(1, cell_cash); } diff --git a/ASCOfficeOdfFile/src/odf/createandread.cpp b/ASCOfficeOdfFile/src/odf/createandread.cpp index 7e69a27e9c..f50001e169 100644 --- a/ASCOfficeOdfFile/src/odf/createandread.cpp +++ b/ASCOfficeOdfFile/src/odf/createandread.cpp @@ -50,7 +50,8 @@ bool create_element_and_read(xml::sax * Reader, { if (office_element_ptr elm = office_element_creator::get()->create(Ns, Name, Context, isRoot)) { - elm->read_sax( Reader ); + elm->afterCreate(); + elm->read_sax( Reader ); elm->afterReadContent(); if (_Element) // элемент читается повторно @@ -63,7 +64,7 @@ bool create_element_and_read(xml::sax * Reader, } else { - _CP_LOG << L"[error] : create element failed (" << Ns << L":" << Name << L")\n"; + _CP_LOG << L"[error] : create element failed (" << Ns << L":" << Name << L")\n"; not_applicable_element(L"[!!!]", Reader, Ns, Name); } diff --git a/ASCOfficeOdfFile/src/odf/datatypes/common_attlists.cpp b/ASCOfficeOdfFile/src/odf/datatypes/common_attlists.cpp index fedc784f8a..176ab15777 100644 --- a/ASCOfficeOdfFile/src/odf/datatypes/common_attlists.cpp +++ b/ASCOfficeOdfFile/src/odf/datatypes/common_attlists.cpp @@ -400,15 +400,25 @@ void common_xlink_attlist::serialize(CP_ATTR_NODE) } ////////////////////////////////////////////////////////////////////////////////////////////////// -bool common_value_and_type_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes ) +bool common_value_and_type_attlist::add_attributes(const xml::attributes_wc_ptr & Attributes) { - CP_APPLY_ATTR(L"office:value-type" , office_value_type_); - CP_APPLY_ATTR(L"office:value" , office_value_); - CP_APPLY_ATTR(L"office:currency" , office_currency_); - CP_APPLY_ATTR(L"office:date-value" , office_date_value_); - CP_APPLY_ATTR(L"office:time-value" , office_time_value_); - CP_APPLY_ATTR(L"office:boolean-value", office_boolean_value_); - CP_APPLY_ATTR(L"office:string-value", office_string_value_); + CP_APPLY_ATTR(L"office:value-type", office_value_type_); + CP_APPLY_ATTR(L"office:value", office_value_); + CP_APPLY_ATTR(L"office:currency", office_currency_); + CP_APPLY_ATTR(L"office:date-value", office_date_value_); + CP_APPLY_ATTR(L"office:time-value", office_time_value_); + CP_APPLY_ATTR(L"office:boolean-value", office_boolean_value_); + CP_APPLY_ATTR(L"office:string-value", office_string_value_); + + if (!office_value_) + { + CP_APPLY_ATTR(L"table:value", office_value_); //openoffice xml 1.0 + } + + if (!office_value_type_) + { + CP_APPLY_ATTR(L"table:value-type", office_value_type_); //openoffice xml 1.0 + } if (office_value_type_ || office_value_ || office_currency_ || office_date_value_ || office_time_value_ || office_boolean_value_ || office_string_value_) return true; diff --git a/ASCOfficeOdfFile/src/odf/datatypes/stylefamily.cpp b/ASCOfficeOdfFile/src/odf/datatypes/stylefamily.cpp index c5586455a4..18ea1f93b0 100644 --- a/ASCOfficeOdfFile/src/odf/datatypes/stylefamily.cpp +++ b/ASCOfficeOdfFile/src/odf/datatypes/stylefamily.cpp @@ -126,7 +126,7 @@ style_family style_family::parse(const std::wstring & Str) return style_family( Default ); else if (tmp == L"drawing-page") return style_family( DrawingPage ); - else if (tmp == L"graphic") + else if (tmp == L"graphic" || tmp == L"graphics") return style_family( Graphic ); else if (tmp == L"presentation") return style_family( Presentation ); diff --git a/ASCOfficeOdfFile/src/odf/documentcontext.cpp b/ASCOfficeOdfFile/src/odf/documentcontext.cpp index 5e8f250a1f..cec6e7328a 100644 --- a/ASCOfficeOdfFile/src/odf/documentcontext.cpp +++ b/ASCOfficeOdfFile/src/odf/documentcontext.cpp @@ -35,46 +35,21 @@ namespace cpdoccore { namespace odf_reader { - -class document_context::Impl -{ -public: - Impl() : last_element_(NULL) {} - - void set_last_element(office_element* elem) - { - last_element_ = elem; - } - - office_element* get_last_element() - { - return last_element_; - } - -private: - office_element * last_element_; - - -}; - -////////////////////////////////////////////////////////////////////////////////////////////////// - -document_context::document_context() : impl_( new document_context::Impl() ) + +document_context::document_context() { - level = 0; } document_context::~document_context() { - delete impl_; -} -void document_context::set_last_element(office_element* elem) -{ - return impl_->set_last_element(elem); } + office_element* document_context::get_last_element() { - return impl_->get_last_element(); + if (levels.size() > 1) + return levels[levels.size() - 2]; + else + return NULL; } diff --git a/ASCOfficeOdfFile/src/odf/documentcontext.h b/ASCOfficeOdfFile/src/odf/documentcontext.h index 104ea1b19b..28ac1eff2c 100644 --- a/ASCOfficeOdfFile/src/odf/documentcontext.h +++ b/ASCOfficeOdfFile/src/odf/documentcontext.h @@ -32,6 +32,7 @@ #pragma once #include +#include namespace cpdoccore { namespace odf_reader { @@ -44,15 +45,10 @@ public: document_context(); virtual ~document_context(); - void set_last_element(office_element* elem); office_element* get_last_element(); - int level = 0; + std::vector levels; std::wstring office_class_; //openoffice xml 1.0 - -private: - class Impl; - Impl * impl_; }; } diff --git a/ASCOfficeOdfFile/src/odf/draw_frame.cpp b/ASCOfficeOdfFile/src/odf/draw_frame.cpp index e856c982db..f221b87e8d 100644 --- a/ASCOfficeOdfFile/src/odf/draw_frame.cpp +++ b/ASCOfficeOdfFile/src/odf/draw_frame.cpp @@ -90,7 +90,14 @@ const wchar_t * draw_image::name = L"image"; void draw_image::add_attributes( const xml::attributes_wc_ptr & Attributes ) { - draw_image_attlist_.add_attributes(Attributes); + office_element* last_element = getContext()->get_last_element(); + if ((!last_element) || (last_element->get_type() != typeDrawFrame)) + { + draw_frame_ptr = office_element_creator::get()->create(L"draw", L"frame", getContext(), false); + draw_frame_ptr->add_attributes(Attributes); + } + + draw_image_attlist_.add_attributes(Attributes); xlink_attlist_.add_attributes(Attributes); } @@ -325,6 +332,12 @@ std::wostream & draw_text_box::text_to_stream(std::wostream & _Wostream, bool bX void draw_text_box::add_attributes( const xml::attributes_wc_ptr & Attributes ) { + office_element* last_element = getContext()->get_last_element(); + if ((!last_element) || (last_element->get_type() != typeDrawFrame)) + { + draw_frame_ptr = office_element_creator::get()->create(L"draw", L"frame", getContext(), false); + draw_frame_ptr->add_attributes(Attributes); + } draw_text_box_attlist_.add_attributes(Attributes); } @@ -340,7 +353,14 @@ const wchar_t * draw_object::name = L"object"; void draw_object::add_attributes( const xml::attributes_wc_ptr & Attributes ) { - draw_object_attlist_.add_attributes(Attributes); + office_element* last_element = getContext()->get_last_element(); + if ((!last_element) || (last_element->get_type() != typeDrawFrame)) + { + draw_frame_ptr = office_element_creator::get()->create(L"draw", L"frame", getContext(), false); + draw_frame_ptr->add_attributes(Attributes); + } + + draw_object_attlist_.add_attributes(Attributes); xlink_attlist_.add_attributes(Attributes); } @@ -390,7 +410,7 @@ void draw_object_ole::detectObject(const std::wstring &fileName, std::wstring &p std::vector str; - while (sz_obj > 0) + while (sz_obj > 4) { _UINT32 sz = 0; pStream->read((unsigned char*)&sz, 4); sz_obj-= 4; diff --git a/ASCOfficeOdfFile/src/odf/draw_frame.h b/ASCOfficeOdfFile/src/odf/draw_frame.h index a99b7be9b5..a20642f7e9 100644 --- a/ASCOfficeOdfFile/src/odf/draw_frame.h +++ b/ASCOfficeOdfFile/src/odf/draw_frame.h @@ -83,9 +83,10 @@ private: draw_image_attlist draw_image_attlist_; odf_types::common_xlink_attlist xlink_attlist_; - office_element_ptr office_binary_data_; - office_element_ptr_array content_; + office_element_ptr office_binary_data_; + + office_element_ptr draw_frame_ptr; //openoffice xml 1.0 }; CP_REGISTER_OFFICE_ELEMENT2(draw_image); @@ -172,10 +173,9 @@ public: office_element_ptr_array content_; office_element_ptr office_event_listeners_; - // в content перенести нельзя - иначе событи будет добавляться не к этому объекту а следующему - office_element_ptr draw_glue_point_; + + office_element_ptr draw_glue_point_; office_element_ptr draw_image_map_; - //office_element_ptr draw_chart_map_; office_element_ptr draw_contour_; // draw-contour-polygon or draw-contour-path @@ -189,8 +189,10 @@ public: 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); + + void docx_convert_start(oox::docx_conversion_context & Context); + void docx_convert_end(oox::docx_conversion_context & Context); }; - CP_REGISTER_OFFICE_ELEMENT2(draw_frame); //------------------------------------------------------------------------------------------------------------- @@ -270,13 +272,14 @@ public: draw_text_box_attlist draw_text_box_attlist_; office_element_ptr_array content_; + office_element_ptr draw_frame_ptr; //openoffice xml 1.0 + 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(draw_text_box); //------------------------------------------------------------------------------------------------------------- @@ -315,6 +318,8 @@ private: virtual void add_child_element ( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name); std::wstring office_convert(odf_document_ptr odfDocument, int type); + + office_element_ptr draw_frame_ptr; //openoffice xml 1.0 }; CP_REGISTER_OFFICE_ELEMENT2(draw_object); diff --git a/ASCOfficeOdfFile/src/odf/draw_frame_docx.cpp b/ASCOfficeOdfFile/src/odf/draw_frame_docx.cpp index fa7d38c2a7..56ae199481 100644 --- a/ASCOfficeOdfFile/src/odf/draw_frame_docx.cpp +++ b/ASCOfficeOdfFile/src/odf/draw_frame_docx.cpp @@ -167,9 +167,9 @@ length ComputeContextWidth(const style_page_layout_properties * pageProperties columnGap = styleColumns->fo_column_gap_.get_value_or( length(0, length::pt )); } } - //$pageWidth - $pageLeftMargin - $pageRightMargin - $columnGap + //$pageWidth - $pageLeftMargin - $pageRightMargin - $columnGap return length( (pageWidth.get_value_or(length(0, length::pt)).get_value_unit(length::pt) - - pageMarginRight.get_value_or(length(0, length::pt)).get_value_unit(length::pt) - + pageMarginRight.get_value_or(length(0, length::pt)).get_value_unit(length::pt) - pageMarginRight.get_value_or(length(0, length::pt)).get_value_unit(length::pt) - columnGap.get_value_unit(length::pt)) / columnsCount ); @@ -1153,19 +1153,36 @@ void draw_shape::docx_convert(oox::docx_conversion_context & Context) void draw_image::docx_convert(oox::docx_conversion_context & Context) { - if (!xlink_attlist_.href_) - return; - - std::wstring href = xlink_attlist_.href_.get_value_or(L""); - size_t pos_replaicement = href.find(L"ObjectReplacements"); + const draw_frame *frame = Context.get_drawing_context().get_current_frame();//owner + + if (!frame && draw_frame_ptr) + { + draw_frame *frame = dynamic_cast(draw_frame_ptr.get()); + if (frame) + { + office_element_ptr elm = office_element_ptr(new draw_image(*this)); + draw_image *image = dynamic_cast(elm.get()); + image->draw_frame_ptr = office_element_ptr(); - const draw_frame * frame = Context.get_drawing_context().get_current_frame();//owner + frame->content_.push_back(elm); + frame->docx_convert(Context); + } + return; + } +//----------------------------------------------------------------------------------------------- if (!frame) return; - oox::_docx_drawing * drawing = dynamic_cast(frame->oox_drawing_.get()); - if (!drawing) return; + if (!xlink_attlist_.href_) + return; + std::wstring href = xlink_attlist_.href_.get_value_or(L""); + + oox::_docx_drawing * drawing = dynamic_cast(frame->oox_drawing_.get()); + if (!drawing) + return; + + size_t pos_replaicement = href.find(L"ObjectReplacements"); if (pos_replaicement != std::wstring::npos) { if (!Context.get_drawing_context().get_use_image_replace()) @@ -1173,6 +1190,7 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context) if (href.length() - (pos_replaicement + 18) < 2) return; //href="./ObjectReplacements/" } + if (href[0] == L'#') href = href.substr(1); if (drawing->type == oox::typeUnknown) drawing->type = oox::typeImage; @@ -1245,6 +1263,24 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context) void draw_text_box::docx_convert(oox::docx_conversion_context & Context) { + const draw_frame *frame = Context.get_drawing_context().get_current_frame();//owner + + if (!frame && draw_frame_ptr) + { + draw_frame *frame = dynamic_cast(draw_frame_ptr.get()); + if (frame) + { + office_element_ptr elm = office_element_ptr(new draw_text_box(*this)); + draw_text_box *text_box = dynamic_cast(elm.get()); + text_box->draw_frame_ptr = office_element_ptr(); + + frame->content_.push_back(elm); + frame->docx_convert(Context); + + } + return; + } +//--------------------------------------------------------------------------------------------------------------- //тут может быть не только текст , но и таблицы, другие объекты ... oox::StreamsManPtr prev = Context.get_stream_man(); @@ -1269,13 +1305,12 @@ void draw_text_box::docx_convert(oox::docx_conversion_context & Context) Context.back_context_state(); //--------------------------------------------------------------------------------------------------------- - - const draw_frame * frame = Context.get_drawing_context().get_current_frame();//owner if (!frame) return; oox::_docx_drawing * drawing = dynamic_cast(frame->oox_drawing_.get()); - if (!drawing) return; + if (!drawing) + return; drawing->type = oox::typeShape; drawing->sub_type = 1; //textBox @@ -1516,7 +1551,8 @@ void draw_frame::docx_convert(oox::docx_conversion_context & Context) drawing->inGroup = Context.get_drawing_context().in_group(); common_draw_docx_convert(Context, common_draw_attlists_, drawing); - +//----------------------------------------------------------------------------------------------------- + for (size_t i = 0 ; i < content_.size(); i++) { content_[i]->docx_convert(Context); @@ -1555,14 +1591,36 @@ void draw_frame::docx_convert(oox::docx_conversion_context & Context) void draw_object::docx_convert(oox::docx_conversion_context & Context) { - try + const draw_frame *frame = Context.get_drawing_context().get_current_frame();//owner + + if (!frame && draw_frame_ptr) + { + draw_frame *frame = dynamic_cast(draw_frame_ptr.get()); + if (frame) + { + office_element_ptr elm = office_element_ptr(new draw_object(*this)); + draw_object *object = dynamic_cast(elm.get()); + object->draw_frame_ptr = office_element_ptr(); + + frame->content_.push_back(elm); + frame->docx_convert(Context); + } + return; + } +//----------------------------------------------------------------------------------------------- + if (!frame) + return; + + oox::_docx_drawing *drawing = dynamic_cast(frame->oox_drawing_.get()); + try { std::wstring href = xlink_attlist_.href_.get_value_or(L""); std::wstring tempPath = Context.root()->get_temp_folder(); std::wstring odfPath = Context.root()->get_folder(); - if (!odf_document_ && !href.empty()) - { + if (!odf_document_ && false == href.empty()) + { + if (href[0] == L'#') href = href.substr(1); std::wstring objectPath = odfPath + FILE_SEPARATOR_STR + href; // normalize path ???? todooo @@ -1571,9 +1629,7 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context) odf_document_ = odf_document_ptr(new odf_document(objectPath, tempPath, L"", NULL)); } //--------------------------------------------------------------------------------------------------------------------- - draw_frame* frame = NULL; - oox::_docx_drawing * drawing = NULL; - office_element* contentSubDoc = odf_document_ ? odf_document_->get_impl()->get_content() : NULL; + office_element* contentSubDoc = odf_document_ ? odf_document_->get_impl()->get_content() : NULL; object_odf_context objectBuild (href); if (contentSubDoc) @@ -1581,10 +1637,6 @@ void draw_object::docx_convert(oox::docx_conversion_context & Context) process_build_object process_build_object_(objectBuild, odf_document_->odf_context()); contentSubDoc->accept(process_build_object_); - frame = Context.get_drawing_context().get_current_frame(); //owner - if (frame) - drawing = dynamic_cast(frame->oox_drawing_.get()); - if (objectBuild.table_table_) { oox::xlsx_conversion_context xlsx_context(odf_document_.get()); diff --git a/ASCOfficeOdfFile/src/odf/draw_frame_pptx.cpp b/ASCOfficeOdfFile/src/odf/draw_frame_pptx.cpp index bf5a2c7e4d..26c7975e24 100644 --- a/ASCOfficeOdfFile/src/odf/draw_frame_pptx.cpp +++ b/ASCOfficeOdfFile/src/odf/draw_frame_pptx.cpp @@ -213,9 +213,32 @@ void draw_frame::pptx_convert(oox::pptx_conversion_context & Context) void draw_image::pptx_convert(oox::pptx_conversion_context & Context) { - const std::wstring href = xlink_attlist_.href_.get_value_or(L""); + if (draw_frame_ptr) + { + draw_frame *frame = dynamic_cast(draw_frame_ptr.get()); + if (frame) + { + office_element_ptr elm = office_element_ptr(new draw_image(*this)); + draw_image *image = dynamic_cast(elm.get()); + image->draw_frame_ptr = office_element_ptr(); - Context.get_slide_context().set_image(href); + frame->content_.push_back(elm); + frame->pptx_convert(Context); + } + return; + } +//----------------------------------------------------------------------------------------------- + std::wstring href = xlink_attlist_.href_.get_value_or(L""); + + if (true == href.empty()) + { + + } + else + { + if (href[0] == L'#') href = href.substr(1); + } + Context.get_slide_context().set_image(href); ////////////////////////////////////в принципе достаточно общая часть ... Context.get_text_context().start_object(); @@ -243,6 +266,22 @@ void draw_chart::pptx_convert(oox::pptx_conversion_context & Context) void draw_text_box::pptx_convert(oox::pptx_conversion_context & Context) { + if (draw_frame_ptr) + { + draw_frame *frame = dynamic_cast(draw_frame_ptr.get()); + if (frame) + { + office_element_ptr elm = office_element_ptr(new draw_text_box(*this)); + draw_text_box *text_box = dynamic_cast(elm.get()); + text_box->draw_frame_ptr = office_element_ptr(); + + frame->content_.push_back(elm); + frame->pptx_convert(Context); + + } + return; + } +//--------------------------------------------------------------------------------------------------------------- Context.get_slide_context().set_text_box(); //rect с наваротами Context.get_text_context().start_object(); @@ -260,14 +299,31 @@ void draw_text_box::pptx_convert(oox::pptx_conversion_context & Context) } void draw_object::pptx_convert(oox::pptx_conversion_context & Context) { - try + if (draw_frame_ptr) + { + draw_frame *frame = dynamic_cast(draw_frame_ptr.get()); + if (frame) + { + office_element_ptr elm = office_element_ptr(new draw_object(*this)); + draw_object *object = dynamic_cast(elm.get()); + object->draw_frame_ptr = office_element_ptr(); + + frame->content_.push_back(elm); + frame->pptx_convert(Context); + } + return; + } +//----------------------------------------------------------------------------------------------- + try { std::wstring tempPath = Context.root()->get_temp_folder(); std::wstring odfPath = Context.root()->get_folder(); std::wstring href = xlink_attlist_.href_.get_value_or(L""); - if (!odf_document_ && !href.empty()) + if (!odf_document_ && false == href.empty()) { + if (href[0] == L'#') href = href.substr(1); + std::wstring objectPath = odfPath + FILE_SEPARATOR_STR + href; // normalize path ???? todooo diff --git a/ASCOfficeOdfFile/src/odf/draw_frame_xlsx.cpp b/ASCOfficeOdfFile/src/odf/draw_frame_xlsx.cpp index 96d58ee89f..fe4acab97b 100644 --- a/ASCOfficeOdfFile/src/odf/draw_frame_xlsx.cpp +++ b/ASCOfficeOdfFile/src/odf/draw_frame_xlsx.cpp @@ -205,9 +205,24 @@ void draw_frame::xlsx_convert(oox::xlsx_conversion_context & Context) void draw_image::xlsx_convert(oox::xlsx_conversion_context & Context) { - std::wstring href = xlink_attlist_.href_.get_value_or(L""); + if (draw_frame_ptr) + { + draw_frame *frame = dynamic_cast(draw_frame_ptr.get()); + if (frame) + { + office_element_ptr elm = office_element_ptr(new draw_image(*this)); + draw_image *image = dynamic_cast(elm.get()); + image->draw_frame_ptr = office_element_ptr(); - if (href.empty() && office_binary_data_) + frame->content_.push_back(elm); + frame->xlsx_convert(Context); + } + return; + } +//----------------------------------------------------------------------------------------------- + std::wstring href = xlink_attlist_.href_.get_value_or(L""); + + if (true == href.empty()) { office_binary_data* binary_data = dynamic_cast(office_binary_data_.get()); @@ -216,6 +231,10 @@ void draw_image::xlsx_convert(oox::xlsx_conversion_context & Context) href = binary_data->write_to(Context.root()->get_folder()); } } + else + { + if (href[0] == L'#') href = href.substr(1); + } Context.get_drawing_context().set_image(href); @@ -246,6 +265,22 @@ void draw_chart::xlsx_convert(oox::xlsx_conversion_context & Context) } void draw_text_box::xlsx_convert(oox::xlsx_conversion_context & Context) { + if (draw_frame_ptr) + { + draw_frame *frame = dynamic_cast(draw_frame_ptr.get()); + if (frame) + { + office_element_ptr elm = office_element_ptr(new draw_text_box(*this)); + draw_text_box *text_box = dynamic_cast(elm.get()); + text_box->draw_frame_ptr = office_element_ptr(); + + frame->content_.push_back(elm); + frame->xlsx_convert(Context); + + } + return; + } +//--------------------------------------------------------------------------------------------------------------- Context.get_drawing_context().set_text_box(); Context.get_text_context().start_drawing_content(); @@ -264,12 +299,29 @@ void draw_text_box::xlsx_convert(oox::xlsx_conversion_context & Context) } void draw_object::xlsx_convert(oox::xlsx_conversion_context & Context) { + if (draw_frame_ptr) + { + draw_frame *frame = dynamic_cast(draw_frame_ptr.get()); + if (frame) + { + office_element_ptr elm = office_element_ptr(new draw_object(*this)); + draw_object *object = dynamic_cast(elm.get()); + object->draw_frame_ptr = office_element_ptr(); + + frame->content_.push_back(elm); + frame->xlsx_convert(Context); + } + return; + } +//----------------------------------------------------------------------------------------------- try { std::wstring href = xlink_attlist_.href_.get_value_or(L""); - if (!odf_document_ && !href.empty()) + if (!odf_document_ && false == href.empty()) { + if (href[0] == L'#') href = href.substr(1); + std::wstring tempPath = Context.root()->get_temp_folder(); std::wstring folderPath = Context.root()->get_folder(); std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href; diff --git a/ASCOfficeOdfFile/src/odf/odf_document_impl.cpp b/ASCOfficeOdfFile/src/odf/odf_document_impl.cpp index a45bb41612..b3b762c373 100644 --- a/ASCOfficeOdfFile/src/odf/odf_document_impl.cpp +++ b/ASCOfficeOdfFile/src/odf/odf_document_impl.cpp @@ -560,6 +560,14 @@ int odf_document::Impl::GetMimetype(std::wstring value) { return 4; } + else if (std::wstring::npos != value.find(L"application/vnd.sun.xml.calc")) + { + return 5; + } + else if (std::wstring::npos != value.find(L"application/vnd.sun.xml.impress")) + { + return 6; + } return 0; } void odf_document::Impl::parse_manifests(office_element *element) @@ -757,7 +765,6 @@ void odf_document::Impl::parse_styles(office_element *element) context_->styleContainer().add_style ( L"common:" + styleInst->style_name_, styleInst->style_display_name_.get_value_or(L""), - styleInst->style_family_.get_type(), &(styleInst->content_), true, false, @@ -840,7 +847,6 @@ void odf_document::Impl::parse_styles(office_element *element) context_->styleContainer().add_style(L"", L"", - styleInst->style_family_.get_type(), &(styleInst->content_), false, true, @@ -879,7 +885,6 @@ void odf_document::Impl::parse_styles(office_element *element) context_->styleContainer().add_style(styleInst->style_name_, styleInst->style_display_name_.get_value_or(L""), - styleInst->style_family_.get_type(), &(styleInst->content_), false, false, @@ -1060,7 +1065,6 @@ void odf_document::Impl::parse_styles(office_element *element) context_->styleContainer().add_style(styleInst->style_name_, styleInst->style_display_name_.get_value_or(L""), - styleInst->style_family_.get_type(), &(styleInst->content_), true, false, diff --git a/ASCOfficeOdfFile/src/odf/odfcontext.cpp b/ASCOfficeOdfFile/src/odf/odfcontext.cpp index 559cf7b147..8edb2444c1 100644 --- a/ASCOfficeOdfFile/src/odf/odfcontext.cpp +++ b/ASCOfficeOdfFile/src/odf/odfcontext.cpp @@ -105,7 +105,6 @@ style_instance * styles_container::hyperlink_style() void styles_container::add_style( const std::wstring & Name, const std::wstring & DisplayName, - style_family::type Type, style_content * Content, bool IsAutomatic, bool IsDefault, @@ -120,6 +119,8 @@ void styles_container::add_style( const std::wstring & Name, { std::wstring ParentStyleName = ParentStyleName_; + style_family::type Type = Content ? Content->style_family_.get_type() : style_family::None; + if (Name == ParentStyleName) { ParentStyleName = L"";//иначе в коде возможно зацикливание. diff --git a/ASCOfficeOdfFile/src/odf/odfcontext.h b/ASCOfficeOdfFile/src/odf/odfcontext.h index 9396dea82a..30940fa0e0 100644 --- a/ASCOfficeOdfFile/src/odf/odfcontext.h +++ b/ASCOfficeOdfFile/src/odf/odfcontext.h @@ -161,8 +161,7 @@ public: void add_style( const std::wstring & Name, const std::wstring & DisplayName, - odf_types::style_family::type Type, - style_content * Content, + style_content *Content, bool IsAutomatic, bool IsDefault, const std::wstring & ParentStyleName, diff --git a/ASCOfficeOdfFile/src/odf/office_elements.h b/ASCOfficeOdfFile/src/odf/office_elements.h index 6c5a67b4e6..99637091c8 100644 --- a/ASCOfficeOdfFile/src/odf/office_elements.h +++ b/ASCOfficeOdfFile/src/odf/office_elements.h @@ -78,11 +78,8 @@ public: if (!context_) return; ElementType type_ = this->get_type(); - - if (type_ != typeTextSection) - { - context_->level++; - } + + context_->levels.push_back(this); } virtual void afterReadContent() { @@ -90,22 +87,18 @@ public: ElementType type_ = this->get_type(); - if (type_ != typeTextSection) + if (context_->levels.size() == 4) { - if (context_->level == 4) + if (office_element * prev= context_->levels[context_->levels.size() - 2]) //for master pages doc { - if (office_element * prev= context_->get_last_element()) + if (element_style_name) { - if (element_style_name) - { - prev->next_element_style_name = element_style_name; - } + prev->next_element_style_name = element_style_name; } - - context_->set_last_element(this); } - context_->level--; } + if (false == context_->levels.empty()) + context_->levels.pop_back(); } CPDOCCORE_DEFINE_VISITABLE(); diff --git a/ASCOfficeOdfFile/src/odf/office_elements_create.cpp b/ASCOfficeOdfFile/src/odf/office_elements_create.cpp index 87ca54e425..3172806805 100644 --- a/ASCOfficeOdfFile/src/odf/office_elements_create.cpp +++ b/ASCOfficeOdfFile/src/odf/office_elements_create.cpp @@ -52,21 +52,17 @@ office_element_ptr office_element_creator::create(const std::wstring & ns, const const std::wstring fullName = ns + (ns.size() > 0 ? L":" : L"") + name; MapType::const_iterator i = map_.find( fullName ); - if (i != map_.end() ) - { - office_element_ptr element = (i->second)(); - - if (element) - { - element->setContext(Context); - } - - if (element && isRoot) - element->set_root(true); + if (i != map_.end()) + { + office_element_ptr element = (i->second)(); - if (element) - element->afterCreate(); + if (element) + { + element->setContext(Context); + if ( isRoot) + element->set_root(true); + } return element; } else diff --git a/ASCOfficeOdfFile/src/odf/paragraph_elements.cpp b/ASCOfficeOdfFile/src/odf/paragraph_elements.cpp index 919a291ad4..b30413bbcd 100644 --- a/ASCOfficeOdfFile/src/odf/paragraph_elements.cpp +++ b/ASCOfficeOdfFile/src/odf/paragraph_elements.cpp @@ -267,7 +267,7 @@ void s::pptx_convert(oox::pptx_conversion_context & Context) } //------------------------------------------------------------------------------------------------------------ const wchar_t * tab_stop::ns = L"text"; -const wchar_t * tab_stop::name = L"tab_stop"; +const wchar_t * tab_stop::name = L"tab-stop"; //------------------------------------------------------------------------------------------------------------ const wchar_t * tab::ns = L"text"; @@ -778,7 +778,40 @@ void a::pptx_convert(oox::pptx_conversion_context & Context) Context.get_text_context().end_hyperlink(hId); } +//------------------------------------------------------------------------------------------------------------ +const wchar_t * endnote::ns = L"text"; +const wchar_t * endnote::name = L"endnote"; +void endnote::add_child_element(xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) +{ + if CP_CHECK_NAME(L"text", L"endnote-citation") + { + create_element_and_read(Reader, L"text", L"note-citation", text_note_citation_, getContext()); + } + else if CP_CHECK_NAME(L"text", L"endnote-body") + { + create_element_and_read(Reader, L"text", L"note-body", text_note_body_, getContext()); + } + else + CP_NOT_APPLICABLE_ELM(); +} +//------------------------------------------------------------------------------------------------------------ +const wchar_t * footnote::ns = L"text"; +const wchar_t * footnote::name = L"footnote"; + +void footnote::add_child_element(xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) +{ + if CP_CHECK_NAME(L"text", L"footnote-citation") + { + create_element_and_read(Reader, L"text", L"note-citation", text_note_citation_, getContext()); + } + else if CP_CHECK_NAME(L"text", L"footnote-body") + { + create_element_and_read(Reader, L"text", L"note-body", text_note_body_, getContext()); + } + else + CP_NOT_APPLICABLE_ELM(); +} //------------------------------------------------------------------------------------------------------------ const wchar_t * note::ns = L"text"; const wchar_t * note::name = L"note"; diff --git a/ASCOfficeOdfFile/src/odf/paragraph_elements.h b/ASCOfficeOdfFile/src/odf/paragraph_elements.h index b8bde7056a..ce8e525d7f 100644 --- a/ASCOfficeOdfFile/src/odf/paragraph_elements.h +++ b/ASCOfficeOdfFile/src/odf/paragraph_elements.h @@ -512,18 +512,60 @@ public: virtual std::wostream & text_to_stream(std::wostream & _Wostream, bool bXmlEncode = true) const; note(); -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); - std::wstring text_id_; odf_types::noteclass text_note_class_; office_element_ptr text_note_citation_; - office_element_ptr text_note_body_; - + office_element_ptr text_note_body_; +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); }; CP_REGISTER_OFFICE_ELEMENT2(note); //------------------------------------------------------------------------------------------------------------------- +// text:endnote openoffice xml 1.0 +//------------------------------------------------------------------------------------------------------------------- +class endnote : public note +{ +public: + static const wchar_t * ns; + static const wchar_t * name; + static const xml::NodeType xml_type = xml::typeElement; + static const ElementType type = typeTextNote; + + CPDOCCORE_DEFINE_VISITABLE(); + CPDOCCORE_OFFICE_DOCUMENT_IMPL_NAME_FUNCS_; + + endnote() + { + text_note_class_ = odf_types::noteclass::Endnote; + } +private: + virtual void add_child_element(xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name); +}; +CP_REGISTER_OFFICE_ELEMENT2(endnote); +//------------------------------------------------------------------------------------------------------------------- +// text:footnote openoffice xml 1.0 +//------------------------------------------------------------------------------------------------------------------- +class footnote : public note +{ +public: + static const wchar_t * ns; + static const wchar_t * name; + static const xml::NodeType xml_type = xml::typeElement; + static const ElementType type = typeTextNote; + + CPDOCCORE_DEFINE_VISITABLE(); + CPDOCCORE_OFFICE_DOCUMENT_IMPL_NAME_FUNCS_; + + footnote() + { + text_note_class_ = odf_types::noteclass::Footnote; + } +private: + virtual void add_child_element(xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name); +}; +CP_REGISTER_OFFICE_ELEMENT2(footnote); +//------------------------------------------------------------------------------------------------------------------- // text:ruby //------------------------------------------------------------------------------------------------------------------- class ruby : public paragraph_content_element diff --git a/ASCOfficeOdfFile/src/odf/style_chart_properties.cpp b/ASCOfficeOdfFile/src/odf/style_chart_properties.cpp index d362a178d2..e1af776da8 100644 --- a/ASCOfficeOdfFile/src/odf/style_chart_properties.cpp +++ b/ASCOfficeOdfFile/src/odf/style_chart_properties.cpp @@ -89,8 +89,10 @@ void chart_format_properties::add_attributes( const xml::attributes_wc_ptr & Att CP_APPLY_ATTR(L"chart:mean-value", bVal); if (bVal) push_back(_property(L"mean-value", bVal.get())); CP_APPLY_ATTR(L"chart:error-upper-indicator",bVal); if (bVal) push_back(_property(L"error-upper-indicator", bVal.get())); CP_APPLY_ATTR(L"chart:error-lower-indicator",bVal); if (bVal) push_back(_property(L"error-lower-indicator", bVal.get())); - + _CP_OPT(std::wstring) strVal; + + CP_APPLY_ATTR(L"chartooo:axis-type", strVal); if (strVal) push_back(_property(L"axis-type", strVal.get())); CP_APPLY_ATTR(L"chart:symbol-type", strVal); if (strVal) push_back(_property(L"symbol-type",chart_symbol_type(chart_symbol_type::parse(strVal.get())).get_type())); diff --git a/ASCOfficeOdfFile/src/odf/styles.cpp b/ASCOfficeOdfFile/src/odf/styles.cpp index 7d86635726..530ba201f4 100644 --- a/ASCOfficeOdfFile/src/odf/styles.cpp +++ b/ASCOfficeOdfFile/src/odf/styles.cpp @@ -170,38 +170,6 @@ style_section_properties * style_content::get_style_section_properties() const { return dynamic_cast(style_section_properties_.get()); } -void style_content::add_properties(office_element_ptr element) -{ - if (!element) return; - - switch (element->get_type()) - { - case typeStyleTextProperties: - style_text_properties_ = element; - break; - case typeStyleParagraphProperties: - style_paragraph_properties_ = element; - break; - case typeStyleTableCellProperties: - style_table_cell_properties_ = element; - break; - case typeStyleTableProperties: - style_table_properties_ = element; - break; - case typeStyleTableRowProperties: - style_table_row_properties_ = element; - break; - case typeStyleTableColumnProperties: - style_table_column_properties_ = element; - break; - case typeStyleGraphicPropertis: - style_graphic_properties_ = element; - break; - case typeStyleChartProperties: - style_chart_properties_ = element; - break; - } -} style_table_cell_properties * style_content::get_style_table_cell_properties(bool always) { if (!style_table_cell_properties_ && always) @@ -314,6 +282,128 @@ void style_content::add_child_element( xml::sax * Reader, const std::wstring & N { CP_CREATE_ELEMENT_SIMPLE(style_drawing_page_properties_); } + else if CP_CHECK_NAME(L"style", L"properties") + { + office_element_ptr element; + CP_CREATE_ELEMENT_SIMPLE(element); + + style_properties *common_props = dynamic_cast(element.get()); + + if (common_props) + { + switch (style_family_.get_type()) + { + case style_family::Text: + { + office_element_ptr elm = office_element_creator::get()->create(L"style", L"text-properties", Context, false); + style_text_properties *text_props = dynamic_cast(elm.get()); + + if (text_props) + text_props->content_.apply_from(common_props->text_properties_); + + style_text_properties_ = elm; + }break; + case style_family::Paragraph: + { + office_element_ptr para_elm = office_element_creator::get()->create(L"style", L"paragraph-properties", Context, false); + style_paragraph_properties *para_props = dynamic_cast(para_elm.get()); + + if (para_props) + para_props->content_.apply_from(common_props->paragraph_properties_); + + style_paragraph_properties_ = para_elm; + + office_element_ptr text_elm = office_element_creator::get()->create(L"style", L"text-properties", Context, false); + style_text_properties *text_props = dynamic_cast(text_elm.get()); + + if (text_props) + text_props->content_.apply_from(common_props->text_properties_); + + style_text_properties_ = text_elm; + }break; + case style_family::Graphic: + { + office_element_ptr elm = office_element_creator::get()->create(L"style", L"graphic-properties", Context, false); + style_graphic_properties *graphic_props = dynamic_cast(elm.get()); + + if (graphic_props) + graphic_props->content_.apply_from(&common_props->graphic_properties_); + + style_graphic_properties_ = elm; + + office_element_ptr para_elm = office_element_creator::get()->create(L"style", L"paragraph-properties", Context, false); + style_paragraph_properties *para_props = dynamic_cast(para_elm.get()); + + if (para_props) + para_props->content_.apply_from(common_props->paragraph_properties_); + + style_paragraph_properties_ = para_elm; + + office_element_ptr text_elm = office_element_creator::get()->create(L"style", L"text-properties", Context, false); + style_text_properties *text_props = dynamic_cast(text_elm.get()); + + if (text_props) + text_props->content_.apply_from(common_props->text_properties_); + + style_text_properties_ = elm; + }break; + case style_family::Chart: + { + office_element_ptr elm = office_element_creator::get()->create(L"style", L"chart-properties", Context, false); + style_chart_properties *chart_props = dynamic_cast(elm.get()); + + if (chart_props) + chart_props->content_.apply_from(common_props->chart_properties_); + + style_chart_properties_ = elm; + + elm = office_element_creator::get()->create(L"style", L"graphic-properties", Context, false); + style_graphic_properties *graphic_props = dynamic_cast(elm.get()); + + if (graphic_props) + graphic_props->content_.apply_from(&common_props->graphic_properties_); + + style_graphic_properties_ = elm; + + office_element_ptr text_elm = office_element_creator::get()->create(L"style", L"text-properties", Context, false); + style_text_properties *text_props = dynamic_cast(text_elm.get()); + + if (text_props) + text_props->content_.apply_from(common_props->text_properties_); + }break; + case style_family::TableCell: + { + office_element_ptr elm = office_element_creator::get()->create(L"style", L"table-cell-properties", Context, false); + style_table_cell_properties *table_cell_props = dynamic_cast(elm.get()); + + if (table_cell_props) + table_cell_props->attlist_.apply_from(common_props->table_cell_properties_); + + style_table_cell_properties_ = elm; + }break; + case style_family::TableRow: + { + office_element_ptr elm = office_element_creator::get()->create(L"style", L"table-row-properties", Context, false); + style_table_row_properties *table_row_props = dynamic_cast(elm.get()); + + if (table_row_props) + table_row_props->attlist_.apply_from(common_props->table_row_properties_); + + style_table_row_properties_ = elm; + }break; + case style_family::TableColumn: + { + office_element_ptr elm = office_element_creator::get()->create(L"style", L"table-column-properties", Context, false); + style_table_column_properties *table_column_props = dynamic_cast(elm.get()); + + if (table_column_props) + table_column_props->attlist_.apply_from(common_props->table_column_properties_); + + style_table_column_properties_ = elm; + }break; + } + } + } else { not_applicable_element(L"style-content", Reader, Ns, Name); @@ -332,7 +422,7 @@ std::wostream & default_style::text_to_stream(std::wostream & _Wostream, bool bX void default_style::add_attributes( const xml::attributes_wc_ptr & Attributes ) { - CP_APPLY_ATTR(L"style:family", style_family_, style_family()); + CP_APPLY_ATTR(L"style:family", content_.style_family_, style_family()); } void default_style::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) @@ -474,9 +564,10 @@ void style::add_attributes( const xml::attributes_wc_ptr & Attributes ) { _CP_OPT(std::wstring) sTest; - CP_APPLY_ATTR(L"style:name" , style_name_, std::wstring(L"")); + CP_APPLY_ATTR(L"style:family" , content_.style_family_, style_family()); + + CP_APPLY_ATTR(L"style:name" , style_name_, std::wstring(L"")); CP_APPLY_ATTR(L"style:display-name" , style_display_name_); - CP_APPLY_ATTR(L"style:family" , style_family_, style_family()); CP_APPLY_ATTR(L"style:parent-style-name" , style_parent_style_name_); CP_APPLY_ATTR(L"style:next-style-name" , style_next_style_name_); CP_APPLY_ATTR(L"style:list-style-name" , style_list_style_name_); @@ -522,98 +613,6 @@ void style::add_child_element( xml::sax * Reader, const std::wstring & Ns, const { CP_CREATE_ELEMENT(style_map_); } - else if CP_CHECK_NAME(L"style", L"properties") - { - office_element_ptr element; - CP_CREATE_ELEMENT(element); - - style_properties *common_props = dynamic_cast(element.get()); - - if (common_props) - { - switch (style_family_.get_type()) - { - case style_family::Text: - { - office_element_ptr elm = office_element_creator::get()->create(L"style", L"text-properties", getContext(), false); - style_text_properties *text_props = dynamic_cast(elm.get()); - - if (text_props) - text_props->content_.apply_from(common_props->text_properties_); - - content_.add_properties(elm); - }break; - case style_family::Paragraph: - { - office_element_ptr para_elm = office_element_creator::get()->create(L"style", L"paragraph-properties", getContext(), false); - style_paragraph_properties *para_props = dynamic_cast(para_elm.get()); - - if (para_props) - para_props->content_.apply_from(common_props->paragraph_properties_); - - content_.add_properties(para_elm); - - office_element_ptr text_elm = office_element_creator::get()->create(L"style", L"text-properties", getContext(), false); - style_text_properties *text_props = dynamic_cast(text_elm.get()); - - if (text_props) - text_props->content_.apply_from(common_props->text_properties_); - - content_.add_properties(text_elm); - }break; - case style_family::Graphic: - { - office_element_ptr elm = office_element_creator::get()->create(L"style", L"graphic-properties", getContext(), false); - style_graphic_properties *graphic_props = dynamic_cast(elm.get()); - - if (graphic_props) - graphic_props->content_.apply_from(&common_props->graphic_properties_); - - content_.add_properties(elm); - }break; - case style_family::Chart: - { - office_element_ptr elm = office_element_creator::get()->create(L"style", L"chart-properties", getContext(), false); - style_chart_properties *chart_props = dynamic_cast(elm.get()); - - if (chart_props) - chart_props->content_.apply_from(common_props->chart_properties_); - - content_.add_properties(elm); - }break; - case style_family::TableCell: - { - office_element_ptr elm = office_element_creator::get()->create(L"style", L"table-cell-properties", getContext(), false); - style_table_cell_properties *table_cell_props = dynamic_cast(elm.get()); - - if (table_cell_props) - table_cell_props->attlist_.apply_from(common_props->table_cell_properties_); - - content_.add_properties(elm); - }break; - case style_family::TableRow: - { - office_element_ptr elm = office_element_creator::get()->create(L"style", L"table-row-properties", getContext(), false); - style_table_row_properties *table_row_props = dynamic_cast(elm.get()); - - if (table_row_props) - table_row_props->attlist_.apply_from(common_props->table_row_properties_); - - content_.add_properties(elm); - }break; - case style_family::TableColumn: - { - office_element_ptr elm = office_element_creator::get()->create(L"style", L"table-column-properties", getContext(), false); - style_table_column_properties *table_column_props = dynamic_cast(elm.get()); - - if (table_column_props) - table_column_props->attlist_.apply_from(common_props->table_column_properties_); - - content_.add_properties(elm); - }break; - } - } - } else content_.add_child_element(Reader, Ns, Name, getContext()); } @@ -705,7 +704,8 @@ void office_automatic_styles::add_attributes( const xml::attributes_wc_ptr & Att void office_automatic_styles::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) { - if (L"style" == Ns && L"page-layout" == Name) + if (L"style" == Ns && ( L"page-layout" == Name || + L"page-master" == Name )) { CP_CREATE_ELEMENT(style_page_layout_); } @@ -905,7 +905,11 @@ void style_header_style::add_child_element( xml::sax * Reader, const std::wstrin { CP_CREATE_ELEMENT(style_header_footer_properties_); } - else + else if (L"style" == Ns && L"properties" == Name) // openoffice xml 1.0 + { + create_element_and_read(Reader, L"style", L"header-footer-properties", style_header_footer_properties_, getContext()); + } + else { CP_NOT_APPLICABLE_ELM(); } @@ -930,14 +934,38 @@ void style_footer_style::add_child_element( xml::sax * Reader, const std::wstrin { CP_CREATE_ELEMENT(style_header_footer_properties_); } - else + else if (L"style" == Ns && L"properties" == Name) // openoffice xml 1.0 + { + create_element_and_read(Reader, L"style", L"header-footer-properties", style_header_footer_properties_, getContext()); + } + else { CP_NOT_APPLICABLE_ELM(); } } +//----------------------------------------------------------------------------------------------------- +const wchar_t * style_page_master::ns = L"style"; +const wchar_t * style_page_master::name = L"page-master"; - -////////////////////////////////////////////////////////////////////////////////////////////////// +void style_page_master::add_child_element(xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) +{ + if (L"style" == Ns && L"header-style" == Name) + { + CP_CREATE_ELEMENT(style_header_style_); + } + else if (L"style" == Ns && L"footer-style" == Name) + { + CP_CREATE_ELEMENT(style_footer_style_); + } + else if (L"style" == Ns && L"properties" == Name) + { + create_element_and_read(Reader, L"style", L"page-layout-properties", style_page_layout_properties_, getContext()); + } + else + { + CP_NOT_APPLICABLE_ELM(); + } +}//----------------------------------------------------------------------------------------------------- const wchar_t * style_page_layout::ns = L"style"; const wchar_t * style_page_layout::name = L"page-layout"; @@ -1597,6 +1625,11 @@ void style_master_page_attlist::add_attributes( const xml::attributes_wc_ptr & A CP_APPLY_ATTR(L"style:page-layout-name",style_page_layout_name_); CP_APPLY_ATTR(L"draw:style-name", draw_style_name_); CP_APPLY_ATTR(L"style:next-style-name", style_next_style_name_); + + if (!style_page_layout_name_) + {//openoffice xml 1.0 + CP_APPLY_ATTR(L"style:page-master-name", style_page_layout_name_); + } } /// style:master-page diff --git a/ASCOfficeOdfFile/src/odf/styles.h b/ASCOfficeOdfFile/src/odf/styles.h index c39d02e9f7..69a8825c86 100644 --- a/ASCOfficeOdfFile/src/odf/styles.h +++ b/ASCOfficeOdfFile/src/odf/styles.h @@ -106,10 +106,8 @@ public: style_drawing_page_properties* get_style_drawing_page_properties() const; style_table_cell_properties * get_style_table_cell_properties (bool always =false); - void add_properties (office_element_ptr element); -private: odf_types::style_family style_family_; - +private: office_element_ptr style_text_properties_; office_element_ptr style_paragraph_properties_; office_element_ptr style_section_properties_; @@ -137,8 +135,6 @@ public: default_style() {}; - odf_types::style_family style_family_; - style_content content_; friend class odf_document; @@ -366,7 +362,6 @@ public: bool style_auto_update_; // default = false _CP_OPT( std::wstring ) style_display_name_; - odf_types::style_family style_family_; _CP_OPT( std::wstring ) style_parent_style_name_; _CP_OPT( std::wstring ) style_next_style_name_; @@ -853,7 +848,7 @@ private: CP_REGISTER_OFFICE_ELEMENT2(style_footer_style); -/// style:page-layout +// style:page-layout class style_page_layout : public office_element_impl { public: @@ -876,9 +871,21 @@ 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); }; - CP_REGISTER_OFFICE_ELEMENT2(style_page_layout); +// style:page-master openoffice xml 1.0 +class style_page_master : public style_page_layout +{ +public: + static const wchar_t * ns; + static const wchar_t * name; + static const xml::NodeType xml_type = xml::typeElement; + static const ElementType type = typeStylePageMaster; +private: + virtual void add_child_element(xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name); +}; +CP_REGISTER_OFFICE_ELEMENT2(style_page_master); + // style-page-layout-properties-attlist class style_page_layout_properties_attlist { diff --git a/ASCOfficeOdfFile/src/odf/styles_list.cpp b/ASCOfficeOdfFile/src/odf/styles_list.cpp index 25d465befc..97dc61b335 100644 --- a/ASCOfficeOdfFile/src/odf/styles_list.cpp +++ b/ASCOfficeOdfFile/src/odf/styles_list.cpp @@ -69,12 +69,18 @@ void text_list_style::add_attributes( const xml::attributes_wc_ptr & Attributes void text_list_style::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) { - if (L"text" == Ns && L"list-level-style-number" == Name) - CP_CREATE_ELEMENT(content_); - else if (L"text" == Ns && L"list-level-style-bullet" == Name) - CP_CREATE_ELEMENT(content_); - else if (L"text" == Ns && L"list-level-style-image" == Name) - CP_CREATE_ELEMENT(content_); + if (L"text" == Ns && L"list-level-style-number" == Name) + { + CP_CREATE_ELEMENT(content_); + } + else if (L"text" == Ns && L"list-level-style-bullet" == Name) + { + CP_CREATE_ELEMENT(content_); + } + else if (L"text" == Ns && L"list-level-style-image" == Name) + { + CP_CREATE_ELEMENT(content_); + } else { CP_NOT_APPLICABLE_ELM(); @@ -132,12 +138,20 @@ void text_list_level_style_number::add_attributes( const xml::attributes_wc_ptr text_list_level_style_number_attr_.add_attributes(Attributes); } -void text_list_level_style_number::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) +void text_list_level_style_number::add_child_element(xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) { - if (L"style" == Ns && L"list-level-properties" == Name) - CP_CREATE_ELEMENT(list_level_properties_); + if (L"style" == Ns && L"list-level-properties" == Name) + { + CP_CREATE_ELEMENT(list_level_properties_); + } + else if (L"style" == Ns && L"properties" == Name) //openoffice xml 1.0 + { + create_element_and_read(Reader, L"style", L"list-level-properties", list_level_properties_, getContext()); + } else if (L"style" == Ns && L"text-properties" == Name) - CP_CREATE_ELEMENT(style_text_properties_); + { + CP_CREATE_ELEMENT(style_text_properties_); + } else { CP_NOT_APPLICABLE_ELM(); @@ -157,10 +171,18 @@ void text_list_level_style_image::add_attributes( const xml::attributes_wc_ptr & void text_list_level_style_image::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) { - if (L"style" == Ns && L"list-level-properties" == Name) - CP_CREATE_ELEMENT(list_level_properties_); + if (L"style" == Ns && L"list-level-properties" == Name) + { + CP_CREATE_ELEMENT(list_level_properties_); + } + else if (L"style" == Ns && L"properties" == Name) + { + create_element_and_read(Reader, L"style", L"list-level-properties", list_level_properties_, getContext()); + } else if (L"style" == Ns && L"text-properties" == Name) - CP_CREATE_ELEMENT(style_text_properties_); + { + CP_CREATE_ELEMENT(style_text_properties_); + } else { CP_NOT_APPLICABLE_ELM(); @@ -230,10 +252,18 @@ void text_list_level_style_bullet::add_attributes( const xml::attributes_wc_ptr void text_list_level_style_bullet::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) { - if (L"style" == Ns && L"list-level-properties" == Name) - CP_CREATE_ELEMENT(list_level_properties_); - else if (L"style" == Ns && L"text-properties" == Name) - CP_CREATE_ELEMENT(style_text_properties_); + if (L"style" == Ns && L"list-level-properties" == Name) + { + CP_CREATE_ELEMENT(list_level_properties_); + } + else if (L"style" == Ns && L"properties" == Name) + { + create_element_and_read(Reader, L"style", L"list-level-properties", list_level_properties_, getContext()); + } + else if (L"style" == Ns && L"text-properties" == Name) + { + CP_CREATE_ELEMENT(style_text_properties_); + } else { CP_NOT_APPLICABLE_ELM(); @@ -865,10 +895,18 @@ void text_outline_level_style::add_attributes( const xml::attributes_wc_ptr & At void text_outline_level_style::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) { - if (L"style" == Ns && L"list-level-properties" == Name) - CP_CREATE_ELEMENT(list_level_properties_); - else if (L"style" == Ns && L"text-properties" == Name) - CP_CREATE_ELEMENT(text_properties_); + if (L"style" == Ns && L"list-level-properties" == Name) + { + CP_CREATE_ELEMENT(list_level_properties_); + } + else if (L"style" == Ns && L"properties" == Name) + { + create_element_and_read(Reader, L"style", L"list-level-properties", list_level_properties_, getContext()); + } + else if (L"style" == Ns && L"text-properties" == Name) + { + CP_CREATE_ELEMENT(text_properties_); + } else { CP_NOT_APPLICABLE_ELM(); diff --git a/ASCOfficeOdfFile/src/odf/table.cpp b/ASCOfficeOdfFile/src/odf/table.cpp index 0ee30990a2..57512bde6e 100644 --- a/ASCOfficeOdfFile/src/odf/table.cpp +++ b/ASCOfficeOdfFile/src/odf/table.cpp @@ -154,7 +154,11 @@ void table_table_protection::add_attributes( const xml::attributes_wc_ptr & Attr //CP_APPLY_ATTR(L"loext:format-rows", format_rows); //CP_APPLY_ATTR(L"loext:format-cells", format_cells); } -////////////////////////////////////////////////////////////////////////////////////////////////// +//--------------------------------------------------------------------------------------------------------- +// table:table +const wchar_t * table_sub_table::ns = L"table"; +const wchar_t * table_sub_table::name = L"sub-table"; +//--------------------------------------------------------------------------------------------------------- // table:table const wchar_t * table_table::ns = L"table"; const wchar_t * table_table::name = L"table"; diff --git a/ASCOfficeOdfFile/src/odf/table.h b/ASCOfficeOdfFile/src/odf/table.h index 353a73c6d0..4bdce5bad3 100644 --- a/ASCOfficeOdfFile/src/odf/table.h +++ b/ASCOfficeOdfFile/src/odf/table.h @@ -102,7 +102,6 @@ public: odf_types::common_value_and_type_attlist common_value_and_type_attlist_; bool table_protect_; // default false - }; class table_table_cell_attlist_extra @@ -590,7 +589,7 @@ public: bool table_display_; // default true }; - +//-------------------------------------------------------------------------------------------- class table_table_row_group : public office_element_impl { public: @@ -617,7 +616,7 @@ public: }; CP_REGISTER_OFFICE_ELEMENT2(table_table_row_group); - +//-------------------------------------------------------------------------------------------- class table_table_protection : public office_element_impl { public: @@ -649,7 +648,7 @@ public: //_CP_OPT(bool) format_cells; }; CP_REGISTER_OFFICE_ELEMENT2(table_table_protection); - +//-------------------------------------------------------------------------------------------- class table_table : public office_element_impl { public: @@ -687,7 +686,17 @@ public: //table-scenario }; CP_REGISTER_OFFICE_ELEMENT2(table_table); - +//-------------------------------------------------------------------------------------------- +class table_sub_table : public table_table +{ +public: + static const wchar_t * ns; + static const wchar_t * name; + static const xml::NodeType xml_type = xml::typeElement; + static const ElementType type = typeTableSubTable; +}; +CP_REGISTER_OFFICE_ELEMENT2(table_sub_table); +//-------------------------------------------------------------------------------------------- //table:content-shapes class table_shapes : public office_element_impl { @@ -733,7 +742,7 @@ private: }; CP_REGISTER_OFFICE_ELEMENT2(table_content_validations); - +//-------------------------------------------------------------------------------------------- //table:content-validation class table_content_validation : public office_element_impl { @@ -784,7 +793,7 @@ public: office_element_ptr_array content_; }; CP_REGISTER_OFFICE_ELEMENT2(table_error_message); - +//-------------------------------------------------------------------------------------------- //table:help-message class table_help_message : public office_element_impl { diff --git a/ASCOfficeOdfFile/src/odf/text_elements.cpp b/ASCOfficeOdfFile/src/odf/text_elements.cpp index e01991d664..d48618f7a8 100644 --- a/ASCOfficeOdfFile/src/odf/text_elements.cpp +++ b/ASCOfficeOdfFile/src/odf/text_elements.cpp @@ -460,6 +460,7 @@ void h::add_attributes( const xml::attributes_wc_ptr & Attributes ) CP_APPLY_ATTR(L"text:restart-numbering" , restart_numbering_); CP_APPLY_ATTR(L"text:start-value" , start_value_); CP_APPLY_ATTR(L"text:is-list-header" , is_list_header_); + CP_APPLY_ATTR(L"text:level" , outline_level_); // openoffice xml 1.0 paragraph_.add_attributes(Attributes); @@ -660,8 +661,6 @@ std::wostream & section::text_to_stream(std::wostream & _Wostream, bool bXmlEnco void section::afterCreate() { - office_element::afterCreate(); - if (document_context * context = getContext()) { if (p *lastPar = dynamic_cast(context->get_last_element())) @@ -678,19 +677,17 @@ void section::afterCreate() void section::afterReadContent() { if (document_context * context = getContext()) - { - if (p *lastPar = dynamic_cast(context->get_last_element())) - { - lastPar->paragraph_.set_next_end_section(true); - } + { + if (p *lastPar = dynamic_cast(context->get_last_element())) + { + lastPar->paragraph_.set_next_end_section(true); + } else if (h *lastPar = dynamic_cast(context->get_last_element())) - { - lastPar->paragraph_.set_next_end_section(true); - } - } - office_element::afterReadContent(); + { + lastPar->paragraph_.set_next_end_section(true); + } + } } - void section::add_attributes( const xml::attributes_wc_ptr & Attributes ) { section_attr_.add_attributes(Attributes); @@ -1136,10 +1133,10 @@ const wchar_t * table_index_entry_template::name = L"table-index-entry-template" const wchar_t * illustration_index::ns = L"text"; const wchar_t * illustration_index::name = L"illustration-index"; -//void illustration_index::afterCreate() -//{ -// office_element::afterCreate(); -// +void illustration_index::afterCreate() +{ + office_element::afterCreate(); + // if (document_context * context = getContext()) // { // if (p *lastPar = dynamic_cast(context->get_last_element())) @@ -1151,7 +1148,7 @@ const wchar_t * illustration_index::name = L"illustration-index"; // lastPar->paragraph_.set_next_section(true); // } // } -//} +} void illustration_index::afterReadContent() { @@ -1293,10 +1290,10 @@ void alphabetical_index::add_child_element( xml::sax * Reader, const std::wstrin CP_CREATE_ELEMENT(alphabetical_index_source_); } } -//void alphabetical_index::afterCreate() -//{ -// office_element::afterCreate(); -// +void alphabetical_index::afterCreate() +{ + office_element::afterCreate(); + // if (document_context * context = getContext()) // { // if (p *lastPar = dynamic_cast(context->get_last_element())) @@ -1308,7 +1305,7 @@ void alphabetical_index::add_child_element( xml::sax * Reader, const std::wstrin // lastPar->paragraph_.set_next_section(true); // } // } -//} +} void alphabetical_index::afterReadContent() { if (document_context * context = getContext()) @@ -1412,10 +1409,10 @@ void alphabetical_index_entry_template::docx_convert(oox::docx_conversion_contex const wchar_t * object_index::ns = L"text"; const wchar_t * object_index::name = L"object-index"; -//void object_index::afterCreate() -//{ -// office_element::afterCreate(); -// +void object_index::afterCreate() +{ + office_element::afterCreate(); + // if (document_context * context = getContext()) // { // if (p *lastPar = dynamic_cast(context->get_last_element())) @@ -1427,7 +1424,7 @@ const wchar_t * object_index::name = L"object-index"; // lastPar->paragraph_.set_next_section(true); // } // } -//} +} void object_index::afterReadContent() { if (document_context * context = getContext()) diff --git a/ASCOfficeOdfFile/src/odf/text_elements.h b/ASCOfficeOdfFile/src/odf/text_elements.h index 251852e373..81e9bdc12a 100644 --- a/ASCOfficeOdfFile/src/odf/text_elements.h +++ b/ASCOfficeOdfFile/src/odf/text_elements.h @@ -366,7 +366,7 @@ public: CPDOCCORE_DEFINE_VISITABLE(); - //virtual void afterCreate(); + virtual void afterCreate(); virtual void afterReadContent(); void docx_convert(oox::docx_conversion_context & Context); @@ -398,7 +398,7 @@ public: CPDOCCORE_DEFINE_VISITABLE(); - //virtual void afterCreate(); + virtual void afterCreate(); virtual void afterReadContent(); void docx_convert(oox::docx_conversion_context & Context); @@ -430,7 +430,7 @@ public: CPDOCCORE_DEFINE_VISITABLE(); - //virtual void afterCreate(); + virtual void afterCreate(); virtual void afterReadContent(); void docx_convert(oox::docx_conversion_context & Context); diff --git a/Common/OfficeFileFormatChecker2.cpp b/Common/OfficeFileFormatChecker2.cpp index 2638107d21..3984739ca8 100644 --- a/Common/OfficeFileFormatChecker2.cpp +++ b/Common/OfficeFileFormatChecker2.cpp @@ -643,6 +643,8 @@ bool COfficeFileFormatChecker::isOpenOfficeFormatFile(const std::wstring & fileN const char *otpFormatLine = "application/vnd.oasis.opendocument.presentation-template"; const char *epubFormatLine = "application/epub+zip"; const char *sxwFormatLine = "application/vnd.sun.xml.writer"; + const char *sxcFormatLine = "application/vnd.sun.xml.calc"; + const char *sxiFormatLine = "application/vnd.sun.xml.impress"; COfficeUtils OfficeUtils(NULL); @@ -679,11 +681,13 @@ bool COfficeFileFormatChecker::isOpenOfficeFormatFile(const std::wstring & fileN { nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT; } - else if ( NULL != strstr((char*)pBuffer, odsFormatLine) ) + else if ( NULL != strstr((char*)pBuffer, odsFormatLine) || + NULL != strstr((char*)pBuffer, sxcFormatLine)) { nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS; } - else if ( NULL != strstr((char*)pBuffer, odpFormatLine) ) + else if ( NULL != strstr((char*)pBuffer, odpFormatLine) || + NULL != strstr((char*)pBuffer, sxiFormatLine)) { nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_ODP; }