Related: cool#11226 sw per-view redline on: fix ratio buttons of is-show
Redline recording is now per-view, but it would be even better to have
UI where the user can decide how to record (don't record, record
per-view, record in all views).
While looking for an example to follow, I noticed that the redline show
UI is similar, but the radio buttons always have a false state. Turns
out simily the command state wasn't implemented in commit
6aeeef8807 (tdf#116757 sw ChangesInMargin:
add "Show Insertions in Margin", 2021-01-20), add this.
Change-Id: Ie50c13c45c4e53fbfbb6befa36b6a29be084f2d8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182427
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
This commit is contained in:
@@ -14,6 +14,7 @@ $(eval $(call gb_CppunitTest_CppunitTest,sw_uibase_shells))
|
||||
$(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_uibase_shells))
|
||||
|
||||
$(eval $(call gb_CppunitTest_add_exception_objects,sw_uibase_shells, \
|
||||
sw/qa/uibase/shells/basesh \
|
||||
sw/qa/uibase/shells/textfld \
|
||||
sw/qa/uibase/shells/textsh \
|
||||
sw/qa/uibase/shells/textsh1 \
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This file is part of the LibreOffice project.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include <swmodeltestbase.hxx>
|
||||
|
||||
#include <sfx2/dispatch.hxx>
|
||||
#include <sfx2/viewfrm.hxx>
|
||||
|
||||
#include <cmdid.h>
|
||||
#include <view.hxx>
|
||||
#include <docsh.hxx>
|
||||
|
||||
namespace
|
||||
{
|
||||
/// Covers sw/source/uibase/shells/basesh.hxx fixes.
|
||||
class Test : public SwModelTestBase
|
||||
{
|
||||
public:
|
||||
Test()
|
||||
: SwModelTestBase("/sw/qa/uibase/shells/data/")
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(Test, testShowChangesStatus)
|
||||
{
|
||||
// Given an empty document:
|
||||
createSwDoc();
|
||||
SwDoc* pDoc = getSwDoc();
|
||||
SwView* pView = pDoc->GetDocShell()->GetView();
|
||||
|
||||
// When showing changes inline:
|
||||
pView->GetViewFrame().GetDispatcher()->Execute(FN_SET_TRACKED_CHANGES_IN_TEXT,
|
||||
SfxCallMode::SYNCHRON);
|
||||
|
||||
// Then make sure the state of the 3 show modes are correct:
|
||||
std::unique_ptr<SfxPoolItem> pItem;
|
||||
pView->GetViewFrame().GetBindings().QueryState(FN_SET_TRACKED_CHANGES_IN_TEXT, pItem);
|
||||
// Without the accompanying fix in place, this test would have failed with:
|
||||
// - Expected: 20267 (FN_SET_TRACKED_CHANGES_IN_TEXT)
|
||||
// - Actual : 0
|
||||
// i.e. the status of these uno commands were not implemented.
|
||||
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(FN_SET_TRACKED_CHANGES_IN_TEXT), pItem->Which());
|
||||
CPPUNIT_ASSERT(dynamic_cast<SfxBoolItem*>(pItem.get())->GetValue());
|
||||
pView->GetViewFrame().GetBindings().QueryState(FN_SET_TRACKED_DELETIONS_IN_MARGIN, pItem);
|
||||
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(FN_SET_TRACKED_DELETIONS_IN_MARGIN),
|
||||
pItem->Which());
|
||||
CPPUNIT_ASSERT(!dynamic_cast<SfxBoolItem*>(pItem.get())->GetValue());
|
||||
pView->GetViewFrame().GetBindings().QueryState(FN_SET_TRACKED_INSERTIONS_IN_MARGIN, pItem);
|
||||
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(FN_SET_TRACKED_INSERTIONS_IN_MARGIN),
|
||||
pItem->Which());
|
||||
CPPUNIT_ASSERT(!dynamic_cast<SfxBoolItem*>(pItem.get())->GetValue());
|
||||
|
||||
// When showing deletions on the margin:
|
||||
pView->GetViewFrame().GetDispatcher()->Execute(FN_SET_TRACKED_DELETIONS_IN_MARGIN,
|
||||
SfxCallMode::SYNCHRON);
|
||||
|
||||
// Then make sure the state of the 3 show modes are correct:
|
||||
pView->GetViewFrame().GetBindings().QueryState(FN_SET_TRACKED_CHANGES_IN_TEXT, pItem);
|
||||
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(FN_SET_TRACKED_CHANGES_IN_TEXT), pItem->Which());
|
||||
CPPUNIT_ASSERT(!dynamic_cast<SfxBoolItem*>(pItem.get())->GetValue());
|
||||
pView->GetViewFrame().GetBindings().QueryState(FN_SET_TRACKED_DELETIONS_IN_MARGIN, pItem);
|
||||
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(FN_SET_TRACKED_DELETIONS_IN_MARGIN),
|
||||
pItem->Which());
|
||||
CPPUNIT_ASSERT(dynamic_cast<SfxBoolItem*>(pItem.get())->GetValue());
|
||||
pView->GetViewFrame().GetBindings().QueryState(FN_SET_TRACKED_INSERTIONS_IN_MARGIN, pItem);
|
||||
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(FN_SET_TRACKED_INSERTIONS_IN_MARGIN),
|
||||
pItem->Which());
|
||||
CPPUNIT_ASSERT(!dynamic_cast<SfxBoolItem*>(pItem.get())->GetValue());
|
||||
|
||||
// When showing insertions on the margin:
|
||||
pView->GetViewFrame().GetDispatcher()->Execute(FN_SET_TRACKED_INSERTIONS_IN_MARGIN,
|
||||
SfxCallMode::SYNCHRON);
|
||||
|
||||
// Then make sure the state of the 3 show modes are correct:
|
||||
pView->GetViewFrame().GetBindings().QueryState(FN_SET_TRACKED_CHANGES_IN_TEXT, pItem);
|
||||
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(FN_SET_TRACKED_CHANGES_IN_TEXT), pItem->Which());
|
||||
CPPUNIT_ASSERT(!dynamic_cast<SfxBoolItem*>(pItem.get())->GetValue());
|
||||
pView->GetViewFrame().GetBindings().QueryState(FN_SET_TRACKED_DELETIONS_IN_MARGIN, pItem);
|
||||
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(FN_SET_TRACKED_DELETIONS_IN_MARGIN),
|
||||
pItem->Which());
|
||||
CPPUNIT_ASSERT(!dynamic_cast<SfxBoolItem*>(pItem.get())->GetValue());
|
||||
pView->GetViewFrame().GetBindings().QueryState(FN_SET_TRACKED_INSERTIONS_IN_MARGIN, pItem);
|
||||
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(FN_SET_TRACKED_INSERTIONS_IN_MARGIN),
|
||||
pItem->Which());
|
||||
CPPUNIT_ASSERT(dynamic_cast<SfxBoolItem*>(pItem.get())->GetValue());
|
||||
|
||||
// Finally, when not showing changes:
|
||||
SfxBoolItem aShow(FN_REDLINE_SHOW, false);
|
||||
pView->GetViewFrame().GetDispatcher()->ExecuteList(FN_REDLINE_SHOW, SfxCallMode::SYNCHRON,
|
||||
{ &aShow });
|
||||
|
||||
// Then make sure the state of the 3 show modes are correct:
|
||||
pView->GetViewFrame().GetBindings().QueryState(FN_SET_TRACKED_CHANGES_IN_TEXT, pItem);
|
||||
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(FN_SET_TRACKED_CHANGES_IN_TEXT), pItem->Which());
|
||||
CPPUNIT_ASSERT(!dynamic_cast<SfxBoolItem*>(pItem.get())->GetValue());
|
||||
pView->GetViewFrame().GetBindings().QueryState(FN_SET_TRACKED_DELETIONS_IN_MARGIN, pItem);
|
||||
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(FN_SET_TRACKED_DELETIONS_IN_MARGIN),
|
||||
pItem->Which());
|
||||
CPPUNIT_ASSERT(!dynamic_cast<SfxBoolItem*>(pItem.get())->GetValue());
|
||||
pView->GetViewFrame().GetBindings().QueryState(FN_SET_TRACKED_INSERTIONS_IN_MARGIN, pItem);
|
||||
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(FN_SET_TRACKED_INSERTIONS_IN_MARGIN),
|
||||
pItem->Which());
|
||||
CPPUNIT_ASSERT(!dynamic_cast<SfxBoolItem*>(pItem.get())->GetValue());
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
@@ -116,6 +116,7 @@
|
||||
#include <fmtrfmrk.hxx>
|
||||
#include <txtrfmrk.hxx>
|
||||
#include <translatehelper.hxx>
|
||||
#include <rootfrm.hxx>
|
||||
|
||||
FlyMode SwBaseShell::s_eFrameMode = FLY_DRAG_END;
|
||||
|
||||
@@ -2160,6 +2161,35 @@ void SwBaseShell::GetState( SfxItemSet &rSet )
|
||||
rSet.DisableItem(nWhich);
|
||||
}
|
||||
break;
|
||||
case FN_SET_TRACKED_CHANGES_IN_TEXT:
|
||||
{
|
||||
bool bShowRedlines = !rSh.GetLayout()->IsHideRedlines();
|
||||
const SwViewOption* pOptions = rSh.GetViewOptions();
|
||||
// First setting is false: inline.
|
||||
bool bAllInText = bShowRedlines && !pOptions->IsShowChangesInMargin();
|
||||
rSet.Put(SfxBoolItem(nWhich, bAllInText));
|
||||
}
|
||||
break;
|
||||
case FN_SET_TRACKED_DELETIONS_IN_MARGIN:
|
||||
{
|
||||
bool bShowRedlines = !rSh.GetLayout()->IsHideRedlines();
|
||||
const SwViewOption* pOptions = rSh.GetViewOptions();
|
||||
// Second setting is false: show deletions in margin.
|
||||
bool bDelInMargin = bShowRedlines && pOptions->IsShowChangesInMargin()
|
||||
&& !pOptions->IsShowChangesInMargin2();
|
||||
rSet.Put(SfxBoolItem(nWhich, bDelInMargin));
|
||||
}
|
||||
break;
|
||||
case FN_SET_TRACKED_INSERTIONS_IN_MARGIN:
|
||||
{
|
||||
bool bShowRedlines = !rSh.GetLayout()->IsHideRedlines();
|
||||
const SwViewOption* pOptions = rSh.GetViewOptions();
|
||||
// Second setting is true: show insertions in margin.
|
||||
bool bInsInMargin = bShowRedlines && pOptions->IsShowChangesInMargin()
|
||||
&& pOptions->IsShowChangesInMargin2();
|
||||
rSet.Put(SfxBoolItem(nWhich, bInsInMargin));
|
||||
}
|
||||
break;
|
||||
}
|
||||
nWhich = aIter.NextWhich();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user