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