summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorMark Hung <marklh9@gmail.com>2017-12-31 21:04:59 +0800
committerMark Hung <marklh9@gmail.com>2018-01-09 13:18:41 +0100
commit7d10477aa54536aeeb190d25979234ab732c1bcf (patch)
treeb97174f7f971ea5a092df373f1c75e0452ce17e2 /editeng
parent1c1653e4d6520aa8fbe5d3dc8a94cfb9330916cf (diff)
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 <ci@libreoffice.org> Reviewed-by: Mark Hung <marklh9@gmail.com>
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/editundo.cxx4
-rw-r--r--editeng/source/editeng/impedit.hxx2
-rw-r--r--editeng/source/editeng/impedit2.cxx7
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 );