[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - sw/source
Patrick Jaap (via logerrit)
logerrit at kemper.freedesktop.org
Mon Apr 8 11:47:32 UTC 2019
sw/source/filter/ww8/docxattributeoutput.cxx | 194 +++++++++++----------------
1 file changed, 81 insertions(+), 113 deletions(-)
New commits:
commit 90b7c88c154d85d1637cdd3c6d0d0150bb8158fd
Author: Patrick Jaap <patrick.jaap at tu-dresden.de>
AuthorDate: Thu Feb 14 10:08:58 2019 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon Apr 8 13:47:11 2019 +0200
Converters for OOXML orients and relations
Change-Id: I8e3ade11881d88e937b1a55598813b2265cafd95
Reviewed-on: https://gerrit.libreoffice.org/69522
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
(cherry picked from commit bbe8bc3c8610d5d218afaa779e86d822a7a76345)
Reviewed-on: https://gerrit.libreoffice.org/70307
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 78a41c64aa6e..dfb12d1cc25e 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -491,6 +491,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() )
@@ -514,38 +587,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())
{
@@ -563,8 +606,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);
@@ -8305,49 +8348,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())
{
@@ -8372,42 +8374,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())
{
More information about the Libreoffice-commits
mailing list