summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2023-10-30 14:42:34 +0100
committerLászló Németh <nemeth@numbertext.org>2023-10-30 21:54:07 +0100
commit79435eb55ef226fb0e3507aabdc2f8af062680f6 (patch)
treebaf38a092ea42d3527f07212f4364f8142ede90b /sw
parenta18174e807e8704c385637b8a53c45b9608bfa42 (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>
Diffstat (limited to 'sw')
-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 53f6dce1a56a..83bc43f6d866 100644
--- a/sw/qa/extras/uiwriter/uiwriter6.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter6.cxx
@@ -690,6 +690,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 3f4c99a8f487..54b29b9b766c 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -3047,6 +3047,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