LibreOffice Module cui (master)  1
treeopt.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 <memory>
21 #include <string_view>
22 
23 #include <config_features.h>
24 #include <config_feature_opencl.h>
25 #include <config_feature_desktop.h>
26 #include <config_gpgme.h>
27 
28 #include <officecfg/Office/Common.hxx>
29 
30 #include <svx/dialogs.hrc>
31 #include <svx/svxids.hrc>
32 
33 #include <treeopt.hrc>
34 #include <helpids.h>
35 
36 #include "cfgchart.hxx"
37 #include "connpoolconfig.hxx"
38 #include "connpooloptions.hxx"
39 #include <cuioptgenrl.hxx>
40 #include <dbregister.hxx>
42 #include <dialmgr.hxx>
43 #include "fontsubs.hxx"
44 #include "optaccessibility.hxx"
45 #include <optasian.hxx>
46 #include "optchart.hxx"
47 #include "optcolor.hxx"
48 #include "optctl.hxx"
49 #include "optfltr.hxx"
50 #include "optgdlg.hxx"
51 #include "opthtml.hxx"
52 #include "optinet2.hxx"
53 #include "optjava.hxx"
54 #include "optjsearch.hxx"
55 #include <optlingu.hxx>
56 #if HAVE_FEATURE_OPENCL
57 #include "optopencl.hxx"
58 #endif
59 #include <optpath.hxx>
60 #include "optsave.hxx"
61 #include "optupdt.hxx"
62 #include "personalization.hxx"
63 #include <treeopt.hxx>
64 #include "optbasic.hxx"
65 
66 #include <com/sun/star/awt/XContainerWindowEventHandler.hpp>
67 #include <com/sun/star/awt/ContainerWindowProvider.hpp>
68 #include <com/sun/star/awt/XControl.hpp>
69 #include <com/sun/star/awt/PosSize.hpp>
70 #include <com/sun/star/frame/Desktop.hpp>
71 #include <com/sun/star/frame/ModuleManager.hpp>
72 #include <com/sun/star/frame/UnknownModuleException.hpp>
73 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
74 #include <com/sun/star/linguistic2/LinguProperties.hpp>
75 #include <com/sun/star/setup/UpdateCheck.hpp>
78 #include <editeng/langitem.hxx>
79 #include <editeng/optitems.hxx>
80 #include <editeng/unolingu.hxx>
81 #include <linguistic/misc.hxx>
82 #include <officecfg/Office/OptionsDialog.hxx>
83 #include <sfx2/app.hxx>
84 #include <sfx2/dispatch.hxx>
85 #include <sfx2/module.hxx>
86 #include <sfx2/printopt.hxx>
87 #include <sfx2/shell.hxx>
88 #include <sfx2/viewsh.hxx>
89 #include <sfx2/viewfrm.hxx>
90 #include <svl/flagitem.hxx>
91 #include <svl/intitem.hxx>
92 #include <svl/languageoptions.hxx>
93 #include <svtools/helpopt.hxx>
94 #include <svtools/miscopt.hxx>
97 #include <tools/urlobj.hxx>
98 #include <tools/diagnose_ex.h>
99 #include <unotools/configmgr.hxx>
101 #include <unotools/optionsdlg.hxx>
102 #include <unotools/viewoptions.hxx>
103 #include <vcl/help.hxx>
104 #include <vcl/svapp.hxx>
105 #include <vcl/weldutils.hxx>
106 #include <vcl/window.hxx>
107 #include <sal/log.hxx>
108 
109 using namespace ::com::sun::star;
110 using namespace ::com::sun::star::beans;
111 using namespace ::com::sun::star::container;
112 using namespace ::com::sun::star::frame;
113 using namespace ::com::sun::star::lang;
114 using namespace ::com::sun::star::linguistic2;
115 using namespace ::com::sun::star::uno;
116 using namespace ::com::sun::star::util;
117 
119 
120 // some stuff for easier changes for SvtViewOptions
121 constexpr OUStringLiteral VIEWOPT_DATANAME = u"page data";
122 
123 static void SetViewOptUserItem( SvtViewOptions& rOpt, const OUString& rData )
124 {
125  rOpt.SetUserItem( VIEWOPT_DATANAME, Any( rData ) );
126 }
127 
128 static OUString GetViewOptUserItem( const SvtViewOptions& rOpt )
129 {
130  Any aAny( rOpt.GetUserItem( VIEWOPT_DATANAME ) );
131  OUString aUserData;
132  aAny >>= aUserData;
133 
134  return aUserData;
135 }
136 
137 namespace {
138 
139 struct ModuleToGroupNameMap_Impl
140 {
141  std::u16string_view m_pModule;
142  OUString m_sGroupName;
143  sal_uInt16 m_nNodeId;
144 };
145 }
146 
147 static ModuleToGroupNameMap_Impl ModuleMap[] =
148 {
149  { u"ProductName", OUString(), SID_GENERAL_OPTIONS },
150  { u"LanguageSettings", OUString(), SID_LANGUAGE_OPTIONS },
151  { u"Internet", OUString(), SID_INET_DLG },
152  { u"LoadSave", OUString(), SID_FILTER_DLG },
153  { u"Writer", OUString(), SID_SW_EDITOPTIONS },
154  { u"WriterWeb", OUString(), SID_SW_ONLINEOPTIONS },
155  { u"Math", OUString(), SID_SM_EDITOPTIONS },
156  { u"Calc", OUString(), SID_SC_EDITOPTIONS },
157  { u"Impress", OUString(), SID_SD_EDITOPTIONS },
158  { u"Draw", OUString(), SID_SD_GRAPHIC_OPTIONS },
159  { u"Charts", OUString(), SID_SCH_EDITOPTIONS },
160  { u"Base", OUString(), SID_SB_STARBASEOPTIONS },
161 };
162 
163 static void setGroupName( const OUString& rModule, const OUString& rGroupName )
164 {
165  for (ModuleToGroupNameMap_Impl& rEntry : ModuleMap)
166  {
167  if ( rEntry.m_pModule == rModule )
168  {
169  rEntry.m_sGroupName = rGroupName;
170  break;
171  }
172  }
173 }
174 
175 static OUString getGroupName( const OUString& rModule, bool bForced )
176 {
177  OUString sGroupName;
178  for (const ModuleToGroupNameMap_Impl& rEntry : ModuleMap)
179  {
180  if ( rEntry.m_pModule == rModule )
181  {
182  sGroupName = rEntry.m_sGroupName;
183  break;
184  }
185  }
186 
187  if ( sGroupName.isEmpty() && bForced )
188  {
189  if ( rModule == "Writer" )
190  sGroupName = CuiResId(SID_SW_EDITOPTIONS_RES[0].first);
191  else if ( rModule == "WriterWeb" )
192  sGroupName = CuiResId(SID_SW_ONLINEOPTIONS_RES[0].first);
193  else if ( rModule == "Calc" )
194  sGroupName = CuiResId(SID_SC_EDITOPTIONS_RES[0].first);
195  else if ( rModule == "Impress" )
196  sGroupName = CuiResId(SID_SD_EDITOPTIONS_RES[0].first);
197  else if ( rModule == "Draw" )
198  sGroupName = CuiResId(SID_SD_GRAPHIC_OPTIONS_RES[0].first);
199  else if ( rModule == "Math" )
200  sGroupName = CuiResId(SID_SM_EDITOPTIONS_RES[0].first);
201  else if ( rModule == "Base" )
202  sGroupName = CuiResId(SID_SB_STARBASEOPTIONS_RES[0].first);
203  }
204  return sGroupName;
205 }
206 
207 static void deleteGroupNames()
208 {
209  for (ModuleToGroupNameMap_Impl& rEntry : ModuleMap)
210  rEntry.m_sGroupName.clear();
211 }
212 
213 static sal_uInt16 getGroupNodeId( const OUString& rModule )
214 {
215  sal_uInt16 nNodeId = 0xFFFF;
216  for (const ModuleToGroupNameMap_Impl& rEntry : ModuleMap)
217  {
218  if ( rEntry.m_pModule == rModule )
219  {
220  nNodeId = rEntry.m_nNodeId;
221  break;
222  }
223  }
224 
225  return nNodeId;
226 }
227 
228 namespace {
229 
230 class MailMergeCfg_Impl : public utl::ConfigItem
231 {
232 private:
233  // variables
234  bool bIsEmailSupported;
235 
236  virtual void ImplCommit() override;
237 
238 public:
239  MailMergeCfg_Impl();
240 
241  virtual void Notify( const css::uno::Sequence< OUString >& _rPropertyNames) override;
242 
243  bool IsEmailSupported() const {return bIsEmailSupported;}
244 
245 };
246 
247 }
248 
249 MailMergeCfg_Impl::MailMergeCfg_Impl() :
250  utl::ConfigItem("Office.Writer/MailMergeWizard"),
251  bIsEmailSupported(false)
252 {
253  Sequence<OUString> aNames { "EMailSupported" };
254  const Sequence< Any > aValues = GetProperties(aNames);
255  const Any* pValues = aValues.getConstArray();
256  if(aValues.hasElements() && pValues[0].hasValue())
257  pValues[0] >>= bIsEmailSupported;
258 }
259 
260 void MailMergeCfg_Impl::ImplCommit()
261 {
262 }
263 
264 void MailMergeCfg_Impl::Notify( const css::uno::Sequence< OUString >& )
265 {
266 }
267 
268 //typedef SfxTabPage* (*FNCreateTabPage)(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet &rAttrSet);
269 static std::unique_ptr<SfxTabPage> CreateGeneralTabPage(sal_uInt16 nId, weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet)
270 {
271  CreateTabPage fnCreate = nullptr;
272  switch(nId)
273  {
274  case RID_SFXPAGE_SAVE: fnCreate = &SvxSaveTabPage::Create; break;
275  case RID_SFXPAGE_PATH: fnCreate = &SvxPathTabPage::Create; break;
276  case RID_SFXPAGE_GENERAL: fnCreate = &SvxGeneralTabPage::Create; break;
278  case OFA_TP_LANGUAGES: fnCreate = &OfaLanguagesTabPage::Create; break;
279  case RID_SFXPAGE_LINGU: fnCreate = &SvxLinguTabPage::Create; break;
280  case OFA_TP_VIEW: fnCreate = &OfaViewTabPage::Create; break;
281  case OFA_TP_MISC: fnCreate = &OfaMiscTabPage::Create; break;
282  case RID_SVXPAGE_ASIAN_LAYOUT: fnCreate = &SvxAsianLayoutPage::Create; break;
284  case RID_SVXPAGE_INET_PROXY: fnCreate = &SvxProxyTabPage::Create; break;
285  case RID_SVXPAGE_INET_SECURITY: fnCreate = &SvxSecurityTabPage::Create; break;
286  case RID_SVXPAGE_INET_MAIL: fnCreate = &SvxEMailTabPage::Create; break;
287 #if HAVE_FEATURE_DESKTOP
289 #endif
291  case RID_OFAPAGE_HTMLOPT: fnCreate = &OfaHtmlTabPage::Create; break;
292  case SID_OPTFILTER_MSOFFICE: fnCreate = &OfaMSFilterTabPage::Create; break;
293  case RID_OFAPAGE_MSFILTEROPT2: fnCreate = &OfaMSFilterTabPage2::Create; break;
295  case SID_SB_CONNECTIONPOOLING: fnCreate = &::offapp::ConnectionPoolOptionsPage::Create; break;
296  case SID_SB_DBREGISTEROPTIONS: fnCreate = &svx::DbRegistrationOptionsPage::Create; break;
298  case RID_SVXPAGE_OPTIONS_CTL: fnCreate = &SvxCTLOptionsPage::Create ; break;
299  case RID_SVXPAGE_OPTIONS_JAVA: fnCreate = &SvxJavaOptionsPage::Create ; break;
300 #if HAVE_FEATURE_OPENCL
301  case RID_SVXPAGE_OPENCL: fnCreate = &SvxOpenCLTabPage::Create ; break;
302 #endif
305 #if HAVE_FEATURE_SCRIPTING
307 #endif
308  }
309 
310  return fnCreate ? (*fnCreate)( pPage, pController, &rSet ) : nullptr;
311 }
312 
313 namespace {
314 
315 struct OptionsMapping_Impl
316 {
317  const char* m_pGroupName;
318  const char* m_pPageName;
319  sal_uInt16 m_nPageId;
320 };
321 
322 }
323 
324 OptionsMapping_Impl const OptionsMap_Impl[] =
325 {
326 // GROUP PAGE PAGE-ID
327  { "ProductName", nullptr, SID_GENERAL_OPTIONS },
328  { "ProductName", "UserData", RID_SFXPAGE_GENERAL },
329  { "ProductName", "General", OFA_TP_MISC },
330  { "ProductName", "View", OFA_TP_VIEW },
331  { "ProductName", "Print", RID_SFXPAGE_PRINTOPTIONS },
332  { "ProductName", "Paths", RID_SFXPAGE_PATH },
333  { "ProductName", "Fonts", RID_SVX_FONT_SUBSTITUTION },
334  { "ProductName", "Security", RID_SVXPAGE_INET_SECURITY },
335  { "ProductName", "Personalization", RID_SVXPAGE_PERSONALIZATION },
336  { "ProductName", "Appearance", RID_SVXPAGE_COLORCONFIG },
337  { "ProductName", "Accessibility", RID_SVXPAGE_ACCESSIBILITYCONFIG },
338  { "ProductName", "Java", RID_SVXPAGE_OPTIONS_JAVA },
339  { "ProductName", "BasicIDEOptions", RID_SVXPAGE_BASICIDE_OPTIONS },
340  { "ProductName", "OnlineUpdate", RID_SVXPAGE_ONLINEUPDATE },
341  { "LanguageSettings", nullptr, SID_LANGUAGE_OPTIONS },
342  { "LanguageSettings", "Languages", OFA_TP_LANGUAGES },
343  { "LanguageSettings", "WritingAids", RID_SFXPAGE_LINGU },
344  { "LanguageSettings", "SearchingInJapanese", RID_SVXPAGE_JSEARCH_OPTIONS },
345  { "LanguageSettings", "AsianLayout", RID_SVXPAGE_ASIAN_LAYOUT },
346  { "LanguageSettings", "ComplexTextLayout", RID_SVXPAGE_OPTIONS_CTL },
347  { "Internet", nullptr, SID_INET_DLG },
348  { "Internet", "Proxy", RID_SVXPAGE_INET_PROXY },
349  { "Internet", "Email", RID_SVXPAGE_INET_MAIL },
350  { "LoadSave", nullptr, SID_FILTER_DLG },
351  { "LoadSave", "General", RID_SFXPAGE_SAVE },
352  { "LoadSave", "VBAProperties", SID_OPTFILTER_MSOFFICE },
353  { "LoadSave", "MicrosoftOffice", RID_OFAPAGE_MSFILTEROPT2 },
354  { "LoadSave", "HTMLCompatibility", RID_OFAPAGE_HTMLOPT },
355  { "Writer", nullptr, SID_SW_EDITOPTIONS },
356  { "Writer", "General", RID_SW_TP_OPTLOAD_PAGE },
357  { "Writer", "View", RID_SW_TP_CONTENT_OPT },
358  { "Writer", "FormattingAids", RID_SW_TP_OPTSHDWCRSR },
359  { "Writer", "Grid", RID_SVXPAGE_GRID },
360  { "Writer", "BasicFontsWestern", RID_SW_TP_STD_FONT },
361  { "Writer", "BasicFontsAsian", RID_SW_TP_STD_FONT_CJK },
362  { "Writer", "BasicFontsCTL", RID_SW_TP_STD_FONT_CTL },
363  { "Writer", "Print", RID_SW_TP_OPTPRINT_PAGE },
364  { "Writer", "Table", RID_SW_TP_OPTTABLE_PAGE },
365  { "Writer", "Changes", RID_SW_TP_REDLINE_OPT },
366  { "Writer", "Comparison", RID_SW_TP_COMPARISON_OPT },
367  { "Writer", "Compatibility", RID_SW_TP_OPTCOMPATIBILITY_PAGE },
368  { "Writer", "AutoCaption", RID_SW_TP_OPTCAPTION_PAGE },
369  { "Writer", "MailMerge", RID_SW_TP_MAILCONFIG },
370  { "WriterWeb", nullptr, SID_SW_ONLINEOPTIONS },
371  { "WriterWeb", "View", RID_SW_TP_HTML_CONTENT_OPT },
372  { "WriterWeb", "FormattingAids", RID_SW_TP_HTML_OPTSHDWCRSR },
373  { "WriterWeb", "Grid", RID_SW_TP_HTML_OPTGRID_PAGE },
374  { "WriterWeb", "Print", RID_SW_TP_HTML_OPTPRINT_PAGE },
375  { "WriterWeb", "Table", RID_SW_TP_HTML_OPTTABLE_PAGE },
376  { "WriterWeb", "Background", RID_SW_TP_BACKGROUND },
377  { "Math", nullptr, SID_SM_EDITOPTIONS },
378  { "Math", "Settings", SID_SM_TP_PRINTOPTIONS },
379  { "Calc", nullptr, SID_SC_EDITOPTIONS },
380  { "Calc", "General", SID_SC_TP_LAYOUT },
381  { "Calc", "View", SID_SC_TP_CONTENT },
382  { "Calc", "Calculate", SID_SC_TP_CALC },
383  { "Calc", "Formula", SID_SC_TP_FORMULA },
384  { "Calc", "SortLists", SID_SC_TP_USERLISTS },
385  { "Calc", "Changes", SID_SC_TP_CHANGES },
386  { "Calc", "Compatibility", SID_SC_TP_COMPATIBILITY },
387  { "Calc", "Grid", SID_SC_TP_GRID },
388  { "Calc", "Print", RID_SC_TP_PRINT },
389  { "Impress", nullptr, SID_SD_EDITOPTIONS },
390  { "Impress", "General", SID_SI_TP_MISC },
391  { "Impress", "View", SID_SI_TP_CONTENTS },
392  { "Impress", "Grid", SID_SI_TP_SNAP },
393  { "Impress", "Print", SID_SI_TP_PRINT },
394  { "Draw", nullptr, SID_SD_GRAPHIC_OPTIONS },
395  { "Draw", "General", SID_SD_TP_MISC },
396  { "Draw", "View", SID_SD_TP_CONTENTS },
397  { "Draw", "Grid", SID_SD_TP_SNAP },
398  { "Draw", "Print", SID_SD_TP_PRINT },
399  { "Charts", nullptr, SID_SCH_EDITOPTIONS },
400  { "Charts", "DefaultColors", RID_OPTPAGE_CHART_DEFCOLORS },
401  { "Base", nullptr, SID_SB_STARBASEOPTIONS },
402  { "Base", "Connections", SID_SB_CONNECTIONPOOLING },
403  { "Base", "Databases", SID_SB_DBREGISTEROPTIONS },
404  { nullptr, nullptr, 0 }
405 };
406 
407 static bool lcl_getStringFromID( sal_uInt16 _nPageId, OUString& _rGroupName, OUString& _rPageName )
408 {
409  bool bRet = false;
410 
411  sal_uInt16 nIdx = 0;
412  while ( OptionsMap_Impl[nIdx].m_pGroupName != nullptr )
413  {
414  if ( _nPageId == OptionsMap_Impl[nIdx].m_nPageId )
415  {
416  bRet = true;
417  _rGroupName = OUString::createFromAscii( OptionsMap_Impl[nIdx].m_pGroupName );
418  if ( OptionsMap_Impl[nIdx].m_pPageName != nullptr )
419  _rPageName = OUString::createFromAscii( OptionsMap_Impl[nIdx].m_pPageName );
420  break;
421  }
422  ++nIdx;
423  }
424 
425  return bRet;
426 }
427 
428 static bool lcl_isOptionHidden( sal_uInt16 _nPageId, const SvtOptionsDialogOptions& _rOptOptions )
429 {
430  bool bIsHidden = false;
431  OUString sGroupName, sPageName;
432  if ( lcl_getStringFromID( _nPageId, sGroupName, sPageName ) )
433  {
434  if ( sPageName.isEmpty() )
435  bIsHidden = _rOptOptions.IsGroupHidden( sGroupName );
436  else
437  bIsHidden = _rOptOptions.IsPageHidden( sPageName, sGroupName );
438  }
439  return bIsHidden;
440 }
441 
443 {
444  std::unique_ptr<SfxTabPage> m_xPage;
445  sal_uInt16 m_nPageId;
446  OUString m_sPageURL;
447  OUString m_sEventHdl;
448  std::unique_ptr<ExtensionsTabPage> m_xExtPage;
449 
450  explicit OptionsPageInfo( sal_uInt16 nId ) : m_nPageId( nId ) {}
451 };
452 
453 namespace {
454 
455 struct OptionsGroupInfo
456 {
457  std::unique_ptr<SfxItemSet> m_pInItemSet;
458  std::unique_ptr<SfxItemSet> m_pOutItemSet;
459  SfxShell* m_pShell; // used to create the page
460  SfxModule* m_pModule; // used to create the ItemSet
461  sal_uInt16 m_nDialogId; // Id of the former dialog
462 
463  OptionsGroupInfo( SfxShell* pSh, SfxModule* pMod, sal_uInt16 nId ) :
464  m_pShell( pSh ),
465  m_pModule( pMod ), m_nDialogId( nId ) {}
466 };
467 
468 }
469 
470 #define INI_LIST() \
471  , m_pParent ( pParent )\
472  , sTitle ( m_xDialog->get_title() )\
473  , bForgetSelection ( false )\
474  , bIsFromExtensionManager( false ) \
475  , bIsForSetDocumentLanguage( false ) \
476  , bNeedsRestart ( false ) \
477  , eRestartReason( svtools::RESTART_REASON_NONE )
478 
479 
481 {
482  xOkPB = m_xBuilder->weld_button("ok");
483  xApplyPB = m_xBuilder->weld_button("apply");
484  xBackPB = m_xBuilder->weld_button("revert");
485  xTreeLB = m_xBuilder->weld_tree_view("pages");
486  xTabBox = m_xBuilder->weld_container("box");
487  Size aSize(xTreeLB->get_approximate_digit_width() * 82, xTreeLB->get_height_rows(30));
488 #if HAVE_FEATURE_GPGME
489  // tdf#115015: make enough space for crypto settings (approx. 14 text edits + padding)
490  aSize.setHeight((weld::GetMinimumEditHeight() + 6) * 14);
491 #endif
492  xTabBox->set_size_request(aSize.Width(), aSize.Height());
493  xTreeLB->set_size_request(xTreeLB->get_approximate_digit_width() * 30, aSize.Height());
494 }
495 
496 // Ctor() with Frame -----------------------------------------------------
497 OfaTreeOptionsDialog::OfaTreeOptionsDialog(weld::Window* pParent, const Reference< XFrame >& _xFrame, bool bActivateLastSelection)
498  : SfxOkDialogController(pParent, "cui/ui/optionsdialog.ui", "OptionsDialog")
499  INI_LIST()
500 {
501  InitWidgets();
502 
504  Initialize( _xFrame );
505  LoadExtensionOptions( OUString() );
506  if (bActivateLastSelection)
508 
509  xTreeLB->set_accessible_name(m_xDialog->get_title());
510 }
511 
512 // Ctor() with ExtensionId -----------------------------------------------
513 OfaTreeOptionsDialog::OfaTreeOptionsDialog(weld::Window* pParent, const OUString& rExtensionId)
514  : SfxOkDialogController(pParent, "cui/ui/optionsdialog.ui", "OptionsDialog")
515  INI_LIST()
516 {
517  InitWidgets();
518 
519  bIsFromExtensionManager = ( !rExtensionId.isEmpty() );
521  LoadExtensionOptions( rExtensionId );
523 }
524 
526 {
527  xCurrentPageEntry.reset();
528 
529  std::unique_ptr<weld::TreeIter> xEntry = xTreeLB->make_iterator();
530  bool bEntry = xTreeLB->get_iter_first(*xEntry);
531  // first children
532  while (bEntry)
533  {
534  // if Child (has parent), then OptionsPageInfo
535  if (xTreeLB->get_iter_depth(*xEntry))
536  {
537  OptionsPageInfo *pPageInfo = reinterpret_cast<OptionsPageInfo*>(xTreeLB->get_id(*xEntry).toInt64());
538  if(pPageInfo->m_xPage)
539  {
540  pPageInfo->m_xPage->FillUserData();
541  OUString aPageData(pPageInfo->m_xPage->GetUserData());
542  if ( !aPageData.isEmpty() )
543  {
544  SvtViewOptions aTabPageOpt( EViewType::TabPage, OUString::number( pPageInfo->m_nPageId) );
545  SetViewOptUserItem( aTabPageOpt, aPageData );
546  }
547  pPageInfo->m_xPage.reset();
548  }
549 
550  if (pPageInfo->m_nPageId == RID_SFXPAGE_LINGU)
551  {
552  // write personal dictionaries
553  Reference< XSearchableDictionaryList > xDicList( LinguMgr::GetDictionaryList() );
554  if (xDicList.is())
555  {
556  linguistic::SaveDictionaries( xDicList );
557  }
558  }
559 
560  pPageInfo->m_xExtPage.reset();
561 
562  delete pPageInfo;
563  }
564  bEntry = xTreeLB->iter_next(*xEntry);
565  }
566 
567  // and parents
568  bEntry = xTreeLB->get_iter_first(*xEntry);
569  while (bEntry)
570  {
571  if (!xTreeLB->get_iter_depth(*xEntry))
572  {
573  OptionsGroupInfo* pGroupInfo = reinterpret_cast<OptionsGroupInfo*>(xTreeLB->get_id(*xEntry).toInt64());
574  delete pGroupInfo;
575  }
576  bEntry = xTreeLB->iter_next(*xEntry);
577  }
579 }
580 
582  sal_uInt16 nId, const OUString& rPageName, sal_uInt16 nGroup )
583 {
584  std::unique_ptr<weld::TreeIter> xParent = xTreeLB->make_iterator();
585  if (!xTreeLB->get_iter_first(*xParent))
586  return nullptr;
587  xTreeLB->iter_nth_sibling(*xParent, nGroup);
588 
589  OptionsPageInfo* pPageInfo = new OptionsPageInfo( nId );
590  OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pPageInfo)));
591  xTreeLB->insert(xParent.get(), -1, &rPageName, &sId, nullptr, nullptr, false, nullptr);
592  return pPageInfo;
593 }
594 
595 // the ItemSet* is passed on to the dialog's ownership
596 sal_uInt16 OfaTreeOptionsDialog::AddGroup(const OUString& rGroupName,
597  SfxShell* pCreateShell,
598  SfxModule* pCreateModule,
599  sal_uInt16 nDialogId )
600 {
601  OptionsGroupInfo* pInfo =
602  new OptionsGroupInfo( pCreateShell, pCreateModule, nDialogId );
603  OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pInfo)));
604  xTreeLB->append(sId, rGroupName);
605 
606  sal_uInt16 nRet = 0;
607  std::unique_ptr<weld::TreeIter> xEntry = xTreeLB->make_iterator();
608  bool bEntry = xTreeLB->get_iter_first(*xEntry);
609  while (bEntry)
610  {
611  if (!xTreeLB->get_iter_depth(*xEntry))
612  nRet++;
613  bEntry = xTreeLB->iter_next(*xEntry);
614  }
615  return nRet - 1;
616 }
617 
619 {
620  SelectHdl_Impl();
621 }
622 
624 {
625  if (!(xCurrentPageEntry && xTreeLB->get_iter_depth(*xCurrentPageEntry)))
626  return;
627 
628  OptionsPageInfo* pPageInfo = reinterpret_cast<OptionsPageInfo*>(xTreeLB->get_id(*xCurrentPageEntry).toInt64());
629  if (pPageInfo->m_xPage)
630  {
631  std::unique_ptr<weld::TreeIter> xParent = xTreeLB->make_iterator(xCurrentPageEntry.get());
632  xTreeLB->iter_parent(*xParent);
633  OptionsGroupInfo* pGroupInfo =
634  reinterpret_cast<OptionsGroupInfo*>(xTreeLB->get_id(*xParent).toInt64());
635  pPageInfo->m_xPage->Reset( pGroupInfo->m_pInItemSet.get() );
636  }
637  else if ( pPageInfo->m_xExtPage )
638  pPageInfo->m_xExtPage->ResetPage();
639 }
640 
642 {
643  std::unique_ptr<weld::TreeIter> xEntry = xTreeLB->make_iterator();
644  bool bEntry = xTreeLB->get_iter_first(*xEntry);
645  while (bEntry)
646  {
647  if (xTreeLB->get_iter_depth(*xEntry))
648  {
649  OptionsPageInfo* pPageInfo = reinterpret_cast<OptionsPageInfo*>(xTreeLB->get_id(*xEntry).toInt64());
650  if ( pPageInfo->m_xPage && !pPageInfo->m_xPage->HasExchangeSupport() )
651  {
652  std::unique_ptr<weld::TreeIter> xParent = xTreeLB->make_iterator(xEntry.get());
653  xTreeLB->iter_parent(*xParent);
654  OptionsGroupInfo* pGroupInfo =
655  reinterpret_cast<OptionsGroupInfo*>(xTreeLB->get_id(*xParent).toInt64());
656  pPageInfo->m_xPage->FillItemSet(pGroupInfo->m_pOutItemSet.get());
657  }
658 
659  if ( pPageInfo->m_xExtPage )
660  {
661  if ( deactivate )
662  {
663  pPageInfo->m_xExtPage->DeactivatePage();
664  }
665  pPageInfo->m_xExtPage->SavePage();
666  }
667  if ( pPageInfo->m_xPage && RID_OPTPAGE_CHART_DEFCOLORS == pPageInfo->m_nPageId )
668  {
669  SvxDefaultColorOptPage* pPage = static_cast<SvxDefaultColorOptPage *>(pPageInfo->m_xPage.get());
670  pPage->SaveChartOptions();
671  }
672  }
673  bEntry = xTreeLB->iter_next(*xEntry);
674  }
675 }
676 
678 {
679  ApplyOptions(/*deactivate =*/false);
680 
681  if ( bNeedsRestart )
682  {
683  SolarMutexGuard aGuard;
685  m_xDialog.get(), eRestartReason))
686  m_xDialog->response(RET_OK);
687  }
688 }
689 
691 {
692  Help* pHelp = Application::GetHelp();
693  if (pHelp && xCurrentPageEntry && xTreeLB->get_iter_depth(*xCurrentPageEntry))
694  {
695  OptionsPageInfo* pPageInfo = reinterpret_cast<OptionsPageInfo*>(xTreeLB->get_id(*xCurrentPageEntry).toInt64());
696  if (pPageInfo->m_xPage)
697  {
698  OString sHelpId(pPageInfo->m_xPage->GetHelpId());
699  pHelp->Start(OStringToOUString(sHelpId, RTL_TEXTENCODING_UTF8), m_xDialog.get());
700  return false;
701  }
702  }
703  return true;
704 }
705 
707 {
708  if (xCurrentPageEntry && xTreeLB->get_iter_depth(*xCurrentPageEntry))
709  {
710  OptionsPageInfo* pPageInfo = reinterpret_cast<OptionsPageInfo*>(xTreeLB->get_id(*xCurrentPageEntry).toInt64());
711  if ( pPageInfo->m_xPage )
712  {
713  std::unique_ptr<weld::TreeIter> xParent = xTreeLB->make_iterator(xCurrentPageEntry.get());
714  xTreeLB->iter_parent(*xParent);
715 
716  OptionsGroupInfo* pGroupInfo = reinterpret_cast<OptionsGroupInfo*>(xTreeLB->get_id(*xParent).toInt64());
717  if ( RID_SVXPAGE_COLOR != pPageInfo->m_nPageId
718  && pPageInfo->m_xPage->HasExchangeSupport() )
719  {
720  DeactivateRC nLeave = pPageInfo->m_xPage->DeactivatePage(pGroupInfo->m_pOutItemSet.get());
721  if ( nLeave == DeactivateRC::KeepPage )
722  {
723  // the page mustn't be left
724  xTreeLB->select(*xCurrentPageEntry);
725  return;
726  }
727  }
728  pPageInfo->m_xPage->set_visible(false);
729  }
730  }
731 
732  ApplyOptions(/*deactivate =*/ true);
733  m_xDialog->response(RET_OK);
734 
735  if ( bNeedsRestart )
736  {
737  SolarMutexGuard aGuard;
738  ::svtools::executeRestartDialog(comphelper::getProcessComponentContext(),
739  m_pParent, eRestartReason);
740  }
741 }
742 
744 {
745  std::unique_ptr<weld::TreeIter> xEntry = xTreeLB->make_iterator();
746  bool bEntry = xTreeLB->get_iter_first(*xEntry);
747  while (bEntry)
748  {
749  if (!xTreeLB->get_iter_depth(*xEntry))
750  {
751  OptionsGroupInfo* pGroupInfo = reinterpret_cast<OptionsGroupInfo*>(xTreeLB->get_id(*xEntry).toInt64());
752  if(pGroupInfo->m_pOutItemSet)
753  {
754  if(pGroupInfo->m_pShell)
755  pGroupInfo->m_pShell->ApplyItemSet( pGroupInfo->m_nDialogId, *pGroupInfo->m_pOutItemSet);
756  else
757  ApplyItemSet( pGroupInfo->m_nDialogId, *pGroupInfo->m_pOutItemSet);
758  }
759  }
760  bEntry = xTreeLB->iter_next(*xEntry);
761  }
762 }
763 
765 {
766  xTreeLB->set_help_id(HID_OFADLG_TREELISTBOX);
767  xTreeLB->connect_changed( LINK( this, OfaTreeOptionsDialog, ShowPageHdl_Impl ) );
768  xBackPB->connect_clicked( LINK( this, OfaTreeOptionsDialog, BackHdl_Impl ) );
769  xApplyPB->connect_clicked( LINK( this, OfaTreeOptionsDialog, ApplyHdl_Impl ) );
770  xOkPB->connect_clicked( LINK( this, OfaTreeOptionsDialog, OKHdl_Impl ) );
771  m_xDialog->connect_help( LINK( this, OfaTreeOptionsDialog, HelpHdl_Impl ) );
772 }
773 
774 void OfaTreeOptionsDialog::ActivatePage( sal_uInt16 nResId )
775 {
778  {
780  nResId = OFA_TP_LANGUAGES;
781  }
782 
783  DBG_ASSERT( !bIsFromExtensionManager, "OfaTreeOptionsDialog::ActivatePage(): call from extension manager" );
784  if ( !pLastPageSaver )
786  bForgetSelection = true;
787  sal_uInt16 nTemp = pLastPageSaver->m_nLastPageId;
788  pLastPageSaver->m_nLastPageId = nResId;
790  pLastPageSaver->m_nLastPageId = nTemp;
791 }
792 
793 void OfaTreeOptionsDialog::ActivatePage( const OUString& rPageURL )
794 {
795  DBG_ASSERT( !bIsFromExtensionManager, "OfaTreeOptionsDialog::ActivatePage(): call from extension manager" );
796  if ( !pLastPageSaver )
798  bForgetSelection = true;
802 }
803 
805 {
806  std::unique_ptr<weld::TreeIter> xEntry;
807 
808  if (pLastPageSaver)
809  {
812  if ( sLastURL.isEmpty() )
813  {
816  }
817 
818  bool bMustExpand = ( INetURLObject( sLastURL ).GetProtocol() == INetProtocol::File );
819 
820  std::unique_ptr<weld::TreeIter> xTemp = xTreeLB->make_iterator();
821  bool bTemp = xTreeLB->get_iter_first(*xTemp);
822  while (bTemp)
823  {
824  // restore only selection of a leaf
825  if (xTreeLB->get_iter_depth(*xTemp) && xTreeLB->get_id(*xTemp).toInt64())
826  {
827  OptionsPageInfo* pPageInfo = reinterpret_cast<OptionsPageInfo*>(xTreeLB->get_id(*xTemp).toInt64());
828  OUString sPageURL = pPageInfo->m_sPageURL;
829  if ( bMustExpand )
830  {
831  sPageURL = comphelper::getExpandedUri(
833  }
834 
836  && pPageInfo->m_nPageId && pPageInfo->m_nPageId == pLastPageSaver->m_nLastPageId )
837  || ( !pPageInfo->m_nPageId && sLastURL == sPageURL ) )
838  {
839  xEntry = xTreeLB->make_iterator(xTemp.get());
840  break;
841  }
842  }
843  bTemp = xTreeLB->iter_next(*xTemp);
844  }
845  }
846 
847  if (!xEntry)
848  {
849  xEntry = xTreeLB->make_iterator();
850  if (!xTreeLB->get_iter_first(*xEntry) || !xTreeLB->iter_next(*xEntry))
851  xEntry.reset();
852  }
853 
854  if (!xEntry)
855  return;
856 
857  std::unique_ptr<weld::TreeIter> xParent(xTreeLB->make_iterator(xEntry.get()));
858  xTreeLB->iter_parent(*xParent);
859  xTreeLB->expand_row(*xParent);
860  xTreeLB->scroll_to_row(*xParent);
861  xTreeLB->scroll_to_row(*xEntry);
862  xTreeLB->set_cursor(*xEntry);
863  xTreeLB->select(*xEntry);
864  xTreeLB->grab_focus();
865  SelectHdl_Impl();
866 }
867 
869 {
870  std::unique_ptr<weld::TreeIter> xEntry(xTreeLB->make_iterator());
871 
872  if (!xTreeLB->get_cursor(xEntry.get()))
873  return;
874 
875  if (xCurrentPageEntry && xCurrentPageEntry->equal(*xEntry))
876  return;
877 
878  std::unique_ptr<weld::TreeIter> xParent(xTreeLB->make_iterator(xEntry.get()));
879  bool bParent = xTreeLB->iter_parent(*xParent);
880 
881  // If the user has selected a category, automatically switch to a suitable
882  // default sub-page instead.
883  if (!bParent)
884  return;
885 
886  BuilderPage* pNewPage = nullptr;
887  OptionsPageInfo* pOptPageInfo = (xCurrentPageEntry && xTreeLB->get_iter_depth(*xCurrentPageEntry))
888  ? reinterpret_cast<OptionsPageInfo*>(xTreeLB->get_id(*xCurrentPageEntry).toInt64()) : nullptr;
889 
890  if (pOptPageInfo && pOptPageInfo->m_xPage && pOptPageInfo->m_xPage->IsVisible())
891  {
892  std::unique_ptr<weld::TreeIter> xCurParent(xTreeLB->make_iterator(xCurrentPageEntry.get()));
893  xTreeLB->iter_parent(*xCurParent);
894 
895  OptionsGroupInfo* pGroupInfo = reinterpret_cast<OptionsGroupInfo*>(xTreeLB->get_id(*xCurParent).toInt64());
896  DeactivateRC nLeave = DeactivateRC::LeavePage;
897  if ( RID_SVXPAGE_COLOR != pOptPageInfo->m_nPageId && pOptPageInfo->m_xPage->HasExchangeSupport() )
898  nLeave = pOptPageInfo->m_xPage->DeactivatePage( pGroupInfo->m_pOutItemSet.get() );
899 
900  if ( nLeave == DeactivateRC::KeepPage )
901  {
902  // we cannot leave this page
903  xTreeLB->select(*xCurrentPageEntry);
904  return;
905  }
906  else
907  pOptPageInfo->m_xPage->set_visible(false);
908  }
909  else if ( pOptPageInfo && pOptPageInfo->m_xExtPage )
910  {
911  pOptPageInfo->m_xExtPage->Hide();
912  pOptPageInfo->m_xExtPage->DeactivatePage();
913  }
914 
915  OptionsPageInfo *pPageInfo = reinterpret_cast<OptionsPageInfo*>(xTreeLB->get_id(*xEntry).toInt64());
916  OptionsGroupInfo* pGroupInfo = reinterpret_cast<OptionsGroupInfo*>(xTreeLB->get_id(*xParent).toInt64());
917  if(!pPageInfo->m_xPage && pPageInfo->m_nPageId > 0)
918  {
919  if(!pGroupInfo->m_pInItemSet)
920  pGroupInfo->m_pInItemSet = pGroupInfo->m_pShell
921  ? pGroupInfo->m_pShell->CreateItemSet( pGroupInfo->m_nDialogId )
922  : CreateItemSet( pGroupInfo->m_nDialogId );
923  if(!pGroupInfo->m_pOutItemSet)
924  pGroupInfo->m_pOutItemSet = std::make_unique<SfxItemSet>(
925  *pGroupInfo->m_pInItemSet->GetPool(),
926  pGroupInfo->m_pInItemSet->GetRanges());
927 
928  pPageInfo->m_xPage = ::CreateGeneralTabPage(pPageInfo->m_nPageId, xTabBox.get(), this, *pGroupInfo->m_pInItemSet);
929 
930  if(!pPageInfo->m_xPage && pGroupInfo->m_pModule)
931  pPageInfo->m_xPage = pGroupInfo->m_pModule->CreateTabPage(pPageInfo->m_nPageId, xTabBox.get(), this, *pGroupInfo->m_pInItemSet);
932 
933  DBG_ASSERT( pPageInfo->m_xPage, "tabpage could not created");
934  if ( pPageInfo->m_xPage )
935  {
936  SvtViewOptions aTabPageOpt( EViewType::TabPage, OUString::number( pPageInfo->m_nPageId) );
937  pPageInfo->m_xPage->SetUserData( GetViewOptUserItem( aTabPageOpt ) );
938  pPageInfo->m_xPage->Reset( pGroupInfo->m_pInItemSet.get() );
939  }
940  }
941  else if ( 0 == pPageInfo->m_nPageId && !pPageInfo->m_xExtPage )
942  {
943  if ( !m_xContainerWinProvider.is() )
944  {
945  m_xContainerWinProvider = awt::ContainerWindowProvider::create( ::comphelper::getProcessComponentContext() );
946  }
947 
948  pPageInfo->m_xExtPage = std::make_unique<ExtensionsTabPage>(
949  xTabBox.get(), pPageInfo->m_sPageURL, pPageInfo->m_sEventHdl, m_xContainerWinProvider);
950  }
951 
952  if ( pPageInfo->m_xPage )
953  {
954  if ( RID_SVXPAGE_COLOR != pPageInfo->m_nPageId &&
955  pPageInfo->m_xPage->HasExchangeSupport())
956  {
957  pPageInfo->m_xPage->ActivatePage(*pGroupInfo->m_pOutItemSet);
958  }
959  pPageInfo->m_xPage->set_visible(true);
960  }
961  else if ( pPageInfo->m_xExtPage )
962  {
963  pPageInfo->m_xExtPage->Show();
964  pPageInfo->m_xExtPage->ActivatePage();
965  }
966 
967  {
968  OUString sTitleText = sTitle
969  + " - " + xTreeLB->get_text(*xParent)
970  + " - " + xTreeLB->get_text(*xEntry);
971  m_xDialog->set_title(sTitleText);
972  }
973 
974  xCurrentPageEntry = std::move(xEntry);
975 
976  if ( !bForgetSelection )
977  {
978  if ( !pLastPageSaver )
981  pLastPageSaver->m_nLastPageId = pPageInfo->m_nPageId;
982  if ( pPageInfo->m_xExtPage )
983  {
986  else
988  }
989  }
990  pNewPage = pPageInfo->m_xPage.get();
991 
992  // fdo#58170 use current page's layout child HelpId, unless there isn't a current page
993  OString sHelpId(pNewPage ? pNewPage->GetHelpId() : OString());
994  if (sHelpId.isEmpty())
995  sHelpId = HID_OFADLG_TREELISTBOX;
996  xTreeLB->set_help_id(sHelpId);
997 }
998 
999 std::unique_ptr<SfxItemSet> OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId )
1000 {
1001  Reference< XLinguProperties > xProp( LinguMgr::GetLinguPropertySet() );
1002  std::unique_ptr<SfxItemSet> pRet;
1003  switch(nId)
1004  {
1005  case SID_GENERAL_OPTIONS:
1006  {
1007  pRet = std::make_unique<SfxItemSet>(
1008  SfxGetpApp()->GetPool(),
1009  svl::Items<
1010  SID_HTML_MODE, SID_HTML_MODE,
1011  SID_ATTR_METRIC, SID_ATTR_METRIC,
1012  SID_AUTOSPELL_CHECK, SID_AUTOSPELL_CHECK,
1013  SID_ATTR_QUICKLAUNCHER, SID_ATTR_QUICKLAUNCHER,
1014  SID_ATTR_YEAR2000, SID_ATTR_YEAR2000>{} );
1015 
1017  SfxGetpApp()->GetOptions(aOptSet);
1018  pRet->Put(aOptSet);
1019 
1020  SfxViewFrame* pViewFrame = SfxViewFrame::Current();
1021  if ( pViewFrame )
1022  {
1023  const SfxPoolItem* pItem = nullptr;
1024  SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
1025 
1026  // miscellaneous - Year2000
1027  if( SfxItemState::DEFAULT <= pDispatch->QueryState( SID_ATTR_YEAR2000, pItem ) )
1028  pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, static_cast<const SfxUInt16Item*>(pItem)->GetValue() ) );
1029  else
1030  pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, officecfg::Office::Common::DateFormat::TwoDigitYear::get() ) );
1031  }
1032  else
1033  pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, officecfg::Office::Common::DateFormat::TwoDigitYear::get() ) );
1034 
1035 
1036  // miscellaneous - Tabulator
1037  pRet->Put(SfxBoolItem(SID_PRINTER_NOTFOUND_WARN, officecfg::Office::Common::Print::Warning::NotFound::get()));
1038 
1039  SfxPrinterChangeFlags nFlag = officecfg::Office::Common::Print::Warning::PaperSize::get() ? SfxPrinterChangeFlags::CHG_SIZE : SfxPrinterChangeFlags::NONE;
1040  nFlag |= officecfg::Office::Common::Print::Warning::PaperOrientation::get() ? SfxPrinterChangeFlags::CHG_ORIENTATION : SfxPrinterChangeFlags::NONE;
1041  pRet->Put( SfxFlagItem( SID_PRINTER_CHANGESTODOC, static_cast<int>(nFlag) ));
1042 
1043  }
1044  break;
1045  case SID_LANGUAGE_OPTIONS :
1046  {
1047  pRet = std::make_unique<SfxItemSet>(
1048  SfxGetpApp()->GetPool(),
1049  svl::Items<
1050  SID_ATTR_CHAR_CJK_LANGUAGE, SID_ATTR_CHAR_CJK_LANGUAGE,
1051  SID_ATTR_CHAR_CTL_LANGUAGE, SID_ATTR_CHAR_CTL_LANGUAGE,
1052  SID_SET_DOCUMENT_LANGUAGE, SID_SET_DOCUMENT_LANGUAGE,
1053  SID_ATTR_LANGUAGE, SID_ATTR_LANGUAGE,
1054  SID_AUTOSPELL_CHECK, SID_AUTOSPELL_CHECK,
1055  SID_OPT_LOCALE_CHANGED, SID_OPT_LOCALE_CHANGED>{});
1056 
1057  // for linguistic
1058  SfxHyphenRegionItem aHyphen( SID_ATTR_HYPHENREGION );
1059 
1060  sal_Int16 nMinLead = 2,
1061  nMinTrail = 2;
1062  if (xProp.is())
1063  {
1064  nMinLead = xProp->getHyphMinLeading();
1065  nMinTrail = xProp->getHyphMinTrailing();
1066  }
1067  aHyphen.GetMinLead() = static_cast<sal_uInt8>(nMinLead);
1068  aHyphen.GetMinTrail() = static_cast<sal_uInt8>(nMinTrail);
1069 
1070  SfxViewFrame* pViewFrame = SfxViewFrame::Current();
1071  if ( pViewFrame )
1072  {
1073  const SfxPoolItem* pItem = nullptr;
1074  SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
1075  if(SfxItemState::DEFAULT <= pDispatch->QueryState(SID_ATTR_LANGUAGE, pItem))
1076  pRet->Put(
1078  (static_cast<const SvxLanguageItem*>(pItem)
1079  ->GetLanguage()),
1080  SID_ATTR_LANGUAGE));
1081  if(SfxItemState::DEFAULT <= pDispatch->QueryState(SID_ATTR_CHAR_CJK_LANGUAGE, pItem))
1082  pRet->Put(
1084  (static_cast<const SvxLanguageItem*>(pItem)
1085  ->GetLanguage()),
1086  SID_ATTR_CHAR_CJK_LANGUAGE));
1087  if(SfxItemState::DEFAULT <= pDispatch->QueryState(SID_ATTR_CHAR_CTL_LANGUAGE, pItem))
1088  pRet->Put(
1090  (static_cast<const SvxLanguageItem*>(pItem)
1091  ->GetLanguage()),
1092  SID_ATTR_CHAR_CTL_LANGUAGE));
1093 
1094  pRet->Put(aHyphen);
1095  if(SfxItemState::DEFAULT <= pDispatch->QueryState(SID_AUTOSPELL_CHECK, pItem))
1096  {
1097  pRet->Put(std::unique_ptr<SfxPoolItem>(pItem->Clone()));
1098  }
1099  else
1100  {
1101  bool bVal = false;
1102  if (xProp.is())
1103  {
1104  bVal = xProp->getIsSpellAuto();
1105  }
1106 
1107  pRet->Put(SfxBoolItem(SID_AUTOSPELL_CHECK, bVal));
1108  }
1109  }
1110  pRet->Put( SfxBoolItem( SID_SET_DOCUMENT_LANGUAGE, bIsForSetDocumentLanguage ) );
1111  }
1112  break;
1113  case SID_INET_DLG :
1114  pRet = std::make_unique<SfxItemSet>( SfxGetpApp()->GetPool(),
1115  svl::Items<SID_BASIC_ENABLED, SID_BASIC_ENABLED,
1116  //SID_OPTIONS_START - ..END
1117  SID_SAVEREL_INET, SID_SAVEREL_FSYS,
1118  SID_INET_NOPROXY, SID_INET_FTP_PROXY_PORT,
1119  SID_SECURE_URL, SID_SECURE_URL>{} );
1120  SfxGetpApp()->GetOptions(*pRet);
1121  break;
1122  case SID_FILTER_DLG:
1123  pRet = std::make_unique<SfxItemSet>(
1124  SfxGetpApp()->GetPool(),
1125  svl::Items<
1126  SID_ATTR_WARNALIENFORMAT, SID_ATTR_WARNALIENFORMAT,
1127  SID_ATTR_DOCINFO, SID_ATTR_AUTOSAVEMINUTE,
1128  SID_SAVEREL_INET, SID_SAVEREL_FSYS,
1129  SID_ATTR_PRETTYPRINTING, SID_ATTR_PRETTYPRINTING>{} );
1130  SfxGetpApp()->GetOptions(*pRet);
1131  break;
1132 
1133  case SID_SB_STARBASEOPTIONS:
1134  pRet = std::make_unique<SfxItemSet>( SfxGetpApp()->GetPool(),
1138  break;
1139 
1140  case SID_SCH_EDITOPTIONS:
1141  {
1142  SvxChartOptions aChartOpt;
1143  pRet = std::make_unique<SfxItemSet>( SfxGetpApp()->GetPool(), svl::Items<SID_SCH_EDITOPTIONS, SID_SCH_EDITOPTIONS>{} );
1144  pRet->Put( SvxChartColorTableItem( SID_SCH_EDITOPTIONS, aChartOpt.GetDefaultColors() ) );
1145  break;
1146  }
1147  }
1148  return pRet;
1149 }
1150 
1151 void OfaTreeOptionsDialog::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet )
1152 {
1153  switch(nId)
1154  {
1155  case SID_GENERAL_OPTIONS:
1156  {
1157  std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
1158 
1159  const SfxPoolItem* pItem = nullptr;
1161  aOptSet.Put(rSet);
1162  if(aOptSet.Count())
1163  SfxGetpApp()->SetOptions( aOptSet );
1164  // get dispatcher anew, because SetOptions() might have destroyed the dispatcher
1165  SfxViewFrame *pViewFrame = SfxViewFrame::Current();
1166 
1167 // evaluate Year2000
1168  sal_uInt16 nY2K = USHRT_MAX;
1169  if( SfxItemState::SET == rSet.GetItemState( SID_ATTR_YEAR2000, false, &pItem ) )
1170  nY2K = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
1171  if( USHRT_MAX != nY2K )
1172  {
1173  if ( pViewFrame )
1174  {
1175  SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
1176  pDispatch->ExecuteList(SID_ATTR_YEAR2000,
1177  SfxCallMode::ASYNCHRON, { pItem });
1178  }
1179  officecfg::Office::Common::DateFormat::TwoDigitYear::set(nY2K, batch);
1180  }
1181 
1182 // evaluate print
1183  if(SfxItemState::SET == rSet.GetItemState(SID_PRINTER_NOTFOUND_WARN, false, &pItem))
1184  officecfg::Office::Common::Print::Warning::NotFound::set(static_cast<const SfxBoolItem*>(pItem)->GetValue(), batch);
1185 
1186  if(SfxItemState::SET == rSet.GetItemState(SID_PRINTER_CHANGESTODOC, false, &pItem))
1187  {
1188  const SfxFlagItem* pFlag = static_cast<const SfxFlagItem*>(pItem);
1189  bool bPaperSizeWarning = bool(static_cast<SfxPrinterChangeFlags>(pFlag->GetValue()) & SfxPrinterChangeFlags::CHG_SIZE);
1190  officecfg::Office::Common::Print::Warning::PaperSize::set(bPaperSizeWarning, batch);
1191  bool bPaperOrientationWarning = bool(static_cast<SfxPrinterChangeFlags>(pFlag->GetValue()) & SfxPrinterChangeFlags::CHG_ORIENTATION);
1192  officecfg::Office::Common::Print::Warning::PaperOrientation::set(bPaperOrientationWarning, batch);
1193  }
1194 
1195 // evaluate help options
1196  if ( SvtHelpOptions().IsHelpTips() != Help::IsQuickHelpEnabled() )
1198  if ( SvtHelpOptions().IsExtendedHelp() != Help::IsBalloonHelpEnabled() )
1200 
1201  batch->commit();
1202  }
1203  break;
1204  case SID_LANGUAGE_OPTIONS :
1205  {
1207  }
1208  break;
1209  case SID_INET_DLG :
1210  case SID_FILTER_DLG:
1211  SfxGetpApp()->SetOptions( rSet );
1212  break;
1213 
1214  case SID_SB_STARBASEOPTIONS:
1217  break;
1218 
1219  case SID_SCH_EDITOPTIONS:
1220  // nothing to do. Chart options only apply to newly created charts
1221  break;
1222 
1223  default:
1224  {
1225  OSL_FAIL( "Unhandled option in ApplyItemSet" );
1226  }
1227  break;
1228  }
1229 
1230 }
1232 {
1233  bool bSaveSpellCheck = false;
1234  const SfxPoolItem* pItem = nullptr;
1235 
1237  Reference< XLinguProperties > xProp = LinguProperties::create( xContext );
1238  if ( SfxItemState::SET == rSet.GetItemState(SID_ATTR_HYPHENREGION, false, &pItem ) )
1239  {
1240  const SfxHyphenRegionItem* pHyphenItem = static_cast<const SfxHyphenRegionItem*>(pItem);
1241 
1242  xProp->setHyphMinLeading( static_cast<sal_Int16>(pHyphenItem->GetMinLead()) );
1243  xProp->setHyphMinTrailing( static_cast<sal_Int16>(pHyphenItem->GetMinTrail()) );
1244  bSaveSpellCheck = true;
1245  }
1246 
1247  SfxViewFrame *pViewFrame = SfxViewFrame::Current();
1248  if ( pViewFrame )
1249  {
1250  SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
1251  pItem = nullptr;
1252  if(SfxItemState::SET == rSet.GetItemState( SID_ATTR_LANGUAGE, false, &pItem ))
1253  {
1254  pDispatch->ExecuteList(pItem->Which(), SfxCallMode::ASYNCHRON, { pItem });
1255  bSaveSpellCheck = true;
1256  }
1257  if(SfxItemState::SET == rSet.GetItemState( SID_ATTR_CHAR_CTL_LANGUAGE, false, &pItem ))
1258  {
1259  pDispatch->ExecuteList(pItem->Which(), SfxCallMode::ASYNCHRON, { pItem });
1260  bSaveSpellCheck = true;
1261  }
1262  if(SfxItemState::SET == rSet.GetItemState( SID_ATTR_CHAR_CJK_LANGUAGE, false, &pItem ))
1263  {
1264  pDispatch->ExecuteList(pItem->Which(), SfxCallMode::ASYNCHRON, { pItem });
1265  bSaveSpellCheck = true;
1266  }
1267 
1268  if( SfxItemState::SET == rSet.GetItemState(SID_AUTOSPELL_CHECK, false, &pItem ))
1269  {
1270  bool bOnlineSpelling = static_cast<const SfxBoolItem*>(pItem)->GetValue();
1271  pDispatch->ExecuteList(SID_AUTOSPELL_CHECK,
1272  SfxCallMode::ASYNCHRON|SfxCallMode::RECORD, { pItem });
1273 
1274  xProp->setIsSpellAuto( bOnlineSpelling );
1275  }
1276 
1277  if( bSaveSpellCheck )
1278  {
1281  pDispatch->Execute(SID_SPELLCHECKER_CHANGED, SfxCallMode::ASYNCHRON);
1282  }
1283  }
1284 
1285  if( SfxItemState::SET == rSet.GetItemState(SID_OPT_LOCALE_CHANGED, false, &pItem ))
1286  {
1287  SfxViewFrame* _pViewFrame = SfxViewFrame::GetFirst();
1288  while ( _pViewFrame )
1289  {
1290  _pViewFrame->GetDispatcher()->ExecuteList(pItem->Which(),
1291  SfxCallMode::ASYNCHRON, { pItem });
1292  _pViewFrame = SfxViewFrame::GetNext( *_pViewFrame );
1293  }
1294  }
1295 }
1296 
1297 static OUString getCurrentFactory_Impl( const Reference< XFrame >& _xFrame )
1298 {
1299  OUString sIdentifier;
1300  Reference < XFrame > xCurrentFrame( _xFrame );
1301  Reference < XModuleManager2 > xModuleManager = ModuleManager::create(::comphelper::getProcessComponentContext());
1302  if ( !xCurrentFrame.is() )
1303  {
1304  Reference< XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() );
1305  xCurrentFrame = xDesktop->getCurrentFrame();
1306  }
1307 
1308  if ( xCurrentFrame.is() )
1309  {
1310  try
1311  {
1312  sIdentifier = xModuleManager->identify( xCurrentFrame );
1313  }
1314  catch ( css::frame::UnknownModuleException& )
1315  {
1316  SAL_INFO( "cui.options", "unknown module" );
1317  }
1318  catch ( Exception const & )
1319  {
1320  TOOLS_WARN_EXCEPTION( "cui.options", "getActiveModule_Impl(): exception of XModuleManager::identify()" );
1321  }
1322  }
1323 
1324  return sIdentifier;
1325 }
1326 
1328 {
1329  sal_uInt16 nGroup = 0;
1330 
1331  SvtOptionsDialogOptions aOptionsDlgOpt;
1332  sal_uInt16 nPageId;
1333 
1334  // %PRODUCTNAME options
1335  if ( !lcl_isOptionHidden( SID_GENERAL_OPTIONS, aOptionsDlgOpt ) )
1336  {
1337  setGroupName("ProductName", CuiResId(SID_GENERAL_OPTIONS_RES[0].first));
1338  nGroup = AddGroup(CuiResId(SID_GENERAL_OPTIONS_RES[0].first), nullptr, nullptr, SID_GENERAL_OPTIONS );
1339  const sal_uInt16 nEnd = static_cast<sal_uInt16>(SAL_N_ELEMENTS(SID_GENERAL_OPTIONS_RES));
1340 
1341  for (sal_uInt16 i = 1; i < nEnd; ++i)
1342  {
1343  OUString sNewTitle = CuiResId(SID_GENERAL_OPTIONS_RES[i].first);
1344  nPageId = SID_GENERAL_OPTIONS_RES[i].second;
1345  if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1346  continue;
1347 
1348  // Disable Online Update page if service not installed
1349  if( RID_SVXPAGE_ONLINEUPDATE == nPageId )
1350  {
1351  try
1352  {
1353  Reference < XInterface > xService( setup::UpdateCheck::create( ::comphelper::getProcessComponentContext() ) );
1354  if( ! xService.is() )
1355  continue;
1356  }
1357  catch ( css::uno::DeploymentException& )
1358  {
1359  continue;
1360  }
1361  }
1362 
1363  // Disable Basic IDE options, if experimental features are not enabled
1364  if( RID_SVXPAGE_BASICIDE_OPTIONS == nPageId )
1365  {
1366  SvtMiscOptions aMiscOpt;
1367  if( ! aMiscOpt.IsExperimentalMode() )
1368  continue;
1369  }
1370 
1371  AddTabPage( nPageId, sNewTitle, nGroup );
1372  }
1373  }
1374 
1375  // Load and Save options
1376  if ( !lcl_isOptionHidden( SID_FILTER_DLG, aOptionsDlgOpt ) )
1377  {
1378  setGroupName( "LoadSave", CuiResId(SID_FILTER_DLG_RES[0].first) );
1379  nGroup = AddGroup( CuiResId(SID_FILTER_DLG_RES[0].first), nullptr, nullptr, SID_FILTER_DLG );
1380  for ( size_t i = 1; i < SAL_N_ELEMENTS(SID_FILTER_DLG_RES); ++i )
1381  {
1382  nPageId = static_cast<sal_uInt16>(SID_FILTER_DLG_RES[i].second);
1383  if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1384  AddTabPage( nPageId, CuiResId(SID_FILTER_DLG_RES[i].first), nGroup );
1385  }
1386  }
1387 
1388  // Language options
1389  SvtLanguageOptions aLanguageOptions;
1390  if ( !lcl_isOptionHidden( SID_LANGUAGE_OPTIONS, aOptionsDlgOpt ) )
1391  {
1392  setGroupName("LanguageSettings", CuiResId(SID_LANGUAGE_OPTIONS_RES[0].first));
1393  nGroup = AddGroup(CuiResId(SID_LANGUAGE_OPTIONS_RES[0].first), nullptr, nullptr, SID_LANGUAGE_OPTIONS );
1394  for (size_t i = 1; i < SAL_N_ELEMENTS(SID_LANGUAGE_OPTIONS_RES); ++i)
1395  {
1396  nPageId = static_cast<sal_uInt16>(SID_LANGUAGE_OPTIONS_RES[i].second);
1397  if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1398  continue;
1399  if ( ( RID_SVXPAGE_JSEARCH_OPTIONS != nPageId || aLanguageOptions.IsJapaneseFindEnabled() ) &&
1400  ( RID_SVXPAGE_ASIAN_LAYOUT != nPageId || aLanguageOptions.IsAsianTypographyEnabled() ) &&
1401  ( RID_SVXPAGE_OPTIONS_CTL != nPageId || aLanguageOptions.IsCTLFontEnabled() ) )
1402  AddTabPage(nPageId, CuiResId(SID_LANGUAGE_OPTIONS_RES[i].first), nGroup);
1403  }
1404  }
1405 
1406  OUString aFactory = getCurrentFactory_Impl( _xFrame );
1407  DBG_ASSERT( GetModuleIdentifier( _xFrame ) == aFactory, "S H I T!!!" );
1408 
1409  // Writer and Writer/Web options
1410  SvtModuleOptions aModuleOpt;
1412  {
1413  // text document
1414  if ( aFactory == "com.sun.star.text.TextDocument"
1415  || aFactory == "com.sun.star.text.WebDocument"
1416  || aFactory == "com.sun.star.text.GlobalDocument" )
1417  {
1418  SfxModule* pSwMod = SfxApplication::GetModule(SfxToolsModule::Writer);
1419  if ( !lcl_isOptionHidden( SID_SW_EDITOPTIONS, aOptionsDlgOpt ) )
1420  {
1421  if ( aFactory == "com.sun.star.text.WebDocument" )
1422  setGroupName( "WriterWeb", CuiResId(SID_SW_EDITOPTIONS_RES[0].first) );
1423  else
1424  setGroupName( "Writer", CuiResId(SID_SW_EDITOPTIONS_RES[0].first) );
1425  nGroup = AddGroup(CuiResId(SID_SW_EDITOPTIONS_RES[0].first), pSwMod, pSwMod, SID_SW_EDITOPTIONS );
1426  for ( size_t i = 1; i < SAL_N_ELEMENTS(SID_SW_EDITOPTIONS_RES); ++i )
1427  {
1428  nPageId = static_cast<sal_uInt16>(SID_SW_EDITOPTIONS_RES[i].second);
1429  if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1430  continue;
1431  if ( ( RID_SW_TP_STD_FONT_CJK != nPageId || aLanguageOptions.IsCJKFontEnabled() ) &&
1432  ( RID_SW_TP_STD_FONT_CTL != nPageId || aLanguageOptions.IsCTLFontEnabled() ) &&
1433  ( RID_SW_TP_MAILCONFIG != nPageId || MailMergeCfg_Impl().IsEmailSupported() ) )
1434  AddTabPage( nPageId, CuiResId(SID_SW_EDITOPTIONS_RES[i].first), nGroup );
1435  }
1436 #ifdef DBG_UTIL
1437  AddTabPage( RID_SW_TP_OPTTEST_PAGE, "Internal Test", nGroup );
1438 #endif
1439  }
1440 
1441  // HTML documents
1442  if ( !lcl_isOptionHidden( SID_SW_ONLINEOPTIONS, aOptionsDlgOpt ) )
1443  {
1444  nGroup = AddGroup(CuiResId(SID_SW_ONLINEOPTIONS_RES[0].first), pSwMod, pSwMod, SID_SW_ONLINEOPTIONS );
1445  for( size_t i = 1; i < SAL_N_ELEMENTS(SID_SW_ONLINEOPTIONS_RES); ++i )
1446  {
1447  nPageId = static_cast<sal_uInt16>(SID_SW_ONLINEOPTIONS_RES[i].second);
1448  if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1449  AddTabPage(nPageId, CuiResId(SID_SW_ONLINEOPTIONS_RES[i].first), nGroup);
1450  }
1451 #ifdef DBG_UTIL
1452  AddTabPage( RID_SW_TP_OPTTEST_PAGE, "Internal Test", nGroup );
1453 #endif
1454  }
1455  }
1456  }
1457 
1458  // Calc options
1460  {
1461  if ( aFactory == "com.sun.star.sheet.SpreadsheetDocument" )
1462  {
1463  if ( !lcl_isOptionHidden( SID_SC_EDITOPTIONS, aOptionsDlgOpt ) )
1464  {
1465  SfxModule* pScMod = SfxApplication::GetModule( SfxToolsModule::Calc );
1466  setGroupName( "Calc", CuiResId(SID_SC_EDITOPTIONS_RES[0].first) );
1467  nGroup = AddGroup( CuiResId(SID_SC_EDITOPTIONS_RES[0].first), pScMod, pScMod, SID_SC_EDITOPTIONS );
1468  const sal_uInt16 nCount = static_cast<sal_uInt16>(SAL_N_ELEMENTS(SID_SC_EDITOPTIONS_RES));
1469  for ( sal_uInt16 i = 1; i < nCount; ++i )
1470  {
1471  nPageId = static_cast<sal_uInt16>(SID_SC_EDITOPTIONS_RES[i].second);
1472  if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1473  continue;
1474 
1475  AddTabPage( nPageId, CuiResId(SID_SC_EDITOPTIONS_RES[i].first), nGroup );
1476  }
1477  }
1478  }
1479  }
1480 
1481  // Impress options
1482  SfxModule* pSdMod = SfxApplication::GetModule( SfxToolsModule::Draw );
1484  {
1485  if ( aFactory == "com.sun.star.presentation.PresentationDocument" )
1486  {
1487  if ( !lcl_isOptionHidden( SID_SD_EDITOPTIONS, aOptionsDlgOpt ) )
1488  {
1489  setGroupName( "Impress", CuiResId(SID_SD_EDITOPTIONS_RES[0].first) );
1490  nGroup = AddGroup( CuiResId(SID_SD_EDITOPTIONS_RES[0].first), pSdMod, pSdMod, SID_SD_EDITOPTIONS );
1491  const sal_uInt16 nCount = static_cast<sal_uInt16>(SAL_N_ELEMENTS(SID_SD_EDITOPTIONS_RES));
1492  for ( sal_uInt16 i = 1; i < nCount; ++i )
1493  {
1494  nPageId = static_cast<sal_uInt16>(SID_SD_EDITOPTIONS_RES[i].second);
1495  if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1496  continue;
1497 
1498  AddTabPage( nPageId, CuiResId(SID_SD_EDITOPTIONS_RES[i].first), nGroup );
1499  }
1500  }
1501  }
1502  }
1503 
1504  // Draw options
1506  {
1507  if ( aFactory == "com.sun.star.drawing.DrawingDocument" )
1508  {
1509  if ( !lcl_isOptionHidden( SID_SD_GRAPHIC_OPTIONS, aOptionsDlgOpt ) )
1510  {
1511  setGroupName( "Draw", CuiResId(SID_SD_GRAPHIC_OPTIONS_RES[0].first) );
1512  nGroup = AddGroup( CuiResId(SID_SD_GRAPHIC_OPTIONS_RES[0].first), pSdMod, pSdMod, SID_SD_GRAPHIC_OPTIONS );
1513  const sal_uInt16 nCount = static_cast<sal_uInt16>(SAL_N_ELEMENTS(SID_SD_GRAPHIC_OPTIONS_RES));
1514  for ( sal_uInt16 i = 1; i < nCount; ++i )
1515  {
1516  nPageId = static_cast<sal_uInt16>(SID_SD_GRAPHIC_OPTIONS_RES[i].second);
1517  if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1518  continue;
1519 
1520  AddTabPage( nPageId, CuiResId(SID_SD_GRAPHIC_OPTIONS_RES[i].first), nGroup );
1521  }
1522  }
1523  }
1524  }
1525 
1526  // Math options
1528  {
1529  if ( aFactory == "com.sun.star.formula.FormulaProperties" )
1530  {
1531  if ( !lcl_isOptionHidden( SID_SM_EDITOPTIONS, aOptionsDlgOpt ) )
1532  {
1533  SfxModule* pSmMod = SfxApplication::GetModule(SfxToolsModule::Math);
1534  setGroupName( "Math", CuiResId(SID_SM_EDITOPTIONS_RES[0].first) );
1535  nGroup = AddGroup(CuiResId(SID_SM_EDITOPTIONS_RES[0].first), pSmMod, pSmMod, SID_SM_EDITOPTIONS );
1536  for ( size_t i = 1; i < SAL_N_ELEMENTS(SID_SM_EDITOPTIONS_RES); ++i )
1537  {
1538  nPageId = static_cast<sal_uInt16>(SID_SM_EDITOPTIONS_RES[i].second);
1539  if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1540  AddTabPage( nPageId, CuiResId(SID_SM_EDITOPTIONS_RES[i].first), nGroup );
1541  }
1542  }
1543  }
1544  }
1545 
1546  // Database - needed only if there is an application which integrates with databases
1547  if ( !lcl_isOptionHidden( SID_SB_STARBASEOPTIONS, aOptionsDlgOpt ) &&
1551  ) )
1552  {
1553  setGroupName( "Base", CuiResId(SID_SB_STARBASEOPTIONS_RES[0].first) );
1554  nGroup = AddGroup( CuiResId(SID_SB_STARBASEOPTIONS_RES[0].first), nullptr, nullptr, SID_SB_STARBASEOPTIONS );
1555  for ( size_t i = 1; i < SAL_N_ELEMENTS(SID_SB_STARBASEOPTIONS_RES); ++i )
1556  {
1557  nPageId = static_cast<sal_uInt16>(SID_SB_STARBASEOPTIONS_RES[i].second);
1558  if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1559  AddTabPage( nPageId, CuiResId(SID_SB_STARBASEOPTIONS_RES[i].first), nGroup );
1560  }
1561  }
1562 
1563  // Chart options (always installed and active)
1564  if ( !lcl_isOptionHidden( SID_SCH_EDITOPTIONS, aOptionsDlgOpt ) )
1565  {
1566  setGroupName( "Charts", CuiResId(SID_SCH_EDITOPTIONS_RES[0].first) );
1567  nGroup = AddGroup( CuiResId(SID_SCH_EDITOPTIONS_RES[0].first), nullptr, nullptr, SID_SCH_EDITOPTIONS );
1568  for ( size_t i = 1; i < SAL_N_ELEMENTS(SID_SCH_EDITOPTIONS_RES); ++i )
1569  {
1570  nPageId = static_cast<sal_uInt16>(SID_SCH_EDITOPTIONS_RES[i].second);
1571  if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1572  AddTabPage( nPageId, CuiResId(SID_SCH_EDITOPTIONS_RES[i].first), nGroup );
1573  }
1574  }
1575 
1576  // Internet options
1577  if ( lcl_isOptionHidden( SID_INET_DLG, aOptionsDlgOpt ) )
1578  return;
1579 
1580  setGroupName("Internet", CuiResId(SID_INET_DLG_RES[0].first));
1581  nGroup = AddGroup(CuiResId(SID_INET_DLG_RES[0].first), nullptr, nullptr, SID_INET_DLG );
1582 
1583  for ( size_t i = 1; i < SAL_N_ELEMENTS(SID_INET_DLG_RES); ++i )
1584  {
1585  nPageId = static_cast<sal_uInt16>(SID_INET_DLG_RES[i].second);
1586  if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1587  continue;
1588 #if defined(_WIN32)
1589  // Disable E-mail tab-page on Windows
1590  if ( nPageId == RID_SVXPAGE_INET_MAIL )
1591  continue;
1592 #endif
1593  AddTabPage( nPageId, CuiResId(SID_INET_DLG_RES[i].first), nGroup );
1594  }
1595 }
1596 
1597 static bool isNodeActive( OptionsNode const * pNode, Module* pModule )
1598 {
1599  if ( pNode )
1600  {
1601  // Node for all modules active?
1602  if ( pNode->m_bAllModules )
1603  return true;
1604 
1605  // OOo-Nodes (Writer, Calc, Impress...) are active if node is already inserted
1606  if ( !getGroupName( pNode->m_sId, false ).isEmpty() )
1607  return true;
1608 
1609  // no module -> not active
1610  if ( !pModule )
1611  return false;
1612 
1613  // search node in active module
1614  if ( pModule->m_bActive )
1615  {
1616  for (auto const& j : pModule->m_aNodeList)
1617  if ( j->m_sId == pNode->m_sId )
1618  return true;
1619  }
1620  }
1621  return false;
1622 }
1623 
1624 void OfaTreeOptionsDialog::LoadExtensionOptions( const OUString& rExtensionId )
1625 {
1626  std::unique_ptr<Module> pModule;
1627 
1628  // when called by Tools - Options then load nodes of active module
1629  if ( rExtensionId.isEmpty() )
1630  {
1632  }
1633 
1634  VectorOfNodes aNodeList = LoadNodes( pModule.get(), rExtensionId );
1635  InsertNodes( aNodeList );
1636 }
1637 
1639 {
1640  OUString sModule;
1641  Reference < XFrame > xCurrentFrame( rFrame );
1643  Reference < XModuleManager2 > xModuleManager = ModuleManager::create(xContext);
1644 
1645  if ( !xCurrentFrame.is() )
1646  {
1647  Reference < XDesktop2 > xDesktop = Desktop::create( xContext );
1648  xCurrentFrame = xDesktop->getCurrentFrame();
1649  }
1650 
1651  if ( xCurrentFrame.is() )
1652  {
1653  try
1654  {
1655  sModule = xModuleManager->identify( xCurrentFrame );
1656  }
1657  catch ( css::frame::UnknownModuleException& )
1658  {
1659  SAL_INFO( "cui.options", "unknown module" );
1660  }
1661  catch ( Exception const & )
1662  {
1663  TOOLS_WARN_EXCEPTION( "cui.options", "OfaTreeOptionsDialog::GetModuleIdentifier(): exception of XModuleManager::identify()");
1664  }
1665  }
1666  return sModule;
1667 }
1668 
1669 std::unique_ptr<Module> OfaTreeOptionsDialog::LoadModule(
1670  const OUString& rModuleIdentifier )
1671 {
1672  std::unique_ptr<Module> pModule;
1674  officecfg::Office::OptionsDialog::Modules::get());
1675 
1676  const Sequence< OUString > seqNames = xSet->getElementNames();
1677  for ( const OUString& rModule : seqNames )
1678  {
1679  if ( rModuleIdentifier == rModule )
1680  {
1681  // current active module found
1682  pModule.reset(new Module);
1683  pModule->m_bActive = true;
1684 
1685  Reference< XNameAccess > xModAccess;
1686  xSet->getByName( rModule ) >>= xModAccess;
1687  if ( xModAccess.is() )
1688  {
1689  // load the nodes of this module
1690  Reference< XNameAccess > xNodeAccess;
1691  xModAccess->getByName( "Nodes" ) >>= xNodeAccess;
1692  if ( xNodeAccess.is() )
1693  {
1694  const Sequence< OUString > xTemp = xNodeAccess->getElementNames();
1695  Reference< XNameAccess > xAccess;
1696  sal_Int32 nIndex = -1;
1697  for ( const OUString& rNode : xTemp)
1698  {
1699  xNodeAccess->getByName( rNode ) >>= xAccess;
1700  if ( xAccess.is() )
1701  {
1702  xAccess->getByName( "Index" ) >>= nIndex;
1703  if ( nIndex < 0 )
1704  // append nodes with index < 0
1705  pModule->m_aNodeList.push_back(
1706  std::unique_ptr<OrderedEntry>(new OrderedEntry(nIndex, rNode)));
1707  else
1708  {
1709  // search position of the node
1710  std::vector<OrderedEntry *>::size_type y = 0;
1711  for ( ; y < pModule->m_aNodeList.size(); ++y )
1712  {
1713  sal_Int32 nNodeIdx = pModule->m_aNodeList[y]->m_nIndex;
1714  if ( nNodeIdx < 0 || nNodeIdx > nIndex )
1715  break;
1716  }
1717  // and insert the node on this position
1718  pModule->m_aNodeList.insert(
1719  pModule->m_aNodeList.begin() + y,
1720  std::unique_ptr<OrderedEntry>(new OrderedEntry( nIndex, rNode )) );
1721  }
1722  }
1723  }
1724  }
1725  }
1726  break;
1727  }
1728  }
1729  return pModule;
1730 }
1731 
1733  Module* pModule, const OUString& rExtensionId)
1734 {
1735  VectorOfNodes aOutNodeList;
1736 
1738  officecfg::Office::OptionsDialog::Nodes::get());
1739  VectorOfNodes aNodeList;
1740  const Sequence< OUString > seqNames = xSet->getElementNames();
1741 
1742  for ( OUString const & sGroupName : seqNames )
1743  {
1744  Reference< XNameAccess > xNodeAccess;
1745  xSet->getByName( sGroupName ) >>= xNodeAccess;
1746 
1747  if ( xNodeAccess.is() )
1748  {
1749  OUString sNodeId, sLabel, sPageURL;
1750  bool bAllModules = false;
1751 
1752  sNodeId = sGroupName;
1753  xNodeAccess->getByName( "Label" ) >>= sLabel;
1754  xNodeAccess->getByName( "OptionsPage" ) >>= sPageURL;
1755  xNodeAccess->getByName( "AllModules" ) >>= bAllModules;
1756 
1757  if ( sLabel.isEmpty() )
1758  sLabel = sGroupName;
1759  OUString sTemp = getGroupName( sLabel, !rExtensionId.isEmpty() );
1760  if ( !sTemp.isEmpty() )
1761  sLabel = sTemp;
1762  std::unique_ptr<OptionsNode> pNode(new OptionsNode(sNodeId, sLabel, bAllModules));
1763 
1764  if ( rExtensionId.isEmpty() && !isNodeActive( pNode.get(), pModule ) )
1765  {
1766  continue;
1767  }
1768 
1769  Reference< XNameAccess > xLeavesSet;
1770  xNodeAccess->getByName( "Leaves" ) >>= xLeavesSet;
1771  if ( xLeavesSet.is() )
1772  {
1773  const Sequence< OUString > seqLeaves = xLeavesSet->getElementNames();
1774  for ( OUString const & leafName : seqLeaves )
1775  {
1776  Reference< XNameAccess > xLeaveAccess;
1777  xLeavesSet->getByName( leafName ) >>= xLeaveAccess;
1778 
1779  if ( xLeaveAccess.is() )
1780  {
1781  OUString sId, sLeafLabel, sEventHdl, sLeafURL, sLeafGrpId;
1782  sal_Int32 nLeafGrpIdx = 0;
1783 
1784  xLeaveAccess->getByName( "Id" ) >>= sId;
1785  xLeaveAccess->getByName( "Label" ) >>= sLeafLabel;
1786  xLeaveAccess->getByName( "OptionsPage" ) >>= sLeafURL;
1787  xLeaveAccess->getByName( "EventHandlerService" ) >>= sEventHdl;
1788  xLeaveAccess->getByName( "GroupId" ) >>= sLeafGrpId;
1789  xLeaveAccess->getByName( "GroupIndex" ) >>= nLeafGrpIdx;
1790 
1791  if ( rExtensionId.isEmpty() || sId == rExtensionId )
1792  {
1793  std::unique_ptr<OptionsLeaf> pLeaf(new OptionsLeaf(
1794  sLeafLabel, sLeafURL, sEventHdl, sLeafGrpId, nLeafGrpIdx ));
1795 
1796  if ( !sLeafGrpId.isEmpty() )
1797  {
1798  bool bAlreadyOpened = false;
1799  if ( !pNode->m_aGroupedLeaves.empty() )
1800  {
1801  for (auto & rGroup : pNode->m_aGroupedLeaves)
1802  {
1803  if ( !rGroup.empty() &&
1804  rGroup[0]->m_sGroupId == sLeafGrpId )
1805  {
1806  std::vector<std::unique_ptr<OptionsLeaf>>::size_type l = 0;
1807  for ( ; l < rGroup.size(); ++l )
1808  {
1809  if ( rGroup[l]->m_nGroupIndex >= nLeafGrpIdx )
1810  break;
1811  }
1812  rGroup.insert( rGroup.begin() + l, std::move(pLeaf) );
1813  bAlreadyOpened = true;
1814  break;
1815  }
1816  }
1817  }
1818  if ( !bAlreadyOpened )
1819  {
1820  std::vector< std::unique_ptr<OptionsLeaf> > aGroupedLeaves;
1821  aGroupedLeaves.push_back( std::move(pLeaf) );
1822  pNode->m_aGroupedLeaves.push_back( std::move(aGroupedLeaves) );
1823  }
1824  }
1825  else
1826  pNode->m_aLeaves.push_back( std::move(pLeaf) );
1827  }
1828  }
1829  }
1830  }
1831 
1832  // do not insert nodes without leaves
1833  if ( !pNode->m_aLeaves.empty() || !pNode->m_aGroupedLeaves.empty() )
1834  {
1835  pModule ? aNodeList.push_back( std::move(pNode) ) : aOutNodeList.push_back( std::move(pNode) );
1836  }
1837  }
1838  }
1839 
1840  if ( pModule && !aNodeList.empty() )
1841  {
1842  for ( auto const & i: pModule->m_aNodeList )
1843  {
1844  OUString sNodeId = i->m_sId;
1845  for ( auto j = aNodeList.begin(); j != aNodeList.end(); ++j )
1846  {
1847  if ( (*j)->m_sId == sNodeId )
1848  {
1849  aOutNodeList.push_back( std::move(*j) );
1850  aNodeList.erase( j );
1851  break;
1852  }
1853  }
1854  }
1855 
1856  for ( auto & i: aNodeList )
1857  aOutNodeList.push_back( std::move(i) );
1858  }
1859  return aOutNodeList;
1860 }
1861 
1862 static sal_uInt16 lcl_getGroupId( const OUString& rGroupName, const weld::TreeView& rTreeLB )
1863 {
1864  sal_uInt16 nRet = 0;
1865 
1866  std::unique_ptr<weld::TreeIter> xEntry = rTreeLB.make_iterator();
1867  bool bEntry = rTreeLB.get_iter_first(*xEntry);
1868  while (bEntry)
1869  {
1870  if (!rTreeLB.get_iter_depth(*xEntry))
1871  {
1872  OUString sTemp(rTreeLB.get_text(*xEntry));
1873  if (sTemp == rGroupName)
1874  return nRet;
1875  nRet++;
1876  }
1877  bEntry = rTreeLB.iter_next(*xEntry);
1878  }
1879 
1880  return USHRT_MAX;
1881 }
1882 
1883 static void lcl_insertLeaf(
1884  OfaTreeOptionsDialog* pDlg, OptionsNode const * pNode, OptionsLeaf const * pLeaf, const weld::TreeView& rTreeLB )
1885 {
1886  sal_uInt16 nGrpId = lcl_getGroupId( pNode->m_sLabel, rTreeLB );
1887  if ( USHRT_MAX == nGrpId )
1888  {
1889  sal_uInt16 nNodeGrpId = getGroupNodeId( pNode->m_sId );
1890  nGrpId = pDlg->AddGroup( pNode->m_sLabel, nullptr, nullptr, nNodeGrpId );
1891  }
1892  OptionsPageInfo* pInfo = pDlg->AddTabPage( 0, pLeaf->m_sLabel, nGrpId );
1893  pInfo->m_sPageURL = pLeaf->m_sPageURL;
1894  pInfo->m_sEventHdl = pLeaf->m_sEventHdl;
1895 }
1896 
1898 {
1899  for (auto const& node : rNodeList)
1900  {
1901  if ( !node->m_aLeaves.empty() || !node->m_aGroupedLeaves.empty() )
1902  {
1903  for ( auto const & j: node->m_aGroupedLeaves )
1904  {
1905  for ( size_t k = 0; k < j.size(); ++k )
1906  {
1907  lcl_insertLeaf( this, node.get(), j[k].get(), *xTreeLB );
1908  }
1909  }
1910 
1911  for ( auto const & j: node->m_aLeaves )
1912  {
1913  lcl_insertLeaf( this, node.get(), j.get(), *xTreeLB );
1914  }
1915  }
1916  }
1917 }
1918 
1920 {
1921  bNeedsRestart = true;
1922  eRestartReason = eReason;
1923 }
1924 
1926 {
1927  std::unique_ptr< SvxDicListChgClamp > pClamp;
1928  if ( !bIsFromExtensionManager )
1929  {
1930  // collect all DictionaryList Events while the dialog is executed
1931  Reference<css::linguistic2::XSearchableDictionaryList> xDictionaryList(LinguMgr::GetDictionaryList());
1932  pClamp.reset( new SvxDicListChgClamp( xDictionaryList ) );
1933  }
1934 
1935  short nRet = SfxOkDialogController::run();
1936 
1937  if( RET_OK == nRet )
1938  {
1939  ApplyItemSets();
1941  }
1942 
1943  return nRet;
1944 }
1945 
1946 // class ExtensionsTabPage -----------------------------------------------
1948  weld::Container* pParent, const OUString& rPageURL,
1949  const OUString& rEvtHdl, const Reference< awt::XContainerWindowProvider >& rProvider )
1950  : m_pContainer(pParent)
1951  , m_sPageURL(rPageURL)
1952  , m_sEventHdl(rEvtHdl)
1953  , m_xWinProvider(rProvider)
1954 {
1955 }
1956 
1958 {
1959  Hide();
1960  DeactivatePage();
1961 
1962  if ( m_xPage.is() )
1963  {
1964  try
1965  {
1966  m_xPage->dispose();
1967  }
1968  catch (const Exception&)
1969  {
1970  }
1971  m_xPage.clear();
1972  }
1973 
1974  if ( m_xPageParent.is() )
1975  {
1976  try
1977  {
1978  m_xPageParent->dispose();
1979  }
1980  catch (const Exception&)
1981  {
1982  }
1983  m_xPageParent.clear();
1984  }
1985 }
1986 
1988 {
1989  try
1990  {
1991  bool bWithHandler = !m_sEventHdl.isEmpty();
1992  if ( bWithHandler )
1993  {
1994  Reference < XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
1995  m_xEventHdl.set( xFactory->createInstance( m_sEventHdl ), UNO_QUERY );
1996  }
1997 
1998  if ( !bWithHandler || m_xEventHdl.is() )
1999  {
2001  Reference<awt::XWindowPeer> xParent(m_xPageParent, UNO_QUERY);
2002  m_xPage =
2003  m_xWinProvider->createContainerWindow(
2004  m_sPageURL, OUString(), xParent, m_xEventHdl );
2005 
2006  Reference< awt::XControl > xPageControl( m_xPage, UNO_QUERY );
2007  if ( xPageControl.is() )
2008  {
2009  Reference< awt::XWindowPeer > xWinPeer( xPageControl->getPeer() );
2010  if ( xWinPeer.is() )
2011  {
2012  VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWinPeer );
2013  if ( pWindow )
2014  pWindow->SetStyle( pWindow->GetStyle() | WB_DIALOGCONTROL | WB_CHILDDLGCTRL );
2015  }
2016  }
2017  }
2018  }
2019  catch (const Exception&)
2020  {
2021  TOOLS_WARN_EXCEPTION( "cui.options", "ExtensionsTabPage::CreateDialogWithHandler(): exception of XDialogProvider2::createDialogWithHandler()");
2022  }
2023 }
2024 
2025 bool ExtensionsTabPage::DispatchAction( const OUString& rAction )
2026 {
2027  bool bRet = false;
2028  if ( m_xEventHdl.is() )
2029  {
2030  try
2031  {
2032  bRet = m_xEventHdl->callHandlerMethod( m_xPage, Any( rAction ), "external_event" );
2033  }
2034  catch ( Exception const & )
2035  {
2036  TOOLS_WARN_EXCEPTION( "cui.options", "ExtensionsTabPage::DispatchAction(): exception of XDialogEventHandler::callHandlerMethod()" );
2037  }
2038  }
2039  return bRet;
2040 }
2041 
2043 {
2044  if (!m_xPageParent.is())
2045  return;
2046 
2048  if (xPageParent)
2049  {
2050  // NoActivate otherwise setVisible will call Window::Show which will grab
2051  // focus to the page by default
2052  xPageParent->Show(true, ShowFlags::NoActivate);
2053  }
2054 
2055  m_xPageParent->setVisible(true);
2056 }
2057 
2059 {
2060  if (!m_xPageParent.is())
2061  return;
2062  m_xPageParent->setVisible(false);
2063 }
2064 
2066 {
2067  if ( !m_xPage.is() )
2068  {
2070 
2071  if ( m_xPage.is() )
2072  {
2073  auto aWindowRect = m_xPageParent->getPosSize();
2074  m_xPage->setPosSize(0, 0, aWindowRect.Width, aWindowRect.Height, awt::PosSize::POSSIZE);
2075  if ( !m_sEventHdl.isEmpty() )
2076  DispatchAction( "initialize" );
2077  }
2078  }
2079 
2080  if ( m_xPage.is() )
2081  {
2082  m_xPage->setVisible( true );
2083  }
2084 }
2085 
2087 {
2088  if ( m_xPage.is() )
2089  m_xPage->setVisible( false );
2090 }
2091 
2093 {
2094  DispatchAction( "back" );
2095  ActivatePage();
2096 }
2097 
2099 {
2100  DispatchAction( "ok" );
2101 }
2102 
2103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool IsExperimentalMode() const
void SetUserItem(const OUString &sName, const css::uno::Any &aValue)
OptionsPageInfo(sal_uInt16 nId)
Definition: treeopt.cxx:450
OUString m_sEventHdl
Definition: treeopt.cxx:447
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
static void DisableBalloonHelp()
bool IsExtendedHelp() const
sal_Int32 nIndex
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: optjsearch.cxx:58
#define RID_SVXPAGE_ONLINEUPDATE
static void setGroupName(const OUString &rModule, const OUString &rGroupName)
Definition: treeopt.cxx:163
std::unique_ptr< weld::TreeIter > xCurrentPageEntry
Definition: treeopt.hxx:128
OUString m_sPageURL
Definition: treeopt.hxx:59
static void storeConfigItems()
#define RID_SVXPAGE_OPENCL
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: optasian.cxx:139
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: optsave.cxx:184
std::string GetValue
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: dbregister.cxx:119
bool IsAsianTypographyEnabled() const
css::uno::Reference< css::awt::XWindow > m_xPageParent
Definition: treeopt.hxx:205
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
static Help * GetHelp()
static void GetOptions(SfxItemSet &_rFillItems)
OUString m_sEventHdl
Definition: treeopt.hxx:60
OUString m_sLastPageURL_Tools
Definition: treeopt.hxx:100
bool bIsFromExtensionManager
Definition: treeopt.hxx:133
sal_uInt8 & GetMinTrail()
SfxDispatcher * GetDispatcher()
#define INI_LIST()
Definition: treeopt.cxx:470
#define RID_SVXPAGE_OPTIONS_CTL
bool IsModuleInstalled(EModule eModule) const
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: optupdt.cxx:178
static VclPtr< vcl::Window > GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
virtual void Notify(const css::uno::Sequence< OUString > &aPropertyNames)=0
#define RID_SVXPAGE_INET_SECURITY
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: optlingu.cxx:913
#define RID_SVXPAGE_PERSONALIZATION
#define RID_SVXPAGE_COLORCONFIG
std::vector< std::unique_ptr< OptionsNode > > VectorOfNodes
Definition: treeopt.hxx:95
bool IsJapaneseFindEnabled() const
bool SaveDictionaries(const uno::Reference< XSearchableDictionaryList > &xDicList)
OUString m_sLastPageURL_ExtMgr
Definition: treeopt.hxx:101
OString GetHelpId() const
OptionsMapping_Impl const OptionsMap_Impl[]
Definition: treeopt.cxx:324
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rInAttrs)
Definition: optchart.cxx:144
OUString m_sPageURL
Definition: treeopt.hxx:204
virtual std::unique_ptr< TreeIter > make_iterator(const TreeIter *pOrig=nullptr) const =0
bool IsCJKFontEnabled() const
SfxApplication * SfxGetpApp()
static css::uno::Reference< css::linguistic2::XLinguProperties > GetLinguPropertySet()
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: opthtml.cxx:67
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: optctl.cxx:56
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: optinet2.cxx:750
bool IsGroupHidden(const OUString &_rGroup) const
OfaTreeOptionsDialog(weld::Window *pParent, const css::uno::Reference< css::frame::XFrame > &_xFrame, bool bActivateLastSelection)
static void EnableBalloonHelp()
sal_uInt16 nPageId
sal_uInt8 & GetMinLead()
#define HID_OFADLG_TREELISTBOX
Definition: helpids.h:25
void GetOptions(SfxItemSet &)
SfxPrinterChangeFlags
void CreateDialogWithHandler()
Definition: treeopt.cxx:1987
static void DisableQuickHelp()
ExtensionsTabPage(weld::Container *pParent, const OUString &rPageURL, const OUString &rEvtHdl, const css::uno::Reference< css::awt::XContainerWindowProvider > &rProvider)
Definition: treeopt.cxx:1947
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
OUString m_sLabel
Definition: treeopt.hxx:58
int nCount
#define RID_SVXPAGE_JSEARCH_OPTIONS
static css::uno::Reference< css::linguistic2::XSearchableDictionaryList > GetDictionaryList()
static OUString GetViewOptUserItem(const SvtViewOptions &rOpt)
Definition: treeopt.cxx:128
#define RID_SFXPAGE_PRINTOPTIONS
static std::shared_ptr< ConfigurationChanges > create(css::uno::Reference< css::uno::XComponentContext > const &context=comphelper::getProcessComponentContext())
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: optinet2.cxx:186
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *)
static OUString getCurrentFactory_Impl(const Reference< XFrame > &_xFrame)
Definition: treeopt.cxx:1297
#define RID_SFXPAGE_PATH
bool IsHelpTips() const
#define RID_SVXPAGE_INET_MAIL
SfxItemPool & GetPool() const
bool m_bAllModules
Definition: treeopt.hxx:82
OptionsPageInfo * AddTabPage(sal_uInt16 nId, const OUString &rPageName, sal_uInt16 nGroup)
Definition: treeopt.cxx:581
float y
OUString m_sId
Definition: treeopt.hxx:80
#define SAL_N_ELEMENTS(arr)
OUString m_sLabel
Definition: treeopt.hxx:81
static VectorOfNodes LoadNodes(Module *pModule, const OUString &rExtensionId)
Definition: treeopt.cxx:1732
sal_uInt16 m_nPageId
Definition: treeopt.cxx:445
const SvxChartColorTable & GetDefaultColors()
Definition: cfgchart.cxx:173
WinBits const WB_DIALOGCONTROL
SVT_DLLPUBLIC bool executeRestartDialog(css::uno::Reference< css::uno::XComponentContext > const &context, weld::Window *parent, RestartReason reason)
std::map< OUString, std::shared_ptr< NoAutoUnloadModule > > ModuleMap
static OUString GetModuleIdentifier(const css::uno::Reference< css::frame::XFrame > &xFrame)
Definition: treeopt.cxx:1638
static void GetOptions(SfxItemSet &_rFillItems)
#define TOOLS_WARN_EXCEPTION(area, stream)
css::uno::Reference< css::awt::XWindow > m_xPage
Definition: treeopt.hxx:206
#define RID_OFAPAGE_MSFILTEROPT2
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
#define DBG_ASSERT(sCon, aError)
std::unique_ptr< weld::TreeView > xTreeLB
Definition: treeopt.hxx:123
int i
#define OFA_TP_MISC
std::unique_ptr< weld::Container > xTabBox
Definition: treeopt.hxx:124
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: optopencl.cxx:48
LanguageType GetLanguage(SwWrtShell &rSh, sal_uInt16 nLangWhichId)
sal_uInt16 GetValue() const
static void ApplyLanguageOptions(const SfxItemSet &rSet)
Definition: treeopt.cxx:1231
static bool IsQuickHelpEnabled()
#define RID_OFAPAGE_HTMLOPT
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: optgdlg.cxx:1346
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: optfltr.cxx:68
static bool lcl_isOptionHidden(sal_uInt16 _nPageId, const SvtOptionsDialogOptions &_rOptOptions)
Definition: treeopt.cxx:428
void LoadExtensionOptions(const OUString &rExtensionId)
Definition: treeopt.cxx:1624
void SetOptions(const SfxItemSet &)
virtual bool Start(const OUString &rHelpId, const vcl::Window *pWindow)
static SfxViewFrame * GetNext(const SfxViewFrame &rPrev, const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
WinBits const WB_CHILDDLGCTRL
static void SetOptions(const SfxItemSet &_rSourceItems)
virtual bool iter_next(TreeIter &rIter) const =0
float u
void DeactivatePage()
Definition: treeopt.cxx:2086
void Initialize(const css::uno::Reference< css::frame::XFrame > &_xFrame)
Definition: treeopt.cxx:1327
#define RID_SFXPAGE_SAVE
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: optcolor.cxx:746
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: optbasic.cxx:121
#define RID_SVX_FONT_SUBSTITUTION
virtual OUString get_text(int row, int col=-1) const =0
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: optfltr.cxx:150
void ApplyOptions(bool deactivate)
Definition: treeopt.cxx:641
bool bIsForSetDocumentLanguage
Definition: treeopt.hxx:136
std::unique_ptr< ExtensionsTabPage > m_xExtPage
Definition: treeopt.cxx:448
Shell * m_pShell
constexpr OUStringLiteral VIEWOPT_DATANAME
Definition: treeopt.cxx:121
#define RID_SVXPAGE_COLOR
#define OFA_TP_VIEW
static void SetOptions(const SfxItemSet &_rSourceItems)
#define RID_SFXPAGE_GENERAL
OUString CuiResId(const char *pKey)
Definition: cuiresmgr.cxx:23
void SetStyle(WinBits nStyle)
static bool IsBalloonHelpEnabled()
std::unique_ptr< weld::Button > xApplyPB
Definition: treeopt.hxx:120
static LastPageSaver * pLastPageSaver
Definition: treeopt.hxx:144
COMPHELPER_DLLPUBLIC OUString getExpandedUri(css::uno::Reference< css::uno::XComponentContext > const &context, OUString const &uri)
static void lcl_insertLeaf(OfaTreeOptionsDialog *pDlg, OptionsNode const *pNode, OptionsLeaf const *pLeaf, const weld::TreeView &rTreeLB)
Definition: treeopt.cxx:1883
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: fontsubs.cxx:141
svtools::RestartReason eRestartReason
Definition: treeopt.hxx:139
css::uno::Reference< css::awt::XContainerWindowEventHandler > m_xEventHdl
Definition: treeopt.hxx:209
sal_uInt16 m_nLastPageId
Definition: treeopt.hxx:99
virtual css::uno::Reference< css::awt::XWindow > CreateChildFrame()=0
#define RID_SVXPAGE_ACCESSIBILITYCONFIG
std::unique_ptr< weld::Button > xOkPB
Definition: treeopt.hxx:119
bool m_bActive
Definition: treeopt.hxx:48
const PropertyValue * pValues
virtual ~OfaTreeOptionsDialog() override
Definition: treeopt.cxx:525
static OUString getGroupName(const OUString &rModule, bool bForced)
Definition: treeopt.cxx:175
Reference< XMultiServiceFactory > getProcessServiceFactory()
static SfxViewFrame * Current()
css::uno::Reference< css::awt::XContainerWindowProvider > m_xWinProvider
Definition: treeopt.hxx:211
#define OFA_TP_LANGUAGES_FOR_SET_DOCUMENT_LANGUAGE
void ActivateLastSelection()
Definition: treeopt.cxx:804
bool DispatchAction(const OUString &rAction)
Definition: treeopt.cxx:2025
std::unique_ptr< SfxTabPage > m_xPage
Definition: treeopt.cxx:444
void SetNeedsRestart(svtools::RestartReason eReason)
Definition: treeopt.cxx:1919
unsigned char sal_uInt8
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: optjava.cxx:464
#define SAL_INFO(area, stream)
static sal_uInt16 lcl_getGroupId(const OUString &rGroupName, const weld::TreeView &rTreeLB)
Definition: treeopt.cxx:1862
#define RID_SVXPAGE_ASIAN_LAYOUT
INetProtocol GetProtocol() const
RET_OK
bool IsCTLFontEnabled() const
css::uno::Reference< css::awt::XContainerWindowProvider > m_xContainerWinProvider
Definition: treeopt.hxx:142
static void SetViewOptUserItem(SvtViewOptions &rOpt, const OUString &rData)
Definition: treeopt.cxx:123
virtual bool get_iter_first(TreeIter &rIter) const =0
Reference< XExecutableDialog > m_xDialog
std::unique_ptr< SfxTabPage >(* CreateTabPage)(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
sal_uInt16 AddGroup(const OUString &rGroupName, SfxShell *pCreateShell, SfxModule *pCreateModule, sal_uInt16 nDialogId)
Definition: treeopt.cxx:596
static void ApplyItemSet(sal_uInt16 nId, const SfxItemSet &rSet)
Definition: treeopt.cxx:1151
Reference< XComponentContext > getProcessComponentContext()
css::uno::Any GetUserItem(const OUString &sName) const
#define RID_SVXPAGE_BASICIDE_OPTIONS
static void EnableQuickHelp()
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
#define RID_SVXPAGE_INET_PROXY
static void deleteGroupNames()
Definition: treeopt.cxx:207
DeactivateRC
OUString sId
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: optinet2.cxx:852
static std::unique_ptr< Module > LoadModule(const OUString &rModuleIdentifier)
Definition: treeopt.cxx:1669
IMPL_LINK_NOARG(OfaTreeOptionsDialog, ShowPageHdl_Impl, weld::TreeView &, void)
Definition: treeopt.cxx:618
static SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
static sal_uInt16 getGroupNodeId(const OUString &rModule)
Definition: treeopt.cxx:213
virtual short run() override
Definition: treeopt.cxx:1925
Reference< XSingleServiceFactory > xFactory
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *_rAttrSet)
std::unique_ptr< weld::Button > xBackPB
Definition: treeopt.hxx:121
static bool lcl_getStringFromID(sal_uInt16 _nPageId, OUString &_rGroupName, OUString &_rPageName)
Definition: treeopt.cxx:407
WinBits GetStyle() const
void InsertNodes(const VectorOfNodes &rNodeList)
Definition: treeopt.cxx:1897
virtual void ImplCommit()=0
#define RID_SFXPAGE_LINGU
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
weld::Container * m_pContainer
Definition: treeopt.hxx:203
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: optgdlg.cxx:793
OUString m_sEventHdl
Definition: treeopt.hxx:207
void InitTreeAndHandler()
Definition: treeopt.cxx:764
#define OFA_TP_LANGUAGES
static std::unique_ptr< SfxTabPage > CreateGeneralTabPage(sal_uInt16 nId, weld::Container *pPage, weld::DialogController *pController, const SfxItemSet &rSet)
Definition: treeopt.cxx:269
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: optpath.cxx:210
#define RID_OPTPAGE_CHART_DEFCOLORS
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: optgdlg.cxx:327
std::unique_ptr< SfxItemSet > CreateItemSet(sal_uInt16 nId)
Definition: treeopt.cxx:999
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rAttrSet)
Definition: optgenrl.cxx:339
static SfxModule * GetModule(SfxToolsModule nSharedLib)
sal_uInt16 Which() const
int GetMinimumEditHeight()
bool IsPageHidden(const OUString &_rPage, const OUString &_rGroup) const
#define RID_SVXPAGE_OPTIONS_JAVA
OUString m_sPageURL
Definition: treeopt.cxx:446
const char first[]
static bool isNodeActive(OptionsNode const *pNode, Module *pModule)
Definition: treeopt.cxx:1597
std::vector< std::unique_ptr< OrderedEntry > > m_aNodeList
Definition: treeopt.hxx:49
virtual int get_iter_depth(const TreeIter &rIter) const =0
void ActivatePage(sal_uInt16 nResId)
Definition: treeopt.cxx:774
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
void setHeight(long nHeight)