From d5a5a05a75438262691a6e2e4fd0c1885a887895 Mon Sep 17 00:00:00 2001 From: "Elen.Subbotina" Date: Sun, 20 Jul 2014 15:20:38 +0000 Subject: [PATCH] ..... git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@57412 954022d7-b5bf-4e40-9824-e11837661b57 --- .../src/odf/datatypes/common_attlists.h | 2 +- .../odf/style_paragraph_properties_docx.cpp | 2 +- .../source/OdfFormat/odf_drawing_context.cpp | 128 +++++++++----- .../OdfFormat/odf_page_layout_context.cpp | 35 +++- .../OdfFormat/odf_page_layout_context.h | 5 + .../source/OdfFormat/odf_style_context.cpp | 6 + .../source/OdfFormat/odf_style_context.h | 1 + .../OdfFormat/style_paragraph_properties.h | 2 +- .../source/Oox2OdfConverter/DocxConverter.cpp | 166 ++++++++++++++++-- .../source/Oox2OdfConverter/DocxConverter.h | 5 + 10 files changed, 294 insertions(+), 58 deletions(-) diff --git a/ASCOfficeOdfFile/src/odf/datatypes/common_attlists.h b/ASCOfficeOdfFile/src/odf/datatypes/common_attlists.h index 24e1b5c60c..991206a5eb 100644 --- a/ASCOfficeOdfFile/src/odf/datatypes/common_attlists.h +++ b/ASCOfficeOdfFile/src/odf/datatypes/common_attlists.h @@ -165,7 +165,7 @@ public: void serialize(CP_ATTR_NODE); public: - _CP_OPT(shadow_type) style_shadow_; + _CP_OPT(std::wstring) style_shadow_; }; diff --git a/ASCOfficeOdfFile/src/odf/style_paragraph_properties_docx.cpp b/ASCOfficeOdfFile/src/odf/style_paragraph_properties_docx.cpp index 7c67c8cb4c..c67d5b3048 100644 --- a/ASCOfficeOdfFile/src/odf/style_paragraph_properties_docx.cpp +++ b/ASCOfficeOdfFile/src/odf/style_paragraph_properties_docx.cpp @@ -210,7 +210,7 @@ void paragraph_format_properties::docx_convert(oox::docx_conversion_context & Co std::wstring w_shadow; if (style_shadow_) - w_shadow = style_shadow_->get_type() != shadow_type::None ? L"1" : L"0"; + w_shadow = style_shadow_->length()>0 ! ? L"1" : L"0"; //стиль тени задается а-ля стилю бордера std::wstring w_top, w_left, w_right, w_bottom, w_between; diff --git a/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.cpp b/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.cpp index 5160b8eaa2..5b3cdd7996 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/odf_drawing_context.cpp @@ -30,8 +30,22 @@ namespace cpdoccore namespace odf { +struct odf_group_state; +typedef shared_ptr::Type odf_group_state_ptr; + struct odf_group_state { + odf_group_state(office_element_ptr elm_, int level_, odf_group_state_ptr prev) + { + delta_x = delta_y = rotate = 0; + koef_cx = koef_cy = 1.; + flipH = flipV = false; + + elm = elm_; + level = level_; + + prev_group = prev; + } office_element_ptr elm; int level; @@ -46,6 +60,8 @@ struct odf_group_state bool flipH; bool flipV; + + odf_group_state_ptr prev_group; }; struct anchor_settings @@ -131,6 +147,7 @@ struct odf_drawing_state oox_shape_preset = -1; in_group = false; + } std::vector elements_; @@ -185,8 +202,9 @@ public: graphic_format_properties preset_graphic_format_properties; - std::vector group_list_; //группы - std::vector drawing_list_; //все элементы(кроме групп) .. для удобства разделение по "топам" + odf_group_state_ptr current_group_; + std::vector group_list_; //группы + std::vector drawing_list_; //все элементы(кроме групп) .. для удобства разделение по "топам" office_element_ptr root_element_; @@ -218,8 +236,11 @@ void odf_drawing_context::start_group(std::wstring name, int id) int level = impl_->current_level_.size(); - odf_group_state group_state = {group_elm, level, 0, 0, 1., 1., false, false}; + + odf_group_state_ptr group_state = boost::shared_ptr(new odf_group_state(group_elm, level,impl_->current_group_)); impl_->group_list_.push_back(group_state); + + impl_->current_group_ = impl_->group_list_.back(); if (impl_->current_level_.size()>0) impl_->current_level_.back()->add_child_element(group_elm); @@ -235,6 +256,9 @@ void odf_drawing_context::start_group(std::wstring name, int id) } void odf_drawing_context::end_group() { + if (impl_->group_list_.size() < 1)return; + + impl_->current_group_ = impl_->group_list_.back()->prev_group; impl_->current_level_.pop_back(); } @@ -242,55 +266,72 @@ void odf_drawing_context::set_group_size_koef( double cx, double cy) { if (impl_->group_list_.size()<1)return; - for (long i = impl_->group_list_.size()-1; i>=0; i--) + odf_group_state_ptr gr = impl_->current_group_; + // на 2 шага вниз !!! текущее еще не записали - нужно предудущее 1, остальные уже учтены + int step = 2; + while (gr && step > 0) { - cx *= impl_->group_list_[i].koef_cx; - cy *= impl_->group_list_[i].koef_cy; + cx *= gr->koef_cx; + cy *= gr->koef_cy; - if (impl_->group_list_[i].level <1) break; + gr = gr->prev_group; + step--; } - impl_->group_list_.back().koef_cx = cx; - impl_->group_list_.back().koef_cy = cy; + impl_->group_list_.back()->koef_cx = cx; + impl_->group_list_.back()->koef_cy = cy; } void odf_drawing_context::set_group_position_delta(double x_pt, double y_pt) { if (impl_->group_list_.size()<1)return; - for (long i = impl_->group_list_.size()-1; i>=0; i--) + odf_group_state_ptr gr = impl_->current_group_; + + int step = 2; + while (gr && step > 0) { - x_pt += impl_->group_list_[i].delta_x; - y_pt += impl_->group_list_[i].delta_y; + x_pt += gr->delta_x; + y_pt += gr->delta_y; - if (impl_->group_list_[i].level <1) break; + gr = gr->prev_group; + step--; } - impl_->group_list_.back().delta_x = x_pt; - impl_->group_list_.back().delta_y = y_pt; + impl_->group_list_.back()->delta_x = x_pt; + impl_->group_list_.back()->delta_y = y_pt; } void odf_drawing_context::set_group_flip_H(bool bVal) { if (impl_->group_list_.size()<1)return; - for (long i = impl_->group_list_.size()-1; i>=0; i--) - { - bVal += impl_->group_list_[i].flipH; + odf_group_state_ptr gr = impl_->current_group_; - if (impl_->group_list_[i].level <1) break; + int step = 2; + while (gr && step > 0) + { + bVal += gr->flipH; + gr = gr->prev_group; + step--; } - impl_->group_list_.back().flipH= bVal; + + impl_->group_list_.back()->flipH= bVal; } + void odf_drawing_context::set_group_flip_V(bool bVal) { if (impl_->group_list_.size()<1)return; - for (long i = impl_->group_list_.size()-1; i>=0; i--) - { - bVal += impl_->group_list_[i].flipV; + odf_group_state_ptr gr = impl_->current_group_; - if (impl_->group_list_[i].level <1) break; + int step = 2; + while (gr && step > 0) + { + bVal += gr->flipV; + gr = gr->prev_group; + step--; } - impl_->group_list_.back().flipV= bVal; + + impl_->group_list_.back()->flipV= bVal; } void odf_drawing_context::set_group_rotate(int iVal) @@ -299,19 +340,20 @@ void odf_drawing_context::set_group_rotate(int iVal) double dRotate = (360 - iVal/60000.)/180. * 3.14159265358979323846; - for (long i = impl_->group_list_.size()-1; i>=0; i--) + odf_group_state_ptr gr = impl_->current_group_; + + int step = 2; + while (gr && step > 0) { - dRotate += impl_->group_list_[i].rotate; - - if (impl_->group_list_[i].level <1) break; + dRotate += gr->rotate; + gr = gr->prev_group; + step--; } - impl_->group_list_.back().rotate = dRotate; - + impl_->group_list_.back()->rotate = dRotate; } void odf_drawing_context::clear() { - impl_->root_element_ = office_element_ptr(); impl_->anchor_settings_.clear(); @@ -350,7 +392,7 @@ void odf_drawing_context::end_drawing() std::wstring strTransform; if (impl_->current_drawing_state_.in_group && impl_->group_list_.size()>0) { - double rotate = impl_->group_list_.back().rotate; + double rotate = impl_->group_list_.back()->rotate; if (impl_->current_drawing_state_.rotateAngle ) rotate += *impl_->current_drawing_state_.rotateAngle; @@ -372,10 +414,8 @@ void odf_drawing_context::end_drawing() impl_->current_drawing_state_.svg_y_ = boost::none; }else if (impl_->current_drawing_state_.in_group) { - strTransform += std::wstring(L"translate(") + boost::lexical_cast(impl_->current_drawing_state_.svg_x_.get() + - (impl_->current_drawing_state_.svg_width_.get()/2))+ std::wstring(L",") + - boost::lexical_cast(impl_->current_drawing_state_.svg_y_.get() + - (impl_->current_drawing_state_.svg_height_.get()/2))+ std::wstring(L")") ; + strTransform += std::wstring(L"translate(") + boost::lexical_cast(impl_->current_drawing_state_.svg_x_.get()) + + std::wstring(L",") + boost::lexical_cast(impl_->current_drawing_state_.svg_y_.get()) + std::wstring(L")") ; impl_->current_drawing_state_.svg_x_ = boost::none; impl_->current_drawing_state_.svg_y_ = boost::none; } @@ -932,19 +972,21 @@ void odf_drawing_context::set_wrap_style(style_wrap::type type) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void odf_drawing_context::set_position(double x_pt, double y_pt) { + x_pt*=20; + y_pt*=20; if (impl_->group_list_.size() < 1)return; if (!impl_->current_drawing_state_.svg_x_) { if (impl_->current_drawing_state_.in_group) - x_pt += impl_->group_list_.back().delta_x; + x_pt += impl_->group_list_.back()->delta_x; impl_->current_drawing_state_.svg_x_ = length(length(x_pt,length::pt).get_value_unit(length::cm),length::cm); } if (!impl_->current_drawing_state_.svg_y_) { if (impl_->current_drawing_state_.in_group) - y_pt += impl_->group_list_.back().delta_y; + y_pt += impl_->group_list_.back()->delta_y; impl_->current_drawing_state_.svg_y_ = length(length(y_pt,length::pt).get_value_unit(length::cm),length::cm); } @@ -960,8 +1002,8 @@ void odf_drawing_context::set_size( double width_pt, double height_pt) { if (impl_->current_drawing_state_.in_group) { - width_pt *= impl_->group_list_.back().koef_cx; - height_pt *= impl_->group_list_.back().koef_cy; + width_pt *= impl_->group_list_.back()->koef_cx; + height_pt *= impl_->group_list_.back()->koef_cy; } //if (!impl_->current_drawing_state_.svg_width_) if (width_pt >= 0) impl_->current_drawing_state_.svg_width_ = length(length(width_pt,length::pt).get_value_unit(length::cm),length::cm); @@ -1213,9 +1255,9 @@ void odf_drawing_context::finalize(office_element_ptr & root_elm)// { for (int i=0; i< impl_->group_list_.size(); i++) { - if (impl_->group_list_[i].level ==0 ) + if (impl_->group_list_[i]->level ==0 ) { - root_elm->add_child_element(impl_->group_list_[i].elm); + root_elm->add_child_element(impl_->group_list_[i]->elm); } } for (int i=0; i< impl_->drawing_list_.size(); i++) diff --git a/ASCOfficeOdfFileW/source/OdfFormat/odf_page_layout_context.cpp b/ASCOfficeOdfFileW/source/OdfFormat/odf_page_layout_context.cpp index 99e3622d6f..0e62c9ddb7 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/odf_page_layout_context.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/odf_page_layout_context.cpp @@ -59,8 +59,11 @@ void odf_page_layout_context::create_master_page(std::wstring oox_name) //default layout create_layout_page(); master_state_list_.back().set_layout_name(layout_state_list_.back().get_name()); +} - +void odf_page_layout_context::set_current_master_page_base() +{ + style_context_->set_current_master_page_base(); } void odf_page_layout_context::set_styles_context(odf_style_context * Context) @@ -129,6 +132,36 @@ void odf_page_layout_context::set_page_margin(_CP_OPT(length) top, _CP_OPT(lengt // props->style_page_layout_properties_attlist_.common_horizontal_margin_attlist_.fo_margin_right_ = // length(footer->get_value_unit(length::cm),length::cm); } +void odf_page_layout_context::set_page_gutter(_CP_OPT(length) length_) +{ + if (!length_) return; + + +} +void odf_page_layout_context::set_page_border_shadow(bool val) +{ + style_page_layout_properties * props = get_properties(); + if (!props)return; + + props->style_page_layout_properties_attlist_.common_shadow_attlist_.style_shadow_ = L"#000000 0.159cm 0.159cm"; +} +void odf_page_layout_context::set_page_border(std::wstring top, std::wstring left, std::wstring bottom, std::wstring right) +{ + style_page_layout_properties * props = get_properties(); + if (!props)return; + + if (bottom == top && top == left && left== right && bottom.length() > 0) + { + props->style_page_layout_properties_attlist_.common_border_attlist_.fo_border_ = left; + } + else + { + if (bottom.length() >0 )props->style_page_layout_properties_attlist_.common_border_attlist_.fo_border_bottom_ = bottom; + if (top.length() >0 ) props->style_page_layout_properties_attlist_.common_border_attlist_.fo_border_top_ = top; + if (left.length() >0 ) props->style_page_layout_properties_attlist_.common_border_attlist_.fo_border_left_ = left; + if (right.length() >0 ) props->style_page_layout_properties_attlist_.common_border_attlist_.fo_border_right_ = right; + } +} void odf_page_layout_context::set_page_size(_CP_OPT(length) width, _CP_OPT(length) height) { style_page_layout_properties * props = get_properties(); diff --git a/ASCOfficeOdfFileW/source/OdfFormat/odf_page_layout_context.h b/ASCOfficeOdfFileW/source/OdfFormat/odf_page_layout_context.h index c1e7d03257..ef3f579020 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/odf_page_layout_context.h +++ b/ASCOfficeOdfFileW/source/OdfFormat/odf_page_layout_context.h @@ -31,9 +31,14 @@ public: void set_page_margin(_CP_OPT(double) top, _CP_OPT(double) left, _CP_OPT(double) bottom, _CP_OPT(double) right, _CP_OPT(double) header, _CP_OPT(double) footer); void set_page_margin(_CP_OPT(length) top, _CP_OPT(length) left, _CP_OPT(length) bottom, _CP_OPT(length) right); + void set_page_gutter(_CP_OPT(length) length_); + void set_page_border(std::wstring top, std::wstring left, std::wstring bottom, std::wstring right); + void set_page_border_shadow(bool val); void set_page_orientation(int type); void set_page_size(_CP_OPT(length) width, _CP_OPT(length) height); + void set_current_master_page_base(); + private: style_page_layout_properties *get_properties(); diff --git a/ASCOfficeOdfFileW/source/OdfFormat/odf_style_context.cpp b/ASCOfficeOdfFileW/source/OdfFormat/odf_style_context.cpp index b416c0cf60..a2fcf7ef70 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/odf_style_context.cpp +++ b/ASCOfficeOdfFileW/source/OdfFormat/odf_style_context.cpp @@ -90,6 +90,12 @@ void odf_style_context::add_master_style(office_element_ptr & elm) } +void odf_style_context::set_current_master_page_base() +{ + master_style_list_.insert(master_style_list_.begin(), master_style_list_.back()); + master_style_list_.pop_back(); +} + void odf_style_context::create_default_style(const style_family family) { office_element_ptr elm; diff --git a/ASCOfficeOdfFileW/source/OdfFormat/odf_style_context.h b/ASCOfficeOdfFileW/source/OdfFormat/odf_style_context.h index fad22071aa..a60545735d 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/odf_style_context.h +++ b/ASCOfficeOdfFileW/source/OdfFormat/odf_style_context.h @@ -33,6 +33,7 @@ public: void add_style(office_element_ptr elm, bool automatic = false, bool root = false, style_family style_family=style_family::None); void add_master_style(office_element_ptr & elm); + void set_current_master_page_base(); office_element_ptr & add_or_find(std::wstring name, const style_family family, bool automatic = false, bool root = false, int id = -1); diff --git a/ASCOfficeOdfFileW/source/OdfFormat/style_paragraph_properties.h b/ASCOfficeOdfFileW/source/OdfFormat/style_paragraph_properties.h index daa9e6037b..e75ed10c52 100644 --- a/ASCOfficeOdfFileW/source/OdfFormat/style_paragraph_properties.h +++ b/ASCOfficeOdfFileW/source/OdfFormat/style_paragraph_properties.h @@ -280,7 +280,7 @@ public: _CP_OPT(length) fo_padding_right_; // + // 15.5.28 style:shadow - _CP_OPT(shadow_type) style_shadow_; + _CP_OPT(std::wstring) style_shadow_; // 15.5.29 fo:keep-with-next _CP_OPT(keep_together) fo_keep_with_next_; // + diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp b/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp index ddcd4f41b1..9bf3e3be68 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.cpp @@ -42,7 +42,7 @@ DocxConverter::DocxConverter(const std::wstring & path, const ProgressCallback* //set flags to default m_bKeepNextParagraph = false; - if (UpdateProgress(400000))return; + if (UpdateProgress(290000))return; } void DocxConverter::write(const std::wstring & path) { @@ -120,8 +120,10 @@ void DocxConverter::convertDocument() odt_context->start_document(); convert_styles(); - if (UpdateProgress(500000))return; + if (UpdateProgress(300000))return; + convert_settings(); + convert_document(); if (UpdateProgress(800000))return; @@ -139,6 +141,7 @@ void DocxConverter::convert_document() if (!document)return; convert(document->m_oBackground.GetPointer());//подложка + for ( int nIndex = 0; nIndex < document->m_arrItems.GetSize(); nIndex++ ) { convert(document->m_arrItems[nIndex]); @@ -152,6 +155,11 @@ void DocxConverter::convert(OOX::WritingElement *oox_unknown) switch(oox_unknown->getType()) { + case OOX::et_w_sdt: + { + OOX::Logic::CSdt* pP= static_cast(oox_unknown); + convert(pP); + }break; case OOX::et_w_r: { OOX::Logic::CRun* pRun= static_cast(oox_unknown); @@ -243,7 +251,21 @@ void DocxConverter::convert(OOX::WritingElement *oox_unknown) }break; } } -void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph) +void DocxConverter::convert(OOX::Logic::CSdt *oox_sdt) +{ + if (oox_sdt == NULL) return; + //nullable m_oSdtEndPr; + //nullable m_oSdtPr; + + if (oox_sdt->m_oSdtContent.IsInit()) + { + for (long i=0; i< oox_sdt->m_oSdtContent->m_arrItems.GetSize(); i++) + { + convert(oox_sdt->m_oSdtContent->m_arrItems[i]); + } + } +} +void DocxConverter::convert(OOX::Logic::CParagraph *oox_paragraph) { if (oox_paragraph == NULL) return; @@ -582,13 +604,13 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r { if (oox_section_pr == NULL) return; - odt_context->page_layout_context()->create_master_page(L""); + odt_context->page_layout_context()->create_master_page(root ? L"Standart" : L""); odt_context->set_master_page_name(odt_context->page_layout_context()->last_master().get_name()); if (oox_section_pr->m_oPgMar.IsInit()) { - _CP_OPT(odf::length) top, left, right, bottom; + _CP_OPT(odf::length) top, left, right, bottom, other; 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); @@ -596,11 +618,42 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r 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); + //nullable m_oFooter; - //nullable m_oGutter; //nullable m_oHeader; } + if (oox_section_pr->m_oPgBorders.IsInit()) + { + std::wstring top, left, right, bottom; + convert(oox_section_pr->m_oPgBorders->m_oBottom.GetPointer(), bottom); + convert(oox_section_pr->m_oPgBorders->m_oLeft.GetPointer() , left); + convert(oox_section_pr->m_oPgBorders->m_oRight.GetPointer() , right); + convert(oox_section_pr->m_oPgBorders->m_oTop.GetPointer() , top); + + odt_context->page_layout_context()->set_page_border(top,left,bottom, right); + bool shadow = false; + if (oox_section_pr->m_oPgBorders->m_oBottom.IsInit() && oox_section_pr->m_oPgBorders->m_oBottom->m_oShadow.IsInit() && oox_section_pr->m_oPgBorders->m_oBottom->m_oShadow->ToBool()) shadow = true; + if (oox_section_pr->m_oPgBorders->m_oTop.IsInit() && oox_section_pr->m_oPgBorders->m_oTop->m_oShadow.IsInit() && oox_section_pr->m_oPgBorders->m_oTop->m_oShadow->ToBool()) shadow = true; + if (oox_section_pr->m_oPgBorders->m_oLeft.IsInit() && oox_section_pr->m_oPgBorders->m_oLeft->m_oShadow.IsInit() && oox_section_pr->m_oPgBorders->m_oLeft->m_oShadow->ToBool()) shadow = true; + if (oox_section_pr->m_oPgBorders->m_oRight.IsInit() && oox_section_pr->m_oPgBorders->m_oRight->m_oShadow.IsInit() && oox_section_pr->m_oPgBorders->m_oRight->m_oShadow->ToBool()) shadow = true; + + if (shadow) odt_context->page_layout_context()->set_page_border_shadow(true); + + if (oox_section_pr->m_oPgBorders->m_oDisplay.IsInit()) + { + // todooo + //pageborderdisplayAllPages = 0, + //pageborderdisplayFirstPage = 1, + //pageborderdisplayNotFirstPage = 2 + //нужно разделить + сделать новые (без этих свойств) стили страниц - действительно для раздела + } + //nullable > m_oOffsetFrom; + //nullable > m_oZOrder; + + } if (oox_section_pr->m_oPgSz.IsInit()) { if (oox_section_pr->m_oPgSz->m_oOrient.IsInit()) @@ -612,6 +665,7 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r convert(oox_section_pr->m_oPgSz->m_oH.GetPointer(), height); odt_context->page_layout_context()->set_page_size(width, height); + //nullable > m_oCode; } //nullable m_oTextDirection; @@ -696,6 +750,9 @@ void DocxConverter::convert(OOX::Logic::CSectionProperty *oox_section_pr, bool r if (root) odt_context->flush_section(); } + + + if (root)odt_context->page_layout_context()->set_current_master_page_base(); } void DocxConverter::convert(ComplexTypes::Word::CFramePr *oox_frame_pr, odf::style_paragraph_properties * paragraph_properties) { @@ -758,7 +815,7 @@ void DocxConverter::convert(OOX::Logic::CTcBorders *oox_border, odf::style_tabl convert(oox_border->m_oBottom.GetPointer() , bottom); convert(oox_border->m_oTop.GetPointer() , top); convert(oox_border->m_oStart.GetPointer() , left); - convert(oox_border->m_oEnd.GetPointer() , right); + convert(oox_border->m_oEnd.GetPointer() , right); if (bottom == top && top == left && left== right && bottom.length() > 0) { @@ -807,7 +864,16 @@ void DocxConverter::convert(OOX::Logic::CPBdr *oox_border, odf::style_paragraph_ if (left.length() >0 ) paragraph_properties->content().common_border_attlist_.fo_border_left_ = left; if (right.length() >0 ) paragraph_properties->content().common_border_attlist_.fo_border_right_ = right; } - + bool shadow = false; + if (oox_border->m_oBottom.IsInit() && oox_border->m_oBottom->m_oShadow.IsInit() && oox_border->m_oBottom->m_oShadow->ToBool()) shadow = true; + if (oox_border->m_oTop.IsInit() && oox_border->m_oTop->m_oShadow.IsInit() && oox_border->m_oTop->m_oShadow->ToBool()) shadow = true; + if (oox_border->m_oLeft.IsInit() && oox_border->m_oLeft->m_oShadow.IsInit() && oox_border->m_oLeft->m_oShadow->ToBool()) shadow = true; + if (oox_border->m_oRight.IsInit() && oox_border->m_oRight->m_oShadow.IsInit() && oox_border->m_oRight->m_oShadow->ToBool()) shadow = true; + + if (shadow) + { + paragraph_properties->content().style_shadow_ = L"#000000 0.159cm 0.159cm"; + } //if (oox_border->m_oTL2BR.IsInit()) //{ // convert(oox_border->m_oTL2BR.GetPointer(), odf_border); @@ -815,18 +881,72 @@ void DocxConverter::convert(OOX::Logic::CPBdr *oox_border, odf::style_paragraph_ //} } +void DocxConverter::convert(ComplexTypes::Word::CPageBorder *borderProp, std::wstring & odf_border_prop) +{ + odf_border_prop = L""; + if (!borderProp)return; + + //nullable > m_oFrame; + //nullable > m_oSpace; + + std::wstringstream border_style; + std::wstring border_color; + + odf::length length; + length = odf::length(borderProp->m_oSz.IsInit() ? borderProp->m_oSz->ToPoints() : 1 , odf::length::pt); + + length = odf::length( length.get_value_unit(odf::length::cm), odf::length::cm); + border_style << length; + if (borderProp->m_oVal.IsInit())//266 styles oO + { + switch(borderProp->m_oVal->GetValue()) + { + case SimpleTypes::bordervalueDotDash: + border_style << L" dashed"; + break; + case SimpleTypes::bordervalueDashed: + border_style << L" dashed"; + break; + case SimpleTypes::bordervalueDotted: + border_style << L" dotted"; + break; + case SimpleTypes::bordervalueDouble: + border_style << L" double"; + break; + case SimpleTypes::bordervalueSingle: + border_style << L" solid"; + break; + case SimpleTypes::bordervalueNone: + odf_border_prop == L"none"; + return; + break; + } + }else border_style << L" solid"; +/////////////////////////////////////////////////////////////////// + _CP_OPT(odf::color) color; + + if (borderProp->m_oColor.IsInit()) + { + if (borderProp->m_oColor->GetValue() != SimpleTypes::hexcolorAuto) + convert(borderProp->m_oColor.GetPointer(), borderProp->m_oThemeColor.GetPointer(), borderProp->m_oThemeTint.GetPointer(),borderProp->m_oThemeShade.GetPointer(), color); + } + if (color) border_color = color->get_hex_value(); + else border_color = L"000000"; + + odf_border_prop = border_style.str() + L" #" + border_color; +} void DocxConverter::convert(ComplexTypes::Word::CBorder *borderProp, std::wstring & odf_border_prop) { odf_border_prop = L""; if (!borderProp)return; - - std::wstringstream border_style; - std::wstring border_color; //nullable > m_oFrame; //nullable > m_oShadow; //nullable > m_oSpace; //nullable > m_oThemeShade; + std::wstringstream border_style; + std::wstring border_color; + odf::length length; length = odf::length(borderProp->m_oSz.IsInit() ? borderProp->m_oSz->ToPoints() : 1 , odf::length::pt); @@ -1548,6 +1668,30 @@ void DocxConverter::convert(ComplexTypes::Word::CColor *color, _CP_OPT(odf::colo if (!color)return; convert(color->m_oVal.GetPointer(), color->m_oThemeColor.GetPointer(),color->m_oThemeTint.GetPointer(),color->m_oThemeShade.GetPointer(), odf_color); } +void DocxConverter::convert_settings() +{ + if (!odt_context) return; + OOX::CSettings * docx_settings = docx_document->GetSettings(); + + if (!docx_settings) return; + + if (docx_settings->m_oZoom.IsInit()) + { + } + if (docx_settings->m_oMirrorMargins.IsInit()) + { + } + + if (docx_settings->m_oPrintTwoOnOne.IsInit()) + { + if (docx_settings->m_oGutterAtTop.IsInit()){} //portrait + else {}//landscape + } +//nullable m_oThemeFontLang; +//nullable m_oEndnotePr; +//nullable m_oCaptions; + //m_oFootnotePr; +} void DocxConverter::convert_styles() { if (!odt_context) return; diff --git a/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.h b/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.h index cbea63d4ce..8865a87557 100644 --- a/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.h +++ b/ASCOfficeOdfFileW/source/Oox2OdfConverter/DocxConverter.h @@ -46,6 +46,7 @@ namespace OOX class CTableRowProperties; class CTcBorders; class CTblBorders; + class CSdt; } @@ -60,6 +61,7 @@ namespace ComplexTypes class CShading; class CFramePr; class CTblWidth; + class CPageBorder; } } namespace cpdoccore @@ -102,8 +104,10 @@ namespace Oox2Odf void convert_document(); void convert_styles(); + void convert_settings(); void convert_comment(int oox_comm_id); + void convert(OOX::Logic::CSdt *oox_sdt); void convert(OOX::Logic::CSectionProperty *oox_section_pr, bool root = false); void convert(OOX::Logic::CParagraph *oox_paragraph); void convert(OOX::Logic::CRun *oox_run); @@ -135,6 +139,7 @@ namespace Oox2Odf void convert(ComplexTypes::Word::CTblWidth *oox_size, _CP_OPT(odf::length) & odf_size); void convert(ComplexTypes::Word::CJc *oox_jc, _CP_OPT(odf::text_align) & align); void convert(ComplexTypes::Word::CBorder *borderProp, std::wstring & odf_border_prop); + void convert(ComplexTypes::Word::CPageBorder *borderProp, std::wstring & odf_border_prop); void convert(OOX::Logic::CPBdr *oox_border, odf::style_paragraph_properties *paragraph_properties); void convert(OOX::Logic::CTcBorders *oox_border, odf::style_table_cell_properties *table_cell_properties);