20#include <config_wasm_strip.h>
22#include <rtl/ustring.hxx>
30#include <com/sun/star/frame/XStorable.hpp>
31#include <com/sun/star/linguistic2/XLinguProperties.hpp>
32#include <com/sun/star/linguistic2/XSpellChecker1.hpp>
33#include <com/sun/star/linguistic2/XHyphenator.hpp>
34#include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
35#include <com/sun/star/linguistic2/XDictionary.hpp>
41#include <editeng/editrids.hrc>
66 sal_Int32 nOldLen = rOldText.getLength();
67 sal_Int32 nNewLen = rNewText.size();
68 if (nOldLen && nNewLen)
70 bool bOldHasDot =
'.' == rOldText[ nOldLen - 1 ],
71 bNewHasDot =
'.' == rNewText[ nNewLen - 1 ];
72 if (bOldHasDot && !bNewHasDot
74 rOldText = rOldText.copy( 0, nOldLen - 1 );
78#define SVX_LANG_NEED_CHECK 0
80#define SVX_LANG_MISSING 2
81#define SVX_LANG_MISSING_DO_WARN 3
88 return aLangCheckState;
96 for (
auto const& elem : rLCS)
99 sal_uInt16 nVal = elem.second;
100 sal_uInt16 nTmpSpell = nVal & 0x00FF;
101 sal_uInt16 nTmpHyph = (nVal >> 8) & 0x00FF;
118 rLCS[ nLang ] = (nTmpHyph << 8) | nTmpSpell;
138 const bool bStart,
const bool bIsAllRight ) :
141 bOtherCntnt ( false ),
143 bRevAllowed ( true ),
144 bAllRight ( bIsAllRight )
147 bool bWrapReverse = xProp.is() && xProp->getIsWrapReverse();
155 Reference< XHyphenator >
const &xHyphenator,
156 const bool bStart,
const bool bOther ) :
158 xHyph ( xHyphenator ),
159 bOtherCntnt ( bOther ),
161 bStartDone ( bOther || bStart ),
163 bStartChk ( bOther ),
164 bRevAllowed ( false ),
171 Reference< XSpellChecker1 >
const & xSpell,
LanguageType nLang)
175 LangCheckState_map_t::iterator aIt( rLCS.find( nLang ) );
178 if (aIt == rLCS.end())
179 rLCS[ nLang ] = nVal;
184 if (xSpell.is() && xSpell->hasLanguage(
static_cast<sal_uInt16
>(nLang) ))
189 rLCS[ nLang ] = nVal;
192 return static_cast<sal_Int16
>(nVal);
196 Reference< XHyphenator >
const & xHyph,
LanguageType nLang)
200 LangCheckState_map_t::iterator aIt( rLCS.find( nLang ) );
201 sal_uInt16 nVal = aIt == rLCS.end() ? 0 : aIt->second;
203 if (aIt == rLCS.end())
204 rLCS[ nLang ] = nVal;
212 nVal |= nTmpVal << 8;
214 rLCS[ nLang ] = nVal;
217 return static_cast<sal_Int16
>(nVal);
254#if ENABLE_WASM_STRIP_HUNSPELL
271 Reference< XHyphenatedWord > xHyphWord(
GetLast(), UNO_QUERY );
278 xHyphWord->getWord(),
293 bool bWrapReverse = xProp.is() && xProp->getIsWrapReverse();
353 VclMessageType::Question, VclButtonsType::YesNo,
376 Reference< XDictionary > xDic;
381 Sequence< Reference< XDictionary > > aDics( xDicList->getDictionaries() );
382 const Reference< XDictionary > *pDic = aDics.getConstArray();
383 sal_Int32
nCount = aDics.getLength();
386 while (!xDic.is() &&
i <
nCount)
388 Reference< XDictionary > xTmp = pDic[
i];
391 if ( xTmp->isActive() &&
392 xTmp->getDictionaryType() != DictionaryType_NEGATIVE &&
395 Reference< frame::XStorable > xStor( xTmp, UNO_QUERY );
396 if (xStor.is() && xStor->hasLocation() && !xStor->isReadonly())
409 xDic->setActive(
true );
424 Reference< XDictionary > xAllRightDic;
432 Reference< XSpellAlternatives > xAlt(
GetLast(), UNO_QUERY );
433 Reference< XHyphenatedWord > xHyphWord(
GetLast(), UNO_QUERY );
439 xAllRightDic->add( xAlt->getWord(),
false, OUString() );
444 Reference< XDictionary > xChangeAllList =
446 Reference< XDictionaryEntry > xEntry;
447 if (xChangeAllList.is())
448 xEntry = xChangeAllList->getEntry( xAlt->getWord() );
459 else if (xHyphWord.is())
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
virtual VclPtr< AbstractHyphenWordDialog > CreateHyphenWordDialog(weld::Widget *, const OUString &rWord, LanguageType nLang, css::uno::Reference< css::linguistic2::XHyphenator > &xHyphen, SvxSpellWrapper *pWrapper)=0
static EditAbstractDialogFactory * Create()
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
LanguageType getLanguageType(bool bResolveSystem=true) const
static css::lang::Locale convertToLocale(LanguageType nLangID, bool bResolveSystem=true)
static css::uno::Reference< css::linguistic2::XDictionary > GetChangeAllList()
static css::uno::Reference< css::linguistic2::XSearchableDictionaryList > GetDictionaryList()
static css::uno::Reference< css::linguistic2::XDictionary > GetStandardDic()
static css::uno::Reference< css::linguistic2::XLinguProperties > GetLinguPropertySet()
static OUString GetLanguageString(const LanguageType eType)
const css::uno::Reference< css::uno::XInterface > & GetLast() const
SvxSpellWrapper(SvxSpellWrapper const &)=delete
css::uno::Reference< css::linguistic2::XHyphenator > xHyph
static void ShowLanguageErrors()
static sal_Int16 CheckHyphLang(css::uno::Reference< css::linguistic2::XHyphenator >const &xHyph, LanguageType nLang)
virtual ~SvxSpellWrapper()
virtual void SpellContinue()
virtual void SpellStart(SvxSpellArea eSpell)
virtual void ReplaceAll(const OUString &rNewText)
static css::uno::Reference< css::linguistic2::XDictionary > GetAllRightDic()
static sal_Int16 CheckSpellLang(css::uno::Reference< css::linguistic2::XSpellChecker1 > const &xSpell, LanguageType nLang)
std::unique_ptr< weld::WaitObject > xWait
virtual void InsertHyphen(const sal_Int32 nPos)
EDITENG_DLLPRIVATE bool SpellNext()
#define ERRCODE_SVX_LINGU_LANGUAGENOTEXISTS
OUString EditResId(TranslateId aId)
static LangCheckState_map_t & GetLangCheckState()
#define SVX_LANG_MISSING_DO_WARN
std::map< LanguageType, sal_uInt16 > LangCheckState_map_t
void SvxPrepareAutoCorrect(OUString &rOldText, std::u16string_view rNewText)
#define SVX_LANG_NEED_CHECK