include/oox/ppt/pptshape.hxx      |    3 +
 oox/inc/drawingml/textbody.hxx    |   10 +++++
 oox/source/drawingml/textbody.cxx |   37 ++++++++++++++++++++
 oox/source/ppt/pptshape.cxx       |   67 ++++++++++++++++++++++++++++++++++++++
 sd/qa/unit/import-tests.cxx       |   44 ++++++++++++++++++++++++
 sd/qa/unit/import-tests2.cxx      |    8 ++--
 6 files changed, 165 insertions(+), 4 deletions(-)

New commits:
commit 2766e7ebd2311365e0b7adb5e647556093e4bb97
Author:     Balazs Varga <balazs.va...@collabora.com>
AuthorDate: Tue Aug 12 19:16:55 2025 +0200
Commit:     Balazs Varga <balazs.va...@collabora.com>
CommitDate: Fri Aug 15 14:22:03 2025 +0200

    tdf#111927 - PPTX: fix placeholder title text becomes small after
    
    clicking in&out
    
    Set the first paragraph of text styles for placeholder shapes.
    
    Change-Id: Ib44a5b2752a1e9aaad4fe7333c0652f0578db7f9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189445
    Tested-by: Jenkins
    Reviewed-by: Balazs Varga <balazs.va...@collabora.com>
    (cherry picked from commit 78e0581ec09078ea5f344bae66d07978396bb23e)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189563
    Reviewed-by: Justin Luth <jl...@mail.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/include/oox/ppt/pptshape.hxx b/include/oox/ppt/pptshape.hxx
index 02c60a69a759..a20c8d5487d6 100644
--- a/include/oox/ppt/pptshape.hxx
+++ b/include/oox/ppt/pptshape.hxx
@@ -55,6 +55,9 @@ class PPTShape final : public oox::drawingml::Shape
 
     bool IsPlaceHolderCandidate(const SlidePersist& rSlidePersist) const;
 
+    void setTextMasterStyles(const SlidePersist& rSlidePersist, const 
oox::core::XmlFilterBase& rFilterBase,
+        const std::u16string_view& sType);
+
 public:
 
     PPTShape( const oox::ppt::ShapeLocation eShapeLocation,
diff --git a/oox/inc/drawingml/textbody.hxx b/oox/inc/drawingml/textbody.hxx
index d059ed501306..e0683c606a8b 100644
--- a/oox/inc/drawingml/textbody.hxx
+++ b/oox/inc/drawingml/textbody.hxx
@@ -31,6 +31,10 @@ namespace com::sun::star::text {
     class XTextCursor;
 }
 
+namespace com::sun::star::style {
+    class XStyle;
+}
+
 namespace oox::core { class XmlFilterBase; }
 
 namespace oox::drawingml {
@@ -91,6 +95,12 @@ public:
                             const css::uno::Reference < css::text::XText > & 
xText,
                             const TextCharacterProperties& 
rTextStyleProperties,
                             const TextListStylePtr& pMasterTextListStylePtr) 
const;
+
+    void                ApplyMasterTextStyle(
+                            const ::oox::core::XmlFilterBase& rFilterBase,
+                            const css::uno::Reference< css::style::XStyle > & 
aXStyle,
+                            const TextCharacterProperties& 
rTextStyleProperties,
+                            const TextListStylePtr& pMasterTextListStylePtr) 
const;
 private:
     TextParagraphVector maParagraphs;
     TextBodyProperties  maTextProperties;
diff --git a/oox/source/drawingml/textbody.cxx 
b/oox/source/drawingml/textbody.cxx
index 9e1c68b5206f..34a80115a231 100644
--- a/oox/source/drawingml/textbody.cxx
+++ b/oox/source/drawingml/textbody.cxx
@@ -19,6 +19,7 @@
 
 #include <drawingml/textbody.hxx>
 #include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/style/XStyle.hpp>
 #include <drawingml/textparagraph.hxx>
 #include <oox/helper/propertyset.hxx>
 #include <oox/token/properties.hxx>
@@ -166,6 +167,42 @@ void TextBody::ApplyStyleEmpty(
     }
 }
 
+void TextBody::ApplyMasterTextStyle(
+    const ::oox::core::XmlFilterBase& rFilterBase,
+    const css::uno::Reference< css::style::XStyle >& aXStyle,
+    const TextCharacterProperties& rTextStyleProperties,
+    const TextListStylePtr& pMasterTextListStylePtr) const
+{
+    assert(!isEmpty());
+
+    if (maParagraphs.empty())
+        return;
+
+    // Apply character properties
+    PropertySet aPropSet(aXStyle);
+    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)
+    {
+        Reference< XPropertySet > xProps(aXStyle, UNO_QUERY_THROW);
+        PropertyMap aioBulletList;
+        aioBulletList.setProperty< sal_Int32 >(PROP_LeftMargin, 0); // Init 
bullets left margin to 0 (no bullets).
+        float nCharHeight = 
xProps->getPropertyValue(u"CharHeight"_ustr).get<float>();
+        TextParagraphProperties aParaProp;
+        aParaProp.apply(*pTextParagraphStyle);
+        aParaProp.pushToPropSet(&rFilterBase, xProps, aioBulletList, 
&pTextParagraphStyle->getBulletList(),
+            true, nCharHeight, true);
+    }
+}
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx
index 61adfbd87512..5b80d96e0add 100644
--- a/oox/source/ppt/pptshape.cxx
+++ b/oox/source/ppt/pptshape.cxx
@@ -26,6 +26,8 @@
 #include <editeng/flditem.hxx>
 
 #include <com/sun/star/text/XTextField.hpp>
+#include <com/sun/star/style/XStyle.hpp>
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
 #include <com/sun/star/container/XNamed.hpp>
 #include <com/sun/star/frame/XModel.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
@@ -157,6 +159,66 @@ bool PPTShape::IsPlaceHolderCandidate(const SlidePersist& 
rSlidePersist) const
     return ShapeHasNoVisualPropertiesOnImport(*this);
 }
 
+void PPTShape::setTextMasterStyles( const SlidePersist& rSlidePersist, const 
oox::core::XmlFilterBase& rFilterBase, const std::u16string_view& sType )
+{
+    if (!rSlidePersist.isMasterPage())
+        return;
+
+    try
+    {
+        Reference< style::XStyleFamiliesSupplier > 
aXStyleFamiliesSupplier(rFilterBase.getModel(), UNO_QUERY_THROW);
+        Reference< container::XNameAccess > 
aXNameAccess(aXStyleFamiliesSupplier->getStyleFamilies());
+        Reference< container::XNamed > aXNamed(rSlidePersist.getPage(), 
UNO_QUERY_THROW);
+
+        if (aXNameAccess.is())
+        {
+            OUString aStyle;
+            OUString aFamily;
+
+            if (sType == u"com.sun.star.presentation.TitleTextShape") // title 
style
+            {
+                aStyle = u"title"_ustr;
+                aFamily = aXNamed->getName();
+            }
+            else if (sType == u"com.sun.star.presentation.SubtitleShape") // 
subtitle
+            {
+                aStyle = u"subtitle"_ustr;
+                aFamily = aXNamed->getName();
+            }
+            else if (sType == u"com.sun.star.presentation.OutlinerShape") // 
body style
+            {
+                aStyle = u"outline1"_ustr;
+                aFamily = aXNamed->getName();
+            }
+            else if (sType == u"com.sun.star.presentation.NotesShape") // 
notes style
+            {
+                aStyle = u"title"_ustr;
+                aFamily = aXNamed->getName();
+            }
+
+            Reference< container::XNameAccess > xFamilies;
+            if (aXNameAccess->hasByName(aFamily))
+            {
+                if (aXNameAccess->getByName(aFamily) >>= xFamilies)
+                {
+                    if (xFamilies->hasByName(aStyle))
+                    {
+                        Reference< style::XStyle > aXStyle;
+                        if (xFamilies->getByName(aStyle) >>= aXStyle)
+                        {
+                            TextCharacterProperties aCharStyleProperties;
+                            getTextBody()->ApplyMasterTextStyle(rFilterBase, 
aXStyle, aCharStyleProperties, mpMasterTextListStyle);
+                        }
+                    }
+                }
+            }
+        }
+    }
+    catch (const Exception&)
+    {
+    }
+}
+
 void PPTShape::addShape(
         oox::core::XmlFilterBase& rFilterBase,
         const SlidePersist& rSlidePersist,
@@ -462,6 +524,11 @@ void PPTShape::addShape(
                     getTextBody()->ApplyStyleEmpty(rFilterBase, xText, 
aCharStyleProperties, mpMasterTextListStyle);
                 }
             }
+            // Apply text properties on master placeholder styles
+            if (meShapeLocation == Layout && getTextBody() && 
!getTextBody()->isEmpty())
+            {
+                setTextMasterStyles(rSlidePersist, rFilterBase, sServiceName);
+            }
             if (pShapeMap)
             {
                 // bnc#705982 - if optional model id reference is
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 41beb185e0c6..4f71fcd9665e 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -2092,6 +2092,50 @@ CPPUNIT_TEST_FIXTURE(SdImportTest, testTdf143603)
     CPPUNIT_ASSERT_EQUAL(size_t(0), 
pDoc->GetUndoManager()->GetUndoActionCount());
 }
 
+CPPUNIT_TEST_FIXTURE(SdImportTest, testTdf111927)
+{
+    createSdImpressDoc("pptx/tdf163239.pptx");
+
+    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);
+    {
+        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_CENTER),
+                             
xPropSet->getPropertyValue(u"ParaAdjust"_ustr).get<sal_Int16>());
+    }
+    {
+        uno::Reference<style::XStyle> 
xStyle(xStyleFamily->getByName(u"subtitle"_ustr),
+                                             uno::UNO_QUERY);
+        uno::Reference<beans::XPropertySet> xPropSet(xStyle, uno::UNO_QUERY);
+
+        CPPUNIT_ASSERT_EQUAL(32.0f, 
xPropSet->getPropertyValue(u"CharHeight"_ustr).get<float>());
+        CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_CENTER),
+                             
xPropSet->getPropertyValue(u"ParaAdjust"_ustr).get<sal_Int16>());
+    }
+    // 2nd slide
+    xStyleFamily.set(xStyleFamilies->getByName(u"simple text 
placeholder"_ustr), uno::UNO_QUERY);
+    {
+        uno::Reference<style::XStyle> 
xStyle(xStyleFamily->getByName(u"outline1"_ustr),
+                                             uno::UNO_QUERY);
+        uno::Reference<beans::XPropertySet> xPropSet(xStyle, uno::UNO_QUERY);
+
+        float nCharHeight = 
xPropSet->getPropertyValue(u"CharHeight"_ustr).get<float>();
+        CPPUNIT_ASSERT_EQUAL(60.0f, nCharHeight);
+        CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_CENTER),
+                             
xPropSet->getPropertyValue(u"ParaAdjust"_ustr).get<sal_Int16>());
+    }
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/qa/unit/import-tests2.cxx b/sd/qa/unit/import-tests2.cxx
index c0b18df3855a..c9986b17b924 100644
--- a/sd/qa/unit/import-tests2.cxx
+++ b/sd/qa/unit/import-tests2.cxx
@@ -174,18 +174,18 @@ CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf157285)
     sal_Int32 nHeight1 = xShape1->getSize().Height;
 
     // Without the fix in place, this test would have failed with
-    // Expected: placeholder height: 2795
+    // Expected: placeholder height: 2565
     // Actual  : placeholder height: 3435
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(2795), nHeight1);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(2565), nHeight1);
 
     uno::Reference<drawing::XShape> xShape2(getShapeFromPage(1, 0), 
uno::UNO_QUERY);
     CPPUNIT_ASSERT(xShape2.is());
     sal_Int32 nHeight2 = xShape2->getSize().Height;
 
     // Without the fix in place, this test would have failed with
-    // Expected: placeholder height: 1271
+    // Expected: placeholder height: 1180
     // Actual  : placeholder height: 11303
-    CPPUNIT_ASSERT_EQUAL(sal_Int32(1271), nHeight2);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1180), nHeight2);
 }
 
 CPPUNIT_TEST_FIXTURE(SdImportTest2, testTdf152186)

Reply via email to