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)",
"")));
266 m_xLanguageLB->SetLanguageList(SvxLanguageListFlags::SPELL_USED,
false,
false,
true);
278 bool bSpellErrorDescription =
m_xSentenceED->GetAlternatives(aSpellErrorDescription);
282 bool bIsGrammarError =
false;
283 if( bSpellErrorDescription )
291 if( bSpellErrorDescription && !aSpellErrorDescription.
sDialogTitle.isEmpty() )
300 if( !bCallFromSelectHdl )
305 const OUString *pNewWords = aNewWords.getConstArray();
306 const sal_Int32 nSize = aNewWords.getLength();
307 for (
i = 0;
i < nSize; ++
i )
309 OUString aTmp( pNewWords[
i] );
325 bool bShowChangeAll = !bIsGrammarError;
357 bool bNextSentence =
false;
368 bool bSpellErrorDescription =
m_xSentenceED->GetAlternatives(aSpellErrorDescription);
369 if (bSpellErrorDescription)
379 pWidget->set_sensitive(
true);
393 m_pInitHdlEvent =
nullptr;
396 m_xAutoCorrPB->set_visible(rParent.HasAutoCorrection());
397 SpellContinue_Impl(
nullptr);
398 m_xSentenceED->ResetUndo();
399 m_xUndoPB->set_sensitive(
false);
407 LockFocusChanges(
true);
408 if(m_xSentenceED->IsEnabled())
409 m_xSentenceED->GrabFocus();
410 else if( m_xChangePB->get_sensitive() )
411 m_xChangePB->grab_focus();
412 else if( m_xIgnorePB->get_sensitive() )
413 m_xIgnorePB->grab_focus();
414 else if( m_xClosePB->get_sensitive() )
415 m_xClosePB->grab_focus();
416 LockFocusChanges(
false);
418 m_xCheckGrammarCB->set_active(rParent.IsGrammarChecking());
424 if (m_xOptionsPB.get() == &rBtn)
425 StartSpellOptDlg_Impl();
426 else if (m_xAutoCorrPB.get() == &rBtn)
429 OUString sCurrentErrorText = m_xSentenceED->GetErrorText();
431 SpellErrorDescription aSpellErrorDescription;
432 bool bSpellErrorDescription = m_xSentenceED->GetAlternatives(aSpellErrorDescription);
433 if (bSpellErrorDescription)
435 OUString sWrong(aSpellErrorDescription.sErrorText);
439 if(sWrong == sCurrentErrorText &&
440 m_xSuggestionLB->get_sensitive() && m_xSuggestionLB->get_selected_index() != -1 &&
441 m_sNoSuggestionsST != m_xSuggestionLB->get_selected_text())
443 sCurrentErrorText = m_xSuggestionLB->get_selected_text();
445 if(sWrong != sCurrentErrorText)
449 rParent.AddAutoCorrection( sWrong, sCurrentErrorText, eLang );
451 ChangeHdl(*m_xAutoCorrPB);
459 rParent.SetGrammarChecking(m_xCheckGrammarCB->get_active());
482 OUString getDotReplacementString(
const OUString &rErrorText,
const OUString &rSuggestedReplacement)
484 OUString aString = rErrorText;
487 bool bDot = aString.endsWith(
".");
489 aString = rSuggestedReplacement;
491 if(bDot && (aString.isEmpty() || !aString.endsWith(
".")))
502 OUString sReplacement(sOrigString);
509 return getDotReplacementString(sOrigString, sReplacement);
514 ChangeHdl(*m_xChangePB);
529 : m_rSentenceED(rSentenceED)
535 m_rSentenceED.UndoActionEnd();
541 if (m_xSentenceED->IsUndoEditMode())
543 SpellContinue_Impl();
547 auto xGuard(std::make_unique<UndoChangeGroupGuard>(*m_xSentenceED));
548 OUString aString = getReplacementString();
549 m_xSentenceED->ChangeMarkedWord(aString, GetSelectedLang_Impl());
550 SpellContinue_Impl(&xGuard);
552 if(!m_xChangePB->get_sensitive())
553 m_xIgnorePB->grab_focus();
558 auto xGuard(std::make_unique<UndoChangeGroupGuard>(*m_xSentenceED));
559 OUString aString = getReplacementString();
563 OUString aOldWord( m_xSentenceED->GetErrorText() );
570 if(nAdded == DictionaryError::NONE)
572 std::unique_ptr<SpellUndoAction_Impl> pAction(
new SpellUndoAction_Impl(
574 pAction->SetDictionary(aXDictionary);
575 pAction->SetAddedWord(aOldWord);
576 m_xSentenceED->AddUndoAction(std::move(pAction));
579 m_xSentenceED->ChangeMarkedWord(aString, eLang);
580 SpellContinue_Impl(&xGuard);
585 auto xGuard(std::make_unique<UndoChangeGroupGuard>(*m_xSentenceED));
589 m_xSentenceED->RestoreCurrentError();
590 if (&rButton == m_xIgnoreRulePB.get())
592 SpellErrorDescription aSpellErrorDescription;
593 bool bSpellErrorDescription = m_xSentenceED->GetAlternatives(aSpellErrorDescription);
596 if( bSpellErrorDescription && aSpellErrorDescription.xGrammarChecker.is() )
598 aSpellErrorDescription.xGrammarChecker->ignoreRule(aSpellErrorDescription.sRuleId,
599 aSpellErrorDescription.aLocale);
601 aXDictionary->setActive(
false);
602 aXDictionary->setActive(
true);
605 catch(
const uno::Exception& )
611 OUString sErrorText(m_xSentenceED->GetErrorText());
615 if (nAdded == DictionaryError::NONE)
617 std::unique_ptr<SpellUndoAction_Impl> pAction(
new SpellUndoAction_Impl(
619 pAction->SetDictionary(aXDictionary);
620 pAction->SetAddedWord(sErrorText);
621 m_xSentenceED->AddUndoAction(std::move(pAction));
625 SpellContinue_Impl(&xGuard);
630 m_xSentenceED->Undo();
631 if(!m_xSentenceED->GetUndoActionCount())
632 m_xUndoPB->set_sensitive(
false);
636IMPL_LINK( SpellDialog, DialogUndoHdl, SpellUndoAction_Impl&, rAction,
void )
638 switch(rAction.GetId())
642 if(rAction.IsEnableChangePB())
643 m_xChangePB->set_sensitive(
false);
644 if(rAction.IsEnableChangeAllPB())
645 m_xChangeAllPB->set_sensitive(
false);
650 m_xSentenceED->MoveErrorMarkTo(
static_cast<sal_Int32
>(rAction.GetOldErrorStart()),
651 static_cast<sal_Int32
>(rAction.GetOldErrorEnd()),
653 if(rAction.IsErrorLanguageSelected())
661 if(rAction.GetDictionary().is())
662 rAction.GetDictionary()->remove(rAction.GetAddedWord());
667 if(rAction.GetOffset() != 0)
668 m_xSentenceED->MoveErrorEnd(rAction.GetOffset());
674 SpellContinue_Impl(
nullptr,
true);
697 if (m_sResumeST == m_xIgnorePB->get_label())
705 m_xSentenceED->RestoreCurrentError();
708 SpellContinue_Impl(
nullptr,
false,
true);
723 pViewFrame->ToggleChildWindow(
rParent.GetType());
740 OUString sError = m_xSentenceED->GetErrorText();
741 m_xSuggestionLB->clear();
742 if (!sError.isEmpty())
744 LanguageType eLanguage = m_xLanguageLB->get_active_id();
745 Reference <XSpellAlternatives> xAlt = xSpell->spell( sError,
static_cast<sal_uInt16
>(eLanguage),
746 Sequence< PropertyValue >() );
748 m_xSentenceED->SetAlternatives( xAlt );
751 m_xSentenceED->ChangeMarkedWord( sError, eLanguage );
752 SpellContinue_Impl();
771 const Reference< XDictionary > *pDic =
nullptr;
782 xDic->setActive(
true );
784 pImpl->aDics = xDicList->getDictionaries();
790 bool bEnable =
false;
791 const sal_Int32 nSize =
pImpl->aDics.getLength();
792 pDic =
pImpl->aDics.getConstArray();
794 sal_uInt16 nItemId = 1;
795 for (sal_Int32
i = 0;
i < nSize; ++
i)
803 if( xDicTmp->isActive()
804 && xDicTmp->getDictionaryType() != linguistic2::DictionaryType_NEGATIVE
806 && (!xStor.is() || !xStor->isReadonly()) )
810 OUString aDictionaryImageUrl;
815 xSvcInfo->getImplementationName());
818 m_xAddToDictMB->append_item(OUString::number(nItemId), xDicTmp->getName(), aDictionaryImageUrl);
826 int nDicts = nItemId-1;
836 AddToDictionaryExecute(OString::number(1));
839IMPL_LINK(SpellDialog, AddToDictSelectHdl,
const OString&, rIdent,
void)
841 AddToDictionaryExecute(rIdent);
846 auto xGuard(std::make_unique<UndoChangeGroupGuard>(*
m_xSentenceED));
857 xDic = xDicList->getDictionaryByName( aDicName );
862 nAddRes =
AddEntryToDic( xDic, aNewWord,
false, OUString() );
868 if (nAddRes == DictionaryError::NONE)
872 pAction->SetDictionary( xDic );
873 pAction->SetAddedWord( aNewWord );
877 if (DictionaryError::NONE != nAddRes && xDic->getEntry( aNewWord ).is())
878 nAddRes = DictionaryError::NONE;
880 if (DictionaryError::NONE != nAddRes)
892 m_xSuggestionLB->unselect_all();
893 m_xSuggestionLB->set_sensitive(
false);
894 m_xAutoCorrPB->set_sensitive(
false);
896 if(!m_xChangeAllPB->get_sensitive())
898 m_xChangeAllPB->set_sensitive(
true);
899 pSpellAction->SetEnableChangeAllPB();
901 if(!m_xChangePB->get_sensitive())
903 m_xChangePB->set_sensitive(
true);
904 pSpellAction->SetEnableChangePB();
906 m_xSentenceED->AddUndoAction(std::move(pSpellAction));
912 if (m_xSentenceED->IsModified())
914 rParent.ApplyChangedSentence(m_xSentenceED->CreateSpellPortions(),
false);
980 pWidget->set_sensitive(
false);
988 if(!bUseSavedSentence)
996 if(!bUseSavedSentence)
998 bool bHasReplaced =
false;
999 while(!aSentence.empty())
1013 if(!aSentence.empty())
1015 OUStringBuffer sText;
1016 for (
auto const& elem : aSentence)
1020 sText.append(elem.sText);
1026 sal_Int32 nStartPosition = 0;
1027 sal_Int32 nEndPosition = 0;
1029 for (
auto const& elem : aSentence)
1034 nEndPosition += elem.sText.getLength();
1035 if(elem.xAlternatives.is())
1038 elem.xAlternatives->getLocale(), elem.xAlternatives->getAlternatives(),
nullptr);
1041 m_xSentenceED->SetAttrib(aSpellErrorDescription, nStartPosition, nEndPosition);
1043 else if(elem.bIsGrammarError )
1045 beans::PropertyValues
aProperties = elem.aGrammarError.aProperties;
1046 OUString sFullCommentURL;
1048 while ( sFullCommentURL.isEmpty() &&
i <
aProperties.getLength() )
1053 aValue >>= sFullCommentURL;
1061 elem.aGrammarError.aSuggestions,
1062 elem.xGrammarChecker,
1064 &elem.aGrammarError.aFullComment,
1065 &elem.aGrammarError.aRuleIdentifier,
1070 m_xSentenceED->SetAttrib(aSpellErrorDescriptionItem, nStartPosition, nEndPosition);
1076 nStartPosition = nEndPosition;
1084 bRet = nStartPosition > 0;
1094 bHasReplaced =
false;
1097 if(!xChangeAll->getCount())
1100 for (
auto & elem : rSentence)
1102 if(elem.xAlternatives.is())
1104 const OUString &rString = elem.sText;
1106 Reference<XDictionaryEntry> xEntry = xChangeAll->getEntry(rString);
1110 elem.sText = getDotReplacementString(rString, xEntry->getReplacementText());
1111 elem.xAlternatives =
nullptr;
1112 bHasReplaced =
true;
1117 else if( elem.bIsGrammarError )
1124 : m_pSpellDialog(nullptr)
1125 , m_pToolbar(nullptr)
1128 , m_bIsUndoEditMode(false)
1155 const EECharAttrib* FindCharAttrib(
int nPosition, sal_uInt16 nWhich, std::vector<EECharAttrib>& rAttribList)
1157 for (
auto it = rAttribList.rbegin(); it != rAttribList.rend(); ++it)
1159 const auto& rTextAtr = *it;
1160 if (rTextAtr.pAttr->Which() != nWhich)
1162 if (rTextAtr.nStart <= nPosition && rTextAtr.nEnd >= nPosition)
1171 void ExtractErrorDescription(
const EECharAttrib& rEECharAttrib, SpellErrorDescription& rSpellErrorDescription)
1173 css::uno::Sequence<css::uno::Any> aSequence;
1174 static_cast<const SfxGrabBagItem*
>(rEECharAttrib.
pAttr)->GetGrabBag().find(
"SpellErrorDescription")->second >>= aSequence;
1175 rSpellErrorDescription.fromSequence(aSequence);
1245#define OUTSIDE_YES 8
1247#define ACTION_UNDOEDIT 0
1248#define ACTION_CONTINUE 1
1249#define ACTION_SELECTFIELD 2
1250#define ACTION_EXPAND 3
1257 bool bConsumed =
false;
1265 aCurrentSelection.
Adjust();
1268 bool bHasFieldLeft =
false;
1269 bool bHasErrorLeft =
false;
1271 bool bHasRange = aCurrentSelection.
HasRange();
1274 std::vector<EECharAttrib> aAttribList;
1277 auto nCursor = aCurrentSelection.
nStartPos;
1283 bool bHasField = pBackAttr !=
nullptr && (bHasRange || pBackAttr->
nEnd > nCursor);
1284 bool bHasError = pErrorAttr !=
nullptr && (bHasRange || pErrorAttr->
nEnd > nCursor);
1291 nSelectionType =
FULL;
1293 else if (pErrorAttr &&
1302 while (nCursor < aCurrentSelection.
nEndPos)
1308 if (pIntBackAttr || pIntErrorAttr)
1309 nSelectionType =
BRACE;
1311 if (pIntBackAttr && !pBackAttr)
1312 pBackAttr = pIntBackAttr;
1313 bHasField |= pIntBackAttr !=
nullptr;
1320 const EECharAttrib* pCurAttr = pBackAttr ? pBackAttr : pErrorAttr;
1329 bHasFieldLeft = pBackAttr && pBackAttr->
nEnd == nCursor;
1332 pBackAttrLeft = pBackAttr;
1333 pBackAttr =
nullptr;
1335 bHasErrorLeft = pErrorAttr && pErrorAttr->
nEnd == nCursor;
1338 pErrorAttrLeft = pErrorAttr;
1339 pErrorAttr =
nullptr;
1349 pErrorAttrLeft = FindCharAttrib(nCursor,
EE_CHAR_GRABBAG, aAttribList);
1350 bHasFieldLeft = pBackAttrLeft !=
nullptr;
1351 bHasErrorLeft = pErrorAttrLeft !=
nullptr;
1360 nSelectionType ==
INVALID,
"cui.dialogs",
1361 "selection type not set");
1368 switch(nSelectionType)
1377 pBackAttr =
nullptr;
1421 sal_Int32 nCurrentLen =
m_xEditEngine->GetText().getLength();
1428 const EECharAttrib* pCharAttr = pBackAttr ? pBackAttr : pBackAttrLeft;
1434 DBG_ASSERT(pErrorAttrLeft || pErrorAttr,
"where is the error");
1439 ExtractErrorDescription(*pErrorAttrLeft, aSpellErrorDescription);
1441 std::unique_ptr<SfxPoolItem> xNewError(pErrorAttrLeft->
pAttr->
Clone());
1442 sal_Int32 nStart = pErrorAttrLeft->
nStart;
1443 sal_Int32 nEnd = pErrorAttrLeft->
nEnd + 1;
1455 else if (pErrorAttr)
1458 ExtractErrorDescription(*pErrorAttr, aSpellErrorDescription);
1461 sal_Int32 nAddedChars =
m_xEditEngine->GetText().getLength() - nCurrentLen;
1463 std::unique_ptr<SfxPoolItem> xNewError(pErrorAttr->
pAttr->
Clone());
1464 sal_Int32 nStart = pErrorAttr->
nStart + nAddedChars;
1465 sal_Int32 nEnd = pErrorAttr->
nEnd + nAddedChars;
1467 nStart = pErrorAttr->
nStart;
1479 std::unique_ptr<SfxPoolItem> xNewBack(pBackAttrLeft->
pAttr->
Clone());
1480 sal_Int32 _nStart = pBackAttrLeft->
nStart + nAddedChars;
1481 sal_Int32 _nEnd = pBackAttrLeft->
nEnd + nAddedChars;
1483 _nStart = pBackAttrLeft->
nStart;
1500 if (pFontColor && pErrorAttrib)
1506 std::unique_ptr<SfxPoolItem> xNewError(pErrorAttrib->
pAttr->
Clone());
1529IMPL_LINK(SentenceEditWindow_Impl, ToolbarHdl,
const OString&, rCurItemId,
void)
1531 if (rCurItemId ==
"paste")
1533 m_xEditView->Paste();
1536 else if (rCurItemId ==
"insert")
1540 OUString aChars = pImplFncGetSpecialChars(GetDrawingArea(), m_xEditEngine->GetStandardFont(0));
1541 if (!aChars.isEmpty())
1543 ESelection aCurrentSelection(m_xEditView->GetSelection());
1544 m_xEditEngine->QuickInsertText(aChars, aCurrentSelection);
1553 if (bIgnoreCurrentError)
1573 std::vector<EECharAttrib> aAttribList;
1578 bool bGrammarError =
false;
1579 while (nCursor < nTextLen)
1584 sal_Int32 nMinPos = nTextLen + 1;
1585 for (
const auto& rTextAtr : aAttribList)
1589 if (rTextAtr.nEnd > nCursor && rTextAtr.nStart < nMinPos)
1591 nMinPos = rTextAtr.
nStart;
1592 pEECharAttrib = &rTextAtr;
1598 ExtractErrorDescription(*pEECharAttrib, aSpellErrorDescription);
1604 pSpellErrorDescription = &aSpellErrorDescription;
1607 nCursor = std::max(nCursor, nMinPos);
1611 Reference<XDictionaryEntry> xEntry;
1613 if (xChangeAll->getCount() && pSpellErrorDescription &&
1614 (xEntry = xChangeAll->getEntry( pSpellErrorDescription->
sErrorText )).is())
1616 OUString sReplacement(getDotReplacementString(
GetErrorText(), xEntry->getReplacementText()));
1620 nCursor += sReplacement.getLength();
1626 else if(pSpellErrorDescription && !bGrammarError &&
1629 Sequence< PropertyValue >() ))
1638 if (nCursor < nTextLen)
1645 pAction->SetErrorMove(nOldErrorStart, nOldErrorEnd);
1649 pAction->SetErrorLanguageSelected(aSpellErrorDescription.
aSuggestions.hasElements() &&
1653 pAction->SetErrorLanguageSelected(
false);
1693 aCurrentSelection.
Adjust();
1694 bool bCurrentSelectionInRange = nStart <= aCurrentSelection.
nEndPos && aCurrentSelection.
nStartPos <= nEnd;
1695 if (!bCurrentSelectionInRange)
1708 std::vector<EECharAttrib> aAttribList;
1716 DBG_ASSERT(pErrorAttrib,
"no error attribute found");
1717 bool bSpellErrorDescription =
false;
1721 ExtractErrorDescription(*pErrorAttrib, aSpellErrorDescription);
1723 bSpellErrorDescription =
true;
1743 if (pLangAttrib && !pLangAttrib->
nStart && pLangAttrib->
nEnd == nTextLen)
1754 std::unique_ptr<SfxPoolItem> xNewBackground(pBackAttrib->
pAttr->
Clone());
1755 const sal_Int32 nStart = pBackAttrib->
nStart;
1765 nEndTemp += nDiffLen;
1770 pAction->SetOffset(nDiffLen);
1772 if (bSpellErrorDescription)
1775 aSpellErrorDescriptionItem.
GetGrabBag()[
"SpellErrorDescription"] <<= aSpellErrorDescription.
toSequence();
1793 std::vector<EECharAttrib> aAttribList;
1798 ExtractErrorDescription(*pEECharAttrib, rSpellErrorDescription);
1823 lang::Locale aLocale;
1827 aWord = xAlt->getWord();
1828 aLocale = xAlt->getLocale();
1829 aAlts = xAlt->getAlternatives();
1853struct LanguagePosition_Impl
1855 sal_Int32 nPosition;
1858 LanguagePosition_Impl(sal_Int32 nPos,
LanguageType eLang) :
1871 LanguagePositions_Impl::iterator aStart = rBreakPositions.begin();
1872 while(aStart != rBreakPositions.end())
1874 if(aStart->nPosition == nInsert)
1878 aStart->eLanguage = eLanguage;
1881 else if(aStart->nPosition > nInsert)
1884 rBreakPositions.insert(aStart, LanguagePosition_Impl(nInsert, eLanguage));
1890 rBreakPositions.emplace_back(nInsert, eLanguage);
1903 std::vector<EECharAttrib> aAttribList;
1914 while (nCursor < nTextLen)
1917 if(pLang && pLang != pLastLang)
1925 if (pError && pLastError != pError)
1929 pLastError = pError;
1935 if (aBreakPositions.empty())
1943 aRet.push_back(aPortion1);
1947 LanguagePositions_Impl::iterator aStart = aBreakPositions.begin();
1949 eLang = aStart->eLanguage;
1950 sal_Int32 nStart = aStart->nPosition;
1951 DBG_ASSERT(!nStart,
"invalid start position - language attribute missing?");
1954 while(aStart != aBreakPositions.end())
1962 if( bIsIgnoreError )
1966 aRet.push_back(aPortion1);
1967 nStart = aStart->nPosition;
1968 eLang = aStart->eLanguage;
1976 const sal_uInt32 nPara =
m_xEditEngine->GetParagraphCount();
1979 OUStringBuffer aLeftOverText;
1980 for (sal_uInt32
i = 1;
i < nPara; ++
i)
1982 aLeftOverText.append(
"\x0a");
1989 aPortion2.
sText = aLeftOverText.makeStringAndClear();
1990 aRet.push_back( aPortion2 );
1994 aRet[ aRet.size() - 1 ].sText += aLeftOverText;
2036 return m_xEditEngine->GetUndoManager().GetUndoActionCount();
2081 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
const SfxItemSet * GetOutputItemSet() const
void SetTabPage(std::unique_ptr< SfxTabPage > xTabPage)
weld::Container * get_content_area()
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
void AddToDictionaryExecute(const OString &rItemId)
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::unique_ptr< weld::Label > m_xSuggestionFT
std::unique_ptr< weld::Button > m_xAutoCorrPB
std::unique_ptr< weld::LinkButton > m_xExplainLink
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
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(AccessibilityCheckEntry, GotoButtonClicked, weld::Button &, 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)