[PATCH] Fixes image drop shadow export to DOCX.

Eilidh McAdam (via Code Review) gerrit at gerrit.libreoffice.org
Fri Jan 11 10:21:21 PST 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/1655

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/55/1655/1

Fixes image drop shadow export to DOCX.

Word has problems if the effect extent element is omitted. This gets
the minimum required extent using the shadow position.

Change-Id: I69d0d7a694c34f50289253e5cb7c4265198deaa8
---
M sw/source/filter/ww8/docxattributeoutput.cxx
1 file changed, 28 insertions(+), 3 deletions(-)



diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index b97b368..2669b5f 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2141,9 +2141,35 @@
             XML_cx, aWidth.getStr(),
             XML_cy, aHeight.getStr(),
             FSEND );
-    // TODO - the right effectExtent, extent including the effect
+
+    // effectExtent, extent including the effect (shadow only for now)
+    SvxShadowItem aShadowItem = pFrmFmt->GetShadow();
+    OString aLeftExt("0"), aRightExt("0"), aTopExt("0"), aBottomExt("0");
+    if ( aShadowItem.GetLocation() != SVX_SHADOW_NONE )
+    {
+        OString aShadowWidth( OString::valueOf( TwipsToEMU( aShadowItem.GetWidth() ) ) );
+        switch ( aShadowItem.GetLocation() )
+        {
+            case SVX_SHADOW_TOPLEFT:
+                aTopExt = aLeftExt = aShadowWidth;
+                break;
+            case SVX_SHADOW_TOPRIGHT:
+                aTopExt = aRightExt = aShadowWidth;
+                break;
+            case SVX_SHADOW_BOTTOMLEFT:
+                aBottomExt = aLeftExt = aShadowWidth;
+                break;
+            case SVX_SHADOW_BOTTOMRIGHT:
+                aBottomExt = aRightExt = aShadowWidth;
+                break;
+            case SVX_SHADOW_NONE:
+            case SVX_SHADOW_END:
+                break;
+        }
+    }
+
     m_pSerializer->singleElementNS( XML_wp, XML_effectExtent,
-            XML_l, "0", XML_t, "0", XML_r, "0", XML_b, "0",
+            XML_l, aLeftExt, XML_t, aTopExt, XML_r, aRightExt, XML_b, aBottomExt,
             FSEND );
 
     if( isAnchor )
@@ -2275,7 +2301,6 @@
     m_pSerializer->endElementNS( XML_a, XML_ln );
 
     // Output effects
-    SvxShadowItem aShadowItem = pFrmFmt->GetShadow();
     if ( aShadowItem.GetLocation() != SVX_SHADOW_NONE )
     {
         // Distance is measured diagonally from corner

-- 
To view, visit https://gerrit.libreoffice.org/1655
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I69d0d7a694c34f50289253e5cb7c4265198deaa8
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Eilidh McAdam <eilidh.mcadam at gmail.com>



More information about the LibreOffice mailing list