LibreOffice Module cui (master)  1
optlingu.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 <vcl/field.hxx>
21 #include <vcl/fixed.hxx>
22 #include <vcl/settings.hxx>
23 #include <vcl/weld.hxx>
25 #include <i18nlangtag/mslangid.hxx>
26 #include <unotools/lingucfg.hxx>
27 #include <unotools/linguprops.hxx>
28 #include <editeng/unolingu.hxx>
29 #include <svx/dlgutil.hxx>
30 #include <linguistic/lngprops.hxx>
31 #include <linguistic/misc.hxx>
32 #include <sfx2/sfxuno.hxx>
33 #include <sfx2/dispatch.hxx>
34 #include <sfx2/sfxsids.hrc>
35 #include <tools/urlobj.hxx>
36 #include <tools/diagnose_ex.h>
37 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
39 #include <com/sun/star/linguistic2/LinguServiceManager.hpp>
40 #include <com/sun/star/linguistic2/XSpellChecker.hpp>
41 #include <com/sun/star/linguistic2/XProofreader.hpp>
42 #include <com/sun/star/linguistic2/XHyphenator.hpp>
43 #include <com/sun/star/linguistic2/XThesaurus.hpp>
44 #include <com/sun/star/linguistic2/XAvailableLocales.hpp>
45 #include <com/sun/star/linguistic2/XDictionary.hpp>
46 #include <com/sun/star/linguistic2/XDictionaryList.hpp>
47 #include <com/sun/star/linguistic2/XLinguProperties.hpp>
48 #include <com/sun/star/lang/XServiceDisplayName.hpp>
49 #include <com/sun/star/frame/XStorable.hpp>
50 #include <com/sun/star/ucb/CommandAbortedException.hpp>
52 #include <vcl/svlbitm.hxx>
53 #include <vcl/treelistbox.hxx>
54 #include <vcl/treelistentry.hxx>
55 #include <svtools/langhelp.hxx>
56 #include <svl/eitem.hxx>
57 #include <svl/intitem.hxx>
58 #include <sfx2/viewfrm.hxx>
59 #include <vcl/svapp.hxx>
60 #include <sal/log.hxx>
61 #include <osl/diagnose.h>
62 
63 #include <svx/svxdlg.hxx>
64 #include <editeng/optitems.hxx>
65 #include <optlingu.hxx>
66 #include <dialmgr.hxx>
67 #include <strings.hrc>
68 
69 #include <ucbhelper/content.hxx>
70 
71 #include <vector>
72 #include <map>
73 
74 using namespace ::ucbhelper;
75 using namespace ::com::sun::star;
76 using namespace css::lang;
77 using namespace css::uno;
78 using namespace css::linguistic2;
79 using namespace css::beans;
80 
81 static const sal_Char cSpell[] = SN_SPELLCHECKER;
83 static const sal_Char cHyph[] = SN_HYPHENATOR;
84 static const sal_Char cThes[] = SN_THESAURUS;
85 
86 // static ----------------------------------------------------------------
87 
88 static sal_Int32 lcl_SeqGetEntryPos(
89  const Sequence< OUString > &rSeq, const OUString &rEntry )
90 {
91  sal_Int32 i;
92  sal_Int32 nLen = rSeq.getLength();
93  const OUString *pItem = rSeq.getConstArray();
94  for (i = 0; i < nLen; ++i)
95  {
96  if (rEntry == pItem[i])
97  break;
98  }
99  return i < nLen ? i : -1;
100 }
101 
102 static bool KillFile_Impl( const OUString& rURL )
103 {
104  bool bRet = true;
105  try
106  {
107  Content aCnt( rURL, uno::Reference< css::ucb::XCommandEnvironment >(), comphelper::getProcessComponentContext() );
108  aCnt.executeCommand( "delete", Any( true ) );
109  }
110  catch( ... )
111  {
112  TOOLS_WARN_EXCEPTION( "cui.options", "KillFile" );
113  bRet = false;
114  }
115 
116  return bRet;
117 }
118 
119 // 0x 0p 0t 0c nn
120 // p: 1 -> parent
121 // t: 1 -> spell, 2 -> hyph, 3 -> thes, 4 -> grammar
122 // c: 1 -> checked 0 -> unchecked
123 // n: index
124 
125 #define TYPE_SPELL sal_uInt8(1)
126 #define TYPE_GRAMMAR sal_uInt8(2)
127 #define TYPE_HYPH sal_uInt8(3)
128 #define TYPE_THES sal_uInt8(4)
129 
131 {
132  bool bParent;
136  OUString sImplName;
137 
138 public:
139  ModuleUserData_Impl( const OUString& sImpName, bool bIsParent, bool bChecked, sal_uInt8 nSetType, sal_uInt8 nSetIndex ) :
140  bParent(bIsParent),
141  bIsChecked(bChecked),
142  nType(nSetType),
143  nIndex(nSetIndex),
144  sImplName(sImpName)
145  {
146  }
147  bool IsParent() const {return bParent;}
148  sal_uInt8 GetType() const {return nType;}
149  bool IsChecked() const {return bIsChecked;}
150  sal_uInt8 GetIndex() const {return nIndex;}
151  const OUString& GetImplName() const {return sImplName;}
152 
153 };
154 
155 
156 // User for user-dictionaries (XDictionary interface)
157 
159 {
160  sal_uInt32 nVal;
161 
162 public:
163  explicit DicUserData(sal_uInt32 nUserData) : nVal( nUserData ) {}
164  DicUserData( sal_uInt16 nEID,
165  bool bChecked, bool bEditable, bool bDeletable );
166 
167  sal_uInt32 GetUserData() const { return nVal; }
168  sal_uInt16 GetEntryId() const { return static_cast<sal_uInt16>(nVal >> 16); }
169  bool IsChecked() const { return static_cast<bool>((nVal >> 8) & 0x01); }
170  bool IsDeletable() const { return static_cast<bool>((nVal >> 10) & 0x01); }
171 };
172 
173 
175  sal_uInt16 nEID,
176  bool bChecked, bool bEditable, bool bDeletable )
177 {
178  DBG_ASSERT( nEID < 65000, "Entry Id out of range" );
179  nVal = (static_cast<sal_uInt32>(0xFFFF & nEID) << 16) |
180  (static_cast<sal_uInt32>(bChecked ? 1 : 0) << 8) |
181  (static_cast<sal_uInt32>(bEditable ? 1 : 0) << 9) |
182  (static_cast<sal_uInt32>(bDeletable ? 1 : 0) << 10);
183 }
184 
185 /*--------------------------------------------------
186  Entry IDs for options listbox of dialog
187 --------------------------------------------------*/
188 
190 {
201 };
202 
204 // It is used to get the respective property name.
205 static const char * aEidToPropName[] =
206 {
207  UPN_IS_SPELL_AUTO, // EID_SPELL_AUTO
208  UPN_IS_GRAMMAR_AUTO, // EID_GRAMMAR_AUTO
209  UPN_IS_SPELL_UPPER_CASE, // EID_CAPITAL_WORDS
210  UPN_IS_SPELL_WITH_DIGITS, // EID_WORDS_WITH_DIGITS
211  UPN_IS_SPELL_SPECIAL, // EID_SPELL_SPECIAL
212  UPN_HYPH_MIN_WORD_LENGTH, // EID_NUM_MIN_WORDLEN,
213  UPN_HYPH_MIN_LEADING, // EID_NUM_PRE_BREAK
214  UPN_HYPH_MIN_TRAILING, // EID_NUM_POST_BREAK
215  UPN_IS_HYPH_AUTO, // EID_HYPH_AUTO
216  UPN_IS_HYPH_SPECIAL // EID_HYPH_SPECIAL
217 };
218 
219 static OUString lcl_GetPropertyName( EID_OPTIONS eEntryId )
220 {
221  DBG_ASSERT( static_cast<unsigned int>(eEntryId) < SAL_N_ELEMENTS(aEidToPropName), "index out of range" );
222  return OUString::createFromAscii( aEidToPropName[ static_cast<int>(eEntryId) ] );
223 }
224 
226 {
227  std::unique_ptr<weld::Widget> m_xBeforeFrame;
228  std::unique_ptr<weld::Widget> m_xAfterFrame;
229  std::unique_ptr<weld::Widget> m_xMinimalFrame;
230  std::unique_ptr<weld::SpinButton> m_xBreakNF;
231 
232 public:
233  OptionsBreakSet(weld::Window* pParent, sal_uInt16 nRID)
234  : GenericDialogController(pParent, "cui/ui/breaknumberoption.ui", "BreakNumberOption")
235  , m_xBeforeFrame(m_xBuilder->weld_widget("beforeframe"))
236  , m_xAfterFrame(m_xBuilder->weld_widget("afterframe"))
237  , m_xMinimalFrame(m_xBuilder->weld_widget("miniframe"))
238  {
239  assert(EID_NUM_PRE_BREAK == nRID || EID_NUM_POST_BREAK == nRID || EID_NUM_MIN_WORDLEN == nRID); //unexpected ID
240 
241  if (nRID == EID_NUM_PRE_BREAK)
242  {
243  m_xBeforeFrame->show();
244  m_xBreakNF = m_xBuilder->weld_spin_button("beforebreak");
245  }
246  else if(nRID == EID_NUM_POST_BREAK)
247  {
248  m_xAfterFrame->show();
249  m_xBreakNF = m_xBuilder->weld_spin_button("afterbreak");
250  }
251  else if(nRID == EID_NUM_MIN_WORDLEN)
252  {
253  m_xMinimalFrame->show();
254  m_xBreakNF = m_xBuilder->weld_spin_button("wordlength");
255  }
256  }
257 
259  {
260  return *m_xBreakNF;
261  }
262 };
263 
264 // class OptionsUserData -------------------------------------------------
265 
267 {
268  sal_uInt32 nVal;
269 
270 public:
271  explicit OptionsUserData( sal_uInt32 nUserData ) : nVal( nUserData ) {}
272  OptionsUserData( sal_uInt16 nEID,
273  bool bHasNV, sal_uInt16 nNumVal,
274  bool bCheckable, bool bChecked );
275 
276  sal_uInt32 GetUserData() const { return nVal; }
277  sal_uInt16 GetEntryId() const { return static_cast<sal_uInt16>(nVal >> 16); }
278  bool HasNumericValue() const { return static_cast<bool>((nVal >> 10) & 0x01); }
279  sal_uInt16 GetNumericValue() const { return static_cast<sal_uInt16>(nVal & 0xFF); }
280  bool IsCheckable() const { return static_cast<bool>((nVal >> 9) & 0x01); }
281  bool IsModified() const { return static_cast<bool>((nVal >> 11) & 0x01); }
282 
283  void SetNumericValue( sal_uInt8 nNumVal );
284 };
285 
287  bool bHasNV, sal_uInt16 nNumVal,
288  bool bCheckable, bool bChecked )
289 {
290  DBG_ASSERT( nEID < 65000, "Entry Id out of range" );
291  DBG_ASSERT( nNumVal < 256, "value out of range" );
292  nVal = (static_cast<sal_uInt32>(0xFFFF & nEID) << 16) |
293  (static_cast<sal_uInt32>(bHasNV ? 1 : 0) << 10) |
294  (static_cast<sal_uInt32>(bCheckable ? 1 : 0) << 9) |
295  (static_cast<sal_uInt32>(bChecked ? 1 : 0) << 8) |
296  static_cast<sal_uInt32>(0xFF & nNumVal);
297 }
298 
300 {
301  if (HasNumericValue() && (GetNumericValue() != nNumVal))
302  {
303  nVal &= 0xffffff00;
304  nVal |= nNumVal;
305  nVal |= sal_uInt32(1) << 11; // mark as modified
306  }
307 }
308 
309 // ServiceInfo_Impl ----------------------------------------------------
310 
312 {
313  OUString sDisplayName;
314  OUString sSpellImplName;
315  OUString sHyphImplName;
316  OUString sThesImplName;
318  uno::Reference< XSpellChecker > xSpell;
319  uno::Reference< XHyphenator > xHyph;
320  uno::Reference< XThesaurus > xThes;
321  uno::Reference< XProofreader > xGrammar;
323 
324  ServiceInfo_Impl() : bConfigured(false) {}
325 };
326 
327 typedef std::vector< ServiceInfo_Impl > ServiceInfoArr;
328 typedef std::map< LanguageType, Sequence< OUString > > LangImplNameTable;
329 
330 
331 // SvxLinguData_Impl ----------------------------------------------------
332 
334 {
335  //contains services and implementation names sorted by implementation names
337  sal_uInt32 nDisplayServices;
338 
339  Sequence< Locale > aAllServiceLocales;
344  uno::Reference< XLinguServiceManager2 > xLinguSrvcMgr;
345 
346 
347  static bool AddRemove( Sequence< OUString > &rConfigured,
348  const OUString &rImplName, bool bAdd );
349 
350 public:
352 
353  uno::Reference<XLinguServiceManager2> & GetManager() { return xLinguSrvcMgr; }
354 
355  void SetChecked( const Sequence< OUString > &rConfiguredServices );
356  void Reconfigure( const OUString &rDisplayName, bool bEnable );
357 
358  const Sequence<Locale> & GetAllSupportedLocales() const { return aAllServiceLocales; }
359 
360  LangImplNameTable & GetSpellTable() { return aCfgSpellTable; }
361  LangImplNameTable & GetHyphTable() { return aCfgHyphTable; }
362  LangImplNameTable & GetThesTable() { return aCfgThesTable; }
363  LangImplNameTable & GetGrammarTable() { return aCfgGrammarTable; }
364 
365  ServiceInfoArr & GetDisplayServiceArray() { return aDisplayServiceArr; }
366 
367  const sal_uInt32 & GetDisplayServiceCount() const { return nDisplayServices; }
368  void SetDisplayServiceCount( sal_uInt32 nVal ) { nDisplayServices = nVal; }
369 
370  // returns the list of service implementation names for the specified
371  // language and service (TYPE_SPELL, TYPE_HYPH, TYPE_THES) sorted in
372  // the proper order for the SvxEditModulesDlg (the ones from the
373  // configuration (keeping that order!) first and then the other ones.
374  // I.e. the ones available but not configured in arbitrary order).
375  // They available ones may contain names that do not(!) support that
376  // language.
377  Sequence< OUString > GetSortedImplNames( LanguageType nLang, sal_uInt8 nType );
378 
379  ServiceInfo_Impl * GetInfoByImplName( const OUString &rSvcImplName );
380 };
381 
382 
383 static sal_Int32 lcl_SeqGetIndex( const Sequence< OUString > &rSeq, const OUString &rTxt )
384 {
385  sal_Int32 nRes = -1;
386  sal_Int32 nLen = rSeq.getLength();
387  const OUString *pString = rSeq.getConstArray();
388  for (sal_Int32 i = 0; i < nLen && nRes == -1; ++i)
389  {
390  if (pString[i] == rTxt)
391  nRes = i;
392  }
393  return nRes;
394 }
395 
396 
398 {
399  LangImplNameTable *pTable = nullptr;
400  switch (nType)
401  {
402  case TYPE_SPELL : pTable = &aCfgSpellTable; break;
403  case TYPE_HYPH : pTable = &aCfgHyphTable; break;
404  case TYPE_THES : pTable = &aCfgThesTable; break;
405  case TYPE_GRAMMAR : pTable = &aCfgGrammarTable; break;
406  }
408  if (!pTable)
409  {
410  SAL_WARN( "cui.options", "unknown linguistic type" );
411  return aRes;
412  }
413  if (pTable->count( nLang ))
414  aRes = (*pTable)[ nLang ]; // add configured services
415  sal_Int32 nIdx = aRes.getLength();
416  DBG_ASSERT( static_cast<sal_Int32>(nDisplayServices) >= nIdx, "size mismatch" );
417  aRes.realloc( nDisplayServices );
418  OUString *pRes = aRes.getArray();
419 
420  // add not configured services
421  for (sal_Int32 i = 0; i < static_cast<sal_Int32>(nDisplayServices); ++i)
422  {
423  const ServiceInfo_Impl &rInfo = aDisplayServiceArr[ i ];
424  OUString aImplName;
425  switch (nType)
426  {
427  case TYPE_SPELL : aImplName = rInfo.sSpellImplName; break;
428  case TYPE_HYPH : aImplName = rInfo.sHyphImplName; break;
429  case TYPE_THES : aImplName = rInfo.sThesImplName; break;
430  case TYPE_GRAMMAR : aImplName = rInfo.sGrammarImplName; break;
431  }
432 
433  if (!aImplName.isEmpty() && (lcl_SeqGetIndex( aRes, aImplName) == -1)) // name not yet added
434  {
435  DBG_ASSERT( nIdx < aRes.getLength(), "index out of range" );
436  if (nIdx < aRes.getLength())
437  pRes[ nIdx++ ] = aImplName;
438  }
439  }
440  // don't forget to put aRes back to its actual size just in case you allocated too much
441  // since all of the names may have already been added
442  // otherwise you get duplicate entries in the edit dialog
443  aRes.realloc( nIdx );
444  return aRes;
445 }
446 
447 
449 {
450  for (sal_uInt32 i = 0; i < nDisplayServices; ++i)
451  {
452  ServiceInfo_Impl &rTmp = aDisplayServiceArr[ i ];
453  if (rTmp.sSpellImplName == rSvcImplName ||
454  rTmp.sHyphImplName == rSvcImplName ||
455  rTmp.sThesImplName == rSvcImplName ||
456  rTmp.sGrammarImplName == rSvcImplName)
457  {
458  return &rTmp;
459  }
460  }
461  return nullptr;
462 }
463 
464 
465 static void lcl_MergeLocales(Sequence< Locale >& aAllLocales, const Sequence< Locale >& rAdd)
466 {
467  const Locale* pAdd = rAdd.getConstArray();
468  Sequence<Locale> aLocToAdd(rAdd.getLength());
469  const Locale* pAllLocales = aAllLocales.getConstArray();
470  Locale* pLocToAdd = aLocToAdd.getArray();
471  sal_Int32 nFound = 0;
472  sal_Int32 i;
473  for(i = 0; i < rAdd.getLength(); i++)
474  {
475  bool bFound = false;
476  for(sal_Int32 j = 0; j < aAllLocales.getLength() && !bFound; j++)
477  {
478  bFound = pAdd[i].Language == pAllLocales[j].Language &&
479  pAdd[i].Country == pAllLocales[j].Country &&
480  pAdd[i].Variant == pAllLocales[j].Variant;
481  }
482  if(!bFound)
483  {
484  pLocToAdd[nFound++] = pAdd[i];
485  }
486  }
487  sal_Int32 nLength = aAllLocales.getLength();
488  aAllLocales.realloc( nLength + nFound);
489  Locale* pAllLocales2 = aAllLocales.getArray();
490  for(i = 0; i < nFound; i++)
491  pAllLocales2[nLength++] = pLocToAdd[i];
492 }
493 
495  SvxLinguData_Impl &rData,
496  const ServiceInfo_Impl &rToAdd )
497 {
498  sal_uInt32 nCnt = 0;
499 
500  ServiceInfoArr &rSvcInfoArr = rData.GetDisplayServiceArray();
501  sal_uInt32 nEntries = rData.GetDisplayServiceCount();
502 
503  for (sal_uInt32 i = 0; i < nEntries; ++i)
504  {
505  ServiceInfo_Impl& rEntry = rSvcInfoArr[i];
506  if (rEntry.sDisplayName == rToAdd.sDisplayName)
507  {
508  if(rToAdd.xSpell.is())
509  {
510  DBG_ASSERT( !rEntry.xSpell.is() &&
511  rEntry.sSpellImplName.isEmpty(),
512  "merge conflict" );
513  rEntry.sSpellImplName = rToAdd.sSpellImplName;
514  rEntry.xSpell = rToAdd.xSpell;
515  }
516  if(rToAdd.xGrammar.is())
517  {
518  DBG_ASSERT( !rEntry.xGrammar.is() &&
519  rEntry.sGrammarImplName.isEmpty(),
520  "merge conflict" );
521  rEntry.sGrammarImplName = rToAdd.sGrammarImplName;
522  rEntry.xGrammar = rToAdd.xGrammar;
523  }
524  if(rToAdd.xHyph.is())
525  {
526  DBG_ASSERT( !rEntry.xHyph.is() &&
527  rEntry.sHyphImplName.isEmpty(),
528  "merge conflict" );
529  rEntry.sHyphImplName = rToAdd.sHyphImplName;
530  rEntry.xHyph = rToAdd.xHyph;
531  }
532  if(rToAdd.xThes.is())
533  {
534  DBG_ASSERT( !rEntry.xThes.is() &&
535  rEntry.sThesImplName.isEmpty(),
536  "merge conflict" );
537  rEntry.sThesImplName = rToAdd.sThesImplName;
538  rEntry.xThes = rToAdd.xThes;
539  }
540  return ;
541  }
542  ++nCnt;
543  }
544  rData.GetDisplayServiceArray().push_back( rToAdd );
545  rData.SetDisplayServiceCount( nCnt + 1 );
546 }
547 
549  nDisplayServices (0)
550 {
551  uno::Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext();
552  xLinguSrvcMgr = LinguServiceManager::create(xContext);
553 
554  const Locale& rCurrentLocale = Application::GetSettings().GetLanguageTag().getLocale();
555  Sequence<Any> aArgs(2);//second arguments has to be empty!
556  aArgs.getArray()[0] <<= LinguMgr::GetLinguPropertySet();
557 
558  //read spell checker
559  Sequence< OUString > aSpellNames = xLinguSrvcMgr->getAvailableServices(
560  cSpell, Locale() );
561  const OUString* pSpellNames = aSpellNames.getConstArray();
562 
563  sal_Int32 nIdx;
564  for(nIdx = 0; nIdx < aSpellNames.getLength(); nIdx++)
565  {
566  ServiceInfo_Impl aInfo;
567  aInfo.sSpellImplName = pSpellNames[nIdx];
568  aInfo.xSpell.set(
569  xContext->getServiceManager()->createInstanceWithArgumentsAndContext(aInfo.sSpellImplName, aArgs, xContext), UNO_QUERY);
570 
571  uno::Reference<XServiceDisplayName> xDispName(aInfo.xSpell, UNO_QUERY);
572  if(xDispName.is())
573  aInfo.sDisplayName = xDispName->getServiceDisplayName( rCurrentLocale );
574 
575  const Sequence< Locale > aLocales( aInfo.xSpell->getLocales() );
577  if (aLocales.hasElements())
578  {
580  lcl_MergeDisplayArray( *this, aInfo );
581  }
582  }
583 
584  //read grammar checker
585  Sequence< OUString > aGrammarNames = xLinguSrvcMgr->getAvailableServices(
586  cGrammar, Locale() );
587  const OUString* pGrammarNames = aGrammarNames.getConstArray();
588  for(nIdx = 0; nIdx < aGrammarNames.getLength(); nIdx++)
589  {
590  ServiceInfo_Impl aInfo;
591  aInfo.sGrammarImplName = pGrammarNames[nIdx];
592  aInfo.xGrammar.set(
593  xContext->getServiceManager()->createInstanceWithArgumentsAndContext(aInfo.sGrammarImplName, aArgs, xContext), UNO_QUERY);
594 
595  uno::Reference<XServiceDisplayName> xDispName(aInfo.xGrammar, UNO_QUERY);
596  if(xDispName.is())
597  aInfo.sDisplayName = xDispName->getServiceDisplayName( rCurrentLocale );
598 
599  const Sequence< Locale > aLocales( aInfo.xGrammar->getLocales() );
601  if (aLocales.hasElements())
602  {
604  lcl_MergeDisplayArray( *this, aInfo );
605  }
606  }
607 
608  //read hyphenator
609  Sequence< OUString > aHyphNames = xLinguSrvcMgr->getAvailableServices(
610  cHyph, Locale() );
611  const OUString* pHyphNames = aHyphNames.getConstArray();
612  for(nIdx = 0; nIdx < aHyphNames.getLength(); nIdx++)
613  {
614  ServiceInfo_Impl aInfo;
615  aInfo.sHyphImplName = pHyphNames[nIdx];
616  aInfo.xHyph.set( xContext->getServiceManager()->createInstanceWithArgumentsAndContext(aInfo.sHyphImplName, aArgs, xContext), UNO_QUERY);
617 
618  uno::Reference<XServiceDisplayName> xDispName(aInfo.xHyph, UNO_QUERY);
619  if(xDispName.is())
620  aInfo.sDisplayName = xDispName->getServiceDisplayName( rCurrentLocale );
621 
622  const Sequence< Locale > aLocales( aInfo.xHyph->getLocales() );
624  if (aLocales.hasElements())
625  {
627  lcl_MergeDisplayArray( *this, aInfo );
628  }
629  }
630 
631  //read thesauri
632  Sequence< OUString > aThesNames = xLinguSrvcMgr->getAvailableServices(
633  cThes, Locale() );
634  const OUString* pThesNames = aThesNames.getConstArray();
635  for(nIdx = 0; nIdx < aThesNames.getLength(); nIdx++)
636  {
637  ServiceInfo_Impl aInfo;
638  aInfo.sThesImplName = pThesNames[nIdx];
639  aInfo.xThes.set( xContext->getServiceManager()->createInstanceWithArgumentsAndContext(aInfo.sThesImplName, aArgs, xContext), UNO_QUERY);
640 
641  uno::Reference<XServiceDisplayName> xDispName(aInfo.xThes, UNO_QUERY);
642  if(xDispName.is())
643  aInfo.sDisplayName = xDispName->getServiceDisplayName( rCurrentLocale );
644 
645  const Sequence< Locale > aLocales( aInfo.xThes->getLocales() );
647  if (aLocales.hasElements())
648  {
650  lcl_MergeDisplayArray( *this, aInfo );
651  }
652  }
653 
654  Sequence< OUString > aCfgSvcs;
655  const Locale* pAllLocales = aAllServiceLocales.getConstArray();
656  for(sal_Int32 nLocale = 0; nLocale < aAllServiceLocales.getLength(); nLocale++)
657  {
658  LanguageType nLang = LanguageTag::convertToLanguageType( pAllLocales[nLocale] );
659 
660  aCfgSvcs = xLinguSrvcMgr->getConfiguredServices(cSpell, pAllLocales[nLocale]);
661  SetChecked( aCfgSvcs );
662  if (aCfgSvcs.hasElements())
663  aCfgSpellTable[ nLang ] = aCfgSvcs;
664 
665  aCfgSvcs = xLinguSrvcMgr->getConfiguredServices(cGrammar, pAllLocales[nLocale]);
666  SetChecked( aCfgSvcs );
667  if (aCfgSvcs.hasElements())
668  aCfgGrammarTable[ nLang ] = aCfgSvcs;
669 
670  aCfgSvcs = xLinguSrvcMgr->getConfiguredServices(cHyph, pAllLocales[nLocale]);
671  SetChecked( aCfgSvcs );
672  if (aCfgSvcs.hasElements())
673  aCfgHyphTable[ nLang ] = aCfgSvcs;
674 
675  aCfgSvcs = xLinguSrvcMgr->getConfiguredServices(cThes, pAllLocales[nLocale]);
676  SetChecked( aCfgSvcs );
677  if (aCfgSvcs.hasElements())
678  aCfgThesTable[ nLang ] = aCfgSvcs;
679  }
680 }
681 
682 void SvxLinguData_Impl::SetChecked(const Sequence<OUString>& rConfiguredServices)
683 {
684  const OUString* pConfiguredServices = rConfiguredServices.getConstArray();
685  for(sal_Int32 n = 0; n < rConfiguredServices.getLength(); n++)
686  {
687  for (sal_uInt32 i = 0; i < nDisplayServices; ++i)
688  {
690  if (!rEntry.bConfigured)
691  {
692  const OUString &rSrvcImplName = pConfiguredServices[n];
693  if (!rSrvcImplName.isEmpty() &&
694  (rEntry.sSpellImplName == rSrvcImplName ||
695  rEntry.sGrammarImplName == rSrvcImplName ||
696  rEntry.sHyphImplName == rSrvcImplName ||
697  rEntry.sThesImplName == rSrvcImplName))
698  {
699  rEntry.bConfigured = true;
700  break;
701  }
702  }
703  }
704  }
705 }
706 
708  Sequence< OUString > &rConfigured,
709  const OUString &rImplName, bool bAdd )
710 {
711  bool bRet = false; // modified?
712 
713  sal_Int32 nEntries = rConfigured.getLength();
714  sal_Int32 nPos = lcl_SeqGetEntryPos(rConfigured, rImplName);
715  if (bAdd && nPos < 0) // add new entry
716  {
717  rConfigured.realloc( ++nEntries );
718  OUString *pConfigured = rConfigured.getArray();
719  pConfigured[nEntries - 1] = rImplName;
720  bRet = true;
721  }
722  else if (!bAdd && nPos >= 0) // remove existing entry
723  {
724  OUString *pConfigured = rConfigured.getArray();
725  for (sal_Int32 i = nPos; i < nEntries - 1; ++i)
726  pConfigured[i] = pConfigured[i + 1];
727  rConfigured.realloc(--nEntries);
728  bRet = true;
729  }
730 
731  return bRet;
732 }
733 
734 
735 void SvxLinguData_Impl::Reconfigure( const OUString &rDisplayName, bool bEnable )
736 {
737  DBG_ASSERT( !rDisplayName.isEmpty(), "empty DisplayName" );
738 
739  ServiceInfo_Impl *pInfo = nullptr;
740  for (sal_uInt32 i = 0; i < nDisplayServices; ++i)
741  {
743  if (rTmp.sDisplayName == rDisplayName)
744  {
745  pInfo = &rTmp;
746  break;
747  }
748  }
749  DBG_ASSERT( pInfo, "DisplayName entry not found" );
750  if (pInfo)
751  {
752  pInfo->bConfigured = bEnable;
753 
754  Sequence< Locale > aLocales;
755  const Locale *pLocale = nullptr;
756  sal_Int32 nLocales = 0;
757  sal_Int32 i;
758 
759  // update configured spellchecker entries
760  if (pInfo->xSpell.is())
761  {
762  aLocales = pInfo->xSpell->getLocales();
763  pLocale = aLocales.getConstArray();
764  nLocales = aLocales.getLength();
765  for (i = 0; i < nLocales; ++i)
766  {
767  LanguageType nLang = LanguageTag::convertToLanguageType( pLocale[i] );
768  if (!aCfgSpellTable.count( nLang ) && bEnable)
770  if (aCfgSpellTable.count( nLang ))
771  AddRemove( aCfgSpellTable[ nLang ], pInfo->sSpellImplName, bEnable );
772  }
773  }
774 
775  // update configured grammar checker entries
776  if (pInfo->xGrammar.is())
777  {
778  aLocales = pInfo->xGrammar->getLocales();
779  pLocale = aLocales.getConstArray();
780  nLocales = aLocales.getLength();
781  for (i = 0; i < nLocales; ++i)
782  {
783  LanguageType nLang = LanguageTag::convertToLanguageType( pLocale[i] );
784  if (!aCfgGrammarTable.count( nLang ) && bEnable)
786  if (aCfgGrammarTable.count( nLang ))
787  AddRemove( aCfgGrammarTable[ nLang ], pInfo->sGrammarImplName, bEnable );
788  }
789  }
790 
791  // update configured hyphenator entries
792  if (pInfo->xHyph.is())
793  {
794  aLocales = pInfo->xHyph->getLocales();
795  pLocale = aLocales.getConstArray();
796  nLocales = aLocales.getLength();
797  for (i = 0; i < nLocales; ++i)
798  {
799  LanguageType nLang = LanguageTag::convertToLanguageType( pLocale[i] );
800  if (!aCfgHyphTable.count( nLang ) && bEnable)
801  aCfgHyphTable[ nLang ] = Sequence< OUString >();
802  if (aCfgHyphTable.count( nLang ))
803  AddRemove( aCfgHyphTable[ nLang ], pInfo->sHyphImplName, bEnable );
804  }
805  }
806 
807  // update configured spellchecker entries
808  if (pInfo->xThes.is())
809  {
810  aLocales = pInfo->xThes->getLocales();
811  pLocale = aLocales.getConstArray();
812  nLocales = aLocales.getLength();
813  for (i = 0; i < nLocales; ++i)
814  {
815  LanguageType nLang = LanguageTag::convertToLanguageType( pLocale[i] );
816  if (!aCfgThesTable.count( nLang ) && bEnable)
817  aCfgThesTable[ nLang ] = Sequence< OUString >();
818  if (aCfgThesTable.count( nLang ))
819  AddRemove( aCfgThesTable[ nLang ], pInfo->sThesImplName, bEnable );
820  }
821  }
822  }
823 }
824 
825 
826 // class SvxLinguTabPage -------------------------------------------------
827 
829  : SfxTabPage(pParent, "cui/ui/optlingupage.ui", "OptLinguPage", &rSet)
830  , sCapitalWords (CuiResId(RID_SVXSTR_CAPITAL_WORDS))
831  , sWordsWithDigits(CuiResId(RID_SVXSTR_WORDS_WITH_DIGITS))
832  , sSpellSpecial (CuiResId(RID_SVXSTR_SPELL_SPECIAL))
833  , sSpellAuto (CuiResId(RID_SVXSTR_SPELL_AUTO))
834  , sGrammarAuto (CuiResId(RID_SVXSTR_GRAMMAR_AUTO))
835  , sNumMinWordlen (CuiResId(RID_SVXSTR_NUM_MIN_WORDLEN))
836  , sNumPreBreak (CuiResId(RID_SVXSTR_NUM_PRE_BREAK))
837  , sNumPostBreak (CuiResId(RID_SVXSTR_NUM_POST_BREAK))
838  , sHyphAuto (CuiResId(RID_SVXSTR_HYPH_AUTO))
839  , sHyphSpecial (CuiResId(RID_SVXSTR_HYPH_SPECIAL))
840  , nUPN_HYPH_MIN_WORD_LENGTH(-1)
841  , nUPN_HYPH_MIN_LEADING(-1)
842  , nUPN_HYPH_MIN_TRAILING(-1)
843  , m_xLinguModulesFT(m_xBuilder->weld_label("lingumodulesft"))
844  , m_xLinguModulesCLB(m_xBuilder->weld_tree_view("lingumodules"))
845  , m_xLinguModulesEditPB(m_xBuilder->weld_button("lingumodulesedit"))
846  , m_xLinguDicsFT(m_xBuilder->weld_label("lingudictsft"))
847  , m_xLinguDicsCLB(m_xBuilder->weld_tree_view("lingudicts"))
848  , m_xLinguDicsNewPB(m_xBuilder->weld_button("lingudictsnew"))
849  , m_xLinguDicsEditPB(m_xBuilder->weld_button("lingudictsedit"))
850  , m_xLinguDicsDelPB(m_xBuilder->weld_button("lingudictsdelete"))
851  , m_xLinguOptionsCLB(m_xBuilder->weld_tree_view("linguoptions"))
852  , m_xLinguOptionsEditPB(m_xBuilder->weld_button("linguoptionsedit"))
853  , m_xMoreDictsLink(m_xBuilder->weld_link_button("moredictslink"))
854 {
855  std::vector<int> aWidths;
856  aWidths.push_back(m_xLinguModulesCLB->get_checkbox_column_width());
857 
858  m_xLinguModulesCLB->set_column_fixed_widths(aWidths);
859  m_xLinguDicsCLB->set_column_fixed_widths(aWidths);
860  m_xLinguOptionsCLB->set_column_fixed_widths(aWidths);
861 
862  m_xLinguModulesCLB->connect_changed( LINK( this, SvxLinguTabPage, SelectHdl_Impl ));
863  m_xLinguModulesCLB->connect_row_activated(LINK(this, SvxLinguTabPage, BoxDoubleClickHdl_Impl));
864  m_xLinguModulesCLB->connect_toggled(LINK(this, SvxLinguTabPage, ModulesBoxCheckButtonHdl_Impl));
865 
866  m_xLinguModulesEditPB->connect_clicked( LINK( this, SvxLinguTabPage, ClickHdl_Impl ));
867  m_xLinguOptionsEditPB->connect_clicked( LINK( this, SvxLinguTabPage, ClickHdl_Impl ));
868 
869  m_xLinguDicsCLB->connect_changed( LINK( this, SvxLinguTabPage, SelectHdl_Impl ));
870  m_xLinguDicsCLB->connect_toggled(LINK(this, SvxLinguTabPage, DicsBoxCheckButtonHdl_Impl));
871 
872  m_xLinguDicsNewPB->connect_clicked( LINK( this, SvxLinguTabPage, ClickHdl_Impl ));
873  m_xLinguDicsEditPB->connect_clicked( LINK( this, SvxLinguTabPage, ClickHdl_Impl ));
874  m_xLinguDicsDelPB->connect_clicked( LINK( this, SvxLinguTabPage, ClickHdl_Impl ));
875 
876  m_xLinguOptionsCLB->connect_changed( LINK( this, SvxLinguTabPage, SelectHdl_Impl ));
877  m_xLinguOptionsCLB->connect_row_activated(LINK(this, SvxLinguTabPage, BoxDoubleClickHdl_Impl));
878 
879  if ( SvtExtendedSecurityOptions().GetOpenHyperlinkMode() == SvtExtendedSecurityOptions::OPEN_NEVER )
880  m_xMoreDictsLink->hide();
881 
883  xDicList.set( LinguMgr::GetDictionaryList(), UNO_QUERY );
884  if (xDicList.is())
885  {
886  // keep references to all **currently** available dictionaries,
887  // since the diclist may get changed meanwhile (e.g. through the API).
888  // We want the dialog to operate on the same set of dictionaries it
889  // was started with.
890  // Also we have to take care to not lose the last reference when
891  // someone else removes a dictionary from the list.
892  // removed dics will be replaced by NULL new entries be added to the end
893  // Thus we may use indices as consistent references.
894  aDics = xDicList->getDictionaries();
895 
897  }
898  else
899  {
900  m_xLinguDicsFT->set_sensitive(false);
901  m_xLinguDicsCLB->set_sensitive(false);
902  m_xLinguDicsNewPB->set_sensitive(false);
903  m_xLinguDicsEditPB->set_sensitive(false);
904  m_xLinguDicsDelPB->set_sensitive(false);
905  }
906 }
907 
909 {
910  disposeOnce();
911 }
912 
914 {
915  pLinguData.reset();
917 }
918 
920  const SfxItemSet* rAttrSet )
921 {
922  return VclPtr<SvxLinguTabPage>::Create( pParent, *rAttrSet );
923 }
924 
926 {
927  bool bModified = true; // !!!!
928 
929  // if not HideGroups was called with GROUP_MODULES...
930  if (m_xLinguModulesCLB->get_visible())
931  {
932  DBG_ASSERT( pLinguData, "pLinguData not yet initialized" );
933  if (!pLinguData)
934  pLinguData.reset( new SvxLinguData_Impl );
935 
936  // update spellchecker configuration entries
937  const LangImplNameTable *pTable = &pLinguData->GetSpellTable();
938  for (auto const& elem : *pTable)
939  {
940  LanguageType nLang = elem.first;
941  const Sequence< OUString > aImplNames(elem.second);
942  uno::Reference< XLinguServiceManager2 > xMgr( pLinguData->GetManager() );
943  Locale aLocale( LanguageTag::convertToLocale(nLang) );
944  if (xMgr.is())
945  xMgr->setConfiguredServices( cSpell, aLocale, aImplNames );
946  }
947 
948  // update grammar checker configuration entries
949  pTable = &pLinguData->GetGrammarTable();
950  for (auto const& elem : *pTable)
951  {
952  LanguageType nLang = elem.first;
953  const Sequence< OUString > aImplNames(elem.second);
954  uno::Reference< XLinguServiceManager2 > xMgr( pLinguData->GetManager() );
955  Locale aLocale( LanguageTag::convertToLocale(nLang) );
956  if (xMgr.is())
957  xMgr->setConfiguredServices( cGrammar, aLocale, aImplNames );
958  }
959 
960  // update hyphenator configuration entries
961  pTable = &pLinguData->GetHyphTable();
962  for (auto const& elem : *pTable)
963  {
964  LanguageType nLang = elem.first;
965  const Sequence< OUString > aImplNames(elem.second);
966  uno::Reference< XLinguServiceManager2 > xMgr( pLinguData->GetManager() );
967  Locale aLocale( LanguageTag::convertToLocale(nLang) );
968  if (xMgr.is())
969  xMgr->setConfiguredServices( cHyph, aLocale, aImplNames );
970  }
971 
972  // update thesaurus configuration entries
973  pTable = &pLinguData->GetThesTable();
974  for (auto const& elem : *pTable)
975  {
976  LanguageType nLang = elem.first;
977  const Sequence< OUString > aImplNames(elem.second);
978  uno::Reference< XLinguServiceManager2 > xMgr( pLinguData->GetManager() );
979  Locale aLocale( LanguageTag::convertToLocale(nLang) );
980  if (xMgr.is())
981  xMgr->setConfiguredServices( cThes, aLocale, aImplNames );
982  }
983  }
984 
985 
986  // activate dictionaries according to checkbox state
987 
988  Sequence< OUString > aActiveDics;
989  sal_Int32 nActiveDics = 0;
990  int nEntries = m_xLinguDicsCLB->n_children();
991  for (int i = 0; i < nEntries; ++i)
992  {
993  sal_Int32 nDics = aDics.getLength();
994 
995  aActiveDics.realloc( nDics );
996  OUString *pActiveDic = aActiveDics.getArray();
997 
998  DicUserData aData(m_xLinguDicsCLB->get_id(i).toUInt32());
999  if (aData.GetEntryId() < nDics)
1000  {
1001  bool bChecked = m_xLinguDicsCLB->get_toggle(i, 0) == TRISTATE_TRUE;
1002  uno::Reference< XDictionary > xDic( aDics.getConstArray()[ i ] );
1003  if (xDic.is())
1004  {
1005  if (LinguMgr::GetIgnoreAllList() == xDic)
1006  bChecked = true;
1007  xDic->setActive( bChecked );
1008 
1009  if (bChecked)
1010  {
1011  OUString aDicName( xDic->getName() );
1012  pActiveDic[ nActiveDics++ ] = aDicName;
1013  }
1014  }
1015  }
1016  }
1017 
1018  aActiveDics.realloc( nActiveDics );
1019  Any aTmp;
1020  aTmp <<= aActiveDics;
1021  SvtLinguConfig aLngCfg;
1022  aLngCfg.SetProperty( UPH_ACTIVE_DICTIONARIES, aTmp );
1023 
1024 
1025  nEntries = m_xLinguOptionsCLB->n_children();
1026  for (int j = 0; j < nEntries; ++j)
1027  {
1028  OptionsUserData aData(m_xLinguOptionsCLB->get_id(j).toUInt32());
1029  OUString aPropName( lcl_GetPropertyName( static_cast<EID_OPTIONS>(aData.GetEntryId()) ) );
1030 
1031  Any aAny;
1032  if (aData.IsCheckable())
1033  {
1034  bool bChecked = m_xLinguOptionsCLB->get_toggle(j, 0) == TRISTATE_TRUE;
1035  aAny <<= bChecked;
1036  }
1037  else if (aData.HasNumericValue())
1038  {
1039  sal_Int16 nVal = aData.GetNumericValue();
1040  aAny <<= nVal;
1041  }
1042 
1043  if (xProp.is())
1044  xProp->setPropertyValue( aPropName, aAny );
1045  aLngCfg.SetProperty( aPropName, aAny );
1046  }
1047 
1048  OptionsUserData aPreBreakData(m_xLinguOptionsCLB->get_id(EID_NUM_PRE_BREAK).toUInt32());
1049  OptionsUserData aPostBreakData(m_xLinguOptionsCLB->get_id(EID_NUM_POST_BREAK).toUInt32());
1050  if ( aPreBreakData.IsModified() || aPostBreakData.IsModified() )
1051  {
1052  SfxHyphenRegionItem aHyp( GetWhich( SID_ATTR_HYPHENREGION ) );
1053  aHyp.GetMinLead() = static_cast<sal_uInt8>(aPreBreakData.GetNumericValue());
1054  aHyp.GetMinTrail() = static_cast<sal_uInt8>(aPostBreakData.GetNumericValue());
1055  rCoreSet->Put( aHyp );
1056  }
1057 
1058  // automatic spell checking
1059  bool bNewAutoCheck = m_xLinguOptionsCLB->get_toggle(EID_SPELL_AUTO, 0) == TRISTATE_TRUE;
1060  const SfxPoolItem* pOld = GetOldItem( *rCoreSet, SID_AUTOSPELL_CHECK );
1061  if ( !pOld || static_cast<const SfxBoolItem*>(pOld)->GetValue() != bNewAutoCheck )
1062  {
1063  rCoreSet->Put( SfxBoolItem( GetWhich( SID_AUTOSPELL_CHECK ),
1064  bNewAutoCheck ) );
1065  bModified = true;
1066  }
1067 
1068  return bModified;
1069 }
1070 
1071 sal_uInt32 SvxLinguTabPage::GetDicUserData( const uno::Reference< XDictionary > &rxDic, sal_uInt16 nIdx )
1072 {
1073  sal_uInt32 nRes = 0;
1074  DBG_ASSERT( rxDic.is(), "dictionary not supplied" );
1075  if (rxDic.is())
1076  {
1077  uno::Reference< frame::XStorable > xStor( rxDic, UNO_QUERY );
1078 
1079  bool bChecked = rxDic->isActive();
1080  bool bEditable = !xStor.is() || !xStor->isReadonly();
1081  bool bDeletable = bEditable;
1082 
1083  nRes = DicUserData( nIdx,
1084  bChecked, bEditable, bDeletable ).GetUserData();
1085  }
1086  return nRes;
1087 }
1088 
1089 
1091  const uno::Reference< XDictionary > &rxDic,
1092  sal_uInt16 nIdx )
1093 {
1094  m_xLinguDicsCLB->freeze();
1095 
1096  OUString aTxt( ::GetDicInfoStr( rxDic->getName(),
1097  LanguageTag( rxDic->getLocale() ).getLanguageType(),
1098  DictionaryType_NEGATIVE == rxDic->getDictionaryType() ) );
1099  m_xLinguDicsCLB->append(); // append at end
1100  int nEntry = m_xLinguDicsCLB->n_children() - 1;
1101  DicUserData aData( GetDicUserData( rxDic, nIdx ) );
1102  m_xLinguDicsCLB->set_id(nEntry, OUString::number(aData.GetUserData()));
1103  m_xLinguDicsCLB->set_toggle(nEntry, aData.IsChecked() ? TRISTATE_TRUE : TRISTATE_FALSE, 0);
1104  m_xLinguDicsCLB->set_text(nEntry, aTxt, 1); // append at end
1105 
1106  m_xLinguDicsCLB->thaw();
1107 }
1108 
1110 {
1111  m_xLinguDicsCLB->freeze();
1112  m_xLinguDicsCLB->clear();
1113 
1114  sal_Int32 nDics = aDics.getLength();
1115  const uno::Reference< XDictionary > *pDic = aDics.getConstArray();
1116  for (sal_Int32 i = 0; i < nDics; ++i)
1117  {
1118  const uno::Reference< XDictionary > &rDic = pDic[i];
1119  if (rDic.is())
1120  AddDicBoxEntry( rDic, static_cast<sal_uInt16>(i) );
1121  }
1122 
1123  m_xLinguDicsCLB->thaw();
1124  if (m_xLinguDicsCLB->n_children())
1125  {
1126  m_xLinguDicsCLB->select(0);
1127  SelectHdl_Impl(*m_xLinguDicsCLB);
1128  }
1129 }
1130 
1132 {
1133  if (pLinguData)
1134  {
1135  const ServiceInfoArr &rAllDispSrvcArr = pLinguData->GetDisplayServiceArray();
1136  const sal_uInt32 nDispSrvcCount = pLinguData->GetDisplayServiceCount();
1137 
1138  m_xLinguModulesCLB->clear();
1139 
1140  for (sal_uInt32 i = 0; i < nDispSrvcCount; ++i)
1141  {
1142  const ServiceInfo_Impl &rInfo = rAllDispSrvcArr[i];
1143  m_xLinguModulesCLB->append();
1144  m_xLinguModulesCLB->set_id(i, OUString::number(reinterpret_cast<sal_Int64>(&rInfo)));
1145  m_xLinguModulesCLB->set_toggle(i, rInfo.bConfigured ? TRISTATE_TRUE : TRISTATE_FALSE, 0);
1146  m_xLinguModulesCLB->set_text(i, rInfo.sDisplayName, 1);
1147  }
1148  if (nDispSrvcCount)
1149  {
1150  m_xLinguModulesCLB->select(0);
1151  SelectHdl_Impl(*m_xLinguModulesCLB);
1152  }
1153  m_xLinguModulesEditPB->set_sensitive( nDispSrvcCount > 0 );
1154  }
1155 }
1156 
1158 {
1159  // if not HideGroups was called with GROUP_MODULES...
1160  if (m_xLinguModulesCLB->get_visible())
1161  {
1162  if (!pLinguData)
1163  pLinguData.reset( new SvxLinguData_Impl );
1165  }
1166 
1167 
1168  // get data from configuration
1169  SvtLinguConfig aLngCfg;
1170 
1171  m_xLinguOptionsCLB->freeze();
1172  m_xLinguOptionsCLB->clear();
1173 
1174  sal_Int16 nVal = 0;
1175  bool bVal = false;
1176  sal_uInt32 nUserData = 0;
1177 
1178  m_xLinguOptionsCLB->append();
1179  int nEntry = 0;
1180 
1181  aLngCfg.GetProperty( UPN_IS_SPELL_AUTO ) >>= bVal;
1182  const SfxPoolItem* pItem = GetItem( *rSet, SID_AUTOSPELL_CHECK );
1183  if (pItem)
1184  bVal = static_cast<const SfxBoolItem *>(pItem)->GetValue();
1185  nUserData = OptionsUserData( EID_SPELL_AUTO, false, 0, true, bVal).GetUserData();
1186  m_xLinguOptionsCLB->set_toggle(nEntry, bVal ? TRISTATE_TRUE : TRISTATE_FALSE, 0);
1187  m_xLinguOptionsCLB->set_text(nEntry, sSpellAuto, 1);
1188  m_xLinguOptionsCLB->set_id(nEntry, OUString::number(nUserData));
1189 
1190  m_xLinguOptionsCLB->append();
1191  ++nEntry;
1192 
1193  aLngCfg.GetProperty( UPN_IS_GRAMMAR_AUTO ) >>= bVal;
1194  nUserData = OptionsUserData( EID_GRAMMAR_AUTO, false, 0, true, bVal).GetUserData();
1195  m_xLinguOptionsCLB->set_toggle(nEntry, bVal ? TRISTATE_TRUE : TRISTATE_FALSE, 0);
1196  m_xLinguOptionsCLB->set_text(nEntry, sGrammarAuto, 1);
1197  m_xLinguOptionsCLB->set_id(nEntry, OUString::number(nUserData));
1198 
1199  m_xLinguOptionsCLB->append();
1200  ++nEntry;
1201 
1202  aLngCfg.GetProperty( UPN_IS_SPELL_UPPER_CASE ) >>= bVal;
1203  nUserData = OptionsUserData( EID_CAPITAL_WORDS, false, 0, true, bVal).GetUserData();
1204  m_xLinguOptionsCLB->set_toggle(nEntry, bVal ? TRISTATE_TRUE : TRISTATE_FALSE, 0);
1205  m_xLinguOptionsCLB->set_text(nEntry, sCapitalWords, 1);
1206  m_xLinguOptionsCLB->set_id(nEntry, OUString::number(nUserData));
1207 
1208  m_xLinguOptionsCLB->append();
1209  ++nEntry;
1210 
1211  aLngCfg.GetProperty( UPN_IS_SPELL_WITH_DIGITS ) >>= bVal;
1212  nUserData = OptionsUserData( EID_WORDS_WITH_DIGITS, false, 0, true, bVal).GetUserData();
1213  m_xLinguOptionsCLB->set_toggle(nEntry, bVal ? TRISTATE_TRUE : TRISTATE_FALSE, 0);
1214  m_xLinguOptionsCLB->set_text(nEntry, sWordsWithDigits, 1);
1215  m_xLinguOptionsCLB->set_id(nEntry, OUString::number(nUserData));
1216 
1217  m_xLinguOptionsCLB->append();
1218  ++nEntry;
1219 
1220  aLngCfg.GetProperty( UPN_IS_SPELL_SPECIAL ) >>= bVal;
1221  nUserData = OptionsUserData( EID_SPELL_SPECIAL, false, 0, true, bVal).GetUserData();
1222  m_xLinguOptionsCLB->set_toggle(nEntry, bVal ? TRISTATE_TRUE : TRISTATE_FALSE, 0);
1223  m_xLinguOptionsCLB->set_text(nEntry, sSpellSpecial, 1);
1224  m_xLinguOptionsCLB->set_id(nEntry, OUString::number(nUserData));
1225 
1226  m_xLinguOptionsCLB->append();
1227  ++nEntry;
1228 
1229  aLngCfg.GetProperty( UPN_HYPH_MIN_WORD_LENGTH ) >>= nVal;
1230  nUserData = OptionsUserData( EID_NUM_MIN_WORDLEN, true, static_cast<sal_uInt16>(nVal), false, false).GetUserData();
1231  m_xLinguOptionsCLB->set_text(nEntry, sNumMinWordlen + " " + OUString::number(nVal), 1);
1232  m_xLinguOptionsCLB->set_id(nEntry, OUString::number(nUserData));
1233  nUPN_HYPH_MIN_WORD_LENGTH = nEntry;
1234 
1235  const SfxHyphenRegionItem *pHyp = nullptr;
1236  sal_uInt16 nWhich = GetWhich( SID_ATTR_HYPHENREGION );
1237  if ( rSet->GetItemState( nWhich, false ) == SfxItemState::SET )
1238  pHyp = &static_cast<const SfxHyphenRegionItem &>( rSet->Get( nWhich ) );
1239 
1240  m_xLinguOptionsCLB->append();
1241  ++nEntry;
1242 
1243  aLngCfg.GetProperty( UPN_HYPH_MIN_LEADING ) >>= nVal;
1244  if (pHyp)
1245  nVal = static_cast<sal_Int16>(pHyp->GetMinLead());
1246  nUserData = OptionsUserData( EID_NUM_PRE_BREAK, true, static_cast<sal_uInt16>(nVal), false, false).GetUserData();
1247  m_xLinguOptionsCLB->set_text(nEntry, sNumPreBreak + " " + OUString::number(nVal), 1);
1248  m_xLinguOptionsCLB->set_id(nEntry, OUString::number(nUserData));
1249  nUPN_HYPH_MIN_LEADING = nEntry;
1250 
1251  m_xLinguOptionsCLB->append();
1252  ++nEntry;
1253 
1254  aLngCfg.GetProperty( UPN_HYPH_MIN_TRAILING ) >>= nVal;
1255  if (pHyp)
1256  nVal = static_cast<sal_Int16>(pHyp->GetMinTrail());
1257  nUserData = OptionsUserData( EID_NUM_POST_BREAK, true, static_cast<sal_uInt16>(nVal), false, false).GetUserData();
1258  m_xLinguOptionsCLB->set_text(nEntry, sNumPostBreak + " " + OUString::number(nVal), 1);
1259  m_xLinguOptionsCLB->set_id(nEntry, OUString::number(nUserData));
1260  nUPN_HYPH_MIN_TRAILING = nEntry;
1261 
1262  m_xLinguOptionsCLB->append();
1263  ++nEntry;
1264 
1265  aLngCfg.GetProperty( UPN_IS_HYPH_AUTO ) >>= bVal;
1266  nUserData = OptionsUserData( EID_HYPH_AUTO, false, 0, true, bVal).GetUserData();
1267  m_xLinguOptionsCLB->set_toggle(nEntry, bVal ? TRISTATE_TRUE : TRISTATE_FALSE, 0);
1268  m_xLinguOptionsCLB->set_text(nEntry, sHyphAuto, 1);
1269  m_xLinguOptionsCLB->set_id(nEntry, OUString::number(nUserData));
1270 
1271  m_xLinguOptionsCLB->append();
1272  ++nEntry;
1273 
1274  aLngCfg.GetProperty( UPN_IS_HYPH_SPECIAL ) >>= bVal;
1275  nUserData = OptionsUserData( EID_HYPH_SPECIAL, false, 0, true, bVal).GetUserData();
1276  m_xLinguOptionsCLB->set_toggle(nEntry, bVal ? TRISTATE_TRUE : TRISTATE_FALSE, 0);
1277  m_xLinguOptionsCLB->set_text(nEntry, sHyphSpecial, 1);
1278  m_xLinguOptionsCLB->set_id(nEntry, OUString::number(nUserData));
1279 
1280  m_xLinguOptionsCLB->thaw();
1281 
1282  m_xLinguOptionsCLB->select(0);
1283  SelectHdl_Impl(*m_xLinguOptionsCLB);
1284 
1285  m_xLinguModulesCLB->set_size_request(m_xLinguModulesCLB->get_preferred_size().Width(),
1286  m_xLinguModulesCLB->get_height_rows(3));
1287  m_xLinguDicsCLB->set_size_request(m_xLinguDicsCLB->get_preferred_size().Width(),
1288  m_xLinguDicsCLB->get_height_rows(5));
1289  m_xLinguOptionsCLB->set_size_request(m_xLinguOptionsCLB->get_preferred_size().Width(),
1290  m_xLinguOptionsCLB->get_height_rows(5));
1291 }
1292 
1293 IMPL_LINK(SvxLinguTabPage, BoxDoubleClickHdl_Impl, weld::TreeView&, rBox, void)
1294 {
1295  if (&rBox == m_xLinguModulesCLB.get())
1296  {
1301  this, SvxLinguTabPage, PostDblClickHdl_Impl ), nullptr, true);
1302  }
1303  else if (&rBox == m_xLinguOptionsCLB.get())
1304  {
1305  ClickHdl_Impl(*m_xLinguOptionsEditPB);
1306  }
1307 }
1308 
1309 IMPL_LINK_NOARG(SvxLinguTabPage, PostDblClickHdl_Impl, void*, void)
1310 {
1311  ClickHdl_Impl(*m_xLinguModulesEditPB);
1312 }
1313 
1314 IMPL_LINK(SvxLinguTabPage, ModulesBoxCheckButtonHdl_Impl, const row_col&, rRowCol, void)
1315 {
1316  if (!pLinguData)
1317  return;
1318  auto nPos = rRowCol.first;
1319  pLinguData->Reconfigure(m_xLinguModulesCLB->get_text(nPos, 1),
1320  m_xLinguModulesCLB->get_toggle(nPos, 0) == TRISTATE_TRUE);
1321 }
1322 
1323 IMPL_LINK(SvxLinguTabPage, DicsBoxCheckButtonHdl_Impl, const row_col&, rRowCol, void)
1324 {
1325  auto nPos = rRowCol.first;
1326  const uno::Reference<XDictionary> &rDic = aDics.getConstArray()[ nPos ];
1327  if (LinguMgr::GetIgnoreAllList() == rDic)
1328  m_xLinguDicsCLB->set_toggle(nPos, TRISTATE_TRUE, 0);
1329 }
1330 
1331 IMPL_LINK(SvxLinguTabPage, ClickHdl_Impl, weld::Button&, rBtn, void)
1332 {
1333  if (m_xLinguModulesEditPB.get() == &rBtn)
1334  {
1335  if (!pLinguData)
1336  pLinguData.reset( new SvxLinguData_Impl );
1337 
1338  SvxLinguData_Impl aOldLinguData( *pLinguData );
1339  SvxEditModulesDlg aDlg(GetDialogFrameWeld(), *pLinguData);
1340  if (aDlg.run() != RET_OK)
1341  *pLinguData = aOldLinguData;
1342 
1343  // evaluate new status of 'bConfigured' flag
1344  sal_uInt32 nLen = pLinguData->GetDisplayServiceCount();
1345  for (sal_uInt32 i = 0; i < nLen; ++i)
1346  pLinguData->GetDisplayServiceArray()[i].bConfigured = false;
1347  const Locale* pAllLocales = pLinguData->GetAllSupportedLocales().getConstArray();
1348  sal_Int32 nLocales = pLinguData->GetAllSupportedLocales().getLength();
1349  for (sal_Int32 k = 0; k < nLocales; ++k)
1350  {
1351  LanguageType nLang = LanguageTag::convertToLanguageType( pAllLocales[k] );
1352  if (pLinguData->GetSpellTable().count( nLang ))
1353  pLinguData->SetChecked( pLinguData->GetSpellTable()[ nLang ] );
1354  if (pLinguData->GetGrammarTable().count( nLang ))
1355  pLinguData->SetChecked( pLinguData->GetGrammarTable()[ nLang ] );
1356  if (pLinguData->GetHyphTable().count( nLang ))
1357  pLinguData->SetChecked( pLinguData->GetHyphTable()[ nLang ] );
1358  if (pLinguData->GetThesTable().count( nLang ))
1359  pLinguData->SetChecked( pLinguData->GetThesTable()[ nLang ] );
1360  }
1361 
1362  // show new status of modules
1363  UpdateModulesBox_Impl();
1364  }
1365  else if (m_xLinguDicsNewPB.get() == &rBtn)
1366  {
1369  uno::Reference< XDictionary > xNewDic;
1370  if ( aDlg->Execute() == RET_OK )
1371  xNewDic = aDlg->GetNewDictionary();
1372  if ( xNewDic.is() )
1373  {
1374  // add new dics to the end
1375  sal_Int32 nLen = aDics.getLength();
1376  aDics.realloc( nLen + 1 );
1377 
1378  aDics.getArray()[ nLen ] = xNewDic;
1379 
1380  AddDicBoxEntry( xNewDic, static_cast<sal_uInt16>(nLen) );
1381  }
1382  }
1383  else if (m_xLinguDicsEditPB.get() == &rBtn)
1384  {
1385  int nEntry = m_xLinguDicsCLB->get_selected_index();
1386  if (nEntry != -1)
1387  {
1388  DicUserData aData(m_xLinguDicsCLB->get_id(nEntry).toUInt32());
1389  sal_uInt16 nDicPos = aData.GetEntryId();
1390  sal_Int32 nDics = aDics.getLength();
1391  if (nDicPos < nDics)
1392  {
1393  uno::Reference< XDictionary > xDic = aDics.getConstArray()[ nDicPos ];
1394  if (xDic.is())
1395  {
1397  ScopedVclPtr<VclAbstractDialog> aDlg(pFact->CreateSvxEditDictionaryDialog(GetDialogFrameWeld(), xDic->getName()));
1398  aDlg->Execute();
1399  }
1400  }
1401  }
1402  }
1403  else if (m_xLinguDicsDelPB.get() == &rBtn)
1404  {
1405  std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetDialogFrameWeld(), "cui/ui/querydeletedictionarydialog.ui"));
1406  std::unique_ptr<weld::MessageDialog> xQuery(xBuilder->weld_message_dialog("QueryDeleteDictionaryDialog"));
1407  if (RET_NO == xQuery->run())
1408  return;
1409 
1410  int nEntry = m_xLinguDicsCLB->get_selected_index();
1411  if (nEntry != -1)
1412  {
1413  DicUserData aData(m_xLinguDicsCLB->get_id(nEntry).toUInt32());
1414  sal_uInt16 nDicPos = aData.GetEntryId();
1415  sal_Int32 nDics = aDics.getLength();
1416  if (nDicPos < nDics)
1417  {
1418  uno::Reference< XDictionary > xDic = aDics.getConstArray()[ nDicPos ];
1419  if (xDic.is())
1420  {
1421  if (LinguMgr::GetIgnoreAllList() == xDic)
1422  xDic->clear();
1423  else
1424  {
1425  if (xDicList.is())
1426  xDicList->removeDictionary( xDic );
1427 
1428  uno::Reference< frame::XStorable > xStor( xDic, UNO_QUERY );
1429  if ( xStor->hasLocation() && !xStor->isReadonly() )
1430  {
1431  OUString sURL = xStor->getLocation();
1432  INetURLObject aObj(sURL);
1433  DBG_ASSERT( aObj.GetProtocol() == INetProtocol::File,
1434  "non-file URLs cannot be deleted" );
1435  if ( aObj.GetProtocol() == INetProtocol::File )
1436  {
1438  }
1439  }
1440 
1441  aDics.getArray()[ nDicPos ] = nullptr;
1442 
1443  // remove entry from checklistbox
1444  int nCnt = m_xLinguDicsCLB->n_children();
1445  for (int i = 0; i < nCnt; ++i)
1446  {
1447  DicUserData aDicData(m_xLinguDicsCLB->get_id(i).toUInt32());
1448  if (aDicData.GetEntryId() == nDicPos )
1449  {
1450  m_xLinguDicsCLB->remove(i);
1451  break;
1452  }
1453  }
1454  DBG_ASSERT( nCnt > m_xLinguDicsCLB->n_children(),
1455  "remove failed ?");
1456  }
1457  }
1458  }
1459  }
1460  }
1461  else if (m_xLinguOptionsEditPB.get() == &rBtn)
1462  {
1463  int nEntry = m_xLinguOptionsCLB->get_selected_index();
1464  DBG_ASSERT(nEntry != -1, "no entry selected");
1465  if (nEntry != -1)
1466  {
1467  OptionsUserData aData(m_xLinguOptionsCLB->get_id(nEntry).toUInt32());
1468  if (aData.HasNumericValue())
1469  {
1470  sal_uInt16 nRID = aData.GetEntryId();
1471  OptionsBreakSet aDlg(GetDialogFrameWeld(), nRID);
1472  aDlg.GetNumericFld().set_value(aData.GetNumericValue());
1473  if (RET_OK == aDlg.run())
1474  {
1475  int nVal = aDlg.GetNumericFld().get_value();
1476  if (-1 != nVal && aData.GetNumericValue() != nVal)
1477  {
1478  aData.SetNumericValue( static_cast<sal_uInt8>(nVal) );
1479  m_xLinguOptionsCLB->set_id(nEntry, OUString::number(aData.GetUserData()));
1480  if (nEntry == nUPN_HYPH_MIN_WORD_LENGTH)
1481  m_xLinguOptionsCLB->set_text(nEntry, sNumMinWordlen + " " + OUString::number(nVal), 1);
1482  else if (nEntry == nUPN_HYPH_MIN_LEADING)
1483  m_xLinguOptionsCLB->set_text(nEntry, sNumPreBreak + " " + OUString::number(nVal), 1);
1484  else if (nEntry == nUPN_HYPH_MIN_TRAILING)
1485  m_xLinguOptionsCLB->set_text(nEntry, sNumPostBreak + " " + OUString::number(nVal), 1);
1486  m_xLinguOptionsCLB->set_id(nEntry, OUString::number(aData.GetUserData()));
1487  }
1488  }
1489  }
1490  }
1491  }
1492  else
1493  {
1494  OSL_FAIL( "rBtn unexpected value" );
1495  }
1496 }
1497 
1498 IMPL_LINK(SvxLinguTabPage, SelectHdl_Impl, weld::TreeView&, rBox, void)
1499 {
1500  if (m_xLinguModulesCLB.get() == &rBox)
1501  {
1502  }
1503  else if (m_xLinguDicsCLB.get() == &rBox)
1504  {
1505  int nEntry = rBox.get_selected_index();
1506  if (nEntry != -1)
1507  {
1508  DicUserData aData(rBox.get_id(nEntry).toUInt32());
1509 
1510  // always allow to edit (i.e. at least view the content of the dictionary)
1511  m_xLinguDicsEditPB->set_sensitive( true );
1512  m_xLinguDicsDelPB->set_sensitive( aData.IsDeletable() );
1513  }
1514  }
1515  else if (m_xLinguOptionsCLB.get() == &rBox)
1516  {
1517  int nEntry = rBox.get_selected_index();
1518  if (nEntry != -1)
1519  {
1520  OptionsUserData aData(rBox.get_id(nEntry).toUInt32());
1521  m_xLinguOptionsEditPB->set_sensitive( aData.HasNumericValue() );
1522  }
1523  }
1524  else
1525  {
1526  OSL_FAIL( "rBox unexpected value" );
1527  }
1528 }
1529 
1530 void SvxLinguTabPage::HideGroups( sal_uInt16 nGrp )
1531 {
1532  if ( 0 != ( GROUP_MODULES & nGrp ) )
1533  {
1534  m_xLinguModulesFT->hide();
1535  m_xLinguModulesCLB->hide();
1536  m_xLinguModulesEditPB->hide();
1537 
1538  if ( SvtExtendedSecurityOptions().GetOpenHyperlinkMode()
1540  {
1541  m_xMoreDictsLink->show();
1542  }
1543  }
1544 }
1545 
1547  : GenericDialogController(pParent, "cui/ui/editmodulesdialog.ui", "EditModulesDialog")
1548  , sSpell(CuiResId(RID_SVXSTR_SPELL))
1549  , sHyph(CuiResId(RID_SVXSTR_HYPH))
1550  , sThes(CuiResId(RID_SVXSTR_THES))
1551  , sGrammar(CuiResId(RID_SVXSTR_GRAMMAR))
1552  , rLinguData(rData)
1553  , m_xModulesCLB(m_xBuilder->weld_tree_view("lingudicts"))
1554  , m_xPrioUpPB(m_xBuilder->weld_button("up"))
1555  , m_xPrioDownPB(m_xBuilder->weld_button("down"))
1556  , m_xBackPB(m_xBuilder->weld_button("back"))
1557  , m_xMoreDictsLink(m_xBuilder->weld_link_button("moredictslink"))
1558  , m_xClosePB(m_xBuilder->weld_button("close"))
1559  , m_xLanguageLB(new LanguageBox(m_xBuilder->weld_combo_box("language")))
1560 {
1561  m_xModulesCLB->set_size_request(m_xModulesCLB->get_approximate_digit_width() * 40,
1562  m_xModulesCLB->get_height_rows(12));
1563 
1564  std::vector<int> aWidths;
1565  aWidths.push_back(m_xModulesCLB->get_checkbox_column_width());
1566  m_xModulesCLB->set_column_fixed_widths(aWidths);
1567 
1569 
1570  m_xModulesCLB->connect_changed( LINK( this, SvxEditModulesDlg, SelectHdl_Impl ));
1571  m_xModulesCLB->connect_toggled(LINK(this, SvxEditModulesDlg, BoxCheckButtonHdl_Impl));
1572 
1573  m_xClosePB->connect_clicked( LINK( this, SvxEditModulesDlg, ClickHdl_Impl ));
1574  m_xPrioUpPB->connect_clicked( LINK( this, SvxEditModulesDlg, UpDownHdl_Impl ));
1575  m_xPrioDownPB->connect_clicked( LINK( this, SvxEditModulesDlg, UpDownHdl_Impl ));
1576  m_xBackPB->connect_clicked( LINK( this, SvxEditModulesDlg, BackHdl_Impl ));
1577  // in case of not installed language modules
1578  m_xPrioUpPB->set_sensitive( false );
1579  m_xPrioDownPB->set_sensitive( false );
1580 
1581  if ( SvtExtendedSecurityOptions().GetOpenHyperlinkMode() == SvtExtendedSecurityOptions::OPEN_NEVER )
1582  m_xMoreDictsLink->hide();
1583 
1584  // set that we want the checkbox shown if spellchecking is available
1585  m_xLanguageLB->SetLanguageList(SvxLanguageListFlags::EMPTY, false, false, true);
1586 
1587  //fill language box
1588  const Sequence< Locale >& rLoc = rLinguData.GetAllSupportedLocales();
1589  const Locale* pLocales = rLoc.getConstArray();
1590  for (int i = 0; i < rLoc.getLength(); ++i)
1591  {
1592  LanguageType nLang = LanguageTag::convertToLanguageType( pLocales[i] );
1593  m_xLanguageLB->InsertLanguage(nLang);
1594  }
1596  m_xLanguageLB->set_active_id( eSysLang );
1597  if (m_xLanguageLB->get_active_id() != eSysLang)
1598  m_xLanguageLB->set_active(0);
1599 
1600  m_xLanguageLB->connect_changed( LINK( this, SvxEditModulesDlg, LangSelectListBoxHdl_Impl ));
1602 }
1603 
1605 {
1606  for (int i = 0, nEntryCount = m_xModulesCLB->n_children(); i < nEntryCount; ++i)
1607  delete reinterpret_cast<ModuleUserData_Impl*>(m_xModulesCLB->get_id(i).toInt64());
1608 }
1609 
1610 IMPL_LINK( SvxEditModulesDlg, SelectHdl_Impl, weld::TreeView&, rBox, void )
1611 {
1612  int nCurPos = rBox.get_selected_index();
1613  if (nCurPos != -1)
1614  {
1615  bool bDisableUp = true;
1616  bool bDisableDown = true;
1617  ModuleUserData_Impl* pData = reinterpret_cast<ModuleUserData_Impl*>(rBox.get_id(nCurPos).toInt64());
1618  if (!pData->IsParent() && pData->GetType() != TYPE_HYPH)
1619  {
1620  if (nCurPos < rBox.n_children() - 1)
1621  {
1622  bDisableDown = reinterpret_cast<ModuleUserData_Impl*>(rBox.get_id(nCurPos + 1).toInt64())->IsParent();
1623  }
1624  if (nCurPos > 1)
1625  {
1626  bDisableUp = reinterpret_cast<ModuleUserData_Impl*>(rBox.get_id(nCurPos - 1).toInt64())->IsParent();
1627  }
1628  }
1629  m_xPrioUpPB->set_sensitive(!bDisableUp);
1630  m_xPrioDownPB->set_sensitive(!bDisableDown);
1631  }
1632 }
1633 
1634 IMPL_LINK( SvxEditModulesDlg, BoxCheckButtonHdl_Impl, const row_col&, rRowCol, void )
1635 {
1636  auto nPos = rRowCol.first;
1637  ModuleUserData_Impl* pData = reinterpret_cast<ModuleUserData_Impl*>(m_xModulesCLB->get_id(nPos).toInt64());
1638  if (!pData->IsParent() && pData->GetType() == TYPE_HYPH)
1639  {
1640  // make hyphenator checkboxes function as radio-buttons
1641  // (at most one box may be checked)
1642  for (int i = 0, nEntryCount = m_xModulesCLB->n_children(); i < nEntryCount; ++i)
1643  {
1644  pData = reinterpret_cast<ModuleUserData_Impl*>(m_xModulesCLB->get_id(i).toInt64());
1645  if (!pData->IsParent() && pData->GetType() == TYPE_HYPH && i != nPos)
1646  {
1647  m_xModulesCLB->set_toggle(i, TRISTATE_FALSE, 0);
1648  }
1649  }
1650  }
1651 }
1652 
1653 IMPL_LINK_NOARG(SvxEditModulesDlg, LangSelectListBoxHdl_Impl, weld::ComboBox&, void)
1654 {
1655  LangSelectHdl_Impl(m_xLanguageLB.get());
1656 }
1657 
1659 {
1660  LanguageType eCurLanguage = m_xLanguageLB->get_active_id();
1661  static Locale aLastLocale;
1662  Locale aCurLocale( LanguageTag::convertToLocale( eCurLanguage));
1663 
1664  if (pBox)
1665  {
1666  // save old probably changed settings
1667  // before switching to new language entries
1668 
1669  LanguageType nLang = LanguageTag::convertToLanguageType( aLastLocale );
1670 
1671  sal_Int32 nStart = 0, nLocalIndex = 0;
1672  Sequence< OUString > aChange;
1673  bool bChanged = false;
1674  for (int i = 0, nEntryCount = m_xModulesCLB->n_children(); i < nEntryCount; ++i)
1675  {
1676  ModuleUserData_Impl* pData = reinterpret_cast<ModuleUserData_Impl*>(m_xModulesCLB->get_id(i).toInt64());
1677  if (pData->IsParent())
1678  {
1679  if (bChanged)
1680  {
1681  LangImplNameTable *pTable = nullptr;
1682  sal_uInt8 nType = pData->GetType();
1683  switch (nType - 1)
1684  {
1685  case TYPE_SPELL : pTable = &rLinguData.GetSpellTable(); break;
1686  case TYPE_GRAMMAR : pTable = &rLinguData.GetGrammarTable(); break;
1687  case TYPE_HYPH : pTable = &rLinguData.GetHyphTable(); break;
1688  case TYPE_THES : pTable = &rLinguData.GetThesTable(); break;
1689  }
1690  if (pTable)
1691  {
1692  aChange.realloc(nStart);
1693  (*pTable)[ nLang ] = aChange;
1694  }
1695  }
1696  nLocalIndex = nStart = 0;
1697  aChange.realloc(nEntryCount);
1698  bChanged = false;
1699  }
1700  else
1701  {
1702  OUString* pChange = aChange.getArray();
1703  pChange[nStart] = pData->GetImplName();
1704  bChanged |= pData->GetIndex() != nLocalIndex ||
1705  static_cast<TriState>(pData->IsChecked()) != m_xModulesCLB->get_toggle(i, 0);
1706  if (m_xModulesCLB->get_toggle(i, 0))
1707  nStart++;
1708  ++nLocalIndex;
1709  }
1710  }
1711  if(bChanged)
1712  {
1713  aChange.realloc(nStart);
1714  rLinguData.GetThesTable()[ nLang ] = aChange;
1715  }
1716  }
1717 
1718  for (int i = 0, nEntryCount = m_xModulesCLB->n_children(); i < nEntryCount; ++i)
1719  delete reinterpret_cast<ModuleUserData_Impl*>(m_xModulesCLB->get_id(i).toInt64());
1720  m_xModulesCLB->clear();
1721 
1722  // display entries for new selected language
1723 
1724  if (LANGUAGE_DONTKNOW != eCurLanguage)
1725  {
1726  sal_uLong n;
1727  ServiceInfo_Impl* pInfo;
1728 
1729  int nRow = 0;
1730  // spellchecker entries
1731 
1732  ModuleUserData_Impl* pUserData = new ModuleUserData_Impl(
1733  OUString(), true, false, TYPE_SPELL, 0 );
1734  OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pUserData)));
1735  m_xModulesCLB->append(nullptr);
1736  m_xModulesCLB->set_id(nRow, sId);
1737  m_xModulesCLB->set_text(nRow, sSpell, 1);
1738  m_xModulesCLB->set_text_emphasis(nRow, true, 1);
1739  ++nRow;
1740 
1741  Sequence< OUString > aNames( rLinguData.GetSortedImplNames( eCurLanguage, TYPE_SPELL ) );
1742  const OUString *pName = aNames.getConstArray();
1743  sal_uLong nNames = static_cast<sal_uLong>(aNames.getLength());
1744  sal_Int32 nLocalIndex = 0; // index relative to parent
1745  for (n = 0; n < nNames; ++n)
1746  {
1747  OUString aImplName;
1748  bool bIsSuppLang = false;
1749 
1750  pInfo = rLinguData.GetInfoByImplName( pName[n] );
1751  if (pInfo)
1752  {
1753  bIsSuppLang = pInfo->xSpell.is() &&
1754  pInfo->xSpell->hasLocale( aCurLocale );
1755  aImplName = pInfo->sSpellImplName;
1756  }
1757  if (!aImplName.isEmpty() && bIsSuppLang)
1758  {
1759  OUString aTxt( pInfo->sDisplayName );
1760 
1762  const bool bHasLang = rTable.count( eCurLanguage );
1763  if (!bHasLang)
1764  {
1765  SAL_INFO( "cui.options", "language entry missing" ); // only relevant if all languages found should be supported
1766  }
1767  const bool bCheck = bHasLang && lcl_SeqGetEntryPos( rTable[ eCurLanguage ], aImplName ) >= 0;
1768  pUserData = new ModuleUserData_Impl( aImplName, false,
1769  bCheck, TYPE_SPELL, static_cast<sal_uInt8>(nLocalIndex++) );
1770  sId = OUString::number(reinterpret_cast<sal_Int64>(pUserData));
1771 
1772  m_xModulesCLB->append(nullptr);
1773  m_xModulesCLB->set_id(nRow, sId);
1774  m_xModulesCLB->set_toggle(nRow, bCheck ? TRISTATE_TRUE : TRISTATE_FALSE, 0);
1775  m_xModulesCLB->set_text(nRow, aTxt, 1);
1776  ++nRow;
1777  }
1778  }
1779 
1780  // grammar checker entries
1781 
1782  pUserData = new ModuleUserData_Impl( OUString(), true, false, TYPE_GRAMMAR, 0 );
1783  sId = OUString::number(reinterpret_cast<sal_Int64>(pUserData));
1784  m_xModulesCLB->append(nullptr);
1785  m_xModulesCLB->set_id(nRow, sId);
1786  m_xModulesCLB->set_text(nRow, sGrammar, 1);
1787  m_xModulesCLB->set_text_emphasis(nRow, true, 1);
1788  ++nRow;
1789 
1790  aNames = rLinguData.GetSortedImplNames( eCurLanguage, TYPE_GRAMMAR );
1791  pName = aNames.getConstArray();
1792  nNames = static_cast<sal_uLong>(aNames.getLength());
1793  nLocalIndex = 0;
1794  for (n = 0; n < nNames; ++n)
1795  {
1796  OUString aImplName;
1797  bool bIsSuppLang = false;
1798 
1799  pInfo = rLinguData.GetInfoByImplName( pName[n] );
1800  if (pInfo)
1801  {
1802  bIsSuppLang = pInfo->xGrammar.is() &&
1803  pInfo->xGrammar->hasLocale( aCurLocale );
1804  aImplName = pInfo->sGrammarImplName;
1805  }
1806  if (!aImplName.isEmpty() && bIsSuppLang)
1807  {
1808  OUString aTxt( pInfo->sDisplayName );
1809 
1811  const bool bHasLang = rTable.count( eCurLanguage );
1812  if (!bHasLang)
1813  {
1814  SAL_INFO( "cui.options", "language entry missing" ); // only relevant if all languages found should be supported
1815  }
1816  const bool bCheck = bHasLang && lcl_SeqGetEntryPos( rTable[ eCurLanguage ], aImplName ) >= 0;
1817  pUserData = new ModuleUserData_Impl( aImplName, false,
1818  bCheck, TYPE_GRAMMAR, static_cast<sal_uInt8>(nLocalIndex++) );
1819 
1820  sId = OUString::number(reinterpret_cast<sal_Int64>(pUserData));
1821 
1822  m_xModulesCLB->append(nullptr);
1823  m_xModulesCLB->set_id(nRow, sId);
1824  m_xModulesCLB->set_toggle(nRow, bCheck ? TRISTATE_TRUE : TRISTATE_FALSE, 0);
1825  m_xModulesCLB->set_text(nRow, aTxt, 1);
1826  ++nRow;
1827  }
1828  }
1829 
1830  // hyphenator entries
1831 
1832  pUserData = new ModuleUserData_Impl( OUString(), true, false, TYPE_HYPH, 0 );
1833  sId = OUString::number(reinterpret_cast<sal_Int64>(pUserData));
1834  m_xModulesCLB->append(nullptr);
1835  m_xModulesCLB->set_id(nRow, sId);
1836  m_xModulesCLB->set_text(nRow, sHyph, 1);
1837  m_xModulesCLB->set_text_emphasis(nRow, true, 1);
1838  ++nRow;
1839 
1840  aNames = rLinguData.GetSortedImplNames( eCurLanguage, TYPE_HYPH );
1841  pName = aNames.getConstArray();
1842  nNames = static_cast<sal_uLong>(aNames.getLength());
1843  nLocalIndex = 0;
1844  for (n = 0; n < nNames; ++n)
1845  {
1846  OUString aImplName;
1847  bool bIsSuppLang = false;
1848 
1849  pInfo = rLinguData.GetInfoByImplName( pName[n] );
1850  if (pInfo)
1851  {
1852  bIsSuppLang = pInfo->xHyph.is() &&
1853  pInfo->xHyph->hasLocale( aCurLocale );
1854  aImplName = pInfo->sHyphImplName;
1855  }
1856  if (!aImplName.isEmpty() && bIsSuppLang)
1857  {
1858  OUString aTxt( pInfo->sDisplayName );
1859 
1861  const bool bHasLang = rTable.count( eCurLanguage );
1862  if (!bHasLang)
1863  {
1864  SAL_INFO( "cui.options", "language entry missing" ); // only relevant if all languages found should be supported
1865  }
1866  const bool bCheck = bHasLang && lcl_SeqGetEntryPos( rTable[ eCurLanguage ], aImplName ) >= 0;
1867  pUserData = new ModuleUserData_Impl( aImplName, false,
1868  bCheck, TYPE_HYPH, static_cast<sal_uInt8>(nLocalIndex++) );
1869  sId = OUString::number(reinterpret_cast<sal_Int64>(pUserData));
1870 
1871  m_xModulesCLB->append(nullptr);
1872  m_xModulesCLB->set_id(nRow, sId);
1873  m_xModulesCLB->set_toggle(nRow, bCheck ? TRISTATE_TRUE : TRISTATE_FALSE, 0);
1874  m_xModulesCLB->set_text(nRow, aTxt, 1);
1875  ++nRow;
1876  }
1877  }
1878 
1879  // thesaurus entries
1880 
1881  pUserData = new ModuleUserData_Impl( OUString(), true, false, TYPE_THES, 0 );
1882  sId = OUString::number(reinterpret_cast<sal_Int64>(pUserData));
1883  m_xModulesCLB->append(nullptr);
1884  m_xModulesCLB->set_id(nRow, sId);
1885  m_xModulesCLB->set_text(nRow, sThes, 1);
1886  m_xModulesCLB->set_text_emphasis(nRow, true, 1);
1887  ++nRow;
1888 
1889  aNames = rLinguData.GetSortedImplNames( eCurLanguage, TYPE_THES );
1890  pName = aNames.getConstArray();
1891  nNames = static_cast<sal_uLong>(aNames.getLength());
1892  nLocalIndex = 0;
1893  for (n = 0; n < nNames; ++n)
1894  {
1895  OUString aImplName;
1896  bool bIsSuppLang = false;
1897 
1898  pInfo = rLinguData.GetInfoByImplName( pName[n] );
1899  if (pInfo)
1900  {
1901  bIsSuppLang = pInfo->xThes.is() &&
1902  pInfo->xThes->hasLocale( aCurLocale );
1903  aImplName = pInfo->sThesImplName;
1904  }
1905  if (!aImplName.isEmpty() && bIsSuppLang)
1906  {
1907  OUString aTxt( pInfo->sDisplayName );
1908 
1910  const bool bHasLang = rTable.count( eCurLanguage );
1911  if (!bHasLang)
1912  {
1913  SAL_INFO( "cui.options", "language entry missing" ); // only relevant if all languages found should be supported
1914  }
1915  const bool bCheck = bHasLang && lcl_SeqGetEntryPos( rTable[ eCurLanguage ], aImplName ) >= 0;
1916  pUserData = new ModuleUserData_Impl( aImplName, false,
1917  bCheck, TYPE_THES, static_cast<sal_uInt8>(nLocalIndex++) );
1918  sId = OUString::number(reinterpret_cast<sal_Int64>(pUserData));
1919 
1920  m_xModulesCLB->append(nullptr);
1921  m_xModulesCLB->set_id(nRow, sId);
1922  m_xModulesCLB->set_toggle(nRow, bCheck ? TRISTATE_TRUE : TRISTATE_FALSE, 0);
1923  m_xModulesCLB->set_text(nRow, aTxt, 1);
1924  ++nRow;
1925  }
1926  }
1927  }
1928  aLastLocale = aCurLocale;
1929 }
1930 
1931 IMPL_LINK( SvxEditModulesDlg, UpDownHdl_Impl, weld::Button&, rBtn, void )
1932 {
1933  bool bUp = m_xPrioUpPB.get() == &rBtn;
1934  int nCurPos = m_xModulesCLB->get_selected_index();
1935  if (nCurPos != -1)
1936  {
1937  m_xModulesCLB->freeze();
1938 
1939  OUString sId(m_xModulesCLB->get_id(nCurPos));
1940  OUString sStr(m_xModulesCLB->get_text(nCurPos));
1941  bool bIsChecked = m_xModulesCLB->get_toggle(nCurPos, nCurPos);
1942 
1943  m_xModulesCLB->remove(nCurPos);
1944 
1945  int nDestPos = bUp ? nCurPos - 1 : nCurPos + 1;
1946 
1947  m_xModulesCLB->insert_text(nDestPos, sStr);
1948  m_xModulesCLB->set_id(nDestPos, sId);
1949  m_xModulesCLB->set_toggle(nDestPos, bIsChecked ? TRISTATE_TRUE : TRISTATE_FALSE, 0);
1950 
1951  m_xModulesCLB->thaw();
1952 
1953  m_xModulesCLB->select(nDestPos);
1954  SelectHdl_Impl(*m_xModulesCLB);
1955  }
1956 }
1957 
1959 {
1960  // store language config
1961  LangSelectHdl_Impl(m_xLanguageLB.get());
1962  m_xDialog->response(RET_OK);
1963 }
1964 
1966 {
1967  rLinguData = *pDefaultLinguData;
1968  LangSelectHdl_Impl(nullptr);
1969 }
1970 
1971 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual VclPtr< AbstractSvxNewDictionaryDialog > CreateSvxNewDictionaryDialog(weld::Window *pParent)=0
IMPL_LINK(SvxLinguTabPage, BoxDoubleClickHdl_Impl, weld::TreeView &, rBox, void)
Definition: optlingu.cxx:1293
SvxEditModulesDlg(weld::Window *pParent, SvxLinguData_Impl &rData)
Definition: optlingu.cxx:1546
static bool KillFile_Impl(const OUString &rURL)
Definition: optlingu.cxx:102
std::unique_ptr< weld::Button > m_xLinguDicsDelPB
Definition: optlingu.hxx:117
SvxLinguTabPage(TabPageParent pParent, const SfxItemSet &rCoreSet)
Definition: optlingu.cxx:828
OUString sHyphSpecial
Definition: optlingu.hxx:93
void UpdateDicBox_Impl()
Definition: optlingu.cxx:1109
SvxLinguData_Impl & rLinguData
Definition: optlingu.hxx:54
uno::Reference< XLinguServiceManager2 > xLinguSrvcMgr
Definition: optlingu.cxx:344
#define TYPE_HYPH
Definition: optlingu.cxx:127
static sal_Int32 lcl_SeqGetEntryPos(const Sequence< OUString > &rSeq, const OUString &rEntry)
Definition: optlingu.cxx:88
sal_uInt32 nVal
Definition: optlingu.cxx:160
Sequence< OUString > GetSortedImplNames(LanguageType nLang, sal_uInt8 nType)
Definition: optlingu.cxx:397
OUString sNumMinWordlen
Definition: optlingu.hxx:89
bool IsDeletable() const
Definition: optlingu.cxx:170
const char * pLocale
std::unique_ptr< weld::LinkButton > m_xMoreDictsLink
Definition: optlingu.hxx:120
#define UPN_IS_HYPH_AUTO
const char aData[]
sal_uInt32 nDisplayServices
Definition: optlingu.cxx:337
#define UPN_HYPH_MIN_WORD_LENGTH
std::string GetValue
std::unique_ptr< weld::Label > m_xLinguModulesFT
Definition: optlingu.hxx:110
ServiceInfoArr aDisplayServiceArr
Definition: optlingu.cxx:336
static const sal_Char cHyph[]
Definition: optlingu.cxx:83
OptionsUserData(sal_uInt32 nUserData)
Definition: optlingu.cxx:271
std::unique_ptr< weld::Label > m_xLinguDicsFT
Definition: optlingu.hxx:113
sal_uInt8 & GetMinTrail()
static bool AddRemove(Sequence< OUString > &rConfigured, const OUString &rImplName, bool bAdd)
Definition: optlingu.cxx:707
std::unique_ptr< SvxLinguData_Impl > pLinguData
Definition: optlingu.hxx:108
static LanguageType convertToLanguageType(const css::lang::Locale &rLocale, bool bResolveSystem=true)
void HideGroups(sal_uInt16 nGrp)
Definition: optlingu.cxx:1530
static SvxAbstractDialogFactory * Create()
sal_uIntPtr sal_uLong
bool IsChecked() const
Definition: optlingu.cxx:149
static const AllSettings & GetSettings()
static const sal_Char cThes[]
Definition: optlingu.cxx:84
std::unique_ptr< weld::Button > m_xPrioUpPB
Definition: optlingu.hxx:57
#define TYPE_THES
Definition: optlingu.cxx:128
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
OUString sThesImplName
Definition: optlingu.cxx:316
bool IsChecked() const
Definition: optlingu.cxx:169
void SetNumericValue(sal_uInt8 nNumVal)
Definition: optlingu.cxx:299
OUString sSpellImplName
Definition: optlingu.cxx:314
std::unique_ptr< weld::Widget > m_xAfterFrame
Definition: optlingu.cxx:228
virtual short Execute()=0
TRISTATE_TRUE
std::unique_ptr< SvxLinguData_Impl > pDefaultLinguData
Definition: optlingu.hxx:53
static const SfxPoolItem * GetItem(const SfxItemSet &rSet, sal_uInt16 nSlot, bool bDeep=true)
const css::lang::Locale & getLocale(bool bResolveSystem=true) const
#define UPN_HYPH_MIN_TRAILING
static css::uno::Reference< css::linguistic2::XLinguProperties > GetLinguPropertySet()
#define UPN_IS_SPELL_SPECIAL
RET_NO
LangImplNameTable & GetThesTable()
Definition: optlingu.cxx:362
virtual ~SvxLinguTabPage() override
Definition: optlingu.cxx:908
sal_uInt8 & GetMinLead()
FUNC_TYPE const nType
void UpdateModulesBox_Impl()
Definition: optlingu.cxx:1131
#define UPN_IS_GRAMMAR_AUTO
#define UPN_IS_SPELL_UPPER_CASE
char sal_Char
virtual VclPtr< VclAbstractDialog > CreateSvxEditDictionaryDialog(weld::Window *pParent, const OUString &rName)=0
static css::uno::Reference< css::linguistic2::XSearchableDictionaryList > GetDictionaryList()
std::unique_ptr< weld::TreeView > m_xModulesCLB
Definition: optlingu.hxx:56
OUString sHyphImplName
Definition: optlingu.cxx:315
static const sal_Char cSpell[]
Definition: optlingu.cxx:81
OUString sHyphAuto
Definition: optlingu.hxx:92
std::map< LanguageType, Sequence< OUString > > LangImplNameTable
Definition: optlingu.cxx:328
virtual int get_value() const =0
sal_uInt16 GetEntryId() const
Definition: optlingu.cxx:277
std::unique_ptr< weld::Button > m_xLinguDicsNewPB
Definition: optlingu.hxx:115
std::unique_ptr< weld::Button > m_xClosePB
Definition: optlingu.hxx:61
std::unique_ptr< weld::TreeView > m_xLinguModulesCLB
Definition: optlingu.hxx:111
#define TYPE_GRAMMAR
Definition: optlingu.cxx:126
std::unique_ptr< weld::LinkButton > m_xMoreDictsLink
Definition: optlingu.hxx:60
std::unique_ptr< weld::Button > m_xLinguOptionsEditPB
Definition: optlingu.hxx:119
virtual void dispose() override
OUString sThes
Definition: optlingu.hxx:50
static css::uno::Reference< css::linguistic2::XDictionary > GetIgnoreAllList()
OUString GetDicInfoStr(const OUString &rName, const LanguageType nLang, bool bNeg)
std::unique_ptr< weld::SpinButton > m_xBreakNF
Definition: optlingu.cxx:230
std::unique_ptr< weld::Button > m_xPrioDownPB
Definition: optlingu.hxx:58
const LanguageTag & GetLanguageTag() const
#define SAL_N_ELEMENTS(arr)
std::unique_ptr< weld::Widget > m_xMinimalFrame
Definition: optlingu.cxx:229
static void lcl_MergeLocales(Sequence< Locale > &aAllLocales, const Sequence< Locale > &rAdd)
Definition: optlingu.cxx:465
ServiceInfo_Impl * GetInfoByImplName(const OUString &rSvcImplName)
Definition: optlingu.cxx:448
#define UPN_IS_SPELL_WITH_DIGITS
int nUPN_HYPH_MIN_LEADING
Definition: optlingu.hxx:96
LangImplNameTable & GetSpellTable()
Definition: optlingu.cxx:360
static LanguageType getSystemLanguage()
OUString sGrammarAuto
Definition: optlingu.hxx:88
const SfxPoolItem * GetOldItem(const SfxItemSet &rSet, sal_uInt16 nSlot, bool bDeep=true)
void SetDisplayServiceCount(sal_uInt32 nVal)
Definition: optlingu.cxx:368
static const sal_Char cGrammar[]
Definition: optlingu.cxx:82
#define TOOLS_WARN_EXCEPTION(area, stream)
OUString sSpellAuto
Definition: optlingu.hxx:87
#define GROUP_MODULES
Definition: optlingu.hxx:42
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
#define DBG_ASSERT(sCon, aError)
OUString sSpellSpecial
Definition: optlingu.hxx:86
uno::Reference< XSpellChecker > xSpell
Definition: optlingu.cxx:318
ServiceInfoArr & GetDisplayServiceArray()
Definition: optlingu.cxx:365
bool IsParent() const
Definition: optlingu.cxx:147
void Reconfigure(const OUString &rDisplayName, bool bEnable)
Definition: optlingu.cxx:735
sal_uInt16 GetNumericValue() const
Definition: optlingu.cxx:279
std::vector< ServiceInfo_Impl > ServiceInfoArr
Definition: optlingu.cxx:327
#define UPN_IS_SPELL_AUTO
DicUserData(sal_uInt32 nUserData)
Definition: optlingu.cxx:163
int i
TRISTATE_FALSE
uno::Reference< XThesaurus > xThes
Definition: optlingu.cxx:320
static VclPtr< SfxTabPage > Create(TabPageParent pParent, const SfxItemSet *rSet)
Definition: optlingu.cxx:919
std::unique_ptr< weld::TreeView > m_xLinguOptionsCLB
Definition: optlingu.hxx:118
std::unique_ptr< weld::TreeView > m_xLinguDicsCLB
Definition: optlingu.hxx:114
uno::Reference< XProofreader > xGrammar
Definition: optlingu.cxx:321
#define LANGUAGE_DONTKNOW
#define SN_HYPHENATOR
static const char * aEidToPropName[]
this array must have an entry for every value of EID_OPTIONS.
Definition: optlingu.cxx:205
OptionsBreakSet(weld::Window *pParent, sal_uInt16 nRID)
Definition: optlingu.cxx:233
sal_uInt16 sal_Char * pName
css::uno::Reference< css::linguistic2::XDictionaryList > xDicList
Definition: optlingu.hxx:103
#define UPN_IS_HYPH_SPECIAL
std::unique_ptr< weld::Widget > m_xBeforeFrame
Definition: optlingu.cxx:227
LangImplNameTable aCfgGrammarTable
Definition: optlingu.cxx:343
static sal_Int32 lcl_SeqGetIndex(const Sequence< OUString > &rSeq, const OUString &rTxt)
Definition: optlingu.cxx:383
std::unique_ptr< weld::Button > m_xBackPB
Definition: optlingu.hxx:59
#define UPH_ACTIVE_DICTIONARIES
OUString sGrammarImplName
Definition: optlingu.cxx:317
OUString sSpell
Definition: optlingu.hxx:48
OUString CuiResId(const char *pKey)
Definition: cuiresmgr.cxx:23
int nUPN_HYPH_MIN_TRAILING
Definition: optlingu.hxx:97
void LangSelectHdl_Impl(const LanguageBox *pBox)
Definition: optlingu.cxx:1658
IMPL_LINK_NOARG(SvxLinguTabPage, PostDblClickHdl_Impl, void *, void)
Definition: optlingu.cxx:1309
sal_uInt8 GetIndex() const
Definition: optlingu.cxx:150
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString sGrammar
Definition: optlingu.hxx:51
sal_uInt16 GetEntryId() const
Definition: optlingu.cxx:168
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
weld::SpinButton & GetNumericFld()
Definition: optlingu.cxx:258
bool IsCheckable() const
Definition: optlingu.cxx:280
sal_uInt32 nVal
Definition: optlingu.cxx:268
#define SN_THESAURUS
LangImplNameTable aCfgHyphTable
Definition: optlingu.cxx:341
virtual void set_value(int value)=0
OUString sWordsWithDigits
Definition: optlingu.hxx:85
const sal_uInt32 & GetDisplayServiceCount() const
Definition: optlingu.cxx:367
LangImplNameTable aCfgThesTable
Definition: optlingu.cxx:342
bool IsModified() const
Definition: optlingu.cxx:281
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
OUString sCapitalWords
Definition: optlingu.hxx:84
unsigned char sal_uInt8
const Sequence< Locale > & GetAllSupportedLocales() const
Definition: optlingu.cxx:358
static sal_uInt32 GetDicUserData(const css::uno::Reference< css::linguistic2::XDictionary > &rxDic, sal_uInt16 nIdx)
Definition: optlingu.cxx:1071
#define SAL_INFO(area, stream)
EID_OPTIONS
Definition: optlingu.cxx:189
INetProtocol GetProtocol() const
Sequence< Locale > aAllServiceLocales
Definition: optlingu.cxx:339
RET_OK
#define UPN_HYPH_MIN_LEADING
static VclPtr< reference_type > Create(Arg &&...arg)
uno::Reference< XHyphenator > xHyph
Definition: optlingu.cxx:319
OUString sHyph
Definition: optlingu.hxx:49
bool SetProperty(const OUString &rPropertyName, const css::uno::Any &rValue)
std::unique_ptr< weld::Button > m_xLinguModulesEditPB
Definition: optlingu.hxx:112
virtual short run()
ModuleUserData_Impl(const OUString &sImpName, bool bIsParent, bool bChecked, sal_uInt8 nSetType, sal_uInt8 nSetIndex)
Definition: optlingu.cxx:139
Reference< XComponentContext > getProcessComponentContext()
static void lcl_MergeDisplayArray(SvxLinguData_Impl &rData, const ServiceInfo_Impl &rToAdd)
Definition: optlingu.cxx:494
int nUPN_HYPH_MIN_WORD_LENGTH
Definition: optlingu.hxx:95
const OUString & GetImplName() const
Definition: optlingu.cxx:151
css::uno::Sequence< css::uno::Reference< css::linguistic2::XDictionary > > aDics
Definition: optlingu.hxx:106
virtual css::uno::Reference< css::linguistic2::XDictionary > GetNewDictionary()=0
static OUString lcl_GetPropertyName(EID_OPTIONS eEntryId)
Definition: optlingu.cxx:219
LangImplNameTable & GetHyphTable()
Definition: optlingu.cxx:361
sal_uInt32 GetUserData() const
Definition: optlingu.cxx:276
virtual bool FillItemSet(SfxItemSet *rSet) override
Definition: optlingu.cxx:925
static weld::Builder * CreateBuilder(weld::Widget *pParent, const OUString &rUIFile)
#define SAL_WARN(area, stream)
OUString sNumPostBreak
Definition: optlingu.hxx:91
css::uno::Any GetProperty(const OUString &rPropertyName) const
virtual void Reset(const SfxItemSet *rSet) override
Definition: optlingu.cxx:1157
virtual ~SvxEditModulesDlg() override
Definition: optlingu.cxx:1604
OUString sDisplayName
Definition: optlingu.cxx:313
#define SN_GRAMMARCHECKER
std::unique_ptr< weld::Button > m_xLinguDicsEditPB
Definition: optlingu.hxx:116
sal_Int32 const nLength
void AddDicBoxEntry(const css::uno::Reference< css::linguistic2::XDictionary > &rxDic, sal_uInt16 nIdx)
Definition: optlingu.cxx:1090
void SetChecked(const Sequence< OUString > &rConfiguredServices)
Definition: optlingu.cxx:682
LangImplNameTable aCfgSpellTable
Definition: optlingu.cxx:340
uno::Reference< XLinguServiceManager2 > & GetManager()
Definition: optlingu.cxx:353
TriState
std::unique_ptr< LanguageBox > m_xLanguageLB
Definition: optlingu.hxx:62
sal_Int32 nPos
#define TYPE_SPELL
Definition: optlingu.cxx:125
sal_uInt32 GetUserData() const
Definition: optlingu.cxx:167
virtual void dispose() override
Definition: optlingu.cxx:913
css::uno::Reference< css::linguistic2::XLinguProperties > xProp
Definition: optlingu.hxx:100
OUString sNumPreBreak
Definition: optlingu.hxx:90
#define SN_SPELLCHECKER
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
bool HasNumericValue() const
Definition: optlingu.cxx:278
sal_uInt8 GetType() const
Definition: optlingu.cxx:148
static css::lang::Locale convertToLocale(LanguageType nLangID, bool bResolveSystem=true)
LangImplNameTable & GetGrammarTable()
Definition: optlingu.cxx:363
OUString sId