[Libreoffice-commits] core.git: oox/source

Miklos Vajna vmiklos at collabora.co.uk
Fri Dec 20 01:31:01 PST 2013


 oox/source/drawingml/shape.cxx |   51 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

New commits:
commit 361bad18d8ab8df1fe852d60d97ca8ce976d1de4
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Dec 20 10:23:56 2013 +0100

    oox: import textframe shadow from drawingml
    
    CppunitTest_sw_ooxmlexport's testTextFrameBorders is a reproducer for
    this problem.
    
    Change-Id: I5e164c6c151caca62e5b4464e7ed3708f59ada82

diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index a28b1b4..1406567 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -52,6 +52,7 @@
 #include <com/sun/star/drawing/GraphicExportFilter.hpp>
 #include <com/sun/star/text/XText.hpp>
 #include <com/sun/star/table/BorderLine2.hpp>
+#include <com/sun/star/table/ShadowFormat.hpp>
 #include <com/sun/star/chart2/XChartDocument.hpp>
 #include <com/sun/star/style/ParagraphAdjust.hpp>
 #include <com/sun/star/io/XOutputStream.hpp>
@@ -642,6 +643,56 @@ Reference< XShape > Shape::createAndInsert(
                     }
                     aShapeProps.erase(PROP_LineColor);
                 }
+
+                // TextFrames have ShadowFormat, not individual shadow properties.
+                boost::optional<sal_Int32> oShadowDistance;
+                if (aShapeProps.hasProperty(PROP_ShadowXDistance))
+                {
+                    oShadowDistance = aShapeProps[PROP_ShadowXDistance].get<sal_Int32>();
+                    aShapeProps.erase(PROP_ShadowXDistance);
+                }
+                if (aShapeProps.hasProperty(PROP_ShadowYDistance))
+                {
+                    // There is a single 'dist' attribute, so no need to count the avg of x and y.
+                    aShapeProps.erase(PROP_ShadowYDistance);
+                }
+                boost::optional<sal_Int32> oShadowColor;
+                if (aShapeProps.hasProperty(PROP_ShadowColor))
+                {
+                    oShadowColor = aShapeProps[PROP_ShadowColor].get<sal_Int32>();
+                    aShapeProps.erase(PROP_ShadowColor);
+                }
+                if (aShapeProps.hasProperty(PROP_Shadow))
+                    aShapeProps.erase(PROP_Shadow);
+
+                if (oShadowDistance || oShadowColor || aEffectProperties.maShadow.moShadowDir.has())
+                {
+                    css::table::ShadowFormat aFormat;
+                    if (oShadowColor)
+                        aFormat.Color = *oShadowColor;
+                    if (aEffectProperties.maShadow.moShadowDir.has())
+                    {
+                        css::table::ShadowLocation nLocation = css::table::ShadowLocation_NONE;
+                        switch (aEffectProperties.maShadow.moShadowDir.get())
+                        {
+                        case 13500000:
+                            nLocation = css::table::ShadowLocation_TOP_LEFT;
+                            break;
+                        case 18900000:
+                            nLocation = css::table::ShadowLocation_TOP_RIGHT;
+                            break;
+                        case 8100000:
+                            nLocation = css::table::ShadowLocation_BOTTOM_LEFT;
+                            break;
+                        case 2700000:
+                            nLocation = css::table::ShadowLocation_BOTTOM_RIGHT;
+                            break;
+                        }
+                        aFormat.Location = nLocation;
+                    }
+                    aFormat.ShadowWidth = *oShadowDistance;
+                    aShapeProps.setProperty(PROP_ShadowFormat, uno::makeAny(aFormat));
+                }
             }
 
             PropertySet( xSet ).setProperties( aShapeProps );


More information about the Libreoffice-commits mailing list