From 8039c9eb27170a162830f0ecd2086010a7a5858f Mon Sep 17 00:00:00 2001 From: László Németh Date: Sun, 29 Dec 2019 12:34:34 +0100 Subject: tdf#38394 AutoCorrect: fix ’« in French l’« word » MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit instead of using the bad ’" -> ’» autocorrection. Change-Id: I48adbb2e8ca8e786c7835ff186d4580e856cf3c7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85945 Tested-by: Jenkins Reviewed-by: László Németh Tested-by: László Németh --- editeng/source/misc/svxacorr.cxx | 9 ++++++ sw/qa/extras/uiwriter/data/tdf38394.fodt | 52 ++++++++++++++++++++++++++++++++ sw/qa/extras/uiwriter/uiwriter.cxx | 16 ++++++++++ 3 files changed, 77 insertions(+) create mode 100644 sw/qa/extras/uiwriter/data/tdf38394.fodt diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index f6db80ba0a25..b023c34ade72 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -1282,6 +1282,15 @@ void SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt, lcl_IsInAsciiArr( "([{", cPrev ) || ( cEmDash == cPrev ) || ( cEnDash == cPrev ); + // tdf#38394 use opening quotation mark << in French l'<> + if ( !bSingle && !bSttQuote && cPrev == cApostrophe && + (nInsPos == 2 || (nInsPos > 2 && IsWordDelim( rTxt[ nInsPos-3 ] ))) ) + { + const LanguageType eLang = GetDocLanguage( rDoc, nInsPos ); + if ( primary(eLang) == primary(LANGUAGE_FRENCH) ) + bSttQuote = true; + } + // tdf#108423 for capitalization of English i'm b_iApostrophe = bSingle && ( cPrev == 'i' ) && (( nInsPos == 1 ) || IsWordDelim( rTxt[ nInsPos-2 ] )); } diff --git a/sw/qa/extras/uiwriter/data/tdf38394.fodt b/sw/qa/extras/uiwriter/data/tdf38394.fodt new file mode 100644 index 000000000000..238bab7b7931 --- /dev/null +++ b/sw/qa/extras/uiwriter/data/tdf38394.fodt @@ -0,0 +1,52 @@ + + + + ms 2015-04-07T22:24:25.3740120802015-04-07T22:25:28.460806924ms PT1M3S1LibreOfficeDev/4.5.0.0.alpha0$Linux_X86_64 LibreOffice_project/52ae345470d8fa657817cf87b3e8e8c1b51bd7da + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 09f77700472f..32fa64f16d45 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -362,6 +362,7 @@ public: void testTdf108423(); void testTdf106164(); void testTdf54409(); + void testTdf38394(); void testInconsistentBookmark(); CPPUNIT_TEST_SUITE(SwUiWriterTest); @@ -567,6 +568,7 @@ public: CPPUNIT_TEST(testTdf108423); CPPUNIT_TEST(testTdf106164); CPPUNIT_TEST(testTdf54409); + CPPUNIT_TEST(testTdf38394); CPPUNIT_TEST_SUITE_END(); private: @@ -7067,6 +7069,20 @@ void SwUiWriterTest::testTdf54409() CPPUNIT_ASSERT_EQUAL(sReplaced3, static_cast(pDoc->GetNodes()[nIndex])->GetText()); } +void SwUiWriterTest::testTdf38394() +{ + SwDoc* pDoc = createDoc("tdf38394.fodt"); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + // testing autocorrect of French l'" -> l'« (instead of l'») + SwAutoCorrect corr(*SvxAutoCorrCfg::Get().GetAutoCorrect()); + pWrtShell->Insert(u"l\u2019"); + const sal_Unicode cChar = '"'; + pWrtShell->AutoCorrect(corr, cChar); + sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex(); + OUString sReplaced(u"l\u2019« "); + CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast(pDoc->GetNodes()[nIndex])->GetText()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest); CPPUNIT_PLUGIN_IMPLEMENT(); -- cgit v1.2.3