sw/qa/uibase/uiview/uiview.cxx | 37 ++++++++++++++++++++++++++++++++ sw/source/uibase/uiview/viewstat.cxx | 1 sw/uiconfig/swriter/menubar/menubar.xml | 1 3 files changed, 39 insertions(+)
New commits: commit 9c2c98ac7668e4a3a2e3a70cc54b632de5f79621 Author: Miklos Vajna <[email protected]> AuthorDate: Wed Mar 26 08:39:55 2025 +0100 Commit: Miklos Vajna <[email protected]> CommitDate: Wed Mar 26 13:53:17 2025 +0100 cool#11357 sw redline reinstate: add command state Go outside a redline with your cursor, the accept and reject UNO commands report disabled state, but reinstate is enabled all the time. This happens because SwView::GetState() handles FN_REDLINE_ACCEPT_DIRECT / FN_REDLINE_REJECT_DIRECT explicitly. Fix the problem by handling FN_REDLINE_REINSTATE_DIRECT the same way: if reject is disabled, then reinstate ("reject with history") is also OK to be disabled. With this, reinstate is mostly usable, so add it to the Edit -> Track changes menu. Change-Id: Ic534bc314f0910b1a8376cabe944bfb6f0bc6953 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183338 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins diff --git a/sw/qa/uibase/uiview/uiview.cxx b/sw/qa/uibase/uiview/uiview.cxx index 3733fcd5dc68..d7ee579fce0d 100644 --- a/sw/qa/uibase/uiview/uiview.cxx +++ b/sw/qa/uibase/uiview/uiview.cxx @@ -33,6 +33,7 @@ #include <wrtsh.hxx> #include <swmodule.hxx> #include <view.hxx> +#include <IDocumentRedlineAccess.hxx> /// Covers sw/source/uibase/uiview/ fixes. class SwUibaseUiviewTest : public SwModelTestBase @@ -403,6 +404,42 @@ CPPUNIT_TEST_FIXTURE(SwUibaseUiviewTest, testShowTextobjectbarInReadonly) bShow = xLayoutManager->isElementVisible(u"private:resource/toolbar/drawtextobjectbar"_ustr); CPPUNIT_ASSERT_EQUAL(false, bShow); // the formatting toolbar should be hidden } + +CPPUNIT_TEST_FIXTURE(SwUibaseUiviewTest, testReinstateTrackedChangeState) +{ + // Given a document with a deletion: + createSwDoc(); + SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell(); + pWrtShell->Insert("abcd"); + RedlineFlags nMode = pWrtShell->GetRedlineFlags(); + pWrtShell->SetRedlineFlags(nMode | RedlineFlags::On); + pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false); + pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/true, 2, /*bBasicCall=*/false); + pWrtShell->DelRight(); + + // When the cursor is inside a redline: + pWrtShell->SttPara(/*bSelect=*/false); + pWrtShell->Right(SwCursorSkipMode::Chars, /*bSelect=*/false, 2, /*bBasicCall=*/false); + + // Then make sure that reinstate is enabled: + SwView* pView = getSwDocShell()->GetView(); + std::unique_ptr<SfxPoolItem> pItem; + SfxItemState eState + = pView->GetViewFrame().GetBindings().QueryState(FN_REDLINE_REINSTATE_DIRECT, pItem); + CPPUNIT_ASSERT_EQUAL(SfxItemState::DEFAULT, eState); + + // When the cursor is outside a redline: + pWrtShell->SttPara(/*bSelect=*/false); + + // Then make sure that reinstate is disabled: + eState = pView->GetViewFrame().GetBindings().QueryState(FN_REDLINE_REINSTATE_DIRECT, pItem); + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 1 (DISABLED) + // - Actual : 32 (DEFAULT) + // i.e. reinstate was always enabled. + CPPUNIT_ASSERT_EQUAL(SfxItemState::DISABLED, eState); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/uiview/viewstat.cxx b/sw/source/uibase/uiview/viewstat.cxx index 0beaee887ff2..b52e9decc369 100644 --- a/sw/source/uibase/uiview/viewstat.cxx +++ b/sw/source/uibase/uiview/viewstat.cxx @@ -391,6 +391,7 @@ void SwView::GetState(SfxItemSet &rSet) break; case FN_REDLINE_ACCEPT_DIRECT: case FN_REDLINE_REJECT_DIRECT: + case FN_REDLINE_REINSTATE_DIRECT: case FN_REDLINE_ACCEPT_TONEXT: case FN_REDLINE_REJECT_TONEXT: { diff --git a/sw/uiconfig/swriter/menubar/menubar.xml b/sw/uiconfig/swriter/menubar/menubar.xml index c6c0c5a0e292..3441fd65f4aa 100644 --- a/sw/uiconfig/swriter/menubar/menubar.xml +++ b/sw/uiconfig/swriter/menubar/menubar.xml @@ -138,6 +138,7 @@ <menu:menuitem menu:id=".uno:RejectTrackedChange"/> <menu:menuitem menu:id=".uno:RejectTrackedChangeToNext"/> <menu:menuitem menu:id=".uno:RejectAllTrackedChanges"/> + <menu:menuitem menu:id=".uno:ReinstateTrackedChange"/> <menu:menuseparator/> <menu:menuitem menu:id=".uno:CommentChangeTracking"/> <menu:menuitem menu:id=".uno:ProtectTraceChangeMode"/>
