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