summaryrefslogtreecommitdiff
path: root/cui/source/options/optdict.cxx
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2017-11-09 16:03:21 +0100
committerLászló Németh <nemeth@numbertext.org>2017-11-17 17:33:00 +0100
commit95d9f596336ebf19dc367f618b3788a4ce0ba542 (patch)
treed33140f4cc24c4f0fd5f46f165906e2908e857f7 /cui/source/options/optdict.cxx
parenta7ec994689f8ea5985f6c8f94f17a4417978ff41 (diff)
tdf#113739 add "Grammar By" feature to user dictionaries
Language-specific user dictionaries (en-US, de-DE, etc.) have got a new "Grammar By" field to specify optional automatic affixation and compounding of the new words by adding an example dictionary word. Test example: Create an en-US user dictionary. Add the new word "crowdfund" to it, also an example, the Hunspell en-US dictionary word "fund" in the optional "Grammar By" field. This way, the word "crowdfund" will be recognized by the spell checker with suffixes of the word "fund", too: crowdfund’s, crowdfunds, crowdfunder, crowdfunders and crowdfunding. Hunspell dictionaries with compound flag usage (German, Hungarian, etc.) can support automatic compounding of the new words, too. Change-Id: Id70dbee4544643967153f730ae64938e5cee0c82 Reviewed-on: https://gerrit.libreoffice.org/44562 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'cui/source/options/optdict.cxx')
-rw-r--r--cui/source/options/optdict.cxx29
1 files changed, 22 insertions, 7 deletions
diff --git a/cui/source/options/optdict.cxx b/cui/source/options/optdict.cxx
index c04584f08bb4..8b23f40c5445 100644
--- a/cui/source/options/optdict.cxx
+++ b/cui/source/options/optdict.cxx
@@ -227,6 +227,7 @@ SvxEditDictionaryDialog::SvxEditDictionaryDialog(
get(pWordED,"word");
get(pReplaceFT,"replace_label");
+ sReplaceFT_Text = pReplaceFT->GetText();
get(pReplaceED,"replace");
get(pWordsLB,"words");
pWordsLB->set_height_request(pWordsLB->GetTextHeight() * 8);
@@ -484,7 +485,22 @@ void SvxEditDictionaryDialog::ShowWords_Impl( sal_uInt16 nId )
pWordED->SetText(aStr);
pReplaceED->SetText(aStr);
- if(xDic->getDictionaryType() != DictionaryType_POSITIVE)
+ bool bIsNegative = xDic->getDictionaryType() != DictionaryType_POSITIVE;
+ bool bLangNone = LanguageTag(
+ xDic->getLocale() ).getLanguageType() == LANGUAGE_NONE;
+
+ // The label is "Replace By" only in negative dictionaries (forbidden
+ // words), otherwise "Grammar By" in language-specific dictionaries
+ // (where the optional second word is the sample word for
+ // the Hunspell based affixation/compounding of the new dictionary word)
+ if (bIsNegative)
+ {
+ pReplaceFT->SetText(sReplaceFT_Text);
+ } else if (!bLangNone) {
+ pReplaceFT->SetText(CuiResId(RID_SVXSTR_OPT_GRAMMAR_BY));
+ }
+
+ if(bIsNegative || !bLangNone)
{
nStaticTabs[0]=2;
@@ -525,7 +541,7 @@ void SvxEditDictionaryDialog::ShowWords_Impl( sal_uInt16 nId )
{
aStr = pEntry[i]->getDictionaryWord();
sal_uLong nPos = GetLBInsertPos( aStr );
- if(pEntry[i]->isNegative())
+ if(!pEntry[i]->getReplacementText().isEmpty())
{
aStr += "\t" + pEntry[i]->getReplacementText();
}
@@ -608,11 +624,10 @@ bool SvxEditDictionaryDialog::NewDelHdl(void const * pBtn)
{
// make changes in dic
- //! ...IsVisible should reflect whether the dictionary is a negativ
- //! or not (hopefully...)
- bool bIsNegEntry = pReplaceFT->IsVisible();
+ bool bIsNegEntry = xDic->getDictionaryType() == DictionaryType_NEGATIVE;
+
OUString aRplcText;
- if(bIsNegEntry)
+ if(!aReplaceStr.isEmpty())
aRplcText = aReplaceStr;
if (_pEntry) // entry selected in pWordsLB ie action = modify entry
@@ -635,7 +650,7 @@ bool SvxEditDictionaryDialog::NewDelHdl(void const * pBtn)
pWordsLB->SetUpdateMode(false);
sal_uLong _nPos = TREELIST_ENTRY_NOTFOUND;
- if(pReplaceFT->IsVisible())
+ if(!aReplaceStr.isEmpty())
{
sEntry += "\t" + aReplaceStr;
}