include/oox/export/drawingml.hxx | 2 oox/source/drawingml/shape.cxx | 17 +++++-- oox/source/export/drawingml.cxx | 27 ++++-------- sw/qa/extras/ooxmlexport/data/shape-theme-preservation.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 15 +++++- 5 files changed, 36 insertions(+), 25 deletions(-)
New commits: commit 42e4d237692a10aaecabbc3499d14d3860d93478 Author: Jacobo Aragunde Pérez <jaragu...@igalia.com> Date: Tue Feb 11 19:07:00 2014 +0100 ooxml: Preserve color transformations for shape theme colors Colors can have modifiers like in the following example: <a:schemeClr val="accent6"> <a:lumMod val="40000"/> <a:lumOff val="60000"/> </a:schemeClr> In the case of RGB colors, the transformations are merged within the RGB color itself on import, so there's no need to preserve the original transformations, but that's necessary in the case of scheme colors. Slightly modified an existing unit test to check this feature too. Change-Id: I3a03a56f2b633f283c392e54842b326bd4df316b diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx index 7a07f5e..84ac606 100644 --- a/include/oox/export/drawingml.hxx +++ b/include/oox/export/drawingml.hxx @@ -127,7 +127,7 @@ public: void WriteConnectorConnections( EscherConnectorListEntry& rConnectorEntry, sal_Int32 nStartID, sal_Int32 nEndID ); void WriteSolidFill( sal_uInt32 nColor, sal_Int32 nAlpha = MAX_PERCENT ); - void WriteSolidFill( OUString sSchemeName, sal_Int32 nAlpha = MAX_PERCENT ); + void WriteSolidFill( OUString sSchemeName, ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aTransformations ); void WriteSolidFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet ); void WriteGradientFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet ); void WriteBlipFill( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet, OUString sURLPropName, sal_Int32 nXmlNamespace ); diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 99940ab..fb17f5d 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -782,22 +782,29 @@ Reference< XShape > Shape::createAndInsert( } // Store original fill and line colors of the shape and the theme color name to InteropGrabBag + Sequence< PropertyValue > aProperties( 6 ); //allocate the maximum possible number of slots sal_Int32 nSize = 2; - Sequence< PropertyValue > aProperties( nSize ); PUT_PROP( aProperties, 0, "OriginalSolidFillClr", aShapeProps[PROP_FillColor] ); PUT_PROP( aProperties, 1, "OriginalLnSolidFillClr", aShapeProps[PROP_LineColor] ); OUString sColorFillScheme = aFillProperties.maFillColor.getSchemeName(); if( !aFillProperties.maFillColor.isPlaceHolder() && !sColorFillScheme.isEmpty() ) { - aProperties.realloc( ++nSize ); - PUT_PROP( aProperties, nSize - 1, "SpPrSolidFillSchemeClr", sColorFillScheme ); + PUT_PROP( aProperties, nSize, "SpPrSolidFillSchemeClr", sColorFillScheme ); + nSize++; + PUT_PROP( aProperties, nSize, "SpPrSolidFillSchemeClrTransformations", + aFillProperties.maFillColor.getTransformations() ); + nSize++; } OUString sLnColorFillScheme = aLineProperties.maLineFill.maFillColor.getSchemeName(); if( !aLineProperties.maLineFill.maFillColor.isPlaceHolder() && !sLnColorFillScheme.isEmpty() ) { - aProperties.realloc( ++nSize ); - PUT_PROP( aProperties, nSize - 1, "SpPrLnSolidFillSchemeClr", sLnColorFillScheme ); + PUT_PROP( aProperties, nSize, "SpPrLnSolidFillSchemeClr", sLnColorFillScheme ); + nSize++; + PUT_PROP( aProperties, nSize, "SpPrLnSolidFillSchemeClrTransformations", + aLineProperties.maLineFill.maFillColor.getTransformations() ); + nSize++; } + aProperties.realloc( nSize ); //shrink the Sequence if we didn't use all the slots putPropertiesToGrabBag( aProperties ); // Store original gradient fill of the shape to InteropGrabBag diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 0058aa7..0f95e70 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -219,21 +219,10 @@ void DrawingML::WriteSolidFill( sal_uInt32 nColor, sal_Int32 nAlpha ) mpFS->endElementNS( XML_a, XML_solidFill ); } -void DrawingML::WriteSolidFill( OUString sSchemeName, sal_Int32 nAlpha ) +void DrawingML::WriteSolidFill( OUString sSchemeName, Sequence< PropertyValue > aTransformations ) { mpFS->startElementNS( XML_a, XML_solidFill, FSEND ); - if( nAlpha < MAX_PERCENT ) - { - Sequence< PropertyValue > aTransformations(1); - aTransformations[0].Name = "alpha"; - aTransformations[0].Value <<= nAlpha; - WriteColor( sSchemeName, aTransformations ); - } - else - { - Sequence< PropertyValue > aTransformations(0); - WriteColor( sSchemeName, aTransformations ); - } + WriteColor( sSchemeName, aTransformations ); mpFS->endElementNS( XML_a, XML_solidFill ); } @@ -247,7 +236,7 @@ void DrawingML::WriteSolidFill( Reference< XPropertySet > rXPropSet ) // get InteropGrabBag and search the relevant attributes OUString sColorFillScheme; sal_uInt32 nOriginalColor = 0; - Sequence< PropertyValue > aStyleProperties; + Sequence< PropertyValue > aStyleProperties, aTransformations; if ( GetProperty( rXPropSet, "InteropGrabBag" ) ) { Sequence< PropertyValue > aGrabBag; @@ -259,6 +248,8 @@ void DrawingML::WriteSolidFill( Reference< XPropertySet > rXPropSet ) aGrabBag[i].Value >>= nOriginalColor; else if( aGrabBag[i].Name == "StyleFillRef" ) aGrabBag[i].Value >>= aStyleProperties; + else if( aGrabBag[i].Name == "SpPrSolidFillSchemeClrTransformations" ) + aGrabBag[i].Value >>= aTransformations; } sal_Int32 nAlpha = MAX_PERCENT; @@ -276,7 +267,7 @@ void DrawingML::WriteSolidFill( Reference< XPropertySet > rXPropSet ) WriteSolidFill( nFillColor & 0xffffff, nAlpha ); else if ( !sColorFillScheme.isEmpty() ) // the shape had a scheme color and the user didn't change it - WriteSolidFill( sColorFillScheme, nAlpha ); + WriteSolidFill( sColorFillScheme, aTransformations ); else if ( aStyleProperties.hasElements() ) { sal_uInt32 nThemeColor = 0; @@ -529,7 +520,7 @@ void DrawingML::WriteOutline( Reference< XPropertySet > rXPropSet ) // get InteropGrabBag and search the relevant attributes OUString sColorFillScheme; sal_uInt32 nOriginalColor( 0 ), nStyleColor( 0 ), nStyleLineWidth( 0 ); - Sequence< PropertyValue > aStyleProperties; + Sequence< PropertyValue > aStyleProperties, aTransformations; drawing::LineStyle aStyleLineStyle( drawing::LineStyle_NONE ); drawing::LineJoint aStyleLineJoint( drawing::LineJoint_NONE ); if ( GetProperty( rXPropSet, "InteropGrabBag" ) ) @@ -543,6 +534,8 @@ void DrawingML::WriteOutline( Reference< XPropertySet > rXPropSet ) aGrabBag[i].Value >>= nOriginalColor; else if( aGrabBag[i].Name == "StyleLnRef" ) aGrabBag[i].Value >>= aStyleProperties; + else if( aGrabBag[i].Name == "SpPrLnSolidFillSchemeClrTransformations" ) + aGrabBag[i].Value >>= aTransformations; if( aStyleProperties.hasElements() ) { for( sal_Int32 i=0; i < aStyleProperties.getLength(); ++i ) @@ -596,7 +589,7 @@ void DrawingML::WriteOutline( Reference< XPropertySet > rXPropSet ) WriteSolidFill( nColor ); else if( !sColorFillScheme.isEmpty() ) // the line had a scheme color and the user didn't change it - WriteSolidFill( sColorFillScheme ); + WriteSolidFill( sColorFillScheme, aTransformations ); else if( aStyleProperties.hasElements() ) { if( nColor != nStyleColor ) diff --git a/sw/qa/extras/ooxmlexport/data/shape-theme-preservation.docx b/sw/qa/extras/ooxmlexport/data/shape-theme-preservation.docx index 74db64e..134f629 100644 Binary files a/sw/qa/extras/ooxmlexport/data/shape-theme-preservation.docx and b/sw/qa/extras/ooxmlexport/data/shape-theme-preservation.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 26b2fe6..232c6e8 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -2608,6 +2608,17 @@ DECLARE_OOXMLEXPORT_TEST(testShapeThemePreservation, "shape-theme-preservation.d "/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:ln/a:solidFill/a:schemeClr", "val", "accent3"); + // check color transformations applied to theme colors have been preserved + assertXPath(pXmlDocument, + "/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:solidFill/a:schemeClr/a:lumMod", + "val", "40000"); + assertXPath(pXmlDocument, + "/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:solidFill/a:schemeClr/a:lumOff", + "val", "60000"); + assertXPath(pXmlDocument, + "/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:ln/a:solidFill/a:schemeClr/a:lumMod", + "val", "50000"); + // check direct color assignments have been preserved OUString sFillColor = getXPath(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:spPr/a:solidFill/a:srgbClr", @@ -2636,10 +2647,10 @@ DECLARE_OOXMLEXPORT_TEST(testShapeThemePreservation, "shape-theme-preservation.d // check colors are properly applied to shapes on import CPPUNIT_ASSERT_EQUAL(sal_Int32(0x4f81bd), getProperty<sal_Int32>(xShape1, "FillColor")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0xf79646), getProperty<sal_Int32>(xShape2, "FillColor")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0xfcd5b5), getProperty<sal_Int32>(xShape2, "FillColor")); CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00b050), getProperty<sal_Int32>(xShape3, "FillColor")); CPPUNIT_ASSERT_EQUAL(sal_Int32(0x3a5f8b), getProperty<sal_Int32>(xShape1, "LineColor")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0x9bbb59), getProperty<sal_Int32>(xShape2, "LineColor")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x4f6228), getProperty<sal_Int32>(xShape2, "LineColor")); CPPUNIT_ASSERT_EQUAL(sal_Int32(0xff0000), getProperty<sal_Int32>(xShape3, "LineColor")); // check line properties are properly applied to shapes on import
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits