From e072e4149ffd4c07be1b6ded38e560f9cb635515 Mon Sep 17 00:00:00 2001 From: Sarper Akdemir Date: Wed, 30 Mar 2022 17:02:30 +0300 Subject: [PATCH] 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 --- 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/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, diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index f261538a0f19..22f2be927f8d 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -3789,10 +3789,10 @@ void DomainMapper::lcl_utext(const sal_uInt8 * data_, size_t len) static_cast(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 f8700faee88c..e3d6f4c41952 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -717,6 +717,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 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()) -- 2.34.1