Kaydet (Commit) 4dac3a64 authored tarafından Tamás Zolnai's avatar Tamás Zolnai Kaydeden (comit) Andras Timar

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.

Reviewed-on: https://gerrit.libreoffice.org/72596
Tested-by: Jenkins
Reviewed-by: 's avatarTamás Zolnai <tamas.zolnai@collabora.com>
(cherry picked from commit 259d01a3)

Change-Id: I09d26238a9c2b501279e6749687dc535e614bbd6
Reviewed-on: https://gerrit.libreoffice.org/72617Reviewed-by: 's avatarAndras Timar <andras.timar@collabora.com>
Tested-by: 's avatarAndras Timar <andras.timar@collabora.com>
üst 30b8d352
...@@ -164,14 +164,14 @@ public: ...@@ -164,14 +164,14 @@ public:
OUString WriteImage( const Graphic &rGraphic , bool bRelPathToMedia = false); OUString WriteImage( const Graphic &rGraphic , bool bRelPathToMedia = false);
void WriteColor( sal_uInt32 nColor, sal_Int32 nAlpha = MAX_PERCENT ); void WriteColor( sal_uInt32 nColor, sal_Int32 nAlpha = MAX_PERCENT );
void WriteColor( const OUString& sColorSchemeName, 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 ); void WriteColorTransformations( const css::uno::Sequence< css::beans::PropertyValue >& aTransformations, sal_Int32 nAlpha = MAX_PERCENT );
void WriteGradientStop( sal_uInt16 nStop, sal_uInt32 nColor ); void WriteGradientStop( sal_uInt16 nStop, sal_uInt32 nColor );
void WriteLineArrow( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, bool bLineStart ); void WriteLineArrow( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet, bool bLineStart );
void WriteConnectorConnections( EscherConnectorListEntry& rConnectorEntry, sal_Int32 nStartID, sal_Int32 nEndID ); void WriteConnectorConnections( EscherConnectorListEntry& rConnectorEntry, sal_Int32 nStartID, sal_Int32 nEndID );
void WriteSolidFill( sal_uInt32 nColor, sal_Int32 nAlpha = MAX_PERCENT ); void WriteSolidFill( sal_uInt32 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 WriteSolidFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
void WriteGradientFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet ); void WriteGradientFill( const css::uno::Reference< css::beans::XPropertySet >& rXPropSet );
void WriteGradientFill( css::awt::Gradient rGradient ); void WriteGradientFill( css::awt::Gradient rGradient );
......
...@@ -234,7 +234,7 @@ void DrawingML::WriteColor( sal_uInt32 nColor, sal_Int32 nAlpha ) ...@@ -234,7 +234,7 @@ void DrawingML::WriteColor( sal_uInt32 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 // prevent writing a tag with empty val attribute
if( sColorSchemeName.isEmpty() ) if( sColorSchemeName.isEmpty() )
...@@ -245,7 +245,15 @@ void DrawingML::WriteColor( const OUString& sColorSchemeName, const Sequence< Pr ...@@ -245,7 +245,15 @@ void DrawingML::WriteColor( const OUString& sColorSchemeName, const Sequence< Pr
mpFS->startElementNS( XML_a, XML_schemeClr, mpFS->startElementNS( XML_a, XML_schemeClr,
XML_val, USS( sColorSchemeName ), XML_val, USS( sColorSchemeName ),
FSEND ); FSEND );
WriteColorTransformations( aTransformations ); WriteColorTransformations( aTransformations, nAlpha );
mpFS->endElementNS( XML_a, XML_schemeClr );
}
else if(nAlpha < MAX_PERCENT)
{
mpFS->startElementNS( XML_a, XML_schemeClr,
XML_val, USS( sColorSchemeName ),
FSEND );
mpFS->singleElementNS(XML_a, XML_alpha, XML_val, OString::number(nAlpha), FSEND);
mpFS->endElementNS( XML_a, XML_schemeClr ); mpFS->endElementNS( XML_a, XML_schemeClr );
} }
else else
...@@ -256,15 +264,22 @@ void DrawingML::WriteColor( const OUString& sColorSchemeName, const Sequence< Pr ...@@ -256,15 +264,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++ ) for( sal_Int32 i = 0; i < aTransformations.getLength(); i++ )
{ {
sal_Int32 nToken = Color::getColorTransformationToken( aTransformations[i].Name ); sal_Int32 nToken = Color::getColorTransformationToken( aTransformations[i].Name );
if( nToken != XML_TOKEN_INVALID && aTransformations[i].Value.hasValue() ) if( nToken != XML_TOKEN_INVALID && aTransformations[i].Value.hasValue() )
{ {
sal_Int32 nValue = aTransformations[i].Value.get<sal_Int32>(); if(nToken == XML_alpha && nAlpha < MAX_PERCENT)
mpFS->singleElementNS( XML_a, nToken, XML_val, I32S( nValue ), FSEND ); {
mpFS->singleElementNS(XML_a, nToken, XML_val, I32S(nAlpha), FSEND);
}
else
{
sal_Int32 nValue = aTransformations[i].Value.get<sal_Int32>();
mpFS->singleElementNS( XML_a, nToken, XML_val, I32S( nValue ), FSEND );
}
} }
} }
} }
...@@ -276,10 +291,10 @@ void DrawingML::WriteSolidFill( sal_uInt32 nColor, sal_Int32 nAlpha ) ...@@ -276,10 +291,10 @@ void DrawingML::WriteSolidFill( sal_uInt32 nColor, sal_Int32 nAlpha )
mpFS->endElementNS( XML_a, XML_solidFill ); 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, FSEND ); mpFS->startElementNS( XML_a, XML_solidFill, FSEND );
WriteColor( sSchemeName, aTransformations ); WriteColor( sSchemeName, aTransformations, nAlpha );
mpFS->endElementNS( XML_a, XML_solidFill ); mpFS->endElementNS( XML_a, XML_solidFill );
} }
...@@ -329,20 +344,33 @@ void DrawingML::WriteSolidFill( const Reference< XPropertySet >& rXPropSet ) ...@@ -329,20 +344,33 @@ void DrawingML::WriteSolidFill( const Reference< XPropertySet >& rXPropSet )
else if ( !sColorFillScheme.isEmpty() ) else if ( !sColorFillScheme.isEmpty() )
{ {
// the shape had a scheme color and the user didn't change it // the shape had a scheme color and the user didn't change it
WriteSolidFill( sColorFillScheme, aTransformations ); WriteSolidFill( sColorFillScheme, aTransformations, nAlpha );
} }
else if ( aStyleProperties.hasElements() ) else if ( aStyleProperties.hasElements() )
{ {
sal_uInt32 nThemeColor = 0; sal_uInt32 nThemeColor = 0;
sal_Int32 nThemeAlpha = MAX_PERCENT;
for( sal_Int32 i=0; i < aStyleProperties.getLength(); ++i ) for( sal_Int32 i=0; i < aStyleProperties.getLength(); ++i )
{ {
if( aStyleProperties[i].Name == "Color" ) if( aStyleProperties[i].Name == "Color" )
{ {
aStyleProperties[i].Value >>= nThemeColor; 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 // the shape contains a theme but it wasn't being used
WriteSolidFill( nFillColor & 0xffffff, nAlpha ); WriteSolidFill( nFillColor & 0xffffff, nAlpha );
// in case the shape used the style color and the user didn't change it, // in case the shape used the style color and the user didn't change it,
......
...@@ -145,6 +145,9 @@ public: ...@@ -145,6 +145,9 @@ public:
void testOpenDocumentAsReadOnly(); void testOpenDocumentAsReadOnly();
void testTdf125346(); void testTdf125346();
void testTdf125346_2(); void testTdf125346_2();
void testTdf125360();
void testTdf125360_1();
void testTdf125360_2();
CPPUNIT_TEST_SUITE(SdOOXMLExportTest2); CPPUNIT_TEST_SUITE(SdOOXMLExportTest2);
...@@ -213,6 +216,9 @@ public: ...@@ -213,6 +216,9 @@ public:
CPPUNIT_TEST(testOpenDocumentAsReadOnly); CPPUNIT_TEST(testOpenDocumentAsReadOnly);
CPPUNIT_TEST(testTdf125346); CPPUNIT_TEST(testTdf125346);
CPPUNIT_TEST(testTdf125346_2); CPPUNIT_TEST(testTdf125346_2);
CPPUNIT_TEST(testTdf125360);
CPPUNIT_TEST(testTdf125360_1);
CPPUNIT_TEST(testTdf125360_2);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
...@@ -1805,6 +1811,76 @@ void SdOOXMLExportTest2::testTdf125346_2() ...@@ -1805,6 +1811,76 @@ void SdOOXMLExportTest2::testTdf125346_2()
xDocShRef->DoClose(); 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_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment