diff options
author | László Németh <nemeth@numbertext.org> | 2021-04-07 09:35:15 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2021-05-16 23:47:21 +0200 |
commit | 91648847a72f50f8cc59d02b9cb1b226bb2f1c41 (patch) | |
tree | 2ca41a5d3ed66601b545e03f87ab874aa0f825ca /sw | |
parent | 0a493b6407af8c1ce8dfc186da2975dcb0fe7eb6 (diff) |
tdf#126226, 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>
Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115183
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/uiwriter/data2/tdf39721.fodt | 42 | ||||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter2.cxx | 52 | ||||
-rw-r--r-- | sw/source/core/crsr/crstrvl.cxx | 18 |
3 files changed, 112 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data2/tdf39721.fodt b/sw/qa/extras/uiwriter/data2/tdf39721.fodt new file mode 100644 index 000000000000..1acf06c5e2a5 --- /dev/null +++ b/sw/qa/extras/uiwriter/data2/tdf39721.fodt @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?> +<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:officeooo="http://openoffice.org/2009/office" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text" xmlns:dc="http://purl.org/dc/elements/1.1/"> + <office:styles> + <style:style style:name="Standard" style:family="paragraph" style:class="text"/> + <style:default-style style:family="paragraph"> + <style:text-properties fo:language="en" fo:country="US"/> + </style:default-style> + </office:styles> + <office:body> + <office:text> + <text:tracked-changes text:track-changes="false"> + <text:changed-region xml:id="ct94454449144064" text:id="ct94454449144064"> + <text:deletion> + <office:change-info> + <dc:creator>Unknown Author</dc:creator> + <dc:date>2021-01-06T16:18:57</dc:date> + </office:change-info> + </text:deletion> + </text:changed-region> + <text:changed-region xml:id="ct94454455394000" text:id="ct94454455394000"> + <text:deletion> + <office:change-info> + <dc:creator>Unknown Author</dc:creator> + <dc:date>2021-01-06T16:20:17</dc:date> + </office:change-info> + </text:deletion> + </text:changed-region> + </text:tracked-changes> + <text:list xml:id="list627175737" text:style-name="L3"> + <text:list-item> + <text:p text:style-name="P1">Lorem<text:change-start text:change-id="ct94454449144064"/> ipsu<text:change-end text:change-id="ct94454449144064"/>m</text:p> + </text:list-item> + <text:list-item> + <text:p text:style-name="P1">dol<text:change-start text:change-id="ct94454455394000"/>or <text:change-end text:change-id="ct94454455394000"/>sit</text:p> + </text:list-item> + <text:list-item> + <text:p text:style-name="P1">amet.</text:p> + </text:list-item> + </text:list> + </office:text> + </office:body> +</office:document> diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 64ad80da0f3b..185187cfbccc 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -3636,4 +3636,56 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf123218) aScaleData = xYAxis->getScaleData(); 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()); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx index 4216a470ebc5..9c6e1fe8e13f 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; @@ -2204,6 +2206,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 @@ -2224,6 +2234,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 |