[Libreoffice-commits] core.git: Branch 'libreoffice-5-0' - include/oox oox/source sd/qa sd/source
Mark Hung
marklh9 at gmail.com
Thu Nov 26 02:40:26 PST 2015
include/oox/export/drawingml.hxx | 4 ++-
oox/source/export/drawingml.cxx | 33 +++++++++++++++++++------------
sd/qa/unit/data/odp/tdf80224.odp |binary
sd/qa/unit/export-tests.cxx | 21 +++++++++++++++++++
sd/source/filter/eppt/epptbase.hxx | 1
sd/source/filter/eppt/pptx-epptbase.cxx | 4 +++
sd/source/filter/eppt/pptx-epptooxml.cxx | 5 +++-
7 files changed, 54 insertions(+), 14 deletions(-)
New commits:
commit 0b5e3885bc706ed02acac1c682c90171700b0cac
Author: Mark Hung <marklh9 at gmail.com>
Date: Sun Aug 2 14:40:18 2015 +0800
Fix tdf#80224 Custom text color changed to black on .PPTX export
1) Write endParaRPr so that PowerPoint display them properly.
2) Original design forbid properites with default value to be exprted, now fixed.
3) Automatic colors are written as white or black based on
whether background is dark.
Note that tdf#77881,tdf#80520,tdf#89525 depend on this.
Change-Id: I255c16f35149b738be2daf2800b1c90389f2c7cf
Reviewed-on: https://gerrit.libreoffice.org/17472
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Norbert Thiebaud <nthiebaud at gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/19862
Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>
Tested-by: Katarina Behrens <Katarina.Behrens at cib.de>
diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx
index bf5669a..fcfb638 100644
--- a/include/oox/export/drawingml.hxx
+++ b/include/oox/export/drawingml.hxx
@@ -103,6 +103,7 @@ protected:
::oox::core::XmlFilterBase* mpFB;
/// If set, this is the parent of the currently handled shape.
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 GetPropertyAndState( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet,
@@ -122,7 +123,7 @@ protected:
public:
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; }
::sax_fastparser::FSHelperPtr GetFS() { return mpFS; }
::oox::core::XmlFilterBase* GetFB() { return mpFB; }
@@ -130,6 +131,7 @@ public:
/// The application-specific text exporter callback, if there is one.
DMLTextExport* GetTextExport() { return mpTextExport; }
+ void SetBackgroundDark(bool bIsDark) { mbIsBackgroundDark = bIsDark; }
/// If bRelPathToMedia is true add "../" to image folder path while adding the image relationship
OUString WriteImage( const Graphic &rGraphic , bool bRelPathToMedia = false);
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 493a894..67a5dad 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -113,6 +113,9 @@ namespace drawingml {
if ( GETA(propName) ) \
mAny >>= variable;
+#define CGETAD(propName) \
+ (( bCheckDirect && GetPropertyAndState( rXPropSet, rXPropState, OUString( #propName ), eState ) && eState == beans::PropertyState_DIRECT_VALUE )||GetProperty( rXPropSet, OUString( #propName ) ))
+
// not thread safe
int DrawingML::mnImageCounter = 1;
int DrawingML::mnWdpImageCounter = 1;
@@ -1214,7 +1217,7 @@ void DrawingML::WriteRunProperties( Reference< XPropertySet > rRun, bool bIsFiel
sal_Int32 nSize = 1800;
sal_Int32 nCharEscapement = 0;
sal_Int32 nCharKerning = 0;
-
+ bool bCheckDirect = XML_endParaRPr != nElement ;
if( GETA( CharHeight ) )
nSize = (sal_Int32) (100*(*static_cast<float const *>(mAny.getValue())));
@@ -1245,7 +1248,7 @@ void DrawingML::WriteRunProperties( Reference< XPropertySet > rRun, bool bIsFiel
break;
}
- if ( GETAD( CharUnderline ) )
+ if ( CGETAD( CharUnderline ) )
{
switch ( *static_cast<sal_Int16 const *>(mAny.getValue()) )
{
@@ -1300,7 +1303,7 @@ void DrawingML::WriteRunProperties( Reference< XPropertySet > rRun, bool bIsFiel
}
}
- if ( GETAD( CharStrikeout ) )
+ if ( CGETAD( CharStrikeout ) )
{
switch ( *static_cast<sal_Int16 const *>(mAny.getValue()) )
{
@@ -1374,16 +1377,14 @@ void DrawingML::WriteRunProperties( Reference< XPropertySet > rRun, bool bIsFiel
FSEND );
// 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());
DBG(fprintf(stderr, "run color: %x auto: %x\n", static_cast<unsigned int>( color ), static_cast<unsigned int>( COL_AUTO )));
if( color == COL_AUTO ) // nCharColor depends to the background color
{
- bool bIsDark = false;
- GET( bIsDark, IsBackgroundDark );
- color = bIsDark ? 0xffffff : 0x000000;
+ color = mbIsBackgroundDark ? COL_WHITE : COL_BLACK ;
}
color &= 0xffffff;
@@ -1392,7 +1393,7 @@ void DrawingML::WriteRunProperties( Reference< XPropertySet > rRun, bool bIsFiel
WriteSolidFill( color );
}
- if( GETAD( CharUnderlineColor ) )
+ if( CGETAD( CharUnderlineColor ) )
{
sal_uInt32 color = *static_cast<sal_uInt32 const *>(mAny.getValue());
@@ -1677,7 +1678,8 @@ void DrawingML::WriteParagraphNumbering( Reference< XPropertySet > rXPropSet, sa
OUString aGraphicURL;
sal_Int16 nBulletRelSize = 0;
sal_Int16 nStartWith = 1;
- sal_Int32 nBulletColor = 0;
+ sal_uInt32 nBulletColor = 0;
+ bool bHasBulletColor = false;
for ( sal_Int32 i = 0; i < nPropertyCount; i++ )
{
@@ -1704,7 +1706,8 @@ void DrawingML::WriteParagraphNumbering( Reference< XPropertySet > rXPropSet, sa
}
else if(aPropName == "BulletColor")
{
- nBulletColor = *static_cast<sal_Int32 const *>(pValue);
+ nBulletColor = *static_cast<sal_uInt32 const *>(pValue);
+ bHasBulletColor = true;
}
else if ( aPropName == "BulletChar" )
{
@@ -1764,8 +1767,12 @@ void DrawingML::WriteParagraphNumbering( Reference< XPropertySet > rXPropSet, sa
}
else
{
- if(nBulletColor)
+ if(bHasBulletColor)
{
+ if (nBulletColor == COL_AUTO )
+ {
+ nBulletColor = mbIsBackgroundDark ? COL_WHITE : COL_BLACK ;
+ }
mpFS->startElementNS( XML_a, XML_buClr, FSEND );
WriteColor( nBulletColor );
mpFS->endElementNS( XML_a, XML_buClr );
@@ -1962,6 +1969,7 @@ void DrawingML::WriteParagraph( Reference< XTextContent > rParagraph )
mpFS->startElementNS( XML_a, XML_p, FSEND );
+
bool bPropertiesWritten = false;
while( enumeration->hasMoreElements() )
{
@@ -1978,7 +1986,8 @@ void DrawingML::WriteParagraph( Reference< XTextContent > rParagraph )
WriteRun( run );
}
}
- mpFS->singleElementNS( XML_a, XML_endParaRPr, FSEND );
+ Reference< XPropertySet > rXPropSet( rParagraph, UNO_QUERY );
+ WriteRunProperties( rXPropSet , false, XML_endParaRPr );
mpFS->endElementNS( XML_a, XML_p );
}
diff --git a/sd/qa/unit/data/odp/tdf80224.odp b/sd/qa/unit/data/odp/tdf80224.odp
new file mode 100644
index 0000000..5712c1a
Binary files /dev/null and b/sd/qa/unit/data/odp/tdf80224.odp differ
diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index 2bb3473..4d1de95 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -111,6 +111,7 @@ public:
#if !defined WNT
void testBnc822341();
#endif
+ void testTdf80224();
CPPUNIT_TEST_SUITE(SdExportTest);
CPPUNIT_TEST(testFdo90607);
@@ -146,6 +147,7 @@ public:
#if !defined WNT
CPPUNIT_TEST(testBnc822341);
#endif
+ CPPUNIT_TEST(testTdf80224);
CPPUNIT_TEST_SUITE_END();
};
@@ -1217,6 +1219,25 @@ void SdExportTest::testTableCellBorder()
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_PLUGIN_IMPLEMENT();
diff --git a/sd/source/filter/eppt/epptbase.hxx b/sd/source/filter/eppt/epptbase.hxx
index 873ab5c..50fa5f1 100644
--- a/sd/source/filter/eppt/epptbase.hxx
+++ b/sd/source/filter/eppt/epptbase.hxx
@@ -347,6 +347,7 @@ protected:
OString mType;
bool mbPresObj;
bool mbEmptyPresObj;
+ bool mbIsBackgroundDark;
sal_Int32 mnAngle;
sal_uInt32 mnPages; ///< number of Slides ( w/o master pages & notes & handout )
diff --git a/sd/source/filter/eppt/pptx-epptbase.cxx b/sd/source/filter/eppt/pptx-epptbase.cxx
index 45febb9..1d58016 100644
--- a/sd/source/filter/eppt/pptx-epptbase.cxx
+++ b/sd/source/filter/eppt/pptx-epptbase.cxx
@@ -133,6 +133,7 @@ PPTWriterBase::PPTWriterBase()
, mbStatusIndicator(false)
, mbPresObj(false)
, mbEmptyPresObj(false)
+ , mbIsBackgroundDark(false)
, mnAngle(0)
, mnPages(0)
, mnMasterPages(0)
@@ -325,6 +326,9 @@ bool PPTWriterBase::GetPageByIndex( sal_uInt32 nIndex, PageType ePageType )
if ( !mXPagePropSet.is() )
break;
+ if (GetPropertyValue( aAny, mXPagePropSet, OUString("IsBackgroundDark") ) )
+ aAny >>= mbIsBackgroundDark;
+
mXShapes = Reference< XShapes >( mXDrawPage, UNO_QUERY );
if ( !mXShapes.is() )
break;
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx b/sd/source/filter/eppt/pptx-epptooxml.cxx
index f454540..0c045d3 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -412,7 +412,9 @@ void PowerPointExport::ImplWriteBackground( FSHelperPtr pFS, Reference< XPropert
pFS->startElementNS( XML_p, XML_bg, 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_bg );
@@ -1706,6 +1708,7 @@ void PowerPointExport::WriteShapeTree( FSHelperPtr pFS, PageType ePageType, bool
PowerPointShapeExport aDML( pFS, &maShapeMap, this );
aDML.SetMaster( bMaster );
aDML.SetPageType( ePageType );
+ aDML.SetBackgroundDark(mbIsBackgroundDark);
sal_uInt32 nShapes;
pFS->startElementNS( XML_p, XML_spTree, FSEND );
More information about the Libreoffice-commits
mailing list