23 #include <sfx2/sfxsids.hrc>
36 #include <com/sun/star/lang/XServiceInfo.hpp>
37 #include <com/sun/star/frame/XStorable.hpp>
38 #include <com/sun/star/linguistic2/XDictionary.hpp>
39 #include <com/sun/star/linguistic2/XSpellAlternatives.hpp>
40 #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
41 #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
43 #include <rtl/ustrbuf.hxx>
69 Sequence< Reference< XDictionary > >
aDics;
73 #define SPELLUNDO_START 200
75 #define SPELLUNDO_CHANGE_LANGUAGE (SPELLUNDO_START + 1)
76 #define SPELLUNDO_CHANGE_TEXTENGINE (SPELLUNDO_START + 2)
77 #define SPELLUNDO_CHANGE_NEXTERROR (SPELLUNDO_START + 3)
78 #define SPELLUNDO_CHANGE_ADD_TO_DICTIONARY (SPELLUNDO_START + 4)
79 #define SPELLUNDO_CHANGE_GROUP (SPELLUNDO_START + 5) //undo list
80 #define SPELLUNDO_MOVE_ERROREND (SPELLUNDO_START + 6)
81 #define SPELLUNDO_UNDO_EDIT_MODE (SPELLUNDO_START + 7)
82 #define SPELLUNDO_ADD_IGNORE_RULE (SPELLUNDO_START + 8)
105 m_rActionLink( rActionLink),
106 m_bEnableChangePB(false),
107 m_bEnableChangeAllPB(false),
108 m_nOldErrorStart(-1),
110 m_bIsErrorLanguageSelected(false),
114 virtual void Undo()
override;
115 sal_uInt16 GetId()
const;
125 m_nOldErrorStart = nOldStart;
126 m_nOldErrorEnd = nOldEnd;
134 void SetDictionary(
const Reference<XDictionary>& xDict) { m_xDictionary = xDict; }
135 const Reference<XDictionary>&
GetDictionary()
const {
return m_xDictionary; }
143 using namespace ::
svx;
145 void SpellUndoAction_Impl::Undo()
147 m_rActionLink.Call(*
this);
151 sal_uInt16 SpellUndoAction_Impl::GetId()
const
161 pParent,
"cui/ui/spellingdialog.ui",
"SpellingDialog")
164 , rParent(*pChildWindow)
166 , m_xAltTitle(m_xBuilder->weld_label(
"alttitleft"))
167 , m_xResumeFT(m_xBuilder->weld_label(
"resumeft"))
168 , m_xNoSuggestionsFT(m_xBuilder->weld_label(
"nosuggestionsft"))
169 , m_xLanguageFT(m_xBuilder->weld_label(
"languageft"))
170 , m_xLanguageLB(new
SvxLanguageBox(m_xBuilder->weld_combo_box(
"languagelb")))
171 , m_xExplainFT(m_xBuilder->weld_label(
"explain"))
172 , m_xExplainLink(m_xBuilder->weld_link_button(
"explainlink"))
173 , m_xNotInDictFT(m_xBuilder->weld_label(
"notindictft"))
175 , m_xSuggestionFT(m_xBuilder->weld_label(
"suggestionsft"))
176 , m_xSuggestionLB(m_xBuilder->weld_tree_view(
"suggestionslb"))
177 , m_xIgnorePB(m_xBuilder->weld_button(
"ignore"))
178 , m_xIgnoreAllPB(m_xBuilder->weld_button(
"ignoreall"))
179 , m_xIgnoreRulePB(m_xBuilder->weld_button(
"ignorerule"))
180 , m_xAddToDictPB(m_xBuilder->weld_button(
"add"))
181 , m_xAddToDictMB(m_xBuilder->weld_menu_button(
"addmb"))
182 , m_xChangePB(m_xBuilder->weld_button(
"change"))
183 , m_xChangeAllPB(m_xBuilder->weld_button(
"changeall"))
184 , m_xAutoCorrPB(m_xBuilder->weld_button(
"autocorrect"))
185 , m_xCheckGrammarCB(m_xBuilder->weld_check_button(
"checkgrammar"))
186 , m_xOptionsPB(m_xBuilder->weld_button(
"options"))
187 , m_xUndoPB(m_xBuilder->weld_button(
"undo"))
188 , m_xClosePB(m_xBuilder->weld_button(
"close"))
189 , m_xToolbar(m_xBuilder->weld_toolbar(
"toolbar"))
190 , m_xSentenceEDWeld(new
weld::CustomWeld(*m_xBuilder,
"sentence", *m_xSentenceED))
201 m_xDialog->set_title(
m_xDialog->strip_mnemonic(sTitle.replaceFirst(
"$LANGUAGE ($LOCATION)",
"")));
262 m_xLanguageLB->SetLanguageList(SvxLanguageListFlags::SPELL_USED,
false,
false,
true);
274 bool bSpellErrorDescription =
m_xSentenceED->GetAlternatives(aSpellErrorDescription);
278 bool bIsGrammarError =
false;
279 if( bSpellErrorDescription )
287 if( bSpellErrorDescription && !aSpellErrorDescription.
sDialogTitle.isEmpty() )
296 if( !bCallFromSelectHdl )
301 const OUString *pNewWords = aNewWords.getConstArray();
302 const sal_Int32 nSize = aNewWords.getLength();
303 for ( i = 0; i < nSize; ++i )
305 OUString aTmp( pNewWords[i] );
321 bool bShowChangeAll = !bIsGrammarError;
353 bool bNextSentence =
false;
359 bool bSpellErrorDescription =
m_xSentenceED->GetAlternatives(aSpellErrorDescription);
360 if (bSpellErrorDescription)
375 while(aControls[++nIdx]);
392 m_xAutoCorrPB->set_visible(rParent.HasAutoCorrection());
393 SpellContinue_Impl(
nullptr);
394 m_xSentenceED->ResetUndo();
395 m_xUndoPB->set_sensitive(
false);
403 LockFocusChanges(
true);
404 if( m_xChangePB->get_sensitive() )
405 m_xChangePB->grab_focus();
406 else if( m_xIgnorePB->get_sensitive() )
407 m_xIgnorePB->grab_focus();
408 else if( m_xClosePB->get_sensitive() )
409 m_xClosePB->grab_focus();
410 LockFocusChanges(
false);
412 m_xCheckGrammarCB->set_active(rParent.IsGrammarChecking());
418 if (m_xOptionsPB.get() == &rBtn)
419 StartSpellOptDlg_Impl();
420 else if (m_xAutoCorrPB.get() == &rBtn)
423 OUString sCurrentErrorText = m_xSentenceED->GetErrorText();
425 SpellErrorDescription aSpellErrorDescription;
426 bool bSpellErrorDescription = m_xSentenceED->GetAlternatives(aSpellErrorDescription);
427 if (bSpellErrorDescription)
429 OUString sWrong(aSpellErrorDescription.sErrorText);
433 if(sWrong == sCurrentErrorText &&
434 m_xSuggestionLB->get_sensitive() && m_xSuggestionLB->get_selected_index() != -1 &&
435 m_sNoSuggestionsST != m_xSuggestionLB->get_selected_text())
437 sCurrentErrorText = m_xSuggestionLB->get_selected_text();
439 if(sWrong != sCurrentErrorText)
443 rParent.AddAutoCorrection( sWrong, sCurrentErrorText, eLang );
451 rParent.SetGrammarChecking(m_xCheckGrammarCB->get_active());
462 aDlg.SetTabPage(std::move(xPage));
466 const SfxItemSet* pOutSet = aDlg.GetOutputItemSet();
474 OUString getDotReplacementString(
const OUString &rErrorText,
const OUString &rSuggestedReplacement)
476 OUString aString = rErrorText;
479 bool bDot = aString.endsWith(
".");
481 aString = rSuggestedReplacement;
483 if(bDot && (aString.isEmpty() || !aString.endsWith(
".")))
494 OUString sReplacement(sOrigString);
501 return getDotReplacementString(sOrigString, sReplacement);
506 ChangeHdl(*m_xChangePB);
521 : m_rSentenceED(rSentenceED)
527 m_rSentenceED.UndoActionEnd();
533 if (m_xSentenceED->IsUndoEditMode())
535 SpellContinue_Impl();
539 auto xGuard(std::make_unique<UndoChangeGroupGuard>(*m_xSentenceED));
540 OUString aString = getReplacementString();
541 m_xSentenceED->ChangeMarkedWord(aString, GetSelectedLang_Impl());
542 SpellContinue_Impl(&xGuard);
544 if(!m_xChangePB->get_sensitive())
545 m_xIgnorePB->grab_focus();
550 auto xGuard(std::make_unique<UndoChangeGroupGuard>(*m_xSentenceED));
551 OUString aString = getReplacementString();
555 OUString aOldWord( m_xSentenceED->GetErrorText() );
562 if(nAdded == DictionaryError::NONE)
564 std::unique_ptr<SpellUndoAction_Impl> pAction(
new SpellUndoAction_Impl(
566 pAction->SetDictionary(aXDictionary);
567 pAction->SetAddedWord(aOldWord);
568 m_xSentenceED->AddUndoAction(std::move(pAction));
571 m_xSentenceED->ChangeMarkedWord(aString, eLang);
572 SpellContinue_Impl(&xGuard);
577 auto xGuard(std::make_unique<UndoChangeGroupGuard>(*m_xSentenceED));
581 m_xSentenceED->RestoreCurrentError();
582 if (&rButton == m_xIgnoreRulePB.get())
584 SpellErrorDescription aSpellErrorDescription;
585 bool bSpellErrorDescription = m_xSentenceED->GetAlternatives(aSpellErrorDescription);
588 if( bSpellErrorDescription && aSpellErrorDescription.xGrammarChecker.is() )
590 aSpellErrorDescription.xGrammarChecker->ignoreRule(aSpellErrorDescription.sRuleId,
591 aSpellErrorDescription.aLocale);
593 aXDictionary->setActive(
false);
594 aXDictionary->setActive(
true);
597 catch(
const uno::Exception& )
603 OUString sErrorText(m_xSentenceED->GetErrorText());
607 if (nAdded == DictionaryError::NONE)
609 std::unique_ptr<SpellUndoAction_Impl> pAction(
new SpellUndoAction_Impl(
611 pAction->SetDictionary(aXDictionary);
612 pAction->SetAddedWord(sErrorText);
613 m_xSentenceED->AddUndoAction(std::move(pAction));
617 SpellContinue_Impl(&xGuard);
622 m_xSentenceED->Undo();
623 if(!m_xSentenceED->GetUndoActionCount())
624 m_xUndoPB->set_sensitive(
false);
628 IMPL_LINK( SpellDialog, DialogUndoHdl, SpellUndoAction_Impl&, rAction,
void )
630 switch(rAction.GetId())
634 if(rAction.IsEnableChangePB())
635 m_xChangePB->set_sensitive(
false);
636 if(rAction.IsEnableChangeAllPB())
637 m_xChangeAllPB->set_sensitive(
false);
642 m_xSentenceED->MoveErrorMarkTo(static_cast<sal_Int32>(rAction.GetOldErrorStart()),
643 static_cast<sal_Int32>(rAction.GetOldErrorEnd()),
645 if(rAction.IsErrorLanguageSelected())
653 if(rAction.GetDictionary().is())
654 rAction.GetDictionary()->remove(rAction.GetAddedWord());
659 if(rAction.GetOffset() != 0)
660 m_xSentenceED->MoveErrorEnd(rAction.GetOffset());
666 SpellContinue_Impl(
nullptr,
true);
689 if (m_sResumeST == m_xIgnorePB->get_label())
697 m_xSentenceED->RestoreCurrentError();
700 SpellContinue_Impl(
nullptr,
false,
true);
733 OUString sError = m_xSentenceED->GetErrorText();
734 m_xSuggestionLB->clear();
735 if (!sError.isEmpty())
737 LanguageType eLanguage = m_xLanguageLB->get_active_id();
738 Reference <XSpellAlternatives> xAlt = xSpell->spell( sError, static_cast<sal_uInt16>(eLanguage),
739 Sequence< PropertyValue >() );
741 m_xSentenceED->SetAlternatives( xAlt );
744 m_xSentenceED->ChangeMarkedWord( sError, eLanguage );
745 SpellContinue_Impl();
764 const Reference< XDictionary > *pDic =
nullptr;
775 xDic->setActive(
true );
777 pImpl->aDics = xDicList->getDictionaries();
783 bool bEnable =
false;
784 const sal_Int32 nSize =
pImpl->aDics.getLength();
785 pDic =
pImpl->aDics.getConstArray();
787 sal_uInt16 nItemId = 1;
788 for (sal_Int32
i = 0;
i < nSize; ++
i)
790 uno::Reference< linguistic2::XDictionary > xDicTmp = pDic[
i];
794 uno::Reference< frame::XStorable > xStor( xDicTmp, uno::UNO_QUERY );
796 if( xDicTmp->isActive()
797 && xDicTmp->getDictionaryType() != linguistic2::DictionaryType_NEGATIVE
799 && (!xStor.is() || !xStor->isReadonly()) )
803 OUString aDictionaryImageUrl;
804 uno::Reference< lang::XServiceInfo > xSvcInfo( xDicTmp, uno::UNO_QUERY );
808 xSvcInfo->getImplementationName());
811 m_xAddToDictMB->append_item(OUString::number(nItemId), xDicTmp->getName(), aDictionaryImageUrl);
819 int nDicts = nItemId-1;
829 AddToDictionaryExecute(OString::number(1));
832 IMPL_LINK(SpellDialog, AddToDictSelectHdl,
const OString&, rIdent,
void)
834 AddToDictionaryExecute(rIdent);
839 auto xGuard(std::make_unique<UndoChangeGroupGuard>(*
m_xSentenceED));
847 uno::Reference< linguistic2::XDictionary > xDic;
850 xDic = xDicList->getDictionaryByName( aDicName );
855 nAddRes =
AddEntryToDic( xDic, aNewWord,
false, OUString() );
857 uno::Reference< frame::XStorable > xSavDic( xDic, uno::UNO_QUERY );
861 if (nAddRes == DictionaryError::NONE)
865 pAction->SetDictionary( xDic );
866 pAction->SetAddedWord( aNewWord );
870 if (DictionaryError::NONE != nAddRes && xDic->getEntry( aNewWord ).is())
871 nAddRes = DictionaryError::NONE;
873 if (DictionaryError::NONE != nAddRes)
885 m_xSuggestionLB->unselect_all();
886 m_xSuggestionLB->set_sensitive(
false);
887 m_xAutoCorrPB->set_sensitive(
false);
889 if(!m_xChangeAllPB->get_sensitive())
891 m_xChangeAllPB->set_sensitive(
true);
892 pSpellAction->SetEnableChangeAllPB();
894 if(!m_xChangePB->get_sensitive())
896 m_xChangePB->set_sensitive(
true);
897 pSpellAction->SetEnableChangePB();
899 m_xSentenceED->AddUndoAction(std::move(pSpellAction));
905 rParent.ApplyChangedSentence(m_xSentenceED->CreateSpellPortions(),
false);
971 while(aDisableArr[i])
982 if(!bUseSavedSentence)
990 if(!bUseSavedSentence)
992 bool bHasReplaced =
false;
993 while(!aSentence.empty())
1007 if(!aSentence.empty())
1009 OUStringBuffer sText;
1010 for (
auto const& elem : aSentence)
1014 sText.append(elem.sText);
1020 sal_Int32 nStartPosition = 0;
1021 sal_Int32 nEndPosition = 0;
1023 for (
auto const& elem : aSentence)
1028 nEndPosition += elem.sText.getLength();
1029 if(elem.xAlternatives.is())
1032 elem.xAlternatives->getLocale(), elem.xAlternatives->getAlternatives(),
nullptr);
1034 aSpellErrorDescription.GetGrabBag()[
"SpellErrorDescription"] <<= aDesc.toSequence();
1035 m_xSentenceED->SetAttrib(aSpellErrorDescription, nStartPosition, nEndPosition);
1037 else if(elem.bIsGrammarError )
1039 beans::PropertyValues
aProperties = elem.aGrammarError.aProperties;
1040 OUString sFullCommentURL;
1042 while ( sFullCommentURL.isEmpty() && i < aProperties.getLength() )
1044 if ( aProperties[i].
Name ==
"FullCommentURL" )
1047 aValue >>= sFullCommentURL;
1055 elem.aGrammarError.aSuggestions,
1056 elem.xGrammarChecker,
1058 &elem.aGrammarError.aFullComment,
1059 &elem.aGrammarError.aRuleIdentifier,
1064 m_xSentenceED->SetAttrib(aSpellErrorDescriptionItem, nStartPosition, nEndPosition);
1070 nStartPosition = nEndPosition;
1078 bRet = nStartPosition > 0;
1088 bHasReplaced =
false;
1091 if(!xChangeAll->getCount())
1094 for (
auto & elem : rSentence)
1096 if(elem.xAlternatives.is())
1098 const OUString &rString = elem.sText;
1100 Reference<XDictionaryEntry> xEntry = xChangeAll->getEntry(rString);
1104 elem.sText = getDotReplacementString(rString, xEntry->getReplacementText());
1105 elem.xAlternatives =
nullptr;
1106 bHasReplaced =
true;
1111 else if( elem.bIsGrammarError )
1118 : m_pSpellDialog(nullptr)
1119 , m_pToolbar(nullptr)
1122 , m_bIsUndoEditMode(false)
1142 const EECharAttrib* FindCharAttrib(
int nPosition, sal_uInt16 nWhich, std::vector<EECharAttrib>& rAttribList)
1144 for (
auto it = rAttribList.rbegin(); it != rAttribList.rend(); ++it)
1146 const auto& rTextAtr = *it;
1147 if (rTextAtr.pAttr->Which() != nWhich)
1149 if (rTextAtr.nStart <= nPosition && rTextAtr.nEnd >= nPosition)
1158 void ExtractErrorDescription(
const EECharAttrib& rEECharAttrib, SpellErrorDescription& rSpellErrorDescription)
1160 css::uno::Sequence<css::uno::Any> aSequence;
1161 static_cast<const SfxGrabBagItem*
>(rEECharAttrib.
pAttr)->GetGrabBag().find(
"SpellErrorDescription")->second >>= aSequence;
1162 rSpellErrorDescription.fromSequence(aSequence);
1229 #define INSIDE_YES 5
1231 #define OUTSIDE_NO 7
1232 #define OUTSIDE_YES 8
1234 #define ACTION_UNDOEDIT 0
1235 #define ACTION_CONTINUE 1
1236 #define ACTION_SELECTFIELD 2
1237 #define ACTION_EXPAND 3
1244 bool bConsumed =
false;
1252 aCurrentSelection.
Adjust();
1255 bool bHasFieldLeft =
false;
1256 bool bHasErrorLeft =
false;
1258 bool bHasRange = aCurrentSelection.HasRange();
1261 std::vector<EECharAttrib> aAttribList;
1264 auto nCursor = aCurrentSelection.nStartPos;
1270 bool bHasField = pBackAttr !=
nullptr && (bHasRange || pBackAttr->
nEnd > nCursor);
1271 bool bHasError = pErrorAttr !=
nullptr && (bHasRange || pErrorAttr->
nEnd > nCursor);
1275 pBackAttr->
nStart == aCurrentSelection.nStartPos &&
1276 pBackAttr->
nEnd == aCurrentSelection.nEndPos)
1278 nSelectionType =
FULL;
1280 else if (pErrorAttr &&
1281 pErrorAttr->
nStart <= aCurrentSelection.nStartPos &&
1282 pErrorAttr->
nEnd >= aCurrentSelection.nEndPos)
1289 while (nCursor < aCurrentSelection.nEndPos)
1295 if (pIntBackAttr || pIntErrorAttr)
1296 nSelectionType =
BRACE;
1298 if (pIntBackAttr && !pBackAttr)
1299 pBackAttr = pIntBackAttr;
1300 bHasField |= pIntBackAttr !=
nullptr;
1307 const EECharAttrib* pCurAttr = pBackAttr ? pBackAttr : pErrorAttr;
1310 nSelectionType = pCurAttr->
nStart == aCurrentSelection.nStartPos ?
1316 bHasFieldLeft = pBackAttr && pBackAttr->
nEnd == nCursor;
1319 pBackAttrLeft = pBackAttr;
1320 pBackAttr =
nullptr;
1322 bHasErrorLeft = pErrorAttr && pErrorAttr->
nEnd == nCursor;
1325 pErrorAttrLeft = pErrorAttr;
1326 pErrorAttr =
nullptr;
1336 pErrorAttrLeft = FindCharAttrib(nCursor,
EE_CHAR_GRABBAG, aAttribList);
1337 bHasFieldLeft = pBackAttrLeft !=
nullptr;
1338 bHasErrorLeft = pErrorAttrLeft !=
nullptr;
1347 nSelectionType ==
INVALID,
"cui.dialogs",
1348 "selection type not set");
1355 switch(nSelectionType)
1364 pBackAttr =
nullptr;
1408 sal_Int32 nCurrentLen =
m_xEditEngine->GetText().getLength();
1415 const EECharAttrib* pCharAttr = pBackAttr ? pBackAttr : pBackAttrLeft;
1421 DBG_ASSERT(pErrorAttrLeft || pErrorAttr,
"where is the error");
1426 ExtractErrorDescription(*pErrorAttrLeft, aSpellErrorDescription);
1428 std::unique_ptr<SfxPoolItem> xNewError(pErrorAttrLeft->
pAttr->
Clone());
1429 sal_Int32 nStart = pErrorAttrLeft->
nStart;
1430 sal_Int32 nEnd = pErrorAttrLeft->
nEnd + 1;
1442 else if (pErrorAttr)
1445 ExtractErrorDescription(*pErrorAttr, aSpellErrorDescription);
1448 sal_Int32 nAddedChars =
m_xEditEngine->GetText().getLength() - nCurrentLen;
1450 std::unique_ptr<SfxPoolItem> xNewError(pErrorAttr->
pAttr->
Clone());
1451 sal_Int32 nStart = pErrorAttr->
nStart + nAddedChars;
1452 sal_Int32 nEnd = pErrorAttr->
nEnd + nAddedChars;
1454 nStart = pErrorAttr->
nStart;
1466 std::unique_ptr<SfxPoolItem> xNewBack(pBackAttrLeft->
pAttr->
Clone());
1467 sal_Int32 _nStart = pBackAttrLeft->
nStart + nAddedChars;
1468 sal_Int32 _nEnd = pBackAttrLeft->
nEnd + nAddedChars;
1470 _nStart = pBackAttrLeft->
nStart;
1487 if (pFontColor && pErrorAttrib)
1493 std::unique_ptr<SfxPoolItem> xNewError(pErrorAttrib->
pAttr->
Clone());
1516 IMPL_LINK(SentenceEditWindow_Impl, ToolbarHdl,
const OString&, rCurItemId,
void)
1518 if (rCurItemId ==
"paste")
1520 m_xEditView->Paste();
1523 else if (rCurItemId ==
"insert")
1528 if (!aChars.isEmpty())
1530 ESelection aCurrentSelection(m_xEditView->GetSelection());
1531 m_xEditEngine->QuickInsertText(aChars, aCurrentSelection);
1540 if (bIgnoreCurrentError)
1560 std::vector<EECharAttrib> aAttribList;
1565 bool bGrammarError =
false;
1566 while (nCursor < nTextLen)
1571 sal_Int32 nMinPos = nTextLen + 1;
1572 for (
const auto& rTextAtr : aAttribList)
1576 if (rTextAtr.nEnd > nCursor && rTextAtr.nStart < nMinPos)
1578 nMinPos = rTextAtr.
nStart;
1579 pEECharAttrib = &rTextAtr;
1585 ExtractErrorDescription(*pEECharAttrib, aSpellErrorDescription);
1591 pSpellErrorDescription = &aSpellErrorDescription;
1594 nCursor = std::max(nCursor, nMinPos);
1598 Reference<XDictionaryEntry> xEntry;
1600 if (xChangeAll->getCount() && pSpellErrorDescription &&
1601 (xEntry = xChangeAll->getEntry( pSpellErrorDescription->
sErrorText )).is())
1603 OUString sReplacement(getDotReplacementString(
GetErrorText(), xEntry->getReplacementText()));
1607 nCursor += sReplacement.getLength();
1613 else if(pSpellErrorDescription && !bGrammarError &&
1616 Sequence< PropertyValue >() ))
1625 if (nCursor < nTextLen)
1632 pAction->SetErrorMove(nOldErrorStart, nOldErrorEnd);
1636 pAction->SetErrorLanguageSelected(aSpellErrorDescription.
aSuggestions.hasElements() &&
1640 pAction->SetErrorLanguageSelected(
false);
1676 aCurrentSelection.
Adjust();
1677 bool bCurrentSelectionInRange = nStart <= aCurrentSelection.
nEndPos && aCurrentSelection.
nStartPos <= nEnd;
1678 if (!bCurrentSelectionInRange)
1691 std::vector<EECharAttrib> aAttribList;
1699 DBG_ASSERT(pErrorAttrib,
"no error attribute found");
1700 bool bSpellErrorDescription =
false;
1704 ExtractErrorDescription(*pErrorAttrib, aSpellErrorDescription);
1706 bSpellErrorDescription =
true;
1726 if (pLangAttrib && !pLangAttrib->
nStart && pLangAttrib->
nEnd == nTextLen)
1735 if (pBackAttrib && pBackAttrib->
nStart < m_nErrorStart && pBackAttrib->
nEnd ==
m_nErrorEnd + nDiffLen)
1737 std::unique_ptr<SfxPoolItem> xNewBackground(pBackAttrib->
pAttr->
Clone());
1738 const sal_Int32 nStart = pBackAttrib->
nStart;
1742 SetAttrib(*xNewBackground, nStart, m_nErrorStart);
1748 nEndTemp += nDiffLen;
1753 pAction->SetOffset(nDiffLen);
1755 if (bSpellErrorDescription)
1758 aSpellErrorDescriptionItem.
GetGrabBag()[
"SpellErrorDescription"] <<= aSpellErrorDescription.
toSequence();
1776 std::vector<EECharAttrib> aAttribList;
1781 ExtractErrorDescription(*pEECharAttrib, rSpellErrorDescription);
1806 lang::Locale aLocale;
1807 uno::Sequence< OUString > aAlts;
1810 aWord = xAlt->getWord();
1811 aLocale = xAlt->getLocale();
1812 aAlts = xAlt->getAlternatives();
1836 struct LanguagePosition_Impl
1838 sal_Int32 nPosition;
1841 LanguagePosition_Impl(sal_Int32 nPos,
LanguageType eLang) :
1852 LanguagePositions_Impl& rBreakPositions, sal_Int32 nInsert,
LanguageType eLanguage)
1854 LanguagePositions_Impl::iterator aStart = rBreakPositions.begin();
1855 while(aStart != rBreakPositions.end())
1857 if(aStart->nPosition == nInsert)
1861 aStart->eLanguage = eLanguage;
1864 else if(aStart->nPosition > nInsert)
1867 rBreakPositions.insert(aStart, LanguagePosition_Impl(nInsert, eLanguage));
1873 rBreakPositions.emplace_back(nInsert, eLanguage);
1886 std::vector<EECharAttrib> aAttribList;
1892 LanguagePositions_Impl aBreakPositions;
1897 while (nCursor < nTextLen)
1900 if(pLang && pLang != pLastLang)
1908 if (pError && pLastError != pError)
1912 pLastError = pError;
1918 if (aBreakPositions.empty())
1926 aRet.push_back(aPortion1);
1930 LanguagePositions_Impl::iterator aStart = aBreakPositions.begin();
1932 eLang = aStart->eLanguage;
1933 sal_Int32 nStart = aStart->nPosition;
1934 DBG_ASSERT(!nStart,
"invalid start position - language attribute missing?");
1937 while(aStart != aBreakPositions.end())
1945 if( bIsIgnoreError )
1949 aRet.push_back(aPortion1);
1950 nStart = aStart->nPosition;
1951 eLang = aStart->eLanguage;
1959 const sal_uInt32 nPara =
m_xEditEngine->GetParagraphCount();
1962 OUStringBuffer aLeftOverText;
1963 for (sal_uInt32
i = 1;
i < nPara; ++
i)
1965 aLeftOverText.append(
"\x0a");
1972 aPortion2.
sText = aLeftOverText.makeStringAndClear();
1973 aRet.push_back( aPortion2 );
1977 aRet[ aRet.size() - 1 ].sText += aLeftOverText;
2019 return m_xEditEngine->GetUndoManager().GetUndoActionCount();
2038 m_nErrorEnd = m_nErrorEnd -
static_cast<sal_Int32
>(-nOffset);
2069 while(aControls[++nIdx]);
SpellUndoAction_Impl(sal_uInt16 nId, const Link< SpellUndoAction_Impl &, void > &rActionLink)
#define LINK(Instance, Class, Member)
SfxUndoAction * GetUndoAction(size_t nNo=0) const
css::uno::Sequence< css::uno::Any > toSequence() const
std::unique_ptr< weld::Label > m_xResumeFT
weld::Toolbar * m_pToolbar
virtual bool HasGrammarChecking()
std::unique_ptr< weld::Label > m_xExplainFT
virtual void GetFocus()=0
std::unique_ptr< weld::TreeView > m_xSuggestionLB
#define SPELLUNDO_CHANGE_ADD_TO_DICTIONARY
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
void SetEnableChangeAllPB()
std::unique_ptr< SvxLanguageBox > m_xLanguageLB
FncGetSpecialChars GetGetSpecialCharsFunction()
std::unique_ptr< weld::Label > m_xNotInDictFT
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
LanguageType getLanguageType(bool bResolveSystem=true) const
tools::Long GetOldErrorEnd() const
#define SPELLUNDO_MOVE_ERROREND
tools::Long m_nOldErrorEnd
std::unique_ptr< SpellDialog_Impl > pImpl
static LanguageType convertToLanguageType(const css::lang::Locale &rLocale, bool bResolveSystem=true)
void AddToDictionaryExecute(const OString &rItemId)
std::unique_ptr< weld::Label > m_xSuggestionFT
css::uno::Sequence< OUString > aSuggestions
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
tools::Long GetOffset() const
#define SPELLUNDO_CHANGE_LANGUAGE
void SetTitle_Impl(LanguageType nLang)
void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction)
std::set< sal_Int32 > m_aIgnoreErrorsAt
std::unique_ptr< weld::Button > m_xOptionsPB
virtual void Deactivate() override
const SfxPoolItem * pAttr
bool GetErrorDescription(SpellErrorDescription &rSpellErrorDescription, sal_Int32 nPosition)
OUString getReplacementString() const
static css::uno::Reference< css::linguistic2::XDictionary > GetStandardDic()
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
sal_uInt16 GetCode() const
void ToplevelFocusChanged()
void Init(weld::Toolbar *pToolbar)
void SetErrorMove(tools::Long nOldStart, tools::Long nOldEnd)
OUString GetErrorText() const
constexpr::Color COL_LIGHTGRAY(0xC0, 0xC0, 0xC0)
bool SaveDictionaries(const uno::Reference< XSearchableDictionaryList > &xDicList)
const Link< SpellUndoAction_Impl &, void > & m_rActionLink
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
void SpellContinue_Impl(std::unique_ptr< UndoChangeGroupGuard > *pGuard=nullptr, bool UseSavedSentence=false, bool bIgnoreCurrentError=false)
void SetText(const OUString &rStr)
SfxApplication * SfxGetpApp()
std::unique_ptr< weld::Button > m_xIgnoreAllPB
virtual bool HasAutoCorrection()
void ToggleChildWindow(sal_uInt16)
std::unique_ptr< weld::Label > m_xNoSuggestionsFT
svx::SpellPortions CreateSpellPortions() const
std::unique_ptr< weld::Button > m_xIgnoreRulePB
std::unique_ptr< weld::Button > m_xAutoCorrPB
bool GetNextSentence_Impl(std::unique_ptr< UndoChangeGroupGuard > *pGuard, bool bUseSavedSentence, bool bRecheck)
Retrieves the next sentence.
virtual void Deactivate() override
std::unique_ptr< weld::Button > m_xAddToDictPB
PropertiesInfo aProperties
svx::SpellDialogChildWindow & rParent
bool m_bEnableChangeAllPB
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
static bool DoesKeyChangeText(const KeyEvent &rKeyEvent)
tools::Long GetOldErrorStart() const
static css::uno::Reference< css::linguistic2::XSearchableDictionaryList > GetDictionaryList()
void SetOffset(tools::Long nSet)
std::unique_ptr< weld::Label > m_xLanguageFT
OUString GetSpellAndGrammarContextDictionaryImage(const OUString &rServiceImplName) const
static css::uno::Reference< css::linguistic2::XDictionary > GetIgnoreAllList()
constexpr TypedWhichId< SfxGrabBagItem > EE_CHAR_GRABBAG(EE_CHAR_START+31)
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_LIGHTRED
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT(EE_CHAR_START+4)
void UndoActionStart(sal_uInt16 nId)
virtual bool KeyInput(const KeyEvent &rKEvt) override
std::unique_ptr< weld::Button > m_xUndoPB
std::vector< SpellPortion > SpellPortions
static css::uno::Reference< css::linguistic2::XDictionary > GetChangeAllList()
short SvxDicError(weld::Window *pParent, linguistic::DictionaryError nError)
virtual void Close() override
virtual void LoseFocus()=0
std::unique_ptr< weld::CheckButton > m_xCheckGrammarCB
std::unique_ptr< weld::Toolbar > m_xToolbar
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
std::unique_ptr< weld::Button > m_xIgnorePB
OUString m_sTitleSpellingGrammar
std::unique_ptr< weld::LinkButton > m_xExplainLink
static css::uno::Reference< css::linguistic2::XSpellChecker1 > GetSpellChecker()
const Reference< XDictionary > & GetDictionary() const
#define DBG_ASSERT(sCon, aError)
bool IsEnableChangeAllPB() const
OUString m_sTitleSpelling
LanguageType GetLanguage(SwWrtShell &rSh, sal_uInt16 nLangWhichId)
std::unique_ptr< weld::Button > m_xClosePB
Link< SpellUndoAction_Impl &, void > aDialogUndoLink
static void ApplyLanguageOptions(const SfxItemSet &rSet)
virtual void Activate() override
std::vector< LanguagePosition_Impl > LanguagePositions_Impl
std::unique_ptr< SentenceEditWindow_Impl > m_xSentenceED
size_t GetUndoActionCount() const
virtual SpellPortions GetNextWrongSentence(bool bRecheck)=0
std::unique_ptr< weld::Button > m_xChangeAllPB
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT_CJK(EE_CHAR_START+21)
void Impl_Restore(bool bUseSavedSentence)
const std::map< OUString, css::uno::Any > & GetGrabBag() const
#define LANGUAGE_DONTKNOW
std::unique_ptr< EditView > m_xEditView
IMPL_LINK(ClassificationDialog, SelectClassificationHdl, weld::ComboBox &, rBox, void)
void UpdateBoxes_Impl(bool bCallFromSelectHdl=false)
constexpr TypedWhichId< SvxBackgroundColorItem > EE_CHAR_BKGCOLOR(EE_CHAR_START+32)
static bool ApplyChangeAllList_Impl(SpellPortions &rSentence, bool &bHasReplaced)
Corrects all errors that have been selected to be changed always.
virtual ~SentenceEditWindow_Impl() override
void SvxPrepareAutoCorrect(OUString &rOldText, const OUString &rNewText)
bool IsEnableChangePB() const
Sequence< Reference< XDictionary > > aDics
#define SPELLUNDO_ADD_IGNORE_RULE
const OUString & GetAddedWord() const
#define SPELLUNDO_UNDO_EDIT_MODE
void SetDictionary(const Reference< XDictionary > &xDict)
tools::Long m_nOldErrorStart
LanguageType GetSelectedLang_Impl() const
#define SPELLUNDO_CHANGE_GROUP
const vcl::KeyCode & GetKeyCode() const
virtual void Activate() override
OUString m_sNoSuggestionsST
void SetAlternatives(const css::uno::Reference< css::linguistic2::XSpellAlternatives > &)
static SfxViewFrame * Current()
bool GetAlternatives(SpellErrorDescription &rDesc)
int ChangeMarkedWord(const OUString &rNewWord, LanguageType eLanguage)
#define SAL_WARN_IF(condition, area, stream)
DictionaryError AddEntryToDic(uno::Reference< XDictionary > const &rxDic, const OUString &rWord, bool bIsNeg, const OUString &rRplcTxt, bool bStripDot)
virtual void ApplyChangedSentence(const SpellPortions &rChanged, bool bRecheck)=0
std::unique_ptr< weld::MenuButton > m_xAddToDictMB
#define SPELLUNDO_CHANGE_NEXTERROR
bool MarkNextError(bool bIgnoreCurrentError, const css::uno::Reference< css::linguistic2::XSpellChecker1 > &)
css::lang::Locale aLocale
void RestoreCurrentError()
std::unique_ptr< weld::Label > m_xAltTitle
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT_CTL(EE_CHAR_START+22)
constexpr TypedWhichId< SvxColorItem > EE_CHAR_COLOR(EE_CHAR_START+0)
void SetAttrib(const SfxPoolItem &rItem, sal_Int32 nStart, sal_Int32 nEnd)
bool IsUndoEditMode() const
void MoveErrorEnd(tools::Long nOffset)
Reference< XExecutableDialog > m_xDialog
#define SPELLUNDO_CHANGE_TEXTENGINE
void MoveErrorMarkTo(sal_Int32 nErrorStart, sal_Int32 nErrorEnd, bool bGrammar)
static void lcl_InsertBreakPosition_Impl(LanguagePositions_Impl &rBreakPositions, sal_Int32 nInsert, LanguageType eLanguage)
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE(EE_CHAR_START+14)
void SetAddedWord(const OUString &rWord)
Reference< XDictionary > m_xDictionary
IMPL_LINK_NOARG(AccessibilityCheckEntry, GotoButtonClicked, weld::Button &, void)
constexpr sal_uInt16 KEY_BACKSPACE
static OUString GetLanguageString(const LanguageType eType)
#define ACTION_SELECTFIELD
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_LIGHTBLUE
svx::SpellPortions m_aSavedSentence
std::unique_ptr< EditEngine > m_xEditEngine
SpellDialog * GetSpellDialog() const
void SetErrorLanguageSelected(bool bSet)
constexpr sal_uInt16 KEY_DELETE
void StartSpellOptDlg_Impl()
void SetUndoEditMode(bool bSet)
std::unique_ptr< weld::Button > m_xChangePB
bool IsErrorLanguageSelected() const
SentenceEditWindow_Impl()
virtual ~SpellDialog() override
css::uno::Reference< css::linguistic2::XSpellChecker1 > xSpell
SentenceEditWindow_Impl & m_rSentenceED
bool m_bIsErrorLanguageSelected
UndoChangeGroupGuard(SentenceEditWindow_Impl &rSentenceED)
constexpr sal_uInt16 KEY_TAB
static css::lang::Locale convertToLocale(LanguageType nLangID, bool bResolveSystem=true)