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

Jacobo Aragunde Pérez jaragunde at igalia.com
Tue Jan 28 08:08:23 PST 2014


 include/oox/drawingml/shape.hxx          |    2 +
 oox/source/drawingml/shape.cxx           |   39 +++++++++++++++++--------------
 oox/source/export/drawingml.cxx          |    8 +++---
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx |    6 ++++
 4 files changed, 34 insertions(+), 21 deletions(-)

New commits:
commit 2c9c3d3ef52db1571064036800feaa9a9ebd4bb4
Author: Jacobo Aragunde Pérez <jaragunde at igalia.com>
Date:   Tue Jan 28 13:51:16 2014 +0100

    ooxml: Small code refactor
    
    * Use PUT_PROPS macro in all cases.
    * Added putPropertyToGrabBag( OUString, Any ) to avoid the explicit
      creation of a PropertyValue object every time.
    
    Change-Id: If098dd3a94d1843c4c5dbc3a507b05754d9d59c7

diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx
index c1618ba6..1419a15 100644
--- a/include/oox/drawingml/shape.hxx
+++ b/include/oox/drawingml/shape.hxx
@@ -218,6 +218,8 @@ protected:
                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes >& rxShapes );
 
     void                putPropertyToGrabBag(
+                            const OUString& sPropertyName, const ::com::sun::star::uno::Any& aPropertyValue );
+    void                putPropertyToGrabBag(
                             const ::com::sun::star::beans::PropertyValue& pProperty );
     void                putPropertiesToGrabBag(
                             const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aProperties );
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index b2d0300..3259f72 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -569,10 +569,7 @@ Reference< XShape > Shape::createAndInsert(
                 PUT_PROP( aProperties, 4, "LineJoint",      aLineProperties.getLineJoint() );
                 PUT_PROP( aProperties, 5, "LineWidth",      aLineProperties.getLineWidth() );
                 PUT_PROP( aProperties, 6, "Transformations", pLineRef->maPhClr.getTransformations() );
-                PropertyValue pStyleFillRef;
-                pStyleFillRef.Name = "StyleLnRef";
-                pStyleFillRef.Value = Any( aProperties );
-                putPropertyToGrabBag( pStyleFillRef );
+                putPropertyToGrabBag( "StyleLnRef", Any( aProperties ) );
             }
             if( const ShapeStyleRef* pFillRef = getShapeStyleRef( XML_fillRef ) )
             {
@@ -584,19 +581,12 @@ Reference< XShape > Shape::createAndInsert(
                 if( !sColorScheme.isEmpty() )
                 {
                     Sequence< PropertyValue > aProperties(4);
-                    aProperties[0].Name = "SchemeClr";
-                    aProperties[0].Value = Any( sColorScheme );
-                    aProperties[1].Name = "Idx";
-                    aProperties[1].Value = Any( pFillRef->mnThemedIdx );
-                    aProperties[2].Name = "Color";
-                    aProperties[2].Value = Any( nFillPhClr );
-                    aProperties[3].Name = "Transformations";
-                    aProperties[3].Value = Any( pFillRef->maPhClr.getTransformations() );
-
-                    PropertyValue pStyleFillRef;
-                    pStyleFillRef.Name = "StyleFillRef";
-                    pStyleFillRef.Value = Any( aProperties );
-                    putPropertyToGrabBag( pStyleFillRef );
+                    PUT_PROP( aProperties, 0, "SchemeClr",      sColorScheme );
+                    PUT_PROP( aProperties, 1, "Idx",            pFillRef->mnThemedIdx );
+                    PUT_PROP( aProperties, 2, "Color",          nFillPhClr );
+                    PUT_PROP( aProperties, 3, "Transformations", pFillRef->maPhClr.getTransformations() );
+
+                    putPropertyToGrabBag( "StyleFillRef", Any( aProperties ) );
                 }
             }
             if( const ShapeStyleRef* pEffectRef = getShapeStyleRef( XML_effectRef ) )
@@ -611,10 +601,7 @@ Reference< XShape > Shape::createAndInsert(
                 PUT_PROP( aProperties, 0, "SchemeClr",      pEffectRef->maPhClr.getSchemeName() );
                 PUT_PROP( aProperties, 1, "Idx",            pEffectRef->mnThemedIdx );
                 PUT_PROP( aProperties, 2, "Transformations", pEffectRef->maPhClr.getTransformations() );
-                PropertyValue pStyleFillRef;
-                pStyleFillRef.Name = "StyleEffectRef";
-                pStyleFillRef.Value = Any( aProperties );
-                putPropertyToGrabBag( pStyleFillRef );
+                putPropertyToGrabBag( "StyleEffectRef", Any( aProperties ) );
             }
         }
 
@@ -1100,6 +1087,14 @@ void Shape::finalizeXShape( XmlFilterBase& rFilter, const Reference< XShapes >&
     }
 }
 
+void Shape::putPropertyToGrabBag( const OUString& sPropertyName, const Any& aPropertyValue )
+{
+    PropertyValue pNewProperty;
+    pNewProperty.Name = sPropertyName;
+    pNewProperty.Value = aPropertyValue;
+    putPropertyToGrabBag( pNewProperty );
+}
+
 void Shape::putPropertyToGrabBag( const PropertyValue& pProperty )
 {
     Reference< XPropertySet > xSet( mxShape, UNO_QUERY );
commit 0d6cb9c123e04585c6adb92a2891048ca2442bac
Author: Jacobo Aragunde Pérez <jaragunde at igalia.com>
Date:   Tue Jan 28 13:39:11 2014 +0100

    ooxml: Preserve shape style effect attributes
    
    Preserve <a:effectRef> tag and its contents from inside shape style
    properties tag <wps:style>.
    
    Added some lines to existing unit tests to check for the preservation
    of these attributes.
    
    Change-Id: I6e47b228dcc9788a4a2dfe87bd1186d2f04dbeea

diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 41fe7fd..b2d0300 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -605,6 +605,16 @@ Reference< XShape > Shape::createAndInsert(
                     aEffectProperties.assignUsed( *pEffectProps );
                 // TODO: use ph color when applying effect properties
                 // nEffectPhClr = pEffectRef->maPhClr.getColor( rGraphicHelper );
+
+                // Store style-related properties to InteropGrabBag to be able to export them back
+                Sequence< PropertyValue > aProperties( 3 );
+                PUT_PROP( aProperties, 0, "SchemeClr",      pEffectRef->maPhClr.getSchemeName() );
+                PUT_PROP( aProperties, 1, "Idx",            pEffectRef->mnThemedIdx );
+                PUT_PROP( aProperties, 2, "Transformations", pEffectRef->maPhClr.getTransformations() );
+                PropertyValue pStyleFillRef;
+                pStyleFillRef.Name = "StyleEffectRef";
+                pStyleFillRef.Value = Any( aProperties );
+                putPropertyToGrabBag( pStyleFillRef );
             }
         }
 
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 70f4f3b..3b84ea0 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -1794,20 +1794,20 @@ void DrawingML::WriteShapeStyle( Reference< XPropertySet > xPropSet )
 
     // extract the relevant properties from the grab bag
     Sequence< PropertyValue > aGrabBag;
-    Sequence< PropertyValue > aFillRefProperties;
-    Sequence< PropertyValue > aLnRefProperties;
+    Sequence< PropertyValue > aFillRefProperties, aLnRefProperties, aEffectRefProperties;
     mAny >>= aGrabBag;
     for( sal_Int32 i=0; i < aGrabBag.getLength(); ++i)
         if( aGrabBag[i].Name == "StyleFillRef" )
             aGrabBag[i].Value >>= aFillRefProperties;
         else if( aGrabBag[i].Name == "StyleLnRef" )
             aGrabBag[i].Value >>= aLnRefProperties;
+        else if( aGrabBag[i].Name == "StyleEffectRef" )
+            aGrabBag[i].Value >>= aEffectRefProperties;
 
     WriteStyleProperties( XML_lnRef, aLnRefProperties );
     WriteStyleProperties( XML_fillRef, aFillRefProperties );
+    WriteStyleProperties( XML_effectRef, aEffectRefProperties );
 
-    // write mock <a:effectRef>
-    mpFS->singleElementNS( XML_a, XML_effectRef, XML_idx, I32S( 0 ), FSEND );
     // write mock <a:fontRef>
     mpFS->singleElementNS( XML_a, XML_fontRef, XML_idx, "minor", FSEND );
 }
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index ae31250..6aa0ed8 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -2547,6 +2547,12 @@ DECLARE_OOXMLEXPORT_TEST(testShapeThemePreservation, "shape-theme-preservation.d
     assertXPath(pXmlDocument,
             "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:style/a:lnRef/a:schemeClr/a:shade",
             "val", "50000");
+    assertXPath(pXmlDocument,
+            "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:style/a:effectRef",
+            "idx", "0");
+    assertXPath(pXmlDocument,
+            "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:style/a:effectRef/a:schemeClr",
+            "val", "accent1");
 
     // check shape style hasn't been overwritten
     assertXPath(pXmlDocument,


More information about the Libreoffice-commits mailing list