LCOV - code coverage report
Current view: top level - sfx2/source/appl - appserv.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 23 557 4.1 %
Date: 2014-11-03 Functions: 4 22 18.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #include <config_features.h>
      21             : 
      22             : #include <com/sun/star/document/XEmbeddedScripts.hpp>
      23             : #include <com/sun/star/drawing/ModuleDispatcher.hpp>
      24             : #include <com/sun/star/embed/XStorage.hpp>
      25             : #include <com/sun/star/embed/ElementModes.hpp>
      26             : #include <com/sun/star/frame/Desktop.hpp>
      27             : #include <com/sun/star/frame/DispatchResultEvent.hpp>
      28             : #include <com/sun/star/frame/DispatchResultState.hpp>
      29             : #include <com/sun/star/frame/DispatchHelper.hpp>
      30             : #include <com/sun/star/frame/XDesktop.hpp>
      31             : #include <com/sun/star/frame/XFramesSupplier.hpp>
      32             : #include <com/sun/star/frame/XLayoutManager.hpp>
      33             : #include <com/sun/star/frame/XSynchronousFrameLoader.hpp>
      34             : #include <com/sun/star/sdbc/DriverManager.hpp>
      35             : #include <com/sun/star/system/SystemShellExecute.hpp>
      36             : #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
      37             : #include <com/sun/star/system/SystemShellExecuteException.hpp>
      38             : #include <com/sun/star/task/XJobExecutor.hpp>
      39             : #include <com/sun/star/text/ModuleDispatcher.hpp>
      40             : #include <com/sun/star/ui/dialogs/AddressBookSourcePilot.hpp>
      41             : #include <com/sun/star/uno/Reference.hxx>
      42             : #include <com/sun/star/util/XCloseable.hpp>
      43             : #include <com/sun/star/util/CloseVetoException.hpp>
      44             : #include <org/freedesktop/PackageKit/SyncDbusSessionHelper.hpp>
      45             : 
      46             : #include <com/sun/star/frame/XComponentLoader.hpp>
      47             : 
      48             : #include <comphelper/processfactory.hxx>
      49             : #include <comphelper/storagehelper.hxx>
      50             : 
      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>
      56             : 
      57             : #include <unotools/configmgr.hxx>
      58             : #include <tools/diagnose_ex.h>
      59             : #include <vcl/layout.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>
      72             : 
      73             : #include <unotools/pathoptions.hxx>
      74             : #include <unotools/moduleoptions.hxx>
      75             : #include <svtools/helpopt.hxx>
      76             : #include <toolkit/helper/vclunohelper.hxx>
      77             : #include <unotools/bootstrap.hxx>
      78             : #include <rtl/bootstrap.hxx>
      79             : #include <cppuhelper/exc_hlp.hxx>
      80             : 
      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>
      84             : 
      85             : #include <sfx2/app.hxx>
      86             : #include <sfx2/request.hxx>
      87             : #include <sfx2/dispatch.hxx>
      88             : #include <sfx2/bindings.hxx>
      89             : #include <sfx2/msg.hxx>
      90             : #include <sfx2/objface.hxx>
      91             : #include <sfx2/objitem.hxx>
      92             : #include <sfx2/objsh.hxx>
      93             : #include <sfx2/hintpost.hxx>
      94             : #include <sfx2/viewsh.hxx>
      95             : #include <sfx2/docfac.hxx>
      96             : #include <sfx2/docfile.hxx>
      97             : #include <sfx2/docfilt.hxx>
      98             : #include <sfx2/new.hxx>
      99             : #include "sfxtypes.hxx"
     100             : #include <sfx2/tabdlg.hxx>
     101             : #include "arrdecl.hxx"
     102             : #include <sfx2/sfx.hrc>
     103             : #include "app.hrc"
     104             : #include <sfx2/passwd.hxx>
     105             : #include <sfx2/sfxresid.hxx>
     106             : #include <sfx2/childwin.hxx>
     107             : #include "appdata.hxx"
     108             : #include <sfx2/minfitem.hxx>
     109             : #include <sfx2/event.hxx>
     110             : #include <sfx2/module.hxx>
     111             : #include <sfx2/viewfrm.hxx>
     112             : #include "sfxpicklist.hxx"
     113             : #include "imestatuswindow.hxx"
     114             : #include <sfx2/sfxdlg.hxx>
     115             : #include <sfx2/dialogs.hrc>
     116             : #include "sorgitm.hxx"
     117             : #include <sfx2/sfxhelp.hxx>
     118             : #include <sfx2/zoomitem.hxx>
     119             : #include <sfx2/templatedlg.hxx>
     120             : 
     121             : #include <officecfg/Office/Common.hxx>
     122             : #include <officecfg/Setup.hxx>
     123             : #include <boost/scoped_ptr.hpp>
     124             : 
     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;
     135             : 
     136             : namespace
     137             : {
     138             :     // lp#527938, debian#602953, fdo#33266, i#105408
     139           0 :     static bool lcl_isBaseAvailable()
     140             :     {
     141             :         try
     142             :         {
     143             :             // if we get com::sun::star::sdbc::DriverManager, libsdbc2 is there
     144             :             // and the bibliography is assumed to work
     145           0 :             return com::sun::star::sdbc::DriverManager::create(comphelper::getProcessComponentContext()).is();
     146             :         }
     147           0 :         catch (Exception & e)
     148             :         {
     149             :             SAL_INFO(
     150             :                 "sfx.appl",
     151             :                 "assuming Base to be missing; caught " << e.Message);
     152           0 :             return false;
     153             :         }
     154             :     }
     155           0 :     static void lcl_tryLoadBibliography()
     156             :     {
     157             :         // lp#527938, debian#602953, fdo#33266, i#105408
     158             :         // make sure we actually can instanciate services from base first
     159           0 :         if(!lcl_isBaseAvailable())
     160             :         {
     161             :             try
     162             :             {
     163             :                 using namespace org::freedesktop::PackageKit;
     164             :                 using namespace svtools;
     165           0 :                 Reference< XSyncDbusSessionHelper > xSyncDbusSessionHelper(SyncDbusSessionHelper::create(comphelper::getProcessComponentContext()));
     166           0 :                 Sequence< OUString > vPackages(1);
     167           0 :                 vPackages[0] = "libreoffice-base";
     168           0 :                 OUString sInteraction;
     169           0 :                 xSyncDbusSessionHelper->InstallPackageNames(0, vPackages, sInteraction);
     170             :                 // Ill be back (hopefully)!
     171           0 :                 SolarMutexGuard aGuard;
     172           0 :                 executeRestartDialog(comphelper::getProcessComponentContext(), NULL, RESTART_REASON_BIBLIOGRAPHY_INSTALL);
     173             :             }
     174           0 :             catch (const Exception & e)
     175             :             {
     176             :                 SAL_INFO(
     177             :                     "sfx.appl",
     178             :                     "trying to install LibreOffice Base, caught " << e.Message);
     179             :             }
     180           0 :             return;
     181             :         }
     182             : 
     183             :         try // fdo#48775
     184             :         {
     185           0 :             SfxStringItem aURL(SID_FILE_NAME, OUString(".component:Bibliography/View1"));
     186           0 :             SfxStringItem aRef(SID_REFERER, OUString("private:user"));
     187           0 :             SfxStringItem aTarget(SID_TARGETNAME, OUString("_blank"));
     188           0 :             SfxViewFrame::Current()->GetDispatcher()->Execute( SID_OPENDOC, SfxCallMode::ASYNCHRON, &aURL, &aRef, &aTarget, 0L);
     189             :         }
     190           0 :         catch (const Exception & e)
     191             :         {
     192             :             SAL_INFO( "sfx.appl",
     193             :                       "trying to load bibliography database, caught " << e.Message);
     194             :         }
     195             :     }
     196             : }
     197             : /// Find the correct location of the document (LICENSE.fodt, etc.), and return
     198             : /// it in rURL if found.
     199           0 : static bool checkURL( const char *pName, const char *pExt, OUString &rURL )
     200             : {
     201             :     using namespace osl;
     202           0 :     DirectoryItem aDirItem;
     203             : 
     204           0 :     rURL = "$BRAND_BASE_DIR/" + OUString::createFromAscii( pName ) +
     205           0 :            OUString::createFromAscii( pExt );
     206           0 :     rtl::Bootstrap::expandMacros( rURL );
     207             : 
     208           0 :     if (!rURL.isEmpty())
     209           0 :         return DirectoryItem::get( rURL, aDirItem ) == DirectoryItem::E_None;
     210             :     else
     211           0 :         return false;
     212             : }
     213             : 
     214             : /// Displays CREDITS or LICENSE in any of the available version
     215           0 : static void showDocument( const char* pBaseName )
     216             : {
     217             :     try {
     218           0 :         Reference < XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() );
     219           0 :         Sequence < com::sun::star::beans::PropertyValue > args(2);
     220           0 :         args[0].Name = "ViewOnly";
     221           0 :         args[0].Value <<= sal_True;
     222           0 :         args[1].Name = "ReadOnly";
     223           0 :         args[1].Value <<= sal_True;
     224             : 
     225           0 :         OUString aURL;
     226           0 :         if ( checkURL ( pBaseName, ".fodt", aURL ) ||
     227           0 :              checkURL ( pBaseName, ".html", aURL ) ||
     228           0 :              checkURL ( pBaseName, "", aURL ) ) {
     229           0 :             xDesktop->loadComponentFromURL( aURL, OUString("_blank"), 0, args );
     230           0 :         }
     231           0 :     } catch (const ::com::sun::star::uno::Exception &) {
     232             :     }
     233           0 : }
     234             : 
     235             : namespace
     236             : {
     237           0 :     class LicenseDialog : public ModalDialog
     238             :     {
     239             :     private:
     240             :         DECL_LINK(ShowHdl, void *);
     241             :     public:
     242             :         LicenseDialog(vcl::Window *pParent=NULL);
     243             :     };
     244             : 
     245           0 :     LicenseDialog::LicenseDialog(vcl::Window *pParent)
     246           0 :         : ModalDialog(pParent, "LicenseDialog", "sfx/ui/licensedialog.ui")
     247             :     {
     248           0 :         get<PushButton>("show")->SetClickHdl(LINK(this, LicenseDialog, ShowHdl));
     249           0 :     }
     250             : 
     251           0 :     IMPL_LINK_NOARG(LicenseDialog, ShowHdl)
     252             :     {
     253           0 :         EndDialog(RET_OK);
     254           0 :         showDocument("LICENSE");
     255           0 :         return 0;
     256             :     }
     257             : }
     258             : 
     259           0 : void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
     260             : {
     261           0 :     bool bDone = false;
     262           0 :     switch ( rReq.GetSlot() )
     263             :     {
     264             :         case SID_SETOPTIONS:
     265             :         {
     266           0 :             if( rReq.GetArgs() )
     267           0 :                 SetOptions_Impl( *rReq.GetArgs() );
     268           0 :             break;
     269             :         }
     270             : 
     271             :         case SID_QUITAPP:
     272             :         case SID_EXITANDRETURN:
     273             :         case SID_LOGOUT:
     274             :         {
     275             :             // protect against reentrant calls
     276           0 :             if ( pAppData_Impl->bInQuit )
     277           0 :                 return;
     278             : 
     279           0 :             if ( rReq.GetSlot() == SID_LOGOUT )
     280             :             {
     281           0 :                 for ( SfxObjectShell *pObjSh = SfxObjectShell::GetFirst();
     282             :                     pObjSh; pObjSh = SfxObjectShell::GetNext( *pObjSh ) )
     283             :                 {
     284           0 :                     if ( !pObjSh->IsModified() )
     285           0 :                         continue;
     286             : 
     287           0 :                     SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pObjSh );
     288           0 :                     if ( !pFrame || !pFrame->GetWindow().IsReallyVisible() )
     289           0 :                         continue;
     290             : 
     291           0 :                     if (pObjSh->PrepareClose(true))
     292           0 :                         pObjSh->SetModified( false );
     293             :                     else
     294           0 :                         return;
     295             :                 }
     296             : 
     297           0 :                 SfxStringItem aNameItem( SID_FILE_NAME, OUString("vnd.sun.star.cmd:logout") );
     298           0 :                 SfxStringItem aReferer( SID_REFERER, "private/user" );
     299           0 :                 pAppData_Impl->pAppDispat->Execute( SID_OPENDOC, SfxCallMode::SLOT, &aNameItem, &aReferer, 0L );
     300           0 :                 return;
     301             :             }
     302             : 
     303             :             // aus verschachtelten Requests nach 100ms nochmal probieren
     304           0 :             if( Application::GetDispatchLevel() > 1 )
     305             :             {
     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 automatically
     309             :                    if this dialog is closed by the user ...
     310             :                    So we ignore this request now and wait for a new user decision.
     311             :                 */
     312             :                 OSL_TRACE( "QueryExit => sal_False (DispatchLevel == %u)", Application::GetDispatchLevel() );
     313           0 :                 return;
     314             :             }
     315             : 
     316             :             // block reentrant calls
     317           0 :             pAppData_Impl->bInQuit = true;
     318           0 :             Reference < XDesktop2 > xDesktop = Desktop::create ( ::comphelper::getProcessComponentContext() );
     319             : 
     320           0 :             rReq.ForgetAllArgs();
     321             : 
     322             :             // if terminate() failed, pAppData_Impl->bInQuit will now be sal_False, allowing further calls of SID_QUITAPP
     323           0 :             bool bTerminated = xDesktop->terminate();
     324           0 :             if (!bTerminated)
     325             :                 // if terminate() was successful, SfxApplication is now dead!
     326           0 :                 pAppData_Impl->bInQuit = false;
     327             : 
     328             :             // Set return value, terminate if possible
     329           0 :             rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bTerminated ) );
     330           0 :             return;
     331             :         }
     332             : 
     333             :         case SID_CONFIG:
     334             :         case SID_TOOLBOXOPTIONS:
     335             :         case SID_CONFIGSTATUSBAR:
     336             :         case SID_CONFIGMENU:
     337             :         case SID_CONFIGACCEL:
     338             :         case SID_CONFIGEVENT:
     339             :         {
     340             :             SfxAbstractDialogFactory* pFact =
     341           0 :                 SfxAbstractDialogFactory::Create();
     342             : 
     343           0 :             if ( pFact )
     344             :             {
     345           0 :                 SFX_REQUEST_ARG(rReq, pStringItem,
     346             :                     SfxStringItem, SID_CONFIG, false);
     347             : 
     348             :                 SfxItemSet aSet(
     349           0 :                     GetPool(), SID_CONFIG, SID_CONFIG );
     350             : 
     351           0 :                 if ( pStringItem )
     352             :                 {
     353             :                     aSet.Put( SfxStringItem(
     354           0 :                         SID_CONFIG, pStringItem->GetValue() ) );
     355             :                 }
     356             : 
     357           0 :                 Reference< XFrame > xFrame;
     358           0 :                 const SfxItemSet* pIntSet = rReq.GetInternalArgs_Impl();
     359           0 :                 SFX_ITEMSET_ARG( pIntSet, pFrameItem, SfxUnoFrameItem, SID_FILLFRAME, false );
     360           0 :                 if ( pFrameItem )
     361           0 :                     xFrame = pFrameItem->GetFrame();
     362             : 
     363             :                 boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateTabDialog(
     364             :                     RID_SVXDLG_CUSTOMIZE,
     365           0 :                     NULL, &aSet, xFrame ));
     366             : 
     367           0 :                 if ( pDlg )
     368             :                 {
     369           0 :                     const short nRet = pDlg->Execute();
     370             : 
     371           0 :                     if ( nRet )
     372           0 :                         bDone = true;
     373           0 :                 }
     374             :             }
     375           0 :             break;
     376             :         }
     377             : 
     378             :         case SID_CLOSEDOCS:
     379             :         case SID_CLOSEWINS:
     380             :         {
     381             : 
     382           0 :             Reference < XDesktop2 > xDesktop  = Desktop::create( ::comphelper::getProcessComponentContext() );
     383           0 :             Reference< XIndexAccess > xTasks( xDesktop->getFrames(), UNO_QUERY );
     384           0 :             if ( !xTasks.is() )
     385           0 :                 break;
     386             : 
     387           0 :             sal_Int32 n=0;
     388             :             do
     389             :             {
     390           0 :                 if ( xTasks->getCount() <= n )
     391           0 :                     break;
     392             : 
     393           0 :                 Any aAny = xTasks->getByIndex(n);
     394           0 :                 Reference < XCloseable > xTask;
     395           0 :                 aAny >>= xTask;
     396             :                 try
     397             :                 {
     398           0 :                     xTask->close(sal_True);
     399           0 :                     n++;
     400             :                 }
     401           0 :                 catch( CloseVetoException& )
     402             :                 {
     403           0 :                 }
     404             :             }
     405             :             while( true );
     406             : 
     407           0 :             bool bOk = ( n == 0);
     408           0 :             rReq.SetReturnValue( SfxBoolItem( 0, bOk ) );
     409           0 :             bDone = true;
     410           0 :             break;
     411             :         }
     412             : 
     413             :         case SID_SAVEDOCS:
     414             :         {
     415           0 :             bool bOK = true;
     416           0 :             for ( SfxObjectShell *pObjSh = SfxObjectShell::GetFirst();
     417             :                   pObjSh;
     418             :                   pObjSh = SfxObjectShell::GetNext( *pObjSh ) )
     419             :             {
     420           0 :                 SfxRequest aReq( SID_SAVEDOC, SfxCallMode::SLOT, pObjSh->GetPool() );
     421           0 :                 if ( pObjSh->IsModified() )
     422             :                 {
     423           0 :                     pObjSh->ExecuteSlot( aReq );
     424           0 :                     const SfxBoolItem *pItem = PTR_CAST( SfxBoolItem, aReq.GetReturnValue() );
     425           0 :                     if ( !pItem || !pItem->GetValue() )
     426           0 :                         bOK = false;
     427             :                 }
     428           0 :             }
     429             : 
     430           0 :             rReq.SetReturnValue( SfxBoolItem( 0, bOK ) );
     431           0 :             rReq.Done();
     432           0 :             break;
     433             :         }
     434             : 
     435             :         case SID_SEND_FEEDBACK:
     436             :         {
     437           0 :             OUString module = SfxHelp::GetCurrentModuleIdentifier();
     438           0 :             OUString sURL("http://hub.libreoffice.org/send-feedback/?LOversion=" + utl::ConfigManager::getAboutBoxProductVersion() +
     439           0 :                 "&LOlocale=" + utl::ConfigManager::getLocale() + "&LOmodule=" + module.copy(module.lastIndexOf('.') + 1 )  );
     440             :             try
     441             :             {
     442             :                 uno::Reference< com::sun::star::system::XSystemShellExecute > xSystemShellExecute(
     443           0 :                     com::sun::star::system::SystemShellExecute::create(::comphelper::getProcessComponentContext()) );
     444           0 :                 xSystemShellExecute->execute( sURL, OUString(), com::sun::star::system::SystemShellExecuteFlags::URIS_ONLY );
     445             :             }
     446           0 :             catch ( uno::Exception& )
     447             :             {
     448             :             }
     449           0 :             break;
     450             :         }
     451             : 
     452             :         case SID_SHOW_LICENSE:
     453             :         {
     454           0 :             LicenseDialog aDialog;
     455           0 :             aDialog.Execute();
     456           0 :             break;
     457             :         }
     458             : 
     459             :         case SID_SHOW_CREDITS:
     460             :         {
     461           0 :             showDocument( "CREDITS" );
     462           0 :             break;
     463             :         }
     464             : 
     465             :         // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     466             :         case SID_HELPINDEX:
     467             :         {
     468           0 :             Help* pHelp = Application::GetHelp();
     469           0 :             if ( pHelp )
     470             :             {
     471           0 :                 pHelp->Start( OUString(".uno:HelpIndex"), NULL ); // show start page
     472           0 :                 bDone = true;
     473             :             }
     474           0 :             break;
     475             :         }
     476             : 
     477             :         // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     478             :         case SID_HELPTIPS:
     479             :         {
     480             :             // Evaluate Parameter
     481           0 :             SFX_REQUEST_ARG(rReq, pOnItem, SfxBoolItem, SID_HELPTIPS, false);
     482             :             bool bOn = pOnItem
     483             :                             ? ((SfxBoolItem*)pOnItem)->GetValue()
     484           0 :                             : !Help::IsQuickHelpEnabled();
     485             : 
     486           0 :             if ( bOn )
     487           0 :                 Help::EnableQuickHelp();
     488             :             else
     489           0 :                 Help::DisableQuickHelp();
     490           0 :             SvtHelpOptions().SetHelpTips( bOn );
     491           0 :             Invalidate(SID_HELPTIPS);
     492           0 :             bDone = true;
     493             : 
     494             :             // Record if possible
     495           0 :             if ( !rReq.IsAPI() )
     496           0 :                 rReq.AppendItem( SfxBoolItem( SID_HELPTIPS, bOn) );
     497           0 :             break;
     498             :         }
     499             :         // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     500             :         case SID_EXTENDEDHELP:
     501             :         {
     502           0 :             Help::StartExtHelp();
     503           0 :             break;
     504             :         }
     505             :         case SID_HELPBALLOONS:
     506             :         {
     507             :             // Evaluate Parameter
     508           0 :             SFX_REQUEST_ARG(rReq, pOnItem, SfxBoolItem, SID_HELPBALLOONS, false);
     509             :             bool bOn = pOnItem
     510             :                             ? ((SfxBoolItem*)pOnItem)->GetValue()
     511           0 :                             : !Help::IsBalloonHelpEnabled();
     512             : 
     513           0 :             if ( bOn )
     514           0 :                 Help::EnableBalloonHelp();
     515             :             else
     516           0 :                 Help::DisableBalloonHelp();
     517           0 :             SvtHelpOptions().SetExtendedHelp( bOn );
     518           0 :             Invalidate(SID_HELPBALLOONS);
     519           0 :             bDone = true;
     520             : 
     521             :             // Record if possible
     522           0 :             if ( !rReq.IsAPI() )
     523           0 :                 rReq.AppendItem( SfxBoolItem( SID_HELPBALLOONS, bOn) );
     524           0 :             break;
     525             :         }
     526             : 
     527             :         // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     528             :         case SID_ABOUT:
     529             :         {
     530           0 :             SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
     531           0 :             if ( pFact )
     532             :             {
     533           0 :                 boost::scoped_ptr<VclAbstractDialog> pDlg(pFact->CreateVclDialog( 0, RID_DEFAULTABOUT ));
     534           0 :                 pDlg->Execute();
     535           0 :                 bDone = true;
     536             :             }
     537           0 :             break;
     538             :         }
     539             : 
     540             :         case SID_TEMPLATE_MANAGER:
     541             :         {
     542           0 :             SfxTemplateManagerDlg dlg;
     543           0 :             dlg.Execute();
     544           0 :             bDone = true;
     545           0 :             break;
     546             :         }
     547             : 
     548             :         case SID_TEMPLATE_ADDRESSBOKSOURCE:
     549             :         {
     550           0 :             svt::AddressBookSourceDialog aDialog(GetTopWindow(), ::comphelper::getProcessComponentContext());
     551           0 :             aDialog.Execute();
     552           0 :             bDone = true;
     553           0 :             break;
     554             :         }
     555             : 
     556             : #if HAVE_FEATURE_SCRIPTING
     557             :         case SID_BASICSTOP:
     558           0 :             StarBASIC::Stop();
     559           0 :             break;
     560             : 
     561             :         case SID_BASICBREAK :
     562           0 :             BasicDLL::BasicBreak();
     563           0 :             break;
     564             : #endif
     565             : 
     566             :         case SID_SHOW_IME_STATUS_WINDOW:
     567           0 :             if (pAppData_Impl->m_xImeStatusWindow->canToggle())
     568             :             {
     569             :                 SfxBoolItem const * pItem = static_cast< SfxBoolItem const * >(
     570             :                     rReq.GetArg(SID_SHOW_IME_STATUS_WINDOW, false,
     571           0 :                                 TYPE(SfxBoolItem)));
     572             :                 bool bShow = pItem == 0
     573           0 :                     ? !pAppData_Impl->m_xImeStatusWindow->isShowing()
     574           0 :                     : pItem->GetValue();
     575           0 :                 pAppData_Impl->m_xImeStatusWindow->show(bShow);
     576           0 :                 if (pItem == 0)
     577             :                     rReq.AppendItem(SfxBoolItem(SID_SHOW_IME_STATUS_WINDOW,
     578           0 :                                                 bShow));
     579             :             }
     580           0 :             bDone = true;
     581           0 :             break;
     582             : 
     583             :         case SID_ZOOM_50_PERCENT:
     584             :         case SID_ZOOM_75_PERCENT:
     585             :         case SID_ZOOM_100_PERCENT:
     586             :         case SID_ZOOM_150_PERCENT:
     587             :         case SID_ZOOM_200_PERCENT:
     588             :         case SID_ZOOM_OPTIMAL:
     589             :         case SID_ZOOM_ENTIRE_PAGE:
     590             :         case SID_ZOOM_PAGE_WIDTH:
     591             :         {
     592           0 :             SfxObjectShell* pCurrentShell = SfxObjectShell::Current();
     593           0 :             if (!pCurrentShell)
     594           0 :                 return;
     595             : 
     596             :             // make sure aZoom is initialized with a proper value if SetType
     597             :             // doesn't work
     598           0 :             SvxZoomItem aZoom( SVX_ZOOM_PERCENT, 100 );
     599             : 
     600           0 :             switch (rReq.GetSlot())
     601             :             {
     602             :                 case SID_ZOOM_50_PERCENT:
     603           0 :                     aZoom.SetValue(50);
     604           0 :                     break;
     605             :                 case SID_ZOOM_75_PERCENT:
     606           0 :                     aZoom.SetValue(75);
     607           0 :                     break;
     608             :                 case SID_ZOOM_100_PERCENT:
     609           0 :                     aZoom.SetValue(100);
     610           0 :                     break;
     611             :                 case SID_ZOOM_150_PERCENT:
     612           0 :                     aZoom.SetValue(150);
     613           0 :                     break;
     614             :                 case SID_ZOOM_200_PERCENT:
     615           0 :                     aZoom.SetValue(200);
     616           0 :                     break;
     617             :                 case SID_ZOOM_OPTIMAL:
     618           0 :                     aZoom.SetType( SVX_ZOOM_OPTIMAL );
     619           0 :                     break;
     620             :                 case SID_ZOOM_ENTIRE_PAGE:
     621           0 :                     aZoom.SetType( SVX_ZOOM_WHOLEPAGE );
     622           0 :                     break;
     623             :                 case SID_ZOOM_PAGE_WIDTH:
     624           0 :                     aZoom.SetType( SVX_ZOOM_PAGEWIDTH );
     625           0 :                     break;
     626             :             }
     627             : 
     628           0 :             pCurrentShell->GetDispatcher()->Execute(SID_ATTR_ZOOM, SfxCallMode::ASYNCHRON, &aZoom, 0L);
     629             : 
     630           0 :             break;
     631             :         }
     632             :         case SID_AVAILABLE_TOOLBARS:
     633             :         {
     634             :             SfxStringItem const * pToolbarName = static_cast< SfxStringItem const *>(
     635           0 :                     rReq.GetArg(SID_AVAILABLE_TOOLBARS, false, TYPE(SfxStringItem)));
     636             : 
     637           0 :             if ( pToolbarName )
     638             :             {
     639           0 :                 Reference < XDesktop2 > xDesktop = Desktop::create ( ::comphelper::getProcessComponentContext() );
     640           0 :                 Reference< XFrame > xFrame = xDesktop->getActiveFrame();
     641             : 
     642           0 :                 Reference< com::sun::star::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY );
     643           0 :                 Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
     644           0 :                 if ( xPropSet.is() )
     645             :                 {
     646             :                     try
     647             :                     {
     648           0 :                         Any aValue = xPropSet->getPropertyValue("LayoutManager");
     649           0 :                         aValue >>= xLayoutManager;
     650             :                     }
     651           0 :                     catch ( const ::com::sun::star::uno::RuntimeException& )
     652             :                     {
     653           0 :                         throw;
     654             :                     }
     655           0 :                     catch ( ::com::sun::star::uno::Exception& )
     656             :                     {
     657             :                     }
     658             :                 }
     659             : 
     660           0 :                 if ( xLayoutManager.is() )
     661             :                 {
     662           0 :                     OUString aToolbarResName( "private:resource/toolbar/" );
     663           0 :                     OUStringBuffer aBuf( aToolbarResName );
     664           0 :                     aBuf.append( pToolbarName->GetValue() );
     665             : 
     666             :                     // Evaluate Parameter
     667           0 :                     OUString aToolbarName( aBuf.makeStringAndClear() );
     668           0 :                     bool bShow( !xLayoutManager->isElementVisible( aToolbarName ));
     669             : 
     670           0 :                     if ( bShow )
     671             :                     {
     672           0 :                         xLayoutManager->createElement( aToolbarName );
     673           0 :                         xLayoutManager->showElement( aToolbarName );
     674             :                     }
     675             :                     else
     676           0 :                         xLayoutManager->hideElement( aToolbarName );
     677           0 :                 }
     678             :             }
     679             : 
     680           0 :             bDone = true;
     681           0 :             break;
     682             :         }
     683             : 
     684             :         default:
     685           0 :             break;
     686             :     }
     687             : 
     688           0 :     if ( bDone )
     689           0 :         rReq.Done();
     690             : }
     691             : 
     692             : 
     693             : 
     694        1584 : void SfxApplication::MiscState_Impl(SfxItemSet &rSet)
     695             : {
     696        1584 :     const sal_uInt16 *pRanges = rSet.GetRanges();
     697             :     DBG_ASSERT(pRanges && *pRanges, "Set without range");
     698        4758 :     while ( *pRanges )
     699             :     {
     700        3180 :         for(sal_uInt16 nWhich = *pRanges++; nWhich <= *pRanges; ++nWhich)
     701             :         {
     702        1590 :             switch(nWhich)
     703             :             {
     704             :                 case SID_TEMPLATE_ADDRESSBOKSOURCE:
     705           0 :                     if ( !SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SDATABASE) )
     706           0 :                         rSet.Put(SfxVisibilityItem(nWhich, false));
     707           0 :                     break;
     708             :                 case SID_EXITANDRETURN:
     709             :                 case SID_QUITAPP:
     710             :                 {
     711           0 :                     if ( pAppData_Impl->nDocModalMode )
     712           0 :                         rSet.DisableItem(nWhich);
     713             :                     else
     714           0 :                         rSet.Put(SfxStringItem(nWhich, SfxResId(STR_QUITAPP).toString()));
     715           0 :                     break;
     716             :                 }
     717             : 
     718             :                 case SID_CONFIG:
     719             :                 case SID_TOOLBOXOPTIONS:
     720             :                 case SID_CONFIGSTATUSBAR:
     721             :                 case SID_CONFIGMENU:
     722             :                 case SID_CONFIGACCEL:
     723             :                 case SID_CONFIGEVENT:
     724             :                 {
     725           2 :                     if( SvtMiscOptions().DisableUICustomization() )
     726           0 :                         rSet.DisableItem(nWhich);
     727           2 :                     break;
     728             :                 }
     729             : 
     730             : #if HAVE_FEATURE_SCRIPTING
     731             :                 case SID_BASICSTOP:
     732           0 :                     if ( !StarBASIC::IsRunning() )
     733           0 :                         rSet.DisableItem(nWhich);
     734           0 :                     break;
     735             : #endif
     736             : 
     737             :                 case SID_HELPTIPS:
     738             :                 {
     739           0 :                     rSet.Put( SfxBoolItem( SID_HELPTIPS, Help::IsQuickHelpEnabled() ) );
     740             :                 }
     741           0 :                 break;
     742             :                 case SID_HELPBALLOONS:
     743             :                 {
     744           0 :                     rSet.Put( SfxBoolItem( SID_HELPBALLOONS, Help::IsBalloonHelpEnabled() ) );
     745             :                 }
     746           0 :                 break;
     747             : 
     748             :                 case SID_EXTENDEDHELP:
     749             :                 {
     750             :                 }
     751        1558 :                 break;
     752             : 
     753             :                 case SID_CLOSEDOCS:
     754             :                 case SID_CLOSEWINS:
     755             :                 {
     756           0 :                     Reference < XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() );
     757           0 :                     Reference< XIndexAccess > xTasks( xDesktop->getFrames(), UNO_QUERY );
     758           0 :                     if ( !xTasks.is() || !xTasks->getCount() )
     759           0 :                         rSet.DisableItem(nWhich);
     760           0 :                     break;
     761             :                 }
     762             : 
     763             :                 case SID_SAVEDOCS:
     764             :                 {
     765           0 :                     bool bModified = false;
     766           0 :                     for ( SfxObjectShell *pObjSh = SfxObjectShell::GetFirst();
     767             :                           pObjSh;
     768             :                           pObjSh = SfxObjectShell::GetNext( *pObjSh ) )
     769             :                     {
     770           0 :                         if ( pObjSh->IsModified() )
     771             :                         {
     772           0 :                             bModified = true;
     773           0 :                             break;
     774             :                         }
     775             :                     }
     776             : 
     777           0 :                     if ( !bModified )
     778           0 :                         rSet.DisableItem( nWhich );
     779           0 :                     break;
     780             :                 }
     781             : 
     782             :                 case SID_SHOW_IME_STATUS_WINDOW:
     783          10 :                     if (pAppData_Impl->m_xImeStatusWindow->canToggle())
     784             :                         rSet.Put(SfxBoolItem(
     785             :                                      SID_SHOW_IME_STATUS_WINDOW,
     786             :                                      pAppData_Impl->m_xImeStatusWindow->
     787           0 :                                          isShowing()));
     788             :                     else
     789          10 :                         rSet.DisableItem(SID_SHOW_IME_STATUS_WINDOW);
     790          10 :                     break;
     791             : 
     792             :                 case SID_TEMPLATE_MANAGER:
     793             :                     {
     794           0 :                         SvtMiscOptions aMiscOptions;
     795           0 :                         if ( !aMiscOptions.IsExperimentalMode() )
     796             :                         {
     797           0 :                            rSet.DisableItem( nWhich );
     798           0 :                            rSet.Put( SfxVisibilityItem( nWhich, false ) );
     799           0 :                         }
     800             :                     }
     801           0 :                     break;
     802             : 
     803             :                 case SID_ZOOM_50_PERCENT:
     804             :                 case SID_ZOOM_75_PERCENT:
     805             :                 case SID_ZOOM_100_PERCENT:
     806             :                 case SID_ZOOM_150_PERCENT:
     807             :                 case SID_ZOOM_200_PERCENT:
     808             :                 case SID_ZOOM_OPTIMAL:
     809             :                 case SID_ZOOM_ENTIRE_PAGE:
     810             :                 case SID_ZOOM_PAGE_WIDTH:
     811             :                     {
     812          18 :                         SfxObjectShell* pCurrentShell = SfxObjectShell::Current();
     813             : 
     814             :                         const SfxPoolItem *pItem;
     815             :                         SfxItemState aState = pCurrentShell ?
     816          18 :                             pCurrentShell->GetDispatcher()->QueryState(SID_ATTR_ZOOM, pItem) : SfxItemState::DISABLED;
     817          18 :                         if ( aState == SfxItemState::DISABLED )
     818           0 :                             rSet.DisableItem( nWhich );
     819             :                     }
     820          18 :                     break;
     821             : 
     822             :                 default:
     823           2 :                     break;
     824             :             }
     825             :         }
     826             : 
     827        1590 :         ++pRanges;
     828             :     }
     829        1584 : }
     830             : 
     831             : #if HAVE_FEATURE_SCRIPTING
     832             : 
     833             : #ifndef DISABLE_DYNLOADING
     834             : 
     835             : typedef rtl_uString* (SAL_CALL *basicide_choose_macro)(XModel*, sal_Bool, rtl_uString*);
     836             : typedef void (SAL_CALL *basicide_macro_organizer)( sal_Int16 );
     837             : 
     838           0 : extern "C" { static void SAL_CALL thisModule() {} }
     839             : 
     840             : #else
     841             : 
     842             : extern "C" rtl_uString* basicide_choose_macro(XModel*, sal_Bool, rtl_uString*);
     843             : extern "C" void basicide_macro_organizer( sal_Int16 );
     844             : 
     845             : #endif
     846             : 
     847           0 : OUString ChooseMacro( const Reference< XModel >& rxLimitToDocument, bool bChooseOnly, const OUString& rMacroDesc = OUString() )
     848             : {
     849             : #ifndef DISABLE_DYNLOADING
     850           0 :     osl::Module aMod;
     851             : 
     852             :     // load basctl module
     853           0 :     aMod.loadRelative(&thisModule, SVLIBRARY("basctl"), 0);
     854             : 
     855             :     // get symbol
     856           0 :     basicide_choose_macro pSymbol = (basicide_choose_macro) aMod.getFunctionSymbol("basicide_choose_macro");
     857             :     SAL_WARN_IF(!pSymbol, "sfx.doc", "SfxApplication::MacroOrganizer, no symbol!");
     858           0 :     if (!pSymbol)
     859           0 :         return OUString();
     860           0 :     aMod.release();
     861             : #else
     862             : #define pSymbol basicide_choose_macro
     863             : #endif
     864             : 
     865             :     // call basicide_choose_macro in basctl
     866           0 :     rtl_uString* pScriptURL = pSymbol( rxLimitToDocument.get(), bChooseOnly, rMacroDesc.pData );
     867           0 :     OUString aScriptURL( pScriptURL );
     868           0 :     rtl_uString_release( pScriptURL );
     869           0 :     return aScriptURL;
     870             : 
     871             : #ifdef DISABLE_DYNLOADING
     872             : #undef pSymbol
     873             : #endif
     874             : }
     875             : 
     876             : #endif
     877             : 
     878       11595 : ResMgr* SfxApplication::GetOffResManager_Impl()
     879             : {
     880       11595 :     if ( !pAppData_Impl->pOfaResMgr )
     881         303 :         pAppData_Impl->pOfaResMgr = ResMgr::CreateResMgr( "ofa");
     882       11595 :     return pAppData_Impl->pOfaResMgr;
     883             : }
     884             : 
     885             : namespace
     886             : {
     887             : #if HAVE_FEATURE_SCRIPTING
     888           0 :     vcl::Window* lcl_getDialogParent( const Reference< XFrame >& _rxFrame, vcl::Window* _pFallback )
     889             :     {
     890           0 :         if ( !_rxFrame.is() )
     891           0 :             return _pFallback;
     892             : 
     893             :         try
     894             :         {
     895           0 :             Reference< awt::XWindow > xContainerWindow( _rxFrame->getContainerWindow(), UNO_SET_THROW );
     896           0 :             vcl::Window* pWindow = VCLUnoHelper::GetWindow( xContainerWindow );
     897             :             OSL_ENSURE( pWindow, "lcl_getDialogParent: cool, somebody implemented a VCL-less toolkit!" );
     898             : 
     899           0 :             if ( pWindow )
     900           0 :                 return pWindow->GetSystemWindow();
     901             :         }
     902           0 :         catch( const Exception& )
     903             :         {
     904             :             DBG_UNHANDLED_EXCEPTION();
     905             :         }
     906           0 :         return _pFallback;
     907             :     }
     908             : 
     909           0 :     const OUString& lcl_getBasicIDEServiceName()
     910             :     {
     911           0 :         static const OUString s_sBasicName( "com.sun.star.script.BasicIDE"  );
     912           0 :         return s_sBasicName;
     913             :     }
     914             : 
     915           0 :     SfxViewFrame* lcl_getBasicIDEViewFrame( SfxObjectShell* i_pBasicIDE )
     916             :     {
     917           0 :         SfxViewFrame* pView = SfxViewFrame::GetFirst( i_pBasicIDE );
     918           0 :         while ( pView )
     919             :         {
     920           0 :             if ( pView->GetObjectShell()->GetFactory().GetDocumentServiceName() == lcl_getBasicIDEServiceName() )
     921           0 :                 break;
     922           0 :             pView = SfxViewFrame::GetNext( *pView, i_pBasicIDE );
     923             :         }
     924           0 :         return pView;
     925             :     }
     926           0 :     Reference< XFrame > lcl_findStartModuleFrame( const Reference<XComponentContext> & rxContext )
     927             :     {
     928             :         try
     929             :         {
     930           0 :             Reference < XDesktop2 > xDesktop = Desktop::create( rxContext );
     931           0 :             Reference < XIndexAccess > xContainer( xDesktop->getFrames(), UNO_QUERY_THROW );
     932             : 
     933           0 :             Reference< XModuleManager2 > xCheck = ModuleManager::create(rxContext);
     934             : 
     935           0 :             sal_Int32 nCount = xContainer->getCount();
     936           0 :             for ( sal_Int32 i=0; i<nCount; ++i )
     937             :             {
     938             :                 try
     939             :                 {
     940           0 :                     Reference < XFrame > xFrame( xContainer->getByIndex(i), UNO_QUERY_THROW );
     941           0 :                     OUString sModule = xCheck->identify( xFrame );
     942           0 :                     if ( sModule == "com.sun.star.frame.StartModule" )
     943           0 :                         return xFrame;
     944             :                 }
     945           0 :                 catch( const UnknownModuleException& )
     946             :                 {
     947             :                     // silence
     948             :                 }
     949           0 :                 catch(const Exception&)
     950             :                 {
     951             :                     // re-throw, caught below
     952           0 :                     throw;
     953             :                 }
     954           0 :             }
     955             :         }
     956           0 :         catch( const Exception& )
     957             :         {
     958             :                DBG_UNHANDLED_EXCEPTION();
     959             :         }
     960           0 :         return NULL;
     961             :     }
     962             : #endif // HAVE_FEATURE_SCRIPTING
     963             : }
     964             : 
     965           0 : void SfxApplication::OfaExec_Impl( SfxRequest& rReq )
     966             : {
     967           0 :     switch ( rReq.GetSlot() )
     968             :     {
     969             :         case SID_OPTIONS_TREEDIALOG:
     970             :         {
     971           0 :             OUString sPageURL;
     972           0 :             SFX_REQUEST_ARG( rReq, pURLItem, SfxStringItem, SID_OPTIONS_PAGEURL, false );
     973           0 :             if ( pURLItem )
     974           0 :                 sPageURL = pURLItem->GetValue();
     975           0 :             const SfxItemSet* pArgs = rReq.GetInternalArgs_Impl();
     976           0 :             const SfxPoolItem* pItem = NULL;
     977           0 :             Reference < XFrame > xFrame;
     978           0 :             if ( pArgs && pArgs->GetItemState( SID_FILLFRAME, false, &pItem ) == SfxItemState::SET )
     979             :             {
     980             :                 OSL_ENSURE( pItem->ISA( SfxUnoFrameItem ), "SfxApplication::OfaExec_Impl: XFrames are to be transported via SfxUnoFrameItem by now!" );
     981           0 :                 xFrame = static_cast< const SfxUnoFrameItem*>( pItem )->GetFrame();
     982             :             }
     983           0 :             SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
     984           0 :             if ( pFact )
     985             :             {
     986             :                 VclAbstractDialog* pDlg =
     987           0 :                     pFact->CreateFrameDialog( NULL, xFrame, rReq.GetSlot(), sPageURL );
     988           0 :                 short nRet = pDlg->Execute();
     989           0 :                 delete pDlg;
     990           0 :                 SfxViewFrame* pView = SfxViewFrame::GetFirst();
     991           0 :                 while ( pView )
     992             :                 {
     993           0 :                     if (nRet == RET_OK)
     994             :                     {
     995           0 :                         SfxObjectShell* pObjSh = pView->GetObjectShell();
     996           0 :                         if (pObjSh)
     997           0 :                             pObjSh->SetConfigOptionsChecked(false);
     998             :                     }
     999           0 :                     pView->GetBindings().InvalidateAll(false);
    1000           0 :                     pView = SfxViewFrame::GetNext( *pView );
    1001             :                 }
    1002             :             }
    1003           0 :             break;
    1004             :         }
    1005             : 
    1006             :         case SID_MORE_DICTIONARIES:
    1007             :         {
    1008             :             try
    1009             :             {
    1010             :                 uno::Reference< uno::XComponentContext > xContext =
    1011           0 :                     ::comphelper::getProcessComponentContext();
    1012             :                 uno::Reference< css::system::XSystemShellExecute > xSystemShell(
    1013           0 :                     css::system::SystemShellExecute::create(xContext) );
    1014             : 
    1015             :                 // read repository URL from configuration
    1016           0 :                 OUString sTemplRepoURL(officecfg::Office::Common::Dictionaries::RepositoryURL::get());
    1017             : 
    1018           0 :                 if ( xSystemShell.is() && !sTemplRepoURL.isEmpty() )
    1019             :                 {
    1020           0 :                     OUStringBuffer aURLBuf( sTemplRepoURL );
    1021           0 :                     aURLBuf.append("?lang=");
    1022             : 
    1023             :                     // read locale from configuration
    1024           0 :                     OUString sLocale(officecfg::Setup::L10N::ooLocale::get());
    1025           0 :                     if (sLocale.isEmpty())
    1026           0 :                         sLocale = "en-US";
    1027             : 
    1028           0 :                     aURLBuf.append( sLocale );
    1029           0 :                     xSystemShell->execute(
    1030             :                         aURLBuf.makeStringAndClear(),
    1031             :                         OUString(),
    1032           0 :                         css::system::SystemShellExecuteFlags::URIS_ONLY );
    1033           0 :                 }
    1034             :             }
    1035           0 :             catch( const ::com::sun::star::uno::Exception& )
    1036             :             {
    1037             :                 SAL_WARN( "sfx.appl", "SfxApplication::OfaExec_Impl(SID_MORE_DICTIONARIES): caught an exception!" );
    1038             :             }
    1039           0 :             break;
    1040             :         }
    1041             : #if HAVE_FEATURE_SCRIPTING
    1042             :         case SID_BASICIDE_APPEAR:
    1043             :         {
    1044           0 :             SfxViewFrame* pView = lcl_getBasicIDEViewFrame( NULL );
    1045           0 :             if ( !pView )
    1046             :             {
    1047           0 :                 SfxObjectShell* pBasicIDE = SfxObjectShell::CreateObject( lcl_getBasicIDEServiceName() );
    1048           0 :                 pBasicIDE->DoInitNew( 0 );
    1049           0 :                 pBasicIDE->SetModified( false );
    1050             :                 try
    1051             :                 {
    1052             :                     // load the Basic IDE via direct access to the SFX frame loader. A generic loadComponentFromURL
    1053             :                     // (which could be done via SfxViewFrame::LoadDocumentIntoFrame) is not feasible here, since the Basic IDE
    1054             :                     // does not really play nice with the framework's concept. For instance, it is a "singleton document",
    1055             :                     // which conflicts, at the latest, with the framework's concept of loading into _blank frames.
    1056             :                     // So, since we know that our frame loader can handle it, we skip the generic framework loader
    1057             :                     // mechanism, and the type detection (which doesn't know about the Basic IDE).
    1058           0 :                     Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() );
    1059             :                     Reference< XSynchronousFrameLoader > xLoader(
    1060           0 :                         xContext->getServiceManager()->createInstanceWithContext("com.sun.star.comp.office.FrameLoader", xContext),
    1061           0 :                         UNO_QUERY_THROW );
    1062           0 :                     ::comphelper::NamedValueCollection aLoadArgs;
    1063           0 :                     aLoadArgs.put( "Model", pBasicIDE->GetModel() );
    1064           0 :                     aLoadArgs.put( "URL", OUString( "private:factory/sbasic"  ) );
    1065             : 
    1066           0 :                     Reference< XFrame > xTargetFrame( lcl_findStartModuleFrame( xContext ) );
    1067           0 :                     if ( !xTargetFrame.is() )
    1068           0 :                         xTargetFrame = SfxFrame::CreateBlankFrame();
    1069           0 :                     ENSURE_OR_THROW( xTargetFrame.is(), "could not obtain a frameto load the Basic IDE into!" );
    1070             : 
    1071           0 :                     xLoader->load( aLoadArgs.getPropertyValues(), xTargetFrame );
    1072             :                 }
    1073           0 :                 catch( const Exception& )
    1074             :                 {
    1075             :                     DBG_UNHANDLED_EXCEPTION();
    1076             :                 }
    1077             : 
    1078           0 :                 pView = lcl_getBasicIDEViewFrame( pBasicIDE );
    1079           0 :                 if ( pView )
    1080           0 :                     pView->SetName( OUString( "BASIC:1" ) );
    1081             :             }
    1082             : 
    1083           0 :             if ( pView )
    1084           0 :                 pView->GetFrame().Appear();
    1085             : 
    1086           0 :             const SfxItemSet* pArgs = rReq.GetArgs();
    1087           0 :             if ( pArgs && pView )
    1088             :             {
    1089           0 :                 SfxViewShell* pViewShell = pView->GetViewShell();
    1090           0 :                 SfxObjectShell* pObjShell = pView->GetObjectShell();
    1091           0 :                 if ( pViewShell && pObjShell )
    1092             :                 {
    1093           0 :                     SfxRequest aReq( SID_BASICIDE_SHOWWINDOW, SfxCallMode::SYNCHRON, pObjShell->GetPool() );
    1094           0 :                     aReq.SetArgs( *pArgs );
    1095           0 :                     pViewShell->ExecuteSlot( aReq );
    1096             :                 }
    1097             :             }
    1098             : 
    1099           0 :             rReq.Done();
    1100             :         }
    1101           0 :         break;
    1102             : 
    1103             :         case SID_BASICCHOOSER:
    1104             :         {
    1105           0 :             const SfxItemSet* pArgs = rReq.GetArgs();
    1106             :             const SfxPoolItem* pItem;
    1107           0 :             bool bChooseOnly = false;
    1108           0 :             Reference< XModel > xLimitToModel;
    1109           0 :             if(pArgs && SfxItemState::SET == pArgs->GetItemState(SID_RECORDMACRO, false, &pItem) )
    1110             :             {
    1111           0 :                 bool bRecord = static_cast<const SfxBoolItem*>(pItem)->GetValue();
    1112           0 :                 if ( bRecord )
    1113             :                 {
    1114             :                     // !Hack
    1115           0 :                     bChooseOnly = false;
    1116           0 :                     SfxObjectShell* pCurrentShell = SfxObjectShell::Current();
    1117             :                     OSL_ENSURE( pCurrentShell, "macro recording outside an SFX document?" );
    1118           0 :                     if ( pCurrentShell )
    1119           0 :                         xLimitToModel = pCurrentShell->GetModel();
    1120             :                 }
    1121             :             }
    1122             : 
    1123           0 :             rReq.SetReturnValue( SfxStringItem( rReq.GetSlot(), ChooseMacro( xLimitToModel, bChooseOnly ) ) );
    1124           0 :             rReq.Done();
    1125             :         }
    1126           0 :         break;
    1127             : 
    1128             :         case SID_MACROORGANIZER:
    1129             :         {
    1130             :             OSL_TRACE("handling SID_MACROORGANIZER");
    1131           0 :             const SfxItemSet* pArgs = rReq.GetArgs();
    1132             :             const SfxPoolItem* pItem;
    1133           0 :             sal_Int16 nTabId = 0;
    1134           0 :             if(pArgs && SfxItemState::SET == pArgs->GetItemState(SID_MACROORGANIZER, false, &pItem) )
    1135             :             {
    1136           0 :                 nTabId = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
    1137             :             }
    1138             : 
    1139           0 :             SfxApplication::MacroOrganizer( nTabId );
    1140           0 :             rReq.Done();
    1141             :         }
    1142           0 :         break;
    1143             : 
    1144             :         case SID_RUNMACRO:
    1145             :         {
    1146           0 :             SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
    1147             :             OSL_TRACE("SfxApplication::OfaExec_Impl: case ScriptOrg");
    1148             : 
    1149           0 :             Reference< XFrame > xFrame;
    1150           0 :             const SfxItemSet* pIntSet = rReq.GetInternalArgs_Impl();
    1151           0 :             SFX_ITEMSET_ARG( pIntSet, pFrameItem, SfxUnoFrameItem, SID_FILLFRAME, false );
    1152           0 :             if ( pFrameItem )
    1153           0 :                 xFrame = pFrameItem->GetFrame();
    1154             : 
    1155           0 :             if ( !xFrame.is() )
    1156             :             {
    1157           0 :                 const SfxViewFrame* pViewFrame = SfxViewFrame::Current();
    1158           0 :                 if ( pViewFrame )
    1159           0 :                     xFrame = pViewFrame->GetFrame().GetFrameInterface();
    1160             :             }
    1161             : 
    1162             :             do  // artificial loop for flow control
    1163             :             {
    1164             :                 boost::scoped_ptr<AbstractScriptSelectorDialog> pDlg(pFact->CreateScriptSelectorDialog(
    1165           0 :                     lcl_getDialogParent( xFrame, GetTopWindow() ), false, xFrame ));
    1166             :                 OSL_ENSURE( pDlg, "SfxApplication::OfaExec_Impl( SID_RUNMACRO ): no dialog!" );
    1167           0 :                 if ( !pDlg )
    1168           0 :                     break;
    1169           0 :                 pDlg->SetRunLabel();
    1170             : 
    1171           0 :                 short nDialogResult = pDlg->Execute();
    1172           0 :                 if ( !nDialogResult )
    1173           0 :                     break;
    1174             : 
    1175           0 :                 Sequence< Any > args;
    1176           0 :                 Sequence< sal_Int16 > outIndex;
    1177           0 :                 Sequence< Any > outArgs;
    1178           0 :                 Any ret;
    1179             : 
    1180           0 :                 Reference< XInterface > xScriptContext;
    1181             : 
    1182           0 :                 Reference< XController > xController;
    1183           0 :                 if ( xFrame.is() )
    1184           0 :                     xController = xFrame->getController();
    1185           0 :                 if ( xController.is() )
    1186           0 :                     xScriptContext = xController->getModel();
    1187           0 :                 if ( !xScriptContext.is() )
    1188           0 :                     xScriptContext = xController;
    1189             : 
    1190           0 :                 SfxObjectShell::CallXScript( xScriptContext, pDlg->GetScriptURL(), args, ret, outIndex, outArgs );
    1191             :             }
    1192             :             while ( false );
    1193           0 :             rReq.Done();
    1194             :         }
    1195           0 :         break;
    1196             : 
    1197             :         case SID_SCRIPTORGANIZER:
    1198             :         {
    1199           0 :             SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
    1200             :             OSL_TRACE("SfxApplication::OfaExec_Impl: case ScriptOrg");
    1201           0 :             const SfxItemSet* pArgs = rReq.GetArgs();
    1202             :             const SfxPoolItem* pItem;
    1203           0 :             OUString aLanguage;
    1204           0 :             if(pArgs && SfxItemState::SET == pArgs->GetItemState(SID_SCRIPTORGANIZER, false, &pItem) )
    1205             :             {
    1206           0 :                 aLanguage = static_cast<const SfxScriptOrganizerItem*>(pItem)->getLanguage();
    1207             :             }
    1208             : 
    1209           0 :             OUString aLang( aLanguage );
    1210             :             OSL_TRACE("SfxApplication::OfaExec_Impl: about to create dialog for: %s", OUStringToOString( aLang , RTL_TEXTENCODING_ASCII_US ).pData->buffer);
    1211             :             // not sure about the vcl::Window*
    1212           0 :             VclAbstractDialog* pDlg = pFact->CreateSvxScriptOrgDialog( GetTopWindow(), aLanguage );
    1213           0 :             if( pDlg )
    1214             :             {
    1215           0 :                 pDlg->Execute();
    1216           0 :                 delete pDlg;
    1217             :             }
    1218             :             else
    1219             :             {
    1220             :                 OSL_TRACE("no dialog!!!");
    1221             :             }
    1222           0 :             rReq.Done();
    1223             :         }
    1224           0 :         break;
    1225             : #endif // HAVE_FEATURE_SCRIPTING
    1226             : 
    1227             :         case SID_OFFICE_CHECK_PLZ:
    1228             :         {
    1229           0 :             bool bRet = false;
    1230           0 :             SFX_REQUEST_ARG(rReq, pStringItem, SfxStringItem, rReq.GetSlot(), false);
    1231             : 
    1232           0 :             if ( pStringItem )
    1233             :             {
    1234           0 :                 bRet = true /*!!!SfxIniManager::CheckPLZ( aPLZ )*/;
    1235             :             }
    1236             : #if HAVE_FEATURE_SCRIPTING
    1237             :             else
    1238           0 :                 SbxBase::SetError( SbxERR_WRONG_ARGS );
    1239             : #endif
    1240           0 :             rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bRet ) );
    1241             :         }
    1242           0 :         break;
    1243             : 
    1244             :         case SID_AUTO_CORRECT_DLG:
    1245             :         {
    1246           0 :             SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
    1247           0 :             if ( pFact )
    1248             :             {
    1249           0 :                 SfxItemSet aSet(GetPool(), SID_AUTO_CORRECT_DLG, SID_AUTO_CORRECT_DLG);
    1250           0 :                 const SfxPoolItem* pItem=NULL;
    1251           0 :                 const SfxItemSet* pSet = rReq.GetArgs();
    1252           0 :                 SfxItemPool* pSetPool = pSet ? pSet->GetPool() : NULL;
    1253           0 :                 if ( pSet && pSet->GetItemState( pSetPool->GetWhich( SID_AUTO_CORRECT_DLG ), false, &pItem ) == SfxItemState::SET )
    1254           0 :                     aSet.Put( *pItem );
    1255             : 
    1256           0 :                 boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateTabDialog( RID_OFA_AUTOCORR_DLG, NULL, &aSet, NULL ));
    1257           0 :                 pDlg->Execute();
    1258             :             }
    1259             : 
    1260           0 :             break;
    1261             :         }
    1262             : 
    1263             :         case SID_SD_AUTOPILOT :
    1264             :         case SID_NEWSD :
    1265             :         {
    1266           0 :             SvtModuleOptions aModuleOpt;
    1267           0 :             if ( !aModuleOpt.IsImpress() )
    1268             :             {
    1269           0 :                 MessageDialog( 0, SFX2_RESSTR( STR_MODULENOTINSTALLED )).Execute();
    1270           0 :                 return;
    1271             :             }
    1272             : 
    1273           0 :             Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
    1274           0 :             Reference< frame::XDispatchProvider > xProv = drawing::ModuleDispatcher::create( xContext );
    1275             : 
    1276           0 :             OUString aCmd = OUString::createFromAscii( GetInterface()->GetSlot( rReq.GetSlot() )->GetUnoName() );
    1277           0 :             Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create(xContext) );
    1278           0 :             Sequence < beans::PropertyValue > aSeq;
    1279           0 :             if ( rReq.GetArgs() )
    1280           0 :                 TransformItems( rReq.GetSlot(), *rReq.GetArgs(), aSeq );
    1281           0 :             Any aResult = xHelper->executeDispatch( xProv, aCmd, OUString(), 0, aSeq );
    1282           0 :             frame::DispatchResultEvent aEvent;
    1283           0 :             bool bSuccess = (aResult >>= aEvent) &&
    1284           0 :                                 (aEvent.State == frame::DispatchResultState::SUCCESS);
    1285           0 :             rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bSuccess ) );
    1286             :         }
    1287           0 :         break;
    1288             : 
    1289             :         case FN_LABEL :
    1290             :         case FN_BUSINESS_CARD :
    1291             :         case FN_XFORMS_INIT :
    1292             :         {
    1293           0 :             Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
    1294           0 :             Reference< frame::XDispatchProvider > xProv = text::ModuleDispatcher::create( xContext );
    1295             : 
    1296           0 :             OUString aCmd = OUString::createFromAscii( GetInterface()->GetSlot( rReq.GetSlot() )->GetUnoName() );
    1297           0 :             Reference< frame::XDispatchHelper > xHelper( frame::DispatchHelper::create(xContext) );
    1298           0 :             Sequence < beans::PropertyValue > aSeq;
    1299           0 :             if ( rReq.GetArgs() )
    1300           0 :                 TransformItems( rReq.GetSlot(), *rReq.GetArgs(), aSeq );
    1301           0 :             Any aResult = xHelper->executeDispatch( xProv, aCmd, OUString(), 0, aSeq );
    1302           0 :             frame::DispatchResultEvent aEvent;
    1303           0 :             bool bSuccess = (aResult >>= aEvent) &&
    1304           0 :                                 (aEvent.State == frame::DispatchResultState::SUCCESS);
    1305           0 :             rReq.SetReturnValue( SfxBoolItem( rReq.GetSlot(), bSuccess ) );
    1306             :         }
    1307           0 :         break;
    1308             : 
    1309             :         case SID_ADDRESS_DATA_SOURCE:
    1310             :         {
    1311             :             try
    1312             :             {
    1313           0 :                 Reference< uno::XComponentContext > xORB = ::comphelper::getProcessComponentContext();
    1314           0 :                 Reference< ui::dialogs::XExecutableDialog > xDialog;
    1315           0 :                 xDialog = ui::dialogs::AddressBookSourcePilot::createWithParent(xORB, 0);
    1316           0 :                 xDialog->execute();
    1317             :             }
    1318           0 :             catch(const ::com::sun::star::uno::Exception&)
    1319             :             {
    1320             :                 DBG_UNHANDLED_EXCEPTION();
    1321             :             }
    1322             :         }
    1323           0 :         break;
    1324             : 
    1325             :         case SID_COMP_BIBLIOGRAPHY:
    1326           0 :             lcl_tryLoadBibliography();
    1327           0 :         break;
    1328             :     }
    1329             : }
    1330             : 
    1331           0 : void SfxApplication::OfaState_Impl(SfxItemSet &rSet)
    1332             : {
    1333           0 :     SvtModuleOptions aModuleOpt;
    1334             : 
    1335           0 :     if( !aModuleOpt.IsWriter())
    1336             :     {
    1337           0 :         rSet.DisableItem( FN_LABEL );
    1338           0 :         rSet.DisableItem( FN_BUSINESS_CARD );
    1339           0 :         rSet.DisableItem( FN_XFORMS_INIT );
    1340             :     }
    1341             : 
    1342           0 :     if ( !aModuleOpt.IsImpress() )
    1343           0 :         rSet.DisableItem( SID_SD_AUTOPILOT );
    1344         951 : }
    1345             : 
    1346             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10