bump product version to 4.2.0.1
[LibreOffice.git] / sfx2 / source / appl / appserv.cxx
blob4ba407c030aaf6e912b9ca3d00e98b5294aba7fe
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/document/XEmbeddedScripts.hpp>
21 #include <com/sun/star/drawing/ModuleDispatcher.hpp>
22 #include <com/sun/star/embed/XStorage.hpp>
23 #include <com/sun/star/embed/ElementModes.hpp>
24 #include <com/sun/star/frame/Desktop.hpp>
25 #include <com/sun/star/frame/DispatchResultEvent.hpp>
26 #include <com/sun/star/frame/DispatchResultState.hpp>
27 #include <com/sun/star/frame/DispatchHelper.hpp>
28 #include <com/sun/star/frame/XDesktop.hpp>
29 #include <com/sun/star/frame/XFramesSupplier.hpp>
30 #include <com/sun/star/frame/XLayoutManager.hpp>
31 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
32 #include <com/sun/star/lang/IllegalArgumentException.hpp>
33 #include <com/sun/star/sdbc/DriverManager.hpp>
34 #include <com/sun/star/system/SystemShellExecute.hpp>
35 #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
36 #include <com/sun/star/system/SystemShellExecuteException.hpp>
37 #include <com/sun/star/task/XJobExecutor.hpp>
38 #include <com/sun/star/text/ModuleDispatcher.hpp>
39 #include <com/sun/star/ui/dialogs/AddressBookSourcePilot.hpp>
40 #include <com/sun/star/uno/Reference.hxx>
41 #include <com/sun/star/util/XCloseable.hpp>
42 #include <com/sun/star/util/CloseVetoException.hpp>
43 #include <org/freedesktop/PackageKit/SyncDbusSessionHelper.hpp>
45 #include <com/sun/star/frame/XComponentLoader.hpp>
47 #include <comphelper/processfactory.hxx>
48 #include <comphelper/storagehelper.hxx>
50 #include <svtools/addresstemplate.hxx>
51 #include <svtools/miscopt.hxx>
52 #include <svtools/restartdialog.hxx>
53 #include <svl/visitem.hxx>
54 #include <unotools/intlwrapper.hxx>
56 #include <unotools/configmgr.hxx>
57 #include <tools/diagnose_ex.h>
58 #include <vcl/msgbox.hxx>
59 #include <svl/intitem.hxx>
60 #include <svl/eitem.hxx>
61 #include <svl/stritem.hxx>
62 #include <basic/sbstar.hxx>
63 #include <basic/basmgr.hxx>
64 #include <basic/basrdll.hxx>
65 #include <svtools/sfxecode.hxx>
66 #include <svtools/ehdl.hxx>
67 #include <vcl/help.hxx>
68 #include <vcl/stdtext.hxx>
69 #include <rtl/ustrbuf.hxx>
70 #include <osl/file.hxx>
72 #include <unotools/pathoptions.hxx>
73 #include <unotools/moduleoptions.hxx>
74 #include <svtools/helpopt.hxx>
75 #include <toolkit/helper/vclunohelper.hxx>
76 #include <tools/shl.hxx>
77 #include <unotools/bootstrap.hxx>
78 #include <rtl/bootstrap.hxx>
79 #include <cppuhelper/exc_hlp.hxx>
81 #include <com/sun/star/script/provider/XScriptProviderFactory.hpp>
82 #include <com/sun/star/frame/ModuleManager.hpp>
83 #include <com/sun/star/beans/XPropertySet.hpp>
85 #include "frmload.hxx"
86 #include <sfx2/app.hxx>
87 #include <sfx2/request.hxx>
88 #include <sfx2/dispatch.hxx>
89 #include <sfx2/bindings.hxx>
90 #include <sfx2/msg.hxx>
91 #include <sfx2/objface.hxx>
92 #include <sfx2/objitem.hxx>
93 #include <sfx2/objsh.hxx>
94 #include <sfx2/hintpost.hxx>
95 #include <sfx2/viewsh.hxx>
96 #include <sfx2/docfac.hxx>
97 #include <sfx2/docfile.hxx>
98 #include <sfx2/docfilt.hxx>
99 #include <sfx2/new.hxx>
100 #include "sfxtypes.hxx"
101 #include <sfx2/tabdlg.hxx>
102 #include "arrdecl.hxx"
103 #include <sfx2/sfx.hrc>
104 #include "app.hrc"
105 #include <sfx2/passwd.hxx>
106 #include <sfx2/sfxresid.hxx>
107 #include <sfx2/childwin.hxx>
108 #include "appdata.hxx"
109 #include <sfx2/minfitem.hxx>
110 #include <sfx2/event.hxx>
111 #include <sfx2/module.hxx>
112 #include <sfx2/viewfrm.hxx>
113 #include "sfxpicklist.hxx"
114 #include "imestatuswindow.hxx"
115 #include <sfx2/sfxdlg.hxx>
116 #include <sfx2/dialogs.hrc>
117 #include "sorgitm.hxx"
118 #include <sfx2/sfxhelp.hxx>
119 #include <sfx2/zoomitem.hxx>
120 #include "templatedlg.hxx"
122 #include <officecfg/Office/Common.hxx>
123 #include <officecfg/Setup.hxx>
125 using namespace ::com::sun::star;
126 using namespace ::com::sun::star::beans;
127 using namespace ::com::sun::star::uno;
128 using namespace ::com::sun::star::frame;
129 using namespace ::com::sun::star::container;
130 using namespace ::com::sun::star::util;
131 using namespace ::com::sun::star::script;
132 using namespace ::com::sun::star::system;
133 using namespace ::com::sun::star::lang;
134 using namespace ::com::sun::star::document;
136 namespace
138 // lp#527938, debian#602953, fdo#33266, i#105408
139 static bool lcl_isBaseAvailable()
143 // if we get com::sun::star::sdbc::DriverManager, libsdbc2 is there
144 // and the bibliography is assumed to work
145 return com::sun::star::sdbc::DriverManager::create(comphelper::getProcessComponentContext()).is();
147 catch (Exception & e)
149 SAL_INFO(
150 "sfx.appl",
151 "assuming Base to be missing; caught " << e.Message);
152 return false;
155 static void lcl_tryLoadBibliography()
157 // lp#527938, debian#602953, fdo#33266, i#105408
158 // make sure we actually can instanciate services from base first
159 if(!lcl_isBaseAvailable())
163 using namespace org::freedesktop::PackageKit;
164 using namespace svtools;
165 Reference< XSyncDbusSessionHelper > xSyncDbusSessionHelper(SyncDbusSessionHelper::create(comphelper::getProcessComponentContext()));
166 Sequence< OUString > vPackages(1);
167 vPackages[0] = "libreoffice-base";
168 OUString sInteraction;
169 xSyncDbusSessionHelper->InstallPackageNames(0, vPackages, sInteraction);
170 // Ill be back (hopefully)!
171 SolarMutexGuard aGuard;
172 executeRestartDialog(comphelper::getProcessComponentContext(), NULL, RESTART_REASON_BIBLIOGRAPHY_INSTALL);
174 catch (const Exception & e)
176 SAL_INFO(
177 "sfx.appl",
178 "trying to install LibreOffice Base, caught " << e.Message);
180 return;
183 try // fdo#48775
185 SfxStringItem aURL(SID_FILE_NAME, OUString(".component:Bibliography/View1"));
186 SfxStringItem aRef(SID_REFERER, OUString("private:user"));
187 SfxStringItem aTarget(SID_TARGETNAME, OUString("_blank"));
188 SfxViewFrame::Current()->GetDispatcher()->Execute( SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, &aURL, &aRef, &aTarget, 0L);
190 catch (const Exception & e)
192 SAL_INFO( "sfx.appl",
193 "trying to load bibliography database, caught " << e.Message);
197 /// Find the correct location of the document (LICENSE.fodt, etc.), and return
198 /// it in rURL if found.
199 static sal_Bool checkURL( const char *pName, const char *pExt, OUString &rURL )
201 using namespace osl;
202 DirectoryItem aDirItem;
204 rURL = "$BRAND_BASE_DIR/" + OUString::createFromAscii( pName ) +
205 OUString::createFromAscii( pExt );
206 rtl::Bootstrap::expandMacros( rURL );
208 if (!rURL.isEmpty())
209 return DirectoryItem::get( rURL, aDirItem ) == DirectoryItem::E_None;
210 else
211 return sal_False;
214 /// Displays CREDITS or LICENSE in any of the available version
215 static void showDocument( const char* pBaseName )
217 try {
218 Reference < XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() );
219 Sequence < com::sun::star::beans::PropertyValue > args(2);
220 args[0].Name = "ViewOnly";
221 args[0].Value <<= sal_True;
222 args[1].Name = "ReadOnly";
223 args[1].Value <<= sal_True;
225 OUString aURL;
226 if ( checkURL ( pBaseName, ".fodt", aURL ) ||
227 checkURL ( pBaseName, ".html", aURL ) ||
228 checkURL ( pBaseName, "", aURL ) ) {
229 xDesktop->loadComponentFromURL( aURL, OUString("_blank"), 0, args );
231 } catch (const ::com::sun::star::uno::Exception &) {
235 namespace
237 class LicenseDialog : public ModalDialog
239 private:
240 DECL_LINK(ShowHdl, void *);
241 public:
242 LicenseDialog(Window *pParent=NULL);
245 LicenseDialog::LicenseDialog(Window *pParent)
246 : ModalDialog(pParent, "LicenseDialog", "sfx/ui/licensedialog.ui")
248 get<PushButton>("show")->SetClickHdl(LINK(this, LicenseDialog, ShowHdl));
251 IMPL_LINK_NOARG(LicenseDialog, ShowHdl)
253 EndDialog(RET_OK);
254 showDocument("LICENSE");
255 return 0;
259 void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
261 bool bDone = false;
262 switch ( rReq.GetSlot() )
264 case SID_SETOPTIONS:
266 if( rReq.GetArgs() )
267 SetOptions_Impl( *rReq.GetArgs() );
268 break;
271 case SID_QUITAPP:
272 case SID_EXITANDRETURN:
273 case SID_LOGOUT:
275 // protect against reentrant calls
276 if ( pAppData_Impl->bInQuit )
277 return;
279 if ( rReq.GetSlot() == SID_LOGOUT )
281 for ( SfxObjectShell *pObjSh = SfxObjectShell::GetFirst();
282 pObjSh; pObjSh = SfxObjectShell::GetNext( *pObjSh ) )
284 if ( !pObjSh->IsModified() )
285 continue;
287 SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pObjSh );
288 if ( !pFrame || !pFrame->GetWindow().IsReallyVisible() )
289 continue;
291 if ( pObjSh->PrepareClose(2) )
292 pObjSh->SetModified( sal_False );
293 else
294 return;
297 SfxStringItem aNameItem( SID_FILE_NAME, OUString("vnd.sun.star.cmd:logout") );
298 SfxStringItem aReferer( SID_REFERER, "private/user" );
299 pAppData_Impl->pAppDispat->Execute( SID_OPENDOC, SFX_CALLMODE_SLOT, &aNameItem, &aReferer, 0L );
300 return;
303 // aus verschachtelten Requests nach 100ms nochmal probieren
304 if( Application::GetDispatchLevel() > 1 )
306 /* Dont save the request for closing the application and try it later
307 again. This is an UI bound functionality ... and the user will try it again
308 if the dialog is closed. But we should not close the application automaticly
309 if this dialog is closed by the user ...
310 So we ignore this request now and wait for a new user decision.
312 OSL_TRACE( "QueryExit => sal_False (DispatchLevel == %u)", Application::GetDispatchLevel() );
313 return;
316 // block reentrant calls
317 pAppData_Impl->bInQuit = sal_True;
318 Reference < XDesktop2 > xDesktop = Desktop::create ( ::comphelper::getProcessComponentContext() );
320 rReq.ForgetAllArgs();
322 // if terminate() failed, pAppData_Impl->bInQuit will now be sal_False, allowing further calls of SID_QUITAPP
323 sal_Bool bTerminated = xDesktop->terminate();
324 if (!bTerminated)
325 // if terminate() was successful, SfxApplication is now dead!
326 pAppData_Impl->bInQuit = sal_False;
328 // Set return value, terminate if possible
329 rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bTerminated ) );
330 return;
333 case SID_CONFIG:
334 case SID_TOOLBOXOPTIONS:
335 case SID_CONFIGSTATUSBAR:
336 case SID_CONFIGMENU:
337 case SID_CONFIGACCEL:
338 case SID_CONFIGEVENT:
340 SfxAbstractDialogFactory* pFact =
341 SfxAbstractDialogFactory::Create();
343 if ( pFact )
345 SFX_REQUEST_ARG(rReq, pStringItem,
346 SfxStringItem, SID_CONFIG, sal_False);
348 SfxItemSet aSet(
349 GetPool(), SID_CONFIG, SID_CONFIG );
351 if ( pStringItem )
353 aSet.Put( SfxStringItem(
354 SID_CONFIG, pStringItem->GetValue() ) );
357 Reference< XFrame > xFrame;
358 const SfxItemSet* pIntSet = rReq.GetInternalArgs_Impl();
359 SFX_ITEMSET_ARG( pIntSet, pFrameItem, SfxUnoFrameItem, SID_FILLFRAME, sal_False );
360 if ( pFrameItem )
361 xFrame = pFrameItem->GetFrame();
363 SfxAbstractTabDialog* pDlg = pFact->CreateTabDialog(
364 RID_SVXDLG_CUSTOMIZE,
365 NULL, &aSet, xFrame );
367 if ( pDlg )
369 const short nRet = pDlg->Execute();
371 if ( nRet )
372 bDone = true;
374 delete pDlg;
377 break;
380 case SID_CLOSEDOCS:
381 case SID_CLOSEWINS:
384 Reference < XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() );
385 Reference< XIndexAccess > xTasks( xDesktop->getFrames(), UNO_QUERY );
386 if ( !xTasks.is() )
387 break;
389 sal_Int32 n=0;
392 if ( xTasks->getCount() <= n )
393 break;
395 Any aAny = xTasks->getByIndex(n);
396 Reference < XCloseable > xTask;
397 aAny >>= xTask;
400 xTask->close(sal_True);
401 n++;
403 catch( CloseVetoException& )
407 while( true );
409 sal_Bool bOk = ( n == 0);
410 rReq.SetReturnValue( SfxBoolItem( 0, bOk ) );
411 bDone = true;
412 break;
415 case SID_SAVEDOCS:
417 sal_Bool bOK = sal_True;
418 for ( SfxObjectShell *pObjSh = SfxObjectShell::GetFirst();
419 pObjSh;
420 pObjSh = SfxObjectShell::GetNext( *pObjSh ) )
422 SfxRequest aReq( SID_SAVEDOC, 0, pObjSh->GetPool() );
423 if ( pObjSh->IsModified() )
425 pObjSh->ExecuteSlot( aReq );
426 SfxBoolItem *pItem = PTR_CAST( SfxBoolItem, aReq.GetReturnValue() );
427 if ( !pItem || !pItem->GetValue() )
428 bOK = sal_False;
432 rReq.SetReturnValue( SfxBoolItem( 0, bOK ) );
433 rReq.Done();
434 break;
437 case SID_SEND_FEEDBACK:
439 OUString module = SfxHelp::GetCurrentModuleIdentifier();
440 OUString sURL("http://hub.libreoffice.org/send-feedback/?LOversion=" + utl::ConfigManager::getAboutBoxProductVersion() +
441 "&LOlocale=" + utl::ConfigManager::getLocale() + "&LOmodule=" + module.copy(module.lastIndexOf('.') + 1 ) );
444 uno::Reference< com::sun::star::system::XSystemShellExecute > xSystemShellExecute(
445 com::sun::star::system::SystemShellExecute::create(::comphelper::getProcessComponentContext()) );
446 xSystemShellExecute->execute( sURL, OUString(), com::sun::star::system::SystemShellExecuteFlags::URIS_ONLY );
448 catch ( uno::Exception& )
451 break;
454 case SID_SHOW_LICENSE:
456 LicenseDialog aDialog;
457 aDialog.Execute();
458 break;
461 case SID_SHOW_CREDITS:
463 showDocument( "CREDITS" );
464 break;
467 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
468 case SID_HELPINDEX:
470 Help* pHelp = Application::GetHelp();
471 if ( pHelp )
473 pHelp->Start( OUString(".uno:HelpIndex"), NULL ); // show start page
474 bDone = true;
476 break;
479 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
480 case SID_HELPTIPS:
482 // Evaluate Parameter
483 SFX_REQUEST_ARG(rReq, pOnItem, SfxBoolItem, SID_HELPTIPS, sal_False);
484 bool bOn = pOnItem
485 ? ((SfxBoolItem*)pOnItem)->GetValue()
486 : !Help::IsQuickHelpEnabled();
488 if ( bOn )
489 Help::EnableQuickHelp();
490 else
491 Help::DisableQuickHelp();
492 SvtHelpOptions().SetHelpTips( bOn );
493 Invalidate(SID_HELPTIPS);
494 bDone = true;
496 // Record if possible
497 if ( !rReq.IsAPI() )
498 rReq.AppendItem( SfxBoolItem( SID_HELPTIPS, bOn) );
499 break;
501 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
502 case SID_EXTENDEDHELP:
504 Help::StartExtHelp();
505 break;
507 case SID_HELPBALLOONS:
509 // Evaluate Parameter
510 SFX_REQUEST_ARG(rReq, pOnItem, SfxBoolItem, SID_HELPBALLOONS, sal_False);
511 bool bOn = pOnItem
512 ? ((SfxBoolItem*)pOnItem)->GetValue()
513 : !Help::IsBalloonHelpEnabled();
515 if ( bOn )
516 Help::EnableBalloonHelp();
517 else
518 Help::DisableBalloonHelp();
519 SvtHelpOptions().SetExtendedHelp( bOn );
520 Invalidate(SID_HELPBALLOONS);
521 bDone = true;
523 // Record if possible
524 if ( !rReq.IsAPI() )
525 rReq.AppendItem( SfxBoolItem( SID_HELPBALLOONS, bOn) );
526 break;
529 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
530 case SID_ABOUT:
532 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
533 if ( pFact )
535 VclAbstractDialog* pDlg = pFact->CreateVclDialog( 0, RID_DEFAULTABOUT );
536 pDlg->Execute();
537 delete pDlg;
538 bDone = true;
540 break;
543 case SID_TEMPLATE_MANAGER:
545 SfxTemplateManagerDlg dlg;
546 dlg.Execute();
547 bDone = true;
548 break;
551 case SID_TEMPLATE_ADDRESSBOKSOURCE:
553 svt::AddressBookSourceDialog aDialog(GetTopWindow(), ::comphelper::getProcessComponentContext());
554 aDialog.Execute();
555 bDone = true;
556 break;
559 #ifndef DISABLE_SCRIPTING
560 case SID_BASICSTOP:
561 StarBASIC::Stop();
562 break;
564 case SID_BASICBREAK :
565 BASIC_DLL()->BasicBreak();
566 break;
567 #endif
569 case SID_CRASH :
571 // Provoke a crash:
572 char * crash = 0;
573 *crash = 0;
574 break;
577 case SID_SHOW_IME_STATUS_WINDOW:
578 if (pAppData_Impl->m_xImeStatusWindow->canToggle())
580 SfxBoolItem const * pItem = static_cast< SfxBoolItem const * >(
581 rReq.GetArg(SID_SHOW_IME_STATUS_WINDOW, false,
582 TYPE(SfxBoolItem)));
583 bool bShow = pItem == 0
584 ? !pAppData_Impl->m_xImeStatusWindow->isShowing()
585 : ( pItem->GetValue() == sal_True );
586 pAppData_Impl->m_xImeStatusWindow->show(bShow);
587 if (pItem == 0)
588 rReq.AppendItem(SfxBoolItem(SID_SHOW_IME_STATUS_WINDOW,
589 bShow));
591 bDone = true;
592 break;
594 case SID_ZOOM_50_PERCENT:
595 case SID_ZOOM_75_PERCENT:
596 case SID_ZOOM_100_PERCENT:
597 case SID_ZOOM_150_PERCENT:
598 case SID_ZOOM_200_PERCENT:
599 case SID_ZOOM_OPTIMAL:
600 case SID_ZOOM_ENTIRE_PAGE:
601 case SID_ZOOM_PAGE_WIDTH:
603 SfxObjectShell* pCurrentShell = SfxObjectShell::Current();
604 if (!pCurrentShell)
605 return;
607 // make sure aZoom is initialized with a proper value if SetType
608 // doesn't work
609 SvxZoomItem aZoom( SVX_ZOOM_PERCENT, 100 );
611 switch (rReq.GetSlot())
613 case SID_ZOOM_50_PERCENT:
614 aZoom.SetValue(50);
615 break;
616 case SID_ZOOM_75_PERCENT:
617 aZoom.SetValue(75);
618 break;
619 case SID_ZOOM_100_PERCENT:
620 aZoom.SetValue(100);
621 break;
622 case SID_ZOOM_150_PERCENT:
623 aZoom.SetValue(150);
624 break;
625 case SID_ZOOM_200_PERCENT:
626 aZoom.SetValue(200);
627 break;
628 case SID_ZOOM_OPTIMAL:
629 aZoom.SetType( SVX_ZOOM_OPTIMAL );
630 break;
631 case SID_ZOOM_ENTIRE_PAGE:
632 aZoom.SetType( SVX_ZOOM_WHOLEPAGE );
633 break;
634 case SID_ZOOM_PAGE_WIDTH:
635 aZoom.SetType( SVX_ZOOM_PAGEWIDTH );
636 break;
639 pCurrentShell->GetDispatcher()->Execute(SID_ATTR_ZOOM, SFX_CALLMODE_ASYNCHRON, &aZoom, 0L);
641 break;
643 case SID_AVAILABLE_TOOLBARS:
645 SfxStringItem const * pToolbarName = static_cast< SfxStringItem const *>(
646 rReq.GetArg(SID_AVAILABLE_TOOLBARS, false, TYPE(SfxStringItem)));
648 if ( pToolbarName )
650 Reference < XDesktop2 > xDesktop = Desktop::create ( ::comphelper::getProcessComponentContext() );
651 Reference< XFrame > xFrame = xDesktop->getActiveFrame();
653 Reference< com::sun::star::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY );
654 Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
655 if ( xPropSet.is() )
659 Any aValue = xPropSet->getPropertyValue("LayoutManager");
660 aValue >>= xLayoutManager;
662 catch ( const ::com::sun::star::uno::RuntimeException& )
664 throw;
666 catch ( ::com::sun::star::uno::Exception& )
671 if ( xLayoutManager.is() )
673 OUString aToolbarResName( "private:resource/toolbar/" );
674 OUStringBuffer aBuf( aToolbarResName );
675 aBuf.append( pToolbarName->GetValue() );
677 // Evaluate Parameter
678 OUString aToolbarName( aBuf.makeStringAndClear() );
679 sal_Bool bShow( !xLayoutManager->isElementVisible( aToolbarName ));
681 if ( bShow )
683 xLayoutManager->createElement( aToolbarName );
684 xLayoutManager->showElement( aToolbarName );
686 else
687 xLayoutManager->hideElement( aToolbarName );
691 bDone = true;
692 break;
695 default:
696 break;
699 if ( bDone )
700 rReq.Done();
703 //--------------------------------------------------------------------
705 void SfxApplication::MiscState_Impl(SfxItemSet &rSet)
707 const sal_uInt16 *pRanges = rSet.GetRanges();
708 DBG_ASSERT(pRanges && *pRanges, "Set without range");
709 while ( *pRanges )
711 for(sal_uInt16 nWhich = *pRanges++; nWhich <= *pRanges; ++nWhich)
713 switch(nWhich)
715 case SID_TEMPLATE_ADDRESSBOKSOURCE:
716 if ( !SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SDATABASE) )
717 rSet.Put(SfxVisibilityItem(nWhich, sal_False));
718 break;
719 case SID_EXITANDRETURN:
720 case SID_QUITAPP:
722 if ( pAppData_Impl->nDocModalMode )
723 rSet.DisableItem(nWhich);
724 else
725 rSet.Put(SfxStringItem(nWhich, SfxResId(STR_QUITAPP).toString()));
726 break;
729 case SID_CONFIG:
730 case SID_TOOLBOXOPTIONS:
731 case SID_CONFIGSTATUSBAR:
732 case SID_CONFIGMENU:
733 case SID_CONFIGACCEL:
734 case SID_CONFIGEVENT:
736 if( SvtMiscOptions().DisableUICustomization() )
737 rSet.DisableItem(nWhich);
738 break;
741 #ifndef DISABLE_SCRIPTING
742 case SID_BASICSTOP:
743 if ( !StarBASIC::IsRunning() )
744 rSet.DisableItem(nWhich);
745 break;
746 #endif
748 case SID_HELPTIPS:
750 rSet.Put( SfxBoolItem( SID_HELPTIPS, Help::IsQuickHelpEnabled() ) );
752 break;
753 case SID_HELPBALLOONS:
755 rSet.Put( SfxBoolItem( SID_HELPBALLOONS, Help::IsBalloonHelpEnabled() ) );
757 break;
759 case SID_EXTENDEDHELP:
762 break;
764 case SID_CLOSEDOCS:
765 case SID_CLOSEWINS:
767 Reference < XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() );
768 Reference< XIndexAccess > xTasks( xDesktop->getFrames(), UNO_QUERY );
769 if ( !xTasks.is() || !xTasks->getCount() )
770 rSet.DisableItem(nWhich);
771 break;
774 case SID_SAVEDOCS:
776 sal_Bool bModified = sal_False;
777 for ( SfxObjectShell *pObjSh = SfxObjectShell::GetFirst();
778 pObjSh;
779 pObjSh = SfxObjectShell::GetNext( *pObjSh ) )
781 if ( pObjSh->IsModified() )
783 bModified = sal_True;
784 break;
788 if ( !bModified )
789 rSet.DisableItem( nWhich );
790 break;
793 case SID_SHOW_IME_STATUS_WINDOW:
794 if (pAppData_Impl->m_xImeStatusWindow->canToggle())
795 rSet.Put(SfxBoolItem(
796 SID_SHOW_IME_STATUS_WINDOW,
797 pAppData_Impl->m_xImeStatusWindow->
798 isShowing()));
799 else
800 rSet.DisableItem(SID_SHOW_IME_STATUS_WINDOW);
801 break;
803 case SID_TEMPLATE_MANAGER:
805 SvtMiscOptions aMiscOptions;
806 if ( !aMiscOptions.IsExperimentalMode() )
808 rSet.DisableItem( nWhich );
809 rSet.Put( SfxVisibilityItem( nWhich, sal_False ) );
812 break;
814 case SID_ZOOM_50_PERCENT:
815 case SID_ZOOM_75_PERCENT:
816 case SID_ZOOM_100_PERCENT:
817 case SID_ZOOM_150_PERCENT:
818 case SID_ZOOM_200_PERCENT:
819 case SID_ZOOM_OPTIMAL:
820 case SID_ZOOM_ENTIRE_PAGE:
821 case SID_ZOOM_PAGE_WIDTH:
823 SfxObjectShell* pCurrentShell = SfxObjectShell::Current();
825 const SfxPoolItem *pItem;
826 SfxItemState aState = pCurrentShell ?
827 pCurrentShell->GetDispatcher()->QueryState(SID_ATTR_ZOOM, pItem) : SFX_ITEM_DISABLED;
828 if ( aState == SFX_ITEM_DISABLED )
829 rSet.DisableItem( nWhich );
831 break;
833 default:
834 break;
838 ++pRanges;
842 #ifndef DISABLE_SCRIPTING
844 #ifndef DISABLE_DYNLOADING
846 typedef rtl_uString* (SAL_CALL *basicide_choose_macro)(XModel*, sal_Bool, rtl_uString*);
847 typedef void (SAL_CALL *basicide_macro_organizer)( sal_Int16 );
849 extern "C" { static void SAL_CALL thisModule() {} }
851 #else
853 extern "C" rtl_uString* basicide_choose_macro(XModel*, sal_Bool, rtl_uString*);
854 extern "C" void basicide_macro_organizer( sal_Int16 );
856 #endif
858 OUString ChooseMacro( const Reference< XModel >& rxLimitToDocument, sal_Bool bChooseOnly, const OUString& rMacroDesc = OUString() )
860 #ifndef DISABLE_DYNLOADING
861 // get basctl dllname
862 static OUString aLibName( SVLIBRARY( "basctl" ) );
864 // load module
865 oslModule handleMod = osl_loadModuleRelative(
866 &thisModule, aLibName.pData, 0 );
868 // get symbol
869 OUString aSymbol( "basicide_choose_macro" );
870 basicide_choose_macro pSymbol = (basicide_choose_macro) osl_getFunctionSymbol( handleMod, aSymbol.pData );
871 #else
872 #define pSymbol basicide_choose_macro
873 #endif
875 // call basicide_choose_macro in basctl
876 rtl_uString* pScriptURL = pSymbol( rxLimitToDocument.get(), bChooseOnly, rMacroDesc.pData );
877 OUString aScriptURL( pScriptURL );
878 rtl_uString_release( pScriptURL );
879 return aScriptURL;
881 #ifdef DISABLE_DYNLOADING
882 #undef pSymbol
883 #endif
886 void MacroOrganizer( sal_Int16 nTabId )
888 #ifndef DISABLE_DYNLOADING
889 // get basctl dllname
890 static OUString aLibName( SVLIBRARY( "basctl" ) );
892 // load module
893 oslModule handleMod = osl_loadModuleRelative(
894 &thisModule, aLibName.pData, 0 );
896 // get symbol
897 OUString aSymbol( "basicide_macro_organizer" );
898 basicide_macro_organizer pSymbol = (basicide_macro_organizer) osl_getFunctionSymbol( handleMod, aSymbol.pData );
899 // call basicide_macro_organizer in basctl
900 pSymbol( nTabId );
901 #else
902 basicide_macro_organizer( nTabId );
903 #endif
907 #endif
910 #define RID_ERRBOX_MODULENOTINSTALLED (RID_OFA_START + 72)
912 ResMgr* SfxApplication::GetOffResManager_Impl()
914 if ( !pAppData_Impl->pOfaResMgr )
915 pAppData_Impl->pOfaResMgr = CreateResManager( "ofa");
916 return pAppData_Impl->pOfaResMgr;
919 namespace
921 #ifndef DISABLE_SCRIPTING
922 Window* lcl_getDialogParent( const Reference< XFrame >& _rxFrame, Window* _pFallback )
924 if ( !_rxFrame.is() )
925 return _pFallback;
929 Reference< awt::XWindow > xContainerWindow( _rxFrame->getContainerWindow(), UNO_SET_THROW );
930 Window* pWindow = VCLUnoHelper::GetWindow( xContainerWindow );
931 OSL_ENSURE( pWindow, "lcl_getDialogParent: cool, somebody implemented a VCL-less toolkit!" );
933 if ( pWindow )
934 return pWindow->GetSystemWindow();
936 catch( const Exception& )
938 DBG_UNHANDLED_EXCEPTION();
940 return _pFallback;
943 const OUString& lcl_getBasicIDEServiceName()
945 static const OUString s_sBasicName( "com.sun.star.script.BasicIDE" );
946 return s_sBasicName;
949 SfxViewFrame* lcl_getBasicIDEViewFrame( SfxObjectShell* i_pBasicIDE )
951 SfxViewFrame* pView = SfxViewFrame::GetFirst( i_pBasicIDE );
952 while ( pView )
954 if ( pView->GetObjectShell()->GetFactory().GetDocumentServiceName() == lcl_getBasicIDEServiceName() )
955 break;
956 pView = SfxViewFrame::GetNext( *pView, i_pBasicIDE );
958 return pView;
960 Reference< XFrame > lcl_findStartModuleFrame( const Reference<XComponentContext> & rxContext )
964 Reference < XDesktop2 > xDesktop = Desktop::create( rxContext );
965 Reference < XIndexAccess > xContainer( xDesktop->getFrames(), UNO_QUERY_THROW );
967 Reference< XModuleManager2 > xCheck = ModuleManager::create(rxContext);
969 sal_Int32 nCount = xContainer->getCount();
970 for ( sal_Int32 i=0; i<nCount; ++i )
974 Reference < XFrame > xFrame( xContainer->getByIndex(i), UNO_QUERY_THROW );
975 OUString sModule = xCheck->identify( xFrame );
976 if ( sModule == "com.sun.star.frame.StartModule" )
977 return xFrame;
979 catch( const UnknownModuleException& )
981 // silence
983 catch(const Exception&)
985 // re-throw, caught below
986 throw;
990 catch( const Exception& )
992 DBG_UNHANDLED_EXCEPTION();
994 return NULL;
996 #endif // !DISABLE_SCRIPTING
999 void SfxApplication::OfaExec_Impl( SfxRequest& rReq )
1001 switch ( rReq.GetSlot() )
1003 case SID_OPTIONS_TREEDIALOG:
1005 OUString sPageURL;
1006 SFX_REQUEST_ARG( rReq, pURLItem, SfxStringItem, SID_OPTIONS_PAGEURL, sal_False );
1007 if ( pURLItem )
1008 sPageURL = pURLItem->GetValue();
1009 const SfxItemSet* pArgs = rReq.GetInternalArgs_Impl();
1010 const SfxPoolItem* pItem = NULL;
1011 Reference < XFrame > xFrame;
1012 if ( pArgs && pArgs->GetItemState( SID_FILLFRAME, sal_False, &pItem ) == SFX_ITEM_SET )
1014 OSL_ENSURE( pItem->ISA( SfxUnoFrameItem ), "SfxApplication::OfaExec_Impl: XFrames are to be transported via SfxUnoFrameItem by now!" );
1015 xFrame = static_cast< const SfxUnoFrameItem*>( pItem )->GetFrame();
1017 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
1018 if ( pFact )
1020 VclAbstractDialog* pDlg =
1021 pFact->CreateFrameDialog( NULL, xFrame, rReq.GetSlot(), sPageURL );
1022 short nRet = pDlg->Execute();
1023 delete pDlg;
1024 SfxViewFrame* pView = SfxViewFrame::GetFirst();
1025 while ( pView )
1027 if (nRet == RET_OK)
1029 SfxObjectShell* pObjSh = pView->GetObjectShell();
1030 if (pObjSh)
1031 pObjSh->SetConfigOptionsChecked(false);
1033 pView->GetBindings().InvalidateAll(sal_False);
1034 pView = SfxViewFrame::GetNext( *pView );
1037 break;
1040 case SID_MORE_DICTIONARIES:
1044 uno::Reference< uno::XComponentContext > xContext =
1045 ::comphelper::getProcessComponentContext();
1046 uno::Reference< css::system::XSystemShellExecute > xSystemShell(
1047 css::system::SystemShellExecute::create(xContext) );
1049 // read repository URL from configuration
1050 OUString sTemplRepoURL(officecfg::Office::Common::Dictionaries::RepositoryURL::get());
1052 if ( xSystemShell.is() && !sTemplRepoURL.isEmpty() )
1054 OUStringBuffer aURLBuf( sTemplRepoURL );
1055 aURLBuf.append("?lang=");
1057 // read locale from configuration
1058 OUString sLocale(officecfg::Setup::L10N::ooLocale::get());
1059 if (sLocale.isEmpty())
1060 sLocale = "en-US";
1062 aURLBuf.append( sLocale );
1063 xSystemShell->execute(
1064 aURLBuf.makeStringAndClear(),
1065 OUString(),
1066 css::system::SystemShellExecuteFlags::URIS_ONLY );
1069 catch( const ::com::sun::star::uno::Exception& )
1071 SAL_WARN( "sfx.appl", "SfxApplication::OfaExec_Impl(SID_MORE_DICTIONARIES): caught an exception!" );
1073 break;
1075 #ifndef DISABLE_SCRIPTING
1076 case SID_BASICIDE_APPEAR:
1078 SfxViewFrame* pView = lcl_getBasicIDEViewFrame( NULL );
1079 if ( !pView )
1081 SfxObjectShell* pBasicIDE = SfxObjectShell::CreateObject( lcl_getBasicIDEServiceName() );
1082 pBasicIDE->DoInitNew( 0 );
1083 pBasicIDE->SetModified( sal_False );
1086 // load the Basic IDE via direct access to the SFX frame loader. A generic loadComponentFromURL
1087 // (which could be done via SfxViewFrame::LoadDocumentIntoFrame) is not feasible here, since the Basic IDE
1088 // does not really play nice with the framework's concept. For instance, it is a "singleton document",
1089 // which conflicts, at the latest, with the framework's concept of loading into _blank frames.
1090 // So, since we know that our frame loader can handle it, we skip the generic framework loader
1091 // mechanism, and the type detection (which doesn't know about the Basic IDE).
1092 Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
1093 Reference< XSynchronousFrameLoader > xLoader(
1094 xContext->getServiceManager()->createInstanceWithContext(SfxFrameLoader_Impl::impl_getStaticImplementationName(), xContext),
1095 UNO_QUERY_THROW );
1096 ::comphelper::NamedValueCollection aLoadArgs;
1097 aLoadArgs.put( "Model", pBasicIDE->GetModel() );
1098 aLoadArgs.put( "URL", OUString( "private:factory/sbasic" ) );
1100 Reference< XFrame > xTargetFrame( lcl_findStartModuleFrame( xContext ) );
1101 if ( !xTargetFrame.is() )
1102 xTargetFrame = SfxFrame::CreateBlankFrame();
1103 ENSURE_OR_THROW( xTargetFrame.is(), "could not obtain a frameto load the Basic IDE into!" );
1105 xLoader->load( aLoadArgs.getPropertyValues(), xTargetFrame );
1107 catch( const Exception& )
1109 DBG_UNHANDLED_EXCEPTION();
1112 pView = lcl_getBasicIDEViewFrame( pBasicIDE );
1113 if ( pView )
1114 pView->SetName( OUString( "BASIC:1" ) );
1117 if ( pView )
1118 pView->GetFrame().Appear();
1120 const SfxItemSet* pArgs = rReq.GetArgs();
1121 if ( pArgs && pView )
1123 SfxViewShell* pViewShell = pView->GetViewShell();
1124 SfxObjectShell* pObjShell = pView->GetObjectShell();
1125 if ( pViewShell && pObjShell )
1127 SfxRequest aReq( SID_BASICIDE_SHOWWINDOW, SFX_CALLMODE_SYNCHRON, pObjShell->GetPool() );
1128 aReq.SetArgs( *pArgs );
1129 pViewShell->ExecuteSlot( aReq );
1133 rReq.Done();
1135 break;
1137 case SID_BASICCHOOSER:
1139 const SfxItemSet* pArgs = rReq.GetArgs();
1140 const SfxPoolItem* pItem;
1141 sal_Bool bChooseOnly = sal_False;
1142 Reference< XModel > xLimitToModel;
1143 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_RECORDMACRO, sal_False, &pItem) )
1145 sal_Bool bRecord = ((SfxBoolItem*)pItem)->GetValue();
1146 if ( bRecord )
1148 // !Hack
1149 bChooseOnly = sal_False;
1150 SfxObjectShell* pCurrentShell = SfxObjectShell::Current();
1151 OSL_ENSURE( pCurrentShell, "macro recording outside an SFX document?" );
1152 if ( pCurrentShell )
1153 xLimitToModel = pCurrentShell->GetModel();
1157 rReq.SetReturnValue( SfxStringItem( rReq.GetSlot(), ChooseMacro( xLimitToModel, bChooseOnly ) ) );
1158 rReq.Done();
1160 break;
1162 case SID_MACROORGANIZER:
1164 OSL_TRACE("handling SID_MACROORGANIZER");
1165 const SfxItemSet* pArgs = rReq.GetArgs();
1166 const SfxPoolItem* pItem;
1167 sal_Int16 nTabId = 0;
1168 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_MACROORGANIZER, sal_False, &pItem) )
1170 nTabId = ((SfxUInt16Item*)pItem)->GetValue();
1173 SfxApplication::MacroOrganizer( nTabId );
1174 rReq.Done();
1176 break;
1178 case SID_RUNMACRO:
1180 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
1181 OSL_TRACE("SfxApplication::OfaExec_Impl: case ScriptOrg");
1183 Reference< XFrame > xFrame;
1184 const SfxItemSet* pIntSet = rReq.GetInternalArgs_Impl();
1185 SFX_ITEMSET_ARG( pIntSet, pFrameItem, SfxUnoFrameItem, SID_FILLFRAME, sal_False );
1186 if ( pFrameItem )
1187 xFrame = pFrameItem->GetFrame();
1189 if ( !xFrame.is() )
1191 const SfxViewFrame* pViewFrame = SfxViewFrame::Current();
1192 if ( pViewFrame )
1193 xFrame = pViewFrame->GetFrame().GetFrameInterface();
1196 do // artificial loop for flow control
1198 AbstractScriptSelectorDialog* pDlg = pFact->CreateScriptSelectorDialog(
1199 lcl_getDialogParent( xFrame, GetTopWindow() ), sal_False, xFrame );
1200 OSL_ENSURE( pDlg, "SfxApplication::OfaExec_Impl( SID_RUNMACRO ): no dialog!" );
1201 if ( !pDlg )
1202 break;
1203 pDlg->SetRunLabel();
1205 short nDialogResult = pDlg->Execute();
1206 if ( !nDialogResult )
1208 delete pDlg;
1209 break;
1212 Sequence< Any > args;
1213 Sequence< sal_Int16 > outIndex;
1214 Sequence< Any > outArgs;
1215 Any ret;
1217 Reference< XInterface > xScriptContext;
1219 Reference< XController > xController;
1220 if ( xFrame.is() )
1221 xController = xFrame->getController();
1222 if ( xController.is() )
1223 xScriptContext = xController->getModel();
1224 if ( !xScriptContext.is() )
1225 xScriptContext = xController;
1227 SfxObjectShell::CallXScript( xScriptContext, pDlg->GetScriptURL(), args, ret, outIndex, outArgs );
1228 delete pDlg;
1230 while ( false );
1231 rReq.Done();
1233 break;
1235 case SID_SCRIPTORGANIZER:
1237 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
1238 OSL_TRACE("SfxApplication::OfaExec_Impl: case ScriptOrg");
1239 const SfxItemSet* pArgs = rReq.GetArgs();
1240 const SfxPoolItem* pItem;
1241 OUString aLanguage;
1242 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_SCRIPTORGANIZER, sal_False, &pItem) )
1244 aLanguage = ((SfxScriptOrganizerItem*)pItem)->getLanguage();
1247 OUString aLang( aLanguage );
1248 OSL_TRACE("SfxApplication::OfaExec_Impl: about to create dialog for: %s", OUStringToOString( aLang , RTL_TEXTENCODING_ASCII_US ).pData->buffer);
1249 // not sure about the Window*
1250 VclAbstractDialog* pDlg = pFact->CreateSvxScriptOrgDialog( GetTopWindow(), aLanguage );
1251 if( pDlg )
1253 pDlg->Execute();
1254 delete pDlg;
1256 else
1258 OSL_TRACE("no dialog!!!");
1260 rReq.Done();
1262 break;
1263 #endif // !DISABLE_SCRIPTING
1265 case SID_OFFICE_CHECK_PLZ:
1267 sal_Bool bRet = sal_False;
1268 SFX_REQUEST_ARG(rReq, pStringItem, SfxStringItem, rReq.GetSlot(), sal_False);
1270 if ( pStringItem )
1272 bRet = sal_True /*!!!SfxIniManager::CheckPLZ( aPLZ )*/;
1274 #ifndef DISABLE_SCRIPTING
1275 else
1276 SbxBase::SetError( SbxERR_WRONG_ARGS );
1277 #endif
1278 rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bRet ) );
1280 break;
1282 case SID_AUTO_CORRECT_DLG:
1284 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
1285 if ( pFact )
1287 SfxItemSet aSet(GetPool(), SID_AUTO_CORRECT_DLG, SID_AUTO_CORRECT_DLG);
1288 const SfxPoolItem* pItem=NULL;
1289 const SfxItemSet* pSet = rReq.GetArgs();
1290 SfxItemPool* pSetPool = pSet ? pSet->GetPool() : NULL;
1291 if ( pSet && pSet->GetItemState( pSetPool->GetWhich( SID_AUTO_CORRECT_DLG ), sal_False, &pItem ) == SFX_ITEM_SET )
1292 aSet.Put( *pItem );
1294 SfxAbstractTabDialog* pDlg = pFact->CreateTabDialog( RID_OFA_AUTOCORR_DLG, NULL, &aSet, NULL );
1295 pDlg->Execute();
1296 delete pDlg;
1299 break;
1302 case SID_SD_AUTOPILOT :
1303 case SID_NEWSD :
1305 SvtModuleOptions aModuleOpt;
1306 if ( !aModuleOpt.IsImpress() )
1308 ErrorBox( 0, ResId( RID_ERRBOX_MODULENOTINSTALLED, *GetOffResManager_Impl() )).Execute();
1309 return;
1312 Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
1313 Reference< frame::XDispatchProvider > xProv = drawing::ModuleDispatcher::create( xContext );
1315 OUString aCmd = OUString::createFromAscii( GetInterface()->GetSlot( rReq.GetSlot() )->GetUnoName() );
1316 Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create(xContext) );
1317 Sequence < beans::PropertyValue > aSeq;
1318 if ( rReq.GetArgs() )
1319 TransformItems( rReq.GetSlot(), *rReq.GetArgs(), aSeq );
1320 Any aResult = xHelper->executeDispatch( xProv, aCmd, OUString(), 0, aSeq );
1321 frame::DispatchResultEvent aEvent;
1322 sal_Bool bSuccess = (aResult >>= aEvent) &&
1323 (aEvent.State == frame::DispatchResultState::SUCCESS);
1324 rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bSuccess ) );
1326 break;
1328 case FN_LABEL :
1329 case FN_BUSINESS_CARD :
1330 case FN_XFORMS_INIT :
1332 Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
1333 Reference< frame::XDispatchProvider > xProv = text::ModuleDispatcher::create( xContext );
1335 OUString aCmd = OUString::createFromAscii( GetInterface()->GetSlot( rReq.GetSlot() )->GetUnoName() );
1336 Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create(xContext) );
1337 Sequence < beans::PropertyValue > aSeq;
1338 if ( rReq.GetArgs() )
1339 TransformItems( rReq.GetSlot(), *rReq.GetArgs(), aSeq );
1340 Any aResult = xHelper->executeDispatch( xProv, aCmd, OUString(), 0, aSeq );
1341 frame::DispatchResultEvent aEvent;
1342 sal_Bool bSuccess = (aResult >>= aEvent) &&
1343 (aEvent.State == frame::DispatchResultState::SUCCESS);
1344 rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bSuccess ) );
1346 break;
1348 case SID_ADDRESS_DATA_SOURCE:
1352 Reference< uno::XComponentContext > xORB = ::comphelper::getProcessComponentContext();
1353 Reference< ui::dialogs::XExecutableDialog > xDialog;
1354 xDialog = ui::dialogs::AddressBookSourcePilot::createWithParent(xORB, 0);
1355 xDialog->execute();
1357 catch(const ::com::sun::star::uno::Exception&)
1359 DBG_UNHANDLED_EXCEPTION();
1362 break;
1364 case SID_COMP_BIBLIOGRAPHY:
1365 lcl_tryLoadBibliography();
1366 break;
1370 void SfxApplication::OfaState_Impl(SfxItemSet &rSet)
1372 SvtModuleOptions aModuleOpt;
1374 if( !aModuleOpt.IsWriter())
1376 rSet.DisableItem( FN_LABEL );
1377 rSet.DisableItem( FN_BUSINESS_CARD );
1378 rSet.DisableItem( FN_XFORMS_INIT );
1381 if ( !aModuleOpt.IsImpress() )
1382 rSet.DisableItem( SID_SD_AUTOPILOT );
1385 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */