1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_cui.hxx"
30 #include <com/sun/star/beans/XPropertySet.hpp>
31 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
32 #include <com/sun/star/loader/CannotActivateFactoryException.hpp>
33 #include <com/sun/star/linguistic2/XDictionaryList.hpp>
34 #include <com/sun/star/frame/XDesktop.hpp>
35 #include <com/sun/star/frame/XFrame.hpp>
36 #include <com/sun/star/frame/XModuleManager.hpp>
37 #include <com/sun/star/util/XMacroExpander.hpp>
38 #include <osl/module.hxx>
39 #include <com/sun/star/util/XCloseable.hpp>
40 #include <com/sun/star/frame/XLoadable.hpp>
41 #include <tools/rcid.h>
42 #include <tools/shl.hxx>
43 #include <tools/urlobj.hxx>
44 #include <comphelper/processfactory.hxx>
45 #include <toolkit/helper/vclunohelper.hxx>
46 #include <com/sun/star/beans/PropertyValue.hpp>
47 #include <com/sun/star/container/XNameContainer.hpp>
48 #include <com/sun/star/container/XNameAccess.hpp>
49 #include <com/sun/star/oooimprovement/XCoreController.hpp>
50 #include <comphelper/configurationhelper.hxx>
51 #include <com/sun/star/awt/XDialogProvider.hpp>
52 #include <com/sun/star/awt/XDialogProvider2.hpp>
53 #include <com/sun/star/awt/XContainerWindowProvider.hpp>
54 #include <com/sun/star/awt/XDialogEventHandler.hpp>
55 #include <com/sun/star/awt/XContainerWindowEventHandler.hpp>
56 #include <com/sun/star/awt/PosSize.hpp>
57 #include <com/sun/star/awt/XTopWindow.hpp>
58 #include <com/sun/star/awt/XControl.hpp>
59 #include <com/sun/star/awt/XTabController.hpp>
60 #include <vcl/help.hxx>
61 #include <linguistic/misc.hxx>
62 #include <svtools/helpopt.hxx>
63 #include <unotools/moduleoptions.hxx>
64 #include <svl/languageoptions.hxx>
65 #include <unotools/optionsdlg.hxx>
66 #include <sfx2/module.hxx>
67 #include <vcl/msgbox.hxx>
68 #include <sfx2/dispatch.hxx>
69 #include <vcl/waitobj.hxx>
70 #include <svl/slstitm.hxx>
71 #include <sfx2/viewfrm.hxx>
72 #include <unotools/viewoptions.hxx>
73 #include <sfx2/printopt.hxx>
74 #include <osl/module.h>
75 #include <osl/process.h>
76 #include <rtl/bootstrap.hxx>
77 #include <unotools/misccfg.hxx>
78 #include <sfx2/objsh.hxx>
79 #include <sfx2/viewsh.hxx>
80 #include <sfx2/tplpitem.hxx>
81 #include <svtools/apearcfg.hxx>
82 #include <unotools/linguprops.hxx>
83 #include <sfx2/app.hxx>
84 #include <svx/xdef.hxx>
85 #include <svx/xflclit.hxx>
86 #include <svx/xpool.hxx>
87 #include "cuitabarea.hxx"
88 #include <svx/ofaitem.hxx>
89 #include "opthtml.hxx"
90 #include "optcolor.hxx"
92 #include "optjava.hxx"
93 #include "optsave.hxx"
94 #include "optpath.hxx"
95 #include "cuioptgenrl.hxx"
96 #include "optlingu.hxx"
97 #include "optinet2.hxx"
98 #include "optasian.hxx"
99 #include "optaccessibility.hxx"
100 #include "optjsearch.hxx"
101 #include "connpooloptions.hxx"
102 #include "optupdt.hxx"
103 #include <optimprove.hxx>
104 #include "optchart.hxx"
105 #include "optgdlg.hxx"
106 #include "optmemory.hxx"
107 #include "optfltr.hxx"
108 #include <cuires.hrc>
109 #include "helpid.hrc"
110 #include <dialmgr.hxx>
111 #include "treeopt.hxx"
112 #include "treeopt.hrc"
113 #include "fontsubs.hxx"
114 #include <editeng/unolingu.hxx>
115 #include <svx/xtable.hxx>
116 #include "connpoolconfig.hxx"
117 #include "dbregister.hxx"
118 #include "dbregisterednamesconfig.hxx"
119 #include "cfgchart.hxx"
120 #include <svx/dialogs.hrc>
122 #ifndef _SVX_LANGITEM_HXX
123 #define ITEMID_LANGUAGE SID_ATTR_CHAR_LANGUAGE
124 #include <editeng/langitem.hxx>
128 #include <editeng/optitems.hxx>
130 #include <svx/drawitem.hxx>
131 #include <rtl/uri.hxx>
135 #include <sys/types.h>
136 #include <sys/stat.h>
140 using namespace ::com::sun::star
;
141 using namespace ::com::sun::star::beans
;
142 using namespace ::com::sun::star::container
;
143 using namespace ::com::sun::star::frame
;
144 using namespace ::com::sun::star::lang
;
145 using namespace ::com::sun::star::linguistic2
;
146 using namespace ::com::sun::star::uno
;
147 using namespace ::com::sun::star::util
;
150 #error "Who define C2U before! I use it to create const ascii strings ..."
152 #define C2U(cChar) rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( cChar ) )
155 #define HINT_TIMEOUT 200
156 #define SELECT_FIRST_TIMEOUT 0
157 #define SELECT_TIMEOUT 300
158 #define COLORPAGE_UNKNOWN ((sal_uInt16)0xFFFF)
159 #define EXPAND_PROTOCOL "vnd.sun.star.expand:"
161 LastPageSaver
* OfaTreeOptionsDialog::pLastPageSaver
= NULL
;
163 // some stuff for easier changes for SvtViewOptions
164 static const sal_Char
* pViewOptDataName
= "page data";
165 #define VIEWOPT_DATANAME rtl::OUString::createFromAscii( pViewOptDataName )
167 static XOutdevItemPool
* mpStaticXOutdevItemPool
= 0L;
169 static inline void SetViewOptUserItem( SvtViewOptions
& rOpt
, const String
& rData
)
171 rOpt
.SetUserItem( VIEWOPT_DATANAME
, makeAny( rtl::OUString( rData
) ) );
174 static inline String
GetViewOptUserItem( const SvtViewOptions
& rOpt
)
176 Any
aAny( rOpt
.GetUserItem( VIEWOPT_DATANAME
) );
177 rtl::OUString aUserData
;
180 return String( aUserData
);
183 struct ModuleToGroupNameMap_Impl
185 const char* m_pModule
;
187 sal_uInt16 m_nNodeId
;
190 static OfaPageResource
* pPageRes
= NULL
;
192 static ModuleToGroupNameMap_Impl ModuleMap
[] =
194 { "ProductName", String::EmptyString(), SID_GENERAL_OPTIONS
},
195 { "LanguageSettings", String::EmptyString(), SID_LANGUAGE_OPTIONS
},
196 { "Internet", String::EmptyString(), SID_INET_DLG
},
197 { "LoadSave", String::EmptyString(), SID_FILTER_DLG
},
198 { "Writer", String::EmptyString(), SID_SW_EDITOPTIONS
},
199 { "WriterWeb", String::EmptyString(), SID_SW_ONLINEOPTIONS
},
200 { "Math", String::EmptyString(), SID_SM_EDITOPTIONS
},
201 { "Calc", String::EmptyString(), SID_SC_EDITOPTIONS
},
202 { "Impress", String::EmptyString(), SID_SD_EDITOPTIONS
},
203 { "Draw", String::EmptyString(), SID_SD_GRAPHIC_OPTIONS
},
204 { "Charts", String::EmptyString(), SID_SCH_EDITOPTIONS
},
205 { "Base", String::EmptyString(), SID_SB_STARBASEOPTIONS
},
207 { NULL
, String::EmptyString(), 0xFFFF }
210 static void setGroupName( const rtl::OUString
& rModule
, const String
& rGroupName
)
212 sal_uInt16 nIndex
= 0;
213 while ( ModuleMap
[ nIndex
].m_pModule
)
215 rtl::OUString sTemp
=
216 rtl::OUString::createFromAscii( ModuleMap
[ nIndex
].m_pModule
);
217 if ( sTemp
== rModule
)
219 ModuleMap
[ nIndex
].m_sGroupName
= rGroupName
;
226 static String
getGroupName( const rtl::OUString
& rModule
, bool bForced
)
229 sal_uInt16 nIndex
= 0;
230 while ( ModuleMap
[ nIndex
].m_pModule
)
232 rtl::OUString sTemp
=
233 rtl::OUString::createFromAscii( ModuleMap
[ nIndex
].m_pModule
);
234 if ( sTemp
== rModule
)
236 sGroupName
= ModuleMap
[ nIndex
].m_sGroupName
;
242 if ( sGroupName
.Len() == 0 && bForced
)
245 pPageRes
= new OfaPageResource
;
247 if ( rModule
== C2U("Writer") )
248 sGroupName
= pPageRes
->GetTextArray().GetString(0);
249 else if ( rModule
== C2U("WriterWeb") )
250 sGroupName
= pPageRes
->GetHTMLArray().GetString(0);
251 else if ( rModule
== C2U("Calc") )
252 sGroupName
= pPageRes
->GetCalcArray().GetString(0);
253 else if ( rModule
== C2U("Impress") )
254 sGroupName
= pPageRes
->GetImpressArray().GetString(0);
255 else if ( rModule
== C2U("Draw") )
256 sGroupName
= pPageRes
->GetDrawArray().GetString(0);
257 else if ( rModule
== C2U("Math") )
258 sGroupName
= pPageRes
->GetStarMathArray().GetString(0);
259 else if ( rModule
== C2U("Base") )
260 sGroupName
= pPageRes
->GetDatasourcesArray().GetString(0);
265 static void deleteGroupNames()
267 sal_uInt16 nIndex
= 0;
268 while ( ModuleMap
[ nIndex
].m_pModule
)
269 ModuleMap
[ nIndex
++ ].m_sGroupName
= String::EmptyString();
272 static sal_uInt16
getGroupNodeId( const rtl::OUString
& rModule
)
274 sal_uInt16 nNodeId
= 0xFFFF, nIndex
= 0;
275 while ( ModuleMap
[ nIndex
].m_pModule
)
277 rtl::OUString sTemp
=
278 rtl::OUString::createFromAscii( ModuleMap
[ nIndex
].m_pModule
);
279 if ( sTemp
== rModule
)
281 nNodeId
= ModuleMap
[ nIndex
].m_nNodeId
;
290 /*-- 29.10.2004 13:57:25---------------------------------------------------
292 -----------------------------------------------------------------------*/
293 class MailMergeCfg_Impl
: public utl::ConfigItem
295 friend class SvxEMailTabPage
;
297 sal_Bool bIsEmailSupported
;
301 virtual ~MailMergeCfg_Impl();
303 virtual void Commit();
304 virtual void Notify( const com::sun::star::uno::Sequence
< rtl::OUString
>& _rPropertyNames
);
306 sal_Bool
IsEmailSupported() const {return bIsEmailSupported
;}
309 /*-- 29.10.2004 13:57:25---------------------------------------------------
311 -----------------------------------------------------------------------*/
312 MailMergeCfg_Impl::MailMergeCfg_Impl() :
313 utl::ConfigItem(C2U("Office.Writer/MailMergeWizard")),
314 bIsEmailSupported(sal_False
)
316 Sequence
<rtl::OUString
> aNames(1);
317 aNames
.getArray()[0] = C2U("EMailSupported");
318 const Sequence
< Any
> aValues
= GetProperties(aNames
);
319 const Any
* pValues
= aValues
.getConstArray();
320 if(aValues
.getLength() && pValues
[0].hasValue())
321 pValues
[0] >>= bIsEmailSupported
;
323 /*-- 29.10.2004 13:57:25---------------------------------------------------
325 -----------------------------------------------------------------------*/
326 MailMergeCfg_Impl::~MailMergeCfg_Impl()
329 /* -------------------------------------------------------------------------*/
330 void MailMergeCfg_Impl::Commit()
334 void MailMergeCfg_Impl::Notify( const com::sun::star::uno::Sequence
< rtl::OUString
>& )
338 //typedef SfxTabPage* (*FNCreateTabPage)( Window *pParent, const SfxItemSet &rAttrSet );
339 SfxTabPage
* CreateGeneralTabPage( sal_uInt16 nId
, Window
* pParent
, const SfxItemSet
& rSet
)
341 CreateTabPage fnCreate
= 0;
344 case RID_SFXPAGE_SAVE
: fnCreate
= &SvxSaveTabPage::Create
; break;
345 case RID_SFXPAGE_PATH
: fnCreate
= &SvxPathTabPage::Create
; break;
346 case RID_SFXPAGE_GENERAL
: fnCreate
= &SvxGeneralTabPage::Create
; break;
347 case RID_SFXPAGE_PRINTOPTIONS
: fnCreate
= &SfxCommonPrintOptionsTabPage::Create
; break;
348 case OFA_TP_LANGUAGES
: fnCreate
= &OfaLanguagesTabPage::Create
; break;
349 case RID_SFXPAGE_LINGU
: fnCreate
= &SvxLinguTabPage::Create
; break;
350 case RID_SVXPAGE_COLOR
: fnCreate
= &SvxColorTabPage::Create
; break;
351 case OFA_TP_VIEW
: fnCreate
= &OfaViewTabPage::Create
; break;
352 case OFA_TP_MISC
: fnCreate
= &OfaMiscTabPage::Create
; break;
353 case OFA_TP_MEMORY
: fnCreate
= &OfaMemoryOptionsPage::Create
; break;
354 case RID_SVXPAGE_ASIAN_LAYOUT
: fnCreate
= &SvxAsianLayoutPage::Create
; break;
355 case RID_SVX_FONT_SUBSTITUTION
: fnCreate
= &SvxFontSubstTabPage::Create
; break;
356 case RID_SVXPAGE_INET_PROXY
: fnCreate
= &SvxProxyTabPage::Create
; break;
357 case RID_SVXPAGE_INET_SEARCH
: fnCreate
= &SvxSearchTabPage::Create
; break;
358 case RID_SVXPAGE_INET_SECURITY
: fnCreate
= &SvxSecurityTabPage::Create
; break;
359 case RID_SVXPAGE_INET_MAIL
: fnCreate
= &SvxEMailTabPage::Create
; break;
360 case RID_SVXPAGE_COLORCONFIG
: fnCreate
= &SvxColorOptionsTabPage::Create
; break;
361 case RID_OFAPAGE_HTMLOPT
: fnCreate
= &OfaHtmlTabPage::Create
; break;
362 case SID_OPTFILTER_MSOFFICE
: fnCreate
= &OfaMSFilterTabPage::Create
; break;
363 case RID_OFAPAGE_MSFILTEROPT2
: fnCreate
= &OfaMSFilterTabPage2::Create
; break;
364 case RID_SVXPAGE_JSEARCH_OPTIONS
: fnCreate
= &SvxJSearchOptionsPage::Create
; break;
365 case SID_SB_CONNECTIONPOOLING
: fnCreate
= &::offapp::ConnectionPoolOptionsPage::Create
; break;
366 case SID_SB_DBREGISTEROPTIONS
: fnCreate
= &::svx::DbRegistrationOptionsPage::Create
; break;
367 case RID_SVXPAGE_ACCESSIBILITYCONFIG
: fnCreate
= &SvxAccessibilityOptionsTabPage::Create
; break;
368 case RID_SVXPAGE_SSO
: fnCreate
= GetSSOCreator(); break;
369 case RID_SVXPAGE_OPTIONS_CTL
: fnCreate
= &SvxCTLOptionsPage::Create
; break;
370 //added by jmeng begin
371 case RID_SVXPAGE_INET_MOZPLUGIN
: fnCreate
= &MozPluginTabPage::Create
; break;
373 case RID_SVXPAGE_OPTIONS_JAVA
: fnCreate
= &SvxJavaOptionsPage::Create
; break;
374 case RID_SVXPAGE_ONLINEUPDATE
: fnCreate
= &SvxOnlineUpdateTabPage::Create
; break;
375 case RID_OPTPAGE_CHART_DEFCOLORS
: fnCreate
= &SvxDefaultColorOptPage::Create
; break;
376 case RID_SVXPAGE_IMPROVEMENT
: fnCreate
= &SvxImprovementOptionsPage::Create
; break;
379 SfxTabPage
* pRet
= fnCreate
? (*fnCreate
)( pParent
, rSet
) : NULL
;
384 struct OptionsMapping_Impl
386 const char* m_pGroupName
;
387 const char* m_pPageName
;
388 sal_uInt16 m_nPageId
;
391 static OptionsMapping_Impl __READONLY_DATA OptionsMap_Impl
[] =
393 // GROUP PAGE PAGE-ID
394 { "ProductName", NULL
, SID_GENERAL_OPTIONS
},
395 { "ProductName", "UserData", RID_SFXPAGE_GENERAL
},
396 { "ProductName", "General", OFA_TP_MISC
},
397 { "ProductName", "Memory", OFA_TP_MEMORY
},
398 { "ProductName", "View", OFA_TP_VIEW
},
399 { "ProductName", "Print", RID_SFXPAGE_PRINTOPTIONS
},
400 { "ProductName", "Paths", RID_SFXPAGE_PATH
},
401 { "ProductName", "Colors", RID_SVXPAGE_COLOR
},
402 { "ProductName", "Fonts", RID_SVX_FONT_SUBSTITUTION
},
403 { "ProductName", "Security", RID_SVXPAGE_INET_SECURITY
},
404 { "ProductName", "Appearance", RID_SVXPAGE_COLORCONFIG
},
405 { "ProductName", "Accessibility", RID_SVXPAGE_ACCESSIBILITYCONFIG
},
406 { "ProductName", "Java", RID_SVXPAGE_OPTIONS_JAVA
},
407 { "ProductName", "NetworkIdentity", RID_SVXPAGE_SSO
},
408 { "ProductName", "OnlineUpdate", RID_SVXPAGE_ONLINEUPDATE
},
409 { "ProductName", "ImprovementProgram", RID_SVXPAGE_IMPROVEMENT
},
410 { "LanguageSettings", NULL
, SID_LANGUAGE_OPTIONS
},
411 { "LanguageSettings", "Languages", OFA_TP_LANGUAGES
},
412 { "LanguageSettings", "WritingAids", RID_SFXPAGE_LINGU
},
413 { "LanguageSettings", "SearchingInJapanese", RID_SVXPAGE_JSEARCH_OPTIONS
},
414 { "LanguageSettings", "AsianLayout", RID_SVXPAGE_ASIAN_LAYOUT
},
415 { "LanguageSettings", "ComplexTextLayout", RID_SVXPAGE_OPTIONS_CTL
},
416 { "Internet", NULL
, SID_INET_DLG
},
417 { "Internet", "Proxy", RID_SVXPAGE_INET_PROXY
},
418 { "Internet", "Search", RID_SVXPAGE_INET_SEARCH
},
419 { "Internet", "Email", RID_SVXPAGE_INET_MAIL
},
420 { "Internet", "MozillaPlugin", RID_SVXPAGE_INET_MOZPLUGIN
},
421 { "LoadSave", NULL
, SID_FILTER_DLG
},
422 { "LoadSave", "General", RID_SFXPAGE_SAVE
},
423 { "LoadSave", "VBAProperties", SID_OPTFILTER_MSOFFICE
},
424 { "LoadSave", "MicrosoftOffice", RID_OFAPAGE_MSFILTEROPT2
},
425 { "LoadSave", "HTMLCompatibility", RID_OFAPAGE_HTMLOPT
},
426 { "Writer", NULL
, SID_SW_EDITOPTIONS
},
427 { "Writer", "General", RID_SW_TP_OPTLOAD_PAGE
},
428 { "Writer", "View", RID_SW_TP_CONTENT_OPT
},
429 { "Writer", "FormattingAids", RID_SW_TP_OPTSHDWCRSR
},
430 { "Writer", "Grid", RID_SVXPAGE_GRID
},
431 { "Writer", "BasicFontsWestern", RID_SW_TP_STD_FONT
},
432 { "Writer", "BasicFontsAsian", RID_SW_TP_STD_FONT_CJK
},
433 { "Writer", "BasicFontsCTL", RID_SW_TP_STD_FONT_CTL
},
434 { "Writer", "Print", RID_SW_TP_OPTPRINT_PAGE
},
435 { "Writer", "Table", RID_SW_TP_OPTTABLE_PAGE
},
436 { "Writer", "Changes", RID_SW_TP_REDLINE_OPT
},
437 { "Writer", "Compatibility", RID_SW_TP_OPTCOMPATIBILITY_PAGE
},
438 { "Writer", "AutoCaption", RID_SW_TP_OPTCAPTION_PAGE
},
439 { "Writer", "MailMerge", RID_SW_TP_MAILCONFIG
},
440 { "WriterWeb", NULL
, SID_SW_ONLINEOPTIONS
},
441 { "WriterWeb", "View", RID_SW_TP_HTML_CONTENT_OPT
},
442 { "WriterWeb", "FormattingAids", RID_SW_TP_HTML_OPTSHDWCRSR
},
443 { "WriterWeb", "Grid", RID_SW_TP_HTML_OPTGRID_PAGE
},
444 { "WriterWeb", "Print", RID_SW_TP_HTML_OPTPRINT_PAGE
},
445 { "WriterWeb", "Table", RID_SW_TP_HTML_OPTTABLE_PAGE
},
446 { "WriterWeb", "Background", RID_SW_TP_BACKGROUND
},
447 { "Math", NULL
, SID_SM_EDITOPTIONS
},
448 { "Math", "Settings", SID_SM_TP_PRINTOPTIONS
},
449 { "Calc", NULL
, SID_SC_EDITOPTIONS
},
450 { "Calc", "General", SID_SC_TP_LAYOUT
},
451 { "Calc", "View", SID_SC_TP_CONTENT
},
452 { "Calc", "International", RID_OFA_TP_INTERNATIONAL
},
453 { "Calc", "Calculate", SID_SC_TP_CALC
},
454 { "Calc", "SortLists", SID_SC_TP_USERLISTS
},
455 { "Calc", "Changes", SID_SC_TP_CHANGES
},
456 { "Calc", "Grid", SID_SC_TP_GRID
},
457 { "Calc", "Print", RID_SC_TP_PRINT
},
458 { "Impress", NULL
, SID_SD_EDITOPTIONS
},
459 { "Impress", "General", SID_SI_TP_MISC
},
460 { "Impress", "View", SID_SI_TP_CONTENTS
},
461 { "Impress", "Grid", SID_SI_TP_SNAP
},
462 { "Impress", "Print", SID_SI_TP_PRINT
},
463 { "Draw", NULL
, SID_SD_GRAPHIC_OPTIONS
},
464 { "Draw", "General", SID_SD_TP_MISC
},
465 { "Draw", "View", SID_SD_TP_CONTENTS
},
466 { "Draw", "Grid", SID_SD_TP_SNAP
},
467 { "Draw", "Print", SID_SD_TP_PRINT
},
468 { "Charts", NULL
, SID_SCH_EDITOPTIONS
},
469 { "Charts", "DefaultColors", RID_OPTPAGE_CHART_DEFCOLORS
},
470 { "Base", NULL
, SID_SB_STARBASEOPTIONS
},
471 { "Base", "Connections", SID_SB_CONNECTIONPOOLING
},
472 { "Base", "Databases", SID_SB_DBREGISTEROPTIONS
},
476 static sal_Bool
lcl_getStringFromID( sal_uInt16 _nPageId
, String
& _rGroupName
, String
& _rPageName
)
478 sal_Bool bRet
= sal_False
;
481 while ( OptionsMap_Impl
[nIdx
].m_pGroupName
!= NULL
)
483 if ( _nPageId
== OptionsMap_Impl
[nIdx
].m_nPageId
)
486 _rGroupName
= String( OptionsMap_Impl
[nIdx
].m_pGroupName
, RTL_TEXTENCODING_ASCII_US
);
487 if ( OptionsMap_Impl
[nIdx
].m_pPageName
!= NULL
)
488 _rPageName
= String( OptionsMap_Impl
[nIdx
].m_pPageName
, RTL_TEXTENCODING_ASCII_US
);
497 static sal_Bool
lcl_isOptionHidden( sal_uInt16 _nPageId
, const SvtOptionsDialogOptions
& _rOptOptions
)
499 sal_Bool bIsHidden
= sal_False
;
500 String sGroupName
, sPageName
;
501 if ( lcl_getStringFromID( _nPageId
, sGroupName
, sPageName
) )
503 if ( sPageName
.Len() == 0 )
504 bIsHidden
= _rOptOptions
.IsGroupHidden( sGroupName
);
506 bIsHidden
= _rOptOptions
.IsPageHidden( sPageName
, sGroupName
);
511 /* -----------------11.02.99 09:56-------------------
513 * --------------------------------------------------*/
514 struct OptionsPageInfo
517 sal_uInt16 m_nPageId
;
518 rtl::OUString m_sPageURL
;
519 rtl::OUString m_sEventHdl
;
520 ExtensionsTabPage
* m_pExtPage
;
522 OptionsPageInfo( sal_uInt16 nId
) : m_pPage( NULL
), m_nPageId( nId
), m_pExtPage( NULL
) {}
525 struct OptionsGroupInfo
527 SfxItemSet
* m_pInItemSet
;
528 SfxItemSet
* m_pOutItemSet
;
529 SfxShell
* m_pShell
; // used to create the page
530 SfxModule
* m_pModule
; // used to create the ItemSet
531 sal_uInt16 m_nDialogId
; // Id of the former dialog
532 sal_Bool m_bLoadError
; // load fails?
533 rtl::OUString m_sPageURL
;
534 ExtensionsTabPage
* m_pExtPage
;
536 OptionsGroupInfo( SfxShell
* pSh
, SfxModule
* pMod
, sal_uInt16 nId
) :
537 m_pInItemSet( NULL
), m_pOutItemSet( NULL
), m_pShell( pSh
),
538 m_pModule( pMod
), m_nDialogId( nId
), m_bLoadError( sal_False
),
539 m_sPageURL( rtl::OUString() ), m_pExtPage( NULL
) {}
540 ~OptionsGroupInfo() { delete m_pInItemSet
; delete m_pOutItemSet
; }
543 /* -----------------04.05.99 15:51-------------------
545 * --------------------------------------------------*/
546 sal_Bool
OfaOptionsTreeListBox::Collapse( SvLBoxEntry
* pParent
)
548 bInCollapse
= sal_True
;
549 sal_Bool bRet
= SvTreeListBox::Collapse(pParent
);
550 bInCollapse
= sal_False
;
554 // -----------------------------------------------------------------------
557 aOkPB ( this, CUI_RES( PB_OK ) ),\
558 aCancelPB ( this, CUI_RES( PB_CANCEL ) ),\
559 aHelpPB ( this, CUI_RES( PB_HELP ) ),\
560 aBackPB ( this, CUI_RES( PB_BACK ) ),\
561 aHiddenGB ( this, CUI_RES( FB_BORDER ) ),\
562 aPageTitleFT ( this, CUI_RES( FT_PAGE_TITLE ) ),\
563 aLine1FL ( this, CUI_RES( FL_LINE_1 ) ),\
564 aHelpFT ( this, CUI_RES( FT_HELPTEXT ) ),\
565 aHelpImg ( this, CUI_RES( IMG_HELP ) ),\
566 aHelpTextsArr ( CUI_RES( STR_HELPTEXTS ) ),\
567 aTreeLB ( this, CUI_RES( TLB_PAGES ) ),\
568 sTitle ( GetText() ),\
569 sNotLoadedError ( CUI_RES( ST_LOAD_ERROR ) ),\
570 pCurrentPageEntry ( NULL ),\
571 pColorPageItemSet ( NULL ),\
573 nChangeType ( CT_NONE ),\
574 nUnknownType ( COLORPAGE_UNKNOWN ),\
575 nUnknownPos ( COLORPAGE_UNKNOWN ),\
576 bIsAreaTP ( sal_False ),\
577 bForgetSelection ( sal_False ),\
578 bImageResized ( sal_False ),\
579 bInSelectHdl_Impl ( false ),\
580 bIsFromExtensionManager( false ), \
581 bIsForSetDocumentLanguage( false )
583 // Ctor() with Frame -----------------------------------------------------
584 using namespace ::com::sun::star
;
585 OfaTreeOptionsDialog::OfaTreeOptionsDialog(
587 const Reference
< XFrame
>& _xFrame
,
588 bool bActivateLastSelection
) :
590 SfxModalDialog( pParent
, CUI_RES( RID_OFADLG_OPTIONS_TREE
) ),
595 InitTreeAndHandler();
596 Initialize( _xFrame
);
597 LoadExtensionOptions( rtl::OUString() );
599 if (bActivateLastSelection
)
600 ActivateLastSelection();
602 aTreeLB
.SetAccessibleName(GetDisplayText());
605 // Ctor() with ExtensionId -----------------------------------------------
607 OfaTreeOptionsDialog::OfaTreeOptionsDialog( Window
* pParent
, const rtl::OUString
& rExtensionId
) :
609 SfxModalDialog( pParent
, CUI_RES( RID_OFADLG_OPTIONS_TREE
) ),
616 bIsFromExtensionManager
= ( rExtensionId
.getLength() > 0 );
617 InitTreeAndHandler();
618 LoadExtensionOptions( rExtensionId
);
620 ActivateLastSelection();
623 /* -----------------11.02.99 07:58-------------------
625 * --------------------------------------------------*/
627 OfaTreeOptionsDialog::~OfaTreeOptionsDialog()
629 SvLBoxEntry
* pEntry
= aTreeLB
.First();
633 // if Child (has parent), then OptionsPageInfo
634 if(aTreeLB
.GetParent(pEntry
))
636 OptionsPageInfo
*pPageInfo
= (OptionsPageInfo
*)pEntry
->GetUserData();
637 if(pPageInfo
->m_pPage
)
639 pPageInfo
->m_pPage
->FillUserData();
640 String
aPageData(pPageInfo
->m_pPage
->GetUserData());
641 if ( aPageData
.Len() )
643 SvtViewOptions
aTabPageOpt( E_TABPAGE
, String::CreateFromInt32( pPageInfo
->m_nPageId
) );
644 SetViewOptUserItem( aTabPageOpt
, aPageData
);
646 delete pPageInfo
->m_pPage
;
649 if (pPageInfo
->m_nPageId
== RID_SFXPAGE_LINGU
)
651 // write personal dictionaries
652 Reference
< XDictionaryList
> xDicList( SvxGetDictionaryList() );
655 linguistic::SaveDictionaries( xDicList
);
659 if( pPageInfo
->m_pExtPage
)
660 delete pPageInfo
->m_pExtPage
;
664 pEntry
= aTreeLB
.Next(pEntry
);
668 pEntry
= aTreeLB
.First();
671 if(!aTreeLB
.GetParent(pEntry
))
673 OptionsGroupInfo
* pGroupInfo
= (OptionsGroupInfo
*)pEntry
->GetUserData();
674 if ( pGroupInfo
&& pGroupInfo
->m_pExtPage
)
675 delete pGroupInfo
->m_pExtPage
;
678 pEntry
= aTreeLB
.Next(pEntry
);
680 delete pColorPageItemSet
;
684 /* -----------------11.02.99 08:21-------------------
686 * --------------------------------------------------*/
687 OptionsPageInfo
* OfaTreeOptionsDialog::AddTabPage(
688 sal_uInt16 nId
, const String
& rPageName
, sal_uInt16 nGroup
)
690 OptionsPageInfo
* pPageInfo
= new OptionsPageInfo( nId
);
691 SvLBoxEntry
* pParent
= aTreeLB
.GetEntry( 0, nGroup
);
692 DBG_ASSERT( pParent
, "OfaTreeOptionsDialog::AddTabPage(): no group found" );
693 SvLBoxEntry
* pEntry
= aTreeLB
.InsertEntry( rPageName
, pParent
);
694 pEntry
->SetUserData( pPageInfo
);
698 /* -----------------11.02.99 10:02-------------------
699 * der ItemSet* geht in den Besitz des Dialogs
700 * --------------------------------------------------*/
701 sal_uInt16
OfaTreeOptionsDialog::AddGroup(const String
& rGroupName
,
702 SfxShell
* pCreateShell
,
703 SfxModule
* pCreateModule
,
704 sal_uInt16 nDialogId
)
706 SvLBoxEntry
* pEntry
= aTreeLB
.InsertEntry(rGroupName
);
707 OptionsGroupInfo
* pInfo
=
708 new OptionsGroupInfo( pCreateShell
, pCreateModule
, nDialogId
);
709 pEntry
->SetUserData(pInfo
);
711 pEntry
= aTreeLB
.First();
714 if(!aTreeLB
.GetParent(pEntry
))
716 pEntry
= aTreeLB
.Next(pEntry
);
721 /* -----------------11.02.99 10:31-------------------
723 * --------------------------------------------------*/
724 IMPL_LINK(OfaTreeOptionsDialog
, ShowPageHdl_Impl
, SvTreeListBox
*, EMPTYARG
)
726 if ( aSelectTimer
.GetTimeout() == SELECT_FIRST_TIMEOUT
)
728 aSelectTimer
.SetTimeout( SELECT_TIMEOUT
);
729 SelectHdl_Impl( NULL
);
731 else if ( aSelectTimer
.GetTimeout() == SELECT_TIMEOUT
)
732 aSelectTimer
.Start();
736 /* -----------------11.02.99 10:49-------------------
738 * --------------------------------------------------*/
739 IMPL_LINK( OfaTreeOptionsDialog
, BackHdl_Impl
, PushButton
*, EMPTYARG
)
741 if ( pCurrentPageEntry
&& aTreeLB
.GetParent( pCurrentPageEntry
) )
743 OptionsPageInfo
* pPageInfo
= (OptionsPageInfo
*)pCurrentPageEntry
->GetUserData();
744 if ( pPageInfo
->m_pPage
)
746 OptionsGroupInfo
* pGroupInfo
=
747 (OptionsGroupInfo
*)aTreeLB
.GetParent( pCurrentPageEntry
)->GetUserData();
748 if ( RID_SVXPAGE_COLOR
== pPageInfo
->m_nPageId
)
749 pPageInfo
->m_pPage
->Reset( *pColorPageItemSet
);
751 pPageInfo
->m_pPage
->Reset( *pGroupInfo
->m_pInItemSet
);
753 else if ( pPageInfo
->m_pExtPage
)
754 pPageInfo
->m_pExtPage
->ResetPage();
758 /* -----------------11.02.99 16:45-------------------
760 * --------------------------------------------------*/
761 IMPL_LINK( OfaTreeOptionsDialog
, OKHdl_Impl
, Button
*, EMPTYARG
)
763 aTreeLB
.EndSelection();
764 if ( pCurrentPageEntry
&& aTreeLB
.GetParent( pCurrentPageEntry
) )
766 OptionsPageInfo
* pPageInfo
= (OptionsPageInfo
*)pCurrentPageEntry
->GetUserData();
767 if ( pPageInfo
->m_pPage
)
769 OptionsGroupInfo
* pGroupInfo
=
770 (OptionsGroupInfo
*)aTreeLB
.GetParent(pCurrentPageEntry
)->GetUserData();
771 if ( RID_SVXPAGE_COLOR
!= pPageInfo
->m_nPageId
772 && pPageInfo
->m_pPage
->HasExchangeSupport() )
774 int nLeave
= pPageInfo
->m_pPage
->DeactivatePage(pGroupInfo
->m_pOutItemSet
);
775 if ( nLeave
== SfxTabPage::KEEP_PAGE
)
777 //die Seite darf nicht verlassen werden!
778 aTreeLB
.Select(pCurrentPageEntry
);
782 pPageInfo
->m_pPage
->Hide();
786 SvLBoxEntry
* pEntry
= aTreeLB
.First();
789 if ( aTreeLB
.GetParent( pEntry
) )
791 OptionsPageInfo
* pPageInfo
= (OptionsPageInfo
*)pEntry
->GetUserData();
792 if ( pPageInfo
->m_pPage
&& !pPageInfo
->m_pPage
->HasExchangeSupport() )
794 OptionsGroupInfo
* pGroupInfo
=
795 (OptionsGroupInfo
*)aTreeLB
.GetParent(pEntry
)->GetUserData();
796 pPageInfo
->m_pPage
->FillItemSet(*pGroupInfo
->m_pOutItemSet
);
799 if ( pPageInfo
->m_pExtPage
)
801 pPageInfo
->m_pExtPage
->DeactivatePage();
802 pPageInfo
->m_pExtPage
->SavePage();
805 pEntry
= aTreeLB
.Next(pEntry
);
811 /* -----------------17.02.99 09:15-------------------
812 * Eine aufgeklappte Gruppe soll vollstaendig sichtbar sein
813 * --------------------------------------------------*/
814 IMPL_LINK(OfaTreeOptionsDialog
, ExpandedHdl_Impl
, SvTreeListBox
*, pBox
)
817 pBox
->InitStartEntry();
818 SvLBoxEntry
* pEntry
= pBox
->GetHdlEntry();
819 if(pEntry
&& pBox
->IsExpanded(pEntry
))
821 sal_uInt32 nChildCount
= pBox
->GetChildCount( pEntry
);
823 SvLBoxEntry
* pNext
= pEntry
;
824 for(sal_uInt32 i
= 0; i
< nChildCount
;i
++)
826 pNext
= pBox
->GetNextEntryInView(pNext
);
829 pBox
->ScrollOutputArea( -(short)(nChildCount
- i
+ 1) );
834 Size
aSz(pBox
->GetOutputSizePixel());
835 int nHeight
= pBox
->GetEntryHeight();
836 Point
aPos(pBox
->GetEntryPosition(pNext
));
837 if(aPos
.Y()+nHeight
> aSz
.Height())
839 pBox
->ScrollOutputArea( -(short)(nChildCount
- i
+ 1) );
848 /* -----------------11.02.99 10:49-------------------
850 * --------------------------------------------------*/
851 void OfaTreeOptionsDialog::ApplyItemSets()
853 SvLBoxEntry
* pEntry
= aTreeLB
.First();
856 if(!aTreeLB
.GetParent(pEntry
))
858 OptionsGroupInfo
* pGroupInfo
= (OptionsGroupInfo
*)pEntry
->GetUserData();
859 if(pGroupInfo
->m_pOutItemSet
)
861 if(pGroupInfo
->m_pShell
)
862 pGroupInfo
->m_pShell
->ApplyItemSet( pGroupInfo
->m_nDialogId
, *pGroupInfo
->m_pOutItemSet
);
864 ApplyItemSet( pGroupInfo
->m_nDialogId
, *pGroupInfo
->m_pOutItemSet
);
867 pEntry
= aTreeLB
.Next(pEntry
);
871 void OfaTreeOptionsDialog::InitTreeAndHandler()
873 aTreeLB
.SetNodeDefaultImages();
874 aPageImages
= ImageList( CUI_RES( RID_IMGLIST_TREEOPT
) );
875 aPageImagesHC
= ImageList( CUI_RES( RID_IMGLIST_TREEOPT_HC
) );
877 aTreeLB
.SetHelpId( HID_OFADLG_TREELISTBOX
);
878 aTreeLB
.SetStyle( aTreeLB
.GetStyle()|WB_HASBUTTONS
| WB_HASBUTTONSATROOT
|
879 WB_HASLINES
| WB_HASLINESATROOT
|
880 WB_CLIPCHILDREN
| WB_HSCROLL
| WB_FORCE_MAKEVISIBLE
| WB_QUICK_SEARCH
);
881 aTreeLB
.SetSpaceBetweenEntries( 0 );
882 aTreeLB
.SetSelectionMode( SINGLE_SELECTION
);
883 aTreeLB
.SetSublistOpenWithLeftRight( sal_True
);
884 aTreeLB
.SetExpandedHdl( LINK( this, OfaTreeOptionsDialog
, ExpandedHdl_Impl
) );
885 aTreeLB
.SetSelectHdl( LINK( this, OfaTreeOptionsDialog
, ShowPageHdl_Impl
) );
886 aBackPB
.SetClickHdl( LINK( this, OfaTreeOptionsDialog
, BackHdl_Impl
) );
887 aOkPB
.SetClickHdl( LINK( this, OfaTreeOptionsDialog
, OKHdl_Impl
) );
890 aSelectTimer
.SetTimeout( SELECT_FIRST_TIMEOUT
);
891 aSelectTimer
.SetTimeoutHdl( LINK( this, OfaTreeOptionsDialog
, SelectHdl_Impl
) );
894 /* -----------------17.02.99 09:51-------------------
896 * --------------------------------------------------*/
897 void OfaTreeOptionsDialog::ActivatePage( sal_uInt16 nResId
)
899 bIsForSetDocumentLanguage
= false;
900 if ( nResId
== OFA_TP_LANGUAGES_FOR_SET_DOCUMENT_LANGUAGE
)
902 bIsForSetDocumentLanguage
= true;
903 nResId
= OFA_TP_LANGUAGES
;
906 DBG_ASSERT( !bIsFromExtensionManager
, "OfaTreeOptionsDialog::ActivatePage(): call from extension manager" );
907 if ( !pLastPageSaver
)
908 pLastPageSaver
= new LastPageSaver
;
909 bForgetSelection
= sal_True
;
910 sal_uInt16 nTemp
= pLastPageSaver
->m_nLastPageId
;
911 pLastPageSaver
->m_nLastPageId
= nResId
;
912 ActivateLastSelection();
913 pLastPageSaver
->m_nLastPageId
= nTemp
;
916 void OfaTreeOptionsDialog::ActivatePage( const String
& rPageURL
)
918 DBG_ASSERT( !bIsFromExtensionManager
, "OfaTreeOptionsDialog::ActivatePage(): call from extension manager" );
919 if ( !pLastPageSaver
)
920 pLastPageSaver
= new LastPageSaver
;
921 bForgetSelection
= sal_True
;
922 pLastPageSaver
->m_nLastPageId
= 0;
923 pLastPageSaver
->m_sLastPageURL_Tools
= rPageURL
;
924 ActivateLastSelection();
927 /* -----------------16.02.99 13:17-------------------
929 * --------------------------------------------------*/
930 void OfaTreeOptionsDialog::ActivateLastSelection()
932 SvLBoxEntry
* pEntry
= NULL
;
933 if ( pLastPageSaver
)
935 String
sExpand( RTL_CONSTASCII_STRINGPARAM( EXPAND_PROTOCOL
) );
936 String sLastURL
= bIsFromExtensionManager
? pLastPageSaver
->m_sLastPageURL_ExtMgr
937 : pLastPageSaver
->m_sLastPageURL_Tools
;
938 if ( sLastURL
.Len() == 0 )
940 sLastURL
= !bIsFromExtensionManager
? pLastPageSaver
->m_sLastPageURL_ExtMgr
941 : pLastPageSaver
->m_sLastPageURL_Tools
;
944 // MacroExpander to convert "expand"-URL to "file"-URL
945 Reference
< XMacroExpander
> m_xMacroExpander
;
946 bool bMustExpand
= ( INetURLObject( sLastURL
).GetProtocol() == INET_PROT_FILE
);
950 Reference
< XComponentContext
> xContext
;
951 Reference
< XPropertySet
> xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY
);
952 xProps
->getPropertyValue(
953 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ) >>= xContext
;
955 m_xMacroExpander
= Reference
< com::sun::star::util::XMacroExpander
>(
956 xContext
->getValueByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
957 "/singletons/com.sun.star.util.theMacroExpander" ) ) ), UNO_QUERY
);
960 SvLBoxEntry
* pTemp
= aTreeLB
.First();
961 while( !pEntry
&& pTemp
)
963 // restore only selection of a leaf
964 if ( aTreeLB
.GetParent( pTemp
) && pTemp
->GetUserData() )
966 OptionsPageInfo
* pPageInfo
= (OptionsPageInfo
*)pTemp
->GetUserData();
967 String sPageURL
= pPageInfo
->m_sPageURL
;
969 && sPageURL
.Len() > 0
970 && sExpand
.Match( sPageURL
) == STRING_MATCH
)
973 ::rtl::OUString
sTemp( sPageURL
.Copy( sizeof( EXPAND_PROTOCOL
) -1 ) );
974 // decode uri class chars
975 sTemp
= ::rtl::Uri::decode(
976 sTemp
, rtl_UriDecodeWithCharset
, RTL_TEXTENCODING_UTF8
);
978 sPageURL
= m_xMacroExpander
->expandMacros( sTemp
);
981 if ( ( !bIsFromExtensionManager
982 && pPageInfo
->m_nPageId
&& pPageInfo
->m_nPageId
== pLastPageSaver
->m_nLastPageId
)
983 || ( !pPageInfo
->m_nPageId
&& sLastURL
== sPageURL
) )
986 pTemp
= aTreeLB
.Next(pTemp
);
992 pEntry
= aTreeLB
.First();
993 pEntry
= aTreeLB
.Next(pEntry
);
996 SvLBoxEntry
* pParent
= aTreeLB
.GetParent(pEntry
);
997 aTreeLB
.Expand(pParent
);
998 aTreeLB
.MakeVisible(pParent
);
999 aTreeLB
.MakeVisible(pEntry
);
1000 aTreeLB
.Select(pEntry
);
1001 aTreeLB
.GrabFocus();
1004 /* -----------------22.02.99 08:52-------------------
1006 * --------------------------------------------------*/
1007 long OfaTreeOptionsDialog::Notify( NotifyEvent
& rNEvt
)
1009 if ( rNEvt
.GetType() == EVENT_KEYINPUT
)
1011 const KeyEvent
* pKEvt
= rNEvt
.GetKeyEvent();
1012 const KeyCode aKeyCode
= pKEvt
->GetKeyCode();
1014 if( aKeyCode
.GetCode() == KEY_PAGEUP
||
1015 aKeyCode
.GetCode() == KEY_PAGEDOWN
)
1017 SvLBoxEntry
* pCurEntry
= aTreeLB
.FirstSelected();
1018 SvLBoxEntry
* pTemp
= 0;
1019 if(aKeyCode
.GetCode() == KEY_PAGEDOWN
)
1021 pTemp
= aTreeLB
.Next( pCurEntry
) ;
1022 if(pTemp
&& !aTreeLB
.GetParent(pTemp
))
1024 pTemp
= aTreeLB
.Next( pTemp
) ;
1025 aTreeLB
.Select(pTemp
);
1030 pTemp
= aTreeLB
.Prev( pCurEntry
) ;
1031 if(pTemp
&& !aTreeLB
.GetParent(pTemp
))
1033 pTemp
= aTreeLB
.Prev( pTemp
) ;
1038 if(!aTreeLB
.IsExpanded(aTreeLB
.GetParent(pTemp
)))
1039 aTreeLB
.Expand(aTreeLB
.GetParent(pTemp
));
1040 aTreeLB
.MakeVisible(pTemp
);
1041 aTreeLB
.Select(pTemp
);
1045 return SfxModalDialog::Notify(rNEvt
);
1048 // --------------------------------------------------------------------
1050 void OfaTreeOptionsDialog::DataChanged( const DataChangedEvent
& rDCEvt
)
1052 SfxModalDialog::DataChanged( rDCEvt
);
1054 SvLBoxEntry
* pEntry
= aTreeLB
.GetCurEntry();
1055 if ( ( rDCEvt
.GetType() == DATACHANGED_SETTINGS
) && ( rDCEvt
.GetFlags() & SETTINGS_STYLE
) &&
1056 !aTreeLB
.GetParent(pEntry
))
1058 OptionsGroupInfo
* pInfo
= static_cast<OptionsGroupInfo
*>(pEntry
->GetUserData());
1059 bool bHighContrast
= GetSettings().GetStyleSettings().GetHighContrastMode();
1060 ImageList
* pImgLst
= bHighContrast
? &aPageImagesHC
: &aPageImages
;
1061 for ( sal_uInt16 i
= 0; i
< aHelpTextsArr
.Count(); ++i
)
1063 if ( aHelpTextsArr
.GetValue(i
) == pInfo
->m_nDialogId
)
1065 aHelpImg
.SetImage( pImgLst
->GetImage( pInfo
->m_nDialogId
) );
1075 FlagSet_Impl(bool& bFlag
) : rFlag(bFlag
){rFlag
= true;}
1076 ~FlagSet_Impl(){rFlag
= false;}
1079 IMPL_LINK( OfaTreeOptionsDialog
, SelectHdl_Impl
, Timer
*, EMPTYARG
)
1081 SvTreeListBox
* pBox
= &aTreeLB
;
1082 SvLBoxEntry
* pEntry
= pBox
->GetCurEntry();
1083 SvLBoxEntry
* pParent
= pBox
->GetParent(pEntry
);
1084 pBox
->EndSelection();
1086 DBG_ASSERT(!bInSelectHdl_Impl
, "Timeout handler called twice");
1087 if(bInSelectHdl_Impl
|| pCurrentPageEntry
== pEntry
)
1089 //#111938# lock the SelectHdl_Impl to prevent multiple executes
1090 FlagSet_Impl
aFlag(bInSelectHdl_Impl
);
1091 TabPage
* pOldPage
= NULL
;
1092 TabPage
* pNewPage
= NULL
;
1093 OptionsPageInfo
* pOptPageInfo
= ( pCurrentPageEntry
&& aTreeLB
.GetParent( pCurrentPageEntry
) )
1094 ? (OptionsPageInfo
*)pCurrentPageEntry
->GetUserData() : NULL
;
1096 if ( pOptPageInfo
&& pOptPageInfo
->m_pPage
&& pOptPageInfo
->m_pPage
->IsVisible() )
1098 pOldPage
= pOptPageInfo
->m_pPage
;
1099 OptionsGroupInfo
* pGroupInfo
= (OptionsGroupInfo
*)aTreeLB
.GetParent(pCurrentPageEntry
)->GetUserData();
1100 int nLeave
= SfxTabPage::LEAVE_PAGE
;
1101 if ( RID_SVXPAGE_COLOR
!= pOptPageInfo
->m_nPageId
&& pOptPageInfo
->m_pPage
->HasExchangeSupport() )
1102 nLeave
= pOptPageInfo
->m_pPage
->DeactivatePage( pGroupInfo
->m_pOutItemSet
);
1104 if ( nLeave
== SfxTabPage::KEEP_PAGE
)
1106 // we cannot leave this page
1107 pBox
->Select( pCurrentPageEntry
);
1111 pOptPageInfo
->m_pPage
->Hide();
1113 else if ( pOptPageInfo
&& pOptPageInfo
->m_pExtPage
)
1115 pOptPageInfo
->m_pExtPage
->Hide();
1116 pOptPageInfo
->m_pExtPage
->DeactivatePage();
1118 else if ( pCurrentPageEntry
&& !aTreeLB
.GetParent( pCurrentPageEntry
) )
1120 OptionsGroupInfo
* pGroupInfo
= (OptionsGroupInfo
*)pCurrentPageEntry
->GetUserData();
1121 if ( pGroupInfo
&& pGroupInfo
->m_pExtPage
)
1123 pGroupInfo
->m_pExtPage
->Hide();
1124 pGroupInfo
->m_pExtPage
->DeactivatePage();
1129 aPageTitleFT
.Hide();
1133 OptionsPageInfo
*pPageInfo
= (OptionsPageInfo
*)pEntry
->GetUserData();
1134 OptionsGroupInfo
* pGroupInfo
= (OptionsGroupInfo
*)pParent
->GetUserData();
1135 if(!pPageInfo
->m_pPage
&& pPageInfo
->m_nPageId
> 0)
1137 if(pGroupInfo
->m_bLoadError
)
1139 if ( RID_SVXPAGE_COLOR
== pPageInfo
->m_nPageId
)
1141 if(!pColorPageItemSet
)
1143 // Move usage of a static XOutdevItemPool instance here
1144 if(!mpStaticXOutdevItemPool
)
1146 mpStaticXOutdevItemPool
= new XOutdevItemPool();
1148 pColorPageItemSet
= new SfxItemSet( *mpStaticXOutdevItemPool
, XATTR_FILLSTYLE
, XATTR_FILLCOLOR
);
1149 pColorPageItemSet
->Put( XFillColorItem() );
1154 if(pGroupInfo
->m_pModule
/*&& !pGroupInfo->pModule->IsLoaded()*/)
1156 SfxModule
* pOldModule
= pGroupInfo
->m_pModule
;
1157 sal_Bool bIdentical
= pGroupInfo
->m_pModule
== pGroupInfo
->m_pShell
;
1159 WaitObject
aWait(this);
1160 //pGroupInfo->pModule = pGroupInfo->pModule->Load();
1161 if(!pGroupInfo
->m_pModule
)
1163 pGroupInfo
->m_bLoadError
= sal_True
;
1164 InfoBox(pBox
, sNotLoadedError
).Execute();
1168 pGroupInfo
->m_pShell
= pGroupInfo
->m_pModule
;
1169 //jetzt noch testen, ob es auch in anderen Gruppen das gleiche Module gab (z.B. Text+HTML)
1170 SvLBoxEntry
* pTemp
= aTreeLB
.First();
1173 if(!aTreeLB
.GetParent(pTemp
) && pTemp
!= pEntry
)
1175 OptionsGroupInfo
* pTGInfo
= (OptionsGroupInfo
*)pTemp
->GetUserData();
1176 if(pTGInfo
->m_pModule
== pOldModule
)
1178 pTGInfo
->m_pModule
= pGroupInfo
->m_pModule
;
1180 pTGInfo
->m_pShell
= pGroupInfo
->m_pModule
;
1183 pTemp
= aTreeLB
.Next(pTemp
);
1187 // if ( pPageInfo->nPageId != RID_OPTPAGE_CHART_DEFCOLORS )
1189 if(!pGroupInfo
->m_pInItemSet
)
1190 pGroupInfo
->m_pInItemSet
= pGroupInfo
->m_pShell
1191 ? pGroupInfo
->m_pShell
->CreateItemSet( pGroupInfo
->m_nDialogId
)
1192 : CreateItemSet( pGroupInfo
->m_nDialogId
);
1193 if(!pGroupInfo
->m_pOutItemSet
)
1194 pGroupInfo
->m_pOutItemSet
= new SfxItemSet(
1195 *pGroupInfo
->m_pInItemSet
->GetPool(),
1196 pGroupInfo
->m_pInItemSet
->GetRanges());
1200 if(pGroupInfo
->m_pModule
)
1202 pPageInfo
->m_pPage
= pGroupInfo
->m_pModule
->CreateTabPage(
1203 pPageInfo
->m_nPageId
, this, *pGroupInfo
->m_pInItemSet
);
1205 else if(RID_SVXPAGE_COLOR
!= pPageInfo
->m_nPageId
)
1206 pPageInfo
->m_pPage
= ::CreateGeneralTabPage( pPageInfo
->m_nPageId
, this, *pGroupInfo
->m_pInItemSet
);
1209 pPageInfo
->m_pPage
= ::CreateGeneralTabPage(
1210 pPageInfo
->m_nPageId
, this, *pColorPageItemSet
);
1211 SvxColorTabPage
& rColPage
= *(SvxColorTabPage
*)pPageInfo
->m_pPage
;
1212 const OfaPtrItem
* pPtr
= NULL
;
1213 if ( SfxViewFrame::Current() && SfxViewFrame::Current()->GetDispatcher() )
1214 pPtr
= (const OfaPtrItem
*)SfxViewFrame::Current()->
1215 GetDispatcher()->Execute( SID_GET_COLORTABLE
, SFX_CALLMODE_SYNCHRON
);
1216 pColorTab
= pPtr
? (XColorTable
*)pPtr
->GetValue() : XColorTable::GetStdColorTable();
1218 rColPage
.SetColorTable( pColorTab
);
1219 rColPage
.SetPageType( &nUnknownType
);
1220 rColPage
.SetDlgType( &nUnknownType
);
1221 rColPage
.SetPos( &nUnknownPos
);
1222 rColPage
.SetAreaTP( &bIsAreaTP
);
1223 rColPage
.SetColorChgd( (ChangeType
*)&nChangeType
);
1224 rColPage
.Construct();
1227 DBG_ASSERT( pPageInfo
->m_pPage
, "tabpage could not created");
1228 if ( pPageInfo
->m_pPage
)
1230 SvtViewOptions
aTabPageOpt( E_TABPAGE
, String::CreateFromInt32( pPageInfo
->m_nPageId
) );
1231 pPageInfo
->m_pPage
->SetUserData( GetViewOptUserItem( aTabPageOpt
) );
1233 Point
aTreePos(aTreeLB
.GetPosPixel());
1234 Size
aTreeSize(aTreeLB
.GetSizePixel());
1235 Point
aGBPos(aHiddenGB
.GetPosPixel());
1236 Size
aPageSize(pPageInfo
->m_pPage
->GetSizePixel());
1237 Size
aGBSize(aHiddenGB
.GetSizePixel());
1238 Point
aPagePos( aGBPos
.X() + ( aGBSize
.Width() - aPageSize
.Width() ) / 2,
1239 aGBPos
.Y() + ( aGBSize
.Height() - aPageSize
.Height() ) / 2 );
1240 pPageInfo
->m_pPage
->SetPosPixel( aPagePos
);
1241 if ( RID_SVXPAGE_COLOR
== pPageInfo
->m_nPageId
)
1243 pPageInfo
->m_pPage
->Reset( *pColorPageItemSet
);
1244 pPageInfo
->m_pPage
->ActivatePage( *pColorPageItemSet
);
1248 pPageInfo
->m_pPage
->Reset( *pGroupInfo
->m_pInItemSet
);
1252 else if ( 0 == pPageInfo
->m_nPageId
&& !pPageInfo
->m_pExtPage
)
1254 if ( !m_xContainerWinProvider
.is() )
1256 Reference
< XMultiServiceFactory
> xFactory( ::comphelper::getProcessServiceFactory() );
1257 m_xContainerWinProvider
= Reference
< awt::XContainerWindowProvider
>(
1258 xFactory
->createInstance(
1259 C2U("com.sun.star.awt.ContainerWindowProvider") ), UNO_QUERY
);
1260 DBG_ASSERT( m_xContainerWinProvider
.is(), "service com.sun.star.awt.ContainerWindowProvider could not be loaded" );
1263 pPageInfo
->m_pExtPage
= new ExtensionsTabPage(
1264 this, 0, pPageInfo
->m_sPageURL
, pPageInfo
->m_sEventHdl
, m_xContainerWinProvider
);
1265 Size aSize
= aHiddenGB
.GetSizePixel();
1266 aSize
.Width() = aSize
.Width() - 4;
1267 aSize
.Height() = aSize
.Height() - 4;
1268 Point aPos
= aHiddenGB
.GetPosPixel();
1269 aPos
.X() = aPos
.X() + 2;
1270 aPos
.Y() = aPos
.Y() + 2;
1271 pPageInfo
->m_pExtPage
->SetPosSizePixel( aPos
, aSize
);
1274 if ( pPageInfo
->m_pPage
)
1276 if ( RID_SVXPAGE_COLOR
!= pPageInfo
->m_nPageId
&&
1277 pPageInfo
->m_pPage
->HasExchangeSupport())
1279 pPageInfo
->m_pPage
->ActivatePage(*pGroupInfo
->m_pOutItemSet
);
1281 pPageInfo
->m_pPage
->Show();
1283 else if ( pPageInfo
->m_pExtPage
)
1285 pPageInfo
->m_pExtPage
->Show();
1286 pPageInfo
->m_pExtPage
->ActivatePage();
1289 String sTmpTitle
= sTitle
;
1290 sTmpTitle
+= String::CreateFromAscii(" - ");
1291 sTmpTitle
+= aTreeLB
.GetEntryText(pParent
);
1292 sTmpTitle
+= String::CreateFromAscii(" - ");
1293 sTmpTitle
+= aTreeLB
.GetEntryText(pEntry
);
1295 pCurrentPageEntry
= pEntry
;
1296 if ( !bForgetSelection
)
1298 if ( !pLastPageSaver
)
1299 pLastPageSaver
= new LastPageSaver
;
1300 if ( !bIsFromExtensionManager
)
1301 pLastPageSaver
->m_nLastPageId
= pPageInfo
->m_nPageId
;
1302 if ( pPageInfo
->m_pExtPage
)
1304 if ( bIsFromExtensionManager
)
1305 pLastPageSaver
->m_sLastPageURL_ExtMgr
= pPageInfo
->m_sPageURL
;
1307 pLastPageSaver
->m_sLastPageURL_Tools
= pPageInfo
->m_sPageURL
;
1310 pNewPage
= pPageInfo
->m_pPage
;
1314 OptionsGroupInfo
* pTGInfo
= (OptionsGroupInfo
*)pEntry
->GetUserData();
1315 if ( pTGInfo
->m_sPageURL
.getLength() == 0 )
1317 bool bHighContrast
= GetSettings().GetStyleSettings().GetHighContrastMode();
1318 ImageList
* pImgLst
= bHighContrast
? &aPageImagesHC
: &aPageImages
;
1319 //hier den Hilfetext anzeigen
1320 for ( sal_uInt16 i
= 0; i
< aHelpTextsArr
.Count(); ++i
)
1322 if ( aHelpTextsArr
.GetValue(i
) == pTGInfo
->m_nDialogId
)
1324 aHelpFT
.SetText(aHelpTextsArr
.GetString(i
));
1325 aHelpImg
.SetImage(pImgLst
->GetImage(pTGInfo
->m_nDialogId
));
1330 aPageTitleFT
.Show();
1335 //auf die Groesse der Bitmap anpassen
1338 const long nCtrlDist
= 2;
1339 bImageResized
= sal_True
;
1340 Point
aImgPos(aHelpImg
.GetPosPixel());
1341 Size
aImgSize(aHelpImg
.GetSizePixel());
1342 Point
aTitlePos(aPageTitleFT
.GetPosPixel());
1343 Point
aLinePos(aLine1FL
.GetPosPixel());
1344 Point
aHelpPos(aHelpFT
.GetPosPixel());
1345 Size
aHelpSize(aHelpFT
.GetSizePixel());
1348 if(aTitlePos
.X() <= (aImgPos
.X() + aImgSize
.Width() + nCtrlDist
))
1350 nXDiff
= aImgPos
.X() + aImgSize
.Width() + nCtrlDist
- aTitlePos
.X();
1352 if(aLinePos
.Y() <= (aImgPos
.Y() + aImgSize
.Height() + nCtrlDist
))
1354 nYDiff
= aImgPos
.Y() + aImgSize
.Height() + nCtrlDist
- aLinePos
.Y();
1356 aLinePos
.Y() += nYDiff
;
1357 aLine1FL
.SetPosPixel(aLinePos
);
1359 aTitlePos
.X() += nXDiff
;
1360 aPageTitleFT
.SetPosPixel(aTitlePos
);
1362 aHelpPos
.X() += nXDiff
;
1363 aHelpPos
.Y() += nYDiff
;
1364 aHelpSize
.Width() -= nXDiff
;
1365 aHelpSize
.Height() -= nYDiff
;
1366 aHelpFT
.SetPosSizePixel(aHelpPos
, aHelpSize
);
1368 Font aFont
= aHelpFT
.GetFont();
1369 Size aSz
= aFont
.GetSize();
1370 aSz
.Height() = (aSz
.Height() * 14 ) / 10;
1372 aPageTitleFT
.SetFont(aFont
);
1375 String sTmpTitle
= sTitle
;
1376 sTmpTitle
+= String::CreateFromAscii(" - ");
1377 aPageTitleFT
.SetText(aTreeLB
.GetEntryText(pEntry
));
1378 sTmpTitle
+= aPageTitleFT
.GetText();
1380 pCurrentPageEntry
= NULL
;
1384 if ( !pTGInfo
->m_pExtPage
)
1386 if ( !m_xContainerWinProvider
.is() )
1388 Reference
< XMultiServiceFactory
> xFactory( ::comphelper::getProcessServiceFactory() );
1389 m_xContainerWinProvider
= Reference
< awt::XContainerWindowProvider
>(
1390 xFactory
->createInstance(
1391 C2U("com.sun.star.awt.ContainerWindowProvider") ), UNO_QUERY
);
1392 DBG_ASSERT( m_xContainerWinProvider
.is(), "service com.sun.star.awt.ContainerWindowProvider could not be loaded" );
1395 pTGInfo
->m_pExtPage
=
1396 new ExtensionsTabPage( this, 0, pTGInfo
->m_sPageURL
, rtl::OUString(), m_xContainerWinProvider
);
1397 Size aSize
= aHiddenGB
.GetSizePixel();
1398 aSize
.Width() = aSize
.Width() - 4;
1399 aSize
.Height() = aSize
.Height() - 4;
1400 Point aPos
= aHiddenGB
.GetPosPixel();
1401 aPos
.X() = aPos
.X() + 2;
1402 aPos
.Y() = aPos
.Y() + 2;
1403 pTGInfo
->m_pExtPage
->SetPosSizePixel( aPos
, aSize
);
1406 if ( pTGInfo
->m_pExtPage
)
1408 pTGInfo
->m_pExtPage
->Show();
1409 pTGInfo
->m_pExtPage
->ActivatePage();
1412 pCurrentPageEntry
= pEntry
;
1416 // restore lost focus, if necessary
1417 Window
* pFocusWin
= Application::GetFocusWindow();
1418 // if the focused window is not the options treebox and the old page has the focus
1419 if ( pFocusWin
&& pFocusWin
!= pBox
&& pOldPage
&& pOldPage
->HasChildPathFocus() )
1420 // then set the focus to the new page or if we are on a group set the focus to the options treebox
1421 pNewPage
? pNewPage
->GrabFocus() : pBox
->GrabFocus();
1426 /* -----------------11.02.99 15:51-------------------
1428 * --------------------------------------------------*/
1430 OfaPageResource::OfaPageResource() :
1431 Resource(CUI_RES(RID_OFADLG_OPTIONS_TREE_PAGES
)),
1432 aGeneralDlgAry(CUI_RES(SID_GENERAL_OPTIONS
)),
1433 aInetDlgAry(CUI_RES(SID_INET_DLG
)),
1434 aLangDlgAry(CUI_RES(SID_LANGUAGE_OPTIONS
)),
1435 aTextDlgAry(CUI_RES(SID_SW_EDITOPTIONS
)),
1436 aHTMLDlgAry(CUI_RES(SID_SW_ONLINEOPTIONS
)),
1437 aCalcDlgAry(CUI_RES(SID_SC_EDITOPTIONS
)),
1438 aStarMathDlgAry(CUI_RES(SID_SM_EDITOPTIONS
)),
1439 aImpressDlgAry(CUI_RES(SID_SD_EDITOPTIONS
)),
1440 aDrawDlgAry(CUI_RES(SID_SD_GRAPHIC_OPTIONS
)),
1441 aChartDlgAry(CUI_RES(SID_SCH_EDITOPTIONS
)),
1442 aFilterDlgAry(CUI_RES(SID_FILTER_DLG
)),
1443 aDatasourcesDlgAry(CUI_RES(SID_SB_STARBASEOPTIONS
))
1448 sal_Bool
EnableSSO( void )
1450 // SSO must be enabled if the configuration manager bootstrap settings
1451 // are configured as follows ...
1452 // CFG_Offline=false
1453 // CFG_ServerType=uno ( or unspecified )
1454 // CFG_BackendService=
1455 // com.sun.star.comp.configuration.backend.LdapSingleBackend
1457 rtl::OUString theIniFile
;
1458 osl_getExecutableFile( &theIniFile
.pData
);
1459 theIniFile
= theIniFile
.copy( 0, theIniFile
.lastIndexOf( '/' ) + 1 ) +
1460 rtl::OUString::createFromAscii( SAL_CONFIGFILE( "configmgr" ) );
1461 ::rtl::Bootstrap
theBootstrap( theIniFile
);
1463 rtl::OUString theOfflineValue
;
1464 rtl::OUString theDefaultOfflineValue
= rtl::OUString::createFromAscii( "false" );
1465 theBootstrap
.getFrom( rtl::OUString::createFromAscii( "CFG_Offline" ),
1467 theDefaultOfflineValue
);
1469 rtl::OUString theServerTypeValue
;
1470 theBootstrap
.getFrom( rtl::OUString::createFromAscii( "CFG_ServerType" ),
1471 theServerTypeValue
);
1473 rtl::OUString theBackendServiceTypeValue
;
1474 theBootstrap
.getFrom( rtl::OUString::createFromAscii( "CFG_BackendService" ),
1475 theBackendServiceTypeValue
);
1477 sal_Bool bSSOEnabled
=
1478 ( theOfflineValue
== theDefaultOfflineValue
&&
1479 ( theServerTypeValue
.getLength() == 0 ||
1480 theServerTypeValue
== rtl::OUString::createFromAscii( "uno" ) ) &&
1481 theBackendServiceTypeValue
==
1482 rtl::OUString::createFromAscii(
1483 "com.sun.star.comp.configuration.backend.LdapSingleBackend" ) );
1484 if ( bSSOEnabled
&& GetSSOCreator() == 0 )
1486 bSSOEnabled
= sal_False
;
1491 extern "C" { static void SAL_CALL
thisModule() {} }
1493 CreateTabPage
GetSSOCreator( void )
1495 static CreateTabPage theSymbol
= 0;
1496 if ( theSymbol
== 0 )
1498 osl::Module aModule
;
1499 rtl::OUString
theModuleName( RTL_CONSTASCII_USTRINGPARAM( SVLIBRARY( "ssoopt" ) ) );
1500 if( aModule
.loadRelative(
1501 &thisModule
, theModuleName
, SAL_LOADMODULE_DEFAULT
) )
1503 rtl::OUString
theSymbolName( rtl::OUString::createFromAscii( "CreateSSOTabPage" ) );
1504 theSymbol
= reinterpret_cast<CreateTabPage
>(aModule
.getFunctionSymbol( theSymbolName
));
1511 SfxItemSet
* OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId
)
1513 Reference
< XPropertySet
> xProp( SvxGetLinguPropertySet() );
1514 SfxItemSet
* pRet
= 0;
1517 case SID_GENERAL_OPTIONS
:
1519 pRet
= new SfxItemSet(
1520 SFX_APP()->GetPool(),
1521 SID_ATTR_METRIC
, SID_ATTR_SPELL
,
1522 SID_AUTOSPELL_CHECK
, SID_AUTOSPELL_CHECK
,
1523 SID_ATTR_QUICKLAUNCHER
, SID_ATTR_QUICKLAUNCHER
,
1524 SID_ATTR_YEAR2000
, SID_ATTR_YEAR2000
,
1525 SID_HTML_MODE
, SID_HTML_MODE
,
1528 SfxItemSet
aOptSet( SFX_APP()->GetPool(), SID_ATTR_QUICKLAUNCHER
, SID_ATTR_QUICKLAUNCHER
);
1529 SFX_APP()->GetOptions(aOptSet
);
1533 const SfxPoolItem
* pItem
;
1534 SfxViewFrame
* pViewFrame
= SfxViewFrame::Current();
1537 SfxDispatcher
* pDispatch
= pViewFrame
->GetDispatcher();
1539 // Sonstiges - Year2000
1540 if( SFX_ITEM_AVAILABLE
<= pDispatch
->QueryState( SID_ATTR_YEAR2000
, pItem
) )
1541 pRet
->Put( SfxUInt16Item( SID_ATTR_YEAR2000
, ((const SfxUInt16Item
*)pItem
)->GetValue() ) );
1543 pRet
->Put( SfxUInt16Item( SID_ATTR_YEAR2000
, (sal_uInt16
)aMisc
.GetYear2000() ) );
1546 pRet
->Put( SfxUInt16Item( SID_ATTR_YEAR2000
, (sal_uInt16
)aMisc
.GetYear2000() ) );
1549 // Sonstiges - Tabulator
1550 pRet
->Put(SfxBoolItem(SID_PRINTER_NOTFOUND_WARN
, aMisc
.IsNotFoundWarning()));
1552 sal_uInt16 nFlag
= aMisc
.IsPaperSizeWarning() ? SFX_PRINTER_CHG_SIZE
: 0;
1553 nFlag
|= aMisc
.IsPaperOrientationWarning() ? SFX_PRINTER_CHG_ORIENTATION
: 0;
1554 pRet
->Put( SfxFlagItem( SID_PRINTER_CHANGESTODOC
, nFlag
));
1558 case SID_LANGUAGE_OPTIONS
:
1560 pRet
= new SfxItemSet(SFX_APP()->GetPool(),
1561 SID_ATTR_LANGUAGE
, SID_AUTOSPELL_CHECK
,
1562 SID_ATTR_CHAR_CJK_LANGUAGE
, SID_ATTR_CHAR_CTL_LANGUAGE
,
1563 SID_OPT_LOCALE_CHANGED
, SID_OPT_LOCALE_CHANGED
,
1564 SID_SET_DOCUMENT_LANGUAGE
, SID_SET_DOCUMENT_LANGUAGE
,
1567 // fuer die Linguistik
1569 Reference
< XSpellChecker1
> xSpell
= SvxGetSpellChecker();
1570 pRet
->Put(SfxSpellCheckItem( xSpell
, SID_ATTR_SPELL
));
1571 SfxHyphenRegionItem
aHyphen( SID_ATTR_HYPHENREGION
);
1573 sal_Int16 nMinLead
= 2,
1577 xProp
->getPropertyValue( String::CreateFromAscii(
1578 UPN_HYPH_MIN_LEADING
) ) >>= nMinLead
;
1579 xProp
->getPropertyValue( String::CreateFromAscii(
1580 UPN_HYPH_MIN_TRAILING
) ) >>= nMinTrail
;
1582 aHyphen
.GetMinLead() = (sal_uInt8
)nMinLead
;
1583 aHyphen
.GetMinTrail() = (sal_uInt8
)nMinTrail
;
1585 const SfxPoolItem
* pItem
;
1586 SfxPoolItem
* pClone
;
1587 SfxViewFrame
* pViewFrame
= SfxViewFrame::Current();
1590 SfxDispatcher
* pDispatch
= pViewFrame
->GetDispatcher();
1591 if(SFX_ITEM_AVAILABLE
<= pDispatch
->QueryState(SID_ATTR_LANGUAGE
, pItem
))
1592 pRet
->Put(SfxUInt16Item(SID_ATTR_LANGUAGE
, ((const SvxLanguageItem
*)pItem
)->GetLanguage()));
1593 if(SFX_ITEM_AVAILABLE
<= pDispatch
->QueryState(SID_ATTR_CHAR_CJK_LANGUAGE
, pItem
))
1594 pRet
->Put(SfxUInt16Item(SID_ATTR_CHAR_CJK_LANGUAGE
, ((const SvxLanguageItem
*)pItem
)->GetLanguage()));
1595 if(SFX_ITEM_AVAILABLE
<= pDispatch
->QueryState(SID_ATTR_CHAR_CTL_LANGUAGE
, pItem
))
1596 pRet
->Put(SfxUInt16Item(SID_ATTR_CHAR_CTL_LANGUAGE
, ((const SvxLanguageItem
*)pItem
)->GetLanguage()));
1599 if(SFX_ITEM_AVAILABLE
<= pDispatch
->QueryState(SID_AUTOSPELL_CHECK
, pItem
))
1601 pClone
= pItem
->Clone();
1607 sal_Bool bVal
= sal_False
;
1610 xProp
->getPropertyValue( String::CreateFromAscii( UPN_IS_SPELL_AUTO
) ) >>= bVal
;
1613 pRet
->Put(SfxBoolItem(SID_AUTOSPELL_CHECK
, bVal
));
1616 pRet
->Put( SfxBoolItem( SID_SET_DOCUMENT_LANGUAGE
, bIsForSetDocumentLanguage
) );
1620 pRet
= new SfxItemSet( SFX_APP()->GetPool(),
1621 SID_BASIC_ENABLED
, SID_BASIC_ENABLED
,
1622 //SID_OPTIONS_START - ..END
1623 SID_OPTIONS_START
, SID_INET_PROXY_PORT
,
1624 SID_SAVEREL_INET
, SID_SAVEREL_FSYS
,
1625 SID_INET_SMTPSERVER
, SID_INET_SMTPSERVER
,
1626 SID_INET_NOPROXY
, SID_INET_SOCKS_PROXY_PORT
,
1627 SID_INET_DNS_AUTO
, SID_INET_DNS_SERVER
,
1628 SID_SECURE_URL
, SID_SECURE_URL
,
1630 SFX_APP()->GetOptions(*pRet
);
1632 case SID_FILTER_DLG
:
1633 pRet
= new SfxItemSet( SFX_APP()->GetPool(),
1634 SID_ATTR_DOCINFO
, SID_ATTR_AUTOSAVEMINUTE
,
1635 SID_SAVEREL_INET
, SID_SAVEREL_FSYS
,
1636 SID_ATTR_PRETTYPRINTING
, SID_ATTR_PRETTYPRINTING
,
1637 SID_ATTR_WARNALIENFORMAT
, SID_ATTR_WARNALIENFORMAT
,
1639 SFX_APP()->GetOptions(*pRet
);
1642 case SID_SB_STARBASEOPTIONS
:
1643 pRet
= new SfxItemSet( SFX_APP()->GetPool(),
1644 SID_SB_POOLING_ENABLED
, SID_SB_DB_REGISTER
,
1646 ::offapp::ConnectionPoolConfig::GetOptions(*pRet
);
1647 ::svx::DbRegisteredNamesConfig::GetOptions(*pRet
);
1650 case SID_SCH_EDITOPTIONS
:
1652 SvxChartOptions aChartOpt
;
1653 pRet
= new SfxItemSet( SFX_APP()->GetPool(), SID_SCH_EDITOPTIONS
, SID_SCH_EDITOPTIONS
);
1654 pRet
->Put( SvxChartColorTableItem( SID_SCH_EDITOPTIONS
, aChartOpt
.GetDefaultColors() ) );
1661 void OfaTreeOptionsDialog::ApplyItemSet( sal_uInt16 nId
, const SfxItemSet
& rSet
)
1665 case SID_GENERAL_OPTIONS
:
1668 const SfxPoolItem
* pItem
;
1669 SfxItemSet
aOptSet(SFX_APP()->GetPool(), SID_ATTR_QUICKLAUNCHER
, SID_ATTR_QUICKLAUNCHER
);
1672 SFX_APP()->SetOptions( aOptSet
);
1673 // Dispatcher neu holen, weil SetOptions() ggf. den Dispatcher zerst"ort hat
1674 SfxViewFrame
*pViewFrame
= SfxViewFrame::Current();
1675 // -------------------------------------------------------------------------
1676 // Year2000 auswerten
1677 // -------------------------------------------------------------------------
1678 sal_uInt16 nY2K
= USHRT_MAX
;
1679 if( SFX_ITEM_SET
== rSet
.GetItemState( SID_ATTR_YEAR2000
, sal_False
, &pItem
) )
1680 nY2K
= ((const SfxUInt16Item
*)pItem
)->GetValue();
1681 if( USHRT_MAX
!= nY2K
)
1685 SfxDispatcher
* pDispatch
= pViewFrame
->GetDispatcher();
1686 pDispatch
->Execute( SID_ATTR_YEAR2000
, SFX_CALLMODE_ASYNCHRON
, pItem
, 0L);
1688 aMisc
.SetYear2000(nY2K
);
1691 // -------------------------------------------------------------------------
1692 // Drucken auswerten
1693 // -------------------------------------------------------------------------
1694 if(SFX_ITEM_SET
== rSet
.GetItemState(SID_PRINTER_NOTFOUND_WARN
, sal_False
, &pItem
))
1695 aMisc
.SetNotFoundWarning(((const SfxBoolItem
*)pItem
)->GetValue());
1697 if(SFX_ITEM_SET
== rSet
.GetItemState(SID_PRINTER_CHANGESTODOC
, sal_False
, &pItem
))
1699 const SfxFlagItem
* pFlag
= (const SfxFlagItem
*)pItem
;
1700 aMisc
.SetPaperSizeWarning(0 != (pFlag
->GetValue() & SFX_PRINTER_CHG_SIZE
));
1701 aMisc
.SetPaperOrientationWarning(0 != (pFlag
->GetValue() & SFX_PRINTER_CHG_ORIENTATION
));
1703 // -------------------------------------------------------------------------
1704 // evaluate help options
1705 // -------------------------------------------------------------------------
1706 if ( SvtHelpOptions().IsHelpTips() != Help::IsQuickHelpEnabled() )
1707 SvtHelpOptions().IsHelpTips() ? Help::EnableQuickHelp() : Help::DisableQuickHelp();
1708 if ( SvtHelpOptions().IsExtendedHelp() != Help::IsBalloonHelpEnabled() )
1709 SvtHelpOptions().IsExtendedHelp() ? Help::EnableBalloonHelp() : Help::DisableBalloonHelp();
1712 case SID_LANGUAGE_OPTIONS
:
1714 OfaTreeOptionsDialog::ApplyLanguageOptions(rSet
);
1718 case SID_FILTER_DLG
:
1719 SFX_APP()->SetOptions( rSet
);
1722 case SID_SB_STARBASEOPTIONS
:
1723 ::offapp::ConnectionPoolConfig::SetOptions( rSet
);
1724 ::svx::DbRegisteredNamesConfig::SetOptions(rSet
);
1727 case SID_SCH_EDITOPTIONS
:
1728 // nothing to do. Chart options only apply to newly created charts
1733 DBG_ERROR( "Unhandled option in ApplyItemSet" );
1739 void OfaTreeOptionsDialog::ApplyLanguageOptions(const SfxItemSet
& rSet
)
1741 sal_Bool bSaveSpellCheck
= sal_False
;
1742 const SfxPoolItem
* pItem
;
1744 if ( SFX_ITEM_SET
== rSet
.GetItemState( SID_SPELL_MODIFIED
, sal_False
, &pItem
) )
1746 bSaveSpellCheck
= ( (const SfxBoolItem
*)pItem
)->GetValue();
1748 Reference
< XMultiServiceFactory
> xMgr( ::comphelper::getProcessServiceFactory() );
1749 Reference
< XPropertySet
> xProp(
1750 xMgr
->createInstance( ::rtl::OUString::createFromAscii(
1751 "com.sun.star.linguistic2.LinguProperties") ),
1753 if ( SFX_ITEM_SET
== rSet
.GetItemState(SID_ATTR_HYPHENREGION
, sal_False
, &pItem
) )
1755 const SfxHyphenRegionItem
* pHyphenItem
= (const SfxHyphenRegionItem
*)pItem
;
1759 xProp
->setPropertyValue(
1760 String::CreateFromAscii(UPN_HYPH_MIN_LEADING
),
1761 makeAny((sal_Int16
) pHyphenItem
->GetMinLead()) );
1762 xProp
->setPropertyValue(
1763 String::CreateFromAscii(UPN_HYPH_MIN_TRAILING
),
1764 makeAny((sal_Int16
) pHyphenItem
->GetMinTrail()) );
1766 bSaveSpellCheck
= sal_True
;
1769 SfxViewFrame
*pViewFrame
= SfxViewFrame::Current();
1772 SfxDispatcher
* pDispatch
= pViewFrame
->GetDispatcher();
1774 if(SFX_ITEM_SET
== rSet
.GetItemState( SID_ATTR_LANGUAGE
, sal_False
, &pItem
))
1776 pDispatch
->Execute(pItem
->Which(), SFX_CALLMODE_ASYNCHRON
, pItem
, 0L);
1777 bSaveSpellCheck
= sal_True
;
1779 if(SFX_ITEM_SET
== rSet
.GetItemState( SID_ATTR_CHAR_CTL_LANGUAGE
, sal_False
, &pItem
))
1781 pDispatch
->Execute(pItem
->Which(), SFX_CALLMODE_ASYNCHRON
, pItem
, 0L);
1782 bSaveSpellCheck
= sal_True
;
1784 if(SFX_ITEM_SET
== rSet
.GetItemState( SID_ATTR_CHAR_CJK_LANGUAGE
, sal_False
, &pItem
))
1786 pDispatch
->Execute(pItem
->Which(), SFX_CALLMODE_ASYNCHRON
, pItem
, 0L);
1787 bSaveSpellCheck
= sal_True
;
1790 if( SFX_ITEM_SET
== rSet
.GetItemState(SID_AUTOSPELL_CHECK
, sal_False
, &pItem
))
1792 sal_Bool bOnlineSpelling
= ((const SfxBoolItem
*)pItem
)->GetValue();
1793 pDispatch
->Execute(SID_AUTOSPELL_CHECK
,
1794 SFX_CALLMODE_ASYNCHRON
|SFX_CALLMODE_RECORD
, pItem
, 0L);
1798 xProp
->setPropertyValue(
1799 String::CreateFromAscii(UPN_IS_SPELL_AUTO
),
1800 makeAny(bOnlineSpelling
) );
1804 if( bSaveSpellCheck
)
1806 //! the config item has changed since we modified the
1807 //! property set it uses
1808 pDispatch
->Execute(SID_SPELLCHECKER_CHANGED
, SFX_CALLMODE_ASYNCHRON
);
1812 if( SFX_ITEM_SET
== rSet
.GetItemState(SID_OPT_LOCALE_CHANGED
, sal_False
, &pItem
))
1814 SfxViewFrame
* _pViewFrame
= SfxViewFrame::GetFirst();
1815 while ( _pViewFrame
)
1817 _pViewFrame
->GetDispatcher()->Execute(pItem
->Which(), SFX_CALLMODE_ASYNCHRON
, pItem
, 0L);
1818 _pViewFrame
= SfxViewFrame::GetNext( *_pViewFrame
);
1823 rtl::OUString
getCurrentFactory_Impl( const Reference
< XFrame
>& _xFrame
)
1825 rtl::OUString sIdentifier
;
1826 Reference
< XFrame
> xCurrentFrame( _xFrame
);
1827 Reference
< XModuleManager
> xModuleManager( ::comphelper::getProcessServiceFactory()->createInstance(
1828 DEFINE_CONST_UNICODE("com.sun.star.frame.ModuleManager") ), UNO_QUERY
);
1829 if ( !xCurrentFrame
.is() )
1831 Reference
< XDesktop
> xDesktop( ::comphelper::getProcessServiceFactory()->createInstance(
1832 DEFINE_CONST_UNICODE("com.sun.star.frame.Desktop") ), UNO_QUERY
);
1833 if ( xDesktop
.is() )
1834 xCurrentFrame
= xDesktop
->getCurrentFrame();
1837 if ( xCurrentFrame
.is() && xModuleManager
.is() )
1841 sIdentifier
= xModuleManager
->identify( xCurrentFrame
);
1843 catch ( ::com::sun::star::frame::UnknownModuleException
& )
1845 DBG_WARNING( "getActiveModule_Impl(): unknown module" );
1847 catch ( Exception
& )
1849 DBG_ERRORFILE( "getActiveModule_Impl(): exception of XModuleManager::identify()" );
1856 void OfaTreeOptionsDialog::Initialize( const Reference
< XFrame
>& _xFrame
)
1858 OfaPageResource aDlgResource
;
1859 sal_uInt16 nGroup
= 0;
1861 SvtOptionsDialogOptions aOptionsDlgOpt
;
1862 sal_uInt16 i
, nPageId
;
1864 // %PRODUCTNAME options
1865 sal_Bool isSSOEnabled
= EnableSSO();
1866 if ( !lcl_isOptionHidden( SID_GENERAL_OPTIONS
, aOptionsDlgOpt
) )
1868 ResStringArray
& rGeneralArray
= aDlgResource
.GetGeneralArray();
1869 setGroupName( C2U("ProductName"), rGeneralArray
.GetString(0) );
1870 nGroup
= AddGroup( rGeneralArray
.GetString(0), 0, 0, SID_GENERAL_OPTIONS
);
1871 sal_uInt16 nEnd
= static_cast< sal_uInt16
>( rGeneralArray
.Count() );
1874 for ( i
= 1; i
< nEnd
; ++i
)
1876 String sNewTitle
= rGeneralArray
.GetString(i
);
1877 nPageId
= (sal_uInt16
)rGeneralArray
.GetValue(i
);
1878 if ( lcl_isOptionHidden( nPageId
, aOptionsDlgOpt
) )
1881 // Disable Online Update page if service not installed
1882 if( RID_SVXPAGE_ONLINEUPDATE
== nPageId
)
1884 const ::rtl::OUString sService
= C2U("com.sun.star.setup.UpdateCheck");
1888 Reference
< XMultiServiceFactory
> xFactory( ::comphelper::getProcessServiceFactory() );
1889 Reference
< XInterface
> xService( xFactory
->createInstance( sService
) );
1891 if( ! xService
.is() )
1894 catch ( ::com::sun::star::loader::CannotActivateFactoryException
& )
1899 // Disable OOoImprovement page if not enabled
1900 if( RID_SVXPAGE_IMPROVEMENT
== nPageId
)
1904 if ( nPageId
!= RID_SVXPAGE_SSO
|| isSSOEnabled
)
1906 AddTabPage( nPageId
, sNewTitle
, nGroup
);
1909 // private iteration hack for Improvement Program
1911 // should not be in found in any later release
1912 for(bool bOnce
= false; bOnce
==false; bOnce
=true)
1914 String sNewTitle
= C2U("Improvement Program");
1916 SvxImprovementPage
aTempTabPage(this);
1917 sNewTitle
= aTempTabPage
.GetTitleText();
1919 nPageId
= RID_SVXPAGE_IMPROVEMENT
;
1920 if ( lcl_isOptionHidden( nPageId
, aOptionsDlgOpt
) )
1922 // Disable OOoImprovement page if not enabled
1924 const ::rtl::OUString sService
= C2U("com.sun.star.oooimprovement.CoreController");
1927 Reference
< XMultiServiceFactory
> xFactory( ::comphelper::getProcessServiceFactory() );
1928 Reference
< ::com::sun::star::oooimprovement::XCoreController
> xService( xFactory
->createInstance( sService
), UNO_QUERY
);
1930 if( ! xService
.is() )
1932 if( ! xService
->showBuiltinOptionsPage(1))
1935 catch ( ::com::sun::star::loader::CannotActivateFactoryException
& )
1940 if ( nPageId
!= RID_SVXPAGE_SSO
|| isSSOEnabled
)
1942 AddTabPage( nPageId
, sNewTitle
, nGroup
);
1947 // Load and Save options
1948 if ( !lcl_isOptionHidden( SID_FILTER_DLG
, aOptionsDlgOpt
) )
1950 ResStringArray
& rFilterArray
= aDlgResource
.GetFilterArray();
1951 setGroupName( C2U("LoadSave"), rFilterArray
.GetString(0) );
1952 nGroup
= AddGroup( rFilterArray
.GetString(0), 0, 0, SID_FILTER_DLG
);
1953 for ( i
= 1; i
< rFilterArray
.Count(); ++i
)
1955 nPageId
= (sal_uInt16
)rFilterArray
.GetValue(i
);
1956 if ( !lcl_isOptionHidden( nPageId
, aOptionsDlgOpt
) )
1957 AddTabPage( nPageId
, rFilterArray
.GetString(i
), nGroup
);
1962 SvtLanguageOptions aLanguageOptions
;
1963 if ( !lcl_isOptionHidden( SID_LANGUAGE_OPTIONS
, aOptionsDlgOpt
) )
1965 ResStringArray
& rLangArray
= aDlgResource
.GetLangArray();
1966 setGroupName( C2U("LanguageSettings"), rLangArray
.GetString(0) );
1967 nGroup
= AddGroup( rLangArray
.GetString(0), 0, 0, SID_LANGUAGE_OPTIONS
);
1968 for ( i
= 1; i
< rLangArray
.Count(); ++i
)
1970 nPageId
= (sal_uInt16
)rLangArray
.GetValue(i
);
1971 if ( lcl_isOptionHidden( nPageId
, aOptionsDlgOpt
) )
1973 if ( ( RID_SVXPAGE_JSEARCH_OPTIONS
!= nPageId
|| aLanguageOptions
.IsJapaneseFindEnabled() ) &&
1974 ( RID_SVXPAGE_ASIAN_LAYOUT
!= nPageId
|| aLanguageOptions
.IsAsianTypographyEnabled() ) &&
1975 ( RID_SVXPAGE_OPTIONS_CTL
!= nPageId
|| aLanguageOptions
.IsCTLFontEnabled() ) )
1976 AddTabPage( nPageId
, rLangArray
.GetString(i
), nGroup
);
1981 rtl::OUString aFactory
= getCurrentFactory_Impl( _xFrame
);
1982 rtl::OUString sTemp
= GetModuleIdentifier( comphelper::getProcessServiceFactory(), _xFrame
);
1983 DBG_ASSERT( sTemp
== aFactory
, "S H I T!!!" );
1985 // Writer and Writer/Web options
1986 sal_Bool bHasAnyFilter
= sal_False
;
1987 SvtModuleOptions aModuleOpt
;
1988 if ( aModuleOpt
.IsModuleInstalled( SvtModuleOptions::E_SWRITER
) )
1991 bHasAnyFilter
= sal_True
;
1992 ResStringArray
& rTextArray
= aDlgResource
.GetTextArray();
1993 if ( aFactory
.equalsAscii( "com.sun.star.text.TextDocument" )
1994 || aFactory
.equalsAscii( "com.sun.star.text.WebDocument" )
1995 || aFactory
.equalsAscii( "com.sun.star.text.GlobalDocument" ) )
1997 SfxModule
* pSwMod
= (*(SfxModule
**) GetAppData(SHL_WRITER
));
1998 if ( !lcl_isOptionHidden( SID_SW_EDITOPTIONS
, aOptionsDlgOpt
) )
2000 if ( aFactory
.equalsAscii( "com.sun.star.text.WebDocument" ) )
2001 setGroupName( C2U("WriterWeb"), rTextArray
.GetString(0) );
2003 setGroupName( C2U("Writer"), rTextArray
.GetString(0) );
2004 nGroup
= AddGroup(rTextArray
.GetString(0), pSwMod
, pSwMod
, SID_SW_EDITOPTIONS
);
2005 for ( i
= 1; i
< rTextArray
.Count(); ++i
)
2007 nPageId
= (sal_uInt16
)rTextArray
.GetValue(i
);
2008 if ( lcl_isOptionHidden( nPageId
, aOptionsDlgOpt
) )
2010 if ( ( RID_SW_TP_STD_FONT_CJK
!= nPageId
|| aLanguageOptions
.IsCJKFontEnabled() ) &&
2011 ( RID_SW_TP_STD_FONT_CTL
!= nPageId
|| aLanguageOptions
.IsCTLFontEnabled() ) &&
2012 ( RID_SW_TP_MAILCONFIG
!= nPageId
|| MailMergeCfg_Impl().IsEmailSupported() ) )
2013 AddTabPage( nPageId
, rTextArray
.GetString(i
), nGroup
);
2016 AddTabPage( RID_SW_TP_OPTTEST_PAGE
, String::CreateFromAscii("Interner Test"), nGroup
);
2021 if ( !lcl_isOptionHidden( SID_SW_ONLINEOPTIONS
, aOptionsDlgOpt
) )
2023 ResStringArray
& rHTMLArray
= aDlgResource
.GetHTMLArray();
2024 nGroup
= AddGroup(rHTMLArray
.GetString(0), pSwMod
, pSwMod
, SID_SW_ONLINEOPTIONS
);
2025 for( i
= 1; i
< rHTMLArray
.Count(); ++i
)
2027 nPageId
= (sal_uInt16
)rHTMLArray
.GetValue(i
);
2028 if ( !lcl_isOptionHidden( nPageId
, aOptionsDlgOpt
) )
2029 AddTabPage( nPageId
, rHTMLArray
.GetString(i
), nGroup
);
2032 AddTabPage( RID_SW_TP_OPTTEST_PAGE
, String::CreateFromAscii("Interner Test"), nGroup
);
2039 if ( aModuleOpt
.IsModuleInstalled( SvtModuleOptions::E_SCALC
) )
2041 bHasAnyFilter
= sal_True
;
2042 if ( aFactory
.equalsAscii( "com.sun.star.sheet.SpreadsheetDocument" ))
2044 if ( !lcl_isOptionHidden( SID_SC_EDITOPTIONS
, aOptionsDlgOpt
) )
2046 ResStringArray
& rCalcArray
= aDlgResource
.GetCalcArray();
2047 SfxModule
* pScMod
= ( *( SfxModule
** ) GetAppData( SHL_CALC
) );
2048 setGroupName( C2U("Calc"), rCalcArray
.GetString(0) );
2049 nGroup
= AddGroup( rCalcArray
.GetString( 0 ), pScMod
, pScMod
, SID_SC_EDITOPTIONS
);
2050 const sal_uInt16 nCount
= static_cast< const sal_uInt16
>( rCalcArray
.Count() );
2051 for ( i
= 1; i
< nCount
; ++i
)
2053 nPageId
= (sal_uInt16
)rCalcArray
.GetValue(i
);
2054 if ( lcl_isOptionHidden( nPageId
, aOptionsDlgOpt
) )
2056 // if( bCTL || nId != RID_OFA_TP_INTERNATIONAL )
2057 // #103755# if an international tabpage is need one day, this should be used again... ;-)
2058 if ( nPageId
!= RID_OFA_TP_INTERNATIONAL
)
2059 AddTabPage( nPageId
, rCalcArray
.GetString( i
), nGroup
);
2066 SfxModule
* pSdMod
= ( *( SfxModule
** ) GetAppData( SHL_DRAW
) );
2067 if ( aModuleOpt
.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS
) )
2069 bHasAnyFilter
= sal_True
;
2070 if ( aFactory
.equalsAscii( "com.sun.star.presentation.PresentationDocument" ))
2072 if ( !lcl_isOptionHidden( SID_SD_EDITOPTIONS
, aOptionsDlgOpt
) )
2074 ResStringArray
& rImpressArray
= aDlgResource
.GetImpressArray();
2075 setGroupName( C2U("Impress"), rImpressArray
.GetString(0) );
2076 nGroup
= AddGroup( rImpressArray
.GetString( 0 ), pSdMod
, pSdMod
, SID_SD_EDITOPTIONS
);
2077 const sal_Bool bCTL
= aLanguageOptions
.IsCTLFontEnabled();
2078 const sal_uInt16 nCount
= static_cast< const sal_uInt16
>( rImpressArray
.Count() );
2079 for ( i
= 1; i
< nCount
; ++i
)
2081 nPageId
= (sal_uInt16
)rImpressArray
.GetValue(i
);
2082 if ( lcl_isOptionHidden( nPageId
, aOptionsDlgOpt
) )
2084 if ( bCTL
|| nPageId
!= RID_OFA_TP_INTERNATIONAL_IMPR
)
2085 AddTabPage( nPageId
, rImpressArray
.GetString(i
), nGroup
);
2092 if ( aModuleOpt
.IsModuleInstalled( SvtModuleOptions::E_SDRAW
) )
2094 if ( aFactory
.equalsAscii( "com.sun.star.drawing.DrawingDocument" ))
2096 if ( !lcl_isOptionHidden( SID_SD_GRAPHIC_OPTIONS
, aOptionsDlgOpt
) )
2098 ResStringArray
& rDrawArray
= aDlgResource
.GetDrawArray();
2099 setGroupName( C2U("Draw"), rDrawArray
.GetString(0) );
2100 nGroup
= AddGroup( rDrawArray
.GetString( 0 ), pSdMod
, pSdMod
, SID_SD_GRAPHIC_OPTIONS
);
2101 const sal_Bool bCTL
= aLanguageOptions
.IsCTLFontEnabled();
2102 const sal_uInt16 nCount
= static_cast< const sal_uInt16
>( rDrawArray
.Count() );
2103 for ( i
= 1; i
< nCount
; ++i
)
2105 nPageId
= (sal_uInt16
)rDrawArray
.GetValue(i
);
2106 if ( lcl_isOptionHidden( nPageId
, aOptionsDlgOpt
) )
2108 if ( bCTL
|| nPageId
!= RID_OFA_TP_INTERNATIONAL_SD
)
2109 AddTabPage( nPageId
, rDrawArray
.GetString(i
), nGroup
);
2116 if ( aModuleOpt
.IsModuleInstalled( SvtModuleOptions::E_SMATH
) )
2118 if ( aFactory
.equalsAscii( "com.sun.star.formula.FormulaProperties" ))
2120 if ( !lcl_isOptionHidden( SID_SM_EDITOPTIONS
, aOptionsDlgOpt
) )
2122 ResStringArray
& rStarMathArray
= aDlgResource
.GetStarMathArray();
2123 SfxModule
* pSmMod
= (*(SfxModule
**) GetAppData(SHL_SM
));
2124 setGroupName( C2U("Math"), rStarMathArray
.GetString(0) );
2125 nGroup
= AddGroup(rStarMathArray
.GetString(0), pSmMod
, pSmMod
, SID_SM_EDITOPTIONS
);
2126 for ( i
= 1; i
< rStarMathArray
.Count(); ++i
)
2128 nPageId
= (sal_uInt16
)rStarMathArray
.GetValue(i
);
2129 if ( !lcl_isOptionHidden( nPageId
, aOptionsDlgOpt
) )
2130 AddTabPage( nPageId
, rStarMathArray
.GetString(i
), nGroup
);
2136 // Database - needed only if there is an application which integrates with databases
2137 if ( !lcl_isOptionHidden( SID_SB_STARBASEOPTIONS
, aOptionsDlgOpt
) &&
2138 ( aModuleOpt
.IsModuleInstalled( SvtModuleOptions::E_SDATABASE
)
2139 || aModuleOpt
.IsModuleInstalled( SvtModuleOptions::E_SWRITER
)
2140 || aModuleOpt
.IsModuleInstalled( SvtModuleOptions::E_SCALC
)
2143 ResStringArray
& rDSArray
= aDlgResource
.GetDatasourcesArray();
2144 setGroupName( C2U("Base"), rDSArray
.GetString(0) );
2145 nGroup
= AddGroup( rDSArray
.GetString(0), 0, NULL
, SID_SB_STARBASEOPTIONS
);
2146 for ( i
= 1; i
< rDSArray
.Count(); ++i
)
2148 nPageId
= (sal_uInt16
)rDSArray
.GetValue(i
);
2149 if ( !lcl_isOptionHidden( nPageId
, aOptionsDlgOpt
) )
2150 AddTabPage( nPageId
, rDSArray
.GetString(i
), nGroup
);
2154 // Chart options (always installed and active)
2155 if ( !lcl_isOptionHidden( SID_SCH_EDITOPTIONS
, aOptionsDlgOpt
) )
2157 ResStringArray
& rChartArray
= aDlgResource
.GetChartArray();
2158 setGroupName( C2U("Charts"), rChartArray
.GetString(0) );
2159 nGroup
= AddGroup( rChartArray
.GetString(0), 0, 0, SID_SCH_EDITOPTIONS
);
2160 for ( i
= 1; i
< rChartArray
.Count(); ++i
)
2162 nPageId
= (sal_uInt16
)rChartArray
.GetValue(i
);
2163 if ( !lcl_isOptionHidden( nPageId
, aOptionsDlgOpt
) )
2164 AddTabPage( nPageId
, rChartArray
.GetString(i
), nGroup
);
2169 if ( !lcl_isOptionHidden( SID_INET_DLG
, aOptionsDlgOpt
) )
2171 ResStringArray
& rInetArray
= aDlgResource
.GetInetArray();
2172 setGroupName( C2U("Internet"), rInetArray
.GetString(0) );
2173 nGroup
= AddGroup(rInetArray
.GetString(0), 0, 0, SID_INET_DLG
);
2175 for ( i
= 1; i
< rInetArray
.Count(); ++i
)
2177 nPageId
= (sal_uInt16
)rInetArray
.GetValue(i
);
2178 if ( lcl_isOptionHidden( nPageId
, aOptionsDlgOpt
) )
2181 // Disable E-mail tab-page on Windows
2182 if ( nPageId
== RID_SVXPAGE_INET_MAIL
)
2186 // Disable Mozilla Plug-in tab-page on Mac
2187 if ( nPageId
== RID_SVXPAGE_INET_MOZPLUGIN
)
2191 // Disable Mozilla Plug-in tab-page on Linux if we find a
2192 // globally installed plugin
2193 if ( nPageId
== RID_SVXPAGE_INET_MOZPLUGIN
) {
2196 bool bHaveSystemWidePlugin
= false;
2197 char mozpaths
[]="/usr/lib/mozilla/plugins/libnpsoplugin.so:/usr/lib/firefox/plugins/libnpsoplugin.so:/usr/lib/mozilla-firefox/plugins/libnpsoplugin.so:/usr/lib/iceweasel/plugins/libnpsoplugin.so:/usr/lib/iceape/plugins/libnpsoplugin.so:/usr/lib/browser-plugins/libnpsoplugin.so:/usr/lib64/browser-plugins/libnpsoplugin.so";
2199 p
= strtok(mozpaths
, ":");
2201 if (stat(p
, &sb
) != -1) {
2202 bHaveSystemWidePlugin
= true;
2205 p
= strtok(NULL
, ":");
2208 if (bHaveSystemWidePlugin
== true)
2212 AddTabPage( nPageId
, rInetArray
.GetString(i
), nGroup
);
2218 ActivateLastSelection();
2224 void MoveControl( Control
& _rCtrl
, long _nDeltaPixel
)
2226 Point
aPt( _rCtrl
.GetPosPixel() );
2227 aPt
.X() += _nDeltaPixel
;
2228 _rCtrl
.SetPosPixel( aPt
);
2232 void OfaTreeOptionsDialog::ResizeTreeLB( void )
2234 const long nMax
= aHiddenGB
.GetSizePixel().Width() * 42 / 100;
2235 // don't ask where 42 comes from... but it looks / feels ok ;-)
2236 long nDelta
= 50; // min.
2237 sal_uInt16 nDepth
= 0;
2238 const long nIndent0
= PixelToLogic( Size( 28, 0 ) ).Width();
2239 const long nIndent1
= PixelToLogic( Size( 52, 0 ) ).Width();
2241 SvTreeList
* pTreeList
= aTreeLB
.GetModel();
2242 DBG_ASSERT( pTreeList
, "-OfaTreeOptionsDialog::ResizeTreeLB(): no model, no cookies!" );
2244 SvListEntry
* pEntry
= pTreeList
->First();
2247 long n
= aTreeLB
.GetTextWidth( aTreeLB
.GetEntryText( static_cast< SvLBoxEntry
* >( pEntry
) ) );
2248 n
+= ( nDepth
== 0 )? nIndent0
: nIndent1
;
2253 pEntry
= pTreeList
->Next( pEntry
, &nDepth
);
2256 nDelta
= LogicToPixel( Size( nDelta
+ 3, 0 ) ).Width(); // + extra space [logic]
2257 nDelta
+= GetSettings().GetStyleSettings().GetScrollBarSize(); // + scroll bar, in case it's needed
2262 // starting resizing with this
2263 Size
aSize( GetSizePixel() );
2264 aSize
.Width() += nDelta
;
2265 SetSizePixel( aSize
);
2267 // resize treelistbox
2268 aSize
= aTreeLB
.GetSizePixel();
2269 aSize
.Width() += nDelta
;
2270 aTreeLB
.SetSizePixel( aSize
);
2272 // ... and move depending controls
2273 MoveControl( aOkPB
, nDelta
);
2274 MoveControl( aCancelPB
, nDelta
);
2275 MoveControl( aHelpPB
, nDelta
);
2276 MoveControl( aBackPB
, nDelta
);
2277 MoveControl( aHiddenGB
, nDelta
);
2278 MoveControl( aPageTitleFT
, nDelta
);
2279 MoveControl( aLine1FL
, nDelta
);
2280 MoveControl( aHelpFT
, nDelta
);
2281 MoveControl( aHelpImg
, nDelta
);
2284 bool isNodeActive( OptionsNode
* pNode
, Module
* pModule
)
2288 // Node for all modules actine?
2289 if ( pNode
->m_bAllModules
)
2292 // OOo-Nodes (Writer, Calc, Impress...) are active if node is already inserted
2293 if ( getGroupName( pNode
->m_sId
, false ).Len() > 0 )
2296 // no module -> not active
2300 // search node in active module
2301 if ( pModule
->m_bActive
)
2303 for ( sal_uInt32 j
= 0; j
< pModule
->m_aNodeList
.size(); ++j
)
2304 if ( pModule
->m_aNodeList
[j
]->m_sId
== pNode
->m_sId
)
2311 void OfaTreeOptionsDialog::LoadExtensionOptions( const rtl::OUString
& rExtensionId
)
2313 Module
* pModule
= NULL
;
2314 Reference
< XMultiServiceFactory
> xMSFac
= comphelper::getProcessServiceFactory();
2315 // open optionsdialog.xcu
2316 Reference
< XNameAccess
> xRoot(
2317 ::comphelper::ConfigurationHelper::openConfig(
2318 xMSFac
, C2U("org.openoffice.Office.OptionsDialog"),
2319 ::comphelper::ConfigurationHelper::E_READONLY
), UNO_QUERY
);
2320 DBG_ASSERT( xRoot
.is(), "OfaTreeOptionsDialog::LoadExtensionOptions(): no config" );
2321 // when called by Tools - Options then load nodes of active module
2322 if ( rExtensionId
.getLength() == 0 )
2323 pModule
= LoadModule( GetModuleIdentifier( xMSFac
, Reference
< XFrame
>() ), xRoot
);
2325 VectorOfNodes aNodeList
;
2326 LoadNodes( xRoot
, pModule
, rExtensionId
, aNodeList
);
2327 InsertNodes( aNodeList
);
2330 rtl::OUString
OfaTreeOptionsDialog::GetModuleIdentifier(
2331 const Reference
< XMultiServiceFactory
>& xMFac
, const Reference
< XFrame
>& rFrame
)
2333 rtl::OUString sModule
;
2334 Reference
< XFrame
> xCurrentFrame( rFrame
);
2335 Reference
< XModuleManager
> xModuleManager( xMFac
->createInstance(
2336 C2U("com.sun.star.frame.ModuleManager") ), UNO_QUERY
);
2338 if ( !xCurrentFrame
.is() )
2340 Reference
< XDesktop
> xDesktop( xMFac
->createInstance(
2341 C2U("com.sun.star.frame.Desktop") ), UNO_QUERY
);
2342 if ( xDesktop
.is() )
2343 xCurrentFrame
= xDesktop
->getCurrentFrame();
2346 if ( xCurrentFrame
.is() && xModuleManager
.is() )
2350 sModule
= xModuleManager
->identify( xCurrentFrame
);
2352 catch ( ::com::sun::star::frame::UnknownModuleException
& )
2354 DBG_WARNING( "OfaTreeOptionsDialog::GetModuleIdentifier(): unknown module" );
2356 catch ( Exception
& )
2358 DBG_ERRORFILE( "OfaTreeOptionsDialog::GetModuleIdentifier(): exception of XModuleManager::identify()" );
2364 Module
* OfaTreeOptionsDialog::LoadModule(
2365 const rtl::OUString
& rModuleIdentifier
, const Reference
< XNameAccess
>& xRoot
)
2367 Module
* pModule
= NULL
;
2368 Reference
< XNameAccess
> xSet
;
2370 if ( xRoot
->hasByName( C2U("Modules") ) )
2372 xRoot
->getByName( C2U("Modules") ) >>= xSet
;
2375 Sequence
< rtl::OUString
> seqNames
= xSet
->getElementNames();
2376 for ( int i
= 0; i
< seqNames
.getLength(); ++i
)
2378 rtl::OUString
sModule( seqNames
[i
] );
2379 if ( rModuleIdentifier
== sModule
)
2381 // current active module found
2382 pModule
= new Module( sModule
);
2383 pModule
->m_bActive
= true;
2385 Reference
< XNameAccess
> xModAccess
;
2386 xSet
->getByName( seqNames
[i
] ) >>= xModAccess
;
2387 if ( xModAccess
.is() )
2389 // load the nodes of this module
2390 Reference
< XNameAccess
> xNodeAccess
;
2391 xModAccess
->getByName( C2U("Nodes") ) >>= xNodeAccess
;
2392 if ( xNodeAccess
.is() )
2394 Sequence
< rtl::OUString
> xTemp
= xNodeAccess
->getElementNames();
2395 Reference
< XNameAccess
> xAccess
;
2396 sal_Int32 nIndex
= -1;
2397 for ( int x
= 0; x
< xTemp
.getLength(); ++x
)
2399 xNodeAccess
->getByName( xTemp
[x
] ) >>= xAccess
;
2402 xAccess
->getByName( C2U("Index") ) >>= nIndex
;
2404 // append nodes with index < 0
2405 pModule
->m_aNodeList
.push_back(
2406 new OrderedEntry( nIndex
, xTemp
[x
] ) );
2409 // search position of the node
2411 for ( ; y
< pModule
->m_aNodeList
.size(); ++y
)
2413 sal_Int32 nNodeIdx
= pModule
->m_aNodeList
[y
]->m_nIndex
;
2414 if ( nNodeIdx
< 0 || nNodeIdx
> nIndex
)
2417 // and insert the node on this position
2418 pModule
->m_aNodeList
.insert(
2419 pModule
->m_aNodeList
.begin() + y
,
2420 new OrderedEntry( nIndex
, xTemp
[x
] ) );
2433 void OfaTreeOptionsDialog::LoadNodes(
2434 const Reference
< XNameAccess
>& xRoot
, Module
* pModule
,
2435 const rtl::OUString
& rExtensionId
, VectorOfNodes
& rOutNodeList
)
2437 Reference
< XNameAccess
> xSet
;
2438 if ( xRoot
->hasByName( C2U("Nodes") ) )
2440 xRoot
->getByName( C2U("Nodes") ) >>= xSet
;
2443 VectorOfNodes aNodeList
;
2444 Sequence
< rtl::OUString
> seqNames
= xSet
->getElementNames();
2446 for ( int i
= 0; i
< seqNames
.getLength(); ++i
)
2448 String
sGroupName( seqNames
[i
] );
2449 Reference
< XNameAccess
> xNodeAccess
;
2450 xSet
->getByName( seqNames
[i
] ) >>= xNodeAccess
;
2452 if ( xNodeAccess
.is() )
2454 rtl::OUString sNodeId
, sLabel
, sPageURL
, sGroupId
;
2455 bool bAllModules
= false;
2456 sal_Int32 nGroupIndex
= 0;
2458 sNodeId
= seqNames
[i
];
2459 xNodeAccess
->getByName( C2U("Label") ) >>= sLabel
;
2460 xNodeAccess
->getByName( C2U("OptionsPage") ) >>= sPageURL
;
2461 xNodeAccess
->getByName( C2U("AllModules") ) >>= bAllModules
;
2462 xNodeAccess
->getByName( C2U("GroupId") ) >>= sGroupId
;
2463 xNodeAccess
->getByName( C2U("GroupIndex") ) >>= nGroupIndex
;
2465 if ( sLabel
.getLength() == 0 )
2466 sLabel
= sGroupName
;
2467 String sTemp
= getGroupName( sLabel
, rExtensionId
.getLength() > 0 );
2468 if ( sTemp
.Len() > 0 )
2470 OptionsNode
* pNode
=
2471 new OptionsNode( sNodeId
, sLabel
, sPageURL
, bAllModules
, sGroupId
, nGroupIndex
);
2473 if ( !rExtensionId
.getLength() && !isNodeActive( pNode
, pModule
) )
2479 Reference
< XNameAccess
> xLeavesSet
;
2480 xNodeAccess
->getByName( C2U( "Leaves" ) ) >>= xLeavesSet
;
2481 if ( xLeavesSet
.is() )
2483 Sequence
< rtl::OUString
> seqLeaves
= xLeavesSet
->getElementNames();
2484 for ( int j
= 0; j
< seqLeaves
.getLength(); ++j
)
2486 Reference
< XNameAccess
> xLeaveAccess
;
2487 xLeavesSet
->getByName( seqLeaves
[j
] ) >>= xLeaveAccess
;
2489 if ( xLeaveAccess
.is() )
2491 rtl::OUString sId
, sLeafLabel
, sEventHdl
, sLeafURL
, sLeafGrpId
;
2492 sal_Int32 nLeafGrpIdx
= 0;
2494 xLeaveAccess
->getByName( C2U("Id") ) >>= sId
;
2495 xLeaveAccess
->getByName( C2U("Label") ) >>= sLeafLabel
;
2496 xLeaveAccess
->getByName( C2U("OptionsPage") ) >>= sLeafURL
;
2497 xLeaveAccess
->getByName( C2U("EventHandlerService") ) >>= sEventHdl
;
2498 xLeaveAccess
->getByName( C2U("GroupId") ) >>= sLeafGrpId
;
2499 xLeaveAccess
->getByName( C2U("GroupIndex") ) >>= nLeafGrpIdx
;
2501 if ( !rExtensionId
.getLength() || sId
== rExtensionId
)
2503 OptionsLeaf
* pLeaf
= new OptionsLeaf(
2504 sId
, sLeafLabel
, sLeafURL
, sEventHdl
, sLeafGrpId
, nLeafGrpIdx
);
2506 if ( sLeafGrpId
.getLength() > 0 )
2508 bool bAlreadyOpened
= false;
2509 if ( pNode
->m_aGroupedLeaves
.size() > 0 )
2511 for ( sal_uInt32 k
= 0;
2512 k
< pNode
->m_aGroupedLeaves
.size(); ++k
)
2514 if ( pNode
->m_aGroupedLeaves
[k
].size() > 0 &&
2515 pNode
->m_aGroupedLeaves
[k
][0]->m_sGroupId
2519 for ( ; l
< pNode
->m_aGroupedLeaves
[k
].size(); ++l
)
2521 if ( pNode
->m_aGroupedLeaves
[k
][l
]->
2522 m_nGroupIndex
>= nLeafGrpIdx
)
2525 pNode
->m_aGroupedLeaves
[k
].insert(
2526 pNode
->m_aGroupedLeaves
[k
].begin() + l
, pLeaf
);
2527 bAlreadyOpened
= true;
2532 if ( !bAlreadyOpened
)
2534 VectorOfLeaves aGroupedLeaves
;
2535 aGroupedLeaves
.push_back( pLeaf
);
2536 pNode
->m_aGroupedLeaves
.push_back( aGroupedLeaves
);
2540 pNode
->m_aLeaves
.push_back(
2542 sId
, sLeafLabel
, sLeafURL
,
2543 sEventHdl
, sLeafGrpId
, nLeafGrpIdx
) );
2549 // do not insert nodes without leaves
2550 if ( pNode
->m_aLeaves
.size() > 0 || pNode
->m_aGroupedLeaves
.size() > 0 )
2552 pModule
? aNodeList
.push_back( pNode
) : rOutNodeList
.push_back( pNode
);
2557 if ( pModule
&& aNodeList
.size() > 0 )
2559 sal_uInt32 i
= 0, j
= 0;
2560 for ( ; i
< pModule
->m_aNodeList
.size(); ++i
)
2562 rtl::OUString sNodeId
= pModule
->m_aNodeList
[i
]->m_sId
;
2563 for ( j
= 0; j
< aNodeList
.size(); ++j
)
2565 OptionsNode
* pNode
= aNodeList
[j
];
2566 if ( pNode
->m_sId
== sNodeId
)
2568 rOutNodeList
.push_back( pNode
);
2569 aNodeList
.erase( aNodeList
.begin() + j
);
2575 for ( i
= 0; i
< aNodeList
.size(); ++i
)
2576 rOutNodeList
.push_back( aNodeList
[i
] );
2582 sal_uInt16
lcl_getGroupId( const rtl::OUString
& rGroupName
, const SvTreeListBox
& rTreeLB
)
2584 String
sGroupName( rGroupName
);
2585 sal_uInt16 nRet
= 0;
2586 SvLBoxEntry
* pEntry
= rTreeLB
.First();
2589 if ( !rTreeLB
.GetParent( pEntry
) )
2591 String
sTemp( rTreeLB
.GetEntryText( pEntry
) );
2592 if ( sTemp
== sGroupName
)
2596 pEntry
= rTreeLB
.Next( pEntry
);
2602 void lcl_insertLeaf(
2603 OfaTreeOptionsDialog
* pDlg
, OptionsNode
* pNode
, OptionsLeaf
* pLeaf
, const SvTreeListBox
& rTreeLB
)
2605 sal_uInt16 nGrpId
= lcl_getGroupId( pNode
->m_sLabel
, rTreeLB
);
2606 if ( USHRT_MAX
== nGrpId
)
2608 sal_uInt16 nNodeGrpId
= getGroupNodeId( pNode
->m_sId
);
2609 nGrpId
= pDlg
->AddGroup( pNode
->m_sLabel
, NULL
, NULL
, nNodeGrpId
);
2610 if ( pNode
->m_sPageURL
.getLength() > 0 )
2612 SvLBoxEntry
* pGrpEntry
= rTreeLB
.GetEntry( 0, nGrpId
);
2613 DBG_ASSERT( pGrpEntry
, "OfaTreeOptionsDialog::InsertNodes(): no group" );
2616 OptionsGroupInfo
* pGrpInfo
=
2617 static_cast<OptionsGroupInfo
*>(pGrpEntry
->GetUserData());
2618 pGrpInfo
->m_sPageURL
= pNode
->m_sPageURL
;
2622 OptionsPageInfo
* pInfo
= pDlg
->AddTabPage( 0, pLeaf
->m_sLabel
, nGrpId
);
2623 pInfo
->m_sPageURL
= pLeaf
->m_sPageURL
;
2624 pInfo
->m_sEventHdl
= pLeaf
->m_sEventHdl
;
2627 void OfaTreeOptionsDialog::InsertNodes( const VectorOfNodes
& rNodeList
)
2629 for ( sal_uInt32 i
= 0; i
< rNodeList
.size(); ++i
)
2631 OptionsNode
* pNode
= rNodeList
[i
];
2633 if ( pNode
->m_aLeaves
.size() > 0 || pNode
->m_aGroupedLeaves
.size() > 0 )
2636 for ( ; j
< pNode
->m_aGroupedLeaves
.size(); ++j
)
2638 for ( sal_uInt32 k
= 0; k
< pNode
->m_aGroupedLeaves
[j
].size(); ++k
)
2640 OptionsLeaf
* pLeaf
= pNode
->m_aGroupedLeaves
[j
][k
];
2641 lcl_insertLeaf( this, pNode
, pLeaf
, aTreeLB
);
2645 for ( j
= 0; j
< pNode
->m_aLeaves
.size(); ++j
)
2647 OptionsLeaf
* pLeaf
= pNode
->m_aLeaves
[j
];
2648 lcl_insertLeaf( this, pNode
, pLeaf
, aTreeLB
);
2654 short OfaTreeOptionsDialog::Execute()
2656 ::std::auto_ptr
< SvxDicListChgClamp
> pClamp
;
2657 if ( !bIsFromExtensionManager
)
2659 // collect all DictionaryList Events while the dialog is executed
2660 Reference
<com::sun::star::linguistic2::XDictionaryList
> xDictionaryList(SvxGetDictionaryList());
2661 pClamp
= ::std::auto_ptr
< SvxDicListChgClamp
>( new SvxDicListChgClamp( xDictionaryList
) );
2663 short nRet
= SfxModalDialog::Execute();
2665 if( RET_OK
== nRet
)
2668 if( GetColorTable() )
2670 GetColorTable()->Save();
2672 // notify current viewframe it it uses the same color table
2673 if ( SfxViewFrame::Current() && SfxViewFrame::Current()->GetDispatcher() )
2675 const OfaPtrItem
* pPtr
= (const OfaPtrItem
*)SfxViewFrame::Current()->GetDispatcher()->Execute( SID_GET_COLORTABLE
, SFX_CALLMODE_SYNCHRON
);
2678 XColorTable
* _pColorTab
= (XColorTable
*)pPtr
->GetValue();
2681 _pColorTab
->GetPath() == GetColorTable()->GetPath() &&
2682 _pColorTab
->GetName() == GetColorTable()->GetName() )
2683 SfxObjectShell::Current()->PutItem( SvxColorTableItem( GetColorTable(), SID_COLOR_TABLE
) );
2688 utl::ConfigManager::GetConfigManager()->StoreConfigItems();
2694 // class ExtensionsTabPage -----------------------------------------------
2696 ExtensionsTabPage::ExtensionsTabPage(
2697 Window
* pParent
, WinBits nStyle
, const rtl::OUString
& rPageURL
,
2698 const rtl::OUString
& rEvtHdl
, const Reference
< awt::XContainerWindowProvider
>& rProvider
) :
2700 TabPage( pParent
, nStyle
),
2702 m_sPageURL ( rPageURL
),
2703 m_sEventHdl ( rEvtHdl
),
2704 m_xWinProvider ( rProvider
),
2705 m_bIsWindowHidden ( false )
2710 // -----------------------------------------------------------------------
2712 ExtensionsTabPage::~ExtensionsTabPage()
2718 // -----------------------------------------------------------------------
2720 void ExtensionsTabPage::CreateDialogWithHandler()
2724 bool bWithHandler
= ( m_sEventHdl
.getLength() > 0 );
2727 Reference
< XMultiServiceFactory
> xFactory( ::comphelper::getProcessServiceFactory() );
2728 m_xEventHdl
= Reference
< awt::XContainerWindowEventHandler
>(
2729 xFactory
->createInstance( m_sEventHdl
), UNO_QUERY
);
2732 if ( !bWithHandler
|| m_xEventHdl
.is() )
2734 SetStyle( GetStyle() | WB_DIALOGCONTROL
| WB_CHILDDLGCTRL
);
2735 Reference
< awt::XWindowPeer
> xParent( VCLUnoHelper::GetInterface( this ), UNO_QUERY
);
2736 m_xPage
= Reference
< awt::XWindow
>(
2737 m_xWinProvider
->createContainerWindow(
2738 m_sPageURL
, rtl::OUString(), xParent
, m_xEventHdl
), UNO_QUERY
);
2740 Reference
< awt::XControl
> xPageControl( m_xPage
, UNO_QUERY
);
2741 if ( xPageControl
.is() )
2743 Reference
< awt::XWindowPeer
> xWinPeer( xPageControl
->getPeer() );
2744 if ( xWinPeer
.is() )
2746 Window
* pWindow
= VCLUnoHelper::GetWindow( xWinPeer
);
2748 pWindow
->SetStyle( pWindow
->GetStyle() | WB_DIALOGCONTROL
| WB_CHILDDLGCTRL
);
2753 catch ( ::com::sun::star::lang::IllegalArgumentException
& )
2755 DBG_ERRORFILE( "ExtensionsTabPage::CreateDialogWithHandler(): illegal argument" );
2757 catch ( Exception
& )
2759 DBG_ERRORFILE( "ExtensionsTabPage::CreateDialogWithHandler(): exception of XDialogProvider2::createDialogWithHandler()" );
2763 // -----------------------------------------------------------------------
2765 sal_Bool
ExtensionsTabPage::DispatchAction( const rtl::OUString
& rAction
)
2767 sal_Bool bRet
= sal_False
;
2768 if ( m_xEventHdl
.is() )
2772 bRet
= m_xEventHdl
->callHandlerMethod( m_xPage
, makeAny( rAction
), C2U("external_event") );
2774 catch ( Exception
& )
2776 DBG_ERRORFILE( "ExtensionsTabPage::DispatchAction(): exception of XDialogEventHandler::callHandlerMethod()" );
2782 // -----------------------------------------------------------------------
2784 void ExtensionsTabPage::ActivatePage()
2786 TabPage::ActivatePage();
2788 if ( !m_xPage
.is() )
2790 CreateDialogWithHandler();
2794 Point aPos
= Point();
2795 Size aSize
= GetSizePixel();
2796 m_xPage
->setPosSize( aPos
.X() + 1, aPos
.Y() + 1,
2797 aSize
.Width() - 2, aSize
.Height() - 2, awt::PosSize::POSSIZE
);
2798 if ( m_sEventHdl
.getLength() > 0 )
2799 DispatchAction( C2U("initialize") );
2805 m_xPage
->setVisible( sal_True
);
2806 m_bIsWindowHidden
= false;
2810 // -----------------------------------------------------------------------
2812 void ExtensionsTabPage::DeactivatePage()
2814 TabPage::DeactivatePage();
2817 m_xPage
->setVisible( sal_False
);
2820 // -----------------------------------------------------------------------
2822 void ExtensionsTabPage::ResetPage()
2824 DispatchAction( C2U("back") );
2828 // -----------------------------------------------------------------------
2830 void ExtensionsTabPage::SavePage()
2832 DispatchAction( C2U("ok") );