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