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 <edtwin.hxx>
25 #include <helpids.h>
26 #include <langhelper.hxx>
27 #include <bitmaps.hlst>
28 #include <olmenu.hxx>
29 #include <swmodule.hxx>
30 #include <swtypes.hxx>
31 #include <swundo.hxx>
32 #include <view.hxx>
33 #include <wrtsh.hxx>
34 
35 #include <comphelper/lok.hxx>
38 #include <cppuhelper/exc_hlp.hxx>
39 #include <editeng/acorrcfg.hxx>
40 #include <editeng/svxacorr.hxx>
41 #include <editeng/splwrap.hxx>
42 #include <editeng/unolingu.hxx>
43 #include <editeng/editview.hxx>
45 #include <linguistic/misc.hxx>
46 #include <rtl/string.hxx>
48 #include <vcl/svapp.hxx>
49 #include <vcl/weld.hxx>
50 #include <sfx2/dispatch.hxx>
51 #include <sfx2/request.hxx>
52 #include <sfx2/viewfrm.hxx>
53 #include <svl/itemset.hxx>
54 #include <svl/languageoptions.hxx>
55 #include <svl/stritem.hxx>
56 #include <svtools/langtab.hxx>
57 #include <unotools/lingucfg.hxx>
58 #include <unotools/linguprops.hxx>
59 #include <vcl/settings.hxx>
60 #include <osl/diagnose.h>
61 
62 #include <map>
63 
64 #include <com/sun/star/document/XDocumentLanguages.hpp>
65 #include <com/sun/star/frame/XFrame.hpp>
66 #include <com/sun/star/frame/XStorable.hpp>
67 #include <com/sun/star/lang/XServiceInfo.hpp>
68 #include <com/sun/star/linguistic2/XLanguageGuessing.hpp>
69 #include <com/sun/star/uno/Any.hxx>
70 #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
71 #include <com/sun/star/system/SystemShellExecute.hpp>
72 #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
73 
74 using namespace ::com::sun::star;
75 
85 // check if nScriptType includes the script type associated to nLang
87 {
88  return bool(nScriptType & SvtLanguageOptions::GetScriptTypeOfLanguage( nLang ));
89 }
90 
92  PopupMenu *pPopupMenu,
93  sal_uInt16 nLangItemIdStart,
94  const uno::Sequence< OUString >& aSeq,
95  SwWrtShell* pWrtSh,
96  std::map< sal_Int16, OUString > &rLangTable )
97 {
98  if (!pPopupMenu)
99  return;
100 
101  // set of languages to be displayed in the sub menus
102  std::set< OUString > aLangItems;
103 
104  OUString aCurLang( aSeq[0] );
105  SvtScriptType nScriptType = static_cast<SvtScriptType>(aSeq[1].toInt32());
106  OUString aKeyboardLang( aSeq[2] );
107  OUString aGuessedTextLang( aSeq[3] );
108 
109  if (!aCurLang.isEmpty() &&
111  aLangItems.insert( aCurLang );
112 
113  //2--System
114  const AllSettings& rAllSettings = Application::GetSettings();
115  LanguageType rSystemLanguage = rAllSettings.GetLanguageTag().getLanguageType();
116  if (rSystemLanguage != LANGUAGE_DONTKNOW)
117  {
118  if (lcl_checkScriptType( nScriptType, rSystemLanguage ))
119  aLangItems.insert( SvtLanguageTable::GetLanguageString(rSystemLanguage) );
120  }
121 
122  //3--UI
123  LanguageType rUILanguage = rAllSettings.GetUILanguageTag().getLanguageType();
124  if (rUILanguage != LANGUAGE_DONTKNOW)
125  {
126  if (lcl_checkScriptType(nScriptType, rUILanguage ))
127  aLangItems.insert( SvtLanguageTable::GetLanguageString(rUILanguage) );
128  }
129 
130  //4--guessed language
131  if (!aGuessedTextLang.isEmpty())
132  {
133  if (lcl_checkScriptType(nScriptType, SvtLanguageTable::GetLanguageType(aGuessedTextLang)))
134  aLangItems.insert( aGuessedTextLang );
135  }
136 
137  //5--keyboard language
138  if (!aKeyboardLang.isEmpty())
139  {
140  if (lcl_checkScriptType(nScriptType, SvtLanguageTable::GetLanguageType(aKeyboardLang)))
141  aLangItems.insert( aKeyboardLang );
142  }
143 
144  //6--all languages used in current document
145  uno::Reference< css::frame::XModel > xModel;
146  uno::Reference< css::frame::XController > xController = pWrtSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface()->getController();
147  if ( xController.is() )
148  xModel = xController->getModel();
149  uno::Reference< document::XDocumentLanguages > xDocumentLanguages( xModel, uno::UNO_QUERY );
150  /*the description of nScriptType flags
151  LATIN : 0x0001
152  ASIAN : 0x0002
153  COMPLEX: 0x0004
154  */
155  const sal_Int16 nMaxCount = 7;
156  if (xDocumentLanguages.is())
157  {
158  const uno::Sequence< lang::Locale > rLocales( xDocumentLanguages->getDocumentLanguages( static_cast<sal_Int16>(nScriptType), nMaxCount ) );
159  for (const lang::Locale& rLocale : rLocales)
160  {
161  if (aLangItems.size() == size_t(nMaxCount))
162  break;
163  if (lcl_checkScriptType( nScriptType, SvtLanguageTable::GetLanguageType( rLocale.Language )))
164  aLangItems.insert( rLocale.Language );
165  }
166  }
167 
168  sal_uInt16 nItemId = nLangItemIdStart;
169  for (const OUString& aEntryText : aLangItems)
170  {
171  if (aEntryText != SvtLanguageTable::GetLanguageString( LANGUAGE_NONE ) &&
172  aEntryText != "*" && // multiple languages in current selection
173  !aEntryText.isEmpty()) // 'no language found' from language guessing
174  {
175  OSL_ENSURE( nLangItemIdStart <= nItemId && nItemId <= nLangItemIdStart + MN_MAX_NUM_LANG,
176  "nItemId outside of expected range!" );
177  pPopupMenu->InsertItem( nItemId, aEntryText, MenuItemBits::RADIOCHECK );
178  if (aEntryText == aCurLang)
179  {
180  //make a check mark for the current language
181  pPopupMenu->CheckItem( nItemId );
182  }
183  rLangTable[ nItemId ] = aEntryText;
184  ++nItemId;
185  }
186  }
187 
188  pPopupMenu->InsertItem( nLangItemIdStart + MN_NONE_OFFSET, SwResId( STR_LANGSTATUS_NONE ), MenuItemBits::RADIOCHECK );
190  pPopupMenu->CheckItem( nLangItemIdStart + MN_NONE_OFFSET );
191 
192  pPopupMenu->InsertItem( nLangItemIdStart + MN_RESET_OFFSET, SwResId( STR_RESET_TO_DEFAULT_LANGUAGE ) );
193  pPopupMenu->InsertItem( nLangItemIdStart + MN_MORE_OFFSET, SwResId( STR_LANGSTATUS_MORE ) );
194 }
195 
197  SwWrtShell* pWrtSh,
198  const uno::Reference< linguistic2::XSpellAlternatives > &xAlt,
199  const OUString &rParaText)
200  : m_aBuilder(nullptr, AllSettings::GetUIRootDir(), "modules/swriter/ui/spellmenu.ui", "")
201  , m_xPopupMenu(m_aBuilder.get_menu("menu"))
202  , m_nIgnoreWordId(m_xPopupMenu->GetItemId("ignoreall"))
203  , m_nAddMenuId(m_xPopupMenu->GetItemId("addmenu"))
204  , m_nAddId(m_xPopupMenu->GetItemId("add"))
205  , m_nSpellDialogId(m_xPopupMenu->GetItemId("spelldialog"))
206  , m_nCorrectMenuId(m_xPopupMenu->GetItemId("correctmenu"))
207  , m_nCorrectDialogId(m_xPopupMenu->GetItemId("correctdialog"))
208  , m_nLangSelectionMenuId(m_xPopupMenu->GetItemId("langselection"))
209  , m_nLangParaMenuId(m_xPopupMenu->GetItemId("langpara"))
210  , m_nRedlineAcceptId(m_xPopupMenu->GetItemId("accept"))
211  , m_nRedlineRejectId(m_xPopupMenu->GetItemId("reject"))
212  , m_nRedlineNextId(m_xPopupMenu->GetItemId("next"))
213  , m_nRedlinePrevId(m_xPopupMenu->GetItemId("prev"))
214  , m_pSh( pWrtSh )
215  , m_xSpellAlt(xAlt)
216  , m_bGrammarResults(false)
217 {
218  OSL_ENSURE(m_xSpellAlt.is(), "no spelling alternatives available");
219 
220  m_xPopupMenu->SetMenuFlags(MenuFlags::NoAutoMnemonics);
221  bool bUseImagesInMenus = Application::GetSettings().GetStyleSettings().GetUseImagesInMenus();
222 
224  css::uno::Sequence< OUString > aSuggestions;
225  if (m_xSpellAlt.is())
226  {
227  m_nCheckedLanguage = LanguageTag( m_xSpellAlt->getLocale() ).getLanguageType();
228  aSuggestions = m_xSpellAlt->getAlternatives();
229  }
230  sal_Int16 nStringCount = static_cast< sal_Int16 >( aSuggestions.getLength() );
231 
232  SvtLinguConfig aCfg;
233 
235  pMenu->SetMenuFlags(MenuFlags::NoAutoMnemonics);
236  bool bEnable = false;
237  if( nStringCount )
238  {
239  Image aImage;
240  OUString aSuggestionImageUrl;
241 
242  if (bUseImagesInMenus)
243  {
244  uno::Reference< container::XNamed > xNamed( m_xSpellAlt, uno::UNO_QUERY );
245  if (xNamed.is())
246  {
247  aSuggestionImageUrl = aCfg.GetSpellAndGrammarContextSuggestionImage( xNamed->getName() );
248  aImage = Image( aSuggestionImageUrl );
249  }
250  }
251 
252  m_xPopupMenu->InsertSeparator(OString(), 0);
253  bEnable = true;
254  sal_uInt16 nAutoCorrItemId = MN_AUTOCORR_START;
255  sal_uInt16 nItemId = MN_SUGGESTION_START;
256  for (sal_uInt16 i = 0; i < nStringCount; ++i)
257  {
258  const OUString aEntry = aSuggestions[ i ];
259  m_xPopupMenu->InsertItem(nItemId, aEntry, MenuItemBits::NONE, OString(), i);
261  if (!aSuggestionImageUrl.isEmpty())
262  m_xPopupMenu->SetItemImage(nItemId, aImage);
263 
264  pMenu->InsertItem( nAutoCorrItemId, aEntry );
265  pMenu->SetHelpId( nAutoCorrItemId, HID_LINGU_AUTOCORR);
266 
267  ++nAutoCorrItemId;
268  ++nItemId;
269  }
270  }
271 
272  uno::Reference< frame::XFrame > xFrame = pWrtSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface();
273  OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(xFrame));
274 
275  {
276  auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(".uno:SpellingAndGrammarDialog", aModuleName);
279  }
280  {
281  auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(".uno:AutoCorrectDlg", aModuleName);
284  }
285 
286  sal_uInt16 nItemPos = m_xPopupMenu->GetItemPos(m_nIgnoreWordId);
287  OUString aIgnoreSelection( SwResId( STR_IGNORE_SELECTION ) );
288  m_xPopupMenu->InsertItem(MN_IGNORE_SELECTION, aIgnoreSelection, MenuItemBits::NONE, OString(), nItemPos);
290 
292 
293  uno::Reference< linguistic2::XLanguageGuessing > xLG = SW_MOD()->GetLanguageGuesser();
294  LanguageType nGuessLangWord = LANGUAGE_NONE;
295  LanguageType nGuessLangPara = LANGUAGE_NONE;
296  if (m_xSpellAlt.is() && xLG.is())
297  {
298  nGuessLangWord = EditView::CheckLanguage( m_xSpellAlt->getWord(), ::GetSpellChecker(), xLG, false );
299  nGuessLangPara = EditView::CheckLanguage( rParaText, ::GetSpellChecker(), xLG, true );
300  }
301  if (nGuessLangWord != LANGUAGE_NONE || nGuessLangPara != LANGUAGE_NONE)
302  {
303  // make sure LANGUAGE_NONE gets not used as menu entry
304  if (nGuessLangWord == LANGUAGE_NONE)
305  nGuessLangWord = nGuessLangPara;
306  if (nGuessLangPara == LANGUAGE_NONE)
307  nGuessLangPara = nGuessLangWord;
308  }
309 
311  pMenu->SetMenuFlags(MenuFlags::NoAutoMnemonics);
312  uno::Reference< linguistic2::XSearchableDictionaryList > xDicList( LinguMgr::GetDictionaryList() );
313  sal_uInt16 nItemId = MN_DICTIONARIES_START;
314  if (xDicList.is())
315  {
316  // add the default positive dictionary to dic-list (if not already done).
317  // This is to ensure that there is at least one dictionary to which
318  // words could be added.
319  uno::Reference< linguistic2::XDictionary > xDic( LinguMgr::GetStandardDic() );
320  if (xDic.is())
321  xDic->setActive( true );
322 
323  m_aDics = xDicList->getDictionaries();
324 
325  for( const uno::Reference< linguistic2::XDictionary >& rDic : std::as_const(m_aDics) )
326  {
327  uno::Reference< linguistic2::XDictionary > xDicTmp = rDic;
328  if (!xDicTmp.is() || LinguMgr::GetIgnoreAllList() == xDicTmp)
329  continue;
330 
331  uno::Reference< frame::XStorable > xStor( xDicTmp, uno::UNO_QUERY );
332  LanguageType nActLanguage = LanguageTag( xDicTmp->getLocale() ).getLanguageType();
333  if( xDicTmp->isActive()
334  && xDicTmp->getDictionaryType() != linguistic2::DictionaryType_NEGATIVE
335  && (m_nCheckedLanguage == nActLanguage || LANGUAGE_NONE == nActLanguage )
336  && (!xStor.is() || !xStor->isReadonly()) )
337  {
338  // the extra 1 is because of the (possible) external
339  // linguistic entry above
340  pMenu->InsertItem( nItemId, xDicTmp->getName() );
341  m_aDicNameSingle = xDicTmp->getName();
342 
343  if (bUseImagesInMenus)
344  {
345  uno::Reference< lang::XServiceInfo > xSvcInfo( xDicTmp, uno::UNO_QUERY );
346  if (xSvcInfo.is())
347  {
348  OUString aDictionaryImageUrl( aCfg.GetSpellAndGrammarContextDictionaryImage(
349  xSvcInfo->getImplementationName() ) );
350  if (!aDictionaryImageUrl.isEmpty())
351  {
352  Image aImage( aDictionaryImageUrl );
353  pMenu->SetItemImage( nItemId, aImage );
354  }
355  }
356  }
357 
358  ++nItemId;
359  }
360  }
361  }
364 
365  //ADD NEW LANGUAGE MENU ITEM
366 
367  OUString aScriptTypesInUse( OUString::number( static_cast<int>(pWrtSh->GetScriptType()) ) );
368 
369  // get keyboard language
370  OUString aKeyboardLang;
371  SwEditWin& rEditWin = pWrtSh->GetView().GetEditWin();
372  LanguageType nLang = rEditWin.GetInputLanguage();
373  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
374  aKeyboardLang = SvtLanguageTable::GetLanguageString( nLang );
375 
376  // get the language that is in use
377  OUString aCurrentLang("*");
378  nLang = SwLangHelper::GetCurrentLanguage( *pWrtSh );
379  if (nLang != LANGUAGE_DONTKNOW)
380  aCurrentLang = SvtLanguageTable::GetLanguageString( nLang );
381 
382  // build sequence for status value
383  uno::Sequence< OUString > aSeq( 4 );
384  aSeq[0] = aCurrentLang;
385  aSeq[1] = aScriptTypesInUse;
386  aSeq[2] = aKeyboardLang;
387  aSeq[3] = SvtLanguageTable::GetLanguageString(nGuessLangWord);
388 
392 
396 
397  if (bUseImagesInMenus)
399  vcl::CommandInfoProvider::GetImageForCommand(".uno:SpellingAndGrammarDialog", xFrame));
400 
401  checkRedline();
402  m_xPopupMenu->RemoveDisabledEntries( true, true );
403 
404  InitItemCommands(aSuggestions);
405 }
406 
408  SwWrtShell *pWrtSh,
409  const linguistic2::ProofreadingResult &rResult,
410  sal_Int32 nErrorInResult,
411  const uno::Sequence< OUString > &rSuggestions,
412  const OUString &rParaText )
413  : m_aBuilder(nullptr, AllSettings::GetUIRootDir(), "modules/swriter/ui/spellmenu.ui", "")
414  , m_xPopupMenu(m_aBuilder.get_menu("menu"))
415  , m_nIgnoreWordId(m_xPopupMenu->GetItemId("ignoreall"))
416  , m_nAddMenuId(m_xPopupMenu->GetItemId("addmenu"))
417  , m_nAddId(m_xPopupMenu->GetItemId("add"))
418  , m_nSpellDialogId(m_xPopupMenu->GetItemId("spelldialog"))
419  , m_nCorrectMenuId(m_xPopupMenu->GetItemId("correctmenu"))
420  , m_nCorrectDialogId(m_xPopupMenu->GetItemId("correctdialog"))
421  , m_nLangSelectionMenuId(m_xPopupMenu->GetItemId("langselection"))
422  , m_nLangParaMenuId(m_xPopupMenu->GetItemId("langpara"))
423  , m_nRedlineAcceptId(m_xPopupMenu->GetItemId("accept"))
424  , m_nRedlineRejectId(m_xPopupMenu->GetItemId("reject"))
425  , m_nRedlineNextId(m_xPopupMenu->GetItemId("next"))
426  , m_nRedlinePrevId(m_xPopupMenu->GetItemId("prev"))
427  , m_pSh(pWrtSh)
428  , m_sExplanationLink()
429  , m_bGrammarResults(true)
430 {
431  m_nCheckedLanguage = LanguageTag::convertToLanguageType( rResult.aLocale );
432  bool bUseImagesInMenus = Application::GetSettings().GetStyleSettings().GetUseImagesInMenus();
433 
434  sal_uInt16 nPos = 0;
435  OUString aMessageText( rResult.aErrors[ nErrorInResult ].aShortComment );
436  m_xPopupMenu->InsertSeparator(OString(), nPos++);
437  m_xPopupMenu->InsertItem(MN_SHORT_COMMENT, aMessageText, MenuItemBits::NOSELECT, OString(), nPos++);
438  if (bUseImagesInMenus)
439  m_xPopupMenu->SetItemImage(MN_SHORT_COMMENT, Image(StockImage::Yes, BMP_INFO_16));
440 
441  // Add an item to show detailed infos if the FullCommentURL property is defined
442  const beans::PropertyValues aProperties = rResult.aErrors[ nErrorInResult ].aProperties;
443  for ( const auto& rProp : aProperties )
444  {
445  if ( rProp.Name == "FullCommentURL" )
446  {
447  uno::Any aValue = rProp.Value;
448  aValue >>= m_sExplanationLink;
449 
450  if ( !m_sExplanationLink.isEmpty( ) )
451  break;
452  }
453  }
454 
455  if ( !m_sExplanationLink.isEmpty( ) )
456  {
457  m_xPopupMenu->InsertItem(MN_EXPLANATION_LINK, SwResId(STR_EXPLANATION_LINK), MenuItemBits::TEXT | MenuItemBits::HELP, OString(), nPos++);
458  }
459 
460  m_xPopupMenu->SetMenuFlags(MenuFlags::NoAutoMnemonics);
461 
462  m_xPopupMenu->InsertSeparator(OString(), nPos++);
463  if ( rSuggestions.hasElements() ) // suggestions available...
464  {
465  Image aImage;
466  OUString aSuggestionImageUrl;
467 
468  if (bUseImagesInMenus)
469  {
470  uno::Reference< lang::XServiceInfo > xInfo( rResult.xProofreader, uno::UNO_QUERY );
471  if (xInfo.is())
472  {
473  aSuggestionImageUrl = SvtLinguConfig().GetSpellAndGrammarContextSuggestionImage( xInfo->getImplementationName() );
474  aImage = Image( aSuggestionImageUrl );
475  }
476  }
477 
478  sal_uInt16 nItemId = MN_SUGGESTION_START;
479  for (const OUString& aEntry : std::as_const(rSuggestions))
480  {
481  m_xPopupMenu->InsertItem(nItemId, aEntry, MenuItemBits::NONE, OString(), nPos++);
483  if (!aSuggestionImageUrl.isEmpty())
484  m_xPopupMenu->SetItemImage(nItemId, aImage);
485 
486  ++nItemId;
487  }
488  m_xPopupMenu->InsertSeparator(OString(), nPos++);
489  }
490 
491  uno::Reference< frame::XFrame > xFrame = pWrtSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface();
492  OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(xFrame));
493 
494  OUString aIgnoreSelection( SwResId( STR_IGNORE_SELECTION ) );
495  auto aCommandProperties = vcl::CommandInfoProvider::GetCommandProperties(".uno:SpellingAndGrammarDialog", aModuleName);
498  sal_uInt16 nItemPos = m_xPopupMenu->GetItemPos(m_nIgnoreWordId);
499  m_xPopupMenu->InsertItem(MN_IGNORE_SELECTION, aIgnoreSelection, MenuItemBits::NONE, OString(), nItemPos);
501 
504 
505  uno::Reference< linguistic2::XLanguageGuessing > xLG = SW_MOD()->GetLanguageGuesser();
506  LanguageType nGuessLangWord = LANGUAGE_NONE;
507  LanguageType nGuessLangPara = LANGUAGE_NONE;
508  if (xLG.is())
509  {
510  nGuessLangPara = EditView::CheckLanguage( rParaText, ::GetSpellChecker(), xLG, true );
511  }
512  if (nGuessLangWord != LANGUAGE_NONE || nGuessLangPara != LANGUAGE_NONE)
513  {
514  // make sure LANGUAGE_NONE gets not used as menu entry
515  if (nGuessLangWord == LANGUAGE_NONE)
516  nGuessLangWord = nGuessLangPara;
517  if (nGuessLangPara == LANGUAGE_NONE)
518  nGuessLangPara = nGuessLangWord;
519  }
520 
523 
524  //ADD NEW LANGUAGE MENU ITEM
525 
526  OUString aScriptTypesInUse( OUString::number( static_cast<int>(pWrtSh->GetScriptType()) ) );
527 
528  // get keyboard language
529  OUString aKeyboardLang;
530  SwEditWin& rEditWin = pWrtSh->GetView().GetEditWin();
531  LanguageType nLang = rEditWin.GetInputLanguage();
532  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
533  aKeyboardLang = SvtLanguageTable::GetLanguageString( nLang );
534 
535  // get the language that is in use
536  OUString aCurrentLang("*");
537  nLang = SwLangHelper::GetCurrentLanguage( *pWrtSh );
538  if (nLang != LANGUAGE_DONTKNOW)
539  aCurrentLang = SvtLanguageTable::GetLanguageString( nLang );
540 
541  // build sequence for status value
542  uno::Sequence< OUString > aSeq( 4 );
543  aSeq[0] = aCurrentLang;
544  aSeq[1] = aScriptTypesInUse;
545  aSeq[2] = aKeyboardLang;
546  aSeq[3] = SvtLanguageTable::GetLanguageString(nGuessLangWord);
547 
551 
555 
556  if (bUseImagesInMenus)
558  vcl::CommandInfoProvider::GetImageForCommand(".uno:SpellingAndGrammarDialog", xFrame));
559 
560  checkRedline();
561  m_xPopupMenu->RemoveDisabledEntries(true, true);
562 
563  SvtLinguConfig().SetProperty( UPN_IS_GRAMMAR_INTERACTIVE, uno::makeAny( true ));
564 
565  InitItemCommands(rSuggestions);
566 }
567 
569 
570 void SwSpellPopup::InitItemCommands(const css::uno::Sequence< OUString >& aSuggestions)
571 {
573  return;
574 
575  // None is added only for LOK, it means there is no need to execute anything
577  m_xPopupMenu->SetItemCommand(m_nSpellDialogId, ".uno:SpellingAndGrammarDialog");
579  m_xPopupMenu->SetItemCommand(m_nIgnoreWordId, ".uno:SpellCheckIgnoreAll?Type:string=Grammar");
580  else
581  m_xPopupMenu->SetItemCommand(m_nIgnoreWordId, ".uno:SpellCheckIgnoreAll?Type:string=Spelling");
583  m_xPopupMenu->SetItemCommand(MN_IGNORE_SELECTION, ".uno:SpellCheckIgnore?Type:string=Grammar");
584  else
585  m_xPopupMenu->SetItemCommand(MN_IGNORE_SELECTION, ".uno:SpellCheckIgnore?Type:string=Spelling");
586 
587  for(int i = 0; i < aSuggestions.getLength(); ++i)
588  {
589  sal_uInt16 nItemId = MN_SUGGESTION_START + i;
590  OUString sCommandString = ".uno:SpellCheckApplySuggestion?ApplyRule:string=";
592  sCommandString += "Grammar_";
593  else if (m_xSpellAlt.is())
594  sCommandString += "Spelling_";
595  sCommandString += m_xPopupMenu->GetItemText(nItemId);
596  m_xPopupMenu->SetItemCommand(nItemId, sCommandString);
597  }
598 
600  m_xPopupMenu->SetItemCommand(m_nLangSelectionMenuId, ".uno:SetSelectionLanguageMenu");
601  if(pMenu)
602  {
603  for (const auto& item : m_aLangTable_Text)
604  {
605  OUString sCommandString = ".uno:LanguageStatus?Language:string=Current_" + item.second;
606  pMenu->SetItemCommand(item.first, sCommandString);
607  }
608 
609  pMenu->SetItemCommand(MN_SET_SELECTION_NONE, ".uno:LanguageStatus?Language:string=Current_LANGUAGE_NONE");
610  pMenu->SetItemCommand(MN_SET_SELECTION_RESET, ".uno:LanguageStatus?Language:string=Current_RESET_LANGUAGES");
611  pMenu->SetItemCommand(MN_SET_SELECTION_MORE, ".uno:FontDialog?Page:string=font");
612  }
613 
615  m_xPopupMenu->SetItemCommand(m_nLangParaMenuId, ".uno:SetParagraphLanguageMenu");
616  if(pMenu)
617  {
618  for (const auto& item : m_aLangTable_Paragraph)
619  {
620  OUString sCommandString = ".uno:LanguageStatus?Language:string=Paragraph_" + item.second;
621  pMenu->SetItemCommand(item.first, sCommandString);
622  }
623 
624  pMenu->SetItemCommand(MN_SET_PARA_NONE, ".uno:LanguageStatus?Language:string=Paragraph_LANGUAGE_NONE");
625  pMenu->SetItemCommand(MN_SET_PARA_RESET, ".uno:LanguageStatus?Language:string=Paragraph_RESET_LANGUAGES");
626  pMenu->SetItemCommand(MN_SET_PARA_MORE, ".uno:FontDialogForParagraph");
627  }
628 }
629 
631 {
632  // Let SwView::GetState() already has the logic on when to disable the
633  // accept/reject and the next/prev change items, let it do the decision.
634 
635  // Build an item set that contains a void item for each menu entry. The
636  // WhichId of each item is set, so SwView may clear it.
637  static const sal_uInt16 pRedlineIds[] = {
642  };
643  SwDoc *pDoc = m_pSh->GetDoc();
645  for (sal_uInt16 nWhich : pRedlineIds)
646  {
647  aSet.Put(SfxVoidItem(nWhich));
648  }
649  m_pSh->GetView().GetState(aSet);
650 
651  // Enable/disable items based on if the which id of the void items are
652  // cleared or not.
653  for (sal_uInt16 nWhich : pRedlineIds)
654  {
655  sal_uInt16 nId(0);
656  if (nWhich == FN_REDLINE_ACCEPT_DIRECT)
657  nId = m_nRedlineAcceptId;
658  else if (nWhich == FN_REDLINE_REJECT_DIRECT)
659  nId = m_nRedlineRejectId;
660  else if (nWhich == FN_REDLINE_NEXT_CHANGE)
661  nId = m_nRedlineNextId;
662  else if (nWhich == FN_REDLINE_PREV_CHANGE)
663  nId = m_nRedlinePrevId;
664  m_xPopupMenu->EnableItem(nId, aSet.Get(nWhich).Which() != 0);
665  }
666 }
667 
668 void SwSpellPopup::Execute( const tools::Rectangle& rWordPos, vcl::Window* pWin )
669 {
670  sal_uInt16 nRet = m_xPopupMenu->Execute(pWin, pWin->LogicToPixel(rWordPos));
671  Execute( nRet );
672 }
673 
674 void SwSpellPopup::Execute( sal_uInt16 nId )
675 {
676  if (nId == USHRT_MAX)
677  return;
678 
679  if (/*m_bGrammarResults && */nId == MN_SHORT_COMMENT)
680  return; // nothing to do since it is the error message (short comment)
681 
682  if (MN_SUGGESTION_START <= nId && nId <= MN_SUGGESTION_END)
683  {
684  OUString sApplyRule("");
686  sApplyRule += "Grammar_";
687  else if (m_xSpellAlt.is())
688  sApplyRule += "Spelling_";
689  sApplyRule += m_xPopupMenu->GetItemText(nId);
690 
691  SfxStringItem aApplyItem(FN_PARAM_1, sApplyRule);
692  m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_SPELLCHECK_APPLY_SUGGESTION, SfxCallMode::SYNCHRON, { &aApplyItem });
693  }
694  else if(MN_AUTOCORR_START <= nId && nId <= MN_AUTOCORR_END)
695  {
696  if (m_xSpellAlt.is())
697  {
698  bool bOldIns = m_pSh->IsInsMode();
699  m_pSh->SetInsMode();
700 
702  assert(pMenu);
703  OUString aTmp( pMenu->GetItemText(nId) );
704  OUString aOrig( m_xSpellAlt->getWord() );
705 
706  // if original word has a trailing . (likely the end of a sentence)
707  // and the replacement text hasn't, then add it to the replacement
708  if (!aTmp.isEmpty() && !aOrig.isEmpty() &&
709  aOrig.endsWith(".") && /* !IsAlphaNumeric ??*/
710  !aTmp.endsWith("."))
711  {
712  aTmp += ".";
713  }
714 
715  SwRewriter aRewriter;
716 
717  aRewriter.AddRule(UndoArg1, m_pSh->GetCursorDescr());
718  aRewriter.AddRule(UndoArg2, SwResId(STR_YIELDS));
719 
720  OUString aTmpStr = SwResId(STR_START_QUOTE) +
721  aTmp + SwResId(STR_END_QUOTE);
722  aRewriter.AddRule(UndoArg3, aTmpStr);
723 
724  m_pSh->StartUndo(SwUndoId::UI_REPLACE, &aRewriter);
725  m_pSh->StartAction();
726 
727  m_pSh->Replace(aTmp, false);
728 
729  /* #102505# EndAction/EndUndo moved down since insertion
730  of temporary auto correction is now undoable two and
731  must reside in the same undo group.*/
732 
733  // record only if it's NOT already present in autocorrection
735 
736  OUString aOrigWord( m_xSpellAlt->getWord() ) ;
737  OUString aNewWord( pMenu->GetItemText(nId) );
738  SvxPrepareAutoCorrect( aOrigWord, aNewWord );
739 
740  pACorr->PutText( aOrigWord, aNewWord, m_nCheckedLanguage );
741 
742  /* #102505# EndAction/EndUndo moved down since insertion
743  of temporary auto correction is now undoable two and
744  must reside in the same undo group.*/
745  m_pSh->EndAction();
746  m_pSh->EndUndo();
747 
748  m_pSh->SetInsMode( bOldIns );
749  }
750  }
751  else if (nId == m_nSpellDialogId)
752  {
753  m_pSh->Left(CRSR_SKIP_CHARS, false, 1, false );
754  {
756  Execute( FN_SPELL_GRAMMAR_DIALOG, SfxCallMode::ASYNCHRON );
757  }
758  }
759  else if (nId == m_nCorrectDialogId)
760  {
761  m_pSh->GetView().GetViewFrame()->GetDispatcher()->Execute( SID_AUTO_CORRECT_DLG, SfxCallMode::ASYNCHRON );
762  }
763  else if (nId == MN_IGNORE_SELECTION)
764  {
765  SfxStringItem aIgnoreString(FN_PARAM_1, m_bGrammarResults ? OUString("Grammar") : OUString("Spelling"));
766  m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_SPELLCHECK_IGNORE, SfxCallMode::SYNCHRON, { &aIgnoreString });
767  }
768  else if (nId == m_nIgnoreWordId)
769  {
770  SfxStringItem aIgnoreString(FN_PARAM_1, m_bGrammarResults ? OUString("Grammar") : OUString("Spelling"));
771  m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_SPELLCHECK_IGNORE_ALL, SfxCallMode::SYNCHRON, { &aIgnoreString });
772  }
773  else if ((MN_DICTIONARIES_START <= nId && nId <= MN_DICTIONARIES_END) || nId == m_nAddId)
774  {
775  OUString sWord( m_xSpellAlt->getWord() );
776  OUString aDicName;
777 
778  if (MN_DICTIONARIES_START <= nId && nId <= MN_DICTIONARIES_END)
779  {
781  aDicName = pMenu->GetItemText(nId);
782  }
783  else
784  aDicName = m_aDicNameSingle;
785 
786  uno::Reference< linguistic2::XDictionary > xDic;
787  uno::Reference< linguistic2::XSearchableDictionaryList > xDicList( LinguMgr::GetDictionaryList() );
788  if (xDicList.is())
789  xDic = xDicList->getDictionaryByName( aDicName );
790 
791  if (xDic.is())
792  {
793  linguistic::DictionaryError nAddRes = linguistic::AddEntryToDic(xDic, sWord, false, OUString());
794  // save modified user-dictionary if it is persistent
795  uno::Reference< frame::XStorable > xSavDic( xDic, uno::UNO_QUERY );
796  if (xSavDic.is())
797  xSavDic->store();
798 
799  if (linguistic::DictionaryError::NONE != nAddRes && !xDic->getEntry(sWord).is())
800  {
801  SvxDicError(m_pSh->GetView().GetFrameWeld(), nAddRes);
802  }
803  }
804  }
805  else if ( nId == MN_EXPLANATION_LINK && !m_sExplanationLink.isEmpty() )
806  {
807  try
808  {
809  uno::Reference< css::system::XSystemShellExecute > xSystemShellExecute(
810  css::system::SystemShellExecute::create( ::comphelper::getProcessComponentContext() ) );
811  xSystemShellExecute->execute( m_sExplanationLink, OUString(),
812  css::system::SystemShellExecuteFlags::URIS_ONLY );
813  }
814  catch (const uno::Exception&)
815  {
817  OUString msg( ::comphelper::anyToString( exc ) );
818  const SolarMutexGuard guard;
819  std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_pSh->GetView().GetFrameWeld(),
820  VclMessageType::Warning, VclButtonsType::Ok, msg));
821  xBox->set_title("Explanations");
822  xBox->run();
823  }
824  }
825  else if (nId == m_nRedlineAcceptId || nId == m_nRedlineRejectId
826  || nId == m_nRedlineNextId || nId == m_nRedlinePrevId)
827  {
828  if (nId == m_nRedlineAcceptId)
830  else if (nId == m_nRedlineRejectId)
832  else if (nId == m_nRedlineNextId)
834  else if (nId == m_nRedlinePrevId)
836  // Let SwView::Execute() handle the redline actions.
837  SfxRequest aReq(m_pSh->GetView().GetViewFrame(), nId);
838  m_pSh->GetView().Execute(aReq);
839  }
840  else
841  {
843  {
844  SfxStringItem aLangString(SID_LANGUAGE_STATUS, "Current_" + m_aLangTable_Text[nId]);
845  m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_LANGUAGE_STATUS, SfxCallMode::SYNCHRON, { &aLangString });
846  }
847  else if (nId == MN_SET_SELECTION_NONE)
848  {
849  SfxStringItem aLangString(SID_LANGUAGE_STATUS, "Current_LANGUAGE_NONE");
850  m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_LANGUAGE_STATUS, SfxCallMode::SYNCHRON, { &aLangString });
851  }
852  else if (nId == MN_SET_SELECTION_RESET)
853  {
854  SfxStringItem aLangString(SID_LANGUAGE_STATUS, "Current_RESET_LANGUAGES");
855  m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_LANGUAGE_STATUS, SfxCallMode::SYNCHRON, { &aLangString });
856  }
857  else if (nId == MN_SET_SELECTION_MORE)
858  {
859  SfxStringItem aDlgString(FN_PARAM_1, "font");
860  m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_CHAR_DLG, SfxCallMode::SYNCHRON, { &aDlgString });
861  }
863  {
864  SfxStringItem aLangString(SID_LANGUAGE_STATUS, "Paragraph_" + m_aLangTable_Paragraph[nId]);
865  m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_LANGUAGE_STATUS, SfxCallMode::SYNCHRON, { &aLangString });
866  }
867  else if (nId == MN_SET_PARA_NONE)
868  {
869  SfxStringItem aLangString(SID_LANGUAGE_STATUS, "Paragraph_LANGUAGE_NONE");
870  m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_LANGUAGE_STATUS, SfxCallMode::SYNCHRON, { &aLangString });
871  }
872  else if (nId == MN_SET_PARA_RESET)
873  {
874  SfxStringItem aLangString(SID_LANGUAGE_STATUS, "Paragraph_RESET_LANGUAGES");
875  m_pSh->GetView().GetViewFrame()->GetDispatcher()->ExecuteList(SID_LANGUAGE_STATUS, SfxCallMode::SYNCHRON, { &aLangString });
876  }
877  else if (nId == MN_SET_PARA_MORE)
878  {
879  m_pSh->GetView().GetViewFrame()->GetDispatcher()->Execute( SID_CHAR_DLG_FOR_PARAGRAPH );
880  }
881  }
882 
883  m_pSh->EnterStdMode();
884 }
885 
886 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxViewFrame * GetViewFrame() const
#define MN_SUGGESTION_START
Definition: olmenu.hxx:45
#define LANGUAGE_NONE
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
PopupMenu * GetPopupMenu(sal_uInt16 nItemId) const
sal_uInt16 m_nCorrectMenuId
Definition: olmenu.hxx:83
void SetItemImage(sal_uInt16 nItemId, const Image &rImage)
static SvxAutoCorrCfg & Get()
#define MN_SET_PARA_MORE
Definition: olmenu.hxx:71
bool IsInsMode() const
Definition: wrtsh.hxx:166
const LanguageTag & GetUILanguageTag() const
sal_uInt16 m_nCorrectDialogId
Definition: olmenu.hxx:84
#define HID_LINGU_AUTOCORR
Definition: helpids.h:62
void SetHelpId(sal_uInt16 nItemId, const OString &rHelpId)
LanguageType getLanguageType(bool bResolveSystem=true) const
SfxDispatcher * GetDispatcher()
static LanguageType convertToLanguageType(const css::lang::Locale &rLocale, bool bResolveSystem=true)
LanguageType m_nCheckedLanguage
Definition: olmenu.hxx:97
Reference< XFrame > xFrame
#define MN_DICTIONARIES_END
Definition: olmenu.hxx:42
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
bool m_bGrammarResults
Definition: olmenu.hxx:103
Definition: doc.hxx:187
sal_Int16 nId
static css::uno::Reference< css::linguistic2::XDictionary > GetStandardDic()
#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:234
#define HID_LINGU_IGNORE_SELECTION
Definition: helpids.h:64
void EnterStdMode()
Definition: select.cxx:551
sal_uInt16 GetItemPos(sal_uInt16 nItemId) const
SwEditWin & GetEditWin()
Definition: view.hxx:416
sal_uInt16 Execute(vcl::Window *pWindow, const Point &rPopupPos)
#define MN_SHORT_COMMENT
Definition: olmenu.hxx:37
OUString GetCursorDescr() const
Returns textual description of the current selection.
Definition: crsrsh.cxx:3637
#define MN_MAX_NUM_LANG
Definition: olmenu.hxx:53
static LanguageType nLang
Definition: srtdlg.cxx:51
Used by the UI to modify the document model.
Definition: wrtsh.hxx:91
OUString m_sExplanationLink
Definition: olmenu.hxx:95
const SwView & GetView() const
Definition: wrtsh.hxx:429
Reference< XController > xController
sal_uInt16 m_nAddId
Definition: olmenu.hxx:81
PropertiesInfo aProperties
Any SAL_CALL getCaughtException()
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
#define MN_EXPLANATION_LINK
Definition: olmenu.hxx:38
static LanguageType GetLanguageType(std::u16string_view rStr)
SfxFrame & GetFrame() const
void SetItemCommand(sal_uInt16 nItemId, const OUString &rCommand)
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:281
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:99
const LanguageTag & GetLanguageTag() const
OUString GetPopupLabelForCommand(const css::uno::Sequence< css::beans::PropertyValue > &rProperties)
short SvxDicError(weld::Window *pParent, linguistic::DictionaryError nError)
sal_uInt16 m_nAddMenuId
Definition: olmenu.hxx:80
Image GetImageForCommand(const OUString &rsCommandName, const Reference< frame::XFrame > &rxFrame, vcl::ImageType eImageType)
#define FN_REDLINE_ACCEPT_DIRECT
Definition: cmdid.h:137
sal_uInt16 m_nSpellDialogId
Definition: olmenu.hxx:82
SvtScriptType
SvtScriptType GetScriptType() const
returns the script type of the selection
Definition: edattr.cxx:673
#define SW_MOD()
Definition: swmodule.hxx:255
OUString GetModuleIdentifier(const Reference< frame::XFrame > &rxFrame)
#define MN_MORE_OFFSET
Definition: olmenu.hxx:57
int i
#define MN_SET_LANGUAGE_SELECTION_START
Definition: olmenu.hxx:60
Window class for the Writer edit area, this is the one handling mouse and keyboard events and doing t...
Definition: edtwin.hxx:58
#define MN_SET_SELECTION_NONE
Definition: olmenu.hxx:62
SvxAutoCorrect * GetAutoCorrect()
#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:223
void AddRule(SwUndoArg eWhat, const OUString &rWith)
Definition: SwRewriter.cxx:27
Object Value
std::map< sal_Int16, OUString > m_aLangTable_Paragraph
Definition: olmenu.hxx:100
static bool lcl_checkScriptType(SvtScriptType nScriptType, LanguageType nLang)
Definition: olmenu.cxx:86
OUString m_aDicNameSingle
Definition: olmenu.hxx:102
#define LANGUAGE_DONTKNOW
#define MN_SET_PARA_RESET
Definition: olmenu.hxx:70
void SvxPrepareAutoCorrect(OUString &rOldText, const OUString &rNewText)
VclPtr< PopupMenu > m_xPopupMenu
Definition: olmenu.hxx:78
sal_uInt16 m_nLangSelectionMenuId
Definition: olmenu.hxx:85
OUString SwResId(const char *pId)
Definition: swmodule.cxx:166
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:226
sal_uInt16 m_nLangParaMenuId
Definition: olmenu.hxx:86
OUString GetSpellAndGrammarContextSuggestionImage(const OUString &rServiceImplName) const
uno::Reference< linguistic2::XSpellChecker1 > GetSpellChecker()
Definition: swtypes.cxx:52
#define MN_SET_SELECTION_RESET
Definition: olmenu.hxx:63
Sequence< beans::PropertyValue > GetCommandProperties(const OUString &rsCommandName, const OUString &rsModuleName)
#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:670
bool PutText(const OUString &rShort, const OUString &rLong, LanguageType eLang)
#define MN_SUGGESTION_END
Definition: olmenu.hxx:46
#define FN_SPELL_GRAMMAR_DIALOG
Definition: cmdid.h:601
weld::Window * GetFrameWeld() const
bool Left(sal_uInt16 nMode, bool bSelect, sal_uInt16 nCount, bool bBasicCall, bool bVisual=false)
Definition: move.cxx:110
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
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:254
#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:91
#define HID_LINGU_REPLACE
Definition: helpids.h:63
sal_uInt16 m_nIgnoreWordId
Definition: olmenu.hxx:79
#define MN_SET_LANGUAGE_PARAGRAPH_START
Definition: olmenu.hxx:67
sal_uInt16 m_nRedlineAcceptId
Definition: olmenu.hxx:87
void InitItemCommands(const css::uno::Sequence< OUString > &aSuggestions)
Definition: olmenu.cxx:570
bool SetProperty(const OUString &rPropertyName, const css::uno::Any &rValue)
sal_uInt16 m_nRedlineRejectId
Definition: olmenu.hxx:88
void Execute(SfxRequest &)
Definition: view2.cxx:534
Reference< XComponentContext > getProcessComponentContext()
Sequence< sal_Int8 > aSeq
LanguageType GetCurrentLanguage(SfxItemSet const &aSet, SvtScriptType nScriptType)
Definition: langhelper.cxx:469
static LanguageType CheckLanguage(const OUString &rText, const css::uno::Reference< css::linguistic2::XSpellChecker1 > &xSpell, const css::uno::Reference< css::linguistic2::XLanguageGuessing > &xLangGuess, bool bIsParaText)
static OUString GetLanguageString(const LanguageType eType)
#define MN_SET_PARA_NONE
Definition: olmenu.hxx:69
const sal_uInt16 CRSR_SKIP_CHARS
Definition: swcrsr.hxx:65
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:630
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
sal_uInt16 m_nRedlineNextId
Definition: olmenu.hxx:89
sal_uInt16 m_nRedlinePrevId
Definition: olmenu.hxx:90
void RemoveDisabledEntries(bool bCheckPopups=true, bool bRemoveEmptyPopups=false)
LanguageType GetInputLanguage() const
void Execute(const tools::Rectangle &rPopupPos, vcl::Window *pWin)
Definition: olmenu.cxx:668
#define FN_REDLINE_REJECT_DIRECT
Definition: cmdid.h:138
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
#define MN_RESET_OFFSET
Definition: olmenu.hxx:56
sal_uInt16 nPos
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1320
bool Replace(const OUString &rNewStr, bool bRegExpRplc)
Replace a selected range in a TextNode by given string.
Definition: eddel.cxx:314
OUString anyToString(uno::Any const &value)
void EndAction(const bool bIdleEnd=false)
Definition: crsrsh.cxx:243
void GetState(SfxItemSet &)
Definition: viewstat.cxx:64
void SetItemText(sal_uInt16 nItemId, const OUString &rStr)