Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <com/sun/star/uno/Reference.hxx>
21 : #include <com/sun/star/frame/XDesktop.hpp>
22 : #include <com/sun/star/util/XURLTransformer.hpp>
23 : #include <com/sun/star/beans/PropertyValue.hpp>
24 : #include <com/sun/star/beans/XPropertySet.hpp>
25 : #include <com/sun/star/util/XFlushable.hpp>
26 :
27 : #include <stdlib.h>
28 : #include <vcl/msgbox.hxx>
29 : #include <rtl/ustring.hxx>
30 : #include <svl/itempool.hxx>
31 : #include <svl/aeitem.hxx>
32 : #include <svl/slstitm.hxx>
33 : #include <svl/stritem.hxx>
34 : #include <svl/intitem.hxx>
35 : #include <svl/eitem.hxx>
36 : #include <svl/szitem.hxx>
37 : #include <svl/undo.hxx>
38 :
39 : #include <sfx2/sfxsids.hrc>
40 : #include <sot/exchange.hxx>
41 :
42 : #include <svl/isethint.hxx>
43 :
44 : #include <officecfg/Inet.hxx>
45 : #include <officecfg/Office/Common.hxx>
46 : #include <unotools/configmgr.hxx>
47 : #include <tools/urlobj.hxx>
48 : #include <unotools/saveopt.hxx>
49 : #include <svtools/helpopt.hxx>
50 : #include <unotools/securityoptions.hxx>
51 : #include <unotools/pathoptions.hxx>
52 : #include <svtools/miscopt.hxx>
53 : #include <vcl/toolbox.hxx>
54 : #include <unotools/localfilehelper.hxx>
55 : #include <rtl/strbuf.hxx>
56 : #include <rtl/ustrbuf.hxx>
57 :
58 : #include <sfx2/app.hxx>
59 : #include <sfx2/docfile.hxx>
60 : #include <sfx2/viewfrm.hxx>
61 : #include <sfx2/sfxhelp.hxx>
62 : #include "sfxtypes.hxx"
63 : #include <sfx2/dispatch.hxx>
64 : #include <sfx2/objsh.hxx>
65 : #include "objshimp.hxx"
66 : #include <sfx2/viewsh.hxx>
67 : #include <sfx2/request.hxx>
68 : #include <sfx2/evntconf.hxx>
69 : #include "appdata.hxx"
70 : #include "workwin.hxx"
71 : #include "helper.hxx"
72 : #include "app.hrc"
73 : #include <sfx2/sfxresid.hxx>
74 : #include "shutdownicon.hxx"
75 :
76 : using namespace ::com::sun::star::uno;
77 : using namespace ::com::sun::star::util;
78 : using namespace ::com::sun::star::frame;
79 : using namespace ::com::sun::star::beans;
80 :
81 :
82 :
83 : class SfxEventAsyncer_Impl : public SfxListener
84 : {
85 : SfxEventHint aHint;
86 : Timer* pTimer;
87 :
88 : public:
89 :
90 : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
91 : SfxEventAsyncer_Impl( const SfxEventHint& rHint );
92 : virtual ~SfxEventAsyncer_Impl();
93 : DECL_LINK( TimerHdl, Timer*);
94 : };
95 :
96 :
97 :
98 194208 : void SfxEventAsyncer_Impl::Notify( SfxBroadcaster&, const SfxHint& rHint )
99 : {
100 194208 : const SfxSimpleHint* pHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
101 194208 : if( pHint && pHint->GetId() == SFX_HINT_DYING && pTimer->IsActive() )
102 : {
103 4268 : pTimer->Stop();
104 4268 : delete this;
105 : }
106 194208 : }
107 :
108 :
109 :
110 6302 : SfxEventAsyncer_Impl::SfxEventAsyncer_Impl( const SfxEventHint& rHint )
111 6302 : : aHint( rHint )
112 : {
113 6302 : if( rHint.GetObjShell() )
114 6302 : StartListening( *rHint.GetObjShell() );
115 6302 : pTimer = new Timer;
116 6302 : pTimer->SetTimeoutHdl( LINK(this, SfxEventAsyncer_Impl, TimerHdl) );
117 6302 : pTimer->SetTimeout( 0 );
118 6302 : pTimer->Start();
119 6302 : }
120 :
121 :
122 :
123 18906 : SfxEventAsyncer_Impl::~SfxEventAsyncer_Impl()
124 : {
125 6302 : delete pTimer;
126 12604 : }
127 :
128 :
129 :
130 4068 : IMPL_LINK(SfxEventAsyncer_Impl, TimerHdl, Timer*, pAsyncTimer)
131 : {
132 : (void)pAsyncTimer; // unused variable
133 2034 : SfxObjectShellRef xRef( aHint.GetObjShell() );
134 2034 : pAsyncTimer->Stop();
135 : #ifdef DBG_UTIL
136 : if (!xRef.Is())
137 : {
138 : OStringBuffer aTmp("SfxEvent: ");
139 : aTmp.append(OUStringToOString(aHint.GetEventName(), RTL_TEXTENCODING_UTF8));
140 : OSL_TRACE( "%s", aTmp.getStr() );
141 : }
142 : #endif
143 2034 : SfxGetpApp()->Broadcast( aHint );
144 2034 : if ( xRef.Is() )
145 2034 : xRef->Broadcast( aHint );
146 2034 : delete this;
147 2034 : return 0L;
148 : }
149 :
150 :
151 :
152 :
153 0 : bool SfxApplication::GetOptions( SfxItemSet& rSet )
154 : {
155 0 : bool bRet = false;
156 0 : SfxItemPool &rPool = GetPool();
157 :
158 0 : const sal_uInt16 *pRanges = rSet.GetRanges();
159 0 : SvtSaveOptions aSaveOptions;
160 0 : SvtHelpOptions aHelpOptions;
161 0 : SvtSecurityOptions aSecurityOptions;
162 0 : SvtMiscOptions aMiscOptions;
163 :
164 0 : while ( *pRanges )
165 : {
166 0 : for(sal_uInt16 nWhich = *pRanges++; nWhich <= *pRanges; ++nWhich)
167 : {
168 0 : switch(nWhich)
169 : {
170 : case SID_ATTR_BUTTON_OUTSTYLE3D :
171 0 : if(rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_BUTTON_OUTSTYLE3D ),
172 0 : aMiscOptions.GetToolboxStyle() != TOOLBOX_STYLE_FLAT)))
173 0 : bRet = true;
174 0 : break;
175 : case SID_ATTR_BUTTON_BIGSIZE :
176 : {
177 0 : if( rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_BUTTON_BIGSIZE ), aMiscOptions.AreCurrentSymbolsLarge() ) ) )
178 0 : bRet = true;
179 0 : break;
180 : }
181 : case SID_ATTR_BACKUP :
182 : {
183 0 : bRet = true;
184 0 : if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_BACKUP))
185 0 : if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_BACKUP ),aSaveOptions.IsBackup())))
186 0 : bRet = false;
187 : }
188 0 : break;
189 : case SID_ATTR_PRETTYPRINTING:
190 : {
191 0 : bRet = true;
192 0 : if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_DOPRETTYPRINTING))
193 0 : if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_PRETTYPRINTING ), aSaveOptions.IsPrettyPrinting())))
194 0 : bRet = false;
195 : }
196 0 : break;
197 : case SID_ATTR_WARNALIENFORMAT:
198 : {
199 0 : bRet = true;
200 0 : if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_WARNALIENFORMAT))
201 0 : if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_WARNALIENFORMAT ), aSaveOptions.IsWarnAlienFormat())))
202 0 : bRet = false;
203 : }
204 0 : break;
205 : case SID_ATTR_AUTOSAVE :
206 : {
207 0 : bRet = true;
208 0 : if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_AUTOSAVE))
209 0 : if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_AUTOSAVE ), aSaveOptions.IsAutoSave())))
210 0 : bRet = false;
211 : }
212 0 : break;
213 : case SID_ATTR_AUTOSAVEPROMPT :
214 : {
215 0 : bRet = true;
216 0 : if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_AUTOSAVEPROMPT))
217 0 : if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_AUTOSAVEPROMPT ), aSaveOptions.IsAutoSavePrompt())))
218 0 : bRet = false;
219 : }
220 0 : break;
221 : case SID_ATTR_AUTOSAVEMINUTE :
222 : {
223 0 : bRet = true;
224 0 : if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_AUTOSAVETIME))
225 0 : if (!rSet.Put( SfxUInt16Item( rPool.GetWhich( SID_ATTR_AUTOSAVEMINUTE ), (sal_uInt16)aSaveOptions.GetAutoSaveTime())))
226 0 : bRet = false;
227 : }
228 0 : break;
229 : case SID_ATTR_USERAUTOSAVE :
230 : {
231 0 : bRet = true;
232 0 : if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_USERAUTOSAVE))
233 0 : if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_USERAUTOSAVE ), aSaveOptions.IsUserAutoSave())))
234 0 : bRet = false;
235 : }
236 0 : break;
237 : case SID_ATTR_DOCINFO :
238 : {
239 0 : bRet = true;
240 0 : if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_DOCINFSAVE))
241 0 : if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_DOCINFO ), aSaveOptions.IsDocInfoSave())))
242 0 : bRet = false;
243 : }
244 0 : break;
245 : case SID_ATTR_WORKINGSET :
246 : {
247 0 : bRet = true;
248 0 : if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_SAVEWORKINGSET))
249 0 : if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_WORKINGSET ), aSaveOptions.IsSaveWorkingSet())))
250 0 : bRet = false;
251 : }
252 0 : break;
253 : case SID_ATTR_SAVEDOCVIEW :
254 : {
255 0 : bRet = true;
256 0 : if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_SAVEDOCVIEW))
257 0 : if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_SAVEDOCVIEW ), aSaveOptions.IsSaveDocView())))
258 0 : bRet = false;
259 : }
260 0 : break;
261 : case SID_ATTR_METRIC :
262 0 : break;
263 : case SID_HELPBALLOONS :
264 0 : if(rSet.Put( SfxBoolItem ( rPool.GetWhich( SID_HELPBALLOONS ),
265 0 : aHelpOptions.IsExtendedHelp() ) ) )
266 0 : bRet = true;
267 0 : break;
268 : case SID_HELPTIPS :
269 0 : if(rSet.Put( SfxBoolItem ( rPool.GetWhich( SID_HELPTIPS ),
270 0 : aHelpOptions.IsHelpTips() ) ) )
271 0 : bRet = true;
272 0 : break;
273 : case SID_ATTR_WELCOMESCREEN :
274 0 : if(rSet.Put( SfxBoolItem ( rPool.GetWhich( SID_ATTR_WELCOMESCREEN ),
275 0 : aHelpOptions.IsWelcomeScreen() ) ) )
276 0 : bRet = true;
277 0 : break;
278 : case SID_HELP_STYLESHEET :
279 0 : if(rSet.Put( SfxStringItem ( rPool.GetWhich( SID_HELP_STYLESHEET ),
280 0 : aHelpOptions.GetHelpStyleSheet() ) ) )
281 0 : bRet = true;
282 0 : break;
283 : case SID_ATTR_UNDO_COUNT :
284 0 : if (rSet.Put(
285 : SfxUInt16Item (
286 0 : rPool.GetWhich(SID_ATTR_UNDO_COUNT),
287 0 : officecfg::Office::Common::Undo::Steps::get())))
288 : {
289 0 : bRet = true;
290 : }
291 0 : break;
292 : case SID_ATTR_QUICKLAUNCHER :
293 : {
294 0 : if ( ShutdownIcon::IsQuickstarterInstalled() )
295 : {
296 0 : if ( rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_QUICKLAUNCHER ),
297 0 : ShutdownIcon::GetAutostart() ) ) )
298 0 : bRet = true;
299 : }
300 : else
301 : {
302 0 : rSet.DisableItem( rPool.GetWhich( SID_ATTR_QUICKLAUNCHER ) );
303 0 : bRet = true;
304 : }
305 0 : break;
306 : }
307 : case SID_SAVEREL_INET :
308 : {
309 0 : bRet = true;
310 0 : if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_SAVERELINET))
311 0 : if (!rSet.Put( SfxBoolItem ( rPool.GetWhich( SID_SAVEREL_INET ), aSaveOptions.IsSaveRelINet() )))
312 0 : bRet = false;
313 : }
314 0 : break;
315 : case SID_SAVEREL_FSYS :
316 : {
317 0 : bRet = true;
318 0 : if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_SAVERELFSYS))
319 0 : if (!rSet.Put( SfxBoolItem ( rPool.GetWhich( SID_SAVEREL_FSYS ), aSaveOptions.IsSaveRelFSys() )))
320 0 : bRet = false;
321 : }
322 0 : break;
323 : case SID_BASIC_ENABLED :
324 : {
325 0 : bRet = true;
326 0 : if (!aSecurityOptions.IsReadOnly(SvtSecurityOptions::E_BASICMODE))
327 : {
328 0 : if ( !rSet.Put( SfxUInt16Item( rPool.GetWhich( SID_BASIC_ENABLED ), sal::static_int_cast< sal_uInt16 >(aSecurityOptions.GetBasicMode()))))
329 0 : bRet = false;
330 : }
331 : }
332 0 : break;
333 : case SID_INET_EXE_PLUGIN :
334 : {
335 0 : bRet = true;
336 0 : if (!aSecurityOptions.IsReadOnly(SvtSecurityOptions::E_EXECUTEPLUGINS))
337 : {
338 0 : if ( !rSet.Put( SfxBoolItem( SID_INET_EXE_PLUGIN, aSecurityOptions.IsExecutePlugins() ) ) )
339 0 : bRet = false;
340 : }
341 : }
342 0 : break;
343 : case SID_MACRO_WARNING :
344 : {
345 0 : bRet = true;
346 0 : if (!aSecurityOptions.IsReadOnly(SvtSecurityOptions::E_WARNING))
347 : {
348 0 : if ( !rSet.Put( SfxBoolItem( SID_MACRO_WARNING, aSecurityOptions.IsWarningEnabled() ) ) )
349 0 : bRet = false;
350 : }
351 : }
352 0 : break;
353 : case SID_MACRO_CONFIRMATION :
354 : {
355 0 : bRet = true;
356 0 : if (!aSecurityOptions.IsReadOnly(SvtSecurityOptions::E_CONFIRMATION))
357 : {
358 0 : if ( !rSet.Put( SfxBoolItem( SID_MACRO_CONFIRMATION, aSecurityOptions.IsConfirmationEnabled() ) ) )
359 0 : bRet = false;
360 : }
361 : }
362 0 : break;
363 : case SID_SECURE_URL :
364 : {
365 0 : bRet = true;
366 0 : if (!aSecurityOptions.IsReadOnly(SvtSecurityOptions::E_SECUREURLS))
367 : {
368 0 : ::com::sun::star::uno::Sequence< OUString > seqURLs = aSecurityOptions.GetSecureURLs();
369 0 : std::vector<OUString> aList;
370 0 : sal_uInt32 nCount = seqURLs.getLength();
371 0 : for( sal_uInt32 nURL=0; nURL<nCount; ++nURL )
372 0 : aList.push_back(seqURLs[nURL]);
373 :
374 0 : if( !rSet.Put( SfxStringListItem( rPool.GetWhich(SID_SECURE_URL), &aList ) ) )
375 0 : bRet = false;
376 : }
377 : }
378 0 : break;
379 : case SID_INET_PROXY_TYPE :
380 0 : if (rSet.Put(
381 : SfxUInt16Item(
382 0 : rPool.GetWhich(SID_INET_PROXY_TYPE),
383 : (officecfg::Inet::Settings::ooInetProxyType::
384 0 : get().get_value_or(0)))))
385 : {
386 0 : bRet = true;
387 : }
388 0 : break;
389 : case SID_INET_HTTP_PROXY_NAME :
390 0 : if (rSet.Put(
391 : SfxStringItem(
392 0 : rPool.GetWhich(SID_INET_HTTP_PROXY_NAME),
393 : officecfg::Inet::Settings::ooInetHTTPProxyName::
394 0 : get())))
395 : {
396 0 : bRet = true;
397 : }
398 0 : break;
399 : case SID_INET_HTTP_PROXY_PORT :
400 0 : if (rSet.Put(
401 : SfxInt32Item(
402 0 : rPool.GetWhich(SID_INET_HTTP_PROXY_PORT),
403 : (officecfg::Inet::Settings::
404 0 : ooInetHTTPProxyPort::get().get_value_or(0)))))
405 : {
406 0 : bRet = true;
407 : }
408 0 : break;
409 : case SID_INET_FTP_PROXY_NAME :
410 0 : if (rSet.Put(
411 : SfxStringItem(
412 0 : rPool.GetWhich(SID_INET_FTP_PROXY_NAME),
413 : officecfg::Inet::Settings::ooInetFTPProxyName::
414 0 : get())))
415 : {
416 0 : bRet = true;
417 : }
418 0 : break;
419 : case SID_INET_FTP_PROXY_PORT :
420 0 : if (rSet.Put(
421 : SfxInt32Item(
422 0 : rPool.GetWhich(SID_INET_FTP_PROXY_PORT),
423 : (officecfg::Inet::Settings::ooInetFTPProxyPort::
424 0 : get().get_value_or(0)))))
425 : {
426 0 : bRet = true;
427 : }
428 0 : break;
429 : case SID_INET_NOPROXY :
430 0 : if (rSet.Put(
431 : SfxStringItem(
432 0 : rPool.GetWhich( SID_INET_NOPROXY),
433 : (officecfg::Inet::Settings::ooInetNoProxy::
434 0 : get()))))
435 : {
436 0 : bRet = true;
437 : }
438 0 : break;
439 : case SID_ATTR_PATHNAME :
440 : case SID_ATTR_PATHGROUP :
441 : {
442 0 : SfxAllEnumItem aNames(rPool.GetWhich(SID_ATTR_PATHGROUP));
443 0 : SfxAllEnumItem aValues(rPool.GetWhich(SID_ATTR_PATHNAME));
444 0 : SvtPathOptions aPathCfg;
445 0 : for ( sal_uInt16 nProp = SvtPathOptions::PATH_ADDIN;
446 : nProp <= SvtPathOptions::PATH_WORK; nProp++ )
447 : {
448 0 : aNames.InsertValue( nProp, SfxResId(CONFIG_PATH_START + nProp).toString() );
449 0 : OUString aValue;
450 0 : switch ( nProp )
451 : {
452 0 : case SvtPathOptions::PATH_ADDIN: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg.GetAddinPath(), aValue ); break;
453 0 : case SvtPathOptions::PATH_AUTOCORRECT: aValue = aPathCfg.GetAutoCorrectPath(); break;
454 0 : case SvtPathOptions::PATH_AUTOTEXT: aValue = aPathCfg.GetAutoTextPath(); break;
455 0 : case SvtPathOptions::PATH_BACKUP: aValue = aPathCfg.GetBackupPath(); break;
456 0 : case SvtPathOptions::PATH_BASIC: aValue = aPathCfg.GetBasicPath(); break;
457 0 : case SvtPathOptions::PATH_BITMAP: aValue = aPathCfg.GetBitmapPath(); break;
458 0 : case SvtPathOptions::PATH_CONFIG: aValue = aPathCfg.GetConfigPath(); break;
459 0 : case SvtPathOptions::PATH_DICTIONARY: aValue = aPathCfg.GetDictionaryPath(); break;
460 0 : case SvtPathOptions::PATH_FAVORITES: aValue = aPathCfg.GetFavoritesPath(); break;
461 0 : case SvtPathOptions::PATH_FILTER: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg.GetFilterPath(), aValue ); break;
462 0 : case SvtPathOptions::PATH_GALLERY: aValue = aPathCfg.GetGalleryPath(); break;
463 0 : case SvtPathOptions::PATH_GRAPHIC: aValue = aPathCfg.GetGraphicPath(); break;
464 0 : case SvtPathOptions::PATH_HELP: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg.GetHelpPath(), aValue ); break;
465 0 : case SvtPathOptions::PATH_LINGUISTIC: aValue = aPathCfg.GetLinguisticPath(); break;
466 0 : case SvtPathOptions::PATH_MODULE: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg.GetModulePath(), aValue ); break;
467 0 : case SvtPathOptions::PATH_PALETTE: aValue = aPathCfg.GetPalettePath(); break;
468 0 : case SvtPathOptions::PATH_PLUGIN: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg.GetPluginPath(), aValue ); break;
469 0 : case SvtPathOptions::PATH_STORAGE: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg.GetStoragePath(), aValue ); break;
470 0 : case SvtPathOptions::PATH_TEMP: aValue = aPathCfg.GetTempPath(); break;
471 0 : case SvtPathOptions::PATH_TEMPLATE: aValue = aPathCfg.GetTemplatePath(); break;
472 0 : case SvtPathOptions::PATH_USERCONFIG: aValue = aPathCfg.GetUserConfigPath(); break;
473 0 : case SvtPathOptions::PATH_WORK: aValue = aPathCfg.GetWorkPath(); break;
474 : }
475 0 : aValues.InsertValue( nProp, aValue );
476 0 : }
477 :
478 0 : if ( rSet.Put(aNames) || rSet.Put(aValues) )
479 0 : bRet = true;
480 : }
481 0 : break;
482 :
483 : default:
484 : DBG_WARNING( "W1:Wrong ID while getting Options!" );
485 0 : break;
486 : }
487 : #ifdef DBG_UTIL
488 : if ( !bRet )
489 : OSL_FAIL( "Putting options failed!" );
490 : #endif
491 : }
492 0 : pRanges++;
493 : }
494 :
495 0 : return bRet;
496 : }
497 :
498 : // TODO/CLEANUP: Why two SetOptions Methods?
499 0 : void SfxApplication::SetOptions_Impl( const SfxItemSet& rSet )
500 : {
501 0 : const SfxPoolItem *pItem = 0;
502 0 : SfxItemPool &rPool = GetPool();
503 :
504 0 : SvtSaveOptions aSaveOptions;
505 0 : SvtHelpOptions aHelpOptions;
506 0 : SvtSecurityOptions aSecurityOptions;
507 0 : SvtMiscOptions aMiscOptions;
508 : boost::shared_ptr< comphelper::ConfigurationChanges > batch(
509 0 : comphelper::ConfigurationChanges::create());
510 0 : if ( SfxItemState::SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_BUTTON_OUTSTYLE3D), true, &pItem) )
511 : {
512 : DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
513 : sal_uInt16 nOutStyle =
514 0 : static_cast<const SfxBoolItem *>(pItem)->GetValue() ? 0 : TOOLBOX_STYLE_FLAT;
515 0 : aMiscOptions.SetToolboxStyle( nOutStyle );
516 : }
517 :
518 0 : if ( SfxItemState::SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_BUTTON_BIGSIZE), true, &pItem) )
519 : {
520 : DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
521 0 : bool bBigSize = static_cast<const SfxBoolItem*>(pItem)->GetValue();
522 : aMiscOptions.SetSymbolsSize(
523 : sal::static_int_cast< sal_Int16 >(
524 0 : bBigSize ? SFX_SYMBOLS_SIZE_LARGE : SFX_SYMBOLS_SIZE_SMALL ) );
525 0 : SfxViewFrame* pCurrViewFrame = SfxViewFrame::GetFirst();
526 0 : while ( pCurrViewFrame )
527 : {
528 : // update all "final" dispatchers
529 0 : if ( !pCurrViewFrame->GetActiveChildFrame_Impl() )
530 0 : pCurrViewFrame->GetDispatcher()->Update_Impl(true);
531 0 : pCurrViewFrame = SfxViewFrame::GetNext(*pCurrViewFrame);
532 : }
533 : }
534 :
535 : // Backup
536 0 : if ( SfxItemState::SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_BACKUP), true, &pItem) )
537 : {
538 : DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
539 0 : aSaveOptions.SetBackup( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
540 : }
541 :
542 : // PrettyPrinting
543 0 : if ( SfxItemState::SET == rSet.GetItemState( rPool.GetWhich( SID_ATTR_PRETTYPRINTING ), true, &pItem ) )
544 : {
545 : DBG_ASSERT( pItem->ISA( SfxBoolItem ), "BoolItem expected" );
546 0 : aSaveOptions.SetPrettyPrinting( static_cast< const SfxBoolItem*> ( pItem )->GetValue() );
547 : }
548 :
549 : // WarnAlienFormat
550 0 : if ( SfxItemState::SET == rSet.GetItemState( rPool.GetWhich( SID_ATTR_WARNALIENFORMAT ), true, &pItem ) )
551 : {
552 : DBG_ASSERT( pItem->ISA( SfxBoolItem ), "BoolItem expected" );
553 0 : aSaveOptions.SetWarnAlienFormat( static_cast< const SfxBoolItem*> ( pItem )->GetValue() );
554 : }
555 :
556 : // AutoSave
557 0 : if ( SfxItemState::SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_AUTOSAVE), true, &pItem))
558 : {
559 : DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
560 0 : aSaveOptions.SetAutoSave( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
561 : }
562 :
563 : // AutoSave-Propt
564 0 : if ( SfxItemState::SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_AUTOSAVEPROMPT), true, &pItem))
565 : {
566 : DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
567 0 : aSaveOptions.SetAutoSavePrompt(static_cast<const SfxBoolItem *>(pItem)->GetValue());
568 : }
569 :
570 : // AutoSave-Time
571 0 : if ( SfxItemState::SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_AUTOSAVEMINUTE), true, &pItem))
572 : {
573 : DBG_ASSERT(pItem->ISA(SfxUInt16Item), "UInt16Item expected");
574 0 : aSaveOptions.SetAutoSaveTime(static_cast<const SfxUInt16Item *>(pItem)->GetValue());
575 : }
576 :
577 : // UserAutoSave
578 0 : if ( SfxItemState::SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_USERAUTOSAVE), true, &pItem))
579 : {
580 : DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
581 0 : aSaveOptions.SetUserAutoSave( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
582 : }
583 :
584 : // DocInfo
585 0 : if ( SfxItemState::SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_DOCINFO), true, &pItem))
586 : {
587 : DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
588 0 : aSaveOptions.SetDocInfoSave(static_cast<const SfxBoolItem *>(pItem)->GetValue());
589 : }
590 :
591 : // Mark open Documents
592 0 : if ( SfxItemState::SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_WORKINGSET), true, &pItem))
593 : {
594 : DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
595 0 : aSaveOptions.SetSaveWorkingSet(static_cast<const SfxBoolItem *>(pItem)->GetValue());
596 : }
597 :
598 : // Save window settings
599 0 : if ( SfxItemState::SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_SAVEDOCVIEW), true, &pItem))
600 : {
601 : DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
602 0 : aSaveOptions.SetSaveDocView(static_cast<const SfxBoolItem *>(pItem)->GetValue());
603 : }
604 :
605 : // Metric
606 0 : if ( SfxItemState::SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_METRIC), true, &pItem))
607 : {
608 : DBG_ASSERT(pItem->ISA(SfxUInt16Item), "UInt16Item expected");
609 : }
610 :
611 : // HelpBalloons
612 0 : if ( SfxItemState::SET == rSet.GetItemState(rPool.GetWhich(SID_HELPBALLOONS), true, &pItem))
613 : {
614 : DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
615 0 : aHelpOptions.SetExtendedHelp(static_cast<const SfxBoolItem *>(pItem)->GetValue());
616 : }
617 :
618 : // HelpTips
619 0 : if ( SfxItemState::SET == rSet.GetItemState(rPool.GetWhich(SID_HELPTIPS), true, &pItem))
620 : {
621 : DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
622 0 : aHelpOptions.SetHelpTips( static_cast<const SfxBoolItem *>(pItem)->GetValue());
623 : }
624 :
625 : // WelcomeScreen
626 0 : if ( SfxItemState::SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_WELCOMESCREEN ), true, &pItem))
627 : {
628 : DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
629 0 : aHelpOptions.SetWelcomeScreen( static_cast<const SfxBoolItem *>(pItem)->GetValue() );
630 : }
631 :
632 : // WelcomeScreen
633 0 : if ( SfxItemState::SET == rSet.GetItemState(rPool.GetWhich(SID_WELCOMESCREEN_RESET ), true, &pItem))
634 : {
635 : DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
636 0 : bool bReset = static_cast<const SfxBoolItem *>(pItem)->GetValue();
637 : if ( bReset )
638 : {
639 : OSL_FAIL( "Not implemented, may be EOL!" );
640 : } }
641 :
642 0 : if ( SfxItemState::SET == rSet.GetItemState(rPool.GetWhich(SID_HELP_STYLESHEET ), true, &pItem))
643 : {
644 : DBG_ASSERT(pItem->ISA(SfxStringItem), "StringItem expected");
645 0 : aHelpOptions.SetHelpStyleSheet( static_cast<const SfxStringItem *>(pItem)->GetValue() );
646 : }
647 :
648 : // SaveRelINet
649 0 : if ( SfxItemState::SET == rSet.GetItemState(rPool.GetWhich(SID_SAVEREL_INET), true, &pItem))
650 : {
651 : DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
652 0 : aSaveOptions.SetSaveRelINet(static_cast<const SfxBoolItem *>(pItem)->GetValue());
653 : }
654 :
655 : // SaveRelFSys
656 0 : if ( SfxItemState::SET == rSet.GetItemState(rPool.GetWhich(SID_SAVEREL_FSYS), true, &pItem))
657 : {
658 : DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
659 0 : aSaveOptions.SetSaveRelFSys(static_cast<const SfxBoolItem *>(pItem)->GetValue());
660 : }
661 :
662 : // Undo-Count
663 0 : if ( SfxItemState::SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_UNDO_COUNT), true, &pItem))
664 : {
665 : DBG_ASSERT(pItem->ISA(SfxUInt16Item), "UInt16Item expected");
666 0 : sal_uInt16 nUndoCount = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
667 0 : officecfg::Office::Common::Undo::Steps::set(nUndoCount, batch);
668 :
669 : // To catch all Undo-Managers: Iterate over all Frames
670 0 : for ( SfxViewFrame *pFrame = SfxViewFrame::GetFirst();
671 : pFrame;
672 : pFrame = SfxViewFrame::GetNext(*pFrame) )
673 : {
674 : // Get the Dispatcher of the Frames
675 0 : SfxDispatcher *pDispat = pFrame->GetDispatcher();
676 0 : pDispat->Flush();
677 :
678 : // Iterate over all SfxShells on the Dispatchers Stack
679 0 : sal_uInt16 nIdx = 0;
680 0 : for ( SfxShell *pSh = pDispat->GetShell(nIdx);
681 : pSh;
682 0 : ++nIdx, pSh = pDispat->GetShell(nIdx) )
683 : {
684 0 : ::svl::IUndoManager *pShUndoMgr = pSh->GetUndoManager();
685 0 : if ( pShUndoMgr )
686 0 : pShUndoMgr->SetMaxUndoActionCount( nUndoCount );
687 : }
688 : }
689 : }
690 :
691 : // Office autostart
692 0 : if ( SfxItemState::SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_QUICKLAUNCHER), true, &pItem))
693 : {
694 : DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
695 0 : ShutdownIcon::SetAutostart( static_cast<const SfxBoolItem*>( pItem )->GetValue() );
696 : }
697 :
698 : // StarBasic Enable
699 0 : if ( SfxItemState::SET == rSet.GetItemState(SID_BASIC_ENABLED, true, &pItem))
700 : {
701 : DBG_ASSERT(pItem->ISA(SfxUInt16Item), "SfxInt16Item expected");
702 0 : aSecurityOptions.SetBasicMode( (EBasicSecurityMode)static_cast<const SfxUInt16Item*>( pItem )->GetValue() );
703 : }
704 :
705 : // Execute PlugIns
706 0 : if ( SfxItemState::SET == rSet.GetItemState(SID_INET_EXE_PLUGIN, true, &pItem))
707 : {
708 : DBG_ASSERT(pItem->ISA(SfxBoolItem), "SfxBoolItem expected");
709 0 : aSecurityOptions.SetExecutePlugins( static_cast<const SfxBoolItem *>( pItem )->GetValue() );
710 : }
711 :
712 0 : if ( SfxItemState::SET == rSet.GetItemState(rPool.GetWhich(SID_INET_PROXY_TYPE), true, &pItem))
713 : {
714 : DBG_ASSERT( pItem->ISA(SfxUInt16Item), "UInt16Item expected" );
715 : officecfg::Inet::Settings::ooInetProxyType::set(
716 0 : static_cast< SfxUInt16Item const * >(pItem)->GetValue(), batch);
717 : }
718 :
719 0 : if ( SfxItemState::SET == rSet.GetItemState( rPool.GetWhich( SID_INET_HTTP_PROXY_NAME ), true, &pItem ) )
720 : {
721 : DBG_ASSERT( pItem->ISA(SfxStringItem), "StringItem expected" );
722 : officecfg::Inet::Settings::ooInetHTTPProxyName::set(
723 0 : static_cast< SfxStringItem const * >(pItem)->GetValue(), batch);
724 : }
725 0 : if ( SfxItemState::SET == rSet.GetItemState( rPool.GetWhich( SID_INET_HTTP_PROXY_PORT ), true, &pItem ) )
726 : {
727 : DBG_ASSERT( pItem->ISA(SfxInt32Item), "Int32Item expected" );
728 : officecfg::Inet::Settings::ooInetHTTPProxyPort::set(
729 0 : static_cast< SfxInt32Item const * >(pItem)->GetValue(), batch);
730 : }
731 0 : if ( SfxItemState::SET == rSet.GetItemState( rPool.GetWhich( SID_INET_FTP_PROXY_NAME ), true, &pItem ) )
732 : {
733 : DBG_ASSERT( pItem->ISA(SfxStringItem), "StringItem expected" );
734 : officecfg::Inet::Settings::ooInetFTPProxyName::set(
735 0 : static_cast< SfxStringItem const * >(pItem)->GetValue(), batch);
736 : }
737 0 : if ( SfxItemState::SET == rSet.GetItemState( rPool.GetWhich( SID_INET_FTP_PROXY_PORT ), true, &pItem ) )
738 : {
739 : DBG_ASSERT( pItem->ISA(SfxInt32Item), "Int32Item expected" );
740 : officecfg::Inet::Settings::ooInetFTPProxyPort::set(
741 0 : static_cast< SfxInt32Item const * >(pItem)->GetValue(), batch);
742 : }
743 0 : if ( SfxItemState::SET == rSet.GetItemState(SID_INET_NOPROXY, true, &pItem))
744 : {
745 : DBG_ASSERT(pItem->ISA(SfxStringItem), "StringItem expected");
746 : officecfg::Inet::Settings::ooInetNoProxy::set(
747 0 : static_cast< SfxStringItem const * >(pItem)->GetValue(), batch);
748 : }
749 :
750 : // Secure-Referers
751 0 : if ( SfxItemState::SET == rSet.GetItemState(SID_SECURE_URL, true, &pItem))
752 : {
753 : DBG_ASSERT(pItem->ISA(SfxStringListItem), "StringListItem expected");
754 0 : ::com::sun::star::uno::Sequence< OUString > seqURLs;
755 0 : static_cast<const SfxStringListItem*>(pItem)->GetStringList(seqURLs);
756 0 : aSecurityOptions.SetSecureURLs( seqURLs );
757 : }
758 :
759 0 : if ( SfxItemState::SET == rSet.GetItemState(SID_MACRO_WARNING, true, &pItem))
760 : {
761 : DBG_ASSERT(pItem->ISA(SfxBoolItem), "SfxBoolItem expected");
762 0 : aSecurityOptions.SetWarningEnabled( static_cast<const SfxBoolItem *>(pItem)->GetValue() );
763 : }
764 0 : if ( SfxItemState::SET == rSet.GetItemState(SID_MACRO_CONFIRMATION, true, &pItem))
765 : {
766 : DBG_ASSERT(pItem->ISA(SfxBoolItem), "SfxBoolItem expected");
767 0 : aSecurityOptions.SetConfirmationEnabled( static_cast<const SfxBoolItem *>(pItem)->GetValue() );
768 : }
769 :
770 : // Store changed data
771 0 : batch->commit();
772 0 : }
773 :
774 :
775 0 : void SfxApplication::SetOptions(const SfxItemSet &rSet)
776 : {
777 0 : SvtPathOptions aPathOptions;
778 :
779 : // Data is saved in DocInfo and IniManager
780 0 : const SfxPoolItem *pItem = 0;
781 0 : SfxItemPool &rPool = GetPool();
782 :
783 0 : SfxAllItemSet aSendSet( rSet );
784 :
785 : // PathName
786 0 : if ( SfxItemState::SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_PATHNAME), true, &pItem))
787 : {
788 : DBG_ASSERT(pItem->ISA(SfxAllEnumItem), "AllEnumItem expected");
789 0 : const SfxAllEnumItem* pEnumItem = static_cast<const SfxAllEnumItem *>(pItem);
790 0 : sal_uInt32 nCount = pEnumItem->GetValueCount();
791 0 : OUString aNoChangeStr( ' ' );
792 0 : for( sal_uInt32 nPath=0; nPath<nCount; ++nPath )
793 : {
794 0 : OUString sValue = pEnumItem->GetValueTextByPos((sal_uInt16)nPath);
795 0 : if ( sValue != aNoChangeStr )
796 : {
797 0 : switch( nPath )
798 : {
799 : case SvtPathOptions::PATH_ADDIN:
800 : {
801 0 : OUString aTmp;
802 0 : if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue, aTmp ) )
803 0 : aPathOptions.SetAddinPath( aTmp );
804 0 : break;
805 : }
806 :
807 0 : case SvtPathOptions::PATH_AUTOCORRECT: aPathOptions.SetAutoCorrectPath( sValue );break;
808 0 : case SvtPathOptions::PATH_AUTOTEXT: aPathOptions.SetAutoTextPath( sValue );break;
809 0 : case SvtPathOptions::PATH_BACKUP: aPathOptions.SetBackupPath( sValue );break;
810 0 : case SvtPathOptions::PATH_BASIC: aPathOptions.SetBasicPath( sValue );break;
811 0 : case SvtPathOptions::PATH_BITMAP: aPathOptions.SetBitmapPath( sValue );break;
812 0 : case SvtPathOptions::PATH_CONFIG: aPathOptions.SetConfigPath( sValue );break;
813 0 : case SvtPathOptions::PATH_DICTIONARY: aPathOptions.SetDictionaryPath( sValue );break;
814 0 : case SvtPathOptions::PATH_FAVORITES: aPathOptions.SetFavoritesPath( sValue );break;
815 : case SvtPathOptions::PATH_FILTER:
816 : {
817 0 : OUString aTmp;
818 0 : if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue, aTmp ) )
819 0 : aPathOptions.SetFilterPath( aTmp );
820 0 : break;
821 : }
822 0 : case SvtPathOptions::PATH_GALLERY: aPathOptions.SetGalleryPath( sValue );break;
823 0 : case SvtPathOptions::PATH_GRAPHIC: aPathOptions.SetGraphicPath( sValue );break;
824 : case SvtPathOptions::PATH_HELP:
825 : {
826 0 : OUString aTmp;
827 0 : if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue, aTmp ) )
828 0 : aPathOptions.SetHelpPath( aTmp );
829 0 : break;
830 : }
831 :
832 0 : case SvtPathOptions::PATH_LINGUISTIC: aPathOptions.SetLinguisticPath( sValue );break;
833 : case SvtPathOptions::PATH_MODULE:
834 : {
835 0 : OUString aTmp;
836 0 : if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue, aTmp ) )
837 0 : aPathOptions.SetModulePath( aTmp );
838 0 : break;
839 : }
840 :
841 0 : case SvtPathOptions::PATH_PALETTE: aPathOptions.SetPalettePath( sValue );break;
842 : case SvtPathOptions::PATH_PLUGIN:
843 : {
844 0 : OUString aTmp;
845 0 : if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue, aTmp ) )
846 0 : aPathOptions.SetPluginPath( aTmp );
847 0 : break;
848 : }
849 :
850 : case SvtPathOptions::PATH_STORAGE:
851 : {
852 0 : OUString aTmp;
853 0 : if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue, aTmp ) )
854 0 : aPathOptions.SetStoragePath( aTmp );
855 0 : break;
856 : }
857 :
858 0 : case SvtPathOptions::PATH_TEMP: aPathOptions.SetTempPath( sValue );break;
859 0 : case SvtPathOptions::PATH_TEMPLATE: aPathOptions.SetTemplatePath( sValue );break;
860 0 : case SvtPathOptions::PATH_USERCONFIG: aPathOptions.SetUserConfigPath( sValue );break;
861 0 : case SvtPathOptions::PATH_WORK: aPathOptions.SetWorkPath( sValue );break;
862 : default: SAL_WARN( "sfx.appl", "SfxApplication::SetOptions_Impl() Invalid path number found for set directories!" );
863 : }
864 : }
865 0 : }
866 :
867 0 : aSendSet.ClearItem( rPool.GetWhich( SID_ATTR_PATHNAME ) );
868 : }
869 :
870 0 : SetOptions_Impl( rSet );
871 :
872 : // Undo-Count
873 0 : Broadcast( SfxItemSetHint( rSet ) );
874 0 : }
875 :
876 :
877 63095 : void SfxApplication::NotifyEvent( const SfxEventHint& rEventHint, bool bSynchron )
878 : {
879 63095 : SfxObjectShell *pDoc = rEventHint.GetObjShell();
880 63095 : if ( pDoc && ( pDoc->IsPreview() || !pDoc->Get_Impl()->bInitialized ) )
881 73029 : return;
882 :
883 53161 : if ( bSynchron )
884 : {
885 : #ifdef DBG_UTIL
886 : if (!pDoc)
887 : {
888 : OStringBuffer aTmp("SfxEvent: ");
889 : aTmp.append(OUStringToOString(rEventHint.GetEventName(), RTL_TEXTENCODING_UTF8));
890 : OSL_TRACE( "%s", aTmp.getStr() );
891 : }
892 : #endif
893 46859 : Broadcast(rEventHint);
894 46859 : if ( pDoc )
895 46859 : pDoc->Broadcast( rEventHint );
896 : }
897 : else
898 6302 : new SfxEventAsyncer_Impl( rEventHint );
899 951 : }
900 :
901 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|