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>
70 Sequence< Reference< XDictionary > >
aDics;
74#define SPELLUNDO_START 200
76#define SPELLUNDO_CHANGE_LANGUAGE (SPELLUNDO_START + 1)
77#define SPELLUNDO_CHANGE_TEXTENGINE (SPELLUNDO_START + 2)
78#define SPELLUNDO_CHANGE_NEXTERROR (SPELLUNDO_START + 3)
79#define SPELLUNDO_CHANGE_ADD_TO_DICTIONARY (SPELLUNDO_START + 4)
80#define SPELLUNDO_CHANGE_GROUP (SPELLUNDO_START + 5)
81#define SPELLUNDO_MOVE_ERROREND (SPELLUNDO_START + 6)
82#define SPELLUNDO_UNDO_EDIT_MODE (SPELLUNDO_START + 7)
83#define SPELLUNDO_ADD_IGNORE_RULE (SPELLUNDO_START + 8)
115 virtual void Undo()
override;
116 sal_uInt16
GetId()
const;
144using namespace ::
svx;
146void SpellUndoAction_Impl::Undo()
148 m_rActionLink.Call(*
this);
162 pParent,
"cui/ui/spellingdialog.ui",
"SpellingDialog")
164 , m_pInitHdlEvent(nullptr)
166 , rParent(*pChildWindow)
168 , m_xAltTitle(m_xBuilder->weld_label(
"alttitleft"))
169 , m_xResumeFT(m_xBuilder->weld_label(
"resumeft"))
170 , m_xNoSuggestionsFT(m_xBuilder->weld_label(
"nosuggestionsft"))
171 , m_xLanguageFT(m_xBuilder->weld_label(
"languageft"))
172 , m_xLanguageLB(new
SvxLanguageBox(m_xBuilder->weld_combo_box(
"languagelb")))
173 , m_xExplainFT(m_xBuilder->weld_label(
"explain"))
174 , m_xExplainLink(m_xBuilder->weld_link_button(
"explainlink"))
175 , m_xNotInDictFT(m_xBuilder->weld_label(
"notindictft"))
177 , m_xSuggestionFT(m_xBuilder->weld_label(
"suggestionsft"))
178 , m_xSuggestionLB(m_xBuilder->weld_tree_view(
"suggestionslb"))
179 , m_xIgnorePB(m_xBuilder->weld_button(
"ignore"))
180 , m_xIgnoreAllPB(m_xBuilder->weld_button(
"ignoreall"))
181 , m_xIgnoreRulePB(m_xBuilder->weld_button(
"ignorerule"))
182 , m_xAddToDictPB(m_xBuilder->weld_button(
"add"))
183 , m_xAddToDictMB(m_xBuilder->weld_menu_button(
"addmb"))
184 , m_xChangePB(m_xBuilder->weld_button(
"change"))
185 , m_xChangeAllPB(m_xBuilder->weld_button(
"changeall"))
186 , m_xAutoCorrPB(m_xBuilder->weld_button(
"autocorrect"))
187 , m_xCheckGrammarCB(m_xBuilder->weld_check_button(
"checkgrammar"))
188 , m_xOptionsPB(m_xBuilder->weld_button(
"options"))
189 , m_xUndoPB(m_xBuilder->weld_button(
"undo"))
190 , m_xClosePB(m_xBuilder->weld_button(
"close"))
191 , m_xToolbar(m_xBuilder->weld_toolbar(
"toolbar"))
192 , m_xSentenceEDWeld(new
weld::CustomWeld(*m_xBuilder,
"sentence", *m_xSentenceED))
203 m_xDialog->set_title(
m_xDialog->strip_mnemonic(sTitle.replaceFirst(
"$LANGUAGE ($LOCATION)",
"")));
272 m_xLanguageLB->SetLanguageList(SvxLanguageListFlags::SPELL_USED,
false,
false,
true);
284 bool bSpellErrorDescription =
m_xSentenceED->GetAlternatives(aSpellErrorDescription);
288 bool bIsGrammarError =
false;
289 if( bSpellErrorDescription )
297 if( bSpellErrorDescription && !aSpellErrorDescription.
sDialogTitle.isEmpty() )
306 if( !bCallFromSelectHdl )
311 const OUString *pNewWords = aNewWords.getConstArray();
312 const sal_Int32 nSize = aNewWords.getLength();
313 for (
i = 0;
i < nSize; ++
i )
315 OUString aTmp( pNewWords[
i] );
331 bool bShowChangeAll = !bIsGrammarError;
363 bool bNextSentence =
false;
374 bool bSpellErrorDescription =
m_xSentenceED->GetAlternatives(aSpellErrorDescription);
375 if (bSpellErrorDescription)
385 pWidget->set_sensitive(
true);
399 m_pInitHdlEvent =
nullptr;
402 m_xAutoCorrPB->set_visible(rParent.HasAutoCorrection());
403 SpellContinue_Impl(
nullptr);
404 m_xSentenceED->ResetUndo();
405 m_xUndoPB->set_sensitive(
false);
413 LockFocusChanges(
true);
414 if(m_xSentenceED->IsEnabled())
415 m_xSentenceED->GrabFocus();
416 else if( m_xChangePB->get_sensitive() )
417 m_xChangePB->grab_focus();
418 else if( m_xIgnorePB->get_sensitive() )
419 m_xIgnorePB->grab_focus();
420 else if( m_xClosePB->get_sensitive() )
421 m_xClosePB->grab_focus();
422 LockFocusChanges(
false);
424 m_xCheckGrammarCB->set_active(rParent.IsGrammarChecking());
430 if (m_xOptionsPB.get() == &rBtn)
431 StartSpellOptDlg_Impl();
432 else if (m_xAutoCorrPB.get() == &rBtn)
435 OUString sCurrentErrorText = m_xSentenceED->GetErrorText();
437 SpellErrorDescription aSpellErrorDescription;
438 bool bSpellErrorDescription = m_xSentenceED->GetAlternatives(aSpellErrorDescription);
439 if (bSpellErrorDescription)
441 OUString sWrong(aSpellErrorDescription.sErrorText);
445 if(sWrong == sCurrentErrorText &&
446 m_xSuggestionLB->get_sensitive() && m_xSuggestionLB->get_selected_index() != -1 &&
447 m_sNoSuggestionsST != m_xSuggestionLB->get_selected_text())
449 sCurrentErrorText = m_xSuggestionLB->get_selected_text();
451 if(sWrong != sCurrentErrorText)
455 rParent.AddAutoCorrection( sWrong, sCurrentErrorText, eLang );
457 ChangeHdl(*m_xAutoCorrPB);
465 rParent.SetGrammarChecking(m_xCheckGrammarCB->get_active());
471 auto xSet = std::make_shared<SfxItemSetFixed<SID_AUTOSPELL_CHECK,SID_AUTOSPELL_CHECK>>(
SfxGetpApp()->
GetPool() );
472 m_xOptionsDlg = std::make_shared<SfxSingleTabDialogController>(
473 m_xDialog.get(), xSet.get(),
"content",
"cui/ui/spelloptionsdialog.ui",
"SpellOptionsDialog");
491 OUString getDotReplacementString(
const OUString &rErrorText,
const OUString &rSuggestedReplacement)
493 OUString aString = rErrorText;
496 bool bDot = aString.endsWith(
".");
498 aString = rSuggestedReplacement;
500 if(bDot && (aString.isEmpty() || !aString.endsWith(
".")))
511 OUString sReplacement(sOrigString);
518 return getDotReplacementString(sOrigString, sReplacement);
523 ChangeHdl(*m_xChangePB);
538 : m_rSentenceED(rSentenceED)
544 m_rSentenceED.UndoActionEnd();
550 if (m_xSentenceED->IsUndoEditMode())
552 SpellContinue_Impl();
556 auto xGuard(std::make_unique<UndoChangeGroupGuard>(*m_xSentenceED));
557 OUString aString = getReplacementString();
558 m_xSentenceED->ChangeMarkedWord(aString, GetSelectedLang_Impl());
559 SpellContinue_Impl(&xGuard);
561 if(!m_xChangePB->get_sensitive())
562 m_xIgnorePB->grab_focus();
567 auto xGuard(std::make_unique<UndoChangeGroupGuard>(*m_xSentenceED));
568 OUString aString = getReplacementString();
572 OUString aOldWord( m_xSentenceED->GetErrorText() );
579 if(nAdded == DictionaryError::NONE)
581 std::unique_ptr<SpellUndoAction_Impl> pAction(
new SpellUndoAction_Impl(
583 pAction->SetDictionary(aXDictionary);
584 pAction->SetAddedWord(aOldWord);
585 m_xSentenceED->AddUndoAction(std::move(pAction));
588 m_xSentenceED->ChangeMarkedWord(aString, eLang);
589 SpellContinue_Impl(&xGuard);
594 auto xGuard(std::make_unique<UndoChangeGroupGuard>(*m_xSentenceED));
598 m_xSentenceED->RestoreCurrentError();
599 if (&rButton == m_xIgnoreRulePB.get())
601 SpellErrorDescription aSpellErrorDescription;
602 bool bSpellErrorDescription = m_xSentenceED->GetAlternatives(aSpellErrorDescription);
605 if( bSpellErrorDescription && aSpellErrorDescription.xGrammarChecker.is() )
607 aSpellErrorDescription.xGrammarChecker->ignoreRule(aSpellErrorDescription.sRuleId,
608 aSpellErrorDescription.aLocale);
610 aXDictionary->setActive(
false);
611 aXDictionary->setActive(
true);
614 catch(
const uno::Exception& )
620 OUString sErrorText(m_xSentenceED->GetErrorText());
624 if (nAdded == DictionaryError::NONE)
626 std::unique_ptr<SpellUndoAction_Impl> pAction(
new SpellUndoAction_Impl(
628 pAction->SetDictionary(aXDictionary);
629 pAction->SetAddedWord(sErrorText);
630 m_xSentenceED->AddUndoAction(std::move(pAction));
634 SpellContinue_Impl(&xGuard);
639 m_xSentenceED->Undo();
640 if(!m_xSentenceED->GetUndoActionCount())
641 m_xUndoPB->set_sensitive(
false);
645IMPL_LINK( SpellDialog, DialogUndoHdl, SpellUndoAction_Impl&, rAction,
void )
647 switch(rAction.GetId())
651 if(rAction.IsEnableChangePB())
652 m_xChangePB->set_sensitive(
false);
653 if(rAction.IsEnableChangeAllPB())
654 m_xChangeAllPB->set_sensitive(
false);
659 m_xSentenceED->MoveErrorMarkTo(
static_cast<sal_Int32
>(rAction.GetOldErrorStart()),
660 static_cast<sal_Int32
>(rAction.GetOldErrorEnd()),
662 if(rAction.IsErrorLanguageSelected())
670 if(rAction.GetDictionary().is())
671 rAction.GetDictionary()->remove(rAction.GetAddedWord());
676 if(rAction.GetOffset() != 0)
677 m_xSentenceED->MoveErrorEnd(rAction.GetOffset());
683 SpellContinue_Impl(
nullptr,
true);
706 if (m_sResumeST == m_xIgnorePB->get_label())
714 m_xSentenceED->RestoreCurrentError();
717 SpellContinue_Impl(
nullptr,
false,
true);
732 pViewFrame->ToggleChildWindow(
rParent.GetType());
749 OUString sError = m_xSentenceED->GetErrorText();
750 m_xSuggestionLB->clear();
751 if (!sError.isEmpty())
753 LanguageType eLanguage = m_xLanguageLB->get_active_id();
754 Reference <XSpellAlternatives> xAlt = xSpell->spell( sError,
static_cast<sal_uInt16
>(eLanguage),
755 Sequence< PropertyValue >() );
757 m_xSentenceED->SetAlternatives( xAlt );
760 m_xSentenceED->ChangeMarkedWord( sError, eLanguage );
761 SpellContinue_Impl();
780 const Reference< XDictionary > *pDic =
nullptr;
791 xDic->setActive(
true );
793 pImpl->aDics = xDicList->getDictionaries();
799 bool bEnable =
false;
800 const sal_Int32 nSize =
pImpl->aDics.getLength();
801 pDic =
pImpl->aDics.getConstArray();
803 sal_uInt16 nItemId = 1;
804 for (sal_Int32
i = 0;
i < nSize; ++
i)
812 if( xDicTmp->isActive()
813 && xDicTmp->getDictionaryType() != linguistic2::DictionaryType_NEGATIVE
815 && (!xStor.is() || !xStor->isReadonly()) )
819 OUString aDictionaryImageUrl;
824 xSvcInfo->getImplementationName());
827 m_xAddToDictMB->append_item(OUString::number(nItemId), xDicTmp->getName(), aDictionaryImageUrl);
835 int nDicts = nItemId-1;
845 AddToDictionaryExecute(OUString::number(1));
848IMPL_LINK(SpellDialog, AddToDictSelectHdl,
const OUString&, rIdent,
void)
850 AddToDictionaryExecute(rIdent);
855 auto xGuard(std::make_unique<UndoChangeGroupGuard>(*
m_xSentenceED));
866 xDic = xDicList->getDictionaryByName( aDicName );
871 nAddRes =
AddEntryToDic( xDic, aNewWord,
false, OUString() );
877 if (nAddRes == DictionaryError::NONE)
881 pAction->SetDictionary( xDic );
882 pAction->SetAddedWord( aNewWord );
886 if (DictionaryError::NONE != nAddRes && xDic->getEntry( aNewWord ).is())
887 nAddRes = DictionaryError::NONE;
889 if (DictionaryError::NONE != nAddRes)
901 m_xSuggestionLB->unselect_all();
902 m_xSuggestionLB->set_sensitive(
false);
903 m_xAutoCorrPB->set_sensitive(
false);
905 if(!m_xChangeAllPB->get_sensitive())
907 m_xChangeAllPB->set_sensitive(
true);
908 pSpellAction->SetEnableChangeAllPB();
910 if(!m_xChangePB->get_sensitive())
912 m_xChangePB->set_sensitive(
true);
913 pSpellAction->SetEnableChangePB();
915 m_xSentenceED->AddUndoAction(std::move(pSpellAction));
921 if (m_xSentenceED->IsModified())
923 rParent.ApplyChangedSentence(m_xSentenceED->CreateSpellPortions(),
false);
989 pWidget->set_sensitive(
false);
997 if(!bUseSavedSentence)
1005 if(!bUseSavedSentence)
1007 bool bHasReplaced =
false;
1008 while(!aSentence.empty())
1022 if(!aSentence.empty())
1024 OUStringBuffer sText;
1025 for (
auto const& elem : aSentence)
1029 sText.append(elem.sText);
1035 sal_Int32 nStartPosition = 0;
1036 sal_Int32 nEndPosition = 0;
1038 for (
auto const& elem : aSentence)
1043 nEndPosition += elem.sText.getLength();
1044 if(elem.xAlternatives.is())
1047 elem.xAlternatives->getLocale(), elem.xAlternatives->getAlternatives(),
nullptr);
1050 m_xSentenceED->SetAttrib(aSpellErrorDescription, nStartPosition, nEndPosition);
1052 else if(elem.bIsGrammarError )
1054 beans::PropertyValues
aProperties = elem.aGrammarError.aProperties;
1055 OUString sFullCommentURL;
1057 while ( sFullCommentURL.isEmpty() &&
i <
aProperties.getLength() )
1062 aValue >>= sFullCommentURL;
1070 elem.aGrammarError.aSuggestions,
1071 elem.xGrammarChecker,
1073 &elem.aGrammarError.aFullComment,
1074 &elem.aGrammarError.aRuleIdentifier,
1079 m_xSentenceED->SetAttrib(aSpellErrorDescriptionItem, nStartPosition, nEndPosition);
1085 nStartPosition = nEndPosition;
1093 bRet = nStartPosition > 0;
1103 bHasReplaced =
false;
1106 if(!xChangeAll->getCount())
1109 for (
auto & elem : rSentence)
1111 if(elem.xAlternatives.is())
1113 const OUString &rString = elem.sText;
1115 Reference<XDictionaryEntry> xEntry = xChangeAll->getEntry(rString);
1119 elem.sText = getDotReplacementString(rString, xEntry->getReplacementText());
1120 elem.xAlternatives =
nullptr;
1121 bHasReplaced =
true;
1126 else if( elem.bIsGrammarError )
1133 : m_pSpellDialog(nullptr)
1134 , m_pToolbar(nullptr)
1137 , m_bIsUndoEditMode(false)
1164 const EECharAttrib* FindCharAttrib(
int nPosition, sal_uInt16 nWhich, std::vector<EECharAttrib>& rAttribList)
1166 for (
auto it = rAttribList.rbegin(); it != rAttribList.rend(); ++it)
1168 const auto& rTextAtr = *it;
1169 if (rTextAtr.pAttr->Which() != nWhich)
1171 if (rTextAtr.nStart <= nPosition && rTextAtr.nEnd >= nPosition)
1180 void ExtractErrorDescription(
const EECharAttrib& rEECharAttrib, SpellErrorDescription& rSpellErrorDescription)
1182 css::uno::Sequence<css::uno::Any> aSequence;
1183 static_cast<const SfxGrabBagItem*
>(rEECharAttrib.
pAttr)->GetGrabBag().find(
"SpellErrorDescription")->second >>= aSequence;
1184 rSpellErrorDescription.fromSequence(aSequence);
1254#define OUTSIDE_YES 8
1256#define ACTION_UNDOEDIT 0
1257#define ACTION_CONTINUE 1
1258#define ACTION_SELECTFIELD 2
1259#define ACTION_EXPAND 3
1266 bool bConsumed =
false;
1274 aCurrentSelection.
Adjust();
1277 bool bHasFieldLeft =
false;
1278 bool bHasErrorLeft =
false;
1280 bool bHasRange = aCurrentSelection.
HasRange();
1283 std::vector<EECharAttrib> aAttribList;
1286 auto nCursor = aCurrentSelection.
nStartPos;
1292 bool bHasField = pBackAttr !=
nullptr && (bHasRange || pBackAttr->
nEnd > nCursor);
1293 bool bHasError = pErrorAttr !=
nullptr && (bHasRange || pErrorAttr->
nEnd > nCursor);
1300 nSelectionType =
FULL;
1302 else if (pErrorAttr &&
1311 while (nCursor < aCurrentSelection.
nEndPos)
1317 if (pIntBackAttr || pIntErrorAttr)
1318 nSelectionType =
BRACE;
1320 if (pIntBackAttr && !pBackAttr)
1321 pBackAttr = pIntBackAttr;
1322 bHasField |= pIntBackAttr !=
nullptr;
1329 const EECharAttrib* pCurAttr = pBackAttr ? pBackAttr : pErrorAttr;
1338 bHasFieldLeft = pBackAttr && pBackAttr->
nEnd == nCursor;
1341 pBackAttrLeft = pBackAttr;
1342 pBackAttr =
nullptr;
1344 bHasErrorLeft = pErrorAttr && pErrorAttr->
nEnd == nCursor;
1347 pErrorAttrLeft = pErrorAttr;
1348 pErrorAttr =
nullptr;
1358 pErrorAttrLeft = FindCharAttrib(nCursor,
EE_CHAR_GRABBAG, aAttribList);
1359 bHasFieldLeft = pBackAttrLeft !=
nullptr;
1360 bHasErrorLeft = pErrorAttrLeft !=
nullptr;
1369 nSelectionType ==
INVALID,
"cui.dialogs",
1370 "selection type not set");
1377 switch(nSelectionType)
1386 pBackAttr =
nullptr;
1430 sal_Int32 nCurrentLen =
m_xEditEngine->GetText().getLength();
1437 const EECharAttrib* pCharAttr = pBackAttr ? pBackAttr : pBackAttrLeft;
1443 DBG_ASSERT(pErrorAttrLeft || pErrorAttr,
"where is the error");
1448 ExtractErrorDescription(*pErrorAttrLeft, aSpellErrorDescription);
1450 std::unique_ptr<SfxPoolItem> xNewError(pErrorAttrLeft->
pAttr->
Clone());
1451 sal_Int32 nStart = pErrorAttrLeft->
nStart;
1452 sal_Int32 nEnd = pErrorAttrLeft->
nEnd + 1;
1464 else if (pErrorAttr)
1467 ExtractErrorDescription(*pErrorAttr, aSpellErrorDescription);
1470 sal_Int32 nAddedChars =
m_xEditEngine->GetText().getLength() - nCurrentLen;
1472 std::unique_ptr<SfxPoolItem> xNewError(pErrorAttr->
pAttr->
Clone());
1473 sal_Int32 nStart = pErrorAttr->
nStart + nAddedChars;
1474 sal_Int32 nEnd = pErrorAttr->
nEnd + nAddedChars;
1476 nStart = pErrorAttr->
nStart;
1488 std::unique_ptr<SfxPoolItem> xNewBack(pBackAttrLeft->
pAttr->
Clone());
1489 sal_Int32 _nStart = pBackAttrLeft->
nStart + nAddedChars;
1490 sal_Int32 _nEnd = pBackAttrLeft->
nEnd + nAddedChars;
1492 _nStart = pBackAttrLeft->
nStart;
1509 if (pFontColor && pErrorAttrib)
1515 std::unique_ptr<SfxPoolItem> xNewError(pErrorAttrib->
pAttr->
Clone());
1538IMPL_LINK(SentenceEditWindow_Impl, ToolbarHdl,
const OUString&, rCurItemId,
void)
1540 if (rCurItemId ==
"paste")
1542 m_xEditView->Paste();
1545 else if (rCurItemId ==
"insert")
1549 OUString aChars = pImplFncGetSpecialChars(GetDrawingArea(), m_xEditEngine->GetStandardFont(0));
1550 if (!aChars.isEmpty())
1552 ESelection aCurrentSelection(m_xEditView->GetSelection());
1553 m_xEditEngine->QuickInsertText(aChars, aCurrentSelection);
1562 if (bIgnoreCurrentError)
1582 std::vector<EECharAttrib> aAttribList;
1587 bool bGrammarError =
false;
1588 while (nCursor < nTextLen)
1593 sal_Int32 nMinPos = nTextLen + 1;
1594 for (
const auto& rTextAtr : aAttribList)
1598 if (rTextAtr.nEnd > nCursor && rTextAtr.nStart < nMinPos)
1600 nMinPos = rTextAtr.
nStart;
1601 pEECharAttrib = &rTextAtr;
1607 ExtractErrorDescription(*pEECharAttrib, aSpellErrorDescription);
1613 pSpellErrorDescription = &aSpellErrorDescription;
1616 nCursor = std::max(nCursor, nMinPos);
1620 Reference<XDictionaryEntry> xEntry;
1622 if (xChangeAll->getCount() && pSpellErrorDescription &&
1623 (xEntry = xChangeAll->getEntry( pSpellErrorDescription->
sErrorText )).is())
1625 OUString sReplacement(getDotReplacementString(
GetErrorText(), xEntry->getReplacementText()));
1629 nCursor += sReplacement.getLength();
1635 else if(pSpellErrorDescription && !bGrammarError &&
1638 Sequence< PropertyValue >() ))
1647 if (nCursor < nTextLen)
1654 pAction->SetErrorMove(nOldErrorStart, nOldErrorEnd);
1658 pAction->SetErrorLanguageSelected(aSpellErrorDescription.
aSuggestions.hasElements() &&
1662 pAction->SetErrorLanguageSelected(
false);
1702 aCurrentSelection.
Adjust();
1703 bool bCurrentSelectionInRange = nStart <= aCurrentSelection.
nEndPos && aCurrentSelection.
nStartPos <= nEnd;
1704 if (!bCurrentSelectionInRange)
1717 std::vector<EECharAttrib> aAttribList;
1725 DBG_ASSERT(pErrorAttrib,
"no error attribute found");
1726 bool bSpellErrorDescription =
false;
1730 ExtractErrorDescription(*pErrorAttrib, aSpellErrorDescription);
1732 bSpellErrorDescription =
true;
1752 if (pLangAttrib && !pLangAttrib->
nStart && pLangAttrib->
nEnd == nTextLen)
1763 std::unique_ptr<SfxPoolItem> xNewBackground(pBackAttrib->
pAttr->
Clone());
1764 const sal_Int32 nStart = pBackAttrib->
nStart;
1774 nEndTemp += nDiffLen;
1779 pAction->SetOffset(nDiffLen);
1781 if (bSpellErrorDescription)
1784 aSpellErrorDescriptionItem.
GetGrabBag()[
"SpellErrorDescription"] <<= aSpellErrorDescription.
toSequence();
1802 std::vector<EECharAttrib> aAttribList;
1807 ExtractErrorDescription(*pEECharAttrib, rSpellErrorDescription);
1832 lang::Locale aLocale;
1836 aWord = xAlt->getWord();
1837 aLocale = xAlt->getLocale();
1838 aAlts = xAlt->getAlternatives();
1862struct LanguagePosition_Impl
1864 sal_Int32 nPosition;
1867 LanguagePosition_Impl(sal_Int32 nPos,
LanguageType eLang) :
1880 LanguagePositions_Impl::iterator aStart = rBreakPositions.begin();
1881 while(aStart != rBreakPositions.end())
1883 if(aStart->nPosition == nInsert)
1887 aStart->eLanguage = eLanguage;
1890 else if(aStart->nPosition > nInsert)
1893 rBreakPositions.insert(aStart, LanguagePosition_Impl(nInsert, eLanguage));
1899 rBreakPositions.emplace_back(nInsert, eLanguage);
1912 std::vector<EECharAttrib> aAttribList;
1923 while (nCursor < nTextLen)
1926 if(pLang && pLang != pLastLang)
1934 if (pError && pLastError != pError)
1938 pLastError = pError;
1944 if (aBreakPositions.empty())
1952 aRet.push_back(aPortion1);
1956 LanguagePositions_Impl::iterator aStart = aBreakPositions.begin();
1958 eLang = aStart->eLanguage;
1959 sal_Int32 nStart = aStart->nPosition;
1960 DBG_ASSERT(!nStart,
"invalid start position - language attribute missing?");
1963 while(aStart != aBreakPositions.end())
1971 if( bIsIgnoreError )
1975 aRet.push_back(aPortion1);
1976 nStart = aStart->nPosition;
1977 eLang = aStart->eLanguage;
1985 const sal_uInt32 nPara =
m_xEditEngine->GetParagraphCount();
1988 OUStringBuffer aLeftOverText;
1989 for (sal_uInt32
i = 1;
i < nPara; ++
i)
1991 aLeftOverText.append(
"\x0a");
1998 aPortion2.
sText = aLeftOverText.makeStringAndClear();
1999 aRet.push_back( aPortion2 );
2003 aRet[ aRet.size() - 1 ].sText += aLeftOverText;
2045 return m_xEditEngine->GetUndoManager().GetUndoActionCount();
2090 pWidget->set_sensitive(
false);
#define ACTION_SELECTFIELD
#define SPELLUNDO_CHANGE_GROUP
#define SPELLUNDO_CHANGE_TEXTENGINE
#define SPELLUNDO_UNDO_EDIT_MODE
#define SPELLUNDO_CHANGE_NEXTERROR
#define SPELLUNDO_CHANGE_LANGUAGE
#define SPELLUNDO_CHANGE_ADD_TO_DICTIONARY
#define SPELLUNDO_MOVE_ERROREND
static void lcl_InsertBreakPosition_Impl(LanguagePositions_Impl &rBreakPositions, sal_Int32 nInsert, LanguageType eLanguage)
std::vector< LanguagePosition_Impl > LanguagePositions_Impl
#define SPELLUNDO_ADD_IGNORE_RULE
PropertiesInfo aProperties
SfxApplication * SfxGetpApp()
Reference< XExecutableDialog > m_xDialog
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
static void RemoveUserEvent(ImplSVEvent *nUserEvent)
const vcl::KeyCode & GetKeyCode() const
LanguageType getLanguageType(bool bResolveSystem=true) const
static css::lang::Locale convertToLocale(LanguageType nLangID, bool bResolveSystem=true)
static LanguageType convertToLanguageType(const css::lang::Locale &rLocale, bool bResolveSystem=true)
static css::uno::Reference< css::linguistic2::XSpellChecker1 > GetSpellChecker()
static css::uno::Reference< css::linguistic2::XDictionary > GetChangeAllList()
static css::uno::Reference< css::linguistic2::XSearchableDictionaryList > GetDictionaryList()
static css::uno::Reference< css::linguistic2::XDictionary > GetIgnoreAllList()
static css::uno::Reference< css::linguistic2::XDictionary > GetStandardDic()
static void ApplyLanguageOptions(const SfxItemSet &rSet)
const std::map< OUString, css::uno::Any > & GetGrabBag() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
virtual void Deactivate() override
virtual void Activate() override
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const=0
SfxItemPool & GetPool() const
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false)
SfxUndoAction * GetUndoAction(size_t nNo=0) const
static SAL_WARN_UNUSED_RESULT SfxViewFrame * Current()
constexpr tools::Long Height() const
constexpr tools::Long Width() const
static OUString GetLanguageString(const LanguageType eType)
OUString GetSpellAndGrammarContextDictionaryImage(const OUString &rServiceImplName) const
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
static bool DoesKeyChangeText(const KeyEvent &rKeyEvent)
SentenceEditWindow_Impl & m_rSentenceED
UndoChangeGroupGuard(SentenceEditWindow_Impl &rSentenceED)
std::unique_ptr< EditEngine > m_xEditEngine
std::unique_ptr< EditView > m_xEditView
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
SentenceEditWindow_Impl()
OUString GetErrorText() const
bool IsUndoEditMode() const
bool GetAlternatives(SpellErrorDescription &rDesc)
void MoveErrorMarkTo(sal_Int32 nErrorStart, sal_Int32 nErrorEnd, bool bGrammar)
size_t GetUndoActionCount() const
virtual bool KeyInput(const KeyEvent &rKEvt) override
void Init(weld::Toolbar *pToolbar)
std::set< sal_Int32 > m_aIgnoreErrorsAt
void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction)
void SetAlternatives(const css::uno::Reference< css::linguistic2::XSpellAlternatives > &)
SpellDialog * GetSpellDialog() const
void UndoActionStart(sal_uInt16 nId)
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
int ChangeMarkedWord(const OUString &rNewWord, LanguageType eLanguage)
void RestoreCurrentError()
void SetText(const OUString &rStr)
virtual ~SentenceEditWindow_Impl() override
weld::Toolbar * m_pToolbar
void MoveErrorEnd(tools::Long nOffset)
svx::SpellPortions CreateSpellPortions() const
bool MarkNextError(bool bIgnoreCurrentError, const css::uno::Reference< css::linguistic2::XSpellChecker1 > &)
void SetUndoEditMode(bool bSet)
void SetAttrib(const SfxPoolItem &rItem, sal_Int32 nStart, sal_Int32 nEnd)
bool GetErrorDescription(SpellErrorDescription &rSpellErrorDescription, sal_Int32 nPosition)
virtual bool HasAutoCorrection()
virtual bool HasGrammarChecking()
virtual void ApplyChangedSentence(const SpellPortions &rChanged, bool bRecheck)=0
virtual SpellPortions GetNextWrongSentence(bool bRecheck)=0
virtual void GetFocus()=0
virtual void LoseFocus()=0
std::unique_ptr< SvxLanguageBox > m_xLanguageLB
std::unique_ptr< weld::MenuButton > m_xAddToDictMB
std::unique_ptr< weld::CheckButton > m_xCheckGrammarCB
void ToplevelFocusChanged()
virtual void Deactivate() override
std::unique_ptr< weld::Label > m_xNoSuggestionsFT
std::unique_ptr< weld::Button > m_xIgnoreRulePB
svx::SpellPortions m_aSavedSentence
void SpellContinue_Impl(std::unique_ptr< UndoChangeGroupGuard > *pGuard=nullptr, bool UseSavedSentence=false, bool bIgnoreCurrentError=false)
std::unique_ptr< weld::Button > m_xChangeAllPB
std::unique_ptr< SpellDialog_Impl > pImpl
std::unique_ptr< weld::Label > m_xResumeFT
std::unique_ptr< weld::Label > m_xExplainFT
Link< SpellUndoAction_Impl &, void > aDialogUndoLink
std::unique_ptr< weld::Button > m_xIgnorePB
void StartSpellOptDlg_Impl()
std::unique_ptr< weld::Button > m_xUndoPB
OUString m_sNoSuggestionsST
OUString m_sTitleSpellingGrammar
void Impl_Restore(bool bUseSavedSentence)
static bool ApplyChangeAllList_Impl(SpellPortions &rSentence, bool &bHasReplaced)
Corrects all errors that have been selected to be changed always.
ImplSVEvent * m_pInitHdlEvent
virtual void Close() override
css::uno::Reference< css::linguistic2::XSpellChecker1 > xSpell
virtual void Activate() override
void SetTitle_Impl(LanguageType nLang)
LanguageType GetSelectedLang_Impl() const
std::unique_ptr< SentenceEditWindow_Impl > m_xSentenceED
OUString m_sTitleSpelling
std::unique_ptr< weld::Button > m_xAddToDictPB
void UpdateBoxes_Impl(bool bCallFromSelectHdl=false)
std::unique_ptr< weld::Button > m_xChangePB
std::unique_ptr< weld::Label > m_xNotInDictFT
virtual ~SpellDialog() override
std::shared_ptr< SfxSingleTabDialogController > m_xOptionsDlg
std::unique_ptr< weld::Label > m_xSuggestionFT
std::unique_ptr< weld::Button > m_xAutoCorrPB
std::unique_ptr< weld::LinkButton > m_xExplainLink
void AddToDictionaryExecute(const OUString &rItemId)
svx::SpellDialogChildWindow & rParent
std::unique_ptr< weld::Label > m_xLanguageFT
std::unique_ptr< weld::Label > m_xAltTitle
std::unique_ptr< weld::Button > m_xIgnoreAllPB
std::unique_ptr< weld::Button > m_xOptionsPB
std::unique_ptr< weld::Button > m_xClosePB
std::unique_ptr< weld::TreeView > m_xSuggestionLB
std::unique_ptr< weld::Toolbar > m_xToolbar
OUString getReplacementString() const
bool GetNextSentence_Impl(std::unique_ptr< UndoChangeGroupGuard > *pGuard, bool bUseSavedSentence, bool bRecheck)
Retrieves the next sentence.
tools::Long GetOffset() const
void SetOffset(tools::Long nSet)
SpellUndoAction_Impl(sal_uInt16 nId, const Link< SpellUndoAction_Impl &, void > &rActionLink)
const Reference< XDictionary > & GetDictionary() const
tools::Long m_nOldErrorEnd
bool IsEnableChangeAllPB() const
bool m_bIsErrorLanguageSelected
void SetAddedWord(const OUString &rWord)
bool m_bEnableChangeAllPB
void SetErrorLanguageSelected(bool bSet)
tools::Long GetOldErrorEnd() const
tools::Long m_nOldErrorStart
bool IsEnableChangePB() const
bool IsErrorLanguageSelected() const
tools::Long GetOldErrorStart() const
Reference< XDictionary > m_xDictionary
void SetEnableChangeAllPB()
void SetDictionary(const Reference< XDictionary > &xDict)
const OUString & GetAddedWord() const
const Link< SpellUndoAction_Impl &, void > & m_rActionLink
void SetErrorMove(tools::Long nOldStart, tools::Long nOldEnd)
virtual void Undo() override
sal_uInt16 GetCode() const
static bool runAsync(const std::shared_ptr< DialogController > &rController, const std::function< void(sal_Int32)> &)
virtual OutputDevice & get_ref_device()=0
constexpr ::Color COL_LIGHTGRAY(0xC0, 0xC0, 0xC0)
#define DBG_ASSERT(sCon, aError)
virtual sal_uInt32 GetId() const override
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT(EE_CHAR_START+4)
constexpr TypedWhichId< SvxColorItem > EE_CHAR_COLOR(EE_CHAR_START+0)
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT_CTL(EE_CHAR_START+22)
constexpr TypedWhichId< SfxGrabBagItem > EE_CHAR_GRABBAG(EE_CHAR_START+31)
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT_CJK(EE_CHAR_START+21)
constexpr TypedWhichId< SvxColorItem > EE_CHAR_BKGCOLOR(EE_CHAR_START+32)
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE(EE_CHAR_START+14)
constexpr sal_uInt16 KEY_TAB
constexpr sal_uInt16 KEY_DELETE
constexpr sal_uInt16 KEY_BACKSPACE
#define LANGUAGE_DONTKNOW
#define LINK(Instance, Class, Member)
#define SAL_WARN_IF(condition, area, stream)
LanguageType GetLanguage(SfxItemSet const &aSet, sal_uInt16 nLangWhichId)
LNG_DLLPUBLIC bool SaveDictionaries(const css::uno::Reference< css::linguistic2::XSearchableDictionaryList > &xDicList)
LNG_DLLPUBLIC DictionaryError AddEntryToDic(css::uno::Reference< css::linguistic2::XDictionary > const &rxDic, const OUString &rWord, bool bIsNeg, const OUString &rRplcTxt, bool bStripDot=true)
IMPL_LINK(ClassificationDialog, SelectClassificationHdl, weld::ComboBox &, rBox, void)
std::vector< SpellPortion > SpellPortions
IMPL_LINK_NOARG(ClassificationDialog, OnAsyncExpandHdl, void *, void)
FncGetSpecialChars GetGetSpecialCharsFunction()
void SvxPrepareAutoCorrect(OUString &rOldText, std::u16string_view rNewText)
const SfxPoolItem * pAttr
Sequence< Reference< XDictionary > > aDics
css::uno::Sequence< OUString > aSuggestions
css::uno::Sequence< css::uno::Any > toSequence() const
css::lang::Locale aLocale
short SvxDicError(weld::Window *pParent, linguistic::DictionaryError nError)