sw/inc/IDocumentRedlineAccess.hxx | 2 - sw/source/core/doc/DocumentRedlineManager.cxx | 32 ++++++++++++++++++-------- sw/source/core/edit/edredln.cxx | 11 -------- sw/source/uibase/uiview/view.cxx | 4 +++ 4 files changed, 28 insertions(+), 21 deletions(-)
New commits: commit e36643877e5ddf57a34481f1c46f87cf250caf19 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Thu Feb 27 13:19:10 2025 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Thu Feb 27 15:45:29 2025 +0100 cool#11226 sw per-view redline on: move the setter to the model Open e.g. an RTF file with evisions in it (enable track changes recording), notice that track changes is not enabled, when the UI would take the "redline on" setting from the view. Commit 025a1e4612fecf59f38910fbf52fc63db054ae5f (cool#11226 sw per-view redline on: add new flag in SwViewOption, 2025-02-26) added the per-view "is record" setter to SwEditShell, but I missed that this setting can be also set by an import filter, which works on an SwDoc with no view. Fix this problem by: - remove the setter from SwEditShell::SetRedlineFlags(), we'll do this in the model instead - use sw::DocumentRedlineManager::SetRedlineFlags_intern() everywhere, so we have a central point where the current view (if there is any) can be updated together with the model - implement the model -> current view synchronization in sw::DocumentRedlineManager::SetRedlineFlags_intern() - extend the the SwView ctor, so the setting of the view is not the default, but it's based on the model Also make it explicit that RedlineFlags::Ignore is not something a user may set. With this rearrangement, implementing a getter (that takes the view into account) looks possible, but is not yet done in this commit. Change-Id: Ifc0c3bbb95539cc1a26582ee7d27653899fbc236 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182304 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/inc/IDocumentRedlineAccess.hxx b/sw/inc/IDocumentRedlineAccess.hxx index 264c23e29895..eeb793530337 100644 --- a/sw/inc/IDocumentRedlineAccess.hxx +++ b/sw/inc/IDocumentRedlineAccess.hxx @@ -43,7 +43,7 @@ enum class RedlineFlags { NONE = 0x000, ///< no RedlineFlags On = 0x001, ///< RedlineFlags on - Ignore = 0x002, ///< ignore Redlines + Ignore = 0x002, ///< ignore Redlines (only set from code, temporarily) ShowInsert = 0x010, ///< show all inserts ShowDelete = 0x020, ///< show all deletes ShowMask = ShowInsert | ShowDelete, diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index 1b658826db39..6763d2ba1ece 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -1223,7 +1223,7 @@ void DocumentRedlineManager::SetRedlineFlags( RedlineFlags eMode ) m_rDoc.SetInXMLImport( bSaveInXMLImportFlag ); } - meRedlineFlags = eMode; + SetRedlineFlags_intern(eMode); m_rDoc.getIDocumentState().SetModified(); // #TODO - add 'SwExtraRedlineTable' also ? @@ -1241,6 +1241,20 @@ bool DocumentRedlineManager::IsIgnoreRedline() const void DocumentRedlineManager::SetRedlineFlags_intern(RedlineFlags eMode) { + SwDocShell* pDocShell = m_rDoc.GetDocShell(); + SwWrtShell* pWrtShell = pDocShell ? pDocShell->GetWrtShell() : nullptr; + if (pWrtShell) + { + // Recording can be per-view, the rest is per-document. + auto bRedlineRecordingOn = bool(eMode & RedlineFlags::On); + SwViewOption aOpt(*pWrtShell->GetViewOptions()); + if (aOpt.IsRedlineRecordingOn() != bRedlineRecordingOn) + { + aOpt.SetRedlineRecordingOn(bRedlineRecordingOn); + pWrtShell->ApplyViewOptions(aOpt); + } + } + meRedlineFlags = eMode; } @@ -1324,9 +1338,9 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* pNewRedl, bool const bCall RedlineFlags eOld = meRedlineFlags; // Set to NONE, so that the Delete::Redo merges the Redline data correctly! // The ShowMode needs to be retained! - meRedlineFlags = eOld & ~RedlineFlags(RedlineFlags::On | RedlineFlags::Ignore); + SetRedlineFlags_intern(eOld & ~RedlineFlags(RedlineFlags::On | RedlineFlags::Ignore)); m_rDoc.getIDocumentContentOperations().DeleteAndJoin( *pNewRedl ); - meRedlineFlags = eOld; + SetRedlineFlags_intern(eOld); } delete pNewRedl; pNewRedl = nullptr; @@ -1826,7 +1840,7 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* pNewRedl, bool const bCall // Set to NONE, so that the Delete::Redo merges the Redline data correctly! // The ShowMode needs to be retained! - meRedlineFlags = eOld & ~RedlineFlags(RedlineFlags::On | RedlineFlags::Ignore); + SetRedlineFlags_intern(eOld & ~RedlineFlags(RedlineFlags::On | RedlineFlags::Ignore)); switch( eCmpPos ) { case SwComparePosition::Equal: @@ -1925,7 +1939,7 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* pNewRedl, bool const bCall break; } - meRedlineFlags = eOld; + SetRedlineFlags_intern(eOld); } else { @@ -2489,9 +2503,9 @@ bool DocumentRedlineManager::AppendTableRowRedline( SwTableRowRedline* pNewRedl RedlineFlags eOld = meRedlineFlags; // Set to NONE, so that the Delete::Redo merges the Redline data correctly! // The ShowMode needs to be retained! - meRedlineFlags = eOld & ~(RedlineFlags::On | RedlineFlags::Ignore); + SetRedlineFlags_intern(eOld & ~(RedlineFlags::On | RedlineFlags::Ignore)); DeleteAndJoin( *pNewRedl ); - meRedlineFlags = eOld; + SetRedlineFlags_intern(eOld); } delete pNewRedl, pNewRedl = 0; */ @@ -2531,9 +2545,9 @@ bool DocumentRedlineManager::AppendTableCellRedline( SwTableCellRedline* pNewRed RedlineFlags eOld = meRedlineFlags; // Set to NONE, so that the Delete::Redo merges the Redline data correctly! // The ShowMode needs to be retained! - meRedlineFlags = eOld & ~(RedlineFlags::On | RedlineFlags::Ignore); + SetRedlineFlags_intern(eOld & ~(RedlineFlags::On | RedlineFlags::Ignore)); DeleteAndJoin( *pNewRedl ); - meRedlineFlags = eOld; + SetRedlineFlags_intern(eOld); } delete pNewRedl, pNewRedl = 0; */ diff --git a/sw/source/core/edit/edredln.cxx b/sw/source/core/edit/edredln.cxx index 9eff073c09b6..1778745f57e4 100644 --- a/sw/source/core/edit/edredln.cxx +++ b/sw/source/core/edit/edredln.cxx @@ -22,7 +22,6 @@ #include <redline.hxx> #include <doc.hxx> #include <editsh.hxx> -#include <viewopt.hxx> #include <frmtool.hxx> RedlineFlags SwEditShell::GetRedlineFlags() const @@ -36,16 +35,6 @@ void SwEditShell::SetRedlineFlags( RedlineFlags eMode ) { CurrShell aCurr( this ); StartAllAction(); - - // Recording is per-view, the rest if per-document. - auto bRedlineRecordingOn = bool(eMode & RedlineFlags::On); - SwViewOption aOpt(*GetViewOptions()); - if (aOpt.IsRedlineRecordingOn() != bRedlineRecordingOn) - { - aOpt.SetRedlineRecordingOn(bRedlineRecordingOn); - ApplyViewOptions(aOpt); - } - GetDoc()->getIDocumentRedlineAccess().SetRedlineFlags( eMode ); EndAllAction(); } diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx index dc3a12d21a7a..ef116f50f38a 100644 --- a/sw/source/uibase/uiview/view.cxx +++ b/sw/source/uibase/uiview/view.cxx @@ -121,6 +121,7 @@ #include <svx/svdview.hxx> #include <node2lay.hxx> #include <cntfrm.hxx> +#include <IDocumentRedlineAccess.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -881,6 +882,9 @@ SwView::SwView(SfxViewFrame& _rFrame, SfxViewShell* pOldSh) SvtLinguConfig().GetOptions( aLinguOpt ); aUsrPref.SetOnlineSpell( aLinguOpt.bIsSpellAuto ); + // Inherit the per-view setting from the per-document one. + aUsrPref.SetRedlineRecordingOn(rDocSh.GetDoc()->getIDocumentRedlineAccess().IsRedlineOn()); + bool bOldShellWasSrcView = false; // determine if there is an existing view for