LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / sfx2 / source / appl / appcfg.cxx
blobfeeb621b159671c51bb576185c96e1d7f6068828
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <memory>
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;
61 namespace {
63 class SfxEventAsyncer_Impl : public SfxListener
65 SfxEventHint aHint;
66 std::unique_ptr<Idle> pIdle;
68 public:
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() )
81 pIdle->Stop();
82 delete this;
87 SfxEventAsyncer_Impl::SfxEventAsyncer_Impl( const SfxEventHint& rHint )
88 : aHint( 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 );
95 pIdle->Start();
99 IMPL_LINK(SfxEventAsyncer_Impl, IdleHdl, Timer*, pAsyncIdle, void)
101 SfxObjectShellRef xRef( aHint.GetObjShell() );
102 pAsyncIdle->Stop();
103 SAL_INFO_IF(!xRef.is(), "sfx.appl", "SfxEvent: " << aHint.GetEventName());
104 SfxGetpApp()->Broadcast( aHint );
105 if ( xRef.is() )
106 xRef->Broadcast( aHint );
107 delete this;
111 void SfxApplication::GetOptions( SfxItemSet& rSet )
113 bool bRet = false;
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)
123 switch(nWhich)
125 case SID_ATTR_BUTTON_BIGSIZE :
127 if( rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_BUTTON_BIGSIZE ), aMiscOptions.AreCurrentSymbolsLarge() ) ) )
128 bRet = true;
129 break;
131 case SID_ATTR_BACKUP :
133 bRet = true;
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() )))
137 bRet = false;
139 break;
140 case SID_ATTR_PRETTYPRINTING:
142 bRet = true;
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())))
146 bRet = false;
148 break;
149 case SID_ATTR_WARNALIENFORMAT:
151 bRet = true;
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() )))
155 bRet = false;
157 break;
158 case SID_ATTR_AUTOSAVE :
160 bRet = true;
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() )))
164 bRet = false;
166 break;
167 case SID_ATTR_AUTOSAVEPROMPT :
169 bRet = true;
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())))
173 bRet = false;
175 break;
176 case SID_ATTR_AUTOSAVEMINUTE :
178 bRet = true;
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() )))
182 bRet = false;
184 break;
185 case SID_ATTR_USERAUTOSAVE :
187 bRet = true;
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() )))
191 bRet = false;
193 break;
194 case SID_ATTR_DOCINFO :
196 bRet = true;
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())))
200 bRet = false;
202 break;
203 case SID_ATTR_WORKINGSET :
205 bRet = true;
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())))
209 bRet = false;
211 break;
212 case SID_ATTR_SAVEDOCVIEW :
214 bRet = true;
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())))
217 bRet = false;
219 break;
220 case SID_ATTR_METRIC :
221 break;
222 case SID_HELPBALLOONS :
223 if(rSet.Put( SfxBoolItem ( rPool.GetWhich( SID_HELPBALLOONS ),
224 officecfg::Office::Common::Help::ExtendedTip::get() ) ) )
225 bRet = true;
226 break;
227 case SID_HELPTIPS :
228 if(rSet.Put( SfxBoolItem ( rPool.GetWhich( SID_HELPTIPS ),
229 officecfg::Office::Common::Help::Tip::get() ) ) )
230 bRet = true;
231 break;
232 case SID_HELP_STYLESHEET :
233 if(rSet.Put( SfxStringItem ( rPool.GetWhich( SID_HELP_STYLESHEET ),
234 officecfg::Office::Common::Help::HelpStyleSheet::get() ) ) )
235 bRet = true;
236 break;
237 case SID_ATTR_UNDO_COUNT :
238 if (rSet.Put(
239 SfxUInt16Item (
240 rPool.GetWhich(SID_ATTR_UNDO_COUNT),
241 officecfg::Office::Common::Undo::Steps::get())))
243 bRet = true;
245 break;
246 case SID_ATTR_QUICKLAUNCHER :
248 if ( ShutdownIcon::IsQuickstarterInstalled() )
250 if ( rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_QUICKLAUNCHER ),
251 ShutdownIcon::GetAutostart() ) ) )
252 bRet = true;
254 else
256 rSet.DisableItem( rPool.GetWhich( SID_ATTR_QUICKLAUNCHER ) );
257 bRet = true;
259 break;
261 case SID_SAVEREL_INET :
263 bRet = true;
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() )))
267 bRet = false;
269 break;
270 case SID_SAVEREL_FSYS :
272 bRet = true;
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() )))
276 bRet = false;
278 break;
279 case SID_SECURE_URL :
281 bRet = true;
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 ) ) )
287 bRet = false;
290 break;
291 case SID_INET_PROXY_TYPE :
292 if (rSet.Put(
293 SfxUInt16Item(
294 rPool.GetWhich(SID_INET_PROXY_TYPE),
295 (officecfg::Inet::Settings::ooInetProxyType::
296 get().value_or(0)))))
298 bRet = true;
300 break;
301 case SID_INET_HTTP_PROXY_NAME :
302 if (rSet.Put(
303 SfxStringItem(
304 rPool.GetWhich(SID_INET_HTTP_PROXY_NAME),
305 officecfg::Inet::Settings::ooInetHTTPProxyName::
306 get())))
308 bRet = true;
310 break;
311 case SID_INET_HTTP_PROXY_PORT :
312 if (rSet.Put(
313 SfxInt32Item(
314 rPool.GetWhich(SID_INET_HTTP_PROXY_PORT),
315 (officecfg::Inet::Settings::
316 ooInetHTTPProxyPort::get().value_or(0)))))
318 bRet = true;
320 break;
321 case SID_INET_FTP_PROXY_NAME :
322 if (rSet.Put(
323 SfxStringItem(
324 rPool.GetWhich(SID_INET_FTP_PROXY_NAME),
325 officecfg::Inet::Settings::ooInetFTPProxyName::
326 get())))
328 bRet = true;
330 break;
331 case SID_INET_FTP_PROXY_PORT :
332 if (rSet.Put(
333 SfxInt32Item(
334 rPool.GetWhich(SID_INET_FTP_PROXY_PORT),
335 (officecfg::Inet::Settings::ooInetFTPProxyPort::
336 get().value_or(0)))))
338 bRet = true;
340 break;
341 case SID_INET_NOPROXY :
342 if (rSet.Put(
343 SfxStringItem(
344 rPool.GetWhich( SID_INET_NOPROXY),
345 (officecfg::Inet::Settings::ooInetNoProxy::
346 get()))))
348 bRet = true;
350 break;
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++ )
358 OUString aValue;
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;
383 default: break;
385 aValues.SetTextByPos( nProp, aValue );
388 if (rSet.Put(aValues))
389 bRet = true;
391 break;
393 default:
394 SAL_INFO( "sfx.appl", "W1:Wrong ID while getting Options!" );
395 break;
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);
428 // Backup
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(),
434 batch );
437 // PrettyPrinting
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(),
443 batch );
446 // WarnAlienFormat
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(),
452 batch);
455 // AutoSave
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(),
461 batch);
464 // AutoSave-Prompt
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(),
470 batch);
473 // AutoSave-Time
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(),
479 batch);
482 // UserAutoSave
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(),
488 batch);
491 // DocInfo
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(),
497 batch);
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(),
506 batch);
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);
516 // Metric
517 if ( SfxItemState::SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_METRIC), true, &pItem))
519 DBG_ASSERT(dynamic_cast< const SfxUInt16Item *>( pItem ) != nullptr, "UInt16Item expected");
522 // HelpBalloons
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(),
528 batch);
531 // HelpTips
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(),
537 batch);
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);
547 // SaveRelINet
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(),
553 batch);
556 // SaveRelFSys
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(),
562 batch);
565 // Undo-Count
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();
574 pFrame;
575 pFrame = SfxViewFrame::GetNext(*pFrame) )
577 // Get the Dispatcher of the Frames
578 SfxDispatcher *pDispat = pFrame->GetDispatcher();
579 pDispat->Flush();
581 // Iterate over all SfxShells on the Dispatchers Stack
582 sal_uInt16 nIdx = 0;
583 for ( SfxShell *pSh = pDispat->GetShell(nIdx);
584 pSh;
585 ++nIdx, pSh = pDispat->GetShell(nIdx) )
587 SfxUndoManager *pShUndoMgr = pSh->GetUndoManager();
588 if ( pShUndoMgr )
589 pShUndoMgr->SetMaxUndoActionCount( nUndoCount );
594 // Office autostart
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);
639 // Secure-Referrer
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
647 batch->commit();
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 );
661 // PathName
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:
677 OUString aTmp;
678 if( osl::FileBase::getSystemPathFromFileURL( sValue, aTmp ) == osl::FileBase::E_None )
679 aPathOptions.SetAddinPath( aTmp );
680 break;
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:
693 OUString aTmp;
694 if( osl::FileBase::getSystemPathFromFileURL( sValue, aTmp ) == osl::FileBase::E_None )
695 aPathOptions.SetFilterPath( aTmp );
696 break;
698 case SvtPathOptions::Paths::Gallery: aPathOptions.SetGalleryPath( sValue );break;
699 case SvtPathOptions::Paths::Graphic: aPathOptions.SetGraphicPath( sValue );break;
700 case SvtPathOptions::Paths::Help:
702 OUString aTmp;
703 if( osl::FileBase::getSystemPathFromFileURL( sValue, aTmp ) == osl::FileBase::E_None )
704 aPathOptions.SetHelpPath( aTmp );
705 break;
708 case SvtPathOptions::Paths::Linguistic: aPathOptions.SetLinguisticPath( sValue );break;
709 case SvtPathOptions::Paths::Module:
711 OUString aTmp;
712 if( osl::FileBase::getSystemPathFromFileURL( sValue, aTmp ) == osl::FileBase::E_None )
713 aPathOptions.SetModulePath( aTmp );
714 break;
717 case SvtPathOptions::Paths::Palette: aPathOptions.SetPalettePath( sValue );break;
718 case SvtPathOptions::Paths::Plugin:
720 OUString aTmp;
721 if( osl::FileBase::getSystemPathFromFileURL( sValue, aTmp ) == osl::FileBase::E_None )
722 aPathOptions.SetPluginPath( aTmp );
723 break;
726 case SvtPathOptions::Paths::Storage:
728 OUString aTmp;
729 if( osl::FileBase::getSystemPathFromFileURL( sValue, aTmp ) == osl::FileBase::E_None )
730 aPathOptions.SetStoragePath( aTmp );
731 break;
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 );
748 // Undo-Count
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 ) )
757 return;
759 if ( bSynchron )
761 SAL_INFO_IF(!pDoc, "sfx.appl", "SfxEvent: " << rEventHint.GetEventName());
762 Broadcast(rEventHint);
763 if ( pDoc )
764 pDoc->Broadcast( rEventHint );
766 else
767 new SfxEventAsyncer_Impl( rEventHint );
770 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */