diff options
author | Sarper Akdemir <sarper.akdemir@collabora.com> | 2022-03-30 17:02:30 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-03-31 15:32:07 +0200 |
commit | e072e4149ffd4c07be1b6ded38e560f9cb635515 (patch) | |
tree | a352a02238ceb327a45f16ba6f28a56d52f204ef /sw | |
parent | ca6d879f765dad8471d42ec736b1f4235e5b8da4 (diff) |
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 <vmiklos@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/unoprnms.hxx | 1 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf148273_sectionBulletFormatLeak.docx | bin | 0 -> 15161 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport17.cxx | 17 | ||||
-rw-r--r-- | sw/source/core/unocore/unoobj.cxx | 9 |
4 files changed, 27 insertions, 0 deletions
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx index db77b87481c3..579e1752508a 100644 --- a/sw/inc/unoprnms.hxx +++ b/sw/inc/unoprnms.hxx @@ -502,6 +502,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 Binary files differnew file mode 100644 index 000000000000..1ebb1e8b419c --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf148273_sectionBulletFormatLeak.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx index 53e80df5a301..69591c638fcc 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx @@ -7,6 +7,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#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> @@ -456,6 +457,22 @@ DECLARE_OOXMLEXPORT_TEST(testTdf135923, "tdf135923-min.docx") CPPUNIT_ASSERT_EQUAL(COL_BLACK, getProperty<Color>(getRun(xParagraph, 2), "CharColor")); } +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 72376372fe2f..067daf3d25f4 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -2118,6 +2118,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, |