[Libreoffice-commits] core.git: include/oox oox/source sd/qa sd/source
Mark Hung
marklh9 at gmail.com
Tue Aug 25 04:55:27 PDT 2015
include/oox/export/drawingml.hxx | 6 +++--
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, 55 insertions(+), 15 deletions(-)
New commits:
commit 43679f94b45f4d9e120c64a3fb5cc3ee77f12b11
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) 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/17472
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Norbert Thiebaud <nthiebaud at gmail.com>
diff --git a/include/oox/export/drawingml.hxx b/include/oox/export/drawingml.hxx
index bfd3c6c..55ef5c7 100644
--- a/include/oox/export/drawingml.hxx
+++ b/include/oox/export/drawingml.hxx
@@ -99,6 +99,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,
@@ -118,7 +119,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; }
@@ -126,6 +127,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);
@@ -173,7 +175,7 @@ public:
void WriteParagraphNumbering( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > rXPropSet,
sal_Int16 nLevel );
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, MSO_SPT eShapeType, bool bPredefinedHandlesUsed, sal_Int32 nAdjustmentsWhichNeedsToBeConverted, const ::com::sun::star::beans::PropertyValue& rProp );
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index a153ff2..6685948 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;
@@ -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) );
}
-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< XPropertyState > rXPropState( rRun, UNO_QUERY );
@@ -1220,7 +1223,7 @@ void DrawingML::WriteRunProperties( Reference< XPropertySet > rRun, bool bIsFiel
break;
}
- if ( GETAD( CharUnderline ) )
+ if ( CGETAD( CharUnderline ) )
{
switch ( *static_cast<sal_Int16 const *>(mAny.getValue()) )
{
@@ -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()) )
{
@@ -1349,16 +1352,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());
SAL_INFO("oox.shape", "run color: " << color << " auto: " << COL_AUTO);
if( color == COL_AUTO ) // nCharColor depends to the background color
{
- bool bIsDark = false;
- GET( bIsDark, IsBackgroundDark );
- color = bIsDark ? 0xffffff : 0x000000;
+ color = mbIsBackgroundDark ? 0xffffff : 0x000000;
}
color &= 0xffffff;
@@ -1367,7 +1368,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());
@@ -1622,7 +1623,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++ )
{
@@ -1649,7 +1651,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" )
{
@@ -1709,8 +1712,12 @@ void DrawingML::WriteParagraphNumbering( Reference< XPropertySet > rXPropSet, sa
}
else
{
- if(nBulletColor)
+ if(bHasBulletColor)
{
+ if (nBulletColor == COL_AUTO )
+ {
+ nBulletColor = mbIsBackgroundDark ? 0xffffff : 0x000000;
+ }
mpFS->startElementNS( XML_a, XML_buClr, FSEND );
WriteColor( nBulletColor );
mpFS->endElementNS( XML_a, XML_buClr );
@@ -1904,6 +1911,7 @@ void DrawingML::WriteParagraph( Reference< XTextContent > rParagraph )
mpFS->startElementNS( XML_a, XML_p, FSEND );
+
bool bPropertiesWritten = false;
while( enumeration->hasMoreElements() )
{
@@ -1920,7 +1928,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, false );
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 0a8a342..a90a3de 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -129,6 +129,7 @@ public:
#if !defined WNT
void testBnc822341();
#endif
+ void testTdf80224();
CPPUNIT_TEST_SUITE(SdExportTest);
CPPUNIT_TEST(testFdo90607);
@@ -166,6 +167,7 @@ public:
#if !defined WNT
CPPUNIT_TEST(testBnc822341);
#endif
+ CPPUNIT_TEST(testTdf80224);
CPPUNIT_TEST_SUITE_END();
};
@@ -1240,6 +1242,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 9180464..99d84cd 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 ff020e0..e30e7fa 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