summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2020-11-05 10:17:03 +0100
committerLászló Németh <nemeth@numbertext.org>2020-11-05 17:06:39 +0100
commit2d3c77e9b10f20091ef338e262ba7756eb280ce9 (patch)
treec09cc0b03d0fe04b7f7ca1f248eb81e8832b5333
parent9f3b85dc29326e779ccc6be3b649b7fb24571ee0 (diff)
tdf#109266 sw change tracking: track transliteration
Format->Text->UPPERCASE, tOGGLE cASE etc. weren't supported by change tracking. Change-Id: Ic2c94375522a5469056837ab23fdbb9557212b53 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105345 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r--sw/qa/extras/uiwriter/data2/lorem.fodt14
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx69
-rw-r--r--sw/source/core/txtnode/txtedt.cxx22
3 files changed, 102 insertions, 3 deletions
diff --git a/sw/qa/extras/uiwriter/data2/lorem.fodt b/sw/qa/extras/uiwriter/data2/lorem.fodt
new file mode 100644
index 000000000000..1996ef8de580
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data2/lorem.fodt
@@ -0,0 +1,14 @@
+<?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:p>Lorem ipsum...</text:p>
+ </office:text>
+ </office:body>
+</office:document>
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 0d3b1aee820c..c2bc2914ade0 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -3093,6 +3093,75 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf90069)
CPPUNIT_ASSERT_EQUAL(OUString("Lohit Devanagari"), sFontName);
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf109266)
+{
+ // transliteration with redlining
+ SwDoc* pDoc = createDoc("lorem.fodt");
+
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+
+ SwDocShell* pDocShell = pTextDoc->GetDocShell();
+ CPPUNIT_ASSERT(pDocShell);
+
+ SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
+ CPPUNIT_ASSERT(pWrtShell);
+
+ sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+ SwTextNode* pTextNode = static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex]);
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Lorem ipsum..."), pTextNode->GetText());
+ CPPUNIT_ASSERT_EQUAL(OUString("Lorem ipsum..."), pTextNode->GetRedlineText());
+
+ dispatchCommand(mxComponent, ".uno:SelectAll", {});
+ dispatchCommand(mxComponent, ".uno:ChangeCaseToTitleCase", {});
+
+ CPPUNIT_ASSERT_EQUAL(OUString("Lorem Ipsum..."), pTextNode->GetText());
+ CPPUNIT_ASSERT_EQUAL(OUString("Lorem Ipsum..."), pTextNode->GetRedlineText());
+
+ //turn on red-lining and show changes
+ RedlineFlags const mode(pWrtShell->GetRedlineFlags() | RedlineFlags::On);
+ CPPUNIT_ASSERT(mode & (RedlineFlags::ShowDelete | RedlineFlags::ShowInsert));
+ pWrtShell->SetRedlineFlags(mode);
+ CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+ pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+ CPPUNIT_ASSERT_MESSAGE(
+ "redlines should be visible",
+ IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+ dispatchCommand(mxComponent, ".uno:SelectAll", {});
+ dispatchCommand(mxComponent, ".uno:ChangeCaseToTitleCase", {});
+
+ // This was "Lorem Ipsum..." (missing redlining)
+ CPPUNIT_ASSERT_EQUAL(OUString("Lorem ipsumIpsum..."), pTextNode->GetText());
+ CPPUNIT_ASSERT_EQUAL(OUString("Lorem Ipsum..."), pTextNode->GetRedlineText());
+
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+ dispatchCommand(mxComponent, ".uno:SelectAll", {});
+ dispatchCommand(mxComponent, ".uno:ChangeCaseToUpper", {});
+
+ // This was "LOREM IPSUM..." (missing redlining)
+ CPPUNIT_ASSERT_EQUAL(OUString("Lorem ipsum...LOREM IPSUM..."), pTextNode->GetText());
+ CPPUNIT_ASSERT_EQUAL(OUString("LOREM IPSUM..."), pTextNode->GetRedlineText());
+
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+ dispatchCommand(mxComponent, ".uno:SelectAll", {});
+ dispatchCommand(mxComponent, ".uno:ChangeCaseToLower", {});
+
+ // This was "lorem ipsum..." (missing redlining)
+ CPPUNIT_ASSERT_EQUAL(OUString("Lorem ipsum...lorem ipsum..."), pTextNode->GetText());
+ CPPUNIT_ASSERT_EQUAL(OUString("lorem ipsum..."), pTextNode->GetRedlineText());
+
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+ dispatchCommand(mxComponent, ".uno:SelectAll", {});
+ dispatchCommand(mxComponent, ".uno:ChangeCaseToToggleCase", {});
+
+ // This was "lOREM IPSUM..." (missing redlining)
+ CPPUNIT_ASSERT_EQUAL(OUString("Lorem ipsum...lOREM IPSUM..."), pTextNode->GetText());
+ CPPUNIT_ASSERT_EQUAL(OUString("lOREM IPSUM..."), pTextNode->GetRedlineText());
+}
+
CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf129655)
{
createDoc("tdf129655-vtextbox.odt");
diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx
index 243683581d67..ba47a0021b73 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -1898,6 +1898,7 @@ void SwTextNode::TransliterateText(
// now apply the changes from end to start to leave the offsets of the
// yet unchanged text parts remain the same.
size_t nSum(0);
+ bool bIsRedlineOn(GetDoc().getIDocumentRedlineAccess().IsRedlineOn());
for (size_t i = 0; i < aChanges.size(); ++i)
{ // check this here since AddChanges cannot be moved below
// call to ReplaceTextOnly
@@ -1910,9 +1911,24 @@ void SwTextNode::TransliterateText(
"node text with insertion > node capacity.");
return;
}
- if (pUndo)
- pUndo->AddChanges( *this, rData.nStart, rData.nLen, rData.aOffsets );
- ReplaceTextOnly( rData.nStart, rData.nLen, rData.sChanged, rData.aOffsets );
+
+ if ( bIsRedlineOn )
+ {
+ // create SwPaM with mark & point spanning the attributed text
+ //SwPaM aCurPaM( *this, *this, nBegin, nBegin + nLen ); <-- wrong c-tor, does sth different
+ SwPaM aCurPaM( *this, rData.nStart );
+ aCurPaM.SetMark();
+ aCurPaM.GetPoint()->nContent = rData.nStart + rData.nLen;
+ // replace the changed words
+ if ( aCurPaM.GetText() != rData.sChanged )
+ GetDoc().getIDocumentContentOperations().ReplaceRange( aCurPaM, rData.sChanged, false );
+ }
+ else
+ {
+ if (pUndo)
+ pUndo->AddChanges( *this, rData.nStart, rData.nLen, rData.aOffsets );
+ ReplaceTextOnly( rData.nStart, rData.nLen, rData.sChanged, rData.aOffsets );
+ }
}
}