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