LibreOffice Module sw (master)  1
olmenu.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <SwRewriter.hxx>
21 #include <cmdid.h>
22 #include <strings.hrc>
23 #include <doc.hxx>
24 #include <docsh.hxx>
25 #include <edtwin.hxx>
26 #include <helpids.h>
27 #include <hintids.hxx>
28 #include <langhelper.hxx>
29 #include <ndtxt.hxx>
30 #include <bitmaps.hlst>
31 #include <olmenu.hxx>
32 #include <swabstdlg.hxx>
33 #include <swmodule.hxx>
34 #include <swtypes.hxx>
35 #include <swundo.hxx>
36 #include <uitool.hxx>
37 #include <unomid.h>
38 #include <view.hxx>
39 #include <viewopt.hxx>
40 #include <wrtsh.hxx>
41 #include <wview.hxx>
42 #include <textsh.hxx>
43 
46 #include <cppuhelper/exc_hlp.hxx>
47 #include <editeng/acorrcfg.hxx>
48 #include <editeng/svxacorr.hxx>
49 #include <editeng/langitem.hxx>
50 #include <editeng/splwrap.hxx>
51 #include <editeng/brushitem.hxx>
52 #include <editeng/unolingu.hxx>
53 #include <editeng/editview.hxx>
54 #include <i18nlangtag/mslangid.hxx>
56 #include <linguistic/lngprops.hxx>
57 #include <linguistic/misc.hxx>
58 #include <osl/file.hxx>
59 #include <rtl/string.hxx>
61 #include <vcl/graphicfilter.hxx>
62 #include <vcl/svapp.hxx>
63 #include <vcl/weld.hxx>
64 #include <sfx2/dispatch.hxx>
65 #include <sfx2/request.hxx>
66 #include <sfx2/sfxdlg.hxx>
67 #include <sfx2/viewfrm.hxx>
68 #include <svl/itemset.hxx>
69 #include <svl/languageoptions.hxx>
70 #include <svl/stritem.hxx>
71 #include <svtools/langtab.hxx>
72 #include <svx/dlgutil.hxx>
73 #include <svx/svxids.hrc>
74 #include <unotools/lingucfg.hxx>
75 #include <unotools/linguprops.hxx>
76 #include <vcl/layout.hxx>
77 #include <vcl/settings.hxx>
78 #include <sal/macros.h>
79 
80 #include <map>
81 
82 #include <com/sun/star/document/XDocumentLanguages.hpp>
83 #include <com/sun/star/frame/XFrame.hpp>
84 #include <com/sun/star/frame/XStorable.hpp>
85 #include <com/sun/star/i18n/ScriptType.hpp>
86 #include <com/sun/star/lang/XServiceInfo.hpp>
87 #include <com/sun/star/linguistic2/XLanguageGuessing.hpp>
88 #include <com/sun/star/uno/Any.hxx>
89 #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
90 #include <com/sun/star/system/SystemShellExecute.hpp>
91 #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
92 
93 using namespace ::com::sun::star;
94 
104 // check if nScriptType includes the script type associated to nLang
106 {
107  return bool(nScriptType & SvtLanguageOptions::GetScriptTypeOfLanguage( nLang ));
108 }
109 
111  PopupMenu *pPopupMenu,
112  sal_uInt16 nLangItemIdStart,
113  const uno::Sequence< OUString >& aSeq,
114  SwWrtShell* pWrtSh,
115  std::map< sal_Int16, OUString > &rLangTable )
116 {
117  if (!pPopupMenu)
118  return;
119 
120  // set of languages to be displayed in the sub menus
121  std::set< OUString > aLangItems;
122 
123  OUString aCurLang( aSeq[0] );
124  SvtScriptType nScriptType = static_cast<SvtScriptType>(aSeq[1].toInt32());
125  OUString aKeyboardLang( aSeq[2] );
126  OUString aGuessedTextLang( aSeq[3] );
127 
128  if (!aCurLang.isEmpty() &&
130  aLangItems.insert( aCurLang );
131 
132  //2--System
133  const AllSettings& rAllSettings = Application::GetSettings();
134  LanguageType rSystemLanguage = rAllSettings.GetLanguageTag().getLanguageType();
135  if (rSystemLanguage != LANGUAGE_DONTKNOW)
136  {
137  if (lcl_checkScriptType( nScriptType, rSystemLanguage ))
138  aLangItems.insert( SvtLanguageTable::GetLanguageString(rSystemLanguage) );
139  }
140 
141  //3--UI
142  LanguageType rUILanguage = rAllSettings.GetUILanguageTag().getLanguageType();
143  if (rUILanguage != LANGUAGE_DONTKNOW)
144  {
145  if (lcl_checkScriptType(nScriptType, rUILanguage ))
146  aLangItems.insert( SvtLanguageTable::GetLanguageString(rUILanguage) );
147  }
148 
149  //4--guessed language
150  if (!aGuessedTextLang.isEmpty())
151  {
152  if (lcl_checkScriptType(nScriptType, SvtLanguageTable::GetLanguageType(aGuessedTextLang)))
153  aLangItems.insert( aGuessedTextLang );
154  }
155 
156  //5--keyboard language
157  if (!aKeyboardLang.isEmpty())
158  {
159  if (lcl_checkScriptType(nScriptType, SvtLanguageTable::GetLanguageType(aKeyboardLang)))
160  aLangItems.insert( aKeyboardLang );
161  }
162 
163  //6--all languages used in current document
164  uno::Reference< css::frame::XModel > xModel;
165  uno::Reference< css::frame::XController > xController( pWrtSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface()->getController(), uno::UNO_QUERY );
166  if ( xController.is() )
167  xModel = xController->getModel();
168  uno::Reference< document::XDocumentLanguages > xDocumentLanguages( xModel, uno::UNO_QUERY );
169  /*the description of nScriptType flags
170  LATIN : 0x0001
171  ASIAN : 0x0002
172  COMPLEX: 0x0004
173  */
174  const sal_Int16 nMaxCount = 7;
175  if (xDocumentLanguages.is())
176  {
177  uno::Sequence< lang::Locale > rLocales( xDocumentLanguages->getDocumentLanguages( static_cast<sal_Int16>(nScriptType), nMaxCount ) );
178  if (rLocales.hasElements())
179  {
180  for (sal_Int32 i = 0; i < rLocales.getLength(); ++i)
181  {
182  if (aLangItems.size() == size_t(nMaxCount))
183  break;
184  const lang::Locale& rLocale = rLocales[i];
185  if (lcl_checkScriptType( nScriptType, SvtLanguageTable::GetLanguageType( rLocale.Language )))
186  aLangItems.insert( rLocale.Language );
187  }
188  }
189  }
190 
191  sal_uInt16 nItemId = nLangItemIdStart;
192  for (const OUString& aEntryText : aLangItems)
193  {
194  if (aEntryText != SvtLanguageTable::GetLanguageString( LANGUAGE_NONE ) &&
195  aEntryText != "*" && // multiple languages in current selection
196  !aEntryText.isEmpty()) // 'no language found' from language guessing
197  {
198  OSL_ENSURE( nLangItemIdStart <= nItemId && nItemId <= nLangItemIdStart + MN_MAX_NUM_LANG,
199  "nItemId outside of expected range!" );
200  pPopupMenu->InsertItem( nItemId, aEntryText, MenuItemBits::RADIOCHECK );
201  if (aEntryText == aCurLang)
202  {
203  //make a check mark for the current language
204  pPopupMenu->CheckItem( nItemId );
205  }
206  rLangTable[ nItemId ] = aEntryText;
207  ++nItemId;
208  }
209  }
210 
211  pPopupMenu->InsertItem( nLangItemIdStart + MN_NONE_OFFSET, SwResId( STR_LANGSTATUS_NONE ), MenuItemBits::RADIOCHECK );
213  pPopupMenu->CheckItem( nLangItemIdStart + MN_NONE_OFFSET );
214 
215  pPopupMenu->InsertItem( nLangItemIdStart + MN_RESET_OFFSET, SwResId( STR_RESET_TO_DEFAULT_LANGUAGE ) );
216  pPopupMenu->InsertItem( nLangItemIdStart + MN_MORE_OFFSET, SwResId( STR_LANGSTATUS_MORE ) );
217 }
218 
220  SwWrtShell* pWrtSh,
221  const uno::Reference< linguistic2::XSpellAlternatives > &xAlt,
222  const OUString &rParaText)
223  : m_aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "modules/swriter/ui/spellmenu.ui", "")
224  , m_xPopupMenu(m_aBuilder.get_menu("menu"))
225  , m_nIgnoreWordId(m_xPopupMenu->GetItemId("ignoreall"))
226  , m_nAddMenuId(m_xPopupMenu->GetItemId("addmenu"))
227  , m_nAddId(m_xPopupMenu->GetItemId("add"))
228  , m_nSpellDialogId(m_xPopupMenu->GetItemId("spelldialog"))
229  , m_nCorrectMenuId(m_xPopupMenu->GetItemId("correctmenu"))
230  , m_nCorrectDialogId(m_xPopupMenu->GetItemId("correctdialog"))
231  , m_nLangSelectionMenuId(m_xPopupMenu->GetItemId("langselection"))
232  , m_nLangParaMenuId(m_xPopupMenu->GetItemId("langpara"))
233  , m_nRedlineAcceptId(m_xPopupMenu->GetItemId("accept"))
234  , m_nRedlineRejectId(m_xPopupMenu->GetItemId("reject"))
235  , m_nRedlineNextId(m_xPopupMenu->GetItemId("next"))
236  , m_nRedlinePrevId(m_xPopupMenu->GetItemId("prev"))
237  , m_pSh( pWrtSh )
238  , m_xSpellAlt(xAlt)
239  , m_nGrammarError(0)
240  , m_bGrammarResults(false)
241 {
242  OSL_ENSURE(m_xSpellAlt.is(), "no spelling alternatives available");
243 
244  m_xPopupMenu->SetMenuFlags(MenuFlags::NoAutoMnemonics);
245  bool bUseImagesInMenus = Application::GetSettings().GetStyleSettings().GetUseImagesInMenus();
246 
248  if (m_xSpellAlt.is())
249  {
250  m_nCheckedLanguage = LanguageTag( m_xSpellAlt->getLocale() ).getLanguageType();
251  m_aSuggestions = m_xSpellAlt->getAlternatives();
252  }
253  sal_Int16 nStringCount = static_cast< sal_Int16 >( m_aSuggestions.getLength() );
254 
255  SvtLinguConfig aCfg;
256 
258  pMenu->SetMenuFlags(MenuFlags::NoAutoMnemonics);
259  bool bEnable = false;
260  if( nStringCount )
261  {
262  Image aImage;
263  OUString aSuggestionImageUrl;
264 
265  if (bUseImagesInMenus)
266  {
267  uno::Reference< container::XNamed > xNamed( m_xSpellAlt, uno::UNO_QUERY );
268  if (xNamed.is())
269  {
270  aSuggestionImageUrl = aCfg.GetSpellAndGrammarContextSuggestionImage( xNamed->getName() );
271  aImage = Image( aSuggestionImageUrl );
272  }
273  }
274 
275  m_xPopupMenu->InsertSeparator(OString(), 0);
276  bEnable = true;
277  sal_uInt16 nAutoCorrItemId = MN_AUTOCORR_START;
278  sal_uInt16 nItemId = MN_SUGGESTION_START;
279  for (sal_uInt16 i = 0; i < nStringCount; ++i)
280  {
281  const OUString aEntry = m_aSuggestions[ i ];
282  m_xPopupMenu->InsertItem(nItemId, aEntry, MenuItemBits::NONE, OString(), i);
284  if (!aSuggestionImageUrl.isEmpty())
285  m_xPopupMenu->SetItemImage(nItemId, aImage);
286 
287  pMenu->InsertItem( nAutoCorrItemId, aEntry );
288  pMenu->SetHelpId( nAutoCorrItemId, HID_LINGU_AUTOCORR);
289 
290  ++nAutoCorrItemId;
291  ++nItemId;
292  }
293  }
294 
295  uno::Reference< frame::XFrame > xFrame = pWrtSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface();
296  OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(xFrame));
297 
298  OUString aIgnoreSelection( SwResId( STR_IGNORE_SELECTION ) );
300  vcl::CommandInfoProvider::GetPopupLabelForCommand(".uno:SpellingAndGrammarDialog", aModuleName));
302  vcl::CommandInfoProvider::GetPopupLabelForCommand(".uno:AutoCorrectDlg", aModuleName));
303  sal_uInt16 nItemPos = m_xPopupMenu->GetItemPos(m_nIgnoreWordId);
304  m_xPopupMenu->InsertItem(MN_IGNORE_SELECTION, aIgnoreSelection, MenuItemBits::NONE, OString(), nItemPos);
306 
308 
309  uno::Reference< linguistic2::XLanguageGuessing > xLG = SW_MOD()->GetLanguageGuesser();
310  LanguageType nGuessLangWord = LANGUAGE_NONE;
311  LanguageType nGuessLangPara = LANGUAGE_NONE;
312  if (m_xSpellAlt.is() && xLG.is())
313  {
314  nGuessLangWord = EditView::CheckLanguage( m_xSpellAlt->getWord(), ::GetSpellChecker(), xLG, false );
315  nGuessLangPara = EditView::CheckLanguage( rParaText, ::GetSpellChecker(), xLG, true );
316  }
317  if (nGuessLangWord != LANGUAGE_NONE || nGuessLangPara != LANGUAGE_NONE)
318  {
319  // make sure LANGUAGE_NONE gets not used as menu entry
320  if (nGuessLangWord == LANGUAGE_NONE)
321  nGuessLangWord = nGuessLangPara;
322  if (nGuessLangPara == LANGUAGE_NONE)
323  nGuessLangPara = nGuessLangWord;
324  }
325 
327  pMenu->SetMenuFlags(MenuFlags::NoAutoMnemonics);
328  uno::Reference< linguistic2::XSearchableDictionaryList > xDicList( LinguMgr::GetDictionaryList() );
329  sal_uInt16 nItemId = MN_DICTIONARIES_START;
330  if (xDicList.is())
331  {
332  // add the default positive dictionary to dic-list (if not already done).
333  // This is to ensure that there is at least one dictionary to which
334  // words could be added.
335  uno::Reference< linguistic2::XDictionary > xDic( LinguMgr::GetStandardDic() );
336  if (xDic.is())
337  xDic->setActive( true );
338 
339  m_aDics = xDicList->getDictionaries();
340  const uno::Reference< linguistic2::XDictionary > *pDic = m_aDics.getConstArray();
341  sal_uInt16 nDicCount = static_cast< sal_uInt16 >(m_aDics.getLength());
342 
343  for( sal_uInt16 i = 0; i < nDicCount; i++ )
344  {
345  uno::Reference< linguistic2::XDictionary > xDicTmp( pDic[i], uno::UNO_QUERY );
346  if (!xDicTmp.is() || LinguMgr::GetIgnoreAllList() == xDicTmp)
347  continue;
348 
349  uno::Reference< frame::XStorable > xStor( xDicTmp, uno::UNO_QUERY );
350  LanguageType nActLanguage = LanguageTag( xDicTmp->getLocale() ).getLanguageType();
351  if( xDicTmp->isActive()
352  && xDicTmp->getDictionaryType() != linguistic2::DictionaryType_NEGATIVE
353  && (m_nCheckedLanguage == nActLanguage || LANGUAGE_NONE == nActLanguage )
354  && (!xStor.is() || !xStor->isReadonly()) )
355  {
356  // the extra 1 is because of the (possible) external
357  // linguistic entry above
358  pMenu->InsertItem( nItemId, xDicTmp->getName() );
359  m_aDicNameSingle = xDicTmp->getName();
360 
361  if (bUseImagesInMenus)
362  {
363  uno::Reference< lang::XServiceInfo > xSvcInfo( xDicTmp, uno::UNO_QUERY );
364  if (xSvcInfo.is())
365  {
366  OUString aDictionaryImageUrl( aCfg.GetSpellAndGrammarContextDictionaryImage(
367  xSvcInfo->getImplementationName() ) );
368  if (!aDictionaryImageUrl.isEmpty())
369  {
370  Image aImage( aDictionaryImageUrl );
371  pMenu->SetItemImage( nItemId, aImage );
372  }
373  }
374  }
375 
376  ++nItemId;
377  }
378  }
379  }
382 
383  //ADD NEW LANGUAGE MENU ITEM
384 
385  OUString aScriptTypesInUse( OUString::number( static_cast<int>(pWrtSh->GetScriptType()) ) );
386 
387  // get keyboard language
388  OUString aKeyboardLang;
389  SwEditWin& rEditWin = pWrtSh->GetView().GetEditWin();
390  LanguageType nLang = rEditWin.GetInputLanguage();
391  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
392  aKeyboardLang = SvtLanguageTable::GetLanguageString( nLang );
393 
394  // get the language that is in use
395  OUString aCurrentLang("*");
396  nLang = SwLangHelper::GetCurrentLanguage( *pWrtSh );
397  if (nLang != LANGUAGE_DONTKNOW)
398  aCurrentLang = SvtLanguageTable::GetLanguageString( nLang );
399 
400  // build sequence for status value
401  uno::Sequence< OUString > aSeq( 4 );
402  aSeq[0] = aCurrentLang;
403  aSeq[1] = aScriptTypesInUse;
404  aSeq[2] = aKeyboardLang;
405  aSeq[3] = SvtLanguageTable::GetLanguageString(nGuessLangWord);
406 
410 
414 
415  if (bUseImagesInMenus)
417  vcl::CommandInfoProvider::GetImageForCommand(".uno:SpellingAndGrammarDialog", xFrame));
418 
419  checkRedline();
420  m_xPopupMenu->RemoveDisabledEntries( true, true );
421 }
422 
424  SwWrtShell *pWrtSh,
425  const linguistic2::ProofreadingResult &rResult,
426  sal_Int32 nErrorInResult,
427  const uno::Sequence< OUString > &rSuggestions,
428  const OUString &rParaText )
429  : m_aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "modules/swriter/ui/spellmenu.ui", "")
430  , m_xPopupMenu(m_aBuilder.get_menu("menu"))
431  , m_nIgnoreWordId(m_xPopupMenu->GetItemId("ignoreall"))
432  , m_nAddMenuId(m_xPopupMenu->GetItemId("addmenu"))
433  , m_nAddId(m_xPopupMenu->GetItemId("add"))
434  , m_nSpellDialogId(m_xPopupMenu->GetItemId("spelldialog"))
435  , m_nCorrectMenuId(m_xPopupMenu->GetItemId("correctmenu"))
436  , m_nCorrectDialogId(m_xPopupMenu->GetItemId("correctdialog"))
437  , m_nLangSelectionMenuId(m_xPopupMenu->GetItemId("langselection"))
438  , m_nLangParaMenuId(m_xPopupMenu->GetItemId("langpara"))
439  , m_nRedlineAcceptId(m_xPopupMenu->GetItemId("accept"))
440  , m_nRedlineRejectId(m_xPopupMenu->GetItemId("reject"))
441  , m_nRedlineNextId(m_xPopupMenu->GetItemId("next"))
442  , m_nRedlinePrevId(m_xPopupMenu->GetItemId("prev"))
443  , m_pSh(pWrtSh)
444  , m_xGrammarResult(rResult)
445  , m_aSuggestions(rSuggestions)
446  , m_sExplanationLink()
447  , m_bGrammarResults(true)
448 {
449  m_nCheckedLanguage = LanguageTag::convertToLanguageType( rResult.aLocale );
450  m_nGrammarError = nErrorInResult;
451  bool bUseImagesInMenus = Application::GetSettings().GetStyleSettings().GetUseImagesInMenus();
452 
453  sal_uInt16 nPos = 0;
454  OUString aMessageText( rResult.aErrors[ nErrorInResult ].aShortComment );
455  m_xPopupMenu->InsertSeparator(OString(), nPos++);
456  m_xPopupMenu->InsertItem(MN_SHORT_COMMENT, aMessageText, MenuItemBits::NOSELECT, OString(), nPos++);
457  if (bUseImagesInMenus)
458  m_xPopupMenu->SetItemImage(MN_SHORT_COMMENT, Image(StockImage::Yes, BMP_INFO_16));
459 
460  // Add an item to show detailed infos if the FullCommentURL property is defined
461  beans::PropertyValues aProperties = rResult.aErrors[ nErrorInResult ].aProperties;
462  {
463  sal_Int32 i = 0;
464  while ( m_sExplanationLink.isEmpty() && i < aProperties.getLength() )
465  {
466  if ( aProperties[i].Name == "FullCommentURL" )
467  {
468  uno::Any aValue = aProperties[i].Value;
469  aValue >>= m_sExplanationLink;
470  }
471  ++i;
472  }
473  }
474 
475  if ( !m_sExplanationLink.isEmpty( ) )
476  {
477  m_xPopupMenu->InsertItem(MN_EXPLANATION_LINK, SwResId(STR_EXPLANATION_LINK), MenuItemBits::TEXT | MenuItemBits::HELP, OString(), nPos++);
478  }
479 
480  m_xPopupMenu->SetMenuFlags(MenuFlags::NoAutoMnemonics);
481 
482  m_xPopupMenu->InsertSeparator(OString(), nPos++);
483  sal_Int32 nStringCount = m_aSuggestions.getLength();
484  if ( nStringCount ) // suggestions available...
485  {
486  Image aImage;
487  OUString aSuggestionImageUrl;
488 
489  if (bUseImagesInMenus)
490  {
491  uno::Reference< lang::XServiceInfo > xInfo( rResult.xProofreader, uno::UNO_QUERY );
492  if (xInfo.is())
493  {
494  aSuggestionImageUrl = SvtLinguConfig().GetSpellAndGrammarContextSuggestionImage( xInfo->getImplementationName() );
495  aImage = Image( aSuggestionImageUrl );
496  }
497  }
498 
499  sal_uInt16 nItemId = MN_SUGGESTION_START;
500  for (sal_Int32 i = 0; i < nStringCount; ++i)
501  {
502  const OUString aEntry = m_aSuggestions[ i ];
503  m_xPopupMenu->InsertItem(nItemId, aEntry, MenuItemBits::NONE, OString(), nPos++);
505  if (!aSuggestionImageUrl.isEmpty())
506  m_xPopupMenu->SetItemImage(nItemId, aImage);
507 
508  ++nItemId;
509  }
510  m_xPopupMenu->InsertSeparator(OString(), nPos++);
511  }
512 
513  uno::Reference< frame::XFrame > xFrame = pWrtSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface();
514  OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(xFrame));
515 
516  OUString aIgnoreSelection( SwResId( STR_IGNORE_SELECTION ) );
518  vcl::CommandInfoProvider::GetPopupLabelForCommand(".uno:SpellingAndGrammarDialog", aModuleName));
519  sal_uInt16 nItemPos = m_xPopupMenu->GetItemPos(m_nIgnoreWordId);
520  m_xPopupMenu->InsertItem(MN_IGNORE_SELECTION, aIgnoreSelection, MenuItemBits::NONE, OString(), nItemPos);
522 
525 
526  uno::Reference< linguistic2::XLanguageGuessing > xLG = SW_MOD()->GetLanguageGuesser();
527  LanguageType nGuessLangWord = LANGUAGE_NONE;
528  LanguageType nGuessLangPara = LANGUAGE_NONE;
529  if (xLG.is())
530  {
531  nGuessLangPara = EditView::CheckLanguage( rParaText, ::GetSpellChecker(), xLG, true );
532  }
533  if (nGuessLangWord != LANGUAGE_NONE || nGuessLangPara != LANGUAGE_NONE)
534  {
535  // make sure LANGUAGE_NONE gets not used as menu entry
536  if (nGuessLangWord == LANGUAGE_NONE)
537  nGuessLangWord = nGuessLangPara;
538  if (nGuessLangPara == LANGUAGE_NONE)
539  nGuessLangPara = nGuessLangWord;
540  }
541 
544 
545  //ADD NEW LANGUAGE MENU ITEM
546 
547  OUString aScriptTypesInUse( OUString::number( static_cast<int>(pWrtSh->GetScriptType()) ) );
548 
549  // get keyboard language
550  OUString aKeyboardLang;
551  SwEditWin& rEditWin = pWrtSh->GetView().GetEditWin();
552  LanguageType nLang = rEditWin.GetInputLanguage();
553  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
554  aKeyboardLang = SvtLanguageTable::GetLanguageString( nLang );
555 
556  // get the language that is in use
557  OUString aCurrentLang("*");
558  nLang = SwLangHelper::GetCurrentLanguage( *pWrtSh );
559  if (nLang != LANGUAGE_DONTKNOW)
560  aCurrentLang = SvtLanguageTable::GetLanguageString( nLang );
561 
562  // build sequence for status value
563  uno::Sequence< OUString > aSeq( 4 );
564  aSeq[0] = aCurrentLang;
565  aSeq[1] = aScriptTypesInUse;
566  aSeq[2] = aKeyboardLang;
567  aSeq[3] = SvtLanguageTable::GetLanguageString(nGuessLangWord);
568 
572 
576 
577  if (bUseImagesInMenus)
579  vcl::CommandInfoProvider::GetImageForCommand(".uno:SpellingAndGrammarDialog", xFrame));
580 
581  checkRedline();
582  m_xPopupMenu->RemoveDisabledEntries(true, true);
583 }
584 
586 
588 {
589  // Let SwView::GetState() already has the logic on when to disable the
590  // accept/reject and the next/prev change items, let it do the decision.
591 
592  // Build an item set that contains a void item for each menu entry. The
593  // WhichId of each item is set, so SwView may clear it.
594  static const sal_uInt16 pRedlineIds[] = {
599  };
600  SwDoc *pDoc = m_pSh->GetDoc();
602  for (sal_uInt16 nWhich : pRedlineIds)
603  {
604  aSet.Put(SfxVoidItem(nWhich));
605  }
606  m_pSh->GetView().GetState(aSet);
607 
608  // Enable/disable items based on if the which id of the void items are
609  // cleared or not.
610  for (sal_uInt16 nWhich : pRedlineIds)
611  {
612  sal_uInt16 nId(0);
613  if (nWhich == FN_REDLINE_ACCEPT_DIRECT)
614  nId = m_nRedlineAcceptId;
615  else if (nWhich == FN_REDLINE_REJECT_DIRECT)
616  nId = m_nRedlineRejectId;
617  else if (nWhich == FN_REDLINE_NEXT_CHANGE)
618  nId = m_nRedlineNextId;
619  else if (nWhich == FN_REDLINE_PREV_CHANGE)
620  nId = m_nRedlinePrevId;
621  m_xPopupMenu->EnableItem(nId, aSet.Get(nWhich).Which() != 0);
622  }
623 }
624 
625 void SwSpellPopup::Execute( const tools::Rectangle& rWordPos, vcl::Window* pWin )
626 {
627  sal_uInt16 nRet = m_xPopupMenu->Execute(pWin, pWin->LogicToPixel(rWordPos));
628  Execute( nRet );
629 }
630 
631 void SwSpellPopup::Execute( sal_uInt16 nId )
632 {
633  if (nId == USHRT_MAX)
634  return;
635 
636  if (/*m_bGrammarResults && */nId == MN_SHORT_COMMENT)
637  return; // nothing to do since it is the error message (short comment)
638 
639  if ((MN_SUGGESTION_START <= nId && nId <= MN_SUGGESTION_END) ||
640  (MN_AUTOCORR_START <= nId && nId <= MN_AUTOCORR_END))
641  {
642  sal_Int32 nAltIdx = (MN_SUGGESTION_START <= nId && nId <= MN_SUGGESTION_END) ?
644  OSL_ENSURE(nAltIdx < m_aSuggestions.getLength(), "index out of range");
645  if (nAltIdx < m_aSuggestions.getLength() && (m_bGrammarResults || m_xSpellAlt.is()))
646  {
647  bool bOldIns = m_pSh->IsInsMode();
648  m_pSh->SetInsMode();
649 
650  OUString aTmp( m_aSuggestions[ nAltIdx ] );
651  OUString aOrig( m_bGrammarResults ? OUString() : m_xSpellAlt->getWord() );
652 
653  // if original word has a trailing . (likely the end of a sentence)
654  // and the replacement text hasn't, then add it to the replacement
655  if (!aTmp.isEmpty() && !aOrig.isEmpty() &&
656  aOrig.endsWith(".") && /* !IsAlphaNumeric ??*/
657  !aTmp.endsWith("."))
658  {
659  aTmp += ".";
660  }
661 
662  SwRewriter aRewriter;
663 
664  aRewriter.AddRule(UndoArg1, m_pSh->GetCursorDescr());
665  aRewriter.AddRule(UndoArg2, SwResId(STR_YIELDS));
666 
667  OUString aTmpStr( SwResId(STR_START_QUOTE) );
668  aTmpStr += aTmp;
669  aTmpStr += SwResId(STR_END_QUOTE);
670  aRewriter.AddRule(UndoArg3, aTmpStr);
671 
672  m_pSh->StartUndo(SwUndoId::UI_REPLACE, &aRewriter);
673  m_pSh->StartAction();
674  m_pSh->DelLeft();
675 
676  m_pSh->Insert( aTmp );
677 
678  /* #102505# EndAction/EndUndo moved down since insertion
679  of temporary auto correction is now undoable two and
680  must reside in the same undo group.*/
681 
682  // record only if it's NOT already present in autocorrection
684 
685  OUString aOrigWord( m_bGrammarResults ? OUString() : m_xSpellAlt->getWord() ) ;
686  OUString aNewWord( m_aSuggestions[ nAltIdx ] );
687  SvxPrepareAutoCorrect( aOrigWord, aNewWord );
688 
689  if (MN_AUTOCORR_START <= nId && nId <= MN_AUTOCORR_END)
690  pACorr->PutText( aOrigWord, aNewWord, m_nCheckedLanguage );
691 
692  /* #102505# EndAction/EndUndo moved down since insertion
693  of temporary auto correction is now undoable two and
694  must reside in the same undo group.*/
695  m_pSh->EndAction();
696  m_pSh->EndUndo();
697 
698  m_pSh->SetInsMode( bOldIns );
699  }
700  }
701  else if (nId == m_nSpellDialogId)
702  {
703  if (m_bGrammarResults)
704  {
705  SvtLinguConfig().SetProperty( UPN_IS_GRAMMAR_INTERACTIVE, uno::makeAny( true ));
706  }
707  m_pSh->Left(CRSR_SKIP_CHARS, false, 1, false );
708  {
709  uno::Reference<linguistic2::XSearchableDictionaryList> xDictionaryList( LinguMgr::GetDictionaryList() );
710  SvxDicListChgClamp aClamp( xDictionaryList );
712  Execute( FN_SPELL_GRAMMAR_DIALOG, SfxCallMode::ASYNCHRON );
713  }
714  }
715  else if (nId == m_nCorrectDialogId)
716  {
717  m_pSh->GetView().GetViewFrame()->GetDispatcher()->Execute( SID_AUTO_CORRECT_DLG, SfxCallMode::ASYNCHRON );
718  }
719  else if (nId == MN_IGNORE_SELECTION)
720  {
721  SwPaM *pPaM = m_pSh->GetCursor();
722  if (pPaM)
724  }
725  else if (nId == m_nIgnoreWordId)
726  {
727  uno::Reference< linguistic2::XDictionary > xDictionary( LinguMgr::GetIgnoreAllList(), uno::UNO_QUERY );
728  if (m_bGrammarResults) {
729  try
730  {
731  m_xGrammarResult.xProofreader->ignoreRule(
732  m_xGrammarResult.aErrors[ m_nGrammarError ].aRuleIdentifier,
733  m_xGrammarResult.aLocale );
734  // refresh the layout of the actual paragraph (faster)
735  SwPaM *pPaM = m_pSh->GetCursor();
736  if (pPaM)
738  // refresh the layout of all paragraphs (workaround to launch a dictionary event)
739  xDictionary->setActive(false);
740  xDictionary->setActive(true);
741  }
742  catch( const uno::Exception& )
743  {
744  }
745  } else {
746  OUString sWord(m_xSpellAlt->getWord());
748  sWord, false, OUString() );
749  if (linguistic::DictionaryError::NONE != nAddRes && !xDictionary->getEntry(sWord).is())
750  {
752  }
753  }
754  }
755  else if ((MN_DICTIONARIES_START <= nId && nId <= MN_DICTIONARIES_END) || nId == m_nAddId)
756  {
757  OUString sWord( m_xSpellAlt->getWord() );
758  OUString aDicName;
759 
760  if (MN_DICTIONARIES_START <= nId && nId <= MN_DICTIONARIES_END)
761  {
763  aDicName = pMenu->GetItemText(nId);
764  }
765  else
766  aDicName = m_aDicNameSingle;
767 
768  uno::Reference< linguistic2::XDictionary > xDic;
769  uno::Reference< linguistic2::XSearchableDictionaryList > xDicList( LinguMgr::GetDictionaryList() );
770  if (xDicList.is())
771  xDic = xDicList->getDictionaryByName( aDicName );
772 
773  if (xDic.is())
774  {
775  linguistic::DictionaryError nAddRes = linguistic::AddEntryToDic(xDic, sWord, false, OUString());
776  // save modified user-dictionary if it is persistent
777  uno::Reference< frame::XStorable > xSavDic( xDic, uno::UNO_QUERY );
778  if (xSavDic.is())
779  xSavDic->store();
780 
781  if (linguistic::DictionaryError::NONE != nAddRes && !xDic->getEntry(sWord).is())
782  {
784  }
785  }
786  }
787  else if ( nId == MN_EXPLANATION_LINK && !m_sExplanationLink.isEmpty() )
788  {
789  try
790  {
791  uno::Reference< css::system::XSystemShellExecute > xSystemShellExecute(
792  css::system::SystemShellExecute::create( ::comphelper::getProcessComponentContext() ) );
793  xSystemShellExecute->execute( m_sExplanationLink, OUString(),
794  css::system::SystemShellExecuteFlags::URIS_ONLY );
795  }
796  catch (const uno::Exception&)
797  {
799  OUString msg( ::comphelper::anyToString( exc ) );
800  const SolarMutexGuard guard;
801  std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_pSh->GetView().GetViewFrame()->GetWindow().GetFrameWeld(),
802  VclMessageType::Warning, VclButtonsType::Ok, msg));
803  xBox->set_title("Explanations");
804  xBox->run();
805  }
806  }
807  else if (nId == m_nRedlineAcceptId || nId == m_nRedlineRejectId
808  || nId == m_nRedlineNextId || nId == m_nRedlinePrevId)
809  {
810  if (nId == m_nRedlineAcceptId)
812  else if (nId == m_nRedlineRejectId)
814  else if (nId == m_nRedlineNextId)
816  else if (nId == m_nRedlinePrevId)
818  // Let SwView::Execute() handle the redline actions.
819  SfxRequest aReq(m_pSh->GetView().GetViewFrame(), nId);
820  m_pSh->GetView().Execute(aReq);
821  }
822  else
823  {
824  // Set language for selection or for paragraph...
825 
826  SfxItemSet aCoreSet( m_pSh->GetView().GetPool(),
829  RES_CHRATR_CTL_LANGUAGE, RES_CHRATR_CTL_LANGUAGE>{} );
830  OUString aNewLangText;
831 
833  {
834  //Set language for current selection
835  aNewLangText = m_aLangTable_Text[nId];
836  SwLangHelper::SetLanguage( *m_pSh, aNewLangText, true, aCoreSet );
837  }
838  else if (nId == MN_SET_SELECTION_NONE)
839  {
840  //Set Language_None for current selection
841  SwLangHelper::SetLanguage_None( *m_pSh, true, aCoreSet );
842  }
843  else if (nId == MN_SET_SELECTION_RESET)
844  {
845  //reset languages for current selection
847  }
848  else if (nId == MN_SET_SELECTION_MORE)
849  {
850  //Open Format/Character Dialog
851  sw_CharDialog( *m_pSh, true, SID_ATTR_CHAR_FONT, nullptr, nullptr );
852  }
854  {
855  //Set language for current paragraph
856  aNewLangText = m_aLangTable_Paragraph[nId];
857  m_pSh->Push(); // save cursor
859  SwLangHelper::SetLanguage( *m_pSh, aNewLangText, true, aCoreSet );
860  m_pSh->Pop(SwCursorShell::PopMode::DeleteCurrent); // restore cursor
861  }
862  else if (nId == MN_SET_PARA_NONE)
863  {
864  //Set Language_None for current paragraph
865  m_pSh->Push(); // save cursor
867  SwLangHelper::SetLanguage_None( *m_pSh, true, aCoreSet );
868  m_pSh->Pop(SwCursorShell::PopMode::DeleteCurrent); // restore cursor
869  }
870  else if (nId == MN_SET_PARA_RESET)
871  {
872  //reset languages for current paragraph
873  m_pSh->Push(); // save cursor
876  m_pSh->Pop(SwCursorShell::PopMode::DeleteCurrent); // restore cursor
877  }
878  else if (nId == MN_SET_PARA_MORE)
879  {
880  m_pSh->Push(); // save cursor
882  //Open Format/Character Dialog
883  sw_CharDialog( *m_pSh, true, SID_ATTR_CHAR_FONT, nullptr, nullptr );
884  m_pSh->Pop(SwCursorShell::PopMode::DeleteCurrent); // restore cursor
885  }
886  }
887 
888  m_pSh->EnterStdMode();
889 }
890 
891 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxViewFrame * GetViewFrame() const
#define MN_SUGGESTION_START
Definition: olmenu.hxx:45
#define LANGUAGE_NONE
PopupMenu * GetPopupMenu(sal_uInt16 nItemId) const
void SetItemImage(sal_uInt16 nItemId, const Image &rImage)
static SvxAutoCorrCfg & Get()
#define MN_SET_PARA_MORE
Definition: olmenu.hxx:71
#define RES_CHRATR_CJK_LANGUAGE
Definition: hintids.hxx:92
bool IsInsMode() const
Definition: wrtsh.hxx:161
SwPaM * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:185
sal_uInt16 const m_nLangParaMenuId
Definition: olmenu.hxx:86
#define RES_CHRATR_LANGUAGE
Definition: hintids.hxx:78
const LanguageTag & GetUILanguageTag() const
#define HID_LINGU_AUTOCORR
Definition: helpids.h:62
OUString GetPopupLabelForCommand(const OUString &rsCommandName, const OUString &rsModuleName)
void SetHelpId(sal_uInt16 nItemId, const OString &rHelpId)
void Insert(SwField const &)
Definition: wrtsh2.cxx:71
LanguageType getLanguageType(bool bResolveSystem=true) const
SfxDispatcher * GetDispatcher()
static LanguageType convertToLanguageType(const css::lang::Locale &rLocale, bool bResolveSystem=true)
sal_uInt16 const m_nIgnoreWordId
Definition: olmenu.hxx:79
LanguageType m_nCheckedLanguage
Definition: olmenu.hxx:101
Reference< XFrame > xFrame
#define MN_DICTIONARIES_END
Definition: olmenu.hxx:42
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
bool Pop(SwCursorShell::PopMode=SwCursorShell::PopMode::DeleteStack)
Definition: wrtsh1.cxx:1690
Definition: doc.hxx:185
sal_Int16 nId
static css::uno::Reference< css::linguistic2::XDictionary > GetStandardDic()
sal_uInt16 const m_nRedlineNextId
Definition: olmenu.hxx:89
#define MN_DICTIONARIES_START
Definition: olmenu.hxx:41
SwUndoId EndUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Closes parenthesis of nUndoId, not used by UI.
Definition: edws.cxx:233
OUString const GetModuleIdentifier(const Reference< frame::XFrame > &rxFrame)
#define HID_LINGU_IGNORE_SELECTION
Definition: helpids.h:64
sal_uInt16 const m_nCorrectMenuId
Definition: olmenu.hxx:83
void EnterStdMode()
Definition: select.cxx:552
sal_uInt16 GetItemPos(sal_uInt16 nItemId) const
SwEditWin & GetEditWin()
Definition: view.hxx:403
sal_uInt16 Execute(vcl::Window *pWindow, const Point &rPopupPos)
sal_uInt16 const m_nAddId
Definition: olmenu.hxx:81
#define MN_SHORT_COMMENT
Definition: olmenu.hxx:37
OUString GetCursorDescr() const
Returns textual description of the current selection.
Definition: crsrsh.cxx:3517
sal_uInt16 const m_nRedlineRejectId
Definition: olmenu.hxx:88
#define MN_MAX_NUM_LANG
Definition: olmenu.hxx:53
static LanguageType nLang
Definition: srtdlg.cxx:58
Used by the UI to modify the document model.
Definition: wrtsh.hxx:86
weld::Window * GetFrameWeld() const
OUString m_sExplanationLink
Definition: olmenu.hxx:99
vcl::Window & GetWindow() const
const SwView & GetView() const
Definition: wrtsh.hxx:424
Reference< XController > xController
Any SAL_CALL getCaughtException()
#define MN_EXPLANATION_LINK
Definition: olmenu.hxx:38
SfxFrame & GetFrame() const
static css::uno::Reference< css::linguistic2::XSearchableDictionaryList > GetDictionaryList()
void SetMenuFlags(MenuFlags nFlags)
#define MN_IGNORE_SELECTION
Don't change these values. You may break context menu modifying extensions!
Definition: olmenu.hxx:36
css::uno::Reference< css::linguistic2::XSpellAlternatives > m_xSpellAlt
Definition: olmenu.hxx:93
OUString GetSpellAndGrammarContextDictionaryImage(const OUString &rServiceImplName) const
SwDoc * GetDoc() const
Definition: viewsh.hxx:284
void InsertSeparator(const OString &rIdent=OString(), sal_uInt16 nPos=MENU_APPEND)
static SvtScriptType GetScriptTypeOfLanguage(LanguageType nLang)
static css::uno::Reference< css::linguistic2::XDictionary > GetIgnoreAllList()
#define MN_SET_SELECTION_MORE
Definition: olmenu.hxx:64
SwWrtShell * m_pSh
Definition: olmenu.hxx:91
std::map< sal_Int16, OUString > m_aLangTable_Text
Definition: olmenu.hxx:103
SfxItemPool & GetPool() const
const LanguageTag & GetLanguageTag() const
#define UPN_IS_GRAMMAR_INTERACTIVE
short SvxDicError(weld::Window *pParent, linguistic::DictionaryError nError)
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
Image GetImageForCommand(const OUString &rsCommandName, const Reference< frame::XFrame > &rxFrame, vcl::ImageType eImageType)
#define FN_REDLINE_ACCEPT_DIRECT
Definition: cmdid.h:137
SvtScriptType
void sw_CharDialog(SwWrtShell &rWrtSh, bool bUseDialog, sal_uInt16 nSlot, const SfxItemSet *pArgs, SfxRequest *pReq)
Definition: textsh1.cxx:135
SvtScriptType GetScriptType() const
returns the script type of the selection
Definition: edattr.cxx:671
#define SW_MOD()
Definition: swmodule.hxx:255
#define MN_MORE_OFFSET
Definition: olmenu.hxx:57
#define MN_SET_LANGUAGE_SELECTION_START
Definition: olmenu.hxx:60
void EndAction(const bool bIdleEnd=false, const bool DoSetPosX=false)
Definition: crsrsh.cxx:229
Window class for the Writer edit area, this is the one handling mouse and keyboard events and doing t...
Definition: edtwin.hxx:59
#define MN_SET_SELECTION_NONE
Definition: olmenu.hxx:62
css::linguistic2::ProofreadingResult m_xGrammarResult
Definition: olmenu.hxx:95
void Push()
store a copy of the current cursor on the cursor stack
Definition: crsrsh.cxx:2143
SvxAutoCorrect * GetAutoCorrect()
int i
void ResetLanguages(SwWrtShell &rWrtSh, OutlinerView const *pOLV=nullptr)
Definition: langhelper.cxx:365
sal_uInt16 const m_nLangSelectionMenuId
Definition: olmenu.hxx:85
#define FN_REDLINE_PREV_CHANGE
Definition: cmdid.h:142
SwUndoId StartUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Undo: set up Undo parenthesis, return nUndoId of this parenthesis.
Definition: edws.cxx:222
bool const m_bGrammarResults
Definition: olmenu.hxx:107
void AddRule(SwUndoArg eWhat, const OUString &rWith)
Definition: SwRewriter.cxx:29
Object Value
std::map< sal_Int16, OUString > m_aLangTable_Paragraph
Definition: olmenu.hxx:104
static bool lcl_checkScriptType(SvtScriptType nScriptType, LanguageType nLang)
Definition: olmenu.cxx:105
OUString m_aDicNameSingle
Definition: olmenu.hxx:106
#define LANGUAGE_DONTKNOW
void SetLanguage_None(SwWrtShell &rWrtSh, bool bIsForSelection, SfxItemSet &rCoreSet)
Definition: langhelper.cxx:305
void SelectCurrentPara(SwWrtShell &rWrtSh)
Definition: langhelper.cxx:573
#define MN_SET_PARA_RESET
Definition: olmenu.hxx:70
void SvxPrepareAutoCorrect(OUString &rOldText, const OUString &rNewText)
VclPtr< PopupMenu > m_xPopupMenu
Definition: olmenu.hxx:78
OUString SwResId(const char *pId)
Definition: swmodule.cxx:191
sal_uInt16 const m_nRedlineAcceptId
Definition: olmenu.hxx:87
bool DelLeft()
Definition: delete.cxx:139
css::uno::Sequence< css::uno::Reference< css::linguistic2::XDictionary > > m_aDics
Definition: olmenu.hxx:92
OUString GetItemText(sal_uInt16 nItemId) const
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
void EnableItem(sal_uInt16 nItemId, bool bEnable=true)
void CheckItem(sal_uInt16 nItemId, bool bCheck=true)
Point LogicToPixel(const Point &rLogicPt) const
void StartAction()
Definition: crsrsh.cxx:212
OUString GetSpellAndGrammarContextSuggestionImage(const OUString &rServiceImplName) const
#define MN_SET_SELECTION_RESET
Definition: olmenu.hxx:63
#define MN_AUTOCORR_START
Definition: olmenu.hxx:49
void InsertItem(sal_uInt16 nItemId, const OUString &rStr, MenuItemBits nItemBits=MenuItemBits::NONE, const OString &rIdent=OString(), sal_uInt16 nPos=MENU_APPEND)
void SetInsMode(bool bOn=true)
Definition: select.cxx:671
bool PutText(const OUString &rShort, const OUString &rLong, LanguageType eLang)
#define MN_SUGGESTION_END
Definition: olmenu.hxx:46
sal_Int32 m_nGrammarError
Definition: olmenu.hxx:96
#define FN_SPELL_GRAMMAR_DIALOG
Definition: cmdid.h:579
bool Left(sal_uInt16 nMode, bool bSelect, sal_uInt16 nCount, bool bBasicCall, bool bVisual=false)
Definition: move.cxx:102
SwSpellPopup(SwWrtShell *pWrtSh, const css::uno::Reference< css::linguistic2::XSpellAlternatives > &xAlt, const OUString &rParaText)
#define MN_AUTOCORR_END
Definition: olmenu.hxx:50
bool GetUseImagesInMenus() const
DictionaryError AddEntryToDic(uno::Reference< XDictionary > const &rxDic, const OUString &rWord, bool bIsNeg, const OUString &rRplcTxt, bool bStripDot)
#define MN_SET_LANGUAGE_SELECTION_END
Definition: olmenu.hxx:61
#define RES_CHRATR_CTL_LANGUAGE
Definition: hintids.hxx:97
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:259
#define FN_REDLINE_NEXT_CHANGE
Definition: cmdid.h:141
#define MN_SET_LANGUAGE_PARAGRAPH_END
Definition: olmenu.hxx:68
static void fillLangPopupMenu(PopupMenu *pPopupMenu, sal_uInt16 nLangStart, const css::uno::Sequence< OUString > &aSeq, SwWrtShell *pWrtSh, std::map< sal_Int16, OUString > &rLangTable)
Definition: olmenu.cxx:110
css::uno::Sequence< OUString > m_aSuggestions
Definition: olmenu.hxx:98
#define HID_LINGU_REPLACE
Definition: helpids.h:63
#define MN_SET_LANGUAGE_PARAGRAPH_START
Definition: olmenu.hxx:67
uno::Reference< linguistic2::XSpellChecker1 > GetSpellChecker()
Definition: swtypes.cxx:66
static void IgnoreGrammarErrorAt(SwPaM &rErrorPosition)
Definition: edlingu.cxx:1688
sal_uInt16 const m_nAddMenuId
Definition: olmenu.hxx:80
bool SetProperty(const OUString &rPropertyName, const css::uno::Any &rValue)
void Execute(SfxRequest &)
Definition: view2.cxx:526
Reference< XComponentContext > getProcessComponentContext()
LanguageType GetCurrentLanguage(SfxItemSet const &aSet, SvtScriptType nScriptType)
Definition: langhelper.cxx:481
static LanguageType CheckLanguage(const OUString &rText, const css::uno::Reference< css::linguistic2::XSpellChecker1 > &xSpell, const css::uno::Reference< css::linguistic2::XLanguageGuessing > &xLangGuess, bool bIsParaText)
void SetLanguage(SwWrtShell &rWrtSh, const OUString &rLangText, bool bIsForSelection, SfxItemSet &rCoreSet)
Definition: langhelper.cxx:223
sal_uInt16 const m_nCorrectDialogId
Definition: olmenu.hxx:84
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage)
static OUString GetLanguageString(const LanguageType eType)
#define MN_SET_PARA_NONE
Definition: olmenu.hxx:69
const sal_uInt16 CRSR_SKIP_CHARS
Definition: swcrsr.hxx:63
sal_uInt16 const m_nSpellDialogId
Definition: olmenu.hxx:82
Reference< XModel > xModel
#define MN_NONE_OFFSET
Definition: olmenu.hxx:55
void checkRedline()
Checks if any of the redline menu items should be hidden.
Definition: olmenu.cxx:587
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
void RemoveDisabledEntries(bool bCheckPopups=true, bool bRemoveEmptyPopups=false)
sal_uInt16 const m_nRedlinePrevId
Definition: olmenu.hxx:90
LanguageType GetInputLanguage() const
void Execute(const tools::Rectangle &rPopupPos, vcl::Window *pWin)
Definition: olmenu.cxx:625
sal_Int32 nPos
#define FN_REDLINE_REJECT_DIRECT
Definition: cmdid.h:138
#define MN_RESET_OFFSET
Definition: olmenu.hxx:56
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1307
static LanguageType GetLanguageType(const OUString &rStr)
OUString anyToString(uno::Any const &value)
void GetState(SfxItemSet &)
Definition: viewstat.cxx:71
void SetItemText(sal_uInt16 nItemId, const OUString &rStr)