diff options
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 194 |
1 files changed, 81 insertions, 113 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 467af568afcb..c40121040717 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -495,6 +495,79 @@ void DocxAttributeOutput::StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pText m_bIsFirstParagraph = false; } +static OString convertToOOXMLVertOrient(sal_Int16 nOrient) +{ + switch( nOrient ) + { + case text::VertOrientation::NONE: + return OString(); + case text::VertOrientation::CENTER: + case text::VertOrientation::LINE_CENTER: + return OString( "center" ); + case text::VertOrientation::BOTTOM: + return OString( "bottom" ); + case text::VertOrientation::LINE_BOTTOM: + return OString( "outside" ); + case text::VertOrientation::TOP: + return OString( "top" ); + case text::VertOrientation::LINE_TOP: + default: + return OString( "inside" ); + } +} + +static OString convertToOOXMLHoriOrient(sal_Int16 nOrient) +{ + switch( nOrient ) + { + case text::VertOrientation::NONE: + return OString(); + case text::VertOrientation::CENTER: + case text::VertOrientation::LINE_CENTER: + return OString( "center" ); + case text::VertOrientation::BOTTOM: + return OString( "bottom" ); + case text::VertOrientation::LINE_BOTTOM: + return OString( "outside" ); + case text::VertOrientation::TOP: + return OString( "top" ); + case text::VertOrientation::LINE_TOP: + default: + return OString( "inside" ); + } +} + +static OString convertToOOXMLVertOrientRel(sal_Int16 nOrientRel) +{ + switch (nOrientRel) + { + case text::RelOrientation::PAGE_PRINT_AREA: + return OString("margin"); + case text::RelOrientation::PAGE_FRAME: + return OString("page"); + case text::RelOrientation::FRAME: + case text::RelOrientation::TEXT_LINE: + default: + return OString("text"); + } +} + +static OString convertToOOXMLHoriOrientRel(sal_Int16 nOrientRel) +{ + switch (nOrientRel) + { + case text::RelOrientation::PAGE_PRINT_AREA: + return OString("margin"); + case text::RelOrientation::PAGE_FRAME: + return OString("page"); + case text::RelOrientation::CHAR: + case text::RelOrientation::PAGE_RIGHT: + case text::RelOrientation::FRAME: + default: + return OString("text"); + } +} + static void lcl_deleteAndResetTheLists( rtl::Reference<sax_fastparser::FastAttributeList>& pSdtPrTokenChildren, rtl::Reference<sax_fastparser::FastAttributeList>& pSdtPrDataBindingAttrs, OUString& rSdtPrAlias) { if( pSdtPrTokenChildren.is() ) @@ -518,38 +591,8 @@ void DocxAttributeOutput::PopulateFrameProperties(const SwFrameFormat* pFrameFor attrList->add( FSNS( XML_w, XML_x), OString::number(aPos.X)); attrList->add( FSNS( XML_w, XML_y), OString::number(aPos.Y)); - const char* relativeFromH; - const char* relativeFromV; - switch (pFrameFormat->GetVertOrient().GetRelationOrient()) - { - case text::RelOrientation::PAGE_PRINT_AREA: - relativeFromV = "margin"; - break; - case text::RelOrientation::PAGE_FRAME: - relativeFromV = "page"; - break; - case text::RelOrientation::FRAME: - case text::RelOrientation::TEXT_LINE: - default: - relativeFromV = "text"; - break; - } - - switch (pFrameFormat->GetHoriOrient().GetRelationOrient()) - { - case text::RelOrientation::PAGE_PRINT_AREA: - relativeFromH = "margin"; - break; - case text::RelOrientation::PAGE_FRAME: - relativeFromH = "page"; - break; - case text::RelOrientation::CHAR: - case text::RelOrientation::PAGE_RIGHT: - case text::RelOrientation::FRAME: - default: - relativeFromH = "text"; - break; - } + OString relativeFromH = convertToOOXMLHoriOrientRel( pFrameFormat->GetHoriOrient().GetRelationOrient() ); + OString relativeFromV = convertToOOXMLVertOrientRel( pFrameFormat->GetVertOrient().GetRelationOrient() ); switch (pFrameFormat->GetSurround().GetValue()) { @@ -567,8 +610,8 @@ void DocxAttributeOutput::PopulateFrameProperties(const SwFrameFormat* pFrameFor attrList->add( FSNS( XML_w, XML_wrap), "auto"); break; } - attrList->add( FSNS( XML_w, XML_vAnchor), relativeFromV); - attrList->add( FSNS( XML_w, XML_hAnchor), relativeFromH); + attrList->add( FSNS( XML_w, XML_vAnchor), relativeFromV ); + attrList->add( FSNS( XML_w, XML_hAnchor), relativeFromH ); attrList->add( FSNS( XML_w, XML_hRule), "exact"); sax_fastparser::XFastAttributeListRef xAttrList(attrList); @@ -8322,49 +8365,8 @@ void DocxAttributeOutput::FormatSurround( const SwFormatSurround& rSurround ) void DocxAttributeOutput::FormatVertOrientation( const SwFormatVertOrient& 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; - } + OString sAlign = convertToOOXMLVertOrient( rFlyVert.GetVertOrient() ); + OString sVAnchor = convertToOOXMLVertOrientRel( rFlyVert.GetRelationOrient() ); if (m_rExport.SdrExporter().getTextFrameSyntax()) { @@ -8389,42 +8391,8 @@ void DocxAttributeOutput::FormatVertOrientation( const SwFormatVertOrient& rFlyV void DocxAttributeOutput::FormatHorizOrientation( const SwFormatHoriOrient& 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; - } + OString sAlign = convertToOOXMLHoriOrient( rFlyHori.GetHoriOrient() ); + OString sHAnchor = convertToOOXMLHoriOrientRel( rFlyHori.GetRelationOrient() ); if (m_rExport.SdrExporter().getTextFrameSyntax()) { |