| 1 |
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 |
/* |
| 3 |
* This file is part of the LibreOffice project. |
| 4 |
* |
| 5 |
* This Source Code Form is subject to the terms of the Mozilla Public |
| 6 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 7 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 8 |
*/ |
| 9 |
|
| 10 |
#include <swmodeltestbase.hxx> |
| 11 |
|
| 12 |
#include <sfx2/dispatch.hxx> |
| 13 |
#include <sfx2/viewfrm.hxx> |
| 14 |
|
| 15 |
#include <cmdid.h> |
| 16 |
#include <view.hxx> |
| 17 |
#include <docsh.hxx> |
| 18 |
|
| 19 |
namespace |
| 20 |
{ |
| 21 |
/// Covers sw/source/uibase/shells/basesh.hxx fixes. |
| 22 |
class Test : public SwModelTestBase |
| 23 |
{ |
| 24 |
public: |
| 25 |
Test() |
| 26 |
: SwModelTestBase("/sw/qa/uibase/shells/data/") |
| 27 |
{ |
| 28 |
} |
| 29 |
}; |
| 30 |
} |
| 31 |
|
| 32 |
CPPUNIT_TEST_FIXTURE(Test, testShowChangesStatus) |
| 33 |
{ |
| 34 |
// Given an empty document: |
| 35 |
createSwDoc(); |
| 36 |
SwDoc* pDoc = getSwDoc(); |
| 37 |
SwView* pView = pDoc->GetDocShell()->GetView(); |
| 38 |
|
| 39 |
// When showing changes inline: |
| 40 |
pView->GetViewFrame().GetDispatcher()->Execute(FN_SET_TRACKED_CHANGES_IN_TEXT, |
| 41 |
SfxCallMode::SYNCHRON); |
| 42 |
|
| 43 |
// Then make sure the state of the 3 show modes are correct: |
| 44 |
std::unique_ptr<SfxPoolItem> pItem; |
| 45 |
pView->GetViewFrame().GetBindings().QueryState(FN_SET_TRACKED_CHANGES_IN_TEXT, pItem); |
| 46 |
// Without the accompanying fix in place, this test would have failed with: |
| 47 |
// - Expected: 20267 (FN_SET_TRACKED_CHANGES_IN_TEXT) |
| 48 |
// - Actual : 0 |
| 49 |
// i.e. the status of these uno commands were not implemented. |
| 50 |
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(FN_SET_TRACKED_CHANGES_IN_TEXT), pItem->Which()); |
| 51 |
CPPUNIT_ASSERT(dynamic_cast<SfxBoolItem*>(pItem.get())->GetValue()); |
| 52 |
pView->GetViewFrame().GetBindings().QueryState(FN_SET_TRACKED_DELETIONS_IN_MARGIN, pItem); |
| 53 |
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(FN_SET_TRACKED_DELETIONS_IN_MARGIN), |
| 54 |
pItem->Which()); |
| 55 |
CPPUNIT_ASSERT(!dynamic_cast<SfxBoolItem*>(pItem.get())->GetValue()); |
| 56 |
pView->GetViewFrame().GetBindings().QueryState(FN_SET_TRACKED_INSERTIONS_IN_MARGIN, pItem); |
| 57 |
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(FN_SET_TRACKED_INSERTIONS_IN_MARGIN), |
| 58 |
pItem->Which()); |
| 59 |
CPPUNIT_ASSERT(!dynamic_cast<SfxBoolItem*>(pItem.get())->GetValue()); |
| 60 |
|
| 61 |
// When showing deletions on the margin: |
| 62 |
pView->GetViewFrame().GetDispatcher()->Execute(FN_SET_TRACKED_DELETIONS_IN_MARGIN, |
| 63 |
SfxCallMode::SYNCHRON); |
| 64 |
|
| 65 |
// Then make sure the state of the 3 show modes are correct: |
| 66 |
pView->GetViewFrame().GetBindings().QueryState(FN_SET_TRACKED_CHANGES_IN_TEXT, pItem); |
| 67 |
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(FN_SET_TRACKED_CHANGES_IN_TEXT), pItem->Which()); |
| 68 |
CPPUNIT_ASSERT(!dynamic_cast<SfxBoolItem*>(pItem.get())->GetValue()); |
| 69 |
pView->GetViewFrame().GetBindings().QueryState(FN_SET_TRACKED_DELETIONS_IN_MARGIN, pItem); |
| 70 |
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(FN_SET_TRACKED_DELETIONS_IN_MARGIN), |
| 71 |
pItem->Which()); |
| 72 |
CPPUNIT_ASSERT(dynamic_cast<SfxBoolItem*>(pItem.get())->GetValue()); |
| 73 |
pView->GetViewFrame().GetBindings().QueryState(FN_SET_TRACKED_INSERTIONS_IN_MARGIN, pItem); |
| 74 |
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(FN_SET_TRACKED_INSERTIONS_IN_MARGIN), |
| 75 |
pItem->Which()); |
| 76 |
CPPUNIT_ASSERT(!dynamic_cast<SfxBoolItem*>(pItem.get())->GetValue()); |
| 77 |
|
| 78 |
// When showing insertions on the margin: |
| 79 |
pView->GetViewFrame().GetDispatcher()->Execute(FN_SET_TRACKED_INSERTIONS_IN_MARGIN, |
| 80 |
SfxCallMode::SYNCHRON); |
| 81 |
|
| 82 |
// Then make sure the state of the 3 show modes are correct: |
| 83 |
pView->GetViewFrame().GetBindings().QueryState(FN_SET_TRACKED_CHANGES_IN_TEXT, pItem); |
| 84 |
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(FN_SET_TRACKED_CHANGES_IN_TEXT), pItem->Which()); |
| 85 |
CPPUNIT_ASSERT(!dynamic_cast<SfxBoolItem*>(pItem.get())->GetValue()); |
| 86 |
pView->GetViewFrame().GetBindings().QueryState(FN_SET_TRACKED_DELETIONS_IN_MARGIN, pItem); |
| 87 |
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(FN_SET_TRACKED_DELETIONS_IN_MARGIN), |
| 88 |
pItem->Which()); |
| 89 |
CPPUNIT_ASSERT(!dynamic_cast<SfxBoolItem*>(pItem.get())->GetValue()); |
| 90 |
pView->GetViewFrame().GetBindings().QueryState(FN_SET_TRACKED_INSERTIONS_IN_MARGIN, pItem); |
| 91 |
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(FN_SET_TRACKED_INSERTIONS_IN_MARGIN), |
| 92 |
pItem->Which()); |
| 93 |
CPPUNIT_ASSERT(dynamic_cast<SfxBoolItem*>(pItem.get())->GetValue()); |
| 94 |
|
| 95 |
// Finally, when not showing changes: |
| 96 |
SfxBoolItem aShow(FN_REDLINE_SHOW, false); |
| 97 |
pView->GetViewFrame().GetDispatcher()->ExecuteList(FN_REDLINE_SHOW, SfxCallMode::SYNCHRON, |
| 98 |
{ &aShow }); |
| 99 |
|
| 100 |
// Then make sure the state of the 3 show modes are correct: |
| 101 |
pView->GetViewFrame().GetBindings().QueryState(FN_SET_TRACKED_CHANGES_IN_TEXT, pItem); |
| 102 |
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(FN_SET_TRACKED_CHANGES_IN_TEXT), pItem->Which()); |
| 103 |
CPPUNIT_ASSERT(!dynamic_cast<SfxBoolItem*>(pItem.get())->GetValue()); |
| 104 |
pView->GetViewFrame().GetBindings().QueryState(FN_SET_TRACKED_DELETIONS_IN_MARGIN, pItem); |
| 105 |
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(FN_SET_TRACKED_DELETIONS_IN_MARGIN), |
| 106 |
pItem->Which()); |
| 107 |
CPPUNIT_ASSERT(!dynamic_cast<SfxBoolItem*>(pItem.get())->GetValue()); |
| 108 |
pView->GetViewFrame().GetBindings().QueryState(FN_SET_TRACKED_INSERTIONS_IN_MARGIN, pItem); |
| 109 |
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(FN_SET_TRACKED_INSERTIONS_IN_MARGIN), |
| 110 |
pItem->Which()); |
| 111 |
CPPUNIT_ASSERT(!dynamic_cast<SfxBoolItem*>(pItem.get())->GetValue()); |
| 112 |
} |
| 113 |
|
| 114 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |