diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-08-18 13:37:42 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-08-19 10:38:31 +0200 |
commit | 787c1a5e777f891bc0ffade69560fad09d0e8677 (patch) | |
tree | 3ce9e6721bcd28f9c650db028a1b6e6a5426956d | |
parent | 1be71c6e6aa4bb6506674220652163fbf0172935 (diff) |
sw: fix accepting/rejecting a change by index when cursor is not at a redline
When there is no index, then the cursor position is used to find out
which redline to accept/reject. LOK uses the index parameter instead, so
there never disable the command.
Change-Id: Icbe0905e4ebd170c6f33fe383cd3042d812a2eb0
(cherry picked from commit b6011f07254f8003929320ad842d8d09daca0e09)
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 32 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewstat.cxx | 9 |
2 files changed, 38 insertions, 3 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 011194879ff7..8cc29776b79c 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -68,6 +68,7 @@ public: void testUndoRepairDispatch(); void testShapeTextUndoShells(); void testShapeTextUndoGroupShells(); + void testTrackChanges(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -100,6 +101,7 @@ public: CPPUNIT_TEST(testUndoRepairDispatch); CPPUNIT_TEST(testShapeTextUndoShells); CPPUNIT_TEST(testShapeTextUndoGroupShells); + CPPUNIT_TEST(testTrackChanges); CPPUNIT_TEST_SUITE_END(); private: @@ -1138,6 +1140,36 @@ void SwTiledRenderingTest::testShapeTextUndoGroupShells() comphelper::LibreOfficeKit::setActive(false); } +void SwTiledRenderingTest::testTrackChanges() +{ + // Load a document. + comphelper::LibreOfficeKit::setActive(); + SwXTextDocument* pXTextDocument = createDoc("dummy.fodt"); + + // Turn on trak changes, type "zzz" at the end, and move to the start. + uno::Reference<beans::XPropertySet> xPropertySet(mxComponent, uno::UNO_QUERY); + xPropertySet->setPropertyValue("RecordChanges", uno::makeAny(true)); + SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + pWrtShell->EndDoc(); + pWrtShell->Insert("zzz"); + pWrtShell->SttDoc(); + + // Reject the change by index, while the cursor does not cover the tracked change. + uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence( + { + {"RejectTrackedChange", uno::makeAny(static_cast<sal_uInt16>(0))} + })); + comphelper::dispatchCommand(".uno:RejectTrackedChange", aPropertyValues); + Scheduler::ProcessEventsToIdle(); + + // Assert that the reject was performed. + SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false); + // This was 'Aaa bbb.zzz', the change wasn't rejected. + CPPUNIT_ASSERT_EQUAL(OUString("Aaa bbb."), pShellCursor->GetPoint()->nNode.GetNode().GetTextNode()->GetText()); + + comphelper::LibreOfficeKit::setActive(false); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/uibase/uiview/viewstat.cxx b/sw/source/uibase/uiview/viewstat.cxx index c37b8d77eac2..5ca0ffc5d749 100644 --- a/sw/source/uibase/uiview/viewstat.cxx +++ b/sw/source/uibase/uiview/viewstat.cxx @@ -52,6 +52,7 @@ #include <globdoc.hxx> #include <svl/stritem.hxx> #include <unotools/moduleoptions.hxx> +#include <comphelper/lok.hxx> #include <svl/visitem.hxx> #include <redline.hxx> #include <docary.hxx> @@ -275,8 +276,10 @@ void SwView::GetState(SfxItemSet &rSet) SwPaM *pCursor = m_pWrtShell->GetCursor(); if (GetDocShell()->HasChangeRecordProtection()) rSet.DisableItem(nWhich); - else if (pCursor->HasMark()) - { // If the selection does not contain redlines, disable accepting/rejecting changes. + else if (pCursor->HasMark() && !comphelper::LibreOfficeKit::isActive()) + { + // If the selection does not contain redlines, disable accepting/rejecting changes. + // Though LibreOfficeKit wants to handle changes by index, so always allow there. sal_uInt16 index = 0; const SwRedlineTable& table = pDoc->getIDocumentRedlineAccess().GetRedlineTable(); const SwRangeRedline* redline = table.FindAtPosition( *pCursor->Start(), index ); @@ -299,7 +302,7 @@ void SwView::GetState(SfxItemSet &rSet) if( redline == nullptr ) rSet.DisableItem(nWhich); } - else + else if (!comphelper::LibreOfficeKit::isActive()) { // If the cursor position isn't on a redline, disable // accepting/rejecting changes. |