summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-07-01 14:38:54 +0100
committerCaolán McNamara <caolanm@redhat.com>2016-07-01 14:49:03 +0100
commit6752590fec030067bde038ee6c28cff05f972eac (patch)
treef7827b7a60693d25ce4ff959916037ad9f98c798 /editeng
parent4760c44c80e6dece5fe1a2e170b0f69c500a9681 (diff)
don't autocapitalize words that follow a field mark
Change-Id: Ia8efa88aaf47edba9a590c858d0ea30d7bfe2977
Diffstat (limited to 'editeng')
-rw-r--r--editeng/qa/unit/core-test.cxx22
-rw-r--r--editeng/source/misc/svxacorr.cxx18
2 files changed, 34 insertions, 6 deletions
diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx
index d303805f0a0c..14f06fe3293e 100644
--- a/editeng/qa/unit/core-test.cxx
+++ b/editeng/qa/unit/core-test.cxx
@@ -340,6 +340,28 @@ void Test::testAutocorrect()
CPPUNIT_ASSERT_EQUAL(sExpected, aFoo.getResult());
}
+
+ {
+ OUString sInput("Test. test");
+ sal_Unicode cNextChar(' ');
+ OUString sExpected("Test. Test ");
+
+ TestAutoCorrDoc aFoo(sInput, LANGUAGE_ENGLISH_US);
+ aAutoCorrect.DoAutoCorrect(aFoo, sInput, sInput.getLength(), cNextChar, true);
+
+ CPPUNIT_ASSERT_MESSAGE("autocorrect", aFoo.getResult() == sExpected);
+ }
+
+ {
+ OUString sInput("Test. \x01 test");
+ sal_Unicode cNextChar(' ');
+ OUString sExpected("Test. \x01 test ");
+
+ TestAutoCorrDoc aFoo(sInput, LANGUAGE_ENGLISH_US);
+ aAutoCorrect.DoAutoCorrect(aFoo, sInput, sInput.getLength(), cNextChar, true);
+
+ CPPUNIT_ASSERT_MESSAGE("autocorrect", aFoo.getResult() == sExpected);
+ }
}
namespace {
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx
index d736d946e2b1..11e56ef27492 100644
--- a/editeng/source/misc/svxacorr.cxx
+++ b/editeng/source/misc/svxacorr.cxx
@@ -102,6 +102,12 @@ static inline bool IsWordDelim( const sal_Unicode c )
cNonBreakingSpace == c || 0x2011 == c || 0x1 == c;
}
+static inline bool IsAutoCapitalizeWordDelim( const sal_Unicode c )
+{
+ return ' ' == c || '\t' == c || 0x0a == c ||
+ cNonBreakingSpace == c || 0x2011 == c;
+}
+
static inline bool IsLowerLetter( sal_Int32 nCharType )
{
return CharClass::isLetterType( nCharType ) &&
@@ -855,9 +861,9 @@ bool SvxAutoCorrect::FnCapitalStartSentence( SvxAutoCorrDoc& rDoc,
if( !bAtStart ) // Still no beginning of a paragraph?
{
- if ( IsWordDelim( *pStr ) )
+ if (IsAutoCapitalizeWordDelim(*pStr))
{
- while( ! ( bAtStart = (pStart == pStr--) ) && IsWordDelim( *pStr ) )
+ while (!(bAtStart = (pStart == pStr--)) && IsAutoCapitalizeWordDelim(*pStr))
;
}
// Asian full stop, full width full stop, full width exclamation mark
@@ -888,7 +894,7 @@ bool SvxAutoCorrect::FnCapitalStartSentence( SvxAutoCorrDoc& rDoc,
do { // overwrite all blanks
--pStr;
- if( !IsWordDelim( *pStr ))
+ if (!IsAutoCapitalizeWordDelim(*pStr))
break;
} while( ! ( bAtStart = (pStart == pStr) ) );
@@ -983,7 +989,7 @@ bool SvxAutoCorrect::FnCapitalStartSentence( SvxAutoCorrDoc& rDoc,
else
bAlphaFnd = true;
}
- else if( bAlphaFnd || IsWordDelim( *pTmpStr ) )
+ else if (bAlphaFnd || IsAutoCapitalizeWordDelim(*pTmpStr))
break;
if( pTmpStr == pStart )
@@ -999,7 +1005,7 @@ bool SvxAutoCorrect::FnCapitalStartSentence( SvxAutoCorrDoc& rDoc,
bool bNumericOnly = '0' <= *(pStr+1) && *(pStr+1) <= '9';
// Search for the beginning of the word
- while( !IsWordDelim( *pStr ))
+ while (!IsAutoCapitalizeWordDelim(*pStr))
{
if( bNumericOnly && rCC.isLetter( aText, pStr - pStart ) )
bNumericOnly = false;
@@ -1013,7 +1019,7 @@ bool SvxAutoCorrect::FnCapitalStartSentence( SvxAutoCorrDoc& rDoc,
if( bNumericOnly ) // consists of only numbers, then not
return false;
- if( IsWordDelim( *pStr ))
+ if (IsAutoCapitalizeWordDelim(*pStr))
++pStr;
OUString sWord;