oox/inc/drawingml/textbody.hxx           |    2 
 oox/source/drawingml/textbody.cxx        |    8 +--
 oox/source/drawingml/textparagraph.cxx   |    1 
 oox/source/ppt/pptshape.cxx              |   24 ++++++++-
 sd/qa/unit/data/pptx/tdf163239_v2.pptx   |binary
 sd/qa/unit/export-tests-ooxml4.cxx       |   80 +++++++++++++++++++++++++++++++
 sd/source/filter/eppt/pptx-epptooxml.cxx |    4 +
 7 files changed, 112 insertions(+), 7 deletions(-)

New commits:
commit 629105991ee77335f856d746ef44408414cc150a
Author:     Balazs Varga <balazs.va...@collabora.com>
AuthorDate: Fri Aug 29 11:00:19 2025 +0200
Commit:     Balazs Varga <balazs.va...@collabora.com>
CommitDate: Mon Sep 1 17:09:30 2025 +0200

    Related: tdf#111927 - PPTX: fix placeholder title text becomes small
    
    after clicking in&out
    
    Follow-up after a7a02a742237d739e7b6b25fcfb9dbe2d4675c28
    
    Wrong  styles were applied to the different Outline (1, 2, ...) levels
    during ooxml import.
    
    Should also the Title, Subtitle, Outliner placeholders properties saved
    in LstStyles as OOXML standard requires.
    
    Even if we have no LstStyles in the xml, still need to apply
    the char/para properties to the placeholder styles.
    
    Change-Id: I5086f706fd8dc2704a439a2e410d74db2656d09b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/190360
    Tested-by: Jenkins
    Reviewed-by: Balazs Varga <balazs.va...@collabora.com>

diff --git a/oox/inc/drawingml/textbody.hxx b/oox/inc/drawingml/textbody.hxx
index 3f4cd0cb7f55..30b4f63b9221 100644
--- a/oox/inc/drawingml/textbody.hxx
+++ b/oox/inc/drawingml/textbody.hxx
@@ -101,7 +101,7 @@ public:
                             const ::oox::core::XmlFilterBase& rFilterBase,
                             const css::uno::Reference< css::style::XStyle > & 
aXStyle,
                             const TextCharacterProperties& 
rTextStyleProperties,
-                            const TextListStylePtr& pMasterTextListStylePtr) 
const;
+                            const TextListStylePtr& pMasterTextListStylePtr, 
size_t nLevel) const;
 private:
     TextParagraphVector maParagraphs;
     TextBodyProperties  maTextProperties;
diff --git a/oox/source/drawingml/textbody.cxx 
b/oox/source/drawingml/textbody.cxx
index 34a80115a231..e713b12a7f37 100644
--- a/oox/source/drawingml/textbody.cxx
+++ b/oox/source/drawingml/textbody.cxx
@@ -171,16 +171,16 @@ void TextBody::ApplyMasterTextStyle(
     const ::oox::core::XmlFilterBase& rFilterBase,
     const css::uno::Reference< css::style::XStyle >& aXStyle,
     const TextCharacterProperties& rTextStyleProperties,
-    const TextListStylePtr& pMasterTextListStylePtr) const
+    const TextListStylePtr& pMasterTextListStylePtr, size_t nLevel) const
 {
     assert(!isEmpty());
 
-    if (maParagraphs.empty())
+    if (maParagraphs.empty() || maParagraphs.size() <= nLevel)
         return;
 
     // Apply character properties
     PropertySet aPropSet(aXStyle);
-    TextCharacterProperties 
aTextCharacterProps(maParagraphs[0]->getCharacterStyle(
+    TextCharacterProperties 
aTextCharacterProps(maParagraphs[nLevel]->getCharacterStyle(
         rTextStyleProperties, *pMasterTextListStylePtr, maTextListStyle));
     aTextCharacterProps.pushToPropSet(aPropSet, rFilterBase);
 
@@ -189,7 +189,7 @@ void TextBody::ApplyMasterTextStyle(
     aCombinedTextStyle.apply(*pMasterTextListStylePtr);
     aCombinedTextStyle.apply(maTextListStyle);
 
-    TextParagraphProperties* pTextParagraphStyle = 
maParagraphs[0]->getParagraphStyle(aCombinedTextStyle);
+    TextParagraphProperties* pTextParagraphStyle = 
maParagraphs[nLevel]->getParagraphStyle(aCombinedTextStyle);
     if (pTextParagraphStyle)
     {
         Reference< XPropertySet > xProps(aXStyle, UNO_QUERY_THROW);
diff --git a/oox/source/drawingml/textparagraph.cxx 
b/oox/source/drawingml/textparagraph.cxx
index d5d4a59e5494..60615e6563e0 100644
--- a/oox/source/drawingml/textparagraph.cxx
+++ b/oox/source/drawingml/textparagraph.cxx
@@ -63,6 +63,7 @@ TextCharacterProperties TextParagraph::getCharacterStyle (
     if (pTextParagraphStyle)
         
aTextCharacterStyle.assignUsed(pTextParagraphStyle->getTextCharacterProperties());
     aTextCharacterStyle.assignUsed(maProperties.getTextCharacterProperties());
+    aTextCharacterStyle.assignUsed(maEndProperties);
     return aTextCharacterStyle;
 }
 
diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx
index a5a0c57aed8f..98385c78e115 100644
--- a/oox/source/ppt/pptshape.cxx
+++ b/oox/source/ppt/pptshape.cxx
@@ -198,7 +198,29 @@ void PPTShape::setTextMasterStyles( const SlidePersist& 
rSlidePersist, const oox
             if (xFamilies->getByName(aStyle) >>= aXStyle)
             {
                 TextCharacterProperties aCharStyleProperties;
-                getTextBody()->ApplyMasterTextStyle(rFilterBase, aXStyle, 
aCharStyleProperties, mpMasterTextListStyle);
+                getTextBody()->ApplyMasterTextStyle(rFilterBase, aXStyle, 
aCharStyleProperties,
+                                                    mpMasterTextListStyle, 
size_t(0));
+                if (aStyle.equals(u"outline1"_ustr)/* BodyStyle */)
+                {
+                    for (size_t nLevel = 2; nLevel < 10; nLevel++) // outline2 
... outline9
+                    {
+                        char pOutline[9] = "outline1";
+                        pOutline[7] = static_cast<char>('0' + nLevel);
+                        OUString 
sOutlineStyle(OUString::createFromAscii(pOutline));
+                        if (xFamilies->hasByName(sOutlineStyle))
+                        {
+                            if (aXStyle.is())
+                                aXStyle.clear();
+
+                            xFamilies->getByName(sOutlineStyle) >>= aXStyle;
+                            if (aXStyle.is())
+                            {
+                                TextCharacterProperties aCharStyleLvlProps;
+                                
getTextBody()->ApplyMasterTextStyle(rFilterBase, aXStyle, aCharStyleLvlProps, 
mpMasterTextListStyle, nLevel - 1);
+                            }
+                        }
+                    }
+                }
             }
         }
     }
diff --git a/sd/qa/unit/data/pptx/tdf163239_v2.pptx 
b/sd/qa/unit/data/pptx/tdf163239_v2.pptx
new file mode 100644
index 000000000000..9005864c3b8d
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf163239_v2.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml4.cxx 
b/sd/qa/unit/export-tests-ooxml4.cxx
index c88f71db7db4..7528b3398c80 100644
--- a/sd/qa/unit/export-tests-ooxml4.cxx
+++ b/sd/qa/unit/export-tests-ooxml4.cxx
@@ -27,6 +27,7 @@
 #include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
 #include <com/sun/star/lang/Locale.hpp>
+#include <com/sun/star/style/ParagraphAdjust.hpp>
 #include <com/sun/star/text/GraphicCrop.hpp>
 #include <com/sun/star/text/WritingMode2.hpp>
 
@@ -1438,6 +1439,85 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest4, 
testCustomPromptTexts)
     }
 }
 
+CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest4, testPresObjTextStyles)
+{
+    createSdImpressDoc("pptx/tdf163239_v2.pptx");
+    saveAndReload(u"Impress Office Open XML"_ustr);
+
+    uno::Reference<style::XStyleFamiliesSupplier> 
xStyleFamiliesSupplier(mxComponent,
+                                                                         
uno::UNO_QUERY);
+    uno::Reference<container::XNameAccess> xStyleFamilies
+        = xStyleFamiliesSupplier->getStyleFamilies();
+    // 1st slide
+    uno::Reference<container::XNameAccess> xStyleFamily(
+        xStyleFamilies->getByName(u"Title Slide"_ustr), uno::UNO_QUERY);
+    {
+        // Title style
+        uno::Reference<style::XStyle> 
xStyle(xStyleFamily->getByName(u"title"_ustr),
+                                             uno::UNO_QUERY);
+        uno::Reference<beans::XPropertySet> xPropSet(xStyle, uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(60.0f, 
xPropSet->getPropertyValue(u"CharHeight"_ustr).get<float>());
+        CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_CENTER),
+                             
xPropSet->getPropertyValue(u"ParaAdjust"_ustr).get<sal_Int16>());
+        CPPUNIT_ASSERT_EQUAL(u"Marianne"_ustr,
+                             
xPropSet->getPropertyValue(u"CharFontName"_ustr).get<OUString>());
+    }
+    // 2nd slide
+    xStyleFamily.set(xStyleFamilies->getByName(u"Title and Content"_ustr), 
uno::UNO_QUERY);
+    {
+        // Title style
+        uno::Reference<style::XStyle> 
xStyle(xStyleFamily->getByName(u"title"_ustr),
+                                             uno::UNO_QUERY);
+        uno::Reference<beans::XPropertySet> xPropSet(xStyle, uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(44.0f, 
xPropSet->getPropertyValue(u"CharHeight"_ustr).get<float>());
+        CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_LEFT),
+                             
xPropSet->getPropertyValue(u"ParaAdjust"_ustr).get<sal_Int16>());
+        CPPUNIT_ASSERT_EQUAL(u"Marianne"_ustr,
+                             
xPropSet->getPropertyValue(u"CharFontName"_ustr).get<OUString>());
+
+        // outline1 style
+        xStyle.set(xStyleFamily->getByName(u"outline1"_ustr), uno::UNO_QUERY);
+        xPropSet.set(xStyle, uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(28.0f, 
xPropSet->getPropertyValue(u"CharHeight"_ustr).get<float>());
+        CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_LEFT),
+                             
xPropSet->getPropertyValue(u"ParaAdjust"_ustr).get<sal_Int16>());
+        CPPUNIT_ASSERT_EQUAL(u"Marianne"_ustr,
+                             
xPropSet->getPropertyValue(u"CharFontName"_ustr).get<OUString>());
+
+        // outline2 style
+        xStyle.set(xStyleFamily->getByName(u"outline2"_ustr), uno::UNO_QUERY);
+        xPropSet.set(xStyle, uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(24.0f, 
xPropSet->getPropertyValue(u"CharHeight"_ustr).get<float>());
+        CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_LEFT),
+                             
xPropSet->getPropertyValue(u"ParaAdjust"_ustr).get<sal_Int16>());
+        CPPUNIT_ASSERT_EQUAL(u"Marianne"_ustr,
+                             
xPropSet->getPropertyValue(u"CharFontName"_ustr).get<OUString>());
+
+        // outline5 style
+        xStyle.set(xStyleFamily->getByName(u"outline5"_ustr), uno::UNO_QUERY);
+        xPropSet.set(xStyle, uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(18.0f, 
xPropSet->getPropertyValue(u"CharHeight"_ustr).get<float>());
+        CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_LEFT),
+                             
xPropSet->getPropertyValue(u"ParaAdjust"_ustr).get<sal_Int16>());
+        CPPUNIT_ASSERT_EQUAL(u"Marianne"_ustr,
+                             
xPropSet->getPropertyValue(u"CharFontName"_ustr).get<OUString>());
+    }
+}
+
+CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest4, testTextStylesXML)
+{
+    createSdImpressDoc("pptx/tdf163239_v2.pptx");
+    save(u"Impress Office Open XML"_ustr);
+
+    xmlDocUniquePtr pXmlDocRels = 
parseExport(u"ppt/slideLayouts/slideLayout1.xml"_ustr);
+
+    assertXPath(pXmlDocRels, 
"/p:sldLayout/p:cSld/p:spTree/p:sp[1]/p:txBody/a:lstStyle/a:lvl1pPr",
+                "algn", u"ctr");
+    assertXPath(pXmlDocRels,
+                
"/p:sldLayout/p:cSld/p:spTree/p:sp[1]/p:txBody/a:lstStyle/a:lvl1pPr/a:defRPr", 
"sz",
+                u"6000");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/filter/eppt/pptx-epptooxml.cxx 
b/sd/source/filter/eppt/pptx-epptooxml.cxx
index f26a9bf05b12..aa8183de5d90 100644
--- a/sd/source/filter/eppt/pptx-epptooxml.cxx
+++ b/sd/source/filter/eppt/pptx-epptooxml.cxx
@@ -2456,7 +2456,9 @@ ShapeExport& 
PowerPointShapeExport::WritePlaceholderShape(const Reference< XShap
     }
     mpFS->endElementNS(XML_p, XML_spPr);
 
-    WriteTextBox(xShape, XML_p, 
/*bWritePropertiesAsLstStyles=*/bUsePlaceholderIndex);
+    bool bWritePropertiesAsLstStyles = bUsePlaceholderIndex || ePlaceholder == 
Title
+                                       || ePlaceholder == Subtitle || 
ePlaceholder == Outliner;
+    WriteTextBox(xShape, XML_p, bWritePropertiesAsLstStyles);
 
     mpFS->endElementNS(XML_p, XML_sp);
 

Reply via email to