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

Jacobo Aragunde Pérez jaragunde at igalia.com
Wed Apr 23 08:42:55 PDT 2014


 include/oox/drawingml/effectpropertiescontext.hxx            |    3 
 oox/source/drawingml/effectpropertiescontext.cxx             |   65 ++++++-----
 oox/source/export/drawingml.cxx                              |    8 +
 sw/qa/extras/ooxmlexport/data/shape-effect-preservation.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx                  |   17 ++
 5 files changed, 64 insertions(+), 29 deletions(-)

New commits:
commit 211637d575d717de8b9e9ed9bf6c4c29f8e8f772
Author: Jacobo Aragunde Pérez <jaragunde at igalia.com>
Date:   Wed Apr 23 17:26:38 2014 +0200

    ooxml: Preserve inner shadow effect on shapes.
    
    Reused most of the code of outerShdw effect. Modified an existing
    unit test to add a check for innerShdw.
    
    Change-Id: Ifdd77850bfd3b5fa250594469455b1b66c338611

diff --git a/include/oox/drawingml/effectpropertiescontext.hxx b/include/oox/drawingml/effectpropertiescontext.hxx
index 060604b..f81396d 100644
--- a/include/oox/drawingml/effectpropertiescontext.hxx
+++ b/include/oox/drawingml/effectpropertiescontext.hxx
@@ -31,6 +31,9 @@ public:
 
 protected:
     EffectProperties& mrEffectProperties;
+
+private:
+    void saveUnsupportedAttribs( const AttributeList& rAttribs );
 };
 
 } }
diff --git a/oox/source/drawingml/effectpropertiescontext.cxx b/oox/source/drawingml/effectpropertiescontext.cxx
index 705adb0..458ee59 100644
--- a/oox/source/drawingml/effectpropertiescontext.cxx
+++ b/oox/source/drawingml/effectpropertiescontext.cxx
@@ -33,6 +33,37 @@ EffectPropertiesContext::~EffectPropertiesContext()
 {
 }
 
+void EffectPropertiesContext::saveUnsupportedAttribs( const AttributeList& rAttribs )
+{
+    if( rAttribs.hasAttribute( XML_algn ) )
+        mrEffectProperties.appendUnsupportedEffectAttrib( "algn",
+                                                          makeAny( rAttribs.getString( XML_algn, "" ) ) );
+    if( rAttribs.hasAttribute( XML_blurRad ) )
+        mrEffectProperties.appendUnsupportedEffectAttrib( "blurRad",
+                                                          makeAny( rAttribs.getInteger( XML_blurRad, 0 ) ) );
+    if( rAttribs.hasAttribute( XML_dir ) )
+        mrEffectProperties.appendUnsupportedEffectAttrib( "dir",
+                                                          makeAny( rAttribs.getInteger( XML_dir, 0 ) ) );
+    if( rAttribs.hasAttribute( XML_dist ) )
+        mrEffectProperties.appendUnsupportedEffectAttrib( "dist",
+                                                          makeAny( rAttribs.getInteger( XML_dist, 0 ) ) );
+    if( rAttribs.hasAttribute( XML_kx ) )
+        mrEffectProperties.appendUnsupportedEffectAttrib( "kx",
+                                                          makeAny( rAttribs.getInteger( XML_kx, 0 ) ) );
+    if( rAttribs.hasAttribute( XML_ky ) )
+        mrEffectProperties.appendUnsupportedEffectAttrib( "ky",
+                                                          makeAny( rAttribs.getInteger( XML_ky, 0 ) ) );
+    if( rAttribs.hasAttribute( XML_rotWithShape ) )
+        mrEffectProperties.appendUnsupportedEffectAttrib( "rotWithShape",
+                                                          makeAny( rAttribs.getInteger( XML_rotWithShape, 0 ) ) );
+    if( rAttribs.hasAttribute( XML_sx ) )
+        mrEffectProperties.appendUnsupportedEffectAttrib( "sx",
+                                                          makeAny( rAttribs.getInteger( XML_sx, 0 ) ) );
+    if( rAttribs.hasAttribute( XML_sy ) )
+        mrEffectProperties.appendUnsupportedEffectAttrib( "sy",
+                                                          makeAny( rAttribs.getInteger( XML_sy, 0 ) ) );
+}
+
 ContextHandlerRef EffectPropertiesContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
 {
     switch( nElement )
@@ -40,39 +71,19 @@ ContextHandlerRef EffectPropertiesContext::onCreateContext( sal_Int32 nElement,
         case A_TOKEN( outerShdw ):
         {
             mrEffectProperties.msUnsupportedEffectName = "outerShdw";
-            if( rAttribs.hasAttribute( XML_algn ) )
-                mrEffectProperties.appendUnsupportedEffectAttrib( "algn",
-                                                                  makeAny( rAttribs.getString( XML_algn, "" ) ) );
-            if( rAttribs.hasAttribute( XML_blurRad ) )
-                mrEffectProperties.appendUnsupportedEffectAttrib( "blurRad",
-                                                                  makeAny( rAttribs.getInteger( XML_blurRad, 0 ) ) );
-            if( rAttribs.hasAttribute( XML_dir ) )
-                mrEffectProperties.appendUnsupportedEffectAttrib( "dir",
-                                                                  makeAny( rAttribs.getInteger( XML_dir, 0 ) ) );
-            if( rAttribs.hasAttribute( XML_dist ) )
-                mrEffectProperties.appendUnsupportedEffectAttrib( "dist",
-                                                                  makeAny( rAttribs.getInteger( XML_dist, 0 ) ) );
-            if( rAttribs.hasAttribute( XML_kx ) )
-                mrEffectProperties.appendUnsupportedEffectAttrib( "kx",
-                                                                  makeAny( rAttribs.getInteger( XML_kx, 0 ) ) );
-            if( rAttribs.hasAttribute( XML_ky ) )
-                mrEffectProperties.appendUnsupportedEffectAttrib( "ky",
-                                                                  makeAny( rAttribs.getInteger( XML_ky, 0 ) ) );
-            if( rAttribs.hasAttribute( XML_rotWithShape ) )
-                mrEffectProperties.appendUnsupportedEffectAttrib( "rotWithShape",
-                                                                  makeAny( rAttribs.getInteger( XML_rotWithShape, 0 ) ) );
-            if( rAttribs.hasAttribute( XML_sx ) )
-                mrEffectProperties.appendUnsupportedEffectAttrib( "sx",
-                                                                  makeAny( rAttribs.getInteger( XML_sx, 0 ) ) );
-            if( rAttribs.hasAttribute( XML_sy ) )
-                mrEffectProperties.appendUnsupportedEffectAttrib( "sy",
-                                                                  makeAny( rAttribs.getInteger( XML_sy, 0 ) ) );
+            saveUnsupportedAttribs( rAttribs );
 
             mrEffectProperties.maShadow.moShadowDist = rAttribs.getInteger( XML_dist, 0 );
             mrEffectProperties.maShadow.moShadowDir = rAttribs.getInteger( XML_dir, 0 );
             return new ColorContext( *this, mrEffectProperties.maShadow.moShadowColor );
         }
         break;
+        case A_TOKEN( innerShdw ):
+        {
+            mrEffectProperties.msUnsupportedEffectName = "innerShdw";
+            saveUnsupportedAttribs( rAttribs );
+        }
+        break;
     }
 
     return 0;
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index a14cf72..b66bfc0 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2093,13 +2093,17 @@ void DrawingML::WriteShapeEffects( Reference< XPropertySet > rXPropSet )
 
     OUString sSchemeClr;
     sal_uInt32 nRgbClr = 0;
+    sal_Int32 nEffectToken = 0;
     sal_Int32 nAlpha = MAX_PERCENT;
     Sequence< PropertyValue > aTransformations;
     sax_fastparser::FastAttributeList *aOuterShdwAttrList = mpFS->createAttrList();
     for( sal_Int32 i=0; i < aEffectProps.getLength(); ++i )
     {
-        if(aEffectProps[i].Name == "outerShdw")
+        if( aEffectProps[i].Name == "outerShdw" || aEffectProps[i].Name == "innerShdw" )
         {
+            nEffectToken = ( aEffectProps[i].Name == "outerShdw") ?
+                    FSNS( XML_a, XML_outerShdw ) :
+                    FSNS( XML_a, XML_innerShdw );
             uno::Sequence< beans::PropertyValue > aOuterShdwProps;
             aEffectProps[0].Value >>= aOuterShdwProps;
             for( sal_Int32 j=0; j < aOuterShdwProps.getLength(); ++j )
@@ -2183,7 +2187,7 @@ void DrawingML::WriteShapeEffects( Reference< XPropertySet > rXPropSet )
 
     mpFS->startElementNS(XML_a, XML_effectLst, FSEND);
     sax_fastparser::XFastAttributeListRef xAttrList( aOuterShdwAttrList );
-    mpFS->startElementNS( XML_a, XML_outerShdw, xAttrList );
+    mpFS->startElement( nEffectToken, xAttrList );
 
     if( sSchemeClr.isEmpty() )
         WriteColor( nRgbClr, nAlpha );
diff --git a/sw/qa/extras/ooxmlexport/data/shape-effect-preservation.docx b/sw/qa/extras/ooxmlexport/data/shape-effect-preservation.docx
index aecbd59..97787eb 100644
Binary files a/sw/qa/extras/ooxmlexport/data/shape-effect-preservation.docx and b/sw/qa/extras/ooxmlexport/data/shape-effect-preservation.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
index a6fdc9e..bfadcec 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
@@ -1086,6 +1086,23 @@ DECLARE_OOXMLEXPORT_TEST(testShapeEffectPreservation, "shape-effect-preservation
     assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
             "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:outerShdw/a:schemeClr/a:alpha",
             "val", "40000");
+
+    // second shape with inner shadow, rgb color
+    assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
+            "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:innerShdw",
+            "blurRad", "63500");
+    assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
+            "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:innerShdw",
+            "dir", "16200000");
+    assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
+            "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:innerShdw",
+            "dist", "50800");
+    assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
+            "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:innerShdw/a:srgbClr",
+            "val", "FFFF00");
+    assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/"
+            "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:innerShdw/a:srgbClr/a:alpha",
+            "val", "50000");
 }
 
 #endif


More information about the Libreoffice-commits mailing list