Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "cuires.hrc"
21 : #include "helpid.hrc"
22 : #include "treeopt.hrc"
23 :
24 : #include <svx/dialogs.hrc>
25 :
26 : #include "cfgchart.hxx"
27 : #include "connpoolconfig.hxx"
28 : #include "connpooloptions.hxx"
29 : #include "cuioptgenrl.hxx"
30 : #include "cuitabarea.hxx"
31 : #include "dbregister.hxx"
32 : #include "dbregisterednamesconfig.hxx"
33 : #include "dialmgr.hxx"
34 : #include "fontsubs.hxx"
35 : #include "optaboutconfig.hxx"
36 : #include "optaccessibility.hxx"
37 : #include "optasian.hxx"
38 : #include "optchart.hxx"
39 : #include "optcolor.hxx"
40 : #include "optctl.hxx"
41 : #include "optfltr.hxx"
42 : #include "optgdlg.hxx"
43 : #include "opthtml.hxx"
44 : #include "optinet2.hxx"
45 : #include "optjava.hxx"
46 : #include "optjsearch.hxx"
47 : #include "optlingu.hxx"
48 : #include "optmemory.hxx"
49 : #include "optpath.hxx"
50 : #include "optsave.hxx"
51 : #include "optupdt.hxx"
52 : #include "personalization.hxx"
53 : #include "treeopt.hxx"
54 : #include "optbasic.hxx"
55 :
56 : #include <com/sun/star/awt/XContainerWindowEventHandler.hpp>
57 : #include <com/sun/star/awt/ContainerWindowProvider.hpp>
58 : #include <com/sun/star/awt/XControl.hpp>
59 : #include <com/sun/star/awt/PosSize.hpp>
60 : #include <com/sun/star/frame/Desktop.hpp>
61 : #include <com/sun/star/frame/ModuleManager.hpp>
62 : #include <com/sun/star/loader/CannotActivateFactoryException.hpp>
63 : #include <com/sun/star/linguistic2/LinguProperties.hpp>
64 : #include <com/sun/star/util/theMacroExpander.hpp>
65 : #include <com/sun/star/setup/UpdateCheck.hpp>
66 : #include <comphelper/processfactory.hxx>
67 : #include <editeng/langitem.hxx>
68 : #include <editeng/optitems.hxx>
69 : #include <editeng/unolingu.hxx>
70 : #include <linguistic/misc.hxx>
71 : #include <officecfg/Office/OptionsDialog.hxx>
72 : #include <osl/module.hxx>
73 : #include <osl/process.h>
74 : #include <rtl/bootstrap.hxx>
75 : #include <rtl/uri.hxx>
76 : #include <sfx2/app.hxx>
77 : #include <sfx2/dispatch.hxx>
78 : #include <sfx2/module.hxx>
79 : #include <sfx2/printopt.hxx>
80 : #include <sfx2/shell.hxx>
81 : #include <sfx2/tplpitem.hxx>
82 : #include <sfx2/viewsh.hxx>
83 : #include <svl/languageoptions.hxx>
84 : #include <svtools/helpopt.hxx>
85 : #include <svx/drawitem.hxx>
86 : #include <svx/xtable.hxx>
87 : #include <svx/xpool.hxx>
88 : #include <toolkit/helper/vclunohelper.hxx>
89 : #include <tools/shl.hxx>
90 : #include <tools/urlobj.hxx>
91 : #include <unotools/linguprops.hxx>
92 : #include <unotools/misccfg.hxx>
93 : #include <unotools/moduleoptions.hxx>
94 : #include <unotools/optionsdlg.hxx>
95 : #include <unotools/viewoptions.hxx>
96 : #include <vcl/help.hxx>
97 : #include <vcl/layout.hxx>
98 : #include <vcl/msgbox.hxx>
99 : #include <vcl/waitobj.hxx>
100 : #include <vcl/settings.hxx>
101 : #include "svtools/treelistentry.hxx"
102 :
103 : #ifdef LINUX
104 : #include <sys/stat.h>
105 : #endif
106 :
107 : #include <boost/scoped_ptr.hpp>
108 :
109 : using namespace ::com::sun::star;
110 : using namespace ::com::sun::star::beans;
111 : using namespace ::com::sun::star::container;
112 : using namespace ::com::sun::star::frame;
113 : using namespace ::com::sun::star::lang;
114 : using namespace ::com::sun::star::linguistic2;
115 : using namespace ::com::sun::star::uno;
116 : using namespace ::com::sun::star::util;
117 :
118 : #define EXPAND_PROTOCOL "vnd.sun.star.expand:"
119 :
120 : LastPageSaver* OfaTreeOptionsDialog::pLastPageSaver = NULL;
121 :
122 : // some stuff for easier changes for SvtViewOptions
123 : static const sal_Char* pViewOptDataName = "page data";
124 : #define VIEWOPT_DATANAME OUString::createFromAscii( pViewOptDataName )
125 :
126 : static XOutdevItemPool* mpStaticXOutdevItemPool = 0L;
127 :
128 0 : static inline void SetViewOptUserItem( SvtViewOptions& rOpt, const OUString& rData )
129 : {
130 0 : rOpt.SetUserItem( VIEWOPT_DATANAME, makeAny( OUString( rData ) ) );
131 0 : }
132 :
133 0 : static inline OUString GetViewOptUserItem( const SvtViewOptions& rOpt )
134 : {
135 0 : Any aAny( rOpt.GetUserItem( VIEWOPT_DATANAME ) );
136 0 : OUString aUserData;
137 0 : aAny >>= aUserData;
138 :
139 0 : return aUserData;
140 : }
141 :
142 0 : struct ModuleToGroupNameMap_Impl
143 : {
144 : const char* m_pModule;
145 : OUString m_sGroupName;
146 : sal_uInt16 m_nNodeId;
147 : };
148 :
149 : static OfaPageResource* pPageRes = NULL;
150 :
151 0 : static ModuleToGroupNameMap_Impl ModuleMap[] =
152 : {
153 : { "ProductName", OUString(), SID_GENERAL_OPTIONS },
154 : { "LanguageSettings", OUString(), SID_LANGUAGE_OPTIONS },
155 : { "Internet", OUString(), SID_INET_DLG },
156 : { "LoadSave", OUString(), SID_FILTER_DLG },
157 : { "Writer", OUString(), SID_SW_EDITOPTIONS },
158 : { "WriterWeb", OUString(), SID_SW_ONLINEOPTIONS },
159 : { "Math", OUString(), SID_SM_EDITOPTIONS },
160 : { "Calc", OUString(), SID_SC_EDITOPTIONS },
161 : { "Impress", OUString(), SID_SD_EDITOPTIONS },
162 : { "Draw", OUString(), SID_SD_GRAPHIC_OPTIONS },
163 : { "Charts", OUString(), SID_SCH_EDITOPTIONS },
164 : { "Base", OUString(), SID_SB_STARBASEOPTIONS },
165 :
166 : { NULL, OUString(), 0xFFFF }
167 0 : };
168 :
169 0 : static void setGroupName( const OUString& rModule, const OUString& rGroupName )
170 : {
171 0 : sal_uInt16 nIndex = 0;
172 0 : while ( ModuleMap[ nIndex ].m_pModule )
173 : {
174 : OUString sTemp =
175 0 : OUString::createFromAscii( ModuleMap[ nIndex ].m_pModule );
176 0 : if ( sTemp == rModule )
177 : {
178 0 : ModuleMap[ nIndex ].m_sGroupName = rGroupName;
179 0 : break;
180 : }
181 0 : ++nIndex;
182 0 : }
183 0 : }
184 :
185 0 : static OUString getGroupName( const OUString& rModule, bool bForced )
186 : {
187 0 : OUString sGroupName;
188 0 : sal_uInt16 nIndex = 0;
189 0 : while ( ModuleMap[ nIndex ].m_pModule )
190 : {
191 : OUString sTemp =
192 0 : OUString::createFromAscii( ModuleMap[ nIndex ].m_pModule );
193 0 : if ( sTemp == rModule )
194 : {
195 0 : sGroupName = ModuleMap[ nIndex ].m_sGroupName;
196 0 : break;
197 : }
198 0 : ++nIndex;
199 0 : }
200 :
201 0 : if ( sGroupName.isEmpty() && bForced )
202 : {
203 0 : if ( !pPageRes )
204 0 : pPageRes = new OfaPageResource;
205 :
206 0 : if ( rModule == "Writer" )
207 0 : sGroupName = pPageRes->GetTextArray().GetString(0);
208 0 : else if ( rModule == "WriterWeb" )
209 0 : sGroupName = pPageRes->GetHTMLArray().GetString(0);
210 0 : else if ( rModule == "Calc" )
211 0 : sGroupName = pPageRes->GetCalcArray().GetString(0);
212 0 : else if ( rModule == "Impress" )
213 0 : sGroupName = pPageRes->GetImpressArray().GetString(0);
214 0 : else if ( rModule == "Draw" )
215 0 : sGroupName = pPageRes->GetDrawArray().GetString(0);
216 0 : else if ( rModule == "Math" )
217 0 : sGroupName = pPageRes->GetStarMathArray().GetString(0);
218 0 : else if ( rModule == "Base" )
219 0 : sGroupName = pPageRes->GetDatasourcesArray().GetString(0);
220 : }
221 0 : return sGroupName;
222 : }
223 :
224 0 : static void deleteGroupNames()
225 : {
226 0 : sal_uInt16 nIndex = 0;
227 0 : while ( ModuleMap[ nIndex ].m_pModule )
228 0 : ModuleMap[ nIndex++ ].m_sGroupName = OUString();
229 0 : }
230 :
231 0 : static sal_uInt16 getGroupNodeId( const OUString& rModule )
232 : {
233 0 : sal_uInt16 nNodeId = 0xFFFF, nIndex = 0;
234 0 : while ( ModuleMap[ nIndex ].m_pModule )
235 : {
236 : OUString sTemp =
237 0 : OUString::createFromAscii( ModuleMap[ nIndex ].m_pModule );
238 0 : if ( sTemp == rModule )
239 : {
240 0 : nNodeId = ModuleMap[ nIndex ].m_nNodeId;
241 0 : break;
242 : }
243 0 : ++nIndex;
244 0 : }
245 :
246 0 : return nNodeId;
247 : }
248 :
249 : class MailMergeCfg_Impl : public utl::ConfigItem
250 : {
251 : friend class SvxEMailTabPage;
252 : // variables
253 : sal_Bool bIsEmailSupported;
254 :
255 : public:
256 : MailMergeCfg_Impl();
257 : virtual ~MailMergeCfg_Impl();
258 :
259 : virtual void Commit() SAL_OVERRIDE;
260 : virtual void Notify( const com::sun::star::uno::Sequence< OUString >& _rPropertyNames) SAL_OVERRIDE;
261 :
262 0 : sal_Bool IsEmailSupported() const {return bIsEmailSupported;}
263 :
264 : };
265 :
266 0 : MailMergeCfg_Impl::MailMergeCfg_Impl() :
267 : utl::ConfigItem("Office.Writer/MailMergeWizard"),
268 0 : bIsEmailSupported(sal_False)
269 : {
270 0 : Sequence<OUString> aNames(1);
271 0 : aNames.getArray()[0] = "EMailSupported";
272 0 : const Sequence< Any > aValues = GetProperties(aNames);
273 0 : const Any* pValues = aValues.getConstArray();
274 0 : if(aValues.getLength() && pValues[0].hasValue())
275 0 : pValues[0] >>= bIsEmailSupported;
276 0 : }
277 :
278 0 : MailMergeCfg_Impl::~MailMergeCfg_Impl()
279 : {
280 0 : }
281 : /* -------------------------------------------------------------------------*/
282 0 : void MailMergeCfg_Impl::Commit()
283 : {
284 0 : }
285 :
286 0 : void MailMergeCfg_Impl::Notify( const com::sun::star::uno::Sequence< OUString >& )
287 : {
288 0 : }
289 :
290 : //typedef SfxTabPage* (*FNCreateTabPage)( Window *pParent, const SfxItemSet &rAttrSet );
291 0 : SfxTabPage* CreateGeneralTabPage( sal_uInt16 nId, Window* pParent, const SfxItemSet& rSet )
292 : {
293 0 : CreateTabPage fnCreate = 0;
294 0 : switch(nId)
295 : {
296 0 : case RID_SFXPAGE_SAVE: fnCreate = &SvxSaveTabPage::Create; break;
297 0 : case RID_SFXPAGE_PATH: fnCreate = &SvxPathTabPage::Create; break;
298 0 : case RID_SFXPAGE_GENERAL: fnCreate = &SvxGeneralTabPage::Create; break;
299 0 : case RID_SFXPAGE_PRINTOPTIONS: fnCreate = &SfxCommonPrintOptionsTabPage::Create; break;
300 0 : case OFA_TP_LANGUAGES: fnCreate = &OfaLanguagesTabPage::Create; break;
301 0 : case RID_SFXPAGE_LINGU: fnCreate = &SvxLinguTabPage::Create; break;
302 0 : case RID_SVXPAGE_COLOR: fnCreate = &SvxColorTabPage::Create; break;
303 0 : case OFA_TP_VIEW: fnCreate = &OfaViewTabPage::Create; break;
304 0 : case OFA_TP_MISC: fnCreate = &OfaMiscTabPage::Create; break;
305 0 : case OFA_TP_MEMORY: fnCreate = &OfaMemoryOptionsPage::Create; break;
306 0 : case RID_SVXPAGE_ASIAN_LAYOUT: fnCreate = &SvxAsianLayoutPage::Create; break;
307 0 : case RID_SVX_FONT_SUBSTITUTION: fnCreate = &SvxFontSubstTabPage::Create; break;
308 0 : case RID_SVXPAGE_INET_PROXY: fnCreate = &SvxProxyTabPage::Create; break;
309 0 : case RID_SVXPAGE_INET_SECURITY: fnCreate = &SvxSecurityTabPage::Create; break;
310 0 : case RID_SVXPAGE_INET_MAIL: fnCreate = &SvxEMailTabPage::Create; break;
311 0 : case RID_SVXPAGE_PERSONALIZATION: fnCreate = &SvxPersonalizationTabPage::Create; break;
312 0 : case RID_SVXPAGE_COLORCONFIG: fnCreate = &SvxColorOptionsTabPage::Create; break;
313 0 : case RID_OFAPAGE_HTMLOPT: fnCreate = &OfaHtmlTabPage::Create; break;
314 0 : case SID_OPTFILTER_MSOFFICE: fnCreate = &OfaMSFilterTabPage::Create; break;
315 0 : case RID_OFAPAGE_MSFILTEROPT2: fnCreate = &OfaMSFilterTabPage2::Create; break;
316 0 : case RID_SVXPAGE_JSEARCH_OPTIONS: fnCreate = &SvxJSearchOptionsPage::Create ; break;
317 0 : case SID_SB_CONNECTIONPOOLING: fnCreate = &::offapp::ConnectionPoolOptionsPage::Create; break;
318 0 : case SID_SB_DBREGISTEROPTIONS: fnCreate = &::svx::DbRegistrationOptionsPage::Create; break;
319 0 : case RID_SVXPAGE_ACCESSIBILITYCONFIG: fnCreate = &SvxAccessibilityOptionsTabPage::Create; break;
320 0 : case RID_SVXPAGE_OPTIONS_CTL: fnCreate = &SvxCTLOptionsPage::Create ; break;
321 0 : case RID_SVXPAGE_INET_MOZPLUGIN: fnCreate = &MozPluginTabPage::Create; break;
322 0 : case RID_SVXPAGE_OPTIONS_JAVA: fnCreate = &SvxJavaOptionsPage::Create ; break;
323 0 : case RID_SVXPAGE_ONLINEUPDATE: fnCreate = &SvxOnlineUpdateTabPage::Create; break;
324 0 : case RID_OPTPAGE_CHART_DEFCOLORS: fnCreate = &SvxDefaultColorOptPage::Create; break;
325 : #ifndef DISABLE_SCRIPTING
326 0 : case RID_SVXPAGE_BASICIDE_OPTIONS: fnCreate = &SvxBasicIDEOptionsPage::Create; break;
327 : #endif
328 : }
329 :
330 0 : SfxTabPage* pRet = fnCreate ? (*fnCreate)( pParent, rSet ) : NULL;
331 0 : return pRet;
332 : }
333 :
334 : struct OptionsMapping_Impl
335 : {
336 : const char* m_pGroupName;
337 : const char* m_pPageName;
338 : sal_uInt16 m_nPageId;
339 : };
340 :
341 : static OptionsMapping_Impl const OptionsMap_Impl[] =
342 : {
343 : // GROUP PAGE PAGE-ID
344 : { "ProductName", NULL, SID_GENERAL_OPTIONS },
345 : { "ProductName", "UserData", RID_SFXPAGE_GENERAL },
346 : { "ProductName", "General", OFA_TP_MISC },
347 : { "ProductName", "Memory", OFA_TP_MEMORY },
348 : { "ProductName", "View", OFA_TP_VIEW },
349 : { "ProductName", "Print", RID_SFXPAGE_PRINTOPTIONS },
350 : { "ProductName", "Paths", RID_SFXPAGE_PATH },
351 : { "ProductName", "Colors", RID_SVXPAGE_COLOR },
352 : { "ProductName", "Fonts", RID_SVX_FONT_SUBSTITUTION },
353 : { "ProductName", "Security", RID_SVXPAGE_INET_SECURITY },
354 : { "ProductName", "Personalization", RID_SVXPAGE_PERSONALIZATION },
355 : { "ProductName", "Appearance", RID_SVXPAGE_COLORCONFIG },
356 : { "ProductName", "Accessibility", RID_SVXPAGE_ACCESSIBILITYCONFIG },
357 : { "ProductName", "Java", RID_SVXPAGE_OPTIONS_JAVA },
358 : { "ProductName", "BasicIDEOptions", RID_SVXPAGE_BASICIDE_OPTIONS },
359 : { "ProductName", "OnlineUpdate", RID_SVXPAGE_ONLINEUPDATE },
360 : { "LanguageSettings", NULL, SID_LANGUAGE_OPTIONS },
361 : { "LanguageSettings", "Languages", OFA_TP_LANGUAGES },
362 : { "LanguageSettings", "WritingAids", RID_SFXPAGE_LINGU },
363 : { "LanguageSettings", "SearchingInJapanese", RID_SVXPAGE_JSEARCH_OPTIONS },
364 : { "LanguageSettings", "AsianLayout", RID_SVXPAGE_ASIAN_LAYOUT },
365 : { "LanguageSettings", "ComplexTextLayout", RID_SVXPAGE_OPTIONS_CTL },
366 : { "Internet", NULL, SID_INET_DLG },
367 : { "Internet", "Proxy", RID_SVXPAGE_INET_PROXY },
368 : { "Internet", "Email", RID_SVXPAGE_INET_MAIL },
369 : { "Internet", "MozillaPlugin", RID_SVXPAGE_INET_MOZPLUGIN },
370 : { "LoadSave", NULL, SID_FILTER_DLG },
371 : { "LoadSave", "General", RID_SFXPAGE_SAVE },
372 : { "LoadSave", "VBAProperties", SID_OPTFILTER_MSOFFICE },
373 : { "LoadSave", "MicrosoftOffice", RID_OFAPAGE_MSFILTEROPT2 },
374 : { "LoadSave", "HTMLCompatibility", RID_OFAPAGE_HTMLOPT },
375 : { "Writer", NULL, SID_SW_EDITOPTIONS },
376 : { "Writer", "General", RID_SW_TP_OPTLOAD_PAGE },
377 : { "Writer", "View", RID_SW_TP_CONTENT_OPT },
378 : { "Writer", "FormattingAids", RID_SW_TP_OPTSHDWCRSR },
379 : { "Writer", "Grid", RID_SVXPAGE_GRID },
380 : { "Writer", "BasicFontsWestern", RID_SW_TP_STD_FONT },
381 : { "Writer", "BasicFontsAsian", RID_SW_TP_STD_FONT_CJK },
382 : { "Writer", "BasicFontsCTL", RID_SW_TP_STD_FONT_CTL },
383 : { "Writer", "Print", RID_SW_TP_OPTPRINT_PAGE },
384 : { "Writer", "Table", RID_SW_TP_OPTTABLE_PAGE },
385 : { "Writer", "Changes", RID_SW_TP_REDLINE_OPT },
386 : { "Writer", "Comparison", RID_SW_TP_COMPARISON_OPT },
387 : { "Writer", "Compatibility", RID_SW_TP_OPTCOMPATIBILITY_PAGE },
388 : { "Writer", "AutoCaption", RID_SW_TP_OPTCAPTION_PAGE },
389 : { "Writer", "MailMerge", RID_SW_TP_MAILCONFIG },
390 : { "WriterWeb", NULL, SID_SW_ONLINEOPTIONS },
391 : { "WriterWeb", "View", RID_SW_TP_HTML_CONTENT_OPT },
392 : { "WriterWeb", "FormattingAids", RID_SW_TP_HTML_OPTSHDWCRSR },
393 : { "WriterWeb", "Grid", RID_SW_TP_HTML_OPTGRID_PAGE },
394 : { "WriterWeb", "Print", RID_SW_TP_HTML_OPTPRINT_PAGE },
395 : { "WriterWeb", "Table", RID_SW_TP_HTML_OPTTABLE_PAGE },
396 : { "WriterWeb", "Background", RID_SW_TP_BACKGROUND },
397 : { "Math", NULL, SID_SM_EDITOPTIONS },
398 : { "Math", "Settings", SID_SM_TP_PRINTOPTIONS },
399 : { "Calc", NULL, SID_SC_EDITOPTIONS },
400 : { "Calc", "General", SID_SC_TP_LAYOUT },
401 : { "Calc", "View", SID_SC_TP_CONTENT },
402 : { "Calc", "Calculate", SID_SC_TP_CALC },
403 : { "Calc", "Formula", SID_SC_TP_FORMULA },
404 : { "Calc", "SortLists", SID_SC_TP_USERLISTS },
405 : { "Calc", "Changes", SID_SC_TP_CHANGES },
406 : { "Calc", "Compatibility", SID_SC_TP_COMPATIBILITY },
407 : { "Calc", "Grid", SID_SC_TP_GRID },
408 : { "Calc", "Print", RID_SC_TP_PRINT },
409 : { "Impress", NULL, SID_SD_EDITOPTIONS },
410 : { "Impress", "General", SID_SI_TP_MISC },
411 : { "Impress", "View", SID_SI_TP_CONTENTS },
412 : { "Impress", "Grid", SID_SI_TP_SNAP },
413 : { "Impress", "Print", SID_SI_TP_PRINT },
414 : { "Draw", NULL, SID_SD_GRAPHIC_OPTIONS },
415 : { "Draw", "General", SID_SD_TP_MISC },
416 : { "Draw", "View", SID_SD_TP_CONTENTS },
417 : { "Draw", "Grid", SID_SD_TP_SNAP },
418 : { "Draw", "Print", SID_SD_TP_PRINT },
419 : { "Charts", NULL, SID_SCH_EDITOPTIONS },
420 : { "Charts", "DefaultColors", RID_OPTPAGE_CHART_DEFCOLORS },
421 : { "Base", NULL, SID_SB_STARBASEOPTIONS },
422 : { "Base", "Connections", SID_SB_CONNECTIONPOOLING },
423 : { "Base", "Databases", SID_SB_DBREGISTEROPTIONS },
424 : { NULL, NULL, 0 }
425 : };
426 :
427 0 : static sal_Bool lcl_getStringFromID( sal_uInt16 _nPageId, OUString& _rGroupName, OUString& _rPageName )
428 : {
429 0 : sal_Bool bRet = sal_False;
430 :
431 0 : sal_uInt16 nIdx = 0;
432 0 : while ( OptionsMap_Impl[nIdx].m_pGroupName != NULL )
433 : {
434 0 : if ( _nPageId == OptionsMap_Impl[nIdx].m_nPageId )
435 : {
436 0 : bRet = sal_True;
437 0 : _rGroupName = OUString::createFromAscii( OptionsMap_Impl[nIdx].m_pGroupName );
438 0 : if ( OptionsMap_Impl[nIdx].m_pPageName != NULL )
439 0 : _rPageName = OUString::createFromAscii( OptionsMap_Impl[nIdx].m_pPageName );
440 0 : break;
441 : }
442 0 : ++nIdx;
443 : }
444 :
445 0 : return bRet;
446 : }
447 :
448 0 : static sal_Bool lcl_isOptionHidden( sal_uInt16 _nPageId, const SvtOptionsDialogOptions& _rOptOptions )
449 : {
450 0 : sal_Bool bIsHidden = sal_False;
451 0 : OUString sGroupName, sPageName;
452 0 : if ( lcl_getStringFromID( _nPageId, sGroupName, sPageName ) )
453 : {
454 0 : if ( sPageName.isEmpty() )
455 0 : bIsHidden = _rOptOptions.IsGroupHidden( sGroupName );
456 : else
457 0 : bIsHidden = _rOptOptions.IsPageHidden( sPageName, sGroupName );
458 : }
459 0 : return bIsHidden;
460 : }
461 :
462 0 : struct OptionsPageInfo
463 : {
464 : SfxTabPage* m_pPage;
465 : sal_uInt16 m_nPageId;
466 : OUString m_sPageURL;
467 : OUString m_sEventHdl;
468 : ExtensionsTabPage* m_pExtPage;
469 :
470 0 : OptionsPageInfo( sal_uInt16 nId ) : m_pPage( NULL ), m_nPageId( nId ), m_pExtPage( NULL ) {}
471 : };
472 :
473 : struct OptionsGroupInfo
474 : {
475 : SfxItemSet* m_pInItemSet;
476 : SfxItemSet* m_pOutItemSet;
477 : SfxShell* m_pShell; // used to create the page
478 : SfxModule* m_pModule; // used to create the ItemSet
479 : sal_uInt16 m_nDialogId; // Id of the former dialog
480 : sal_Bool m_bLoadError; // load fails?
481 : OUString m_sPageURL;
482 : ExtensionsTabPage* m_pExtPage;
483 :
484 0 : OptionsGroupInfo( SfxShell* pSh, SfxModule* pMod, sal_uInt16 nId ) :
485 : m_pInItemSet( NULL ), m_pOutItemSet( NULL ), m_pShell( pSh ),
486 : m_pModule( pMod ), m_nDialogId( nId ), m_bLoadError( sal_False ),
487 0 : m_sPageURL( OUString() ), m_pExtPage( NULL ) {}
488 0 : ~OptionsGroupInfo() { delete m_pInItemSet; delete m_pOutItemSet; }
489 : };
490 :
491 :
492 :
493 : #define INI_LIST() \
494 : pCurrentPageEntry ( NULL ),\
495 : aOkPB ( this, CUI_RES( PB_OK ) ),\
496 : aCancelPB ( this, CUI_RES( PB_CANCEL ) ),\
497 : aHelpPB ( this, CUI_RES( PB_HELP ) ),\
498 : aBackPB ( this, CUI_RES( PB_BACK ) ),\
499 : aSeparatorFL ( this, CUI_RES( FL_SEPARATOR ) ),\
500 : aTreeLB ( this, CUI_RES( TLB_PAGES ) ),\
501 : sTitle ( GetText() ),\
502 : sNotLoadedError ( CUI_RES( ST_LOAD_ERROR ) ),\
503 : pColorPageItemSet ( NULL ),\
504 : mpColorPage ( NULL ),\
505 : bForgetSelection ( sal_False ),\
506 : bIsFromExtensionManager( false ), \
507 : bIsForSetDocumentLanguage( false )
508 :
509 : // Ctor() with Frame -----------------------------------------------------
510 : using namespace ::com::sun::star;
511 0 : OfaTreeOptionsDialog::OfaTreeOptionsDialog(
512 : Window* pParent,
513 : const Reference< XFrame >& _xFrame,
514 : bool bActivateLastSelection ) :
515 :
516 0 : SfxModalDialog( pParent, CUI_RES( RID_OFADLG_OPTIONS_TREE ) ),
517 0 : INI_LIST()
518 : {
519 0 : FreeResource();
520 :
521 0 : InitTreeAndHandler();
522 0 : Initialize( _xFrame );
523 0 : LoadExtensionOptions( OUString() );
524 0 : ResizeTreeLB();
525 0 : if (bActivateLastSelection)
526 0 : ActivateLastSelection();
527 :
528 0 : aTreeLB.SetAccessibleName(GetDisplayText());
529 0 : }
530 :
531 : // Ctor() with ExtensionId -----------------------------------------------
532 :
533 0 : OfaTreeOptionsDialog::OfaTreeOptionsDialog( Window* pParent, const OUString& rExtensionId ) :
534 :
535 0 : SfxModalDialog( pParent, CUI_RES( RID_OFADLG_OPTIONS_TREE ) ),
536 0 : INI_LIST()
537 : {
538 0 : FreeResource();
539 :
540 0 : bIsFromExtensionManager = ( !rExtensionId.isEmpty() );
541 0 : InitTreeAndHandler();
542 0 : LoadExtensionOptions( rExtensionId );
543 0 : ResizeTreeLB();
544 0 : ActivateLastSelection();
545 0 : }
546 :
547 0 : OfaTreeOptionsDialog::~OfaTreeOptionsDialog()
548 : {
549 0 : maTreeLayoutTimer.Stop();
550 0 : pCurrentPageEntry = NULL;
551 0 : SvTreeListEntry* pEntry = aTreeLB.First();
552 : // first children
553 0 : while(pEntry)
554 : {
555 : // if Child (has parent), then OptionsPageInfo
556 0 : if(aTreeLB.GetParent(pEntry))
557 : {
558 0 : OptionsPageInfo *pPageInfo = (OptionsPageInfo *)pEntry->GetUserData();
559 0 : if(pPageInfo->m_pPage)
560 : {
561 0 : pPageInfo->m_pPage->FillUserData();
562 0 : OUString aPageData(pPageInfo->m_pPage->GetUserData());
563 0 : if ( !aPageData.isEmpty() )
564 : {
565 0 : SvtViewOptions aTabPageOpt( E_TABPAGE, OUString::number( pPageInfo->m_nPageId) );
566 0 : SetViewOptUserItem( aTabPageOpt, aPageData );
567 : }
568 0 : delete pPageInfo->m_pPage;
569 : }
570 :
571 0 : if (pPageInfo->m_nPageId == RID_SFXPAGE_LINGU)
572 : {
573 : // write personal dictionaries
574 0 : Reference< XSearchableDictionaryList > xDicList( SvxGetDictionaryList() );
575 0 : if (xDicList.is())
576 : {
577 0 : linguistic::SaveDictionaries( xDicList );
578 0 : }
579 : }
580 :
581 0 : if( pPageInfo->m_pExtPage )
582 0 : delete pPageInfo->m_pExtPage;
583 :
584 0 : delete pPageInfo;
585 : }
586 0 : pEntry = aTreeLB.Next(pEntry);
587 : }
588 :
589 : // and parents
590 0 : pEntry = aTreeLB.First();
591 0 : while(pEntry)
592 : {
593 0 : if(!aTreeLB.GetParent(pEntry))
594 : {
595 0 : OptionsGroupInfo* pGroupInfo = (OptionsGroupInfo*)pEntry->GetUserData();
596 0 : if ( pGroupInfo && pGroupInfo->m_pExtPage )
597 0 : delete pGroupInfo->m_pExtPage;
598 0 : delete pGroupInfo;
599 : }
600 0 : pEntry = aTreeLB.Next(pEntry);
601 : }
602 0 : delete pColorPageItemSet;
603 0 : deleteGroupNames();
604 0 : }
605 :
606 0 : OptionsPageInfo* OfaTreeOptionsDialog::AddTabPage(
607 : sal_uInt16 nId, const OUString& rPageName, sal_uInt16 nGroup )
608 : {
609 0 : OptionsPageInfo* pPageInfo = new OptionsPageInfo( nId );
610 0 : SvTreeListEntry* pParent = aTreeLB.GetEntry( 0, nGroup );
611 : DBG_ASSERT( pParent, "OfaTreeOptionsDialog::AddTabPage(): no group found" );
612 0 : SvTreeListEntry* pEntry = aTreeLB.InsertEntry( rPageName, pParent );
613 0 : pEntry->SetUserData( pPageInfo );
614 0 : return pPageInfo;
615 : }
616 :
617 : // the ItemSet* is passed on to the dialog's ownership
618 0 : sal_uInt16 OfaTreeOptionsDialog::AddGroup(const OUString& rGroupName,
619 : SfxShell* pCreateShell,
620 : SfxModule* pCreateModule,
621 : sal_uInt16 nDialogId )
622 : {
623 0 : SvTreeListEntry* pEntry = aTreeLB.InsertEntry(rGroupName);
624 : OptionsGroupInfo* pInfo =
625 0 : new OptionsGroupInfo( pCreateShell, pCreateModule, nDialogId );
626 0 : pEntry->SetUserData(pInfo);
627 0 : sal_uInt16 nRet = 0;
628 0 : pEntry = aTreeLB.First();
629 0 : while(pEntry)
630 : {
631 0 : if(!aTreeLB.GetParent(pEntry))
632 0 : nRet++;
633 0 : pEntry = aTreeLB.Next(pEntry);
634 : }
635 0 : return nRet - 1;
636 : }
637 :
638 0 : IMPL_LINK_NOARG(OfaTreeOptionsDialog, ShowPageHdl_Impl)
639 : {
640 0 : SelectHdl_Impl();
641 0 : return 0;
642 : }
643 :
644 0 : IMPL_LINK_NOARG(OfaTreeOptionsDialog, BackHdl_Impl)
645 : {
646 0 : if ( pCurrentPageEntry && aTreeLB.GetParent( pCurrentPageEntry ) )
647 : {
648 0 : OptionsPageInfo* pPageInfo = (OptionsPageInfo*)pCurrentPageEntry->GetUserData();
649 0 : if ( pPageInfo->m_pPage )
650 : {
651 : OptionsGroupInfo* pGroupInfo =
652 0 : (OptionsGroupInfo*)aTreeLB.GetParent( pCurrentPageEntry )->GetUserData();
653 0 : if ( RID_SVXPAGE_COLOR == pPageInfo->m_nPageId )
654 0 : pPageInfo->m_pPage->Reset( *pColorPageItemSet );
655 : else
656 0 : pPageInfo->m_pPage->Reset( *pGroupInfo->m_pInItemSet );
657 : }
658 0 : else if ( pPageInfo->m_pExtPage )
659 0 : pPageInfo->m_pExtPage->ResetPage();
660 : }
661 0 : return 0;
662 : }
663 :
664 0 : IMPL_LINK_NOARG(OfaTreeOptionsDialog, OKHdl_Impl)
665 : {
666 0 : aTreeLB.EndSelection();
667 0 : if ( pCurrentPageEntry && aTreeLB.GetParent( pCurrentPageEntry ) )
668 : {
669 0 : OptionsPageInfo* pPageInfo = (OptionsPageInfo *)pCurrentPageEntry->GetUserData();
670 0 : if ( pPageInfo->m_pPage )
671 : {
672 : OptionsGroupInfo* pGroupInfo =
673 0 : (OptionsGroupInfo *)aTreeLB.GetParent(pCurrentPageEntry)->GetUserData();
674 0 : if ( RID_SVXPAGE_COLOR != pPageInfo->m_nPageId
675 0 : && pPageInfo->m_pPage->HasExchangeSupport() )
676 : {
677 0 : int nLeave = pPageInfo->m_pPage->DeactivatePage(pGroupInfo->m_pOutItemSet);
678 0 : if ( nLeave == SfxTabPage::KEEP_PAGE )
679 : {
680 : // the page mustn't be left
681 0 : aTreeLB.Select(pCurrentPageEntry);
682 0 : return 0;
683 : }
684 : }
685 0 : pPageInfo->m_pPage->Hide();
686 : }
687 : }
688 :
689 0 : SvTreeListEntry* pEntry = aTreeLB.First();
690 0 : while ( pEntry )
691 : {
692 0 : if ( aTreeLB.GetParent( pEntry ) )
693 : {
694 0 : OptionsPageInfo* pPageInfo = (OptionsPageInfo *)pEntry->GetUserData();
695 0 : if ( pPageInfo->m_pPage && !pPageInfo->m_pPage->HasExchangeSupport() )
696 : {
697 : OptionsGroupInfo* pGroupInfo =
698 0 : (OptionsGroupInfo*)aTreeLB.GetParent(pEntry)->GetUserData();
699 0 : pPageInfo->m_pPage->FillItemSet(*pGroupInfo->m_pOutItemSet);
700 : }
701 :
702 0 : if ( pPageInfo->m_pExtPage )
703 : {
704 0 : pPageInfo->m_pExtPage->DeactivatePage();
705 0 : pPageInfo->m_pExtPage->SavePage();
706 : }
707 : }
708 0 : pEntry = aTreeLB.Next(pEntry);
709 : }
710 0 : EndDialog(RET_OK);
711 0 : return 0;
712 : }
713 :
714 : // an opened group shall be completely visible
715 0 : IMPL_LINK(OfaTreeOptionsDialog, ExpandedHdl_Impl, SvTreeListBox*, pBox )
716 : {
717 0 : pBox->Update();
718 0 : pBox->InitStartEntry();
719 0 : SvTreeListEntry* pEntry = pBox->GetHdlEntry();
720 0 : if(pEntry && pBox->IsExpanded(pEntry))
721 : {
722 0 : sal_uInt32 nChildCount = pBox->GetChildCount( pEntry );
723 :
724 0 : SvTreeListEntry* pNext = pEntry;
725 0 : for(sal_uInt32 i = 0; i < nChildCount;i++)
726 : {
727 0 : pNext = pBox->GetNextEntryInView(pNext);
728 0 : if(!pNext)
729 : {
730 0 : pBox->ScrollOutputArea( -(short)(nChildCount - i + 1) );
731 0 : break;
732 : }
733 : else
734 : {
735 0 : Size aSz(pBox->GetOutputSizePixel());
736 0 : int nHeight = pBox->GetEntryHeight();
737 0 : Point aPos(pBox->GetEntryPosition(pNext));
738 0 : if(aPos.Y()+nHeight > aSz.Height())
739 : {
740 0 : pBox->ScrollOutputArea( -(short)(nChildCount - i + 1) );
741 0 : break;
742 : }
743 : }
744 : }
745 : }
746 0 : return 0;
747 : }
748 :
749 0 : void OfaTreeOptionsDialog::ApplyItemSets()
750 : {
751 0 : SvTreeListEntry* pEntry = aTreeLB.First();
752 0 : while(pEntry)
753 : {
754 0 : if(!aTreeLB.GetParent(pEntry))
755 : {
756 0 : OptionsGroupInfo* pGroupInfo = (OptionsGroupInfo *)pEntry->GetUserData();
757 0 : if(pGroupInfo->m_pOutItemSet)
758 : {
759 0 : if(pGroupInfo->m_pShell)
760 0 : pGroupInfo->m_pShell->ApplyItemSet( pGroupInfo->m_nDialogId, *pGroupInfo->m_pOutItemSet);
761 : else
762 0 : ApplyItemSet( pGroupInfo->m_nDialogId, *pGroupInfo->m_pOutItemSet);
763 : }
764 : }
765 0 : pEntry = aTreeLB.Next(pEntry);
766 : }
767 0 : }
768 :
769 0 : void OfaTreeOptionsDialog::InitTreeAndHandler()
770 : {
771 0 : maTreeLayoutTimer.SetTimeout(50);
772 0 : maTreeLayoutTimer.SetTimeoutHdl( LINK( this, OfaTreeOptionsDialog, ImplHandleTreeLayoutTimerHdl ) );
773 :
774 0 : aTreeLB.SetNodeDefaultImages();
775 :
776 0 : aTreeLB.SetHelpId( HID_OFADLG_TREELISTBOX );
777 0 : aTreeLB.SetStyle( aTreeLB.GetStyle()|WB_HASBUTTONS | WB_HASBUTTONSATROOT |
778 : WB_HASLINES | WB_HASLINESATROOT |
779 0 : WB_CLIPCHILDREN | WB_HSCROLL | WB_FORCE_MAKEVISIBLE | WB_QUICK_SEARCH );
780 0 : aTreeLB.SetSpaceBetweenEntries( 0 );
781 0 : aTreeLB.SetSelectionMode( SINGLE_SELECTION );
782 0 : aTreeLB.SetSublistOpenWithLeftRight( true );
783 0 : aTreeLB.SetExpandedHdl( LINK( this, OfaTreeOptionsDialog, ExpandedHdl_Impl ) );
784 0 : aTreeLB.SetSelectHdl( LINK( this, OfaTreeOptionsDialog, ShowPageHdl_Impl ) );
785 0 : aBackPB.SetClickHdl( LINK( this, OfaTreeOptionsDialog, BackHdl_Impl ) );
786 0 : aOkPB.SetClickHdl( LINK( this, OfaTreeOptionsDialog, OKHdl_Impl ) );
787 0 : }
788 :
789 0 : void OfaTreeOptionsDialog::ActivatePage( sal_uInt16 nResId )
790 : {
791 0 : bIsForSetDocumentLanguage = false;
792 0 : if ( nResId == OFA_TP_LANGUAGES_FOR_SET_DOCUMENT_LANGUAGE )
793 : {
794 0 : bIsForSetDocumentLanguage = true;
795 0 : nResId = OFA_TP_LANGUAGES;
796 : }
797 :
798 : DBG_ASSERT( !bIsFromExtensionManager, "OfaTreeOptionsDialog::ActivatePage(): call from extension manager" );
799 0 : if ( !pLastPageSaver )
800 0 : pLastPageSaver = new LastPageSaver;
801 0 : bForgetSelection = sal_True;
802 0 : sal_uInt16 nTemp = pLastPageSaver->m_nLastPageId;
803 0 : pLastPageSaver->m_nLastPageId = nResId;
804 0 : ActivateLastSelection();
805 0 : pLastPageSaver->m_nLastPageId = nTemp;
806 0 : }
807 :
808 0 : void OfaTreeOptionsDialog::ActivatePage( const OUString& rPageURL )
809 : {
810 : DBG_ASSERT( !bIsFromExtensionManager, "OfaTreeOptionsDialog::ActivatePage(): call from extension manager" );
811 0 : if ( !pLastPageSaver )
812 0 : pLastPageSaver = new LastPageSaver;
813 0 : bForgetSelection = sal_True;
814 0 : pLastPageSaver->m_nLastPageId = 0;
815 0 : pLastPageSaver->m_sLastPageURL_Tools = rPageURL;
816 0 : ActivateLastSelection();
817 0 : }
818 :
819 0 : void OfaTreeOptionsDialog::ActivateLastSelection()
820 : {
821 0 : SvTreeListEntry* pEntry = NULL;
822 0 : if ( pLastPageSaver )
823 : {
824 0 : OUString sExpand( EXPAND_PROTOCOL );
825 : OUString sLastURL = bIsFromExtensionManager ? pLastPageSaver->m_sLastPageURL_ExtMgr
826 0 : : pLastPageSaver->m_sLastPageURL_Tools;
827 0 : if ( sLastURL.isEmpty() )
828 : {
829 0 : sLastURL = !bIsFromExtensionManager ? pLastPageSaver->m_sLastPageURL_ExtMgr
830 0 : : pLastPageSaver->m_sLastPageURL_Tools;
831 : }
832 :
833 : // MacroExpander to convert "expand"-URL to "file"-URL
834 0 : Reference< XMacroExpander > xMacroExpander;
835 0 : bool bMustExpand = ( INetURLObject( sLastURL ).GetProtocol() == INET_PROT_FILE );
836 :
837 0 : if ( bMustExpand )
838 : {
839 : Reference< XComponentContext > xContext(
840 0 : comphelper::getProcessComponentContext() );
841 0 : xMacroExpander = theMacroExpander::get(xContext);
842 : }
843 :
844 0 : SvTreeListEntry* pTemp = aTreeLB.First();
845 0 : while( !pEntry && pTemp )
846 : {
847 : // restore only selection of a leaf
848 0 : if ( aTreeLB.GetParent( pTemp ) && pTemp->GetUserData() )
849 : {
850 0 : OptionsPageInfo* pPageInfo = (OptionsPageInfo*)pTemp->GetUserData();
851 0 : OUString sPageURL = pPageInfo->m_sPageURL;
852 0 : if ( bMustExpand
853 0 : && !sPageURL.isEmpty()
854 0 : && sPageURL.startsWith( sExpand ) )
855 : {
856 : // cut protocol
857 0 : OUString sTemp( sPageURL.copy( sExpand.getLength() ) );
858 : // decode uri class chars
859 0 : sTemp = ::rtl::Uri::decode(
860 0 : sTemp, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
861 : // expand string
862 0 : sPageURL = xMacroExpander->expandMacros( sTemp );
863 : }
864 :
865 0 : if ( ( !bIsFromExtensionManager
866 0 : && pPageInfo->m_nPageId && pPageInfo->m_nPageId == pLastPageSaver->m_nLastPageId )
867 0 : || ( !pPageInfo->m_nPageId && sLastURL == sPageURL ) )
868 0 : pEntry = pTemp;
869 : }
870 0 : pTemp = aTreeLB.Next(pTemp);
871 0 : }
872 : }
873 :
874 0 : if ( !pEntry )
875 : {
876 0 : pEntry = aTreeLB.First();
877 0 : pEntry = aTreeLB.Next(pEntry);
878 : }
879 :
880 0 : if ( !pEntry )
881 0 : return;
882 :
883 0 : SvTreeListEntry* pParent = aTreeLB.GetParent(pEntry);
884 0 : aTreeLB.Expand(pParent);
885 0 : aTreeLB.MakeVisible(pParent);
886 0 : aTreeLB.MakeVisible(pEntry);
887 0 : aTreeLB.Select(pEntry);
888 0 : aTreeLB.GrabFocus();
889 : }
890 :
891 0 : bool OfaTreeOptionsDialog::Notify( NotifyEvent& rNEvt )
892 : {
893 0 : if ( rNEvt.GetType() == EVENT_KEYINPUT )
894 : {
895 0 : const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
896 0 : const KeyCode aKeyCode = pKEvt->GetKeyCode();
897 :
898 0 : if( aKeyCode.GetCode() == KEY_PAGEUP ||
899 0 : aKeyCode.GetCode() == KEY_PAGEDOWN)
900 : {
901 0 : SvTreeListEntry* pCurEntry = aTreeLB.FirstSelected();
902 0 : SvTreeListEntry* pTemp = 0;
903 0 : if(aKeyCode.GetCode() == KEY_PAGEDOWN)
904 : {
905 0 : pTemp = aTreeLB.Next( pCurEntry ) ;
906 0 : if(pTemp && !aTreeLB.GetParent(pTemp))
907 : {
908 0 : pTemp = aTreeLB.Next( pTemp ) ;
909 0 : aTreeLB.Select(pTemp);
910 : }
911 : }
912 : else
913 : {
914 0 : pTemp = aTreeLB.Prev( pCurEntry ) ;
915 0 : if(pTemp && !aTreeLB.GetParent(pTemp))
916 : {
917 0 : pTemp = aTreeLB.Prev( pTemp ) ;
918 : }
919 : }
920 0 : if(pTemp)
921 : {
922 0 : if(!aTreeLB.IsExpanded(aTreeLB.GetParent(pTemp)))
923 0 : aTreeLB.Expand(aTreeLB.GetParent(pTemp));
924 0 : aTreeLB.MakeVisible(pTemp);
925 0 : aTreeLB.Select(pTemp);
926 : }
927 : }
928 : }
929 0 : return SfxModalDialog::Notify(rNEvt);
930 : }
931 :
932 0 : bool OfaTreeOptionsDialog::hasTreePendingLayout() const
933 : {
934 0 : return maTreeLayoutTimer.IsActive();
935 : }
936 :
937 0 : void OfaTreeOptionsDialog::queue_resize()
938 : {
939 0 : if (hasTreePendingLayout())
940 0 : return;
941 0 : if (IsInClose())
942 0 : return;
943 0 : maTreeLayoutTimer.Start();
944 : }
945 :
946 0 : IMPL_LINK( OfaTreeOptionsDialog, ImplHandleTreeLayoutTimerHdl, void*, EMPTYARG )
947 : {
948 0 : if (pCurrentPageEntry && aTreeLB.GetParent(pCurrentPageEntry))
949 : {
950 0 : OptionsPageInfo* pPageInfo = (OptionsPageInfo*)pCurrentPageEntry->GetUserData();
951 0 : if (pPageInfo->m_pPage && ::isLayoutEnabled(pPageInfo->m_pPage))
952 0 : SetPaneSize(pPageInfo->m_pPage);
953 : }
954 0 : return 0;
955 : }
956 :
957 :
958 0 : void OfaTreeOptionsDialog::SetPaneSize(Window *pPane)
959 : {
960 : //The OfaTreeOptionsDialog is not fully widget layout enabled
961 : //yet so it's a classic fixed dimension dialog, but to make
962 : //it possible to incrementally convert it over each pane
963 : //can be converted to .ui layout format and the fixed area
964 : //size reserved for panes is allocated to them here
965 0 : Point aPos(aSeparatorFL.GetPosPixel().X(), aTreeLB.GetPosPixel().Y());
966 0 : Size aSize(aSeparatorFL.GetSizePixel().Width(),
967 0 : aSeparatorFL.GetPosPixel().Y() - aTreeLB.GetPosPixel().Y());
968 0 : pPane->SetPosSizePixel( aPos, aSize );
969 0 : }
970 :
971 0 : void OfaTreeOptionsDialog::SelectHdl_Impl()
972 : {
973 0 : SvTreeListBox* pBox = &aTreeLB;
974 :
975 0 : if(pCurrentPageEntry == pBox->GetCurEntry())
976 : {
977 0 : pBox->EndSelection();
978 0 : return;
979 : }
980 :
981 0 : SvTreeListEntry* pEntry = pBox->GetCurEntry();
982 0 : SvTreeListEntry* pParent = pBox->GetParent(pEntry);
983 :
984 : // If the user has selected a category, automatically switch to a suitable
985 : // default sub-page instead.
986 0 : if (!pParent)
987 : {
988 0 : pBox->EndSelection();
989 0 : return;
990 : }
991 :
992 0 : pBox->EndSelection();
993 :
994 0 : TabPage* pOldPage = NULL;
995 0 : TabPage* pNewPage = NULL;
996 0 : OptionsPageInfo* pOptPageInfo = ( pCurrentPageEntry && aTreeLB.GetParent( pCurrentPageEntry ) )
997 0 : ? (OptionsPageInfo*)pCurrentPageEntry->GetUserData() : NULL;
998 :
999 0 : if ( pOptPageInfo && pOptPageInfo->m_pPage && pOptPageInfo->m_pPage->IsVisible() )
1000 : {
1001 0 : pOldPage = pOptPageInfo->m_pPage;
1002 0 : OptionsGroupInfo* pGroupInfo = (OptionsGroupInfo*)aTreeLB.GetParent(pCurrentPageEntry)->GetUserData();
1003 0 : int nLeave = SfxTabPage::LEAVE_PAGE;
1004 0 : if ( RID_SVXPAGE_COLOR != pOptPageInfo->m_nPageId && pOptPageInfo->m_pPage->HasExchangeSupport() )
1005 0 : nLeave = pOptPageInfo->m_pPage->DeactivatePage( pGroupInfo->m_pOutItemSet );
1006 :
1007 0 : if ( nLeave == SfxTabPage::KEEP_PAGE )
1008 : {
1009 : // we cannot leave this page
1010 0 : pBox->Select( pCurrentPageEntry );
1011 0 : return;
1012 : }
1013 : else
1014 0 : pOptPageInfo->m_pPage->Hide();
1015 : }
1016 0 : else if ( pOptPageInfo && pOptPageInfo->m_pExtPage )
1017 : {
1018 0 : pOptPageInfo->m_pExtPage->Hide();
1019 0 : pOptPageInfo->m_pExtPage->DeactivatePage();
1020 : }
1021 0 : else if ( pCurrentPageEntry && !aTreeLB.GetParent( pCurrentPageEntry ) )
1022 : {
1023 0 : OptionsGroupInfo* pGroupInfo = (OptionsGroupInfo*)pCurrentPageEntry->GetUserData();
1024 0 : if ( pGroupInfo && pGroupInfo->m_pExtPage )
1025 : {
1026 0 : pGroupInfo->m_pExtPage->Hide();
1027 0 : pGroupInfo->m_pExtPage->DeactivatePage();
1028 : }
1029 : }
1030 :
1031 0 : OptionsPageInfo *pPageInfo = (OptionsPageInfo *)pEntry->GetUserData();
1032 0 : OptionsGroupInfo* pGroupInfo = (OptionsGroupInfo *)pParent->GetUserData();
1033 0 : if(!pPageInfo->m_pPage && pPageInfo->m_nPageId > 0)
1034 : {
1035 0 : if(pGroupInfo->m_bLoadError)
1036 0 : return;
1037 0 : if ( RID_SVXPAGE_COLOR == pPageInfo->m_nPageId )
1038 : {
1039 0 : if(!pColorPageItemSet)
1040 : {
1041 : // Move usage of a static XOutdevItemPool instance here
1042 0 : if(!mpStaticXOutdevItemPool)
1043 0 : mpStaticXOutdevItemPool = new XOutdevItemPool();
1044 :
1045 0 : pColorPageItemSet = new SfxItemSet( *mpStaticXOutdevItemPool, XATTR_FILLSTYLE, XATTR_FILLCOLOR);
1046 0 : pColorPageItemSet->Put( XFillColorItem() );
1047 : }
1048 : }
1049 : else
1050 : {
1051 0 : if(pGroupInfo->m_pModule /*&& !pGroupInfo->pModule->IsLoaded()*/)
1052 : {
1053 0 : SfxModule* pOldModule = pGroupInfo->m_pModule;
1054 0 : sal_Bool bIdentical = pGroupInfo->m_pModule == pGroupInfo->m_pShell;
1055 :
1056 0 : WaitObject aWait(this);
1057 : //pGroupInfo->pModule = pGroupInfo->pModule->Load();
1058 0 : if(!pGroupInfo->m_pModule)
1059 : {
1060 0 : pGroupInfo->m_bLoadError = sal_True;
1061 0 : InfoBox(pBox, sNotLoadedError).Execute();
1062 0 : return;
1063 : }
1064 0 : if(bIdentical)
1065 0 : pGroupInfo->m_pShell = pGroupInfo->m_pModule;
1066 : // now test whether there was the same module in other groups, too (e. g. Text+HTML)
1067 0 : SvTreeListEntry* pTemp = aTreeLB.First();
1068 0 : while(pTemp)
1069 : {
1070 0 : if(!aTreeLB.GetParent(pTemp) && pTemp != pEntry)
1071 : {
1072 0 : OptionsGroupInfo* pTGInfo = (OptionsGroupInfo *)pTemp->GetUserData();
1073 0 : if(pTGInfo->m_pModule == pOldModule)
1074 : {
1075 0 : pTGInfo->m_pModule = pGroupInfo->m_pModule;
1076 0 : if(bIdentical)
1077 0 : pTGInfo->m_pShell = pGroupInfo->m_pModule;
1078 : }
1079 : }
1080 0 : pTemp = aTreeLB.Next(pTemp);
1081 0 : }
1082 : }
1083 :
1084 0 : if(!pGroupInfo->m_pInItemSet)
1085 : pGroupInfo->m_pInItemSet = pGroupInfo->m_pShell
1086 0 : ? pGroupInfo->m_pShell->CreateItemSet( pGroupInfo->m_nDialogId )
1087 0 : : CreateItemSet( pGroupInfo->m_nDialogId );
1088 0 : if(!pGroupInfo->m_pOutItemSet)
1089 : pGroupInfo->m_pOutItemSet = new SfxItemSet(
1090 0 : *pGroupInfo->m_pInItemSet->GetPool(),
1091 0 : pGroupInfo->m_pInItemSet->GetRanges());
1092 : }
1093 :
1094 0 : if(pPageInfo->m_nPageId == RID_SVXPAGE_COLOR)
1095 : {
1096 : pPageInfo->m_pPage = ::CreateGeneralTabPage(
1097 0 : pPageInfo->m_nPageId, this, *pColorPageItemSet );
1098 0 : mpColorPage = (SvxColorTabPage*)pPageInfo->m_pPage;
1099 0 : mpColorPage->SetupForViewFrame( SfxViewFrame::Current() );
1100 : }
1101 : else
1102 : {
1103 0 : pPageInfo->m_pPage = ::CreateGeneralTabPage(pPageInfo->m_nPageId, this, *pGroupInfo->m_pInItemSet );
1104 :
1105 0 : if(!pPageInfo->m_pPage && pGroupInfo->m_pModule)
1106 0 : pPageInfo->m_pPage = pGroupInfo->m_pModule->CreateTabPage(pPageInfo->m_nPageId, this, *pGroupInfo->m_pInItemSet);
1107 :
1108 : }
1109 :
1110 : DBG_ASSERT( pPageInfo->m_pPage, "tabpage could not created");
1111 0 : if ( pPageInfo->m_pPage )
1112 : {
1113 0 : SvtViewOptions aTabPageOpt( E_TABPAGE, OUString::number( pPageInfo->m_nPageId) );
1114 0 : pPageInfo->m_pPage->SetUserData( GetViewOptUserItem( aTabPageOpt ) );
1115 :
1116 0 : Point aPagePos( aSeparatorFL.GetPosPixel().X(), aTreeLB.GetPosPixel().Y());
1117 0 : pPageInfo->m_pPage->SetPosPixel( aPagePos );
1118 0 : if ( RID_SVXPAGE_COLOR == pPageInfo->m_nPageId )
1119 : {
1120 0 : pPageInfo->m_pPage->Reset( *pColorPageItemSet );
1121 0 : pPageInfo->m_pPage->ActivatePage( *pColorPageItemSet );
1122 : }
1123 : else
1124 : {
1125 0 : pPageInfo->m_pPage->Reset( *pGroupInfo->m_pInItemSet );
1126 : }
1127 0 : if (::isLayoutEnabled(pPageInfo->m_pPage))
1128 0 : SetPaneSize(pPageInfo->m_pPage);
1129 0 : }
1130 : }
1131 0 : else if ( 0 == pPageInfo->m_nPageId && !pPageInfo->m_pExtPage )
1132 : {
1133 0 : if ( !m_xContainerWinProvider.is() )
1134 : {
1135 0 : m_xContainerWinProvider = awt::ContainerWindowProvider::create( ::comphelper::getProcessComponentContext() );
1136 : }
1137 :
1138 : pPageInfo->m_pExtPage = new ExtensionsTabPage(
1139 0 : this, 0, pPageInfo->m_sPageURL, pPageInfo->m_sEventHdl, m_xContainerWinProvider );
1140 :
1141 0 : SetPaneSize(pPageInfo->m_pExtPage);
1142 : }
1143 :
1144 0 : if ( pPageInfo->m_pPage )
1145 : {
1146 0 : if ( RID_SVXPAGE_COLOR != pPageInfo->m_nPageId &&
1147 0 : pPageInfo->m_pPage->HasExchangeSupport())
1148 : {
1149 0 : pPageInfo->m_pPage->ActivatePage(*pGroupInfo->m_pOutItemSet);
1150 : }
1151 0 : pPageInfo->m_pPage->Show();
1152 : }
1153 0 : else if ( pPageInfo->m_pExtPage )
1154 : {
1155 0 : pPageInfo->m_pExtPage->Show();
1156 0 : pPageInfo->m_pExtPage->ActivatePage();
1157 : }
1158 :
1159 : {
1160 0 : OUStringBuffer sTitleBuf(sTitle);
1161 0 : sTitleBuf.append(" - ");
1162 0 : sTitleBuf.append(aTreeLB.GetEntryText(pParent));
1163 0 : sTitleBuf.append(" - ");
1164 0 : sTitleBuf.append(aTreeLB.GetEntryText(pEntry));
1165 0 : SetText(sTitleBuf.makeStringAndClear());
1166 : }
1167 :
1168 0 : pCurrentPageEntry = pEntry;
1169 0 : if ( !bForgetSelection )
1170 : {
1171 0 : if ( !pLastPageSaver )
1172 0 : pLastPageSaver = new LastPageSaver;
1173 0 : if ( !bIsFromExtensionManager )
1174 0 : pLastPageSaver->m_nLastPageId = pPageInfo->m_nPageId;
1175 0 : if ( pPageInfo->m_pExtPage )
1176 : {
1177 0 : if ( bIsFromExtensionManager )
1178 0 : pLastPageSaver->m_sLastPageURL_ExtMgr = pPageInfo->m_sPageURL;
1179 : else
1180 0 : pLastPageSaver->m_sLastPageURL_Tools = pPageInfo->m_sPageURL;
1181 : }
1182 : }
1183 0 : pNewPage = pPageInfo->m_pPage;
1184 :
1185 : // restore lost focus, if necessary
1186 0 : Window* pFocusWin = Application::GetFocusWindow();
1187 : // if the focused window is not the options treebox and the old page has the focus
1188 0 : if ( pFocusWin && pFocusWin != pBox && pOldPage && pOldPage->HasChildPathFocus() )
1189 : // then set the focus to the new page or if we are on a group set the focus to the options treebox
1190 0 : pNewPage ? pNewPage->GrabFocus() : pBox->GrabFocus();
1191 :
1192 0 : return;
1193 : }
1194 :
1195 0 : OfaPageResource::OfaPageResource() :
1196 0 : Resource(CUI_RES(RID_OFADLG_OPTIONS_TREE_PAGES)),
1197 0 : aGeneralDlgAry(CUI_RES(SID_GENERAL_OPTIONS)),
1198 0 : aInetDlgAry(CUI_RES(SID_INET_DLG)),
1199 0 : aLangDlgAry(CUI_RES(SID_LANGUAGE_OPTIONS)),
1200 0 : aTextDlgAry(CUI_RES(SID_SW_EDITOPTIONS)),
1201 0 : aHTMLDlgAry(CUI_RES(SID_SW_ONLINEOPTIONS)),
1202 0 : aCalcDlgAry(CUI_RES(SID_SC_EDITOPTIONS)),
1203 0 : aStarMathDlgAry(CUI_RES(SID_SM_EDITOPTIONS)),
1204 0 : aImpressDlgAry(CUI_RES(SID_SD_EDITOPTIONS)),
1205 0 : aDrawDlgAry(CUI_RES(SID_SD_GRAPHIC_OPTIONS)),
1206 0 : aChartDlgAry(CUI_RES(SID_SCH_EDITOPTIONS)),
1207 0 : aFilterDlgAry(CUI_RES(SID_FILTER_DLG)),
1208 0 : aDatasourcesDlgAry(CUI_RES(SID_SB_STARBASEOPTIONS))
1209 : {
1210 0 : FreeResource();
1211 0 : }
1212 :
1213 0 : SfxItemSet* OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId )
1214 : {
1215 0 : Reference< XLinguProperties > xProp( SvxGetLinguPropertySet() );
1216 0 : SfxItemSet* pRet = 0;
1217 0 : switch(nId)
1218 : {
1219 : case SID_GENERAL_OPTIONS:
1220 : {
1221 : pRet = new SfxItemSet(
1222 0 : SFX_APP()->GetPool(),
1223 : SID_ATTR_METRIC, SID_ATTR_SPELL,
1224 : SID_AUTOSPELL_CHECK, SID_AUTOSPELL_CHECK,
1225 : SID_ATTR_QUICKLAUNCHER, SID_ATTR_QUICKLAUNCHER,
1226 : SID_ATTR_YEAR2000, SID_ATTR_YEAR2000,
1227 : SID_HTML_MODE, SID_HTML_MODE,
1228 0 : 0 );
1229 :
1230 0 : SfxItemSet aOptSet( SFX_APP()->GetPool(), SID_ATTR_QUICKLAUNCHER, SID_ATTR_QUICKLAUNCHER );
1231 0 : SFX_APP()->GetOptions(aOptSet);
1232 0 : pRet->Put(aOptSet);
1233 :
1234 0 : utl::MiscCfg aMisc;
1235 : const SfxPoolItem* pItem;
1236 0 : SfxViewFrame* pViewFrame = SfxViewFrame::Current();
1237 0 : if ( pViewFrame )
1238 : {
1239 0 : SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
1240 :
1241 : // miscellaneous - Year2000
1242 0 : if( SFX_ITEM_AVAILABLE <= pDispatch->QueryState( SID_ATTR_YEAR2000, pItem ) )
1243 0 : pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, ((const SfxUInt16Item*)pItem)->GetValue() ) );
1244 : else
1245 0 : pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, (sal_uInt16)aMisc.GetYear2000() ) );
1246 : }
1247 : else
1248 0 : pRet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, (sal_uInt16)aMisc.GetYear2000() ) );
1249 :
1250 :
1251 : // miscellaneous - Tabulator
1252 0 : pRet->Put(SfxBoolItem(SID_PRINTER_NOTFOUND_WARN, aMisc.IsNotFoundWarning()));
1253 :
1254 0 : sal_uInt16 nFlag = aMisc.IsPaperSizeWarning() ? SFX_PRINTER_CHG_SIZE : 0;
1255 0 : nFlag |= aMisc.IsPaperOrientationWarning() ? SFX_PRINTER_CHG_ORIENTATION : 0;
1256 0 : pRet->Put( SfxFlagItem( SID_PRINTER_CHANGESTODOC, nFlag ));
1257 :
1258 : }
1259 0 : break;
1260 : case SID_LANGUAGE_OPTIONS :
1261 : {
1262 0 : pRet = new SfxItemSet(SFX_APP()->GetPool(),
1263 : SID_ATTR_LANGUAGE, SID_AUTOSPELL_CHECK,
1264 : SID_ATTR_CHAR_CJK_LANGUAGE, SID_ATTR_CHAR_CTL_LANGUAGE,
1265 : SID_OPT_LOCALE_CHANGED, SID_OPT_LOCALE_CHANGED,
1266 : SID_SET_DOCUMENT_LANGUAGE, SID_SET_DOCUMENT_LANGUAGE,
1267 0 : 0 );
1268 :
1269 : // for linguistic
1270 :
1271 0 : Reference< XSpellChecker1 > xSpell = SvxGetSpellChecker();
1272 0 : pRet->Put(SfxSpellCheckItem( xSpell, SID_ATTR_SPELL ));
1273 0 : SfxHyphenRegionItem aHyphen( SID_ATTR_HYPHENREGION );
1274 :
1275 0 : sal_Int16 nMinLead = 2,
1276 0 : nMinTrail = 2;
1277 0 : if (xProp.is())
1278 : {
1279 0 : nMinLead = xProp->getHyphMinLeading();
1280 0 : nMinTrail = xProp->getHyphMinTrailing();
1281 : }
1282 0 : aHyphen.GetMinLead() = (sal_uInt8)nMinLead;
1283 0 : aHyphen.GetMinTrail() = (sal_uInt8)nMinTrail;
1284 :
1285 : const SfxPoolItem* pItem;
1286 : SfxPoolItem* pClone;
1287 0 : SfxViewFrame* pViewFrame = SfxViewFrame::Current();
1288 0 : if ( pViewFrame )
1289 : {
1290 0 : SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
1291 0 : if(SFX_ITEM_AVAILABLE <= pDispatch->QueryState(SID_ATTR_LANGUAGE, pItem))
1292 0 : pRet->Put(SfxUInt16Item(SID_ATTR_LANGUAGE, ((const SvxLanguageItem*)pItem)->GetLanguage()));
1293 0 : if(SFX_ITEM_AVAILABLE <= pDispatch->QueryState(SID_ATTR_CHAR_CJK_LANGUAGE, pItem))
1294 0 : pRet->Put(SfxUInt16Item(SID_ATTR_CHAR_CJK_LANGUAGE, ((const SvxLanguageItem*)pItem)->GetLanguage()));
1295 0 : if(SFX_ITEM_AVAILABLE <= pDispatch->QueryState(SID_ATTR_CHAR_CTL_LANGUAGE, pItem))
1296 0 : pRet->Put(SfxUInt16Item(SID_ATTR_CHAR_CTL_LANGUAGE, ((const SvxLanguageItem*)pItem)->GetLanguage()));
1297 :
1298 0 : pRet->Put(aHyphen);
1299 0 : if(SFX_ITEM_AVAILABLE <= pDispatch->QueryState(SID_AUTOSPELL_CHECK, pItem))
1300 : {
1301 0 : pClone = pItem->Clone();
1302 0 : pRet->Put(*pClone);
1303 0 : delete pClone;
1304 : }
1305 : else
1306 : {
1307 0 : sal_Bool bVal = sal_False;
1308 0 : if (xProp.is())
1309 : {
1310 0 : bVal = xProp->getIsSpellAuto();
1311 : }
1312 :
1313 0 : pRet->Put(SfxBoolItem(SID_AUTOSPELL_CHECK, bVal));
1314 : }
1315 : }
1316 0 : pRet->Put( SfxBoolItem( SID_SET_DOCUMENT_LANGUAGE, bIsForSetDocumentLanguage ) );
1317 : }
1318 0 : break;
1319 : case SID_INET_DLG :
1320 0 : pRet = new SfxItemSet( SFX_APP()->GetPool(),
1321 : SID_BASIC_ENABLED, SID_BASIC_ENABLED,
1322 : //SID_OPTIONS_START - ..END
1323 : SID_INET_PROXY_TYPE, SID_INET_PROXY_PORT,
1324 : SID_SAVEREL_INET, SID_SAVEREL_FSYS,
1325 : SID_INET_SMTPSERVER, SID_INET_SMTPSERVER,
1326 : SID_INET_NOPROXY, SID_INET_SOCKS_PROXY_PORT,
1327 : SID_INET_DNS_AUTO, SID_INET_DNS_SERVER,
1328 : SID_SECURE_URL, SID_SECURE_URL,
1329 0 : 0L );
1330 0 : SFX_APP()->GetOptions(*pRet);
1331 0 : break;
1332 : case SID_FILTER_DLG:
1333 0 : pRet = new SfxItemSet( SFX_APP()->GetPool(),
1334 : SID_ATTR_DOCINFO, SID_ATTR_AUTOSAVEMINUTE,
1335 : SID_SAVEREL_INET, SID_SAVEREL_FSYS,
1336 : SID_ATTR_PRETTYPRINTING, SID_ATTR_PRETTYPRINTING,
1337 : SID_ATTR_WARNALIENFORMAT, SID_ATTR_WARNALIENFORMAT,
1338 0 : 0 );
1339 0 : SFX_APP()->GetOptions(*pRet);
1340 0 : break;
1341 :
1342 : case SID_SB_STARBASEOPTIONS:
1343 0 : pRet = new SfxItemSet( SFX_APP()->GetPool(),
1344 : SID_SB_POOLING_ENABLED, SID_SB_DB_REGISTER,
1345 0 : 0 );
1346 0 : ::offapp::ConnectionPoolConfig::GetOptions(*pRet);
1347 0 : ::svx::DbRegisteredNamesConfig::GetOptions(*pRet);
1348 0 : break;
1349 :
1350 : case SID_SCH_EDITOPTIONS:
1351 : {
1352 0 : SvxChartOptions aChartOpt;
1353 0 : pRet = new SfxItemSet( SFX_APP()->GetPool(), SID_SCH_EDITOPTIONS, SID_SCH_EDITOPTIONS );
1354 0 : pRet->Put( SvxChartColorTableItem( SID_SCH_EDITOPTIONS, aChartOpt.GetDefaultColors() ) );
1355 0 : break;
1356 : }
1357 : }
1358 0 : return pRet;
1359 : }
1360 :
1361 0 : void OfaTreeOptionsDialog::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet )
1362 : {
1363 0 : switch(nId)
1364 : {
1365 : case SID_GENERAL_OPTIONS:
1366 : {
1367 0 : utl::MiscCfg aMisc;
1368 : const SfxPoolItem* pItem;
1369 0 : SfxItemSet aOptSet(SFX_APP()->GetPool(), SID_ATTR_QUICKLAUNCHER, SID_ATTR_QUICKLAUNCHER );
1370 0 : aOptSet.Put(rSet);
1371 0 : if(aOptSet.Count())
1372 0 : SFX_APP()->SetOptions( aOptSet );
1373 : // get dispatcher anew, because SetOptions() might have destroyed the dispatcher
1374 0 : SfxViewFrame *pViewFrame = SfxViewFrame::Current();
1375 :
1376 : // evaluate Year2000
1377 :
1378 0 : sal_uInt16 nY2K = USHRT_MAX;
1379 0 : if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_YEAR2000, false, &pItem ) )
1380 0 : nY2K = ((const SfxUInt16Item*)pItem)->GetValue();
1381 0 : if( USHRT_MAX != nY2K )
1382 : {
1383 0 : if ( pViewFrame )
1384 : {
1385 0 : SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
1386 0 : pDispatch->Execute( SID_ATTR_YEAR2000, SFX_CALLMODE_ASYNCHRON, pItem, 0L);
1387 : }
1388 0 : aMisc.SetYear2000(nY2K);
1389 : }
1390 :
1391 :
1392 : // evaluate print
1393 :
1394 0 : if(SFX_ITEM_SET == rSet.GetItemState(SID_PRINTER_NOTFOUND_WARN, false, &pItem))
1395 0 : aMisc.SetNotFoundWarning(((const SfxBoolItem*)pItem)->GetValue());
1396 :
1397 0 : if(SFX_ITEM_SET == rSet.GetItemState(SID_PRINTER_CHANGESTODOC, false, &pItem))
1398 : {
1399 0 : const SfxFlagItem* pFlag = (const SfxFlagItem*)pItem;
1400 0 : aMisc.SetPaperSizeWarning(0 != (pFlag->GetValue() & SFX_PRINTER_CHG_SIZE ));
1401 0 : aMisc.SetPaperOrientationWarning(0 != (pFlag->GetValue() & SFX_PRINTER_CHG_ORIENTATION ));
1402 : }
1403 :
1404 : // evaluate help options
1405 :
1406 0 : if ( SvtHelpOptions().IsHelpTips() != Help::IsQuickHelpEnabled() )
1407 0 : SvtHelpOptions().IsHelpTips() ? Help::EnableQuickHelp() : Help::DisableQuickHelp();
1408 0 : if ( SvtHelpOptions().IsExtendedHelp() != Help::IsBalloonHelpEnabled() )
1409 0 : SvtHelpOptions().IsExtendedHelp() ? Help::EnableBalloonHelp() : Help::DisableBalloonHelp();
1410 : }
1411 0 : break;
1412 : case SID_LANGUAGE_OPTIONS :
1413 : {
1414 0 : OfaTreeOptionsDialog::ApplyLanguageOptions(rSet);
1415 : }
1416 0 : break;
1417 : case SID_INET_DLG :
1418 : case SID_FILTER_DLG:
1419 0 : SFX_APP()->SetOptions( rSet );
1420 0 : break;
1421 :
1422 : case SID_SB_STARBASEOPTIONS:
1423 0 : ::offapp::ConnectionPoolConfig::SetOptions( rSet );
1424 0 : ::svx::DbRegisteredNamesConfig::SetOptions(rSet);
1425 0 : break;
1426 :
1427 : case SID_SCH_EDITOPTIONS:
1428 : // nothing to do. Chart options only apply to newly created charts
1429 0 : break;
1430 :
1431 : default:
1432 : {
1433 : OSL_FAIL( "Unhandled option in ApplyItemSet" );
1434 : }
1435 0 : break;
1436 : }
1437 :
1438 0 : }
1439 0 : void OfaTreeOptionsDialog::ApplyLanguageOptions(const SfxItemSet& rSet)
1440 : {
1441 0 : sal_Bool bSaveSpellCheck = sal_False;
1442 : const SfxPoolItem* pItem;
1443 :
1444 0 : if ( SFX_ITEM_SET == rSet.GetItemState( SID_SPELL_MODIFIED, false, &pItem ) )
1445 : {
1446 0 : bSaveSpellCheck = ( (const SfxBoolItem*)pItem )->GetValue();
1447 : }
1448 0 : Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
1449 0 : Reference< XLinguProperties > xProp = LinguProperties::create( xContext );
1450 0 : if ( SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_HYPHENREGION, false, &pItem ) )
1451 : {
1452 0 : const SfxHyphenRegionItem* pHyphenItem = (const SfxHyphenRegionItem*)pItem;
1453 :
1454 0 : xProp->setHyphMinLeading( (sal_Int16) pHyphenItem->GetMinLead() );
1455 0 : xProp->setHyphMinTrailing( (sal_Int16) pHyphenItem->GetMinTrail() );
1456 0 : bSaveSpellCheck = sal_True;
1457 : }
1458 :
1459 0 : SfxViewFrame *pViewFrame = SfxViewFrame::Current();
1460 0 : if ( pViewFrame )
1461 : {
1462 0 : SfxDispatcher* pDispatch = pViewFrame->GetDispatcher();
1463 0 : pItem = 0;
1464 0 : if(SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_LANGUAGE, false, &pItem ))
1465 : {
1466 0 : pDispatch->Execute(pItem->Which(), SFX_CALLMODE_ASYNCHRON, pItem, 0L);
1467 0 : bSaveSpellCheck = sal_True;
1468 : }
1469 0 : if(SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_CHAR_CTL_LANGUAGE, false, &pItem ))
1470 : {
1471 0 : pDispatch->Execute(pItem->Which(), SFX_CALLMODE_ASYNCHRON, pItem, 0L);
1472 0 : bSaveSpellCheck = sal_True;
1473 : }
1474 0 : if(SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_CHAR_CJK_LANGUAGE, false, &pItem ))
1475 : {
1476 0 : pDispatch->Execute(pItem->Which(), SFX_CALLMODE_ASYNCHRON, pItem, 0L);
1477 0 : bSaveSpellCheck = sal_True;
1478 : }
1479 :
1480 0 : if( SFX_ITEM_SET == rSet.GetItemState(SID_AUTOSPELL_CHECK, false, &pItem ))
1481 : {
1482 0 : sal_Bool bOnlineSpelling = ((const SfxBoolItem*)pItem)->GetValue();
1483 : pDispatch->Execute(SID_AUTOSPELL_CHECK,
1484 0 : SFX_CALLMODE_ASYNCHRON|SFX_CALLMODE_RECORD, pItem, 0L);
1485 :
1486 0 : xProp->setIsSpellAuto( bOnlineSpelling );
1487 : }
1488 :
1489 0 : if( bSaveSpellCheck )
1490 : {
1491 : //! the config item has changed since we modified the
1492 : //! property set it uses
1493 0 : pDispatch->Execute(SID_SPELLCHECKER_CHANGED, SFX_CALLMODE_ASYNCHRON);
1494 : }
1495 : }
1496 :
1497 0 : if( SFX_ITEM_SET == rSet.GetItemState(SID_OPT_LOCALE_CHANGED, false, &pItem ))
1498 : {
1499 0 : SfxViewFrame* _pViewFrame = SfxViewFrame::GetFirst();
1500 0 : while ( _pViewFrame )
1501 : {
1502 0 : _pViewFrame->GetDispatcher()->Execute(pItem->Which(), SFX_CALLMODE_ASYNCHRON, pItem, 0L);
1503 0 : _pViewFrame = SfxViewFrame::GetNext( *_pViewFrame );
1504 : }
1505 0 : }
1506 0 : }
1507 :
1508 0 : OUString getCurrentFactory_Impl( const Reference< XFrame >& _xFrame )
1509 : {
1510 0 : OUString sIdentifier;
1511 0 : Reference < XFrame > xCurrentFrame( _xFrame );
1512 0 : Reference < XModuleManager2 > xModuleManager = ModuleManager::create(::comphelper::getProcessComponentContext());
1513 0 : if ( !xCurrentFrame.is() )
1514 : {
1515 0 : Reference< XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() );
1516 0 : xCurrentFrame = xDesktop->getCurrentFrame();
1517 : }
1518 :
1519 0 : if ( xCurrentFrame.is() )
1520 : {
1521 : try
1522 : {
1523 0 : sIdentifier = xModuleManager->identify( xCurrentFrame );
1524 : }
1525 0 : catch ( ::com::sun::star::frame::UnknownModuleException& )
1526 : {
1527 : DBG_WARNING( "getActiveModule_Impl(): unknown module" );
1528 : }
1529 0 : catch ( Exception& )
1530 : {
1531 : SAL_WARN( "cui.options", "getActiveModule_Impl(): exception of XModuleManager::identify()" );
1532 : }
1533 : }
1534 :
1535 0 : return sIdentifier;
1536 : }
1537 :
1538 0 : void OfaTreeOptionsDialog::Initialize( const Reference< XFrame >& _xFrame )
1539 : {
1540 0 : OfaPageResource aDlgResource;
1541 0 : sal_uInt16 nGroup = 0;
1542 :
1543 0 : SvtOptionsDialogOptions aOptionsDlgOpt;
1544 : sal_uInt16 i, nPageId;
1545 :
1546 : // %PRODUCTNAME options
1547 0 : if ( !lcl_isOptionHidden( SID_GENERAL_OPTIONS, aOptionsDlgOpt ) )
1548 : {
1549 0 : ResStringArray& rGeneralArray = aDlgResource.GetGeneralArray();
1550 0 : setGroupName( "ProductName", rGeneralArray.GetString(0) );
1551 0 : nGroup = AddGroup( rGeneralArray.GetString(0), 0, 0, SID_GENERAL_OPTIONS );
1552 0 : sal_uInt16 nEnd = static_cast< sal_uInt16 >( rGeneralArray.Count() );
1553 :
1554 0 : for ( i = 1; i < nEnd; ++i )
1555 : {
1556 0 : OUString sNewTitle = rGeneralArray.GetString(i);
1557 0 : nPageId = (sal_uInt16)rGeneralArray.GetValue(i);
1558 0 : if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1559 0 : continue;
1560 :
1561 : // Disable Online Update page if service not installed
1562 0 : if( RID_SVXPAGE_ONLINEUPDATE == nPageId )
1563 : {
1564 : try
1565 : {
1566 0 : Reference < XInterface > xService( setup::UpdateCheck::create( ::comphelper::getProcessComponentContext() ) );
1567 0 : if( ! xService.is() )
1568 0 : continue;
1569 : }
1570 0 : catch ( ::com::sun::star::uno::DeploymentException& )
1571 : {
1572 0 : continue;
1573 : }
1574 : }
1575 0 : AddTabPage( nPageId, sNewTitle, nGroup );
1576 0 : }
1577 : }
1578 :
1579 : // Load and Save options
1580 0 : if ( !lcl_isOptionHidden( SID_FILTER_DLG, aOptionsDlgOpt ) )
1581 : {
1582 0 : ResStringArray& rFilterArray = aDlgResource.GetFilterArray();
1583 0 : setGroupName( "LoadSave", rFilterArray.GetString(0) );
1584 0 : nGroup = AddGroup( rFilterArray.GetString(0), 0, 0, SID_FILTER_DLG );
1585 0 : for ( i = 1; i < rFilterArray.Count(); ++i )
1586 : {
1587 0 : nPageId = (sal_uInt16)rFilterArray.GetValue(i);
1588 0 : if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1589 0 : AddTabPage( nPageId, rFilterArray.GetString(i), nGroup );
1590 : }
1591 : }
1592 :
1593 : // Language options
1594 0 : SvtLanguageOptions aLanguageOptions;
1595 0 : if ( !lcl_isOptionHidden( SID_LANGUAGE_OPTIONS, aOptionsDlgOpt ) )
1596 : {
1597 0 : ResStringArray& rLangArray = aDlgResource.GetLangArray();
1598 0 : setGroupName( "LanguageSettings", rLangArray.GetString(0) );
1599 0 : nGroup = AddGroup( rLangArray.GetString(0), 0, 0, SID_LANGUAGE_OPTIONS );
1600 0 : for ( i = 1; i < rLangArray.Count(); ++i )
1601 : {
1602 0 : nPageId = (sal_uInt16)rLangArray.GetValue(i);
1603 0 : if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1604 0 : continue;
1605 0 : if ( ( RID_SVXPAGE_JSEARCH_OPTIONS != nPageId || aLanguageOptions.IsJapaneseFindEnabled() ) &&
1606 0 : ( RID_SVXPAGE_ASIAN_LAYOUT != nPageId || aLanguageOptions.IsAsianTypographyEnabled() ) &&
1607 0 : ( RID_SVXPAGE_OPTIONS_CTL != nPageId || aLanguageOptions.IsCTLFontEnabled() ) )
1608 0 : AddTabPage( nPageId, rLangArray.GetString(i), nGroup );
1609 : }
1610 : }
1611 :
1612 :
1613 0 : OUString aFactory = getCurrentFactory_Impl( _xFrame );
1614 : DBG_ASSERT( GetModuleIdentifier( _xFrame ) == aFactory, "S H I T!!!" );
1615 :
1616 : // Writer and Writer/Web options
1617 0 : SvtModuleOptions aModuleOpt;
1618 0 : if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER ) )
1619 : {
1620 : // text document
1621 0 : ResStringArray& rTextArray = aDlgResource.GetTextArray();
1622 0 : if ( aFactory == "com.sun.star.text.TextDocument"
1623 0 : || aFactory == "com.sun.star.text.WebDocument"
1624 0 : || aFactory == "com.sun.star.text.GlobalDocument" )
1625 : {
1626 0 : SfxModule* pSwMod = (*(SfxModule**) GetAppData(SHL_WRITER));
1627 0 : if ( !lcl_isOptionHidden( SID_SW_EDITOPTIONS, aOptionsDlgOpt ) )
1628 : {
1629 0 : if ( aFactory == "com.sun.star.text.WebDocument" )
1630 0 : setGroupName( "WriterWeb", rTextArray.GetString(0) );
1631 : else
1632 0 : setGroupName( "Writer", rTextArray.GetString(0) );
1633 0 : nGroup = AddGroup(rTextArray.GetString(0), pSwMod, pSwMod, SID_SW_EDITOPTIONS );
1634 0 : for ( i = 1; i < rTextArray.Count(); ++i )
1635 : {
1636 0 : nPageId = (sal_uInt16)rTextArray.GetValue(i);
1637 0 : if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1638 0 : continue;
1639 0 : if ( ( RID_SW_TP_STD_FONT_CJK != nPageId || aLanguageOptions.IsCJKFontEnabled() ) &&
1640 0 : ( RID_SW_TP_STD_FONT_CTL != nPageId || aLanguageOptions.IsCTLFontEnabled() ) &&
1641 0 : ( RID_SW_TP_MAILCONFIG != nPageId || MailMergeCfg_Impl().IsEmailSupported() ) )
1642 0 : AddTabPage( nPageId, rTextArray.GetString(i), nGroup );
1643 : }
1644 : #ifdef DBG_UTIL
1645 : AddTabPage( RID_SW_TP_OPTTEST_PAGE, OUString("Internal Test"), nGroup );
1646 : #endif
1647 : }
1648 :
1649 : // HTML documents
1650 0 : if ( !lcl_isOptionHidden( SID_SW_ONLINEOPTIONS, aOptionsDlgOpt ) )
1651 : {
1652 0 : ResStringArray& rHTMLArray = aDlgResource.GetHTMLArray();
1653 0 : nGroup = AddGroup(rHTMLArray.GetString(0), pSwMod, pSwMod, SID_SW_ONLINEOPTIONS );
1654 0 : for( i = 1; i < rHTMLArray.Count(); ++i )
1655 : {
1656 0 : nPageId = (sal_uInt16)rHTMLArray.GetValue(i);
1657 0 : if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1658 0 : AddTabPage( nPageId, rHTMLArray.GetString(i), nGroup );
1659 : }
1660 : #ifdef DBG_UTIL
1661 : AddTabPage( RID_SW_TP_OPTTEST_PAGE, OUString("Internal Test"), nGroup );
1662 : #endif
1663 : }
1664 : }
1665 : }
1666 :
1667 : // Calc options
1668 0 : if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC ) )
1669 : {
1670 0 : if ( aFactory == "com.sun.star.sheet.SpreadsheetDocument" )
1671 : {
1672 0 : if ( !lcl_isOptionHidden( SID_SC_EDITOPTIONS, aOptionsDlgOpt ) )
1673 : {
1674 0 : ResStringArray& rCalcArray = aDlgResource.GetCalcArray();
1675 0 : SfxModule* pScMod = ( *( SfxModule** ) GetAppData( SHL_CALC ) );
1676 0 : setGroupName( "Calc", rCalcArray.GetString(0) );
1677 0 : nGroup = AddGroup( rCalcArray.GetString( 0 ), pScMod, pScMod, SID_SC_EDITOPTIONS );
1678 0 : const sal_uInt16 nCount = static_cast< const sal_uInt16 >( rCalcArray.Count() );
1679 0 : for ( i = 1; i < nCount; ++i )
1680 : {
1681 0 : nPageId = (sal_uInt16)rCalcArray.GetValue(i);
1682 0 : if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1683 0 : continue;
1684 :
1685 0 : AddTabPage( nPageId, rCalcArray.GetString( i ), nGroup );
1686 : }
1687 : }
1688 : }
1689 : }
1690 :
1691 : // Impress options
1692 0 : SfxModule* pSdMod = ( *( SfxModule** ) GetAppData( SHL_DRAW ) );
1693 0 : if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SIMPRESS ) )
1694 : {
1695 0 : if ( aFactory == "com.sun.star.presentation.PresentationDocument" )
1696 : {
1697 0 : if ( !lcl_isOptionHidden( SID_SD_EDITOPTIONS, aOptionsDlgOpt ) )
1698 : {
1699 0 : ResStringArray& rImpressArray = aDlgResource.GetImpressArray();
1700 0 : setGroupName( "Impress", rImpressArray.GetString(0) );
1701 0 : nGroup = AddGroup( rImpressArray.GetString( 0 ), pSdMod, pSdMod, SID_SD_EDITOPTIONS );
1702 0 : const sal_uInt16 nCount = static_cast< const sal_uInt16 >( rImpressArray.Count() );
1703 0 : for ( i = 1; i < nCount; ++i )
1704 : {
1705 0 : nPageId = (sal_uInt16)rImpressArray.GetValue(i);
1706 0 : if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1707 0 : continue;
1708 :
1709 0 : AddTabPage( nPageId, rImpressArray.GetString(i), nGroup );
1710 : }
1711 : }
1712 : }
1713 : }
1714 :
1715 : // Draw options
1716 0 : if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SDRAW ) )
1717 : {
1718 0 : if ( aFactory == "com.sun.star.drawing.DrawingDocument" )
1719 : {
1720 0 : if ( !lcl_isOptionHidden( SID_SD_GRAPHIC_OPTIONS, aOptionsDlgOpt ) )
1721 : {
1722 0 : ResStringArray& rDrawArray = aDlgResource.GetDrawArray();
1723 0 : setGroupName( "Draw", rDrawArray.GetString(0) );
1724 0 : nGroup = AddGroup( rDrawArray.GetString( 0 ), pSdMod, pSdMod, SID_SD_GRAPHIC_OPTIONS );
1725 0 : const sal_uInt16 nCount = static_cast< const sal_uInt16 >( rDrawArray.Count() );
1726 0 : for ( i = 1; i < nCount; ++i )
1727 : {
1728 0 : nPageId = (sal_uInt16)rDrawArray.GetValue(i);
1729 0 : if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1730 0 : continue;
1731 :
1732 0 : AddTabPage( nPageId, rDrawArray.GetString(i), nGroup );
1733 : }
1734 : }
1735 : }
1736 : }
1737 :
1738 : // Math options
1739 0 : if ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SMATH ) )
1740 : {
1741 0 : if ( aFactory == "com.sun.star.formula.FormulaProperties" )
1742 : {
1743 0 : if ( !lcl_isOptionHidden( SID_SM_EDITOPTIONS, aOptionsDlgOpt ) )
1744 : {
1745 0 : ResStringArray& rStarMathArray = aDlgResource.GetStarMathArray();
1746 0 : SfxModule* pSmMod = (*(SfxModule**) GetAppData(SHL_SM));
1747 0 : setGroupName( "Math", rStarMathArray.GetString(0) );
1748 0 : nGroup = AddGroup(rStarMathArray.GetString(0), pSmMod, pSmMod, SID_SM_EDITOPTIONS );
1749 0 : for ( i = 1; i < rStarMathArray.Count(); ++i )
1750 : {
1751 0 : nPageId = (sal_uInt16)rStarMathArray.GetValue(i);
1752 0 : if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1753 0 : AddTabPage( nPageId, rStarMathArray.GetString(i), nGroup );
1754 : }
1755 : }
1756 : }
1757 : }
1758 :
1759 : // Database - needed only if there is an application which integrates with databases
1760 0 : if ( !lcl_isOptionHidden( SID_SB_STARBASEOPTIONS, aOptionsDlgOpt ) &&
1761 0 : ( aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SDATABASE )
1762 0 : || aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SWRITER )
1763 0 : || aModuleOpt.IsModuleInstalled( SvtModuleOptions::E_SCALC )
1764 : ) )
1765 : {
1766 0 : ResStringArray& rDSArray = aDlgResource.GetDatasourcesArray();
1767 0 : setGroupName( "Base", rDSArray.GetString(0) );
1768 0 : nGroup = AddGroup( rDSArray.GetString(0), 0, NULL, SID_SB_STARBASEOPTIONS );
1769 0 : for ( i = 1; i < rDSArray.Count(); ++i )
1770 : {
1771 0 : nPageId = (sal_uInt16)rDSArray.GetValue(i);
1772 0 : if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1773 0 : AddTabPage( nPageId, rDSArray.GetString(i), nGroup );
1774 : }
1775 : }
1776 :
1777 : // Chart options (always installed and active)
1778 0 : if ( !lcl_isOptionHidden( SID_SCH_EDITOPTIONS, aOptionsDlgOpt ) )
1779 : {
1780 0 : ResStringArray& rChartArray = aDlgResource.GetChartArray();
1781 0 : setGroupName( "Charts", rChartArray.GetString(0) );
1782 0 : nGroup = AddGroup( rChartArray.GetString(0), 0, 0, SID_SCH_EDITOPTIONS );
1783 0 : for ( i = 1; i < rChartArray.Count(); ++i )
1784 : {
1785 0 : nPageId = (sal_uInt16)rChartArray.GetValue(i);
1786 0 : if ( !lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1787 0 : AddTabPage( nPageId, rChartArray.GetString(i), nGroup );
1788 : }
1789 : }
1790 :
1791 : // Internet options
1792 0 : if ( !lcl_isOptionHidden( SID_INET_DLG, aOptionsDlgOpt ) )
1793 : {
1794 0 : ResStringArray& rInetArray = aDlgResource.GetInetArray();
1795 0 : setGroupName( "Internet", rInetArray.GetString(0) );
1796 0 : nGroup = AddGroup(rInetArray.GetString(0), 0, 0, SID_INET_DLG );
1797 :
1798 0 : for ( i = 1; i < rInetArray.Count(); ++i )
1799 : {
1800 0 : nPageId = (sal_uInt16)rInetArray.GetValue(i);
1801 0 : if ( lcl_isOptionHidden( nPageId, aOptionsDlgOpt ) )
1802 0 : continue;
1803 : #if defined WNT
1804 : // Disable E-mail tab-page on Windows
1805 : if ( nPageId == RID_SVXPAGE_INET_MAIL )
1806 : continue;
1807 : #endif
1808 : #if defined MACOSX
1809 : // Disable Mozilla Plug-in tab-page on Mac
1810 : if ( nPageId == RID_SVXPAGE_INET_MOZPLUGIN )
1811 : continue;
1812 : #endif
1813 : #ifdef LINUX
1814 : // Disable Mozilla Plug-in tab-page on Linux if we find a
1815 : // globally installed plugin
1816 0 : if ( nPageId == RID_SVXPAGE_INET_MOZPLUGIN ) {
1817 : struct stat sb;
1818 : char *p;
1819 0 : bool bHaveSystemWidePlugin = false;
1820 0 : 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";
1821 :
1822 0 : p = strtok(mozpaths, ":");
1823 0 : while (p != NULL) {
1824 0 : if (stat(p, &sb) != -1) {
1825 0 : bHaveSystemWidePlugin = true;
1826 0 : break;
1827 : }
1828 0 : p = strtok(NULL, ":");
1829 : }
1830 :
1831 0 : if (bHaveSystemWidePlugin == true)
1832 0 : continue;
1833 : }
1834 : #endif
1835 0 : AddTabPage( nPageId, rInetArray.GetString(i), nGroup );
1836 : }
1837 0 : }
1838 :
1839 : /*!!!
1840 : ResizeTreeLB();
1841 : ActivateLastSelection();
1842 : */
1843 0 : }
1844 :
1845 : namespace
1846 : {
1847 0 : void MoveControl( Control& _rCtrl, long _nDeltaPixel )
1848 : {
1849 0 : Point aPt( _rCtrl.GetPosPixel() );
1850 0 : aPt.X() += _nDeltaPixel;
1851 0 : _rCtrl.SetPosPixel( aPt );
1852 0 : }
1853 : }
1854 :
1855 0 : void OfaTreeOptionsDialog::ResizeTreeLB( void )
1856 : {
1857 0 : const long nMax = aSeparatorFL.GetSizePixel().Width() * 42 / 100;
1858 : // don't ask where 42 comes from... but it looks / feels ok ;-)
1859 0 : long nDelta = 50; // min.
1860 0 : sal_uInt16 nDepth = 0;
1861 0 : const long nIndent0 = PixelToLogic( Size( 28, 0 ) ).Width();
1862 0 : const long nIndent1 = PixelToLogic( Size( 52, 0 ) ).Width();
1863 :
1864 0 : SvTreeList* pTreeList = aTreeLB.GetModel();
1865 : DBG_ASSERT( pTreeList, "-OfaTreeOptionsDialog::ResizeTreeLB(): no model, no cookies!" );
1866 :
1867 0 : SvTreeListEntry* pEntry = pTreeList->First();
1868 0 : while( pEntry )
1869 : {
1870 0 : long n = aTreeLB.GetTextWidth(aTreeLB.GetEntryText(pEntry));
1871 0 : n += ((nDepth == 0) ? nIndent0 : nIndent1);
1872 :
1873 0 : if( n > nDelta )
1874 0 : nDelta = n;
1875 :
1876 0 : pEntry = pTreeList->Next( pEntry, &nDepth );
1877 : }
1878 :
1879 0 : nDelta = LogicToPixel( Size( nDelta + 3, 0 ) ).Width(); // + extra space [logic]
1880 0 : nDelta += GetSettings().GetStyleSettings().GetScrollBarSize(); // + scroll bar, in case it's needed
1881 :
1882 0 : if( nDelta > nMax )
1883 0 : nDelta = nMax;
1884 :
1885 : // starting resizing with this
1886 0 : Size aSize( GetSizePixel() );
1887 0 : aSize.Width() += nDelta;
1888 0 : SetSizePixel( aSize );
1889 :
1890 : // resize treelistbox
1891 0 : aSize = aTreeLB.GetSizePixel();
1892 0 : aSize.Width() += nDelta;
1893 0 : aTreeLB.SetSizePixel( aSize );
1894 :
1895 : // ... and move depending controls
1896 0 : MoveControl( aOkPB, nDelta );
1897 0 : MoveControl( aCancelPB, nDelta );
1898 0 : MoveControl( aHelpPB, nDelta );
1899 0 : MoveControl( aBackPB, nDelta );
1900 0 : MoveControl( aSeparatorFL, nDelta );
1901 0 : }
1902 :
1903 0 : bool isNodeActive( OptionsNode* pNode, Module* pModule )
1904 : {
1905 0 : if ( pNode )
1906 : {
1907 : // Node for all modules actine?
1908 0 : if ( pNode->m_bAllModules )
1909 0 : return true;
1910 :
1911 : // OOo-Nodes (Writer, Calc, Impress...) are active if node is already inserted
1912 0 : if ( !getGroupName( pNode->m_sId, false ).isEmpty() )
1913 0 : return true;
1914 :
1915 : // no module -> not active
1916 0 : if ( !pModule )
1917 0 : return false;
1918 :
1919 : // search node in active module
1920 0 : if ( pModule->m_bActive )
1921 : {
1922 0 : for ( sal_uInt32 j = 0; j < pModule->m_aNodeList.size(); ++j )
1923 0 : if ( pModule->m_aNodeList[j]->m_sId == pNode->m_sId )
1924 0 : return true;
1925 : }
1926 : }
1927 0 : return false;
1928 : }
1929 :
1930 0 : void OfaTreeOptionsDialog::LoadExtensionOptions( const OUString& rExtensionId )
1931 : {
1932 0 : Module* pModule = NULL;
1933 :
1934 : // when called by Tools - Options then load nodes of active module
1935 0 : if ( rExtensionId.isEmpty() )
1936 : {
1937 0 : pModule = LoadModule( GetModuleIdentifier( Reference< XFrame >() ) );
1938 : }
1939 :
1940 0 : VectorOfNodes aNodeList = LoadNodes( pModule, rExtensionId );
1941 0 : InsertNodes( aNodeList );
1942 :
1943 0 : delete pModule;
1944 0 : }
1945 :
1946 0 : OUString OfaTreeOptionsDialog::GetModuleIdentifier( const Reference< XFrame >& rFrame )
1947 : {
1948 0 : OUString sModule;
1949 0 : Reference < XFrame > xCurrentFrame( rFrame );
1950 0 : Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
1951 0 : Reference < XModuleManager2 > xModuleManager = ModuleManager::create(xContext);
1952 :
1953 0 : if ( !xCurrentFrame.is() )
1954 : {
1955 0 : Reference < XDesktop2 > xDesktop = Desktop::create( xContext );
1956 0 : xCurrentFrame = xDesktop->getCurrentFrame();
1957 : }
1958 :
1959 0 : if ( xCurrentFrame.is() )
1960 : {
1961 : try
1962 : {
1963 0 : sModule = xModuleManager->identify( xCurrentFrame );
1964 : }
1965 0 : catch ( ::com::sun::star::frame::UnknownModuleException& )
1966 : {
1967 : DBG_WARNING( "OfaTreeOptionsDialog::GetModuleIdentifier(): unknown module" );
1968 : }
1969 0 : catch ( Exception& )
1970 : {
1971 : SAL_WARN( "cui.options", "OfaTreeOptionsDialog::GetModuleIdentifier(): exception of XModuleManager::identify()" );
1972 : }
1973 : }
1974 0 : return sModule;
1975 : }
1976 :
1977 0 : Module* OfaTreeOptionsDialog::LoadModule(
1978 : const OUString& rModuleIdentifier )
1979 : {
1980 0 : Module* pModule = NULL;
1981 : Reference< XNameAccess > xSet(
1982 0 : officecfg::Office::OptionsDialog::Modules::get());
1983 :
1984 0 : Sequence< OUString > seqNames = xSet->getElementNames();
1985 0 : for ( int i = 0; i < seqNames.getLength(); ++i )
1986 : {
1987 0 : OUString sModule( seqNames[i] );
1988 0 : if ( rModuleIdentifier == sModule )
1989 : {
1990 : // current active module found
1991 0 : pModule = new Module( sModule );
1992 0 : pModule->m_bActive = true;
1993 :
1994 0 : Reference< XNameAccess > xModAccess;
1995 0 : xSet->getByName( seqNames[i] ) >>= xModAccess;
1996 0 : if ( xModAccess.is() )
1997 : {
1998 : // load the nodes of this module
1999 0 : Reference< XNameAccess > xNodeAccess;
2000 0 : xModAccess->getByName( "Nodes" ) >>= xNodeAccess;
2001 0 : if ( xNodeAccess.is() )
2002 : {
2003 0 : Sequence< OUString > xTemp = xNodeAccess->getElementNames();
2004 0 : Reference< XNameAccess > xAccess;
2005 0 : sal_Int32 nIndex = -1;
2006 0 : for ( int x = 0; x < xTemp.getLength(); ++x )
2007 : {
2008 0 : xNodeAccess->getByName( xTemp[x] ) >>= xAccess;
2009 0 : if ( xAccess.is() )
2010 : {
2011 0 : xAccess->getByName( "Index" ) >>= nIndex;
2012 0 : if ( nIndex < 0 )
2013 : // append nodes with index < 0
2014 : pModule->m_aNodeList.push_back(
2015 0 : new OrderedEntry( nIndex, xTemp[x] ) );
2016 : else
2017 : {
2018 : // search position of the node
2019 0 : sal_uInt32 y = 0;
2020 0 : for ( ; y < pModule->m_aNodeList.size(); ++y )
2021 : {
2022 0 : sal_Int32 nNodeIdx = pModule->m_aNodeList[y]->m_nIndex;
2023 0 : if ( nNodeIdx < 0 || nNodeIdx > nIndex )
2024 : break;
2025 : }
2026 : // and insert the node on this position
2027 : pModule->m_aNodeList.insert(
2028 0 : pModule->m_aNodeList.begin() + y,
2029 0 : new OrderedEntry( nIndex, xTemp[x] ) );
2030 : }
2031 : }
2032 0 : }
2033 0 : }
2034 : }
2035 0 : break;
2036 : }
2037 0 : }
2038 0 : return pModule;
2039 : }
2040 :
2041 0 : VectorOfNodes OfaTreeOptionsDialog::LoadNodes(
2042 : Module* pModule, const OUString& rExtensionId)
2043 : {
2044 0 : VectorOfNodes aOutNodeList;
2045 :
2046 : Reference< XNameAccess > xSet(
2047 0 : officecfg::Office::OptionsDialog::Nodes::get());
2048 0 : VectorOfNodes aNodeList;
2049 0 : Sequence< OUString > seqNames = xSet->getElementNames();
2050 :
2051 0 : for ( int i = 0; i < seqNames.getLength(); ++i )
2052 : {
2053 0 : OUString sGroupName( seqNames[i] );
2054 0 : Reference< XNameAccess > xNodeAccess;
2055 0 : xSet->getByName( seqNames[i] ) >>= xNodeAccess;
2056 :
2057 0 : if ( xNodeAccess.is() )
2058 : {
2059 0 : OUString sNodeId, sLabel, sPageURL, sGroupId;
2060 0 : bool bAllModules = false;
2061 0 : sal_Int32 nGroupIndex = 0;
2062 :
2063 0 : sNodeId = seqNames[i];
2064 0 : xNodeAccess->getByName( "Label" ) >>= sLabel;
2065 0 : xNodeAccess->getByName( "OptionsPage" ) >>= sPageURL;
2066 0 : xNodeAccess->getByName( "AllModules" ) >>= bAllModules;
2067 0 : xNodeAccess->getByName( "GroupId" ) >>= sGroupId;
2068 0 : xNodeAccess->getByName( "GroupIndex" ) >>= nGroupIndex;
2069 :
2070 0 : if ( sLabel.isEmpty() )
2071 0 : sLabel = sGroupName;
2072 0 : OUString sTemp = getGroupName( sLabel, !rExtensionId.isEmpty() );
2073 0 : if ( !sTemp.isEmpty() )
2074 0 : sLabel = sTemp;
2075 : OptionsNode* pNode =
2076 0 : new OptionsNode( sNodeId, sLabel, sPageURL, bAllModules, sGroupId, nGroupIndex );
2077 :
2078 0 : if ( rExtensionId.isEmpty() && !isNodeActive( pNode, pModule ) )
2079 : {
2080 0 : delete pNode;
2081 0 : continue;
2082 : }
2083 :
2084 0 : Reference< XNameAccess > xLeavesSet;
2085 0 : xNodeAccess->getByName( "Leaves" ) >>= xLeavesSet;
2086 0 : if ( xLeavesSet.is() )
2087 : {
2088 0 : Sequence< OUString > seqLeaves = xLeavesSet->getElementNames();
2089 0 : for ( int j = 0; j < seqLeaves.getLength(); ++j )
2090 : {
2091 0 : Reference< XNameAccess > xLeaveAccess;
2092 0 : xLeavesSet->getByName( seqLeaves[j] ) >>= xLeaveAccess;
2093 :
2094 0 : if ( xLeaveAccess.is() )
2095 : {
2096 0 : OUString sId, sLeafLabel, sEventHdl, sLeafURL, sLeafGrpId;
2097 0 : sal_Int32 nLeafGrpIdx = 0;
2098 :
2099 0 : xLeaveAccess->getByName( "Id" ) >>= sId;
2100 0 : xLeaveAccess->getByName( "Label" ) >>= sLeafLabel;
2101 0 : xLeaveAccess->getByName( "OptionsPage" ) >>= sLeafURL;
2102 0 : xLeaveAccess->getByName( "EventHandlerService" ) >>= sEventHdl;
2103 0 : xLeaveAccess->getByName( "GroupId" ) >>= sLeafGrpId;
2104 0 : xLeaveAccess->getByName( "GroupIndex" ) >>= nLeafGrpIdx;
2105 :
2106 0 : if ( rExtensionId.isEmpty() || sId == rExtensionId )
2107 : {
2108 : OptionsLeaf* pLeaf = new OptionsLeaf(
2109 0 : sId, sLeafLabel, sLeafURL, sEventHdl, sLeafGrpId, nLeafGrpIdx );
2110 :
2111 0 : if ( !sLeafGrpId.isEmpty() )
2112 : {
2113 0 : bool bAlreadyOpened = false;
2114 0 : if ( pNode->m_aGroupedLeaves.size() > 0 )
2115 : {
2116 0 : for ( sal_uInt32 k = 0;
2117 0 : k < pNode->m_aGroupedLeaves.size(); ++k )
2118 : {
2119 0 : if ( pNode->m_aGroupedLeaves[k].size() > 0 &&
2120 0 : pNode->m_aGroupedLeaves[k][0]->m_sGroupId
2121 0 : == sLeafGrpId )
2122 : {
2123 0 : sal_uInt32 l = 0;
2124 0 : for ( ; l < pNode->m_aGroupedLeaves[k].size(); ++l )
2125 : {
2126 0 : if ( pNode->m_aGroupedLeaves[k][l]->
2127 0 : m_nGroupIndex >= nLeafGrpIdx )
2128 0 : break;
2129 : }
2130 0 : pNode->m_aGroupedLeaves[k].insert(
2131 0 : pNode->m_aGroupedLeaves[k].begin() + l, pLeaf );
2132 0 : bAlreadyOpened = true;
2133 0 : break;
2134 : }
2135 : }
2136 : }
2137 0 : if ( !bAlreadyOpened )
2138 : {
2139 0 : VectorOfLeaves aGroupedLeaves;
2140 0 : aGroupedLeaves.push_back( pLeaf );
2141 0 : pNode->m_aGroupedLeaves.push_back( aGroupedLeaves );
2142 : }
2143 : }
2144 : else
2145 0 : pNode->m_aLeaves.push_back( pLeaf );
2146 0 : }
2147 : }
2148 0 : }
2149 : }
2150 :
2151 : // do not insert nodes without leaves
2152 0 : if ( pNode->m_aLeaves.size() > 0 || pNode->m_aGroupedLeaves.size() > 0 )
2153 : {
2154 0 : pModule ? aNodeList.push_back( pNode ) : aOutNodeList.push_back( pNode );
2155 : }
2156 : else
2157 0 : delete pNode;
2158 : }
2159 0 : }
2160 :
2161 0 : if ( pModule && aNodeList.size() > 0 )
2162 : {
2163 0 : sal_uInt32 i = 0, j = 0;
2164 0 : for ( ; i < pModule->m_aNodeList.size(); ++i )
2165 : {
2166 0 : OUString sNodeId = pModule->m_aNodeList[i]->m_sId;
2167 0 : for ( j = 0; j < aNodeList.size(); ++j )
2168 : {
2169 0 : OptionsNode* pNode = aNodeList[j];
2170 0 : if ( pNode->m_sId == sNodeId )
2171 : {
2172 0 : aOutNodeList.push_back( pNode );
2173 0 : aNodeList.erase( aNodeList.begin() + j );
2174 0 : break;
2175 : }
2176 : }
2177 0 : }
2178 :
2179 0 : for ( i = 0; i < aNodeList.size(); ++i )
2180 0 : aOutNodeList.push_back( aNodeList[i] );
2181 : }
2182 0 : return aOutNodeList;
2183 : }
2184 :
2185 0 : static sal_uInt16 lcl_getGroupId( const OUString& rGroupName, const SvTreeListBox& rTreeLB )
2186 : {
2187 0 : OUString sGroupName( rGroupName );
2188 0 : sal_uInt16 nRet = 0;
2189 0 : SvTreeListEntry* pEntry = rTreeLB.First();
2190 0 : while( pEntry )
2191 : {
2192 0 : if ( !rTreeLB.GetParent( pEntry ) )
2193 : {
2194 0 : OUString sTemp( rTreeLB.GetEntryText( pEntry ) );
2195 0 : if ( sTemp == sGroupName )
2196 0 : return nRet;
2197 0 : nRet++;
2198 : }
2199 0 : pEntry = rTreeLB.Next( pEntry );
2200 : }
2201 :
2202 0 : return USHRT_MAX;
2203 : }
2204 :
2205 0 : static void lcl_insertLeaf(
2206 : OfaTreeOptionsDialog* pDlg, OptionsNode* pNode, OptionsLeaf* pLeaf, const SvTreeListBox& rTreeLB )
2207 : {
2208 0 : sal_uInt16 nGrpId = lcl_getGroupId( pNode->m_sLabel, rTreeLB );
2209 0 : if ( USHRT_MAX == nGrpId )
2210 : {
2211 0 : sal_uInt16 nNodeGrpId = getGroupNodeId( pNode->m_sId );
2212 0 : nGrpId = pDlg->AddGroup( pNode->m_sLabel, NULL, NULL, nNodeGrpId );
2213 0 : if ( !pNode->m_sPageURL.isEmpty() )
2214 : {
2215 0 : SvTreeListEntry* pGrpEntry = rTreeLB.GetEntry( 0, nGrpId );
2216 : DBG_ASSERT( pGrpEntry, "OfaTreeOptionsDialog::InsertNodes(): no group" );
2217 0 : if ( pGrpEntry )
2218 : {
2219 : OptionsGroupInfo* pGrpInfo =
2220 0 : static_cast<OptionsGroupInfo*>(pGrpEntry->GetUserData());
2221 0 : pGrpInfo->m_sPageURL = pNode->m_sPageURL;
2222 : }
2223 : }
2224 : }
2225 0 : OptionsPageInfo* pInfo = pDlg->AddTabPage( 0, pLeaf->m_sLabel, nGrpId );
2226 0 : pInfo->m_sPageURL = pLeaf->m_sPageURL;
2227 0 : pInfo->m_sEventHdl = pLeaf->m_sEventHdl;
2228 0 : }
2229 :
2230 0 : void OfaTreeOptionsDialog::InsertNodes( const VectorOfNodes& rNodeList )
2231 : {
2232 0 : for ( sal_uInt32 i = 0; i < rNodeList.size(); ++i )
2233 : {
2234 0 : OptionsNode* pNode = rNodeList[i];
2235 :
2236 0 : if ( pNode->m_aLeaves.size() > 0 || pNode->m_aGroupedLeaves.size() > 0 )
2237 : {
2238 0 : sal_uInt32 j = 0;
2239 0 : for ( ; j < pNode->m_aGroupedLeaves.size(); ++j )
2240 : {
2241 0 : for ( sal_uInt32 k = 0; k < pNode->m_aGroupedLeaves[j].size(); ++k )
2242 : {
2243 0 : OptionsLeaf* pLeaf = pNode->m_aGroupedLeaves[j][k];
2244 0 : lcl_insertLeaf( this, pNode, pLeaf, aTreeLB );
2245 : }
2246 : }
2247 :
2248 0 : for ( j = 0; j < pNode->m_aLeaves.size(); ++j )
2249 : {
2250 0 : OptionsLeaf* pLeaf = pNode->m_aLeaves[j];
2251 0 : lcl_insertLeaf( this, pNode, pLeaf, aTreeLB );
2252 : }
2253 : }
2254 : }
2255 0 : }
2256 :
2257 0 : short OfaTreeOptionsDialog::Execute()
2258 : {
2259 0 : boost::scoped_ptr< SvxDicListChgClamp > pClamp;
2260 0 : if ( !bIsFromExtensionManager )
2261 : {
2262 : // collect all DictionaryList Events while the dialog is executed
2263 0 : Reference<com::sun::star::linguistic2::XSearchableDictionaryList> xDictionaryList(SvxGetDictionaryList());
2264 0 : pClamp.reset( new SvxDicListChgClamp( xDictionaryList ) );
2265 : }
2266 0 : short nRet = SfxModalDialog::Execute();
2267 :
2268 0 : if( RET_OK == nRet )
2269 : {
2270 0 : ApplyItemSets();
2271 0 : if( mpColorPage )
2272 0 : mpColorPage->SaveToViewFrame( SfxViewFrame::Current() );
2273 0 : utl::ConfigManager::storeConfigItems();
2274 : }
2275 :
2276 0 : return nRet;
2277 : }
2278 :
2279 : // class ExtensionsTabPage -----------------------------------------------
2280 :
2281 0 : ExtensionsTabPage::ExtensionsTabPage(
2282 : Window* pParent, WinBits nStyle, const OUString& rPageURL,
2283 : const OUString& rEvtHdl, const Reference< awt::XContainerWindowProvider >& rProvider ) :
2284 :
2285 : TabPage( pParent, nStyle ),
2286 :
2287 : m_sPageURL ( rPageURL ),
2288 : m_sEventHdl ( rEvtHdl ),
2289 : m_xWinProvider ( rProvider ),
2290 0 : m_bIsWindowHidden ( false )
2291 :
2292 : {
2293 0 : }
2294 :
2295 :
2296 :
2297 0 : ExtensionsTabPage::~ExtensionsTabPage()
2298 : {
2299 0 : Hide();
2300 0 : DeactivatePage();
2301 :
2302 0 : if ( m_xPage.is() )
2303 : {
2304 0 : Reference< XComponent > xComponent( m_xPage, UNO_QUERY );
2305 0 : if ( xComponent.is() )
2306 : {
2307 : try
2308 : {
2309 0 : xComponent->dispose();
2310 : }
2311 0 : catch ( const Exception & )
2312 : {
2313 : }
2314 : }
2315 0 : m_xPage.clear();
2316 : }
2317 0 : }
2318 :
2319 :
2320 :
2321 0 : void ExtensionsTabPage::CreateDialogWithHandler()
2322 : {
2323 : try
2324 : {
2325 0 : bool bWithHandler = ( !m_sEventHdl.isEmpty() );
2326 0 : if ( bWithHandler )
2327 : {
2328 0 : Reference < XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() );
2329 0 : m_xEventHdl = Reference< awt::XContainerWindowEventHandler >(
2330 0 : xFactory->createInstance( m_sEventHdl ), UNO_QUERY );
2331 : }
2332 :
2333 0 : if ( !bWithHandler || m_xEventHdl.is() )
2334 : {
2335 0 : SetStyle( GetStyle() | WB_DIALOGCONTROL | WB_CHILDDLGCTRL );
2336 0 : Reference< awt::XWindowPeer > xParent( VCLUnoHelper::GetInterface( this ), UNO_QUERY );
2337 0 : m_xPage = Reference < awt::XWindow >(
2338 0 : m_xWinProvider->createContainerWindow(
2339 0 : m_sPageURL, OUString(), xParent, m_xEventHdl ), UNO_QUERY );
2340 :
2341 0 : Reference< awt::XControl > xPageControl( m_xPage, UNO_QUERY );
2342 0 : if ( xPageControl.is() )
2343 : {
2344 0 : Reference< awt::XWindowPeer > xWinPeer( xPageControl->getPeer() );
2345 0 : if ( xWinPeer.is() )
2346 : {
2347 0 : Window* pWindow = VCLUnoHelper::GetWindow( xWinPeer );
2348 0 : if ( pWindow )
2349 0 : pWindow->SetStyle( pWindow->GetStyle() | WB_DIALOGCONTROL | WB_CHILDDLGCTRL );
2350 0 : }
2351 0 : }
2352 : }
2353 : }
2354 0 : catch ( ::com::sun::star::lang::IllegalArgumentException& )
2355 : {
2356 : SAL_WARN( "cui.options", "ExtensionsTabPage::CreateDialogWithHandler(): illegal argument" );
2357 : }
2358 0 : catch ( Exception& )
2359 : {
2360 : SAL_WARN( "cui.options", "ExtensionsTabPage::CreateDialogWithHandler(): exception of XDialogProvider2::createDialogWithHandler()" );
2361 : }
2362 0 : }
2363 :
2364 :
2365 :
2366 0 : sal_Bool ExtensionsTabPage::DispatchAction( const OUString& rAction )
2367 : {
2368 0 : sal_Bool bRet = sal_False;
2369 0 : if ( m_xEventHdl.is() )
2370 : {
2371 : try
2372 : {
2373 0 : bRet = m_xEventHdl->callHandlerMethod( m_xPage, makeAny( rAction ), "external_event" );
2374 : }
2375 0 : catch ( Exception& )
2376 : {
2377 : SAL_WARN( "cui.options", "ExtensionsTabPage::DispatchAction(): exception of XDialogEventHandler::callHandlerMethod()" );
2378 : }
2379 : }
2380 0 : return bRet;
2381 : }
2382 :
2383 :
2384 :
2385 0 : void ExtensionsTabPage::ActivatePage()
2386 : {
2387 0 : TabPage::ActivatePage();
2388 :
2389 0 : if ( !m_xPage.is() )
2390 : {
2391 0 : CreateDialogWithHandler();
2392 :
2393 0 : if ( m_xPage.is() )
2394 : {
2395 0 : Point aPos = Point();
2396 0 : Size aSize = GetSizePixel();
2397 0 : m_xPage->setPosSize( aPos.X() + 1, aPos.Y() + 1,
2398 0 : aSize.Width() - 2, aSize.Height() - 2, awt::PosSize::POSSIZE );
2399 0 : if ( !m_sEventHdl.isEmpty() )
2400 0 : DispatchAction( "initialize" );
2401 : }
2402 : }
2403 :
2404 0 : if ( m_xPage.is() )
2405 : {
2406 0 : m_xPage->setVisible( sal_True );
2407 0 : m_bIsWindowHidden = false;
2408 : }
2409 0 : }
2410 :
2411 :
2412 :
2413 0 : void ExtensionsTabPage::DeactivatePage()
2414 : {
2415 0 : TabPage::DeactivatePage();
2416 :
2417 0 : if ( m_xPage.is() )
2418 0 : m_xPage->setVisible( sal_False );
2419 0 : }
2420 :
2421 :
2422 :
2423 0 : void ExtensionsTabPage::ResetPage()
2424 : {
2425 0 : DispatchAction( "back" );
2426 0 : ActivatePage();
2427 0 : }
2428 :
2429 :
2430 :
2431 0 : void ExtensionsTabPage::SavePage()
2432 : {
2433 0 : DispatchAction( "ok" );
2434 0 : }
2435 :
2436 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|