summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@suse.com>2012-05-14 22:32:37 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-05-15 09:25:38 +0100
commitbc5e702c54bcee479af6e0a81b72e87eaad185a3 (patch)
tree981136e24135f82640a19158fe22581b61cef916
parentRevert "sw: avoid over-using over-complicated SfxUndoManager::IsUndoEnabled" (diff)
downloadcore-bc5e702c54bcee479af6e0a81b72e87eaad185a3.tar.gz
core-bc5e702c54bcee479af6e0a81b72e87eaad185a3.zip
sw: avoid over-using over-complicated SfxUndoManager::IsUndoEnabled
(cherry picked from commit 51270f84bbeed46b3253ecfa1f8ddd408106b746) Signed-off-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/source/core/doc/doc.cxx13
1 files 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));