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 <officecfg/Office/Recovery.hxx>
41 #include <unotools/saveopt.hxx>
42 #include <unotools/securityoptions.hxx>
43 #include <unotools/pathoptions.hxx>
44 #include <svtools/miscopt.hxx>
45 #include <svtools/imgdef.hxx>
46 #include <sal/log.hxx>
47 #include <vcl/idle.hxx>
49 #include <sfx2/app.hxx>
50 #include <sfx2/event.hxx>
51 #include <sfx2/viewfrm.hxx>
52 #include <sfx2/dispatch.hxx>
53 #include <sfx2/objsh.hxx>
54 #include <objshimp.hxx>
55 #include "shutdownicon.hxx"
57 using namespace ::com::sun::star::uno
;
58 using namespace ::com::sun::star::util
;
59 using namespace ::com::sun::star::beans
;
63 class SfxEventAsyncer_Impl
: public SfxListener
66 std::unique_ptr
<Idle
> pIdle
;
70 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
71 explicit SfxEventAsyncer_Impl(const SfxEventHint
& rHint
);
72 DECL_LINK( IdleHdl
, Timer
*, void );
77 void SfxEventAsyncer_Impl::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
79 if( rHint
.GetId() == SfxHintId::Dying
&& pIdle
->IsActive() )
87 SfxEventAsyncer_Impl::SfxEventAsyncer_Impl( const SfxEventHint
& rHint
)
90 if( rHint
.GetObjShell() )
91 StartListening( *rHint
.GetObjShell() );
92 pIdle
.reset( new Idle("sfx::SfxEventAsyncer_Impl pIdle") );
93 pIdle
->SetInvokeHandler( LINK(this, SfxEventAsyncer_Impl
, IdleHdl
) );
94 pIdle
->SetPriority( TaskPriority::HIGH_IDLE
);
99 IMPL_LINK(SfxEventAsyncer_Impl
, IdleHdl
, Timer
*, pAsyncIdle
, void)
101 SfxObjectShellRef
xRef( aHint
.GetObjShell() );
103 SAL_INFO_IF(!xRef
.is(), "sfx.appl", "SfxEvent: " << aHint
.GetEventName());
104 SfxGetpApp()->Broadcast( aHint
);
106 xRef
->Broadcast( aHint
);
111 void SfxApplication::GetOptions( SfxItemSet
& rSet
)
114 SfxItemPool
&rPool
= GetPool();
116 const WhichRangesContainer
& pRanges
= rSet
.GetRanges();
117 SvtMiscOptions aMiscOptions
;
119 for (auto const & pRange
: pRanges
)
121 for(sal_uInt16 nWhich
= pRange
.first
; nWhich
<= pRange
.second
; ++nWhich
)
125 case SID_ATTR_BUTTON_BIGSIZE
:
127 if( rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_BUTTON_BIGSIZE
), aMiscOptions
.AreCurrentSymbolsLarge() ) ) )
131 case SID_ATTR_BACKUP
:
134 if (!officecfg::Office::Common::Save::Document::CreateBackup::isReadOnly())
135 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_BACKUP
),
136 officecfg::Office::Common::Save::Document::CreateBackup::get() )))
140 case SID_ATTR_PRETTYPRINTING
:
143 if (!officecfg::Office::Common::Save::Document::PrettyPrinting::isReadOnly())
144 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_PRETTYPRINTING
),
145 officecfg::Office::Common::Save::Document::PrettyPrinting::get())))
149 case SID_ATTR_WARNALIENFORMAT
:
152 if (!officecfg::Office::Common::Save::Document::WarnAlienFormat::isReadOnly())
153 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_WARNALIENFORMAT
),
154 officecfg::Office::Common::Save::Document::WarnAlienFormat::get() )))
158 case SID_ATTR_AUTOSAVE
:
161 if (!officecfg::Office::Common::Save::Document::AutoSave::isReadOnly())
162 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_AUTOSAVE
),
163 officecfg::Office::Common::Save::Document::AutoSave::get() )))
167 case SID_ATTR_AUTOSAVEPROMPT
:
170 if (!officecfg::Office::Common::Save::Document::AutoSavePrompt::isReadOnly())
171 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_AUTOSAVEPROMPT
),
172 officecfg::Office::Common::Save::Document::AutoSavePrompt::get())))
176 case SID_ATTR_AUTOSAVEMINUTE
:
179 if (!officecfg::Office::Common::Save::Document::AutoSaveTimeIntervall::isReadOnly())
180 if (!rSet
.Put( SfxUInt16Item( rPool
.GetWhich( SID_ATTR_AUTOSAVEMINUTE
),
181 officecfg::Office::Common::Save::Document::AutoSaveTimeIntervall::get() )))
185 case SID_ATTR_USERAUTOSAVE
:
188 if (!officecfg::Office::Recovery::AutoSave::UserAutoSaveEnabled::isReadOnly())
189 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_USERAUTOSAVE
),
190 officecfg::Office::Recovery::AutoSave::UserAutoSaveEnabled::get() )))
194 case SID_ATTR_DOCINFO
:
197 if (!officecfg::Office::Common::Save::Document::EditProperty::isReadOnly())
198 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_DOCINFO
),
199 officecfg::Office::Common::Save::Document::EditProperty::get())))
203 case SID_ATTR_WORKINGSET
:
206 if (!officecfg::Office::Common::Save::WorkingSet::isReadOnly())
207 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_WORKINGSET
),
208 officecfg::Office::Common::Save::WorkingSet::get())))
212 case SID_ATTR_SAVEDOCVIEW
:
215 if (!officecfg::Office::Common::Save::Document::ViewInfo::isReadOnly())
216 if (!rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_SAVEDOCVIEW
), officecfg::Office::Common::Save::Document::ViewInfo::get())))
220 case SID_ATTR_METRIC
:
222 case SID_HELPBALLOONS
:
223 if(rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_HELPBALLOONS
),
224 officecfg::Office::Common::Help::ExtendedTip::get() ) ) )
228 if(rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_HELPTIPS
),
229 officecfg::Office::Common::Help::Tip::get() ) ) )
232 case SID_HELP_STYLESHEET
:
233 if(rSet
.Put( SfxStringItem ( rPool
.GetWhich( SID_HELP_STYLESHEET
),
234 officecfg::Office::Common::Help::HelpStyleSheet::get() ) ) )
237 case SID_ATTR_UNDO_COUNT
:
240 rPool
.GetWhich(SID_ATTR_UNDO_COUNT
),
241 officecfg::Office::Common::Undo::Steps::get())))
246 case SID_ATTR_QUICKLAUNCHER
:
248 if ( ShutdownIcon::IsQuickstarterInstalled() )
250 if ( rSet
.Put( SfxBoolItem( rPool
.GetWhich( SID_ATTR_QUICKLAUNCHER
),
251 ShutdownIcon::GetAutostart() ) ) )
256 rSet
.DisableItem( rPool
.GetWhich( SID_ATTR_QUICKLAUNCHER
) );
261 case SID_SAVEREL_INET
:
264 if (!officecfg::Office::Common::Save::URL::Internet::isReadOnly())
265 if (!rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_SAVEREL_INET
),
266 officecfg::Office::Common::Save::URL::Internet::get() )))
270 case SID_SAVEREL_FSYS
:
273 if (!officecfg::Office::Common::Save::URL::FileSystem::isReadOnly())
274 if (!rSet
.Put( SfxBoolItem ( rPool
.GetWhich( SID_SAVEREL_FSYS
),
275 officecfg::Office::Common::Save::URL::FileSystem::get() )))
279 case SID_SECURE_URL
:
282 if (!SvtSecurityOptions::IsReadOnly(SvtSecurityOptions::EOption::SecureUrls
))
284 std::vector
< OUString
> seqURLs
= SvtSecurityOptions::GetSecureURLs();
286 if( !rSet
.Put( SfxStringListItem( rPool
.GetWhich(SID_SECURE_URL
), &seqURLs
) ) )
291 case SID_INET_PROXY_TYPE
:
294 rPool
.GetWhich(SID_INET_PROXY_TYPE
),
295 (officecfg::Inet::Settings::ooInetProxyType::
296 get().value_or(0)))))
301 case SID_INET_HTTP_PROXY_NAME
:
304 rPool
.GetWhich(SID_INET_HTTP_PROXY_NAME
),
305 officecfg::Inet::Settings::ooInetHTTPProxyName::
311 case SID_INET_HTTP_PROXY_PORT
:
314 rPool
.GetWhich(SID_INET_HTTP_PROXY_PORT
),
315 (officecfg::Inet::Settings::
316 ooInetHTTPProxyPort::get().value_or(0)))))
321 case SID_INET_FTP_PROXY_NAME
:
324 rPool
.GetWhich(SID_INET_FTP_PROXY_NAME
),
325 officecfg::Inet::Settings::ooInetFTPProxyName::
331 case SID_INET_FTP_PROXY_PORT
:
334 rPool
.GetWhich(SID_INET_FTP_PROXY_PORT
),
335 (officecfg::Inet::Settings::ooInetFTPProxyPort::
336 get().value_or(0)))))
341 case SID_INET_NOPROXY
:
344 rPool
.GetWhich( SID_INET_NOPROXY
),
345 (officecfg::Inet::Settings::ooInetNoProxy::
351 case SID_ATTR_PATHNAME
:
353 SfxAllEnumItem
aValues(rPool
.GetWhich(SID_ATTR_PATHNAME
));
354 SvtPathOptions aPathCfg
;
355 for ( sal_uInt16 nProp
= static_cast<sal_uInt16
>(SvtPathOptions::Paths::AddIn
);
356 nProp
<= static_cast<sal_uInt16
>(SvtPathOptions::Paths::Work
); nProp
++ )
359 switch ( static_cast<SvtPathOptions::Paths
>(nProp
) )
361 case SvtPathOptions::Paths::AddIn
: osl::FileBase::getFileURLFromSystemPath( aPathCfg
.GetAddinPath(), aValue
); break;
362 case SvtPathOptions::Paths::AutoCorrect
: aValue
= aPathCfg
.GetAutoCorrectPath(); break;
363 case SvtPathOptions::Paths::AutoText
: aValue
= aPathCfg
.GetAutoTextPath(); break;
364 case SvtPathOptions::Paths::Backup
: aValue
= aPathCfg
.GetBackupPath(); break;
365 case SvtPathOptions::Paths::Basic
: aValue
= aPathCfg
.GetBasicPath(); break;
366 case SvtPathOptions::Paths::Bitmap
: aValue
= aPathCfg
.GetBitmapPath(); break;
367 case SvtPathOptions::Paths::Config
: aValue
= aPathCfg
.GetConfigPath(); break;
368 case SvtPathOptions::Paths::Dictionary
: aValue
= aPathCfg
.GetDictionaryPath(); break;
369 case SvtPathOptions::Paths::Favorites
: aValue
= aPathCfg
.GetFavoritesPath(); break;
370 case SvtPathOptions::Paths::Filter
: osl::FileBase::getFileURLFromSystemPath( aPathCfg
.GetFilterPath(), aValue
); break;
371 case SvtPathOptions::Paths::Gallery
: aValue
= aPathCfg
.GetGalleryPath(); break;
372 case SvtPathOptions::Paths::Graphic
: aValue
= aPathCfg
.GetGraphicPath(); break;
373 case SvtPathOptions::Paths::Help
: osl::FileBase::getFileURLFromSystemPath( aPathCfg
.GetHelpPath(), aValue
); break;
374 case SvtPathOptions::Paths::Linguistic
: aValue
= aPathCfg
.GetLinguisticPath(); break;
375 case SvtPathOptions::Paths::Module
: osl::FileBase::getFileURLFromSystemPath( aPathCfg
.GetModulePath(), aValue
); break;
376 case SvtPathOptions::Paths::Palette
: aValue
= aPathCfg
.GetPalettePath(); break;
377 case SvtPathOptions::Paths::Plugin
: osl::FileBase::getFileURLFromSystemPath( aPathCfg
.GetPluginPath(), aValue
); break;
378 case SvtPathOptions::Paths::Storage
: osl::FileBase::getFileURLFromSystemPath( aPathCfg
.GetStoragePath(), aValue
); break;
379 case SvtPathOptions::Paths::Temp
: aValue
= aPathCfg
.GetTempPath(); break;
380 case SvtPathOptions::Paths::Template
: aValue
= aPathCfg
.GetTemplatePath(); break;
381 case SvtPathOptions::Paths::UserConfig
: aValue
= aPathCfg
.GetUserConfigPath(); break;
382 case SvtPathOptions::Paths::Work
: aValue
= aPathCfg
.GetWorkPath(); break;
385 aValues
.SetTextByPos( nProp
, aValue
);
388 if (rSet
.Put(aValues
))
394 SAL_INFO( "sfx.appl", "W1:Wrong ID while getting Options!" );
397 SAL_WARN_IF(!bRet
, "sfx.appl", "Putting options failed!");
402 // TODO/CLEANUP: Why two SetOptions Methods?
403 void SfxApplication::SetOptions_Impl( const SfxItemSet
& rSet
)
405 const SfxPoolItem
*pItem
= nullptr;
406 SfxItemPool
&rPool
= GetPool();
408 SvtMiscOptions aMiscOptions
;
409 std::shared_ptr
< comphelper::ConfigurationChanges
> batch(
410 comphelper::ConfigurationChanges::create());
412 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_BUTTON_BIGSIZE
), true, &pItem
) )
414 DBG_ASSERT(dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected");
415 bool bBigSize
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
416 aMiscOptions
.SetSymbolsSize(
417 sal::static_int_cast
< sal_Int16
>(
418 bBigSize
? SFX_SYMBOLS_SIZE_LARGE
: SFX_SYMBOLS_SIZE_SMALL
) );
419 SfxViewFrame
* pCurrViewFrame
= SfxViewFrame::GetFirst();
420 while ( pCurrViewFrame
)
422 // update all "final" dispatchers
423 pCurrViewFrame
->GetDispatcher()->Update_Impl(true);
424 pCurrViewFrame
= SfxViewFrame::GetNext(*pCurrViewFrame
);
429 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_BACKUP
), true, &pItem
) )
431 DBG_ASSERT(dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected");
432 officecfg::Office::Common::Save::Document::CreateBackup::set(
433 static_cast<const SfxBoolItem
*>(pItem
)->GetValue(),
438 if ( SfxItemState::SET
== rSet
.GetItemState( rPool
.GetWhich( SID_ATTR_PRETTYPRINTING
), true, &pItem
) )
440 DBG_ASSERT( dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected" );
441 officecfg::Office::Common::Save::Document::PrettyPrinting::set(
442 static_cast< const SfxBoolItem
*> ( pItem
)->GetValue(),
447 if ( SfxItemState::SET
== rSet
.GetItemState( rPool
.GetWhich( SID_ATTR_WARNALIENFORMAT
), true, &pItem
) )
449 DBG_ASSERT( dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected" );
450 officecfg::Office::Common::Save::Document::WarnAlienFormat::set(
451 static_cast< const SfxBoolItem
*> ( pItem
)->GetValue(),
456 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_AUTOSAVE
), true, &pItem
))
458 DBG_ASSERT(dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected");
459 officecfg::Office::Common::Save::Document::AutoSave::set(
460 static_cast<const SfxBoolItem
*>(pItem
)->GetValue(),
465 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_AUTOSAVEPROMPT
), true, &pItem
))
467 DBG_ASSERT(dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected");
468 officecfg::Office::Common::Save::Document::AutoSavePrompt::set(
469 static_cast<const SfxBoolItem
*>(pItem
)->GetValue(),
474 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_AUTOSAVEMINUTE
), true, &pItem
))
476 DBG_ASSERT(dynamic_cast< const SfxUInt16Item
*>( pItem
) != nullptr, "UInt16Item expected");
477 officecfg::Office::Common::Save::Document::AutoSaveTimeIntervall::set(
478 static_cast<const SfxUInt16Item
*>(pItem
)->GetValue(),
483 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_USERAUTOSAVE
), true, &pItem
))
485 DBG_ASSERT(dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected");
486 officecfg::Office::Recovery::AutoSave::UserAutoSaveEnabled::set(
487 static_cast<const SfxBoolItem
*>(pItem
)->GetValue(),
492 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_DOCINFO
), true, &pItem
))
494 DBG_ASSERT(dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected");
495 officecfg::Office::Common::Save::Document::EditProperty::set(
496 static_cast<const SfxBoolItem
*>(pItem
)->GetValue(),
500 // Mark open Documents
501 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_WORKINGSET
), true, &pItem
))
503 DBG_ASSERT(dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected");
504 officecfg::Office::Common::Save::WorkingSet::set(
505 static_cast<const SfxBoolItem
*>(pItem
)->GetValue(),
509 // Save window settings
510 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_SAVEDOCVIEW
), true, &pItem
))
512 DBG_ASSERT(dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected");
513 officecfg::Office::Common::Save::Document::ViewInfo::set(static_cast<const SfxBoolItem
*>(pItem
)->GetValue(), batch
);
517 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_METRIC
), true, &pItem
))
519 DBG_ASSERT(dynamic_cast< const SfxUInt16Item
*>( pItem
) != nullptr, "UInt16Item expected");
523 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_HELPBALLOONS
), true, &pItem
))
525 DBG_ASSERT(dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected");
526 officecfg::Office::Common::Help::ExtendedTip::set(
527 static_cast<const SfxBoolItem
*>(pItem
)->GetValue(),
532 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_HELPTIPS
), true, &pItem
))
534 DBG_ASSERT(dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected");
535 officecfg::Office::Common::Help::Tip::set(
536 static_cast<const SfxBoolItem
*>(pItem
)->GetValue(),
540 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_HELP_STYLESHEET
), true, &pItem
))
542 DBG_ASSERT(dynamic_cast< const SfxStringItem
*>( pItem
) != nullptr, "StringItem expected");
543 OUString sStyleSheet
= static_cast<const SfxStringItem
*>(pItem
)->GetValue();
544 officecfg::Office::Common::Help::HelpStyleSheet::set(sStyleSheet
, batch
);
548 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_SAVEREL_INET
), true, &pItem
))
550 DBG_ASSERT(dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected");
551 officecfg::Office::Common::Save::URL::Internet::set(
552 static_cast<const SfxBoolItem
*>(pItem
)->GetValue(),
557 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_SAVEREL_FSYS
), true, &pItem
))
559 DBG_ASSERT(dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected");
560 officecfg::Office::Common::Save::URL::FileSystem::set(
561 static_cast<const SfxBoolItem
*>(pItem
)->GetValue(),
566 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_UNDO_COUNT
), true, &pItem
))
568 DBG_ASSERT(dynamic_cast< const SfxUInt16Item
*>( pItem
) != nullptr, "UInt16Item expected");
569 sal_uInt16 nUndoCount
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
570 officecfg::Office::Common::Undo::Steps::set(nUndoCount
, batch
);
572 // To catch all Undo-Managers: Iterate over all Frames
573 for ( SfxViewFrame
*pFrame
= SfxViewFrame::GetFirst();
575 pFrame
= SfxViewFrame::GetNext(*pFrame
) )
577 // Get the Dispatcher of the Frames
578 SfxDispatcher
*pDispat
= pFrame
->GetDispatcher();
581 // Iterate over all SfxShells on the Dispatchers Stack
583 for ( SfxShell
*pSh
= pDispat
->GetShell(nIdx
);
585 ++nIdx
, pSh
= pDispat
->GetShell(nIdx
) )
587 SfxUndoManager
*pShUndoMgr
= pSh
->GetUndoManager();
589 pShUndoMgr
->SetMaxUndoActionCount( nUndoCount
);
595 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_QUICKLAUNCHER
), true, &pItem
))
597 DBG_ASSERT(dynamic_cast< const SfxBoolItem
*>( pItem
) != nullptr, "BoolItem expected");
598 ShutdownIcon::SetAutostart( static_cast<const SfxBoolItem
*>( pItem
)->GetValue() );
601 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_INET_PROXY_TYPE
), true, &pItem
))
603 DBG_ASSERT( dynamic_cast< const SfxUInt16Item
*>( pItem
) != nullptr, "UInt16Item expected" );
604 officecfg::Inet::Settings::ooInetProxyType::set(
605 static_cast< SfxUInt16Item
const * >(pItem
)->GetValue(), batch
);
608 if ( SfxItemState::SET
== rSet
.GetItemState( rPool
.GetWhich( SID_INET_HTTP_PROXY_NAME
), true, &pItem
) )
610 DBG_ASSERT( dynamic_cast< const SfxStringItem
*>( pItem
) != nullptr, "StringItem expected" );
611 officecfg::Inet::Settings::ooInetHTTPProxyName::set(
612 static_cast< SfxStringItem
const * >(pItem
)->GetValue(), batch
);
614 if ( SfxItemState::SET
== rSet
.GetItemState( rPool
.GetWhich( SID_INET_HTTP_PROXY_PORT
), true, &pItem
) )
616 DBG_ASSERT( dynamic_cast< const SfxInt32Item
*>( pItem
) != nullptr, "Int32Item expected" );
617 officecfg::Inet::Settings::ooInetHTTPProxyPort::set(
618 static_cast< SfxInt32Item
const * >(pItem
)->GetValue(), batch
);
620 if ( SfxItemState::SET
== rSet
.GetItemState( rPool
.GetWhich( SID_INET_FTP_PROXY_NAME
), true, &pItem
) )
622 DBG_ASSERT( dynamic_cast< const SfxStringItem
*>( pItem
) != nullptr, "StringItem expected" );
623 officecfg::Inet::Settings::ooInetFTPProxyName::set(
624 static_cast< SfxStringItem
const * >(pItem
)->GetValue(), batch
);
626 if ( SfxItemState::SET
== rSet
.GetItemState( rPool
.GetWhich( SID_INET_FTP_PROXY_PORT
), true, &pItem
) )
628 DBG_ASSERT( dynamic_cast< const SfxInt32Item
*>( pItem
) != nullptr, "Int32Item expected" );
629 officecfg::Inet::Settings::ooInetFTPProxyPort::set(
630 static_cast< SfxInt32Item
const * >(pItem
)->GetValue(), batch
);
632 if ( SfxItemState::SET
== rSet
.GetItemState(SID_INET_NOPROXY
, true, &pItem
))
634 DBG_ASSERT(dynamic_cast< const SfxStringItem
*>( pItem
) != nullptr, "StringItem expected");
635 officecfg::Inet::Settings::ooInetNoProxy::set(
636 static_cast< SfxStringItem
const * >(pItem
)->GetValue(), batch
);
640 if ( SfxItemState::SET
== rSet
.GetItemState(SID_SECURE_URL
, true, &pItem
))
642 DBG_ASSERT(dynamic_cast< const SfxStringListItem
*>( pItem
) != nullptr, "StringListItem expected");
643 SvtSecurityOptions::SetSecureURLs( std::vector(static_cast<const SfxStringListItem
*>(pItem
)->GetList()) );
646 // Store changed data
651 void SfxApplication::SetOptions(const SfxItemSet
&rSet
)
653 SvtPathOptions aPathOptions
;
655 // Data is saved in DocInfo and IniManager
656 const SfxPoolItem
*pItem
= nullptr;
657 SfxItemPool
&rPool
= GetPool();
659 SfxAllItemSet
aSendSet( rSet
);
662 if ( SfxItemState::SET
== rSet
.GetItemState(rPool
.GetWhich(SID_ATTR_PATHNAME
), true, &pItem
))
664 DBG_ASSERT(dynamic_cast< const SfxAllEnumItem
*>( pItem
) != nullptr, "AllEnumItem expected");
665 const SfxAllEnumItem
* pEnumItem
= static_cast<const SfxAllEnumItem
*>(pItem
);
666 sal_uInt32 nCount
= pEnumItem
->GetTextCount();
667 OUString
aNoChangeStr( ' ' );
668 for( sal_uInt32 nPath
=0; nPath
<nCount
; ++nPath
)
670 const OUString
& sValue
= pEnumItem
->GetTextByPos(static_cast<sal_uInt16
>(nPath
));
671 if ( sValue
!= aNoChangeStr
)
673 switch( static_cast<SvtPathOptions::Paths
>(nPath
) )
675 case SvtPathOptions::Paths::AddIn
:
678 if( osl::FileBase::getSystemPathFromFileURL( sValue
, aTmp
) == osl::FileBase::E_None
)
679 aPathOptions
.SetAddinPath( aTmp
);
683 case SvtPathOptions::Paths::AutoCorrect
: aPathOptions
.SetAutoCorrectPath( sValue
);break;
684 case SvtPathOptions::Paths::AutoText
: aPathOptions
.SetAutoTextPath( sValue
);break;
685 case SvtPathOptions::Paths::Backup
: aPathOptions
.SetBackupPath( sValue
);break;
686 case SvtPathOptions::Paths::Basic
: aPathOptions
.SetBasicPath( sValue
);break;
687 case SvtPathOptions::Paths::Bitmap
: aPathOptions
.SetBitmapPath( sValue
);break;
688 case SvtPathOptions::Paths::Config
: aPathOptions
.SetConfigPath( sValue
);break;
689 case SvtPathOptions::Paths::Dictionary
: aPathOptions
.SetDictionaryPath( sValue
);break;
690 case SvtPathOptions::Paths::Favorites
: aPathOptions
.SetFavoritesPath( sValue
);break;
691 case SvtPathOptions::Paths::Filter
:
694 if( osl::FileBase::getSystemPathFromFileURL( sValue
, aTmp
) == osl::FileBase::E_None
)
695 aPathOptions
.SetFilterPath( aTmp
);
698 case SvtPathOptions::Paths::Gallery
: aPathOptions
.SetGalleryPath( sValue
);break;
699 case SvtPathOptions::Paths::Graphic
: aPathOptions
.SetGraphicPath( sValue
);break;
700 case SvtPathOptions::Paths::Help
:
703 if( osl::FileBase::getSystemPathFromFileURL( sValue
, aTmp
) == osl::FileBase::E_None
)
704 aPathOptions
.SetHelpPath( aTmp
);
708 case SvtPathOptions::Paths::Linguistic
: aPathOptions
.SetLinguisticPath( sValue
);break;
709 case SvtPathOptions::Paths::Module
:
712 if( osl::FileBase::getSystemPathFromFileURL( sValue
, aTmp
) == osl::FileBase::E_None
)
713 aPathOptions
.SetModulePath( aTmp
);
717 case SvtPathOptions::Paths::Palette
: aPathOptions
.SetPalettePath( sValue
);break;
718 case SvtPathOptions::Paths::Plugin
:
721 if( osl::FileBase::getSystemPathFromFileURL( sValue
, aTmp
) == osl::FileBase::E_None
)
722 aPathOptions
.SetPluginPath( aTmp
);
726 case SvtPathOptions::Paths::Storage
:
729 if( osl::FileBase::getSystemPathFromFileURL( sValue
, aTmp
) == osl::FileBase::E_None
)
730 aPathOptions
.SetStoragePath( aTmp
);
734 case SvtPathOptions::Paths::Temp
: aPathOptions
.SetTempPath( sValue
);break;
735 case SvtPathOptions::Paths::Template
: aPathOptions
.SetTemplatePath( sValue
);break;
736 case SvtPathOptions::Paths::UserConfig
: aPathOptions
.SetUserConfigPath( sValue
);break;
737 case SvtPathOptions::Paths::Work
: aPathOptions
.SetWorkPath( sValue
);break;
738 default: SAL_WARN( "sfx.appl", "SfxApplication::SetOptions_Impl() Invalid path number found for set directories!" );
743 aSendSet
.ClearItem( rPool
.GetWhich( SID_ATTR_PATHNAME
) );
746 SetOptions_Impl( rSet
);
749 Broadcast( SfxItemSetHint( rSet
) );
753 void SfxApplication::NotifyEvent( const SfxEventHint
& rEventHint
, bool bSynchron
)
755 SfxObjectShell
*pDoc
= rEventHint
.GetObjShell();
756 if ( pDoc
&& ( pDoc
->IsPreview() || !pDoc
->Get_Impl()->bInitialized
) )
761 SAL_INFO_IF(!pDoc
, "sfx.appl", "SfxEvent: " << rEventHint
.GetEventName());
762 Broadcast(rEventHint
);
764 pDoc
->Broadcast( rEventHint
);
767 new SfxEventAsyncer_Impl( rEventHint
);
770 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */