diff --git a/ASCOfficeDocFile/DocDocxConverter/CommentsMapping.h b/ASCOfficeDocFile/DocDocxConverter/CommentsMapping.h index 5630c3ea56..95e456711d 100644 --- a/ASCOfficeDocFile/DocDocxConverter/CommentsMapping.h +++ b/ASCOfficeDocFile/DocDocxConverter/CommentsMapping.h @@ -82,6 +82,7 @@ namespace DocFileFormat int cp = m_document->FIB->m_RgLw97.ccpText + m_document->FIB->m_RgLw97.ccpFtn + m_document->FIB->m_RgLw97.ccpHdr; size_t count = m_document->AnnotationsReferencePlex->Elements.size(); + for (size_t index = 0; index < count; ++index) { AnnotationReferenceDescriptor* atrdPre10 = static_cast(m_document->AnnotationsReferencePlex->Elements[index]); @@ -92,14 +93,15 @@ namespace DocFileFormat } m_pXmlWriter->WriteNodeBegin( L"w:comment", TRUE ); - if (atrdPre10->m_BookmarkId < 0)//-1 - easy ref (not start/end comment ref) - { - m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::SizeTToWideString( index + 1 + count + 1024 )); - } - else - { + //if (atrdPre10->m_BookmarkId < 0)//-1 - easy ref (not start/end comment ref) + //{ + // m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::SizeTToWideString( index + 1 + count + 1024 )); + //} + //else + //{ m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::SizeTToWideString( index + 1 )); - } + //} + if (atrdPost10) { m_pXmlWriter->WriteAttribute( L"w:date", atrdPost10->m_nDTTM.getString()); diff --git a/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp b/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp index 0c646b1ff5..530b9135b8 100755 --- a/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp +++ b/ASCOfficeDocFile/DocDocxConverter/DocumentMapping.cpp @@ -1057,8 +1057,8 @@ namespace DocFileFormat AnnotationReferenceDescriptor* atrdPre10 = static_cast(m_document->AnnotationsReferencePlex->Elements[index - 1]); - if (atrdPre10->m_BookmarkId < 0) - index += m_document->AnnotationsReferencePlex->Elements.size() + 1024; + //if (atrdPre10->m_BookmarkId < 0) + // index += m_document->AnnotationsReferencePlex->Elements.size() + 1024; m_pXmlWriter->WriteAttribute( L"w:id", FormatUtils::IntToWideString(index)); m_pXmlWriter->WriteNodeEnd( L"", true ); diff --git a/ASCOfficeOdfFile/include/odf/odf_elements_type.h b/ASCOfficeOdfFile/include/odf/odf_elements_type.h index 22d15f74ab..02159db2f8 100644 --- a/ASCOfficeOdfFile/include/odf/odf_elements_type.h +++ b/ASCOfficeOdfFile/include/odf/odf_elements_type.h @@ -39,7 +39,8 @@ enum ElementType typeNone = 0, type_AbstractXml, - typeTextText = 1000, + typeTextTextElement = 1000, + typeTextText, typeTextS, typeTextTab, typeTextLineBreak, diff --git a/ASCOfficeOdfFile/src/docx/xlsx_table_state.cpp b/ASCOfficeOdfFile/src/docx/xlsx_table_state.cpp index 0140c37668..98662a9d96 100644 --- a/ASCOfficeOdfFile/src/docx/xlsx_table_state.cpp +++ b/ASCOfficeOdfFile/src/docx/xlsx_table_state.cpp @@ -420,7 +420,7 @@ void xlsx_table_state::serialize_header_footer (std::wostream & strm) odf_reader::style_footer *footer_odd = dynamic_cast (master_style_->style_footer_.get()); odf_reader::style_footer_first *footer_first = dynamic_cast (master_style_->style_footer_first_.get()); - odf_reader::style_footer_left *footer_even = dynamic_cast (master_style_->style_header_left_.get()); + odf_reader::style_footer_left *footer_even = dynamic_cast (master_style_->style_footer_left_.get()); if (!header_odd && !header_first && !header_even && !footer_odd && !footer_first && !footer_even) return; diff --git a/ASCOfficeOdfFile/src/docx/xlsx_table_state.h b/ASCOfficeOdfFile/src/docx/xlsx_table_state.h index 2b530a3a01..e73f289c00 100644 --- a/ASCOfficeOdfFile/src/docx/xlsx_table_state.h +++ b/ASCOfficeOdfFile/src/docx/xlsx_table_state.h @@ -218,6 +218,9 @@ private: int tableId_; std::wstring tableBackground_; + _CP_OPT(double) header_page; + _CP_OPT(double) footer_page; + std::wstring table_style_; std::wstring table_row_style_; std::wstring cell_style_; diff --git a/ASCOfficeOdfFile/src/docx/xlsx_tablecontext.cpp b/ASCOfficeOdfFile/src/docx/xlsx_tablecontext.cpp index dc90c18ac9..b489bb82d9 100644 --- a/ASCOfficeOdfFile/src/docx/xlsx_tablecontext.cpp +++ b/ASCOfficeOdfFile/src/docx/xlsx_tablecontext.cpp @@ -290,6 +290,23 @@ unsigned int xlsx_table_context::columns_count() return state()->columns_count(); } +void xlsx_table_context::set_header_page(_CP_OPT(double) val) +{ + state()->header_page = val; +} +_CP_OPT(double) xlsx_table_context::get_header_page() +{ + return state()->header_page; +} +void xlsx_table_context::set_footer_page(_CP_OPT(double) val) +{ + state()->footer_page = val; +} +_CP_OPT(double) xlsx_table_context::get_footer_page() +{ + return state()->footer_page; +} + std::wstring xlsx_table_context::default_row_cell_style() { return state()->default_row_cell_style(); diff --git a/ASCOfficeOdfFile/src/docx/xlsx_tablecontext.h b/ASCOfficeOdfFile/src/docx/xlsx_tablecontext.h index 2560693982..351803c16f 100644 --- a/ASCOfficeOdfFile/src/docx/xlsx_tablecontext.h +++ b/ASCOfficeOdfFile/src/docx/xlsx_tablecontext.h @@ -83,6 +83,12 @@ public: unsigned int columns_count(); + void set_header_page(_CP_OPT(double) val); + _CP_OPT(double) get_header_page(); + + void set_footer_page(_CP_OPT(double) val); + _CP_OPT(double) get_footer_page(); + void serialize_tableParts (std::wostream & _Wostream, rels & Rels); void serialize_sort (std::wostream & _Wostream); void serialize_autofilter (std::wostream & _Wostream); diff --git a/ASCOfficeOdfFile/src/odf/draw_frame_docx.cpp b/ASCOfficeOdfFile/src/odf/draw_frame_docx.cpp index f4fd35fe2a..2355b12548 100644 --- a/ASCOfficeOdfFile/src/odf/draw_frame_docx.cpp +++ b/ASCOfficeOdfFile/src/odf/draw_frame_docx.cpp @@ -159,7 +159,7 @@ length ComputeContextWidth(const style_page_layout_properties * pageProperties if (pagePropertiesNode) { if (const style_columns * styleColumns - = dynamic_cast( pagePropertiesNode->elements_.style_columns_.get())) + = dynamic_cast( pagePropertiesNode->style_columns_.get())) { columnsCount = styleColumns->fo_column_count_.get_value_or(1); if (!columnsCount) diff --git a/ASCOfficeOdfFile/src/odf/odfcontext.cpp b/ASCOfficeOdfFile/src/odf/odfcontext.cpp index 441d16aaba..8624c04ff0 100644 --- a/ASCOfficeOdfFile/src/odf/odfcontext.cpp +++ b/ASCOfficeOdfFile/src/odf/odfcontext.cpp @@ -364,6 +364,34 @@ style_page_layout_properties * page_layout_instance::properties() const void page_layout_instance::xlsx_serialize(std::wostream & strm, oox::xlsx_conversion_context & Context) { + const style_header_style * headerStyle = dynamic_cast(style_page_layout_->style_header_style_.get()); + const style_footer_style * footerStyle = dynamic_cast(style_page_layout_->style_footer_style_.get()); + + style_header_footer_properties * headerProp = headerStyle ? dynamic_cast(headerStyle->style_header_footer_properties_.get()) : NULL; + style_header_footer_properties * footerProp = footerStyle ? dynamic_cast(footerStyle->style_header_footer_properties_.get()) : NULL; + + if (headerProp) + { + const style_header_footer_properties_attlist & attr = headerProp->style_header_footer_properties_attlist_; + _CP_OPT(double) header; + + if (attr.fo_min_height_) header = attr.fo_min_height_->get_value_unit(length::pt); + else if (attr.svg_height_) header = attr.svg_height_->get_value_unit(length::pt); + + Context.get_table_context().set_header_page(header); + } + + if (footerProp) + { + const style_header_footer_properties_attlist & attr = footerProp->style_header_footer_properties_attlist_; + _CP_OPT(double) footer; + + if (attr.fo_min_height_) footer = attr.fo_min_height_->get_value_unit(length::pt); + else if (attr.svg_height_) footer = attr.svg_height_->get_value_unit(length::pt); + + Context.get_table_context().set_footer_page(footer); + } + style_page_layout_properties * props = properties(); if (props) props->xlsx_serialize(strm, Context); diff --git a/ASCOfficeOdfFile/src/odf/office_body.cpp b/ASCOfficeOdfFile/src/odf/office_body.cpp index 1bb1c12ce9..d7f98eca71 100644 --- a/ASCOfficeOdfFile/src/odf/office_body.cpp +++ b/ASCOfficeOdfFile/src/odf/office_body.cpp @@ -113,7 +113,7 @@ void office_body::docx_convert(oox::docx_conversion_context & Context) oox::_oox_fill fill; Compute_GraphicFill(layout_properties->attlist_.common_draw_fill_attlist_, - layout_properties->elements_.style_background_image_, + layout_properties->style_background_image_, Context.root()->odf_context().drawStyles(), fill); if (layout_properties->attlist_.common_background_color_attlist_.fo_background_color_ || fill.type != 0) diff --git a/ASCOfficeOdfFile/src/odf/paragraph_elements.cpp b/ASCOfficeOdfFile/src/odf/paragraph_elements.cpp index 8006506dd9..c1b0f394a2 100644 --- a/ASCOfficeOdfFile/src/odf/paragraph_elements.cpp +++ b/ASCOfficeOdfFile/src/odf/paragraph_elements.cpp @@ -65,8 +65,11 @@ namespace odf_reader { namespace text { -template -void paragraph_content_element::docx_serialize_field(const std::wstring & field_name, office_element_ptr & text, +//------------------------------------------------------------------------------------------------------------ +const wchar_t * paragraph_content_element::ns = L""; +const wchar_t * paragraph_content_element::name = L""; + +void paragraph_content_element::docx_serialize_field(const std::wstring & field_name, office_element_ptr & text, oox::docx_conversion_context & Context, bool bLock ) { std::wostream & strm = Context.output_stream(); @@ -90,8 +93,7 @@ void paragraph_content_element::docx_serialize_field(const std::wstrin strm << L""; } } -template -void paragraph_content_element::docx_serialize_sdt_placeholder(const std::wstring & name, office_element_ptr & text, oox::docx_conversion_context & Context) +void paragraph_content_element::docx_serialize_sdt_placeholder(const std::wstring & name, office_element_ptr & text, oox::docx_conversion_context & Context) { std::wostream & strm = Context.output_stream(); Context.finish_run(); @@ -106,8 +108,7 @@ void paragraph_content_element::docx_serialize_sdt_placeholder(const s strm << L""; } -template -void paragraph_content_element::docx_serialize_run(office_element_ptr & text, oox::docx_conversion_context & Context) +void paragraph_content_element::docx_serialize_run(office_element_ptr & text, oox::docx_conversion_context & Context) { Context.add_new_run(); if (text) @@ -116,6 +117,7 @@ void paragraph_content_element::docx_serialize_run(office_element_ptr } Context.finish_run(); } + //------------------------------------------------------------------------------------------------------------ const wchar_t * text::ns = L""; const wchar_t * text::name = L""; @@ -570,6 +572,25 @@ void span::xlsx_convert(oox::xlsx_conversion_context & Context) } Context.end_span(); } +void span::xlsx_serialize(std::wostream & _Wostream, oox::xlsx_conversion_context & Context) +{ + for (size_t i = 0; i < content_.size(); i++) + { + text *t = dynamic_cast(content_[i].get()); + if (t) + { + t->text_to_stream(_Wostream, true); + } + else + { + text::paragraph_content_element *element = dynamic_cast(content_[i].get()); + if (element) + { + element->xlsx_serialize(_Wostream, Context); + } + } + } +} void span::pptx_convert(oox::pptx_conversion_context & Context) { if (style_instance * styleInst = Context.root()->odf_context().styleContainer().style_by_name(text_style_name_, style_family::Text,false)) @@ -1015,6 +1036,10 @@ void text_page_number::docx_convert(oox::docx_conversion_context & Context) { docx_serialize_field(L"PAGE", text_, Context); } +void text_page_number::xlsx_serialize(std::wostream & _Wostream, oox::xlsx_conversion_context & Context) +{ + _Wostream << L"&P"; +} void text_page_number::pptx_convert(oox::pptx_conversion_context & Context) { Context.get_text_context().start_field(oox::page_number, L""); @@ -1053,6 +1078,10 @@ void text_page_count::docx_convert(oox::docx_conversion_context & Context) { docx_serialize_field(L"NUMPAGES", text_, Context); } +void text_page_count::xlsx_serialize(std::wostream & _Wostream, oox::xlsx_conversion_context & Context) +{ + _Wostream << L"&N"; +} void text_page_count::pptx_convert(oox::pptx_conversion_context & Context) { //поскольку такого поля в ms нет - конвертим как обычный текст @@ -1090,7 +1119,10 @@ void text_date::docx_convert(oox::docx_conversion_context & Context) docx_serialize_field(L"DATE", text_, Context, bLock); } - +void text_date::xlsx_serialize(std::wostream & _Wostream, oox::xlsx_conversion_context & Context) +{ + _Wostream << L"&D"; +} void text_date::pptx_convert(oox::pptx_conversion_context & Context) { Context.get_text_context().start_field(oox::date,style_data_style_name_.get_value_or(L"")); @@ -1151,6 +1183,10 @@ void text_time::docx_convert(oox::docx_conversion_context & Context) docx_serialize_field(L"TIME", text_, Context, bLock); } +void text_time::xlsx_serialize(std::wostream & _Wostream, oox::xlsx_conversion_context & Context) +{ + _Wostream << L"&T"; +} void text_time::pptx_convert(oox::pptx_conversion_context & Context) { Context.get_text_context().start_field(oox::time, style_data_style_name_.get_value_or(L"")); @@ -1204,6 +1240,10 @@ void text_file_name::docx_convert(oox::docx_conversion_context & Context) { docx_serialize_field(L"FILENAME", text_, Context); } +void text_file_name::xlsx_serialize(std::wostream & _Wostream, oox::xlsx_conversion_context & Context) +{ + _Wostream << L"&F"; +} void text_file_name::pptx_convert(oox::pptx_conversion_context & Context) { // Context.get_text_context().start_field(oox::file_name, style_data_style_name_.get_value_or(L"")); @@ -1467,6 +1507,10 @@ void sheet_name::docx_convert(oox::docx_conversion_context & Context) { docx_serialize_sdt_placeholder(L"sheet name", text_, Context); } +void sheet_name::xlsx_serialize(std::wostream & _Wostream, oox::xlsx_conversion_context & Context) +{ + _Wostream << L"&A"; +} //------------------------------------------------------------------------------------------------------------ const wchar_t * author_name::ns = L"text"; const wchar_t * author_name::name = L"author-name"; diff --git a/ASCOfficeOdfFile/src/odf/paragraph_elements.h b/ASCOfficeOdfFile/src/odf/paragraph_elements.h index 05faf53d26..7f834d2811 100644 --- a/ASCOfficeOdfFile/src/odf/paragraph_elements.h +++ b/ASCOfficeOdfFile/src/odf/paragraph_elements.h @@ -53,18 +53,32 @@ namespace odf_reader { namespace text { -template -class paragraph_content_element : public office_element_impl +class paragraph_content_element : public office_element_impl { public: - void docx_serialize_sdt_placeholder(const std::wstring & name, office_element_ptr & text, oox::docx_conversion_context & Context); - void docx_serialize_field(const std::wstring & field_name, office_element_ptr & text, oox::docx_conversion_context & Context, bool bLock = false); - void docx_serialize_run(office_element_ptr & text, oox::docx_conversion_context & Context); + static const wchar_t * ns; + static const wchar_t * name; + static const xml::NodeType xml_type = xml::typeElement; + static const ElementType type = typeTextTextElement; + 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){} + + virtual void docx_serialize_sdt_placeholder(const std::wstring & name, office_element_ptr & text, oox::docx_conversion_context & Context); + virtual void docx_serialize_field(const std::wstring & field_name, office_element_ptr & text, oox::docx_conversion_context & Context, bool bLock = false); + virtual void docx_serialize_run(office_element_ptr & text, oox::docx_conversion_context & Context); + + virtual void xlsx_serialize(std::wostream & _Wostream, oox::xlsx_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){} }; //------------------------------------------------------------------------------------------------------------------- // simple text //------------------------------------------------------------------------------------------------------------------- -class text : public paragraph_content_element +class text : public paragraph_content_element { public: static office_element_ptr create(const std::wstring & Text); @@ -99,7 +113,7 @@ private: //------------------------------------------------------------------------------------------------------------------- // text:s //------------------------------------------------------------------------------------------------------------------- -class s : public paragraph_content_element +class s : public paragraph_content_element { public: static const wchar_t * ns; @@ -130,7 +144,7 @@ CP_REGISTER_OFFICE_ELEMENT2(s); //------------------------------------------------------------------------------------------------------------------- // text:tab //------------------------------------------------------------------------------------------------------------------- -class tab : public paragraph_content_element +class tab : public paragraph_content_element { public: static const wchar_t * ns; @@ -161,7 +175,7 @@ CP_REGISTER_OFFICE_ELEMENT2(tab); //------------------------------------------------------------------------------------------------------------------- // text:line-break //------------------------------------------------------------------------------------------------------------------- -class line_break : public paragraph_content_element +class line_break : public paragraph_content_element { public: static const wchar_t * ns; @@ -187,7 +201,7 @@ CP_REGISTER_OFFICE_ELEMENT2(line_break); //------------------------------------------------------------------------------------------------------------------- // text:bookmark //------------------------------------------------------------------------------------------------------------------- -class bookmark : public paragraph_content_element +class bookmark : public paragraph_content_element { public: static const wchar_t * ns; @@ -211,7 +225,7 @@ CP_REGISTER_OFFICE_ELEMENT2(bookmark); //------------------------------------------------------------------------------------------------------------------- // text:bookmark-start //------------------------------------------------------------------------------------------------------------------- -class bookmark_start : public paragraph_content_element +class bookmark_start : public paragraph_content_element { public: static const wchar_t * ns; @@ -235,7 +249,7 @@ CP_REGISTER_OFFICE_ELEMENT2(bookmark_start); //------------------------------------------------------------------------------------------------------------------- // text:bookmark-end //------------------------------------------------------------------------------------------------------------------- -class bookmark_end : public paragraph_content_element +class bookmark_end : public paragraph_content_element { public: static const wchar_t * ns; @@ -260,7 +274,7 @@ CP_REGISTER_OFFICE_ELEMENT2(bookmark_end); //------------------------------------------------------------------------------------------------------------------- // text:bookmark-ref //------------------------------------------------------------------------------------------------------------------- -class bookmark_ref : public paragraph_content_element +class bookmark_ref : public paragraph_content_element { public: static const wchar_t * ns; @@ -281,7 +295,7 @@ CP_REGISTER_OFFICE_ELEMENT2(bookmark_ref); //------------------------------------------------------------------------------------------------------------------- // text:reference-ref //------------------------------------------------------------------------------------------------------------------- -class reference_ref : public paragraph_content_element +class reference_ref : public paragraph_content_element { public: static const wchar_t * ns; @@ -303,7 +317,7 @@ CP_REGISTER_OFFICE_ELEMENT2(reference_ref); //------------------------------------------------------------------------------------------------------------------- // text:reference-mark //------------------------------------------------------------------------------------------------------------------- -class reference_mark : public paragraph_content_element +class reference_mark : public paragraph_content_element { public: static const wchar_t * ns; @@ -324,7 +338,7 @@ CP_REGISTER_OFFICE_ELEMENT2(reference_mark); //------------------------------------------------------------------------------------------------------------------- // text:reference-mark-start //------------------------------------------------------------------------------------------------------------------- -class reference_mark_start : public paragraph_content_element +class reference_mark_start : public paragraph_content_element { public: static const wchar_t * ns; @@ -345,7 +359,7 @@ CP_REGISTER_OFFICE_ELEMENT2(reference_mark_start); //------------------------------------------------------------------------------------------------------------------- // text:reference-mark-end //------------------------------------------------------------------------------------------------------------------- -class reference_mark_end : public paragraph_content_element +class reference_mark_end : public paragraph_content_element { public: static const wchar_t * ns; @@ -367,7 +381,7 @@ CP_REGISTER_OFFICE_ELEMENT2(reference_mark_end); //------------------------------------------------------------------------------------------------------------------- // text:span //------------------------------------------------------------------------------------------------------------------- -class span : public paragraph_content_element +class span : public paragraph_content_element { public: static const wchar_t * ns; @@ -380,6 +394,8 @@ public: virtual void xlsx_convert(oox::xlsx_conversion_context & Context); virtual void pptx_convert(oox::pptx_conversion_context & Context) ; + virtual void xlsx_serialize(std::wostream & _Wostream, oox::xlsx_conversion_context & Context); + virtual std::wostream & text_to_stream(std::wostream & _Wostream, bool bXmlEncode = true) const; span() {} @@ -400,7 +416,7 @@ CP_REGISTER_OFFICE_ELEMENT2(span); //------------------------------------------------------------------------------------------------------------------- // text:a //------------------------------------------------------------------------------------------------------------------- -class a : public paragraph_content_element +class a : public paragraph_content_element { public: static const wchar_t * ns; @@ -438,7 +454,7 @@ CP_REGISTER_OFFICE_ELEMENT2(a); //------------------------------------------------------------------------------------------------------------------- // text:note //------------------------------------------------------------------------------------------------------------------- -class note : public paragraph_content_element +class note : public paragraph_content_element { public: static const wchar_t * ns; @@ -467,7 +483,7 @@ CP_REGISTER_OFFICE_ELEMENT2(note); //------------------------------------------------------------------------------------------------------------------- // text:ruby //------------------------------------------------------------------------------------------------------------------- -class ruby : public paragraph_content_element +class ruby : public paragraph_content_element { public: static const wchar_t * ns; @@ -491,7 +507,7 @@ CP_REGISTER_OFFICE_ELEMENT2(ruby); //------------------------------------------------------------------------------------------------------------------- // text:title //------------------------------------------------------------------------------------------------------------------- -class title : public paragraph_content_element +class title : public paragraph_content_element { public: static const wchar_t * ns; @@ -519,7 +535,7 @@ CP_REGISTER_OFFICE_ELEMENT2(title); // text:chapter ////////////////////////////////////////////////////////////////////////////////////////////////// -class chapter : public paragraph_content_element<chapter> +class chapter : public paragraph_content_element { public: static const wchar_t * ns; @@ -545,7 +561,7 @@ CP_REGISTER_OFFICE_ELEMENT2(chapter); //------------------------------------------------------------------------------------------------------------------- //text:subject //------------------------------------------------------------------------------------------------------------------- -class subject : public paragraph_content_element<subject> +class subject : public paragraph_content_element { public: static const wchar_t * ns; @@ -570,7 +586,7 @@ CP_REGISTER_OFFICE_ELEMENT2(subject); //------------------------------------------------------------------------------------------------------------------- // text:placeholder //------------------------------------------------------------------------------------------------------------------- -class text_placeholder : public paragraph_content_element<text_placeholder> +class text_placeholder : public paragraph_content_element { public: static const wchar_t * ns; @@ -597,7 +613,7 @@ CP_REGISTER_OFFICE_ELEMENT2(text_placeholder); //------------------------------------------------------------------------------------------------------------------- // text:page-number //------------------------------------------------------------------------------------------------------------------- -class text_page_number: public paragraph_content_element<text_page_number> +class text_page_number: public paragraph_content_element { public: static const wchar_t * ns; @@ -609,6 +625,8 @@ public: void docx_convert(oox::docx_conversion_context & Context); void pptx_convert(oox::pptx_conversion_context & Context); + virtual void xlsx_serialize(std::wostream & _Wostream, oox::xlsx_conversion_context & Context); + virtual std::wostream & text_to_stream(std::wostream & _Wostream, bool bXmlEncode = true) const; private: @@ -629,7 +647,7 @@ CP_REGISTER_OFFICE_ELEMENT2(text_page_number); //------------------------------------------------------------------------------------------------------------------- // text:page-count //------------------------------------------------------------------------------------------------------------------- -class text_page_count : public paragraph_content_element<text_page_count> +class text_page_count : public paragraph_content_element { public: static const wchar_t * ns; @@ -641,6 +659,8 @@ public: void docx_convert(oox::docx_conversion_context & Context); void pptx_convert(oox::pptx_conversion_context & Context); + virtual void xlsx_serialize(std::wostream & _Wostream, oox::xlsx_conversion_context & Context); + virtual std::wostream & text_to_stream(std::wostream & _Wostream, bool bXmlEncode = true) const; _CP_OPT(odf_types::style_numformat) style_num_format_; @@ -658,7 +678,7 @@ CP_REGISTER_OFFICE_ELEMENT2(text_page_count); //------------------------------------------------------------------------------------------------------------------- // text:date //------------------------------------------------------------------------------------------------------------------- -class text_date : public paragraph_content_element<text_date> +class text_date : public paragraph_content_element { public: static const wchar_t * ns; @@ -670,7 +690,8 @@ public: virtual void docx_convert(oox::docx_conversion_context & Context); virtual void pptx_convert(oox::pptx_conversion_context & Context); - std::wostream & text_to_stream(std::wostream & _Wostream, bool bXmlEncode = true) const; + virtual void xlsx_serialize(std::wostream & _Wostream, oox::xlsx_conversion_context & Context); + std::wostream & text_to_stream(std::wostream & _Wostream, bool bXmlEncode = true) const; _CP_OPT(std::wstring) style_data_style_name_; _CP_OPT(odf_types::Bool) text_fixed_; @@ -713,7 +734,7 @@ CP_REGISTER_OFFICE_ELEMENT2(text_modification_date); //------------------------------------------------------------------------------------------------------------------- // text:time //------------------------------------------------------------------------------------------------------------------- -class text_time : public paragraph_content_element<text_time> +class text_time : public paragraph_content_element { public: static const wchar_t * ns; @@ -725,7 +746,9 @@ public: virtual void docx_convert(oox::docx_conversion_context & Context); virtual void pptx_convert(oox::pptx_conversion_context & Context); - std::wostream & text_to_stream(std::wostream & _Wostream, bool bXmlEncode = true) const; + virtual void xlsx_serialize(std::wostream & _Wostream, oox::xlsx_conversion_context & Context); + + std::wostream & text_to_stream(std::wostream & _Wostream, bool bXmlEncode = true) const; _CP_OPT(std::wstring) style_data_style_name_; _CP_OPT(odf_types::Bool)text_fixed_; @@ -768,7 +791,7 @@ CP_REGISTER_OFFICE_ELEMENT2(text_modification_time); //------------------------------------------------------------------------------------------------------------------- // text:file-name //------------------------------------------------------------------------------------------------------------------- -class text_file_name : public paragraph_content_element<text_file_name> +class text_file_name : public paragraph_content_element { public: static const wchar_t * ns; @@ -780,7 +803,9 @@ public: void docx_convert(oox::docx_conversion_context & Context); void pptx_convert(oox::pptx_conversion_context & Context); - virtual std::wostream & text_to_stream(std::wostream & _Wostream, bool bXmlEncode = true) const; + virtual void xlsx_serialize(std::wostream & _Wostream, oox::xlsx_conversion_context & Context); + + virtual std::wostream & text_to_stream(std::wostream & _Wostream, bool bXmlEncode = true) const; private: virtual void add_attributes( const xml::attributes_wc_ptr & Attributes ); @@ -795,7 +820,7 @@ CP_REGISTER_OFFICE_ELEMENT2(text_file_name); //------------------------------------------------------------------------------------------------------------------- // text:hidden-paragraph //------------------------------------------------------------------------------------------------------------------- -class hidden_paragraph : public paragraph_content_element<hidden_paragraph> +class hidden_paragraph : public paragraph_content_element { public: static const wchar_t * ns; @@ -819,7 +844,7 @@ CP_REGISTER_OFFICE_ELEMENT2(hidden_paragraph); //------------------------------------------------------------------------------------------------------------------- // text:hidden-text //------------------------------------------------------------------------------------------------------------------- -class hidden_text : public paragraph_content_element<hidden_text> +class hidden_text : public paragraph_content_element { public: static const wchar_t * ns; @@ -844,7 +869,7 @@ CP_REGISTER_OFFICE_ELEMENT2(hidden_text); //------------------------------------------------------------------------------------------------------------------- // text:sequence //------------------------------------------------------------------------------------------------------------------- -class sequence : public paragraph_content_element<sequence> +class sequence : public paragraph_content_element { public: static const wchar_t * ns; @@ -875,7 +900,7 @@ CP_REGISTER_OFFICE_ELEMENT2(sequence); //------------------------------------------------------------------------------------------------------------------- // text:expression //------------------------------------------------------------------------------------------------------------------- -class expression: public paragraph_content_element<expression> +class expression: public paragraph_content_element { public: static const wchar_t * ns; @@ -903,7 +928,7 @@ CP_REGISTER_OFFICE_ELEMENT2(expression); //------------------------------------------------------------------------------------------------------------------- // text:text-input //------------------------------------------------------------------------------------------------------------------- -class text_input: public paragraph_content_element<text_input> +class text_input: public paragraph_content_element { public: static const wchar_t * ns; @@ -927,7 +952,7 @@ CP_REGISTER_OFFICE_ELEMENT2(text_input); //------------------------------------------------------------------------------------------------------------------- // text:sequence_ref //------------------------------------------------------------------------------------------------------------------- -class sequence_ref : public paragraph_content_element<sequence_ref> +class sequence_ref : public paragraph_content_element { public: static const wchar_t * ns; @@ -952,7 +977,7 @@ CP_REGISTER_OFFICE_ELEMENT2(sequence_ref); //------------------------------------------------------------------------------------------------------------------- //text:drop-down //------------------------------------------------------------------------------------------------------------------- -class text_drop_down : public paragraph_content_element<text_drop_down> +class text_drop_down : public paragraph_content_element { public: static const wchar_t * ns; @@ -979,7 +1004,7 @@ CP_REGISTER_OFFICE_ELEMENT2(text_drop_down); //------------------------------------------------------------------------------------------------------------------- //text:label //------------------------------------------------------------------------------------------------------------------- -class text_label : public paragraph_content_element<text_label> +class text_label : public paragraph_content_element { public: static const wchar_t * ns; @@ -1000,7 +1025,7 @@ CP_REGISTER_OFFICE_ELEMENT2(text_label); //------------------------------------------------------------------------------------------------------------------- // text:sheet-name //------------------------------------------------------------------------------------------------------------------- -class sheet_name : public paragraph_content_element<sheet_name> +class sheet_name : public paragraph_content_element { public: static const wchar_t * ns; @@ -1010,6 +1035,8 @@ public: CPDOCCORE_DEFINE_VISITABLE(); virtual void docx_convert(oox::docx_conversion_context & Context); + + virtual void xlsx_serialize(std::wostream & _Wostream, oox::xlsx_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){} @@ -1022,7 +1049,7 @@ CP_REGISTER_OFFICE_ELEMENT2(sheet_name); //------------------------------------------------------------------------------------------------------------------- // text:author-name //------------------------------------------------------------------------------------------------------------------- -class author_name : public paragraph_content_element<author_name> +class author_name : public paragraph_content_element { public: static const wchar_t * ns; @@ -1044,7 +1071,7 @@ CP_REGISTER_OFFICE_ELEMENT2(author_name); //------------------------------------------------------------------------------------------------------------------- // text:author-initials //------------------------------------------------------------------------------------------------------------------- -class author_initials : public paragraph_content_element<author_initials> +class author_initials : public paragraph_content_element { public: static const wchar_t * ns; @@ -1066,7 +1093,7 @@ CP_REGISTER_OFFICE_ELEMENT2(author_initials); //------------------------------------------------------------------------------------------------------------------- // text:sender-city //------------------------------------------------------------------------------------------------------------------- -class sender_city : public paragraph_content_element<sender_city> +class sender_city : public paragraph_content_element { public: static const wchar_t * ns; @@ -1088,7 +1115,7 @@ CP_REGISTER_OFFICE_ELEMENT2(sender_city); //------------------------------------------------------------------------------------------------------------------- // text:sender-postal-code //------------------------------------------------------------------------------------------------------------------- -class sender_postal_code : public paragraph_content_element<sender_postal_code> +class sender_postal_code : public paragraph_content_element { public: static const wchar_t * ns; @@ -1112,7 +1139,7 @@ CP_REGISTER_OFFICE_ELEMENT2(sender_postal_code); //------------------------------------------------------------------------------------------------------------------- // text:sender-street //------------------------------------------------------------------------------------------------------------------- -class sender_street : public paragraph_content_element<sender_street> +class sender_street : public paragraph_content_element { public: static const wchar_t * ns; @@ -1134,7 +1161,7 @@ CP_REGISTER_OFFICE_ELEMENT2(sender_street); //------------------------------------------------------------------------------------------------------------------- // text:sender-state-or-province //------------------------------------------------------------------------------------------------------------------- -class sender_state_or_province : public paragraph_content_element<sender_state_or_province> +class sender_state_or_province : public paragraph_content_element { public: static const wchar_t * ns; @@ -1156,7 +1183,7 @@ CP_REGISTER_OFFICE_ELEMENT2(sender_state_or_province); //------------------------------------------------------------------------------------------------------------------- // text:sender-email //------------------------------------------------------------------------------------------------------------------- -class sender_email : public paragraph_content_element<sender_email> +class sender_email : public paragraph_content_element { public: static const wchar_t * ns; @@ -1178,7 +1205,7 @@ CP_REGISTER_OFFICE_ELEMENT2(sender_email); //------------------------------------------------------------------------------------------------------------------- // text:sender-firstname //------------------------------------------------------------------------------------------------------------------- -class sender_firstname : public paragraph_content_element<sender_firstname> +class sender_firstname : public paragraph_content_element { public: static const wchar_t * ns; @@ -1200,7 +1227,7 @@ CP_REGISTER_OFFICE_ELEMENT2(sender_firstname); //------------------------------------------------------------------------------------------------------------------- // text:sender-lastname //------------------------------------------------------------------------------------------------------------------- -class sender_lastname : public paragraph_content_element<sender_lastname> +class sender_lastname : public paragraph_content_element { public: static const wchar_t * ns; @@ -1222,7 +1249,7 @@ CP_REGISTER_OFFICE_ELEMENT2(sender_lastname); //------------------------------------------------------------------------------------------------------------------- // text:sender-company //------------------------------------------------------------------------------------------------------------------- -class sender_company : public paragraph_content_element<sender_company> +class sender_company : public paragraph_content_element { public: static const wchar_t * ns; @@ -1245,7 +1272,7 @@ CP_REGISTER_OFFICE_ELEMENT2(sender_company); //------------------------------------------------------------------------------------------------------------------- //text:user-field-get //--------------------------------------------------------------------------------------------------- -class text_user_field_get : public paragraph_content_element<text_user_field_get> +class text_user_field_get : public paragraph_content_element { public: static const wchar_t * ns; @@ -1271,7 +1298,7 @@ CP_REGISTER_OFFICE_ELEMENT2(text_user_field_get); //------------------------------------------------------------------------------------------------------------------- //text:user-defined //--------------------------------------------------------------------------------------------------- -class text_user_defined : public paragraph_content_element<text_user_defined> +class text_user_defined : public paragraph_content_element { public: static const wchar_t * ns; @@ -1299,7 +1326,7 @@ CP_REGISTER_OFFICE_ELEMENT2(text_user_defined); //--------------------------------------------------------------------------------------------------- //text:bibliography-mark //--------------------------------------------------------------------------------------------------- -class bibliography_mark : public paragraph_content_element<bibliography_mark> +class bibliography_mark : public paragraph_content_element { public: static const wchar_t * ns; @@ -1356,7 +1383,7 @@ CP_REGISTER_OFFICE_ELEMENT2(bibliography_mark); //--------------------------------------------------------------------------------------------------- //text:alphabetical-index-auto-mark-file //--------------------------------------------------------------------------------------------------- -class alphabetical_index_auto_mark_file : public paragraph_content_element<alphabetical_index_auto_mark_file> +class alphabetical_index_auto_mark_file : public paragraph_content_element { public: static const wchar_t * ns; @@ -1377,7 +1404,7 @@ CP_REGISTER_OFFICE_ELEMENT2(alphabetical_index_auto_mark_file); //--------------------------------------------------------------------------------------------------- //text:alphabetical-index-mark-start //--------------------------------------------------------------------------------------------------- -class alphabetical_index_mark_start : public paragraph_content_element<alphabetical_index_mark_start> +class alphabetical_index_mark_start : public paragraph_content_element { public: static const wchar_t * ns; @@ -1403,7 +1430,7 @@ CP_REGISTER_OFFICE_ELEMENT2(alphabetical_index_mark_start); //--------------------------------------------------------------------------------------------------- //text:alphabetical-index-mark-end //--------------------------------------------------------------------------------------------------- -class alphabetical_index_mark_end : public paragraph_content_element<alphabetical_index_mark_end> +class alphabetical_index_mark_end : public paragraph_content_element { public: static const wchar_t * ns; @@ -1424,7 +1451,7 @@ CP_REGISTER_OFFICE_ELEMENT2(alphabetical_index_mark_end); //--------------------------------------------------------------------------------------------------- //text:alphabetical-index-mark //--------------------------------------------------------------------------------------------------- -class alphabetical_index_mark : public paragraph_content_element<alphabetical_index_mark> +class alphabetical_index_mark : public paragraph_content_element { public: static const wchar_t * ns; @@ -1450,7 +1477,7 @@ CP_REGISTER_OFFICE_ELEMENT2(alphabetical_index_mark); //--------------------------------------------------------------------------------------------------- //text:user-index-mark-start //--------------------------------------------------------------------------------------------------- -class user_index_mark_start : public paragraph_content_element<user_index_mark_start> +class user_index_mark_start : public paragraph_content_element { public: static const wchar_t * ns; @@ -1473,7 +1500,7 @@ CP_REGISTER_OFFICE_ELEMENT2(user_index_mark_start); //--------------------------------------------------------------------------------------------------- //text:user-index-mark-end //--------------------------------------------------------------------------------------------------- -class user_index_mark_end : public paragraph_content_element<user_index_mark_end> +class user_index_mark_end : public paragraph_content_element { public: static const wchar_t * ns; @@ -1494,7 +1521,7 @@ CP_REGISTER_OFFICE_ELEMENT2(user_index_mark_end); //--------------------------------------------------------------------------------------------------- //text:user-index-mark //--------------------------------------------------------------------------------------------------- -class user_index_mark : public paragraph_content_element<user_index_mark> +class user_index_mark : public paragraph_content_element { public: static const wchar_t * ns; @@ -1517,7 +1544,7 @@ CP_REGISTER_OFFICE_ELEMENT2(user_index_mark); //--------------------------------------------------------------------------------------------------- //text:toc-mark-start //--------------------------------------------------------------------------------------------------- -class toc_mark_start : public paragraph_content_element<toc_mark_start> +class toc_mark_start : public paragraph_content_element { public: static const wchar_t * ns; @@ -1539,7 +1566,7 @@ CP_REGISTER_OFFICE_ELEMENT2(toc_mark_start); //--------------------------------------------------------------------------------------------------- //text:toc-mark-end //--------------------------------------------------------------------------------------------------- -class toc_mark_end : public paragraph_content_element<toc_mark_end> +class toc_mark_end : public paragraph_content_element { public: static const wchar_t * ns; @@ -1560,7 +1587,7 @@ CP_REGISTER_OFFICE_ELEMENT2(toc_mark_end); //--------------------------------------------------------------------------------------------------- //text:toc-mark //--------------------------------------------------------------------------------------------------- -class toc_mark : public paragraph_content_element<toc_mark> +class toc_mark : public paragraph_content_element { public: static const wchar_t * ns; @@ -1584,7 +1611,7 @@ CP_REGISTER_OFFICE_ELEMENT2(toc_mark); //------------------------------------------------------------------------------------------------------------------- //presentation:footer //------------------------------------------------------------------------------------------------------------------- -class presentation_footer : public text::paragraph_content_element<presentation_footer> +class presentation_footer : public text::paragraph_content_element { public: static const wchar_t * ns; @@ -1606,7 +1633,7 @@ CP_REGISTER_OFFICE_ELEMENT2(presentation_footer); //------------------------------------------------------------------------------------------------------------------- //presentation:date-time //------------------------------------------------------------------------------------------------------------------- -class presentation_date_time: public text::paragraph_content_element<presentation_date_time> +class presentation_date_time: public text::paragraph_content_element { public: static const wchar_t * ns; @@ -1629,7 +1656,7 @@ CP_REGISTER_OFFICE_ELEMENT2(presentation_date_time); //------------------------------------------------------------------------------------------------------------------- // field:fieldmark-start //------------------------------------------------------------------------------------------------------------------- -class field_fieldmark_start : public text::paragraph_content_element<field_fieldmark_start> +class field_fieldmark_start : public text::paragraph_content_element { public: static const wchar_t * ns; @@ -1651,7 +1678,7 @@ CP_REGISTER_OFFICE_ELEMENT2(field_fieldmark_start); //------------------------------------------------------------------------------------------------------------------- // field:fieldmark-end //------------------------------------------------------------------------------------------------------------------- -class field_fieldmark_end : public text::paragraph_content_element<field_fieldmark_end> +class field_fieldmark_end : public text::paragraph_content_element { public: static const wchar_t * ns; @@ -1670,7 +1697,7 @@ CP_REGISTER_OFFICE_ELEMENT2(field_fieldmark_end); //------------------------------------------------------------------------------------------------------------------- // field:fieldmark //------------------------------------------------------------------------------------------------------------------- -class field_fieldmark : public text::paragraph_content_element<field_fieldmark> +class field_fieldmark : public text::paragraph_content_element { public: static const wchar_t * ns; @@ -1694,7 +1721,7 @@ CP_REGISTER_OFFICE_ELEMENT2(field_fieldmark); //------------------------------------------------------------------------------------------------------------------- // field:param //------------------------------------------------------------------------------------------------------------------- -class field_param : public text::paragraph_content_element<field_param> +class field_param : public text::paragraph_content_element { public: static const wchar_t * ns; diff --git a/ASCOfficeOdfFile/src/odf/style_regions.cpp b/ASCOfficeOdfFile/src/odf/style_regions.cpp index 941fc3e127..36d4b85e29 100644 --- a/ASCOfficeOdfFile/src/odf/style_regions.cpp +++ b/ASCOfficeOdfFile/src/odf/style_regions.cpp @@ -31,13 +31,14 @@ */ #include "style_regions.h" +#include "text_elements.h" +#include "paragraph_elements.h" #include <xml/xmlchar.h> #include <xml/attributes.h> #include "serialize_elements.h" - namespace cpdoccore { namespace odf_reader { @@ -61,11 +62,34 @@ void style_region_impl::xlsx_convert(oox::xlsx_conversion_context & Context) } void style_region_impl::xlsx_serialize(std::wostream & _Wostream, oox::xlsx_conversion_context & Context) { - CP_SERIALIZE_TEXT(content_, true); + for (size_t i = 0; i < content_.size(); i++) + { + text::p* paragr = dynamic_cast<text::p*>(content_[i].get()); + text::h* header = dynamic_cast<text::h*>(content_[i].get()); - //for (size_t i = 0; i < content_.size(); i++) - //{ - //} + if (paragr || header) + { + text::paragraph* p = paragr ? ¶gr->paragraph_ : &header->paragraph_; + + for (size_t j = 0; j < p->content_.size(); j++) + { + text::paragraph_content_element *element = dynamic_cast<text::paragraph_content_element*>(p->content_[j].get()); + + if (element) + { + element->xlsx_serialize(_Wostream, Context); + } + else + { + CP_SERIALIZE_TEXT(p->content_[j], true); + } + } + } + else + { + CP_SERIALIZE_TEXT(content_[i], true); + } + } } void style_region_impl::add_attributes( const xml::attributes_wc_ptr & Attributes ) { diff --git a/ASCOfficeOdfFile/src/odf/styles.cpp b/ASCOfficeOdfFile/src/odf/styles.cpp index dd4544d0a9..f408270a16 100644 --- a/ASCOfficeOdfFile/src/odf/styles.cpp +++ b/ASCOfficeOdfFile/src/odf/styles.cpp @@ -1179,7 +1179,21 @@ void style_page_layout_properties::add_attributes( const xml::attributes_wc_ptr void style_page_layout_properties::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name) { - elements_.add_child_element(Reader, Ns, Name, getContext()); + if (L"style" == Ns && L"background-image" == Name) + { + CP_CREATE_ELEMENT(style_background_image_); + } + else if (L"style" == Ns && L"columns" == Name) + { + CP_CREATE_ELEMENT(style_columns_); + } + else if (L"style" == Ns && L"footnote-sep" == Name) + { + CP_CREATE_ELEMENT(style_footnote_sep_); + } + else + { + } } bool style_page_layout_properties::docx_background_serialize(std::wostream & strm, oox::docx_conversion_context & Context, oox::_oox_fill & fill, int id) @@ -1217,10 +1231,10 @@ void style_page_layout_properties::xlsx_serialize(std::wostream & strm, oox::xls if (horizontal_margins.fo_margin_left_ || horizontal_margins.fo_margin_right_ || vertical_margins.fo_margin_top_ || vertical_margins.fo_margin_bottom_ ) { - //_CP_OPT(odf_types::length) margin_top, margin_bottom; + _CP_OPT(double) header, footer; - //margin_top = Context.get_header_footer_context().header(); - //margin_bottom = Context.get_header_footer_context().footer(); + header = Context.get_table_context().get_header_page(); + footer = Context.get_table_context().get_footer_page(); CP_XML_NODE(L"pageMargins") { @@ -1240,12 +1254,10 @@ void style_page_layout_properties::xlsx_serialize(std::wostream & strm, oox::xls CP_XML_ATTR(L"bottom" , vertical_margins.fo_margin_bottom_->get_length().get_value_unit(odf_types::length::inch)); else CP_XML_ATTR(L"bottom", 1.025); - if (vertical_margins.fo_margin_top_) - CP_XML_ATTR(L"header" , vertical_margins.fo_margin_top_->get_length().get_value_unit(odf_types::length::inch)); + if (header) CP_XML_ATTR(L"header" , *header / 72.0); // pt -> inch else CP_XML_ATTR(L"header", 0.7875); - if (vertical_margins.fo_margin_bottom_) - CP_XML_ATTR(L"footer" , vertical_margins.fo_margin_bottom_->get_length().get_value_unit(odf_types::length::inch)); + if (footer) CP_XML_ATTR(L"footer" , *footer / 72.0); else CP_XML_ATTR(L"footer", 0.7875); } } @@ -1272,11 +1284,11 @@ void style_page_layout_properties::xlsx_serialize(std::wostream & strm, oox::xls } } } - if (elements_.style_background_image_) + if (style_background_image_) { oox::_oox_fill fill; - Compute_GraphicFill(attlist_.common_draw_fill_attlist_, elements_.style_background_image_, Context.root()->odf_context().drawStyles(), fill); + Compute_GraphicFill(attlist_.common_draw_fill_attlist_, style_background_image_, Context.root()->odf_context().drawStyles(), fill); if (fill.bitmap) { if ( fill.bitmap->rId.empty()) @@ -1294,7 +1306,7 @@ void style_page_layout_properties::xlsx_serialize(std::wostream & strm, oox::xls void style_page_layout_properties::docx_serialize(std::wostream & strm, oox::docx_conversion_context & Context) { - style_columns * columns = dynamic_cast<style_columns *>( elements_.style_columns_.get()); + style_columns * columns = dynamic_cast<style_columns *>( style_columns_.get()); CP_XML_WRITER(strm) { @@ -1386,28 +1398,6 @@ void style_page_layout_properties::pptx_serialize(std::wostream & strm, oox::ppt } } -// style-page-layout-properties-elements -////////////////////////////////////////////////////////////////////////////////////////////////// - -void style_page_layout_properties_elements::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name, document_context * Context ) -{ - if (L"style" == Ns && L"background-image" == Name) - { - CP_CREATE_ELEMENT_SIMPLE(style_background_image_); - } - else if (L"style" == Ns && L"columns" == Name) - { - CP_CREATE_ELEMENT_SIMPLE(style_columns_); - } - else if (L"style" == Ns && L"footnote-sep" == Name) - { - CP_CREATE_ELEMENT_SIMPLE(style_footnote_sep_); - } - else - { - not_applicable_element(L"style-page-layout-properties-elements", Reader, Ns, Name); - } -} // style-master-page-attlist ////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/ASCOfficeOdfFile/src/odf/styles.h b/ASCOfficeOdfFile/src/odf/styles.h index 71751164a3..96f2e96151 100644 --- a/ASCOfficeOdfFile/src/odf/styles.h +++ b/ASCOfficeOdfFile/src/odf/styles.h @@ -945,20 +945,6 @@ private: CP_REGISTER_OFFICE_ELEMENT2(style_footnote_sep); -// style-page-layout-properties-elements -class style_page_layout_properties_elements -{ -public: - void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name, document_context * Context); - - office_element_ptr style_background_image_; - office_element_ptr style_columns_; - - // 15.2.20 - office_element_ptr style_footnote_sep_; - -}; - // style:page-layout-properties class style_page_layout_properties : public office_element_impl<style_page_layout_properties> { @@ -969,19 +955,21 @@ public: static const ElementType type = typeStylePageLayout; CPDOCCORE_DEFINE_VISITABLE(); - void pptx_convert (oox::pptx_conversion_context & Context); - void xlsx_convert (oox::xlsx_conversion_context & Context){} + void pptx_convert(oox::pptx_conversion_context & Context); bool docx_background_serialize(std::wostream & strm, oox::docx_conversion_context & Context, oox::_oox_fill & fill, int id); - void docx_serialize (std::wostream & strm, oox::docx_conversion_context & Context); + void docx_serialize(std::wostream & strm, oox::docx_conversion_context & Context); void xlsx_serialize(std::wostream & strm, oox::xlsx_conversion_context & Context); void pptx_serialize(std::wostream & strm, oox::pptx_conversion_context & Context); style_page_layout_properties() { } - style_page_layout_properties_attlist attlist_; - style_page_layout_properties_elements elements_; + style_page_layout_properties_attlist attlist_; + + office_element_ptr style_background_image_; + office_element_ptr style_columns_; + office_element_ptr style_footnote_sep_; private: diff --git a/ASCOfficeOdfFileW/source/OdfFormat/odf_page_layout_context.cpp b/ASCOfficeOdfFileW/source/OdfFormat/odf_page_layout_context.cpp index 05d9812d22..273900c42c 100755 --- a/ASCOfficeOdfFileW/source/OdfFormat/odf_page_layout_context.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/odf_page_layout_context.cpp @@ -330,31 +330,11 @@ bool odf_page_layout_context::add_footer(int type) style_page_layout_properties *props = get_properties(); if (!props)return true; - length length_ = length(layout_state_list_.back().footer_size_->get_value_unit(length::cm),length::cm); + length length_ = length(layout_state_list_.back().footer_size_->get_value_unit(length::cm), length::cm); - _CP_OPT(length) bottom_; - - if (props->attlist_.common_vertical_margin_attlist_.fo_margin_bottom_) - bottom_= props->attlist_.common_vertical_margin_attlist_.fo_margin_bottom_->get_length(); + footer_props->style_header_footer_properties_attlist_.svg_height_ = length_; + footer_props->style_header_footer_properties_attlist_.fo_min_height_ = length_; - if (bottom_) - { - double length_cm = bottom_->get_value_unit(length::cm) - length_.get_value_unit(length::cm); - - if (length_cm > 0.01) - { - props->attlist_.common_vertical_margin_attlist_.fo_margin_bottom_ = length_; - footer_props->style_header_footer_properties_attlist_.svg_height_ = length(fabs(length_cm),length::cm);//fo_min_height_ - footer_props->style_header_footer_properties_attlist_.fo_min_height_ = length(fabs(length_cm),length::cm); - } - else if (-length_cm >0.01) - { - footer_props->style_header_footer_properties_attlist_.svg_height_ = length(-length_cm,length::cm);//fo_min_height_ - } - }else - { - props->attlist_.common_vertical_margin_attlist_.fo_margin_bottom_ = length_; - } layout_state_list_.back().footer_size_ = boost::none; return true; @@ -395,29 +375,9 @@ bool odf_page_layout_context::add_header(int type) length length_ = length(layout_state_list_.back().header_size_->get_value_unit(length::cm), length::cm); - _CP_OPT(length) top_; + header_props->style_header_footer_properties_attlist_.svg_height_ = length_; + header_props->style_header_footer_properties_attlist_.fo_min_height_ = length_; - if (props->attlist_.common_vertical_margin_attlist_.fo_margin_top_) - top_ = props->attlist_.common_vertical_margin_attlist_.fo_margin_top_->get_length();; - - if (top_) - { - double length_cm = top_->get_value_unit(length::cm) - length_.get_value_unit(length::cm); - if (length_cm > 0.01) - { - props->attlist_.common_vertical_margin_attlist_.fo_margin_top_ = length_; - header_props->style_header_footer_properties_attlist_.svg_height_ = length(fabs(length_cm),length::cm); - header_props->style_header_footer_properties_attlist_.fo_min_height_ = length(fabs(length_cm),length::cm);//fo_min_height_ - } - else if (-length_cm >0.01) - { - header_props->style_header_footer_properties_attlist_.svg_height_ = length(-length_cm,length::cm); - header_props->style_header_footer_properties_attlist_.fo_min_height_ = length(-length_cm,length::cm);//fo_min_height_ - } - } - else - props->attlist_.common_vertical_margin_attlist_.fo_margin_top_ = length_; - layout_state_list_.back().header_size_ = boost::none; return true; } diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp index fba20307e4..32795a1c69 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp @@ -1591,37 +1591,59 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool b { odt_context->page_layout_context()->add_master_page(master_name); } - - bool present_header = false; - bool present_footer = false; if (oox_section_pr->m_oPgMar.IsInit()) { - _CP_OPT(odf_types::length) top, left, right, bottom, other; + _CP_OPT(odf_types::length) top, left, right, bottom, header, footer, gutter; convert(oox_section_pr->m_oPgMar->m_oBottom.GetPointer(), bottom); convert(oox_section_pr->m_oPgMar->m_oLeft.GetPointer(), left); convert(oox_section_pr->m_oPgMar->m_oRight.GetPointer(), right); convert(oox_section_pr->m_oPgMar->m_oTop.GetPointer(), top); + convert(oox_section_pr->m_oPgMar->m_oHeader.GetPointer(), header); + convert(oox_section_pr->m_oPgMar->m_oFooter.GetPointer(), footer); + convert(oox_section_pr->m_oPgMar->m_oGutter.GetPointer(), gutter); + if (bottom) + { + double length_cm = bottom->get_value_unit(length::cm) -( footer ? footer->get_value_unit(length::cm) : 0); + + if (length_cm > 0.01) + { + bottom = footer; + footer = length(fabs(length_cm), length::cm); + } + else if (-length_cm > 0.01) + { + footer = length(-length_cm, length::cm);//fo_min_height_ + } + } + else + { + bottom = footer; + } + if (top) + { + double length_cm = top->get_value_unit(length::cm) - (header ? header->get_value_unit(length::cm) : 0); + + if (length_cm > 0.01) + { + top = header; + header = length(fabs(length_cm), length::cm); + } + else if (-length_cm > 0.01) + { + header = length(-length_cm, length::cm);//fo_min_height_ + } + } + else + { + top = header; + } odt_context->page_layout_context()->set_page_margin(top, left, bottom, right); - - convert(oox_section_pr->m_oPgMar->m_oGutter.GetPointer(), other); - odt_context->page_layout_context()->set_page_gutter(other); - - if (oox_section_pr->m_oPgMar->m_oFooter.IsInit()) - { - convert(oox_section_pr->m_oPgMar->m_oFooter.GetPointer(), other); - odt_context->page_layout_context()->set_footer_size(other); - present_footer = true; - } - - if (oox_section_pr->m_oPgMar->m_oHeader.IsInit()) - { - convert(oox_section_pr->m_oPgMar->m_oHeader.GetPointer(), other); - odt_context->page_layout_context()->set_header_size(other); - present_header =true; - } + odt_context->page_layout_context()->set_page_gutter(gutter); + odt_context->page_layout_context()->set_header_size(header); + odt_context->page_layout_context()->set_footer_size(footer); } if (oox_section_pr->m_oPgBorders.IsInit()) { diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp index bbe3e98529..d0f617b1f0 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/XlsxConverter.cpp @@ -1595,13 +1595,13 @@ void XlsxConverter::convert(OOX::Spreadsheet::CPageSetup *oox_page) height = odf_types::length(11, odf_types::length::inch); break; case SimpleTypes::Spreadsheet::pagesizeA3Paper: - width = odf_types::length(210, odf_types::length::mm); - height = odf_types::length(297, odf_types::length::mm); - break; - case SimpleTypes::Spreadsheet::pagesizeA4Paper: width = odf_types::length(297, odf_types::length::mm); height = odf_types::length(420, odf_types::length::mm); break; + case SimpleTypes::Spreadsheet::pagesizeA4Paper: + width = odf_types::length(210, odf_types::length::mm); + height = odf_types::length(297, odf_types::length::mm); + break; default: break; //todooo