sw/qa/writerfilter/dmapper/DomainMapper_Impl.cxx | 23 +++++++++++++ sw/qa/writerfilter/dmapper/data/redline-range-comment.docx |binary sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx | 2 - 3 files changed, 24 insertions(+), 1 deletion(-)
New commits: commit 2b5bada07bcd096cea5517d2c931cc8c7bf21e47 Author: Miklos Vajna <[email protected]> AuthorDate: Fri Jan 23 09:31:05 2026 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Fri Jan 23 17:06:19 2026 +0100 cool#13988 DOCX import: fix missing delete flag on deleted comments with ranges The bugdoc has commented text range inside a deletion. The import result doesn't mark the comment as deleted. Comments with a single anchor point work fine, since commit 419b70b5d4db227509614bdea5b4b89bcf7a6032 (tdf#105485 DOCX: import deleted comments as deleted, 2019-08-26). Fix the problem by invoking CheckRedline() in DomainMapper_Impl::PopAnnotation() in the range case as well, that correctly creates the delete redline for the comment anchor. This is shared code for any redlines, so fixes inserts, too. Change-Id: I620e1419cee79ab729ea7be248f1ad079a9fc536 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197914 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Caolán McNamara <[email protected]> diff --git a/sw/qa/writerfilter/dmapper/DomainMapper_Impl.cxx b/sw/qa/writerfilter/dmapper/DomainMapper_Impl.cxx index ddefd9e2faa0..a79421ce0674 100644 --- a/sw/qa/writerfilter/dmapper/DomainMapper_Impl.cxx +++ b/sw/qa/writerfilter/dmapper/DomainMapper_Impl.cxx @@ -29,6 +29,8 @@ #include <ndtxt.hxx> #include <swtable.hxx> #include <txatbase.hxx> +#include <wrtsh.hxx> +#include <IDocumentRedlineAccess.hxx> using namespace ::com::sun::star; @@ -516,6 +518,27 @@ CPPUNIT_TEST_FIXTURE(Test, testFieldCharHeightHeaderToC) = rAutoFormat.GetStyleHandle()->Get(RES_CHRATR_FONTSIZE); CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(480), rFontHeightItem.GetHeight()); } + +CPPUNIT_TEST_FIXTURE(Test, testAnnotationMarkRedline) +{ + // Given a document with a commented text range, inside a redline: + // When importing that document: + createSwDoc("redline-range-comment.docx"); + + // Then make sure the comment anchor is inside a redline: + SwDocShell* pDocShell = getSwDocShell(); + SwWrtShell* pWrtShell = pDocShell->GetWrtShell(); + pWrtShell->SttEndDoc(/*bStt=*/true); + pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 7, /*bBasicCall=*/false); + SwPaM* pCursor = pWrtShell->GetCursor(); + SwField* pField = SwCursorShell::GetFieldAtCursor(pCursor, true); + CPPUNIT_ASSERT_EQUAL(SwFieldIds::Postit, pField->Which()); + const IDocumentRedlineAccess& rIDRA = pDocShell->GetDoc()->getIDocumentRedlineAccess(); + const SwRangeRedline* pRedline = rIDRA.GetRedline(*pCursor->Start(), nullptr); + // Without the accompanying fix in place, this test would have failed, the anchor point was not + // inside a redline. + CPPUNIT_ASSERT(pRedline); +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/writerfilter/dmapper/data/redline-range-comment.docx b/sw/qa/writerfilter/dmapper/data/redline-range-comment.docx new file mode 100644 index 000000000000..1110971401f5 Binary files /dev/null and b/sw/qa/writerfilter/dmapper/data/redline-range-comment.docx differ diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx index 76517ee98357..3d5111cd0361 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx @@ -4659,7 +4659,6 @@ void DomainMapper_Impl::PopAnnotation() { uno::Sequence< beans::PropertyValue > aEmptyProperties; appendTextContent( m_xAnnotationField, aEmptyProperties ); - CheckRedline( m_xAnnotationField->getAnchor( ) ); } else { @@ -4721,6 +4720,7 @@ void DomainMapper_Impl::PopAnnotation() xCursor->setString(OUString()); } } + CheckRedline(m_xAnnotationField->getAnchor()); m_aAnnotationPositions.erase( m_nAnnotationId ); } catch (uno::Exception const&)
