editeng/source/misc/svxacorr.cxx          |   30 +++++++++++++++++++++---------
 sw/qa/extras/uiwriter/data/tdf123786.fodt |   14 ++++++++++++++
 sw/qa/extras/uiwriter/uiwriter.cxx        |   27 +++++++++++++++++++++++++++
 3 files changed, 62 insertions(+), 9 deletions(-)

New commits:
commit f9943909d26530eea6351c88745fa5bc2e1df946
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Thu Jun 25 10:54:41 2020 +0200
Commit:     Adolfo Jayme Barrientos <fit...@ubuntu.com>
CommitDate: Sun Jul 5 22:51:20 2020 +0200

    tdf#123786 AutoCorrect: fix apostrophe in Russian
    
    and Ukrainian at "Single quotes" replacement
    outside of second level quotations.
    
    For example:
    
    „quote' -> „quote“
    
    but now
    
    apostrophe' -> apostrophe’
    
    instead of the bad
    
    apostrophe' -> apostrophe“
    
    Conflicts:
            sw/qa/extras/uiwriter/uiwriter.cxx
    
    Change-Id: Iad69b7f88ab9677f25ee0f806d035e16cdebe29b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97096
    Tested-by: Jenkins
    Reviewed-by: László Németh <nem...@numbertext.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98139
    Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com>

diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index 983660bab918..f991370c6b99 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -321,6 +321,7 @@ static constexpr sal_Unicode cRightSingleAngleQuote = 
0x203A;
 const sal_Unicode aStopDoubleAngleQuoteStart[] = { 0x201E, 0x201D, 0 }; // 
preceding ,,
 const sal_Unicode aStopDoubleAngleQuoteEnd[] = { cRightDoubleAngleQuote, 
cLeftDoubleAngleQuote, 0x201D, 0x201E, 0 }; // preceding >>
 const sal_Unicode aStopSingleQuoteEnd[] = { 0x201A, 0x2018, 0x201C, 0x201E, 0 
};
+const sal_Unicode aStopSingleQuoteEndRuUa[] = { 0x201E, 0x201C, 
cRightDoubleAngleQuote, cLeftDoubleAngleQuote, 0 };
 
 SvxAutoCorrect::SvxAutoCorrect( const OUString& rShareAutocorrFile,
                                 const OUString& rUserAutocorrFile )
@@ -1355,19 +1356,30 @@ void SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& 
rDoc, const OUString& rTxt,
                     {
                         eType = ACQuotes::DoubleAngleQuote;
                     }
-                    // tdf#128860 use apostrophe outside of second level 
quotation in Czech, German, Icelandic,
-                    // Slovak and Slovenian instead of the – in this case, bad 
– closing quotation mark U+2018.
                     else if ( bSingle && nInsPos && !bSttQuote &&
-                        ( primary(eLang) == primary(LANGUAGE_GERMAN) || 
eLang.anyOf (
-                             LANGUAGE_CZECH,
-                             LANGUAGE_ICELANDIC,
-                             LANGUAGE_SLOVAK,
-                             LANGUAGE_SLOVENIAN ) ) &&
-                        !lcl_HasPrecedingChar( rTxt, nInsPos, 
aStopSingleQuoteEnd[0],  aStopSingleQuoteEnd + 1 ) )
+                        // tdf#128860 use apostrophe outside of second level 
quotation in Czech, German, Icelandic,
+                        // Slovak and Slovenian instead of the – in this case, 
bad – closing quotation mark U+2018.
+                        // tdf#123786 the same for Russian and Ukrainian
+                        ( ( eLang.anyOf (
+                                 LANGUAGE_CZECH,
+                                 LANGUAGE_GERMAN,
+                                 LANGUAGE_GERMAN_SWISS,
+                                 LANGUAGE_GERMAN_AUSTRIAN,
+                                 LANGUAGE_GERMAN_LUXEMBOURG,
+                                 LANGUAGE_GERMAN_LIECHTENSTEIN,
+                                 LANGUAGE_ICELANDIC,
+                                 LANGUAGE_SLOVAK,
+                                 LANGUAGE_SLOVENIAN ) &&
+                            !lcl_HasPrecedingChar( rTxt, nInsPos, 
aStopSingleQuoteEnd[0],  aStopSingleQuoteEnd + 1 ) ) ||
+                          ( eLang.anyOf (
+                                 LANGUAGE_RUSSIAN,
+                                 LANGUAGE_UKRAINIAN ) &&
+                            !lcl_HasPrecedingChar( rTxt, nInsPos, 
aStopSingleQuoteEndRuUa[0],  aStopSingleQuoteEndRuUa + 1 ) ) ) )
                     {
                         LocaleDataWrapper& rLcl = GetLocaleDataWrapper( eLang 
);
                         CharClass& rCC = GetCharClass( eLang );
-                        if ( rLcl.getQuotationMarkStart() == 
OUStringChar(aStopSingleQuoteEnd[0]) &&
+                        if ( ( rLcl.getQuotationMarkStart() == 
OUStringChar(aStopSingleQuoteEnd[0]) ||
+                             rLcl.getQuotationMarkStart() == 
OUStringChar(aStopSingleQuoteEndRuUa[0]) ) &&
                              // use apostrophe only after letters, not after 
digits or punctuation
                              rCC.isLetter(rTxt, nInsPos-1) )
                         {
diff --git a/sw/qa/extras/uiwriter/data/tdf123786.fodt 
b/sw/qa/extras/uiwriter/data/tdf123786.fodt
new file mode 100644
index 000000000000..8eb85164bb5e
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/tdf123786.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="ru" fo:country="RU"/>
+  </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 2b8490b09135..2e295b8f4d53 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -371,6 +371,7 @@ public:
     void testTdf59666();
     void testTdf133524();
     void testTdf128860();
+    void testTdf123786();
 #if ENABLE_LIBNUMBERTEXT
     void testTdf133589();
 #endif
@@ -591,6 +592,7 @@ public:
     CPPUNIT_TEST(testTdf59666);
     CPPUNIT_TEST(testTdf133524);
     CPPUNIT_TEST(testTdf128860);
+    CPPUNIT_TEST(testTdf123786);
 #if ENABLE_LIBNUMBERTEXT
     CPPUNIT_TEST(testTdf133589);
 #endif
@@ -7282,6 +7284,31 @@ void SwUiWriterTest::testTdf128860()
     CPPUNIT_ASSERT_EQUAL(sReplaced, 
static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
 }
 
+void SwUiWriterTest::testTdf123786()
+{
+    SwDoc* pDoc = createDoc("tdf123786.fodt");
+    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+    // Second level ending quote: „word' -> „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());
+    // 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());
+}
+
 #if ENABLE_LIBNUMBERTEXT
 void SwUiWriterTest::testTdf133589()
 {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to