bump product version to 4.2.0.1
[LibreOffice.git] / sfx2 / source / appl / appcfg.cxx
blobacd9eebc1998c50e67b7ca9272959ce681819cdd
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 <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>
27 #include <stdlib.h>
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>
58 #include <sfx2/app.hxx>
59 #include <sfx2/docfile.hxx>
60 #include <sfx2/viewfrm.hxx>
61 #include <sfx2/sfxhelp.hxx>
62 #include "sfxtypes.hxx"
63 #include <sfx2/dispatch.hxx>
64 #include <sfx2/objsh.hxx>
65 #include "objshimp.hxx"
66 #include <sfx2/viewsh.hxx>
67 #include <sfx2/request.hxx>
68 #include <sfx2/evntconf.hxx>
69 #include "appdata.hxx"
70 #include "workwin.hxx"
71 #include "helper.hxx"
72 #include "app.hrc"
73 #include <sfx2/sfxresid.hxx>
74 #include "shutdownicon.hxx"
76 using namespace ::com::sun::star::uno;
77 using namespace ::com::sun::star::util;
78 using namespace ::com::sun::star::frame;
79 using namespace ::com::sun::star::beans;
81 //-------------------------------------------------------------------------
83 class SfxEventAsyncer_Impl : public SfxListener
85 SfxEventHint aHint;
86 Timer* pTimer;
88 public:
90 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
91 SfxEventAsyncer_Impl( const SfxEventHint& rHint );
92 ~SfxEventAsyncer_Impl();
93 DECL_LINK( TimerHdl, Timer*);
96 // -----------------------------------------------------------------------
98 void SfxEventAsyncer_Impl::Notify( SfxBroadcaster&, const SfxHint& rHint )
100 SfxSimpleHint* pHint = PTR_CAST( SfxSimpleHint, &rHint );
101 if( pHint && pHint->GetId() == SFX_HINT_DYING && pTimer->IsActive() )
103 pTimer->Stop();
104 delete this;
108 // -----------------------------------------------------------------------
110 SfxEventAsyncer_Impl::SfxEventAsyncer_Impl( const SfxEventHint& rHint )
111 : aHint( rHint )
113 if( rHint.GetObjShell() )
114 StartListening( *rHint.GetObjShell() );
115 pTimer = new Timer;
116 pTimer->SetTimeoutHdl( LINK(this, SfxEventAsyncer_Impl, TimerHdl) );
117 pTimer->SetTimeout( 0 );
118 pTimer->Start();
121 // -----------------------------------------------------------------------
123 SfxEventAsyncer_Impl::~SfxEventAsyncer_Impl()
125 delete pTimer;
128 // -----------------------------------------------------------------------
130 IMPL_LINK(SfxEventAsyncer_Impl, TimerHdl, Timer*, pAsyncTimer)
132 (void)pAsyncTimer; // unused variable
133 SfxObjectShellRef xRef( aHint.GetObjShell() );
134 pAsyncTimer->Stop();
135 #ifdef DBG_UTIL
136 if (!xRef.Is())
138 OStringBuffer aTmp("SfxEvent: ");
139 aTmp.append(OUStringToOString(aHint.GetEventName(), RTL_TEXTENCODING_UTF8));
140 OSL_TRACE( "%s", aTmp.getStr() );
142 #endif
143 SFX_APP()->Broadcast( aHint );
144 if ( xRef.Is() )
145 xRef->Broadcast( aHint );
146 delete this;
147 return 0L;
151 //--------------------------------------------------------------------
153 sal_Bool SfxApplication::GetOptions( SfxItemSet& rSet )
155 sal_Bool bRet = sal_False;
156 SfxItemPool &rPool = GetPool();
158 const sal_uInt16 *pRanges = rSet.GetRanges();
159 SvtSaveOptions aSaveOptions;
160 SvtHelpOptions aHelpOptions;
161 SvtSecurityOptions aSecurityOptions;
162 SvtMiscOptions aMiscOptions;
164 while ( *pRanges )
166 for(sal_uInt16 nWhich = *pRanges++; nWhich <= *pRanges; ++nWhich)
168 switch(nWhich)
170 case SID_ATTR_BUTTON_OUTSTYLE3D :
171 if(rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_BUTTON_OUTSTYLE3D ),
172 aMiscOptions.GetToolboxStyle() != TOOLBOX_STYLE_FLAT)))
173 bRet = sal_True;
174 break;
175 case SID_ATTR_BUTTON_BIGSIZE :
177 if( rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_BUTTON_BIGSIZE ), aMiscOptions.AreCurrentSymbolsLarge() ) ) )
178 bRet = sal_True;
179 break;
181 case SID_ATTR_BACKUP :
183 bRet = sal_True;
184 if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_BACKUP))
185 if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_BACKUP ),aSaveOptions.IsBackup())))
186 bRet = sal_False;
188 break;
189 case SID_ATTR_PRETTYPRINTING:
191 bRet = sal_True;
192 if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_DOPRETTYPRINTING))
193 if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_PRETTYPRINTING ), aSaveOptions.IsPrettyPrinting())))
194 bRet = sal_False;
196 break;
197 case SID_ATTR_WARNALIENFORMAT:
199 bRet = sal_True;
200 if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_WARNALIENFORMAT))
201 if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_WARNALIENFORMAT ), aSaveOptions.IsWarnAlienFormat())))
202 bRet = sal_False;
204 break;
205 case SID_ATTR_AUTOSAVE :
207 bRet = sal_True;
208 if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_AUTOSAVE))
209 if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_AUTOSAVE ), aSaveOptions.IsAutoSave())))
210 bRet = sal_False;
212 break;
213 case SID_ATTR_AUTOSAVEPROMPT :
215 bRet = sal_True;
216 if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_AUTOSAVEPROMPT))
217 if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_AUTOSAVEPROMPT ), aSaveOptions.IsAutoSavePrompt())))
218 bRet = sal_False;
220 break;
221 case SID_ATTR_AUTOSAVEMINUTE :
223 bRet = sal_True;
224 if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_AUTOSAVETIME))
225 if (!rSet.Put( SfxUInt16Item( rPool.GetWhich( SID_ATTR_AUTOSAVEMINUTE ), (sal_uInt16)aSaveOptions.GetAutoSaveTime())))
226 bRet = sal_False;
228 break;
229 case SID_ATTR_USERAUTOSAVE :
231 bRet = sal_True;
232 if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_USERAUTOSAVE))
233 if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_USERAUTOSAVE ), aSaveOptions.IsUserAutoSave())))
234 bRet = sal_False;
236 break;
237 case SID_ATTR_DOCINFO :
239 bRet = sal_True;
240 if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_DOCINFSAVE))
241 if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_DOCINFO ), aSaveOptions.IsDocInfoSave())))
242 bRet = sal_False;
244 break;
245 case SID_ATTR_WORKINGSET :
247 bRet = sal_True;
248 if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_SAVEWORKINGSET))
249 if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_WORKINGSET ), aSaveOptions.IsSaveWorkingSet())))
250 bRet = sal_False;
252 break;
253 case SID_ATTR_SAVEDOCVIEW :
255 bRet = sal_True;
256 if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_SAVEDOCVIEW))
257 if (!rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_SAVEDOCVIEW ), aSaveOptions.IsSaveDocView())))
258 bRet = sal_False;
260 break;
261 case SID_ATTR_METRIC :
262 break;
263 case SID_HELPBALLOONS :
264 if(rSet.Put( SfxBoolItem ( rPool.GetWhich( SID_HELPBALLOONS ),
265 aHelpOptions.IsExtendedHelp() ) ) )
266 bRet = sal_True;
267 break;
268 case SID_HELPTIPS :
269 if(rSet.Put( SfxBoolItem ( rPool.GetWhich( SID_HELPTIPS ),
270 aHelpOptions.IsHelpTips() ) ) )
271 bRet = sal_True;
272 break;
273 case SID_ATTR_WELCOMESCREEN :
274 if(rSet.Put( SfxBoolItem ( rPool.GetWhich( SID_ATTR_WELCOMESCREEN ),
275 aHelpOptions.IsWelcomeScreen() ) ) )
276 bRet = sal_True;
277 break;
278 case SID_HELP_STYLESHEET :
279 if(rSet.Put( SfxStringItem ( rPool.GetWhich( SID_HELP_STYLESHEET ),
280 aHelpOptions.GetHelpStyleSheet() ) ) )
281 bRet = sal_True;
282 break;
283 case SID_ATTR_UNDO_COUNT :
284 if (rSet.Put(
285 SfxUInt16Item (
286 rPool.GetWhich(SID_ATTR_UNDO_COUNT),
287 officecfg::Office::Common::Undo::Steps::get())))
289 bRet = true;
291 break;
292 case SID_ATTR_QUICKLAUNCHER :
294 if ( ShutdownIcon::IsQuickstarterInstalled() )
296 if ( rSet.Put( SfxBoolItem( rPool.GetWhich( SID_ATTR_QUICKLAUNCHER ),
297 ShutdownIcon::GetAutostart() ) ) )
298 bRet = sal_True;
300 else
302 rSet.DisableItem( rPool.GetWhich( SID_ATTR_QUICKLAUNCHER ) );
303 bRet = sal_True;
305 break;
307 case SID_SAVEREL_INET :
309 bRet = sal_True;
310 if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_SAVERELINET))
311 if (!rSet.Put( SfxBoolItem ( rPool.GetWhich( SID_SAVEREL_INET ), aSaveOptions.IsSaveRelINet() )))
312 bRet = sal_False;
314 break;
315 case SID_SAVEREL_FSYS :
317 bRet = sal_True;
318 if (!aSaveOptions.IsReadOnly(SvtSaveOptions::E_SAVERELFSYS))
319 if (!rSet.Put( SfxBoolItem ( rPool.GetWhich( SID_SAVEREL_FSYS ), aSaveOptions.IsSaveRelFSys() )))
320 bRet = sal_False;
322 break;
323 case SID_BASIC_ENABLED :
325 bRet = sal_True;
326 if (!aSecurityOptions.IsReadOnly(SvtSecurityOptions::E_BASICMODE))
328 if ( !rSet.Put( SfxUInt16Item( rPool.GetWhich( SID_BASIC_ENABLED ), sal::static_int_cast< sal_uInt16 >(aSecurityOptions.GetBasicMode()))))
329 bRet = sal_False;
332 break;
333 case SID_INET_EXE_PLUGIN :
335 bRet = sal_True;
336 if (!aSecurityOptions.IsReadOnly(SvtSecurityOptions::E_EXECUTEPLUGINS))
338 if ( !rSet.Put( SfxBoolItem( SID_INET_EXE_PLUGIN, aSecurityOptions.IsExecutePlugins() ) ) )
339 bRet = sal_False;
342 break;
343 case SID_MACRO_WARNING :
345 bRet = sal_True;
346 if (!aSecurityOptions.IsReadOnly(SvtSecurityOptions::E_WARNING))
348 if ( !rSet.Put( SfxBoolItem( SID_MACRO_WARNING, aSecurityOptions.IsWarningEnabled() ) ) )
349 bRet = sal_False;
352 break;
353 case SID_MACRO_CONFIRMATION :
355 bRet = sal_True;
356 if (!aSecurityOptions.IsReadOnly(SvtSecurityOptions::E_CONFIRMATION))
358 if ( !rSet.Put( SfxBoolItem( SID_MACRO_CONFIRMATION, aSecurityOptions.IsConfirmationEnabled() ) ) )
359 bRet = sal_False;
362 break;
363 case SID_SECURE_URL :
365 bRet = sal_True;
366 if (!aSecurityOptions.IsReadOnly(SvtSecurityOptions::E_SECUREURLS))
368 ::com::sun::star::uno::Sequence< OUString > seqURLs = aSecurityOptions.GetSecureURLs();
369 std::vector<OUString> aList;
370 sal_uInt32 nCount = seqURLs.getLength();
371 for( sal_uInt32 nURL=0; nURL<nCount; ++nURL )
372 aList.push_back(seqURLs[nURL]);
374 if( !rSet.Put( SfxStringListItem( rPool.GetWhich(SID_SECURE_URL), &aList ) ) )
375 bRet = sal_False;
378 break;
379 case SID_INET_PROXY_TYPE :
380 if (rSet.Put(
381 SfxUInt16Item(
382 rPool.GetWhich(SID_INET_PROXY_TYPE),
383 (officecfg::Inet::Settings::ooInetProxyType::
384 get().get_value_or(0)))))
386 bRet = true;
388 break;
389 case SID_INET_HTTP_PROXY_NAME :
390 if (rSet.Put(
391 SfxStringItem(
392 rPool.GetWhich(SID_INET_HTTP_PROXY_NAME),
393 officecfg::Inet::Settings::ooInetHTTPProxyName::
394 get())))
396 bRet = true;
398 break;
399 case SID_INET_HTTP_PROXY_PORT :
400 if (rSet.Put(
401 SfxInt32Item(
402 rPool.GetWhich(SID_INET_HTTP_PROXY_PORT),
403 (officecfg::Inet::Settings::
404 ooInetHTTPProxyPort::get().get_value_or(0)))))
406 bRet = true;
408 break;
409 case SID_INET_FTP_PROXY_NAME :
410 if (rSet.Put(
411 SfxStringItem(
412 rPool.GetWhich(SID_INET_FTP_PROXY_NAME),
413 officecfg::Inet::Settings::ooInetFTPProxyName::
414 get())))
416 bRet = true;
418 break;
419 case SID_INET_FTP_PROXY_PORT :
420 if (rSet.Put(
421 SfxInt32Item(
422 rPool.GetWhich(SID_INET_FTP_PROXY_PORT),
423 (officecfg::Inet::Settings::ooInetFTPProxyPort::
424 get().get_value_or(0)))))
426 bRet = true;
428 break;
429 case SID_INET_NOPROXY :
430 if (rSet.Put(
431 SfxStringItem(
432 rPool.GetWhich( SID_INET_NOPROXY),
433 (officecfg::Inet::Settings::ooInetNoProxy::
434 get()))))
436 bRet = true;
438 break;
439 case SID_ATTR_PATHNAME :
440 case SID_ATTR_PATHGROUP :
442 SfxAllEnumItem aNames(rPool.GetWhich(SID_ATTR_PATHGROUP));
443 SfxAllEnumItem aValues(rPool.GetWhich(SID_ATTR_PATHNAME));
444 SvtPathOptions aPathCfg;
445 for ( sal_uInt16 nProp = SvtPathOptions::PATH_ADDIN;
446 nProp <= SvtPathOptions::PATH_WORK; nProp++ )
448 aNames.InsertValue( nProp, SfxResId(CONFIG_PATH_START + nProp).toString() );
449 OUString aValue;
450 switch ( nProp )
452 case SvtPathOptions::PATH_ADDIN: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg.GetAddinPath(), aValue ); break;
453 case SvtPathOptions::PATH_AUTOCORRECT: aValue = aPathCfg.GetAutoCorrectPath(); break;
454 case SvtPathOptions::PATH_AUTOTEXT: aValue = aPathCfg.GetAutoTextPath(); break;
455 case SvtPathOptions::PATH_BACKUP: aValue = aPathCfg.GetBackupPath(); break;
456 case SvtPathOptions::PATH_BASIC: aValue = aPathCfg.GetBasicPath(); break;
457 case SvtPathOptions::PATH_BITMAP: aValue = aPathCfg.GetBitmapPath(); break;
458 case SvtPathOptions::PATH_CONFIG: aValue = aPathCfg.GetConfigPath(); break;
459 case SvtPathOptions::PATH_DICTIONARY: aValue = aPathCfg.GetDictionaryPath(); break;
460 case SvtPathOptions::PATH_FAVORITES: aValue = aPathCfg.GetFavoritesPath(); break;
461 case SvtPathOptions::PATH_FILTER: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg.GetFilterPath(), aValue ); break;
462 case SvtPathOptions::PATH_GALLERY: aValue = aPathCfg.GetGalleryPath(); break;
463 case SvtPathOptions::PATH_GRAPHIC: aValue = aPathCfg.GetGraphicPath(); break;
464 case SvtPathOptions::PATH_HELP: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg.GetHelpPath(), aValue ); break;
465 case SvtPathOptions::PATH_LINGUISTIC: aValue = aPathCfg.GetLinguisticPath(); break;
466 case SvtPathOptions::PATH_MODULE: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg.GetModulePath(), aValue ); break;
467 case SvtPathOptions::PATH_PALETTE: aValue = aPathCfg.GetPalettePath(); break;
468 case SvtPathOptions::PATH_PLUGIN: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg.GetPluginPath(), aValue ); break;
469 case SvtPathOptions::PATH_STORAGE: ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aPathCfg.GetStoragePath(), aValue ); break;
470 case SvtPathOptions::PATH_TEMP: aValue = aPathCfg.GetTempPath(); break;
471 case SvtPathOptions::PATH_TEMPLATE: aValue = aPathCfg.GetTemplatePath(); break;
472 case SvtPathOptions::PATH_USERCONFIG: aValue = aPathCfg.GetUserConfigPath(); break;
473 case SvtPathOptions::PATH_WORK: aValue = aPathCfg.GetWorkPath(); break;
475 aValues.InsertValue( nProp, aValue );
478 if ( rSet.Put(aNames) || rSet.Put(aValues) )
479 bRet = sal_True;
482 default:
483 DBG_WARNING( "W1:Wrong ID while getting Options!" );
484 break;
486 #ifdef DBG_UTIL
487 if ( !bRet )
488 OSL_FAIL( "Putting options failed!" );
489 #endif
491 pRanges++;
494 return bRet;
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 boost::shared_ptr< comphelper::ConfigurationChanges > batch(
508 comphelper::ConfigurationChanges::create());
509 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_BUTTON_OUTSTYLE3D), sal_True, &pItem) )
511 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
512 sal_uInt16 nOutStyle =
513 ( (const SfxBoolItem *)pItem)->GetValue() ? 0 : TOOLBOX_STYLE_FLAT;
514 aMiscOptions.SetToolboxStyle( nOutStyle );
517 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_BUTTON_BIGSIZE), sal_True, &pItem) )
519 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
520 sal_Bool bBigSize = ( (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(sal_True);
530 pCurrViewFrame = SfxViewFrame::GetNext(*pCurrViewFrame);
534 // Backup
535 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_BACKUP), sal_True, &pItem) )
537 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
538 aSaveOptions.SetBackup( ( (const SfxBoolItem*)pItem )->GetValue() );
541 // PrettyPrinting
542 if ( SFX_ITEM_SET == rSet.GetItemState( rPool.GetWhich( SID_ATTR_PRETTYPRINTING ), sal_True, &pItem ) )
544 DBG_ASSERT( pItem->ISA( SfxBoolItem ), "BoolItem expected" );
545 aSaveOptions.SetPrettyPrinting( static_cast< const SfxBoolItem*> ( pItem )->GetValue() );
548 // WarnAlienFormat
549 if ( SFX_ITEM_SET == rSet.GetItemState( rPool.GetWhich( SID_ATTR_WARNALIENFORMAT ), sal_True, &pItem ) )
551 DBG_ASSERT( pItem->ISA( SfxBoolItem ), "BoolItem expected" );
552 aSaveOptions.SetWarnAlienFormat( static_cast< const SfxBoolItem*> ( pItem )->GetValue() );
555 // AutoSave
556 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_AUTOSAVE), sal_True, &pItem))
558 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
559 aSaveOptions.SetAutoSave( ( (const SfxBoolItem*)pItem )->GetValue() );
562 // AutoSave-Propt
563 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_AUTOSAVEPROMPT), sal_True, &pItem))
565 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
566 aSaveOptions.SetAutoSavePrompt(((const SfxBoolItem *)pItem)->GetValue());
569 // AutoSave-Time
570 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_AUTOSAVEMINUTE), sal_True, &pItem))
572 DBG_ASSERT(pItem->ISA(SfxUInt16Item), "UInt16Item expected");
573 aSaveOptions.SetAutoSaveTime(((const SfxUInt16Item *)pItem)->GetValue());
576 // UserAutoSave
577 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_USERAUTOSAVE), sal_True, &pItem))
579 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
580 aSaveOptions.SetUserAutoSave( ( (const SfxBoolItem*)pItem )->GetValue() );
583 // DocInfo
584 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_DOCINFO), sal_True, &pItem))
586 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
587 aSaveOptions.SetDocInfoSave(((const SfxBoolItem *)pItem)->GetValue());
590 // Mark open Documents
591 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_WORKINGSET), sal_True, &pItem))
593 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
594 aSaveOptions.SetSaveWorkingSet(((const SfxBoolItem *)pItem)->GetValue());
597 // Save window settings
598 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_SAVEDOCVIEW), sal_True, &pItem))
600 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
601 aSaveOptions.SetSaveDocView(((const SfxBoolItem *)pItem)->GetValue());
604 // Metric
605 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_METRIC), sal_True, &pItem))
607 DBG_ASSERT(pItem->ISA(SfxUInt16Item), "UInt16Item expected");
610 // HelpBalloons
611 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_HELPBALLOONS), sal_True, &pItem))
613 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
614 aHelpOptions.SetExtendedHelp(((const SfxBoolItem *)pItem)->GetValue());
617 // HelpTips
618 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_HELPTIPS), sal_True, &pItem))
620 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
621 aHelpOptions.SetHelpTips(((const SfxBoolItem *)pItem)->GetValue());
624 // WelcomeScreen
625 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_WELCOMESCREEN ), sal_True, &pItem))
627 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
628 aHelpOptions.SetWelcomeScreen( ((const SfxBoolItem *)pItem)->GetValue() );
631 // WelcomeScreen
632 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_WELCOMESCREEN_RESET ), sal_True, &pItem))
634 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
635 sal_Bool bReset = ((const SfxBoolItem *)pItem)->GetValue();
636 if ( bReset )
638 OSL_FAIL( "Not implemented, may be EOL!" );
641 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_HELP_STYLESHEET ), sal_True, &pItem))
643 DBG_ASSERT(pItem->ISA(SfxStringItem), "StringItem expected");
644 aHelpOptions.SetHelpStyleSheet( ((const SfxStringItem *)pItem)->GetValue() );
647 // SaveRelINet
648 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_SAVEREL_INET), sal_True, &pItem))
650 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
651 aSaveOptions.SetSaveRelINet(((const SfxBoolItem *)pItem)->GetValue());
654 // SaveRelFSys
655 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_SAVEREL_FSYS), sal_True, &pItem))
657 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
658 aSaveOptions.SetSaveRelFSys(((const SfxBoolItem *)pItem)->GetValue());
661 // Undo-Count
662 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_UNDO_COUNT), sal_True, &pItem))
664 DBG_ASSERT(pItem->ISA(SfxUInt16Item), "UInt16Item expected");
665 sal_uInt16 nUndoCount = ((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();
670 pFrame;
671 pFrame = SfxViewFrame::GetNext(*pFrame) )
673 // Get the Dispatcher of the Frames
674 SfxDispatcher *pDispat = pFrame->GetDispatcher();
675 pDispat->Flush();
677 // Iterate over all SfxShells on the Dispatchers Stack
678 sal_uInt16 nIdx = 0;
679 for ( SfxShell *pSh = pDispat->GetShell(nIdx);
680 pSh;
681 ++nIdx, pSh = pDispat->GetShell(nIdx) )
683 ::svl::IUndoManager *pShUndoMgr = pSh->GetUndoManager();
684 if ( pShUndoMgr )
685 pShUndoMgr->SetMaxUndoActionCount( nUndoCount );
690 // Office autostart
691 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_QUICKLAUNCHER), sal_True, &pItem))
693 DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected");
694 ShutdownIcon::SetAutostart( ( (const SfxBoolItem*)pItem )->GetValue() != sal_False );
697 // StarBasic Enable
698 if ( SFX_ITEM_SET == rSet.GetItemState(SID_BASIC_ENABLED, sal_True, &pItem))
700 DBG_ASSERT(pItem->ISA(SfxUInt16Item), "SfxInt16Item expected");
701 aSecurityOptions.SetBasicMode( (EBasicSecurityMode)( (const SfxUInt16Item*)pItem )->GetValue() );
704 // Execute PlugIns
705 if ( SFX_ITEM_SET == rSet.GetItemState(SID_INET_EXE_PLUGIN, sal_True, &pItem))
707 DBG_ASSERT(pItem->ISA(SfxBoolItem), "SfxBoolItem expected");
708 aSecurityOptions.SetExecutePlugins( ( (const SfxBoolItem *)pItem )->GetValue() );
711 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_INET_PROXY_TYPE), sal_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 ( SFX_ITEM_SET == rSet.GetItemState( rPool.GetWhich( SID_INET_HTTP_PROXY_NAME ), sal_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 ( SFX_ITEM_SET == rSet.GetItemState( rPool.GetWhich( SID_INET_HTTP_PROXY_PORT ), sal_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 ( SFX_ITEM_SET == rSet.GetItemState( rPool.GetWhich( SID_INET_FTP_PROXY_NAME ), sal_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 ( SFX_ITEM_SET == rSet.GetItemState( rPool.GetWhich( SID_INET_FTP_PROXY_PORT ), sal_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 ( SFX_ITEM_SET == rSet.GetItemState(SID_INET_NOPROXY, sal_True, &pItem))
744 DBG_ASSERT(pItem->ISA(SfxStringItem), "StringItem expected");
745 officecfg::Inet::Settings::ooInetNoProxy::set(
746 static_cast< SfxStringItem const * >(pItem)->GetValue(), batch);
749 // Secure-Referers
750 if ( SFX_ITEM_SET == rSet.GetItemState(SID_SECURE_URL, sal_True, &pItem))
752 DBG_ASSERT(pItem->ISA(SfxStringListItem), "StringListItem expected");
753 ::com::sun::star::uno::Sequence< OUString > seqURLs;
754 ((SfxStringListItem*)pItem)->GetStringList(seqURLs);
755 aSecurityOptions.SetSecureURLs( seqURLs );
758 if ( SFX_ITEM_SET == rSet.GetItemState(SID_MACRO_WARNING, sal_True, &pItem))
760 DBG_ASSERT(pItem->ISA(SfxBoolItem), "SfxBoolItem expected");
761 aSecurityOptions.SetWarningEnabled( ( (const SfxBoolItem *)pItem )->GetValue() );
763 if ( SFX_ITEM_SET == rSet.GetItemState(SID_MACRO_CONFIRMATION, sal_True, &pItem))
765 DBG_ASSERT(pItem->ISA(SfxBoolItem), "SfxBoolItem expected");
766 aSecurityOptions.SetConfirmationEnabled( ( (const SfxBoolItem *)pItem )->GetValue() );
769 // Store changed data
770 batch->commit();
773 //--------------------------------------------------------------------
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 );
784 // PathName
785 if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_PATHNAME), sal_True, &pItem))
787 DBG_ASSERT(pItem->ISA(SfxAllEnumItem), "AllEnumItem expected");
788 const SfxAllEnumItem* pEnumItem = (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 )
796 switch( nPath )
798 case SvtPathOptions::PATH_ADDIN:
800 OUString aTmp;
801 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue, aTmp ) )
802 aPathOptions.SetAddinPath( aTmp );
803 break;
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:
816 OUString aTmp;
817 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue, aTmp ) )
818 aPathOptions.SetFilterPath( aTmp );
819 break;
821 case SvtPathOptions::PATH_GALLERY: aPathOptions.SetGalleryPath( sValue );break;
822 case SvtPathOptions::PATH_GRAPHIC: aPathOptions.SetGraphicPath( sValue );break;
823 case SvtPathOptions::PATH_HELP:
825 OUString aTmp;
826 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue, aTmp ) )
827 aPathOptions.SetHelpPath( aTmp );
828 break;
831 case SvtPathOptions::PATH_LINGUISTIC: aPathOptions.SetLinguisticPath( sValue );break;
832 case SvtPathOptions::PATH_MODULE:
834 OUString aTmp;
835 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue, aTmp ) )
836 aPathOptions.SetModulePath( aTmp );
837 break;
840 case SvtPathOptions::PATH_PALETTE: aPathOptions.SetPalettePath( sValue );break;
841 case SvtPathOptions::PATH_PLUGIN:
843 OUString aTmp;
844 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue, aTmp ) )
845 aPathOptions.SetPluginPath( aTmp );
846 break;
849 case SvtPathOptions::PATH_STORAGE:
851 OUString aTmp;
852 if( ::utl::LocalFileHelper::ConvertURLToPhysicalName( sValue, aTmp ) )
853 aPathOptions.SetStoragePath( aTmp );
854 break;
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 );
871 // Undo-Count
872 Broadcast( SfxItemSetHint( rSet ) );
875 //--------------------------------------------------------------------
876 void SfxApplication::NotifyEvent( const SfxEventHint& rEventHint, bool bSynchron )
878 SfxObjectShell *pDoc = rEventHint.GetObjShell();
879 if ( pDoc && ( pDoc->IsPreview() || !pDoc->Get_Impl()->bInitialized ) )
880 return;
882 if ( bSynchron )
884 #ifdef DBG_UTIL
885 if (!pDoc)
887 OStringBuffer aTmp("SfxEvent: ");
888 aTmp.append(OUStringToOString(rEventHint.GetEventName(), RTL_TEXTENCODING_UTF8));
889 OSL_TRACE( "%s", aTmp.getStr() );
891 #endif
892 Broadcast(rEventHint);
893 if ( pDoc )
894 pDoc->Broadcast( rEventHint );
896 else
897 new SfxEventAsyncer_Impl( rEventHint );
900 IMPL_OBJHINT( SfxStringHint, OUString )
902 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */