Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / sfx2 / source / appl / appcfg.cxx
blob4b8d786d4b1a9a729e311e06cccadf6c3e3c9345
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
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.
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).
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.
27 ************************************************************************/
29 #include <com/sun/star/uno/Reference.hxx>
30 #include <com/sun/star/frame/XDesktop.hpp>
31 #include <com/sun/star/util/XURLTransformer.hpp>
32 #include <com/sun/star/beans/PropertyValue.hpp>
33 #include <com/sun/star/beans/XPropertySet.hpp>
34 #include <com/sun/star/util/XFlushable.hpp>
36 #include <stdlib.h>
37 #include <vcl/sound.hxx>
38 #include <vcl/msgbox.hxx>
39 #include <tools/string.hxx>
40 #include <svl/itempool.hxx>
41 #include <svl/aeitem.hxx>
42 #include <svl/slstitm.hxx>
43 #include <svl/stritem.hxx>
44 #include <svl/intitem.hxx>
45 #include <svl/eitem.hxx>
46 #include <svl/szitem.hxx>
47 #include <svl/undo.hxx>
49 #include <sfx2/sfxsids.hrc>
50 #include <sot/exchange.hxx>
52 #include <svl/isethint.hxx>
54 #include <officecfg/Inet.hxx>
55 #include <officecfg/Office/Common.hxx>
56 #include <unotools/configmgr.hxx>
57 #include <tools/urlobj.hxx>
58 #include <unotools/saveopt.hxx>
59 #include <svtools/helpopt.hxx>
60 #include <unotools/securityoptions.hxx>
61 #include <unotools/pathoptions.hxx>
62 #include <svtools/miscopt.hxx>
63 #include <vcl/toolbox.hxx>
64 #include <unotools/localfilehelper.hxx>
65 #include <rtl/strbuf.hxx>
66 #include <rtl/ustrbuf.hxx>
68 #include <sfx2/app.hxx>
69 #include <sfx2/docfile.hxx>
70 #include <sfx2/viewfrm.hxx>
71 #include "sfx2/sfxhelp.hxx"
72 #include "sfxtypes.hxx"
73 #include <sfx2/dispatch.hxx>
74 #include <sfx2/objsh.hxx>
75 #include "objshimp.hxx"
76 #include <sfx2/viewsh.hxx>
77 #include <sfx2/request.hxx>
78 #include <sfx2/evntconf.hxx>
79 #include "appdata.hxx"
80 #include "workwin.hxx"
81 #include "helper.hxx" // SfxContentHelper::...
82 #include "app.hrc"
83 #include "sfx2/sfxresid.hxx"
84 #include "shutdownicon.hxx"
86 using namespace ::com::sun::star::uno;
87 using namespace ::com::sun::star::util;
88 using namespace ::com::sun::star::frame;
89 using namespace ::com::sun::star::beans;
91 //-------------------------------------------------------------------------
93 class SfxEventAsyncer_Impl : public SfxListener
95 SfxEventHint aHint;
96 Timer* pTimer;
98 public:
100 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
101 SfxEventAsyncer_Impl( const SfxEventHint& rHint );
102 ~SfxEventAsyncer_Impl();
103 DECL_LINK( TimerHdl, Timer*);
106 // -----------------------------------------------------------------------
108 void SfxEventAsyncer_Impl::Notify( SfxBroadcaster&, const SfxHint& rHint )
110 SfxSimpleHint* pHint = PTR_CAST( SfxSimpleHint, &rHint );
111 if( pHint && pHint->GetId() == SFX_HINT_DYING && pTimer->IsActive() )
113 pTimer->Stop();
114 delete this;
118 // -----------------------------------------------------------------------
120 SfxEventAsyncer_Impl::SfxEventAsyncer_Impl( const SfxEventHint& rHint )
121 : aHint( rHint )
123 if( rHint.GetObjShell() )
124 StartListening( *rHint.GetObjShell() );
125 pTimer = new Timer;
126 pTimer->SetTimeoutHdl( LINK(this, SfxEventAsyncer_Impl, TimerHdl) );
127 pTimer->SetTimeout( 0 );
128 pTimer->Start();
131 // -----------------------------------------------------------------------
133 SfxEventAsyncer_Impl::~SfxEventAsyncer_Impl()
135 delete pTimer;
138 // -----------------------------------------------------------------------
140 IMPL_LINK(SfxEventAsyncer_Impl, TimerHdl, Timer*, pAsyncTimer)
142 (void)pAsyncTimer; // unused variable
143 SfxObjectShellRef xRef( aHint.GetObjShell() );
144 pAsyncTimer->Stop();
145 #ifdef DBG_UTIL
146 if (!xRef.Is())
148 rtl::OStringBuffer aTmp(RTL_CONSTASCII_STRINGPARAM("SfxEvent: "));
149 aTmp.append(rtl::OUStringToOString(aHint.GetEventName(), RTL_TEXTENCODING_UTF8));
150 OSL_TRACE( "%s", aTmp.getStr() );
152 #endif
153 SFX_APP()->Broadcast( aHint );
154 if ( xRef.Is() )
155 xRef->Broadcast( aHint );
156 delete this;
157 return 0L;
161 //--------------------------------------------------------------------
163 sal_Bool SfxApplication::GetOptions( SfxItemSet& rSet )
165 sal_Bool bRet = sal_False;
166 SfxItemPool &rPool = GetPool();
167 String asal_TrueStr('1');
169 const sal_uInt16 *pRanges = rSet.GetRanges();
170 SvtSaveOptions aSaveOptions;
171 SvtHelpOptions aHelpOptions;
172 SvtSecurityOptions aSecurityOptions;
173 SvtMiscOptions aMiscOptions;
175 while ( *pRanges )
177 for(sal_uInt16 nWhich = *pRanges++; nWhich <= *pRanges; ++nWhich)
179 switch(nWhich)
181 case SID_ATTR_BUTTON_OUTSTYLE3D :
182 if(rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_BUTTON_OUTSTYLE3D ),
183 aMiscOptions.GetToolboxStyle() != TOOLBOX_STYLE_FLAT)))
184 bRet = sal_True;
185 break;
186 case SID_ATTR_BUTTON_BIGSIZE :
188 if( rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_BUTTON_BIGSIZE ), aMiscOptions.AreCurrentSymbolsLarge() ) ) )
189 bRet = sal_True;
190 break;
192 case SID_ATTR_BACKUP :
194 bRet = sal_True;
195 if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_BACKUP))
196 if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_BACKUP ),aSaveOptions.IsBackup())))
197 bRet = sal_False;
199 break;
200 case SID_ATTR_PRETTYPRINTING:
202 bRet = sal_True;
203 if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_DOPRETTYPRINTING))
204 if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_PRETTYPRINTING ), aSaveOptions.IsPrettyPrinting())))
205 bRet = sal_False;
207 break;
208 case SID_ATTR_WARNALIENFORMAT:
210 bRet = sal_True;
211 if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_WARNALIENFORMAT))
212 if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_WARNALIENFORMAT ), aSaveOptions.IsWarnAlienFormat())))
213 bRet = sal_False;
215 break;
216 case SID_ATTR_AUTOSAVE :
218 bRet = sal_True;
219 if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_AUTOSAVE))
220 if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_AUTOSAVE ), aSaveOptions.IsAutoSave())))
221 bRet = sal_False;
223 break;
224 case SID_ATTR_AUTOSAVEPROMPT :
226 bRet = sal_True;
227 if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_AUTOSAVEPROMPT))
228 if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_AUTOSAVEPROMPT ), aSaveOptions.IsAutoSavePrompt())))
229 bRet = sal_False;
231 break;
232 case SID_ATTR_AUTOSAVEMINUTE :
234 bRet = sal_True;
235 if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_AUTOSAVETIME))
236 if (!rSet.Put( SfxUInt16Item( rPool.GetWhich( SID_ATTR_AUTOSAVEMINUTE ), (sal_uInt16)aSaveOptions.GetAutoSaveTime())))
237 bRet = sal_False;
239 break;
240 case SID_ATTR_DOCINFO :
242 bRet = sal_True;
243 if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_DOCINFSAVE))
244 if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_DOCINFO ), aSaveOptions.IsDocInfoSave())))
245 bRet = sal_False;
247 break;
248 case SID_ATTR_WORKINGSET :
250 bRet = sal_True;
251 if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_SAVEWORKINGSET))
252 if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_WORKINGSET ), aSaveOptions.IsSaveWorkingSet())))
253 bRet = sal_False;
255 break;
256 case SID_ATTR_SAVEDOCVIEW :
258 bRet = sal_True;
259 if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_SAVEDOCVIEW))
260 if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_SAVEDOCVIEW ), aSaveOptions.IsSaveDocView())))
261 bRet = sal_False;
263 break;
264 case SID_ATTR_METRIC :
265 break;
266 case SID_HELPBALLOONS :
267 if(rSet.Put( SfxBoolItem ( rPool.GetWhich( SID_HELPBALLOONS ),
268 aHelpOptions.IsExtendedHelp() ) ) )
269 bRet = sal_True;
270 break;
271 case SID_HELPTIPS :
272 if(rSet.Put( SfxBoolItem ( rPool.GetWhich( SID_HELPTIPS ),
273 aHelpOptions.IsHelpTips() ) ) )
274 bRet = sal_True;
275 break;
276 case SID_ATTR_AUTOHELPAGENT :
277 if(rSet.Put( SfxBoolItem ( rPool.GetWhich( SID_ATTR_AUTOHELPAGENT ),
278 aHelpOptions.IsHelpAgentAutoStartMode() ) ) )
279 bRet = sal_True;
280 break;
281 case SID_HELPAGENT_TIMEOUT :
282 if ( rSet.Put( SfxInt32Item( rPool.GetWhich( SID_HELPAGENT_TIMEOUT ),
283 aHelpOptions.GetHelpAgentTimeoutPeriod() ) ) )
284 bRet = sal_True;
285 break;
286 case SID_ATTR_WELCOMESCREEN :
287 if(rSet.Put( SfxBoolItem ( rPool.GetWhich( SID_ATTR_WELCOMESCREEN ),
288 aHelpOptions.IsWelcomeScreen() ) ) )
289 bRet = sal_True;
290 break;
291 case SID_HELP_STYLESHEET :
292 if(rSet.Put( SfxStringItem ( rPool.GetWhich( SID_HELP_STYLESHEET ),
293 aHelpOptions.GetHelpStyleSheet() ) ) )
294 bRet = sal_True;
295 break;
296 case SID_ATTR_UNDO_COUNT :
297 if (rSet.Put(
298 SfxUInt16Item (
299 rPool.GetWhich(SID_ATTR_UNDO_COUNT),
300 officecfg::Office::Common::Undo::Steps::get())))
302 bRet = true;
304 break;
305 case SID_ATTR_QUICKLAUNCHER :
307 if ( ShutdownIcon::IsQuickstarterInstalled() )
309 if ( rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_QUICKLAUNCHER ),
310 ShutdownIcon::GetAutostart() ) ) )
311 bRet = sal_True;
313 else
315 rSet.DisableItem( rPool.GetWhich( SID_ATTR_QUICKLAUNCHER ) );
316 bRet = sal_True;
318 break;
320 case SID_SAVEREL_INET :
322 bRet = sal_True;
323 if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_SAVERELINET))
324 if (!rSet.Put( SfxBoolItem ( rPool.GetWhich( SID_SAVEREL_INET ), aSaveOptions.IsSaveRelINet() )))
325 bRet = sal_False;
327 break;
328 case SID_SAVEREL_FSYS :
330 bRet = sal_True;
331 if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_SAVERELFSYS))
332 if (!rSet.Put( SfxBoolItem ( rPool.GetWhich( SID_SAVEREL_FSYS ), aSaveOptions.IsSaveRelFSys() )))
333 bRet = sal_False;
335 break;
336 case SID_BASIC_ENABLED :
338 bRet = sal_True;
339 if (!aSecurityOptions.IsReadOnly(SvtSecurityOptions::E_BASICMODE))
341 if ( !rSet.Put( SfxUInt16Item( rPool.GetWhich( SID_BASIC_ENABLED ), sal::static_int_cast< sal_uInt16 >(aSecurityOptions.GetBasicMode()))))
342 bRet = sal_False;
345 break;
346 case SID_INET_EXE_PLUGIN :
348 bRet = sal_True;
349 if (!aSecurityOptions.IsReadOnly(SvtSecurityOptions::E_EXECUTEPLUGINS))
351 if ( !rSet.Put( SfxBoolItem( SID_INET_EXE_PLUGIN, aSecurityOptions.IsExecutePlugins() ) ) )
352 bRet = sal_False;
355 break;
356 case SID_MACRO_WARNING :
358 bRet = sal_True;
359 if (!aSecurityOptions.IsReadOnly(SvtSecurityOptions::E_WARNING))
361 if ( !rSet.Put( SfxBoolItem( SID_MACRO_WARNING, aSecurityOptions.IsWarningEnabled() ) ) )
362 bRet = sal_False;
365 break;
366 case SID_MACRO_CONFIRMATION :
368 bRet = sal_True;
369 if (!aSecurityOptions.IsReadOnly(SvtSecurityOptions::E_CONFIRMATION))
371 if ( !rSet.Put( SfxBoolItem( SID_MACRO_CONFIRMATION, aSecurityOptions.IsConfirmationEnabled() ) ) )
372 bRet = sal_False;
375 break;
376 case SID_SECURE_URL :
378 bRet = sal_True;
379 if (!aSecurityOptions.IsReadOnly(SvtSecurityOptions::E_SECUREURLS))
381 ::com::sun::star::uno::Sequence< ::rtl::OUString > seqURLs = aSecurityOptions.GetSecureURLs();
382 std::vector<String> aList;
383 sal_uInt32 nCount = seqURLs.getLength();
384 sal_uInt32 nURL;
385 for( nURL=0; nURL<nCount; ++nURL )
386 aList.push_back(seqURLs[nURL]);
388 if( !rSet.Put( SfxStringListItem( rPool.GetWhich(SID_SECURE_URL), &aList ) ) )
389 bRet = sal_False;
392 break;
393 case SID_ENABLE_METAFILEPRINT :
394 #ifdef ENABLE_MISSINGKEYASSERTIONS//MUSTINI
395 DBG_ASSERT(sal_False, "SfxApplication::GetOptions()\nSoffice.ini key \"Common\\MetafilePrint\" is obsolete! .. How I can support SID_ENABLE_METAFILEPRINT any longer?\n");
396 #endif
397 break;
398 case SID_INET_PROXY_TYPE :
399 if (rSet.Put(
400 SfxUInt16Item(
401 rPool.GetWhich(SID_INET_PROXY_TYPE),
402 (officecfg::Inet::Settings::ooInetProxyType::
403 get().get_value_or(0)))))
405 bRet = true;
407 break;
408 case SID_INET_HTTP_PROXY_NAME :
409 if (rSet.Put(
410 SfxStringItem(
411 rPool.GetWhich(SID_INET_HTTP_PROXY_NAME),
412 officecfg::Inet::Settings::ooInetHTTPProxyName::
413 get())))
415 bRet = true;
417 break;
418 case SID_INET_HTTP_PROXY_PORT :
419 if (rSet.Put(
420 SfxInt32Item(
421 rPool.GetWhich(SID_INET_HTTP_PROXY_PORT),
422 (officecfg::Inet::Settings::
423 ooInetHTTPProxyPort::get().get_value_or(0)))))
425 bRet = true;
427 break;
428 case SID_INET_FTP_PROXY_NAME :
429 if (rSet.Put(
430 SfxStringItem(
431 rPool.GetWhich(SID_INET_FTP_PROXY_NAME),
432 officecfg::Inet::Settings::ooInetFTPProxyName::
433 get())))
435 bRet = true;
437 break;
438 case SID_INET_FTP_PROXY_PORT :
439 if (rSet.Put(
440 SfxInt32Item(
441 rPool.GetWhich(SID_INET_FTP_PROXY_PORT),
442 (officecfg::Inet::Settings::ooInetFTPProxyPort::
443 get().get_value_or(0)))))
445 bRet = true;
447 break;
448 case SID_INET_SECURITY_PROXY_NAME :
449 case SID_INET_SECURITY_PROXY_PORT :
450 #ifdef ENABLE_MISSINGKEYASSERTIONS//MUSTINI
451 DBG_ASSERT( sal_False, "SfxApplication::GetOptions()\nSome INET values no longer supported!\n" );
452 #endif
453 break;
454 case SID_INET_NOPROXY :
455 if (rSet.Put(
456 SfxStringItem(
457 rPool.GetWhich( SID_INET_NOPROXY),
458 (officecfg::Inet::Settings::ooInetNoProxy::
459 get()))))
461 bRet = true;
463 break;
464 case SID_ATTR_PATHNAME :
465 case SID_ATTR_PATHGROUP :
467 SfxAllEnumItem aNames(rPool.GetWhich(SID_ATTR_PATHGROUP));
468 SfxAllEnumItem aValues(rPool.GetWhich(SID_ATTR_PATHNAME));
469 SvtPathOptions aPathCfg;
470 for ( sal_uInt16 nProp = SvtPathOptions::PATH_ADDIN;
471 nProp <= SvtPathOptions::PATH_WORK; nProp++ )
473 const String aName( SfxResId( CONFIG_PATH_START + nProp ) );
474 aNames.InsertValue( nProp, aName );
475 rtl::OUString aValue;
476 switch ( nProp )
478 case SvtPathOptions::PATH_ADDIN: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg.GetAddinPath(), aValue ); break;
479 case SvtPathOptions::PATH_AUTOCORRECT: aValue = aPathCfg.GetAutoCorrectPath(); break;
480 case SvtPathOptions::PATH_AUTOTEXT: aValue = aPathCfg.GetAutoTextPath(); break;
481 case SvtPathOptions::PATH_BACKUP: aValue = aPathCfg.GetBackupPath(); break;
482 case SvtPathOptions::PATH_BASIC: aValue = aPathCfg.GetBasicPath(); break;
483 case SvtPathOptions::PATH_BITMAP: aValue = aPathCfg.GetBitmapPath(); break;
484 case SvtPathOptions::PATH_CONFIG: aValue = aPathCfg.GetConfigPath(); break;
485 case SvtPathOptions::PATH_DICTIONARY: aValue = aPathCfg.GetDictionaryPath(); break;
486 case SvtPathOptions::PATH_FAVORITES: aValue = aPathCfg.GetFavoritesPath(); break;
487 case SvtPathOptions::PATH_FILTER: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg.GetFilterPath(), aValue ); break;
488 case SvtPathOptions::PATH_GALLERY: aValue = aPathCfg.GetGalleryPath(); break;
489 case SvtPathOptions::PATH_GRAPHIC: aValue = aPathCfg.GetGraphicPath(); break;
490 case SvtPathOptions::PATH_HELP: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg.GetHelpPath(), aValue ); break;
491 case SvtPathOptions::PATH_LINGUISTIC: aValue = aPathCfg.GetLinguisticPath(); break;
492 case SvtPathOptions::PATH_MODULE: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg.GetModulePath(), aValue ); break;
493 case SvtPathOptions::PATH_PALETTE: aValue = aPathCfg.GetPalettePath(); break;
494 case SvtPathOptions::PATH_PLUGIN: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg.GetPluginPath(), aValue ); break;
495 case SvtPathOptions::PATH_STORAGE: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg.GetStoragePath(), aValue ); break;
496 case SvtPathOptions::PATH_TEMP: aValue = aPathCfg.GetTempPath(); break;
497 case SvtPathOptions::PATH_TEMPLATE: aValue = aPathCfg.GetTemplatePath(); break;
498 case SvtPathOptions::PATH_USERCONFIG: aValue = aPathCfg.GetUserConfigPath(); break;
499 case SvtPathOptions::PATH_WORK: aValue = aPathCfg.GetWorkPath(); break;
501 aValues.InsertValue( nProp, aValue );
504 if ( rSet.Put(aNames) || rSet.Put(aValues) )
505 bRet = sal_True;
508 default:
509 DBG_WARNING( "W1:Wrong ID while getting Options!" );
510 break;
512 #ifdef DBG_UTIL
513 if ( !bRet )
514 OSL_FAIL( "Putting options failed!" );
515 #endif
517 pRanges++;
520 return bRet;
523 //--------------------------------------------------------------------
524 sal_Bool SfxApplication::IsSecureURL( const INetURLObject& rURL, const String* pReferer ) const
526 return SvtSecurityOptions().IsSecureURL( rURL.GetMainURL( INetURLObject::NO_DECODE ), *pReferer );
528 //--------------------------------------------------------------------
529 // TODO/CLEANUP: Why two SetOptions Methods?
530 void SfxApplication::SetOptions_Impl( const SfxItemSet& rSet )
532 const SfxPoolItem *pItem = 0;
533 SfxItemPool &rPool = GetPool();
535 SvtSaveOptions aSaveOptions;
536 SvtHelpOptions aHelpOptions;
537 SvtSecurityOptions aSecurityOptions;
538 SvtPathOptions aPathOptions;
539 SvtMiscOptions aMiscOptions;
540 boost::shared_ptr< comphelper::ConfigurationChanges > batch(
541 comphelper::ConfigurationChanges::create());
542 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_BUTTON_OUTSTYLE3D), sal_True, &pItem) )
544 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
545 sal_uInt16 nOutStyle =
546 ( (const SfxBoolItem *)pItem)->GetValue() ? 0 : TOOLBOX_STYLE_FLAT;
547 aMiscOptions.SetToolboxStyle( nOutStyle );
550 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_BUTTON_BIGSIZE), sal_True, &pItem) )
552 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
553 sal_Bool bBigSize = ( (const SfxBoolItem*)pItem )->GetValue();
554 aMiscOptions.SetSymbolsSize(
555 sal::static_int_cast< sal_Int16 >(
556 bBigSize ? SFX_SYMBOLS_SIZE_LARGE : SFX_SYMBOLS_SIZE_SMALL ) );
557 SfxViewFrame* pCurrViewFrame = SfxViewFrame::GetFirst();
558 while ( pCurrViewFrame )
560 // update all "final" dispatchers
561 if ( !pCurrViewFrame->GetActiveChildFrame_Impl() )
562 pCurrViewFrame->GetDispatcher()->Update_Impl(sal_True);
563 pCurrViewFrame = SfxViewFrame::GetNext(*pCurrViewFrame);
567 // Backup
568 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_BACKUP), sal_True, &pItem) )
570 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
571 aSaveOptions.SetBackup( ( (const SfxBoolItem*)pItem )->GetValue() );
574 // PrettyPrinting
575 if ( SFX_ITEM_SET == rSet.GetItemState( rPool.GetWhich( SID_ATTR_PRETTYPRINTING ), sal_True, &pItem ) )
577 DBG_ASSERT( pItem->ISA( SfxBoolItem ), "BoolItem expected" );
578 aSaveOptions.SetPrettyPrinting( static_cast< const SfxBoolItem*> ( pItem )->GetValue() );
581 // WarnAlienFormat
582 if ( SFX_ITEM_SET == rSet.GetItemState( rPool.GetWhich( SID_ATTR_WARNALIENFORMAT ), sal_True, &pItem ) )
584 DBG_ASSERT( pItem->ISA( SfxBoolItem ), "BoolItem expected" );
585 aSaveOptions.SetWarnAlienFormat( static_cast< const SfxBoolItem*> ( pItem )->GetValue() );
588 // AutoSave
589 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_AUTOSAVE), sal_True, &pItem))
591 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
592 aSaveOptions.SetAutoSave( ( (const SfxBoolItem*)pItem )->GetValue() );
595 // AutoSave-Propt
596 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_AUTOSAVEPROMPT), sal_True, &pItem))
598 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
599 aSaveOptions.SetAutoSavePrompt(((const SfxBoolItem *)pItem)->GetValue());
602 // AutoSave-Time
603 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_AUTOSAVEMINUTE), sal_True, &pItem))
605 DBG_ASSERT(pItem->ISA(SfxUInt16Item), "UInt16Item expected");
606 aSaveOptions.SetAutoSaveTime(((const SfxUInt16Item *)pItem)->GetValue());
609 // DocInfo
610 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_DOCINFO), sal_True, &pItem))
612 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
613 aSaveOptions.SetDocInfoSave(((const SfxBoolItem *)pItem)->GetValue());
616 // Mark open Documents
617 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_WORKINGSET), sal_True, &pItem))
619 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
620 aSaveOptions.SetSaveWorkingSet(((const SfxBoolItem *)pItem)->GetValue());
623 // Save window settings
624 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_SAVEDOCVIEW), sal_True, &pItem))
626 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
627 aSaveOptions.SetSaveDocView(((const SfxBoolItem *)pItem)->GetValue());
630 // Metric
631 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_METRIC), sal_True, &pItem))
633 DBG_ASSERT(pItem->ISA(SfxUInt16Item), "UInt16Item expected");
636 // HelpBalloons
637 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_HELPBALLOONS), sal_True, &pItem))
639 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
640 aHelpOptions.SetExtendedHelp(((const SfxBoolItem *)pItem)->GetValue());
643 // HelpTips
644 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_HELPTIPS), sal_True, &pItem))
646 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
647 aHelpOptions.SetHelpTips(((const SfxBoolItem *)pItem)->GetValue());
650 // AutoHelpAgent
651 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_AUTOHELPAGENT ), sal_True, &pItem))
653 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
654 aHelpOptions.SetHelpAgentAutoStartMode( ((const SfxBoolItem *)pItem)->GetValue() );
657 // help agent timeout
658 if ( SFX_ITEM_SET == rSet.GetItemState( rPool.GetWhich( SID_HELPAGENT_TIMEOUT ), sal_True, &pItem ) )
660 DBG_ASSERT(pItem->ISA(SfxInt32Item), "Int32Item expected");
661 aHelpOptions.SetHelpAgentTimeoutPeriod( ( (const SfxInt32Item*)pItem )->GetValue() );
664 // WelcomeScreen
665 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_WELCOMESCREEN ), sal_True, &pItem))
667 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
668 aHelpOptions.SetWelcomeScreen( ((const SfxBoolItem *)pItem)->GetValue() );
671 // WelcomeScreen
672 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_WELCOMESCREEN_RESET ), sal_True, &pItem))
674 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
675 sal_Bool bReset = ((const SfxBoolItem *)pItem)->GetValue();
676 if ( bReset )
678 OSL_FAIL( "Not implemented, may be EOL!" );
681 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_HELP_STYLESHEET ), sal_True, &pItem))
683 DBG_ASSERT(pItem->ISA(SfxStringItem), "StringItem expected");
684 aHelpOptions.SetHelpStyleSheet( ((const SfxStringItem *)pItem)->GetValue() );
687 // SaveRelINet
688 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_SAVEREL_INET), sal_True, &pItem))
690 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
691 aSaveOptions.SetSaveRelINet(((const SfxBoolItem *)pItem)->GetValue());
694 // SaveRelFSys
695 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_SAVEREL_FSYS), sal_True, &pItem))
697 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
698 aSaveOptions.SetSaveRelFSys(((const SfxBoolItem *)pItem)->GetValue());
701 // Undo-Count
702 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_UNDO_COUNT), sal_True, &pItem))
704 DBG_ASSERT(pItem->ISA(SfxUInt16Item), "UInt16Item expected");
705 sal_uInt16 nUndoCount = ((const SfxUInt16Item*)pItem)->GetValue();
706 officecfg::Office::Common::Undo::Steps::set(nUndoCount, batch);
708 // To catch all Undo-Managers: Iterate over all Frames
709 for ( SfxViewFrame *pFrame = SfxViewFrame::GetFirst();
710 pFrame;
711 pFrame = SfxViewFrame::GetNext(*pFrame) )
713 // Get the Dispatcher of the Frames
714 SfxDispatcher *pDispat = pFrame->GetDispatcher();
715 pDispat->Flush();
717 // Iterate over all SfxShells on the Dispatchers Stack
718 sal_uInt16 nIdx = 0;
719 for ( SfxShell *pSh = pDispat->GetShell(nIdx);
720 pSh;
721 ++nIdx, pSh = pDispat->GetShell(nIdx) )
723 ::svl::IUndoManager *pShUndoMgr = pSh->GetUndoManager();
724 if ( pShUndoMgr )
725 pShUndoMgr->SetMaxUndoActionCount( nUndoCount );
730 // Office autostart
731 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_QUICKLAUNCHER), sal_True, &pItem))
733 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
734 ShutdownIcon::SetAutostart( ( (const SfxBoolItem*)pItem )->GetValue() != sal_False );
737 // StarBasic Enable
738 if ( SFX_ITEM_SET == rSet.GetItemState(SID_BASIC_ENABLED, sal_True, &pItem))
740 DBG_ASSERT(pItem->ISA(SfxUInt16Item), "SfxInt16Item expected");
741 aSecurityOptions.SetBasicMode( (EBasicSecurityMode)( (const SfxUInt16Item*)pItem )->GetValue() );
744 // Execute PlugIns
745 if ( SFX_ITEM_SET == rSet.GetItemState(SID_INET_EXE_PLUGIN, sal_True, &pItem))
747 DBG_ASSERT(pItem->ISA(SfxBoolItem), "SfxBoolItem expected");
748 aSecurityOptions.SetExecutePlugins( ( (const SfxBoolItem *)pItem )->GetValue() );
751 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_INET_PROXY_TYPE), sal_True, &pItem))
753 DBG_ASSERT( pItem->ISA(SfxUInt16Item), "UInt16Item expected" );
754 officecfg::Inet::Settings::ooInetProxyType::set(
755 static_cast< SfxUInt16Item const * >(pItem)->GetValue(), batch);
758 if ( SFX_ITEM_SET == rSet.GetItemState( rPool.GetWhich( SID_INET_HTTP_PROXY_NAME ), sal_True, &pItem ) )
760 DBG_ASSERT( pItem->ISA(SfxStringItem), "StringItem expected" );
761 officecfg::Inet::Settings::ooInetHTTPProxyName::set(
762 static_cast< SfxStringItem const * >(pItem)->GetValue(), batch);
764 if ( SFX_ITEM_SET == rSet.GetItemState( rPool.GetWhich( SID_INET_HTTP_PROXY_PORT ), sal_True, &pItem ) )
766 DBG_ASSERT( pItem->ISA(SfxInt32Item), "Int32Item expected" );
767 officecfg::Inet::Settings::ooInetHTTPProxyPort::set(
768 static_cast< SfxInt32Item const * >(pItem)->GetValue(), batch);
770 if ( SFX_ITEM_SET == rSet.GetItemState( rPool.GetWhich( SID_INET_FTP_PROXY_NAME ), sal_True, &pItem ) )
772 DBG_ASSERT( pItem->ISA(SfxStringItem), "StringItem expected" );
773 officecfg::Inet::Settings::ooInetFTPProxyName::set(
774 static_cast< SfxStringItem const * >(pItem)->GetValue(), batch);
776 if ( SFX_ITEM_SET == rSet.GetItemState( rPool.GetWhich( SID_INET_FTP_PROXY_PORT ), sal_True, &pItem ) )
778 DBG_ASSERT( pItem->ISA(SfxInt32Item), "Int32Item expected" );
779 officecfg::Inet::Settings::ooInetFTPProxyPort::set(
780 static_cast< SfxInt32Item const * >(pItem)->GetValue(), batch);
782 if ( SFX_ITEM_SET == rSet.GetItemState(SID_INET_NOPROXY, sal_True, &pItem))
784 DBG_ASSERT(pItem->ISA(SfxStringItem), "StringItem expected");
785 officecfg::Inet::Settings::ooInetNoProxy::set(
786 static_cast< SfxStringItem const * >(pItem)->GetValue(), batch);
789 // Secure-Referers
790 if ( SFX_ITEM_SET == rSet.GetItemState(SID_SECURE_URL, sal_True, &pItem))
792 DBG_ASSERT(pItem->ISA(SfxStringListItem), "StringListItem expected");
793 const std::vector<String> &aList = ((SfxStringListItem*)pItem)->GetList();
794 sal_uInt32 nCount = aList.size();
795 ::com::sun::star::uno::Sequence< ::rtl::OUString > seqURLs(nCount);
796 for( sal_uInt32 nPosition=0;nPosition<nCount;++nPosition)
797 seqURLs[nPosition] = aList[nPosition];
799 aSecurityOptions.SetSecureURLs( seqURLs );
802 if ( SFX_ITEM_SET == rSet.GetItemState(SID_MACRO_WARNING, sal_True, &pItem))
804 DBG_ASSERT(pItem->ISA(SfxBoolItem), "SfxBoolItem expected");
805 aSecurityOptions.SetWarningEnabled( ( (const SfxBoolItem *)pItem )->GetValue() );
807 if ( SFX_ITEM_SET == rSet.GetItemState(SID_MACRO_CONFIRMATION, sal_True, &pItem))
809 DBG_ASSERT(pItem->ISA(SfxBoolItem), "SfxBoolItem expected");
810 aSecurityOptions.SetConfirmationEnabled( ( (const SfxBoolItem *)pItem )->GetValue() );
813 // EnableMetafilePrint
814 if ( SFX_ITEM_SET == rSet.GetItemState( rPool.GetWhich( SID_ENABLE_METAFILEPRINT ), sal_True, &pItem ) )
816 #ifdef ENABLE_MISSINGKEYASSERTIONS//MUSTINI
817 DBG_ASSERT(sal_False, "SfxApplication::SetOptions_Impl()\nsoffice.ini key \"MetafilPrint\" not supported any longer!\n");
818 #endif
821 // Store changed data
822 batch->commit();
825 //--------------------------------------------------------------------
826 void SfxApplication::SetOptions(const SfxItemSet &rSet)
828 SvtPathOptions aPathOptions;
830 // Data is saved in DocInfo and IniManager
831 const SfxPoolItem *pItem = 0;
832 SfxItemPool &rPool = GetPool();
834 SfxAllItemSet aSendSet( rSet );
836 // PathName
837 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_PATHNAME), sal_True, &pItem))
839 DBG_ASSERT(pItem->ISA(SfxAllEnumItem), "AllEnumItem expected");
840 const SfxAllEnumItem* pEnumItem = (const SfxAllEnumItem *)pItem;
841 sal_uInt32 nCount = pEnumItem->GetValueCount();
842 String aNoChangeStr( ' ' );
843 for( sal_uInt32 nPath=0; nPath<nCount; ++nPath )
845 String sValue = pEnumItem->GetValueTextByPos((sal_uInt16)nPath);
846 if ( sValue != aNoChangeStr )
848 switch( nPath )
850 case SvtPathOptions::PATH_ADDIN:
852 rtl::OUString aTmp;
853 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue, aTmp ) )
854 aPathOptions.SetAddinPath( aTmp );
855 break;
858 case SvtPathOptions::PATH_AUTOCORRECT: aPathOptions.SetAutoCorrectPath( sValue );break;
859 case SvtPathOptions::PATH_AUTOTEXT: aPathOptions.SetAutoTextPath( sValue );break;
860 case SvtPathOptions::PATH_BACKUP: aPathOptions.SetBackupPath( sValue );break;
861 case SvtPathOptions::PATH_BASIC: aPathOptions.SetBasicPath( sValue );break;
862 case SvtPathOptions::PATH_BITMAP: aPathOptions.SetBitmapPath( sValue );break;
863 case SvtPathOptions::PATH_CONFIG: aPathOptions.SetConfigPath( sValue );break;
864 case SvtPathOptions::PATH_DICTIONARY: aPathOptions.SetDictionaryPath( sValue );break;
865 case SvtPathOptions::PATH_FAVORITES: aPathOptions.SetFavoritesPath( sValue );break;
866 case SvtPathOptions::PATH_FILTER:
868 rtl::OUString aTmp;
869 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue, aTmp ) )
870 aPathOptions.SetFilterPath( aTmp );
871 break;
873 case SvtPathOptions::PATH_GALLERY: aPathOptions.SetGalleryPath( sValue );break;
874 case SvtPathOptions::PATH_GRAPHIC: aPathOptions.SetGraphicPath( sValue );break;
875 case SvtPathOptions::PATH_HELP:
877 rtl::OUString aTmp;
878 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue, aTmp ) )
879 aPathOptions.SetHelpPath( aTmp );
880 break;
883 case SvtPathOptions::PATH_LINGUISTIC: aPathOptions.SetLinguisticPath( sValue );break;
884 case SvtPathOptions::PATH_MODULE:
886 rtl::OUString aTmp;
887 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue, aTmp ) )
888 aPathOptions.SetModulePath( aTmp );
889 break;
892 case SvtPathOptions::PATH_PALETTE: aPathOptions.SetPalettePath( sValue );break;
893 case SvtPathOptions::PATH_PLUGIN:
895 rtl::OUString aTmp;
896 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue, aTmp ) )
897 aPathOptions.SetPluginPath( aTmp );
898 break;
901 case SvtPathOptions::PATH_STORAGE:
903 rtl::OUString aTmp;
904 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue, aTmp ) )
905 aPathOptions.SetStoragePath( aTmp );
906 break;
909 case SvtPathOptions::PATH_TEMP: aPathOptions.SetTempPath( sValue );break;
910 case SvtPathOptions::PATH_TEMPLATE: aPathOptions.SetTemplatePath( sValue );break;
911 case SvtPathOptions::PATH_USERCONFIG: aPathOptions.SetUserConfigPath( sValue );break;
912 case SvtPathOptions::PATH_WORK: aPathOptions.SetWorkPath( sValue );break;
913 default: SAL_WARN( "sfx2.appl", "SfxApplication::SetOptions_Impl() Invalid path number found for set directories!" );
918 aSendSet.ClearItem( rPool.GetWhich( SID_ATTR_PATHNAME ) );
921 SetOptions_Impl( rSet );
923 // Undo-Count
924 Broadcast( SfxItemSetHint( rSet ) );
927 //--------------------------------------------------------------------
928 void SfxApplication::NotifyEvent( const SfxEventHint& rEventHint, bool bSynchron )
930 SfxObjectShell *pDoc = rEventHint.GetObjShell();
931 if ( pDoc && ( pDoc->IsPreview() || !pDoc->Get_Impl()->bInitialized ) )
932 return;
934 if ( bSynchron )
936 #ifdef DBG_UTIL
937 if (!pDoc)
939 rtl::OStringBuffer aTmp(RTL_CONSTASCII_STRINGPARAM("SfxEvent: "));
940 aTmp.append(rtl::OUStringToOString(rEventHint.GetEventName(), RTL_TEXTENCODING_UTF8));
941 OSL_TRACE( "%s", aTmp.getStr() );
943 #endif
944 Broadcast(rEventHint);
945 if ( pDoc )
946 pDoc->Broadcast( rEventHint );
948 else
949 new SfxEventAsyncer_Impl( rEventHint );
952 IMPL_OBJHINT( SfxStringHint, String )
954 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */