diff options
author | László Németh <nemeth@numbertext.org> | 2020-06-01 19:31:38 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2020-06-02 18:40:06 +0200 |
commit | da64ec8c8a91db6a6ec9657898f081d5ee67e739 (patch) | |
tree | 2bd7d3ddf24ce6c5adeb3c29dd46ead2e1215c0a /editeng | |
parent | 2d6395b87218cbf3512aa9b54807a859205006f0 (diff) |
tdf#133589 AutoCorrect: transliterate to Old Hungarian
In right-to-left paragraph mode, transliterate
Hungarian text word by word during typing, also
add the associated checkbox to Localized Options
page of AutoCorrect dialog window.
Old Hungarian (ISO 15924: Hung) is a historical
and renewed script which is still in use to
transliterate Hungarian writing.
As a localized AutoCorrect feature, the patch supports
the followings:
– word-by-word transliteration of Hungarian texts only
in right-to-left paragraph mode.
– consonant disambiguation of digraphs and trigraphs
based on hyphenation (now pattern-based Huhyphn
dictionary of libhyphen, planned dictionary based
Hunspell later)
– transliteration by extended hu-Hung module of
Numbertext library.
Note: transliteration of the selected text using
AutoCorrect Apply function has't been implemented, yet.
Change-Id: Iee0f18e2485c974c35acf0a3abc3a49c2cf80196
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95303
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/inc/edtspell.hxx | 2 | ||||
-rw-r--r-- | editeng/qa/unit/core-test.cxx | 4 | ||||
-rw-r--r-- | editeng/source/editeng/edtspell.cxx | 11 | ||||
-rw-r--r-- | editeng/source/misc/acorrcfg.cxx | 26 | ||||
-rw-r--r-- | editeng/source/misc/svxacorr.cxx | 9 | ||||
-rw-r--r-- | editeng/source/misc/swafopt.cxx | 1 |
6 files changed, 46 insertions, 7 deletions
diff --git a/editeng/inc/edtspell.hxx b/editeng/inc/edtspell.hxx index 43edeadd9213..efd9272f4859 100644 --- a/editeng/inc/edtspell.hxx +++ b/editeng/inc/edtspell.hxx @@ -132,6 +132,8 @@ public: virtual bool ChgAutoCorrWord( sal_Int32& rSttPos, sal_Int32 nEndPos, SvxAutoCorrect& rACorrect, OUString* pPara ) override; + virtual bool TransliterateRTLWord( sal_Int32& rSttPos, sal_Int32 nEndPos ) override; + virtual LanguageType GetLanguage( sal_Int32 nPos ) const override; diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx index a91565bce2a9..b98edae2b967 100644 --- a/editeng/qa/unit/core-test.cxx +++ b/editeng/qa/unit/core-test.cxx @@ -428,6 +428,10 @@ private: return false; } + virtual bool TransliterateRTLWord( sal_Int32& /*rSttPos*/, sal_Int32 /*nEndPos*/ ) override + { + return false; + } }; //https://bugs.libreoffice.org/show_bug.cgi?id=55693 diff --git a/editeng/source/editeng/edtspell.cxx b/editeng/source/editeng/edtspell.cxx index db4fa899f34d..04658edad326 100644 --- a/editeng/source/editeng/edtspell.cxx +++ b/editeng/source/editeng/edtspell.cxx @@ -680,6 +680,17 @@ bool EdtAutoCorrDoc::ChgAutoCorrWord( sal_Int32& rSttPos, return bRet; } +bool EdtAutoCorrDoc::TransliterateRTLWord( sal_Int32& /*rSttPos*/, + sal_Int32 /*nEndPos*/ ) +{ + // Paragraph-start or a blank found, search for the word + // shortcut in Auto + bool bRet = false; + + return bRet; +} + + LanguageType EdtAutoCorrDoc::GetLanguage( sal_Int32 nPos ) const { return mpEditEngine->GetLanguage( EditPaM( pCurNode, nPos+1 ) ); diff --git a/editeng/source/misc/acorrcfg.cxx b/editeng/source/misc/acorrcfg.cxx index 20648438d16a..d3e9f75b8413 100644 --- a/editeng/source/misc/acorrcfg.cxx +++ b/editeng/source/misc/acorrcfg.cxx @@ -109,9 +109,10 @@ Sequence<OUString> SvxBaseAutoCorrCfg::GetPropertyNames() "ReplaceDoubleQuote", // 14 "DoubleQuoteAtStart", // 15 "DoubleQuoteAtEnd", // 16 - "CorrectAccidentalCapsLock" // 17 + "CorrectAccidentalCapsLock", // 17 + "TransliterateRTL" // 18 }; - const int nCount = 18; + const int nCount = 19; Sequence<OUString> aNames(nCount); OUString* pNames = aNames.getArray(); for(int i = 0; i < nCount; i++) @@ -214,12 +215,16 @@ void SvxBaseAutoCorrCfg::Load(bool bInit) if(*o3tl::doAccess<bool>(pValues[nProp])) nFlags |= ACFlags::CorrectCapsLock; break;//"CorrectAccidentalCapsLock" + case 18: + if(*o3tl::doAccess<bool>(pValues[nProp])) + nFlags |= ACFlags::TransliterateRTL; + break;//"TransliterateRTL" } } } if( nFlags != ACFlags::NONE ) rParent.pAutoCorrect->SetAutoCorrFlag( nFlags ); - rParent.pAutoCorrect->SetAutoCorrFlag( ( static_cast<ACFlags>(0x3fff) & ~nFlags ), false ); + rParent.pAutoCorrect->SetAutoCorrFlag( ( static_cast<ACFlags>(0x7fff) & ~nFlags ), false ); } SvxBaseAutoCorrCfg::SvxBaseAutoCorrCfg(SvxAutoCorrCfg& rPar) : @@ -265,8 +270,10 @@ void SvxBaseAutoCorrCfg::ImplCommit() // "DoubleQuoteAtStart" css::uno::Any(sal_Int32(rParent.pAutoCorrect->GetEndDoubleQuote())), // "DoubleQuoteAtEnd" - css::uno::Any(bool(nFlags & ACFlags::CorrectCapsLock))}); + css::uno::Any(bool(nFlags & ACFlags::CorrectCapsLock)), // "CorrectAccidentalCapsLock" + css::uno::Any(bool(nFlags & ACFlags::TransliterateRTL))}); + // "TransliterateRTL" } void SvxBaseAutoCorrCfg::Notify( const Sequence<OUString>& /* aPropertyNames */) @@ -324,9 +331,10 @@ Sequence<OUString> SvxSwAutoCorrCfg::GetPropertyNames() "Format/ByInput/ApplyNumbering/SpecialCharacter/Font", //43 "Format/ByInput/ApplyNumbering/SpecialCharacter/FontFamily", //44 "Format/ByInput/ApplyNumbering/SpecialCharacter/FontCharset", //45 - "Format/ByInput/ApplyNumbering/SpecialCharacter/FontPitch" //46 + "Format/ByInput/ApplyNumbering/SpecialCharacter/FontPitch", //46 + "Format/Option/TransliterateRTL" //47 }; - const int nCount = 47; + const int nCount = 48; Sequence<OUString> aNames(nCount); OUString* pNames = aNames.getArray(); for(int i = 0; i < nCount; i++) @@ -476,6 +484,7 @@ void SvxSwAutoCorrCfg::Load(bool bInit) rSwFlags.aByInputBulletFont.SetPitch(FontPitch(nVal)); } break;// "Format/ByInput/ApplyNumbering/SpecialCharacter/FontPitch", + case 47 : rSwFlags.bTransliterateRTL = *o3tl::doAccess<bool>(pValues[nProp]); break; // "Format/Option/TransliterateRTL", } } } @@ -577,8 +586,11 @@ void SvxSwAutoCorrCfg::ImplCommit() // "Format/ByInput/ApplyNumbering/SpecialCharacter/FontFamily" css::uno::Any(sal_Int32(rSwFlags.aByInputBulletFont.GetCharSet())), // "Format/ByInput/ApplyNumbering/SpecialCharacter/FontCharset" - css::uno::Any(sal_Int32(rSwFlags.aByInputBulletFont.GetPitch()))}); + css::uno::Any(sal_Int32(rSwFlags.aByInputBulletFont.GetPitch())), // "Format/ByInput/ApplyNumbering/SpecialCharacter/FontPitch" + css::uno::Any(rSwFlags.bTransliterateRTL)}); + // "Format/Option/TransliterateRTL" + } void SvxSwAutoCorrCfg::Notify( const Sequence<OUString>& /* aPropertyNames */ ) diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index b381b1726f45..51fdf5c30746 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -285,6 +285,7 @@ ACFlags SvxAutoCorrect::GetDefaultFlags() | ACFlags::ChgOrdinalNumber | ACFlags::ChgToEnEmDash | ACFlags::AddNonBrkSpace + | ACFlags::TransliterateRTL | ACFlags::ChgWeightUnderl | ACFlags::SetINetAttr | ACFlags::ChgQuotes @@ -1525,6 +1526,14 @@ void SvxAutoCorrect::DoAutoCorrect( SvxAutoCorrDoc& rDoc, const OUString& rTxt, } } + if( IsAutoCorrFlag( ACFlags::TransliterateRTL ) && GetDocLanguage( rDoc, nInsPos ) == LANGUAGE_HUNGARIAN ) + { + // WARNING ATTENTION: rTxt is an alias of the text node's OUString + // and becomes INVALID if TransliterateRTLWord returns true! + if ( rDoc.TransliterateRTLWord( nCapLttrPos, nInsPos ) ) + break; + } + if( ( IsAutoCorrFlag( ACFlags::ChgOrdinalNumber ) && (nInsPos >= 2 ) && // fdo#69762 avoid autocorrect for 2e-3 ( '-' != cChar || 'E' != rtl::toAsciiUpperCase(rTxt[nInsPos-1]) || '0' > rTxt[nInsPos-2] || '9' < rTxt[nInsPos-2] ) && diff --git a/editeng/source/misc/swafopt.cxx b/editeng/source/misc/swafopt.cxx index 751b3e575a53..f682c690ae32 100644 --- a/editeng/source/misc/swafopt.cxx +++ b/editeng/source/misc/swafopt.cxx @@ -31,6 +31,7 @@ SvxSwAutoFormatFlags::SvxSwAutoFormatFlags() bChgEnumNum = bAddNonBrkSpace = bChgOrdinalNumber = + bTransliterateRTL = bChgToEnEmDash = bChgWeightUnderl = bSetINetAttr = |