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