summaryrefslogtreecommitdiff
path: root/linguistic
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2022-12-30 10:26:07 +0100
committerLászló Németh <nemeth@numbertext.org>2022-12-30 11:03:39 +0000
commit57d79744c77eef96b4c2bd3b16e0a04317ffcf9e (patch)
tree7945482864b5be38eb2b88ba2c3fd38a1c21e293 /linguistic
parentb22bbfa25ab1f0b9cfa1dedc85b8f9874f0a5e5b (diff)
tdf#136306 offapi linguistic: add options to disable rule-based compounding
Add two new spell checking options to disable rule-based closed and hyphenated compound word recognition with Hunspell dictionaries: com::sun::star::linguistic2::XLinguProperties::IsSpellClosedCompound com::sun::star::linguistic2::XLinguProperties::IsSpellHyphenatedCompound For professional proofreaders, it can be more important to avoid of the mistakes of the rule-based compound word recognition, than to speed up proofreading. Disabling the following two new options will report all rule-based closed compound words (default in Dutch, German, Hungarian etc. dictionaries) and rule-based hyphenated compound words (all languages with BREAK usage in their Hunspell dictionaries): - "Accept possible closed compound words" - "Accept possible hyphenated compound words" For example, disabling the second one, dictionary word "scot-free" will be still correct word in English spell checking, but not the previously accepted compound "arbitrary-word-with-hyphen". Note: the second option works with the update to Hunspell 1.7.2. Change-Id: Id879610927d5e8269fda5ad207c1c2fe1f57a0b6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144875 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'linguistic')
-rw-r--r--linguistic/source/iprcache.cxx6
-rw-r--r--linguistic/source/lngopt.cxx8
-rw-r--r--linguistic/source/lngopt.hxx8
-rw-r--r--linguistic/source/lngprophelp.cxx42
-rw-r--r--linguistic/workben/sprophelp.cxx35
5 files changed, 93 insertions, 6 deletions
diff --git a/linguistic/source/iprcache.cxx b/linguistic/source/iprcache.cxx
index 2b82e5684d83..5dc0031cb139 100644
--- a/linguistic/source/iprcache.cxx
+++ b/linguistic/source/iprcache.cxx
@@ -37,7 +37,7 @@ namespace linguistic
{
-#define NUM_FLUSH_PROPS 6
+#define NUM_FLUSH_PROPS 8
const struct
{
@@ -49,7 +49,9 @@ const struct
{ UPN_IS_IGNORE_CONTROL_CHARACTERS, UPH_IS_IGNORE_CONTROL_CHARACTERS },
{ UPN_IS_SPELL_UPPER_CASE, UPH_IS_SPELL_UPPER_CASE },
{ UPN_IS_SPELL_WITH_DIGITS, UPH_IS_SPELL_WITH_DIGITS },
- { UPN_IS_SPELL_CAPITALIZATION, UPH_IS_SPELL_CAPITALIZATION }
+ { UPN_IS_SPELL_CAPITALIZATION, UPH_IS_SPELL_CAPITALIZATION },
+ { UPN_IS_SPELL_CLOSED_COMPOUND, UPH_IS_SPELL_CLOSED_COMPOUND },
+ { UPN_IS_SPELL_HYPHENATED_COMPOUND, UPH_IS_SPELL_HYPHENATED_COMPOUND }
};
diff --git a/linguistic/source/lngopt.cxx b/linguistic/source/lngopt.cxx
index f1cd69636a42..d46dfbb52bbd 100644
--- a/linguistic/source/lngopt.cxx
+++ b/linguistic/source/lngopt.cxx
@@ -115,7 +115,9 @@ WID_Name const aWID_Name[] =
{ 0, "" },
{ UPH_DEFAULT_LANGUAGE, UPN_DEFAULT_LANGUAGE },
{ UPH_DEFAULT_LOCALE_CJK, UPN_DEFAULT_LOCALE_CJK },
- { UPH_DEFAULT_LOCALE_CTL, UPN_DEFAULT_LOCALE_CTL }
+ { UPH_DEFAULT_LOCALE_CTL, UPN_DEFAULT_LOCALE_CTL },
+ { UPH_IS_SPELL_CLOSED_COMPOUND, UPN_IS_SPELL_CLOSED_COMPOUND },
+ { UPH_IS_SPELL_HYPHENATED_COMPOUND, UPN_IS_SPELL_HYPHENATED_COMPOUND }
};
@@ -166,9 +168,9 @@ static o3tl::span<const SfxItemPropertyMapEntry> lcl_GetLinguProps()
cppu::UnoType<bool>::get(), 0, 0 },
{ UPN_IS_SPELL_CAPITALIZATION, UPH_IS_SPELL_CAPITALIZATION,
cppu::UnoType<bool>::get(), 0, 0 },
- { UPN_IS_SPELL_HIDE, UPH_IS_SPELL_HIDE, /*! deprecated !*/
+ { UPN_IS_SPELL_CLOSED_COMPOUND, UPH_IS_SPELL_CLOSED_COMPOUND,
cppu::UnoType<bool>::get(), 0, 0 },
- { UPN_IS_SPELL_IN_ALL_LANGUAGES, UPH_IS_SPELL_IN_ALL_LANGUAGES, /*! deprecated !*/
+ { UPN_IS_SPELL_HYPHENATED_COMPOUND, UPH_IS_SPELL_HYPHENATED_COMPOUND,
cppu::UnoType<bool>::get(), 0, 0 },
{ UPN_IS_SPELL_SPECIAL, UPH_IS_SPELL_SPECIAL,
cppu::UnoType<bool>::get(), 0, 0 },
diff --git a/linguistic/source/lngopt.hxx b/linguistic/source/lngopt.hxx
index 896e345edb74..08dde49e117c 100644
--- a/linguistic/source/lngopt.hxx
+++ b/linguistic/source/lngopt.hxx
@@ -124,6 +124,14 @@ public:
{ return getPropertyBool(UPN_IS_SPELL_CAPITALIZATION); }
virtual void SAL_CALL setIsSpellCapitalization(sal_Bool p1) override
{ setProperty(UPN_IS_SPELL_CAPITALIZATION, static_cast<bool>(p1)); }
+ virtual sal_Bool SAL_CALL getIsSpellClosedCompound() override
+ { return getPropertyBool(UPN_IS_SPELL_CLOSED_COMPOUND); }
+ virtual void SAL_CALL setIsSpellClosedCompound(sal_Bool p1) override
+ { setProperty(UPN_IS_SPELL_CLOSED_COMPOUND, static_cast<bool>(p1)); }
+ virtual sal_Bool SAL_CALL getIsSpellHyphenatedCompound() override
+ { return getPropertyBool(UPN_IS_SPELL_HYPHENATED_COMPOUND); }
+ virtual void SAL_CALL setIsSpellHyphenatedCompound(sal_Bool p1) override
+ { setProperty(UPN_IS_SPELL_HYPHENATED_COMPOUND, static_cast<bool>(p1)); }
virtual sal_Int16 SAL_CALL getHyphMinLeading() override
{ return getPropertyInt16(UPN_HYPH_MIN_LEADING); }
virtual void SAL_CALL setHyphMinLeading(sal_Int16 p1) override
diff --git a/linguistic/source/lngprophelp.cxx b/linguistic/source/lngprophelp.cxx
index a14c96c9501e..543685dc33c4 100644
--- a/linguistic/source/lngprophelp.cxx
+++ b/linguistic/source/lngprophelp.cxx
@@ -292,6 +292,8 @@ PropertyHelper_Spell::PropertyHelper_Spell(
rPropNames.push_back(UPN_IS_SPELL_UPPER_CASE);
rPropNames.push_back(UPN_IS_SPELL_WITH_DIGITS);
rPropNames.push_back(UPN_IS_SPELL_CAPITALIZATION);
+ rPropNames.push_back(UPN_IS_SPELL_CLOSED_COMPOUND);
+ rPropNames.push_back(UPN_IS_SPELL_HYPHENATED_COMPOUND);
SetDefaultValues();
GetCurrentValues();
}
@@ -309,6 +311,8 @@ void PropertyHelper_Spell::SetDefaultValues()
bResIsSpellUpperCase = bIsSpellUpperCase = false;
bResIsSpellWithDigits = bIsSpellWithDigits = false;
bResIsSpellCapitalization = bIsSpellCapitalization = true;
+ bResIsSpellClosedCompound = bIsSpellClosedCompound = true;
+ bResIsSpellHyphenatedCompound = bIsSpellHyphenatedCompound = true;
}
@@ -340,6 +344,16 @@ void PropertyHelper_Spell::GetCurrentValues()
pbVal = &bIsSpellCapitalization;
pbResVal = &bResIsSpellCapitalization;
}
+ else if ( rPropName == UPN_IS_SPELL_CLOSED_COMPOUND )
+ {
+ pbVal = &bIsSpellClosedCompound;
+ pbResVal = &bResIsSpellClosedCompound;
+ }
+ else if ( rPropName == UPN_IS_SPELL_HYPHENATED_COMPOUND )
+ {
+ pbVal = &bIsSpellHyphenatedCompound;
+ pbResVal = &bResIsSpellHyphenatedCompound;
+ }
if (pbVal && pbResVal)
{
@@ -383,6 +397,20 @@ bool PropertyHelper_Spell::propertyChange_Impl( const PropertyChangeEvent& rEvt
bSWWA = !bSCWA; // sal_True->sal_False change?
break;
}
+ case UPH_IS_SPELL_CLOSED_COMPOUND :
+ {
+ pbVal = &bIsSpellClosedCompound;
+ bSCWA = ! *pbVal; // sal_False->sal_True change?
+ bSWWA = !bSCWA; // sal_True->sal_False change?
+ break;
+ }
+ case UPH_IS_SPELL_HYPHENATED_COMPOUND :
+ {
+ pbVal = &bIsSpellHyphenatedCompound;
+ bSCWA = ! *pbVal; // sal_False->sal_True change?
+ bSWWA = !bSCWA; // sal_True->sal_False change?
+ break;
+ }
default:
SAL_WARN( "linguistic", "unknown property" );
}
@@ -425,6 +453,8 @@ void PropertyHelper_Spell::SetTmpPropVals( const PropertyValues &rPropVals )
// temporary value
bResIsSpellWithDigits = bIsSpellWithDigits;
bResIsSpellCapitalization = bIsSpellCapitalization;
+ bResIsSpellClosedCompound = bIsSpellClosedCompound;
+ bResIsSpellHyphenatedCompound = bIsSpellHyphenatedCompound;
bResIsSpellUpperCase = bIsSpellUpperCase;
for (const PropertyValue& rVal : rPropVals)
@@ -441,6 +471,8 @@ void PropertyHelper_Spell::SetTmpPropVals( const PropertyValues &rPropVals )
case UPH_IS_SPELL_UPPER_CASE : pbResVal = &bResIsSpellUpperCase; break;
case UPH_IS_SPELL_WITH_DIGITS : pbResVal = &bResIsSpellWithDigits; break;
case UPH_IS_SPELL_CAPITALIZATION : pbResVal = &bResIsSpellCapitalization; break;
+ case UPH_IS_SPELL_CLOSED_COMPOUND : pbResVal = &bResIsSpellClosedCompound; break;
+ case UPH_IS_SPELL_HYPHENATED_COMPOUND : pbResVal = &bResIsSpellHyphenatedCompound; break;
default:
SAL_WARN( "linguistic", "unknown property" );
}
@@ -731,6 +763,16 @@ bool PropertyHelper_Spelling::IsSpellCapitalization() const
return mxPropHelper->IsSpellCapitalization();
}
+bool PropertyHelper_Spelling::IsSpellClosedCompound() const
+{
+ return mxPropHelper->IsSpellClosedCompound();
+}
+
+bool PropertyHelper_Spelling::IsSpellHyphenatedCompound() const
+{
+ return mxPropHelper->IsSpellHyphenatedCompound();
+}
+
bool PropertyHelper_Spelling::addLinguServiceEventListener(
const css::uno::Reference<
css::linguistic2::XLinguServiceEventListener >& rxListener )
diff --git a/linguistic/workben/sprophelp.cxx b/linguistic/workben/sprophelp.cxx
index 41542fec155f..9da626319a72 100644
--- a/linguistic/workben/sprophelp.cxx
+++ b/linguistic/workben/sprophelp.cxx
@@ -167,7 +167,9 @@ static const char *aSP[] =
UPN_IS_USE_DICTIONARY_LIST,
UPN_IS_SPELL_UPPER_CASE,
UPN_IS_SPELL_WITH_DIGITS,
- UPN_IS_SPELL_CAPITALIZATION
+ UPN_IS_SPELL_CAPITALIZATION,
+ UPN_IS_SPELL_CLOSED_COMPOUND,
+ UPN_IS_SPELL_HYPHENATED_COMPOUND
};
@@ -216,6 +218,16 @@ PropertyHelper_Spell::PropertyHelper_Spell(
pbVal = &bIsSpellCapitalization;
pbResVal = &bResIsSpellCapitalization;
}
+ else if (OUString( UPN_IS_SPELL_CLOSED_COMPOUND ) == pPropName[i])
+ {
+ pbVal = &bIsSpellClosedCompound;
+ pbResVal = &bResIsSpellClosedCompound;
+ }
+ else if (OUString( UPN_IS_SPELL_HYPHENATED_COMPOUND ) == pPropName[i])
+ {
+ pbVal = &bIsSpellHyphenatedCompound;
+ pbResVal = &bResIsSpellHyphenatedCompound;
+ }
if (pbVal && pbResVal)
{
@@ -240,6 +252,8 @@ void PropertyHelper_Spell::SetDefault()
bResIsSpellUpperCase = bIsSpellUpperCase = sal_False;
bResIsSpellWithDigits = bIsSpellWithDigits = sal_False;
bResIsSpellCapitalization = bIsSpellCapitalization = sal_True;
+ bResIsSpellClosedCompound = bIsSpellClosedCompound = sal_True;
+ bResIsSpellHyphenatedCompound = bIsSpellHyphenatedCompound = sal_True;
}
@@ -296,6 +310,21 @@ void SAL_CALL
bSWWA = !bSCWA; // sal_True->sal_False change?
break;
}
+ case UPH_IS_SPELL_CLOSED_COMPOUND :
+ {
+ pbVal = &bIsSpellClosedCompound;
+ bSCWA = sal_False == *pbVal; // sal_False->sal_True change?
+ bSWWA = !bSCWA; // sal_True->sal_False change?
+ break;
+ }
+ case UPH_IS_SPELL_HYPHENATED_COMPOUND :
+ {
+ pbVal = &bIsSpellHyphenatedCompound;
+ bSCWA = sal_False == *pbVal; // sal_False->sal_True change?
+ bSWWA = !bSCWA; // sal_True->sal_False change?
+ break;
+ }
+
default:
OSL_FAIL( "unknown property" );
}
@@ -325,6 +354,8 @@ void PropertyHelper_Spell::SetTmpPropVals( const PropertyValues &rPropVals )
bResIsSpellUpperCase = bIsSpellUpperCase;
bResIsSpellWithDigits = bIsSpellWithDigits;
bResIsSpellCapitalization = bIsSpellCapitalization;
+ bResIsSpellClosedCompound = bIsSpellClosedCompound;
+ bResIsSpellHyphenatedCompound = bIsSpellHyphenatedCompound;
sal_Int32 nLen = rPropVals.getLength();
if (nLen)
@@ -341,6 +372,8 @@ void PropertyHelper_Spell::SetTmpPropVals( const PropertyValues &rPropVals )
case UPH_IS_SPELL_UPPER_CASE : pbResVal = &bResIsSpellUpperCase; break;
case UPH_IS_SPELL_WITH_DIGITS : pbResVal = &bResIsSpellWithDigits; break;
case UPH_IS_SPELL_CAPITALIZATION : pbResVal = &bResIsSpellCapitalization; break;
+ case UPH_IS_SPELL_CLOSED_COMPOUND : pbResVal = &bResIsSpellClosedCompound; break;
+ case UPH_IS_SPELL_HYPHENATED_COMPOUND : pbResVal = &bResIsSpellHyphenatedCompound; break;
default:
OSL_FAIL( "unknown property" );
}