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>
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::...
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
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() )
118 // -----------------------------------------------------------------------
120 SfxEventAsyncer_Impl::SfxEventAsyncer_Impl( const SfxEventHint
& rHint
)
123 if( rHint
.GetObjShell() )
124 StartListening( *rHint
.GetObjShell() );
126 pTimer
->SetTimeoutHdl( LINK(this, SfxEventAsyncer_Impl
, TimerHdl
) );
127 pTimer
->SetTimeout( 0 );
131 // -----------------------------------------------------------------------
133 SfxEventAsyncer_Impl::~SfxEventAsyncer_Impl()
138 // -----------------------------------------------------------------------
140 IMPL_LINK(SfxEventAsyncer_Impl
, TimerHdl
, Timer
*, pAsyncTimer
)
142 (void)pAsyncTimer
; // unused variable
143 SfxObjectShellRef
xRef( aHint
.GetObjShell() );
148 rtl::OStringBuffer
aTmp(RTL_CONSTASCII_STRINGPARAM("SfxEvent: "));
149 aTmp
.append(rtl::OUStringToOString(aHint
.GetEventName(), RTL_TEXTENCODING_UTF8
));
150 OSL_TRACE( "%s", aTmp
.getStr() );
153 SFX_APP()->Broadcast( aHint
);
155 xRef
->Broadcast( aHint
);
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
;
177 for(sal_uInt16 nWhich
= *pRanges
++; nWhich
<= *pRanges
; ++nWhich
)
181 case SID_ATTR_BUTTON_OUTSTYLE3D
:
182 if(rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_BUTTON_OUTSTYLE3D
),
183 aMiscOptions
.GetToolboxStyle() != TOOLBOX_STYLE_FLAT
)))
186 case SID_ATTR_BUTTON_BIGSIZE
:
188 if( rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_BUTTON_BIGSIZE
), aMiscOptions
.AreCurrentSymbolsLarge() ) ) )
192 case SID_ATTR_BACKUP
:
195 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_BACKUP
))
196 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_BACKUP
),aSaveOptions
.IsBackup())))
200 case SID_ATTR_PRETTYPRINTING
:
203 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_DOPRETTYPRINTING
))
204 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_PRETTYPRINTING
), aSaveOptions
.IsPrettyPrinting())))
208 case SID_ATTR_WARNALIENFORMAT
:
211 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_WARNALIENFORMAT
))
212 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_WARNALIENFORMAT
), aSaveOptions
.IsWarnAlienFormat())))
216 case SID_ATTR_AUTOSAVE
:
219 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_AUTOSAVE
))
220 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_AUTOSAVE
), aSaveOptions
.IsAutoSave())))
224 case SID_ATTR_AUTOSAVEPROMPT
:
227 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_AUTOSAVEPROMPT
))
228 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_AUTOSAVEPROMPT
), aSaveOptions
.IsAutoSavePrompt())))
232 case SID_ATTR_AUTOSAVEMINUTE
:
235 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_AUTOSAVETIME
))
236 if (!rSet
.Put( SfxUInt16Item( rPool
.GetWhich( SID_ATTR_AUTOSAVEMINUTE
), (sal_uInt16
)aSaveOptions
.GetAutoSaveTime())))
240 case SID_ATTR_DOCINFO
:
243 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_DOCINFSAVE
))
244 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_DOCINFO
), aSaveOptions
.IsDocInfoSave())))
248 case SID_ATTR_WORKINGSET
:
251 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_SAVEWORKINGSET
))
252 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_WORKINGSET
), aSaveOptions
.IsSaveWorkingSet())))
256 case SID_ATTR_SAVEDOCVIEW
:
259 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_SAVEDOCVIEW
))
260 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_SAVEDOCVIEW
), aSaveOptions
.IsSaveDocView())))
264 case SID_ATTR_METRIC
:
266 case SID_HELPBALLOONS
:
267 if(rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_HELPBALLOONS
),
268 aHelpOptions
.IsExtendedHelp() ) ) )
272 if(rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_HELPTIPS
),
273 aHelpOptions
.IsHelpTips() ) ) )
276 case SID_ATTR_AUTOHELPAGENT
:
277 if(rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_ATTR_AUTOHELPAGENT
),
278 aHelpOptions
.IsHelpAgentAutoStartMode() ) ) )
281 case SID_HELPAGENT_TIMEOUT
:
282 if ( rSet
.Put( SfxInt32Item( rPool
.GetWhich( SID_HELPAGENT_TIMEOUT
),
283 aHelpOptions
.GetHelpAgentTimeoutPeriod() ) ) )
286 case SID_ATTR_WELCOMESCREEN
:
287 if(rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_ATTR_WELCOMESCREEN
),
288 aHelpOptions
.IsWelcomeScreen() ) ) )
291 case SID_HELP_STYLESHEET
:
292 if(rSet
.Put( SfxStringItem ( rPool
.GetWhich( SID_HELP_STYLESHEET
),
293 aHelpOptions
.GetHelpStyleSheet() ) ) )
296 case SID_ATTR_UNDO_COUNT
:
299 rPool
.GetWhich(SID_ATTR_UNDO_COUNT
),
300 officecfg::Office::Common::Undo::Steps::get())))
305 case SID_ATTR_QUICKLAUNCHER
:
307 if ( ShutdownIcon::IsQuickstarterInstalled() )
309 if ( rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_QUICKLAUNCHER
),
310 ShutdownIcon::GetAutostart() ) ) )
315 rSet
.DisableItem( rPool
.GetWhich( SID_ATTR_QUICKLAUNCHER
) );
320 case SID_SAVEREL_INET
:
323 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_SAVERELINET
))
324 if (!rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_SAVEREL_INET
), aSaveOptions
.IsSaveRelINet() )))
328 case SID_SAVEREL_FSYS
:
331 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_SAVERELFSYS
))
332 if (!rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_SAVEREL_FSYS
), aSaveOptions
.IsSaveRelFSys() )))
336 case SID_BASIC_ENABLED
:
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()))))
346 case SID_INET_EXE_PLUGIN
:
349 if (!aSecurityOptions
.IsReadOnly(SvtSecurityOptions::E_EXECUTEPLUGINS
))
351 if ( !rSet
.Put( SfxBoolItem( SID_INET_EXE_PLUGIN
, aSecurityOptions
.IsExecutePlugins() ) ) )
356 case SID_MACRO_WARNING
:
359 if (!aSecurityOptions
.IsReadOnly(SvtSecurityOptions::E_WARNING
))
361 if ( !rSet
.Put( SfxBoolItem( SID_MACRO_WARNING
, aSecurityOptions
.IsWarningEnabled() ) ) )
366 case SID_MACRO_CONFIRMATION
:
369 if (!aSecurityOptions
.IsReadOnly(SvtSecurityOptions::E_CONFIRMATION
))
371 if ( !rSet
.Put( SfxBoolItem( SID_MACRO_CONFIRMATION
, aSecurityOptions
.IsConfirmationEnabled() ) ) )
376 case SID_SECURE_URL
:
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();
385 for( nURL
=0; nURL
<nCount
; ++nURL
)
386 aList
.push_back(seqURLs
[nURL
]);
388 if( !rSet
.Put( SfxStringListItem( rPool
.GetWhich(SID_SECURE_URL
), &aList
) ) )
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");
398 case SID_INET_PROXY_TYPE
:
401 rPool
.GetWhich(SID_INET_PROXY_TYPE
),
402 (officecfg::Inet::Settings::ooInetProxyType::
403 get().get_value_or(0)))))
408 case SID_INET_HTTP_PROXY_NAME
:
411 rPool
.GetWhich(SID_INET_HTTP_PROXY_NAME
),
412 officecfg::Inet::Settings::ooInetHTTPProxyName::
418 case SID_INET_HTTP_PROXY_PORT
:
421 rPool
.GetWhich(SID_INET_HTTP_PROXY_PORT
),
422 (officecfg::Inet::Settings::
423 ooInetHTTPProxyPort::get().get_value_or(0)))))
428 case SID_INET_FTP_PROXY_NAME
:
431 rPool
.GetWhich(SID_INET_FTP_PROXY_NAME
),
432 officecfg::Inet::Settings::ooInetFTPProxyName::
438 case SID_INET_FTP_PROXY_PORT
:
441 rPool
.GetWhich(SID_INET_FTP_PROXY_PORT
),
442 (officecfg::Inet::Settings::ooInetFTPProxyPort::
443 get().get_value_or(0)))))
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" );
454 case SID_INET_NOPROXY
:
457 rPool
.GetWhich( SID_INET_NOPROXY
),
458 (officecfg::Inet::Settings::ooInetNoProxy::
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
;
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
) )
509 DBG_WARNING( "W1:Wrong ID while getting Options!" );
514 OSL_FAIL( "Putting options failed!" );
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
);
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() );
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() );
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() );
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() );
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());
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());
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());
631 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_METRIC
), sal_True
, &pItem
))
633 DBG_ASSERT(pItem
->ISA(SfxUInt16Item
), "UInt16Item expected");
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());
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());
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() );
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() );
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();
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() );
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());
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());
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();
711 pFrame
= SfxViewFrame::GetNext(*pFrame
) )
713 // Get the Dispatcher of the Frames
714 SfxDispatcher
*pDispat
= pFrame
->GetDispatcher();
717 // Iterate over all SfxShells on the Dispatchers Stack
719 for ( SfxShell
*pSh
= pDispat
->GetShell(nIdx
);
721 ++nIdx
, pSh
= pDispat
->GetShell(nIdx
) )
723 ::svl::IUndoManager
*pShUndoMgr
= pSh
->GetUndoManager();
725 pShUndoMgr
->SetMaxUndoActionCount( nUndoCount
);
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
);
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() );
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
);
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");
821 // Store changed data
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
);
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
)
850 case SvtPathOptions::PATH_ADDIN
:
853 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue
, aTmp
) )
854 aPathOptions
.SetAddinPath( aTmp
);
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
:
869 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue
, aTmp
) )
870 aPathOptions
.SetFilterPath( aTmp
);
873 case SvtPathOptions::PATH_GALLERY
: aPathOptions
.SetGalleryPath( sValue
);break;
874 case SvtPathOptions::PATH_GRAPHIC
: aPathOptions
.SetGraphicPath( sValue
);break;
875 case SvtPathOptions::PATH_HELP
:
878 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue
, aTmp
) )
879 aPathOptions
.SetHelpPath( aTmp
);
883 case SvtPathOptions::PATH_LINGUISTIC
: aPathOptions
.SetLinguisticPath( sValue
);break;
884 case SvtPathOptions::PATH_MODULE
:
887 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue
, aTmp
) )
888 aPathOptions
.SetModulePath( aTmp
);
892 case SvtPathOptions::PATH_PALETTE
: aPathOptions
.SetPalettePath( sValue
);break;
893 case SvtPathOptions::PATH_PLUGIN
:
896 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue
, aTmp
) )
897 aPathOptions
.SetPluginPath( aTmp
);
901 case SvtPathOptions::PATH_STORAGE
:
904 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue
, aTmp
) )
905 aPathOptions
.SetStoragePath( aTmp
);
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
);
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
) )
939 rtl::OStringBuffer
aTmp(RTL_CONSTASCII_STRINGPARAM("SfxEvent: "));
940 aTmp
.append(rtl::OUStringToOString(rEventHint
.GetEventName(), RTL_TEXTENCODING_UTF8
));
941 OSL_TRACE( "%s", aTmp
.getStr() );
944 Broadcast(rEventHint
);
946 pDoc
->Broadcast( rEventHint
);
949 new SfxEventAsyncer_Impl( rEventHint
);
952 IMPL_OBJHINT( SfxStringHint
, String
)
954 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */