Kaydet (Commit) 43679f94 authored tarafından Mark Hung's avatar Mark Hung Kaydeden (comit) Norbert Thiebaud

Fix tdf#80224 Custom text color changed to black on .PPTX export

1) Indirect property values were ignored, now they are used.
2) Write endParaRPr so that PowerPoint display them.
3) Automatic colors are written as white or black based on
   whether background is dark.

Change-Id: I255c16f35149b738be2daf2800b1c90389f2c7cf
Reviewed-on: https://gerrit.libreoffice.org/17472Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNorbert Thiebaud <nthiebaud@gmail.com>
üst 3ac03b3f
...@@ -99,6 +99,7 @@ protected: ...@@ -99,6 +99,7 @@ protected:
::oox::core::XmlFilterBase* mpFB; ::oox::core::XmlFilterBase* mpFB;
/// If set, this is the parent of the currently handled shape. /// If set, this is the parent of the currently handled shape.
com::sun::star::uno::Reference<com::sun::star::drawing::XShape> m_xParent; com::sun::star::uno::Reference<com::sun::star::drawing::XShape> m_xParent;
bool mbIsBackgroundDark;
bool GetProperty( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet, const OUString& aName ); bool GetProperty( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet, const OUString& aName );
bool GetPropertyAndState( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet, bool GetPropertyAndState( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet,
...@@ -118,7 +119,7 @@ protected: ...@@ -118,7 +119,7 @@ protected:
public: public:
DrawingML( ::sax_fastparser::FSHelperPtr pFS, ::oox::core::XmlFilterBase* pFB = NULL, DocumentType eDocumentType = DOCUMENT_PPTX, DMLTextExport* pTextExport = 0 ) DrawingML( ::sax_fastparser::FSHelperPtr pFS, ::oox::core::XmlFilterBase* pFB = NULL, DocumentType eDocumentType = DOCUMENT_PPTX, DMLTextExport* pTextExport = 0 )
: meDocumentType( eDocumentType ), mpTextExport(pTextExport), mpFS( pFS ), mpFB( pFB ) {} : meDocumentType( eDocumentType ), mpTextExport(pTextExport), mpFS( pFS ), mpFB( pFB ), mbIsBackgroundDark( false ) {}
void SetFS( ::sax_fastparser::FSHelperPtr pFS ) { mpFS = pFS; } void SetFS( ::sax_fastparser::FSHelperPtr pFS ) { mpFS = pFS; }
::sax_fastparser::FSHelperPtr GetFS() { return mpFS; } ::sax_fastparser::FSHelperPtr GetFS() { return mpFS; }
::oox::core::XmlFilterBase* GetFB() { return mpFB; } ::oox::core::XmlFilterBase* GetFB() { return mpFB; }
...@@ -126,6 +127,7 @@ public: ...@@ -126,6 +127,7 @@ public:
/// The application-specific text exporter callback, if there is one. /// The application-specific text exporter callback, if there is one.
DMLTextExport* GetTextExport() { return mpTextExport; } DMLTextExport* GetTextExport() { return mpTextExport; }
void SetBackgroundDark(bool bIsDark) { mbIsBackgroundDark = bIsDark; }
/// If bRelPathToMedia is true add "../" to image folder path while adding the image relationship /// If bRelPathToMedia is true add "../" to image folder path while adding the image relationship
OUString WriteImage( const Graphic &rGraphic , bool bRelPathToMedia = false); OUString WriteImage( const Graphic &rGraphic , bool bRelPathToMedia = false);
...@@ -173,7 +175,7 @@ public: ...@@ -173,7 +175,7 @@ public:
void WriteParagraphNumbering( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet, void WriteParagraphNumbering( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet,
sal_Int16 nLevel ); sal_Int16 nLevel );
void WriteRun( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > rRun ); void WriteRun( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > rRun );
void WriteRunProperties( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rRun, bool bIsField, sal_Int32 nElement = XML_rPr ); void WriteRunProperties( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rRun, bool bIsField, sal_Int32 nElement = XML_rPr ,bool bCheckDirect = true);
void WritePresetShape( const char* pShape ); void WritePresetShape( const char* pShape );
void WritePresetShape( const char* pShape, MSO_SPT eShapeType, bool bPredefinedHandlesUsed, sal_Int32 nAdjustmentsWhichNeedsToBeConverted, const ::com::sun::star::beans::PropertyValue& rProp ); void WritePresetShape( const char* pShape, MSO_SPT eShapeType, bool bPredefinedHandlesUsed, sal_Int32 nAdjustmentsWhichNeedsToBeConverted, const ::com::sun::star::beans::PropertyValue& rProp );
......
...@@ -113,6 +113,9 @@ namespace drawingml { ...@@ -113,6 +113,9 @@ namespace drawingml {
if ( GETA(propName) ) \ if ( GETA(propName) ) \
mAny >>= variable; mAny >>= variable;
#define CGETAD(propName) \
(( bCheckDirect && GetPropertyAndState( rXPropSet, rXPropState, OUString( #propName ), eState ) && eState == beans::PropertyState_DIRECT_VALUE )||GetProperty( rXPropSet, OUString( #propName ) ))
// not thread safe // not thread safe
int DrawingML::mnImageCounter = 1; int DrawingML::mnImageCounter = 1;
int DrawingML::mnWdpImageCounter = 1; int DrawingML::mnWdpImageCounter = 1;
...@@ -1173,7 +1176,7 @@ void DrawingML::WriteShapeTransformation( Reference< XShape > rXShape, sal_Int32 ...@@ -1173,7 +1176,7 @@ void DrawingML::WriteShapeTransformation( Reference< XShape > rXShape, sal_Int32
WriteTransformation( Rectangle( Point( aPos.X, aPos.Y ), Size( aSize.Width, aSize.Height ) ), nXmlNamespace, bFlipH, bFlipV, OOX_DRAWINGML_EXPORT_ROTATE_CLOCKWISIFY(nRotation) ); WriteTransformation( Rectangle( Point( aPos.X, aPos.Y ), Size( aSize.Width, aSize.Height ) ), nXmlNamespace, bFlipH, bFlipV, OOX_DRAWINGML_EXPORT_ROTATE_CLOCKWISIFY(nRotation) );
} }
void DrawingML::WriteRunProperties( Reference< XPropertySet > rRun, bool bIsField, sal_Int32 nElement /*= XML_rPr*/ ) void DrawingML::WriteRunProperties( Reference< XPropertySet > rRun, bool bIsField, sal_Int32 nElement /*= XML_rPr*/, bool bCheckDirect/* = true */)
{ {
Reference< XPropertySet > rXPropSet( rRun, UNO_QUERY ); Reference< XPropertySet > rXPropSet( rRun, UNO_QUERY );
Reference< XPropertyState > rXPropState( rRun, UNO_QUERY ); Reference< XPropertyState > rXPropState( rRun, UNO_QUERY );
...@@ -1220,7 +1223,7 @@ void DrawingML::WriteRunProperties( Reference< XPropertySet > rRun, bool bIsFiel ...@@ -1220,7 +1223,7 @@ void DrawingML::WriteRunProperties( Reference< XPropertySet > rRun, bool bIsFiel
break; break;
} }
if ( GETAD( CharUnderline ) ) if ( CGETAD( CharUnderline ) )
{ {
switch ( *static_cast<sal_Int16 const *>(mAny.getValue()) ) switch ( *static_cast<sal_Int16 const *>(mAny.getValue()) )
{ {
...@@ -1275,7 +1278,7 @@ void DrawingML::WriteRunProperties( Reference< XPropertySet > rRun, bool bIsFiel ...@@ -1275,7 +1278,7 @@ void DrawingML::WriteRunProperties( Reference< XPropertySet > rRun, bool bIsFiel
} }
} }
if ( GETAD( CharStrikeout ) ) if ( CGETAD( CharStrikeout ) )
{ {
switch ( *static_cast<sal_Int16 const *>(mAny.getValue()) ) switch ( *static_cast<sal_Int16 const *>(mAny.getValue()) )
{ {
...@@ -1349,16 +1352,14 @@ void DrawingML::WriteRunProperties( Reference< XPropertySet > rRun, bool bIsFiel ...@@ -1349,16 +1352,14 @@ void DrawingML::WriteRunProperties( Reference< XPropertySet > rRun, bool bIsFiel
FSEND ); FSEND );
// mso doesn't like text color to be placed after typeface // mso doesn't like text color to be placed after typeface
if( GETAD( CharColor ) ) if( CGETAD( CharColor ) )
{ {
sal_uInt32 color = *static_cast<sal_uInt32 const *>(mAny.getValue()); sal_uInt32 color = *static_cast<sal_uInt32 const *>(mAny.getValue());
SAL_INFO("oox.shape", "run color: " << color << " auto: " << COL_AUTO); SAL_INFO("oox.shape", "run color: " << color << " auto: " << COL_AUTO);
if( color == COL_AUTO ) // nCharColor depends to the background color if( color == COL_AUTO ) // nCharColor depends to the background color
{ {
bool bIsDark = false; color = mbIsBackgroundDark ? 0xffffff : 0x000000;
GET( bIsDark, IsBackgroundDark );
color = bIsDark ? 0xffffff : 0x000000;
} }
color &= 0xffffff; color &= 0xffffff;
...@@ -1367,7 +1368,7 @@ void DrawingML::WriteRunProperties( Reference< XPropertySet > rRun, bool bIsFiel ...@@ -1367,7 +1368,7 @@ void DrawingML::WriteRunProperties( Reference< XPropertySet > rRun, bool bIsFiel
WriteSolidFill( color ); WriteSolidFill( color );
} }
if( GETAD( CharUnderlineColor ) ) if( CGETAD( CharUnderlineColor ) )
{ {
sal_uInt32 color = *static_cast<sal_uInt32 const *>(mAny.getValue()); sal_uInt32 color = *static_cast<sal_uInt32 const *>(mAny.getValue());
...@@ -1622,7 +1623,8 @@ void DrawingML::WriteParagraphNumbering( Reference< XPropertySet > rXPropSet, sa ...@@ -1622,7 +1623,8 @@ void DrawingML::WriteParagraphNumbering( Reference< XPropertySet > rXPropSet, sa
OUString aGraphicURL; OUString aGraphicURL;
sal_Int16 nBulletRelSize = 0; sal_Int16 nBulletRelSize = 0;
sal_Int16 nStartWith = 1; sal_Int16 nStartWith = 1;
sal_Int32 nBulletColor = 0; sal_uInt32 nBulletColor = 0;
bool bHasBulletColor = false;
for ( sal_Int32 i = 0; i < nPropertyCount; i++ ) for ( sal_Int32 i = 0; i < nPropertyCount; i++ )
{ {
...@@ -1649,7 +1651,8 @@ void DrawingML::WriteParagraphNumbering( Reference< XPropertySet > rXPropSet, sa ...@@ -1649,7 +1651,8 @@ void DrawingML::WriteParagraphNumbering( Reference< XPropertySet > rXPropSet, sa
} }
else if(aPropName == "BulletColor") else if(aPropName == "BulletColor")
{ {
nBulletColor = *static_cast<sal_Int32 const *>(pValue); nBulletColor = *static_cast<sal_uInt32 const *>(pValue);
bHasBulletColor = true;
} }
else if ( aPropName == "BulletChar" ) else if ( aPropName == "BulletChar" )
{ {
...@@ -1709,8 +1712,12 @@ void DrawingML::WriteParagraphNumbering( Reference< XPropertySet > rXPropSet, sa ...@@ -1709,8 +1712,12 @@ void DrawingML::WriteParagraphNumbering( Reference< XPropertySet > rXPropSet, sa
} }
else else
{ {
if(nBulletColor) if(bHasBulletColor)
{ {
if (nBulletColor == COL_AUTO )
{
nBulletColor = mbIsBackgroundDark ? 0xffffff : 0x000000;
}
mpFS->startElementNS( XML_a, XML_buClr, FSEND ); mpFS->startElementNS( XML_a, XML_buClr, FSEND );
WriteColor( nBulletColor ); WriteColor( nBulletColor );
mpFS->endElementNS( XML_a, XML_buClr ); mpFS->endElementNS( XML_a, XML_buClr );
...@@ -1904,6 +1911,7 @@ void DrawingML::WriteParagraph( Reference< XTextContent > rParagraph ) ...@@ -1904,6 +1911,7 @@ void DrawingML::WriteParagraph( Reference< XTextContent > rParagraph )
mpFS->startElementNS( XML_a, XML_p, FSEND ); mpFS->startElementNS( XML_a, XML_p, FSEND );
bool bPropertiesWritten = false; bool bPropertiesWritten = false;
while( enumeration->hasMoreElements() ) while( enumeration->hasMoreElements() )
{ {
...@@ -1920,7 +1928,8 @@ void DrawingML::WriteParagraph( Reference< XTextContent > rParagraph ) ...@@ -1920,7 +1928,8 @@ void DrawingML::WriteParagraph( Reference< XTextContent > rParagraph )
WriteRun( run ); WriteRun( run );
} }
} }
mpFS->singleElementNS( XML_a, XML_endParaRPr, FSEND ); Reference< XPropertySet > rXPropSet( rParagraph, UNO_QUERY );
WriteRunProperties( rXPropSet , false, XML_endParaRPr, false );
mpFS->endElementNS( XML_a, XML_p ); mpFS->endElementNS( XML_a, XML_p );
} }
......
...@@ -129,6 +129,7 @@ public: ...@@ -129,6 +129,7 @@ public:
#if !defined WNT #if !defined WNT
void testBnc822341(); void testBnc822341();
#endif #endif
void testTdf80224();
CPPUNIT_TEST_SUITE(SdExportTest); CPPUNIT_TEST_SUITE(SdExportTest);
CPPUNIT_TEST(testFdo90607); CPPUNIT_TEST(testFdo90607);
...@@ -166,6 +167,7 @@ public: ...@@ -166,6 +167,7 @@ public:
#if !defined WNT #if !defined WNT
CPPUNIT_TEST(testBnc822341); CPPUNIT_TEST(testBnc822341);
#endif #endif
CPPUNIT_TEST(testTdf80224);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
}; };
...@@ -1240,6 +1242,25 @@ void SdExportTest::testTableCellBorder() ...@@ -1240,6 +1242,25 @@ void SdExportTest::testTableCellBorder()
xDocShRef->DoClose(); xDocShRef->DoClose();
} }
void SdExportTest::testTdf80224()
{
::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/odp/tdf80224.odp"), ODP);
xDocShRef = saveAndReload( xDocShRef, PPTX );
uno::Reference< drawing::XDrawPagesSupplier > xDoc( xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
uno::Reference< drawing::XDrawPage > xPage( xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
uno::Reference< drawing::XShape > xShape(xPage->getByIndex(0), uno::UNO_QUERY);
uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText();
uno::Reference<container::XEnumerationAccess> paraEnumAccess;
paraEnumAccess.set(xText, uno::UNO_QUERY);
uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration();
uno::Reference<text::XTextRange> const xParagraph(paraEnum->nextElement(), uno::UNO_QUERY_THROW);
uno::Reference< beans::XPropertySet > xPropSet( xParagraph->getStart(), uno::UNO_QUERY_THROW );
sal_Int32 nCharColor;
xPropSet->getPropertyValue("CharColor") >>= nCharColor;
CPPUNIT_ASSERT_EQUAL(sal_Int32(6644396), nCharColor);
xDocShRef->DoClose();
}
CPPUNIT_TEST_SUITE_REGISTRATION(SdExportTest); CPPUNIT_TEST_SUITE_REGISTRATION(SdExportTest);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -347,6 +347,7 @@ protected: ...@@ -347,6 +347,7 @@ protected:
OString mType; OString mType;
bool mbPresObj; bool mbPresObj;
bool mbEmptyPresObj; bool mbEmptyPresObj;
bool mbIsBackgroundDark;
sal_Int32 mnAngle; sal_Int32 mnAngle;
sal_uInt32 mnPages; ///< number of Slides ( w/o master pages & notes & handout ) sal_uInt32 mnPages; ///< number of Slides ( w/o master pages & notes & handout )
......
...@@ -133,6 +133,7 @@ PPTWriterBase::PPTWriterBase() ...@@ -133,6 +133,7 @@ PPTWriterBase::PPTWriterBase()
, mbStatusIndicator(false) , mbStatusIndicator(false)
, mbPresObj(false) , mbPresObj(false)
, mbEmptyPresObj(false) , mbEmptyPresObj(false)
, mbIsBackgroundDark(false)
, mnAngle(0) , mnAngle(0)
, mnPages(0) , mnPages(0)
, mnMasterPages(0) , mnMasterPages(0)
...@@ -325,6 +326,9 @@ bool PPTWriterBase::GetPageByIndex( sal_uInt32 nIndex, PageType ePageType ) ...@@ -325,6 +326,9 @@ bool PPTWriterBase::GetPageByIndex( sal_uInt32 nIndex, PageType ePageType )
if ( !mXPagePropSet.is() ) if ( !mXPagePropSet.is() )
break; break;
if (GetPropertyValue( aAny, mXPagePropSet, OUString("IsBackgroundDark") ) )
aAny >>= mbIsBackgroundDark;
mXShapes = Reference< XShapes >( mXDrawPage, UNO_QUERY ); mXShapes = Reference< XShapes >( mXDrawPage, UNO_QUERY );
if ( !mXShapes.is() ) if ( !mXShapes.is() )
break; break;
......
...@@ -412,7 +412,9 @@ void PowerPointExport::ImplWriteBackground( FSHelperPtr pFS, Reference< XPropert ...@@ -412,7 +412,9 @@ void PowerPointExport::ImplWriteBackground( FSHelperPtr pFS, Reference< XPropert
pFS->startElementNS( XML_p, XML_bg, FSEND ); pFS->startElementNS( XML_p, XML_bg, FSEND );
pFS->startElementNS( XML_p, XML_bgPr, FSEND ); pFS->startElementNS( XML_p, XML_bgPr, FSEND );
PowerPointShapeExport( pFS, &maShapeMap, this ).WriteFill( rXPropSet ); PowerPointShapeExport aDML( pFS, &maShapeMap, this );
aDML.SetBackgroundDark(mbIsBackgroundDark);
aDML.WriteFill( rXPropSet );
pFS->endElementNS( XML_p, XML_bgPr ); pFS->endElementNS( XML_p, XML_bgPr );
pFS->endElementNS( XML_p, XML_bg ); pFS->endElementNS( XML_p, XML_bg );
...@@ -1706,6 +1708,7 @@ void PowerPointExport::WriteShapeTree( FSHelperPtr pFS, PageType ePageType, bool ...@@ -1706,6 +1708,7 @@ void PowerPointExport::WriteShapeTree( FSHelperPtr pFS, PageType ePageType, bool
PowerPointShapeExport aDML( pFS, &maShapeMap, this ); PowerPointShapeExport aDML( pFS, &maShapeMap, this );
aDML.SetMaster( bMaster ); aDML.SetMaster( bMaster );
aDML.SetPageType( ePageType ); aDML.SetPageType( ePageType );
aDML.SetBackgroundDark(mbIsBackgroundDark);
sal_uInt32 nShapes; sal_uInt32 nShapes;
pFS->startElementNS( XML_p, XML_spTree, FSEND ); pFS->startElementNS( XML_p, XML_spTree, FSEND );
......
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