sw/qa/extras/uiwriter/uiwriter2.cxx | 51 ++++++++++++++++++++++++++++++++++++ sw/source/core/crsr/crstrvl.cxx | 18 ++++++++++++ 2 files changed, 69 insertions(+)
New commits: commit 8e6203bd8f4390698f83a74a04f901437a9a61a3 Author: László Németh <nem...@numbertext.org> AuthorDate: Wed Apr 7 09:35:15 2021 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Wed Apr 7 12:22:53 2021 +0200 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 <nem...@numbertext.org> 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 _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits