From d794c377e503aa7d00dbc6daad0aa32efad9e682 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 8 Feb 2022 19:27:14 +0100 Subject: (related: tdf#147206) writerfilter: fix another end in... ...DomainMapper_Impl::PopFieldContext() that probably should use the m_aTextAppendStack insert position. Change-Id: I718d4b745258ca88e8ffec0bff5e5ea95037a312 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129686 Tested-by: Jenkins Reviewed-by: Michael Stahl --- writerfilter/source/dmapper/DomainMapper_Impl.cxx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'writerfilter') diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index e9f53d461deb..f1efe6614047 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -7033,13 +7033,23 @@ void DomainMapper_Impl::PopFieldContext() // End of index is the first item on a new paragraph - this paragraph // should not be part of index auto xCursor - = xTextAppend->createTextCursorByRange(xTextAppend->getEnd()); - xCursor->gotoEnd(false); + = xTextAppend->createTextCursorByRange( + m_aTextAppendStack.top().xInsertPosition.is() + ? m_aTextAppendStack.top().xInsertPosition + : xTextAppend->getEnd()); xCursor->goLeft(1, true); // delete xCursor->setString(OUString()); // But a new paragraph should be started after the index instead - xTextAppend->finishParagraph(css::beans::PropertyValues()); + if (m_bIsNewDoc) // this check - see testTdf129402 + { // where finishParagraph inserts between 2 EndNode + xTextAppend->finishParagraph(css::beans::PropertyValues()); + } + else + { + xTextAppend->finishParagraphInsert(css::beans::PropertyValues(), + m_aTextAppendStack.top().xInsertPosition); + } } m_bStartedTOC = false; m_aTextAppendStack.pop(); -- cgit