update dev300-m58
[ooovba.git] / svx / source / cui / treeopt.cxx
blob4525b15102c54865f71bbb8fadd5912966c83037
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: treeopt.cxx,v $
10 * $Revision: 1.58 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #ifdef SVX_DLLIMPLEMENTATION
35 #undef SVX_DLLIMPLEMENTATION
36 #endif
37 #include <com/sun/star/beans/XPropertySet.hpp>
38 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
39 #include <com/sun/star/loader/CannotActivateFactoryException.hpp>
40 #include <com/sun/star/linguistic2/XDictionaryList.hpp>
41 #include <com/sun/star/frame/XDesktop.hpp>
42 #include <com/sun/star/frame/XFrame.hpp>
43 #include <com/sun/star/frame/XModuleManager.hpp>
44 #include <com/sun/star/util/XMacroExpander.hpp>
45 #include <osl/module.hxx>
47 #include <com/sun/star/util/XCloseable.hpp>
48 #include <com/sun/star/frame/XLoadable.hpp>
49 #include <tools/rcid.h>
51 #include <tools/shl.hxx>
53 #include <comphelper/processfactory.hxx>
54 #include <toolkit/helper/vclunohelper.hxx>
55 #include <com/sun/star/beans/PropertyValue.hpp>
56 #include <com/sun/star/container/XNameContainer.hpp>
57 #include <com/sun/star/container/XNameAccess.hpp>
58 #include <com/sun/star/oooimprovement/XCoreController.hpp>
59 #include <comphelper/configurationhelper.hxx>
60 #include <com/sun/star/awt/XDialogProvider.hpp>
61 #include <com/sun/star/awt/XDialogProvider2.hpp>
62 #include <com/sun/star/awt/XContainerWindowProvider.hpp>
63 #include <com/sun/star/awt/XDialogEventHandler.hpp>
64 #include <com/sun/star/awt/XContainerWindowEventHandler.hpp>
65 #include <com/sun/star/awt/PosSize.hpp>
66 #include <com/sun/star/awt/XTopWindow.hpp>
67 #include <com/sun/star/awt/XControl.hpp>
68 #include <com/sun/star/awt/XTabController.hpp>
69 #include <vcl/help.hxx>
70 #ifndef _LINGUISTIC_MISC_HHX_
71 #include <linguistic/misc.hxx>
72 #endif
73 #include <svtools/helpopt.hxx>
74 #include <svtools/moduleoptions.hxx>
75 #include <svtools/languageoptions.hxx>
76 #include <svtools/optionsdlg.hxx>
77 #include <sfx2/module.hxx>
78 #include <vcl/msgbox.hxx>
79 #include <sfx2/dispatch.hxx>
80 #include <vcl/waitobj.hxx>
81 #include <svtools/slstitm.hxx>
82 #include <sfx2/viewfrm.hxx>
83 #include <svtools/viewoptions.hxx>
84 #include <sfx2/printopt.hxx>
85 #include <osl/module.h>
86 #include <osl/process.h>
87 #include <rtl/bootstrap.hxx>
89 #include <svtools/misccfg.hxx>
90 #include <sfx2/objsh.hxx>
91 #include <sfx2/viewsh.hxx>
92 #include <sfx2/tplpitem.hxx>
93 #include <svtools/apearcfg.hxx>
94 #include <svtools/linguprops.hxx>
95 #include <sfx2/app.hxx>
96 #include <svx/xdef.hxx>
97 #include <svx/xflclit.hxx>
98 #include <svx/xpool.hxx>
99 #ifndef _SVX_TAB_AREA_HXX //autogen
100 #include "cuitabarea.hxx"
101 #endif
102 #include "ofaitem.hxx"
103 #include "opthtml.hxx"
104 #include "optcolor.hxx"
105 #include "optctl.hxx"
106 #include "optjava.hxx"
107 #include "optsave.hxx"
108 #include "optpath.hxx"
109 #include "cuioptgenrl.hxx"
110 #include <svx/optlingu.hxx>
111 #ifndef _SVX_TAB_AREA_HXX //autogen
112 #include "cuitabarea.hxx"
113 #endif
114 #include "optinet2.hxx"
115 #include "optasian.hxx"
116 #include "optaccessibility.hxx"
117 #include "optjsearch.hxx"
118 #include "connpooloptions.hxx"
119 #include "optupdt.hxx"
120 #include "svx/optimprove.hxx"
121 #include "optchart.hxx"
123 #include "optgdlg.hxx"
124 #include "optmemory.hxx"
125 #include "optfltr.hxx"
126 #include <svx/dialogs.hrc>
127 #include "helpid.hrc"
128 #include <svx/dialmgr.hxx>
129 #include "treeopt.hxx"
130 #include "treeopt.hrc"
131 #include "fontsubs.hxx"
132 #include "unolingu.hxx"
133 #include <svx/xtable.hxx>
134 #include "connpoolconfig.hxx"
135 #include "dbregister.hxx"
136 #include "dbregisterednamesconfig.hxx"
137 #include "cfgchart.hxx"
139 #ifndef _SVX_LANGITEM_HXX
140 #define ITEMID_LANGUAGE SID_ATTR_CHAR_LANGUAGE
141 #include <svx/langitem.hxx>
142 #endif
143 #ifndef _SVX_OPTITEMS_HXX
146 #include <optitems.hxx>
147 #endif
148 #include <drawitem.hxx>
149 #include <rtl/uri.hxx>
151 using namespace ::com::sun::star;
152 using namespace ::com::sun::star::beans;
153 using namespace ::com::sun::star::container;
154 using namespace ::com::sun::star::frame;
155 using namespace ::com::sun::star::lang;
156 using namespace ::com::sun::star::linguistic2;
157 using namespace ::com::sun::star::uno;
158 using namespace ::com::sun::star::util;
160 #ifdef C2U
161 #error "Who define C2U before! I use it to create const ascii strings ..."
162 #else
163 #define C2U(cChar) rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( cChar ) )
164 #endif
166 #define HINT_TIMEOUT 200
167 #define SELECT_FIRST_TIMEOUT 0
168 #define SELECT_TIMEOUT 300
169 #define COLORPAGE_UNKNOWN ((sal_uInt16)0xFFFF)
170 #define EXPAND_PROTOCOL "vnd.sun.star.expand:"
172 LastPageSaver* OfaTreeOptionsDialog::pLastPageSaver = NULL;
174 // some stuff for easier changes for SvtViewOptions
175 static const sal_Char* pViewOptDataName = "page data";
176 #define VIEWOPT_DATANAME rtl::OUString::createFromAscii( pViewOptDataName )
178 static XOutdevItemPool* mpStaticXOutdevItemPool = 0L;
180 static inline void SetViewOptUserItem( SvtViewOptions& rOpt, const String& rData )
182 rOpt.SetUserItem( VIEWOPT_DATANAME, makeAny( rtl::OUString( rData ) ) );
185 static inline String GetViewOptUserItem( const SvtViewOptions& rOpt )
187 Any aAny( rOpt.GetUserItem( VIEWOPT_DATANAME ) );
188 rtl::OUString aUserData;
189 aAny >>= aUserData;
191 return String( aUserData );
194 struct ModuleToGroupNameMap_Impl
196 const char* m_pModule;
197 String m_sGroupName;
198 USHORT m_nNodeId;
201 static OfaPageResource* pPageRes = NULL;
203 static ModuleToGroupNameMap_Impl ModuleMap[] =
205 { "ProductName", String::EmptyString(), SID_GENERAL_OPTIONS },
206 { "LanguageSettings", String::EmptyString(), SID_LANGUAGE_OPTIONS },
207 { "Internet", String::EmptyString(), SID_INET_DLG },
208 { "LoadSave", String::EmptyString(), SID_FILTER_DLG },
209 { "Writer", String::EmptyString(), SID_SW_EDITOPTIONS },
210 { "WriterWeb", String::EmptyString(), SID_SW_ONLINEOPTIONS },
211 { "Math", String::EmptyString(), SID_SM_EDITOPTIONS },
212 { "Calc", String::EmptyString(), SID_SC_EDITOPTIONS },
213 { "Impress", String::EmptyString(), SID_SD_EDITOPTIONS },
214 { "Draw", String::EmptyString(), SID_SD_GRAPHIC_OPTIONS },
215 { "Charts", String::EmptyString(), SID_SCH_EDITOPTIONS },
216 { "Base", String::EmptyString(), SID_SB_STARBASEOPTIONS },
218 { NULL, String::EmptyString(), 0xFFFF }
221 static void setGroupName( const rtl::OUString& rModule, const String& rGroupName )
223 USHORT nIndex = 0;
224 while ( ModuleMap[ nIndex ].m_pModule )
226 rtl::OUString sTemp =
227 rtl::OUString::createFromAscii( ModuleMap[ nIndex ].m_pModule );
228 if ( sTemp == rModule )
230 ModuleMap[ nIndex ].m_sGroupName = rGroupName;
231 break;
233 ++nIndex;
237 static String getGroupName( const rtl::OUString& rModule, bool bForced )
239 String sGroupName;
240 USHORT nIndex = 0;
241 while ( ModuleMap[ nIndex ].m_pModule )
243 rtl::OUString sTemp =
244 rtl::OUString::createFromAscii( ModuleMap[ nIndex ].m_pModule );
245 if ( sTemp == rModule )
247 sGroupName = ModuleMap[ nIndex ].m_sGroupName;
248 break;
250 ++nIndex;
253 if ( sGroupName.Len() == 0 && bForced )
255 if ( !pPageRes )
256 pPageRes = new OfaPageResource;
258 if ( rModule == C2U("Writer") )
259 sGroupName = pPageRes->GetTextArray().GetString(0);
260 else if ( rModule == C2U("WriterWeb") )
261 sGroupName = pPageRes->GetHTMLArray().GetString(0);
262 else if ( rModule == C2U("Calc") )
263 sGroupName = pPageRes->GetCalcArray().GetString(0);
264 else if ( rModule == C2U("Impress") )
265 sGroupName = pPageRes->GetImpressArray().GetString(0);
266 else if ( rModule == C2U("Draw") )
267 sGroupName = pPageRes->GetDrawArray().GetString(0);
268 else if ( rModule == C2U("Math") )
269 sGroupName = pPageRes->GetStarMathArray().GetString(0);
270 else if ( rModule == C2U("Base") )
271 sGroupName = pPageRes->GetDatasourcesArray().GetString(0);
273 return sGroupName;
276 static void deleteGroupNames()
278 USHORT nIndex = 0;
279 while ( ModuleMap[ nIndex ].m_pModule )
280 ModuleMap[ nIndex++ ].m_sGroupName = String::EmptyString();
283 static USHORT getGroupNodeId( const rtl::OUString& rModule )
285 USHORT nNodeId = 0xFFFF, nIndex = 0;
286 while ( ModuleMap[ nIndex ].m_pModule )
288 rtl::OUString sTemp =
289 rtl::OUString::createFromAscii( ModuleMap[ nIndex ].m_pModule );
290 if ( sTemp == rModule )
292 nNodeId = ModuleMap[ nIndex ].m_nNodeId;
293 break;
295 ++nIndex;
298 return nNodeId;
301 /*-- 29.10.2004 13:57:25---------------------------------------------------
303 -----------------------------------------------------------------------*/
304 class MailMergeCfg_Impl : public utl::ConfigItem
306 friend class SvxEMailTabPage;
307 // variables
308 sal_Bool bIsEmailSupported;
310 public:
311 MailMergeCfg_Impl();
312 virtual ~MailMergeCfg_Impl();
314 virtual void Commit();
316 sal_Bool IsEmailSupported() const {return bIsEmailSupported;}
319 /*-- 29.10.2004 13:57:25---------------------------------------------------
321 -----------------------------------------------------------------------*/
322 MailMergeCfg_Impl::MailMergeCfg_Impl() :
323 utl::ConfigItem(C2U("Office.Writer/MailMergeWizard")),
324 bIsEmailSupported(sal_False)
326 Sequence<rtl::OUString> aNames(1);
327 aNames.getArray()[0] = C2U("EMailSupported");
328 const Sequence< Any > aValues = GetProperties(aNames);
329 const Any* pValues = aValues.getConstArray();
330 if(aValues.getLength() && pValues[0].hasValue())
331 pValues[0] >>= bIsEmailSupported;
333 /*-- 29.10.2004 13:57:25---------------------------------------------------
335 -----------------------------------------------------------------------*/
336 MailMergeCfg_Impl::~MailMergeCfg_Impl()
339 /* -------------------------------------------------------------------------*/
340 void MailMergeCfg_Impl::Commit()
344 //typedef SfxTabPage* (*FNCreateTabPage)( Window *pParent, const SfxItemSet &rAttrSet );
345 SfxTabPage* CreateGeneralTabPage( sal_uInt16 nId, Window* pParent, const SfxItemSet& rSet )
347 CreateTabPage fnCreate = 0;
348 switch(nId)
350 case RID_SFXPAGE_SAVE: fnCreate = &SvxSaveTabPage::Create; break;
351 case RID_SFXPAGE_PATH: fnCreate = &SvxPathTabPage::Create; break;
352 case RID_SFXPAGE_GENERAL: fnCreate = &SvxGeneralTabPage::Create; break;
353 case RID_SFXPAGE_PRINTOPTIONS: fnCreate = &SfxCommonPrintOptionsTabPage::Create; break;
354 case OFA_TP_LANGUAGES: fnCreate = &OfaLanguagesTabPage::Create; break;
355 case RID_SFXPAGE_LINGU: fnCreate = &SvxLinguTabPage::Create; break;
356 case RID_SVXPAGE_COLOR: fnCreate = &SvxColorTabPage::Create; break;
357 case OFA_TP_VIEW: fnCreate = &OfaViewTabPage::Create; break;
358 case OFA_TP_MISC: fnCreate = &OfaMiscTabPage::Create; break;
359 case OFA_TP_MEMORY: fnCreate = &OfaMemoryOptionsPage::Create; break;
360 case RID_SVXPAGE_ASIAN_LAYOUT: fnCreate = &SvxAsianLayoutPage::Create; break;
361 case RID_SVX_FONT_SUBSTITUTION: fnCreate = &SvxFontSubstTabPage::Create; break;
362 case RID_SVXPAGE_INET_PROXY: fnCreate = &SvxProxyTabPage::Create; break;
363 case RID_SVXPAGE_INET_SEARCH: fnCreate = &SvxSearchTabPage::Create; break;
364 case RID_SVXPAGE_INET_SECURITY: fnCreate = &SvxSecurityTabPage::Create; break;
365 case RID_SVXPAGE_INET_MAIL: fnCreate = &SvxEMailTabPage::Create; break;
366 case RID_SVXPAGE_COLORCONFIG: fnCreate = &SvxColorOptionsTabPage::Create; break;
367 case RID_OFAPAGE_HTMLOPT: fnCreate = &OfaHtmlTabPage::Create; break;
368 case SID_OPTFILTER_MSOFFICE: fnCreate = &OfaMSFilterTabPage::Create; break;
369 case RID_OFAPAGE_MSFILTEROPT2: fnCreate = &OfaMSFilterTabPage2::Create; break;
370 case RID_SVXPAGE_JSEARCH_OPTIONS: fnCreate = &SvxJSearchOptionsPage::Create ; break;
371 case SID_SB_CONNECTIONPOOLING: fnCreate = &::offapp::ConnectionPoolOptionsPage::Create; break;
372 case SID_SB_DBREGISTEROPTIONS: fnCreate = &::svx::DbRegistrationOptionsPage::Create; break;
373 case RID_SVXPAGE_ACCESSIBILITYCONFIG: fnCreate = &SvxAccessibilityOptionsTabPage::Create; break;
374 case RID_SVXPAGE_SSO: fnCreate = GetSSOCreator(); break;
375 case RID_SVXPAGE_OPTIONS_CTL: fnCreate = &SvxCTLOptionsPage::Create ; break;
376 //added by jmeng begin
377 case RID_SVXPAGE_INET_MOZPLUGIN: fnCreate = &MozPluginTabPage::Create; break;
378 //added by jmeng end
379 case RID_SVXPAGE_OPTIONS_JAVA: fnCreate = &SvxJavaOptionsPage::Create ; break;
380 case RID_SVXPAGE_ONLINEUPDATE: fnCreate = &SvxOnlineUpdateTabPage::Create; break;
381 case RID_OPTPAGE_CHART_DEFCOLORS: fnCreate = &SvxDefaultColorOptPage::Create; break;
382 case RID_SVXPAGE_IMPROVEMENT: fnCreate = &SvxImprovementOptionsPage::Create; break;
385 SfxTabPage* pRet = fnCreate ? (*fnCreate)( pParent, rSet ) : NULL;
386 return pRet;
390 struct OptionsMapping_Impl
392 const char* m_pGroupName;
393 const char* m_pPageName;
394 USHORT m_nPageId;
397 static OptionsMapping_Impl __READONLY_DATA OptionsMap_Impl[] =
399 // GROUP PAGE PAGE-ID
400 { "ProductName", NULL, SID_GENERAL_OPTIONS },
401 { "ProductName", "UserData", RID_SFXPAGE_GENERAL },
402 { "ProductName", "General", OFA_TP_MISC },
403 { "ProductName", "Memory", OFA_TP_MEMORY },
404 { "ProductName", "View", OFA_TP_VIEW },
405 { "ProductName", "Print", RID_SFXPAGE_PRINTOPTIONS },
406 { "ProductName", "Paths", RID_SFXPAGE_PATH },
407 { "ProductName", "Colors", RID_SVXPAGE_COLOR },
408 { "ProductName", "Fonts", RID_SVX_FONT_SUBSTITUTION },
409 { "ProductName", "Security", RID_SVXPAGE_INET_SECURITY },
410 { "ProductName", "Appearance", RID_SVXPAGE_COLORCONFIG },
411 { "ProductName", "Accessibility", RID_SVXPAGE_ACCESSIBILITYCONFIG },
412 { "ProductName", "Java", RID_SVXPAGE_OPTIONS_JAVA },
413 { "ProductName", "NetworkIdentity", RID_SVXPAGE_SSO },
414 { "ProductName", "OnlineUpdate", RID_SVXPAGE_ONLINEUPDATE },
415 { "ProductName", "ImprovementProgram", RID_SVXPAGE_IMPROVEMENT },
416 { "LanguageSettings", NULL, SID_LANGUAGE_OPTIONS },
417 { "LanguageSettings", "Languages", OFA_TP_LANGUAGES },
418 { "LanguageSettings", "WritingAids", RID_SFXPAGE_LINGU },
419 { "LanguageSettings", "SearchingInJapanese", RID_SVXPAGE_JSEARCH_OPTIONS },
420 { "LanguageSettings", "AsianLayout", RID_SVXPAGE_ASIAN_LAYOUT },
421 { "LanguageSettings", "ComplexTextLayout", RID_SVXPAGE_OPTIONS_CTL },
422 { "Internet", NULL, SID_INET_DLG },
423 { "Internet", "Proxy", RID_SVXPAGE_INET_PROXY },
424 { "Internet", "Search", RID_SVXPAGE_INET_SEARCH },
425 { "Internet", "Email", RID_SVXPAGE_INET_MAIL },
426 { "Internet", "MozillaPlugin", RID_SVXPAGE_INET_MOZPLUGIN },
427 { "LoadSave", NULL, SID_FILTER_DLG },
428 { "LoadSave", "General", RID_SFXPAGE_SAVE },
429 { "LoadSave", "VBAProperties", SID_OPTFILTER_MSOFFICE },
430 { "LoadSave", "MicrosoftOffice", RID_OFAPAGE_MSFILTEROPT2 },
431 { "LoadSave", "HTMLCompatibility", RID_OFAPAGE_HTMLOPT },
432 { "Writer", NULL, SID_SW_EDITOPTIONS },
433 { "Writer", "General", RID_SW_TP_OPTLOAD_PAGE },
434 { "Writer", "View", RID_SW_TP_CONTENT_OPT },
435 { "Writer", "FormattingAids", RID_SW_TP_OPTSHDWCRSR },
436 { "Writer", "Grid", RID_SVXPAGE_GRID },
437 { "Writer", "BasicFontsWestern", RID_SW_TP_STD_FONT },
438 { "Writer", "BasicFontsAsian", RID_SW_TP_STD_FONT_CJK },
439 { "Writer", "BasicFontsCTL", RID_SW_TP_STD_FONT_CTL },
440 { "Writer", "Print", RID_SW_TP_OPTPRINT_PAGE },
441 { "Writer", "Table", RID_SW_TP_OPTTABLE_PAGE },
442 { "Writer", "Changes", RID_SW_TP_REDLINE_OPT },
443 { "Writer", "Compatibility", RID_SW_TP_OPTCOMPATIBILITY_PAGE },
444 { "Writer", "AutoCaption", RID_SW_TP_OPTCAPTION_PAGE },
445 { "Writer", "MailMerge", RID_SW_TP_MAILCONFIG },
446 { "WriterWeb", NULL, SID_SW_ONLINEOPTIONS },
447 { "WriterWeb", "View", RID_SW_TP_HTML_CONTENT_OPT },
448 { "WriterWeb", "FormattingAids", RID_SW_TP_HTML_OPTSHDWCRSR },
449 { "WriterWeb", "Grid", RID_SW_TP_HTML_OPTGRID_PAGE },
450 { "WriterWeb", "Print", RID_SW_TP_HTML_OPTPRINT_PAGE },
451 { "WriterWeb", "Table", RID_SW_TP_HTML_OPTTABLE_PAGE },
452 { "WriterWeb", "Background", RID_SW_TP_BACKGROUND },
453 { "Math", NULL, SID_SM_EDITOPTIONS },
454 { "Math", "Settings", SID_SM_TP_PRINTOPTIONS },
455 { "Calc", NULL, SID_SC_EDITOPTIONS },
456 { "Calc", "General", SID_SC_TP_LAYOUT },
457 { "Calc", "View", SID_SC_TP_CONTENT },
458 { "Calc", "International", RID_OFA_TP_INTERNATIONAL },
459 { "Calc", "Calculate", SID_SC_TP_CALC },
460 { "Calc", "Formula", SID_SC_TP_FORMULA },
461 { "Calc", "SortLists", SID_SC_TP_USERLISTS },
462 { "Calc", "Changes", SID_SC_TP_CHANGES },
463 { "Calc", "Grid", SID_SC_TP_GRID },
464 { "Calc", "Print", RID_SC_TP_PRINT },
465 { "Impress", NULL, SID_SD_EDITOPTIONS },
466 { "Impress", "General", SID_SI_TP_MISC },
467 { "Impress", "View", SID_SI_TP_CONTENTS },
468 { "Impress", "Grid", SID_SI_TP_SNAP },
469 { "Impress", "Print", SID_SI_TP_PRINT },
470 { "Draw", NULL, SID_SD_GRAPHIC_OPTIONS },
471 { "Draw", "General", SID_SD_TP_MISC },
472 { "Draw", "View", SID_SD_TP_CONTENTS },
473 { "Draw", "Grid", SID_SD_TP_SNAP },
474 { "Draw", "Print", SID_SD_TP_PRINT },
475 { "Charts", NULL, SID_SCH_EDITOPTIONS },
476 { "Charts", "DefaultColors", RID_OPTPAGE_CHART_DEFCOLORS },
477 { "Base", NULL, SID_SB_STARBASEOPTIONS },
478 { "Base", "Connections", SID_SB_CONNECTIONPOOLING },
479 { "Base", "Databases", SID_SB_DBREGISTEROPTIONS },
480 { NULL, NULL, 0 }
483 static sal_Bool lcl_getStringFromID( USHORT _nPageId, String& _rGroupName, String& _rPageName )
485 sal_Bool bRet = sal_False;
487 USHORT nIdx = 0;
488 while ( OptionsMap_Impl[nIdx].m_pGroupName != NULL )
490 if ( _nPageId == OptionsMap_Impl[nIdx].m_nPageId )
492 bRet = sal_True;
493 _rGroupName = String( OptionsMap_Impl[nIdx].m_pGroupName, RTL_TEXTENCODING_ASCII_US );
494 if ( OptionsMap_Impl[nIdx].m_pPageName != NULL )
495 _rPageName = String( OptionsMap_Impl[nIdx].m_pPageName, RTL_TEXTENCODING_ASCII_US );
496 break;
498 ++nIdx;
501 return bRet;
504 static sal_Bool lcl_isOptionHidden( USHORT _nPageId, const SvtOptionsDialogOptions& _rOptOptions )
506 sal_Bool bIsHidden = sal_False;
507 String sGroupName, sPageName;
508 if ( lcl_getStringFromID( _nPageId, sGroupName, sPageName ) )
510 if ( sPageName.Len() == 0 )
511 bIsHidden = _rOptOptions.IsGroupHidden( sGroupName );
512 else
513 bIsHidden = _rOptOptions.IsPageHidden( sPageName, sGroupName );
515 return bIsHidden;
518 /* -----------------11.02.99 09:56-------------------
520 * --------------------------------------------------*/
521 struct OptionsPageInfo
523 SfxTabPage* m_pPage;
524 sal_uInt16 m_nPageId;
525 rtl::OUString m_sPageURL;
526 rtl::OUString m_sEventHdl;
527 ExtensionsTabPage* m_pExtPage;
529 OptionsPageInfo( sal_uInt16 nId ) : m_pPage( NULL ), m_nPageId( nId ), m_pExtPage( NULL ) {}
532 struct OptionsGroupInfo
534 SfxItemSet* m_pInItemSet;
535 SfxItemSet* m_pOutItemSet;
536 SfxShell* m_pShell; // used to create the page
537 SfxModule* m_pModule; // used to create the ItemSet
538 sal_uInt16 m_nDialogId; // Id of the former dialog
539 sal_Bool m_bLoadError; // load fails?
540 rtl::OUString m_sPageURL;
541 ExtensionsTabPage* m_pExtPage;
543 OptionsGroupInfo( SfxShell* pSh, SfxModule* pMod, sal_uInt16 nId ) :
544 m_pInItemSet( NULL ), m_pOutItemSet( NULL ), m_pShell( pSh ),
545 m_pModule( pMod ), m_nDialogId( nId ), m_bLoadError( sal_False ),
546 m_sPageURL( rtl::OUString() ), m_pExtPage( NULL ) {}
547 ~OptionsGroupInfo() { delete m_pInItemSet; delete m_pOutItemSet; }
550 /* -----------------04.05.99 15:51-------------------
552 * --------------------------------------------------*/
553 sal_Bool OfaOptionsTreeListBox::Collapse( SvLBoxEntry* pParent )
555 bInCollapse = sal_True;
556 sal_Bool bRet = SvTreeListBox::Collapse(pParent);
557 bInCollapse = sal_False;
558 return bRet;
561 // -----------------------------------------------------------------------
563 #define INI_LIST() \
564 aOkPB ( this, SVX_RES( PB_OK ) ),\
565 aCancelPB ( this, SVX_RES( PB_CANCEL ) ),\
566 aHelpPB ( this, SVX_RES( PB_HELP ) ),\
567 aBackPB ( this, SVX_RES( PB_BACK ) ),\
568 aHiddenGB ( this, SVX_RES( FB_BORDER ) ),\
569 aPageTitleFT ( this, SVX_RES( FT_PAGE_TITLE ) ),\
570 aLine1FL ( this, SVX_RES( FL_LINE_1 ) ),\
571 aHelpFT ( this, SVX_RES( FT_HELPTEXT ) ),\
572 aHelpImg ( this, SVX_RES( IMG_HELP ) ),\
573 aHelpTextsArr ( SVX_RES( STR_HELPTEXTS ) ),\
574 aTreeLB ( this, SVX_RES( TLB_PAGES ) ),\
575 sTitle ( GetText() ),\
576 sNotLoadedError ( SVX_RES( ST_LOAD_ERROR ) ),\
577 pCurrentPageEntry ( NULL ),\
578 pColorPageItemSet ( NULL ),\
579 pColorTab ( NULL ),\
580 nChangeType ( CT_NONE ),\
581 nUnknownType ( COLORPAGE_UNKNOWN ),\
582 nUnknownPos ( COLORPAGE_UNKNOWN ),\
583 bIsAreaTP ( sal_False ),\
584 bForgetSelection ( sal_False ),\
585 bImageResized ( sal_False ),\
586 bInSelectHdl_Impl ( false ),\
587 bIsFromExtensionManager( false ), \
588 bIsForSetDocumentLanguage( false )
590 // Ctor() with Frame -----------------------------------------------------
591 using namespace ::com::sun::star;
592 OfaTreeOptionsDialog::OfaTreeOptionsDialog(
593 Window* pParent,
594 const Reference< XFrame >& _xFrame,
595 bool bActivateLastSelection ) :
597 SfxModalDialog( pParent, SVX_RES( RID_OFADLG_OPTIONS_TREE ) ),
598 INI_LIST()
600 FreeResource();
602 InitTreeAndHandler();
603 Initialize( _xFrame );
604 LoadExtensionOptions( rtl::OUString() );
605 ResizeTreeLB();
606 if (bActivateLastSelection)
607 ActivateLastSelection();
610 // Ctor() with ExtensionId -----------------------------------------------
612 OfaTreeOptionsDialog::OfaTreeOptionsDialog( Window* pParent, const rtl::OUString& rExtensionId ) :
614 SfxModalDialog( pParent, SVX_RES( RID_OFADLG_OPTIONS_TREE ) ),
616 INI_LIST()
619 FreeResource();
621 bIsFromExtensionManager = ( rExtensionId.getLength() > 0 );
622 InitTreeAndHandler();
623 LoadExtensionOptions( rExtensionId );
624 ResizeTreeLB();
625 ActivateLastSelection();
628 /* -----------------11.02.99 07:58-------------------
630 * --------------------------------------------------*/
632 OfaTreeOptionsDialog::~OfaTreeOptionsDialog()
634 SvLBoxEntry* pEntry = aTreeLB.First();
635 // first children
636 while(pEntry)
638 // if Child (has parent), then OptionsPageInfo
639 if(aTreeLB.GetParent(pEntry))
641 OptionsPageInfo *pPageInfo = (OptionsPageInfo *)pEntry->GetUserData();
642 if(pPageInfo->m_pPage)
644 pPageInfo->m_pPage->FillUserData();
645 String aPageData(pPageInfo->m_pPage->GetUserData());
646 if ( aPageData.Len() )
648 SvtViewOptions aTabPageOpt( E_TABPAGE, String::CreateFromInt32( pPageInfo->m_nPageId ) );
649 SetViewOptUserItem( aTabPageOpt, aPageData );
651 delete pPageInfo->m_pPage;
654 if (pPageInfo->m_nPageId == RID_SFXPAGE_LINGU)
656 // write personal dictionaries
657 Reference< XDictionaryList > xDicList( SvxGetDictionaryList() );
658 if (xDicList.is())
660 linguistic::SaveDictionaries( xDicList );
664 if( pPageInfo->m_pExtPage )
665 delete pPageInfo->m_pExtPage;
667 delete pPageInfo;
669 pEntry = aTreeLB.Next(pEntry);
672 // and parents
673 pEntry = aTreeLB.First();
674 while(pEntry)
676 if(!aTreeLB.GetParent(pEntry))
678 OptionsGroupInfo* pGroupInfo = (OptionsGroupInfo*)pEntry->GetUserData();
679 if ( pGroupInfo && pGroupInfo->m_pExtPage )
680 delete pGroupInfo->m_pExtPage;
681 delete pGroupInfo;
683 pEntry = aTreeLB.Next(pEntry);
685 delete pColorPageItemSet;
686 deleteGroupNames();
689 /* -----------------11.02.99 08:21-------------------
691 * --------------------------------------------------*/
692 OptionsPageInfo* OfaTreeOptionsDialog::AddTabPage(
693 sal_uInt16 nId, const String& rPageName, sal_uInt16 nGroup )
695 OptionsPageInfo* pPageInfo = new OptionsPageInfo( nId );
696 SvLBoxEntry* pParent = aTreeLB.GetEntry( 0, nGroup );
697 DBG_ASSERT( pParent, "OfaTreeOptionsDialog::AddTabPage(): no group found" );
698 SvLBoxEntry* pEntry = aTreeLB.InsertEntry( rPageName, pParent );
699 pEntry->SetUserData( pPageInfo );
700 return pPageInfo;
703 /* -----------------11.02.99 10:02-------------------
704 * der ItemSet* geht in den Besitz des Dialogs
705 * --------------------------------------------------*/
706 sal_uInt16 OfaTreeOptionsDialog::AddGroup(const String& rGroupName,
707 SfxShell* pCreateShell,
708 SfxModule* pCreateModule,
709 sal_uInt16 nDialogId )
711 SvLBoxEntry* pEntry = aTreeLB.InsertEntry(rGroupName);
712 OptionsGroupInfo* pInfo =
713 new OptionsGroupInfo( pCreateShell, pCreateModule, nDialogId );
714 pEntry->SetUserData(pInfo);
715 sal_uInt16 nRet = 0;
716 pEntry = aTreeLB.First();
717 while(pEntry)
719 if(!aTreeLB.GetParent(pEntry))
720 nRet++;
721 pEntry = aTreeLB.Next(pEntry);
723 return nRet - 1;
726 /* -----------------11.02.99 10:31-------------------
728 * --------------------------------------------------*/
729 IMPL_LINK(OfaTreeOptionsDialog, ShowPageHdl_Impl, SvTreeListBox*, EMPTYARG)
731 if ( aSelectTimer.GetTimeout() == SELECT_FIRST_TIMEOUT )
733 aSelectTimer.SetTimeout( SELECT_TIMEOUT );
734 SelectHdl_Impl( NULL );
736 else if ( aSelectTimer.GetTimeout() == SELECT_TIMEOUT )
737 aSelectTimer.Start();
739 return 0;
741 /* -----------------11.02.99 10:49-------------------
743 * --------------------------------------------------*/
744 IMPL_LINK( OfaTreeOptionsDialog, BackHdl_Impl, PushButton*, EMPTYARG )
746 if ( pCurrentPageEntry && aTreeLB.GetParent( pCurrentPageEntry ) )
748 OptionsPageInfo* pPageInfo = (OptionsPageInfo*)pCurrentPageEntry->GetUserData();
749 if ( pPageInfo->m_pPage )
751 OptionsGroupInfo* pGroupInfo =
752 (OptionsGroupInfo*)aTreeLB.GetParent( pCurrentPageEntry )->GetUserData();
753 if ( RID_SVXPAGE_COLOR == pPageInfo->m_nPageId )
754 pPageInfo->m_pPage->Reset( *pColorPageItemSet );
755 else
756 pPageInfo->m_pPage->Reset( *pGroupInfo->m_pInItemSet );
758 else if ( pPageInfo->m_pExtPage )
759 pPageInfo->m_pExtPage->ResetPage();
761 return 0;
763 /* -----------------11.02.99 16:45-------------------
765 * --------------------------------------------------*/
766 IMPL_LINK( OfaTreeOptionsDialog, OKHdl_Impl, Button *, EMPTYARG )
768 aTreeLB.EndSelection();
769 if ( pCurrentPageEntry && aTreeLB.GetParent( pCurrentPageEntry ) )
771 OptionsPageInfo* pPageInfo = (OptionsPageInfo *)pCurrentPageEntry->GetUserData();
772 if ( pPageInfo->m_pPage )
774 OptionsGroupInfo* pGroupInfo =
775 (OptionsGroupInfo *)aTreeLB.GetParent(pCurrentPageEntry)->GetUserData();
776 if ( RID_SVXPAGE_COLOR != pPageInfo->m_nPageId
777 && pPageInfo->m_pPage->HasExchangeSupport() )
779 int nLeave = pPageInfo->m_pPage->DeactivatePage(pGroupInfo->m_pOutItemSet);
780 if ( nLeave == SfxTabPage::KEEP_PAGE )
782 //die Seite darf nicht verlassen werden!
783 aTreeLB.Select(pCurrentPageEntry);
784 return 0;
787 pPageInfo->m_pPage->Hide();
791 SvLBoxEntry* pEntry = aTreeLB.First();
792 while ( pEntry )
794 if ( aTreeLB.GetParent( pEntry ) )
796 OptionsPageInfo* pPageInfo = (OptionsPageInfo *)pEntry->GetUserData();
797 if ( pPageInfo->m_pPage && !pPageInfo->m_pPage->HasExchangeSupport() )
799 OptionsGroupInfo* pGroupInfo =
800 (OptionsGroupInfo*)aTreeLB.GetParent(pEntry)->GetUserData();
801 pPageInfo->m_pPage->FillItemSet(*pGroupInfo->m_pOutItemSet);
804 if ( pPageInfo->m_pExtPage )
806 pPageInfo->m_pExtPage->DeactivatePage();
807 pPageInfo->m_pExtPage->SavePage();
810 pEntry = aTreeLB.Next(pEntry);
812 EndDialog(RET_OK);
813 return 0;
816 /* -----------------17.02.99 09:15-------------------
817 * Eine aufgeklappte Gruppe soll vollstaendig sichtbar sein
818 * --------------------------------------------------*/
819 IMPL_LINK(OfaTreeOptionsDialog, ExpandedHdl_Impl, SvTreeListBox*, pBox )
821 pBox->Update();
822 pBox->InitStartEntry();
823 SvLBoxEntry* pEntry = pBox->GetHdlEntry();
824 if(pEntry && pBox->IsExpanded(pEntry))
826 sal_uInt32 nChildCount = pBox->GetChildCount( pEntry );
828 SvLBoxEntry* pNext = pEntry;
829 for(sal_uInt32 i = 0; i < nChildCount;i++)
831 pNext = pBox->GetNextEntryInView(pNext);
832 if(!pNext)
834 pBox->ScrollOutputArea( -(short)(nChildCount - i + 1) );
835 break;
837 else
839 Size aSz(pBox->GetOutputSizePixel());
840 int nHeight = pBox->GetEntryHeight();
841 Point aPos(pBox->GetEntryPosition(pNext));
842 if(aPos.Y()+nHeight > aSz.Height())
844 pBox->ScrollOutputArea( -(short)(nChildCount - i + 1) );
845 break;
850 return 0;
853 /* -----------------11.02.99 10:49-------------------
855 * --------------------------------------------------*/
856 void OfaTreeOptionsDialog::ApplyItemSets()
858 SvLBoxEntry* pEntry = aTreeLB.First();
859 while(pEntry)
861 if(!aTreeLB.GetParent(pEntry))
863 OptionsGroupInfo* pGroupInfo = (OptionsGroupInfo *)pEntry->GetUserData();
864 if(pGroupInfo->m_pOutItemSet)
866 if(pGroupInfo->m_pShell)
867 pGroupInfo->m_pShell->ApplyItemSet( pGroupInfo->m_nDialogId, *pGroupInfo->m_pOutItemSet);
868 else
869 ApplyItemSet( pGroupInfo->m_nDialogId, *pGroupInfo->m_pOutItemSet);
872 pEntry = aTreeLB.Next(pEntry);
876 void OfaTreeOptionsDialog::InitTreeAndHandler()
878 aTreeLB.SetNodeDefaultImages();
880 String sResName = String::CreateFromAscii( "iso" );
881 ResMgr* pIsoRes = ResMgr::CreateResMgr( ::rtl::OUStringToOString( sResName, RTL_TEXTENCODING_UTF8 ) );
882 if ( !pIsoRes )
884 // Fallback: Use ooo resource file
885 String sOOoName = String::CreateFromAscii( "ooo" );
886 pIsoRes = ResMgr::CreateResMgr( ::rtl::OUStringToOString( sOOoName, RTL_TEXTENCODING_UTF8 ) );
889 //! ResMgr* pIsoRes = SFX_APP()->GetLabelResManager();
890 ResId aImgLstRes( RID_IMGLIST_TREEOPT, *pIsoRes );
891 aImgLstRes.SetRT( RSC_IMAGELIST );
892 if ( pIsoRes->IsAvailable( aImgLstRes ) )
893 aPageImages = ImageList( ResId( RID_IMGLIST_TREEOPT, *pIsoRes ) );
894 ResId aImgLstHCRes( RID_IMGLIST_TREEOPT_HC, *pIsoRes );
895 aImgLstHCRes.SetRT( RSC_IMAGELIST );
896 if ( pIsoRes->IsAvailable( aImgLstHCRes ) )
897 aPageImagesHC = ImageList( ResId( RID_IMGLIST_TREEOPT_HC, *pIsoRes ) );
898 delete pIsoRes;
900 aTreeLB.SetHelpId( HID_OFADLG_TREELISTBOX );
901 aTreeLB.SetWindowBits( WB_HASBUTTONS | WB_HASBUTTONSATROOT |
902 WB_HASLINES | WB_HASLINESATROOT |
903 WB_CLIPCHILDREN | WB_HSCROLL | WB_FORCE_MAKEVISIBLE );
904 aTreeLB.SetSpaceBetweenEntries( 0 );
905 aTreeLB.SetSelectionMode( SINGLE_SELECTION );
906 aTreeLB.SetSublistOpenWithLeftRight( TRUE );
907 aTreeLB.SetExpandedHdl( LINK( this, OfaTreeOptionsDialog, ExpandedHdl_Impl ) );
908 aTreeLB.SetSelectHdl( LINK( this, OfaTreeOptionsDialog, ShowPageHdl_Impl ) );
909 aBackPB.SetClickHdl( LINK( this, OfaTreeOptionsDialog, BackHdl_Impl ) );
910 aOkPB.SetClickHdl( LINK( this, OfaTreeOptionsDialog, OKHdl_Impl ) );
912 aHiddenGB.Show();
913 aSelectTimer.SetTimeout( SELECT_FIRST_TIMEOUT );
914 aSelectTimer.SetTimeoutHdl( LINK( this, OfaTreeOptionsDialog, SelectHdl_Impl ) );
917 /* -----------------17.02.99 09:51-------------------
919 * --------------------------------------------------*/
920 void OfaTreeOptionsDialog::ActivatePage( sal_uInt16 nResId )
922 bIsForSetDocumentLanguage = false;
923 if ( nResId == OFA_TP_LANGUAGES_FOR_SET_DOCUMENT_LANGUAGE )
925 bIsForSetDocumentLanguage = true;
926 nResId = OFA_TP_LANGUAGES;
929 DBG_ASSERT( !bIsFromExtensionManager, "OfaTreeOptionsDialog::ActivatePage(): call from extension manager" );
930 if ( !pLastPageSaver )
931 pLastPageSaver = new LastPageSaver;
932 bForgetSelection = sal_True;
933 sal_uInt16 nTemp = pLastPageSaver->m_nLastPageId;
934 pLastPageSaver->m_nLastPageId = nResId;
935 ActivateLastSelection();
936 pLastPageSaver->m_nLastPageId = nTemp;
939 void OfaTreeOptionsDialog::ActivatePage( const String& rPageURL )
941 DBG_ASSERT( !bIsFromExtensionManager, "OfaTreeOptionsDialog::ActivatePage(): call from extension manager" );
942 if ( !pLastPageSaver )
943 pLastPageSaver = new LastPageSaver;
944 bForgetSelection = sal_True;
945 pLastPageSaver->m_nLastPageId = 0;
946 pLastPageSaver->m_sLastPageURL_Tools = rPageURL;
947 ActivateLastSelection();
950 /* -----------------16.02.99 13:17-------------------
952 * --------------------------------------------------*/
953 void OfaTreeOptionsDialog::ActivateLastSelection()
955 SvLBoxEntry* pEntry = NULL;
956 if ( pLastPageSaver )
958 String sExpand( RTL_CONSTASCII_STRINGPARAM( EXPAND_PROTOCOL ) );
959 String sLastURL = bIsFromExtensionManager ? pLastPageSaver->m_sLastPageURL_ExtMgr
960 : pLastPageSaver->m_sLastPageURL_Tools;
961 if ( sLastURL.Len() == 0 )
963 sLastURL = !bIsFromExtensionManager ? pLastPageSaver->m_sLastPageURL_ExtMgr
964 : pLastPageSaver->m_sLastPageURL_Tools;
967 // MacroExpander to convert "expand"-URL to "file"-URL
968 Reference< XMacroExpander > m_xMacroExpander;
969 bool bMustExpand = ( INetURLObject( sLastURL ).GetProtocol() == INET_PROT_FILE );
971 if ( bMustExpand )
973 Reference< XComponentContext > xContext;
974 Reference< XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY );
975 xProps->getPropertyValue(
976 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ) >>= xContext;
977 if ( xContext.is() )
978 m_xMacroExpander = Reference< com::sun::star::util::XMacroExpander >(
979 xContext->getValueByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
980 "/singletons/com.sun.star.util.theMacroExpander" ) ) ), UNO_QUERY );
983 SvLBoxEntry* pTemp = aTreeLB.First();
984 while( !pEntry && pTemp )
986 // restore only selection of a leaf
987 if ( aTreeLB.GetParent( pTemp ) && pTemp->GetUserData() )
989 OptionsPageInfo* pPageInfo = (OptionsPageInfo*)pTemp->GetUserData();
990 String sPageURL = pPageInfo->m_sPageURL;
991 if ( bMustExpand
992 && sPageURL.Len() > 0
993 && sExpand.Match( sPageURL ) == STRING_MATCH )
995 // cut protocol
996 ::rtl::OUString sTemp( sPageURL.Copy( sizeof( EXPAND_PROTOCOL ) -1 ) );
997 // decode uri class chars
998 sTemp = ::rtl::Uri::decode(
999 sTemp, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
1000 // expand string
1001 sPageURL = m_xMacroExpander->expandMacros( sTemp );
1004 if ( ( !bIsFromExtensionManager
1005 && pPageInfo->m_nPageId && pPageInfo->m_nPageId == pLastPageSaver->m_nLastPageId )
1006 || ( !pPageInfo->m_nPageId && sLastURL == sPageURL ) )
1007 pEntry = pTemp;
1009 pTemp = aTreeLB.Next(pTemp);
1013 if ( !pEntry )
1015 pEntry = aTreeLB.First();
1016 pEntry = aTreeLB.Next(pEntry);
1019 SvLBoxEntry* pParent = aTreeLB.GetParent(pEntry);
1020 aTreeLB.Expand(pParent);
1021 aTreeLB.MakeVisible(pParent);
1022 aTreeLB.MakeVisible(pEntry);
1023 aTreeLB.Select(pEntry);
1024 aTreeLB.GrabFocus();
1027 /* -----------------22.02.99 08:52-------------------
1029 * --------------------------------------------------*/
1030 long OfaTreeOptionsDialog::Notify( NotifyEvent& rNEvt )
1032 if ( rNEvt.GetType() == EVENT_KEYINPUT )
1034 const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
1035 const KeyCode aKeyCode = pKEvt->GetKeyCode();
1037 if( aKeyCode.GetCode() == KEY_PAGEUP ||
1038 aKeyCode.GetCode() == KEY_PAGEDOWN)
1040 SvLBoxEntry* pCurEntry = aTreeLB.FirstSelected();
1041 SvLBoxEntry* pTemp = 0;
1042 if(aKeyCode.GetCode() == KEY_PAGEDOWN)
1044 pTemp = aTreeLB.Next( pCurEntry ) ;
1045 if(pTemp && !aTreeLB.GetParent(pTemp))
1047 pTemp = aTreeLB.Next( pTemp ) ;
1048 aTreeLB.Select(pTemp);
1051 else
1053 pTemp = aTreeLB.Prev( pCurEntry ) ;
1054 if(pTemp && !aTreeLB.GetParent(pTemp))
1056 pTemp = aTreeLB.Prev( pTemp ) ;
1059 if(pTemp)
1061 if(!aTreeLB.IsExpanded(aTreeLB.GetParent(pTemp)))
1062 aTreeLB.Expand(aTreeLB.GetParent(pTemp));
1063 aTreeLB.MakeVisible(pTemp);
1064 aTreeLB.Select(pTemp);
1068 return SfxModalDialog::Notify(rNEvt);
1071 // --------------------------------------------------------------------
1073 void OfaTreeOptionsDialog::DataChanged( const DataChangedEvent& rDCEvt )
1075 SfxModalDialog::DataChanged( rDCEvt );
1077 SvLBoxEntry* pEntry = aTreeLB.GetCurEntry();
1078 if ( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) &&
1079 !aTreeLB.GetParent(pEntry))
1081 OptionsGroupInfo* pInfo = static_cast<OptionsGroupInfo*>(pEntry->GetUserData());
1082 bool bHighContrast = GetDisplayBackground().GetColor().IsDark() != 0;
1083 ImageList* pImgLst = bHighContrast ? &aPageImagesHC : &aPageImages;
1084 for ( sal_uInt16 i = 0; i < aHelpTextsArr.Count(); ++i )
1086 if ( aHelpTextsArr.GetValue(i) == pInfo->m_nDialogId )
1088 aHelpImg.SetImage( pImgLst->GetImage( pInfo->m_nDialogId ) );
1089 break;
1094 class FlagSet_Impl
1096 bool & rFlag;
1097 public:
1098 FlagSet_Impl(bool& bFlag) : rFlag(bFlag){rFlag = true;}
1099 ~FlagSet_Impl(){rFlag = false;}
1102 IMPL_LINK( OfaTreeOptionsDialog, SelectHdl_Impl, Timer*, EMPTYARG )
1104 SvTreeListBox* pBox = &aTreeLB;
1105 SvLBoxEntry* pEntry = pBox->GetCurEntry();
1106 SvLBoxEntry* pParent = pBox->GetParent(pEntry);
1107 pBox->EndSelection();
1109 DBG_ASSERT(!bInSelectHdl_Impl, "Timeout handler called twice");
1110 if(bInSelectHdl_Impl || pCurrentPageEntry == pEntry)
1111 return 0;
1112 //#111938# lock the SelectHdl_Impl to prevent multiple executes
1113 FlagSet_Impl aFlag(bInSelectHdl_Impl);
1114 TabPage* pOldPage = NULL;
1115 TabPage* pNewPage = NULL;
1116 OptionsPageInfo* pOptPageInfo = ( pCurrentPageEntry && aTreeLB.GetParent( pCurrentPageEntry ) )
1117 ? (OptionsPageInfo*)pCurrentPageEntry->GetUserData() : NULL;
1119 if ( pOptPageInfo && pOptPageInfo->m_pPage && pOptPageInfo->m_pPage->IsVisible() )
1121 pOldPage = pOptPageInfo->m_pPage;
1122 OptionsGroupInfo* pGroupInfo = (OptionsGroupInfo*)aTreeLB.GetParent(pCurrentPageEntry)->GetUserData();
1123 int nLeave = SfxTabPage::LEAVE_PAGE;
1124 if ( RID_SVXPAGE_COLOR != pOptPageInfo->m_nPageId && pOptPageInfo->m_pPage->HasExchangeSupport() )
1125 nLeave = pOptPageInfo->m_pPage->DeactivatePage( pGroupInfo->m_pOutItemSet );
1127 if ( nLeave == SfxTabPage::KEEP_PAGE )
1129 // we cannot leave this page
1130 pBox->Select( pCurrentPageEntry );
1131 return 0;
1133 else
1134 pOptPageInfo->m_pPage->Hide();
1136 else if ( pOptPageInfo && pOptPageInfo->m_pExtPage )
1138 pOptPageInfo->m_pExtPage->Hide();
1139 pOptPageInfo->m_pExtPage->DeactivatePage();
1141 else if ( pCurrentPageEntry && !aTreeLB.GetParent( pCurrentPageEntry ) )
1143 OptionsGroupInfo* pGroupInfo = (OptionsGroupInfo*)pCurrentPageEntry->GetUserData();
1144 if ( pGroupInfo && pGroupInfo->m_pExtPage )
1146 pGroupInfo->m_pExtPage->Hide();
1147 pGroupInfo->m_pExtPage->DeactivatePage();
1150 if ( pParent )
1152 aPageTitleFT.Hide();
1153 aLine1FL.Hide();
1154 aHelpFT.Hide();
1155 aHelpImg.Hide();
1156 OptionsPageInfo *pPageInfo = (OptionsPageInfo *)pEntry->GetUserData();
1157 OptionsGroupInfo* pGroupInfo = (OptionsGroupInfo *)pParent->GetUserData();
1158 if(!pPageInfo->m_pPage && pPageInfo->m_nPageId > 0)
1160 if(pGroupInfo->m_bLoadError)
1161 return 0;
1162 if ( RID_SVXPAGE_COLOR == pPageInfo->m_nPageId )
1164 if(!pColorPageItemSet)
1166 // Move usage of a static XOutdevItemPool instance here
1167 if(!mpStaticXOutdevItemPool)
1169 mpStaticXOutdevItemPool = new XOutdevItemPool();
1171 pColorPageItemSet = new SfxItemSet( *mpStaticXOutdevItemPool, XATTR_FILLSTYLE, XATTR_FILLCOLOR);
1172 pColorPageItemSet->Put( XFillColorItem() );
1175 else
1177 if(pGroupInfo->m_pModule /*&& !pGroupInfo->pModule->IsLoaded()*/)
1179 SfxModule* pOldModule = pGroupInfo->m_pModule;
1180 sal_Bool bIdentical = pGroupInfo->m_pModule == pGroupInfo->m_pShell;
1182 WaitObject aWait(this);
1183 //pGroupInfo->pModule = pGroupInfo->pModule->Load();
1184 if(!pGroupInfo->m_pModule)
1186 pGroupInfo->m_bLoadError = sal_True;
1187 InfoBox(pBox, sNotLoadedError).Execute();
1188 return 0;
1190 if(bIdentical)
1191 pGroupInfo->m_pShell = pGroupInfo->m_pModule;
1192 //jetzt noch testen, ob es auch in anderen Gruppen das gleiche Module gab (z.B. Text+HTML)
1193 SvLBoxEntry* pTemp = aTreeLB.First();
1194 while(pTemp)
1196 if(!aTreeLB.GetParent(pTemp) && pTemp != pEntry)
1198 OptionsGroupInfo* pTGInfo = (OptionsGroupInfo *)pTemp->GetUserData();
1199 if(pTGInfo->m_pModule == pOldModule)
1201 pTGInfo->m_pModule = pGroupInfo->m_pModule;
1202 if(bIdentical)
1203 pTGInfo->m_pShell = pGroupInfo->m_pModule;
1206 pTemp = aTreeLB.Next(pTemp);
1210 // if ( pPageInfo->nPageId != RID_OPTPAGE_CHART_DEFCOLORS )
1212 if(!pGroupInfo->m_pInItemSet)
1213 pGroupInfo->m_pInItemSet = pGroupInfo->m_pShell
1214 ? pGroupInfo->m_pShell->CreateItemSet( pGroupInfo->m_nDialogId )
1215 : CreateItemSet( pGroupInfo->m_nDialogId );
1216 if(!pGroupInfo->m_pOutItemSet)
1217 pGroupInfo->m_pOutItemSet = new SfxItemSet(
1218 *pGroupInfo->m_pInItemSet->GetPool(),
1219 pGroupInfo->m_pInItemSet->GetRanges());
1223 if(pGroupInfo->m_pModule)
1225 pPageInfo->m_pPage = pGroupInfo->m_pModule->CreateTabPage(
1226 pPageInfo->m_nPageId, this, *pGroupInfo->m_pInItemSet );
1228 else if(RID_SVXPAGE_COLOR != pPageInfo->m_nPageId)
1229 pPageInfo->m_pPage = ::CreateGeneralTabPage( pPageInfo->m_nPageId, this, *pGroupInfo->m_pInItemSet );
1230 else
1232 pPageInfo->m_pPage = ::CreateGeneralTabPage(
1233 pPageInfo->m_nPageId, this, *pColorPageItemSet );
1234 SvxColorTabPage& rColPage = *(SvxColorTabPage*)pPageInfo->m_pPage;
1235 const OfaPtrItem* pPtr = NULL;
1236 if ( SfxViewFrame::Current() && SfxViewFrame::Current()->GetDispatcher() )
1237 pPtr = (const OfaPtrItem*)SfxViewFrame::Current()->
1238 GetDispatcher()->Execute( SID_GET_COLORTABLE, SFX_CALLMODE_SYNCHRON );
1239 pColorTab = pPtr ? (XColorTable*)pPtr->GetValue() : XColorTable::GetStdColorTable();
1241 rColPage.SetColorTable( pColorTab );
1242 rColPage.SetPageType( &nUnknownType );
1243 rColPage.SetDlgType( &nUnknownType );
1244 rColPage.SetPos( &nUnknownPos );
1245 rColPage.SetAreaTP( &bIsAreaTP );
1246 rColPage.SetColorChgd( (ChangeType*)&nChangeType );
1247 rColPage.Construct();
1250 DBG_ASSERT( pPageInfo->m_pPage, "tabpage could not created");
1251 if ( pPageInfo->m_pPage )
1253 SvtViewOptions aTabPageOpt( E_TABPAGE, String::CreateFromInt32( pPageInfo->m_nPageId ) );
1254 pPageInfo->m_pPage->SetUserData( GetViewOptUserItem( aTabPageOpt ) );
1256 Point aTreePos(aTreeLB.GetPosPixel());
1257 Size aTreeSize(aTreeLB.GetSizePixel());
1258 Point aGBPos(aHiddenGB.GetPosPixel());
1259 Size aPageSize(pPageInfo->m_pPage->GetSizePixel());
1260 Size aGBSize(aHiddenGB.GetSizePixel());
1261 Point aPagePos( aGBPos.X() + ( aGBSize.Width() - aPageSize.Width() ) / 2,
1262 aGBPos.Y() + ( aGBSize.Height() - aPageSize.Height() ) / 2 );
1263 pPageInfo->m_pPage->SetPosPixel( aPagePos );
1264 if ( RID_SVXPAGE_COLOR == pPageInfo->m_nPageId )
1266 pPageInfo->m_pPage->Reset( *pColorPageItemSet );
1267 pPageInfo->m_pPage->ActivatePage( *pColorPageItemSet );
1269 else
1271 pPageInfo->m_pPage->Reset( *pGroupInfo->m_pInItemSet );
1275 else if ( 0 == pPageInfo->m_nPageId && !pPageInfo->m_pExtPage )
1277 if ( !m_xContainerWinProvider.is() )
1279 Reference < XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
1280 m_xContainerWinProvider = Reference < awt::XContainerWindowProvider >(
1281 xFactory->createInstance(
1282 C2U("com.sun.star.awt.ContainerWindowProvider") ), UNO_QUERY );
1283 DBG_ASSERT( m_xContainerWinProvider.is(), "service com.sun.star.awt.ContainerWindowProvider could not be loaded" );
1286 pPageInfo->m_pExtPage = new ExtensionsTabPage(
1287 this, 0, pPageInfo->m_sPageURL, pPageInfo->m_sEventHdl, m_xContainerWinProvider );
1288 Size aSize = aHiddenGB.GetSizePixel();
1289 aSize.Width() = aSize.Width() - 4;
1290 aSize.Height() = aSize.Height() - 4;
1291 Point aPos = aHiddenGB.GetPosPixel();
1292 aPos.X() = aPos.X() + 2;
1293 aPos.Y() = aPos.Y() + 2;
1294 pPageInfo->m_pExtPage->SetPosSizePixel( aPos, aSize );
1297 if ( pPageInfo->m_pPage )
1299 if ( RID_SVXPAGE_COLOR != pPageInfo->m_nPageId &&
1300 pPageInfo->m_pPage->HasExchangeSupport())
1302 pPageInfo->m_pPage->ActivatePage(*pGroupInfo->m_pOutItemSet);
1304 pPageInfo->m_pPage->Show();
1306 else if ( pPageInfo->m_pExtPage )
1308 pPageInfo->m_pExtPage->Show();
1309 pPageInfo->m_pExtPage->ActivatePage();
1312 String sTmpTitle = sTitle;
1313 sTmpTitle += String::CreateFromAscii(" - ");
1314 sTmpTitle += aTreeLB.GetEntryText(pParent);
1315 sTmpTitle += String::CreateFromAscii(" - ");
1316 sTmpTitle += aTreeLB.GetEntryText(pEntry);
1317 SetText(sTmpTitle);
1318 pCurrentPageEntry = pEntry;
1319 if ( !bForgetSelection )
1321 if ( !pLastPageSaver )
1322 pLastPageSaver = new LastPageSaver;
1323 if ( !bIsFromExtensionManager )
1324 pLastPageSaver->m_nLastPageId = pPageInfo->m_nPageId;
1325 if ( pPageInfo->m_pExtPage )
1327 if ( bIsFromExtensionManager )
1328 pLastPageSaver->m_sLastPageURL_ExtMgr = pPageInfo->m_sPageURL;
1329 else
1330 pLastPageSaver->m_sLastPageURL_Tools = pPageInfo->m_sPageURL;
1333 pNewPage = pPageInfo->m_pPage;
1335 else
1337 OptionsGroupInfo* pTGInfo = (OptionsGroupInfo *)pEntry->GetUserData();
1338 if ( pTGInfo->m_sPageURL.getLength() == 0 )
1340 bool bHighContrast = GetDisplayBackground().GetColor().IsDark() != 0;
1341 ImageList* pImgLst = bHighContrast ? &aPageImagesHC : &aPageImages;
1342 //hier den Hilfetext anzeigen
1343 for ( sal_uInt16 i = 0; i < aHelpTextsArr.Count(); ++i )
1345 if ( aHelpTextsArr.GetValue(i) == pTGInfo->m_nDialogId )
1347 aHelpFT.SetText(aHelpTextsArr.GetString(i));
1348 aHelpImg.SetImage(pImgLst->GetImage(pTGInfo->m_nDialogId));
1349 break;
1353 aPageTitleFT.Show();
1354 aLine1FL.Show();
1355 aHelpFT.Show();
1356 aHelpImg.Show();
1358 //auf die Groesse der Bitmap anpassen
1359 if(!bImageResized)
1361 const long nCtrlDist = 2;
1362 bImageResized = sal_True;
1363 Point aImgPos(aHelpImg.GetPosPixel());
1364 Size aImgSize(aHelpImg.GetSizePixel());
1365 Point aTitlePos(aPageTitleFT.GetPosPixel());
1366 Point aLinePos(aLine1FL.GetPosPixel());
1367 Point aHelpPos(aHelpFT.GetPosPixel());
1368 Size aHelpSize(aHelpFT.GetSizePixel());
1369 long nXDiff = 0;
1370 long nYDiff = 0;
1371 if(aTitlePos.X() <= (aImgPos.X() + aImgSize.Width() + nCtrlDist))
1373 nXDiff = aImgPos.X() + aImgSize.Width() + nCtrlDist - aTitlePos.X();
1375 if(aLinePos.Y() <= (aImgPos.Y() + aImgSize.Height() + nCtrlDist))
1377 nYDiff = aImgPos.Y() + aImgSize.Height() + nCtrlDist - aLinePos.Y();
1379 aLinePos.Y() += nYDiff;
1380 aLine1FL.SetPosPixel(aLinePos);
1382 aTitlePos.X() += nXDiff;
1383 aPageTitleFT.SetPosPixel(aTitlePos);
1385 aHelpPos.X() += nXDiff;
1386 aHelpPos.Y() += nYDiff;
1387 aHelpSize.Width() -= nXDiff;
1388 aHelpSize.Height() -= nYDiff;
1389 aHelpFT.SetPosSizePixel(aHelpPos, aHelpSize);
1391 Font aFont = aHelpFT.GetFont();
1392 Size aSz = aFont.GetSize();
1393 aSz.Height() = (aSz.Height() * 14 ) / 10;
1394 aFont.SetSize(aSz);
1395 aPageTitleFT.SetFont(aFont);
1398 String sTmpTitle = sTitle;
1399 sTmpTitle += String::CreateFromAscii(" - ");
1400 aPageTitleFT.SetText(aTreeLB.GetEntryText(pEntry));
1401 sTmpTitle += aPageTitleFT.GetText();
1402 SetText(sTmpTitle);
1403 pCurrentPageEntry = NULL;
1405 else
1407 if ( !pTGInfo->m_pExtPage )
1409 if ( !m_xContainerWinProvider.is() )
1411 Reference < XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
1412 m_xContainerWinProvider = Reference < awt::XContainerWindowProvider >(
1413 xFactory->createInstance(
1414 C2U("com.sun.star.awt.ContainerWindowProvider") ), UNO_QUERY );
1415 DBG_ASSERT( m_xContainerWinProvider.is(), "service com.sun.star.awt.ContainerWindowProvider could not be loaded" );
1418 pTGInfo->m_pExtPage =
1419 new ExtensionsTabPage( this, 0, pTGInfo->m_sPageURL, rtl::OUString(), m_xContainerWinProvider );
1420 Size aSize = aHiddenGB.GetSizePixel();
1421 aSize.Width() = aSize.Width() - 4;
1422 aSize.Height() = aSize.Height() - 4;
1423 Point aPos = aHiddenGB.GetPosPixel();
1424 aPos.X() = aPos.X() + 2;
1425 aPos.Y() = aPos.Y() + 2;
1426 pTGInfo->m_pExtPage->SetPosSizePixel( aPos, aSize );
1429 if ( pTGInfo->m_pExtPage )
1431 pTGInfo->m_pExtPage->Show();
1432 pTGInfo->m_pExtPage->ActivatePage();
1435 pCurrentPageEntry = pEntry;
1439 // restore lost focus, if necessary
1440 Window* pFocusWin = Application::GetFocusWindow();
1441 // if the focused window is not the options treebox and the old page has the focus
1442 if ( pFocusWin && pFocusWin != pBox && pOldPage && pOldPage->HasChildPathFocus() )
1443 // then set the focus to the new page or if we are on a group set the focus to the options treebox
1444 pNewPage ? pNewPage->GrabFocus() : pBox->GrabFocus();
1446 return 0;
1449 /* -----------------11.02.99 15:51-------------------
1451 * --------------------------------------------------*/
1453 OfaPageResource::OfaPageResource() :
1454 Resource(SVX_RES(RID_OFADLG_OPTIONS_TREE_PAGES)),
1455 aGeneralDlgAry(SVX_RES(SID_GENERAL_OPTIONS)),
1456 aInetDlgAry(SVX_RES(SID_INET_DLG)),
1457 aLangDlgAry(SVX_RES(SID_LANGUAGE_OPTIONS)),
1458 aTextDlgAry(SVX_RES(SID_SW_EDITOPTIONS)),
1459 aHTMLDlgAry(SVX_RES(SID_SW_ONLINEOPTIONS)),
1460 aCalcDlgAry(SVX_RES(SID_SC_EDITOPTIONS)),
1461 aStarMathDlgAry(SVX_RES(SID_SM_EDITOPTIONS)),
1462 aImpressDlgAry(SVX_RES(SID_SD_EDITOPTIONS)),
1463 aDrawDlgAry(SVX_RES(SID_SD_GRAPHIC_OPTIONS)),
1464 aChartDlgAry(SVX_RES(SID_SCH_EDITOPTIONS)),
1465 aFilterDlgAry(SVX_RES(SID_FILTER_DLG)),
1466 aDatasourcesDlgAry(SVX_RES(SID_SB_STARBASEOPTIONS))
1468 FreeResource();
1471 BOOL EnableSSO( void )
1473 // SSO must be enabled if the configuration manager bootstrap settings
1474 // are configured as follows ...
1475 // CFG_Offline=false
1476 // CFG_ServerType=uno ( or unspecified )
1477 // CFG_BackendService=
1478 // com.sun.star.comp.configuration.backend.LdapSingleBackend
1480 rtl::OUString theIniFile;
1481 osl_getExecutableFile( &theIniFile.pData );
1482 theIniFile = theIniFile.copy( 0, theIniFile.lastIndexOf( '/' ) + 1 ) +
1483 rtl::OUString::createFromAscii( SAL_CONFIGFILE( "configmgr" ) );
1484 ::rtl::Bootstrap theBootstrap( theIniFile );
1486 rtl::OUString theOfflineValue;
1487 rtl::OUString theDefaultOfflineValue = rtl::OUString::createFromAscii( "false" );
1488 theBootstrap.getFrom( rtl::OUString::createFromAscii( "CFG_Offline" ),
1489 theOfflineValue,
1490 theDefaultOfflineValue );
1492 rtl::OUString theServerTypeValue;
1493 theBootstrap.getFrom( rtl::OUString::createFromAscii( "CFG_ServerType" ),
1494 theServerTypeValue );
1496 rtl::OUString theBackendServiceTypeValue;
1497 theBootstrap.getFrom( rtl::OUString::createFromAscii( "CFG_BackendService" ),
1498 theBackendServiceTypeValue );
1500 BOOL bSSOEnabled =
1501 ( theOfflineValue == theDefaultOfflineValue &&
1502 ( theServerTypeValue.getLength() == 0 ||
1503 theServerTypeValue == rtl::OUString::createFromAscii( "uno" ) ) &&
1504 theBackendServiceTypeValue ==
1505 rtl::OUString::createFromAscii(
1506 "com.sun.star.comp.configuration.backend.LdapSingleBackend" ) );
1507 if ( bSSOEnabled && GetSSOCreator() == 0 )
1509 bSSOEnabled = FALSE;
1511 return bSSOEnabled;
1514 extern "C" { static void SAL_CALL thisModule() {} }
1516 CreateTabPage GetSSOCreator( void )
1518 static CreateTabPage theSymbol = 0;
1519 if ( theSymbol == 0 )
1521 osl::Module aModule;
1522 rtl::OUString theModuleName( RTL_CONSTASCII_USTRINGPARAM( SVLIBRARY( "ssoopt" ) ) );
1523 if( aModule.loadRelative(
1524 &thisModule, theModuleName, SAL_LOADMODULE_DEFAULT ) )
1526 rtl::OUString theSymbolName( rtl::OUString::createFromAscii( "CreateSSOTabPage" ) );
1527 theSymbol = reinterpret_cast<CreateTabPage>(aModule.getFunctionSymbol( theSymbolName ));
1531 return theSymbol;
1534 SfxItemSet* OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId )
1536 Reference< XPropertySet > xProp( SvxGetLinguPropertySet() );
1537 SfxItemSet* pRet = 0;
1538 switch(nId)
1540 case SID_GENERAL_OPTIONS:
1542 pRet = new SfxItemSet(
1543 SFX_APP()->GetPool(),
1544 SID_ATTR_METRIC, SID_ATTR_SPELL,
1545 SID_AUTOSPELL_CHECK, SID_AUTOSPELL_CHECK,
1546 SID_ATTR_QUICKLAUNCHER, SID_ATTR_QUICKLAUNCHER,
1547 SID_ATTR_YEAR2000, SID_ATTR_YEAR2000,
1548 SID_HTML_MODE, SID_HTML_MODE,
1549 0 );
1551 SfxItemSet aOptSet( SFX_APP()->GetPool(), SID_ATTR_QUICKLAUNCHER, SID_ATTR_QUICKLAUNCHER );
1552 SFX_APP()->GetOptions(aOptSet);
1553 pRet->Put(aOptSet);
1555 SfxMiscCfg* pMisc = SFX_APP()->GetMiscConfig();
1556 const SfxPoolItem* pItem;
1557 SfxViewFrame* pViewFrame = SfxViewFrame::Current();
1558 if ( pViewFrame )
1560 SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
1562 // Sonstiges - Year2000
1563 if( SFX_ITEM_AVAILABLE <= pDispatch->QueryState( SID_ATTR_YEAR2000, pItem ) )
1564 pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, ((const SfxUInt16Item*)pItem)->GetValue() ) );
1565 else
1566 pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, (USHORT)pMisc->GetYear2000() ) );
1568 else
1569 pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, (USHORT)pMisc->GetYear2000() ) );
1572 // Sonstiges - Tabulator
1573 pRet->Put(SfxBoolItem(SID_PRINTER_NOTFOUND_WARN, pMisc->IsNotFoundWarning()));
1575 sal_uInt16 nFlag = pMisc->IsPaperSizeWarning() ? SFX_PRINTER_CHG_SIZE : 0;
1576 nFlag |= pMisc->IsPaperOrientationWarning() ? SFX_PRINTER_CHG_ORIENTATION : 0;
1577 pRet->Put( SfxFlagItem( SID_PRINTER_CHANGESTODOC, nFlag ));
1580 break;
1581 case SID_LANGUAGE_OPTIONS :
1583 pRet = new SfxItemSet(SFX_APP()->GetPool(),
1584 SID_ATTR_LANGUAGE, SID_AUTOSPELL_CHECK,
1585 SID_ATTR_CHAR_CJK_LANGUAGE, SID_ATTR_CHAR_CTL_LANGUAGE,
1586 SID_OPT_LOCALE_CHANGED, SID_OPT_LOCALE_CHANGED,
1587 SID_SET_DOCUMENT_LANGUAGE, SID_SET_DOCUMENT_LANGUAGE,
1588 0 );
1590 // fuer die Linguistik
1592 Reference< XSpellChecker1 > xSpell = SvxGetSpellChecker();
1593 pRet->Put(SfxSpellCheckItem( xSpell, SID_ATTR_SPELL ));
1594 SfxHyphenRegionItem aHyphen( SID_ATTR_HYPHENREGION );
1596 sal_Int16 nMinLead = 2,
1597 nMinTrail = 2;
1598 if (xProp.is())
1600 xProp->getPropertyValue( String::CreateFromAscii(
1601 UPN_HYPH_MIN_LEADING) ) >>= nMinLead;
1602 xProp->getPropertyValue( String::CreateFromAscii(
1603 UPN_HYPH_MIN_TRAILING) ) >>= nMinTrail;
1605 aHyphen.GetMinLead() = (sal_uInt8)nMinLead;
1606 aHyphen.GetMinTrail() = (sal_uInt8)nMinTrail;
1608 const SfxPoolItem* pItem;
1609 SfxPoolItem* pClone;
1610 SfxViewFrame* pViewFrame = SfxViewFrame::Current();
1611 if ( pViewFrame )
1613 SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
1614 if(SFX_ITEM_AVAILABLE <= pDispatch->QueryState(SID_ATTR_LANGUAGE, pItem))
1615 pRet->Put(SfxUInt16Item(SID_ATTR_LANGUAGE, ((const SvxLanguageItem*)pItem)->GetLanguage()));
1616 if(SFX_ITEM_AVAILABLE <= pDispatch->QueryState(SID_ATTR_CHAR_CJK_LANGUAGE, pItem))
1617 pRet->Put(SfxUInt16Item(SID_ATTR_CHAR_CJK_LANGUAGE, ((const SvxLanguageItem*)pItem)->GetLanguage()));
1618 if(SFX_ITEM_AVAILABLE <= pDispatch->QueryState(SID_ATTR_CHAR_CTL_LANGUAGE, pItem))
1619 pRet->Put(SfxUInt16Item(SID_ATTR_CHAR_CTL_LANGUAGE, ((const SvxLanguageItem*)pItem)->GetLanguage()));
1621 pRet->Put(aHyphen);
1622 if(SFX_ITEM_AVAILABLE <= pDispatch->QueryState(SID_AUTOSPELL_CHECK, pItem))
1624 pClone = pItem->Clone();
1625 pRet->Put(*pClone);
1626 delete pClone;
1628 else
1630 sal_Bool bVal = sal_False;
1631 if (xProp.is())
1633 xProp->getPropertyValue( String::CreateFromAscii( UPN_IS_SPELL_AUTO) ) >>= bVal;
1636 pRet->Put(SfxBoolItem(SID_AUTOSPELL_CHECK, bVal));
1639 pRet->Put( SfxBoolItem( SID_SET_DOCUMENT_LANGUAGE, bIsForSetDocumentLanguage ) );
1641 break;
1642 case SID_INET_DLG :
1643 pRet = new SfxItemSet( SFX_APP()->GetPool(),
1644 SID_BASIC_ENABLED, SID_BASIC_ENABLED,
1645 //SID_OPTIONS_START - ..END
1646 SID_OPTIONS_START, SID_INET_PROXY_PORT,
1647 SID_SAVEREL_INET, SID_SAVEREL_FSYS,
1648 SID_INET_SMTPSERVER, SID_INET_SMTPSERVER,
1649 SID_INET_NOPROXY, SID_INET_SOCKS_PROXY_PORT,
1650 SID_INET_DNS_AUTO, SID_INET_DNS_SERVER,
1651 SID_SECURE_URL, SID_SECURE_URL,
1652 0L );
1653 SFX_APP()->GetOptions(*pRet);
1654 break;
1655 case SID_FILTER_DLG:
1656 pRet = new SfxItemSet( SFX_APP()->GetPool(),
1657 SID_ATTR_DOCINFO, SID_ATTR_AUTOSAVEMINUTE,
1658 SID_SAVEREL_INET, SID_SAVEREL_FSYS,
1659 SID_ATTR_PRETTYPRINTING, SID_ATTR_PRETTYPRINTING,
1660 SID_ATTR_WARNALIENFORMAT, SID_ATTR_WARNALIENFORMAT,
1661 0 );
1662 SFX_APP()->GetOptions(*pRet);
1663 break;
1665 case SID_SB_STARBASEOPTIONS:
1666 pRet = new SfxItemSet( SFX_APP()->GetPool(),
1667 SID_SB_POOLING_ENABLED, SID_SB_DB_REGISTER,
1668 0 );
1669 ::offapp::ConnectionPoolConfig::GetOptions(*pRet);
1670 ::svx::DbRegisteredNamesConfig::GetOptions(*pRet);
1671 break;
1673 case SID_SCH_EDITOPTIONS:
1675 SvxChartOptions aChartOpt;
1676 pRet = new SfxItemSet( SFX_APP()->GetPool(), SID_SCH_EDITOPTIONS, SID_SCH_EDITOPTIONS );
1677 pRet->Put( SvxChartColorTableItem( SID_SCH_EDITOPTIONS, aChartOpt.GetDefaultColors() ) );
1678 break;
1681 return pRet;
1684 void OfaTreeOptionsDialog::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet )
1686 switch(nId)
1688 case SID_GENERAL_OPTIONS:
1690 SfxMiscCfg* pMisc = SFX_APP()->GetMiscConfig();
1691 const SfxPoolItem* pItem;
1692 SfxItemSet aOptSet(SFX_APP()->GetPool(), SID_ATTR_QUICKLAUNCHER, SID_ATTR_QUICKLAUNCHER );
1693 aOptSet.Put(rSet);
1694 if(aOptSet.Count())
1695 SFX_APP()->SetOptions( aOptSet );
1696 // Dispatcher neu holen, weil SetOptions() ggf. den Dispatcher zerst"ort hat
1697 SfxViewFrame *pViewFrame = SfxViewFrame::Current();
1698 // -------------------------------------------------------------------------
1699 // Year2000 auswerten
1700 // -------------------------------------------------------------------------
1701 USHORT nY2K = USHRT_MAX;
1702 if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_YEAR2000, sal_False, &pItem ) )
1703 nY2K = ((const SfxUInt16Item*)pItem)->GetValue();
1704 if( USHRT_MAX != nY2K )
1706 if ( pViewFrame )
1708 SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
1709 pDispatch->Execute( SID_ATTR_YEAR2000, SFX_CALLMODE_ASYNCHRON, pItem, 0L);
1711 pMisc->SetYear2000(nY2K);
1714 // -------------------------------------------------------------------------
1715 // Drucken auswerten
1716 // -------------------------------------------------------------------------
1717 if(SFX_ITEM_SET == rSet.GetItemState(SID_PRINTER_NOTFOUND_WARN, sal_False, &pItem))
1718 pMisc->SetNotFoundWarning(((const SfxBoolItem*)pItem)->GetValue());
1720 if(SFX_ITEM_SET == rSet.GetItemState(SID_PRINTER_CHANGESTODOC, sal_False, &pItem))
1722 const SfxFlagItem* pFlag = (const SfxFlagItem*)pItem;
1723 pMisc->SetPaperSizeWarning(0 != (pFlag->GetValue() & SFX_PRINTER_CHG_SIZE ));
1724 pMisc->SetPaperOrientationWarning(0 != (pFlag->GetValue() & SFX_PRINTER_CHG_ORIENTATION ));
1726 // -------------------------------------------------------------------------
1727 // evaluate help options
1728 // -------------------------------------------------------------------------
1729 if ( SvtHelpOptions().IsHelpTips() != Help::IsQuickHelpEnabled() )
1730 SvtHelpOptions().IsHelpTips() ? Help::EnableQuickHelp() : Help::DisableQuickHelp();
1731 if ( SvtHelpOptions().IsExtendedHelp() != Help::IsBalloonHelpEnabled() )
1732 SvtHelpOptions().IsExtendedHelp() ? Help::EnableBalloonHelp() : Help::DisableBalloonHelp();
1734 break;
1735 case SID_LANGUAGE_OPTIONS :
1737 OfaTreeOptionsDialog::ApplyLanguageOptions(rSet);
1739 break;
1740 case SID_INET_DLG :
1741 case SID_FILTER_DLG:
1742 SFX_APP()->SetOptions( rSet );
1743 break;
1745 case SID_SB_STARBASEOPTIONS:
1746 ::offapp::ConnectionPoolConfig::SetOptions( rSet );
1747 ::svx::DbRegisteredNamesConfig::SetOptions(rSet);
1748 break;
1750 case SID_SCH_EDITOPTIONS:
1751 // nothing to do. Chart options only apply to newly created charts
1752 break;
1754 default:
1756 DBG_ERROR( "Unhandled option in ApplyItemSet" );
1758 break;
1762 void OfaTreeOptionsDialog::ApplyLanguageOptions(const SfxItemSet& rSet)
1764 sal_Bool bSaveSpellCheck = sal_False;
1765 const SfxPoolItem* pItem;
1767 if ( SFX_ITEM_SET == rSet.GetItemState( SID_SPELL_MODIFIED, sal_False, &pItem ) )
1769 bSaveSpellCheck = ( (const SfxBoolItem*)pItem )->GetValue();
1771 Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
1772 Reference< XPropertySet > xProp(
1773 xMgr->createInstance( ::rtl::OUString::createFromAscii(
1774 "com.sun.star.linguistic2.LinguProperties") ),
1775 UNO_QUERY );
1776 if ( SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_HYPHENREGION, sal_False, &pItem ) )
1778 const SfxHyphenRegionItem* pHyphenItem = (const SfxHyphenRegionItem*)pItem;
1780 if (xProp.is())
1782 xProp->setPropertyValue(
1783 String::CreateFromAscii(UPN_HYPH_MIN_LEADING),
1784 makeAny((sal_Int16) pHyphenItem->GetMinLead()) );
1785 xProp->setPropertyValue(
1786 String::CreateFromAscii(UPN_HYPH_MIN_TRAILING),
1787 makeAny((sal_Int16) pHyphenItem->GetMinTrail()) );
1789 bSaveSpellCheck = sal_True;
1792 SfxViewFrame *pViewFrame = SfxViewFrame::Current();
1793 if ( pViewFrame )
1795 SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
1796 pItem = 0;
1797 if(SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_LANGUAGE, sal_False, &pItem ))
1799 pDispatch->Execute(pItem->Which(), SFX_CALLMODE_ASYNCHRON, pItem, 0L);
1800 bSaveSpellCheck = sal_True;
1802 if(SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_CHAR_CTL_LANGUAGE, sal_False, &pItem ))
1804 pDispatch->Execute(pItem->Which(), SFX_CALLMODE_ASYNCHRON, pItem, 0L);
1805 bSaveSpellCheck = sal_True;
1807 if(SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_CHAR_CJK_LANGUAGE, sal_False, &pItem ))
1809 pDispatch->Execute(pItem->Which(), SFX_CALLMODE_ASYNCHRON, pItem, 0L);
1810 bSaveSpellCheck = sal_True;
1813 if( SFX_ITEM_SET == rSet.GetItemState(SID_AUTOSPELL_CHECK, sal_False, &pItem ))
1815 sal_Bool bOnlineSpelling = ((const SfxBoolItem*)pItem)->GetValue();
1816 pDispatch->Execute(SID_AUTOSPELL_CHECK,
1817 SFX_CALLMODE_ASYNCHRON|SFX_CALLMODE_RECORD, pItem, 0L);
1819 if (xProp.is())
1821 xProp->setPropertyValue(
1822 String::CreateFromAscii(UPN_IS_SPELL_AUTO),
1823 makeAny(bOnlineSpelling) );
1827 if( bSaveSpellCheck )
1829 //! the config item has changed since we modified the
1830 //! property set it uses
1831 pDispatch->Execute(SID_SPELLCHECKER_CHANGED, SFX_CALLMODE_ASYNCHRON);
1835 if( SFX_ITEM_SET == rSet.GetItemState(SID_OPT_LOCALE_CHANGED, sal_False, &pItem ))
1837 SfxViewFrame* _pViewFrame = SfxViewFrame::GetFirst();
1838 while ( _pViewFrame )
1840 _pViewFrame->GetDispatcher()->Execute(pItem->Which(), SFX_CALLMODE_ASYNCHRON, pItem, 0L);
1841 _pViewFrame = SfxViewFrame::GetNext( *pViewFrame );
1846 rtl::OUString getCurrentFactory_Impl( const Reference< XFrame >& _xFrame )
1848 rtl::OUString sIdentifier;
1849 Reference < XFrame > xCurrentFrame( _xFrame );
1850 Reference < XModuleManager > xModuleManager( ::comphelper::getProcessServiceFactory()->createInstance(
1851 DEFINE_CONST_UNICODE("com.sun.star.frame.ModuleManager") ), UNO_QUERY );
1852 if ( !xCurrentFrame.is() )
1854 Reference< XDesktop > xDesktop( ::comphelper::getProcessServiceFactory()->createInstance(
1855 DEFINE_CONST_UNICODE("com.sun.star.frame.Desktop") ), UNO_QUERY );
1856 if ( xDesktop.is() )
1857 xCurrentFrame = xDesktop->getCurrentFrame();
1860 if ( xCurrentFrame.is() && xModuleManager.is() )
1864 sIdentifier = xModuleManager->identify( xCurrentFrame );
1866 catch ( ::com::sun::star::frame::UnknownModuleException& )
1868 DBG_WARNING( "getActiveModule_Impl(): unknown module" );
1870 catch ( Exception& )
1872 DBG_ERRORFILE( "getActiveModule_Impl(): exception of XModuleManager::identify()" );
1876 return sIdentifier;
1879 void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame )
1881 OfaPageResource aDlgResource;
1882 sal_uInt16 nGroup = 0;
1884 SvtOptionsDialogOptions aOptionsDlgOpt;
1885 sal_uInt16 i, nPageId;
1887 // %PRODUCTNAME options
1888 BOOL isSSOEnabled = EnableSSO();
1889 if ( !lcl_isOptionHidden( SID_GENERAL_OPTIONS, aOptionsDlgOpt ) )
1891 ResStringArray& rGeneralArray = aDlgResource.GetGeneralArray();
1892 setGroupName( C2U("ProductName"), rGeneralArray.GetString(0) );
1893 nGroup = AddGroup( rGeneralArray.GetString(0), 0, 0, SID_GENERAL_OPTIONS );
1894 sal_uInt16 nEnd = static_cast< sal_uInt16 >( rGeneralArray.Count() );
1895 String sPageTitle;
1897 for ( i = 1; i < nEnd; ++i )
1899 String sNewTitle = rGeneralArray.GetString(i);
1900 nPageId = (sal_uInt16)rGeneralArray.GetValue(i);
1901 if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1902 continue;
1904 // Disable Online Update page if service not installed
1905 if( RID_SVXPAGE_ONLINEUPDATE == nPageId )
1907 const ::rtl::OUString sService = C2U("com.sun.star.setup.UpdateCheck");
1911 Reference < XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
1912 Reference < XInterface > xService( xFactory->createInstance( sService ) );
1914 if( ! xService.is() )
1915 continue;
1917 catch ( ::com::sun::star::loader::CannotActivateFactoryException& )
1919 continue;
1922 // Disable OOoImprovement page if not enabled
1923 if( RID_SVXPAGE_IMPROVEMENT == nPageId )
1925 continue;
1927 if ( nPageId != RID_SVXPAGE_SSO || isSSOEnabled )
1929 AddTabPage( nPageId, sNewTitle, nGroup );
1932 // private iteration hack for Improvement Program
1933 // hack for OOo 3.1
1934 // should not be in found in any later release
1935 for(bool bOnce = false; bOnce==false; bOnce=true)
1937 String sNewTitle = C2U("Improvement Program");
1939 SvxImprovementPage aTempTabPage(this);
1940 sNewTitle = aTempTabPage.GetTitleText();
1942 nPageId = RID_SVXPAGE_IMPROVEMENT;
1943 if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1944 continue;
1945 // Disable OOoImprovement page if not enabled
1947 const ::rtl::OUString sService = C2U("com.sun.star.oooimprovement.CoreController");
1950 Reference < XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
1951 Reference < ::com::sun::star::oooimprovement::XCoreController > xService( xFactory->createInstance( sService ), UNO_QUERY );
1953 if( ! xService.is() )
1954 continue;
1955 if( ! xService->showBuiltinOptionsPage(1))
1956 continue;
1958 catch ( ::com::sun::star::loader::CannotActivateFactoryException& )
1960 continue;
1963 if ( nPageId != RID_SVXPAGE_SSO || isSSOEnabled )
1965 AddTabPage( nPageId, sNewTitle, nGroup );
1970 // Load and Save options
1971 if ( !lcl_isOptionHidden( SID_FILTER_DLG, aOptionsDlgOpt ) )
1973 ResStringArray& rFilterArray = aDlgResource.GetFilterArray();
1974 setGroupName( C2U("LoadSave"), rFilterArray.GetString(0) );
1975 nGroup = AddGroup( rFilterArray.GetString(0), 0, 0, SID_FILTER_DLG );
1976 for ( i = 1; i < rFilterArray.Count(); ++i )
1978 nPageId = (sal_uInt16)rFilterArray.GetValue(i);
1979 if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1980 AddTabPage( nPageId, rFilterArray.GetString(i), nGroup );
1984 // Language options
1985 SvtLanguageOptions aLanguageOptions;
1986 if ( !lcl_isOptionHidden( SID_LANGUAGE_OPTIONS, aOptionsDlgOpt ) )
1988 ResStringArray& rLangArray = aDlgResource.GetLangArray();
1989 setGroupName( C2U("LanguageSettings"), rLangArray.GetString(0) );
1990 nGroup = AddGroup( rLangArray.GetString(0), 0, 0, SID_LANGUAGE_OPTIONS );
1991 for ( i = 1; i < rLangArray.Count(); ++i )
1993 nPageId = (sal_uInt16)rLangArray.GetValue(i);
1994 if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1995 continue;
1996 if ( ( RID_SVXPAGE_JSEARCH_OPTIONS != nPageId || aLanguageOptions.IsJapaneseFindEnabled() ) &&
1997 ( RID_SVXPAGE_ASIAN_LAYOUT != nPageId || aLanguageOptions.IsAsianTypographyEnabled() ) &&
1998 ( RID_SVXPAGE_OPTIONS_CTL != nPageId || aLanguageOptions.IsCTLFontEnabled() ) )
1999 AddTabPage( nPageId, rLangArray.GetString(i), nGroup );
2004 rtl::OUString aFactory = getCurrentFactory_Impl( _xFrame );
2005 rtl::OUString sTemp = GetModuleIdentifier( comphelper::getProcessServiceFactory(), _xFrame );
2006 DBG_ASSERT( sTemp == aFactory, "S H I T!!!" );
2008 // Writer and Writer/Web options
2009 sal_Bool bHasAnyFilter = sal_False;
2010 SvtModuleOptions aModuleOpt;
2011 if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) )
2013 // Textdokument
2014 bHasAnyFilter = sal_True;
2015 ResStringArray& rTextArray = aDlgResource.GetTextArray();
2016 if ( aFactory.equalsAscii( "com.sun.star.text.TextDocument" )
2017 || aFactory.equalsAscii( "com.sun.star.text.WebDocument" )
2018 || aFactory.equalsAscii( "com.sun.star.text.GlobalDocument" ) )
2020 SfxModule* pSwMod = (*(SfxModule**) GetAppData(SHL_WRITER));
2021 if ( !lcl_isOptionHidden( SID_SW_EDITOPTIONS, aOptionsDlgOpt ) )
2023 if ( aFactory.equalsAscii( "com.sun.star.text.WebDocument" ) )
2024 setGroupName( C2U("WriterWeb"), rTextArray.GetString(0) );
2025 else
2026 setGroupName( C2U("Writer"), rTextArray.GetString(0) );
2027 nGroup = AddGroup(rTextArray.GetString(0), pSwMod, pSwMod, SID_SW_EDITOPTIONS );
2028 for ( i = 1; i < rTextArray.Count(); ++i )
2030 nPageId = (sal_uInt16)rTextArray.GetValue(i);
2031 if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
2032 continue;
2033 if ( ( RID_SW_TP_STD_FONT_CJK != nPageId || aLanguageOptions.IsCJKFontEnabled() ) &&
2034 ( RID_SW_TP_STD_FONT_CTL != nPageId || aLanguageOptions.IsCTLFontEnabled() ) &&
2035 ( RID_SW_TP_MAILCONFIG != nPageId || MailMergeCfg_Impl().IsEmailSupported() ) )
2036 AddTabPage( nPageId, rTextArray.GetString(i), nGroup );
2038 #ifndef PRODUCT
2039 AddTabPage( RID_SW_TP_OPTTEST_PAGE, String::CreateFromAscii("Interner Test"), nGroup );
2040 #endif
2043 // HTML-Dokument
2044 if ( !lcl_isOptionHidden( SID_SW_ONLINEOPTIONS, aOptionsDlgOpt ) )
2046 ResStringArray& rHTMLArray = aDlgResource.GetHTMLArray();
2047 nGroup = AddGroup(rHTMLArray.GetString(0), pSwMod, pSwMod, SID_SW_ONLINEOPTIONS );
2048 for( i = 1; i < rHTMLArray.Count(); ++i )
2050 nPageId = (sal_uInt16)rHTMLArray.GetValue(i);
2051 if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
2052 AddTabPage( nPageId, rHTMLArray.GetString(i), nGroup );
2054 #ifndef PRODUCT
2055 AddTabPage( RID_SW_TP_OPTTEST_PAGE, String::CreateFromAscii("Interner Test"), nGroup );
2056 #endif
2061 // Calc options
2062 if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) )
2064 bHasAnyFilter = sal_True;
2065 if ( aFactory.equalsAscii( "com.sun.star.sheet.SpreadsheetDocument" ))
2067 if ( !lcl_isOptionHidden( SID_SC_EDITOPTIONS, aOptionsDlgOpt ) )
2069 ResStringArray& rCalcArray = aDlgResource.GetCalcArray();
2070 SfxModule* pScMod = ( *( SfxModule** ) GetAppData( SHL_CALC ) );
2071 setGroupName( C2U("Calc"), rCalcArray.GetString(0) );
2072 nGroup = AddGroup( rCalcArray.GetString( 0 ), pScMod, pScMod, SID_SC_EDITOPTIONS );
2073 const USHORT nCount = static_cast< const USHORT >( rCalcArray.Count() );
2074 for ( i = 1; i < nCount; ++i )
2076 nPageId = (sal_uInt16)rCalcArray.GetValue(i);
2077 if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
2078 continue;
2079 // if( bCTL || nId != RID_OFA_TP_INTERNATIONAL )
2080 // #103755# if an international tabpage is need one day, this should be used again... ;-)
2081 if ( nPageId != RID_OFA_TP_INTERNATIONAL )
2082 AddTabPage( nPageId, rCalcArray.GetString( i ), nGroup );
2088 // Impress options
2089 SfxModule* pSdMod = ( *( SfxModule** ) GetAppData( SHL_DRAW ) );
2090 if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) )
2092 bHasAnyFilter = sal_True;
2093 if ( aFactory.equalsAscii( "com.sun.star.presentation.PresentationDocument" ))
2095 if ( !lcl_isOptionHidden( SID_SD_EDITOPTIONS, aOptionsDlgOpt ) )
2097 ResStringArray& rImpressArray = aDlgResource.GetImpressArray();
2098 setGroupName( C2U("Impress"), rImpressArray.GetString(0) );
2099 nGroup = AddGroup( rImpressArray.GetString( 0 ), pSdMod, pSdMod, SID_SD_EDITOPTIONS );
2100 const sal_Bool bCTL = aLanguageOptions.IsCTLFontEnabled();
2101 const USHORT nCount = static_cast< const USHORT >( rImpressArray.Count() );
2102 for ( i = 1; i < nCount; ++i )
2104 nPageId = (sal_uInt16)rImpressArray.GetValue(i);
2105 if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
2106 continue;
2107 if ( bCTL || nPageId != RID_OFA_TP_INTERNATIONAL_IMPR )
2108 AddTabPage( nPageId, rImpressArray.GetString(i), nGroup );
2114 // Draw options
2115 if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) )
2117 if ( aFactory.equalsAscii( "com.sun.star.drawing.DrawingDocument" ))
2119 if ( !lcl_isOptionHidden( SID_SD_GRAPHIC_OPTIONS, aOptionsDlgOpt ) )
2121 ResStringArray& rDrawArray = aDlgResource.GetDrawArray();
2122 setGroupName( C2U("Draw"), rDrawArray.GetString(0) );
2123 nGroup = AddGroup( rDrawArray.GetString( 0 ), pSdMod, pSdMod, SID_SD_GRAPHIC_OPTIONS );
2124 const sal_Bool bCTL = aLanguageOptions.IsCTLFontEnabled();
2125 const USHORT nCount = static_cast< const USHORT >( rDrawArray.Count() );
2126 for ( i = 1; i < nCount; ++i )
2128 nPageId = (sal_uInt16)rDrawArray.GetValue(i);
2129 if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
2130 continue;
2131 if ( bCTL || nPageId != RID_OFA_TP_INTERNATIONAL_SD )
2132 AddTabPage( nPageId, rDrawArray.GetString(i), nGroup );
2138 // Math options
2139 if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SMATH ) )
2141 if ( aFactory.equalsAscii( "com.sun.star.formula.FormulaProperties" ))
2143 if ( !lcl_isOptionHidden( SID_SM_EDITOPTIONS, aOptionsDlgOpt ) )
2145 ResStringArray& rStarMathArray = aDlgResource.GetStarMathArray();
2146 SfxModule* pSmMod = (*(SfxModule**) GetAppData(SHL_SM));
2147 setGroupName( C2U("Math"), rStarMathArray.GetString(0) );
2148 nGroup = AddGroup(rStarMathArray.GetString(0), pSmMod, pSmMod, SID_SM_EDITOPTIONS );
2149 for ( i = 1; i < rStarMathArray.Count(); ++i )
2151 nPageId = (sal_uInt16)rStarMathArray.GetValue(i);
2152 if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
2153 AddTabPage( nPageId, rStarMathArray.GetString(i), nGroup );
2159 // Database - needed only if there is an application which integrates with databases
2160 if ( !lcl_isOptionHidden( SID_SB_STARBASEOPTIONS, aOptionsDlgOpt ) &&
2161 ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SDATABASE )
2162 || aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER )
2163 || aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC )
2166 ResStringArray& rDSArray = aDlgResource.GetDatasourcesArray();
2167 setGroupName( C2U("Base"), rDSArray.GetString(0) );
2168 nGroup = AddGroup( rDSArray.GetString(0), 0, NULL, SID_SB_STARBASEOPTIONS );
2169 for ( i = 1; i < rDSArray.Count(); ++i )
2171 nPageId = (sal_uInt16)rDSArray.GetValue(i);
2172 if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
2173 AddTabPage( nPageId, rDSArray.GetString(i), nGroup );
2177 // Chart options (always installed and active)
2178 if ( !lcl_isOptionHidden( SID_SCH_EDITOPTIONS, aOptionsDlgOpt ) )
2180 ResStringArray& rChartArray = aDlgResource.GetChartArray();
2181 setGroupName( C2U("Charts"), rChartArray.GetString(0) );
2182 nGroup = AddGroup( rChartArray.GetString(0), 0, 0, SID_SCH_EDITOPTIONS );
2183 for ( i = 1; i < rChartArray.Count(); ++i )
2185 nPageId = (sal_uInt16)rChartArray.GetValue(i);
2186 if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
2187 AddTabPage( nPageId, rChartArray.GetString(i), nGroup );
2191 // Internet options
2192 if ( !lcl_isOptionHidden( SID_INET_DLG, aOptionsDlgOpt ) )
2194 ResStringArray& rInetArray = aDlgResource.GetInetArray();
2195 setGroupName( C2U("Internet"), rInetArray.GetString(0) );
2196 nGroup = AddGroup(rInetArray.GetString(0), 0, 0, SID_INET_DLG );
2198 for ( i = 1; i < rInetArray.Count(); ++i )
2200 nPageId = (sal_uInt16)rInetArray.GetValue(i);
2201 if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
2202 continue;
2203 #if defined WNT
2204 // Disable E-mail tab-page on Windows
2205 if ( nPageId == RID_SVXPAGE_INET_MAIL )
2206 continue;
2207 #endif
2208 #if defined MACOSX
2209 // Disable Mozilla Plug-in tab-page on Mac
2210 if ( nPageId == RID_SVXPAGE_INET_MOZPLUGIN )
2211 continue;
2212 #endif
2213 AddTabPage( nPageId, rInetArray.GetString(i), nGroup );
2217 /*!!!
2218 ResizeTreeLB();
2219 ActivateLastSelection();
2223 namespace
2225 void MoveControl( Control& _rCtrl, long _nDeltaPixel )
2227 Point aPt( _rCtrl.GetPosPixel() );
2228 aPt.X() += _nDeltaPixel;
2229 _rCtrl.SetPosPixel( aPt );
2233 void OfaTreeOptionsDialog::ResizeTreeLB( void )
2235 const long nMax = aHiddenGB.GetSizePixel().Width() * 42 / 100;
2236 // don't ask where 42 comes from... but it looks / feels ok ;-)
2237 long nDelta = 50; // min.
2238 USHORT nDepth = 0;
2239 const long nIndent0 = PixelToLogic( Size( 28, 0 ) ).Width();
2240 const long nIndent1 = PixelToLogic( Size( 52, 0 ) ).Width();
2242 SvTreeList* pTreeList = aTreeLB.GetModel();
2243 DBG_ASSERT( pTreeList, "-OfaTreeOptionsDialog::ResizeTreeLB(): no model, no cookies!" );
2245 SvListEntry* pEntry = pTreeList->First();
2246 while( pEntry )
2248 long n = aTreeLB.GetTextWidth( aTreeLB.GetEntryText( static_cast< SvLBoxEntry* >( pEntry ) ) );
2249 n += ( nDepth == 0 )? nIndent0 : nIndent1;
2251 if( n > nDelta )
2252 nDelta = n;
2254 pEntry = pTreeList->Next( pEntry, &nDepth );
2257 nDelta = LogicToPixel( Size( nDelta + 3, 0 ) ).Width(); // + extra space [logic]
2258 nDelta += GetSettings().GetStyleSettings().GetScrollBarSize(); // + scroll bar, in case it's needed
2260 if( nDelta > nMax )
2261 nDelta = nMax;
2263 // starting resizing with this
2264 Size aSize( GetSizePixel() );
2265 aSize.Width() += nDelta;
2266 SetSizePixel( aSize );
2268 // resize treelistbox
2269 aSize = aTreeLB.GetSizePixel();
2270 aSize.Width() += nDelta;
2271 aTreeLB.SetSizePixel( aSize );
2273 // ... and move depending controls
2274 MoveControl( aOkPB, nDelta );
2275 MoveControl( aCancelPB, nDelta );
2276 MoveControl( aHelpPB, nDelta );
2277 MoveControl( aBackPB, nDelta );
2278 MoveControl( aHiddenGB, nDelta );
2279 MoveControl( aPageTitleFT, nDelta );
2280 MoveControl( aLine1FL, nDelta );
2281 MoveControl( aHelpFT, nDelta );
2282 MoveControl( aHelpImg, nDelta );
2285 bool isNodeActive( OptionsNode* pNode, Module* pModule )
2287 if ( pNode )
2289 // Node for all modules actine?
2290 if ( pNode->m_bAllModules )
2291 return true;
2293 // OOo-Nodes (Writer, Calc, Impress...) are active if node is already inserted
2294 if ( getGroupName( pNode->m_sId, false ).Len() > 0 )
2295 return true;
2297 // no module -> not active
2298 if ( !pModule )
2299 return false;
2301 // search node in active module
2302 if ( pModule->m_bActive )
2304 for ( sal_uInt32 j = 0; j < pModule->m_aNodeList.size(); ++j )
2305 if ( pModule->m_aNodeList[j]->m_sId == pNode->m_sId )
2306 return true;
2309 return false;
2312 void OfaTreeOptionsDialog::LoadExtensionOptions( const rtl::OUString& rExtensionId )
2314 Module* pModule = NULL;
2315 Reference< XMultiServiceFactory > xMSFac = comphelper::getProcessServiceFactory();
2316 // open optionsdialog.xcu
2317 Reference< XNameAccess > xRoot(
2318 ::comphelper::ConfigurationHelper::openConfig(
2319 xMSFac, C2U("org.openoffice.Office.OptionsDialog"),
2320 ::comphelper::ConfigurationHelper::E_READONLY ), UNO_QUERY );
2321 DBG_ASSERT( xRoot.is(), "OfaTreeOptionsDialog::LoadExtensionOptions(): no config" );
2322 // when called by Tools - Options then load nodes of active module
2323 if ( rExtensionId.getLength() == 0 )
2324 pModule = LoadModule( GetModuleIdentifier( xMSFac, Reference< XFrame >() ), xRoot );
2326 VectorOfNodes aNodeList;
2327 LoadNodes( xRoot, pModule, rExtensionId, aNodeList );
2328 InsertNodes( aNodeList );
2331 rtl::OUString OfaTreeOptionsDialog::GetModuleIdentifier(
2332 const Reference< XMultiServiceFactory >& xMFac, const Reference< XFrame >& rFrame )
2334 rtl::OUString sModule;
2335 Reference < XFrame > xCurrentFrame( rFrame );
2336 Reference < XModuleManager > xModuleManager( xMFac->createInstance(
2337 C2U("com.sun.star.frame.ModuleManager") ), UNO_QUERY );
2339 if ( !xCurrentFrame.is() )
2341 Reference < XDesktop > xDesktop( xMFac->createInstance(
2342 C2U("com.sun.star.frame.Desktop") ), UNO_QUERY );
2343 if ( xDesktop.is() )
2344 xCurrentFrame = xDesktop->getCurrentFrame();
2347 if ( xCurrentFrame.is() && xModuleManager.is() )
2351 sModule = xModuleManager->identify( xCurrentFrame );
2353 catch ( ::com::sun::star::frame::UnknownModuleException& )
2355 DBG_WARNING( "OfaTreeOptionsDialog::GetModuleIdentifier(): unknown module" );
2357 catch ( Exception& )
2359 DBG_ERRORFILE( "OfaTreeOptionsDialog::GetModuleIdentifier(): exception of XModuleManager::identify()" );
2362 return sModule;
2365 Module* OfaTreeOptionsDialog::LoadModule(
2366 const rtl::OUString& rModuleIdentifier, const Reference< XNameAccess >& xRoot )
2368 Module* pModule = NULL;
2369 Reference< XNameAccess > xSet;
2371 if ( xRoot->hasByName( C2U("Modules") ) )
2373 xRoot->getByName( C2U("Modules") ) >>= xSet;
2374 if ( xSet.is() )
2376 Sequence< rtl::OUString > seqNames = xSet->getElementNames();
2377 for ( int i = 0; i < seqNames.getLength(); ++i )
2379 rtl::OUString sModule( seqNames[i] );
2380 if ( rModuleIdentifier == sModule )
2382 // current active module found
2383 pModule = new Module( sModule );
2384 pModule->m_bActive = true;
2386 Reference< XNameAccess > xModAccess;
2387 xSet->getByName( seqNames[i] ) >>= xModAccess;
2388 if ( xModAccess.is() )
2390 // load the nodes of this module
2391 Reference< XNameAccess > xNodeAccess;
2392 xModAccess->getByName( C2U("Nodes") ) >>= xNodeAccess;
2393 if ( xNodeAccess.is() )
2395 Sequence< rtl::OUString > xTemp = xNodeAccess->getElementNames();
2396 Reference< XNameAccess > xAccess;
2397 sal_Int32 nIndex = -1;
2398 for ( int x = 0; x < xTemp.getLength(); ++x )
2400 xNodeAccess->getByName( xTemp[x] ) >>= xAccess;
2401 if ( xAccess.is() )
2403 xAccess->getByName( C2U("Index") ) >>= nIndex;
2404 if ( nIndex < 0 )
2405 // append nodes with index < 0
2406 pModule->m_aNodeList.push_back(
2407 new OrderedEntry( nIndex, xTemp[x] ) );
2408 else
2410 // search position of the node
2411 sal_uInt32 y = 0;
2412 for ( ; y < pModule->m_aNodeList.size(); ++y )
2414 sal_Int32 nNodeIdx = pModule->m_aNodeList[y]->m_nIndex;
2415 if ( nNodeIdx < 0 || nNodeIdx > nIndex )
2416 break;
2418 // and insert the node on this position
2419 pModule->m_aNodeList.insert(
2420 pModule->m_aNodeList.begin() + y,
2421 new OrderedEntry( nIndex, xTemp[x] ) );
2431 return pModule;
2434 void OfaTreeOptionsDialog::LoadNodes(
2435 const Reference< XNameAccess >& xRoot, Module* pModule,
2436 const rtl::OUString& rExtensionId, VectorOfNodes& rOutNodeList )
2438 Reference< XNameAccess > xSet;
2439 if ( xRoot->hasByName( C2U("Nodes") ) )
2441 xRoot->getByName( C2U("Nodes") ) >>= xSet;
2442 if ( xSet.is() )
2444 VectorOfNodes aNodeList;
2445 Sequence< rtl::OUString > seqNames = xSet->getElementNames();
2447 for ( int i = 0; i < seqNames.getLength(); ++i )
2449 String sGroupName( seqNames[i] );
2450 Reference< XNameAccess > xNodeAccess;
2451 xSet->getByName( seqNames[i] ) >>= xNodeAccess;
2453 if ( xNodeAccess.is() )
2455 rtl::OUString sNodeId, sLabel, sPageURL, sGroupId;
2456 bool bAllModules = false;
2457 sal_Int32 nGroupIndex = 0;
2459 sNodeId = seqNames[i];
2460 xNodeAccess->getByName( C2U("Label") ) >>= sLabel;
2461 xNodeAccess->getByName( C2U("OptionsPage") ) >>= sPageURL;
2462 xNodeAccess->getByName( C2U("AllModules") ) >>= bAllModules;
2463 xNodeAccess->getByName( C2U("GroupId") ) >>= sGroupId;
2464 xNodeAccess->getByName( C2U("GroupIndex") ) >>= nGroupIndex;
2466 if ( sLabel.getLength() == 0 )
2467 sLabel = sGroupName;
2468 String sTemp = getGroupName( sLabel, rExtensionId.getLength() > 0 );
2469 if ( sTemp.Len() > 0 )
2470 sLabel = sTemp;
2471 OptionsNode* pNode =
2472 new OptionsNode( sNodeId, sLabel, sPageURL, bAllModules, sGroupId, nGroupIndex );
2474 if ( !rExtensionId.getLength() && !isNodeActive( pNode, pModule ) )
2476 delete pNode;
2477 continue;
2480 Reference< XNameAccess > xLeavesSet;
2481 xNodeAccess->getByName( C2U( "Leaves" ) ) >>= xLeavesSet;
2482 if ( xLeavesSet.is() )
2484 Sequence< rtl::OUString > seqLeaves = xLeavesSet->getElementNames();
2485 for ( int j = 0; j < seqLeaves.getLength(); ++j )
2487 Reference< XNameAccess > xLeaveAccess;
2488 xLeavesSet->getByName( seqLeaves[j] ) >>= xLeaveAccess;
2490 if ( xLeaveAccess.is() )
2492 rtl::OUString sId, sLeafLabel, sEventHdl, sLeafURL, sLeafGrpId;
2493 sal_Int32 nLeafGrpIdx = 0;
2495 xLeaveAccess->getByName( C2U("Id") ) >>= sId;
2496 xLeaveAccess->getByName( C2U("Label") ) >>= sLeafLabel;
2497 xLeaveAccess->getByName( C2U("OptionsPage") ) >>= sLeafURL;
2498 xLeaveAccess->getByName( C2U("EventHandlerService") ) >>= sEventHdl;
2499 xLeaveAccess->getByName( C2U("GroupId") ) >>= sLeafGrpId;
2500 xLeaveAccess->getByName( C2U("GroupIndex") ) >>= nLeafGrpIdx;
2502 if ( !rExtensionId.getLength() || sId == rExtensionId )
2504 OptionsLeaf* pLeaf = new OptionsLeaf(
2505 sId, sLeafLabel, sLeafURL, sEventHdl, sLeafGrpId, nLeafGrpIdx );
2507 if ( sLeafGrpId.getLength() > 0 )
2509 bool bAlreadyOpened = false;
2510 if ( pNode->m_aGroupedLeaves.size() > 0 )
2512 for ( sal_uInt32 k = 0;
2513 k < pNode->m_aGroupedLeaves.size(); ++k )
2515 if ( pNode->m_aGroupedLeaves[k].size() > 0 &&
2516 pNode->m_aGroupedLeaves[k][0]->m_sGroupId
2517 == sLeafGrpId )
2519 sal_uInt32 l = 0;
2520 for ( ; l < pNode->m_aGroupedLeaves[k].size(); ++l )
2522 if ( pNode->m_aGroupedLeaves[k][l]->
2523 m_nGroupIndex >= nLeafGrpIdx )
2524 break;
2526 pNode->m_aGroupedLeaves[k].insert(
2527 pNode->m_aGroupedLeaves[k].begin() + l, pLeaf );
2528 bAlreadyOpened = true;
2529 break;
2533 if ( !bAlreadyOpened )
2535 VectorOfLeaves aGroupedLeaves;
2536 aGroupedLeaves.push_back( pLeaf );
2537 pNode->m_aGroupedLeaves.push_back( aGroupedLeaves );
2540 else
2541 pNode->m_aLeaves.push_back(
2542 new OptionsLeaf(
2543 sId, sLeafLabel, sLeafURL,
2544 sEventHdl, sLeafGrpId, nLeafGrpIdx ) );
2550 // do not insert nodes without leaves
2551 if ( pNode->m_aLeaves.size() > 0 || pNode->m_aGroupedLeaves.size() > 0 )
2553 pModule ? aNodeList.push_back( pNode ) : rOutNodeList.push_back( pNode );
2558 if ( pModule && aNodeList.size() > 0 )
2560 sal_uInt32 i = 0, j = 0;
2561 for ( ; i < pModule->m_aNodeList.size(); ++i )
2563 rtl::OUString sNodeId = pModule->m_aNodeList[i]->m_sId;
2564 for ( j = 0; j < aNodeList.size(); ++j )
2566 OptionsNode* pNode = aNodeList[j];
2567 if ( pNode->m_sId == sNodeId )
2569 rOutNodeList.push_back( pNode );
2570 aNodeList.erase( aNodeList.begin() + j );
2571 break;
2576 for ( i = 0; i < aNodeList.size(); ++i )
2577 rOutNodeList.push_back( aNodeList[i] );
2583 USHORT lcl_getGroupId( const rtl::OUString& rGroupName, const SvTreeListBox& rTreeLB )
2585 String sGroupName( rGroupName );
2586 USHORT nRet = 0;
2587 SvLBoxEntry* pEntry = rTreeLB.First();
2588 while( pEntry )
2590 if ( !rTreeLB.GetParent( pEntry ) )
2592 String sTemp( rTreeLB.GetEntryText( pEntry ) );
2593 if ( sTemp == sGroupName )
2594 return nRet;
2595 nRet++;
2597 pEntry = rTreeLB.Next( pEntry );
2600 return USHRT_MAX;
2603 void lcl_insertLeaf(
2604 OfaTreeOptionsDialog* pDlg, OptionsNode* pNode, OptionsLeaf* pLeaf, const SvTreeListBox& rTreeLB )
2606 USHORT nGrpId = lcl_getGroupId( pNode->m_sLabel, rTreeLB );
2607 if ( USHRT_MAX == nGrpId )
2609 USHORT nNodeGrpId = getGroupNodeId( pNode->m_sId );
2610 nGrpId = pDlg->AddGroup( pNode->m_sLabel, NULL, NULL, nNodeGrpId );
2611 if ( pNode->m_sPageURL.getLength() > 0 )
2613 SvLBoxEntry* pGrpEntry = rTreeLB.GetEntry( 0, nGrpId );
2614 DBG_ASSERT( pGrpEntry, "OfaTreeOptionsDialog::InsertNodes(): no group" );
2615 if ( pGrpEntry )
2617 OptionsGroupInfo* pGrpInfo =
2618 static_cast<OptionsGroupInfo*>(pGrpEntry->GetUserData());
2619 pGrpInfo->m_sPageURL = pNode->m_sPageURL;
2623 OptionsPageInfo* pInfo = pDlg->AddTabPage( 0, pLeaf->m_sLabel, nGrpId );
2624 pInfo->m_sPageURL = pLeaf->m_sPageURL;
2625 pInfo->m_sEventHdl = pLeaf->m_sEventHdl;
2628 void OfaTreeOptionsDialog::InsertNodes( const VectorOfNodes& rNodeList )
2630 for ( sal_uInt32 i = 0; i < rNodeList.size(); ++i )
2632 OptionsNode* pNode = rNodeList[i];
2634 if ( pNode->m_aLeaves.size() > 0 || pNode->m_aGroupedLeaves.size() > 0 )
2636 sal_uInt32 j = 0;
2637 for ( ; j < pNode->m_aGroupedLeaves.size(); ++j )
2639 for ( sal_uInt32 k = 0; k < pNode->m_aGroupedLeaves[j].size(); ++k )
2641 OptionsLeaf* pLeaf = pNode->m_aGroupedLeaves[j][k];
2642 lcl_insertLeaf( this, pNode, pLeaf, aTreeLB );
2646 for ( j = 0; j < pNode->m_aLeaves.size(); ++j )
2648 OptionsLeaf* pLeaf = pNode->m_aLeaves[j];
2649 lcl_insertLeaf( this, pNode, pLeaf, aTreeLB );
2655 short OfaTreeOptionsDialog::Execute()
2657 ::std::auto_ptr< SvxDicListChgClamp > pClamp;
2658 if ( !bIsFromExtensionManager )
2660 // collect all DictionaryList Events while the dialog is executed
2661 Reference<com::sun::star::linguistic2::XDictionaryList> xDictionaryList(SvxGetDictionaryList());
2662 pClamp = ::std::auto_ptr< SvxDicListChgClamp >( new SvxDicListChgClamp( xDictionaryList ) );
2664 short nRet = SfxModalDialog::Execute();
2666 if( RET_OK == nRet )
2668 ApplyItemSets();
2669 if( GetColorTable() )
2671 GetColorTable()->Save();
2673 // notify current viewframe it it uses the same color table
2674 if ( SfxViewFrame::Current() && SfxViewFrame::Current()->GetDispatcher() )
2676 const OfaPtrItem* pPtr = (const OfaPtrItem*)SfxViewFrame::Current()->GetDispatcher()->Execute( SID_GET_COLORTABLE, SFX_CALLMODE_SYNCHRON );
2677 if( pPtr )
2679 XColorTable* _pColorTab = (XColorTable*)pPtr->GetValue();
2681 if( _pColorTab &&
2682 _pColorTab->GetPath() == GetColorTable()->GetPath() &&
2683 _pColorTab->GetName() == GetColorTable()->GetName() )
2684 SfxObjectShell::Current()->PutItem( SvxColorTableItem( GetColorTable(), SID_COLOR_TABLE ) );
2689 utl::ConfigManager::GetConfigManager()->StoreConfigItems();
2692 return nRet;
2695 // class ExtensionsTabPage -----------------------------------------------
2697 ExtensionsTabPage::ExtensionsTabPage(
2698 Window* pParent, const ResId& rResId, const rtl::OUString& rPageURL,
2699 const rtl::OUString& rEvtHdl, const Reference< awt::XContainerWindowProvider >& rProvider ) :
2701 TabPage( pParent, rResId ),
2703 m_sPageURL ( rPageURL ),
2704 m_sEventHdl ( rEvtHdl ),
2705 m_xWinProvider ( rProvider ),
2706 m_bIsWindowHidden ( false )
2711 // -----------------------------------------------------------------------
2713 ExtensionsTabPage::ExtensionsTabPage(
2714 Window* pParent, WinBits nStyle, const rtl::OUString& rPageURL,
2715 const rtl::OUString& rEvtHdl, const Reference< awt::XContainerWindowProvider >& rProvider ) :
2717 TabPage( pParent, nStyle ),
2719 m_sPageURL ( rPageURL ),
2720 m_sEventHdl ( rEvtHdl ),
2721 m_xWinProvider ( rProvider ),
2722 m_bIsWindowHidden ( false )
2727 // -----------------------------------------------------------------------
2729 ExtensionsTabPage::~ExtensionsTabPage()
2731 Hide();
2732 DeactivatePage();
2735 // -----------------------------------------------------------------------
2737 void ExtensionsTabPage::CreateDialogWithHandler()
2741 bool bWithHandler = ( m_sEventHdl.getLength() > 0 );
2742 if ( bWithHandler )
2744 Reference < XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
2745 m_xEventHdl = Reference< awt::XContainerWindowEventHandler >(
2746 xFactory->createInstance( m_sEventHdl ), UNO_QUERY );
2749 if ( !bWithHandler || m_xEventHdl.is() )
2751 SetStyle( GetStyle() | WB_DIALOGCONTROL | WB_CHILDDLGCTRL );
2752 Reference< awt::XWindowPeer > xParent( VCLUnoHelper::GetInterface( this ), UNO_QUERY );
2753 m_xPage = Reference < awt::XWindow >(
2754 m_xWinProvider->createContainerWindow(
2755 m_sPageURL, rtl::OUString(), xParent, m_xEventHdl ), UNO_QUERY );
2757 Reference< awt::XControl > xPageControl( m_xPage, UNO_QUERY );
2758 if ( xPageControl.is() )
2760 Reference< awt::XWindowPeer > xWinPeer( xPageControl->getPeer() );
2761 if ( xWinPeer.is() )
2763 Window* pWindow = VCLUnoHelper::GetWindow( xWinPeer );
2764 if ( pWindow )
2765 pWindow->SetStyle( pWindow->GetStyle() | WB_DIALOGCONTROL | WB_CHILDDLGCTRL );
2770 catch ( ::com::sun::star::lang::IllegalArgumentException& )
2772 DBG_ERRORFILE( "ExtensionsTabPage::CreateDialogWithHandler(): illegal argument" );
2774 catch ( Exception& )
2776 DBG_ERRORFILE( "ExtensionsTabPage::CreateDialogWithHandler(): exception of XDialogProvider2::createDialogWithHandler()" );
2780 // -----------------------------------------------------------------------
2782 sal_Bool ExtensionsTabPage::DispatchAction( const rtl::OUString& rAction )
2784 sal_Bool bRet = sal_False;
2785 if ( m_xEventHdl.is() )
2789 bRet = m_xEventHdl->callHandlerMethod( m_xPage, makeAny( rAction ), C2U("external_event") );
2791 catch ( Exception& )
2793 DBG_ERRORFILE( "ExtensionsTabPage::DispatchAction(): exception of XDialogEventHandler::callHandlerMethod()" );
2796 return bRet;
2799 // -----------------------------------------------------------------------
2801 void ExtensionsTabPage::ActivatePage()
2803 TabPage::ActivatePage();
2805 if ( !m_xPage.is() )
2807 CreateDialogWithHandler();
2809 if ( m_xPage.is() )
2811 Point aPos = Point();
2812 Size aSize = GetSizePixel();
2813 m_xPage->setPosSize( aPos.X() + 1, aPos.Y() + 1,
2814 aSize.Width() - 2, aSize.Height() - 2, awt::PosSize::POSSIZE );
2815 if ( m_sEventHdl.getLength() > 0 )
2816 DispatchAction( C2U("initialize") );
2820 if ( m_xPage.is() )
2822 m_xPage->setVisible( sal_True );
2823 m_bIsWindowHidden = false;
2827 // -----------------------------------------------------------------------
2829 void ExtensionsTabPage::DeactivatePage()
2831 TabPage::DeactivatePage();
2833 if ( m_xPage.is() )
2834 m_xPage->setVisible( sal_False );
2837 // -----------------------------------------------------------------------
2839 void ExtensionsTabPage::ResetPage()
2841 DispatchAction( C2U("back") );
2842 ActivatePage();
2845 // -----------------------------------------------------------------------
2847 void ExtensionsTabPage::SavePage()
2849 DispatchAction( C2U("ok") );
2852 // -----------------------------------------------------------------------
2854 void ExtensionsTabPage::HideWindow()
2856 if ( !m_bIsWindowHidden && m_xPage.is() )
2858 m_xPage->setVisible( sal_False );
2859 m_bIsWindowHidden = true;