summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2023-10-30 14:42:34 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2023-11-02 09:29:56 +0100
commit6bf92349cab2a558a8160ad6ace409cd4b6f260e (patch)
treea13f706f971a99040aa22da75607ac03fc558c12
parent0f3d1f346b5c4dfb4073e772df1ccd91e538cf3f (diff)
tdf#157988 sw track changes: fix cycle case on a selected word
Cycle case didn't work on a selected word, only on the word under the cursor without selection. Add unit test also for tdf#141198. Follow up to commit dc748d7dbd114fbf663752258dbaf003af2926c3 "tdf#141198 sw: fix cycle case with change tracking". Change-Id: I0c1361c78d09e9b8743192a47dcdfa6f6da52e38 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158666 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/+/158686
-rw-r--r--sw/qa/extras/uiwriter/uiwriter6.cxx69
-rw-r--r--sw/source/core/doc/DocumentContentOperationsManager.cxx38
2 files changed, 107 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx b/sw/qa/extras/uiwriter/uiwriter6.cxx
index edfc5c153afc..316181c37cff 100644
--- a/sw/qa/extras/uiwriter/uiwriter6.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter6.cxx
@@ -689,6 +689,75 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf157937)
dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf157988)
+{
+ createSwDoc("tdf130088.docx");
+ SwDoc* pDoc = getSwDoc();
+
+ // select the second word
+ dispatchCommand(mxComponent, ".uno:GoToNextWord", {});
+ dispatchCommand(mxComponent, ".uno:SelectWord", {});
+
+ // enable redlining
+ dispatchCommand(mxComponent, ".uno:TrackChanges", {});
+ CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+ pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+
+ // show changes
+ CPPUNIT_ASSERT_MESSAGE(
+ "redlines should be visible",
+ IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+
+ // cycle case with change tracking
+
+ dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+ CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer sodalesSodales"));
+
+ dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+ // This was false (missing revert of the tracked change)
+ CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer sodales tincidunt"));
+
+ dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+ CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer sodalesSODALES"));
+
+ dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+ CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer sodales tincidunt"));
+
+ dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+ CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer sodalesSodales"));
+
+ dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+ CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer sodales tincidunt"));
+
+ // tdf#141198 cycle case without selection: the word under the cursor
+
+ dispatchCommand(mxComponent, ".uno:Escape", {});
+
+ dispatchCommand(mxComponent, ".uno:GoRight", {});
+
+ dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+ CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer sodalesSODALES"));
+
+ dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+ CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer sodales tincidunt"));
+
+ dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+ CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer sodalesSodales"));
+
+ dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {});
+
+ CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Integer sodales tincidunt"));
+}
+
CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf108048)
{
createSwDoc();
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 47e5b818b2fb..bac73a325a5f 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -3036,6 +3036,44 @@ void DocumentContentOperationsManager::TransliterateText(
return;
}
}
+ else
+ {
+ bool bHasTrackedChange = false;
+ IDocumentRedlineAccess& rIDRA = m_rDoc.getIDocumentRedlineAccess();
+ if ( IDocumentRedlineAccess::IsShowChanges( rIDRA.GetRedlineFlags() ) &&
+ pEnd->GetContentIndex() > 0 )
+ {
+ SwPosition aPos(*pEnd->GetContentNode(), pEnd->GetContentIndex() - 1);
+ SwRedlineTable::size_type n = 0;
+
+ const SwRangeRedline* pFnd =
+ rIDRA.GetRedlineTable().FindAtPosition( aPos, n );
+ if ( pFnd && RedlineType::Insert == pFnd->GetType() && n > 0 )
+ {
+ const SwRangeRedline* pFnd2 = rIDRA.GetRedlineTable()[n-1];
+ if ( RedlineType::Delete == pFnd2->GetType() &&
+ m_rDoc.getIDocumentLayoutAccess().GetCurrentViewShell() &&
+ *pFnd2->End() == *pFnd->Start() &&
+ pFnd->GetAuthor() == pFnd2->GetAuthor() )
+ {
+ bHasTrackedChange = true;
+ SwPosition aPos2(*pFnd2->Start());
+ rIDRA.RejectRedline(*pFnd, true);
+
+ rIDRA.RejectRedline(*pFnd2, true);
+ // positionate the text cursor before the changed word to select it
+ if ( SwWrtShell *pWrtShell = dynamic_cast<SwWrtShell*>(
+ m_rDoc.getIDocumentLayoutAccess().GetCurrentViewShell()) )
+ {
+ pWrtShell->GetCursor()->GetPoint()->
+ Assign(*aPos2.GetContentNode(), aPos2.GetContentIndex());
+ }
+ }
+ }
+ }
+ if ( bHasTrackedChange )
+ return;
+ }
bool bUseRedlining = m_rDoc.getIDocumentRedlineAccess().IsRedlineOn();
// as a workaround for a known performance problem, switch off redlining