summaryrefslogtreecommitdiff
path: root/sw/inc
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2025-04-07 09:12:57 +0200
committerMiklos Vajna <vmiklos@collabora.com>2025-04-07 17:38:54 +0200
commit94e683b5e18cfa40a65d970b50f03a88ec352b60 (patch)
tree154f1ad642bb84c7eda176541ddc41c0dad873e1 /sw/inc
parenteee10ae0c83a62b39ae466e4cca433c95f9a9433 (diff)
cool#11226 sw per-view redline on: fix bad record mode change on undo
Have 2 Writer views, enable recording for "this view", type a few characters, undo. The recording is now enabled for all views, not just this view. The problem is that sw::DocumentRedlineManager::SetRedlineFlags_intern() only gets flags, so in case UndoRedoRedlineGuard sets new temporary flags & then restores those flags later, then that guard assumes that we return to the old state, but it implicitly calls SetRedlineFlags_intern() with 'bRecordAllViews = true', so the record mode changes from "this view" to "all views" at the end. Fix the problem by changing the RecordAllViews boolean to an enum and introducing a "view agnostic" mode: here we don't care too much about views, since these calls are typically just temporary, but what we care is that 1) if they enable recording, then IsRedlineOn() reports true and 2) if they set new flags & later restore the old flags, the state is unchanged. Alternatives considered: - It would be possible to just touch the model in the "view agnostic" case, but then IsRedlineOn() would still get the recording bool from the view, leading to a stack overflow: lcl_DoWithBreaks() -> sw::DocumentContentOperationsManager::DeleteAndJoinWithRedlineImpl() -> sw::DocumentRedlineManager::AppendRedline() -> sw::DocumentContentOperationsManager::DeleteAndJoin() -> lcl_DoWithBreaks() again. - It would be possible to fix this on the undo side (to query the record mode and restore that mode explicitly when restoring flags), but we have many other use-cases for setting & restoring flags: e.g. autocorrect or autoformat. Change-Id: I75697c6b5b3767ad8db899cda080be312eb6c821 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183792 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/inc')
-rw-r--r--sw/inc/IDocumentRedlineAccess.hxx5
-rw-r--r--sw/inc/docsh.hxx2
-rw-r--r--sw/inc/editsh.hxx4
3 files changed, 7 insertions, 4 deletions
diff --git a/sw/inc/IDocumentRedlineAccess.hxx b/sw/inc/IDocumentRedlineAccess.hxx
index 804678479ab1..7861a5858421 100644
--- a/sw/inc/IDocumentRedlineAccess.hxx
+++ b/sw/inc/IDocumentRedlineAccess.hxx
@@ -28,6 +28,7 @@
#include <com/sun/star/uno/Sequence.h>
#include <o3tl/typed_flags_set.hxx>
#include <svx/ctredlin.hxx>
+#include <sfx2/redlinerecordingmode.hxx>
#include "docary.hxx"
@@ -107,14 +108,14 @@ public:
@param eMode
[in] the new redline mode.
*/
- virtual void SetRedlineFlags_intern(/*[in]*/RedlineFlags eMode, bool bRecordAllViews = true, bool bRecordModeChange = false) = 0;
+ virtual void SetRedlineFlags_intern(/*[in]*/RedlineFlags eMode, SfxRedlineRecordingMode eRedlineRecordingMode = SfxRedlineRecordingMode::ViewAgnostic, bool bRecordModeChange = false) = 0;
/** Set a new redline mode.
@param eMode
[in] the new redline mode.
*/
- virtual void SetRedlineFlags(/*[in]*/RedlineFlags eMode, bool bRecordAllViews = true, bool bRecordModeChange = false) = 0;
+ virtual void SetRedlineFlags(/*[in]*/RedlineFlags eMode, SfxRedlineRecordingMode eRedlineRecordingMode = SfxRedlineRecordingMode::ViewAgnostic, bool bRecordModeChange = false) = 0;
/** Query if redlining is on.
diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx
index d67471627c5c..767234155d5f 100644
--- a/sw/inc/docsh.hxx
+++ b/sw/inc/docsh.hxx
@@ -323,7 +323,7 @@ public:
see also: FN_REDLINE_ON, FN_REDLINE_ON */
virtual bool IsChangeRecording(SfxViewShell* pViewShell = nullptr, bool bRecordAllViews = true) const override;
virtual bool HasChangeRecordProtection() const override;
- virtual void SetChangeRecording( bool bActivate, bool bLockAllViews = false, bool bRecordAllViews = true ) override;
+ virtual void SetChangeRecording( bool bActivate, bool bLockAllViews = false, SfxRedlineRecordingMode eRedlineRecordingMode = SfxRedlineRecordingMode::ViewAgnostic) override;
virtual void SetProtectionPassword( const OUString &rPassword ) override;
virtual bool GetProtectionHash( /*out*/ css::uno::Sequence< sal_Int8 > &rPasswordHash ) override;
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index 00ed2ad9dacf..3568be169fad 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -19,6 +19,8 @@
#ifndef INCLUDED_SW_INC_EDITSH_HXX
#define INCLUDED_SW_INC_EDITSH_HXX
+#include <sfx2/redlinerecordingmode.hxx>
+
#include "crsrsh.hxx"
#include "charfmt.hxx"
@@ -953,7 +955,7 @@ public:
/// For Redlining.
SW_DLLPUBLIC RedlineFlags GetRedlineFlags() const;
- SW_DLLPUBLIC void SetRedlineFlags( RedlineFlags eMode, bool bRecordAllViews = true );
+ SW_DLLPUBLIC void SetRedlineFlags( RedlineFlags eMode, SfxRedlineRecordingMode eRedlineRecordingMode = SfxRedlineRecordingMode::ViewAgnostic );
bool IsRedlineOn() const;
SW_DLLPUBLIC SwRedlineTable::size_type GetRedlineCount() const;
const SwRangeRedline& GetRedline( SwRedlineTable::size_type nPos ) const;