From f5ac56c9f7f54bb6603f6f1e8dba06da20f7e0a4 Mon Sep 17 00:00:00 2001 From: Georgy Litvinov Date: Sat, 15 May 2021 10:57:38 +0200 Subject: Don't remove section at the end of inserted text tdf#142157 Change-Id: Ie52721a480e0bbc76d00f0cc5c9182be6476d939 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115643 Tested-by: Michael Stahl Reviewed-by: Michael Stahl --- sw/source/filter/xml/xmlimp.cxx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'sw') diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx index 28e7e3ff9db3..5951a8e36724 100644 --- a/sw/source/filter/xml/xmlimp.cxx +++ b/sw/source/filter/xml/xmlimp.cxx @@ -755,12 +755,12 @@ void SwXMLImport::endDocument() if( pCurrNd->CanJoinNext( &pPos->nNode )) { SwTextNode* pNextNd = pPos->nNode.GetNode().GetTextNode(); - + bool endNodeFound = pDoc->GetNodes()[nNodeIdx-1]->IsEndNode(); SwNode *pLastPar = pDoc->GetNodes()[nNodeIdx -2]; if ( !pLastPar->IsTextNode() ) { pLastPar = pDoc->GetNodes()[nNodeIdx -1]; } - if ( pLastPar->IsTextNode() ) + if ( !endNodeFound && pLastPar->IsTextNode() ) { pNextNd->ChgFormatColl(pLastPar->GetTextNode()->GetTextColl()); } @@ -768,10 +768,11 @@ void SwXMLImport::endDocument() pPos->nContent.Assign( pNextNd, 0 ); pPaM->SetMark(); pPaM->DeleteMark(); pNextNd->JoinPrev(); - + // Remove line break that has been inserted by the import, - // but only if one has been inserted! - if( pNextNd->CanJoinPrev(/* &pPos->nNode*/ ) && + // but only if one has been inserted and + // no endNode found to avoid removing section + if( pNextNd->CanJoinPrev(/* &pPos->nNode*/ ) && !endNodeFound && *m_pSttNdIdx != pPos->nNode ) { pNextNd->JoinPrev(); -- cgit