bump product version to 4.1.6.2
[LibreOffice.git] / sfx2 / source / appl / appserv.cxx
blobd4d8fff69c718093b367910d01e8438c765bf4b9
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>
49 #include "comphelper/configurationhelper.hxx"
51 #include <svtools/addresstemplate.hxx>
52 #include <svtools/miscopt.hxx>
53 #include <svtools/restartdialog.hxx>
54 #include <svl/visitem.hxx>
55 #include <unotools/intlwrapper.hxx>
57 #include <unotools/configmgr.hxx>
58 #include <tools/diagnose_ex.h>
59 #include <vcl/msgbox.hxx>
60 #include <svl/intitem.hxx>
61 #include <svl/eitem.hxx>
62 #include <svl/stritem.hxx>
63 #include <basic/sbstar.hxx>
64 #include <basic/basmgr.hxx>
65 #include <basic/basrdll.hxx>
66 #include <svtools/sfxecode.hxx>
67 #include <svtools/ehdl.hxx>
68 #include <vcl/help.hxx>
69 #include <vcl/stdtext.hxx>
70 #include <rtl/ustrbuf.hxx>
71 #include <osl/file.hxx>
73 #include <unotools/pathoptions.hxx>
74 #include <unotools/moduleoptions.hxx>
75 #include <svtools/helpopt.hxx>
76 #include <toolkit/helper/vclunohelper.hxx>
77 #include <tools/shl.hxx>
78 #include <unotools/bootstrap.hxx>
79 #include <rtl/bootstrap.hxx>
80 #include <cppuhelper/exc_hlp.hxx>
82 #include <com/sun/star/script/provider/XScriptProviderFactory.hpp>
83 #include <com/sun/star/frame/ModuleManager.hpp>
84 #include <com/sun/star/beans/XPropertySet.hpp>
86 #include "frmload.hxx"
87 #include "referers.hxx"
88 #include <sfx2/app.hxx>
89 #include <sfx2/request.hxx>
90 #include <sfx2/dispatch.hxx>
91 #include <sfx2/bindings.hxx>
92 #include <sfx2/msg.hxx>
93 #include <sfx2/objface.hxx>
94 #include <sfx2/objitem.hxx>
95 #include <sfx2/objsh.hxx>
96 #include <sfx2/hintpost.hxx>
97 #include <sfx2/viewsh.hxx>
98 #include <sfx2/docfac.hxx>
99 #include <sfx2/docfile.hxx>
100 #include <sfx2/docfilt.hxx>
101 #include <sfx2/new.hxx>
102 #include "sfxtypes.hxx"
103 #include <sfx2/tabdlg.hxx>
104 #include "arrdecl.hxx"
105 #include "fltfnc.hxx"
106 #include <sfx2/sfx.hrc>
107 #include "app.hrc"
108 #include <sfx2/passwd.hxx>
109 #include "sfx2/sfxresid.hxx"
110 #include <sfx2/childwin.hxx>
111 #include "appdata.hxx"
112 #include "sfx2/minfitem.hxx"
113 #include <sfx2/event.hxx>
114 #include <sfx2/module.hxx>
115 #include <sfx2/viewfrm.hxx>
116 #include "sfxpicklist.hxx"
117 #include "imestatuswindow.hxx"
118 #include <sfx2/sfxdlg.hxx>
119 #include <sfx2/dialogs.hrc>
120 #include "sorgitm.hxx"
121 #include "sfx2/sfxhelp.hxx"
122 #include <sfx2/zoomitem.hxx>
123 #include "templatedlg.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 "sfx2.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 "sfx2.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( "sfx2.appl",
193 "trying to load bibliography database, caught " << e.Message);
197 /// Find the correct location of the document (LICENSE.odt, 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 = OUString( "$BRAND_BASE_DIR/" );
205 rURL += OUString::createFromAscii( pName );
206 rURL += OUString::createFromAscii( pExt );
207 rtl::Bootstrap::expandMacros( rURL );
209 if (!rURL.isEmpty())
210 return DirectoryItem::get( rURL, aDirItem ) == DirectoryItem::E_None;
211 else
212 return sal_False;
215 /// Displays CREDITS or LICENSE in any of the available version
216 static void showDocument( const char* pBaseName )
218 try {
219 Reference < XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() );
220 Sequence < com::sun::star::beans::PropertyValue > args(2);
221 args[0].Name = OUString("ViewOnly");
222 args[0].Value <<= sal_True;
223 args[1].Name = OUString("ReadOnly");
224 args[1].Value <<= sal_True;
226 OUString aURL;
227 if ( checkURL ( pBaseName, ".odt", aURL ) ||
228 checkURL ( pBaseName, ".html", aURL ) ||
229 checkURL ( pBaseName, "", aURL ) ) {
230 xDesktop->loadComponentFromURL( aURL, OUString("_blank"), 0, args );
232 } catch (const ::com::sun::star::uno::Exception &) {
236 namespace
238 class LicenseDialog : public ModalDialog
240 private:
241 DECL_LINK(ShowHdl, void *);
242 public:
243 LicenseDialog(Window *pParent=NULL);
246 LicenseDialog::LicenseDialog(Window *pParent)
247 : ModalDialog(pParent, "LicenseDialog", "sfx/ui/licensedialog.ui")
249 get<PushButton>("show")->SetClickHdl(LINK(this, LicenseDialog, ShowHdl));
252 IMPL_LINK_NOARG(LicenseDialog, ShowHdl)
254 EndDialog(RET_OK);
255 showDocument("LICENSE");
256 return 0;
260 void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
262 bool bDone = false;
263 switch ( rReq.GetSlot() )
265 case SID_SETOPTIONS:
267 if( rReq.GetArgs() )
268 SetOptions_Impl( *rReq.GetArgs() );
269 break;
272 case SID_QUITAPP:
273 case SID_EXITANDRETURN:
274 case SID_LOGOUT:
276 // protect against reentrant calls
277 if ( pAppData_Impl->bInQuit )
278 return;
280 if ( rReq.GetSlot() == SID_LOGOUT )
282 for ( SfxObjectShell *pObjSh = SfxObjectShell::GetFirst();
283 pObjSh; pObjSh = SfxObjectShell::GetNext( *pObjSh ) )
285 if ( !pObjSh->IsModified() )
286 continue;
288 SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pObjSh );
289 if ( !pFrame || !pFrame->GetWindow().IsReallyVisible() )
290 continue;
292 if ( pObjSh->PrepareClose(2) )
293 pObjSh->SetModified( sal_False );
294 else
295 return;
298 SfxStringItem aNameItem( SID_FILE_NAME, OUString("vnd.sun.star.cmd:logout") );
299 SfxStringItem aReferer( SID_REFERER, "private/user" );
300 pAppData_Impl->pAppDispat->Execute( SID_OPENDOC, SFX_CALLMODE_SLOT, &aNameItem, &aReferer, 0L );
301 return;
304 // aus verschachtelten Requests nach 100ms nochmal probieren
305 if( Application::GetDispatchLevel() > 1 )
307 /* Dont save the request for closing the application and try it later
308 again. This is an UI bound functionality ... and the user will try it again
309 if the dialog is closed. But we shouldnt close the application automaticly
310 if this dialog is closed by the user ...
311 So we ignore this request now and wait for a new user decision.
313 OSL_TRACE( "QueryExit => sal_False (DispatchLevel == %u)", Application::GetDispatchLevel() );
314 return;
317 // block reentrant calls
318 pAppData_Impl->bInQuit = sal_True;
319 Reference < XDesktop2 > xDesktop = Desktop::create ( ::comphelper::getProcessComponentContext() );
321 rReq.ForgetAllArgs();
323 // if terminate() failed, pAppData_Impl->bInQuit will now be sal_False, allowing further calls of SID_QUITAPP
324 sal_Bool bTerminated = xDesktop->terminate();
325 if (!bTerminated)
326 // if terminate() was successful, SfxApplication is now dead!
327 pAppData_Impl->bInQuit = sal_False;
329 // Set return value, terminate if possible
330 rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bTerminated ) );
331 return;
334 case SID_CONFIG:
335 case SID_TOOLBOXOPTIONS:
336 case SID_CONFIGSTATUSBAR:
337 case SID_CONFIGMENU:
338 case SID_CONFIGACCEL:
339 case SID_CONFIGEVENT:
341 SfxAbstractDialogFactory* pFact =
342 SfxAbstractDialogFactory::Create();
344 if ( pFact )
346 SFX_REQUEST_ARG(rReq, pStringItem,
347 SfxStringItem, SID_CONFIG, sal_False);
349 SfxItemSet aSet(
350 GetPool(), SID_CONFIG, SID_CONFIG );
352 if ( pStringItem )
354 aSet.Put( SfxStringItem(
355 SID_CONFIG, pStringItem->GetValue() ) );
358 Reference< XFrame > xFrame;
359 const SfxItemSet* pIntSet = rReq.GetInternalArgs_Impl();
360 SFX_ITEMSET_ARG( pIntSet, pFrameItem, SfxUnoFrameItem, SID_FILLFRAME, sal_False );
361 if ( pFrameItem )
362 xFrame = pFrameItem->GetFrame();
364 SfxAbstractTabDialog* pDlg = pFact->CreateTabDialog(
365 RID_SVXDLG_CUSTOMIZE,
366 NULL, &aSet, xFrame );
368 if ( pDlg )
370 const short nRet = pDlg->Execute();
372 if ( nRet )
373 bDone = true;
375 delete pDlg;
378 break;
381 case SID_CLOSEDOCS:
382 case SID_CLOSEWINS:
385 Reference < XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() );
386 Reference< XIndexAccess > xTasks( xDesktop->getFrames(), UNO_QUERY );
387 if ( !xTasks.is() )
388 break;
390 sal_Int32 n=0;
393 if ( xTasks->getCount() <= n )
394 break;
396 Any aAny = xTasks->getByIndex(n);
397 Reference < XCloseable > xTask;
398 aAny >>= xTask;
401 xTask->close(sal_True);
402 n++;
404 catch( CloseVetoException& )
408 while( true );
410 sal_Bool bOk = ( n == 0);
411 rReq.SetReturnValue( SfxBoolItem( 0, bOk ) );
412 bDone = true;
413 break;
416 case SID_SAVEDOCS:
418 sal_Bool bOK = sal_True;
419 for ( SfxObjectShell *pObjSh = SfxObjectShell::GetFirst();
420 pObjSh;
421 pObjSh = SfxObjectShell::GetNext( *pObjSh ) )
423 SfxRequest aReq( SID_SAVEDOC, 0, pObjSh->GetPool() );
424 if ( pObjSh->IsModified() )
426 pObjSh->ExecuteSlot( aReq );
427 SfxBoolItem *pItem = PTR_CAST( SfxBoolItem, aReq.GetReturnValue() );
428 if ( !pItem || !pItem->GetValue() )
429 bOK = sal_False;
433 rReq.SetReturnValue( SfxBoolItem( 0, bOK ) );
434 rReq.Done();
435 break;
438 case SID_SEND_FEEDBACK:
440 OUString module = SfxHelp::GetCurrentModuleIdentifier();
441 OUString sURL("http://hub.libreoffice.org/send-feedback/?LOversion=" + utl::ConfigManager::getAboutBoxProductVersion() +
442 "&LOlocale=" + utl::ConfigManager::getLocale() + "&LOmodule=" + module.copy(module.lastIndexOf(".") + 1 ) );
445 uno::Reference< com::sun::star::system::XSystemShellExecute > xSystemShellExecute(
446 com::sun::star::system::SystemShellExecute::create(::comphelper::getProcessComponentContext()) );
447 xSystemShellExecute->execute( sURL, OUString(), com::sun::star::system::SystemShellExecuteFlags::URIS_ONLY );
449 catch ( uno::Exception& )
452 break;
455 case SID_SHOW_LICENSE:
457 LicenseDialog aDialog;
458 aDialog.Execute();
459 break;
462 case SID_SHOW_CREDITS:
464 showDocument( "CREDITS" );
465 break;
468 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
469 case SID_HELPINDEX:
471 Help* pHelp = Application::GetHelp();
472 if ( pHelp )
474 pHelp->Start( OUString(".uno:HelpIndex"), NULL ); // show start page
475 bDone = true;
477 break;
480 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
481 case SID_HELPTIPS:
483 // Evaluate Parameter
484 SFX_REQUEST_ARG(rReq, pOnItem, SfxBoolItem, SID_HELPTIPS, sal_False);
485 bool bOn = pOnItem
486 ? ((SfxBoolItem*)pOnItem)->GetValue()
487 : !Help::IsQuickHelpEnabled();
489 if ( bOn )
490 Help::EnableQuickHelp();
491 else
492 Help::DisableQuickHelp();
493 SvtHelpOptions().SetHelpTips( bOn );
494 Invalidate(SID_HELPTIPS);
495 bDone = true;
497 // Record if possible
498 if ( !rReq.IsAPI() )
499 rReq.AppendItem( SfxBoolItem( SID_HELPTIPS, bOn) );
500 break;
502 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
503 case SID_EXTENDEDHELP:
505 Help::StartExtHelp();
506 break;
508 case SID_HELPBALLOONS:
510 // Evaluate Parameter
511 SFX_REQUEST_ARG(rReq, pOnItem, SfxBoolItem, SID_HELPBALLOONS, sal_False);
512 bool bOn = pOnItem
513 ? ((SfxBoolItem*)pOnItem)->GetValue()
514 : !Help::IsBalloonHelpEnabled();
516 if ( bOn )
517 Help::EnableBalloonHelp();
518 else
519 Help::DisableBalloonHelp();
520 SvtHelpOptions().SetExtendedHelp( bOn );
521 Invalidate(SID_HELPBALLOONS);
522 bDone = true;
524 // Record if possible
525 if ( !rReq.IsAPI() )
526 rReq.AppendItem( SfxBoolItem( SID_HELPBALLOONS, bOn) );
527 break;
530 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
531 case SID_ABOUT:
533 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
534 if ( pFact )
536 VclAbstractDialog* pDlg = pFact->CreateVclDialog( 0, RID_DEFAULTABOUT );
537 pDlg->Execute();
538 delete pDlg;
539 bDone = true;
541 break;
544 case SID_TEMPLATE_MANAGER:
546 SfxTemplateManagerDlg dlg;
547 dlg.Execute();
548 bDone = true;
549 break;
552 case SID_TEMPLATE_ADDRESSBOKSOURCE:
554 svt::AddressBookSourceDialog aDialog(GetTopWindow(), ::comphelper::getProcessComponentContext());
555 aDialog.Execute();
556 bDone = true;
557 break;
560 #ifndef DISABLE_SCRIPTING
561 case SID_BASICSTOP:
562 StarBASIC::Stop();
563 break;
565 case SID_BASICBREAK :
566 BASIC_DLL()->BasicBreak();
567 break;
568 #endif
570 case SID_CRASH :
572 // Provoke a crash:
573 char * crash = 0;
574 *crash = 0;
575 break;
578 case SID_SHOW_IME_STATUS_WINDOW:
579 if (pAppData_Impl->m_xImeStatusWindow->canToggle())
581 SfxBoolItem const * pItem = static_cast< SfxBoolItem const * >(
582 rReq.GetArg(SID_SHOW_IME_STATUS_WINDOW, false,
583 TYPE(SfxBoolItem)));
584 bool bShow = pItem == 0
585 ? !pAppData_Impl->m_xImeStatusWindow->isShowing()
586 : ( pItem->GetValue() == sal_True );
587 pAppData_Impl->m_xImeStatusWindow->show(bShow);
588 if (pItem == 0)
589 rReq.AppendItem(SfxBoolItem(SID_SHOW_IME_STATUS_WINDOW,
590 bShow));
592 bDone = true;
593 break;
595 case SID_ZOOM_50_PERCENT:
596 case SID_ZOOM_75_PERCENT:
597 case SID_ZOOM_100_PERCENT:
598 case SID_ZOOM_150_PERCENT:
599 case SID_ZOOM_200_PERCENT:
600 case SID_ZOOM_OPTIMAL:
601 case SID_ZOOM_ENTIRE_PAGE:
602 case SID_ZOOM_PAGE_WIDTH:
604 SfxObjectShell* pCurrentShell = SfxObjectShell::Current();
605 if (!pCurrentShell)
606 return;
608 // make sure aZoom is initialized with a proper value if SetType
609 // doesn't work
610 SvxZoomItem aZoom( SVX_ZOOM_PERCENT, 100 );
612 switch (rReq.GetSlot())
614 case SID_ZOOM_50_PERCENT:
615 aZoom.SetValue(50);
616 break;
617 case SID_ZOOM_75_PERCENT:
618 aZoom.SetValue(75);
619 break;
620 case SID_ZOOM_100_PERCENT:
621 aZoom.SetValue(100);
622 break;
623 case SID_ZOOM_150_PERCENT:
624 aZoom.SetValue(150);
625 break;
626 case SID_ZOOM_200_PERCENT:
627 aZoom.SetValue(200);
628 break;
629 case SID_ZOOM_OPTIMAL:
630 aZoom.SetType( SVX_ZOOM_OPTIMAL );
631 break;
632 case SID_ZOOM_ENTIRE_PAGE:
633 aZoom.SetType( SVX_ZOOM_WHOLEPAGE );
634 break;
635 case SID_ZOOM_PAGE_WIDTH:
636 aZoom.SetType( SVX_ZOOM_PAGEWIDTH );
637 break;
640 pCurrentShell->GetDispatcher()->Execute(SID_ATTR_ZOOM, SFX_CALLMODE_ASYNCHRON, &aZoom, 0L);
642 break;
644 case SID_AVAILABLE_TOOLBARS:
646 SfxStringItem const * pToolbarName = static_cast< SfxStringItem const *>(
647 rReq.GetArg(SID_AVAILABLE_TOOLBARS, false, TYPE(SfxStringItem)));
649 if ( pToolbarName )
651 Reference < XDesktop2 > xDesktop = Desktop::create ( ::comphelper::getProcessComponentContext() );
652 Reference< XFrame > xFrame = xDesktop->getActiveFrame();
654 Reference< com::sun::star::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY );
655 Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
656 if ( xPropSet.is() )
660 Any aValue = xPropSet->getPropertyValue( OUString( "LayoutManager" ));
661 aValue >>= xLayoutManager;
663 catch ( const ::com::sun::star::uno::RuntimeException& )
665 throw;
667 catch ( ::com::sun::star::uno::Exception& )
672 if ( xLayoutManager.is() )
674 OUString aToolbarResName( "private:resource/toolbar/" );
675 OUStringBuffer aBuf( aToolbarResName );
676 aBuf.append( pToolbarName->GetValue() );
678 // Evaluate Parameter
679 OUString aToolbarName( aBuf.makeStringAndClear() );
680 sal_Bool bShow( !xLayoutManager->isElementVisible( aToolbarName ));
682 if ( bShow )
684 xLayoutManager->createElement( aToolbarName );
685 xLayoutManager->showElement( aToolbarName );
687 else
688 xLayoutManager->hideElement( aToolbarName );
692 bDone = true;
693 break;
696 default:
697 break;
700 if ( bDone )
701 rReq.Done();
704 //--------------------------------------------------------------------
706 void SfxApplication::MiscState_Impl(SfxItemSet &rSet)
708 const sal_uInt16 *pRanges = rSet.GetRanges();
709 DBG_ASSERT(pRanges && *pRanges, "Set without range");
710 while ( *pRanges )
712 for(sal_uInt16 nWhich = *pRanges++; nWhich <= *pRanges; ++nWhich)
714 switch(nWhich)
716 case SID_TEMPLATE_ADDRESSBOKSOURCE:
717 if ( !SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SDATABASE) )
718 rSet.Put(SfxVisibilityItem(nWhich, sal_False));
719 break;
720 case SID_EXITANDRETURN:
721 case SID_QUITAPP:
723 if ( pAppData_Impl->nDocModalMode )
724 rSet.DisableItem(nWhich);
725 else
726 rSet.Put(SfxStringItem(nWhich, SfxResId(STR_QUITAPP).toString()));
727 break;
730 case SID_CONFIG:
731 case SID_TOOLBOXOPTIONS:
732 case SID_CONFIGSTATUSBAR:
733 case SID_CONFIGMENU:
734 case SID_CONFIGACCEL:
735 case SID_CONFIGEVENT:
737 if( SvtMiscOptions().DisableUICustomization() )
738 rSet.DisableItem(nWhich);
739 break;
742 #ifndef DISABLE_SCRIPTING
743 case SID_BASICSTOP:
744 if ( !StarBASIC::IsRunning() )
745 rSet.DisableItem(nWhich);
746 break;
747 #endif
749 case SID_HELPTIPS:
751 rSet.Put( SfxBoolItem( SID_HELPTIPS, Help::IsQuickHelpEnabled() ) );
753 break;
754 case SID_HELPBALLOONS:
756 rSet.Put( SfxBoolItem( SID_HELPBALLOONS, Help::IsBalloonHelpEnabled() ) );
758 break;
760 case SID_EXTENDEDHELP:
763 break;
765 case SID_CLOSEDOCS:
766 case SID_CLOSEWINS:
768 Reference < XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() );
769 Reference< XIndexAccess > xTasks( xDesktop->getFrames(), UNO_QUERY );
770 if ( !xTasks.is() || !xTasks->getCount() )
771 rSet.DisableItem(nWhich);
772 break;
775 case SID_SAVEDOCS:
777 sal_Bool bModified = sal_False;
778 for ( SfxObjectShell *pObjSh = SfxObjectShell::GetFirst();
779 pObjSh;
780 pObjSh = SfxObjectShell::GetNext( *pObjSh ) )
782 if ( pObjSh->IsModified() )
784 bModified = sal_True;
785 break;
789 if ( !bModified )
790 rSet.DisableItem( nWhich );
791 break;
794 case SID_SHOW_IME_STATUS_WINDOW:
795 if (pAppData_Impl->m_xImeStatusWindow->canToggle())
796 rSet.Put(SfxBoolItem(
797 SID_SHOW_IME_STATUS_WINDOW,
798 pAppData_Impl->m_xImeStatusWindow->
799 isShowing()));
800 else
801 rSet.DisableItem(SID_SHOW_IME_STATUS_WINDOW);
802 break;
804 case SID_TEMPLATE_MANAGER:
806 SvtMiscOptions aMiscOptions;
807 if ( !aMiscOptions.IsExperimentalMode() )
809 rSet.DisableItem( nWhich );
810 rSet.Put( SfxVisibilityItem( nWhich, sal_False ) );
813 break;
815 default:
816 break;
820 ++pRanges;
824 #ifndef DISABLE_SCRIPTING
826 #ifndef DISABLE_DYNLOADING
828 typedef rtl_uString* (SAL_CALL *basicide_choose_macro)(XModel*, sal_Bool, rtl_uString*);
829 typedef void (SAL_CALL *basicide_macro_organizer)( sal_Int16 );
831 extern "C" { static void SAL_CALL thisModule() {} }
833 #else
835 extern "C" rtl_uString* basicide_choose_macro(XModel*, sal_Bool, rtl_uString*);
836 extern "C" void basicide_macro_organizer( sal_Int16 );
838 #endif
840 OUString ChooseMacro( const Reference< XModel >& rxLimitToDocument, sal_Bool bChooseOnly, const OUString& rMacroDesc = OUString() )
842 #ifndef DISABLE_DYNLOADING
843 // get basctl dllname
844 static OUString aLibName( SVLIBRARY( "basctl" ) );
846 // load module
847 oslModule handleMod = osl_loadModuleRelative(
848 &thisModule, aLibName.pData, 0 );
850 // get symbol
851 OUString aSymbol( "basicide_choose_macro" );
852 basicide_choose_macro pSymbol = (basicide_choose_macro) osl_getFunctionSymbol( handleMod, aSymbol.pData );
853 #else
854 #define pSymbol basicide_choose_macro
855 #endif
857 // call basicide_choose_macro in basctl
858 rtl_uString* pScriptURL = pSymbol( rxLimitToDocument.get(), bChooseOnly, rMacroDesc.pData );
859 OUString aScriptURL( pScriptURL );
860 rtl_uString_release( pScriptURL );
861 return aScriptURL;
863 #ifdef DISABLE_DYNLOADING
864 #undef pSymbol
865 #endif
868 void MacroOrganizer( sal_Int16 nTabId )
870 #ifndef DISABLE_DYNLOADING
871 // get basctl dllname
872 static OUString aLibName( SVLIBRARY( "basctl" ) );
874 // load module
875 oslModule handleMod = osl_loadModuleRelative(
876 &thisModule, aLibName.pData, 0 );
878 // get symbol
879 OUString aSymbol( "basicide_macro_organizer" );
880 basicide_macro_organizer pSymbol = (basicide_macro_organizer) osl_getFunctionSymbol( handleMod, aSymbol.pData );
881 // call basicide_macro_organizer in basctl
882 pSymbol( nTabId );
883 #else
884 basicide_macro_organizer( nTabId );
885 #endif
889 #endif
892 #define RID_ERRBOX_MODULENOTINSTALLED (RID_OFA_START + 72)
894 ResMgr* SfxApplication::GetOffResManager_Impl()
896 if ( !pAppData_Impl->pOfaResMgr )
897 pAppData_Impl->pOfaResMgr = CreateResManager( "ofa");
898 return pAppData_Impl->pOfaResMgr;
901 namespace
903 #ifndef DISABLE_SCRIPTING
904 Window* lcl_getDialogParent( const Reference< XFrame >& _rxFrame, Window* _pFallback )
906 if ( !_rxFrame.is() )
907 return _pFallback;
911 Reference< awt::XWindow > xContainerWindow( _rxFrame->getContainerWindow(), UNO_SET_THROW );
912 Window* pWindow = VCLUnoHelper::GetWindow( xContainerWindow );
913 OSL_ENSURE( pWindow, "lcl_getDialogParent: cool, somebody implemented a VCL-less toolkit!" );
915 if ( pWindow )
916 return pWindow->GetSystemWindow();
918 catch( const Exception& )
920 DBG_UNHANDLED_EXCEPTION();
922 return _pFallback;
925 const OUString& lcl_getBasicIDEServiceName()
927 static const OUString s_sBasicName( "com.sun.star.script.BasicIDE" );
928 return s_sBasicName;
931 SfxViewFrame* lcl_getBasicIDEViewFrame( SfxObjectShell* i_pBasicIDE )
933 SfxViewFrame* pView = SfxViewFrame::GetFirst( i_pBasicIDE );
934 while ( pView )
936 if ( pView->GetObjectShell()->GetFactory().GetDocumentServiceName() == lcl_getBasicIDEServiceName() )
937 break;
938 pView = SfxViewFrame::GetNext( *pView, i_pBasicIDE );
940 return pView;
942 Reference< XFrame > lcl_findStartModuleFrame( const Reference<XComponentContext> & rxContext )
946 Reference < XDesktop2 > xDesktop = Desktop::create( rxContext );
947 Reference < XIndexAccess > xContainer( xDesktop->getFrames(), UNO_QUERY_THROW );
949 Reference< XModuleManager2 > xCheck = ModuleManager::create(rxContext);
951 sal_Int32 nCount = xContainer->getCount();
952 for ( sal_Int32 i=0; i<nCount; ++i )
956 Reference < XFrame > xFrame( xContainer->getByIndex(i), UNO_QUERY_THROW );
957 OUString sModule = xCheck->identify( xFrame );
958 if ( sModule == "com.sun.star.frame.StartModule" )
959 return xFrame;
961 catch( const UnknownModuleException& )
963 // silence
965 catch(const Exception&)
967 // re-throw, caught below
968 throw;
972 catch( const Exception& )
974 DBG_UNHANDLED_EXCEPTION();
976 return NULL;
978 #endif // !DISABLE_SCRIPTING
981 static OUString getConfigurationStringValue(
982 const OUString& rPackage,
983 const OUString& rRelPath,
984 const OUString& rKey,
985 const OUString& rDefaultValue )
987 OUString aDefVal( rDefaultValue );
991 ::comphelper::ConfigurationHelper::readDirectKey(
992 comphelper::getProcessComponentContext(),
993 rPackage,
994 rRelPath,
995 rKey,
996 ::comphelper::ConfigurationHelper::E_READONLY) >>= aDefVal;
998 catch(const com::sun::star::uno::RuntimeException&)
999 { throw; }
1000 catch(const com::sun::star::uno::Exception&)
1003 return aDefVal;
1006 void SfxApplication::OfaExec_Impl( SfxRequest& rReq )
1008 switch ( rReq.GetSlot() )
1010 case SID_OPTIONS_TREEDIALOG:
1012 String sPageURL;
1013 SFX_REQUEST_ARG( rReq, pURLItem, SfxStringItem, SID_OPTIONS_PAGEURL, sal_False );
1014 if ( pURLItem )
1015 sPageURL = pURLItem->GetValue();
1016 const SfxItemSet* pArgs = rReq.GetInternalArgs_Impl();
1017 const SfxPoolItem* pItem = NULL;
1018 Reference < XFrame > xFrame;
1019 if ( pArgs && pArgs->GetItemState( SID_FILLFRAME, sal_False, &pItem ) == SFX_ITEM_SET )
1021 OSL_ENSURE( pItem->ISA( SfxUnoFrameItem ), "SfxApplication::OfaExec_Impl: XFrames are to be transported via SfxUnoFrameItem by now!" );
1022 xFrame = static_cast< const SfxUnoFrameItem*>( pItem )->GetFrame();
1024 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
1025 if ( pFact )
1027 VclAbstractDialog* pDlg =
1028 pFact->CreateFrameDialog( NULL, xFrame, rReq.GetSlot(), sPageURL );
1029 short nRet = pDlg->Execute();
1030 delete pDlg;
1031 SfxViewFrame* pView = SfxViewFrame::GetFirst();
1032 while ( pView )
1034 if (nRet == RET_OK)
1036 SfxObjectShell* pObjSh = pView->GetObjectShell();
1037 if (pObjSh)
1038 pObjSh->SetConfigOptionsChecked(false);
1040 pView->GetBindings().InvalidateAll(sal_False);
1041 pView = SfxViewFrame::GetNext( *pView );
1044 break;
1047 case SID_MORE_DICTIONARIES:
1051 uno::Reference< uno::XComponentContext > xContext =
1052 ::comphelper::getProcessComponentContext();
1053 uno::Reference< css::system::XSystemShellExecute > xSystemShell(
1054 css::system::SystemShellExecute::create(xContext) );
1056 // read repository URL from configuration
1057 OUString sTemplRepoURL =
1058 getConfigurationStringValue(
1059 OUString("org.openoffice.Office.Common"),
1060 OUString("Dictionaries"),
1061 OUString("RepositoryURL"),
1062 OUString());
1064 if ( xSystemShell.is() && !sTemplRepoURL.isEmpty() )
1066 OUStringBuffer aURLBuf( sTemplRepoURL );
1067 aURLBuf.appendAscii(RTL_CONSTASCII_STRINGPARAM("?lang="));
1069 // read locale from configuration
1070 OUString sLocale = getConfigurationStringValue(
1071 OUString("org.openoffice.Setup"),
1072 OUString("L10N"),
1073 OUString("ooLocale"),
1074 OUString("en-US"));
1076 aURLBuf.append( sLocale );
1077 xSystemShell->execute(
1078 aURLBuf.makeStringAndClear(),
1079 OUString(),
1080 css::system::SystemShellExecuteFlags::URIS_ONLY );
1083 catch( const ::com::sun::star::uno::Exception& )
1085 SAL_WARN( "sfx2.appl", "SfxApplication::OfaExec_Impl(SID_MORE_DICTIONARIES): caught an exception!" );
1087 break;
1089 #ifndef DISABLE_SCRIPTING
1090 case SID_BASICIDE_APPEAR:
1092 SfxViewFrame* pView = lcl_getBasicIDEViewFrame( NULL );
1093 if ( !pView )
1095 SfxObjectShell* pBasicIDE = SfxObjectShell::CreateObject( lcl_getBasicIDEServiceName() );
1096 pBasicIDE->DoInitNew( 0 );
1097 pBasicIDE->SetModified( sal_False );
1100 // load the Basic IDE via direct access to the SFX frame loader. A generic loadComponentFromURL
1101 // (which could be done via SfxViewFrame::LoadDocumentIntoFrame) is not feasible here, since the Basic IDE
1102 // does not really play nice with the framework's concept. For instance, it is a "singleton document",
1103 // which conflicts, at the latest, with the framework's concept of loading into _blank frames.
1104 // So, since we know that our frame loader can handle it, we skip the generic framework loader
1105 // mechanism, and the type detection (which doesn't know about the Basic IDE).
1106 Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
1107 Reference< XSynchronousFrameLoader > xLoader(
1108 xContext->getServiceManager()->createInstanceWithContext(SfxFrameLoader_Impl::impl_getStaticImplementationName(), xContext),
1109 UNO_QUERY_THROW );
1110 ::comphelper::NamedValueCollection aLoadArgs;
1111 aLoadArgs.put( "Model", pBasicIDE->GetModel() );
1112 aLoadArgs.put( "URL", OUString( "private:factory/sbasic" ) );
1114 Reference< XFrame > xTargetFrame( lcl_findStartModuleFrame( xContext ) );
1115 if ( !xTargetFrame.is() )
1116 xTargetFrame = SfxFrame::CreateBlankFrame();
1117 ENSURE_OR_THROW( xTargetFrame.is(), "could not obtain a frameto load the Basic IDE into!" );
1119 xLoader->load( aLoadArgs.getPropertyValues(), xTargetFrame );
1121 catch( const Exception& )
1123 DBG_UNHANDLED_EXCEPTION();
1126 pView = lcl_getBasicIDEViewFrame( pBasicIDE );
1127 if ( pView )
1128 pView->SetName( String( RTL_CONSTASCII_USTRINGPARAM( "BASIC:1" ) ) );
1131 if ( pView )
1132 pView->GetFrame().Appear();
1134 const SfxItemSet* pArgs = rReq.GetArgs();
1135 if ( pArgs && pView )
1137 SfxViewShell* pViewShell = pView->GetViewShell();
1138 SfxObjectShell* pObjShell = pView->GetObjectShell();
1139 if ( pViewShell && pObjShell )
1141 SfxRequest aReq( SID_BASICIDE_SHOWWINDOW, SFX_CALLMODE_SYNCHRON, pObjShell->GetPool() );
1142 aReq.SetArgs( *pArgs );
1143 pViewShell->ExecuteSlot( aReq );
1147 rReq.Done();
1149 break;
1151 case SID_BASICCHOOSER:
1153 const SfxItemSet* pArgs = rReq.GetArgs();
1154 const SfxPoolItem* pItem;
1155 sal_Bool bChooseOnly = sal_False;
1156 Reference< XModel > xLimitToModel;
1157 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_RECORDMACRO, sal_False, &pItem) )
1159 sal_Bool bRecord = ((SfxBoolItem*)pItem)->GetValue();
1160 if ( bRecord )
1162 // !Hack
1163 bChooseOnly = sal_False;
1164 SfxObjectShell* pCurrentShell = SfxObjectShell::Current();
1165 OSL_ENSURE( pCurrentShell, "macro recording outside an SFX document?" );
1166 if ( pCurrentShell )
1167 xLimitToModel = pCurrentShell->GetModel();
1171 rReq.SetReturnValue( SfxStringItem( rReq.GetSlot(), ChooseMacro( xLimitToModel, bChooseOnly ) ) );
1172 rReq.Done();
1174 break;
1176 case SID_MACROORGANIZER:
1178 OSL_TRACE("handling SID_MACROORGANIZER");
1179 const SfxItemSet* pArgs = rReq.GetArgs();
1180 const SfxPoolItem* pItem;
1181 sal_Int16 nTabId = 0;
1182 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_MACROORGANIZER, sal_False, &pItem) )
1184 nTabId = ((SfxUInt16Item*)pItem)->GetValue();
1187 SfxApplication::MacroOrganizer( nTabId );
1188 rReq.Done();
1190 break;
1192 case SID_RUNMACRO:
1194 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
1195 OSL_TRACE("SfxApplication::OfaExec_Impl: case ScriptOrg");
1197 Reference< XFrame > xFrame;
1198 const SfxItemSet* pIntSet = rReq.GetInternalArgs_Impl();
1199 SFX_ITEMSET_ARG( pIntSet, pFrameItem, SfxUnoFrameItem, SID_FILLFRAME, sal_False );
1200 if ( pFrameItem )
1201 xFrame = pFrameItem->GetFrame();
1203 if ( !xFrame.is() )
1205 const SfxViewFrame* pViewFrame = SfxViewFrame::Current();
1206 if ( pViewFrame )
1207 xFrame = pViewFrame->GetFrame().GetFrameInterface();
1210 do // artificial loop for flow control
1212 AbstractScriptSelectorDialog* pDlg = pFact->CreateScriptSelectorDialog(
1213 lcl_getDialogParent( xFrame, GetTopWindow() ), sal_False, xFrame );
1214 OSL_ENSURE( pDlg, "SfxApplication::OfaExec_Impl( SID_RUNMACRO ): no dialog!" );
1215 if ( !pDlg )
1216 break;
1217 pDlg->SetRunLabel();
1219 short nDialogResult = pDlg->Execute();
1220 if ( !nDialogResult )
1222 delete pDlg;
1223 break;
1226 Sequence< Any > args;
1227 Sequence< sal_Int16 > outIndex;
1228 Sequence< Any > outArgs;
1229 Any ret;
1231 Reference< XInterface > xScriptContext;
1233 Reference< XController > xController;
1234 if ( xFrame.is() )
1235 xController = xFrame->getController();
1236 if ( xController.is() )
1237 xScriptContext = xController->getModel();
1238 if ( !xScriptContext.is() )
1239 xScriptContext = xController;
1241 SfxObjectShell::CallXScript( xScriptContext, pDlg->GetScriptURL(), args, ret, outIndex, outArgs );
1242 delete pDlg;
1244 while ( false );
1245 rReq.Done();
1247 break;
1249 case SID_SCRIPTORGANIZER:
1251 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
1252 OSL_TRACE("SfxApplication::OfaExec_Impl: case ScriptOrg");
1253 const SfxItemSet* pArgs = rReq.GetArgs();
1254 const SfxPoolItem* pItem;
1255 String aLanguage;
1256 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_SCRIPTORGANIZER, sal_False, &pItem) )
1258 aLanguage = ((SfxScriptOrganizerItem*)pItem)->getLanguage();
1261 OUString aLang( aLanguage );
1262 OSL_TRACE("SfxApplication::OfaExec_Impl: about to create dialog for: %s", OUStringToOString( aLang , RTL_TEXTENCODING_ASCII_US ).pData->buffer);
1263 // not sure about the Window*
1264 VclAbstractDialog* pDlg = pFact->CreateSvxScriptOrgDialog( GetTopWindow(), aLanguage );
1265 if( pDlg )
1267 pDlg->Execute();
1268 delete pDlg;
1270 else
1272 OSL_TRACE("no dialog!!!");
1274 rReq.Done();
1276 break;
1277 #endif // !DISABLE_SCRIPTING
1279 case SID_OFFICE_CHECK_PLZ:
1281 sal_Bool bRet = sal_False;
1282 SFX_REQUEST_ARG(rReq, pStringItem, SfxStringItem, rReq.GetSlot(), sal_False);
1284 if ( pStringItem )
1286 bRet = sal_True /*!!!SfxIniManager::CheckPLZ( aPLZ )*/;
1288 #ifndef DISABLE_SCRIPTING
1289 else
1290 SbxBase::SetError( SbxERR_WRONG_ARGS );
1291 #endif
1292 rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bRet ) );
1294 break;
1296 case SID_AUTO_CORRECT_DLG:
1298 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
1299 if ( pFact )
1301 SfxItemSet aSet(GetPool(), SID_AUTO_CORRECT_DLG, SID_AUTO_CORRECT_DLG);
1302 const SfxPoolItem* pItem=NULL;
1303 const SfxItemSet* pSet = rReq.GetArgs();
1304 SfxItemPool* pSetPool = pSet ? pSet->GetPool() : NULL;
1305 if ( pSet && pSet->GetItemState( pSetPool->GetWhich( SID_AUTO_CORRECT_DLG ), sal_False, &pItem ) == SFX_ITEM_SET )
1306 aSet.Put( *pItem );
1308 SfxAbstractTabDialog* pDlg = pFact->CreateTabDialog( RID_OFA_AUTOCORR_DLG, NULL, &aSet, NULL );
1309 pDlg->Execute();
1310 delete pDlg;
1313 break;
1316 case SID_SD_AUTOPILOT :
1317 case SID_NEWSD :
1319 SvtModuleOptions aModuleOpt;
1320 if ( !aModuleOpt.IsImpress() )
1322 ErrorBox( 0, ResId( RID_ERRBOX_MODULENOTINSTALLED, *GetOffResManager_Impl() )).Execute();
1323 return;
1326 Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
1327 Reference< frame::XDispatchProvider > xProv = drawing::ModuleDispatcher::create( xContext );
1329 OUString aCmd = OUString::createFromAscii( GetInterface()->GetSlot( rReq.GetSlot() )->GetUnoName() );
1330 Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create(xContext) );
1331 Sequence < beans::PropertyValue > aSeq;
1332 if ( rReq.GetArgs() )
1333 TransformItems( rReq.GetSlot(), *rReq.GetArgs(), aSeq );
1334 Any aResult = xHelper->executeDispatch( xProv, aCmd, OUString(), 0, aSeq );
1335 frame::DispatchResultEvent aEvent;
1336 sal_Bool bSuccess = (aResult >>= aEvent) &&
1337 (aEvent.State == frame::DispatchResultState::SUCCESS);
1338 rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bSuccess ) );
1340 break;
1342 case FN_LABEL :
1343 case FN_BUSINESS_CARD :
1344 case FN_XFORMS_INIT :
1346 Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
1347 Reference< frame::XDispatchProvider > xProv = text::ModuleDispatcher::create( xContext );
1349 OUString aCmd = OUString::createFromAscii( GetInterface()->GetSlot( rReq.GetSlot() )->GetUnoName() );
1350 Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create(xContext) );
1351 Sequence < beans::PropertyValue > aSeq;
1352 if ( rReq.GetArgs() )
1353 TransformItems( rReq.GetSlot(), *rReq.GetArgs(), aSeq );
1354 Any aResult = xHelper->executeDispatch( xProv, aCmd, OUString(), 0, aSeq );
1355 frame::DispatchResultEvent aEvent;
1356 sal_Bool bSuccess = (aResult >>= aEvent) &&
1357 (aEvent.State == frame::DispatchResultState::SUCCESS);
1358 rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bSuccess ) );
1360 break;
1362 case SID_ADDRESS_DATA_SOURCE:
1366 Reference< uno::XComponentContext > xORB = ::comphelper::getProcessComponentContext();
1367 Reference< ui::dialogs::XExecutableDialog > xDialog;
1368 xDialog = ui::dialogs::AddressBookSourcePilot::createWithParent(xORB, 0);
1369 xDialog->execute();
1371 catch(const ::com::sun::star::uno::Exception&)
1373 DBG_UNHANDLED_EXCEPTION();
1376 break;
1378 case SID_COMP_BIBLIOGRAPHY:
1379 lcl_tryLoadBibliography();
1380 break;
1384 void SfxApplication::OfaState_Impl(SfxItemSet &rSet)
1386 SvtModuleOptions aModuleOpt;
1388 if( !aModuleOpt.IsWriter())
1390 rSet.DisableItem( FN_LABEL );
1391 rSet.DisableItem( FN_BUSINESS_CARD );
1392 rSet.DisableItem( FN_XFORMS_INIT );
1395 if ( !aModuleOpt.IsImpress() )
1396 rSet.DisableItem( SID_SD_AUTOPILOT );
1399 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */