oox/inc/drawingml/textparagraph.hxx    |    2 ++
 oox/source/drawingml/textbody.cxx      |   18 +++++++++---------
 oox/source/drawingml/textparagraph.cxx |   15 ++++++++++++---
 sd/qa/unit/data/pptx/tdf103800.pptx    |binary
 sd/qa/unit/import-tests.cxx            |   17 +++++++++++++++++
 5 files changed, 40 insertions(+), 12 deletions(-)
New commits:
commit 7d6212e218d4d5c76c8bc60983b548a6893fc6a5
Author:     Tünde Tóth <toth.tu...@nisz.hu>
AuthorDate: Fri Feb 18 10:30:54 2022 +0100
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Mon Feb 28 15:39:07 2022 +0100

    tdf#103800 PPTX shape import: fix regression of text color
    
    defined by list styles. Properties in a:lstStyle of p:txBody
    should take precedence over the same properties defined in
    a:fontRef of style elements.
    
    Change-Id: I02cc886eb9eba94f49fe413a63bf7c46c9e3c127
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130237
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git a/oox/inc/drawingml/textparagraph.hxx 
b/oox/inc/drawingml/textparagraph.hxx
index 021434d6a5fb..1f43249372a5 100644
--- a/oox/inc/drawingml/textparagraph.hxx
+++ b/oox/inc/drawingml/textparagraph.hxx
@@ -63,6 +63,7 @@ public:
 
     TextCharacterProperties          getCharacterStyle(
         const TextCharacterProperties& rTextStyleProperties,
+        const TextListStyle& rMasterTextListStyle,
         const TextListStyle& rTextListStyle) const;
 
     TextParagraphProperties*      getParagraphStyle(
@@ -73,6 +74,7 @@ public:
                                     const css::uno::Reference < 
css::text::XText > & xText,
                                     const css::uno::Reference < 
css::text::XTextCursor > &xAt,
                                     const TextCharacterProperties& 
rTextStyleProperties,
+                                    const TextListStyle& rMasterTextListStyle,
                                     const TextListStyle& rTextListStyle,
                                     bool bFirst,
                                     float nDefaultCharHeight) const;
diff --git a/oox/source/drawingml/textbody.cxx 
b/oox/source/drawingml/textbody.cxx
index f4da6886a69c..41a237e97cee 100644
--- a/oox/source/drawingml/textbody.cxx
+++ b/oox/source/drawingml/textbody.cxx
@@ -57,16 +57,15 @@ void TextBody::insertAt(
         const TextCharacterProperties& rTextStyleProperties,
         const TextListStylePtr& pMasterTextListStylePtr ) const
 {
-    TextListStyle aCombinedTextStyle;
-    aCombinedTextStyle.apply( *pMasterTextListStylePtr );
-    aCombinedTextStyle.apply( maTextListStyle );
+    TextListStyle aMasterTextStyle(*pMasterTextListStylePtr);
 
     Reference<css::beans::XPropertySet> xPropertySet(xAt, UNO_QUERY);
     float nCharHeight = 
xPropertySet->getPropertyValue("CharHeight").get<float>();
     size_t nIndex = 0;
     for (auto const& paragraph : maParagraphs)
     {
-        paragraph->insertAt( rFilterBase, xText, xAt, rTextStyleProperties, 
aCombinedTextStyle, (nIndex == 0), nCharHeight );
+        paragraph->insertAt(rFilterBase, xText, xAt, rTextStyleProperties, 
aMasterTextStyle,
+                            maTextListStyle, (nIndex == 0), nCharHeight);
         ++nIndex;
     }
 }
@@ -127,15 +126,16 @@ void TextBody::ApplyStyleEmpty(
         return;
 
     // Apply character properties
-    TextListStyle aCombinedTextStyle;
-    aCombinedTextStyle.apply( *pMasterTextListStylePtr );
-    aCombinedTextStyle.apply( maTextListStyle );
-
     PropertySet aPropSet(xText);
-    TextCharacterProperties 
aTextCharacterProps(maParagraphs[0]->getCharacterStyle(rTextStyleProperties, 
aCombinedTextStyle));
+    TextCharacterProperties 
aTextCharacterProps(maParagraphs[0]->getCharacterStyle(
+        rTextStyleProperties, *pMasterTextListStylePtr, maTextListStyle));
     aTextCharacterProps.pushToPropSet(aPropSet, rFilterBase);
 
     // Apply paragraph properties
+    TextListStyle aCombinedTextStyle;
+    aCombinedTextStyle.apply(*pMasterTextListStylePtr);
+    aCombinedTextStyle.apply(maTextListStyle);
+
     TextParagraphProperties* pTextParagraphStyle = 
maParagraphs[0]->getParagraphStyle(aCombinedTextStyle);
     if (pTextParagraphStyle)
     {
diff --git a/oox/source/drawingml/textparagraph.cxx 
b/oox/source/drawingml/textparagraph.cxx
index 9e4f309e9391..f91ee279bb3b 100644
--- a/oox/source/drawingml/textparagraph.cxx
+++ b/oox/source/drawingml/textparagraph.cxx
@@ -48,14 +48,18 @@ TextParagraph::~TextParagraph()
 
 TextCharacterProperties TextParagraph::getCharacterStyle (
     const TextCharacterProperties& rTextStyleProperties,
+    const TextListStyle& rMasterTextListStyle,
     const TextListStyle& rTextListStyle) const
 {
+    const TextParagraphProperties* pMasterTextParagraphStyle = 
getParagraphStyle(rMasterTextListStyle);
     const TextParagraphProperties* pTextParagraphStyle = 
getParagraphStyle(rTextListStyle);
 
     TextCharacterProperties aTextCharacterStyle;
+    if (pMasterTextParagraphStyle)
+        
aTextCharacterStyle.assignUsed(pMasterTextParagraphStyle->getTextCharacterProperties());
+    aTextCharacterStyle.assignUsed(rTextStyleProperties);
     if (pTextParagraphStyle)
         
aTextCharacterStyle.assignUsed(pTextParagraphStyle->getTextCharacterProperties());
-    aTextCharacterStyle.assignUsed(rTextStyleProperties);
     aTextCharacterStyle.assignUsed(maProperties.getTextCharacterProperties());
     return aTextCharacterStyle;
 }
@@ -82,11 +86,13 @@ void TextParagraph::insertAt(
         const Reference < XText > &xText,
         const Reference < XTextCursor > &xAt,
         const TextCharacterProperties& rTextStyleProperties,
+        const TextListStyle& rMasterTextListStyle,
         const TextListStyle& rTextListStyle, bool bFirst, float 
nDefaultCharHeight) const
 {
     try {
         sal_Int32 nParagraphSize = 0;
-        TextCharacterProperties aTextCharacterStyle = 
getCharacterStyle(rTextStyleProperties, rTextListStyle);
+        TextCharacterProperties aTextCharacterStyle
+            = getCharacterStyle(rTextStyleProperties, rMasterTextListStyle, 
rTextListStyle);
 
         if( !bFirst )
         {
@@ -127,7 +133,10 @@ void TextParagraph::insertAt(
         PropertyMap aioBulletList;
         Reference< XPropertySet > xProps( xAt, UNO_QUERY);
 
-        TextParagraphProperties* pTextParagraphStyle = 
getParagraphStyle(rTextListStyle);
+        TextListStyle aCombinedTextStyle;
+        aCombinedTextStyle.apply(rMasterTextListStyle);
+        aCombinedTextStyle.apply(rTextListStyle);
+        TextParagraphProperties* pTextParagraphStyle = 
getParagraphStyle(aCombinedTextStyle);
         if ( pTextParagraphStyle )
         {
             TextParagraphProperties aParaProp;
diff --git a/sd/qa/unit/data/pptx/tdf103800.pptx 
b/sd/qa/unit/data/pptx/tdf103800.pptx
new file mode 100644
index 000000000000..91f8bb719fef
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf103800.pptx differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 7e8d8f2ade0e..9d479fb69437 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -140,6 +140,7 @@ public:
     void testTdf93097();
     void testTdf62255();
     void testTdf89927();
+    void testTdf103800();
 
     CPPUNIT_TEST_SUITE(SdImportTest);
 
@@ -205,6 +206,7 @@ public:
     CPPUNIT_TEST(testTdf93097);
     CPPUNIT_TEST(testTdf62255);
     CPPUNIT_TEST(testTdf89927);
+    CPPUNIT_TEST(testTdf103800);
 
     CPPUNIT_TEST_SUITE_END();
 };
@@ -1749,6 +1751,21 @@ void SdImportTest::testTdf89927()
     xDocShRef->DoClose();
 }
 
+void SdImportTest::testTdf103800()
+{
+    sd::DrawDocShellRef xDocShRef = 
loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf103800.pptx"), 
PPTX);
+    uno::Reference< beans::XPropertySet > xShape(getShapeFromPage(0, 0, 
xDocShRef));
+    uno::Reference< text::XTextRange > xParagraph(getParagraphFromShape(0, 
xShape));
+    uno::Reference< text::XTextRange > xRun(getRunFromParagraph(0, 
xParagraph));
+    uno::Reference< beans::XPropertySet > xPropSet(xRun, uno::UNO_QUERY_THROW);
+
+    Color nCharColor;
+    xPropSet->getPropertyValue("CharColor") >>= nCharColor;
+    CPPUNIT_ASSERT_EQUAL(Color(0xC00000), nCharColor);
+
+    xDocShRef->DoClose();
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();

Reply via email to