diff options
author | Zolnai Tamás <tamas.zolnai@collabora.com> | 2014-02-20 11:48:35 +0100 |
---|---|---|
committer | Zolnai Tamás <tamas.zolnai@collabora.com> | 2014-02-21 09:28:24 +0100 |
commit | 191f648ffd97b58f57afca65961e5dbcc2bbe724 (patch) | |
tree | 7be863909852730d385e3f0ede0522eea79a79ef | |
parent | 1d512fb31c20e17426f0652234a1304ead2d8c8d (diff) |
drawingML export: gradient fill defined by imported theme
Plus avoid writing out empty <a:gradFill></a:gradFill>.
Change-Id: I50fa92b2cc30eedfe28a8c6af697d43d98a3aee8
-rw-r--r-- | oox/source/drawingml/shape.cxx | 5 | ||||
-rw-r--r-- | oox/source/export/drawingml.cxx | 16 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/dml-gradientfill-theme.docx | bin | 0 -> 15771 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 24 |
4 files changed, 40 insertions, 5 deletions
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index b3020107a9ff..9066d44fac31 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -853,7 +853,10 @@ Reference< XShape > Shape::createAndInsert( PUT_PROP( aGradientStops, i, OUString::number( i ), aGradientStop ); ++aIt; } - putPropertyToGrabBag( "GradFillDefinition", Any( aGradientStops ) ); + // If getFillProperties.moFillType is unused that means gradient is defined by a theme + // which is already saved into StyleFillRef property, so no need to save the explicit values too + if( getFillProperties().moFillType.has() ) + putPropertyToGrabBag( "GradFillDefinition", Any( aGradientStops ) ); putPropertyToGrabBag( "OriginalGradFill", Any( aShapeProps[PROP_FillGradient] ) ); } } diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 8ff54aa0fe27..e019ed68fbac 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -339,15 +339,23 @@ void DrawingML::WriteGradientFill( Reference< XPropertySet > rXPropSet ) aGrabBag[i].Value >>= aOriginalGradient; } - mpFS->startElementNS( XML_a, XML_gradFill, FSEND ); // check if an ooxml gradient had been imported and if the user has modified it - if( aGradientStops.hasElements() && EqualGradients( aOriginalGradient, aGradient ) ) + if( EqualGradients( aOriginalGradient, aGradient ) ) { - WriteGrabBagGradientFill(aGradientStops, aGradient); + // If we have no gradient stops that means original gradient were defined by a theme. + if( aGradientStops.hasElements() ) + { + mpFS->startElementNS( XML_a, XML_gradFill, FSEND ); + WriteGrabBagGradientFill(aGradientStops, aGradient); + mpFS->endElementNS( XML_a, XML_gradFill ); + } } else + { + mpFS->startElementNS( XML_a, XML_gradFill, FSEND ); WriteGradientFill(aGradient); - mpFS->endElementNS( XML_a, XML_gradFill ); + mpFS->endElementNS( XML_a, XML_gradFill ); + } } } diff --git a/sw/qa/extras/ooxmlexport/data/dml-gradientfill-theme.docx b/sw/qa/extras/ooxmlexport/data/dml-gradientfill-theme.docx Binary files differnew file mode 100644 index 000000000000..3311ce8a0431 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/dml-gradientfill-theme.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index dc434a32e863..bda5ea084ce2 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -3318,6 +3318,30 @@ DECLARE_OOXMLEXPORT_TEST(testDMLGroupShapeChildPosition, "dml-groupshape-childpo CPPUNIT_ASSERT_EQUAL(sal_Int32(m_bExported ? -2119 : -2121), xChildGroup->getPosition().X); CPPUNIT_ASSERT_EQUAL(sal_Int32(m_bExported ? 14028 : 14025), xChildGroup->getPosition().Y); } + +DECLARE_OOXMLEXPORT_TEST(testDMLGradientFillTheme, "dml-gradientfill-theme.docx") +{ + // Problem was when a fill gradient was imported from a theme, (fillRef in ooxml) + // not just the theme was written out but the explicit values too + // Besides the duplication of values it causes problems with writing out + // <a:schemeClr val="phClr"> into document.xml, while phClr can be used just for theme definitions. + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + + // check no explicit gradFill has been exported + assertXPath(pXmlDoc, + "/w:document/w:body/w:p[2]/w:r/mc:AlternateContent[1]/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:gradFill", + 0); + + // check shape style has been exported + 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:style/a:fillRef", + "idx", "2"); + 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:style/a:fillRef/a:schemeClr", + "val", "accent1"); +} #endif CPPUNIT_PLUGIN_IMPLEMENT(); |