summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2019-05-18 17:42:25 +0200
committerTamás Zolnai <tamas.zolnai@collabora.com>2019-05-20 16:46:19 +0200
commit259d01a34d27df2fbfd11c3bf6fe9dc508ff6ac2 (patch)
treeb1b8acf552ec6cea17a16f2044eb3e4b33623ea6
parent0385f4235850b8c3949f6564e1e5b79cbe56b146 (diff)
tdf#125360: PPTX: Shape fill transparency is not exported
.. if the original shape fill is defined with a theme Override the alpha value with the current value get from FillTransparence API attirbute even if the color is defined with a style or a color scheme. Change-Id: I09d26238a9c2b501279e6749687dc535e614bbd6 Reviewed-on: https://gerrit.libreoffice.org/72596 Tested-by: Jenkins Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
-rw-r--r--include/oox/export/drawingml.hxx6
-rw-r--r--oox/source/export/drawingml.cxx47
-rw-r--r--sd/qa/unit/data/pptx/tdf125360.pptxbin0 -> 15379 bytes
-rw-r--r--sd/qa/unit/data/pptx/tdf125360_1.pptxbin0 -> 15480 bytes
-rw-r--r--sd/qa/unit/data/pptx/tdf125360_2.pptxbin0 -> 15213 bytes
-rw-r--r--sd/qa/unit/export-tests-ooxml2.cxx76
6 files changed, 116 insertions, 13 deletions
diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx
index 8ed1aaf0d702..d74c82ff8b28 100644
--- a/include/oox/export/drawingml.hxx
+++ b/include/oox/export/drawingml.hxx
@@ -181,14 +181,14 @@ public:
OUString WriteImage( const Graphic &rGraphic , bool bRelPathToMedia = false);
void WriteColor( ::Color nColor, sal_Int32 nAlpha = MAX_PERCENT );
- void WriteColor( const OUString& sColorSchemeName, const css::uno::Sequence< css::beans::PropertyValue >& aTransformations );
- void WriteColorTransformations( const css::uno::Sequence< css::beans::PropertyValue >& aTransformations );
+ void WriteColor( const OUString& sColorSchemeName, const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha = MAX_PERCENT );
+ void WriteColorTransformations( const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha = MAX_PERCENT );
void WriteGradientStop( sal_uInt16 nStop, ::Color nColor );
void WriteLineArrow( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, bool bLineStart );
void WriteConnectorConnections( EscherConnectorListEntry& rConnectorEntry, sal_Int32 nStartID, sal_Int32 nEndID );
void WriteSolidFill( ::Color nColor, sal_Int32 nAlpha = MAX_PERCENT );
- void WriteSolidFill( const OUString& sSchemeName, const css::uno::Sequence< css::beans::PropertyValue >& aTransformations );
+ void WriteSolidFill( const OUString& sSchemeName, const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha = MAX_PERCENT );
void WriteSolidFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
void WriteGradientFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
void WriteGradientFill( css::awt::Gradient rGradient );
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 78225dcc532a..cd91bb12cbe0 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -268,7 +268,7 @@ void DrawingML::WriteColor( ::Color nColor, sal_Int32 nAlpha )
}
}
-void DrawingML::WriteColor( const OUString& sColorSchemeName, const Sequence< PropertyValue >& aTransformations )
+void DrawingML::WriteColor( const OUString& sColorSchemeName, const Sequence< PropertyValue >& aTransformations, sal_Int32 nAlpha )
{
// prevent writing a tag with empty val attribute
if( sColorSchemeName.isEmpty() )
@@ -277,7 +277,13 @@ void DrawingML::WriteColor( const OUString& sColorSchemeName, const Sequence< Pr
if( aTransformations.hasElements() )
{
mpFS->startElementNS(XML_a, XML_schemeClr, XML_val, sColorSchemeName.toUtf8());
- WriteColorTransformations( aTransformations );
+ WriteColorTransformations( aTransformations, nAlpha );
+ mpFS->endElementNS( XML_a, XML_schemeClr );
+ }
+ else if(nAlpha < MAX_PERCENT)
+ {
+ mpFS->startElementNS(XML_a, XML_schemeClr, XML_val, sColorSchemeName.toUtf8());
+ mpFS->singleElementNS(XML_a, XML_alpha, XML_val, OString::number(nAlpha));
mpFS->endElementNS( XML_a, XML_schemeClr );
}
else
@@ -286,15 +292,22 @@ void DrawingML::WriteColor( const OUString& sColorSchemeName, const Sequence< Pr
}
}
-void DrawingML::WriteColorTransformations( const Sequence< PropertyValue >& aTransformations )
+void DrawingML::WriteColorTransformations( const Sequence< PropertyValue >& aTransformations, sal_Int32 nAlpha )
{
for( sal_Int32 i = 0; i < aTransformations.getLength(); i++ )
{
sal_Int32 nToken = Color::getColorTransformationToken( aTransformations[i].Name );
if( nToken != XML_TOKEN_INVALID && aTransformations[i].Value.hasValue() )
{
- sal_Int32 nValue = aTransformations[i].Value.get<sal_Int32>();
- mpFS->singleElementNS(XML_a, nToken, XML_val, OString::number(nValue));
+ if(nToken == XML_alpha && nAlpha < MAX_PERCENT)
+ {
+ mpFS->singleElementNS(XML_a, nToken, XML_val, OString::number(nAlpha));
+ }
+ else
+ {
+ sal_Int32 nValue = aTransformations[i].Value.get<sal_Int32>();
+ mpFS->singleElementNS(XML_a, nToken, XML_val, OString::number(nValue));
+ }
}
}
}
@@ -306,10 +319,10 @@ void DrawingML::WriteSolidFill( ::Color nColor, sal_Int32 nAlpha )
mpFS->endElementNS( XML_a, XML_solidFill );
}
-void DrawingML::WriteSolidFill( const OUString& sSchemeName, const Sequence< PropertyValue >& aTransformations )
+void DrawingML::WriteSolidFill( const OUString& sSchemeName, const Sequence< PropertyValue >& aTransformations, sal_Int32 nAlpha )
{
mpFS->startElementNS(XML_a, XML_solidFill);
- WriteColor( sSchemeName, aTransformations );
+ WriteColor( sSchemeName, aTransformations, nAlpha );
mpFS->endElementNS( XML_a, XML_solidFill );
}
@@ -359,22 +372,36 @@ void DrawingML::WriteSolidFill( const Reference< XPropertySet >& rXPropSet )
else if ( !sColorFillScheme.isEmpty() )
{
// the shape had a scheme color and the user didn't change it
- WriteSolidFill( sColorFillScheme, aTransformations );
+ WriteSolidFill( sColorFillScheme, aTransformations, nAlpha );
}
else if ( aStyleProperties.hasElements() )
{
sal_uInt32 nThemeColor = 0;
+ sal_Int32 nThemeAlpha = MAX_PERCENT;
for( sal_Int32 i=0; i < aStyleProperties.getLength(); ++i )
{
if( aStyleProperties[i].Name == "Color" )
{
aStyleProperties[i].Value >>= nThemeColor;
- break;
+ }
+ else if(aStyleProperties[i].Name == "Transformations" )
+ {
+ Sequence< PropertyValue > aStyleTransformations;
+ aStyleProperties[i].Value >>= aStyleTransformations;
+ for( sal_Int32 j = 0; j < aStyleTransformations.getLength(); j++ )
+ {
+ if (aStyleTransformations[j].Name == "alpha" )
+ {
+ aStyleTransformations[j].Value >>= nThemeAlpha;
+ break;
+ }
+ }
}
}
- if ( nFillColor != nThemeColor )
+ if ( nFillColor != nThemeColor || nAlpha != nThemeAlpha )
// the shape contains a theme but it wasn't being used
WriteSolidFill( ::Color(nFillColor & 0xffffff), nAlpha );
+
// in case the shape used the style color and the user didn't change it,
// we must not write a <a: solidFill> tag.
}
diff --git a/sd/qa/unit/data/pptx/tdf125360.pptx b/sd/qa/unit/data/pptx/tdf125360.pptx
new file mode 100644
index 000000000000..c1a3045bc17b
--- /dev/null
+++ b/sd/qa/unit/data/pptx/tdf125360.pptx
Binary files differ
diff --git a/sd/qa/unit/data/pptx/tdf125360_1.pptx b/sd/qa/unit/data/pptx/tdf125360_1.pptx
new file mode 100644
index 000000000000..cfc5798369db
--- /dev/null
+++ b/sd/qa/unit/data/pptx/tdf125360_1.pptx
Binary files differ
diff --git a/sd/qa/unit/data/pptx/tdf125360_2.pptx b/sd/qa/unit/data/pptx/tdf125360_2.pptx
new file mode 100644
index 000000000000..4f6b16455f71
--- /dev/null
+++ b/sd/qa/unit/data/pptx/tdf125360_2.pptx
Binary files differ
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx
index 3fd98f4b99bb..bc987a018af2 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -202,6 +202,9 @@ public:
void testSmartArtPreserve();
void testTdf125346();
void testTdf125346_2();
+ void testTdf125360();
+ void testTdf125360_1();
+ void testTdf125360_2();
CPPUNIT_TEST_SUITE(SdOOXMLExportTest2);
@@ -286,6 +289,9 @@ public:
CPPUNIT_TEST(testSmartArtPreserve);
CPPUNIT_TEST(testTdf125346);
CPPUNIT_TEST(testTdf125346_2);
+ CPPUNIT_TEST(testTdf125360);
+ CPPUNIT_TEST(testTdf125360_1);
+ CPPUNIT_TEST(testTdf125360_2);
CPPUNIT_TEST_SUITE_END();
@@ -2242,6 +2248,76 @@ void SdOOXMLExportTest2::testTdf125346_2()
xDocShRef->DoClose();
}
+void SdOOXMLExportTest2::testTdf125360()
+{
+ // Check whether the changed fill transparency is exported correctly.
+ // Color is defined by shape style
+ ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf125360.pptx"), PPTX);
+
+ uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
+
+ xShape->setPropertyValue("FillTransparence", uno::makeAny(static_cast<sal_Int32>(23)));
+
+ utl::TempFile tempFile;
+ xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
+
+ xShape.set( getShapeFromPage( 0, 0, xDocShRef ) );
+
+ sal_Int32 nTransparence = 0;
+ xShape->getPropertyValue("FillTransparence") >>= nTransparence;
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(23), nTransparence);
+
+ xDocShRef->DoClose();
+}
+
+void SdOOXMLExportTest2::testTdf125360_1()
+{
+ // Check whether the changed fill transparency is exported correctly.
+ // Color is defined by color scheme
+ ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf125360_1.pptx"), PPTX);
+
+ uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
+
+ xShape->setPropertyValue("FillTransparence", uno::makeAny(static_cast<sal_Int32>(23)));
+
+ utl::TempFile tempFile;
+ xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
+
+ xShape.set( getShapeFromPage( 0, 0, xDocShRef ) );
+
+ sal_Int32 nTransparence = 0;
+ xShape->getPropertyValue("FillTransparence") >>= nTransparence;
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(23), nTransparence);
+
+ xDocShRef->DoClose();
+}
+
+void SdOOXMLExportTest2::testTdf125360_2()
+{
+ // Check whether the changed fill transparency is exported correctly.
+ // Color is defined by color scheme with a transparency
+ ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf125360_2.pptx"), PPTX);
+
+ uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
+
+ sal_Int32 nTransparence = 0;
+ xShape->getPropertyValue("FillTransparence") >>= nTransparence;
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(82), nTransparence);
+
+ xShape->setPropertyValue("FillTransparence", uno::makeAny(static_cast<sal_Int32>(23)));
+
+ utl::TempFile tempFile;
+ xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
+
+ xShape.set( getShapeFromPage( 0, 0, xDocShRef ) );
+
+ nTransparence = 0;
+ xShape->getPropertyValue("FillTransparence") >>= nTransparence;
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(23), nTransparence);
+
+ xDocShRef->DoClose();
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2);
CPPUNIT_PLUGIN_IMPLEMENT();