bump product version to 5.0.4.1
[LibreOffice.git] / cui / source / options / treeopt.cxx
blob5691393f3da1689748d8683f68e65190e8699602
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <config_features.h>
22 #include "cuires.hrc"
23 #include "helpid.hrc"
25 #include <svx/dialogs.hrc>
27 #include "cfgchart.hxx"
28 #include "connpoolconfig.hxx"
29 #include "connpooloptions.hxx"
30 #include "cuioptgenrl.hxx"
31 #include "cuitabarea.hxx"
32 #include "dbregister.hxx"
33 #include "dbregisterednamesconfig.hxx"
34 #include "dialmgr.hxx"
35 #include "fontsubs.hxx"
36 #include "optaboutconfig.hxx"
37 #include "optaccessibility.hxx"
38 #include "optasian.hxx"
39 #include "optchart.hxx"
40 #include "optcolor.hxx"
41 #include "optctl.hxx"
42 #include "optfltr.hxx"
43 #include "optgdlg.hxx"
44 #include "opthtml.hxx"
45 #include "optinet2.hxx"
46 #include "optjava.hxx"
47 #include "optjsearch.hxx"
48 #include "optlingu.hxx"
49 #include "optmemory.hxx"
50 #if HAVE_FEATURE_OPENCL
51 #include "optopencl.hxx"
52 #endif
53 #include "optpath.hxx"
54 #include "optsave.hxx"
55 #include "optupdt.hxx"
56 #include "personalization.hxx"
57 #include "treeopt.hxx"
58 #include "optbasic.hxx"
60 #include <com/sun/star/awt/XContainerWindowEventHandler.hpp>
61 #include <com/sun/star/awt/ContainerWindowProvider.hpp>
62 #include <com/sun/star/awt/XControl.hpp>
63 #include <com/sun/star/awt/PosSize.hpp>
64 #include <com/sun/star/frame/Desktop.hpp>
65 #include <com/sun/star/frame/ModuleManager.hpp>
66 #include <com/sun/star/loader/CannotActivateFactoryException.hpp>
67 #include <com/sun/star/linguistic2/LinguProperties.hpp>
68 #include <com/sun/star/setup/UpdateCheck.hpp>
69 #include <comphelper/getexpandeduri.hxx>
70 #include <comphelper/processfactory.hxx>
71 #include <editeng/langitem.hxx>
72 #include <editeng/optitems.hxx>
73 #include <editeng/unolingu.hxx>
74 #include <linguistic/misc.hxx>
75 #include <officecfg/Office/OptionsDialog.hxx>
76 #include <osl/module.hxx>
77 #include <osl/process.h>
78 #include <rtl/bootstrap.hxx>
79 #include <sfx2/app.hxx>
80 #include <sfx2/dispatch.hxx>
81 #include <sfx2/module.hxx>
82 #include <sfx2/printopt.hxx>
83 #include <sfx2/shell.hxx>
84 #include <sfx2/tplpitem.hxx>
85 #include <sfx2/viewsh.hxx>
86 #include <svl/languageoptions.hxx>
87 #include <svtools/helpopt.hxx>
88 #include <svx/drawitem.hxx>
89 #include <svx/xtable.hxx>
90 #include <svx/xpool.hxx>
91 #include <toolkit/helper/vclunohelper.hxx>
92 #include <tools/shl.hxx>
93 #include <tools/urlobj.hxx>
94 #include <unotools/linguprops.hxx>
95 #include <unotools/misccfg.hxx>
96 #include <unotools/moduleoptions.hxx>
97 #include <unotools/optionsdlg.hxx>
98 #include <unotools/viewoptions.hxx>
99 #include <vcl/help.hxx>
100 #include <vcl/layout.hxx>
101 #include <vcl/msgbox.hxx>
102 #include <vcl/waitobj.hxx>
103 #include <vcl/settings.hxx>
104 #include "svtools/treelistentry.hxx"
106 #ifdef LINUX
107 #include <sys/stat.h>
108 #endif
110 #include <boost/scoped_ptr.hpp>
112 using namespace ::com::sun::star;
113 using namespace ::com::sun::star::beans;
114 using namespace ::com::sun::star::container;
115 using namespace ::com::sun::star::frame;
116 using namespace ::com::sun::star::lang;
117 using namespace ::com::sun::star::linguistic2;
118 using namespace ::com::sun::star::uno;
119 using namespace ::com::sun::star::util;
121 LastPageSaver* OfaTreeOptionsDialog::pLastPageSaver = NULL;
123 // some stuff for easier changes for SvtViewOptions
124 static const sal_Char* pViewOptDataName = "page data";
125 #define VIEWOPT_DATANAME OUString::createFromAscii( pViewOptDataName )
127 static XOutdevItemPool* mpStaticXOutdevItemPool = 0L;
129 static inline void SetViewOptUserItem( SvtViewOptions& rOpt, const OUString& rData )
131 rOpt.SetUserItem( VIEWOPT_DATANAME, makeAny( OUString( rData ) ) );
134 static inline OUString GetViewOptUserItem( const SvtViewOptions& rOpt )
136 Any aAny( rOpt.GetUserItem( VIEWOPT_DATANAME ) );
137 OUString aUserData;
138 aAny >>= aUserData;
140 return aUserData;
143 struct ModuleToGroupNameMap_Impl
145 const char* m_pModule;
146 OUString m_sGroupName;
147 sal_uInt16 m_nNodeId;
150 static OfaPageResource* pPageRes = NULL;
152 static ModuleToGroupNameMap_Impl ModuleMap[] =
154 { "ProductName", OUString(), SID_GENERAL_OPTIONS },
155 { "LanguageSettings", OUString(), SID_LANGUAGE_OPTIONS },
156 { "Internet", OUString(), SID_INET_DLG },
157 { "LoadSave", OUString(), SID_FILTER_DLG },
158 { "Writer", OUString(), SID_SW_EDITOPTIONS },
159 { "WriterWeb", OUString(), SID_SW_ONLINEOPTIONS },
160 { "Math", OUString(), SID_SM_EDITOPTIONS },
161 { "Calc", OUString(), SID_SC_EDITOPTIONS },
162 { "Impress", OUString(), SID_SD_EDITOPTIONS },
163 { "Draw", OUString(), SID_SD_GRAPHIC_OPTIONS },
164 { "Charts", OUString(), SID_SCH_EDITOPTIONS },
165 { "Base", OUString(), SID_SB_STARBASEOPTIONS },
167 { NULL, OUString(), 0xFFFF }
170 static void setGroupName( const OUString& rModule, const OUString& rGroupName )
172 sal_uInt16 nIndex = 0;
173 while ( ModuleMap[ nIndex ].m_pModule )
175 OUString sTemp =
176 OUString::createFromAscii( ModuleMap[ nIndex ].m_pModule );
177 if ( sTemp == rModule )
179 ModuleMap[ nIndex ].m_sGroupName = rGroupName;
180 break;
182 ++nIndex;
186 static OUString getGroupName( const OUString& rModule, bool bForced )
188 OUString sGroupName;
189 sal_uInt16 nIndex = 0;
190 while ( ModuleMap[ nIndex ].m_pModule )
192 OUString sTemp =
193 OUString::createFromAscii( ModuleMap[ nIndex ].m_pModule );
194 if ( sTemp == rModule )
196 sGroupName = ModuleMap[ nIndex ].m_sGroupName;
197 break;
199 ++nIndex;
202 if ( sGroupName.isEmpty() && bForced )
204 if ( !pPageRes )
205 pPageRes = new OfaPageResource;
207 if ( rModule == "Writer" )
208 sGroupName = pPageRes->GetTextArray().GetString(0);
209 else if ( rModule == "WriterWeb" )
210 sGroupName = pPageRes->GetHTMLArray().GetString(0);
211 else if ( rModule == "Calc" )
212 sGroupName = pPageRes->GetCalcArray().GetString(0);
213 else if ( rModule == "Impress" )
214 sGroupName = pPageRes->GetImpressArray().GetString(0);
215 else if ( rModule == "Draw" )
216 sGroupName = pPageRes->GetDrawArray().GetString(0);
217 else if ( rModule == "Math" )
218 sGroupName = pPageRes->GetStarMathArray().GetString(0);
219 else if ( rModule == "Base" )
220 sGroupName = pPageRes->GetDatasourcesArray().GetString(0);
222 return sGroupName;
225 static void deleteGroupNames()
227 sal_uInt16 nIndex = 0;
228 while ( ModuleMap[ nIndex ].m_pModule )
229 ModuleMap[ nIndex++ ].m_sGroupName.clear();
232 static sal_uInt16 getGroupNodeId( const OUString& rModule )
234 sal_uInt16 nNodeId = 0xFFFF, nIndex = 0;
235 while ( ModuleMap[ nIndex ].m_pModule )
237 OUString sTemp =
238 OUString::createFromAscii( ModuleMap[ nIndex ].m_pModule );
239 if ( sTemp == rModule )
241 nNodeId = ModuleMap[ nIndex ].m_nNodeId;
242 break;
244 ++nIndex;
247 return nNodeId;
250 class MailMergeCfg_Impl : public utl::ConfigItem
252 private:
253 friend class SvxEMailTabPage;
254 // variables
255 bool bIsEmailSupported;
257 virtual void ImplCommit() SAL_OVERRIDE;
259 public:
260 MailMergeCfg_Impl();
261 virtual ~MailMergeCfg_Impl();
263 virtual void Notify( const com::sun::star::uno::Sequence< OUString >& _rPropertyNames) SAL_OVERRIDE;
265 bool IsEmailSupported() const {return bIsEmailSupported;}
269 MailMergeCfg_Impl::MailMergeCfg_Impl() :
270 utl::ConfigItem("Office.Writer/MailMergeWizard"),
271 bIsEmailSupported(false)
273 Sequence<OUString> aNames(1);
274 aNames.getArray()[0] = "EMailSupported";
275 const Sequence< Any > aValues = GetProperties(aNames);
276 const Any* pValues = aValues.getConstArray();
277 if(aValues.getLength() && pValues[0].hasValue())
278 pValues[0] >>= bIsEmailSupported;
281 MailMergeCfg_Impl::~MailMergeCfg_Impl()
284 /* -------------------------------------------------------------------------*/
285 void MailMergeCfg_Impl::ImplCommit()
289 void MailMergeCfg_Impl::Notify( const com::sun::star::uno::Sequence< OUString >& )
293 //typedef SfxTabPage* (*FNCreateTabPage)( vcl::Window *pParent, const SfxItemSet &rAttrSet );
294 VclPtr<SfxTabPage> CreateGeneralTabPage( sal_uInt16 nId, vcl::Window* pParent, const SfxItemSet& rSet )
296 CreateTabPage fnCreate = 0;
297 switch(nId)
299 case RID_SFXPAGE_SAVE: fnCreate = &SvxSaveTabPage::Create; break;
300 case RID_SFXPAGE_PATH: fnCreate = &SvxPathTabPage::Create; break;
301 case RID_SFXPAGE_GENERAL: fnCreate = &SvxGeneralTabPage::Create; break;
302 case RID_SFXPAGE_PRINTOPTIONS: fnCreate = &SfxCommonPrintOptionsTabPage::Create; break;
303 case OFA_TP_LANGUAGES: fnCreate = &OfaLanguagesTabPage::Create; break;
304 case RID_SFXPAGE_LINGU: fnCreate = &SvxLinguTabPage::Create; break;
305 case RID_SVXPAGE_COLOR: fnCreate = &SvxColorTabPage::Create; break;
306 case OFA_TP_VIEW: fnCreate = &OfaViewTabPage::Create; break;
307 case OFA_TP_MISC: fnCreate = &OfaMiscTabPage::Create; break;
308 case OFA_TP_MEMORY: fnCreate = &OfaMemoryOptionsPage::Create; break;
309 case RID_SVXPAGE_ASIAN_LAYOUT: fnCreate = &SvxAsianLayoutPage::Create; break;
310 case RID_SVX_FONT_SUBSTITUTION: fnCreate = &SvxFontSubstTabPage::Create; break;
311 case RID_SVXPAGE_INET_PROXY: fnCreate = &SvxProxyTabPage::Create; break;
312 case RID_SVXPAGE_INET_SECURITY: fnCreate = &SvxSecurityTabPage::Create; break;
313 case RID_SVXPAGE_INET_MAIL: fnCreate = &SvxEMailTabPage::Create; break;
314 case RID_SVXPAGE_PERSONALIZATION: fnCreate = &SvxPersonalizationTabPage::Create; break;
315 case RID_SVXPAGE_COLORCONFIG: fnCreate = &SvxColorOptionsTabPage::Create; break;
316 case RID_OFAPAGE_HTMLOPT: fnCreate = &OfaHtmlTabPage::Create; break;
317 case SID_OPTFILTER_MSOFFICE: fnCreate = &OfaMSFilterTabPage::Create; break;
318 case RID_OFAPAGE_MSFILTEROPT2: fnCreate = &OfaMSFilterTabPage2::Create; break;
319 case RID_SVXPAGE_JSEARCH_OPTIONS: fnCreate = &SvxJSearchOptionsPage::Create ; break;
320 case SID_SB_CONNECTIONPOOLING: fnCreate = &::offapp::ConnectionPoolOptionsPage::Create; break;
321 case SID_SB_DBREGISTEROPTIONS: fnCreate = &svx::DbRegistrationOptionsPage::Create; break;
322 case RID_SVXPAGE_ACCESSIBILITYCONFIG: fnCreate = &SvxAccessibilityOptionsTabPage::Create; break;
323 case RID_SVXPAGE_OPTIONS_CTL: fnCreate = &SvxCTLOptionsPage::Create ; break;
324 case RID_SVXPAGE_OPTIONS_JAVA: fnCreate = &SvxJavaOptionsPage::Create ; break;
325 #if HAVE_FEATURE_OPENCL
326 case RID_SVXPAGE_OPENCL: fnCreate = &SvxOpenCLTabPage::Create ; break;
327 #endif
328 case RID_SVXPAGE_ONLINEUPDATE: fnCreate = &SvxOnlineUpdateTabPage::Create; break;
329 case RID_OPTPAGE_CHART_DEFCOLORS: fnCreate = &SvxDefaultColorOptPage::Create; break;
330 #if HAVE_FEATURE_SCRIPTING
331 case RID_SVXPAGE_BASICIDE_OPTIONS: fnCreate = &SvxBasicIDEOptionsPage::Create; break;
332 #endif
335 VclPtr<SfxTabPage> pRet = fnCreate ? (*fnCreate)( pParent, &rSet ) : nullptr;
336 return pRet;
339 struct OptionsMapping_Impl
341 const char* m_pGroupName;
342 const char* m_pPageName;
343 sal_uInt16 m_nPageId;
346 static OptionsMapping_Impl const OptionsMap_Impl[] =
348 // GROUP PAGE PAGE-ID
349 { "ProductName", NULL, SID_GENERAL_OPTIONS },
350 { "ProductName", "UserData", RID_SFXPAGE_GENERAL },
351 { "ProductName", "General", OFA_TP_MISC },
352 { "ProductName", "Memory", OFA_TP_MEMORY },
353 { "ProductName", "View", OFA_TP_VIEW },
354 { "ProductName", "Print", RID_SFXPAGE_PRINTOPTIONS },
355 { "ProductName", "Paths", RID_SFXPAGE_PATH },
356 { "ProductName", "Colors", RID_SVXPAGE_COLOR },
357 { "ProductName", "Fonts", RID_SVX_FONT_SUBSTITUTION },
358 { "ProductName", "Security", RID_SVXPAGE_INET_SECURITY },
359 { "ProductName", "Personalization", RID_SVXPAGE_PERSONALIZATION },
360 { "ProductName", "Appearance", RID_SVXPAGE_COLORCONFIG },
361 { "ProductName", "Accessibility", RID_SVXPAGE_ACCESSIBILITYCONFIG },
362 { "ProductName", "Java", RID_SVXPAGE_OPTIONS_JAVA },
363 { "ProductName", "BasicIDEOptions", RID_SVXPAGE_BASICIDE_OPTIONS },
364 { "ProductName", "OnlineUpdate", RID_SVXPAGE_ONLINEUPDATE },
365 { "LanguageSettings", NULL, SID_LANGUAGE_OPTIONS },
366 { "LanguageSettings", "Languages", OFA_TP_LANGUAGES },
367 { "LanguageSettings", "WritingAids", RID_SFXPAGE_LINGU },
368 { "LanguageSettings", "SearchingInJapanese", RID_SVXPAGE_JSEARCH_OPTIONS },
369 { "LanguageSettings", "AsianLayout", RID_SVXPAGE_ASIAN_LAYOUT },
370 { "LanguageSettings", "ComplexTextLayout", RID_SVXPAGE_OPTIONS_CTL },
371 { "Internet", NULL, SID_INET_DLG },
372 { "Internet", "Proxy", RID_SVXPAGE_INET_PROXY },
373 { "Internet", "Email", RID_SVXPAGE_INET_MAIL },
374 { "LoadSave", NULL, SID_FILTER_DLG },
375 { "LoadSave", "General", RID_SFXPAGE_SAVE },
376 { "LoadSave", "VBAProperties", SID_OPTFILTER_MSOFFICE },
377 { "LoadSave", "MicrosoftOffice", RID_OFAPAGE_MSFILTEROPT2 },
378 { "LoadSave", "HTMLCompatibility", RID_OFAPAGE_HTMLOPT },
379 { "Writer", NULL, SID_SW_EDITOPTIONS },
380 { "Writer", "General", RID_SW_TP_OPTLOAD_PAGE },
381 { "Writer", "View", RID_SW_TP_CONTENT_OPT },
382 { "Writer", "FormattingAids", RID_SW_TP_OPTSHDWCRSR },
383 { "Writer", "Grid", RID_SVXPAGE_GRID },
384 { "Writer", "BasicFontsWestern", RID_SW_TP_STD_FONT },
385 { "Writer", "BasicFontsAsian", RID_SW_TP_STD_FONT_CJK },
386 { "Writer", "BasicFontsCTL", RID_SW_TP_STD_FONT_CTL },
387 { "Writer", "Print", RID_SW_TP_OPTPRINT_PAGE },
388 { "Writer", "Table", RID_SW_TP_OPTTABLE_PAGE },
389 { "Writer", "Changes", RID_SW_TP_REDLINE_OPT },
390 { "Writer", "Comparison", RID_SW_TP_COMPARISON_OPT },
391 { "Writer", "Compatibility", RID_SW_TP_OPTCOMPATIBILITY_PAGE },
392 { "Writer", "AutoCaption", RID_SW_TP_OPTCAPTION_PAGE },
393 { "Writer", "MailMerge", RID_SW_TP_MAILCONFIG },
394 { "WriterWeb", NULL, SID_SW_ONLINEOPTIONS },
395 { "WriterWeb", "View", RID_SW_TP_HTML_CONTENT_OPT },
396 { "WriterWeb", "FormattingAids", RID_SW_TP_HTML_OPTSHDWCRSR },
397 { "WriterWeb", "Grid", RID_SW_TP_HTML_OPTGRID_PAGE },
398 { "WriterWeb", "Print", RID_SW_TP_HTML_OPTPRINT_PAGE },
399 { "WriterWeb", "Table", RID_SW_TP_HTML_OPTTABLE_PAGE },
400 { "WriterWeb", "Background", RID_SW_TP_BACKGROUND },
401 { "Math", NULL, SID_SM_EDITOPTIONS },
402 { "Math", "Settings", SID_SM_TP_PRINTOPTIONS },
403 { "Calc", NULL, SID_SC_EDITOPTIONS },
404 { "Calc", "General", SID_SC_TP_LAYOUT },
405 { "Calc", "View", SID_SC_TP_CONTENT },
406 { "Calc", "Calculate", SID_SC_TP_CALC },
407 { "Calc", "Formula", SID_SC_TP_FORMULA },
408 { "Calc", "SortLists", SID_SC_TP_USERLISTS },
409 { "Calc", "Changes", SID_SC_TP_CHANGES },
410 { "Calc", "Compatibility", SID_SC_TP_COMPATIBILITY },
411 { "Calc", "Grid", SID_SC_TP_GRID },
412 { "Calc", "Print", RID_SC_TP_PRINT },
413 { "Impress", NULL, SID_SD_EDITOPTIONS },
414 { "Impress", "General", SID_SI_TP_MISC },
415 { "Impress", "View", SID_SI_TP_CONTENTS },
416 { "Impress", "Grid", SID_SI_TP_SNAP },
417 { "Impress", "Print", SID_SI_TP_PRINT },
418 { "Draw", NULL, SID_SD_GRAPHIC_OPTIONS },
419 { "Draw", "General", SID_SD_TP_MISC },
420 { "Draw", "View", SID_SD_TP_CONTENTS },
421 { "Draw", "Grid", SID_SD_TP_SNAP },
422 { "Draw", "Print", SID_SD_TP_PRINT },
423 { "Charts", NULL, SID_SCH_EDITOPTIONS },
424 { "Charts", "DefaultColors", RID_OPTPAGE_CHART_DEFCOLORS },
425 { "Base", NULL, SID_SB_STARBASEOPTIONS },
426 { "Base", "Connections", SID_SB_CONNECTIONPOOLING },
427 { "Base", "Databases", SID_SB_DBREGISTEROPTIONS },
428 { NULL, NULL, 0 }
431 static bool lcl_getStringFromID( sal_uInt16 _nPageId, OUString& _rGroupName, OUString& _rPageName )
433 bool bRet = false;
435 sal_uInt16 nIdx = 0;
436 while ( OptionsMap_Impl[nIdx].m_pGroupName != NULL )
438 if ( _nPageId == OptionsMap_Impl[nIdx].m_nPageId )
440 bRet = true;
441 _rGroupName = OUString::createFromAscii( OptionsMap_Impl[nIdx].m_pGroupName );
442 if ( OptionsMap_Impl[nIdx].m_pPageName != NULL )
443 _rPageName = OUString::createFromAscii( OptionsMap_Impl[nIdx].m_pPageName );
444 break;
446 ++nIdx;
449 return bRet;
452 static bool lcl_isOptionHidden( sal_uInt16 _nPageId, const SvtOptionsDialogOptions& _rOptOptions )
454 bool bIsHidden = false;
455 OUString sGroupName, sPageName;
456 if ( lcl_getStringFromID( _nPageId, sGroupName, sPageName ) )
458 if ( sPageName.isEmpty() )
459 bIsHidden = _rOptOptions.IsGroupHidden( sGroupName );
460 else
461 bIsHidden = _rOptOptions.IsPageHidden( sPageName, sGroupName );
463 return bIsHidden;
466 struct OptionsPageInfo
468 ScopedVclPtr<SfxTabPage> m_pPage;
469 sal_uInt16 m_nPageId;
470 OUString m_sPageURL;
471 OUString m_sEventHdl;
472 VclPtr<ExtensionsTabPage> m_pExtPage;
474 OptionsPageInfo( sal_uInt16 nId ) : m_pPage( NULL ), m_nPageId( nId ), m_pExtPage( NULL ) {}
477 struct OptionsGroupInfo
479 SfxItemSet* m_pInItemSet;
480 SfxItemSet* m_pOutItemSet;
481 SfxShell* m_pShell; // used to create the page
482 SfxModule* m_pModule; // used to create the ItemSet
483 sal_uInt16 m_nDialogId; // Id of the former dialog
484 bool m_bLoadError; // load fails?
485 OUString m_sPageURL;
486 VclPtr<ExtensionsTabPage> m_pExtPage;
488 OptionsGroupInfo( SfxShell* pSh, SfxModule* pMod, sal_uInt16 nId ) :
489 m_pInItemSet( NULL ), m_pOutItemSet( NULL ), m_pShell( pSh ),
490 m_pModule( pMod ), m_nDialogId( nId ), m_bLoadError( false ),
491 m_sPageURL( OUString() ), m_pExtPage( NULL ) {}
492 ~OptionsGroupInfo() { delete m_pInItemSet; delete m_pOutItemSet; }
495 #define INI_LIST() \
496 pCurrentPageEntry ( NULL ),\
497 sTitle ( GetText() ),\
498 sNotLoadedError ( CUI_RES( RID_SVXSTR_LOAD_ERROR ) ),\
499 pColorPageItemSet ( NULL ),\
500 mpColorPage ( NULL ),\
501 bForgetSelection ( false ),\
502 bIsFromExtensionManager( false ), \
503 bIsForSetDocumentLanguage( false )
505 void OfaTreeOptionsDialog::InitWidgets()
507 get(pOkPB, "ok");
508 get(pBackPB, "revert");
509 get(pTreeLB, "pages");
510 get(pTabBox, "box");
511 Size aSize(pTabBox->LogicToPixel(Size(278, 259), MAP_APPFONT));
512 pTabBox->set_width_request(aSize.Width());
513 pTabBox->set_height_request(aSize.Height() - get_action_area()->get_preferred_size().Height());
514 pTreeLB->set_width_request(pTreeLB->approximate_char_width() * 25);
515 pTreeLB->set_height_request(pTabBox->get_height_request());
518 // Ctor() with Frame -----------------------------------------------------
519 using namespace ::com::sun::star;
520 OfaTreeOptionsDialog::OfaTreeOptionsDialog(
521 vcl::Window* pParent,
522 const Reference< XFrame >& _xFrame,
523 bool bActivateLastSelection ) :
525 SfxModalDialog( pParent, "OptionsDialog", "cui/ui/optionsdialog.ui" ),
526 INI_LIST()
528 InitWidgets();
530 InitTreeAndHandler();
531 Initialize( _xFrame );
532 LoadExtensionOptions( OUString() );
533 if (bActivateLastSelection)
534 ActivateLastSelection();
536 pTreeLB->SetAccessibleName(GetDisplayText());
539 // Ctor() with ExtensionId -----------------------------------------------
540 OfaTreeOptionsDialog::OfaTreeOptionsDialog( vcl::Window* pParent, const OUString& rExtensionId ) :
542 SfxModalDialog( pParent, "OptionsDialog", "cui/ui/optionsdialog.ui" ),
543 INI_LIST()
545 InitWidgets();
547 bIsFromExtensionManager = ( !rExtensionId.isEmpty() );
548 InitTreeAndHandler();
549 LoadExtensionOptions( rExtensionId );
550 ActivateLastSelection();
553 OfaTreeOptionsDialog::~OfaTreeOptionsDialog()
555 disposeOnce();
558 void OfaTreeOptionsDialog::dispose()
560 pCurrentPageEntry = NULL;
561 SvTreeListEntry* pEntry = pTreeLB ? pTreeLB->First() : NULL;
562 // first children
563 while(pEntry)
565 // if Child (has parent), then OptionsPageInfo
566 if(pTreeLB->GetParent(pEntry))
568 OptionsPageInfo *pPageInfo = static_cast<OptionsPageInfo *>(pEntry->GetUserData());
569 if(pPageInfo->m_pPage)
571 pPageInfo->m_pPage->FillUserData();
572 OUString aPageData(pPageInfo->m_pPage->GetUserData());
573 if ( !aPageData.isEmpty() )
575 SvtViewOptions aTabPageOpt( E_TABPAGE, OUString::number( pPageInfo->m_nPageId) );
576 SetViewOptUserItem( aTabPageOpt, aPageData );
578 pPageInfo->m_pPage.disposeAndClear();
581 if (pPageInfo->m_nPageId == RID_SFXPAGE_LINGU)
583 // write personal dictionaries
584 Reference< XSearchableDictionaryList > xDicList( SvxGetDictionaryList() );
585 if (xDicList.is())
587 linguistic::SaveDictionaries( xDicList );
591 pPageInfo->m_pExtPage.disposeAndClear();
593 delete pPageInfo;
595 pEntry = pTreeLB->Next(pEntry);
598 // and parents
599 pEntry = pTreeLB ? pTreeLB->First() : NULL;
600 while(pEntry)
602 if(!pTreeLB->GetParent(pEntry))
604 OptionsGroupInfo* pGroupInfo = static_cast<OptionsGroupInfo*>(pEntry->GetUserData());
605 if ( pGroupInfo )
606 pGroupInfo->m_pExtPage.disposeAndClear();
607 delete pGroupInfo;
609 pEntry = pTreeLB->Next(pEntry);
611 delete pColorPageItemSet;
612 pColorPageItemSet = NULL;
613 deleteGroupNames();
614 pOkPB.clear();
615 pBackPB.clear();
616 pTreeLB.clear();
617 pTabBox.clear();
618 mpColorPage.clear();
619 SfxModalDialog::dispose();
622 OptionsPageInfo* OfaTreeOptionsDialog::AddTabPage(
623 sal_uInt16 nId, const OUString& rPageName, sal_uInt16 nGroup )
625 OptionsPageInfo* pPageInfo = new OptionsPageInfo( nId );
626 SvTreeListEntry* pParent = pTreeLB->GetEntry( 0, nGroup );
627 DBG_ASSERT( pParent, "OfaTreeOptionsDialog::AddTabPage(): no group found" );
628 SvTreeListEntry* pEntry = pTreeLB->InsertEntry( rPageName, pParent );
629 pEntry->SetUserData( pPageInfo );
630 return pPageInfo;
633 // the ItemSet* is passed on to the dialog's ownership
634 sal_uInt16 OfaTreeOptionsDialog::AddGroup(const OUString& rGroupName,
635 SfxShell* pCreateShell,
636 SfxModule* pCreateModule,
637 sal_uInt16 nDialogId )
639 SvTreeListEntry* pEntry = pTreeLB->InsertEntry(rGroupName);
640 OptionsGroupInfo* pInfo =
641 new OptionsGroupInfo( pCreateShell, pCreateModule, nDialogId );
642 pEntry->SetUserData(pInfo);
643 sal_uInt16 nRet = 0;
644 pEntry = pTreeLB->First();
645 while(pEntry)
647 if(!pTreeLB->GetParent(pEntry))
648 nRet++;
649 pEntry = pTreeLB->Next(pEntry);
651 return nRet - 1;
654 IMPL_LINK_NOARG(OfaTreeOptionsDialog, ShowPageHdl_Impl)
656 SelectHdl_Impl();
657 return 0;
660 IMPL_LINK_NOARG(OfaTreeOptionsDialog, BackHdl_Impl)
662 if ( pCurrentPageEntry && pTreeLB->GetParent( pCurrentPageEntry ) )
664 OptionsPageInfo* pPageInfo = static_cast<OptionsPageInfo*>(pCurrentPageEntry->GetUserData());
665 if ( pPageInfo->m_pPage )
667 OptionsGroupInfo* pGroupInfo =
668 static_cast<OptionsGroupInfo*>(pTreeLB->GetParent( pCurrentPageEntry )->GetUserData());
669 if ( RID_SVXPAGE_COLOR == pPageInfo->m_nPageId )
670 pPageInfo->m_pPage->Reset( pColorPageItemSet );
671 else
672 pPageInfo->m_pPage->Reset( pGroupInfo->m_pInItemSet );
674 else if ( pPageInfo->m_pExtPage )
675 pPageInfo->m_pExtPage->ResetPage();
677 return 0;
680 IMPL_LINK_NOARG(OfaTreeOptionsDialog, OKHdl_Impl)
682 pTreeLB->EndSelection();
683 if ( pCurrentPageEntry && pTreeLB->GetParent( pCurrentPageEntry ) )
685 OptionsPageInfo* pPageInfo = static_cast<OptionsPageInfo *>(pCurrentPageEntry->GetUserData());
686 if ( pPageInfo->m_pPage )
688 OptionsGroupInfo* pGroupInfo =
689 static_cast<OptionsGroupInfo *>(pTreeLB->GetParent(pCurrentPageEntry)->GetUserData());
690 if ( RID_SVXPAGE_COLOR != pPageInfo->m_nPageId
691 && pPageInfo->m_pPage->HasExchangeSupport() )
693 int nLeave = pPageInfo->m_pPage->DeactivatePage(pGroupInfo->m_pOutItemSet);
694 if ( nLeave == SfxTabPage::KEEP_PAGE )
696 // the page mustn't be left
697 pTreeLB->Select(pCurrentPageEntry);
698 return 0;
701 pPageInfo->m_pPage->Hide();
705 SvTreeListEntry* pEntry = pTreeLB->First();
706 while ( pEntry )
708 if ( pTreeLB->GetParent( pEntry ) )
710 OptionsPageInfo* pPageInfo = static_cast<OptionsPageInfo *>(pEntry->GetUserData());
711 if ( pPageInfo->m_pPage && !pPageInfo->m_pPage->HasExchangeSupport() )
713 OptionsGroupInfo* pGroupInfo =
714 static_cast<OptionsGroupInfo*>(pTreeLB->GetParent(pEntry)->GetUserData());
715 pPageInfo->m_pPage->FillItemSet(pGroupInfo->m_pOutItemSet);
718 if ( pPageInfo->m_pExtPage )
720 pPageInfo->m_pExtPage->DeactivatePage();
721 pPageInfo->m_pExtPage->SavePage();
724 pEntry = pTreeLB->Next(pEntry);
726 EndDialog(RET_OK);
727 return 0;
730 // an opened group shall be completely visible
731 IMPL_STATIC_LINK(
732 OfaTreeOptionsDialog, ExpandedHdl_Impl, SvTreeListBox*, pBox )
734 pBox->Update();
735 pBox->InitStartEntry();
736 SvTreeListEntry* pEntry = pBox->GetHdlEntry();
737 if(pEntry && pBox->IsExpanded(pEntry))
739 sal_uInt32 nChildCount = pBox->GetChildCount( pEntry );
741 SvTreeListEntry* pNext = pEntry;
742 for(sal_uInt32 i = 0; i < nChildCount;i++)
744 pNext = pBox->GetNextEntryInView(pNext);
745 if(!pNext)
747 pBox->ScrollOutputArea( -(short)(nChildCount - i + 1) );
748 break;
750 else
752 Size aSz(pBox->GetOutputSizePixel());
753 int nHeight = pBox->GetEntryHeight();
754 Point aPos(pBox->GetEntryPosition(pNext));
755 if(aPos.Y()+nHeight > aSz.Height())
757 pBox->ScrollOutputArea( -(short)(nChildCount - i + 1) );
758 break;
763 return 0;
766 void OfaTreeOptionsDialog::ApplyItemSets()
768 SvTreeListEntry* pEntry = pTreeLB->First();
769 while(pEntry)
771 if(!pTreeLB->GetParent(pEntry))
773 OptionsGroupInfo* pGroupInfo = static_cast<OptionsGroupInfo *>(pEntry->GetUserData());
774 if(pGroupInfo->m_pOutItemSet)
776 if(pGroupInfo->m_pShell)
777 pGroupInfo->m_pShell->ApplyItemSet( pGroupInfo->m_nDialogId, *pGroupInfo->m_pOutItemSet);
778 else
779 ApplyItemSet( pGroupInfo->m_nDialogId, *pGroupInfo->m_pOutItemSet);
782 pEntry = pTreeLB->Next(pEntry);
786 void OfaTreeOptionsDialog::InitTreeAndHandler()
788 pTreeLB->SetNodeDefaultImages();
790 pTreeLB->SetHelpId( HID_OFADLG_TREELISTBOX );
791 pTreeLB->SetStyle( pTreeLB->GetStyle()|WB_HASBUTTONS | WB_HASBUTTONSATROOT |
792 WB_HASLINES | WB_HASLINESATROOT |
793 WB_CLIPCHILDREN | WB_HSCROLL | WB_FORCE_MAKEVISIBLE | WB_QUICK_SEARCH );
794 pTreeLB->SetSpaceBetweenEntries( 0 );
795 pTreeLB->SetSelectionMode( SINGLE_SELECTION );
796 pTreeLB->SetSublistOpenWithLeftRight( true );
797 pTreeLB->SetExpandedHdl( LINK( this, OfaTreeOptionsDialog, ExpandedHdl_Impl ) );
798 pTreeLB->SetSelectHdl( LINK( this, OfaTreeOptionsDialog, ShowPageHdl_Impl ) );
799 pBackPB->SetClickHdl( LINK( this, OfaTreeOptionsDialog, BackHdl_Impl ) );
800 pOkPB->SetClickHdl( LINK( this, OfaTreeOptionsDialog, OKHdl_Impl ) );
803 void OfaTreeOptionsDialog::ActivatePage( sal_uInt16 nResId )
805 bIsForSetDocumentLanguage = false;
806 if ( nResId == OFA_TP_LANGUAGES_FOR_SET_DOCUMENT_LANGUAGE )
808 bIsForSetDocumentLanguage = true;
809 nResId = OFA_TP_LANGUAGES;
812 DBG_ASSERT( !bIsFromExtensionManager, "OfaTreeOptionsDialog::ActivatePage(): call from extension manager" );
813 if ( !pLastPageSaver )
814 pLastPageSaver = new LastPageSaver;
815 bForgetSelection = true;
816 sal_uInt16 nTemp = pLastPageSaver->m_nLastPageId;
817 pLastPageSaver->m_nLastPageId = nResId;
818 ActivateLastSelection();
819 pLastPageSaver->m_nLastPageId = nTemp;
822 void OfaTreeOptionsDialog::ActivatePage( const OUString& rPageURL )
824 DBG_ASSERT( !bIsFromExtensionManager, "OfaTreeOptionsDialog::ActivatePage(): call from extension manager" );
825 if ( !pLastPageSaver )
826 pLastPageSaver = new LastPageSaver;
827 bForgetSelection = true;
828 pLastPageSaver->m_nLastPageId = 0;
829 pLastPageSaver->m_sLastPageURL_Tools = rPageURL;
830 ActivateLastSelection();
833 void OfaTreeOptionsDialog::ActivateLastSelection()
835 SvTreeListEntry* pEntry = NULL;
836 if ( pLastPageSaver )
838 OUString sLastURL = bIsFromExtensionManager ? pLastPageSaver->m_sLastPageURL_ExtMgr
839 : pLastPageSaver->m_sLastPageURL_Tools;
840 if ( sLastURL.isEmpty() )
842 sLastURL = !bIsFromExtensionManager ? pLastPageSaver->m_sLastPageURL_ExtMgr
843 : pLastPageSaver->m_sLastPageURL_Tools;
846 bool bMustExpand = ( INetURLObject( sLastURL ).GetProtocol() == INetProtocol::File );
848 SvTreeListEntry* pTemp = pTreeLB->First();
849 while( !pEntry && pTemp )
851 // restore only selection of a leaf
852 if ( pTreeLB->GetParent( pTemp ) && pTemp->GetUserData() )
854 OptionsPageInfo* pPageInfo = static_cast<OptionsPageInfo*>(pTemp->GetUserData());
855 OUString sPageURL = pPageInfo->m_sPageURL;
856 if ( bMustExpand )
858 sPageURL = comphelper::getExpandedUri(
859 comphelper::getProcessComponentContext(), sPageURL);
862 if ( ( !bIsFromExtensionManager
863 && pPageInfo->m_nPageId && pPageInfo->m_nPageId == pLastPageSaver->m_nLastPageId )
864 || ( !pPageInfo->m_nPageId && sLastURL == sPageURL ) )
865 pEntry = pTemp;
867 pTemp = pTreeLB->Next(pTemp);
871 if ( !pEntry )
873 pEntry = pTreeLB->First();
874 pEntry = pTreeLB->Next(pEntry);
877 if ( !pEntry )
878 return;
880 SvTreeListEntry* pParent = pTreeLB->GetParent(pEntry);
881 pTreeLB->Expand(pParent);
882 pTreeLB->MakeVisible(pParent);
883 pTreeLB->MakeVisible(pEntry);
884 pTreeLB->Select(pEntry);
885 pTreeLB->GrabFocus();
888 bool OfaTreeOptionsDialog::Notify( NotifyEvent& rNEvt )
890 if ( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT )
892 const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
893 const vcl::KeyCode aKeyCode = pKEvt->GetKeyCode();
895 if( aKeyCode.GetCode() == KEY_PAGEUP ||
896 aKeyCode.GetCode() == KEY_PAGEDOWN)
898 SvTreeListEntry* pCurEntry = pTreeLB->FirstSelected();
899 SvTreeListEntry* pTemp = 0;
900 if(aKeyCode.GetCode() == KEY_PAGEDOWN)
902 pTemp = pTreeLB->Next( pCurEntry ) ;
903 if(pTemp && !pTreeLB->GetParent(pTemp))
905 pTemp = pTreeLB->Next( pTemp ) ;
906 pTreeLB->Select(pTemp);
909 else
911 pTemp = pTreeLB->Prev( pCurEntry ) ;
912 if(pTemp && !pTreeLB->GetParent(pTemp))
914 pTemp = pTreeLB->Prev( pTemp ) ;
917 if(pTemp)
919 if(!pTreeLB->IsExpanded(pTreeLB->GetParent(pTemp)))
920 pTreeLB->Expand(pTreeLB->GetParent(pTemp));
921 pTreeLB->MakeVisible(pTemp);
922 pTreeLB->Select(pTemp);
926 return SfxModalDialog::Notify(rNEvt);
929 void OfaTreeOptionsDialog::SelectHdl_Impl()
931 SvTreeListBox* pBox = pTreeLB;
933 if(pCurrentPageEntry == pBox->GetCurEntry())
935 pBox->EndSelection();
936 return;
939 SvTreeListEntry* pEntry = pBox->GetCurEntry();
940 SvTreeListEntry* pParent = pBox->GetParent(pEntry);
942 // If the user has selected a category, automatically switch to a suitable
943 // default sub-page instead.
944 if (!pParent)
946 pBox->EndSelection();
947 return;
950 pBox->EndSelection();
952 TabPage* pOldPage = NULL;
953 TabPage* pNewPage = NULL;
954 OptionsPageInfo* pOptPageInfo = ( pCurrentPageEntry && pTreeLB->GetParent( pCurrentPageEntry ) )
955 ? static_cast<OptionsPageInfo*>(pCurrentPageEntry->GetUserData()) : NULL;
957 if ( pOptPageInfo && pOptPageInfo->m_pPage && pOptPageInfo->m_pPage->IsVisible() )
959 pOldPage = pOptPageInfo->m_pPage;
960 OptionsGroupInfo* pGroupInfo = static_cast<OptionsGroupInfo*>(pTreeLB->GetParent(pCurrentPageEntry)->GetUserData());
961 int nLeave = SfxTabPage::LEAVE_PAGE;
962 if ( RID_SVXPAGE_COLOR != pOptPageInfo->m_nPageId && pOptPageInfo->m_pPage->HasExchangeSupport() )
963 nLeave = pOptPageInfo->m_pPage->DeactivatePage( pGroupInfo->m_pOutItemSet );
965 if ( nLeave == SfxTabPage::KEEP_PAGE )
967 // we cannot leave this page
968 pBox->Select( pCurrentPageEntry );
969 return;
971 else
972 pOptPageInfo->m_pPage->Hide();
974 else if ( pOptPageInfo && pOptPageInfo->m_pExtPage )
976 pOptPageInfo->m_pExtPage->Hide();
977 pOptPageInfo->m_pExtPage->DeactivatePage();
979 else if ( pCurrentPageEntry && !pTreeLB->GetParent( pCurrentPageEntry ) )
981 OptionsGroupInfo* pGroupInfo = static_cast<OptionsGroupInfo*>(pCurrentPageEntry->GetUserData());
982 if ( pGroupInfo && pGroupInfo->m_pExtPage )
984 pGroupInfo->m_pExtPage->Hide();
985 pGroupInfo->m_pExtPage->DeactivatePage();
989 OptionsPageInfo *pPageInfo = static_cast<OptionsPageInfo *>(pEntry->GetUserData());
990 OptionsGroupInfo* pGroupInfo = static_cast<OptionsGroupInfo *>(pParent->GetUserData());
991 if(!pPageInfo->m_pPage && pPageInfo->m_nPageId > 0)
993 if(pGroupInfo->m_bLoadError)
994 return;
995 if ( RID_SVXPAGE_COLOR == pPageInfo->m_nPageId )
997 if(!pColorPageItemSet)
999 // Move usage of a static XOutdevItemPool instance here
1000 if(!mpStaticXOutdevItemPool)
1001 mpStaticXOutdevItemPool = new XOutdevItemPool();
1003 pColorPageItemSet = new SfxItemSet( *mpStaticXOutdevItemPool, XATTR_FILLSTYLE, XATTR_FILLCOLOR);
1004 pColorPageItemSet->Put( XFillColorItem() );
1007 else
1009 if(pGroupInfo->m_pModule /*&& !pGroupInfo->pModule->IsLoaded()*/)
1011 SfxModule* pOldModule = pGroupInfo->m_pModule;
1012 bool bIdentical = pGroupInfo->m_pModule == pGroupInfo->m_pShell;
1014 WaitObject aWait(this);
1015 //pGroupInfo->pModule = pGroupInfo->pModule->Load();
1016 if(!pGroupInfo->m_pModule)
1018 pGroupInfo->m_bLoadError = true;
1019 ScopedVclPtr<InfoBox>::Create(pBox, sNotLoadedError)->Execute();
1020 return;
1022 if(bIdentical)
1023 pGroupInfo->m_pShell = pGroupInfo->m_pModule;
1024 // now test whether there was the same module in other groups, too (e. g. Text+HTML)
1025 SvTreeListEntry* pTemp = pTreeLB->First();
1026 while(pTemp)
1028 if(!pTreeLB->GetParent(pTemp) && pTemp != pEntry)
1030 OptionsGroupInfo* pTGInfo = static_cast<OptionsGroupInfo *>(pTemp->GetUserData());
1031 if(pTGInfo->m_pModule == pOldModule)
1033 pTGInfo->m_pModule = pGroupInfo->m_pModule;
1034 if(bIdentical)
1035 pTGInfo->m_pShell = pGroupInfo->m_pModule;
1038 pTemp = pTreeLB->Next(pTemp);
1042 if(!pGroupInfo->m_pInItemSet)
1043 pGroupInfo->m_pInItemSet = pGroupInfo->m_pShell
1044 ? pGroupInfo->m_pShell->CreateItemSet( pGroupInfo->m_nDialogId )
1045 : CreateItemSet( pGroupInfo->m_nDialogId );
1046 if(!pGroupInfo->m_pOutItemSet)
1047 pGroupInfo->m_pOutItemSet = new SfxItemSet(
1048 *pGroupInfo->m_pInItemSet->GetPool(),
1049 pGroupInfo->m_pInItemSet->GetRanges());
1052 if(pPageInfo->m_nPageId == RID_SVXPAGE_COLOR)
1054 pPageInfo->m_pPage.reset( ::CreateGeneralTabPage(
1055 pPageInfo->m_nPageId, pTabBox, *pColorPageItemSet ) );
1056 mpColorPage = static_cast<SvxColorTabPage*>(pPageInfo->m_pPage.get());
1057 mpColorPage->SetupForViewFrame( SfxViewFrame::Current() );
1059 else
1061 pPageInfo->m_pPage.reset( ::CreateGeneralTabPage(pPageInfo->m_nPageId, pTabBox, *pGroupInfo->m_pInItemSet ) );
1063 if(!pPageInfo->m_pPage && pGroupInfo->m_pModule)
1064 pPageInfo->m_pPage.reset( pGroupInfo->m_pModule->CreateTabPage(pPageInfo->m_nPageId, pTabBox, *pGroupInfo->m_pInItemSet) );
1068 DBG_ASSERT( pPageInfo->m_pPage, "tabpage could not created");
1069 if ( pPageInfo->m_pPage )
1071 SvtViewOptions aTabPageOpt( E_TABPAGE, OUString::number( pPageInfo->m_nPageId) );
1072 pPageInfo->m_pPage->SetUserData( GetViewOptUserItem( aTabPageOpt ) );
1074 if ( RID_SVXPAGE_COLOR == pPageInfo->m_nPageId )
1076 pPageInfo->m_pPage->Reset( pColorPageItemSet );
1077 pPageInfo->m_pPage->ActivatePage( *pColorPageItemSet );
1079 else
1081 pPageInfo->m_pPage->Reset( pGroupInfo->m_pInItemSet );
1085 else if ( 0 == pPageInfo->m_nPageId && !pPageInfo->m_pExtPage )
1087 if ( !m_xContainerWinProvider.is() )
1089 m_xContainerWinProvider = awt::ContainerWindowProvider::create( ::comphelper::getProcessComponentContext() );
1092 pPageInfo->m_pExtPage = VclPtr<ExtensionsTabPage>::Create(
1094 pTabBox, 0, pPageInfo->m_sPageURL, pPageInfo->m_sEventHdl, m_xContainerWinProvider );
1097 if ( pPageInfo->m_pPage )
1099 if ( RID_SVXPAGE_COLOR != pPageInfo->m_nPageId &&
1100 pPageInfo->m_pPage->HasExchangeSupport())
1102 pPageInfo->m_pPage->ActivatePage(*pGroupInfo->m_pOutItemSet);
1104 pPageInfo->m_pPage->Show();
1106 else if ( pPageInfo->m_pExtPage )
1108 pPageInfo->m_pExtPage->Show();
1109 pPageInfo->m_pExtPage->ActivatePage();
1113 OUStringBuffer sTitleBuf(sTitle);
1114 sTitleBuf.append(" - ");
1115 sTitleBuf.append(pTreeLB->GetEntryText(pParent));
1116 sTitleBuf.append(" - ");
1117 sTitleBuf.append(pTreeLB->GetEntryText(pEntry));
1118 SetText(sTitleBuf.makeStringAndClear());
1121 pCurrentPageEntry = pEntry;
1122 if ( !bForgetSelection )
1124 if ( !pLastPageSaver )
1125 pLastPageSaver = new LastPageSaver;
1126 if ( !bIsFromExtensionManager )
1127 pLastPageSaver->m_nLastPageId = pPageInfo->m_nPageId;
1128 if ( pPageInfo->m_pExtPage )
1130 if ( bIsFromExtensionManager )
1131 pLastPageSaver->m_sLastPageURL_ExtMgr = pPageInfo->m_sPageURL;
1132 else
1133 pLastPageSaver->m_sLastPageURL_Tools = pPageInfo->m_sPageURL;
1136 pNewPage = pPageInfo->m_pPage;
1138 // restore lost focus, if necessary
1139 vcl::Window* pFocusWin = Application::GetFocusWindow();
1140 // if the focused window is not the options treebox and the old page has the focus
1141 if ( pFocusWin && pFocusWin != pBox && pOldPage && pOldPage->HasChildPathFocus() )
1142 // then set the focus to the new page or if we are on a group set the focus to the options treebox
1143 pNewPage ? pNewPage->GrabFocus() : pBox->GrabFocus();
1145 //fdo#58170 use current page's layout child HelpId, unless there isn't a
1146 //current page
1147 OString sHelpId(HID_OFADLG_TREELISTBOX);
1148 if (::isLayoutEnabled(pNewPage))
1150 vcl::Window *pFirstChild = pNewPage->GetWindow(GetWindowType::FirstChild);
1151 assert(pFirstChild);
1152 sHelpId = pFirstChild->GetHelpId();
1154 pBox->SetHelpId(sHelpId);
1156 return;
1159 OfaPageResource::OfaPageResource() :
1160 Resource(CUI_RES(RID_OFADLG_OPTIONS_TREE_PAGES)),
1161 aGeneralDlgAry(CUI_RES(SID_GENERAL_OPTIONS)),
1162 aInetDlgAry(CUI_RES(SID_INET_DLG)),
1163 aLangDlgAry(CUI_RES(SID_LANGUAGE_OPTIONS)),
1164 aTextDlgAry(CUI_RES(SID_SW_EDITOPTIONS)),
1165 aHTMLDlgAry(CUI_RES(SID_SW_ONLINEOPTIONS)),
1166 aCalcDlgAry(CUI_RES(SID_SC_EDITOPTIONS)),
1167 aStarMathDlgAry(CUI_RES(SID_SM_EDITOPTIONS)),
1168 aImpressDlgAry(CUI_RES(SID_SD_EDITOPTIONS)),
1169 aDrawDlgAry(CUI_RES(SID_SD_GRAPHIC_OPTIONS)),
1170 aChartDlgAry(CUI_RES(SID_SCH_EDITOPTIONS)),
1171 aFilterDlgAry(CUI_RES(SID_FILTER_DLG)),
1172 aDatasourcesDlgAry(CUI_RES(SID_SB_STARBASEOPTIONS))
1174 FreeResource();
1177 SfxItemSet* OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId )
1179 Reference< XLinguProperties > xProp( SvxGetLinguPropertySet() );
1180 SfxItemSet* pRet = 0;
1181 switch(nId)
1183 case SID_GENERAL_OPTIONS:
1185 pRet = new SfxItemSet(
1186 SfxGetpApp()->GetPool(),
1187 SID_ATTR_METRIC, SID_ATTR_SPELL,
1188 SID_AUTOSPELL_CHECK, SID_AUTOSPELL_CHECK,
1189 SID_ATTR_QUICKLAUNCHER, SID_ATTR_QUICKLAUNCHER,
1190 SID_ATTR_YEAR2000, SID_ATTR_YEAR2000,
1191 SID_HTML_MODE, SID_HTML_MODE,
1192 0 );
1194 SfxItemSet aOptSet( SfxGetpApp()->GetPool(), SID_ATTR_QUICKLAUNCHER, SID_ATTR_QUICKLAUNCHER );
1195 SfxGetpApp()->GetOptions(aOptSet);
1196 pRet->Put(aOptSet);
1198 utl::MiscCfg aMisc;
1199 SfxViewFrame* pViewFrame = SfxViewFrame::Current();
1200 if ( pViewFrame )
1202 const SfxPoolItem* pItem = NULL;
1203 SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
1205 // miscellaneous - Year2000
1206 if( SfxItemState::DEFAULT <= pDispatch->QueryState( SID_ATTR_YEAR2000, pItem ) )
1207 pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, static_cast<const SfxUInt16Item*>(pItem)->GetValue() ) );
1208 else
1209 pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, (sal_uInt16)aMisc.GetYear2000() ) );
1211 else
1212 pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, (sal_uInt16)aMisc.GetYear2000() ) );
1215 // miscellaneous - Tabulator
1216 pRet->Put(SfxBoolItem(SID_PRINTER_NOTFOUND_WARN, aMisc.IsNotFoundWarning()));
1218 SfxPrinterChangeFlags nFlag = aMisc.IsPaperSizeWarning() ? SfxPrinterChangeFlags::CHG_SIZE : SfxPrinterChangeFlags::NONE;
1219 nFlag |= aMisc.IsPaperOrientationWarning() ? SfxPrinterChangeFlags::CHG_ORIENTATION : SfxPrinterChangeFlags::NONE;
1220 pRet->Put( SfxFlagItem( SID_PRINTER_CHANGESTODOC, static_cast<int>(nFlag) ));
1223 break;
1224 case SID_LANGUAGE_OPTIONS :
1226 pRet = new SfxItemSet(SfxGetpApp()->GetPool(),
1227 SID_ATTR_LANGUAGE, SID_AUTOSPELL_CHECK,
1228 SID_ATTR_CHAR_CJK_LANGUAGE, SID_ATTR_CHAR_CTL_LANGUAGE,
1229 SID_OPT_LOCALE_CHANGED, SID_OPT_LOCALE_CHANGED,
1230 SID_SET_DOCUMENT_LANGUAGE, SID_SET_DOCUMENT_LANGUAGE,
1231 0 );
1233 // for linguistic
1235 Reference< XSpellChecker1 > xSpell = SvxGetSpellChecker();
1236 pRet->Put(SfxSpellCheckItem( xSpell, SID_ATTR_SPELL ));
1237 SfxHyphenRegionItem aHyphen( SID_ATTR_HYPHENREGION );
1239 sal_Int16 nMinLead = 2,
1240 nMinTrail = 2;
1241 if (xProp.is())
1243 nMinLead = xProp->getHyphMinLeading();
1244 nMinTrail = xProp->getHyphMinTrailing();
1246 aHyphen.GetMinLead() = (sal_uInt8)nMinLead;
1247 aHyphen.GetMinTrail() = (sal_uInt8)nMinTrail;
1249 SfxViewFrame* pViewFrame = SfxViewFrame::Current();
1250 if ( pViewFrame )
1252 const SfxPoolItem* pItem = NULL;
1253 SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
1254 if(SfxItemState::DEFAULT <= pDispatch->QueryState(SID_ATTR_LANGUAGE, pItem))
1255 pRet->Put(SfxUInt16Item(SID_ATTR_LANGUAGE, static_cast<const SvxLanguageItem*>(pItem)->GetLanguage()));
1256 if(SfxItemState::DEFAULT <= pDispatch->QueryState(SID_ATTR_CHAR_CJK_LANGUAGE, pItem))
1257 pRet->Put(SfxUInt16Item(SID_ATTR_CHAR_CJK_LANGUAGE, static_cast<const SvxLanguageItem*>(pItem)->GetLanguage()));
1258 if(SfxItemState::DEFAULT <= pDispatch->QueryState(SID_ATTR_CHAR_CTL_LANGUAGE, pItem))
1259 pRet->Put(SfxUInt16Item(SID_ATTR_CHAR_CTL_LANGUAGE, static_cast<const SvxLanguageItem*>(pItem)->GetLanguage()));
1261 pRet->Put(aHyphen);
1262 if(SfxItemState::DEFAULT <= pDispatch->QueryState(SID_AUTOSPELL_CHECK, pItem))
1264 SfxPoolItem* pClone = pItem->Clone();
1265 pRet->Put(*pClone);
1266 delete pClone;
1268 else
1270 bool bVal = false;
1271 if (xProp.is())
1273 bVal = xProp->getIsSpellAuto();
1276 pRet->Put(SfxBoolItem(SID_AUTOSPELL_CHECK, bVal));
1279 pRet->Put( SfxBoolItem( SID_SET_DOCUMENT_LANGUAGE, bIsForSetDocumentLanguage ) );
1281 break;
1282 case SID_INET_DLG :
1283 pRet = new SfxItemSet( SfxGetpApp()->GetPool(),
1284 SID_BASIC_ENABLED, SID_BASIC_ENABLED,
1285 //SID_OPTIONS_START - ..END
1286 SID_INET_PROXY_TYPE, SID_INET_PROXY_PORT,
1287 SID_SAVEREL_INET, SID_SAVEREL_FSYS,
1288 SID_INET_SMTPSERVER, SID_INET_SMTPSERVER,
1289 SID_INET_NOPROXY, SID_INET_SOCKS_PROXY_PORT,
1290 SID_INET_DNS_AUTO, SID_INET_DNS_SERVER,
1291 SID_SECURE_URL, SID_SECURE_URL,
1292 0L );
1293 SfxGetpApp()->GetOptions(*pRet);
1294 break;
1295 case SID_FILTER_DLG:
1296 pRet = new SfxItemSet( SfxGetpApp()->GetPool(),
1297 SID_ATTR_DOCINFO, SID_ATTR_AUTOSAVEMINUTE,
1298 SID_SAVEREL_INET, SID_SAVEREL_FSYS,
1299 SID_ATTR_PRETTYPRINTING, SID_ATTR_PRETTYPRINTING,
1300 SID_ATTR_WARNALIENFORMAT, SID_ATTR_WARNALIENFORMAT,
1301 0 );
1302 SfxGetpApp()->GetOptions(*pRet);
1303 break;
1305 case SID_SB_STARBASEOPTIONS:
1306 pRet = new SfxItemSet( SfxGetpApp()->GetPool(),
1307 SID_SB_POOLING_ENABLED, SID_SB_DB_REGISTER,
1308 0 );
1309 ::offapp::ConnectionPoolConfig::GetOptions(*pRet);
1310 svx::DbRegisteredNamesConfig::GetOptions(*pRet);
1311 break;
1313 case SID_SCH_EDITOPTIONS:
1315 SvxChartOptions aChartOpt;
1316 pRet = new SfxItemSet( SfxGetpApp()->GetPool(), SID_SCH_EDITOPTIONS, SID_SCH_EDITOPTIONS );
1317 pRet->Put( SvxChartColorTableItem( SID_SCH_EDITOPTIONS, aChartOpt.GetDefaultColors() ) );
1318 break;
1321 return pRet;
1324 void OfaTreeOptionsDialog::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet )
1326 switch(nId)
1328 case SID_GENERAL_OPTIONS:
1330 utl::MiscCfg aMisc;
1331 const SfxPoolItem* pItem = NULL;
1332 SfxItemSet aOptSet(SfxGetpApp()->GetPool(), SID_ATTR_QUICKLAUNCHER, SID_ATTR_QUICKLAUNCHER );
1333 aOptSet.Put(rSet);
1334 if(aOptSet.Count())
1335 SfxGetpApp()->SetOptions( aOptSet );
1336 // get dispatcher anew, because SetOptions() might have destroyed the dispatcher
1337 SfxViewFrame *pViewFrame = SfxViewFrame::Current();
1339 // evaluate Year2000
1341 sal_uInt16 nY2K = USHRT_MAX;
1342 if( SfxItemState::SET == rSet.GetItemState( SID_ATTR_YEAR2000, false, &pItem ) )
1343 nY2K = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
1344 if( USHRT_MAX != nY2K )
1346 if ( pViewFrame )
1348 SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
1349 pDispatch->Execute( SID_ATTR_YEAR2000, SfxCallMode::ASYNCHRON, pItem, 0L);
1351 aMisc.SetYear2000(nY2K);
1355 // evaluate print
1357 if(SfxItemState::SET == rSet.GetItemState(SID_PRINTER_NOTFOUND_WARN, false, &pItem))
1358 aMisc.SetNotFoundWarning(static_cast<const SfxBoolItem*>(pItem)->GetValue());
1360 if(SfxItemState::SET == rSet.GetItemState(SID_PRINTER_CHANGESTODOC, false, &pItem))
1362 const SfxFlagItem* pFlag = static_cast<const SfxFlagItem*>(pItem);
1363 aMisc.SetPaperSizeWarning(bool(static_cast<SfxPrinterChangeFlags>(pFlag->GetValue()) & SfxPrinterChangeFlags::CHG_SIZE ));
1364 aMisc.SetPaperOrientationWarning(bool(static_cast<SfxPrinterChangeFlags>(pFlag->GetValue()) & SfxPrinterChangeFlags::CHG_ORIENTATION ));
1367 // evaluate help options
1369 if ( SvtHelpOptions().IsHelpTips() != Help::IsQuickHelpEnabled() )
1370 SvtHelpOptions().IsHelpTips() ? Help::EnableQuickHelp() : Help::DisableQuickHelp();
1371 if ( SvtHelpOptions().IsExtendedHelp() != Help::IsBalloonHelpEnabled() )
1372 SvtHelpOptions().IsExtendedHelp() ? Help::EnableBalloonHelp() : Help::DisableBalloonHelp();
1374 break;
1375 case SID_LANGUAGE_OPTIONS :
1377 OfaTreeOptionsDialog::ApplyLanguageOptions(rSet);
1379 break;
1380 case SID_INET_DLG :
1381 case SID_FILTER_DLG:
1382 SfxGetpApp()->SetOptions( rSet );
1383 break;
1385 case SID_SB_STARBASEOPTIONS:
1386 ::offapp::ConnectionPoolConfig::SetOptions( rSet );
1387 svx::DbRegisteredNamesConfig::SetOptions(rSet);
1388 break;
1390 case SID_SCH_EDITOPTIONS:
1391 // nothing to do. Chart options only apply to newly created charts
1392 break;
1394 default:
1396 OSL_FAIL( "Unhandled option in ApplyItemSet" );
1398 break;
1402 void OfaTreeOptionsDialog::ApplyLanguageOptions(const SfxItemSet& rSet)
1404 bool bSaveSpellCheck = false;
1405 const SfxPoolItem* pItem = NULL;
1407 if ( SfxItemState::SET == rSet.GetItemState( SID_SPELL_MODIFIED, false, &pItem ) )
1409 bSaveSpellCheck = static_cast<const SfxBoolItem*>(pItem)->GetValue();
1411 Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
1412 Reference< XLinguProperties > xProp = LinguProperties::create( xContext );
1413 if ( SfxItemState::SET == rSet.GetItemState(SID_ATTR_HYPHENREGION, false, &pItem ) )
1415 const SfxHyphenRegionItem* pHyphenItem = static_cast<const SfxHyphenRegionItem*>(pItem);
1417 xProp->setHyphMinLeading( (sal_Int16) pHyphenItem->GetMinLead() );
1418 xProp->setHyphMinTrailing( (sal_Int16) pHyphenItem->GetMinTrail() );
1419 bSaveSpellCheck = true;
1422 SfxViewFrame *pViewFrame = SfxViewFrame::Current();
1423 if ( pViewFrame )
1425 SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
1426 pItem = NULL;
1427 if(SfxItemState::SET == rSet.GetItemState( SID_ATTR_LANGUAGE, false, &pItem ))
1429 pDispatch->Execute(pItem->Which(), SfxCallMode::ASYNCHRON, pItem, 0L);
1430 bSaveSpellCheck = true;
1432 if(SfxItemState::SET == rSet.GetItemState( SID_ATTR_CHAR_CTL_LANGUAGE, false, &pItem ))
1434 pDispatch->Execute(pItem->Which(), SfxCallMode::ASYNCHRON, pItem, 0L);
1435 bSaveSpellCheck = true;
1437 if(SfxItemState::SET == rSet.GetItemState( SID_ATTR_CHAR_CJK_LANGUAGE, false, &pItem ))
1439 pDispatch->Execute(pItem->Which(), SfxCallMode::ASYNCHRON, pItem, 0L);
1440 bSaveSpellCheck = true;
1443 if( SfxItemState::SET == rSet.GetItemState(SID_AUTOSPELL_CHECK, false, &pItem ))
1445 bool bOnlineSpelling = static_cast<const SfxBoolItem*>(pItem)->GetValue();
1446 pDispatch->Execute(SID_AUTOSPELL_CHECK,
1447 SfxCallMode::ASYNCHRON|SfxCallMode::RECORD, pItem, 0L);
1449 xProp->setIsSpellAuto( bOnlineSpelling );
1452 if( bSaveSpellCheck )
1454 //! the config item has changed since we modified the
1455 //! property set it uses
1456 pDispatch->Execute(SID_SPELLCHECKER_CHANGED, SfxCallMode::ASYNCHRON);
1460 if( SfxItemState::SET == rSet.GetItemState(SID_OPT_LOCALE_CHANGED, false, &pItem ))
1462 SfxViewFrame* _pViewFrame = SfxViewFrame::GetFirst();
1463 while ( _pViewFrame )
1465 _pViewFrame->GetDispatcher()->Execute(pItem->Which(), SfxCallMode::ASYNCHRON, pItem, 0L);
1466 _pViewFrame = SfxViewFrame::GetNext( *_pViewFrame );
1471 OUString getCurrentFactory_Impl( const Reference< XFrame >& _xFrame )
1473 OUString sIdentifier;
1474 Reference < XFrame > xCurrentFrame( _xFrame );
1475 Reference < XModuleManager2 > xModuleManager = ModuleManager::create(::comphelper::getProcessComponentContext());
1476 if ( !xCurrentFrame.is() )
1478 Reference< XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() );
1479 xCurrentFrame = xDesktop->getCurrentFrame();
1482 if ( xCurrentFrame.is() )
1486 sIdentifier = xModuleManager->identify( xCurrentFrame );
1488 catch ( ::com::sun::star::frame::UnknownModuleException& )
1490 DBG_WARNING( "getActiveModule_Impl(): unknown module" );
1492 catch ( Exception& )
1494 SAL_WARN( "cui.options", "getActiveModule_Impl(): exception of XModuleManager::identify()" );
1498 return sIdentifier;
1501 void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame )
1503 OfaPageResource aDlgResource;
1504 sal_uInt16 nGroup = 0;
1506 SvtOptionsDialogOptions aOptionsDlgOpt;
1507 sal_uInt16 i, nPageId;
1509 // %PRODUCTNAME options
1510 if ( !lcl_isOptionHidden( SID_GENERAL_OPTIONS, aOptionsDlgOpt ) )
1512 ResStringArray& rGeneralArray = aDlgResource.GetGeneralArray();
1513 setGroupName( "ProductName", rGeneralArray.GetString(0) );
1514 nGroup = AddGroup( rGeneralArray.GetString(0), 0, 0, SID_GENERAL_OPTIONS );
1515 sal_uInt16 nEnd = static_cast< sal_uInt16 >( rGeneralArray.Count() );
1517 for ( i = 1; i < nEnd; ++i )
1519 OUString sNewTitle = rGeneralArray.GetString(i);
1520 nPageId = (sal_uInt16)rGeneralArray.GetValue(i);
1521 if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1522 continue;
1524 // Disable Online Update page if service not installed
1525 if( RID_SVXPAGE_ONLINEUPDATE == nPageId )
1529 Reference < XInterface > xService( setup::UpdateCheck::create( ::comphelper::getProcessComponentContext() ) );
1530 if( ! xService.is() )
1531 continue;
1533 catch ( ::com::sun::star::uno::DeploymentException& )
1535 continue;
1538 AddTabPage( nPageId, sNewTitle, nGroup );
1542 // Load and Save options
1543 if ( !lcl_isOptionHidden( SID_FILTER_DLG, aOptionsDlgOpt ) )
1545 ResStringArray& rFilterArray = aDlgResource.GetFilterArray();
1546 setGroupName( "LoadSave", rFilterArray.GetString(0) );
1547 nGroup = AddGroup( rFilterArray.GetString(0), 0, 0, SID_FILTER_DLG );
1548 for ( i = 1; i < rFilterArray.Count(); ++i )
1550 nPageId = (sal_uInt16)rFilterArray.GetValue(i);
1551 if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1552 AddTabPage( nPageId, rFilterArray.GetString(i), nGroup );
1556 // Language options
1557 SvtLanguageOptions aLanguageOptions;
1558 if ( !lcl_isOptionHidden( SID_LANGUAGE_OPTIONS, aOptionsDlgOpt ) )
1560 ResStringArray& rLangArray = aDlgResource.GetLangArray();
1561 setGroupName( "LanguageSettings", rLangArray.GetString(0) );
1562 nGroup = AddGroup( rLangArray.GetString(0), 0, 0, SID_LANGUAGE_OPTIONS );
1563 for ( i = 1; i < rLangArray.Count(); ++i )
1565 nPageId = (sal_uInt16)rLangArray.GetValue(i);
1566 if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1567 continue;
1568 if ( ( RID_SVXPAGE_JSEARCH_OPTIONS != nPageId || aLanguageOptions.IsJapaneseFindEnabled() ) &&
1569 ( RID_SVXPAGE_ASIAN_LAYOUT != nPageId || aLanguageOptions.IsAsianTypographyEnabled() ) &&
1570 ( RID_SVXPAGE_OPTIONS_CTL != nPageId || aLanguageOptions.IsCTLFontEnabled() ) )
1571 AddTabPage( nPageId, rLangArray.GetString(i), nGroup );
1576 OUString aFactory = getCurrentFactory_Impl( _xFrame );
1577 DBG_ASSERT( GetModuleIdentifier( _xFrame ) == aFactory, "S H I T!!!" );
1579 // Writer and Writer/Web options
1580 SvtModuleOptions aModuleOpt;
1581 if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::EModule::WRITER ) )
1583 // text document
1584 ResStringArray& rTextArray = aDlgResource.GetTextArray();
1585 if ( aFactory == "com.sun.star.text.TextDocument"
1586 || aFactory == "com.sun.star.text.WebDocument"
1587 || aFactory == "com.sun.star.text.GlobalDocument" )
1589 SfxModule* pSwMod = *reinterpret_cast<SfxModule**>(GetAppData(SHL_WRITER));
1590 if ( !lcl_isOptionHidden( SID_SW_EDITOPTIONS, aOptionsDlgOpt ) )
1592 if ( aFactory == "com.sun.star.text.WebDocument" )
1593 setGroupName( "WriterWeb", rTextArray.GetString(0) );
1594 else
1595 setGroupName( "Writer", rTextArray.GetString(0) );
1596 nGroup = AddGroup(rTextArray.GetString(0), pSwMod, pSwMod, SID_SW_EDITOPTIONS );
1597 for ( i = 1; i < rTextArray.Count(); ++i )
1599 nPageId = (sal_uInt16)rTextArray.GetValue(i);
1600 if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1601 continue;
1602 if ( ( RID_SW_TP_STD_FONT_CJK != nPageId || aLanguageOptions.IsCJKFontEnabled() ) &&
1603 ( RID_SW_TP_STD_FONT_CTL != nPageId || aLanguageOptions.IsCTLFontEnabled() ) &&
1604 ( RID_SW_TP_MAILCONFIG != nPageId || MailMergeCfg_Impl().IsEmailSupported() ) )
1605 AddTabPage( nPageId, rTextArray.GetString(i), nGroup );
1607 #ifdef DBG_UTIL
1608 AddTabPage( RID_SW_TP_OPTTEST_PAGE, OUString("Internal Test"), nGroup );
1609 #endif
1612 // HTML documents
1613 if ( !lcl_isOptionHidden( SID_SW_ONLINEOPTIONS, aOptionsDlgOpt ) )
1615 ResStringArray& rHTMLArray = aDlgResource.GetHTMLArray();
1616 nGroup = AddGroup(rHTMLArray.GetString(0), pSwMod, pSwMod, SID_SW_ONLINEOPTIONS );
1617 for( i = 1; i < rHTMLArray.Count(); ++i )
1619 nPageId = (sal_uInt16)rHTMLArray.GetValue(i);
1620 if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1621 AddTabPage( nPageId, rHTMLArray.GetString(i), nGroup );
1623 #ifdef DBG_UTIL
1624 AddTabPage( RID_SW_TP_OPTTEST_PAGE, OUString("Internal Test"), nGroup );
1625 #endif
1630 // Calc options
1631 if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::EModule::CALC ) )
1633 if ( aFactory == "com.sun.star.sheet.SpreadsheetDocument" )
1635 if ( !lcl_isOptionHidden( SID_SC_EDITOPTIONS, aOptionsDlgOpt ) )
1637 ResStringArray& rCalcArray = aDlgResource.GetCalcArray();
1638 SfxModule* pScMod = *reinterpret_cast<SfxModule**>(GetAppData( SHL_CALC ));
1639 setGroupName( "Calc", rCalcArray.GetString(0) );
1640 nGroup = AddGroup( rCalcArray.GetString( 0 ), pScMod, pScMod, SID_SC_EDITOPTIONS );
1641 const sal_uInt16 nCount = static_cast< const sal_uInt16 >( rCalcArray.Count() );
1642 for ( i = 1; i < nCount; ++i )
1644 nPageId = (sal_uInt16)rCalcArray.GetValue(i);
1645 if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1646 continue;
1648 AddTabPage( nPageId, rCalcArray.GetString( i ), nGroup );
1654 // Impress options
1655 SfxModule* pSdMod = *reinterpret_cast<SfxModule**>(GetAppData( SHL_DRAW ));
1656 if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::EModule::IMPRESS ) )
1658 if ( aFactory == "com.sun.star.presentation.PresentationDocument" )
1660 if ( !lcl_isOptionHidden( SID_SD_EDITOPTIONS, aOptionsDlgOpt ) )
1662 ResStringArray& rImpressArray = aDlgResource.GetImpressArray();
1663 setGroupName( "Impress", rImpressArray.GetString(0) );
1664 nGroup = AddGroup( rImpressArray.GetString( 0 ), pSdMod, pSdMod, SID_SD_EDITOPTIONS );
1665 const sal_uInt16 nCount = static_cast< const sal_uInt16 >( rImpressArray.Count() );
1666 for ( i = 1; i < nCount; ++i )
1668 nPageId = (sal_uInt16)rImpressArray.GetValue(i);
1669 if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1670 continue;
1672 AddTabPage( nPageId, rImpressArray.GetString(i), nGroup );
1678 // Draw options
1679 if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::EModule::DRAW ) )
1681 if ( aFactory == "com.sun.star.drawing.DrawingDocument" )
1683 if ( !lcl_isOptionHidden( SID_SD_GRAPHIC_OPTIONS, aOptionsDlgOpt ) )
1685 ResStringArray& rDrawArray = aDlgResource.GetDrawArray();
1686 setGroupName( "Draw", rDrawArray.GetString(0) );
1687 nGroup = AddGroup( rDrawArray.GetString( 0 ), pSdMod, pSdMod, SID_SD_GRAPHIC_OPTIONS );
1688 const sal_uInt16 nCount = static_cast< const sal_uInt16 >( rDrawArray.Count() );
1689 for ( i = 1; i < nCount; ++i )
1691 nPageId = (sal_uInt16)rDrawArray.GetValue(i);
1692 if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1693 continue;
1695 AddTabPage( nPageId, rDrawArray.GetString(i), nGroup );
1701 // Math options
1702 if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::EModule::MATH ) )
1704 if ( aFactory == "com.sun.star.formula.FormulaProperties" )
1706 if ( !lcl_isOptionHidden( SID_SM_EDITOPTIONS, aOptionsDlgOpt ) )
1708 ResStringArray& rStarMathArray = aDlgResource.GetStarMathArray();
1709 SfxModule* pSmMod = *reinterpret_cast<SfxModule**>(GetAppData(SHL_SM));
1710 setGroupName( "Math", rStarMathArray.GetString(0) );
1711 nGroup = AddGroup(rStarMathArray.GetString(0), pSmMod, pSmMod, SID_SM_EDITOPTIONS );
1712 for ( i = 1; i < rStarMathArray.Count(); ++i )
1714 nPageId = (sal_uInt16)rStarMathArray.GetValue(i);
1715 if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1716 AddTabPage( nPageId, rStarMathArray.GetString(i), nGroup );
1722 // Database - needed only if there is an application which integrates with databases
1723 if ( !lcl_isOptionHidden( SID_SB_STARBASEOPTIONS, aOptionsDlgOpt ) &&
1724 ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::EModule::DATABASE )
1725 || aModuleOpt.IsModuleInstalled( SvtModuleOptions::EModule::WRITER )
1726 || aModuleOpt.IsModuleInstalled( SvtModuleOptions::EModule::CALC )
1729 ResStringArray& rDSArray = aDlgResource.GetDatasourcesArray();
1730 setGroupName( "Base", rDSArray.GetString(0) );
1731 nGroup = AddGroup( rDSArray.GetString(0), 0, NULL, SID_SB_STARBASEOPTIONS );
1732 for ( i = 1; i < rDSArray.Count(); ++i )
1734 nPageId = (sal_uInt16)rDSArray.GetValue(i);
1735 if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1736 AddTabPage( nPageId, rDSArray.GetString(i), nGroup );
1740 // Chart options (always installed and active)
1741 if ( !lcl_isOptionHidden( SID_SCH_EDITOPTIONS, aOptionsDlgOpt ) )
1743 ResStringArray& rChartArray = aDlgResource.GetChartArray();
1744 setGroupName( "Charts", rChartArray.GetString(0) );
1745 nGroup = AddGroup( rChartArray.GetString(0), 0, 0, SID_SCH_EDITOPTIONS );
1746 for ( i = 1; i < rChartArray.Count(); ++i )
1748 nPageId = (sal_uInt16)rChartArray.GetValue(i);
1749 if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1750 AddTabPage( nPageId, rChartArray.GetString(i), nGroup );
1754 // Internet options
1755 if ( !lcl_isOptionHidden( SID_INET_DLG, aOptionsDlgOpt ) )
1757 ResStringArray& rInetArray = aDlgResource.GetInetArray();
1758 setGroupName( "Internet", rInetArray.GetString(0) );
1759 nGroup = AddGroup(rInetArray.GetString(0), 0, 0, SID_INET_DLG );
1761 for ( i = 1; i < rInetArray.Count(); ++i )
1763 nPageId = (sal_uInt16)rInetArray.GetValue(i);
1764 if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1765 continue;
1766 #if defined WNT
1767 // Disable E-mail tab-page on Windows
1768 if ( nPageId == RID_SVXPAGE_INET_MAIL )
1769 continue;
1770 #endif
1771 AddTabPage( nPageId, rInetArray.GetString(i), nGroup );
1775 /*!!!
1776 ActivateLastSelection();
1780 bool isNodeActive( OptionsNode* pNode, Module* pModule )
1782 if ( pNode )
1784 // Node for all modules actine?
1785 if ( pNode->m_bAllModules )
1786 return true;
1788 // OOo-Nodes (Writer, Calc, Impress...) are active if node is already inserted
1789 if ( !getGroupName( pNode->m_sId, false ).isEmpty() )
1790 return true;
1792 // no module -> not active
1793 if ( !pModule )
1794 return false;
1796 // search node in active module
1797 if ( pModule->m_bActive )
1799 for ( sal_uInt32 j = 0; j < pModule->m_aNodeList.size(); ++j )
1800 if ( pModule->m_aNodeList[j]->m_sId == pNode->m_sId )
1801 return true;
1804 return false;
1807 void OfaTreeOptionsDialog::LoadExtensionOptions( const OUString& rExtensionId )
1809 Module* pModule = NULL;
1811 // when called by Tools - Options then load nodes of active module
1812 if ( rExtensionId.isEmpty() )
1814 pModule = LoadModule( GetModuleIdentifier( Reference< XFrame >() ) );
1817 VectorOfNodes aNodeList = LoadNodes( pModule, rExtensionId );
1818 InsertNodes( aNodeList );
1820 delete pModule;
1823 OUString OfaTreeOptionsDialog::GetModuleIdentifier( const Reference< XFrame >& rFrame )
1825 OUString sModule;
1826 Reference < XFrame > xCurrentFrame( rFrame );
1827 Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
1828 Reference < XModuleManager2 > xModuleManager = ModuleManager::create(xContext);
1830 if ( !xCurrentFrame.is() )
1832 Reference < XDesktop2 > xDesktop = Desktop::create( xContext );
1833 xCurrentFrame = xDesktop->getCurrentFrame();
1836 if ( xCurrentFrame.is() )
1840 sModule = xModuleManager->identify( xCurrentFrame );
1842 catch ( ::com::sun::star::frame::UnknownModuleException& )
1844 DBG_WARNING( "OfaTreeOptionsDialog::GetModuleIdentifier(): unknown module" );
1846 catch ( Exception& )
1848 SAL_WARN( "cui.options", "OfaTreeOptionsDialog::GetModuleIdentifier(): exception of XModuleManager::identify()" );
1851 return sModule;
1854 Module* OfaTreeOptionsDialog::LoadModule(
1855 const OUString& rModuleIdentifier )
1857 Module* pModule = NULL;
1858 Reference< XNameAccess > xSet(
1859 officecfg::Office::OptionsDialog::Modules::get());
1861 Sequence< OUString > seqNames = xSet->getElementNames();
1862 for ( int i = 0; i < seqNames.getLength(); ++i )
1864 OUString sModule( seqNames[i] );
1865 if ( rModuleIdentifier == sModule )
1867 // current active module found
1868 pModule = new Module( sModule );
1869 pModule->m_bActive = true;
1871 Reference< XNameAccess > xModAccess;
1872 xSet->getByName( seqNames[i] ) >>= xModAccess;
1873 if ( xModAccess.is() )
1875 // load the nodes of this module
1876 Reference< XNameAccess > xNodeAccess;
1877 xModAccess->getByName( "Nodes" ) >>= xNodeAccess;
1878 if ( xNodeAccess.is() )
1880 Sequence< OUString > xTemp = xNodeAccess->getElementNames();
1881 Reference< XNameAccess > xAccess;
1882 sal_Int32 nIndex = -1;
1883 for ( int x = 0; x < xTemp.getLength(); ++x )
1885 xNodeAccess->getByName( xTemp[x] ) >>= xAccess;
1886 if ( xAccess.is() )
1888 xAccess->getByName( "Index" ) >>= nIndex;
1889 if ( nIndex < 0 )
1890 // append nodes with index < 0
1891 pModule->m_aNodeList.push_back(
1892 new OrderedEntry( nIndex, xTemp[x] ) );
1893 else
1895 // search position of the node
1896 sal_uInt32 y = 0;
1897 for ( ; y < pModule->m_aNodeList.size(); ++y )
1899 sal_Int32 nNodeIdx = pModule->m_aNodeList[y]->m_nIndex;
1900 if ( nNodeIdx < 0 || nNodeIdx > nIndex )
1901 break;
1903 // and insert the node on this position
1904 pModule->m_aNodeList.insert(
1905 pModule->m_aNodeList.begin() + y,
1906 new OrderedEntry( nIndex, xTemp[x] ) );
1912 break;
1915 return pModule;
1918 VectorOfNodes OfaTreeOptionsDialog::LoadNodes(
1919 Module* pModule, const OUString& rExtensionId)
1921 VectorOfNodes aOutNodeList;
1923 Reference< XNameAccess > xSet(
1924 officecfg::Office::OptionsDialog::Nodes::get());
1925 VectorOfNodes aNodeList;
1926 Sequence< OUString > seqNames = xSet->getElementNames();
1928 for ( int i = 0; i < seqNames.getLength(); ++i )
1930 OUString sGroupName( seqNames[i] );
1931 Reference< XNameAccess > xNodeAccess;
1932 xSet->getByName( seqNames[i] ) >>= xNodeAccess;
1934 if ( xNodeAccess.is() )
1936 OUString sNodeId, sLabel, sPageURL, sGroupId;
1937 bool bAllModules = false;
1938 sal_Int32 nGroupIndex = 0;
1940 sNodeId = seqNames[i];
1941 xNodeAccess->getByName( "Label" ) >>= sLabel;
1942 xNodeAccess->getByName( "OptionsPage" ) >>= sPageURL;
1943 xNodeAccess->getByName( "AllModules" ) >>= bAllModules;
1944 xNodeAccess->getByName( "GroupId" ) >>= sGroupId;
1945 xNodeAccess->getByName( "GroupIndex" ) >>= nGroupIndex;
1947 if ( sLabel.isEmpty() )
1948 sLabel = sGroupName;
1949 OUString sTemp = getGroupName( sLabel, !rExtensionId.isEmpty() );
1950 if ( !sTemp.isEmpty() )
1951 sLabel = sTemp;
1952 OptionsNode* pNode =
1953 new OptionsNode( sNodeId, sLabel, sPageURL, bAllModules, sGroupId, nGroupIndex );
1955 if ( rExtensionId.isEmpty() && !isNodeActive( pNode, pModule ) )
1957 delete pNode;
1958 continue;
1961 Reference< XNameAccess > xLeavesSet;
1962 xNodeAccess->getByName( "Leaves" ) >>= xLeavesSet;
1963 if ( xLeavesSet.is() )
1965 Sequence< OUString > seqLeaves = xLeavesSet->getElementNames();
1966 for ( int j = 0; j < seqLeaves.getLength(); ++j )
1968 Reference< XNameAccess > xLeaveAccess;
1969 xLeavesSet->getByName( seqLeaves[j] ) >>= xLeaveAccess;
1971 if ( xLeaveAccess.is() )
1973 OUString sId, sLeafLabel, sEventHdl, sLeafURL, sLeafGrpId;
1974 sal_Int32 nLeafGrpIdx = 0;
1976 xLeaveAccess->getByName( "Id" ) >>= sId;
1977 xLeaveAccess->getByName( "Label" ) >>= sLeafLabel;
1978 xLeaveAccess->getByName( "OptionsPage" ) >>= sLeafURL;
1979 xLeaveAccess->getByName( "EventHandlerService" ) >>= sEventHdl;
1980 xLeaveAccess->getByName( "GroupId" ) >>= sLeafGrpId;
1981 xLeaveAccess->getByName( "GroupIndex" ) >>= nLeafGrpIdx;
1983 if ( rExtensionId.isEmpty() || sId == rExtensionId )
1985 OptionsLeaf* pLeaf = new OptionsLeaf(
1986 sId, sLeafLabel, sLeafURL, sEventHdl, sLeafGrpId, nLeafGrpIdx );
1988 if ( !sLeafGrpId.isEmpty() )
1990 bool bAlreadyOpened = false;
1991 if ( pNode->m_aGroupedLeaves.size() > 0 )
1993 for ( sal_uInt32 k = 0;
1994 k < pNode->m_aGroupedLeaves.size(); ++k )
1996 if ( pNode->m_aGroupedLeaves[k].size() > 0 &&
1997 pNode->m_aGroupedLeaves[k][0]->m_sGroupId
1998 == sLeafGrpId )
2000 sal_uInt32 l = 0;
2001 for ( ; l < pNode->m_aGroupedLeaves[k].size(); ++l )
2003 if ( pNode->m_aGroupedLeaves[k][l]->
2004 m_nGroupIndex >= nLeafGrpIdx )
2005 break;
2007 pNode->m_aGroupedLeaves[k].insert(
2008 pNode->m_aGroupedLeaves[k].begin() + l, pLeaf );
2009 bAlreadyOpened = true;
2010 break;
2014 if ( !bAlreadyOpened )
2016 VectorOfLeaves aGroupedLeaves;
2017 aGroupedLeaves.push_back( pLeaf );
2018 pNode->m_aGroupedLeaves.push_back( aGroupedLeaves );
2021 else
2022 pNode->m_aLeaves.push_back( pLeaf );
2028 // do not insert nodes without leaves
2029 if ( pNode->m_aLeaves.size() > 0 || pNode->m_aGroupedLeaves.size() > 0 )
2031 pModule ? aNodeList.push_back( pNode ) : aOutNodeList.push_back( pNode );
2033 else
2034 delete pNode;
2038 if ( pModule && aNodeList.size() > 0 )
2040 sal_uInt32 i = 0, j = 0;
2041 for ( ; i < pModule->m_aNodeList.size(); ++i )
2043 OUString sNodeId = pModule->m_aNodeList[i]->m_sId;
2044 for ( j = 0; j < aNodeList.size(); ++j )
2046 OptionsNode* pNode = aNodeList[j];
2047 if ( pNode->m_sId == sNodeId )
2049 aOutNodeList.push_back( pNode );
2050 aNodeList.erase( aNodeList.begin() + j );
2051 break;
2056 for ( i = 0; i < aNodeList.size(); ++i )
2057 aOutNodeList.push_back( aNodeList[i] );
2059 return aOutNodeList;
2062 static sal_uInt16 lcl_getGroupId( const OUString& rGroupName, const SvTreeListBox& rTreeLB )
2064 OUString sGroupName( rGroupName );
2065 sal_uInt16 nRet = 0;
2066 SvTreeListEntry* pEntry = rTreeLB.First();
2067 while( pEntry )
2069 if ( !rTreeLB.GetParent( pEntry ) )
2071 OUString sTemp( rTreeLB.GetEntryText( pEntry ) );
2072 if ( sTemp == sGroupName )
2073 return nRet;
2074 nRet++;
2076 pEntry = rTreeLB.Next( pEntry );
2079 return USHRT_MAX;
2082 static void lcl_insertLeaf(
2083 OfaTreeOptionsDialog* pDlg, OptionsNode* pNode, OptionsLeaf* pLeaf, const SvTreeListBox& rTreeLB )
2085 sal_uInt16 nGrpId = lcl_getGroupId( pNode->m_sLabel, rTreeLB );
2086 if ( USHRT_MAX == nGrpId )
2088 sal_uInt16 nNodeGrpId = getGroupNodeId( pNode->m_sId );
2089 nGrpId = pDlg->AddGroup( pNode->m_sLabel, NULL, NULL, nNodeGrpId );
2090 if ( !pNode->m_sPageURL.isEmpty() )
2092 SvTreeListEntry* pGrpEntry = rTreeLB.GetEntry( 0, nGrpId );
2093 DBG_ASSERT( pGrpEntry, "OfaTreeOptionsDialog::InsertNodes(): no group" );
2094 if ( pGrpEntry )
2096 OptionsGroupInfo* pGrpInfo =
2097 static_cast<OptionsGroupInfo*>(pGrpEntry->GetUserData());
2098 pGrpInfo->m_sPageURL = pNode->m_sPageURL;
2102 OptionsPageInfo* pInfo = pDlg->AddTabPage( 0, pLeaf->m_sLabel, nGrpId );
2103 pInfo->m_sPageURL = pLeaf->m_sPageURL;
2104 pInfo->m_sEventHdl = pLeaf->m_sEventHdl;
2107 void OfaTreeOptionsDialog::InsertNodes( const VectorOfNodes& rNodeList )
2109 for ( sal_uInt32 i = 0; i < rNodeList.size(); ++i )
2111 OptionsNode* pNode = rNodeList[i];
2113 if ( pNode->m_aLeaves.size() > 0 || pNode->m_aGroupedLeaves.size() > 0 )
2115 sal_uInt32 j = 0;
2116 for ( ; j < pNode->m_aGroupedLeaves.size(); ++j )
2118 for ( sal_uInt32 k = 0; k < pNode->m_aGroupedLeaves[j].size(); ++k )
2120 OptionsLeaf* pLeaf = pNode->m_aGroupedLeaves[j][k];
2121 lcl_insertLeaf( this, pNode, pLeaf, *pTreeLB );
2125 for ( j = 0; j < pNode->m_aLeaves.size(); ++j )
2127 OptionsLeaf* pLeaf = pNode->m_aLeaves[j];
2128 lcl_insertLeaf( this, pNode, pLeaf, *pTreeLB );
2134 short OfaTreeOptionsDialog::Execute()
2136 boost::scoped_ptr< SvxDicListChgClamp > pClamp;
2137 if ( !bIsFromExtensionManager )
2139 // collect all DictionaryList Events while the dialog is executed
2140 Reference<com::sun::star::linguistic2::XSearchableDictionaryList> xDictionaryList(SvxGetDictionaryList());
2141 pClamp.reset( new SvxDicListChgClamp( xDictionaryList ) );
2143 short nRet = SfxModalDialog::Execute();
2145 if( RET_OK == nRet )
2147 ApplyItemSets();
2148 if( mpColorPage )
2149 mpColorPage->SaveToViewFrame( SfxViewFrame::Current() );
2150 utl::ConfigManager::storeConfigItems();
2153 return nRet;
2156 // class ExtensionsTabPage -----------------------------------------------
2157 ExtensionsTabPage::ExtensionsTabPage(
2158 vcl::Window* pParent, WinBits nStyle, const OUString& rPageURL,
2159 const OUString& rEvtHdl, const Reference< awt::XContainerWindowProvider >& rProvider ) :
2161 TabPage( pParent, nStyle ),
2163 m_sPageURL ( rPageURL ),
2164 m_sEventHdl ( rEvtHdl ),
2165 m_xWinProvider ( rProvider ),
2166 m_bIsWindowHidden ( false )
2171 ExtensionsTabPage::~ExtensionsTabPage()
2173 disposeOnce();
2176 void ExtensionsTabPage::dispose()
2178 Hide();
2179 DeactivatePage();
2181 if ( m_xPage.is() )
2183 Reference< XComponent > xComponent( m_xPage, UNO_QUERY );
2184 if ( xComponent.is() )
2188 xComponent->dispose();
2190 catch ( const Exception & )
2194 m_xPage.clear();
2196 TabPage::dispose();
2201 void ExtensionsTabPage::CreateDialogWithHandler()
2205 bool bWithHandler = ( !m_sEventHdl.isEmpty() );
2206 if ( bWithHandler )
2208 Reference < XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
2209 m_xEventHdl = Reference< awt::XContainerWindowEventHandler >(
2210 xFactory->createInstance( m_sEventHdl ), UNO_QUERY );
2213 if ( !bWithHandler || m_xEventHdl.is() )
2215 SetStyle( GetStyle() | WB_DIALOGCONTROL | WB_CHILDDLGCTRL );
2216 Reference< awt::XWindowPeer > xParent( VCLUnoHelper::GetInterface( this ), UNO_QUERY );
2217 m_xPage = Reference < awt::XWindow >(
2218 m_xWinProvider->createContainerWindow(
2219 m_sPageURL, OUString(), xParent, m_xEventHdl ), UNO_QUERY );
2221 Reference< awt::XControl > xPageControl( m_xPage, UNO_QUERY );
2222 if ( xPageControl.is() )
2224 Reference< awt::XWindowPeer > xWinPeer( xPageControl->getPeer() );
2225 if ( xWinPeer.is() )
2227 vcl::Window* pWindow = VCLUnoHelper::GetWindow( xWinPeer );
2228 if ( pWindow )
2229 pWindow->SetStyle( pWindow->GetStyle() | WB_DIALOGCONTROL | WB_CHILDDLGCTRL );
2234 catch (const css::lang::IllegalArgumentException& e)
2236 SAL_WARN("cui.options", "ExtensionsTabPage::CreateDialogWithHandler(): illegal argument:" << e.Message);
2238 catch (const Exception& e)
2240 SAL_WARN( "cui.options", "ExtensionsTabPage::CreateDialogWithHandler(): exception of XDialogProvider2::createDialogWithHandler(): " << e.Message);
2246 bool ExtensionsTabPage::DispatchAction( const OUString& rAction )
2248 bool bRet = false;
2249 if ( m_xEventHdl.is() )
2253 bRet = m_xEventHdl->callHandlerMethod( m_xPage, makeAny( rAction ), "external_event" );
2255 catch ( Exception& )
2257 SAL_WARN( "cui.options", "ExtensionsTabPage::DispatchAction(): exception of XDialogEventHandler::callHandlerMethod()" );
2260 return bRet;
2263 void ExtensionsTabPage::ActivatePage()
2265 TabPage::ActivatePage();
2267 if ( !m_xPage.is() )
2269 CreateDialogWithHandler();
2271 if ( m_xPage.is() )
2273 Point aPos = Point();
2274 Size aSize = GetParent()->get_preferred_size();
2275 m_xPage->setPosSize( aPos.X() + 1, aPos.Y() + 1,
2276 aSize.Width() - 2, aSize.Height() - 2, awt::PosSize::POSSIZE );
2277 if ( !m_sEventHdl.isEmpty() )
2278 DispatchAction( "initialize" );
2282 if ( m_xPage.is() )
2284 m_xPage->setVisible( sal_True );
2285 m_bIsWindowHidden = false;
2289 void ExtensionsTabPage::DeactivatePage()
2291 TabPage::DeactivatePage();
2293 if ( m_xPage.is() )
2294 m_xPage->setVisible( sal_False );
2299 void ExtensionsTabPage::ResetPage()
2301 DispatchAction( "back" );
2302 ActivatePage();
2307 void ExtensionsTabPage::SavePage()
2309 DispatchAction( "ok" );
2312 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */