summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2021-04-07 09:35:15 +0200
committerLászló Németh <nemeth@numbertext.org>2021-04-07 12:22:53 +0200
commit8e6203bd8f4390698f83a74a04f901437a9a61a3 (patch)
tree325b9781e370752226f070b00beb0d8c846b778d
parentd3c5087b1f3edaf40fdd62311a3e9895a1fb7916 (diff)
tdf#126735 sw Next Change: cycle through tracked changes
Next/Previous Change commands don't stop at the start or end of the document, but continue on the end or start of the document to cycle through all tracked changes, like Find Next/Previous and other office suites do. Change-Id: I5578d6b98b81ca1f8f222ba78e7d3c08339eca89 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113716 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx51
-rw-r--r--sw/source/core/crsr/crstrvl.cxx18
2 files changed, 69 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 0f1ddaaa1cb7..6ffead1dbea9 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -3883,6 +3883,57 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf123218)
CPPUNIT_ASSERT_EQUAL(chart2::AxisOrientation_REVERSE, aScaleData.Orientation);
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf126735)
+{
+ SwDoc* pDoc = createDoc("tdf39721.fodt");
+
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+
+ //turn on red-lining and show changes
+ pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::On | RedlineFlags::ShowDelete
+ | RedlineFlags::ShowInsert);
+ CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+ pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+ CPPUNIT_ASSERT_MESSAGE(
+ "redlines should be visible",
+ IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+
+ // check next selected tracked change
+ dispatchCommand(mxComponent, ".uno:NextTrackedChange", {});
+ uno::Reference<view::XSelectionSupplier> xSelSupplier(pTextDoc->getCurrentController(),
+ uno::UNO_QUERY_THROW);
+ uno::Any aSelection = xSelSupplier->getSelection();
+ uno::Reference<text::XTextRange> xTextRange = getAssociatedTextRange(aSelection);
+ CPPUNIT_ASSERT(xTextRange);
+ CPPUNIT_ASSERT_EQUAL(OUString(" ipsu"), xTextRange->getString());
+
+ // check next selected tracked change
+ dispatchCommand(mxComponent, ".uno:NextTrackedChange", {});
+ aSelection = xSelSupplier->getSelection();
+ xTextRange = getAssociatedTextRange(aSelection);
+ CPPUNIT_ASSERT(xTextRange);
+ CPPUNIT_ASSERT_EQUAL(OUString("or "), xTextRange->getString());
+
+ // check next selected tracked change at the end of the document:
+ // select the first tracked change of the document
+ dispatchCommand(mxComponent, ".uno:NextTrackedChange", {});
+ aSelection = xSelSupplier->getSelection();
+ xTextRange = getAssociatedTextRange(aSelection);
+ CPPUNIT_ASSERT(xTextRange);
+ // This was empty (collapsing at the end of the last tracked change)
+ CPPUNIT_ASSERT_EQUAL(OUString(" ipsu"), xTextRange->getString());
+
+ // check the previous tracked change at the start of the document:
+ // select the last tracked change of the document
+ dispatchCommand(mxComponent, ".uno:PreviousTrackedChange", {});
+ aSelection = xSelSupplier->getSelection();
+ xTextRange = getAssociatedTextRange(aSelection);
+ CPPUNIT_ASSERT(xTextRange);
+ // This was empty (collapsing at the start of the last tracked change)
+ CPPUNIT_ASSERT_EQUAL(OUString("or "), xTextRange->getString());
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index 08cf06763f44..529ab1efe032 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -71,6 +71,8 @@
#include <docufld.hxx>
#include <svx/srchdlg.hxx>
#include <frameformats.hxx>
+#include <docsh.hxx>
+#include <wrtsh.hxx>
using namespace ::com::sun::star;
@@ -2208,6 +2210,14 @@ const SwRangeRedline* SwCursorShell::SelNextRedline()
// ensure point is at the end so alternating SelNext/SelPrev works
NormalizePam(false);
pFnd = GetDoc()->getIDocumentRedlineAccess().SelNextRedline( *m_pCurrentCursor );
+
+ // at the end of the document, go the the start of the document, and try again
+ if ( !pFnd )
+ {
+ GetDoc()->GetDocShell()->GetWrtShell()->StartOfSection();
+ pFnd = GetDoc()->getIDocumentRedlineAccess().SelNextRedline( *m_pCurrentCursor );
+ }
+
if( pFnd && !m_pCurrentCursor->IsInProtectTable() && !m_pCurrentCursor->IsSelOvr() )
UpdateCursor( SwCursorShell::SCROLLWIN|SwCursorShell::CHKRANGE|SwCursorShell::READONLY);
else
@@ -2228,6 +2238,14 @@ const SwRangeRedline* SwCursorShell::SelPrevRedline()
// ensure point is at the start so alternating SelNext/SelPrev works
NormalizePam(true);
pFnd = GetDoc()->getIDocumentRedlineAccess().SelPrevRedline( *m_pCurrentCursor );
+
+ // at the start of the document, go the the end of the document, and try again
+ if ( !pFnd )
+ {
+ GetDoc()->GetDocShell()->GetWrtShell()->EndOfSection();
+ pFnd = GetDoc()->getIDocumentRedlineAccess().SelPrevRedline( *m_pCurrentCursor );
+ }
+
if( pFnd && !m_pCurrentCursor->IsInProtectTable() && !m_pCurrentCursor->IsSelOvr() )
UpdateCursor( SwCursorShell::SCROLLWIN|SwCursorShell::CHKRANGE|SwCursorShell::READONLY);
else