diff options
-rw-r--r-- | editeng/source/misc/svxacorr.cxx | 23 | ||||
-rw-r--r-- | include/editeng/svxacorr.hxx | 2 | ||||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter.cxx | 21 |
3 files changed, 43 insertions, 3 deletions
diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index c85c8a55e1b2..ca29b4e22f7c 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -1180,7 +1180,7 @@ sal_Unicode SvxAutoCorrect::GetQuote( sal_Unicode cInsChar, bool bSttQuote, void SvxAutoCorrect::InsertQuote( SvxAutoCorrDoc& rDoc, sal_Int32 nInsPos, sal_Unicode cInsChar, bool bSttQuote, - bool bIns ) + bool bIns, bool b_iApostrophe ) { const LanguageType eLang = GetDocLanguage( rDoc, nInsPos ); sal_Unicode cRet = GetQuote( cInsChar, bSttQuote, eLang ); @@ -1212,6 +1212,22 @@ void SvxAutoCorrect::InsertQuote( SvxAutoCorrDoc& rDoc, sal_Int32 nInsPos, } rDoc.Replace( nInsPos, sChg ); + + // i' -> I' in English (last step for the undo) + if( b_iApostrophe && eLang.anyOf( + LANGUAGE_ENGLISH, + LANGUAGE_ENGLISH_US, + LANGUAGE_ENGLISH_UK, + LANGUAGE_ENGLISH_AUS, + LANGUAGE_ENGLISH_CAN, + LANGUAGE_ENGLISH_NZ, + LANGUAGE_ENGLISH_EIRE, + LANGUAGE_ENGLISH_SAFRICA, + LANGUAGE_ENGLISH_JAMAICA, + LANGUAGE_ENGLISH_CARRIBEAN)) + { + rDoc.Replace( nInsPos-1, "I" ); + } } OUString SvxAutoCorrect::GetQuote( SvxAutoCorrDoc const & rDoc, sal_Int32 nInsPos, @@ -1267,6 +1283,7 @@ void SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt, { sal_Unicode cPrev; bool bSttQuote = !nInsPos; + bool b_iApostrophe = false; if (!bSttQuote) { cPrev = rTxt[ nInsPos-1 ]; @@ -1274,8 +1291,10 @@ void SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt, lcl_IsInAsciiArr( "([{", cPrev ) || ( cEmDash == cPrev ) || ( cEnDash == cPrev ); + b_iApostrophe = bSingle && ( cPrev == 'i' ) && + (( nInsPos == 1 ) || IsWordDelim( rTxt[ nInsPos-2 ] )); } - InsertQuote( rDoc, nInsPos, cChar, bSttQuote, bInsert ); + InsertQuote( rDoc, nInsPos, cChar, bSttQuote, bInsert, b_iApostrophe ); break; } diff --git a/include/editeng/svxacorr.hxx b/include/editeng/svxacorr.hxx index 0c7a5fc7cb80..311ed4cfadf7 100644 --- a/include/editeng/svxacorr.hxx +++ b/include/editeng/svxacorr.hxx @@ -318,7 +318,7 @@ public: OUString GetQuote( SvxAutoCorrDoc const & rDoc, sal_Int32 nInsPos, sal_Unicode cInsChar, bool bSttQuote ); void InsertQuote( SvxAutoCorrDoc& rDoc, sal_Int32 nInsPos, - sal_Unicode cInsChar, bool bSttQuote, bool bIns ); + sal_Unicode cInsChar, bool bSttQuote, bool bIns, bool b_iApostrophe ); // Query/Set the name of the AutoCorrect file // the default is "autocorr.dat" diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index c283aa5a755a..9a50ff1d5819 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -352,6 +352,7 @@ public: void testTdf117225(); void testTdf91801(); void testTdf51223(); + void testTdf108423(); void testInconsistentBookmark(); CPPUNIT_TEST_SUITE(SwUiWriterTest); @@ -556,6 +557,7 @@ public: CPPUNIT_TEST(testTdf91801); CPPUNIT_TEST(testTdf51223); CPPUNIT_TEST(testInconsistentBookmark); + CPPUNIT_TEST(testTdf108423); CPPUNIT_TEST_SUITE_END(); private: @@ -6842,6 +6844,25 @@ void SwUiWriterTest::testInconsistentBookmark() } } +void SwUiWriterTest::testTdf108423() +{ + SwDoc* pDoc = createDoc(); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + // testing autocorrect of i' -> I' on start of first paragraph + SwAutoCorrect corr(*SvxAutoCorrCfg::Get().GetAutoCorrect()); + pWrtShell->Insert("i"); + const sal_Unicode cChar = '\''; + pWrtShell->AutoCorrect(corr, cChar); + // The word "i" should be capitalized due to autocorrect, followed by a typographical apostrophe + sal_uLong nIndex = pWrtShell->GetCursor()->GetNode().GetIndex(); + OUString sIApostrophe = OUString(u"I" + OUStringLiteral1(0x2019)); + CPPUNIT_ASSERT_EQUAL(sIApostrophe, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText()); + pWrtShell->Insert(" i"); + pWrtShell->AutoCorrect(corr, cChar); + OUString sText = OUString(sIApostrophe + u" " + sIApostrophe); + CPPUNIT_ASSERT_EQUAL(sText, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest); CPPUNIT_PLUGIN_IMPLEMENT(); |