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