1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/uno/Reference.hxx>
21 #include <com/sun/star/frame/XDesktop.hpp>
22 #include <com/sun/star/util/XURLTransformer.hpp>
23 #include <com/sun/star/beans/PropertyValue.hpp>
24 #include <com/sun/star/beans/XPropertySet.hpp>
25 #include <com/sun/star/util/XFlushable.hpp>
28 #include <vcl/msgbox.hxx>
29 #include <rtl/ustring.hxx>
30 #include <svl/itempool.hxx>
31 #include <svl/aeitem.hxx>
32 #include <svl/slstitm.hxx>
33 #include <svl/stritem.hxx>
34 #include <svl/intitem.hxx>
35 #include <svl/eitem.hxx>
36 #include <svl/szitem.hxx>
37 #include <svl/undo.hxx>
39 #include <sfx2/sfxsids.hrc>
40 #include <sot/exchange.hxx>
42 #include <svl/isethint.hxx>
44 #include <officecfg/Inet.hxx>
45 #include <officecfg/Office/Common.hxx>
46 #include <unotools/configmgr.hxx>
47 #include <tools/urlobj.hxx>
48 #include <unotools/saveopt.hxx>
49 #include <svtools/helpopt.hxx>
50 #include <unotools/securityoptions.hxx>
51 #include <unotools/pathoptions.hxx>
52 #include <svtools/miscopt.hxx>
53 #include <vcl/toolbox.hxx>
54 #include <unotools/localfilehelper.hxx>
55 #include <rtl/strbuf.hxx>
56 #include <rtl/ustrbuf.hxx>
57 #include <vcl/idle.hxx>
59 #include <sfx2/app.hxx>
60 #include <sfx2/docfile.hxx>
61 #include <sfx2/viewfrm.hxx>
62 #include <sfx2/sfxhelp.hxx>
63 #include "sfxtypes.hxx"
64 #include <sfx2/dispatch.hxx>
65 #include <sfx2/objsh.hxx>
66 #include "objshimp.hxx"
67 #include <sfx2/viewsh.hxx>
68 #include <sfx2/request.hxx>
69 #include <sfx2/evntconf.hxx>
70 #include "appdata.hxx"
71 #include "workwin.hxx"
74 #include <sfx2/sfxresid.hxx>
75 #include "shutdownicon.hxx"
77 using namespace ::com::sun::star::uno
;
78 using namespace ::com::sun::star::util
;
79 using namespace ::com::sun::star::frame
;
80 using namespace ::com::sun::star::beans
;
84 class SfxEventAsyncer_Impl
: public SfxListener
91 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) SAL_OVERRIDE
;
92 SfxEventAsyncer_Impl( const SfxEventHint
& rHint
);
93 virtual ~SfxEventAsyncer_Impl();
94 DECL_LINK_TYPED( IdleHdl
, Idle
*, void );
99 void SfxEventAsyncer_Impl::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
101 const SfxSimpleHint
* pHint
= dynamic_cast<const SfxSimpleHint
*>(&rHint
);
102 if( pHint
&& pHint
->GetId() == SFX_HINT_DYING
&& pIdle
->IsActive() )
111 SfxEventAsyncer_Impl::SfxEventAsyncer_Impl( const SfxEventHint
& rHint
)
114 if( rHint
.GetObjShell() )
115 StartListening( *rHint
.GetObjShell() );
117 pIdle
->SetIdleHdl( LINK(this, SfxEventAsyncer_Impl
, IdleHdl
) );
118 pIdle
->SetPriority( SchedulerPriority::HIGHEST
);
124 SfxEventAsyncer_Impl::~SfxEventAsyncer_Impl()
131 IMPL_LINK_TYPED(SfxEventAsyncer_Impl
, IdleHdl
, Idle
*, pAsyncIdle
, void)
133 SfxObjectShellRef
xRef( aHint
.GetObjShell() );
138 OStringBuffer
aTmp("SfxEvent: ");
139 aTmp
.append(OUStringToOString(aHint
.GetEventName(), RTL_TEXTENCODING_UTF8
));
140 OSL_TRACE( "%s", aTmp
.getStr() );
143 SfxGetpApp()->Broadcast( aHint
);
145 xRef
->Broadcast( aHint
);
152 bool SfxApplication::GetOptions( SfxItemSet
& rSet
)
155 SfxItemPool
&rPool
= GetPool();
157 const sal_uInt16
*pRanges
= rSet
.GetRanges();
158 SvtSaveOptions aSaveOptions
;
159 SvtHelpOptions aHelpOptions
;
160 SvtSecurityOptions aSecurityOptions
;
161 SvtMiscOptions aMiscOptions
;
165 for(sal_uInt16 nWhich
= *pRanges
++; nWhich
<= *pRanges
; ++nWhich
)
169 case SID_ATTR_BUTTON_OUTSTYLE3D
:
170 if(rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_BUTTON_OUTSTYLE3D
),
171 aMiscOptions
.GetToolboxStyle() != TOOLBOX_STYLE_FLAT
)))
174 case SID_ATTR_BUTTON_BIGSIZE
:
176 if( rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_BUTTON_BIGSIZE
), aMiscOptions
.AreCurrentSymbolsLarge() ) ) )
180 case SID_ATTR_BACKUP
:
183 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_BACKUP
))
184 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_BACKUP
),aSaveOptions
.IsBackup())))
188 case SID_ATTR_PRETTYPRINTING
:
191 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_DOPRETTYPRINTING
))
192 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_PRETTYPRINTING
), aSaveOptions
.IsPrettyPrinting())))
196 case SID_ATTR_WARNALIENFORMAT
:
199 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_WARNALIENFORMAT
))
200 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_WARNALIENFORMAT
), aSaveOptions
.IsWarnAlienFormat())))
204 case SID_ATTR_AUTOSAVE
:
207 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_AUTOSAVE
))
208 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_AUTOSAVE
), aSaveOptions
.IsAutoSave())))
212 case SID_ATTR_AUTOSAVEPROMPT
:
215 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_AUTOSAVEPROMPT
))
216 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_AUTOSAVEPROMPT
), aSaveOptions
.IsAutoSavePrompt())))
220 case SID_ATTR_AUTOSAVEMINUTE
:
223 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_AUTOSAVETIME
))
224 if (!rSet
.Put( SfxUInt16Item( rPool
.GetWhich( SID_ATTR_AUTOSAVEMINUTE
), (sal_uInt16
)aSaveOptions
.GetAutoSaveTime())))
228 case SID_ATTR_USERAUTOSAVE
:
231 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_USERAUTOSAVE
))
232 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_USERAUTOSAVE
), aSaveOptions
.IsUserAutoSave())))
236 case SID_ATTR_DOCINFO
:
239 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_DOCINFSAVE
))
240 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_DOCINFO
), aSaveOptions
.IsDocInfoSave())))
244 case SID_ATTR_WORKINGSET
:
247 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_SAVEWORKINGSET
))
248 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_WORKINGSET
), aSaveOptions
.IsSaveWorkingSet())))
252 case SID_ATTR_SAVEDOCVIEW
:
255 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_SAVEDOCVIEW
))
256 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_SAVEDOCVIEW
), aSaveOptions
.IsSaveDocView())))
260 case SID_ATTR_METRIC
:
262 case SID_HELPBALLOONS
:
263 if(rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_HELPBALLOONS
),
264 aHelpOptions
.IsExtendedHelp() ) ) )
268 if(rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_HELPTIPS
),
269 aHelpOptions
.IsHelpTips() ) ) )
272 case SID_ATTR_WELCOMESCREEN
:
273 if(rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_ATTR_WELCOMESCREEN
),
274 aHelpOptions
.IsWelcomeScreen() ) ) )
277 case SID_HELP_STYLESHEET
:
278 if(rSet
.Put( SfxStringItem ( rPool
.GetWhich( SID_HELP_STYLESHEET
),
279 aHelpOptions
.GetHelpStyleSheet() ) ) )
282 case SID_ATTR_UNDO_COUNT
:
285 rPool
.GetWhich(SID_ATTR_UNDO_COUNT
),
286 officecfg::Office::Common::Undo::Steps::get())))
291 case SID_ATTR_QUICKLAUNCHER
:
293 if ( ShutdownIcon::IsQuickstarterInstalled() )
295 if ( rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_QUICKLAUNCHER
),
296 ShutdownIcon::GetAutostart() ) ) )
301 rSet
.DisableItem( rPool
.GetWhich( SID_ATTR_QUICKLAUNCHER
) );
306 case SID_SAVEREL_INET
:
309 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_SAVERELINET
))
310 if (!rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_SAVEREL_INET
), aSaveOptions
.IsSaveRelINet() )))
314 case SID_SAVEREL_FSYS
:
317 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::E_SAVERELFSYS
))
318 if (!rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_SAVEREL_FSYS
), aSaveOptions
.IsSaveRelFSys() )))
322 case SID_BASIC_ENABLED
:
325 if (!aSecurityOptions
.IsReadOnly(SvtSecurityOptions::E_BASICMODE
))
327 if ( !rSet
.Put( SfxUInt16Item( rPool
.GetWhich( SID_BASIC_ENABLED
), sal::static_int_cast
< sal_uInt16
>(aSecurityOptions
.GetBasicMode()))))
332 case SID_INET_EXE_PLUGIN
:
335 if (!aSecurityOptions
.IsReadOnly(SvtSecurityOptions::E_EXECUTEPLUGINS
))
337 if ( !rSet
.Put( SfxBoolItem( SID_INET_EXE_PLUGIN
, aSecurityOptions
.IsExecutePlugins() ) ) )
342 case SID_MACRO_WARNING
:
345 if (!aSecurityOptions
.IsReadOnly(SvtSecurityOptions::E_WARNING
))
347 if ( !rSet
.Put( SfxBoolItem( SID_MACRO_WARNING
, aSecurityOptions
.IsWarningEnabled() ) ) )
352 case SID_MACRO_CONFIRMATION
:
355 if (!aSecurityOptions
.IsReadOnly(SvtSecurityOptions::E_CONFIRMATION
))
357 if ( !rSet
.Put( SfxBoolItem( SID_MACRO_CONFIRMATION
, aSecurityOptions
.IsConfirmationEnabled() ) ) )
362 case SID_SECURE_URL
:
365 if (!aSecurityOptions
.IsReadOnly(SvtSecurityOptions::E_SECUREURLS
))
367 ::com::sun::star::uno::Sequence
< OUString
> seqURLs
= aSecurityOptions
.GetSecureURLs();
368 std::vector
<OUString
> aList
;
369 sal_uInt32 nCount
= seqURLs
.getLength();
370 for( sal_uInt32 nURL
=0; nURL
<nCount
; ++nURL
)
371 aList
.push_back(seqURLs
[nURL
]);
373 if( !rSet
.Put( SfxStringListItem( rPool
.GetWhich(SID_SECURE_URL
), &aList
) ) )
378 case SID_INET_PROXY_TYPE
:
381 rPool
.GetWhich(SID_INET_PROXY_TYPE
),
382 (officecfg::Inet::Settings::ooInetProxyType::
383 get().get_value_or(0)))))
388 case SID_INET_HTTP_PROXY_NAME
:
391 rPool
.GetWhich(SID_INET_HTTP_PROXY_NAME
),
392 officecfg::Inet::Settings::ooInetHTTPProxyName::
398 case SID_INET_HTTP_PROXY_PORT
:
401 rPool
.GetWhich(SID_INET_HTTP_PROXY_PORT
),
402 (officecfg::Inet::Settings::
403 ooInetHTTPProxyPort::get().get_value_or(0)))))
408 case SID_INET_FTP_PROXY_NAME
:
411 rPool
.GetWhich(SID_INET_FTP_PROXY_NAME
),
412 officecfg::Inet::Settings::ooInetFTPProxyName::
418 case SID_INET_FTP_PROXY_PORT
:
421 rPool
.GetWhich(SID_INET_FTP_PROXY_PORT
),
422 (officecfg::Inet::Settings::ooInetFTPProxyPort::
423 get().get_value_or(0)))))
428 case SID_INET_NOPROXY
:
431 rPool
.GetWhich( SID_INET_NOPROXY
),
432 (officecfg::Inet::Settings::ooInetNoProxy::
438 case SID_ATTR_PATHNAME
:
439 case SID_ATTR_PATHGROUP
:
441 SfxAllEnumItem
aNames(rPool
.GetWhich(SID_ATTR_PATHGROUP
));
442 SfxAllEnumItem
aValues(rPool
.GetWhich(SID_ATTR_PATHNAME
));
443 SvtPathOptions aPathCfg
;
444 for ( sal_uInt16 nProp
= SvtPathOptions::PATH_ADDIN
;
445 nProp
<= SvtPathOptions::PATH_WORK
; nProp
++ )
447 aNames
.InsertValue( nProp
, SfxResId(CONFIG_PATH_START
+ nProp
).toString() );
451 case SvtPathOptions::PATH_ADDIN
: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg
.GetAddinPath(), aValue
); break;
452 case SvtPathOptions::PATH_AUTOCORRECT
: aValue
= aPathCfg
.GetAutoCorrectPath(); break;
453 case SvtPathOptions::PATH_AUTOTEXT
: aValue
= aPathCfg
.GetAutoTextPath(); break;
454 case SvtPathOptions::PATH_BACKUP
: aValue
= aPathCfg
.GetBackupPath(); break;
455 case SvtPathOptions::PATH_BASIC
: aValue
= aPathCfg
.GetBasicPath(); break;
456 case SvtPathOptions::PATH_BITMAP
: aValue
= aPathCfg
.GetBitmapPath(); break;
457 case SvtPathOptions::PATH_CONFIG
: aValue
= aPathCfg
.GetConfigPath(); break;
458 case SvtPathOptions::PATH_DICTIONARY
: aValue
= aPathCfg
.GetDictionaryPath(); break;
459 case SvtPathOptions::PATH_FAVORITES
: aValue
= aPathCfg
.GetFavoritesPath(); break;
460 case SvtPathOptions::PATH_FILTER
: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg
.GetFilterPath(), aValue
); break;
461 case SvtPathOptions::PATH_GALLERY
: aValue
= aPathCfg
.GetGalleryPath(); break;
462 case SvtPathOptions::PATH_GRAPHIC
: aValue
= aPathCfg
.GetGraphicPath(); break;
463 case SvtPathOptions::PATH_HELP
: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg
.GetHelpPath(), aValue
); break;
464 case SvtPathOptions::PATH_LINGUISTIC
: aValue
= aPathCfg
.GetLinguisticPath(); break;
465 case SvtPathOptions::PATH_MODULE
: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg
.GetModulePath(), aValue
); break;
466 case SvtPathOptions::PATH_PALETTE
: aValue
= aPathCfg
.GetPalettePath(); break;
467 case SvtPathOptions::PATH_PLUGIN
: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg
.GetPluginPath(), aValue
); break;
468 case SvtPathOptions::PATH_STORAGE
: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg
.GetStoragePath(), aValue
); break;
469 case SvtPathOptions::PATH_TEMP
: aValue
= aPathCfg
.GetTempPath(); break;
470 case SvtPathOptions::PATH_TEMPLATE
: aValue
= aPathCfg
.GetTemplatePath(); break;
471 case SvtPathOptions::PATH_USERCONFIG
: aValue
= aPathCfg
.GetUserConfigPath(); break;
472 case SvtPathOptions::PATH_WORK
: aValue
= aPathCfg
.GetWorkPath(); break;
474 aValues
.InsertValue( nProp
, aValue
);
477 if ( rSet
.Put(aNames
) || rSet
.Put(aValues
) )
483 DBG_WARNING( "W1:Wrong ID while getting Options!" );
488 OSL_FAIL( "Putting options failed!" );
497 // TODO/CLEANUP: Why two SetOptions Methods?
498 void SfxApplication::SetOptions_Impl( const SfxItemSet
& rSet
)
500 const SfxPoolItem
*pItem
= 0;
501 SfxItemPool
&rPool
= GetPool();
503 SvtSaveOptions aSaveOptions
;
504 SvtHelpOptions aHelpOptions
;
505 SvtSecurityOptions aSecurityOptions
;
506 SvtMiscOptions aMiscOptions
;
507 std::shared_ptr
< comphelper::ConfigurationChanges
> batch(
508 comphelper::ConfigurationChanges::create());
509 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_BUTTON_OUTSTYLE3D
), true, &pItem
) )
511 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
512 sal_uInt16 nOutStyle
=
513 static_cast<const SfxBoolItem
*>(pItem
)->GetValue() ? 0 : TOOLBOX_STYLE_FLAT
;
514 aMiscOptions
.SetToolboxStyle( nOutStyle
);
517 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_BUTTON_BIGSIZE
), true, &pItem
) )
519 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
520 bool bBigSize
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
521 aMiscOptions
.SetSymbolsSize(
522 sal::static_int_cast
< sal_Int16
>(
523 bBigSize
? SFX_SYMBOLS_SIZE_LARGE
: SFX_SYMBOLS_SIZE_SMALL
) );
524 SfxViewFrame
* pCurrViewFrame
= SfxViewFrame::GetFirst();
525 while ( pCurrViewFrame
)
527 // update all "final" dispatchers
528 if ( !pCurrViewFrame
->GetActiveChildFrame_Impl() )
529 pCurrViewFrame
->GetDispatcher()->Update_Impl(true);
530 pCurrViewFrame
= SfxViewFrame::GetNext(*pCurrViewFrame
);
535 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_BACKUP
), true, &pItem
) )
537 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
538 aSaveOptions
.SetBackup( static_cast<const SfxBoolItem
*>(pItem
)->GetValue() );
542 if ( SfxItemState::SET
== rSet
.GetItemState( rPool
.GetWhich( SID_ATTR_PRETTYPRINTING
), true, &pItem
) )
544 DBG_ASSERT( pItem
->ISA( SfxBoolItem
), "BoolItem expected" );
545 aSaveOptions
.SetPrettyPrinting( static_cast< const SfxBoolItem
*> ( pItem
)->GetValue() );
549 if ( SfxItemState::SET
== rSet
.GetItemState( rPool
.GetWhich( SID_ATTR_WARNALIENFORMAT
), true, &pItem
) )
551 DBG_ASSERT( pItem
->ISA( SfxBoolItem
), "BoolItem expected" );
552 aSaveOptions
.SetWarnAlienFormat( static_cast< const SfxBoolItem
*> ( pItem
)->GetValue() );
556 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_AUTOSAVE
), true, &pItem
))
558 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
559 aSaveOptions
.SetAutoSave( static_cast<const SfxBoolItem
*>(pItem
)->GetValue() );
563 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_AUTOSAVEPROMPT
), true, &pItem
))
565 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
566 aSaveOptions
.SetAutoSavePrompt(static_cast<const SfxBoolItem
*>(pItem
)->GetValue());
570 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_AUTOSAVEMINUTE
), true, &pItem
))
572 DBG_ASSERT(pItem
->ISA(SfxUInt16Item
), "UInt16Item expected");
573 aSaveOptions
.SetAutoSaveTime(static_cast<const SfxUInt16Item
*>(pItem
)->GetValue());
577 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_USERAUTOSAVE
), true, &pItem
))
579 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
580 aSaveOptions
.SetUserAutoSave( static_cast<const SfxBoolItem
*>(pItem
)->GetValue() );
584 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_DOCINFO
), true, &pItem
))
586 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
587 aSaveOptions
.SetDocInfoSave(static_cast<const SfxBoolItem
*>(pItem
)->GetValue());
590 // Mark open Documents
591 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_WORKINGSET
), true, &pItem
))
593 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
594 aSaveOptions
.SetSaveWorkingSet(static_cast<const SfxBoolItem
*>(pItem
)->GetValue());
597 // Save window settings
598 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_SAVEDOCVIEW
), true, &pItem
))
600 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
601 aSaveOptions
.SetSaveDocView(static_cast<const SfxBoolItem
*>(pItem
)->GetValue());
605 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_METRIC
), true, &pItem
))
607 DBG_ASSERT(pItem
->ISA(SfxUInt16Item
), "UInt16Item expected");
611 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_HELPBALLOONS
), true, &pItem
))
613 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
614 aHelpOptions
.SetExtendedHelp(static_cast<const SfxBoolItem
*>(pItem
)->GetValue());
618 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_HELPTIPS
), true, &pItem
))
620 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
621 aHelpOptions
.SetHelpTips( static_cast<const SfxBoolItem
*>(pItem
)->GetValue());
625 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_WELCOMESCREEN
), true, &pItem
))
627 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
628 aHelpOptions
.SetWelcomeScreen( static_cast<const SfxBoolItem
*>(pItem
)->GetValue() );
632 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_WELCOMESCREEN_RESET
), true, &pItem
))
634 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
635 bool bReset
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
638 OSL_FAIL( "Not implemented, may be EOL!" );
641 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_HELP_STYLESHEET
), true, &pItem
))
643 DBG_ASSERT(pItem
->ISA(SfxStringItem
), "StringItem expected");
644 aHelpOptions
.SetHelpStyleSheet( static_cast<const SfxStringItem
*>(pItem
)->GetValue() );
648 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_SAVEREL_INET
), true, &pItem
))
650 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
651 aSaveOptions
.SetSaveRelINet(static_cast<const SfxBoolItem
*>(pItem
)->GetValue());
655 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_SAVEREL_FSYS
), true, &pItem
))
657 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
658 aSaveOptions
.SetSaveRelFSys(static_cast<const SfxBoolItem
*>(pItem
)->GetValue());
662 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_UNDO_COUNT
), true, &pItem
))
664 DBG_ASSERT(pItem
->ISA(SfxUInt16Item
), "UInt16Item expected");
665 sal_uInt16 nUndoCount
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
666 officecfg::Office::Common::Undo::Steps::set(nUndoCount
, batch
);
668 // To catch all Undo-Managers: Iterate over all Frames
669 for ( SfxViewFrame
*pFrame
= SfxViewFrame::GetFirst();
671 pFrame
= SfxViewFrame::GetNext(*pFrame
) )
673 // Get the Dispatcher of the Frames
674 SfxDispatcher
*pDispat
= pFrame
->GetDispatcher();
677 // Iterate over all SfxShells on the Dispatchers Stack
679 for ( SfxShell
*pSh
= pDispat
->GetShell(nIdx
);
681 ++nIdx
, pSh
= pDispat
->GetShell(nIdx
) )
683 ::svl::IUndoManager
*pShUndoMgr
= pSh
->GetUndoManager();
685 pShUndoMgr
->SetMaxUndoActionCount( nUndoCount
);
691 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_QUICKLAUNCHER
), true, &pItem
))
693 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "BoolItem expected");
694 ShutdownIcon::SetAutostart( static_cast<const SfxBoolItem
*>( pItem
)->GetValue() );
698 if ( SfxItemState::SET
== rSet
.GetItemState(SID_BASIC_ENABLED
, true, &pItem
))
700 DBG_ASSERT(pItem
->ISA(SfxUInt16Item
), "SfxInt16Item expected");
701 aSecurityOptions
.SetBasicMode( (EBasicSecurityMode
)static_cast<const SfxUInt16Item
*>( pItem
)->GetValue() );
705 if ( SfxItemState::SET
== rSet
.GetItemState(SID_INET_EXE_PLUGIN
, true, &pItem
))
707 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "SfxBoolItem expected");
708 aSecurityOptions
.SetExecutePlugins( static_cast<const SfxBoolItem
*>( pItem
)->GetValue() );
711 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_INET_PROXY_TYPE
), true, &pItem
))
713 DBG_ASSERT( pItem
->ISA(SfxUInt16Item
), "UInt16Item expected" );
714 officecfg::Inet::Settings::ooInetProxyType::set(
715 static_cast< SfxUInt16Item
const * >(pItem
)->GetValue(), batch
);
718 if ( SfxItemState::SET
== rSet
.GetItemState( rPool
.GetWhich( SID_INET_HTTP_PROXY_NAME
), true, &pItem
) )
720 DBG_ASSERT( pItem
->ISA(SfxStringItem
), "StringItem expected" );
721 officecfg::Inet::Settings::ooInetHTTPProxyName::set(
722 static_cast< SfxStringItem
const * >(pItem
)->GetValue(), batch
);
724 if ( SfxItemState::SET
== rSet
.GetItemState( rPool
.GetWhich( SID_INET_HTTP_PROXY_PORT
), true, &pItem
) )
726 DBG_ASSERT( pItem
->ISA(SfxInt32Item
), "Int32Item expected" );
727 officecfg::Inet::Settings::ooInetHTTPProxyPort::set(
728 static_cast< SfxInt32Item
const * >(pItem
)->GetValue(), batch
);
730 if ( SfxItemState::SET
== rSet
.GetItemState( rPool
.GetWhich( SID_INET_FTP_PROXY_NAME
), true, &pItem
) )
732 DBG_ASSERT( pItem
->ISA(SfxStringItem
), "StringItem expected" );
733 officecfg::Inet::Settings::ooInetFTPProxyName::set(
734 static_cast< SfxStringItem
const * >(pItem
)->GetValue(), batch
);
736 if ( SfxItemState::SET
== rSet
.GetItemState( rPool
.GetWhich( SID_INET_FTP_PROXY_PORT
), true, &pItem
) )
738 DBG_ASSERT( pItem
->ISA(SfxInt32Item
), "Int32Item expected" );
739 officecfg::Inet::Settings::ooInetFTPProxyPort::set(
740 static_cast< SfxInt32Item
const * >(pItem
)->GetValue(), batch
);
742 if ( SfxItemState::SET
== rSet
.GetItemState(SID_INET_NOPROXY
, true, &pItem
))
744 DBG_ASSERT(pItem
->ISA(SfxStringItem
), "StringItem expected");
745 officecfg::Inet::Settings::ooInetNoProxy::set(
746 static_cast< SfxStringItem
const * >(pItem
)->GetValue(), batch
);
750 if ( SfxItemState::SET
== rSet
.GetItemState(SID_SECURE_URL
, true, &pItem
))
752 DBG_ASSERT(pItem
->ISA(SfxStringListItem
), "StringListItem expected");
753 ::com::sun::star::uno::Sequence
< OUString
> seqURLs
;
754 static_cast<const SfxStringListItem
*>(pItem
)->GetStringList(seqURLs
);
755 aSecurityOptions
.SetSecureURLs( seqURLs
);
758 if ( SfxItemState::SET
== rSet
.GetItemState(SID_MACRO_WARNING
, true, &pItem
))
760 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "SfxBoolItem expected");
761 aSecurityOptions
.SetWarningEnabled( static_cast<const SfxBoolItem
*>(pItem
)->GetValue() );
763 if ( SfxItemState::SET
== rSet
.GetItemState(SID_MACRO_CONFIRMATION
, true, &pItem
))
765 DBG_ASSERT(pItem
->ISA(SfxBoolItem
), "SfxBoolItem expected");
766 aSecurityOptions
.SetConfirmationEnabled( static_cast<const SfxBoolItem
*>(pItem
)->GetValue() );
769 // Store changed data
774 void SfxApplication::SetOptions(const SfxItemSet
&rSet
)
776 SvtPathOptions aPathOptions
;
778 // Data is saved in DocInfo and IniManager
779 const SfxPoolItem
*pItem
= 0;
780 SfxItemPool
&rPool
= GetPool();
782 SfxAllItemSet
aSendSet( rSet
);
785 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_PATHNAME
), true, &pItem
))
787 DBG_ASSERT(pItem
->ISA(SfxAllEnumItem
), "AllEnumItem expected");
788 const SfxAllEnumItem
* pEnumItem
= static_cast<const SfxAllEnumItem
*>(pItem
);
789 sal_uInt32 nCount
= pEnumItem
->GetValueCount();
790 OUString
aNoChangeStr( ' ' );
791 for( sal_uInt32 nPath
=0; nPath
<nCount
; ++nPath
)
793 OUString sValue
= pEnumItem
->GetValueTextByPos((sal_uInt16
)nPath
);
794 if ( sValue
!= aNoChangeStr
)
798 case SvtPathOptions::PATH_ADDIN
:
801 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue
, aTmp
) )
802 aPathOptions
.SetAddinPath( aTmp
);
806 case SvtPathOptions::PATH_AUTOCORRECT
: aPathOptions
.SetAutoCorrectPath( sValue
);break;
807 case SvtPathOptions::PATH_AUTOTEXT
: aPathOptions
.SetAutoTextPath( sValue
);break;
808 case SvtPathOptions::PATH_BACKUP
: aPathOptions
.SetBackupPath( sValue
);break;
809 case SvtPathOptions::PATH_BASIC
: aPathOptions
.SetBasicPath( sValue
);break;
810 case SvtPathOptions::PATH_BITMAP
: aPathOptions
.SetBitmapPath( sValue
);break;
811 case SvtPathOptions::PATH_CONFIG
: aPathOptions
.SetConfigPath( sValue
);break;
812 case SvtPathOptions::PATH_DICTIONARY
: aPathOptions
.SetDictionaryPath( sValue
);break;
813 case SvtPathOptions::PATH_FAVORITES
: aPathOptions
.SetFavoritesPath( sValue
);break;
814 case SvtPathOptions::PATH_FILTER
:
817 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue
, aTmp
) )
818 aPathOptions
.SetFilterPath( aTmp
);
821 case SvtPathOptions::PATH_GALLERY
: aPathOptions
.SetGalleryPath( sValue
);break;
822 case SvtPathOptions::PATH_GRAPHIC
: aPathOptions
.SetGraphicPath( sValue
);break;
823 case SvtPathOptions::PATH_HELP
:
826 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue
, aTmp
) )
827 aPathOptions
.SetHelpPath( aTmp
);
831 case SvtPathOptions::PATH_LINGUISTIC
: aPathOptions
.SetLinguisticPath( sValue
);break;
832 case SvtPathOptions::PATH_MODULE
:
835 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue
, aTmp
) )
836 aPathOptions
.SetModulePath( aTmp
);
840 case SvtPathOptions::PATH_PALETTE
: aPathOptions
.SetPalettePath( sValue
);break;
841 case SvtPathOptions::PATH_PLUGIN
:
844 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue
, aTmp
) )
845 aPathOptions
.SetPluginPath( aTmp
);
849 case SvtPathOptions::PATH_STORAGE
:
852 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue
, aTmp
) )
853 aPathOptions
.SetStoragePath( aTmp
);
857 case SvtPathOptions::PATH_TEMP
: aPathOptions
.SetTempPath( sValue
);break;
858 case SvtPathOptions::PATH_TEMPLATE
: aPathOptions
.SetTemplatePath( sValue
);break;
859 case SvtPathOptions::PATH_USERCONFIG
: aPathOptions
.SetUserConfigPath( sValue
);break;
860 case SvtPathOptions::PATH_WORK
: aPathOptions
.SetWorkPath( sValue
);break;
861 default: SAL_WARN( "sfx.appl", "SfxApplication::SetOptions_Impl() Invalid path number found for set directories!" );
866 aSendSet
.ClearItem( rPool
.GetWhich( SID_ATTR_PATHNAME
) );
869 SetOptions_Impl( rSet
);
872 Broadcast( SfxItemSetHint( rSet
) );
876 void SfxApplication::NotifyEvent( const SfxEventHint
& rEventHint
, bool bSynchron
)
878 SfxObjectShell
*pDoc
= rEventHint
.GetObjShell();
879 if ( pDoc
&& ( pDoc
->IsPreview() || !pDoc
->Get_Impl()->bInitialized
) )
887 OStringBuffer
aTmp("SfxEvent: ");
888 aTmp
.append(OUStringToOString(rEventHint
.GetEventName(), RTL_TEXTENCODING_UTF8
));
889 OSL_TRACE( "%s", aTmp
.getStr() );
892 Broadcast(rEventHint
);
894 pDoc
->Broadcast( rEventHint
);
897 new SfxEventAsyncer_Impl( rEventHint
);
900 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */