summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2020-07-04 16:37:33 +0200
committerLászló Németh <nemeth@numbertext.org>2020-07-05 10:10:43 +0200
commit99d4bf9446c392c3cf2877219c78917ca4d5dd87 (patch)
treebd0fa634eebe05865efc0890af5f8f1277f47d6d /sw/qa
parentfdf39bcc9bc1eb1a867e9d1536e8daa437cf0553 (diff)
tdf#133524 AutoCorrect: fix Romanian nested quotations
typing " inside primary quotation marks: use the correct order of the double angle quotes: „... «quote» ...” Add also Aragonese, Asturian and Catalan to the "<<" and ">>" replacement. See commit 57f07b1d7378d218648667c5b1315cc8ad905875 (tdf#133524 AutoCorrect: support double angle quotes). Change-Id: I2e80cc45768eefa3eb62b446ca822ee6c46f7242 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97970 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/extras/uiwriter/data/tdf133524_ro.fodt14
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx54
2 files changed, 55 insertions, 13 deletions
diff --git a/sw/qa/extras/uiwriter/data/tdf133524_ro.fodt b/sw/qa/extras/uiwriter/data/tdf133524_ro.fodt
new file mode 100644
index 000000000000..591db1f4eff3
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/tdf133524_ro.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:table="urn:oasis:names:tc:opendocument:xmlns:table: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" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:styles>
+ <style:style style:name="Standard" style:family="paragraph" style:class="text"/>
+ <style:default-style style:family="paragraph">
+ <style:text-properties fo:language="ro" fo:country="RO"/>
+ </style:default-style>
+ </office:styles>
+ <office:body>
+ <office:text>
+ <text:p text:style-name="Standard"></text:p>
+ </office:text>
+ </office:body>
+</office:document>
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 779a785ec226..02cf3597baf1 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -369,6 +369,7 @@ public:
void testTdf38394();
void testTdf59666();
void testTdf133524();
+ void testTdf133524_Romanian();
void testTdf128860();
void testTdf123786();
void testTdf133589();
@@ -588,6 +589,7 @@ public:
CPPUNIT_TEST(testTdf38394);
CPPUNIT_TEST(testTdf59666);
CPPUNIT_TEST(testTdf133524);
+ CPPUNIT_TEST(testTdf133524_Romanian);
CPPUNIT_TEST(testTdf128860);
CPPUNIT_TEST(testTdf123786);
CPPUNIT_TEST(testTdf133589);
@@ -7186,7 +7188,6 @@ void SwUiWriterTest::testTdf38394()
// tdf#132301 autocorrect of qu'«
pWrtShell->Insert(u" qu\u2019");
pWrtShell->AutoCorrect(corr, cChar);
- nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
sReplaced += u" qu\u2019« ";
CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
}
@@ -7221,7 +7222,6 @@ void SwUiWriterTest::testTdf133524()
// <<
pWrtShell->Insert(u"word<");
pWrtShell->AutoCorrect(corr, '<');
- nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
sReplaced += u"word«";
CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
// 2. Testing autocorrect of " to >> and << inside „...”
@@ -7229,29 +7229,64 @@ void SwUiWriterTest::testTdf133524()
// opening primary level quote
pWrtShell->Insert(u" ");
pWrtShell->AutoCorrect(corr, '"');
- nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
sReplaced += u" „";
CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
// opening second level quote
pWrtShell->Insert(u"Sentence and ");
pWrtShell->AutoCorrect(corr, '"');
- nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
sReplaced += u"Sentence and »";
CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
// closing second level quote
pWrtShell->Insert(u"word");
pWrtShell->AutoCorrect(corr, '"');
- nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
sReplaced += u"word«";
CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
// closing primary level quote
pWrtShell->Insert(u".");
pWrtShell->AutoCorrect(corr, '"');
- nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
sReplaced += u".”";
CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
}
+void SwUiWriterTest::testTdf133524_Romanian()
+{
+ SwDoc* pDoc = createDoc("tdf133524_ro.fodt");
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ SwAutoCorrect corr(*SvxAutoCorrCfg::Get().GetAutoCorrect());
+ // 1. Testing autocorrect of " to << and >> inside „...”
+ // Example: „Sentence and «word».”
+ // opening primary level quote
+ pWrtShell->AutoCorrect(corr, '"');
+ sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
+ OUString sReplaced(u"„");
+ CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
+ // opening second level quote
+ pWrtShell->Insert(u"Sentence and ");
+ pWrtShell->AutoCorrect(corr, '"');
+ sReplaced += u"Sentence and «";
+ CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
+ // closing second level quote
+ pWrtShell->Insert(u"word");
+ pWrtShell->AutoCorrect(corr, '"');
+ sReplaced += u"word»";
+ CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
+ // closing primary level quote
+ pWrtShell->Insert(u".");
+ pWrtShell->AutoCorrect(corr, '"');
+ sReplaced += u".”";
+ CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
+ // 2. Testing recognition of closing double quotation mark ”
+ pWrtShell->Insert(u" ");
+ pWrtShell->AutoCorrect(corr, '"');
+ sReplaced += u" „";
+ CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
+ // 3. Testing recognition of alternative closing double quotation mark “
+ pWrtShell->Insert(u"Alternative.“ ");
+ pWrtShell->AutoCorrect(corr, '"');
+ sReplaced += u"Alternative.“ „";
+ CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
+}
+
void SwUiWriterTest::testTdf128860()
{
SwDoc* pDoc = createDoc("tdf128860.fodt");
@@ -7266,13 +7301,11 @@ void SwUiWriterTest::testTdf128860()
// Us apostrophe without preceding starting quote: word' -> word’
pWrtShell->Insert(u" word");
pWrtShell->AutoCorrect(corr, '\'');
- nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
sReplaced += u" word’";
CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
// But only after letters: word.' -> word.‘
pWrtShell->Insert(u" word.");
pWrtShell->AutoCorrect(corr, '\'');
- nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
sReplaced += u" word.‘";
CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
}
@@ -7291,13 +7324,11 @@ void SwUiWriterTest::testTdf123786()
// Us apostrophe without preceding starting quote: word' -> word’
pWrtShell->Insert(u" слово");
pWrtShell->AutoCorrect(corr, '\'');
- nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
sReplaced += u" слово’";
CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
// But only after letters: word.' -> word.“
pWrtShell->Insert(u" слово.");
pWrtShell->AutoCorrect(corr, '\'');
- nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
sReplaced += u" слово.“";
CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
}
@@ -7317,7 +7348,6 @@ void SwUiWriterTest::testTdf133589()
// disambiguate consonants: asszony -> asz|szony
pWrtShell->Insert(u"asszony");
pWrtShell->AutoCorrect(corr, ' ');
- nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
sReplaced += u"𐳀𐳥𐳥𐳛𐳚 ";
CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
// disambiguate consonants: kosszarv -> kos|szarv
@@ -7326,13 +7356,11 @@ void SwUiWriterTest::testTdf133589()
// pWrtShell->Insert(u"kosszarv");
pWrtShell->Insert(u"kos​szarv");
pWrtShell->AutoCorrect(corr, ' ');
- nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
sReplaced += u"𐳓𐳛𐳤𐳥𐳀𐳢𐳮 ";
CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
// transliterate numbers to Old Hungarian
pWrtShell->Insert(u"2020");
pWrtShell->AutoCorrect(corr, ' ');
- nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
sReplaced += u"𐳺𐳺𐳿𐳼𐳼 ";
CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
}