24#include <com/sun/star/linguistic2/LinguServiceEvent.hpp>
25#include <com/sun/star/linguistic2/LinguServiceEventFlags.hpp>
26#include <com/sun/star/linguistic2/XLinguServiceEventListener.hpp>
27#include <com/sun/star/linguistic2/XLinguProperties.hpp>
28#include <com/sun/star/beans/XPropertySet.hpp>
29#include <osl/mutex.hxx>
50PropertyChgHelper::PropertyChgHelper(
53 int nAllowedEvents ) :
58 nEvtFlags (nAllowedEvents)
63PropertyChgHelper::~PropertyChgHelper()
67void PropertyChgHelper::SetDefaultValues()
69 bResIsIgnoreControlCharacters = bIsIgnoreControlCharacters =
true;
70 bResIsUseDictionaryList = bIsUseDictionaryList =
true;
74void PropertyChgHelper::GetCurrentValues()
76 const auto& rPropNames = GetPropNames();
77 if (!GetPropSet().is() || rPropNames.empty())
80 for (
const OUString& rPropName : rPropNames)
82 bool *pbVal =
nullptr,
85 if ( rPropName == UPN_IS_IGNORE_CONTROL_CHARACTERS )
87 pbVal = &bIsIgnoreControlCharacters;
88 pbResVal = &bResIsIgnoreControlCharacters;
90 else if ( rPropName == UPN_IS_USE_DICTIONARY_LIST )
92 pbVal = &bIsUseDictionaryList;
93 pbResVal = &bResIsUseDictionaryList;
96 if (pbVal && pbResVal)
98 GetPropSet()->getPropertyValue( rPropName ) >>= *pbVal;
105void PropertyChgHelper::SetTmpPropVals(
const PropertyValues &rPropVals )
109 bResIsIgnoreControlCharacters = bIsIgnoreControlCharacters;
110 bResIsUseDictionaryList = bIsUseDictionaryList;
112 for (
const PropertyValue& rVal : rPropVals)
114 bool *pbResVal =
nullptr;
118 pbResVal = &bResIsIgnoreControlCharacters;
break;
120 pbResVal = &bResIsUseDictionaryList;
break;
125 rVal.Value >>= *pbResVal;
130bool PropertyChgHelper::propertyChange_Impl(
const PropertyChangeEvent& rEvt )
134 if (GetPropSet().is() && rEvt.Source == GetPropSet())
137 LinguServiceEventFlags::HYPHENATE_AGAIN : 0;
141 bool *pbVal =
nullptr;
142 switch (rEvt.PropertyHandle)
146 pbVal = &bIsIgnoreControlCharacters;
152 pbVal = &bIsUseDictionaryList;
153 bSCWA = bSWWA =
true;
158 rEvt.NewValue >>= *pbVal;
160 bRes =
nullptr != pbVal;
164 if (bSCWA && bSpellEvts)
165 nLngSvcFlags |= LinguServiceEventFlags::SPELL_CORRECT_WORDS_AGAIN;
166 if (bSWWA && bSpellEvts)
167 nLngSvcFlags |= LinguServiceEventFlags::SPELL_WRONG_WORDS_AGAIN;
170 LinguServiceEvent aEvt( GetEvtObj(), nLngSvcFlags );
181 PropertyChgHelper::propertyChange(
const PropertyChangeEvent& rEvt )
184 propertyChange_Impl( rEvt );
188void PropertyChgHelper::AddAsPropListener()
192 for (
const OUString& rPropName : std::as_const(aPropNames))
194 if (!rPropName.isEmpty())
195 xPropSet->addPropertyChangeListener( rPropName,
this );
200void PropertyChgHelper::RemoveAsPropListener()
204 for (
const OUString& rPropName : std::as_const(aPropNames))
206 if (!rPropName.isEmpty())
207 xPropSet->removePropertyChangeListener( rPropName,
this );
213void PropertyChgHelper::LaunchEvent(
const LinguServiceEvent &rEvt )
215 aLngSvcEvtListeners.notifyEach( &XLinguServiceEventListener::processLinguServiceEvent, rEvt );
219void SAL_CALL PropertyChgHelper::disposing(
const EventObject& rSource )
222 if (rSource.Source == xPropSet)
224 RemoveAsPropListener();
232 PropertyChgHelper::addLinguServiceEventListener(
240 sal_Int32
nCount = aLngSvcEvtListeners.getLength();
241 bRes = aLngSvcEvtListeners.addInterface( rxListener ) !=
nCount;
248 PropertyChgHelper::removeLinguServiceEventListener(
256 sal_Int32
nCount = aLngSvcEvtListeners.getLength();
257 bRes = aLngSvcEvtListeners.removeInterface( rxListener ) !=
nCount;
263PropertyHelper_Thes::PropertyHelper_Thes(
266 PropertyChgHelper ( rxSource, rxPropSet, 0 )
273PropertyHelper_Thes::~PropertyHelper_Thes()
282 PropertyChgHelper::propertyChange_Impl( rEvt );
286PropertyHelper_Spell::PropertyHelper_Spell(
291 auto& rPropNames = GetPropNames();
292 rPropNames.push_back(UPN_IS_SPELL_UPPER_CASE);
293 rPropNames.push_back(UPN_IS_SPELL_WITH_DIGITS);
294 rPropNames.push_back(UPN_IS_SPELL_CAPITALIZATION);
295 rPropNames.push_back(UPN_IS_SPELL_CLOSED_COMPOUND);
296 rPropNames.push_back(UPN_IS_SPELL_HYPHENATED_COMPOUND);
302PropertyHelper_Spell::~PropertyHelper_Spell()
307void PropertyHelper_Spell::SetDefaultValues()
309 PropertyChgHelper::SetDefaultValues();
311 bResIsSpellUpperCase = bIsSpellUpperCase =
false;
312 bResIsSpellWithDigits = bIsSpellWithDigits =
false;
313 bResIsSpellCapitalization = bIsSpellCapitalization =
true;
314 bResIsSpellClosedCompound = bIsSpellClosedCompound =
true;
315 bResIsSpellHyphenatedCompound = bIsSpellHyphenatedCompound =
true;
319void PropertyHelper_Spell::GetCurrentValues()
321 PropertyChgHelper::GetCurrentValues();
323 const auto& rPropNames = GetPropNames();
324 if (!GetPropSet().is() || rPropNames.empty())
327 for (
const OUString& rPropName : rPropNames)
329 bool *pbVal =
nullptr,
332 if ( rPropName == UPN_IS_SPELL_UPPER_CASE )
334 pbVal = &bIsSpellUpperCase;
335 pbResVal = &bResIsSpellUpperCase;
337 else if ( rPropName == UPN_IS_SPELL_WITH_DIGITS )
339 pbVal = &bIsSpellWithDigits;
340 pbResVal = &bResIsSpellWithDigits;
342 else if ( rPropName == UPN_IS_SPELL_CAPITALIZATION )
344 pbVal = &bIsSpellCapitalization;
345 pbResVal = &bResIsSpellCapitalization;
347 else if ( rPropName == UPN_IS_SPELL_CLOSED_COMPOUND )
349 pbVal = &bIsSpellClosedCompound;
350 pbResVal = &bResIsSpellClosedCompound;
352 else if ( rPropName == UPN_IS_SPELL_HYPHENATED_COMPOUND )
354 pbVal = &bIsSpellHyphenatedCompound;
355 pbResVal = &bResIsSpellHyphenatedCompound;
358 if (pbVal && pbResVal)
360 GetPropSet()->getPropertyValue( rPropName ) >>= *pbVal;
367bool PropertyHelper_Spell::propertyChange_Impl(
const PropertyChangeEvent& rEvt )
369 bool bRes = PropertyChgHelper::propertyChange_Impl( rEvt );
371 if (!bRes && GetPropSet().is() && rEvt.Source == GetPropSet())
376 bool *pbVal =
nullptr;
377 switch (rEvt.PropertyHandle)
381 pbVal = &bIsSpellUpperCase;
388 pbVal = &bIsSpellWithDigits;
395 pbVal = &bIsSpellCapitalization;
402 pbVal = &bIsSpellClosedCompound;
409 pbVal = &bIsSpellHyphenatedCompound;
415 SAL_WARN(
"linguistic",
"unknown property handle " << rEvt.PropertyHandle <<
" (check in include/unotools/linguprops.hxx)" );
418 rEvt.NewValue >>= *pbVal;
420 bRes = (pbVal !=
nullptr);
423 sal_Int16 nLngSvcFlags = 0;
425 nLngSvcFlags |= LinguServiceEventFlags::SPELL_CORRECT_WORDS_AGAIN;
427 nLngSvcFlags |= LinguServiceEventFlags::SPELL_WRONG_WORDS_AGAIN;
430 LinguServiceEvent aEvt( GetEvtObj(), nLngSvcFlags );
441 PropertyHelper_Spell::propertyChange(
const PropertyChangeEvent& rEvt )
444 propertyChange_Impl( rEvt );
448void PropertyHelper_Spell::SetTmpPropVals(
const PropertyValues &rPropVals )
450 PropertyChgHelper::SetTmpPropVals( rPropVals );
454 bResIsSpellWithDigits = bIsSpellWithDigits;
455 bResIsSpellCapitalization = bIsSpellCapitalization;
456 bResIsSpellClosedCompound = bIsSpellClosedCompound;
457 bResIsSpellHyphenatedCompound = bIsSpellHyphenatedCompound;
458 bResIsSpellUpperCase = bIsSpellUpperCase;
460 for (
const PropertyValue& rVal : rPropVals)
468 bool *pbResVal =
nullptr;
477 SAL_WARN(
"linguistic",
"unknown property handle " << rVal.Handle <<
" (check in include/unotools/linguprops.hxx)" );
480 rVal.Value >>= *pbResVal;
490 auto& rPropNames = GetPropNames();
491 rPropNames.push_back(UPN_HYPH_MIN_LEADING);
492 rPropNames.push_back(UPN_HYPH_MIN_TRAILING);
493 rPropNames.push_back(UPN_HYPH_MIN_WORD_LENGTH);
506 PropertyChgHelper::SetDefaultValues();
517 PropertyChgHelper::GetCurrentValues();
519 const auto& rPropNames = GetPropNames();
520 if (!GetPropSet().is() || rPropNames.empty())
523 for (
const OUString& rPropName : rPropNames)
525 sal_Int16 *pnVal =
nullptr,
527 bool *pbVal =
nullptr;
528 bool *pbResVal =
nullptr;
551 if (pnVal && pnResVal)
553 GetPropSet()->getPropertyValue( rPropName ) >>= *pnVal;
556 else if (pbVal && pbResVal)
558 GetPropSet()->getPropertyValue( rPropName ) >>= *pbVal;
567 bool bRes = PropertyChgHelper::propertyChange_Impl( rEvt );
569 if (!bRes && GetPropSet().is() && rEvt.Source == GetPropSet())
571 sal_Int16 *pnVal =
nullptr;
572 bool *pbVal =
nullptr;
573 switch (rEvt.PropertyHandle)
580 SAL_WARN(
"linguistic",
"unknown property handle " << rEvt.PropertyHandle <<
" (check in include/unotools/linguprops.hxx)");
583 rEvt.NewValue >>= *pnVal;
585 rEvt.NewValue >>= *pbVal;
587 bRes = (pnVal !=
nullptr || pbVal !=
nullptr);
590 LinguServiceEvent aEvt(GetEvtObj(), LinguServiceEventFlags::HYPHENATE_AGAIN);
609 PropertyChgHelper::SetTmpPropVals( rPropVals );
618 for (
const PropertyValue& rVal : rPropVals)
620 sal_Int16 *pnResVal =
nullptr;
621 bool *pbResVal =
nullptr;
632 SAL_WARN_IF( !(pnResVal || pbResVal),
"linguistic",
"unknown property '" << rVal.Name <<
"'");
635 rVal.Value >>= *pnResVal;
637 rVal.Value >>= *pbResVal;
641PropertyHelper_Thesaurus::PropertyHelper_Thesaurus(
642 const css::uno::Reference< css::uno::XInterface > &rxSource,
643 css::uno::Reference< css::linguistic2::XLinguProperties >
const &rxPropSet )
648PropertyHelper_Thesaurus::~PropertyHelper_Thesaurus()
652void PropertyHelper_Thesaurus::AddAsPropListener()
654 mxPropHelper->AddAsPropListener();
657void PropertyHelper_Thesaurus::RemoveAsPropListener()
659 mxPropHelper->RemoveAsPropListener();
662void PropertyHelper_Thesaurus::SetTmpPropVals(
const css::beans::PropertyValues &rPropVals )
664 mxPropHelper->SetTmpPropVals( rPropVals );
667PropertyHelper_Hyphenation::PropertyHelper_Hyphenation(
668 const css::uno::Reference< css::uno::XInterface > &rxSource,
669 css::uno::Reference< css::linguistic2::XLinguProperties >
const &rxPropSet)
674PropertyHelper_Hyphenation::~PropertyHelper_Hyphenation()
678void PropertyHelper_Hyphenation::AddAsPropListener()
680 mxPropHelper->AddAsPropListener();
683void PropertyHelper_Hyphenation::RemoveAsPropListener()
685 mxPropHelper->RemoveAsPropListener();
688void PropertyHelper_Hyphenation::SetTmpPropVals(
const css::beans::PropertyValues &rPropVals )
690 mxPropHelper->SetTmpPropVals( rPropVals );
693sal_Int16 PropertyHelper_Hyphenation::GetMinLeading()
const
695 return mxPropHelper->GetMinLeading();
698sal_Int16 PropertyHelper_Hyphenation::GetMinTrailing()
const
700 return mxPropHelper->GetMinTrailing();
703sal_Int16 PropertyHelper_Hyphenation::GetMinWordLength()
const
705 return mxPropHelper->GetMinWordLength();
708bool PropertyHelper_Hyphenation::IsNoHyphenateCaps()
const
710 return mxPropHelper->IsNoHyphenateCaps();
713bool PropertyHelper_Hyphenation::addLinguServiceEventListener(
714 const css::uno::Reference< css::linguistic2::XLinguServiceEventListener >& rxListener )
716 return mxPropHelper->addLinguServiceEventListener( rxListener );
719bool PropertyHelper_Hyphenation::removeLinguServiceEventListener(
720 const css::uno::Reference< css::linguistic2::XLinguServiceEventListener >& rxListener )
722 return mxPropHelper->removeLinguServiceEventListener( rxListener );
725PropertyHelper_Spelling::PropertyHelper_Spelling(
726 const css::uno::Reference< css::uno::XInterface > &rxSource,
727 css::uno::Reference< css::linguistic2::XLinguProperties >
const &rxPropSet )
729 mxPropHelper =
new PropertyHelper_Spell( rxSource, rxPropSet );
732PropertyHelper_Spelling::~PropertyHelper_Spelling()
736void PropertyHelper_Spelling::AddAsPropListener()
738 mxPropHelper->AddAsPropListener();
741void PropertyHelper_Spelling::RemoveAsPropListener()
743 mxPropHelper->RemoveAsPropListener();
746void PropertyHelper_Spelling::SetTmpPropVals(
const css::beans::PropertyValues &rPropVals )
748 mxPropHelper->SetTmpPropVals( rPropVals );
751bool PropertyHelper_Spelling::IsSpellUpperCase()
const
753 return mxPropHelper->IsSpellUpperCase();
756bool PropertyHelper_Spelling::IsSpellWithDigits()
const
758 return mxPropHelper->IsSpellWithDigits();
761bool PropertyHelper_Spelling::IsSpellCapitalization()
const
763 return mxPropHelper->IsSpellCapitalization();
766bool PropertyHelper_Spelling::IsSpellClosedCompound()
const
768 return mxPropHelper->IsSpellClosedCompound();
771bool PropertyHelper_Spelling::IsSpellHyphenatedCompound()
const
773 return mxPropHelper->IsSpellHyphenatedCompound();
776bool PropertyHelper_Spelling::addLinguServiceEventListener(
777 const css::uno::Reference<
778 css::linguistic2::XLinguServiceEventListener >& rxListener )
780 return mxPropHelper->addLinguServiceEventListener( rxListener );
783bool PropertyHelper_Spelling::removeLinguServiceEventListener(
784 const css::uno::Reference<
785 css::linguistic2::XLinguServiceEventListener >& rxListener )
787 return mxPropHelper->removeLinguServiceEventListener( rxListener );
sal_Int16 nResHyphMinWordLength
virtual void GetCurrentValues() override
sal_Int16 nHyphMinWordLength
virtual bool propertyChange_Impl(const css::beans::PropertyChangeEvent &rEvt) override
virtual ~PropertyHelper_Hyphen() override
sal_Int16 nResHyphMinLeading
virtual void SetTmpPropVals(const css::beans::PropertyValues &rPropVals) override
PropertyHelper_Hyphen(const PropertyHelper_Hyphen &)=delete
sal_Int16 nHyphMinLeading
virtual void SetDefaultValues() override
virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent &rEvt) override
sal_Int16 nHyphMinTrailing
sal_Int16 nResHyphMinTrailing
virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent &rEvt) override
#define UPH_HYPH_MIN_WORD_LENGTH
#define UPH_IS_SPELL_WITH_DIGITS
#define UPH_IS_SPELL_CLOSED_COMPOUND
#define UPH_HYPH_MIN_LEADING
#define UPH_IS_SPELL_HYPHENATED_COMPOUND
constexpr OUStringLiteral UPN_HYPH_NO_CAPS
constexpr OUStringLiteral UPN_IS_USE_DICTIONARY_LIST
constexpr OUStringLiteral UPN_HYPH_MIN_WORD_LENGTH
constexpr OUStringLiteral UPN_HYPH_MIN_LEADING
#define UPH_IS_SPELL_UPPER_CASE
constexpr OUStringLiteral UPN_IS_IGNORE_CONTROL_CHARACTERS
#define UPH_HYPH_MIN_TRAILING
constexpr OUStringLiteral UPN_HYPH_MIN_TRAILING
#define UPH_IS_USE_DICTIONARY_LIST
#define UPH_IS_SPELL_CAPITALIZATION
#define UPH_IS_IGNORE_CONTROL_CHARACTERS
constexpr OUStringLiteral UPN_MAX_NUMBER_OF_SUGGESTIONS
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
std::map< sal_Int32, std::shared_ptr< SetItemPropertyStorage > > PropertyValues
osl::Mutex & GetLinguMutex()
! multi-thread safe mutex for all platforms !!
const PropertyStruct aPropNames[]