diff options
author | László Németh <nemeth@numbertext.org> | 2020-05-28 08:50:39 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2020-05-31 23:13:23 +0200 |
commit | 57f07b1d7378d218648667c5b1315cc8ad905875 (patch) | |
tree | 5637c6bb18c61d960c1d1771a1f7d887649d8ba2 /sw | |
parent | c87c7ddca46ae093a703ca673a204e4593402c38 (diff) |
tdf#133524 AutoCorrect: support double angle quotes
Add two methods to support double angle quotes,
as part of "Double quotes" replacement:
1. Correct ">>" and "<<" to » and « in several languages,
where double angle quotes are default or alternative
primary or second level quotation marks, but actual
LibreOffice locale settings don't contain double angle
quotes.
2. Correct " to double angle quotes, if the cursor
is there in a primary level quotation (i.e. there
is a preceding primary level opening quote, but not
other quotes). For example, it's possible to type
Hungarian or Romanian quotation marks in
„... »quote« ...”
pressing only Shift + 2 (") for them. (These languages,
where "Single quotes" replacement is used for apostrophe
and third level quotes instead of the standard second
level quotation marks.)
Change-Id: Icd1584a5a2b81422de693217d2d1f7f3058a74b1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95212
Tested-by: Jenkins
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/uiwriter/data/tdf133524.fodt | 14 | ||||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter.cxx | 49 |
2 files changed, 63 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data/tdf133524.fodt b/sw/qa/extras/uiwriter/data/tdf133524.fodt new file mode 100644 index 000000000000..aaa4b88d5bc0 --- /dev/null +++ b/sw/qa/extras/uiwriter/data/tdf133524.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="hu" fo:country="HU"/> + </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 cfbc9a5ebe3f..9ba5cb946328 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -368,6 +368,7 @@ public: void testTdf54409(); void testTdf38394(); void testTdf59666(); + void testTdf133524(); void testInconsistentBookmark(); #if HAVE_FEATURE_PDFIUM void testInsertPdf(); @@ -582,6 +583,7 @@ public: CPPUNIT_TEST(testTdf54409); CPPUNIT_TEST(testTdf38394); CPPUNIT_TEST(testTdf59666); + CPPUNIT_TEST(testTdf133524); #if HAVE_FEATURE_PDFIUM CPPUNIT_TEST(testInsertPdf); #endif @@ -7191,6 +7193,53 @@ void SwUiWriterTest::testTdf59666() CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText()); } +void SwUiWriterTest::testTdf133524() +{ + SwDoc* pDoc = createDoc("tdf133524.fodt"); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + // 1. Testing autocorrect of >> and << + // Example: »word« + SwAutoCorrect corr(*SvxAutoCorrCfg::Get().GetAutoCorrect()); + // >> + pWrtShell->Insert(u">"); + pWrtShell->AutoCorrect(corr, '>'); + sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex(); + OUString sReplaced(u"»"); + CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText()); + // << + 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 „...” + // Example: „Sentence and »word«.” + // 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()); +} + #if HAVE_FEATURE_PDFIUM void SwUiWriterTest::testInsertPdf() { |