summaryrefslogtreecommitdiff
path: root/editeng/qa
diff options
context:
space:
mode:
authorMichael Warner <michael.warner.ut+libreoffice@gmail.com>2022-02-13 22:45:48 -0500
committerXisco Fauli <xiscofauli@libreoffice.org>2022-02-17 17:15:16 +0100
commitb7308bda7212da5681b7047c02e2e13e36b2a98a (patch)
treeadc0fea3b951fb5fda1439dc6e1741e716684aed /editeng/qa
parent957d99a539df6e21fd40370938ca5dab1613cf8c (diff)
tdf#147196: Fix crash in editeng when applying title case format
Fixes a possiblity of crashing when applying title case format using the edit engine. Change-Id: I4f44f635a1c96b021c084bb5bb973180744e56e2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129888 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'editeng/qa')
-rw-r--r--editeng/qa/unit/core-test.cxx22
1 files changed, 22 insertions, 0 deletions
diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx
index f3500e01ce26..ffdec6ffb2fe 100644
--- a/editeng/qa/unit/core-test.cxx
+++ b/editeng/qa/unit/core-test.cxx
@@ -97,6 +97,8 @@ public:
void testTransliterate();
+ void testTdf147196();
+
DECL_STATIC_LINK( Test, CalcFieldValueHdl, EditFieldInfo*, void );
CPPUNIT_TEST_SUITE(Test);
@@ -119,6 +121,7 @@ public:
CPPUNIT_TEST(testSectionAttributes);
CPPUNIT_TEST(testLargeParaCopyPaste);
CPPUNIT_TEST(testTransliterate);
+ CPPUNIT_TEST(testTdf147196);
CPPUNIT_TEST_SUITE_END();
private:
@@ -1830,6 +1833,17 @@ void Test::testTransliterate()
CPPUNIT_ASSERT_EQUAL(OUString("Mary Jones mET joe Smith. Time Passed."), lcl_translitTest(editEng, sText2, esel, TF::LOWERCASE_UPPERCASE));
CPPUNIT_ASSERT_EQUAL(OUString("Mary Jones met joe Smith. Time Passed."), lcl_translitTest(editEng, sText2, esel, TF::UPPERCASE_LOWERCASE));
+ /* Test behavior when there is a selection that ends in the middle of a word */
+ selStart = 11;
+ selEnd = 13;
+ esel = ESelection(0, selStart, 0, selEnd);
+ CPPUNIT_ASSERT_EQUAL(OUString("me"), editEng.GetText(esel));
+ CPPUNIT_ASSERT_EQUAL(OUString("Mary Jones Met joe Smith. Time Passed."), lcl_translitTest(editEng, sText2, esel, TF::SENTENCE_CASE));
+ CPPUNIT_ASSERT_EQUAL(OUString("Mary Jones Met joe Smith. Time Passed."), lcl_translitTest(editEng, sText2, esel, TF::TITLE_CASE));
+ CPPUNIT_ASSERT_EQUAL(OUString("Mary Jones MEt joe Smith. Time Passed."), lcl_translitTest(editEng, sText2, esel, TF::LOWERCASE_UPPERCASE));
+ CPPUNIT_ASSERT_EQUAL(OUString("Mary Jones met joe Smith. Time Passed."), lcl_translitTest(editEng, sText2, esel, TF::UPPERCASE_LOWERCASE));
+
+
/* Test behavior when there is a selection that crosses a word boundary: "nes met joe Sm" */
selStart = 7;
selEnd = 21;
@@ -1865,9 +1879,17 @@ void Test::testTransliterate()
CPPUNIT_ASSERT_EQUAL(OUString("CURRENT IS EQUAL TO 10 A"), lcl_translitTest(editEng, sText3, esel, TF::LOWERCASE_UPPERCASE));
CPPUNIT_ASSERT_EQUAL(OUString("current is equal to 10 A"), lcl_translitTest(editEng, sText3, esel, TF::UPPERCASE_LOWERCASE));
+}
+void Test::testTdf147196()
+{
+ EditEngine editEng( mpItemPool.get() );
+ editEng.SetText("2.2 Publication of information - CAA\nSection 4.2 of a CA\'s Certificate Policy and/or Certification Practice Statement SHALL state the CA\'s policy or practice on processing CAA Records for Fully Qualified Domain Names; that policy shall be consistent with these Requirements. \n\nIt shall clearly specify the set of Issuer Domain Names that the CA recognises in CAA \"issue\" or \"issuewild\" records as permitting it to issue. The CA SHALL log all actions taken, if any, consistent with its processing practice.");
+ editEng.TransliterateText(ESelection(0, 0, 3, 232), TransliterationFlags::TITLE_CASE);
+ CPPUNIT_ASSERT_EQUAL(OUString("2.2 Publication Of Information - Caa\nSection 4.2 Of A Ca\'s Certificate Policy And/Or Certification Practice Statement Shall State The Ca\'s Policy Or Practice On Processing Caa Records For Fully Qualified Domain Names; That Policy Shall Be Consistent With These Requirements. \n\nIt Shall Clearly Specify The Set Of Issuer Domain Names That The Ca Recognises In Caa \"Issue\" Or \"Issuewild\" Records As Permitting It To Issue. The Ca Shall Log All Actions Taken, If Any, Consistent With Its Processing Practice."), editEng.GetText());
}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
}