From bc5e702c54bcee479af6e0a81b72e87eaad185a3 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Mon, 14 May 2012 22:32:37 +0100 Subject: sw: avoid over-using over-complicated SfxUndoManager::IsUndoEnabled (cherry picked from commit 51270f84bbeed46b3253ecfa1f8ddd408106b746) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Caolán McNamara --- sw/source/core/doc/doc.cxx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 5a2f44cfa467..635d73ed763a 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -870,10 +870,10 @@ bool SwDoc::AppendTxtNode( SwPosition& rPos ) bool SwDoc::InsertString( const SwPaM &rRg, const String &rStr, const enum InsertFlags nInsertMode ) { - if (GetIDocumentUndoRedo().DoesUndo()) - { + // fetching DoesUndo is surprisingly expensive + bool bDoesUndo = GetIDocumentUndoRedo().DoesUndo(); + if (bDoesUndo) GetIDocumentUndoRedo().ClearRedo(); // AppendUndo not always called! - } const SwPosition& rPos = *rRg.GetPoint(); @@ -888,18 +888,15 @@ bool SwDoc::InsertString( const SwPaM &rRg, const String &rStr, SwTxtNode *const pNode = rPos.nNode.GetNode().GetTxtNode(); if(!pNode) - { return false; - } SwDataChanged aTmp( rRg, 0 ); - if (!GetIDocumentUndoRedo().DoesUndo() || - !GetIDocumentUndoRedo().DoesGroupUndo()) + if (!bDoesUndo || !GetIDocumentUndoRedo().DoesGroupUndo()) { pNode->InsertText( rStr, rPos.nContent, nInsertMode ); - if (GetIDocumentUndoRedo().DoesUndo()) + if (bDoesUndo) { SwUndoInsert * const pUndo( new SwUndoInsert( rPos.nNode, rPos.nContent.GetIndex(), rStr.Len(), nInsertMode)); -- cgit