diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-09-25 19:54:16 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-09-28 17:06:17 +0200 |
commit | 071e31fdb77b34ea90fbfa0e0001669500395119 (patch) | |
tree | a6335847f48d6640d46af9bfa644c0996dac2eb2 /sw | |
parent | 2c771c0552bfab8d97ec5c35b363a3e4eda0b6dc (diff) |
Resolves: tdf#136985 bogus undo steps added by comment manipulation
Change-Id: I33d699375dcb1f7a9ed4d30e3f60f7161620c9a8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103546
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/uibase/docvw/AnnotationWin2.cxx | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx b/sw/source/uibase/docvw/AnnotationWin2.cxx index ef1248ae1bde..a84d0017a8f9 100644 --- a/sw/source/uibase/docvw/AnnotationWin2.cxx +++ b/sw/source/uibase/docvw/AnnotationWin2.cxx @@ -24,6 +24,7 @@ #include "SidebarWinAcc.hxx" #include <PostItMgr.hxx> #include <AnnotationWin.hxx> +#include <IDocumentUndoRedo.hxx> #include <basegfx/range/b2drange.hxx> #include "SidebarTxtControl.hxx" #include "SidebarScrollBar.hxx" @@ -1078,6 +1079,20 @@ void SwAnnotationWin::SetReadonly(bool bSet) void SwAnnotationWin::SetLanguage(const SvxLanguageItem& rNewItem) { + IDocumentUndoRedo& rUndoRedo( + mrView.GetDocShell()->GetDoc()->GetIDocumentUndoRedo()); + const bool bDocUndoEnabled = rUndoRedo.DoesUndo(); + const bool bOutlinerUndoEnabled = mpOutliner->IsUndoEnabled(); + const bool bOutlinerModified = mpOutliner->IsModified(); + const bool bDisableAndRestoreUndoMode = !bDocUndoEnabled && bOutlinerUndoEnabled; + + if (bDisableAndRestoreUndoMode) + { + // doc undo is disabled, but outliner was enabled, turn outliner undo off + // for the duration of this function + mpOutliner->EnableUndo(false); + } + Link<LinkParamNone*,void> aLink = mpOutliner->GetModifyHdl(); mpOutliner->SetModifyHdl( Link<LinkParamNone*,void>() ); ESelection aOld = GetOutlinerView()->GetSelection(); @@ -1088,6 +1103,13 @@ void SwAnnotationWin::SetLanguage(const SvxLanguageItem& rNewItem) aEditAttr.Put(rNewItem); GetOutlinerView()->SetAttribs( aEditAttr ); + if (!mpOutliner->IsUndoEnabled() && !bOutlinerModified) + { + // if undo was disabled (e.g. this is a redo action) and we were + // originally 'unmodified' keep it that way + mpOutliner->ClearModifyFlag(); + } + GetOutlinerView()->SetSelection(aOld); mpOutliner->SetModifyHdl( aLink ); @@ -1105,6 +1127,11 @@ void SwAnnotationWin::SetLanguage(const SvxLanguageItem& rNewItem) mpOutliner->SetControlWord(nCntrl); mpOutliner->CompleteOnlineSpelling(); + + // restore original mode + if (bDisableAndRestoreUndoMode) + mpOutliner->EnableUndo(true); + Invalidate(); } |