[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - sw/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Tue Sep 29 10:03:45 UTC 2020
sw/source/uibase/docvw/AnnotationWin2.cxx | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
New commits:
commit 45096d16b82678873964802fd21922368a25296d
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Sep 25 19:54:16 2020 +0100
Commit: Michael Stahl <michael.stahl at cib.de>
CommitDate: Tue Sep 29 12:03:11 2020 +0200
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 at redhat.com>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
(cherry picked from commit 071e31fdb77b34ea90fbfa0e0001669500395119)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103444
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl at cib.de>
diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx b/sw/source/uibase/docvw/AnnotationWin2.cxx
index f74ff69fdb25..f3734704e1ed 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"
@@ -1074,6 +1075,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();
@@ -1084,6 +1099,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 );
@@ -1101,6 +1123,11 @@ void SwAnnotationWin::SetLanguage(const SvxLanguageItem& rNewItem)
mpOutliner->SetControlWord(nCntrl);
mpOutliner->CompleteOnlineSpelling();
+
+ // restore original mode
+ if (bDisableAndRestoreUndoMode)
+ mpOutliner->EnableUndo(true);
+
Invalidate();
}
More information about the Libreoffice-commits
mailing list