sw/qa/extras/ooxmlexport/data/tdf166553_paraStyleAfterBreak.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport22.cxx                       |   22 
++++++++++
 sw/source/writerfilter/dmapper/DomainMapper.cxx                  |   13 ++++-
 3 files changed, 32 insertions(+), 3 deletions(-)

New commits:
commit eafbbc41049045a89cdb86710a37553aeb8eba7b
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Tue Jul 29 18:50:42 2025 -0400
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Wed Jul 30 21:09:36 2025 +0200

    tdf#166553 writerfilter: don't force para style when IsSplitPara
    
    This patch fixes an old problem that now is more exposed
    due to 25.8's commit a993c7849f0cc43c05ea8a505e38b44badc7539c
    
    Of course when a new paragraph is started,
    the paragraph style needs to be reset to the default one.
    
    However, in the emulation case when we are forcefully splitting
    a single paragraph into two,
    then don't reset the current paragraph style.
    
    make CppunitTest_sw_ooxmlexport22 \
        CPPUNIT_TEST_NAME=testTdf166553_paraStyleAfterBreak
    
    Change-Id: Iff6582d533cef2f1d815b3e7378e93880af9622b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188566
    Reviewed-by: Justin Luth <jl...@mail.com>
    Tested-by: Jenkins

diff --git a/sw/qa/extras/ooxmlexport/data/tdf166553_paraStyleAfterBreak.docx 
b/sw/qa/extras/ooxmlexport/data/tdf166553_paraStyleAfterBreak.docx
new file mode 100644
index 000000000000..821edb9c4e81
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf166553_paraStyleAfterBreak.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx
index 76d9d0af8a30..7b9cee2d517a 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx
@@ -9,6 +9,7 @@
 
 #include <swmodeltestbase.hxx>
 
+#include <com/sun/star/awt/FontWeight.hpp>
 #include <com/sun/star/beans/XPropertyState.hpp>
 
 #include <comphelper/configuration.hxx>
@@ -186,6 +187,27 @@ CPPUNIT_TEST_FIXTURE(Test, 
testTdf165047_contextualSpacingTopMargin)
     CPPUNIT_ASSERT_EQUAL(static_cast<SwTwips>(0), nParaTopMargin);
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf166553_paraStyleAfterBreak)
+{
+    // Given a distinctively styled paragraph containing a (column) break in 
the middle of the para
+    createSwDoc("tdf166553_paraStyleAfterBreak.docx");
+    saveAndReload(mpFilter);
+
+    // Note: we emulate this by creating two real paragraphs.
+    // The paragraph style/formatting after the break must be (almost) the 
same as before the break
+    uno::Reference<text::XTextRange> xPara
+        = getParagraph(2, "A paragraph with a large 75pt top margin, split");
+    CPPUNIT_ASSERT_EQUAL(u"Subtitle"_ustr, getProperty<OUString>(xPara, 
u"ParaStyleName"_ustr));
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(2646), getProperty<sal_Int32>(xPara, 
u"ParaTopMargin"_ustr));
+
+    xPara.set(getParagraph(3, " by a column break")); // after the break
+    CPPUNIT_ASSERT_EQUAL(u"Subtitle"_ustr, getProperty<OUString>(xPara, 
u"ParaStyleName"_ustr));
+    // The top margin ONLY applies at the beginning of the paragraph (i.e. 
before the break)
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPara, 
u"ParaTopMargin"_ustr));
+    xPara.set(getRun(getParagraph(3), 1));
+    CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(xPara, 
u"CharWeight"_ustr));
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf83844)
 {
     createSwDoc("tdf83844.fodt");
diff --git a/sw/source/writerfilter/dmapper/DomainMapper.cxx 
b/sw/source/writerfilter/dmapper/DomainMapper.cxx
index e3d5655b33c3..ba397f7a9cec 100644
--- a/sw/source/writerfilter/dmapper/DomainMapper.cxx
+++ b/sw/source/writerfilter/dmapper/DomainMapper.cxx
@@ -3887,6 +3887,9 @@ void DomainMapper::lcl_startParagraphGroup()
 {
     if (m_pImpl->hasTableManager())
         m_pImpl->getTableManager().startParagraphGroup();
+
+    const bool bIsSplitPara = m_pImpl->m_bIsSplitPara; // preserve flag reset 
by PushProperties
+
     /*
      * Add new para properties only if paragraph is not split
      * or the top context is not of paragraph properties
@@ -3902,10 +3905,14 @@ void DomainMapper::lcl_startParagraphGroup()
     {
         if (m_pImpl->GetTopContext())
         {
-            const OUString sDefaultParaStyle = 
m_pImpl->GetDefaultParaStyleName();
             auto pContext = 
static_cast<ParagraphPropertyMap*>(m_pImpl->GetTopContext().get());
-            m_pImpl->GetTopContext()->Insert( PROP_PARA_STYLE_NAME, uno::Any( 
sDefaultParaStyle ) );
-            m_pImpl->SetCurrentParaStyleName( sDefaultParaStyle );
+
+            if (!bIsSplitPara)
+            {
+                const OUString sDefaultParaStyle = 
m_pImpl->GetDefaultParaStyleName();
+                m_pImpl->GetTopContext()->Insert(PROP_PARA_STYLE_NAME, 
uno::Any(sDefaultParaStyle));
+                m_pImpl->SetCurrentParaStyleName(sDefaultParaStyle);
+            }
 
             if (m_pImpl->isBreakDeferred(PAGE_BREAK))
             {

Reply via email to