sw/inc/unoprnms.hxx                                                  |    1 
 sw/qa/extras/ooxmlexport/data/tdf148273_sectionBulletFormatLeak.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport17.cxx                           |   17 
++++++++++
 sw/source/core/unocore/unoobj.cxx                                    |    9 
+++++
 writerfilter/source/dmapper/DomainMapper.cxx                         |    2 -
 writerfilter/source/dmapper/DomainMapper_Impl.cxx                    |    8 
++++
 6 files changed, 36 insertions(+), 1 deletion(-)

New commits:
commit 87c1615c1f6525c3f0e0d16dd98269744d21d183
Author:     Sarper Akdemir <sarper.akde...@collabora.com>
AuthorDate: Wed Mar 30 17:02:30 2022 +0300
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Sun Apr 3 17:33:46 2022 +0200

    tdf#148273 docx import: fix section break format leak to bullets
    
    Fixes RES_PARATR_LIST_AUTOFMT leaking into the next section.
    
    Achieves this by resetting list related attributes on the cursor's
    text node in DomainMapper_Impl::RemoveLastParagraph() after the
    deletion of the paragraph.
    
    Change-Id: Ib4d09c5f190b8b8fd3bdc119ddd57d91f353de2f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132324
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132440
    Reviewed-by: Andras Timar <andras.ti...@collabora.com>

diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index 7ef5d0a58cd7..b9dbdc40e9fa 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -500,6 +500,7 @@
 #define UNO_NAME_SEPARATOR_LINE_IS_ON "SeparatorLineIsOn"
 #define UNO_NAME_IS_SKIP_HIDDEN_TEXT "IsSkipHiddenText"
 #define UNO_NAME_IS_SKIP_PROTECTED_TEXT "IsSkipProtectedText"
+#define UNO_NAME_RESET_PARAGRAPH_LIST_ATTRIBUTES "ResetParagraphListAttributes"
 #define UNO_NAME_DOCUMENT_INDEX_MARKS "DocumentIndexMarks"
 #define UNO_NAME_FOOTNOTE_IS_COLLECT_AT_TEXT_END "FootnoteIsCollectAtTextEnd"
 #define UNO_NAME_FOOTNOTE_IS_RESTART_NUMBERING "FootnoteIsRestartNumbering"
diff --git 
a/sw/qa/extras/ooxmlexport/data/tdf148273_sectionBulletFormatLeak.docx 
b/sw/qa/extras/ooxmlexport/data/tdf148273_sectionBulletFormatLeak.docx
new file mode 100644
index 000000000000..1ebb1e8b419c
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf148273_sectionBulletFormatLeak.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index f23721767fc9..370989a9d6b7 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -11,6 +11,7 @@
 
 #include <string_view>
 
+#include <com/sun/star/beans/NamedValue.hpp>
 #include <com/sun/star/text/XBookmarksSupplier.hpp>
 #include <com/sun/star/text/XTextFieldsSupplier.hpp>
 #include <com/sun/star/text/XTextField.hpp>
@@ -282,6 +283,22 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf147978enhancedPathABVW)
     }
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf148273_sectionBulletFormatLeak, 
"tdf148273_sectionBulletFormatLeak.docx")
+{
+    // get a paragraph with bullet point after section break
+    uno::Reference<text::XTextRange> xParagraph = getParagraph(4);
+    uno::Reference<beans::XPropertySet> xProps(xParagraph, uno::UNO_QUERY);
+
+    // Make sure that the bullet has no ListAutoFormat inherited from
+    // the empty paragraph before the section break
+    // Without the accompanying fix in place, this test would have failed with:
+    // - Expected: 0
+    // - Actual  : 1
+    // i.e. empty paragraph formats from the first section leaked to the 
bullet's formatting
+    uno::Any aValue = xProps->getPropertyValue("ListAutoFormat");
+    CPPUNIT_ASSERT_EQUAL(false, aValue.hasValue());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/unocore/unoobj.cxx 
b/sw/source/core/unocore/unoobj.cxx
index b26acac97282..09136cf44c8c 100644
--- a/sw/source/core/unocore/unoobj.cxx
+++ b/sw/source/core/unocore/unoobj.cxx
@@ -2087,6 +2087,15 @@ SwXTextCursor::setPropertyValue(
         }
         rUnoCursor.SetSkipOverProtectSections(bSet);
     }
+    else if (rPropertyName == UNO_NAME_RESET_PARAGRAPH_LIST_ATTRIBUTES)
+    {
+        SwTextNode* pTextNode= GetPaM()->GetNode().GetTextNode();
+
+        if(pTextNode)
+        {
+            pTextNode->ResetAttr(RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END);
+        }
+    }
     else
     {
         SwUnoCursorHelper::SetPropertyValue(rUnoCursor,
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index ffa829351baa..691e876d4859 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3768,10 +3768,10 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, 
size_t len)
                 
static_cast<ParagraphPropertyMap*>(xContext.get())->SetListId(-1);;
                 xContext->Erase(PROP_NUMBERING_LEVEL);
             }
-            m_pImpl->SetParaSectpr(false);
             finishParagraph(bRemove, bNoNumbering);
             if (bRemove)
                 m_pImpl->RemoveLastParagraph();
+            m_pImpl->SetParaSectpr(false);
         }
         else
         {
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 8afcede51d13..7eb9964e36a4 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -716,6 +716,14 @@ void DomainMapper_Impl::RemoveLastParagraph( )
                 // delete
                 xCursor->setString(OUString());
 
+                // While removing paragraphs that contain section properties, 
reset list
+                // related attributes to prevent them leaking into the 
following section's lists
+                if (GetParaSectpr())
+                {
+                    uno::Reference<beans::XPropertySet> XCursorProps(xCursor, 
uno::UNO_QUERY);
+                    
XCursorProps->setPropertyValue("ResetParagraphListAttributes", uno::Any());
+                }
+
                 // call to xCursor->setString possibly did remove final 
bookmark
                 // from previous paragraph. We need to restore it, if there 
was any.
                 if (sLastBookmarkName.getLength())

Reply via email to