[Libreoffice-commits] core.git: sw/qa sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Thu Aug 18 13:33:33 UTC 2016
sw/qa/extras/tiledrendering/tiledrendering.cxx | 32 +++++++++++++++++++++++++
sw/source/uibase/uiview/viewstat.cxx | 9 ++++---
2 files changed, 38 insertions(+), 3 deletions(-)
New commits:
commit b6011f07254f8003929320ad842d8d09daca0e09
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Aug 18 13:37:42 2016 +0200
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
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index d1837c7..ad8deaf 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -67,6 +67,7 @@ public:
void testUndoRepairDispatch();
void testShapeTextUndoShells();
void testShapeTextUndoGroupShells();
+ void testTrackChanges();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -99,6 +100,7 @@ public:
CPPUNIT_TEST(testUndoRepairDispatch);
CPPUNIT_TEST(testShapeTextUndoShells);
CPPUNIT_TEST(testShapeTextUndoGroupShells);
+ CPPUNIT_TEST(testTrackChanges);
CPPUNIT_TEST_SUITE_END();
private:
@@ -1137,6 +1139,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 6815a61..31d6b03 100644
--- a/sw/source/uibase/uiview/viewstat.cxx
+++ b/sw/source/uibase/uiview/viewstat.cxx
@@ -51,6 +51,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>
@@ -286,8 +287,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 );
@@ -310,7 +313,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.
More information about the Libreoffice-commits
mailing list