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