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 .
21 #include <comphelper/sequence.hxx>
22 #include <osl/file.hxx>
24 #include <rtl/ustring.hxx>
25 #include <svl/itempool.hxx>
26 #include <svl/itemset.hxx>
27 #include <svl/aeitem.hxx>
28 #include <svl/slstitm.hxx>
29 #include <svl/stritem.hxx>
30 #include <svl/intitem.hxx>
31 #include <svl/eitem.hxx>
32 #include <svl/undo.hxx>
34 #include <sfx2/sfxsids.hrc>
36 #include <svl/isethint.hxx>
38 #include <officecfg/Inet.hxx>
39 #include <officecfg/Office/Common.hxx>
40 #include <unotools/saveopt.hxx>
41 #include <svtools/helpopt.hxx>
42 #include <unotools/securityoptions.hxx>
43 #include <unotools/pathoptions.hxx>
44 #include <svtools/miscopt.hxx>
45 #include <svtools/imgdef.hxx>
46 #include <vcl/toolbox.hxx>
47 #include <sal/log.hxx>
48 #include <vcl/idle.hxx>
50 #include <sfx2/app.hxx>
51 #include <sfx2/event.hxx>
52 #include <sfx2/viewfrm.hxx>
53 #include <sfx2/dispatch.hxx>
54 #include <sfx2/objsh.hxx>
55 #include <objshimp.hxx>
56 #include "shutdownicon.hxx"
58 using namespace ::com::sun::star::uno
;
59 using namespace ::com::sun::star::util
;
60 using namespace ::com::sun::star::beans
;
64 class SfxEventAsyncer_Impl
: public SfxListener
67 std::unique_ptr
<Idle
> pIdle
;
71 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
72 explicit SfxEventAsyncer_Impl(const SfxEventHint
& rHint
);
73 DECL_LINK( IdleHdl
, Timer
*, void );
78 void SfxEventAsyncer_Impl::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
80 if( rHint
.GetId() == SfxHintId::Dying
&& pIdle
->IsActive() )
88 SfxEventAsyncer_Impl::SfxEventAsyncer_Impl( const SfxEventHint
& rHint
)
91 if( rHint
.GetObjShell() )
92 StartListening( *rHint
.GetObjShell() );
93 pIdle
.reset( new Idle("SfxEventASyncer") );
94 pIdle
->SetInvokeHandler( LINK(this, SfxEventAsyncer_Impl
, IdleHdl
) );
95 pIdle
->SetPriority( TaskPriority::HIGH_IDLE
);
96 pIdle
->SetDebugName( "sfx::SfxEventAsyncer_Impl pIdle" );
101 IMPL_LINK(SfxEventAsyncer_Impl
, IdleHdl
, Timer
*, pAsyncIdle
, void)
103 SfxObjectShellRef
xRef( aHint
.GetObjShell() );
105 SAL_INFO_IF(!xRef
.is(), "sfx.appl", "SfxEvent: " << aHint
.GetEventName());
106 SfxGetpApp()->Broadcast( aHint
);
108 xRef
->Broadcast( aHint
);
113 void SfxApplication::GetOptions( SfxItemSet
& rSet
)
116 SfxItemPool
&rPool
= GetPool();
118 const sal_uInt16
*pRanges
= rSet
.GetRanges();
119 SvtSaveOptions aSaveOptions
;
120 SvtHelpOptions aHelpOptions
;
121 SvtSecurityOptions aSecurityOptions
;
122 SvtMiscOptions aMiscOptions
;
126 for(sal_uInt16 nWhich
= *pRanges
++; nWhich
<= *pRanges
; ++nWhich
)
130 case SID_ATTR_BUTTON_BIGSIZE
:
132 if( rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_BUTTON_BIGSIZE
), aMiscOptions
.AreCurrentSymbolsLarge() ) ) )
136 case SID_ATTR_BACKUP
:
139 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::EOption::Backup
))
140 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_BACKUP
),aSaveOptions
.IsBackup())))
144 case SID_ATTR_PRETTYPRINTING
:
147 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::EOption::DoPrettyPrinting
))
148 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_PRETTYPRINTING
), aSaveOptions
.IsPrettyPrinting())))
152 case SID_ATTR_WARNALIENFORMAT
:
155 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::EOption::WarnAlienFormat
))
156 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_WARNALIENFORMAT
), aSaveOptions
.IsWarnAlienFormat())))
160 case SID_ATTR_AUTOSAVE
:
163 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::EOption::AutoSave
))
164 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_AUTOSAVE
), aSaveOptions
.IsAutoSave())))
168 case SID_ATTR_AUTOSAVEPROMPT
:
171 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::EOption::AutoSavePrompt
))
172 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_AUTOSAVEPROMPT
), aSaveOptions
.IsAutoSavePrompt())))
176 case SID_ATTR_AUTOSAVEMINUTE
:
179 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::EOption::AutoSaveTime
))
180 if (!rSet
.Put( SfxUInt16Item( rPool
.GetWhich( SID_ATTR_AUTOSAVEMINUTE
), static_cast<sal_uInt16
>(aSaveOptions
.GetAutoSaveTime()))))
184 case SID_ATTR_USERAUTOSAVE
:
187 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::EOption::UserAutoSave
))
188 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_USERAUTOSAVE
), aSaveOptions
.IsUserAutoSave())))
192 case SID_ATTR_DOCINFO
:
195 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::EOption::DocInfSave
))
196 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_DOCINFO
), aSaveOptions
.IsDocInfoSave())))
200 case SID_ATTR_WORKINGSET
:
203 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::EOption::SaveWorkingSet
))
204 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_WORKINGSET
), aSaveOptions
.IsSaveWorkingSet())))
208 case SID_ATTR_SAVEDOCVIEW
:
211 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::EOption::SaveDocView
))
212 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_SAVEDOCVIEW
), aSaveOptions
.IsSaveDocView())))
216 case SID_ATTR_METRIC
:
218 case SID_HELPBALLOONS
:
219 if(rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_HELPBALLOONS
),
220 aHelpOptions
.IsExtendedHelp() ) ) )
224 if(rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_HELPTIPS
),
225 aHelpOptions
.IsHelpTips() ) ) )
228 case SID_HELP_STYLESHEET
:
229 if(rSet
.Put( SfxStringItem ( rPool
.GetWhich( SID_HELP_STYLESHEET
),
230 aHelpOptions
.GetHelpStyleSheet() ) ) )
233 case SID_ATTR_UNDO_COUNT
:
236 rPool
.GetWhich(SID_ATTR_UNDO_COUNT
),
237 officecfg::Office::Common::Undo::Steps::get())))
242 case SID_ATTR_QUICKLAUNCHER
:
244 if ( ShutdownIcon::IsQuickstarterInstalled() )
246 if ( rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_QUICKLAUNCHER
),
247 ShutdownIcon::GetAutostart() ) ) )
252 rSet
.DisableItem( rPool
.GetWhich( SID_ATTR_QUICKLAUNCHER
) );
257 case SID_SAVEREL_INET
:
260 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::EOption::SaveRelInet
))
261 if (!rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_SAVEREL_INET
), aSaveOptions
.IsSaveRelINet() )))
265 case SID_SAVEREL_FSYS
:
268 if (!aSaveOptions
.IsReadOnly(SvtSaveOptions::EOption::SaveRelFsys
))
269 if (!rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_SAVEREL_FSYS
), aSaveOptions
.IsSaveRelFSys() )))
273 case SID_BASIC_ENABLED
:
276 if (!aSecurityOptions
.IsReadOnly(SvtSecurityOptions::EOption::BasicMode
))
278 if ( !rSet
.Put( SfxUInt16Item( rPool
.GetWhich( SID_BASIC_ENABLED
), sal::static_int_cast
< sal_uInt16
>(aSecurityOptions
.GetBasicMode()))))
283 case SID_INET_EXE_PLUGIN
:
286 if (!aSecurityOptions
.IsReadOnly(SvtSecurityOptions::EOption::ExecutePlugins
))
288 if ( !rSet
.Put( SfxBoolItem( SID_INET_EXE_PLUGIN
, aSecurityOptions
.IsExecutePlugins() ) ) )
293 case SID_MACRO_WARNING
:
296 if (!aSecurityOptions
.IsReadOnly(SvtSecurityOptions::EOption::Warning
))
298 if ( !rSet
.Put( SfxBoolItem( SID_MACRO_WARNING
, aSecurityOptions
.IsWarningEnabled() ) ) )
303 case SID_MACRO_CONFIRMATION
:
306 if (!aSecurityOptions
.IsReadOnly(SvtSecurityOptions::EOption::Confirmation
))
308 if ( !rSet
.Put( SfxBoolItem( SID_MACRO_CONFIRMATION
, aSecurityOptions
.IsConfirmationEnabled() ) ) )
313 case SID_SECURE_URL
:
316 if (!aSecurityOptions
.IsReadOnly(SvtSecurityOptions::EOption::SecureUrls
))
318 css::uno::Sequence
< OUString
> seqURLs
= aSecurityOptions
.GetSecureURLs();
319 auto aList
= comphelper::sequenceToContainer
<std::vector
<OUString
>>(seqURLs
);
321 if( !rSet
.Put( SfxStringListItem( rPool
.GetWhich(SID_SECURE_URL
), &aList
) ) )
326 case SID_INET_PROXY_TYPE
:
329 rPool
.GetWhich(SID_INET_PROXY_TYPE
),
330 (officecfg::Inet::Settings::ooInetProxyType::
331 get().value_or(0)))))
336 case SID_INET_HTTP_PROXY_NAME
:
339 rPool
.GetWhich(SID_INET_HTTP_PROXY_NAME
),
340 officecfg::Inet::Settings::ooInetHTTPProxyName::
346 case SID_INET_HTTP_PROXY_PORT
:
349 rPool
.GetWhich(SID_INET_HTTP_PROXY_PORT
),
350 (officecfg::Inet::Settings::
351 ooInetHTTPProxyPort::get().value_or(0)))))
356 case SID_INET_FTP_PROXY_NAME
:
359 rPool
.GetWhich(SID_INET_FTP_PROXY_NAME
),
360 officecfg::Inet::Settings::ooInetFTPProxyName::
366 case SID_INET_FTP_PROXY_PORT
:
369 rPool
.GetWhich(SID_INET_FTP_PROXY_PORT
),
370 (officecfg::Inet::Settings::ooInetFTPProxyPort::
371 get().value_or(0)))))
376 case SID_INET_NOPROXY
:
379 rPool
.GetWhich( SID_INET_NOPROXY
),
380 (officecfg::Inet::Settings::ooInetNoProxy::
386 case SID_ATTR_PATHNAME
:
388 SfxAllEnumItem
aValues(rPool
.GetWhich(SID_ATTR_PATHNAME
));
389 SvtPathOptions aPathCfg
;
390 for ( sal_uInt16 nProp
= SvtPathOptions::PATH_ADDIN
;
391 nProp
<= SvtPathOptions::PATH_WORK
; nProp
++ )
396 case SvtPathOptions::PATH_ADDIN
: osl::FileBase::getFileURLFromSystemPath( aPathCfg
.GetAddinPath(), aValue
); break;
397 case SvtPathOptions::PATH_AUTOCORRECT
: aValue
= aPathCfg
.GetAutoCorrectPath(); break;
398 case SvtPathOptions::PATH_AUTOTEXT
: aValue
= aPathCfg
.GetAutoTextPath(); break;
399 case SvtPathOptions::PATH_BACKUP
: aValue
= aPathCfg
.GetBackupPath(); break;
400 case SvtPathOptions::PATH_BASIC
: aValue
= aPathCfg
.GetBasicPath(); break;
401 case SvtPathOptions::PATH_BITMAP
: aValue
= aPathCfg
.GetBitmapPath(); break;
402 case SvtPathOptions::PATH_CONFIG
: aValue
= aPathCfg
.GetConfigPath(); break;
403 case SvtPathOptions::PATH_DICTIONARY
: aValue
= aPathCfg
.GetDictionaryPath(); break;
404 case SvtPathOptions::PATH_FAVORITES
: aValue
= aPathCfg
.GetFavoritesPath(); break;
405 case SvtPathOptions::PATH_FILTER
: osl::FileBase::getFileURLFromSystemPath( aPathCfg
.GetFilterPath(), aValue
); break;
406 case SvtPathOptions::PATH_GALLERY
: aValue
= aPathCfg
.GetGalleryPath(); break;
407 case SvtPathOptions::PATH_GRAPHIC
: aValue
= aPathCfg
.GetGraphicPath(); break;
408 case SvtPathOptions::PATH_HELP
: osl::FileBase::getFileURLFromSystemPath( aPathCfg
.GetHelpPath(), aValue
); break;
409 case SvtPathOptions::PATH_LINGUISTIC
: aValue
= aPathCfg
.GetLinguisticPath(); break;
410 case SvtPathOptions::PATH_MODULE
: osl::FileBase::getFileURLFromSystemPath( aPathCfg
.GetModulePath(), aValue
); break;
411 case SvtPathOptions::PATH_PALETTE
: aValue
= aPathCfg
.GetPalettePath(); break;
412 case SvtPathOptions::PATH_PLUGIN
: osl::FileBase::getFileURLFromSystemPath( aPathCfg
.GetPluginPath(), aValue
); break;
413 case SvtPathOptions::PATH_STORAGE
: osl::FileBase::getFileURLFromSystemPath( aPathCfg
.GetStoragePath(), aValue
); break;
414 case SvtPathOptions::PATH_TEMP
: aValue
= aPathCfg
.GetTempPath(); break;
415 case SvtPathOptions::PATH_TEMPLATE
: aValue
= aPathCfg
.GetTemplatePath(); break;
416 case SvtPathOptions::PATH_USERCONFIG
: aValue
= aPathCfg
.GetUserConfigPath(); break;
417 case SvtPathOptions::PATH_WORK
: aValue
= aPathCfg
.GetWorkPath(); break;
419 aValues
.SetTextByPos( nProp
, aValue
);
422 if (rSet
.Put(aValues
))
428 SAL_INFO( "sfx.appl", "W1:Wrong ID while getting Options!" );
431 SAL_WARN_IF(!bRet
, "sfx.appl", "Putting options failed!");
437 // TODO/CLEANUP: Why two SetOptions Methods?
438 void SfxApplication::SetOptions_Impl( const SfxItemSet
& rSet
)
440 const SfxPoolItem
*pItem
= nullptr;
441 SfxItemPool
&rPool
= GetPool();
443 SvtSaveOptions aSaveOptions
;
444 SvtHelpOptions aHelpOptions
;
445 SvtSecurityOptions aSecurityOptions
;
446 SvtMiscOptions aMiscOptions
;
447 std::shared_ptr
< comphelper::ConfigurationChanges
> batch(
448 comphelper::ConfigurationChanges::create());
450 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_BUTTON_BIGSIZE
), true, &pItem
) )
452 DBG_ASSERT(dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected");
453 bool bBigSize
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
454 aMiscOptions
.SetSymbolsSize(
455 sal::static_int_cast
< sal_Int16
>(
456 bBigSize
? SFX_SYMBOLS_SIZE_LARGE
: SFX_SYMBOLS_SIZE_SMALL
) );
457 SfxViewFrame
* pCurrViewFrame
= SfxViewFrame::GetFirst();
458 while ( pCurrViewFrame
)
460 // update all "final" dispatchers
461 pCurrViewFrame
->GetDispatcher()->Update_Impl(true);
462 pCurrViewFrame
= SfxViewFrame::GetNext(*pCurrViewFrame
);
467 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_BACKUP
), true, &pItem
) )
469 DBG_ASSERT(dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected");
470 aSaveOptions
.SetBackup( static_cast<const SfxBoolItem
*>(pItem
)->GetValue() );
474 if ( SfxItemState::SET
== rSet
.GetItemState( rPool
.GetWhich( SID_ATTR_PRETTYPRINTING
), true, &pItem
) )
476 DBG_ASSERT( dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected" );
477 aSaveOptions
.SetPrettyPrinting( static_cast< const SfxBoolItem
*> ( pItem
)->GetValue() );
481 if ( SfxItemState::SET
== rSet
.GetItemState( rPool
.GetWhich( SID_ATTR_WARNALIENFORMAT
), true, &pItem
) )
483 DBG_ASSERT( dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected" );
484 aSaveOptions
.SetWarnAlienFormat( static_cast< const SfxBoolItem
*> ( pItem
)->GetValue() );
488 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_AUTOSAVE
), true, &pItem
))
490 DBG_ASSERT(dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected");
491 aSaveOptions
.SetAutoSave( static_cast<const SfxBoolItem
*>(pItem
)->GetValue() );
495 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_AUTOSAVEPROMPT
), true, &pItem
))
497 DBG_ASSERT(dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected");
498 aSaveOptions
.SetAutoSavePrompt(static_cast<const SfxBoolItem
*>(pItem
)->GetValue());
502 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_AUTOSAVEMINUTE
), true, &pItem
))
504 DBG_ASSERT(dynamic_cast< const SfxUInt16Item
*>( pItem
) != nullptr, "UInt16Item expected");
505 aSaveOptions
.SetAutoSaveTime(static_cast<const SfxUInt16Item
*>(pItem
)->GetValue());
509 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_USERAUTOSAVE
), true, &pItem
))
511 DBG_ASSERT(dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected");
512 aSaveOptions
.SetUserAutoSave( static_cast<const SfxBoolItem
*>(pItem
)->GetValue() );
516 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_DOCINFO
), true, &pItem
))
518 DBG_ASSERT(dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected");
519 aSaveOptions
.SetDocInfoSave(static_cast<const SfxBoolItem
*>(pItem
)->GetValue());
522 // Mark open Documents
523 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_WORKINGSET
), true, &pItem
))
525 DBG_ASSERT(dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected");
526 aSaveOptions
.SetSaveWorkingSet(static_cast<const SfxBoolItem
*>(pItem
)->GetValue());
529 // Save window settings
530 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_SAVEDOCVIEW
), true, &pItem
))
532 DBG_ASSERT(dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected");
533 aSaveOptions
.SetSaveDocView(static_cast<const SfxBoolItem
*>(pItem
)->GetValue());
537 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_METRIC
), true, &pItem
))
539 DBG_ASSERT(dynamic_cast< const SfxUInt16Item
*>( pItem
) != nullptr, "UInt16Item expected");
543 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_HELPBALLOONS
), true, &pItem
))
545 DBG_ASSERT(dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected");
546 aHelpOptions
.SetExtendedHelp(static_cast<const SfxBoolItem
*>(pItem
)->GetValue());
550 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_HELPTIPS
), true, &pItem
))
552 DBG_ASSERT(dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected");
553 aHelpOptions
.SetHelpTips( static_cast<const SfxBoolItem
*>(pItem
)->GetValue());
556 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_HELP_STYLESHEET
), true, &pItem
))
558 DBG_ASSERT(dynamic_cast< const SfxStringItem
*>( pItem
) != nullptr, "StringItem expected");
559 aHelpOptions
.SetHelpStyleSheet( static_cast<const SfxStringItem
*>(pItem
)->GetValue() );
563 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_SAVEREL_INET
), true, &pItem
))
565 DBG_ASSERT(dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected");
566 aSaveOptions
.SetSaveRelINet(static_cast<const SfxBoolItem
*>(pItem
)->GetValue());
570 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_SAVEREL_FSYS
), true, &pItem
))
572 DBG_ASSERT(dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected");
573 aSaveOptions
.SetSaveRelFSys(static_cast<const SfxBoolItem
*>(pItem
)->GetValue());
577 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_UNDO_COUNT
), true, &pItem
))
579 DBG_ASSERT(dynamic_cast< const SfxUInt16Item
*>( pItem
) != nullptr, "UInt16Item expected");
580 sal_uInt16 nUndoCount
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
581 officecfg::Office::Common::Undo::Steps::set(nUndoCount
, batch
);
583 // To catch all Undo-Managers: Iterate over all Frames
584 for ( SfxViewFrame
*pFrame
= SfxViewFrame::GetFirst();
586 pFrame
= SfxViewFrame::GetNext(*pFrame
) )
588 // Get the Dispatcher of the Frames
589 SfxDispatcher
*pDispat
= pFrame
->GetDispatcher();
592 // Iterate over all SfxShells on the Dispatchers Stack
594 for ( SfxShell
*pSh
= pDispat
->GetShell(nIdx
);
596 ++nIdx
, pSh
= pDispat
->GetShell(nIdx
) )
598 SfxUndoManager
*pShUndoMgr
= pSh
->GetUndoManager();
600 pShUndoMgr
->SetMaxUndoActionCount( nUndoCount
);
606 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_QUICKLAUNCHER
), true, &pItem
))
608 DBG_ASSERT(dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected");
609 ShutdownIcon::SetAutostart( static_cast<const SfxBoolItem
*>( pItem
)->GetValue() );
613 if ( SfxItemState::SET
== rSet
.GetItemState(SID_BASIC_ENABLED
, true, &pItem
))
615 DBG_ASSERT(dynamic_cast< const SfxUInt16Item
*>( pItem
) != nullptr, "SfxInt16Item expected");
616 aSecurityOptions
.SetBasicMode( static_cast<EBasicSecurityMode
>(static_cast<const SfxUInt16Item
*>( pItem
)->GetValue()) );
620 if ( SfxItemState::SET
== rSet
.GetItemState(SID_INET_EXE_PLUGIN
, true, &pItem
))
622 DBG_ASSERT(dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "SfxBoolItem expected");
623 aSecurityOptions
.SetExecutePlugins( static_cast<const SfxBoolItem
*>( pItem
)->GetValue() );
626 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_INET_PROXY_TYPE
), true, &pItem
))
628 DBG_ASSERT( dynamic_cast< const SfxUInt16Item
*>( pItem
) != nullptr, "UInt16Item expected" );
629 officecfg::Inet::Settings::ooInetProxyType::set(
630 static_cast< SfxUInt16Item
const * >(pItem
)->GetValue(), batch
);
633 if ( SfxItemState::SET
== rSet
.GetItemState( rPool
.GetWhich( SID_INET_HTTP_PROXY_NAME
), true, &pItem
) )
635 DBG_ASSERT( dynamic_cast< const SfxStringItem
*>( pItem
) != nullptr, "StringItem expected" );
636 officecfg::Inet::Settings::ooInetHTTPProxyName::set(
637 static_cast< SfxStringItem
const * >(pItem
)->GetValue(), batch
);
639 if ( SfxItemState::SET
== rSet
.GetItemState( rPool
.GetWhich( SID_INET_HTTP_PROXY_PORT
), true, &pItem
) )
641 DBG_ASSERT( dynamic_cast< const SfxInt32Item
*>( pItem
) != nullptr, "Int32Item expected" );
642 officecfg::Inet::Settings::ooInetHTTPProxyPort::set(
643 static_cast< SfxInt32Item
const * >(pItem
)->GetValue(), batch
);
645 if ( SfxItemState::SET
== rSet
.GetItemState( rPool
.GetWhich( SID_INET_FTP_PROXY_NAME
), true, &pItem
) )
647 DBG_ASSERT( dynamic_cast< const SfxStringItem
*>( pItem
) != nullptr, "StringItem expected" );
648 officecfg::Inet::Settings::ooInetFTPProxyName::set(
649 static_cast< SfxStringItem
const * >(pItem
)->GetValue(), batch
);
651 if ( SfxItemState::SET
== rSet
.GetItemState( rPool
.GetWhich( SID_INET_FTP_PROXY_PORT
), true, &pItem
) )
653 DBG_ASSERT( dynamic_cast< const SfxInt32Item
*>( pItem
) != nullptr, "Int32Item expected" );
654 officecfg::Inet::Settings::ooInetFTPProxyPort::set(
655 static_cast< SfxInt32Item
const * >(pItem
)->GetValue(), batch
);
657 if ( SfxItemState::SET
== rSet
.GetItemState(SID_INET_NOPROXY
, true, &pItem
))
659 DBG_ASSERT(dynamic_cast< const SfxStringItem
*>( pItem
) != nullptr, "StringItem expected");
660 officecfg::Inet::Settings::ooInetNoProxy::set(
661 static_cast< SfxStringItem
const * >(pItem
)->GetValue(), batch
);
665 if ( SfxItemState::SET
== rSet
.GetItemState(SID_SECURE_URL
, true, &pItem
))
667 DBG_ASSERT(dynamic_cast< const SfxStringListItem
*>( pItem
) != nullptr, "StringListItem expected");
668 css::uno::Sequence
< OUString
> seqURLs
;
669 static_cast<const SfxStringListItem
*>(pItem
)->GetStringList(seqURLs
);
670 aSecurityOptions
.SetSecureURLs( seqURLs
);
673 if ( SfxItemState::SET
== rSet
.GetItemState(SID_MACRO_WARNING
, true, &pItem
))
675 DBG_ASSERT(dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "SfxBoolItem expected");
676 aSecurityOptions
.SetWarningEnabled( static_cast<const SfxBoolItem
*>(pItem
)->GetValue() );
678 if ( SfxItemState::SET
== rSet
.GetItemState(SID_MACRO_CONFIRMATION
, true, &pItem
))
680 DBG_ASSERT(dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "SfxBoolItem expected");
681 aSecurityOptions
.SetConfirmationEnabled( static_cast<const SfxBoolItem
*>(pItem
)->GetValue() );
684 // Store changed data
689 void SfxApplication::SetOptions(const SfxItemSet
&rSet
)
691 SvtPathOptions aPathOptions
;
693 // Data is saved in DocInfo and IniManager
694 const SfxPoolItem
*pItem
= nullptr;
695 SfxItemPool
&rPool
= GetPool();
697 SfxAllItemSet
aSendSet( rSet
);
700 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_PATHNAME
), true, &pItem
))
702 DBG_ASSERT(dynamic_cast< const SfxAllEnumItem
*>( pItem
) != nullptr, "AllEnumItem expected");
703 const SfxAllEnumItem
* pEnumItem
= static_cast<const SfxAllEnumItem
*>(pItem
);
704 sal_uInt32 nCount
= pEnumItem
->GetTextCount();
705 OUString
aNoChangeStr( ' ' );
706 for( sal_uInt32 nPath
=0; nPath
<nCount
; ++nPath
)
708 const OUString
& sValue
= pEnumItem
->GetTextByPos(static_cast<sal_uInt16
>(nPath
));
709 if ( sValue
!= aNoChangeStr
)
713 case SvtPathOptions::PATH_ADDIN
:
716 if( osl::FileBase::getSystemPathFromFileURL( sValue
, aTmp
) == osl::FileBase::E_None
)
717 aPathOptions
.SetAddinPath( aTmp
);
721 case SvtPathOptions::PATH_AUTOCORRECT
: aPathOptions
.SetAutoCorrectPath( sValue
);break;
722 case SvtPathOptions::PATH_AUTOTEXT
: aPathOptions
.SetAutoTextPath( sValue
);break;
723 case SvtPathOptions::PATH_BACKUP
: aPathOptions
.SetBackupPath( sValue
);break;
724 case SvtPathOptions::PATH_BASIC
: aPathOptions
.SetBasicPath( sValue
);break;
725 case SvtPathOptions::PATH_BITMAP
: aPathOptions
.SetBitmapPath( sValue
);break;
726 case SvtPathOptions::PATH_CONFIG
: aPathOptions
.SetConfigPath( sValue
);break;
727 case SvtPathOptions::PATH_DICTIONARY
: aPathOptions
.SetDictionaryPath( sValue
);break;
728 case SvtPathOptions::PATH_FAVORITES
: aPathOptions
.SetFavoritesPath( sValue
);break;
729 case SvtPathOptions::PATH_FILTER
:
732 if( osl::FileBase::getSystemPathFromFileURL( sValue
, aTmp
) == osl::FileBase::E_None
)
733 aPathOptions
.SetFilterPath( aTmp
);
736 case SvtPathOptions::PATH_GALLERY
: aPathOptions
.SetGalleryPath( sValue
);break;
737 case SvtPathOptions::PATH_GRAPHIC
: aPathOptions
.SetGraphicPath( sValue
);break;
738 case SvtPathOptions::PATH_HELP
:
741 if( osl::FileBase::getSystemPathFromFileURL( sValue
, aTmp
) == osl::FileBase::E_None
)
742 aPathOptions
.SetHelpPath( aTmp
);
746 case SvtPathOptions::PATH_LINGUISTIC
: aPathOptions
.SetLinguisticPath( sValue
);break;
747 case SvtPathOptions::PATH_MODULE
:
750 if( osl::FileBase::getSystemPathFromFileURL( sValue
, aTmp
) == osl::FileBase::E_None
)
751 aPathOptions
.SetModulePath( aTmp
);
755 case SvtPathOptions::PATH_PALETTE
: aPathOptions
.SetPalettePath( sValue
);break;
756 case SvtPathOptions::PATH_PLUGIN
:
759 if( osl::FileBase::getSystemPathFromFileURL( sValue
, aTmp
) == osl::FileBase::E_None
)
760 aPathOptions
.SetPluginPath( aTmp
);
764 case SvtPathOptions::PATH_STORAGE
:
767 if( osl::FileBase::getSystemPathFromFileURL( sValue
, aTmp
) == osl::FileBase::E_None
)
768 aPathOptions
.SetStoragePath( aTmp
);
772 case SvtPathOptions::PATH_TEMP
: aPathOptions
.SetTempPath( sValue
);break;
773 case SvtPathOptions::PATH_TEMPLATE
: aPathOptions
.SetTemplatePath( sValue
);break;
774 case SvtPathOptions::PATH_USERCONFIG
: aPathOptions
.SetUserConfigPath( sValue
);break;
775 case SvtPathOptions::PATH_WORK
: aPathOptions
.SetWorkPath( sValue
);break;
776 default: SAL_WARN( "sfx.appl", "SfxApplication::SetOptions_Impl() Invalid path number found for set directories!" );
781 aSendSet
.ClearItem( rPool
.GetWhich( SID_ATTR_PATHNAME
) );
784 SetOptions_Impl( rSet
);
787 Broadcast( SfxItemSetHint( rSet
) );
791 void SfxApplication::NotifyEvent( const SfxEventHint
& rEventHint
, bool bSynchron
)
793 SfxObjectShell
*pDoc
= rEventHint
.GetObjShell();
794 if ( pDoc
&& ( pDoc
->IsPreview() || !pDoc
->Get_Impl()->bInitialized
) )
799 SAL_INFO_IF(!pDoc
, "sfx.appl", "SfxEvent: " << rEventHint
.GetEventName());
800 Broadcast(rEventHint
);
802 pDoc
->Broadcast( rEventHint
);
805 new SfxEventAsyncer_Impl( rEventHint
);
808 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */