cool#11226 sw per-view redline on: add view-aware getter

Have 2 views, view 1 enables tracked changes recording by dispatching
.uno:TrackChanges, view 2 does not. The result is that this gets enabled
in both views, including the toolbar button state, insertion recording,
deletion recording.

The toolbar button state behavior was introduced in commit
d890ec2f13 (tdf#101592 sw: track changes
state is doc-specific, not view-specific, 2016-08-19), but there the
motivation was that *if* the setting is per-doc, then all views should
show the same toolbar button state.

Fix the problem by:
- improving SwDocShell::IsChangeRecording(), so it takes a hitn on what
  is the relevant view; the relevant view is the view where the state is
  updated, it may not be the current view
- using sw::DocumentRedlineManager::GetRedlineFlags() everywhere, so
  we'll have a central points for reading these flags
- extending sw::DocumentRedlineManager::GetRedlineFlags() to try to take
  the "is recording" setting from the current view (if there is such a
  view)
- improving SwEditShell::GetRedlineFlags() to pass itself to
  sw::DocumentRedlineManager::GetRedlineFlags(), so the entire chain of
  calls for the toolbar button work with the correct view

Also add tests to make sure all of uno command state, insert & delete
works. Drop the desktop/ test that is now redundant -- and testing
per-view callbacks there is harder than in sw/.

Change-Id: I6dbd826ea27facb9f8d06029efe805c637b7e080
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182423
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
This commit is contained in:
Miklos Vajna
2025-03-03 11:45:24 +01:00
parent 509b6d19d4
commit ae6d396552
13 changed files with 227 additions and 66 deletions
@@ -180,7 +180,6 @@ public:
void testBinaryCallback();
void testInput();
void testRedlineWriter();
void testTrackChanges();
void testRedlineCalc();
void testPaintPartTile();
void testPaintPartTileDifferentSchemes();
@@ -253,7 +252,6 @@ public:
CPPUNIT_TEST(testBinaryCallback);
CPPUNIT_TEST(testInput);
CPPUNIT_TEST(testRedlineWriter);
CPPUNIT_TEST(testTrackChanges);
CPPUNIT_TEST(testRedlineCalc);
CPPUNIT_TEST(testPaintPartTile);
CPPUNIT_TEST(testPaintPartTileDifferentSchemes);
@@ -1039,26 +1037,6 @@ void DesktopLOKTest::testWriterComments()
CPPUNIT_ASSERT_EQUAL(u"test"_ustr, xTextField->getPropertyValue(u"Content"_ustr).get<OUString>());
}
void DesktopLOKTest::testTrackChanges()
{
// Load a document and create two views.
LibLibreOffice_Impl aOffice;
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
pDocument->pClass->initializeForRendering(pDocument, nullptr);
pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
pDocument->pClass->createView(pDocument);
pDocument->pClass->initializeForRendering(pDocument, nullptr);
pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
Scheduler::ProcessEventsToIdle();
// Enable track changes and assert that both views get notified.
m_nTrackChanges = 0;
pDocument->pClass->postUnoCommand(pDocument, ".uno:TrackChanges", nullptr, false);
Scheduler::ProcessEventsToIdle();
// This was 1, only the active view was notified.
CPPUNIT_ASSERT_EQUAL(2, m_nTrackChanges);
}
void DesktopLOKTest::testSheetOperations()
{
LibLODocument_Impl* pDocument = loadDoc("sheets.ods");
+1 -1
View File
@@ -694,7 +694,7 @@ public:
// change recording and respective passwword protection for Writer and Calc
// slots available for Writer: FN_REDLINE_ON, FN_REDLINE_ON
// slots used for Calc: FID_CHG_RECORD, SID_CHG_PROTECT
virtual bool IsChangeRecording() const;
virtual bool IsChangeRecording(SfxViewShell* pViewShell = nullptr) const;
virtual bool HasChangeRecordProtection() const;
virtual void SetChangeRecording( bool bActivate, bool bLockAllViews = false );
virtual void SetProtectionPassword( const OUString &rPassword );
+1 -1
View File
@@ -3394,7 +3394,7 @@ void ScDocShellModificator::SetDocumentModified()
}
}
bool ScDocShell::IsChangeRecording() const
bool ScDocShell::IsChangeRecording(SfxViewShell* /*pViewShell*/) const
{
ScChangeTrack* pChangeTrack = m_pDocument->GetChangeTrack();
return pChangeTrack != nullptr;
+1 -1
View File
@@ -425,7 +425,7 @@ public:
// password protection for Calc (derived from SfxObjectShell)
// see also: FID_CHG_RECORD, SID_CHG_PROTECT
virtual bool IsChangeRecording() const override;
virtual bool IsChangeRecording(SfxViewShell* pViewShell = nullptr) const override;
virtual bool HasChangeRecordProtection() const override;
virtual void SetChangeRecording( bool bActivate, bool bLockAllViews = false ) override;
virtual void SetProtectionPassword( const OUString &rPassword ) override;
+1 -1
View File
@@ -1124,7 +1124,7 @@ void SfxObjectShell::SetInitialized_Impl( const bool i_fromInitNew )
}
bool SfxObjectShell::IsChangeRecording() const
bool SfxObjectShell::IsChangeRecording(SfxViewShell* /*pViewShell*/) const
{
// currently this function needs to be overwritten by Writer and Calc only
SAL_WARN( "sfx.doc", "function not implemented" );
+2 -1
View File
@@ -38,6 +38,7 @@ class SwPaM;
struct SwPosition;
class SwStartNode;
class SwNode;
class SwViewShell;
enum class RedlineFlags
{
@@ -99,7 +100,7 @@ public:
@returns
the currently set redline mode
*/
virtual RedlineFlags GetRedlineFlags() const = 0;
virtual RedlineFlags GetRedlineFlags(const SwViewShell* pViewShell = nullptr) const = 0;
/** Set a new redline mode.
+1 -1
View File
@@ -321,7 +321,7 @@ public:
/** passwword protection for Writer (derived from SfxObjectShell)
see also: FN_REDLINE_ON, FN_REDLINE_ON */
virtual bool IsChangeRecording() const override;
virtual bool IsChangeRecording(SfxViewShell* pViewShell = nullptr) const override;
virtual bool HasChangeRecordProtection() const override;
virtual void SetChangeRecording( bool bActivate, bool bLockAllViews = false ) override;
virtual void SetProtectionPassword( const OUString &rPassword ) override;
@@ -358,6 +358,156 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testLoadVisibleArea)
SwPageFrame* pPage3 = pPage2->GetNext()->DynCastPageFrame();
CPPUNIT_ASSERT(pPage3->IsInvalidContent());
}
std::vector<OString> FilterStateChanges(const std::vector<OString>& rChanges,
std::string_view rPrefix)
{
std::vector<OString> aRet;
for (const auto& rChange : rChanges)
{
if (rChange.startsWith(rPrefix))
{
aRet.push_back(rChange);
}
}
return aRet;
}
CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testTrackChangesPerViewEnableOne)
{
// Given a document with two views:
SwXTextDocument* pXTextDocument = createDoc();
CPPUNIT_ASSERT(pXTextDocument);
SwTestViewCallback aView1;
int nView1 = SfxLokHelper::getView();
SfxLokHelper::createView();
SwTestViewCallback aView2;
int nView2 = SfxLokHelper::getView();
// When recording changes in view1:
SfxLokHelper::setView(nView1);
aView1.m_aStateChanges.clear();
aView2.m_aStateChanges.clear();
comphelper::dispatchCommand(".uno:TrackChanges", {});
// Then make sure view1 gets a state track changes state change, but not view2:
// Filter out .uno:ModifiedStatus=true, which is not interesting here.
std::vector<OString> aRecord1 = FilterStateChanges(aView1.m_aStateChanges, ".uno:TrackChanges");
CPPUNIT_ASSERT(!aRecord1.empty());
std::vector<OString> aRecord2 = FilterStateChanges(aView2.m_aStateChanges, ".uno:TrackChanges");
CPPUNIT_ASSERT(aRecord2.empty());
// And given a reset state (both view1 and view2 recording is disabled):
comphelper::dispatchCommand(".uno:TrackChanges", {});
// When recording changes in view2:
SfxLokHelper::setView(nView2);
aView1.m_aStateChanges.clear();
aView2.m_aStateChanges.clear();
comphelper::dispatchCommand(".uno:TrackChanges", {});
// Then make sure view2 gets a state track changes state change, but not view1:
CPPUNIT_ASSERT(aView1.m_aStateChanges.empty());
CPPUNIT_ASSERT(!aView2.m_aStateChanges.empty());
}
CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testTrackChangesPerViewEnableBoth)
{
// Given a document with 2 views, view1 record changes:
SwXTextDocument* pXTextDocument = createDoc();
CPPUNIT_ASSERT(pXTextDocument);
SwTestViewCallback aView1;
int nView1 = SfxLokHelper::getView();
SwWrtShell* pWrtShell1 = pXTextDocument->GetDocShell()->GetWrtShell();
SfxLokHelper::createView();
SwTestViewCallback aView2;
int nView2 = SfxLokHelper::getView();
SwWrtShell* pWrtShell2 = pXTextDocument->GetDocShell()->GetWrtShell();
SfxLokHelper::setView(nView1);
comphelper::dispatchCommand(".uno:TrackChanges", {});
SfxLokHelper::setView(nView2);
CPPUNIT_ASSERT(pWrtShell1->GetViewOptions()->IsRedlineRecordingOn());
CPPUNIT_ASSERT(!pWrtShell2->GetViewOptions()->IsRedlineRecordingOn());
// When turning on track changes for view2:
comphelper::dispatchCommand(".uno:TrackChanges", {});
// Then make sure both views have track changes turned on:
CPPUNIT_ASSERT(pWrtShell1->GetViewOptions()->IsRedlineRecordingOn());
// Without the accompanying fix in place, this test would have failed, .uno:TrackChanges in
// view2 was ignored when view1 already tracked changes.
CPPUNIT_ASSERT(pWrtShell2->GetViewOptions()->IsRedlineRecordingOn());
}
CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testTrackChangesPerViewInsert)
{
// Given 2 views, view 1 records changes, view does not record changes:
SwXTextDocument* pXTextDocument = createDoc();
CPPUNIT_ASSERT(pXTextDocument);
SwTestViewCallback aView1;
int nView1 = SfxLokHelper::getView();
SwWrtShell* pWrtShell1 = pXTextDocument->GetDocShell()->GetWrtShell();
pWrtShell1->Insert(u"X"_ustr);
SfxLokHelper::createView();
SwTestViewCallback aView2;
int nView2 = SfxLokHelper::getView();
SwWrtShell* pWrtShell2 = pXTextDocument->GetDocShell()->GetWrtShell();
SfxLokHelper::setView(nView1);
comphelper::dispatchCommand(".uno:TrackChanges", {});
// When view 1 types:
pWrtShell1->SttEndDoc(/*bStt=*/true);
pWrtShell1->Insert(u"A"_ustr);
// Then make sure a redline is created:
CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(1), pWrtShell1->GetRedlineCount());
// When view 2 types:
SfxLokHelper::setView(nView2);
pWrtShell2->SttEndDoc(/*bStt=*/false);
pWrtShell2->Insert(u"Z"_ustr);
// Then make sure no redline is created:
// Without the accompanying fix in place, this test would have failed with:
// - Expected: 1
// - Actual : 2
// i.e. the insertion in view 2 was recorded.
CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(1), pWrtShell2->GetRedlineCount());
}
CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testTrackChangesPerViewDelete)
{
// Given 2 views, view 1 records changes, view does not record changes:
SwXTextDocument* pXTextDocument = createDoc();
CPPUNIT_ASSERT(pXTextDocument);
SwTestViewCallback aView1;
int nView1 = SfxLokHelper::getView();
SwWrtShell* pWrtShell1 = pXTextDocument->GetDocShell()->GetWrtShell();
pWrtShell1->Insert(u"test"_ustr);
SfxLokHelper::createView();
SwTestViewCallback aView2;
int nView2 = SfxLokHelper::getView();
SwWrtShell* pWrtShell2 = pXTextDocument->GetDocShell()->GetWrtShell();
SfxLokHelper::setView(nView1);
comphelper::dispatchCommand(".uno:TrackChanges", {});
// When view 1 deletes:
pWrtShell1->SttEndDoc(/*bStt=*/true);
pWrtShell1->Right(SwCursorSkipMode::Chars, /*bSelect=*/true, 1, /*bBasicCall=*/false);
pWrtShell1->DelRight();
// Then make sure a redline is created:
CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(1), pWrtShell1->GetRedlineCount());
// When view 2 deletes:
SfxLokHelper::setView(nView2);
pWrtShell2->SttEndDoc(/*bStt=*/false);
pWrtShell2->Left(SwCursorSkipMode::Chars, /*bSelect=*/true, 1, /*bBasicCall=*/false);
pWrtShell2->DelLeft();
// Then make sure no redline is created:
// Without the accompanying fix in place, this test would have failed with:
// - Expected: 1
// - Actual : 2
// i.e. the deletion in view 2 was recorded.
CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(1), pWrtShell2->GetRedlineCount());
}
}
CPPUNIT_PLUGIN_IMPLEMENT();
+51 -30
View File
@@ -1145,17 +1145,38 @@ DocumentRedlineManager::DocumentRedlineManager(SwDoc& i_rSwdoc)
{
}
RedlineFlags DocumentRedlineManager::GetRedlineFlags() const
RedlineFlags DocumentRedlineManager::GetRedlineFlags(const SwViewShell* pViewShell) const
{
return meRedlineFlags;
if (!pViewShell)
{
SwDocShell* pDocShell = m_rDoc.GetDocShell();
if (pDocShell)
{
pViewShell = pDocShell->GetWrtShell();
}
}
RedlineFlags eRedlineFlags = meRedlineFlags;
if (pViewShell)
{
// Recording can be per-view, the rest is per-document.
eRedlineFlags = eRedlineFlags & ~RedlineFlags::On;
if (pViewShell->GetViewOptions()->IsRedlineRecordingOn())
{
eRedlineFlags |= RedlineFlags::On;
}
}
return eRedlineFlags;
}
void DocumentRedlineManager::SetRedlineFlags( RedlineFlags eMode )
{
if( meRedlineFlags == eMode )
if( GetRedlineFlags() == eMode )
return;
if( (RedlineFlags::ShowMask & meRedlineFlags) != (RedlineFlags::ShowMask & eMode)
if( (RedlineFlags::ShowMask & GetRedlineFlags()) != (RedlineFlags::ShowMask & eMode)
|| !(RedlineFlags::ShowMask & eMode) )
{
bool bSaveInXMLImportFlag = m_rDoc.IsInXMLImport();
@@ -1231,27 +1252,27 @@ void DocumentRedlineManager::SetRedlineFlags( RedlineFlags eMode )
bool DocumentRedlineManager::IsRedlineOn() const
{
return IDocumentRedlineAccess::IsRedlineOn(meRedlineFlags);
return IDocumentRedlineAccess::IsRedlineOn(GetRedlineFlags());
}
bool DocumentRedlineManager::IsIgnoreRedline() const
{
return bool(RedlineFlags::Ignore & meRedlineFlags);
return bool(RedlineFlags::Ignore & GetRedlineFlags());
}
void DocumentRedlineManager::SetRedlineFlags_intern(RedlineFlags eMode)
{
SwDocShell* pDocShell = m_rDoc.GetDocShell();
SwWrtShell* pWrtShell = pDocShell ? pDocShell->GetWrtShell() : nullptr;
if (pWrtShell)
SwViewShell* pViewShell = pDocShell ? pDocShell->GetWrtShell() : nullptr;
if (pViewShell)
{
// Recording can be per-view, the rest is per-document.
auto bRedlineRecordingOn = bool(eMode & RedlineFlags::On);
SwViewOption aOpt(*pWrtShell->GetViewOptions());
SwViewOption aOpt(*pViewShell->GetViewOptions());
if (aOpt.IsRedlineRecordingOn() != bRedlineRecordingOn)
{
aOpt.SetRedlineRecordingOn(bRedlineRecordingOn);
pWrtShell->ApplyViewOptions(aOpt);
pViewShell->ApplyViewOptions(aOpt);
}
}
@@ -1331,11 +1352,11 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* pNewRedl, bool const bCall
{
CHECK_REDLINE( *this )
if (!IsRedlineOn() || IsShowOriginal(meRedlineFlags))
if (!IsRedlineOn() || IsShowOriginal(GetRedlineFlags()))
{
if( bCallDelete && RedlineType::Delete == pNewRedl->GetType() )
{
RedlineFlags eOld = meRedlineFlags;
RedlineFlags eOld = GetRedlineFlags();
// Set to NONE, so that the Delete::Redo merges the Redline data correctly!
// The ShowMode needs to be retained!
SetRedlineFlags_intern(eOld & ~RedlineFlags(RedlineFlags::On | RedlineFlags::Ignore));
@@ -1772,7 +1793,7 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* pNewRedl, bool const bCall
if( pRedl->IsOwnRedline( *pNewRedl ) &&
pRedl->CanCombine( *pNewRedl ) )
{
if( IsHideChanges( meRedlineFlags ))
if( IsHideChanges( GetRedlineFlags() ))
{
// Before we can merge, we make it visible!
// We insert temporarily so that pNew is
@@ -1820,7 +1841,7 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* pNewRedl, bool const bCall
{
// b62341295: Do not throw away redlines
// even if they are not allowed to be combined
RedlineFlags eOld = meRedlineFlags;
RedlineFlags eOld = GetRedlineFlags();
if( !( eOld & RedlineFlags::DontCombineRedlines ) &&
pRedl->IsOwnRedline( *pNewRedl ) &&
// tdf#116084 tdf#121176 don't combine anonymized deletion
@@ -1956,7 +1977,7 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* pNewRedl, bool const bCall
pRedl->PushData( *pNewRedl );
delete pNewRedl;
pNewRedl = nullptr;
if( IsHideChanges( meRedlineFlags ))
if( IsHideChanges( GetRedlineFlags() ))
{
pRedl->Hide(0, maRedlineTable.GetPos(pRedl));
}
@@ -2032,7 +2053,7 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* pNewRedl, bool const bCall
{
pRedl->PushData( *pNewRedl );
pNewRedl->SetEnd( *pRStt, pEnd );
if( IsHideChanges( meRedlineFlags ))
if( IsHideChanges( GetRedlineFlags() ))
{
maRedlineTable.Insert(pNewRedl);
pRedl->Hide(0, maRedlineTable.GetPos(pRedl));
@@ -2060,7 +2081,7 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* pNewRedl, bool const bCall
{
pRedl->PushData( *pNewRedl );
pNewRedl->SetStart( *pREnd, pStart );
if( IsHideChanges( meRedlineFlags ))
if( IsHideChanges( GetRedlineFlags() ))
{
maRedlineTable.Insert( pNewRedl );
pRedl->Hide(0, maRedlineTable.GetPos(pRedl));
@@ -2483,7 +2504,7 @@ bool DocumentRedlineManager::AppendTableRowRedline( SwTableRowRedline* pNewRedl
CHECK_REDLINE( this )
*/
if (IsRedlineOn() && !IsShowOriginal(meRedlineFlags))
if (IsRedlineOn() && !IsShowOriginal(GetRedlineFlags()))
{
// #TODO - equivalent for 'SwTableRowRedline'
/*
@@ -2500,7 +2521,7 @@ bool DocumentRedlineManager::AppendTableRowRedline( SwTableRowRedline* pNewRedl
/*
if( bCallDelete && RedlineType::Delete == pNewRedl->GetType() )
{
RedlineFlags eOld = meRedlineFlags;
RedlineFlags eOld = GetRedlineFlags();
// Set to NONE, so that the Delete::Redo merges the Redline data correctly!
// The ShowMode needs to be retained!
SetRedlineFlags_intern(eOld & ~(RedlineFlags::On | RedlineFlags::Ignore));
@@ -2525,7 +2546,7 @@ bool DocumentRedlineManager::AppendTableCellRedline( SwTableCellRedline* pNewRed
CHECK_REDLINE( this )
*/
if (IsRedlineOn() && !IsShowOriginal(meRedlineFlags))
if (IsRedlineOn() && !IsShowOriginal(GetRedlineFlags()))
{
// #TODO - equivalent for 'SwTableCellRedline'
/*
@@ -2542,7 +2563,7 @@ bool DocumentRedlineManager::AppendTableCellRedline( SwTableCellRedline* pNewRed
/*
if( bCallDelete && RedlineType::Delete == pNewRedl->GetType() )
{
RedlineFlags eOld = meRedlineFlags;
RedlineFlags eOld = GetRedlineFlags();
// Set to NONE, so that the Delete::Redo merges the Redline data correctly!
// The ShowMode needs to be retained!
SetRedlineFlags_intern(eOld & ~(RedlineFlags::On | RedlineFlags::Ignore));
@@ -2565,7 +2586,7 @@ void DocumentRedlineManager::CompressRedlines(size_t nStartIndex)
CHECK_REDLINE( *this )
void (SwRangeRedline::*pFnc)(sal_uInt16, size_t, bool) = nullptr;
RedlineFlags eShow = RedlineFlags::ShowMask & meRedlineFlags;
RedlineFlags eShow = RedlineFlags::ShowMask & GetRedlineFlags();
if( eShow == (RedlineFlags::ShowInsert | RedlineFlags::ShowDelete))
pFnc = &SwRangeRedline::Show;
else if (eShow == RedlineFlags::ShowInsert)
@@ -3175,8 +3196,8 @@ bool DocumentRedlineManager::AcceptRedline(SwRedlineTable::size_type nPos, bool
// Switch to visible in any case
if( (RedlineFlags::ShowInsert | RedlineFlags::ShowDelete) !=
(RedlineFlags::ShowMask & meRedlineFlags) )
SetRedlineFlags( RedlineFlags::ShowInsert | RedlineFlags::ShowDelete | meRedlineFlags );
(RedlineFlags::ShowMask & GetRedlineFlags()) )
SetRedlineFlags( RedlineFlags::ShowInsert | RedlineFlags::ShowDelete | GetRedlineFlags() );
SwRangeRedline* pTmp = maRedlineTable[ nPos ];
bool bAnonym = pTmp->GetRedlineData(0).IsAnonymized();
@@ -3269,8 +3290,8 @@ bool DocumentRedlineManager::AcceptRedline( const SwPaM& rPam, bool bCallDelete,
{
// Switch to visible in any case
if( (RedlineFlags::ShowInsert | RedlineFlags::ShowDelete) !=
(RedlineFlags::ShowMask & meRedlineFlags) )
SetRedlineFlags( RedlineFlags::ShowInsert | RedlineFlags::ShowDelete | meRedlineFlags );
(RedlineFlags::ShowMask & GetRedlineFlags()) )
SetRedlineFlags( RedlineFlags::ShowInsert | RedlineFlags::ShowDelete | GetRedlineFlags() );
// The Selection is only in the ContentSection. If there are Redlines
// to Non-ContentNodes before or after that, then the Selections
@@ -3465,8 +3486,8 @@ bool DocumentRedlineManager::RejectRedline(SwRedlineTable::size_type nPos,
// Switch to visible in any case
if( (RedlineFlags::ShowInsert | RedlineFlags::ShowDelete) !=
(RedlineFlags::ShowMask & meRedlineFlags) )
SetRedlineFlags( RedlineFlags::ShowInsert | RedlineFlags::ShowDelete | meRedlineFlags );
(RedlineFlags::ShowMask & GetRedlineFlags()) )
SetRedlineFlags( RedlineFlags::ShowInsert | RedlineFlags::ShowDelete | GetRedlineFlags() );
SwRangeRedline* pTmp = maRedlineTable[ nPos ];
bool bAnonym = pTmp->GetRedlineData(0).IsAnonymized();
@@ -3559,8 +3580,8 @@ bool DocumentRedlineManager::RejectRedline( const SwPaM& rPam, bool bCallDelete,
{
// Switch to visible in any case
if( (RedlineFlags::ShowInsert | RedlineFlags::ShowDelete) !=
(RedlineFlags::ShowMask & meRedlineFlags) )
SetRedlineFlags( RedlineFlags::ShowInsert | RedlineFlags::ShowDelete | meRedlineFlags );
(RedlineFlags::ShowMask & GetRedlineFlags()) )
SetRedlineFlags( RedlineFlags::ShowInsert | RedlineFlags::ShowDelete | GetRedlineFlags() );
// The Selection is only in the ContentSection. If there are Redlines
// to Non-ContentNodes before or after that, then the Selections
+1 -1
View File
@@ -26,7 +26,7 @@
RedlineFlags SwEditShell::GetRedlineFlags() const
{
return GetDoc()->getIDocumentRedlineAccess().GetRedlineFlags();
return GetDoc()->getIDocumentRedlineAccess().GetRedlineFlags(this);
}
void SwEditShell::SetRedlineFlags( RedlineFlags eMode )
@@ -34,9 +34,9 @@ public:
/**
* Replaced by SwRootFrame::IsHideRedlines() (this is model-level redline
* hiding).
* hiding) for hide/show.
*/
virtual RedlineFlags GetRedlineFlags() const override;
virtual RedlineFlags GetRedlineFlags(const SwViewShell* pViewShell = nullptr) const override;
virtual void SetRedlineFlags_intern(/*[in]*/RedlineFlags eMode) override;
+14 -3
View File
@@ -1355,11 +1355,22 @@ const ::sfx2::IXmlIdRegistry* SwDocShell::GetXmlIdRegistry() const
return m_xDoc ? &m_xDoc->GetXmlIdRegistry() : nullptr;
}
bool SwDocShell::IsChangeRecording() const
bool SwDocShell::IsChangeRecording(SfxViewShell* pViewShell) const
{
if (!m_pWrtShell)
SwWrtShell* pWrtShell = nullptr;
auto pView = dynamic_cast<SwView*>(pViewShell);
if (pView)
{
pWrtShell = pView->GetWrtShellPtr();
}
if (!pWrtShell)
{
pWrtShell = m_pWrtShell;
}
if (!pWrtShell)
return false;
return bool(m_pWrtShell->GetRedlineFlags() & RedlineFlags::On);
return bool(pWrtShell->GetRedlineFlags() & RedlineFlags::On);
}
bool SwDocShell::HasChangeRecordProtection() const
+2 -2
View File
@@ -332,7 +332,7 @@ void SwView::GetState(SfxItemSet &rSet)
}
break;
case FN_REDLINE_ON:
rSet.Put( SfxBoolItem( nWhich, GetDocShell()->IsChangeRecording() ) );
rSet.Put( SfxBoolItem( nWhich, GetDocShell()->IsChangeRecording(this) ) );
// When the view is new (e.g. on load), show the Hidden Track Changes infobar
// if Show Changes is disabled, but recording of changes is enabled
// or hidden tracked changes are there already in the document.
@@ -340,7 +340,7 @@ void SwView::GetState(SfxItemSet &rSet)
// enabled, see in sfx2.
if ( m_bForceChangesToolbar && m_pWrtShell->GetLayout()->IsHideRedlines() )
{
bool isRecording = GetDocShell()->IsChangeRecording();
bool isRecording = GetDocShell()->IsChangeRecording(this);
bool hasRecorded =
m_pWrtShell->GetDoc()->getIDocumentRedlineAccess().GetRedlineTable().size();
if ( isRecording || hasRecorded )