oox/source/token/properties.txt | 1 oox/source/vml/vmlshape.cxx | 27 ++ sw/qa/extras/ooxmlexport/data/bnc884615-mso-position.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 37 +++ sw/source/filter/ww8/docxattributeoutput.cxx | 168 +++++++------- 5 files changed, 151 insertions(+), 82 deletions(-)
New commits: commit bccb5eff14b2aebd18fd933c2790d78a2fa940e9 Author: LuboÅ¡ LuÅák <l.lu...@collabora.com> Date: Sat Sep 27 16:59:48 2014 +0200 fix/improve handling of mso-position-(horizontal|vertical)(-relative) This is a squash of commits f6fa787 to e5bbc721 . Change-Id: Ieb76ccb2fe8a425af3204de144021b7a731d0778 Reviewed-on: https://gerrit.libreoffice.org/11701 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Miklos Vajna <vmik...@collabora.co.uk> diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt index 988857b..f1b237b 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -339,6 +339,7 @@ OutputPosition OverlapSequence PageScale PageStyle +PageToggle PageViewZoomValue PaintTransparent ParaAdjust diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index d7783d8..3adf5c8 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -482,12 +482,38 @@ void lcl_SetAnchorType(PropertySet& rPropSet, const ShapeTypeModel& rTypeModel) { if ( rTypeModel.maPositionHorizontal == "center" ) rPropSet.setAnyProperty(PROP_HoriOrient, makeAny(text::HoriOrientation::CENTER)); + else if ( rTypeModel.maPositionHorizontal == "left" ) + rPropSet.setAnyProperty(PROP_HoriOrient, makeAny(text::HoriOrientation::LEFT)); + else if ( rTypeModel.maPositionHorizontal == "right" ) + rPropSet.setAnyProperty(PROP_HoriOrient, makeAny(text::HoriOrientation::RIGHT)); + else if ( rTypeModel.maPositionHorizontal == "inside" ) + { + rPropSet.setAnyProperty(PROP_HoriOrient, makeAny(text::HoriOrientation::LEFT)); + rPropSet.setAnyProperty(PROP_PageToggle, makeAny(sal_True)); + } + else if ( rTypeModel.maPositionHorizontal == "outside" ) + { + rPropSet.setAnyProperty(PROP_HoriOrient, makeAny(text::HoriOrientation::RIGHT)); + rPropSet.setAnyProperty(PROP_PageToggle, makeAny(sal_True)); + } if ( rTypeModel.maPositionHorizontalRelative == "page" ) rPropSet.setAnyProperty(PROP_HoriOrientRelation, makeAny(text::RelOrientation::PAGE_FRAME)); + else if ( rTypeModel.maPositionVerticalRelative == "margin" ) + rPropSet.setProperty(PROP_VertOrientRelation, text::RelOrientation::PAGE_PRINT_AREA); + else if ( rTypeModel.maPositionVerticalRelative == "text" ) + rPropSet.setProperty(PROP_VertOrientRelation, text::RelOrientation::FRAME); if ( rTypeModel.maPositionVertical == "center" ) rPropSet.setAnyProperty(PROP_VertOrient, makeAny(text::VertOrientation::CENTER)); + else if ( rTypeModel.maPositionVertical == "top" ) + rPropSet.setAnyProperty(PROP_VertOrient, makeAny(text::VertOrientation::TOP)); + else if ( rTypeModel.maPositionVertical == "bottom" ) + rPropSet.setAnyProperty(PROP_VertOrient, makeAny(text::VertOrientation::BOTTOM)); + else if ( rTypeModel.maPositionVertical == "inside" ) + rPropSet.setAnyProperty(PROP_VertOrient, makeAny(text::VertOrientation::LINE_TOP)); + else if ( rTypeModel.maPositionVertical == "outside" ) + rPropSet.setAnyProperty(PROP_VertOrient, makeAny(text::VertOrientation::LINE_BOTTOM)); if ( rTypeModel.maPosition == "absolute" ) { @@ -504,7 +530,6 @@ void lcl_SetAnchorType(PropertySet& rPropSet, const ShapeTypeModel& rTypeModel) } else { - // Vertical placement relative to margin, because parent style must not modify vertical position rPropSet.setProperty(PROP_VertOrientRelation, text::RelOrientation::FRAME); } } diff --git a/sw/qa/extras/ooxmlexport/data/bnc884615-mso-position.docx b/sw/qa/extras/ooxmlexport/data/bnc884615-mso-position.docx new file mode 100644 index 0000000..2fb28ec Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/bnc884615-mso-position.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 5590246..18c15fa 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -3658,6 +3658,43 @@ DECLARE_OOXMLEXPORT_TEST(testFooterBodyDistance, "footer-body-distance.docx") #endif +DECLARE_OOXMLEXPORT_TEST(testMsoPosition, "bnc884615-mso-position.docx") +{ + if(xmlDocPtr doc = parseExport("word/footer1.xml")) + { + // We write the frames out in different order than they were read, so check it's the correct + // textbox first by checking width. These tests may need reordering if that gets fixed. + OUString style1 = getXPath(doc, "/w:ftr/w:p/w:r[3]/mc:AlternateContent/mc:Fallback/w:pict/v:rect", "style"); + CPPUNIT_ASSERT( style1.indexOf( ";width:531pt;" ) >= 0 ); + CPPUNIT_ASSERT( style1.indexOf( ";mso-position-vertical-relative:page" ) >= 0 ); + CPPUNIT_ASSERT( style1.indexOf( ";mso-position-horizontal-relative:page" ) >= 0 ); + OUString style2 = getXPath(doc, "/w:ftr/w:p/w:r[4]/mc:AlternateContent/mc:Fallback/w:pict/v:rect", "style"); + CPPUNIT_ASSERT( style2.indexOf( ";width:549pt;" ) >= 0 ); + CPPUNIT_ASSERT( style2.indexOf( ";mso-position-vertical-relative:text" ) >= 0 ); + CPPUNIT_ASSERT( style2.indexOf( ";mso-position-horizontal:center" ) >= 0 ); + CPPUNIT_ASSERT( style2.indexOf( ";mso-position-horizontal-relative:text" ) >= 0 ); + OUString style3 = getXPath(doc, "/w:ftr/w:p/w:r[5]/mc:AlternateContent/mc:Fallback/w:pict/v:rect", "style"); + CPPUNIT_ASSERT( style3.indexOf( ";width:36pt;" ) >= 0 ); + CPPUNIT_ASSERT( style3.indexOf( ";mso-position-horizontal-relative:text" ) >= 0 ); + CPPUNIT_ASSERT( style3.indexOf( ";mso-position-vertical-relative:text" ) >= 0 ); + } + if(xmlDocPtr doc = parseExport("word/header1.xml")) + { + OUString style1 = getXPath(doc, "/w:hdr/w:p/w:r[2]/mc:AlternateContent/mc:Fallback/w:pict/v:rect", "style"); + CPPUNIT_ASSERT( style1.indexOf( ";width:335.75pt;" ) >= 0 ); + CPPUNIT_ASSERT( style1.indexOf( ";mso-position-horizontal-relative:page" ) >= 0 ); + CPPUNIT_ASSERT( style1.indexOf( ";mso-position-vertical-relative:page" ) >= 0 ); + OUString style2 = getXPath(doc, "/w:hdr/w:p/w:r[3]/mc:AlternateContent/mc:Fallback/w:pict/v:rect", "style"); + CPPUNIT_ASSERT( style2.indexOf( ";width:138.15pt;" ) >= 0 ); + CPPUNIT_ASSERT( style2.indexOf( ";mso-position-horizontal-relative:page" ) >= 0 ); + CPPUNIT_ASSERT( style2.indexOf( ";mso-position-vertical-relative:page" ) >= 0 ); + OUString style3 = getXPath(doc, "/w:hdr/w:p/w:r[4]/mc:AlternateContent/mc:Fallback/w:pict/v:rect", "style"); + CPPUNIT_ASSERT( style3.indexOf( ";width:163.8pt;" ) >= 0 ); + CPPUNIT_ASSERT( style3.indexOf( ";mso-position-horizontal-relative:page" ) >= 0 ); + CPPUNIT_ASSERT( style3.indexOf( ";mso-position-vertical-relative:page" ) >= 0 ); + } +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index a77b8fa..37ad4f7 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -6665,121 +6665,127 @@ void DocxAttributeOutput::FormatSurround( const SwFmtSurround& rSurround ) void DocxAttributeOutput::FormatVertOrientation( const SwFmtVertOrient& rFlyVert ) { + OString sAlign; + switch( rFlyVert.GetVertOrient() ) + { + case text::VertOrientation::NONE: + break; + case text::VertOrientation::CENTER: + case text::VertOrientation::LINE_CENTER: + sAlign = OString( "center" ); + break; + case text::VertOrientation::BOTTOM: + sAlign = OString( "bottom" ); + break; + case text::VertOrientation::LINE_BOTTOM: + sAlign = OString( "outside" ); + break; + case text::VertOrientation::TOP: + sAlign = OString( "top" ); + break; + case text::VertOrientation::LINE_TOP: + default: + sAlign = OString( "inside" ); + break; + } + OString sVAnchor( "page" ); + switch ( rFlyVert.GetRelationOrient( ) ) + { + case text::RelOrientation::CHAR: + case text::RelOrientation::PRINT_AREA: + case text::RelOrientation::TEXT_LINE: + case text::RelOrientation::FRAME: + sVAnchor = OString( "text" ); + break; + case text::RelOrientation::PAGE_LEFT: + case text::RelOrientation::PAGE_RIGHT: + case text::RelOrientation::FRAME_LEFT: + case text::RelOrientation::FRAME_RIGHT: + case text::RelOrientation::PAGE_PRINT_AREA: + sVAnchor = OString( "margin" ); + break; + case text::RelOrientation::PAGE_FRAME: + default: + break; + } + if (m_rExport.SdrExporter().getTextFrameSyntax()) { m_rExport.SdrExporter().getTextFrameStyle().append(";margin-top:").append(double(rFlyVert.GetPos()) / 20).append("pt"); + if ( !sAlign.isEmpty() ) + m_rExport.SdrExporter().getTextFrameStyle().append(";mso-position-vertical:").append(sAlign); + m_rExport.SdrExporter().getTextFrameStyle().append(";mso-position-vertical-relative:").append(sVAnchor); } else if (m_rExport.SdrExporter().getDMLTextFrameSyntax()) { } else if ( m_rExport.bOutFlyFrmAttrs ) { - OString sAlign; - switch( rFlyVert.GetVertOrient() ) - { - case text::VertOrientation::NONE: - break; - case text::VertOrientation::CENTER: - case text::VertOrientation::LINE_CENTER: - sAlign = OString( "center" ); - break; - case text::VertOrientation::BOTTOM: - case text::VertOrientation::LINE_BOTTOM: - sAlign = OString( "bottom" ); - break; - case text::VertOrientation::TOP: - case text::VertOrientation::LINE_TOP: - default: - sAlign = OString( "top" ); - break; - } - if ( !sAlign.isEmpty() ) AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(), FSNS( XML_w, XML_yAlign ), sAlign.getStr() ); else AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(), FSNS( XML_w, XML_y ), OString::number( rFlyVert.GetPos() ).getStr() ); - - OString sVAnchor( "page" ); - switch ( rFlyVert.GetRelationOrient( ) ) - { - case text::RelOrientation::CHAR: - case text::RelOrientation::PRINT_AREA: - case text::RelOrientation::TEXT_LINE: - sVAnchor = OString( "column" ); - break; - case text::RelOrientation::FRAME: - case text::RelOrientation::PAGE_LEFT: - case text::RelOrientation::PAGE_RIGHT: - case text::RelOrientation::FRAME_LEFT: - case text::RelOrientation::FRAME_RIGHT: - sVAnchor = OString( "margin" ); - break; - case text::RelOrientation::PAGE_FRAME: - case text::RelOrientation::PAGE_PRINT_AREA: - default: - break; - } - AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(), FSNS( XML_w, XML_vAnchor ), sVAnchor.getStr() ); } } void DocxAttributeOutput::FormatHorizOrientation( const SwFmtHoriOrient& rFlyHori ) { + OString sAlign; + switch( rFlyHori.GetHoriOrient() ) + { + case text::HoriOrientation::NONE: + break; + case text::HoriOrientation::LEFT: + sAlign = OString( rFlyHori.IsPosToggle( ) ? "inside" : "left" ); + break; + case text::HoriOrientation::RIGHT: + sAlign = OString( rFlyHori.IsPosToggle( ) ? "outside" : "right" ); + break; + case text::HoriOrientation::CENTER: + case text::HoriOrientation::FULL: // FULL only for tables + default: + sAlign = OString( "center" ); + break; + } + OString sHAnchor( "page" ); + switch ( rFlyHori.GetRelationOrient( ) ) + { + case text::RelOrientation::CHAR: + case text::RelOrientation::PRINT_AREA: + case text::RelOrientation::FRAME: + sHAnchor = OString( "text" ); + break; + case text::RelOrientation::PAGE_LEFT: + case text::RelOrientation::PAGE_RIGHT: + case text::RelOrientation::FRAME_LEFT: + case text::RelOrientation::FRAME_RIGHT: + case text::RelOrientation::PAGE_PRINT_AREA: + sHAnchor = OString( "margin" ); + break; + case text::RelOrientation::PAGE_FRAME: + default: + break; + } + if (m_rExport.SdrExporter().getTextFrameSyntax()) { m_rExport.SdrExporter().getTextFrameStyle().append(";margin-left:").append(double(rFlyHori.GetPos()) / 20).append("pt"); + if ( !sAlign.isEmpty() ) + m_rExport.SdrExporter().getTextFrameStyle().append(";mso-position-horizontal:").append(sAlign); + m_rExport.SdrExporter().getTextFrameStyle().append(";mso-position-horizontal-relative:").append(sHAnchor); } else if (m_rExport.SdrExporter().getDMLTextFrameSyntax()) { } else if ( m_rExport.bOutFlyFrmAttrs ) { - OString sAlign; - switch( rFlyHori.GetHoriOrient() ) - { - case text::HoriOrientation::NONE: - break; - case text::HoriOrientation::LEFT: - sAlign = OString( rFlyHori.IsPosToggle( ) ? "inside" : "left" ); - break; - case text::HoriOrientation::RIGHT: - sAlign = OString( rFlyHori.IsPosToggle( ) ? "outside" : "right" ); - break; - case text::HoriOrientation::CENTER: - case text::HoriOrientation::FULL: // FULL only for tables - default: - sAlign = OString( "center" ); - break; - } - if ( !sAlign.isEmpty() ) AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(), FSNS( XML_w, XML_xAlign ), sAlign.getStr() ); else AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(), FSNS( XML_w, XML_x ), OString::number( rFlyHori.GetPos() ).getStr() ); - - OString sHAnchor( "page" ); - switch ( rFlyHori.GetRelationOrient( ) ) - { - case text::RelOrientation::CHAR: - case text::RelOrientation::PRINT_AREA: - sHAnchor = OString( "text" ); - break; - case text::RelOrientation::FRAME: - case text::RelOrientation::PAGE_LEFT: - case text::RelOrientation::PAGE_RIGHT: - case text::RelOrientation::FRAME_LEFT: - case text::RelOrientation::FRAME_RIGHT: - sHAnchor = OString( "margin" ); - break; - case text::RelOrientation::PAGE_FRAME: - case text::RelOrientation::PAGE_PRINT_AREA: - default: - break; - } - AddToAttrList( m_rExport.SdrExporter().getFlyAttrList(), FSNS( XML_w, XML_hAnchor ), sHAnchor.getStr() ); } }
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits