1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: appcfg.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sfx2.hxx"
33 #include <com/sun/star/uno/Reference.hxx>
34 #include <com/sun/star/frame/XDesktop.hpp>
35 #include <com/sun/star/util/XURLTransformer.hpp>
36 #ifndef _COM_SUN_STAR_BEANS_PropertyValue_HPP_
37 #include <com/sun/star/beans/PropertyValue.hpp>
39 #include <com/sun/star/beans/XPropertySet.hpp>
40 #include <com/sun/star/util/XFlushable.hpp>
45 #include <tools/config.hxx>
46 #include <vcl/sound.hxx>
47 #include <vcl/msgbox.hxx>
48 #include <tools/string.hxx>
49 #include <svtools/itempool.hxx>
50 #include <svtools/aeitem.hxx>
51 #include <svtools/slstitm.hxx>
52 #include <svtools/stritem.hxx>
53 #include <svtools/intitem.hxx>
54 #include <svtools/eitem.hxx>
55 #include <svtools/szitem.hxx>
56 #include <svtools/undo.hxx>
58 #define _SVSTDARR_STRINGS
59 #include <svtools/svstdarr.hxx>
60 #include <svtools/ttprops.hxx>
61 #include <sfx2/sfxsids.hrc>
62 #include <sot/exchange.hxx>
64 //#include <svtools/agprop.hxx>
65 #include <sj2/sjapplet.hxx>
66 #include <svtools/isethint.hxx>
68 #include <unotools/configmgr.hxx>
69 #include <tools/urlobj.hxx>
70 #include <tools/wldcrd.hxx>
71 #include <svtools/saveopt.hxx>
72 #include <svtools/helpopt.hxx>
73 #include <svtools/undoopt.hxx>
74 #include <svtools/securityoptions.hxx>
75 #include <svtools/pathoptions.hxx>
76 #include <svtools/inetoptions.hxx>
77 #include <svtools/miscopt.hxx>
78 #include <vcl/toolbox.hxx>
79 #include <unotools/localfilehelper.hxx>
80 #include <comphelper/processfactory.hxx>
81 #include <rtl/ustrbuf.hxx>
82 #include <svtools/misccfg.hxx>
84 #include <sfx2/app.hxx>
85 #include <sfx2/docfile.hxx>
86 #include <sfx2/viewfrm.hxx>
87 #include "sfxhelp.hxx"
88 #include "sfxtypes.hxx"
89 #include <sfx2/dispatch.hxx>
90 #include <sfx2/objsh.hxx>
91 #include "objshimp.hxx"
92 #include <sfx2/viewsh.hxx>
93 #include <sfx2/request.hxx>
94 #include <sfx2/evntconf.hxx>
95 #include "appdata.hxx"
96 #include "workwin.hxx"
97 #include <sfx2/macrconf.hxx>
98 #include "helper.hxx" // SfxContentHelper::...
100 #include "sfxresid.hxx"
101 #include "shutdownicon.hxx"
103 using namespace ::com::sun::star::uno
;
104 using namespace ::com::sun::star::util
;
105 using namespace ::com::sun::star::frame
;
106 using namespace ::com::sun::star::beans
;
108 //-------------------------------------------------------------------------
110 class SfxEventAsyncer_Impl
: public SfxListener
117 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
118 SfxEventAsyncer_Impl( const SfxEventHint
& rHint
);
119 ~SfxEventAsyncer_Impl();
120 DECL_LINK( TimerHdl
, Timer
*);
123 // -----------------------------------------------------------------------
125 void SfxEventAsyncer_Impl::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
127 SfxSimpleHint
* pHint
= PTR_CAST( SfxSimpleHint
, &rHint
);
128 if( pHint
&& pHint
->GetId() == SFX_HINT_DYING
&& pTimer
->IsActive() )
135 // -----------------------------------------------------------------------
137 SfxEventAsyncer_Impl::SfxEventAsyncer_Impl( const SfxEventHint
& rHint
)
140 if( rHint
.GetObjShell() )
141 StartListening( *rHint
.GetObjShell() );
143 pTimer
->SetTimeoutHdl( LINK(this, SfxEventAsyncer_Impl
, TimerHdl
) );
144 pTimer
->SetTimeout( 0 );
148 // -----------------------------------------------------------------------
150 SfxEventAsyncer_Impl::~SfxEventAsyncer_Impl()
155 // -----------------------------------------------------------------------
157 IMPL_LINK(SfxEventAsyncer_Impl
, TimerHdl
, Timer
*, pAsyncTimer
)
159 (void)pAsyncTimer
; // unused variable
160 SfxObjectShellRef
xRef( aHint
.GetObjShell() );
163 ::rtl::OUString aName
= SfxEventConfiguration::GetEventName_Impl( aHint
.GetEventId() );
164 ByteString
aTmp( "SfxEvent: ");
165 aTmp
+= ByteString( String(aName
), RTL_TEXTENCODING_UTF8
);
166 DBG_TRACE( aTmp
.GetBuffer() );
168 SFX_APP()->Broadcast( aHint
);
170 xRef
->Broadcast( aHint
);
176 //--------------------------------------------------------------------
178 BOOL
SfxApplication::GetOptions( SfxItemSet
& rSet
)
181 SfxItemPool
&rPool
= GetPool();
182 String
aTRUEStr('1');
184 const USHORT
*pRanges
= rSet
.GetRanges();
185 SvtSaveOptions aSaveOptions
;
186 SvtUndoOptions aUndoOptions
;
187 SvtHelpOptions aHelpOptions
;
188 SvtInetOptions aInetOptions
;
189 SvtSecurityOptions aSecurityOptions
;
190 SvtMiscOptions aMiscOptions
;
194 for(USHORT nWhich
= *pRanges
++; nWhich
<= *pRanges
; ++nWhich
)
198 case SID_ATTR_BUTTON_OUTSTYLE3D
:
199 if(rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_BUTTON_OUTSTYLE3D
),
200 aMiscOptions
.GetToolboxStyle() != TOOLBOX_STYLE_FLAT
)))
203 case SID_ATTR_BUTTON_BIGSIZE
:
205 if( rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_BUTTON_BIGSIZE
), aMiscOptions
.AreCurrentSymbolsLarge() ) ) )
209 case SID_ATTR_BACKUP
:
212 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_BACKUP
))
213 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_BACKUP
),aSaveOptions
.IsBackup())))
217 case SID_ATTR_PRETTYPRINTING
:
220 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_DOPRETTYPRINTING
))
221 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_PRETTYPRINTING
), aSaveOptions
.IsPrettyPrinting())))
225 case SID_ATTR_WARNALIENFORMAT
:
228 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_WARNALIENFORMAT
))
229 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_WARNALIENFORMAT
), aSaveOptions
.IsWarnAlienFormat())))
233 case SID_ATTR_AUTOSAVE
:
236 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_AUTOSAVE
))
237 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_AUTOSAVE
), aSaveOptions
.IsAutoSave())))
241 case SID_ATTR_AUTOSAVEPROMPT
:
244 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_AUTOSAVEPROMPT
))
245 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_AUTOSAVEPROMPT
), aSaveOptions
.IsAutoSavePrompt())))
249 case SID_ATTR_AUTOSAVEMINUTE
:
252 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_AUTOSAVETIME
))
253 if (!rSet
.Put( SfxUInt16Item( rPool
.GetWhich( SID_ATTR_AUTOSAVEMINUTE
), (UINT16
)aSaveOptions
.GetAutoSaveTime())))
257 case SID_ATTR_DOCINFO
:
260 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_DOCINFSAVE
))
261 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_DOCINFO
), aSaveOptions
.IsDocInfoSave())))
265 case SID_ATTR_WORKINGSET
:
268 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_SAVEWORKINGSET
))
269 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_WORKINGSET
), aSaveOptions
.IsSaveWorkingSet())))
273 case SID_ATTR_SAVEDOCWINS
:
276 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_SAVEDOCWINS
))
277 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_SAVEDOCWINS
), aSaveOptions
.IsSaveDocWins())))
281 case SID_ATTR_SAVEDOCVIEW
:
284 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_SAVEDOCVIEW
))
285 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_SAVEDOCVIEW
), aSaveOptions
.IsSaveDocView())))
289 case SID_ATTR_METRIC
:
290 // if(rSet.Put( SfxUInt16Item( rPool.GetWhich( SID_ATTR_METRIC ),
291 // pOptions->GetMetric() ) ) )
294 case SID_HELPBALLOONS
:
295 if(rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_HELPBALLOONS
),
296 aHelpOptions
.IsExtendedHelp() ) ) )
300 if(rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_HELPTIPS
),
301 aHelpOptions
.IsHelpTips() ) ) )
304 case SID_ATTR_AUTOHELPAGENT
:
305 if(rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_ATTR_AUTOHELPAGENT
),
306 aHelpOptions
.IsHelpAgentAutoStartMode() ) ) )
309 case SID_HELPAGENT_TIMEOUT
:
310 if ( rSet
.Put( SfxInt32Item( rPool
.GetWhich( SID_HELPAGENT_TIMEOUT
),
311 aHelpOptions
.GetHelpAgentTimeoutPeriod() ) ) )
314 case SID_ATTR_WELCOMESCREEN
:
315 if(rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_ATTR_WELCOMESCREEN
),
316 aHelpOptions
.IsWelcomeScreen() ) ) )
319 case SID_HELP_STYLESHEET
:
320 if(rSet
.Put( SfxStringItem ( rPool
.GetWhich( SID_HELP_STYLESHEET
),
321 aHelpOptions
.GetHelpStyleSheet() ) ) )
324 case SID_ATTR_UNDO_COUNT
:
325 if(rSet
.Put( SfxUInt16Item ( rPool
.GetWhich( SID_ATTR_UNDO_COUNT
),
326 (UINT16
)aUndoOptions
.GetUndoCount() ) ) )
329 case SID_ATTR_QUICKLAUNCHER
:
331 if ( ShutdownIcon::IsQuickstarterInstalled() )
333 if ( rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_QUICKLAUNCHER
),
334 ShutdownIcon::GetAutostart() ) ) )
339 rSet
.DisableItem( rPool
.GetWhich( SID_ATTR_QUICKLAUNCHER
) );
344 case SID_SAVEREL_INET
:
347 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_SAVERELINET
))
348 if (!rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_SAVEREL_INET
), aSaveOptions
.IsSaveRelINet() )))
352 case SID_SAVEREL_FSYS
:
355 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_SAVERELFSYS
))
356 if (!rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_SAVEREL_FSYS
), aSaveOptions
.IsSaveRelFSys() )))
360 case SID_BASIC_ENABLED
:
363 if (!aSecurityOptions
.IsReadOnly(SvtSecurityOptions::E_BASICMODE
))
365 if ( !rSet
.Put( SfxUInt16Item( rPool
.GetWhich( SID_BASIC_ENABLED
), sal::static_int_cast
< UINT16
>(aSecurityOptions
.GetBasicMode()))))
370 case SID_INET_EXE_PLUGIN
:
373 if (!aSecurityOptions
.IsReadOnly(SvtSecurityOptions::E_EXECUTEPLUGINS
))
375 if ( !rSet
.Put( SfxBoolItem( SID_INET_EXE_PLUGIN
, aSecurityOptions
.IsExecutePlugins() ) ) )
380 case SID_MACRO_WARNING
:
383 if (!aSecurityOptions
.IsReadOnly(SvtSecurityOptions::E_WARNING
))
385 if ( !rSet
.Put( SfxBoolItem( SID_MACRO_WARNING
, aSecurityOptions
.IsWarningEnabled() ) ) )
390 case SID_MACRO_CONFIRMATION
:
393 if (!aSecurityOptions
.IsReadOnly(SvtSecurityOptions::E_CONFIRMATION
))
395 if ( !rSet
.Put( SfxBoolItem( SID_MACRO_CONFIRMATION
, aSecurityOptions
.IsConfirmationEnabled() ) ) )
400 case SID_SECURE_URL
:
403 if (!aSecurityOptions
.IsReadOnly(SvtSecurityOptions::E_SECUREURLS
))
405 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> seqURLs
= aSecurityOptions
.GetSecureURLs();
407 sal_uInt32 nCount
= seqURLs
.getLength();
409 for( nURL
=0; nURL
<nCount
; ++nURL
)
411 aList
.Insert( new String( seqURLs
[nURL
] ), LIST_APPEND
);
413 if( !rSet
.Put( SfxStringListItem( rPool
.GetWhich(SID_SECURE_URL
),
418 for( nURL
=0; nURL
<nCount
; ++nURL
)
420 delete (String
*)aList
.GetObject(nURL
);
426 case SID_ENABLE_METAFILEPRINT
:
427 #ifdef ENABLE_MISSINGKEYASSERTIONS//MUSTINI
428 DBG_ASSERT(sal_False
, "SfxApplication::GetOptions()\nSoffice.ini key \"Common\\MetafilePrint\" is obsolete! .. How I can support SID_ENABLE_METAFILEPRINT any longer?\n");
431 case SID_INET_PROXY_TYPE
:
433 if( rSet
.Put( SfxUInt16Item ( rPool
.GetWhich( SID_INET_PROXY_TYPE
),
434 (UINT16
)aInetOptions
.GetProxyType() )))
438 case SID_INET_HTTP_PROXY_NAME
:
440 if ( rSet
.Put( SfxStringItem ( rPool
.GetWhich(SID_INET_HTTP_PROXY_NAME
),
441 aInetOptions
.GetProxyHttpName() )))
445 case SID_INET_HTTP_PROXY_PORT
:
446 if ( rSet
.Put( SfxInt32Item( rPool
.GetWhich(SID_INET_HTTP_PROXY_PORT
),
447 aInetOptions
.GetProxyHttpPort() )))
450 case SID_INET_FTP_PROXY_NAME
:
451 if ( rSet
.Put( SfxStringItem ( rPool
.GetWhich(SID_INET_FTP_PROXY_NAME
),
452 aInetOptions
.GetProxyFtpName() )))
455 case SID_INET_FTP_PROXY_PORT
:
456 if ( rSet
.Put( SfxInt32Item ( rPool
.GetWhich(SID_INET_FTP_PROXY_PORT
),
457 aInetOptions
.GetProxyFtpPort() )))
460 case SID_INET_SECURITY_PROXY_NAME
:
461 case SID_INET_SECURITY_PROXY_PORT
:
462 #ifdef ENABLE_MISSINGKEYASSERTIONS//MUSTINI
463 DBG_ASSERT( sal_False
, "SfxApplication::GetOptions()\nSome INET values no longer supported!\n" );
466 case SID_INET_NOPROXY
:
467 if( rSet
.Put( SfxStringItem ( rPool
.GetWhich( SID_INET_NOPROXY
),
468 aInetOptions
.GetProxyNoProxy() )))
471 case SID_ATTR_PATHNAME
:
472 case SID_ATTR_PATHGROUP
:
474 SfxAllEnumItem
aNames(rPool
.GetWhich(SID_ATTR_PATHGROUP
));
475 SfxAllEnumItem
aValues(rPool
.GetWhich(SID_ATTR_PATHNAME
));
476 SvtPathOptions aPathCfg
;
477 for ( USHORT nProp
= SvtPathOptions::PATH_ADDIN
;
478 nProp
<= SvtPathOptions::PATH_WORK
; nProp
++ )
480 const String
aName( SfxResId( CONFIG_PATH_START
+ nProp
) );
481 aNames
.InsertValue( nProp
, aName
);
485 case SvtPathOptions::PATH_ADDIN
: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg
.GetAddinPath(), aValue
); break;
486 case SvtPathOptions::PATH_AUTOCORRECT
: aValue
= aPathCfg
.GetAutoCorrectPath(); break;
487 case SvtPathOptions::PATH_AUTOTEXT
: aValue
= aPathCfg
.GetAutoTextPath(); break;
488 case SvtPathOptions::PATH_BACKUP
: aValue
= aPathCfg
.GetBackupPath(); break;
489 case SvtPathOptions::PATH_BASIC
: aValue
= aPathCfg
.GetBasicPath(); break;
490 case SvtPathOptions::PATH_BITMAP
: aValue
= aPathCfg
.GetBitmapPath(); break;
491 case SvtPathOptions::PATH_CONFIG
: aValue
= aPathCfg
.GetConfigPath(); break;
492 case SvtPathOptions::PATH_DICTIONARY
: aValue
= aPathCfg
.GetDictionaryPath(); break;
493 case SvtPathOptions::PATH_FAVORITES
: aValue
= aPathCfg
.GetFavoritesPath(); break;
494 case SvtPathOptions::PATH_FILTER
: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg
.GetFilterPath(), aValue
); break;
495 case SvtPathOptions::PATH_GALLERY
: aValue
= aPathCfg
.GetGalleryPath(); break;
496 case SvtPathOptions::PATH_GRAPHIC
: aValue
= aPathCfg
.GetGraphicPath(); break;
497 case SvtPathOptions::PATH_HELP
: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg
.GetHelpPath(), aValue
); break;
498 case SvtPathOptions::PATH_LINGUISTIC
: aValue
= aPathCfg
.GetLinguisticPath(); break;
499 case SvtPathOptions::PATH_MODULE
: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg
.GetModulePath(), aValue
); break;
500 case SvtPathOptions::PATH_PALETTE
: aValue
= aPathCfg
.GetPalettePath(); break;
501 case SvtPathOptions::PATH_PLUGIN
: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg
.GetPluginPath(), aValue
); break;
502 case SvtPathOptions::PATH_STORAGE
: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg
.GetStoragePath(), aValue
); break;
503 case SvtPathOptions::PATH_TEMP
: aValue
= aPathCfg
.GetTempPath(); break;
504 case SvtPathOptions::PATH_TEMPLATE
: aValue
= aPathCfg
.GetTemplatePath(); break;
505 case SvtPathOptions::PATH_USERCONFIG
: aValue
= aPathCfg
.GetUserConfigPath(); break;
506 case SvtPathOptions::PATH_WORK
: aValue
= aPathCfg
.GetWorkPath(); break;
508 aValues
.InsertValue( nProp
, aValue
);
511 if ( rSet
.Put(aNames
) || rSet
.Put(aValues
) )
516 DBG_WARNING( "W1:Wrong ID while getting Options!" );
521 DBG_ERROR( "Putting options failed!" );
530 //--------------------------------------------------------------------
531 BOOL
SfxApplication::IsSecureURL( const INetURLObject
& rURL
, const String
* pReferer
) const
533 return SvtSecurityOptions().IsSecureURL( rURL
.GetMainURL( INetURLObject::NO_DECODE
), *pReferer
);
535 //--------------------------------------------------------------------
536 // TODO/CLEANUP: wieso zwei SetOptions Methoden?
537 void SfxApplication::SetOptions_Impl( const SfxItemSet
& rSet
)
539 const SfxPoolItem
*pItem
= 0;
540 SfxItemPool
&rPool
= GetPool();
541 BOOL bResetSession
= FALSE
;
542 BOOL bProxiesModified
= FALSE
;
544 SvtSaveOptions aSaveOptions
;
545 SvtUndoOptions aUndoOptions
;
546 SvtHelpOptions aHelpOptions
;
547 SvtSecurityOptions aSecurityOptions
;
548 SvtPathOptions aPathOptions
;
549 SvtInetOptions aInetOptions
;
550 SvtMiscOptions aMiscOptions
;
551 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_BUTTON_OUTSTYLE3D
), TRUE
, &pItem
) )
553 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
555 ( (const SfxBoolItem
*)pItem
)->GetValue() ? 0 : TOOLBOX_STYLE_FLAT
;
556 aMiscOptions
.SetToolboxStyle( nOutStyle
);
559 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_BUTTON_BIGSIZE
), TRUE
, &pItem
) )
561 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
562 BOOL bBigSize
= ( (const SfxBoolItem
*)pItem
)->GetValue();
563 aMiscOptions
.SetSymbolsSize(
564 sal::static_int_cast
< sal_Int16
>(
565 bBigSize
? SFX_SYMBOLS_SIZE_LARGE
: SFX_SYMBOLS_SIZE_SMALL
) );
566 SfxViewFrame
* pCurrViewFrame
= SfxViewFrame::GetFirst();
567 while ( pCurrViewFrame
)
569 // update all "final" dispatchers
570 if ( !pCurrViewFrame
->GetActiveChildFrame_Impl() )
571 pCurrViewFrame
->GetDispatcher()->Update_Impl(sal_True
);
572 pCurrViewFrame
= SfxViewFrame::GetNext(*pCurrViewFrame
);
577 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_BACKUP
), TRUE
, &pItem
) )
579 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
580 aSaveOptions
.SetBackup( ( (const SfxBoolItem
*)pItem
)->GetValue() );
584 if ( SFX_ITEM_SET
== rSet
.GetItemState( rPool
.GetWhich( SID_ATTR_PRETTYPRINTING
), TRUE
, &pItem
) )
586 DBG_ASSERT( pItem
->ISA( SfxBoolItem
), "BoolItem expected" );
587 aSaveOptions
.SetPrettyPrinting( static_cast< const SfxBoolItem
*> ( pItem
)->GetValue() );
591 if ( SFX_ITEM_SET
== rSet
.GetItemState( rPool
.GetWhich( SID_ATTR_WARNALIENFORMAT
), TRUE
, &pItem
) )
593 DBG_ASSERT( pItem
->ISA( SfxBoolItem
), "BoolItem expected" );
594 aSaveOptions
.SetWarnAlienFormat( static_cast< const SfxBoolItem
*> ( pItem
)->GetValue() );
598 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_AUTOSAVE
), TRUE
, &pItem
))
600 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
601 aSaveOptions
.SetAutoSave( ( (const SfxBoolItem
*)pItem
)->GetValue() );
605 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_AUTOSAVEPROMPT
), TRUE
, &pItem
))
607 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
608 aSaveOptions
.SetAutoSavePrompt(((const SfxBoolItem
*)pItem
)->GetValue());
612 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_AUTOSAVEMINUTE
), TRUE
, &pItem
))
614 DBG_ASSERT(pItem
->ISA(SfxUInt16Item
), "UInt16Item expected");
615 aSaveOptions
.SetAutoSaveTime(((const SfxUInt16Item
*)pItem
)->GetValue());
619 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_DOCINFO
), TRUE
, &pItem
))
621 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
622 aSaveOptions
.SetDocInfoSave(((const SfxBoolItem
*)pItem
)->GetValue());
625 // offende Dokumente merken
626 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_WORKINGSET
), TRUE
, &pItem
))
628 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
629 aSaveOptions
.SetSaveWorkingSet(((const SfxBoolItem
*)pItem
)->GetValue());
632 // offene Fenster speichern
633 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_SAVEDOCWINS
), TRUE
, &pItem
))
635 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
636 aSaveOptions
.SetSaveDocWins(((const SfxBoolItem
*)pItem
)->GetValue());
639 // Fenster-Einstellung speichern
640 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_SAVEDOCVIEW
), TRUE
, &pItem
))
642 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
643 aSaveOptions
.SetSaveDocView(((const SfxBoolItem
*)pItem
)->GetValue());
647 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_METRIC
), TRUE
, &pItem
))
649 DBG_ASSERT(pItem
->ISA(SfxUInt16Item
), "UInt16Item expected");
650 // pOptions->SetMetric((FieldUnit)((const SfxUInt16Item*)pItem)->GetValue());
654 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_HELPBALLOONS
), TRUE
, &pItem
))
656 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
657 aHelpOptions
.SetExtendedHelp(((const SfxBoolItem
*)pItem
)->GetValue());
661 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_HELPTIPS
), TRUE
, &pItem
))
663 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
664 aHelpOptions
.SetHelpTips(((const SfxBoolItem
*)pItem
)->GetValue());
668 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_AUTOHELPAGENT
), TRUE
, &pItem
))
670 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
671 aHelpOptions
.SetHelpAgentAutoStartMode( ((const SfxBoolItem
*)pItem
)->GetValue() );
674 // help agent timeout
675 if ( SFX_ITEM_SET
== rSet
.GetItemState( rPool
.GetWhich( SID_HELPAGENT_TIMEOUT
), TRUE
, &pItem
) )
677 DBG_ASSERT(pItem
->ISA(SfxInt32Item
), "Int32Item expected");
678 aHelpOptions
.SetHelpAgentTimeoutPeriod( ( (const SfxInt32Item
*)pItem
)->GetValue() );
682 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_WELCOMESCREEN
), TRUE
, &pItem
))
684 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
685 aHelpOptions
.SetWelcomeScreen( ((const SfxBoolItem
*)pItem
)->GetValue() );
689 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_WELCOMESCREEN_RESET
), TRUE
, &pItem
))
691 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
692 BOOL bReset
= ((const SfxBoolItem
*)pItem
)->GetValue();
695 DBG_ERROR( "Not implemented, may be EOL!" );
698 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_HELP_STYLESHEET
), TRUE
, &pItem
))
700 DBG_ASSERT(pItem
->ISA(SfxStringItem
), "StringItem expected");
701 aHelpOptions
.SetHelpStyleSheet( ((const SfxStringItem
*)pItem
)->GetValue() );
705 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_SAVEREL_INET
), TRUE
, &pItem
))
707 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
708 aSaveOptions
.SetSaveRelINet(((const SfxBoolItem
*)pItem
)->GetValue());
712 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_SAVEREL_FSYS
), TRUE
, &pItem
))
714 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
715 aSaveOptions
.SetSaveRelFSys(((const SfxBoolItem
*)pItem
)->GetValue());
719 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_UNDO_COUNT
), TRUE
, &pItem
))
721 DBG_ASSERT(pItem
->ISA(SfxUInt16Item
), "UInt16Item expected");
722 USHORT nUndoCount
= ((const SfxUInt16Item
*)pItem
)->GetValue();
723 aUndoOptions
.SetUndoCount( nUndoCount
);
725 // um alle Undo-Manager zu erwischen: "uber alle Frames iterieren
726 for ( SfxViewFrame
*pFrame
= SfxViewFrame::GetFirst();
728 pFrame
= SfxViewFrame::GetNext(*pFrame
) )
730 // den Dispatcher des Frames rausholen
731 SfxDispatcher
*pDispat
= pFrame
->GetDispatcher();
734 // "uber alle SfxShells auf dem Stack des Dispatchers iterieren
736 for ( SfxShell
*pSh
= pDispat
->GetShell(nIdx
);
738 ++nIdx
, pSh
= pDispat
->GetShell(nIdx
) )
740 SfxUndoManager
*pShUndoMgr
= pSh
->GetUndoManager();
742 pShUndoMgr
->SetMaxUndoActionCount( nUndoCount
);
748 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_QUICKLAUNCHER
), TRUE
, &pItem
))
750 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
751 ShutdownIcon::SetAutostart( ( (const SfxBoolItem
*)pItem
)->GetValue() != FALSE
);
755 if ( SFX_ITEM_SET
== rSet
.GetItemState(SID_BASIC_ENABLED
, TRUE
, &pItem
))
757 DBG_ASSERT(pItem
->ISA(SfxUInt16Item
), "SfxInt16Item expected");
758 aSecurityOptions
.SetBasicMode( (EBasicSecurityMode
)( (const SfxUInt16Item
*)pItem
)->GetValue() );
762 if ( SFX_ITEM_SET
== rSet
.GetItemState(SID_INET_EXE_PLUGIN
, TRUE
, &pItem
))
764 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "SfxBoolItem expected");
765 aSecurityOptions
.SetExecutePlugins( ( (const SfxBoolItem
*)pItem
)->GetValue() );
766 bResetSession
= TRUE
;
769 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_INET_PROXY_TYPE
), TRUE
, &pItem
))
771 DBG_ASSERT( pItem
->ISA(SfxUInt16Item
), "UInt16Item expected" );
772 aInetOptions
.SetProxyType((SvtInetOptions::ProxyType
)( (const SfxUInt16Item
*)pItem
)->GetValue());
773 bResetSession
= TRUE
;
774 bProxiesModified
= TRUE
;
777 if ( SFX_ITEM_SET
== rSet
.GetItemState( rPool
.GetWhich( SID_INET_HTTP_PROXY_NAME
), TRUE
, &pItem
) )
779 DBG_ASSERT( pItem
->ISA(SfxStringItem
), "StringItem expected" );
780 aInetOptions
.SetProxyHttpName( ((const SfxStringItem
*)pItem
)->GetValue() );
781 bResetSession
= TRUE
;
782 bProxiesModified
= TRUE
;
784 if ( SFX_ITEM_SET
== rSet
.GetItemState( rPool
.GetWhich( SID_INET_HTTP_PROXY_PORT
), TRUE
, &pItem
) )
786 DBG_ASSERT( pItem
->ISA(SfxInt32Item
), "Int32Item expected" );
787 aInetOptions
.SetProxyHttpPort( ( (const SfxInt32Item
*)pItem
)->GetValue() );
788 bResetSession
= TRUE
;
789 bProxiesModified
= TRUE
;
791 if ( SFX_ITEM_SET
== rSet
.GetItemState( rPool
.GetWhich( SID_INET_FTP_PROXY_NAME
), TRUE
, &pItem
) )
793 DBG_ASSERT( pItem
->ISA(SfxStringItem
), "StringItem expected" );
794 aInetOptions
.SetProxyFtpName( ((const SfxStringItem
*)pItem
)->GetValue() );
795 bResetSession
= TRUE
;
796 bProxiesModified
= TRUE
;
798 if ( SFX_ITEM_SET
== rSet
.GetItemState( rPool
.GetWhich( SID_INET_FTP_PROXY_PORT
), TRUE
, &pItem
) )
800 DBG_ASSERT( pItem
->ISA(SfxInt32Item
), "Int32Item expected" );
801 aInetOptions
.SetProxyFtpPort( ( (const SfxInt32Item
*)pItem
)->GetValue() );
802 bResetSession
= TRUE
;
803 bProxiesModified
= TRUE
;
805 if ( SFX_ITEM_SET
== rSet
.GetItemState(SID_INET_NOPROXY
, TRUE
, &pItem
))
807 DBG_ASSERT(pItem
->ISA(SfxStringItem
), "StringItem expected");
808 aInetOptions
.SetProxyNoProxy(((const SfxStringItem
*)pItem
)->GetValue());
809 bResetSession
= TRUE
;
810 bProxiesModified
= TRUE
;
814 if ( SFX_ITEM_SET
== rSet
.GetItemState(SID_SECURE_URL
, TRUE
, &pItem
))
816 DELETEZ(pAppData_Impl
->pSecureURLs
);
818 DBG_ASSERT(pItem
->ISA(SfxStringListItem
), "StringListItem expected");
819 const List
*pList
= ((SfxStringListItem
*)pItem
)->GetList();
820 sal_uInt32 nCount
= pList
->Count();
821 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> seqURLs(nCount
);
822 for( sal_uInt32 nPosition
=0;nPosition
<nCount
;++nPosition
)
824 seqURLs
[nPosition
] = *(const String
*)(pList
->GetObject(nPosition
));
826 aSecurityOptions
.SetSecureURLs( seqURLs
);
829 if ( SFX_ITEM_SET
== rSet
.GetItemState(SID_MACRO_WARNING
, TRUE
, &pItem
))
831 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "SfxBoolItem expected");
832 aSecurityOptions
.SetWarningEnabled( ( (const SfxBoolItem
*)pItem
)->GetValue() );
834 if ( SFX_ITEM_SET
== rSet
.GetItemState(SID_MACRO_CONFIRMATION
, TRUE
, &pItem
))
836 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "SfxBoolItem expected");
837 aSecurityOptions
.SetConfirmationEnabled( ( (const SfxBoolItem
*)pItem
)->GetValue() );
840 // EnableMetafilePrint
841 if ( SFX_ITEM_SET
== rSet
.GetItemState( rPool
.GetWhich( SID_ENABLE_METAFILEPRINT
), TRUE
, &pItem
) )
843 #ifdef ENABLE_MISSINGKEYASSERTIONS//MUSTINI
844 DBG_ASSERT(sal_False
, "SfxApplication::SetOptions_Impl()\nsoffice.ini key \"MetafilPrint\" not supported any longer!\n");
848 // INet Session neu aufsetzen
853 SjApplet2::settingsChanged();
857 DBG_ERRORFILE( "SjApplet2::settingsChanged() throws an exception" );
861 // geaenderte Daten speichern
862 aInetOptions
.flush();
865 //--------------------------------------------------------------------
866 void SfxApplication::SetOptions(const SfxItemSet
&rSet
)
868 SvtPathOptions aPathOptions
;
870 // Daten werden in DocInfo und IniManager gespeichert
871 const SfxPoolItem
*pItem
= 0;
872 SfxItemPool
&rPool
= GetPool();
874 SfxAllItemSet
aSendSet( rSet
);
877 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_PATHNAME
), TRUE
, &pItem
))
879 DBG_ASSERT(pItem
->ISA(SfxAllEnumItem
), "AllEnumItem expected");
880 const SfxAllEnumItem
* pEnumItem
= (const SfxAllEnumItem
*)pItem
;
881 sal_uInt32 nCount
= pEnumItem
->GetValueCount();
882 String
aNoChangeStr( ' ' );
883 for( sal_uInt32 nPath
=0; nPath
<nCount
; ++nPath
)
885 String sValue
= pEnumItem
->GetValueTextByPos((USHORT
)nPath
);
886 if ( sValue
!= aNoChangeStr
)
890 case SvtPathOptions::PATH_ADDIN
:
893 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue
, aTmp
) )
894 aPathOptions
.SetAddinPath( aTmp
);
898 case SvtPathOptions::PATH_AUTOCORRECT
: aPathOptions
.SetAutoCorrectPath( sValue
);break;
899 case SvtPathOptions::PATH_AUTOTEXT
: aPathOptions
.SetAutoTextPath( sValue
);break;
900 case SvtPathOptions::PATH_BACKUP
: aPathOptions
.SetBackupPath( sValue
);break;
901 case SvtPathOptions::PATH_BASIC
: aPathOptions
.SetBasicPath( sValue
);break;
902 case SvtPathOptions::PATH_BITMAP
: aPathOptions
.SetBitmapPath( sValue
);break;
903 case SvtPathOptions::PATH_CONFIG
: aPathOptions
.SetConfigPath( sValue
);break;
904 case SvtPathOptions::PATH_DICTIONARY
: aPathOptions
.SetDictionaryPath( sValue
);break;
905 case SvtPathOptions::PATH_FAVORITES
: aPathOptions
.SetFavoritesPath( sValue
);break;
906 case SvtPathOptions::PATH_FILTER
:
909 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue
, aTmp
) )
910 aPathOptions
.SetFilterPath( aTmp
);
913 case SvtPathOptions::PATH_GALLERY
: aPathOptions
.SetGalleryPath( sValue
);break;
914 case SvtPathOptions::PATH_GRAPHIC
: aPathOptions
.SetGraphicPath( sValue
);break;
915 case SvtPathOptions::PATH_HELP
:
918 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue
, aTmp
) )
919 aPathOptions
.SetHelpPath( aTmp
);
923 case SvtPathOptions::PATH_LINGUISTIC
: aPathOptions
.SetLinguisticPath( sValue
);break;
924 case SvtPathOptions::PATH_MODULE
:
927 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue
, aTmp
) )
928 aPathOptions
.SetModulePath( aTmp
);
932 case SvtPathOptions::PATH_PALETTE
: aPathOptions
.SetPalettePath( sValue
);break;
933 case SvtPathOptions::PATH_PLUGIN
:
936 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue
, aTmp
) )
937 aPathOptions
.SetPluginPath( aTmp
);
941 case SvtPathOptions::PATH_STORAGE
:
944 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue
, aTmp
) )
945 aPathOptions
.SetStoragePath( aTmp
);
949 case SvtPathOptions::PATH_TEMP
: aPathOptions
.SetTempPath( sValue
);break;
950 case SvtPathOptions::PATH_TEMPLATE
: aPathOptions
.SetTemplatePath( sValue
);break;
951 case SvtPathOptions::PATH_USERCONFIG
: aPathOptions
.SetUserConfigPath( sValue
);break;
952 case SvtPathOptions::PATH_WORK
: aPathOptions
.SetWorkPath( sValue
);break;
953 default: DBG_ERRORFILE("SfxApplication::SetOptions_Impl()\nInvalid path number found for set directories!");
958 aSendSet
.ClearItem( rPool
.GetWhich( SID_ATTR_PATHNAME
) );
961 SetOptions_Impl( rSet
);
964 Broadcast( SfxItemSetHint( rSet
) );
967 //--------------------------------------------------------------------
969 // alle Dokumente speichern
971 BOOL
SfxApplication::SaveAll_Impl(BOOL bPrompt
, BOOL bAutoSave
)
973 bAutoSave
= FALSE
; // functionality moved to new AutoRecovery Service!
978 for ( SfxObjectShell
*pDoc
= SfxObjectShell::GetFirst();
980 pDoc
= SfxObjectShell::GetNext(*pDoc
) )
982 if( SFX_CREATE_MODE_STANDARD
== pDoc
->GetCreateMode() &&
983 SfxViewFrame::GetFirst(pDoc
) &&
984 !pDoc
->IsInModalMode() &&
985 !pDoc
->HasModalViews() )
987 if ( pDoc
->GetProgress() == 0 )
989 if ( !pDoc
->IsModified() )
992 if ( bPrompt
|| (bAutoSave
&& !pDoc
->HasName()) )
993 nRet
= QuerySave_Impl( *pDoc
, bAutoSave
);
997 if ( nRet
== RET_YES
)
999 SfxRequest
aReq( SID_SAVEDOC
, 0, pDoc
->GetPool() );
1000 const SfxPoolItem
*pPoolItem
= pDoc
->ExecuteSlot( aReq
);
1001 if ( !pPoolItem
|| !pPoolItem
->ISA(SfxBoolItem
) ||
1002 !( (const SfxBoolItem
*) pPoolItem
)->GetValue() )
1005 else if ( nRet
== RET_CANCEL
)
1010 else if ( nRet
== RET_NO
)
1020 //--------------------------------------------------------------------
1022 SfxMacroConfig
* SfxApplication::GetMacroConfig() const
1024 return SfxMacroConfig::GetOrCreate();
1027 //--------------------------------------------------------------------
1028 SfxEventConfiguration
* SfxApplication::GetEventConfig() const
1030 if (!pAppData_Impl
->pEventConfig
)
1031 pAppData_Impl
->pEventConfig
= new SfxEventConfiguration
;
1032 return pAppData_Impl
->pEventConfig
;
1035 //--------------------------------------------------------------------
1037 //--------------------------------------------------------------------
1038 void SfxApplication::NotifyEvent( const SfxEventHint
& rEventHint
, FASTBOOL bSynchron
)
1040 DBG_ASSERT(pAppData_Impl
->pEventConfig
,"Keine Events angemeldet!");
1042 SfxObjectShell
*pDoc
= rEventHint
.GetObjShell();
1043 if ( pDoc
&& ( pDoc
->IsPreview() || !pDoc
->Get_Impl()->bInitialized
) )
1047 ::rtl::OUString aName
= SfxEventConfiguration::GetEventName_Impl( rEventHint
.GetEventId() );
1048 ByteString
aTmp( "SfxEvent: ");
1049 aTmp
+= ByteString( String(aName
), RTL_TEXTENCODING_UTF8
);
1050 DBG_TRACE( aTmp
.GetBuffer() );
1055 Broadcast(rEventHint
);
1057 pDoc
->Broadcast( rEventHint
);
1060 new SfxEventAsyncer_Impl( rEventHint
);
1063 IMPL_OBJHINT( SfxStringHint
, String
)
1065 SfxMiscCfg
* SfxApplication::GetMiscConfig()
1067 if ( !pAppData_Impl
->pMiscConfig
)
1068 pAppData_Impl
->pMiscConfig
= new SfxMiscCfg
;
1070 return pAppData_Impl
->pMiscConfig
;