writerfilter/source/dmapper/DomainMapper_Impl.cxx |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

New commits:
commit d794c377e503aa7d00dbc6daad0aa32efad9e682
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Tue Feb 8 19:27:14 2022 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Wed Feb 9 14:11:30 2022 +0100

    (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 <michael.st...@allotropia.de>

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();

Reply via email to