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