sw/source/uibase/docvw/AnnotationWin2.cxx | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
New commits: commit 071e31fdb77b34ea90fbfa0e0001669500395119 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Fri Sep 25 19:54:16 2020 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Mon Sep 28 17:06:17 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 <caol...@redhat.com> Reviewed-by: Caolán McNamara <caol...@redhat.com> 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(); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits