71f3062
From 1f44a635681af51a213f69d0fc60ec91a4458f09 Mon Sep 17 00:00:00 2001
71f3062
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
71f3062
Date: Mon, 19 Jun 2017 15:02:17 +0100
71f3062
Subject: [PATCH 2/2] consider field marks as text for auto quotes
71f3062
71f3062
Change-Id: I511a13f7785a0de6efaa8439d3f0bff20a1644ed
71f3062
---
71f3062
 editeng/qa/unit/core-test.cxx    | 17 +++++++++++++++++
71f3062
 editeng/source/misc/svxacorr.cxx |  2 +-
71f3062
 2 files changed, 18 insertions(+), 1 deletion(-)
71f3062
71f3062
diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx
71f3062
index f620a72..b71c90c 100644
71f3062
--- a/editeng/qa/unit/core-test.cxx
71f3062
+++ b/editeng/qa/unit/core-test.cxx
71f3062
@@ -375,6 +375,7 @@ void Test::testAutocorrect()
71f3062
         CPPUNIT_ASSERT_EQUAL_MESSAGE("autocorrect", sExpected, aFoo.getResult());
71f3062
     }
71f3062
 
71f3062
+    // don't autocapitalize after a field mark
71f3062
     {
71f3062
         OUString sInput("Test. \x01 test");
71f3062
         sal_Unicode cNextChar(' ');
71f3062
@@ -385,6 +386,22 @@ void Test::testAutocorrect()
71f3062
 
71f3062
         CPPUNIT_ASSERT_EQUAL_MESSAGE("autocorrect", sExpected, aFoo.getResult());
71f3062
     }
71f3062
+
71f3062
+    // consider field contents as text for auto quotes
71f3062
+    {
71f3062
+        OUString sInput("T\x01");
71f3062
+        sal_Unicode cNextChar('"');
71f3062
+        const sal_Unicode EXPECTED[] = { 'T', 0x01, 0x0201d };
71f3062
+        OUString sExpected(EXPECTED, SAL_N_ELEMENTS(EXPECTED));
71f3062
+
71f3062
+        TestAutoCorrDoc aFoo(sInput, LANGUAGE_ENGLISH_US);
71f3062
+        aAutoCorrect.SetAutoCorrFlag(ChgQuotes, true);
71f3062
+        aAutoCorrect.DoAutoCorrect(aFoo, sInput, sInput.getLength(), cNextChar, true);
71f3062
+        fprintf(stderr, "text is %x\n", aFoo.getResult()[aFoo.getResult().getLength() - 1]);
71f3062
+
71f3062
+        CPPUNIT_ASSERT_EQUAL_MESSAGE("autocorrect", sExpected, aFoo.getResult());
71f3062
+    }
71f3062
+
71f3062
 }
71f3062
 
71f3062
 void Test::testHyperlinkCopyPaste()
71f3062
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
71f3062
index c7ec14c..d8804dc 100644
71f3062
--- a/editeng/source/misc/svxacorr.cxx
71f3062
+++ b/editeng/source/misc/svxacorr.cxx
71f3062
@@ -1258,7 +1258,7 @@ void SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt,
71f3062
             {
71f3062
                 sal_Unicode cPrev;
71f3062
                 bool bSttQuote = !nInsPos ||
71f3062
-                        IsWordDelim( ( cPrev = rTxt[ nInsPos-1 ])) ||
71f3062
+                        NonFieldWordDelim( ( cPrev = rTxt[ nInsPos-1 ])) ||
71f3062
                         lcl_IsInAsciiArr( "([{", cPrev ) ||
71f3062
                         ( cEmDash && cEmDash == cPrev ) ||
71f3062
                         ( cEnDash && cEnDash == cPrev );
71f3062
-- 
71f3062
2.9.3
71f3062