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() );
165 ByteString
aTmp( "SfxEvent: ");
166 aTmp
+= ByteString( String( aHint
.GetEventName() ), RTL_TEXTENCODING_UTF8
);
167 DBG_TRACE( aTmp
.GetBuffer() );
170 SFX_APP()->Broadcast( aHint
);
172 xRef
->Broadcast( aHint
);
178 //--------------------------------------------------------------------
180 BOOL
SfxApplication::GetOptions( SfxItemSet
& rSet
)
183 SfxItemPool
&rPool
= GetPool();
184 String
aTRUEStr('1');
186 const USHORT
*pRanges
= rSet
.GetRanges();
187 SvtSaveOptions aSaveOptions
;
188 SvtUndoOptions aUndoOptions
;
189 SvtHelpOptions aHelpOptions
;
190 SvtInetOptions aInetOptions
;
191 SvtSecurityOptions aSecurityOptions
;
192 SvtMiscOptions aMiscOptions
;
196 for(USHORT nWhich
= *pRanges
++; nWhich
<= *pRanges
; ++nWhich
)
200 case SID_ATTR_BUTTON_OUTSTYLE3D
:
201 if(rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_BUTTON_OUTSTYLE3D
),
202 aMiscOptions
.GetToolboxStyle() != TOOLBOX_STYLE_FLAT
)))
205 case SID_ATTR_BUTTON_BIGSIZE
:
207 if( rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_BUTTON_BIGSIZE
), aMiscOptions
.AreCurrentSymbolsLarge() ) ) )
211 case SID_ATTR_BACKUP
:
214 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_BACKUP
))
215 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_BACKUP
),aSaveOptions
.IsBackup())))
219 case SID_ATTR_PRETTYPRINTING
:
222 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_DOPRETTYPRINTING
))
223 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_PRETTYPRINTING
), aSaveOptions
.IsPrettyPrinting())))
227 case SID_ATTR_WARNALIENFORMAT
:
230 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_WARNALIENFORMAT
))
231 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_WARNALIENFORMAT
), aSaveOptions
.IsWarnAlienFormat())))
235 case SID_ATTR_AUTOSAVE
:
238 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_AUTOSAVE
))
239 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_AUTOSAVE
), aSaveOptions
.IsAutoSave())))
243 case SID_ATTR_AUTOSAVEPROMPT
:
246 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_AUTOSAVEPROMPT
))
247 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_AUTOSAVEPROMPT
), aSaveOptions
.IsAutoSavePrompt())))
251 case SID_ATTR_AUTOSAVEMINUTE
:
254 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_AUTOSAVETIME
))
255 if (!rSet
.Put( SfxUInt16Item( rPool
.GetWhich( SID_ATTR_AUTOSAVEMINUTE
), (UINT16
)aSaveOptions
.GetAutoSaveTime())))
259 case SID_ATTR_DOCINFO
:
262 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_DOCINFSAVE
))
263 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_DOCINFO
), aSaveOptions
.IsDocInfoSave())))
267 case SID_ATTR_WORKINGSET
:
270 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_SAVEWORKINGSET
))
271 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_WORKINGSET
), aSaveOptions
.IsSaveWorkingSet())))
275 case SID_ATTR_SAVEDOCWINS
:
278 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_SAVEDOCWINS
))
279 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_SAVEDOCWINS
), aSaveOptions
.IsSaveDocWins())))
283 case SID_ATTR_SAVEDOCVIEW
:
286 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_SAVEDOCVIEW
))
287 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_SAVEDOCVIEW
), aSaveOptions
.IsSaveDocView())))
291 case SID_ATTR_METRIC
:
292 // if(rSet.Put( SfxUInt16Item( rPool.GetWhich( SID_ATTR_METRIC ),
293 // pOptions->GetMetric() ) ) )
296 case SID_HELPBALLOONS
:
297 if(rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_HELPBALLOONS
),
298 aHelpOptions
.IsExtendedHelp() ) ) )
302 if(rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_HELPTIPS
),
303 aHelpOptions
.IsHelpTips() ) ) )
306 case SID_ATTR_AUTOHELPAGENT
:
307 if(rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_ATTR_AUTOHELPAGENT
),
308 aHelpOptions
.IsHelpAgentAutoStartMode() ) ) )
311 case SID_HELPAGENT_TIMEOUT
:
312 if ( rSet
.Put( SfxInt32Item( rPool
.GetWhich( SID_HELPAGENT_TIMEOUT
),
313 aHelpOptions
.GetHelpAgentTimeoutPeriod() ) ) )
316 case SID_ATTR_WELCOMESCREEN
:
317 if(rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_ATTR_WELCOMESCREEN
),
318 aHelpOptions
.IsWelcomeScreen() ) ) )
321 case SID_HELP_STYLESHEET
:
322 if(rSet
.Put( SfxStringItem ( rPool
.GetWhich( SID_HELP_STYLESHEET
),
323 aHelpOptions
.GetHelpStyleSheet() ) ) )
326 case SID_ATTR_UNDO_COUNT
:
327 if(rSet
.Put( SfxUInt16Item ( rPool
.GetWhich( SID_ATTR_UNDO_COUNT
),
328 (UINT16
)aUndoOptions
.GetUndoCount() ) ) )
331 case SID_ATTR_QUICKLAUNCHER
:
333 if ( ShutdownIcon::IsQuickstarterInstalled() )
335 if ( rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_QUICKLAUNCHER
),
336 ShutdownIcon::GetAutostart() ) ) )
341 rSet
.DisableItem( rPool
.GetWhich( SID_ATTR_QUICKLAUNCHER
) );
346 case SID_SAVEREL_INET
:
349 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_SAVERELINET
))
350 if (!rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_SAVEREL_INET
), aSaveOptions
.IsSaveRelINet() )))
354 case SID_SAVEREL_FSYS
:
357 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_SAVERELFSYS
))
358 if (!rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_SAVEREL_FSYS
), aSaveOptions
.IsSaveRelFSys() )))
362 case SID_BASIC_ENABLED
:
365 if (!aSecurityOptions
.IsReadOnly(SvtSecurityOptions::E_BASICMODE
))
367 if ( !rSet
.Put( SfxUInt16Item( rPool
.GetWhich( SID_BASIC_ENABLED
), sal::static_int_cast
< UINT16
>(aSecurityOptions
.GetBasicMode()))))
372 case SID_INET_EXE_PLUGIN
:
375 if (!aSecurityOptions
.IsReadOnly(SvtSecurityOptions::E_EXECUTEPLUGINS
))
377 if ( !rSet
.Put( SfxBoolItem( SID_INET_EXE_PLUGIN
, aSecurityOptions
.IsExecutePlugins() ) ) )
382 case SID_MACRO_WARNING
:
385 if (!aSecurityOptions
.IsReadOnly(SvtSecurityOptions::E_WARNING
))
387 if ( !rSet
.Put( SfxBoolItem( SID_MACRO_WARNING
, aSecurityOptions
.IsWarningEnabled() ) ) )
392 case SID_MACRO_CONFIRMATION
:
395 if (!aSecurityOptions
.IsReadOnly(SvtSecurityOptions::E_CONFIRMATION
))
397 if ( !rSet
.Put( SfxBoolItem( SID_MACRO_CONFIRMATION
, aSecurityOptions
.IsConfirmationEnabled() ) ) )
402 case SID_SECURE_URL
:
405 if (!aSecurityOptions
.IsReadOnly(SvtSecurityOptions::E_SECUREURLS
))
407 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> seqURLs
= aSecurityOptions
.GetSecureURLs();
409 sal_uInt32 nCount
= seqURLs
.getLength();
411 for( nURL
=0; nURL
<nCount
; ++nURL
)
413 aList
.Insert( new String( seqURLs
[nURL
] ), LIST_APPEND
);
415 if( !rSet
.Put( SfxStringListItem( rPool
.GetWhich(SID_SECURE_URL
),
420 for( nURL
=0; nURL
<nCount
; ++nURL
)
422 delete (String
*)aList
.GetObject(nURL
);
428 case SID_ENABLE_METAFILEPRINT
:
429 #ifdef ENABLE_MISSINGKEYASSERTIONS//MUSTINI
430 DBG_ASSERT(sal_False
, "SfxApplication::GetOptions()\nSoffice.ini key \"Common\\MetafilePrint\" is obsolete! .. How I can support SID_ENABLE_METAFILEPRINT any longer?\n");
433 case SID_INET_PROXY_TYPE
:
435 if( rSet
.Put( SfxUInt16Item ( rPool
.GetWhich( SID_INET_PROXY_TYPE
),
436 (UINT16
)aInetOptions
.GetProxyType() )))
440 case SID_INET_HTTP_PROXY_NAME
:
442 if ( rSet
.Put( SfxStringItem ( rPool
.GetWhich(SID_INET_HTTP_PROXY_NAME
),
443 aInetOptions
.GetProxyHttpName() )))
447 case SID_INET_HTTP_PROXY_PORT
:
448 if ( rSet
.Put( SfxInt32Item( rPool
.GetWhich(SID_INET_HTTP_PROXY_PORT
),
449 aInetOptions
.GetProxyHttpPort() )))
452 case SID_INET_FTP_PROXY_NAME
:
453 if ( rSet
.Put( SfxStringItem ( rPool
.GetWhich(SID_INET_FTP_PROXY_NAME
),
454 aInetOptions
.GetProxyFtpName() )))
457 case SID_INET_FTP_PROXY_PORT
:
458 if ( rSet
.Put( SfxInt32Item ( rPool
.GetWhich(SID_INET_FTP_PROXY_PORT
),
459 aInetOptions
.GetProxyFtpPort() )))
462 case SID_INET_SECURITY_PROXY_NAME
:
463 case SID_INET_SECURITY_PROXY_PORT
:
464 #ifdef ENABLE_MISSINGKEYASSERTIONS//MUSTINI
465 DBG_ASSERT( sal_False
, "SfxApplication::GetOptions()\nSome INET values no longer supported!\n" );
468 case SID_INET_NOPROXY
:
469 if( rSet
.Put( SfxStringItem ( rPool
.GetWhich( SID_INET_NOPROXY
),
470 aInetOptions
.GetProxyNoProxy() )))
473 case SID_ATTR_PATHNAME
:
474 case SID_ATTR_PATHGROUP
:
476 SfxAllEnumItem
aNames(rPool
.GetWhich(SID_ATTR_PATHGROUP
));
477 SfxAllEnumItem
aValues(rPool
.GetWhich(SID_ATTR_PATHNAME
));
478 SvtPathOptions aPathCfg
;
479 for ( USHORT nProp
= SvtPathOptions::PATH_ADDIN
;
480 nProp
<= SvtPathOptions::PATH_WORK
; nProp
++ )
482 const String
aName( SfxResId( CONFIG_PATH_START
+ nProp
) );
483 aNames
.InsertValue( nProp
, aName
);
487 case SvtPathOptions::PATH_ADDIN
: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg
.GetAddinPath(), aValue
); break;
488 case SvtPathOptions::PATH_AUTOCORRECT
: aValue
= aPathCfg
.GetAutoCorrectPath(); break;
489 case SvtPathOptions::PATH_AUTOTEXT
: aValue
= aPathCfg
.GetAutoTextPath(); break;
490 case SvtPathOptions::PATH_BACKUP
: aValue
= aPathCfg
.GetBackupPath(); break;
491 case SvtPathOptions::PATH_BASIC
: aValue
= aPathCfg
.GetBasicPath(); break;
492 case SvtPathOptions::PATH_BITMAP
: aValue
= aPathCfg
.GetBitmapPath(); break;
493 case SvtPathOptions::PATH_CONFIG
: aValue
= aPathCfg
.GetConfigPath(); break;
494 case SvtPathOptions::PATH_DICTIONARY
: aValue
= aPathCfg
.GetDictionaryPath(); break;
495 case SvtPathOptions::PATH_FAVORITES
: aValue
= aPathCfg
.GetFavoritesPath(); break;
496 case SvtPathOptions::PATH_FILTER
: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg
.GetFilterPath(), aValue
); break;
497 case SvtPathOptions::PATH_GALLERY
: aValue
= aPathCfg
.GetGalleryPath(); break;
498 case SvtPathOptions::PATH_GRAPHIC
: aValue
= aPathCfg
.GetGraphicPath(); break;
499 case SvtPathOptions::PATH_HELP
: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg
.GetHelpPath(), aValue
); break;
500 case SvtPathOptions::PATH_LINGUISTIC
: aValue
= aPathCfg
.GetLinguisticPath(); break;
501 case SvtPathOptions::PATH_MODULE
: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg
.GetModulePath(), aValue
); break;
502 case SvtPathOptions::PATH_PALETTE
: aValue
= aPathCfg
.GetPalettePath(); break;
503 case SvtPathOptions::PATH_PLUGIN
: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg
.GetPluginPath(), aValue
); break;
504 case SvtPathOptions::PATH_STORAGE
: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg
.GetStoragePath(), aValue
); break;
505 case SvtPathOptions::PATH_TEMP
: aValue
= aPathCfg
.GetTempPath(); break;
506 case SvtPathOptions::PATH_TEMPLATE
: aValue
= aPathCfg
.GetTemplatePath(); break;
507 case SvtPathOptions::PATH_USERCONFIG
: aValue
= aPathCfg
.GetUserConfigPath(); break;
508 case SvtPathOptions::PATH_WORK
: aValue
= aPathCfg
.GetWorkPath(); break;
510 aValues
.InsertValue( nProp
, aValue
);
513 if ( rSet
.Put(aNames
) || rSet
.Put(aValues
) )
518 DBG_WARNING( "W1:Wrong ID while getting Options!" );
523 DBG_ERROR( "Putting options failed!" );
532 //--------------------------------------------------------------------
533 BOOL
SfxApplication::IsSecureURL( const INetURLObject
& rURL
, const String
* pReferer
) const
535 return SvtSecurityOptions().IsSecureURL( rURL
.GetMainURL( INetURLObject::NO_DECODE
), *pReferer
);
537 //--------------------------------------------------------------------
538 // TODO/CLEANUP: wieso zwei SetOptions Methoden?
539 void SfxApplication::SetOptions_Impl( const SfxItemSet
& rSet
)
541 const SfxPoolItem
*pItem
= 0;
542 SfxItemPool
&rPool
= GetPool();
543 BOOL bResetSession
= FALSE
;
544 BOOL bProxiesModified
= FALSE
;
546 SvtSaveOptions aSaveOptions
;
547 SvtUndoOptions aUndoOptions
;
548 SvtHelpOptions aHelpOptions
;
549 SvtSecurityOptions aSecurityOptions
;
550 SvtPathOptions aPathOptions
;
551 SvtInetOptions aInetOptions
;
552 SvtMiscOptions aMiscOptions
;
553 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_BUTTON_OUTSTYLE3D
), TRUE
, &pItem
) )
555 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
557 ( (const SfxBoolItem
*)pItem
)->GetValue() ? 0 : TOOLBOX_STYLE_FLAT
;
558 aMiscOptions
.SetToolboxStyle( nOutStyle
);
561 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_BUTTON_BIGSIZE
), TRUE
, &pItem
) )
563 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
564 BOOL bBigSize
= ( (const SfxBoolItem
*)pItem
)->GetValue();
565 aMiscOptions
.SetSymbolsSize(
566 sal::static_int_cast
< sal_Int16
>(
567 bBigSize
? SFX_SYMBOLS_SIZE_LARGE
: SFX_SYMBOLS_SIZE_SMALL
) );
568 SfxViewFrame
* pCurrViewFrame
= SfxViewFrame::GetFirst();
569 while ( pCurrViewFrame
)
571 // update all "final" dispatchers
572 if ( !pCurrViewFrame
->GetActiveChildFrame_Impl() )
573 pCurrViewFrame
->GetDispatcher()->Update_Impl(sal_True
);
574 pCurrViewFrame
= SfxViewFrame::GetNext(*pCurrViewFrame
);
579 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_BACKUP
), TRUE
, &pItem
) )
581 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
582 aSaveOptions
.SetBackup( ( (const SfxBoolItem
*)pItem
)->GetValue() );
586 if ( SFX_ITEM_SET
== rSet
.GetItemState( rPool
.GetWhich( SID_ATTR_PRETTYPRINTING
), TRUE
, &pItem
) )
588 DBG_ASSERT( pItem
->ISA( SfxBoolItem
), "BoolItem expected" );
589 aSaveOptions
.SetPrettyPrinting( static_cast< const SfxBoolItem
*> ( pItem
)->GetValue() );
593 if ( SFX_ITEM_SET
== rSet
.GetItemState( rPool
.GetWhich( SID_ATTR_WARNALIENFORMAT
), TRUE
, &pItem
) )
595 DBG_ASSERT( pItem
->ISA( SfxBoolItem
), "BoolItem expected" );
596 aSaveOptions
.SetWarnAlienFormat( static_cast< const SfxBoolItem
*> ( pItem
)->GetValue() );
600 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_AUTOSAVE
), TRUE
, &pItem
))
602 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
603 aSaveOptions
.SetAutoSave( ( (const SfxBoolItem
*)pItem
)->GetValue() );
607 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_AUTOSAVEPROMPT
), TRUE
, &pItem
))
609 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
610 aSaveOptions
.SetAutoSavePrompt(((const SfxBoolItem
*)pItem
)->GetValue());
614 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_AUTOSAVEMINUTE
), TRUE
, &pItem
))
616 DBG_ASSERT(pItem
->ISA(SfxUInt16Item
), "UInt16Item expected");
617 aSaveOptions
.SetAutoSaveTime(((const SfxUInt16Item
*)pItem
)->GetValue());
621 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_DOCINFO
), TRUE
, &pItem
))
623 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
624 aSaveOptions
.SetDocInfoSave(((const SfxBoolItem
*)pItem
)->GetValue());
627 // offende Dokumente merken
628 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_WORKINGSET
), TRUE
, &pItem
))
630 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
631 aSaveOptions
.SetSaveWorkingSet(((const SfxBoolItem
*)pItem
)->GetValue());
634 // offene Fenster speichern
635 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_SAVEDOCWINS
), TRUE
, &pItem
))
637 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
638 aSaveOptions
.SetSaveDocWins(((const SfxBoolItem
*)pItem
)->GetValue());
641 // Fenster-Einstellung speichern
642 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_SAVEDOCVIEW
), TRUE
, &pItem
))
644 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
645 aSaveOptions
.SetSaveDocView(((const SfxBoolItem
*)pItem
)->GetValue());
649 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_METRIC
), TRUE
, &pItem
))
651 DBG_ASSERT(pItem
->ISA(SfxUInt16Item
), "UInt16Item expected");
652 // pOptions->SetMetric((FieldUnit)((const SfxUInt16Item*)pItem)->GetValue());
656 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_HELPBALLOONS
), TRUE
, &pItem
))
658 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
659 aHelpOptions
.SetExtendedHelp(((const SfxBoolItem
*)pItem
)->GetValue());
663 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_HELPTIPS
), TRUE
, &pItem
))
665 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
666 aHelpOptions
.SetHelpTips(((const SfxBoolItem
*)pItem
)->GetValue());
670 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_AUTOHELPAGENT
), TRUE
, &pItem
))
672 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
673 aHelpOptions
.SetHelpAgentAutoStartMode( ((const SfxBoolItem
*)pItem
)->GetValue() );
676 // help agent timeout
677 if ( SFX_ITEM_SET
== rSet
.GetItemState( rPool
.GetWhich( SID_HELPAGENT_TIMEOUT
), TRUE
, &pItem
) )
679 DBG_ASSERT(pItem
->ISA(SfxInt32Item
), "Int32Item expected");
680 aHelpOptions
.SetHelpAgentTimeoutPeriod( ( (const SfxInt32Item
*)pItem
)->GetValue() );
684 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_WELCOMESCREEN
), TRUE
, &pItem
))
686 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
687 aHelpOptions
.SetWelcomeScreen( ((const SfxBoolItem
*)pItem
)->GetValue() );
691 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_WELCOMESCREEN_RESET
), TRUE
, &pItem
))
693 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
694 BOOL bReset
= ((const SfxBoolItem
*)pItem
)->GetValue();
697 DBG_ERROR( "Not implemented, may be EOL!" );
700 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_HELP_STYLESHEET
), TRUE
, &pItem
))
702 DBG_ASSERT(pItem
->ISA(SfxStringItem
), "StringItem expected");
703 aHelpOptions
.SetHelpStyleSheet( ((const SfxStringItem
*)pItem
)->GetValue() );
707 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_SAVEREL_INET
), TRUE
, &pItem
))
709 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
710 aSaveOptions
.SetSaveRelINet(((const SfxBoolItem
*)pItem
)->GetValue());
714 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_SAVEREL_FSYS
), TRUE
, &pItem
))
716 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
717 aSaveOptions
.SetSaveRelFSys(((const SfxBoolItem
*)pItem
)->GetValue());
721 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_UNDO_COUNT
), TRUE
, &pItem
))
723 DBG_ASSERT(pItem
->ISA(SfxUInt16Item
), "UInt16Item expected");
724 USHORT nUndoCount
= ((const SfxUInt16Item
*)pItem
)->GetValue();
725 aUndoOptions
.SetUndoCount( nUndoCount
);
727 // um alle Undo-Manager zu erwischen: "uber alle Frames iterieren
728 for ( SfxViewFrame
*pFrame
= SfxViewFrame::GetFirst();
730 pFrame
= SfxViewFrame::GetNext(*pFrame
) )
732 // den Dispatcher des Frames rausholen
733 SfxDispatcher
*pDispat
= pFrame
->GetDispatcher();
736 // "uber alle SfxShells auf dem Stack des Dispatchers iterieren
738 for ( SfxShell
*pSh
= pDispat
->GetShell(nIdx
);
740 ++nIdx
, pSh
= pDispat
->GetShell(nIdx
) )
742 SfxUndoManager
*pShUndoMgr
= pSh
->GetUndoManager();
744 pShUndoMgr
->SetMaxUndoActionCount( nUndoCount
);
750 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_QUICKLAUNCHER
), TRUE
, &pItem
))
752 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
753 ShutdownIcon::SetAutostart( ( (const SfxBoolItem
*)pItem
)->GetValue() != FALSE
);
757 if ( SFX_ITEM_SET
== rSet
.GetItemState(SID_BASIC_ENABLED
, TRUE
, &pItem
))
759 DBG_ASSERT(pItem
->ISA(SfxUInt16Item
), "SfxInt16Item expected");
760 aSecurityOptions
.SetBasicMode( (EBasicSecurityMode
)( (const SfxUInt16Item
*)pItem
)->GetValue() );
764 if ( SFX_ITEM_SET
== rSet
.GetItemState(SID_INET_EXE_PLUGIN
, TRUE
, &pItem
))
766 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "SfxBoolItem expected");
767 aSecurityOptions
.SetExecutePlugins( ( (const SfxBoolItem
*)pItem
)->GetValue() );
768 bResetSession
= TRUE
;
771 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_INET_PROXY_TYPE
), TRUE
, &pItem
))
773 DBG_ASSERT( pItem
->ISA(SfxUInt16Item
), "UInt16Item expected" );
774 aInetOptions
.SetProxyType((SvtInetOptions::ProxyType
)( (const SfxUInt16Item
*)pItem
)->GetValue());
775 bResetSession
= TRUE
;
776 bProxiesModified
= TRUE
;
779 if ( SFX_ITEM_SET
== rSet
.GetItemState( rPool
.GetWhich( SID_INET_HTTP_PROXY_NAME
), TRUE
, &pItem
) )
781 DBG_ASSERT( pItem
->ISA(SfxStringItem
), "StringItem expected" );
782 aInetOptions
.SetProxyHttpName( ((const SfxStringItem
*)pItem
)->GetValue() );
783 bResetSession
= TRUE
;
784 bProxiesModified
= TRUE
;
786 if ( SFX_ITEM_SET
== rSet
.GetItemState( rPool
.GetWhich( SID_INET_HTTP_PROXY_PORT
), TRUE
, &pItem
) )
788 DBG_ASSERT( pItem
->ISA(SfxInt32Item
), "Int32Item expected" );
789 aInetOptions
.SetProxyHttpPort( ( (const SfxInt32Item
*)pItem
)->GetValue() );
790 bResetSession
= TRUE
;
791 bProxiesModified
= TRUE
;
793 if ( SFX_ITEM_SET
== rSet
.GetItemState( rPool
.GetWhich( SID_INET_FTP_PROXY_NAME
), TRUE
, &pItem
) )
795 DBG_ASSERT( pItem
->ISA(SfxStringItem
), "StringItem expected" );
796 aInetOptions
.SetProxyFtpName( ((const SfxStringItem
*)pItem
)->GetValue() );
797 bResetSession
= TRUE
;
798 bProxiesModified
= TRUE
;
800 if ( SFX_ITEM_SET
== rSet
.GetItemState( rPool
.GetWhich( SID_INET_FTP_PROXY_PORT
), TRUE
, &pItem
) )
802 DBG_ASSERT( pItem
->ISA(SfxInt32Item
), "Int32Item expected" );
803 aInetOptions
.SetProxyFtpPort( ( (const SfxInt32Item
*)pItem
)->GetValue() );
804 bResetSession
= TRUE
;
805 bProxiesModified
= TRUE
;
807 if ( SFX_ITEM_SET
== rSet
.GetItemState(SID_INET_NOPROXY
, TRUE
, &pItem
))
809 DBG_ASSERT(pItem
->ISA(SfxStringItem
), "StringItem expected");
810 aInetOptions
.SetProxyNoProxy(((const SfxStringItem
*)pItem
)->GetValue());
811 bResetSession
= TRUE
;
812 bProxiesModified
= TRUE
;
816 if ( SFX_ITEM_SET
== rSet
.GetItemState(SID_SECURE_URL
, TRUE
, &pItem
))
818 DELETEZ(pAppData_Impl
->pSecureURLs
);
820 DBG_ASSERT(pItem
->ISA(SfxStringListItem
), "StringListItem expected");
821 const List
*pList
= ((SfxStringListItem
*)pItem
)->GetList();
822 sal_uInt32 nCount
= pList
->Count();
823 ::com::sun::star::uno::Sequence
< ::rtl::OUString
> seqURLs(nCount
);
824 for( sal_uInt32 nPosition
=0;nPosition
<nCount
;++nPosition
)
826 seqURLs
[nPosition
] = *(const String
*)(pList
->GetObject(nPosition
));
828 aSecurityOptions
.SetSecureURLs( seqURLs
);
831 if ( SFX_ITEM_SET
== rSet
.GetItemState(SID_MACRO_WARNING
, TRUE
, &pItem
))
833 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "SfxBoolItem expected");
834 aSecurityOptions
.SetWarningEnabled( ( (const SfxBoolItem
*)pItem
)->GetValue() );
836 if ( SFX_ITEM_SET
== rSet
.GetItemState(SID_MACRO_CONFIRMATION
, TRUE
, &pItem
))
838 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "SfxBoolItem expected");
839 aSecurityOptions
.SetConfirmationEnabled( ( (const SfxBoolItem
*)pItem
)->GetValue() );
842 // EnableMetafilePrint
843 if ( SFX_ITEM_SET
== rSet
.GetItemState( rPool
.GetWhich( SID_ENABLE_METAFILEPRINT
), TRUE
, &pItem
) )
845 #ifdef ENABLE_MISSINGKEYASSERTIONS//MUSTINI
846 DBG_ASSERT(sal_False
, "SfxApplication::SetOptions_Impl()\nsoffice.ini key \"MetafilPrint\" not supported any longer!\n");
850 // INet Session neu aufsetzen
857 SjApplet2::settingsChanged();
861 DBG_ERRORFILE( "SjApplet2::settingsChanged() throws an exception" );
866 // geaenderte Daten speichern
867 aInetOptions
.flush();
870 //--------------------------------------------------------------------
871 void SfxApplication::SetOptions(const SfxItemSet
&rSet
)
873 SvtPathOptions aPathOptions
;
875 // Daten werden in DocInfo und IniManager gespeichert
876 const SfxPoolItem
*pItem
= 0;
877 SfxItemPool
&rPool
= GetPool();
879 SfxAllItemSet
aSendSet( rSet
);
882 if ( SFX_ITEM_SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_PATHNAME
), TRUE
, &pItem
))
884 DBG_ASSERT(pItem
->ISA(SfxAllEnumItem
), "AllEnumItem expected");
885 const SfxAllEnumItem
* pEnumItem
= (const SfxAllEnumItem
*)pItem
;
886 sal_uInt32 nCount
= pEnumItem
->GetValueCount();
887 String
aNoChangeStr( ' ' );
888 for( sal_uInt32 nPath
=0; nPath
<nCount
; ++nPath
)
890 String sValue
= pEnumItem
->GetValueTextByPos((USHORT
)nPath
);
891 if ( sValue
!= aNoChangeStr
)
895 case SvtPathOptions::PATH_ADDIN
:
898 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue
, aTmp
) )
899 aPathOptions
.SetAddinPath( aTmp
);
903 case SvtPathOptions::PATH_AUTOCORRECT
: aPathOptions
.SetAutoCorrectPath( sValue
);break;
904 case SvtPathOptions::PATH_AUTOTEXT
: aPathOptions
.SetAutoTextPath( sValue
);break;
905 case SvtPathOptions::PATH_BACKUP
: aPathOptions
.SetBackupPath( sValue
);break;
906 case SvtPathOptions::PATH_BASIC
: aPathOptions
.SetBasicPath( sValue
);break;
907 case SvtPathOptions::PATH_BITMAP
: aPathOptions
.SetBitmapPath( sValue
);break;
908 case SvtPathOptions::PATH_CONFIG
: aPathOptions
.SetConfigPath( sValue
);break;
909 case SvtPathOptions::PATH_DICTIONARY
: aPathOptions
.SetDictionaryPath( sValue
);break;
910 case SvtPathOptions::PATH_FAVORITES
: aPathOptions
.SetFavoritesPath( sValue
);break;
911 case SvtPathOptions::PATH_FILTER
:
914 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue
, aTmp
) )
915 aPathOptions
.SetFilterPath( aTmp
);
918 case SvtPathOptions::PATH_GALLERY
: aPathOptions
.SetGalleryPath( sValue
);break;
919 case SvtPathOptions::PATH_GRAPHIC
: aPathOptions
.SetGraphicPath( sValue
);break;
920 case SvtPathOptions::PATH_HELP
:
923 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue
, aTmp
) )
924 aPathOptions
.SetHelpPath( aTmp
);
928 case SvtPathOptions::PATH_LINGUISTIC
: aPathOptions
.SetLinguisticPath( sValue
);break;
929 case SvtPathOptions::PATH_MODULE
:
932 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue
, aTmp
) )
933 aPathOptions
.SetModulePath( aTmp
);
937 case SvtPathOptions::PATH_PALETTE
: aPathOptions
.SetPalettePath( sValue
);break;
938 case SvtPathOptions::PATH_PLUGIN
:
941 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue
, aTmp
) )
942 aPathOptions
.SetPluginPath( aTmp
);
946 case SvtPathOptions::PATH_STORAGE
:
949 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue
, aTmp
) )
950 aPathOptions
.SetStoragePath( aTmp
);
954 case SvtPathOptions::PATH_TEMP
: aPathOptions
.SetTempPath( sValue
);break;
955 case SvtPathOptions::PATH_TEMPLATE
: aPathOptions
.SetTemplatePath( sValue
);break;
956 case SvtPathOptions::PATH_USERCONFIG
: aPathOptions
.SetUserConfigPath( sValue
);break;
957 case SvtPathOptions::PATH_WORK
: aPathOptions
.SetWorkPath( sValue
);break;
958 default: DBG_ERRORFILE("SfxApplication::SetOptions_Impl()\nInvalid path number found for set directories!");
963 aSendSet
.ClearItem( rPool
.GetWhich( SID_ATTR_PATHNAME
) );
966 SetOptions_Impl( rSet
);
969 Broadcast( SfxItemSetHint( rSet
) );
972 //--------------------------------------------------------------------
974 // alle Dokumente speichern
976 BOOL
SfxApplication::SaveAll_Impl(BOOL bPrompt
, BOOL bAutoSave
)
978 bAutoSave
= FALSE
; // functionality moved to new AutoRecovery Service!
983 for ( SfxObjectShell
*pDoc
= SfxObjectShell::GetFirst();
985 pDoc
= SfxObjectShell::GetNext(*pDoc
) )
987 if( SFX_CREATE_MODE_STANDARD
== pDoc
->GetCreateMode() &&
988 SfxViewFrame::GetFirst(pDoc
) &&
989 !pDoc
->IsInModalMode() &&
990 !pDoc
->HasModalViews() )
992 if ( pDoc
->GetProgress() == 0 )
994 if ( !pDoc
->IsModified() )
997 if ( bPrompt
|| (bAutoSave
&& !pDoc
->HasName()) )
998 nRet
= QuerySave_Impl( *pDoc
, bAutoSave
);
1002 if ( nRet
== RET_YES
)
1004 SfxRequest
aReq( SID_SAVEDOC
, 0, pDoc
->GetPool() );
1005 const SfxPoolItem
*pPoolItem
= pDoc
->ExecuteSlot( aReq
);
1006 if ( !pPoolItem
|| !pPoolItem
->ISA(SfxBoolItem
) ||
1007 !( (const SfxBoolItem
*) pPoolItem
)->GetValue() )
1010 else if ( nRet
== RET_CANCEL
)
1015 else if ( nRet
== RET_NO
)
1025 //--------------------------------------------------------------------
1027 SfxMacroConfig
* SfxApplication::GetMacroConfig() const
1029 return SfxMacroConfig::GetOrCreate();
1032 //--------------------------------------------------------------------
1033 SfxEventConfiguration
* SfxApplication::GetEventConfig() const
1035 if (!pAppData_Impl
->pEventConfig
)
1036 pAppData_Impl
->pEventConfig
= new SfxEventConfiguration
;
1037 return pAppData_Impl
->pEventConfig
;
1040 //--------------------------------------------------------------------
1042 //--------------------------------------------------------------------
1043 void SfxApplication::NotifyEvent( const SfxEventHint
& rEventHint
, FASTBOOL bSynchron
)
1045 //DBG_ASSERT(pAppData_Impl->pEventConfig,"Keine Events angemeldet!");
1047 SfxObjectShell
*pDoc
= rEventHint
.GetObjShell();
1048 if ( pDoc
&& ( pDoc
->IsPreview() || !pDoc
->Get_Impl()->bInitialized
) )
1052 //::rtl::OUString aName = SfxEventConfiguration::GetEventName_Impl( rEventHint.GetEventId() );
1053 //ByteString aTmp( "SfxEvent: ");
1054 //aTmp += ByteString( String(aName), RTL_TEXTENCODING_UTF8 );
1055 //DBG_TRACE( aTmp.GetBuffer() );
1063 ByteString
aTmp( "SfxEvent: ");
1064 aTmp
+= ByteString( String( rEventHint
.GetEventName() ), RTL_TEXTENCODING_UTF8
);
1065 DBG_TRACE( aTmp
.GetBuffer() );
1068 Broadcast(rEventHint
);
1070 pDoc
->Broadcast( rEventHint
);
1073 new SfxEventAsyncer_Impl( rEventHint
);
1076 IMPL_OBJHINT( SfxStringHint
, String
)
1078 SfxMiscCfg
* SfxApplication::GetMiscConfig()
1080 if ( !pAppData_Impl
->pMiscConfig
)
1081 pAppData_Impl
->pMiscConfig
= new SfxMiscCfg
;
1083 return pAppData_Impl
->pMiscConfig
;