From 7d10477aa54536aeeb190d25979234ab732c1bcf Mon Sep 17 00:00:00 2001 From: Mark Hung Date: Sun, 31 Dec 2017 21:04:59 +0800 Subject: tdf#99524 - allow backward connect paragraph to undo. When pressing backspace, two paragaphs connected. The first paragraph get the style of the second paragraph. However the ParaAttribsChanged() doesn't update Outliner's nDepth because it is not in undo. So it create incorrect undo information when user press enter later. And during undo, the nDepth isn't updated because there is a check to compare the number of paragraphs, so SetParaAttribs needs to be called after ParagraphInserted. Change-Id: I6a860514042240035cde95d64bdd1f374e05a94e Reviewed-on: https://gerrit.libreoffice.org/47226 Tested-by: Jenkins Reviewed-by: Mark Hung --- editeng/source/editeng/editundo.cxx | 4 +++- editeng/source/editeng/impedit.hxx | 2 +- editeng/source/editeng/impedit2.cxx | 7 ++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/editeng/source/editeng/editundo.cxx b/editeng/source/editeng/editundo.cxx index 6beb8617be28..13f066dafc02 100644 --- a/editeng/source/editeng/editundo.cxx +++ b/editeng/source/editeng/editundo.cxx @@ -253,7 +253,6 @@ void EditUndoConnectParas::Undo() GetEditEngine()->SetCallParaInsertedOrDeleted(false); EditPaM aPaM = GetEditEngine()->SplitContent(nNode, nSepPos); - GetEditEngine()->SetParaAttribs( nNode, aLeftParaAttribs ); GetEditEngine()->SetCallParaInsertedOrDeleted( bCall ); if (GetEditEngine()->IsCallParaInsertedOrDeleted()) @@ -262,6 +261,9 @@ void EditUndoConnectParas::Undo() GetEditEngine()->SetParaAttribs( nNode+1, aRightParaAttribs ); } + // Calling SetParaAttribs is effective only after ParagraphInserted + GetEditEngine()->SetParaAttribs( nNode, aLeftParaAttribs ); + if (GetEditEngine()->GetStyleSheetPool()) { if ( !aLeftStyleName.isEmpty() ) diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index 698f16b60f3e..30694a1e5c1d 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -543,7 +543,7 @@ private: void CursorMoved( const ContentNode* pPrevNode ); - void ParaAttribsChanged( ContentNode const * pNode ); + void ParaAttribsChanged( ContentNode const * pNode, bool bIgnoreUndoCheck = false ); void TextModified(); void CalcHeight( ParaPortion* pPortion ); diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 8f2336c21b3b..f837b2a57cac 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -731,7 +731,7 @@ void ImpEditEngine::TextModified() } -void ImpEditEngine::ParaAttribsChanged( ContentNode const * pNode ) +void ImpEditEngine::ParaAttribsChanged( ContentNode const * pNode, bool bIgnoreUndoCheck ) { assert(pNode && "ParaAttribsChanged: Which one?"); @@ -743,7 +743,8 @@ void ImpEditEngine::ParaAttribsChanged( ContentNode const * pNode ) pPortion->MarkSelectionInvalid( 0 ); sal_Int32 nPara = aEditDoc.GetPos( pNode ); - pEditEngine->ParaAttribsChanged( nPara ); + if ( bIgnoreUndoCheck || pEditEngine->IsInUndo() ) + pEditEngine->ParaAttribsChanged( nPara ); ParaPortion* pNextPortion = GetParaPortions().SafeGetObject( nPara+1 ); // => is formatted again anyway, if Invalid. @@ -2261,7 +2262,7 @@ EditPaM ImpEditEngine::ImpConnectParagraphs( ContentNode* pLeft, ContentNode* pR pLeft->GetCharAttribs().GetDefFont() = pRight->GetCharAttribs().GetDefFont(); } - ParaAttribsChanged( pLeft ); + ParaAttribsChanged( pLeft, true ); // First search for Portions since pRight is gone after ConnectParagraphs. ParaPortion* pLeftPortion = FindParaPortion( pLeft ); -- cgit v1.2.3