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();
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  const uno::Sequence< lang::Locale > rLocales( xDocumentLanguages->getDocumentLanguages( static_cast<sal_Int16>(nScriptType), nMaxCount ) );
178  for (const lang::Locale& rLocale : rLocales)
179  {
180  if (aLangItems.size() == size_t(nMaxCount))
181  break;
182  if (lcl_checkScriptType( nScriptType, SvtLanguageTable::GetLanguageType( rLocale.Language )))
183  aLangItems.insert( rLocale.Language );
184  }
185  }
186 
187  sal_uInt16 nItemId = nLangItemIdStart;
188  for (const OUString& aEntryText : aLangItems)
189  {
190  if (aEntryText != SvtLanguageTable::GetLanguageString( LANGUAGE_NONE ) &&
191  aEntryText != "*" && // multiple languages in current selection
192  !aEntryText.isEmpty()) // 'no language found' from language guessing
193  {
194  OSL_ENSURE( nLangItemIdStart <= nItemId && nItemId <= nLangItemIdStart + MN_MAX_NUM_LANG,
195  "nItemId outside of expected range!" );
196  pPopupMenu->InsertItem( nItemId, aEntryText, MenuItemBits::RADIOCHECK );
197  if (aEntryText == aCurLang)
198  {
199  //make a check mark for the current language
200  pPopupMenu->CheckItem( nItemId );
201  }
202  rLangTable[ nItemId ] = aEntryText;
203  ++nItemId;
204  }
205  }
206 
207  pPopupMenu->InsertItem( nLangItemIdStart + MN_NONE_OFFSET, SwResId( STR_LANGSTATUS_NONE ), MenuItemBits::RADIOCHECK );
209  pPopupMenu->CheckItem( nLangItemIdStart + MN_NONE_OFFSET );
210 
211  pPopupMenu->InsertItem( nLangItemIdStart + MN_RESET_OFFSET, SwResId( STR_RESET_TO_DEFAULT_LANGUAGE ) );
212  pPopupMenu->InsertItem( nLangItemIdStart + MN_MORE_OFFSET, SwResId( STR_LANGSTATUS_MORE ) );
213 }
214 
216  SwWrtShell* pWrtSh,
217  const uno::Reference< linguistic2::XSpellAlternatives > &xAlt,
218  const OUString &rParaText)
219  : m_aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "modules/swriter/ui/spellmenu.ui", "")
220  , m_xPopupMenu(m_aBuilder.get_menu("menu"))
221  , m_nIgnoreWordId(m_xPopupMenu->GetItemId("ignoreall"))
222  , m_nAddMenuId(m_xPopupMenu->GetItemId("addmenu"))
223  , m_nAddId(m_xPopupMenu->GetItemId("add"))
224  , m_nSpellDialogId(m_xPopupMenu->GetItemId("spelldialog"))
225  , m_nCorrectMenuId(m_xPopupMenu->GetItemId("correctmenu"))
226  , m_nCorrectDialogId(m_xPopupMenu->GetItemId("correctdialog"))
227  , m_nLangSelectionMenuId(m_xPopupMenu->GetItemId("langselection"))
228  , m_nLangParaMenuId(m_xPopupMenu->GetItemId("langpara"))
229  , m_nRedlineAcceptId(m_xPopupMenu->GetItemId("accept"))
230  , m_nRedlineRejectId(m_xPopupMenu->GetItemId("reject"))
231  , m_nRedlineNextId(m_xPopupMenu->GetItemId("next"))
232  , m_nRedlinePrevId(m_xPopupMenu->GetItemId("prev"))
233  , m_pSh( pWrtSh )
234  , m_xSpellAlt(xAlt)
235  , m_nGrammarError(0)
236  , m_bGrammarResults(false)
237 {
238  OSL_ENSURE(m_xSpellAlt.is(), "no spelling alternatives available");
239 
240  m_xPopupMenu->SetMenuFlags(MenuFlags::NoAutoMnemonics);
241  bool bUseImagesInMenus = Application::GetSettings().GetStyleSettings().GetUseImagesInMenus();
242 
244  if (m_xSpellAlt.is())
245  {
246  m_nCheckedLanguage = LanguageTag( m_xSpellAlt->getLocale() ).getLanguageType();
247  m_aSuggestions = m_xSpellAlt->getAlternatives();
248  }
249  sal_Int16 nStringCount = static_cast< sal_Int16 >( m_aSuggestions.getLength() );
250 
251  SvtLinguConfig aCfg;
252 
254  pMenu->SetMenuFlags(MenuFlags::NoAutoMnemonics);
255  bool bEnable = false;
256  if( nStringCount )
257  {
258  Image aImage;
259  OUString aSuggestionImageUrl;
260 
261  if (bUseImagesInMenus)
262  {
263  uno::Reference< container::XNamed > xNamed( m_xSpellAlt, uno::UNO_QUERY );
264  if (xNamed.is())
265  {
266  aSuggestionImageUrl = aCfg.GetSpellAndGrammarContextSuggestionImage( xNamed->getName() );
267  aImage = Image( aSuggestionImageUrl );
268  }
269  }
270 
271  m_xPopupMenu->InsertSeparator(OString(), 0);
272  bEnable = true;
273  sal_uInt16 nAutoCorrItemId = MN_AUTOCORR_START;
274  sal_uInt16 nItemId = MN_SUGGESTION_START;
275  for (sal_uInt16 i = 0; i < nStringCount; ++i)
276  {
277  const OUString aEntry = m_aSuggestions[ i ];
278  m_xPopupMenu->InsertItem(nItemId, aEntry, MenuItemBits::NONE, OString(), i);
280  if (!aSuggestionImageUrl.isEmpty())
281  m_xPopupMenu->SetItemImage(nItemId, aImage);
282 
283  pMenu->InsertItem( nAutoCorrItemId, aEntry );
284  pMenu->SetHelpId( nAutoCorrItemId, HID_LINGU_AUTOCORR);
285 
286  ++nAutoCorrItemId;
287  ++nItemId;
288  }
289  }
290 
291  uno::Reference< frame::XFrame > xFrame = pWrtSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface();
292  OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(xFrame));
293 
294  OUString aIgnoreSelection( SwResId( STR_IGNORE_SELECTION ) );
296  vcl::CommandInfoProvider::GetPopupLabelForCommand(".uno:SpellingAndGrammarDialog", aModuleName));
298  vcl::CommandInfoProvider::GetPopupLabelForCommand(".uno:AutoCorrectDlg", aModuleName));
299  sal_uInt16 nItemPos = m_xPopupMenu->GetItemPos(m_nIgnoreWordId);
300  m_xPopupMenu->InsertItem(MN_IGNORE_SELECTION, aIgnoreSelection, MenuItemBits::NONE, OString(), nItemPos);
302 
304 
305  uno::Reference< linguistic2::XLanguageGuessing > xLG = SW_MOD()->GetLanguageGuesser();
306  LanguageType nGuessLangWord = LANGUAGE_NONE;
307  LanguageType nGuessLangPara = LANGUAGE_NONE;
308  if (m_xSpellAlt.is() && xLG.is())
309  {
310  nGuessLangWord = EditView::CheckLanguage( m_xSpellAlt->getWord(), ::GetSpellChecker(), xLG, false );
311  nGuessLangPara = EditView::CheckLanguage( rParaText, ::GetSpellChecker(), xLG, true );
312  }
313  if (nGuessLangWord != LANGUAGE_NONE || nGuessLangPara != LANGUAGE_NONE)
314  {
315  // make sure LANGUAGE_NONE gets not used as menu entry
316  if (nGuessLangWord == LANGUAGE_NONE)
317  nGuessLangWord = nGuessLangPara;
318  if (nGuessLangPara == LANGUAGE_NONE)
319  nGuessLangPara = nGuessLangWord;
320  }
321 
323  pMenu->SetMenuFlags(MenuFlags::NoAutoMnemonics);
324  uno::Reference< linguistic2::XSearchableDictionaryList > xDicList( LinguMgr::GetDictionaryList() );
325  sal_uInt16 nItemId = MN_DICTIONARIES_START;
326  if (xDicList.is())
327  {
328  // add the default positive dictionary to dic-list (if not already done).
329  // This is to ensure that there is at least one dictionary to which
330  // words could be added.
331  uno::Reference< linguistic2::XDictionary > xDic( LinguMgr::GetStandardDic() );
332  if (xDic.is())
333  xDic->setActive( true );
334 
335  m_aDics = xDicList->getDictionaries();
336 
337  for( const uno::Reference< linguistic2::XDictionary >& rDic : std::as_const(m_aDics) )
338  {
339  uno::Reference< linguistic2::XDictionary > xDicTmp = rDic;
340  if (!xDicTmp.is() || LinguMgr::GetIgnoreAllList() == xDicTmp)
341  continue;
342 
343  uno::Reference< frame::XStorable > xStor( xDicTmp, uno::UNO_QUERY );
344  LanguageType nActLanguage = LanguageTag( xDicTmp->getLocale() ).getLanguageType();
345  if( xDicTmp->isActive()
346  && xDicTmp->getDictionaryType() != linguistic2::DictionaryType_NEGATIVE
347  && (m_nCheckedLanguage == nActLanguage || LANGUAGE_NONE == nActLanguage )
348  && (!xStor.is() || !xStor->isReadonly()) )
349  {
350  // the extra 1 is because of the (possible) external
351  // linguistic entry above
352  pMenu->InsertItem( nItemId, xDicTmp->getName() );
353  m_aDicNameSingle = xDicTmp->getName();
354 
355  if (bUseImagesInMenus)
356  {
357  uno::Reference< lang::XServiceInfo > xSvcInfo( xDicTmp, uno::UNO_QUERY );
358  if (xSvcInfo.is())
359  {
360  OUString aDictionaryImageUrl( aCfg.GetSpellAndGrammarContextDictionaryImage(
361  xSvcInfo->getImplementationName() ) );
362  if (!aDictionaryImageUrl.isEmpty())
363  {
364  Image aImage( aDictionaryImageUrl );
365  pMenu->SetItemImage( nItemId, aImage );
366  }
367  }
368  }
369 
370  ++nItemId;
371  }
372  }
373  }
376 
377  //ADD NEW LANGUAGE MENU ITEM
378 
379  OUString aScriptTypesInUse( OUString::number( static_cast<int>(pWrtSh->GetScriptType()) ) );
380 
381  // get keyboard language
382  OUString aKeyboardLang;
383  SwEditWin& rEditWin = pWrtSh->GetView().GetEditWin();
384  LanguageType nLang = rEditWin.GetInputLanguage();
385  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
386  aKeyboardLang = SvtLanguageTable::GetLanguageString( nLang );
387 
388  // get the language that is in use
389  OUString aCurrentLang("*");
390  nLang = SwLangHelper::GetCurrentLanguage( *pWrtSh );
391  if (nLang != LANGUAGE_DONTKNOW)
392  aCurrentLang = SvtLanguageTable::GetLanguageString( nLang );
393 
394  // build sequence for status value
395  uno::Sequence< OUString > aSeq( 4 );
396  aSeq[0] = aCurrentLang;
397  aSeq[1] = aScriptTypesInUse;
398  aSeq[2] = aKeyboardLang;
399  aSeq[3] = SvtLanguageTable::GetLanguageString(nGuessLangWord);
400 
404 
408 
409  if (bUseImagesInMenus)
411  vcl::CommandInfoProvider::GetImageForCommand(".uno:SpellingAndGrammarDialog", xFrame));
412 
413  checkRedline();
414  m_xPopupMenu->RemoveDisabledEntries( true, true );
415 }
416 
418  SwWrtShell *pWrtSh,
419  const linguistic2::ProofreadingResult &rResult,
420  sal_Int32 nErrorInResult,
421  const uno::Sequence< OUString > &rSuggestions,
422  const OUString &rParaText )
423  : m_aBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "modules/swriter/ui/spellmenu.ui", "")
424  , m_xPopupMenu(m_aBuilder.get_menu("menu"))
425  , m_nIgnoreWordId(m_xPopupMenu->GetItemId("ignoreall"))
426  , m_nAddMenuId(m_xPopupMenu->GetItemId("addmenu"))
427  , m_nAddId(m_xPopupMenu->GetItemId("add"))
428  , m_nSpellDialogId(m_xPopupMenu->GetItemId("spelldialog"))
429  , m_nCorrectMenuId(m_xPopupMenu->GetItemId("correctmenu"))
430  , m_nCorrectDialogId(m_xPopupMenu->GetItemId("correctdialog"))
431  , m_nLangSelectionMenuId(m_xPopupMenu->GetItemId("langselection"))
432  , m_nLangParaMenuId(m_xPopupMenu->GetItemId("langpara"))
433  , m_nRedlineAcceptId(m_xPopupMenu->GetItemId("accept"))
434  , m_nRedlineRejectId(m_xPopupMenu->GetItemId("reject"))
435  , m_nRedlineNextId(m_xPopupMenu->GetItemId("next"))
436  , m_nRedlinePrevId(m_xPopupMenu->GetItemId("prev"))
437  , m_pSh(pWrtSh)
438  , m_xGrammarResult(rResult)
439  , m_aSuggestions(rSuggestions)
440  , m_sExplanationLink()
441  , m_bGrammarResults(true)
442 {
443  m_nCheckedLanguage = LanguageTag::convertToLanguageType( rResult.aLocale );
444  m_nGrammarError = nErrorInResult;
445  bool bUseImagesInMenus = Application::GetSettings().GetStyleSettings().GetUseImagesInMenus();
446 
447  sal_uInt16 nPos = 0;
448  OUString aMessageText( rResult.aErrors[ nErrorInResult ].aShortComment );
449  m_xPopupMenu->InsertSeparator(OString(), nPos++);
450  m_xPopupMenu->InsertItem(MN_SHORT_COMMENT, aMessageText, MenuItemBits::NOSELECT, OString(), nPos++);
451  if (bUseImagesInMenus)
452  m_xPopupMenu->SetItemImage(MN_SHORT_COMMENT, Image(StockImage::Yes, BMP_INFO_16));
453 
454  // Add an item to show detailed infos if the FullCommentURL property is defined
455  const beans::PropertyValues aProperties = rResult.aErrors[ nErrorInResult ].aProperties;
456  for ( const auto& rProp : aProperties )
457  {
458  if ( rProp.Name == "FullCommentURL" )
459  {
460  uno::Any aValue = rProp.Value;
461  aValue >>= m_sExplanationLink;
462 
463  if ( !m_sExplanationLink.isEmpty( ) )
464  break;
465  }
466  }
467 
468  if ( !m_sExplanationLink.isEmpty( ) )
469  {
470  m_xPopupMenu->InsertItem(MN_EXPLANATION_LINK, SwResId(STR_EXPLANATION_LINK), MenuItemBits::TEXT | MenuItemBits::HELP, OString(), nPos++);
471  }
472 
473  m_xPopupMenu->SetMenuFlags(MenuFlags::NoAutoMnemonics);
474 
475  m_xPopupMenu->InsertSeparator(OString(), nPos++);
476  if ( m_aSuggestions.hasElements() ) // suggestions available...
477  {
478  Image aImage;
479  OUString aSuggestionImageUrl;
480 
481  if (bUseImagesInMenus)
482  {
483  uno::Reference< lang::XServiceInfo > xInfo( rResult.xProofreader, uno::UNO_QUERY );
484  if (xInfo.is())
485  {
486  aSuggestionImageUrl = SvtLinguConfig().GetSpellAndGrammarContextSuggestionImage( xInfo->getImplementationName() );
487  aImage = Image( aSuggestionImageUrl );
488  }
489  }
490 
491  sal_uInt16 nItemId = MN_SUGGESTION_START;
492  for (const OUString& aEntry : std::as_const(m_aSuggestions))
493  {
494  m_xPopupMenu->InsertItem(nItemId, aEntry, MenuItemBits::NONE, OString(), nPos++);
496  if (!aSuggestionImageUrl.isEmpty())
497  m_xPopupMenu->SetItemImage(nItemId, aImage);
498 
499  ++nItemId;
500  }
501  m_xPopupMenu->InsertSeparator(OString(), nPos++);
502  }
503 
504  uno::Reference< frame::XFrame > xFrame = pWrtSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface();
505  OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(xFrame));
506 
507  OUString aIgnoreSelection( SwResId( STR_IGNORE_SELECTION ) );
509  vcl::CommandInfoProvider::GetPopupLabelForCommand(".uno:SpellingAndGrammarDialog", aModuleName));
510  sal_uInt16 nItemPos = m_xPopupMenu->GetItemPos(m_nIgnoreWordId);
511  m_xPopupMenu->InsertItem(MN_IGNORE_SELECTION, aIgnoreSelection, MenuItemBits::NONE, OString(), nItemPos);
513 
516 
517  uno::Reference< linguistic2::XLanguageGuessing > xLG = SW_MOD()->GetLanguageGuesser();
518  LanguageType nGuessLangWord = LANGUAGE_NONE;
519  LanguageType nGuessLangPara = LANGUAGE_NONE;
520  if (xLG.is())
521  {
522  nGuessLangPara = EditView::CheckLanguage( rParaText, ::GetSpellChecker(), xLG, true );
523  }
524  if (nGuessLangWord != LANGUAGE_NONE || nGuessLangPara != LANGUAGE_NONE)
525  {
526  // make sure LANGUAGE_NONE gets not used as menu entry
527  if (nGuessLangWord == LANGUAGE_NONE)
528  nGuessLangWord = nGuessLangPara;
529  if (nGuessLangPara == LANGUAGE_NONE)
530  nGuessLangPara = nGuessLangWord;
531  }
532 
535 
536  //ADD NEW LANGUAGE MENU ITEM
537 
538  OUString aScriptTypesInUse( OUString::number( static_cast<int>(pWrtSh->GetScriptType()) ) );
539 
540  // get keyboard language
541  OUString aKeyboardLang;
542  SwEditWin& rEditWin = pWrtSh->GetView().GetEditWin();
543  LanguageType nLang = rEditWin.GetInputLanguage();
544  if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
545  aKeyboardLang = SvtLanguageTable::GetLanguageString( nLang );
546 
547  // get the language that is in use
548  OUString aCurrentLang("*");
549  nLang = SwLangHelper::GetCurrentLanguage( *pWrtSh );
550  if (nLang != LANGUAGE_DONTKNOW)
551  aCurrentLang = SvtLanguageTable::GetLanguageString( nLang );
552 
553  // build sequence for status value
554  uno::Sequence< OUString > aSeq( 4 );
555  aSeq[0] = aCurrentLang;
556  aSeq[1] = aScriptTypesInUse;
557  aSeq[2] = aKeyboardLang;
558  aSeq[3] = SvtLanguageTable::GetLanguageString(nGuessLangWord);
559 
563 
567 
568  if (bUseImagesInMenus)
570  vcl::CommandInfoProvider::GetImageForCommand(".uno:SpellingAndGrammarDialog", xFrame));
571 
572  checkRedline();
573  m_xPopupMenu->RemoveDisabledEntries(true, true);
574 }
575 
577 
579 {
580  // Let SwView::GetState() already has the logic on when to disable the
581  // accept/reject and the next/prev change items, let it do the decision.
582 
583  // Build an item set that contains a void item for each menu entry. The
584  // WhichId of each item is set, so SwView may clear it.
585  static const sal_uInt16 pRedlineIds[] = {
590  };
591  SwDoc *pDoc = m_pSh->GetDoc();
593  for (sal_uInt16 nWhich : pRedlineIds)
594  {
595  aSet.Put(SfxVoidItem(nWhich));
596  }
597  m_pSh->GetView().GetState(aSet);
598 
599  // Enable/disable items based on if the which id of the void items are
600  // cleared or not.
601  for (sal_uInt16 nWhich : pRedlineIds)
602  {
603  sal_uInt16 nId(0);
604  if (nWhich == FN_REDLINE_ACCEPT_DIRECT)
605  nId = m_nRedlineAcceptId;
606  else if (nWhich == FN_REDLINE_REJECT_DIRECT)
607  nId = m_nRedlineRejectId;
608  else if (nWhich == FN_REDLINE_NEXT_CHANGE)
609  nId = m_nRedlineNextId;
610  else if (nWhich == FN_REDLINE_PREV_CHANGE)
611  nId = m_nRedlinePrevId;
612  m_xPopupMenu->EnableItem(nId, aSet.Get(nWhich).Which() != 0);
613  }
614 }
615 
616 void SwSpellPopup::Execute( const tools::Rectangle& rWordPos, vcl::Window* pWin )
617 {
618  sal_uInt16 nRet = m_xPopupMenu->Execute(pWin, pWin->LogicToPixel(rWordPos));
619  Execute( nRet );
620 }
621 
622 void SwSpellPopup::Execute( sal_uInt16 nId )
623 {
624  if (nId == USHRT_MAX)
625  return;
626 
627  if (/*m_bGrammarResults && */nId == MN_SHORT_COMMENT)
628  return; // nothing to do since it is the error message (short comment)
629 
630  if ((MN_SUGGESTION_START <= nId && nId <= MN_SUGGESTION_END) ||
631  (MN_AUTOCORR_START <= nId && nId <= MN_AUTOCORR_END))
632  {
633  sal_Int32 nAltIdx = (MN_SUGGESTION_START <= nId && nId <= MN_SUGGESTION_END) ?
635  OSL_ENSURE(nAltIdx < m_aSuggestions.getLength(), "index out of range");
636  if (nAltIdx < m_aSuggestions.getLength() && (m_bGrammarResults || m_xSpellAlt.is()))
637  {
638  bool bOldIns = m_pSh->IsInsMode();
639  m_pSh->SetInsMode();
640 
641  OUString aTmp( m_aSuggestions[ nAltIdx ] );
642  OUString aOrig( m_bGrammarResults ? OUString() : m_xSpellAlt->getWord() );
643 
644  // if original word has a trailing . (likely the end of a sentence)
645  // and the replacement text hasn't, then add it to the replacement
646  if (!aTmp.isEmpty() && !aOrig.isEmpty() &&
647  aOrig.endsWith(".") && /* !IsAlphaNumeric ??*/
648  !aTmp.endsWith("."))
649  {
650  aTmp += ".";
651  }
652 
653  SwRewriter aRewriter;
654 
655  aRewriter.AddRule(UndoArg1, m_pSh->GetCursorDescr());
656  aRewriter.AddRule(UndoArg2, SwResId(STR_YIELDS));
657 
658  OUString aTmpStr( SwResId(STR_START_QUOTE) );
659  aTmpStr += aTmp;
660  aTmpStr += SwResId(STR_END_QUOTE);
661  aRewriter.AddRule(UndoArg3, aTmpStr);
662 
663  m_pSh->StartUndo(SwUndoId::UI_REPLACE, &aRewriter);
664  m_pSh->StartAction();
665  m_pSh->DelLeft();
666 
667  m_pSh->Insert( aTmp );
668 
669  /* #102505# EndAction/EndUndo moved down since insertion
670  of temporary auto correction is now undoable two and
671  must reside in the same undo group.*/
672 
673  // record only if it's NOT already present in autocorrection
675 
676  OUString aOrigWord( m_bGrammarResults ? OUString() : m_xSpellAlt->getWord() ) ;
677  OUString aNewWord( m_aSuggestions[ nAltIdx ] );
678  SvxPrepareAutoCorrect( aOrigWord, aNewWord );
679 
680  if (MN_AUTOCORR_START <= nId && nId <= MN_AUTOCORR_END)
681  pACorr->PutText( aOrigWord, aNewWord, m_nCheckedLanguage );
682 
683  /* #102505# EndAction/EndUndo moved down since insertion
684  of temporary auto correction is now undoable two and
685  must reside in the same undo group.*/
686  m_pSh->EndAction();
687  m_pSh->EndUndo();
688 
689  m_pSh->SetInsMode( bOldIns );
690  }
691  }
692  else if (nId == m_nSpellDialogId)
693  {
694  if (m_bGrammarResults)
695  {
696  SvtLinguConfig().SetProperty( UPN_IS_GRAMMAR_INTERACTIVE, uno::makeAny( true ));
697  }
698  m_pSh->Left(CRSR_SKIP_CHARS, false, 1, false );
699  {
700  uno::Reference<linguistic2::XSearchableDictionaryList> xDictionaryList( LinguMgr::GetDictionaryList() );
701  SvxDicListChgClamp aClamp( xDictionaryList );
703  Execute( FN_SPELL_GRAMMAR_DIALOG, SfxCallMode::ASYNCHRON );
704  }
705  }
706  else if (nId == m_nCorrectDialogId)
707  {
708  m_pSh->GetView().GetViewFrame()->GetDispatcher()->Execute( SID_AUTO_CORRECT_DLG, SfxCallMode::ASYNCHRON );
709  }
710  else if (nId == MN_IGNORE_SELECTION)
711  {
712  SwPaM *pPaM = m_pSh->GetCursor();
713  if (pPaM)
715  }
716  else if (nId == m_nIgnoreWordId)
717  {
718  uno::Reference< linguistic2::XDictionary > xDictionary = LinguMgr::GetIgnoreAllList();
719  if (m_bGrammarResults) {
720  try
721  {
722  m_xGrammarResult.xProofreader->ignoreRule(
723  m_xGrammarResult.aErrors[ m_nGrammarError ].aRuleIdentifier,
724  m_xGrammarResult.aLocale );
725  // refresh the layout of the actual paragraph (faster)
726  SwPaM *pPaM = m_pSh->GetCursor();
727  if (pPaM)
729  // refresh the layout of all paragraphs (workaround to launch a dictionary event)
730  xDictionary->setActive(false);
731  xDictionary->setActive(true);
732  }
733  catch( const uno::Exception& )
734  {
735  }
736  } else {
737  OUString sWord(m_xSpellAlt->getWord());
739  sWord, false, OUString() );
740  if (linguistic::DictionaryError::NONE != nAddRes && !xDictionary->getEntry(sWord).is())
741  {
742  SvxDicError(m_pSh->GetView().GetFrameWeld(), nAddRes);
743  }
744  }
745  }
746  else if ((MN_DICTIONARIES_START <= nId && nId <= MN_DICTIONARIES_END) || nId == m_nAddId)
747  {
748  OUString sWord( m_xSpellAlt->getWord() );
749  OUString aDicName;
750 
751  if (MN_DICTIONARIES_START <= nId && nId <= MN_DICTIONARIES_END)
752  {
754  aDicName = pMenu->GetItemText(nId);
755  }
756  else
757  aDicName = m_aDicNameSingle;
758 
759  uno::Reference< linguistic2::XDictionary > xDic;
760  uno::Reference< linguistic2::XSearchableDictionaryList > xDicList( LinguMgr::GetDictionaryList() );
761  if (xDicList.is())
762  xDic = xDicList->getDictionaryByName( aDicName );
763 
764  if (xDic.is())
765  {
766  linguistic::DictionaryError nAddRes = linguistic::AddEntryToDic(xDic, sWord, false, OUString());
767  // save modified user-dictionary if it is persistent
768  uno::Reference< frame::XStorable > xSavDic( xDic, uno::UNO_QUERY );
769  if (xSavDic.is())
770  xSavDic->store();
771 
772  if (linguistic::DictionaryError::NONE != nAddRes && !xDic->getEntry(sWord).is())
773  {
774  SvxDicError(m_pSh->GetView().GetFrameWeld(), nAddRes);
775  }
776  }
777  }
778  else if ( nId == MN_EXPLANATION_LINK && !m_sExplanationLink.isEmpty() )
779  {
780  try
781  {
782  uno::Reference< css::system::XSystemShellExecute > xSystemShellExecute(
783  css::system::SystemShellExecute::create( ::comphelper::getProcessComponentContext() ) );
784  xSystemShellExecute->execute( m_sExplanationLink, OUString(),
785  css::system::SystemShellExecuteFlags::URIS_ONLY );
786  }
787  catch (const uno::Exception&)
788  {
790  OUString msg( ::comphelper::anyToString( exc ) );
791  const SolarMutexGuard guard;
792  std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_pSh->GetView().GetFrameWeld(),
793  VclMessageType::Warning, VclButtonsType::Ok, msg));
794  xBox->set_title("Explanations");
795  xBox->run();
796  }
797  }
798  else if (nId == m_nRedlineAcceptId || nId == m_nRedlineRejectId
799  || nId == m_nRedlineNextId || nId == m_nRedlinePrevId)
800  {
801  if (nId == m_nRedlineAcceptId)
803  else if (nId == m_nRedlineRejectId)
805  else if (nId == m_nRedlineNextId)
807  else if (nId == m_nRedlinePrevId)
809  // Let SwView::Execute() handle the redline actions.
810  SfxRequest aReq(m_pSh->GetView().GetViewFrame(), nId);
811  m_pSh->GetView().Execute(aReq);
812  }
813  else
814  {
815  // Set language for selection or for paragraph...
816 
817  SfxItemSet aCoreSet( m_pSh->GetView().GetPool(),
820  RES_CHRATR_CTL_LANGUAGE, RES_CHRATR_CTL_LANGUAGE>{} );
821  OUString aNewLangText;
822 
824  {
825  //Set language for current selection
826  aNewLangText = m_aLangTable_Text[nId];
827  SwLangHelper::SetLanguage( *m_pSh, aNewLangText, true, aCoreSet );
828  }
829  else if (nId == MN_SET_SELECTION_NONE)
830  {
831  //Set Language_None for current selection
832  SwLangHelper::SetLanguage_None( *m_pSh, true, aCoreSet );
833  }
834  else if (nId == MN_SET_SELECTION_RESET)
835  {
836  //reset languages for current selection
838  }
839  else if (nId == MN_SET_SELECTION_MORE)
840  {
841  //Open Format/Character Dialog
842  sw_CharDialog( *m_pSh, true, SID_ATTR_CHAR_FONT, nullptr, nullptr );
843  }
845  {
846  //Set language for current paragraph
847  aNewLangText = m_aLangTable_Paragraph[nId];
848  m_pSh->Push(); // save cursor
850  SwLangHelper::SetLanguage( *m_pSh, aNewLangText, true, aCoreSet );
851  m_pSh->Pop(SwCursorShell::PopMode::DeleteCurrent); // restore cursor
852  }
853  else if (nId == MN_SET_PARA_NONE)
854  {
855  //Set Language_None for current paragraph
856  m_pSh->Push(); // save cursor
858  SwLangHelper::SetLanguage_None( *m_pSh, true, aCoreSet );
859  m_pSh->Pop(SwCursorShell::PopMode::DeleteCurrent); // restore cursor
860  }
861  else if (nId == MN_SET_PARA_RESET)
862  {
863  //reset languages for current paragraph
864  m_pSh->Push(); // save cursor
867  m_pSh->Pop(SwCursorShell::PopMode::DeleteCurrent); // restore cursor
868  }
869  else if (nId == MN_SET_PARA_MORE)
870  {
871  m_pSh->Push(); // save cursor
873  //Open Format/Character Dialog
874  sw_CharDialog( *m_pSh, true, SID_ATTR_CHAR_FONT, nullptr, nullptr );
875  m_pSh->Pop(SwCursorShell::PopMode::DeleteCurrent); // restore cursor
876  }
877  }
878 
879  m_pSh->EnterStdMode();
880 }
881 
882 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxViewFrame * GetViewFrame() const
#define MN_SUGGESTION_START
Definition: olmenu.hxx:46
#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:72
#define RES_CHRATR_CJK_LANGUAGE
Definition: hintids.hxx:92
bool IsInsMode() const
Definition: wrtsh.hxx:163
SwPaM * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:184
sal_uInt16 const m_nLangParaMenuId
Definition: olmenu.hxx:87
#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)
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:102
Reference< XFrame > xFrame
#define MN_DICTIONARIES_END
Definition: olmenu.hxx:43
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
bool Pop(SwCursorShell::PopMode=SwCursorShell::PopMode::DeleteStack)
Definition: wrtsh1.cxx:1721
Definition: doc.hxx:185
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: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:82
#define MN_SHORT_COMMENT
Definition: olmenu.hxx:38
OUString GetCursorDescr() const
Returns textual description of the current selection.
Definition: crsrsh.cxx:3595
sal_uInt16 const m_nRedlineRejectId
Definition: olmenu.hxx:89
#define MN_MAX_NUM_LANG
Definition: olmenu.hxx:54
static LanguageType nLang
Definition: srtdlg.cxx:60
Used by the UI to modify the document model.
Definition: wrtsh.hxx:88
OUString m_sExplanationLink
Definition: olmenu.hxx:100
const SwView & GetView() const
Definition: wrtsh.hxx:426
Reference< XController > xController
Any SAL_CALL getCaughtException()
#define MN_EXPLANATION_LINK
Definition: olmenu.hxx:39
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: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:71
#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:104
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:136
SvtScriptType
void sw_CharDialog(SwWrtShell &rWrtSh, bool bUseDialog, sal_uInt16 nSlot, const SfxItemSet *pArgs, SfxRequest *pReq)
Definition: textsh1.cxx:136
SvtScriptType GetScriptType() const
returns the script type of the selection
Definition: edattr.cxx:671
#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:228
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
css::linguistic2::ProofreadingResult m_xGrammarResult
Definition: olmenu.hxx:96
void Push()
store a copy of the current cursor on the cursor stack
Definition: crsrsh.cxx:2221
SvxAutoCorrect * GetAutoCorrect()
int i
void ResetLanguages(SwWrtShell &rWrtSh, OutlinerView const *pOLV=nullptr)
Definition: langhelper.cxx:365
sal_uInt16 const m_nLangSelectionMenuId
Definition: olmenu.hxx:86
#define FN_REDLINE_PREV_CHANGE
Definition: cmdid.h:141
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:108
void AddRule(SwUndoArg eWhat, const OUString &rWith)
Definition: SwRewriter.cxx:29
Object Value
std::map< sal_Int16, OUString > m_aLangTable_Paragraph
Definition: olmenu.hxx:105
static bool lcl_checkScriptType(SvtScriptType nScriptType, LanguageType nLang)
Definition: olmenu.cxx:105
OUString m_aDicNameSingle
Definition: olmenu.hxx:107
#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:71
void SvxPrepareAutoCorrect(OUString &rOldText, const OUString &rNewText)
VclPtr< PopupMenu > m_xPopupMenu
Definition: olmenu.hxx:79
OUString SwResId(const char *pId)
Definition: swmodule.cxx:191
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:211
OUString GetSpellAndGrammarContextSuggestionImage(const OUString &rServiceImplName) const
#define MN_SET_SELECTION_RESET
Definition: olmenu.hxx:64
#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:671
bool PutText(const OUString &rShort, const OUString &rLong, LanguageType eLang)
#define MN_SUGGESTION_END
Definition: olmenu.hxx:47
sal_Int32 m_nGrammarError
Definition: olmenu.hxx:97
#define FN_SPELL_GRAMMAR_DIALOG
Definition: cmdid.h:583
weld::Window * GetFrameWeld() const
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: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
#define RES_CHRATR_CTL_LANGUAGE
Definition: hintids.hxx:97
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:261
#define FN_REDLINE_NEXT_CHANGE
Definition: cmdid.h:140
#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:110
css::uno::Sequence< OUString > m_aSuggestions
Definition: olmenu.hxx:99
#define HID_LINGU_REPLACE
Definition: helpids.h:63
#define MN_SET_LANGUAGE_PARAGRAPH_START
Definition: olmenu.hxx:68
uno::Reference< linguistic2::XSpellChecker1 > GetSpellChecker()
Definition: swtypes.cxx:45
static void IgnoreGrammarErrorAt(SwPaM &rErrorPosition)
Definition: edlingu.cxx:1680
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()
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: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:578
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:616
sal_Int32 nPos
#define FN_REDLINE_REJECT_DIRECT
Definition: cmdid.h:137
#define MN_RESET_OFFSET
Definition: olmenu.hxx:57
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1308
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)