LCOV - code coverage report
Current view: top level - sfx2/source/appl - app.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 87 168 51.8 %
Date: 2012-08-25 Functions: 14 30 46.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 99 286 34.6 %

           Branch data     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                 :            : #if defined UNX
      21                 :            : #include <limits.h>
      22                 :            : #else // UNX
      23                 :            : #include <stdlib.h>
      24                 :            : #ifndef PATH_MAX
      25                 :            : #define PATH_MAX _MAX_PATH
      26                 :            : #endif
      27                 :            : #endif // UNX
      28                 :            : 
      29                 :            : #include <sfx2/app.hxx>
      30                 :            : #include <sfx2/frame.hxx>
      31                 :            : #include <basic/basrdll.hxx>
      32                 :            : #include <basic/sbmeth.hxx>
      33                 :            : #include <basic/sbmod.hxx>
      34                 :            : #include <svtools/asynclink.hxx>
      35                 :            : #include <svl/stritem.hxx>
      36                 :            : #include <svl/eitem.hxx>
      37                 :            : #include <svl/urlbmk.hxx>
      38                 :            : #include <vcl/msgbox.hxx>
      39                 :            : #include <svtools/sfxecode.hxx>
      40                 :            : #include <svtools/ehdl.hxx>
      41                 :            : 
      42                 :            : #include <svl/svdde.hxx>
      43                 :            : #include <unotools/tempfile.hxx>
      44                 :            : #include <osl/file.hxx>
      45                 :            : #include <com/sun/star/uno/Sequence.hxx>
      46                 :            : #include <com/sun/star/uno/Any.hxx>
      47                 :            : #include <com/sun/star/lang/XInitialization.hpp>
      48                 :            : #include <com/sun/star/frame/XFrameActionListener.hpp>
      49                 :            : #include <com/sun/star/frame/XComponentLoader.hpp>
      50                 :            : #include <com/sun/star/frame/XFrame.hpp>
      51                 :            : #include <com/sun/star/frame/FrameActionEvent.hpp>
      52                 :            : #include <com/sun/star/frame/FrameAction.hpp>
      53                 :            : #include <com/sun/star/loader/XImplementationLoader.hpp>
      54                 :            : #include <com/sun/star/mozilla/XPluginInstance.hpp>
      55                 :            : #include <com/sun/star/frame/XFramesSupplier.hpp>
      56                 :            : #include <com/sun/star/container/XIndexAccess.hpp>
      57                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      58                 :            : #include <comphelper/processfactory.hxx>
      59                 :            : #include <com/sun/star/uri/XUriReferenceFactory.hpp>
      60                 :            : #include <com/sun/star/uri/XVndSunStarScriptUrl.hpp>
      61                 :            : #include <basic/basmgr.hxx>
      62                 :            : #include <toolkit/helper/vclunohelper.hxx>
      63                 :            : #include <vcl/svapp.hxx>
      64                 :            : #include <rtl/logfile.hxx>
      65                 :            : #include <sfx2/appuno.hxx>
      66                 :            : #include "sfx2/sfxhelp.hxx"
      67                 :            : #include <sfx2/request.hxx>
      68                 :            : #include "sfxtypes.hxx"
      69                 :            : #include "sfx2/sfxresid.hxx"
      70                 :            : #include "arrdecl.hxx"
      71                 :            : #include <sfx2/progress.hxx>
      72                 :            : #include <sfx2/objsh.hxx>
      73                 :            : #include <sfx2/docfac.hxx>
      74                 :            : #include <sfx2/docfile.hxx>
      75                 :            : #include <sfx2/docfilt.hxx>
      76                 :            : #include "fltfnc.hxx"
      77                 :            : #include "nfltdlg.hxx"
      78                 :            : #include <sfx2/new.hxx>
      79                 :            : #include <sfx2/bindings.hxx>
      80                 :            : #include <sfx2/dispatch.hxx>
      81                 :            : #include <sfx2/viewsh.hxx>
      82                 :            : #include <sfx2/genlink.hxx>
      83                 :            : #include <sfx2/viewfrm.hxx>
      84                 :            : #include "appdata.hxx"
      85                 :            : #include "openflag.hxx"
      86                 :            : #include "app.hrc"
      87                 :            : #include "virtmenu.hxx"
      88                 :            : #include <sfx2/module.hxx>
      89                 :            : #include <sfx2/event.hxx>
      90                 :            : #include "imestatuswindow.hxx"
      91                 :            : #include "workwin.hxx"
      92                 :            : #include <sfx2/tbxctrl.hxx>
      93                 :            : #include <sfx2/sfxdlg.hxx>
      94                 :            : #include "sfx2/stbitem.hxx"
      95                 :            : #include "eventsupplier.hxx"
      96                 :            : #include <sfx2/dockwin.hxx>
      97                 :            : 
      98                 :            : #ifdef DBG_UTIL
      99                 :            : #include <sfx2/mnuitem.hxx>
     100                 :            : #endif
     101                 :            : 
     102                 :            : #include <unotools/saveopt.hxx>
     103                 :            : #include <svtools/helpopt.hxx>
     104                 :            : #include <unotools/pathoptions.hxx>
     105                 :            : #include <unotools/viewoptions.hxx>
     106                 :            : #include <unotools/moduleoptions.hxx>
     107                 :            : #include <unotools/historyoptions.hxx>
     108                 :            : #include <svtools/menuoptions.hxx>
     109                 :            : #include <svtools/miscopt.hxx>
     110                 :            : #include <unotools/useroptions.hxx>
     111                 :            : #include <unotools/startoptions.hxx>
     112                 :            : #include <unotools/securityoptions.hxx>
     113                 :            : #include <unotools/localisationoptions.hxx>
     114                 :            : #include <unotools/fontoptions.hxx>
     115                 :            : #include <unotools/internaloptions.hxx>
     116                 :            : #include <unotools/workingsetoptions.hxx>
     117                 :            : #include <unotools/syslocaleoptions.hxx>
     118                 :            : #include <unotools/syslocale.hxx>
     119                 :            : #include <framework/addonsoptions.hxx>
     120                 :            : #include <unotools/extendedsecurityoptions.hxx>
     121                 :            : #include <rtl/instance.hxx>
     122                 :            : #include <rtl/strbuf.hxx>
     123                 :            : 
     124                 :            : using namespace ::com::sun::star;
     125                 :            : 
     126                 :            : // Static member
     127                 :            : SfxApplication* SfxApplication::pApp = NULL;
     128                 :            : #ifndef DISABLE_SCRIPTING
     129                 :            : static BasicDLL*       pBasic   = NULL;
     130                 :            : #endif
     131                 :            : static SfxHelp*        pSfxHelp = NULL;
     132                 :            : 
     133                 :            : namespace
     134                 :            : {
     135                 :            :     class theApplicationMutex
     136                 :            :         : public rtl::Static<osl::Mutex, theApplicationMutex> {};
     137                 :            : }
     138                 :            : 
     139                 :            : #include <framework/imageproducer.hxx>
     140                 :            : #include <framework/sfxhelperfunctions.hxx>
     141                 :            : #include "sfx2/imagemgr.hxx"
     142                 :            : #include "fwkhelper.hxx"
     143                 :            : 
     144                 :     795272 : SfxApplication* SfxApplication::GetOrCreate()
     145                 :            : {
     146                 :            :     // SFX on demand
     147 [ +  - ][ +  - ]:     795272 :     ::osl::MutexGuard aGuard(theApplicationMutex::get());
     148         [ +  + ]:     795272 :     if (!pApp)
     149                 :            :     {
     150                 :            :         RTL_LOGFILE_CONTEXT( aLog, "sfx2 (mb93783) ::SfxApplication::SetApp" );
     151                 :            : 
     152 [ +  - ][ +  - ]:        233 :         pApp = new SfxApplication;
     153                 :            : 
     154                 :            :         // at the moment a bug may occur when Initialize_Impl returns FALSE,
     155                 :            :         // but this is only temporary because all code that may cause such
     156                 :            :         // a fault will be moved outside the SFX
     157         [ +  - ]:        233 :         pApp->Initialize_Impl();
     158                 :            : 
     159         [ +  - ]:        233 :         ::framework::SetImageProducer( GetImage );
     160         [ +  - ]:        233 :         ::framework::SetRefreshToolbars( RefreshToolbars );
     161         [ +  - ]:        233 :         ::framework::SetToolBoxControllerCreator( SfxToolBoxControllerFactory );
     162         [ +  - ]:        233 :         ::framework::SetStatusBarControllerCreator( SfxStatusBarControllerFactory );
     163         [ +  - ]:        233 :         ::framework::SetDockingWindowCreator( SfxDockingWindowFactory );
     164         [ +  - ]:        233 :         ::framework::SetIsDockingWindowVisible( IsDockingWindowVisible );
     165         [ +  - ]:        233 :         ::framework::SetActivateToolPanel( &SfxViewFrame::ActivateToolPanel );
     166                 :            : 
     167         [ +  - ]:        233 :         Application::SetHelp( pSfxHelp );
     168 [ +  - ][ +  - ]:        233 :         if ( SvtHelpOptions().IsHelpTips() )
         [ +  - ][ +  - ]
     169         [ +  - ]:        233 :             Help::EnableQuickHelp();
     170                 :            :         else
     171         [ #  # ]:          0 :             Help::DisableQuickHelp();
     172 [ +  - ][ +  - ]:        233 :         if ( SvtHelpOptions().IsHelpTips() && SvtHelpOptions().IsExtendedHelp() )
         [ +  - ][ +  - ]
         [ +  - ][ -  + ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
           [ -  +  #  #  
                   #  # ]
     173         [ #  # ]:          0 :             Help::EnableBalloonHelp();
     174                 :            :         else
     175         [ +  - ]:        233 :             Help::DisableBalloonHelp();
     176                 :            :     }
     177         [ +  - ]:     795272 :     return pApp;
     178                 :            : }
     179                 :            : 
     180                 :        233 : SfxApplication::SfxApplication()
     181                 :        233 :     : pAppData_Impl( 0 )
     182                 :            : {
     183                 :            :     RTL_LOGFILE_CONTEXT( aLog, "sfx2 (mb93783) ::SfxApplication::SfxApplication" );
     184                 :            : 
     185 [ +  - ][ +  - ]:        233 :     SetName( DEFINE_CONST_UNICODE("StarOffice") );
                 [ +  - ]
     186         [ +  - ]:        233 :     SvtViewOptions::AcquireOptions();
     187                 :            : 
     188 [ +  - ][ +  - ]:        233 :     pAppData_Impl = new SfxAppData_Impl( this );
     189         [ +  - ]:        233 :     pAppData_Impl->m_xImeStatusWindow->init();
     190                 :            : 
     191                 :            :     RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ initialize DDE" );
     192                 :            : 
     193         [ +  - ]:        233 :     sal_Bool bOk = InitializeDde();
     194                 :            : 
     195                 :            : #ifdef DBG_UTIL
     196                 :            :     if( !bOk )
     197                 :            :     {
     198                 :            :         rtl::OStringBuffer aStr(
     199                 :            :             RTL_CONSTASCII_STRINGPARAM("No DDE-Service possible. Error: "));
     200                 :            :         if( GetDdeService() )
     201                 :            :             aStr.append(static_cast<sal_Int32>(GetDdeService()->GetError()));
     202                 :            :         else
     203                 :            :             aStr.append('?');
     204                 :            :         DBG_ASSERT( sal_False, aStr.getStr() );
     205                 :            :     }
     206                 :            : #else
     207                 :            :     (void)bOk;
     208                 :            : #endif
     209                 :            : 
     210 [ +  - ][ +  - ]:        233 :     pSfxHelp = new SfxHelp;
     211                 :            : 
     212                 :            : #ifndef DISABLE_SCRIPTING
     213 [ +  - ][ +  - ]:        233 :     pBasic   = new BasicDLL;
     214 [ +  - ][ +  - ]:        233 :     StarBASIC::SetGlobalErrorHdl( LINK( this, SfxApplication, GlobalBasicErrorHdl_Impl ) );
     215                 :            : #endif
     216                 :            :     RTL_LOGFILE_CONTEXT_TRACE( aLog, "} initialize DDE" );
     217                 :        233 : }
     218                 :            : 
     219                 :        158 : SfxApplication::~SfxApplication()
     220                 :            : {
     221                 :            :     OSL_ENSURE( GetObjectShells_Impl().size() == 0, "Memory leak: some object shells were not removed!" );
     222                 :            : 
     223 [ +  - ][ +  - ]:        158 :     Broadcast( SfxSimpleHint(SFX_HINT_DYING) );
                 [ +  - ]
     224                 :            : 
     225         [ +  - ]:        158 :     SfxModule::DestroyModules_Impl();
     226                 :            : 
     227 [ +  - ][ +  - ]:        158 :     delete pSfxHelp;
     228         [ +  - ]:        158 :     Application::SetHelp( NULL );
     229                 :            : 
     230                 :            :     // delete global options
     231         [ +  - ]:        158 :     SvtViewOptions::ReleaseOptions();
     232                 :            : #ifndef DISABLE_SCRIPTING
     233 [ +  - ][ +  - ]:        158 :     delete pBasic;
     234                 :            : #endif
     235         [ +  - ]:        158 :     if ( !pAppData_Impl->bDowning )
     236         [ +  - ]:        158 :         Deinitialize();
     237                 :            : 
     238 [ +  - ][ +  - ]:        158 :     delete pAppData_Impl;
     239                 :        158 :     pApp = 0;
     240         [ -  + ]:        316 : }
     241                 :            : 
     242                 :            : //====================================================================
     243                 :            : 
     244                 :          0 : const String& SfxApplication::GetLastDir_Impl() const
     245                 :            : 
     246                 :            : /*  [Description]
     247                 :            : 
     248                 :            :     Internal method by which the last set directory with the method
     249                 :            :     <SfxApplication::SetLastDir_Impl()> in SFX is returned.
     250                 :            : 
     251                 :            :     This is usually the most recently addressed by the
     252                 :            :     SfxFileDialog directory.
     253                 :            : 
     254                 :            :     [Cross-reference]
     255                 :            :     <SfxApplication::SetLastDir_Impl()>
     256                 :            : */
     257                 :            : 
     258                 :            : {
     259                 :          0 :     return pAppData_Impl->aLastDir;
     260                 :            : }
     261                 :            : 
     262                 :          0 : const String& SfxApplication::GetLastSaveDirectory() const
     263                 :            : 
     264                 :            : /*  [Description]
     265                 :            : 
     266                 :            :     As <SfxApplication::GetLastDir_Impl()>, only external
     267                 :            : 
     268                 :            :     [Cross-reference]
     269                 :            :     <SfxApplication::GetLastDir_Impl()>
     270                 :            : */
     271                 :            : 
     272                 :            : {
     273                 :          0 :     return GetLastDir_Impl();
     274                 :            : }
     275                 :            : 
     276                 :            : //--------------------------------------------------------------------
     277                 :            : 
     278                 :          0 : void SfxApplication::SetLastDir_Impl
     279                 :            : (
     280                 :            :     const String&   rNewDir     /* Complete directory path as a string */
     281                 :            : )
     282                 :            : 
     283                 :            : /*  [Description]
     284                 :            : 
     285                 :            :     Internal Method, by which a directory path is set that was last addressed
     286                 :            :     (eg by the SfxFileDialog).
     287                 :            : 
     288                 :            :     [Cross-reference]
     289                 :            :     <SfxApplication::GetLastDir_Impl()>
     290                 :            : */
     291                 :            : 
     292                 :            : {
     293                 :          0 :     pAppData_Impl->aLastDir = rNewDir;
     294                 :          0 : }
     295                 :            : 
     296                 :            : //--------------------------------------------------------------------
     297                 :            : 
     298                 :          0 : void SfxApplication::ResetLastDir()
     299                 :            : {
     300         [ #  # ]:          0 :     String aEmpty;
     301 [ #  # ][ #  # ]:          0 :     pAppData_Impl->aLastDir = aEmpty;
     302                 :          0 : }
     303                 :            : 
     304                 :            : //--------------------------------------------------------------------
     305                 :            : 
     306                 :          0 : SfxDispatcher* SfxApplication::GetDispatcher_Impl()
     307                 :            : {
     308         [ #  # ]:          0 :     return pAppData_Impl->pViewFrame? pAppData_Impl->pViewFrame->GetDispatcher(): pAppData_Impl->pAppDispat;
     309                 :            : }
     310                 :            : 
     311                 :            : //--------------------------------------------------------------------
     312                 :       6996 : void SfxApplication::SetViewFrame_Impl( SfxViewFrame *pFrame )
     313                 :            : {
     314         [ +  + ]:       6996 :     if ( pFrame != pAppData_Impl->pViewFrame )
     315                 :            :     {
     316                 :            :         // get the containerframes ( if one of the frames is an InPlaceFrame )
     317                 :       3270 :         SfxViewFrame *pOldContainerFrame = pAppData_Impl->pViewFrame;
     318 [ +  + ][ -  + ]:       3270 :         while ( pOldContainerFrame && pOldContainerFrame->GetParentViewFrame_Impl() )
                 [ -  + ]
     319                 :          0 :             pOldContainerFrame = pOldContainerFrame->GetParentViewFrame_Impl();
     320                 :       3270 :         SfxViewFrame *pNewContainerFrame = pFrame;
     321 [ +  + ][ -  + ]:       3270 :         while ( pNewContainerFrame && pNewContainerFrame->GetParentViewFrame_Impl() )
                 [ -  + ]
     322                 :          0 :             pNewContainerFrame = pNewContainerFrame->GetParentViewFrame_Impl();
     323                 :            : 
     324                 :            :         // DocWinActivate : both frames belong to the same TopWindow
     325                 :            :         // TopWinActivate : both frames belong to different TopWindows
     326                 :            : 
     327                 :       3270 :         sal_Bool bTaskActivate = pOldContainerFrame != pNewContainerFrame;
     328                 :            : 
     329         [ +  + ]:       3270 :         if ( pOldContainerFrame )
     330                 :            :         {
     331         [ +  - ]:       1691 :             if ( bTaskActivate )
     332 [ +  - ][ +  - ]:       1691 :                 NotifyEvent( SfxViewEventHint( SFX_EVENT_DEACTIVATEDOC, GlobalEventConfig::GetEventName(STR_EVENT_DEACTIVATEDOC), pOldContainerFrame->GetObjectShell(), pOldContainerFrame->GetFrame().GetController() ) );
         [ +  - ][ +  - ]
                 [ +  - ]
     333                 :       1691 :             pOldContainerFrame->DoDeactivate( bTaskActivate, pFrame );
     334                 :            : 
     335         [ -  + ]:       1691 :             if( pOldContainerFrame->GetProgress() )
     336                 :          0 :                 pOldContainerFrame->GetProgress()->Suspend();
     337                 :            :         }
     338                 :            : 
     339                 :       3270 :         pAppData_Impl->pViewFrame = pFrame;
     340                 :            : 
     341         [ +  + ]:       3270 :         if( pNewContainerFrame )
     342                 :            :         {
     343                 :       1695 :             pNewContainerFrame->DoActivate( bTaskActivate );
     344 [ +  - ][ +  - ]:       1695 :             if ( bTaskActivate && pNewContainerFrame->GetObjectShell() )
                 [ +  - ]
     345                 :            :             {
     346                 :       1695 :                 pNewContainerFrame->GetObjectShell()->PostActivateEvent_Impl( pNewContainerFrame );
     347 [ +  - ][ +  - ]:       1695 :                 NotifyEvent(SfxViewEventHint(SFX_EVENT_ACTIVATEDOC, GlobalEventConfig::GetEventName(STR_EVENT_ACTIVATEDOC), pNewContainerFrame->GetObjectShell(), pNewContainerFrame->GetFrame().GetController() ) );
         [ +  - ][ +  - ]
                 [ +  - ]
     348                 :            :             }
     349                 :            : 
     350                 :       1695 :             SfxProgress *pProgress = pNewContainerFrame->GetProgress();
     351         [ -  + ]:       1695 :             if ( pProgress )
     352                 :            :             {
     353         [ #  # ]:          0 :                 if( pProgress->IsSuspended() )
     354                 :          0 :                     pProgress->Resume();
     355                 :            :                 else
     356                 :          0 :                     pProgress->SetState( pProgress->GetState() );
     357                 :            :             }
     358                 :            : 
     359         [ +  - ]:       1695 :             if ( pAppData_Impl->pViewFrame->GetViewShell() )
     360                 :            :             {
     361                 :       1695 :                 SfxDispatcher* pDisp = pAppData_Impl->pViewFrame->GetDispatcher();
     362                 :       1695 :                 pDisp->Flush();
     363                 :       1695 :                 pDisp->Update_Impl(sal_True);
     364                 :            :             }
     365                 :            :         }
     366                 :            :     }
     367                 :            : 
     368                 :            :     // even if the frame actually didn't change, ensure its document is forwarded
     369                 :            :     // to SfxObjectShell::SetCurrentComponent.
     370                 :            :     // Otherwise, the CurrentComponent might not be correct, in case it has meanwhile
     371                 :            :     // been reset to some other document, by some non-SFX component.
     372                 :            :     // #i49133# / 2007-12-19 / frank.schoenheit@sun.com
     373 [ +  + ][ +  - ]:       6996 :     if ( pFrame && pFrame->GetViewShell() )
                 [ +  + ]
     374                 :       5421 :         pFrame->GetViewShell()->SetCurrentDocument();
     375                 :       6996 : }
     376                 :            : 
     377                 :            : //---------------------------------------------------------------------
     378                 :            : 
     379                 :       1091 : ResMgr* SfxApplication::CreateResManager( const char *pPrefix )
     380                 :            : {
     381         [ +  - ]:       1091 :     return ResMgr::CreateResMgr(pPrefix);
     382                 :            : }
     383                 :            : 
     384                 :            : //--------------------------------------------------------------------
     385                 :            : 
     386                 :      10374 : ResMgr* SfxApplication::GetSfxResManager()
     387                 :            : {
     388                 :      10374 :     return SfxResId::GetResMgr();
     389                 :            : }
     390                 :            : 
     391                 :            : //------------------------------------------------------------------------
     392                 :            : 
     393                 :          0 : void SfxApplication::SetProgress_Impl
     394                 :            : (
     395                 :            :     SfxProgress *pProgress
     396                 :            : 
     397                 :            : )
     398                 :            : {
     399                 :            :     DBG_ASSERT( ( !pAppData_Impl->pProgress && pProgress ) ||
     400                 :            :                 ( pAppData_Impl->pProgress && !pProgress ),
     401                 :            :                 "Progress acitivation/deacitivation mismatch" );
     402                 :            : 
     403 [ #  # ][ #  # ]:          0 :     if ( pAppData_Impl->pProgress && pProgress )
     404                 :            :     {
     405                 :          0 :         pAppData_Impl->pProgress->Suspend();
     406                 :          0 :         pAppData_Impl->pProgress->UnLock();
     407         [ #  # ]:          0 :         delete pAppData_Impl->pProgress;
     408                 :            :     }
     409                 :            : 
     410                 :          0 :     pAppData_Impl->pProgress = pProgress;
     411                 :          0 : }
     412                 :            : 
     413                 :            : //------------------------------------------------------------------------
     414                 :            : 
     415                 :       1094 : sal_uInt16 SfxApplication::GetFreeIndex()
     416                 :            : {
     417                 :       1094 :     return pAppData_Impl->aIndexBitSet.GetFreeIndex()+1;
     418                 :            : }
     419                 :            : 
     420                 :            : //------------------------------------------------------------------------
     421                 :            : 
     422                 :       1094 : void SfxApplication::ReleaseIndex(sal_uInt16 i)
     423                 :            : {
     424                 :       1094 :     pAppData_Impl->aIndexBitSet.ReleaseIndex(i-1);
     425                 :       1094 : }
     426                 :            : 
     427                 :            : //--------------------------------------------------------------------
     428                 :            : 
     429                 :          0 : Window* SfxApplication::GetTopWindow() const
     430                 :            : {
     431                 :          0 :     SfxWorkWindow* pWork = GetWorkWindow_Impl( SfxViewFrame::Current() );
     432         [ #  # ]:          0 :     return pWork ? pWork->GetWindow() : NULL;
     433                 :            : }
     434                 :            : 
     435                 :      52018 : SfxTbxCtrlFactArr_Impl&     SfxApplication::GetTbxCtrlFactories_Impl() const
     436                 :            : {
     437                 :      52018 :     return *pAppData_Impl->pTbxCtrlFac;
     438                 :            : }
     439                 :            : 
     440                 :       1518 : SfxStbCtrlFactArr_Impl&     SfxApplication::GetStbCtrlFactories_Impl() const
     441                 :            : {
     442                 :       1518 :     return *pAppData_Impl->pStbCtrlFac;
     443                 :            : }
     444                 :            : 
     445                 :          0 : SfxMenuCtrlFactArr_Impl&    SfxApplication::GetMenuCtrlFactories_Impl() const
     446                 :            : {
     447                 :          0 :     return *pAppData_Impl->pMenuCtrlFac;
     448                 :            : }
     449                 :            : 
     450                 :     113539 : SfxViewFrameArr_Impl&       SfxApplication::GetViewFrames_Impl() const
     451                 :            : {
     452                 :     113539 :     return *pAppData_Impl->pViewFrames;
     453                 :            : }
     454                 :            : 
     455                 :       4321 : SfxViewShellArr_Impl&       SfxApplication::GetViewShells_Impl() const
     456                 :            : {
     457                 :       4321 :     return *pAppData_Impl->pViewShells;
     458                 :            : }
     459                 :            : 
     460                 :      26267 : SfxObjectShellArr_Impl&     SfxApplication::GetObjectShells_Impl() const
     461                 :            : {
     462                 :      26267 :     return *pAppData_Impl->pObjShells;
     463                 :            : }
     464                 :            : 
     465                 :          0 : void SfxApplication::Invalidate( sal_uInt16 nId )
     466                 :            : {
     467         [ #  # ]:          0 :     for( SfxViewFrame* pFrame = SfxViewFrame::GetFirst(); pFrame; pFrame = SfxViewFrame::GetNext( *pFrame ) )
     468                 :          0 :         Invalidate_Impl( pFrame->GetBindings(), nId );
     469                 :          0 : }
     470                 :            : 
     471                 :            : #define DOSTRING( x )                       #x
     472                 :            : #define STRING( x )                         DOSTRING( x )
     473                 :            : 
     474                 :            : #ifndef DISABLE_SCRIPTING
     475                 :            : 
     476                 :            : typedef long (SAL_CALL *basicide_handle_basic_error)(void*);
     477                 :            : typedef rtl_uString* (SAL_CALL *basicide_choose_macro)(void*, sal_Bool, rtl_uString*);
     478                 :            : typedef void* (SAL_CALL *basicide_macro_organizer)(sal_Int16);
     479                 :            : 
     480                 :          0 : extern "C" { static void SAL_CALL thisModule() {} }
     481                 :            : 
     482                 :            : #endif
     483                 :            : 
     484                 :          0 : IMPL_LINK( SfxApplication, GlobalBasicErrorHdl_Impl, StarBASIC*, pStarBasic )
     485                 :            : {
     486                 :            : #ifdef DISABLE_SCRIPTING
     487                 :            :     (void) pStarBasic;
     488                 :            :     return 0;
     489                 :            : #else
     490                 :            :     // get basctl dllname
     491 [ #  # ][ #  # ]:          0 :     static ::rtl::OUString aLibName( SVLIBRARY( "basctl"  ) );
     492                 :            : 
     493                 :            :     // load module
     494                 :            :     oslModule handleMod = osl_loadModuleRelative(
     495         [ #  # ]:          0 :         &thisModule, aLibName.pData, 0 );
     496                 :            : 
     497                 :            :     // get symbol
     498                 :          0 :     ::rtl::OUString aSymbol( "basicide_handle_basic_error"  );
     499         [ #  # ]:          0 :     basicide_handle_basic_error pSymbol = (basicide_handle_basic_error) osl_getFunctionSymbol( handleMod, aSymbol.pData );
     500                 :            : 
     501                 :            :     // call basicide_handle_basic_error in basctl
     502 [ #  # ][ #  # ]:          0 :     long nRet = pSymbol ? pSymbol( pStarBasic ) : 0;
     503                 :            : 
     504                 :          0 :     return nRet;
     505                 :            : #endif
     506                 :            : }
     507                 :            : 
     508                 :          0 : sal_Bool SfxApplication::IsXScriptURL( const String& rScriptURL )
     509                 :            : {
     510                 :          0 :     sal_Bool result = sal_False;
     511                 :            : 
     512                 :            : #ifdef DISABLE_SCRIPTING
     513                 :            :     (void) rScriptURL;
     514                 :            : #else
     515                 :            :     ::com::sun::star::uno::Reference
     516                 :            :         < ::com::sun::star::lang::XMultiServiceFactory > xSMgr =
     517         [ #  # ]:          0 :             ::comphelper::getProcessServiceFactory();
     518                 :            : 
     519                 :            :     ::com::sun::star::uno::Reference
     520                 :            :         < ::com::sun::star::uri::XUriReferenceFactory >
     521         [ #  # ]:          0 :             xFactory( xSMgr->createInstance(
     522                 :            :                 ::rtl::OUString(
     523                 :          0 :                     "com.sun.star.uri.UriReferenceFactory" ) ),
     524 [ #  # ][ #  # ]:          0 :                 ::com::sun::star::uno::UNO_QUERY );
     525                 :            : 
     526         [ #  # ]:          0 :     if ( xFactory.is() )
     527                 :            :     {
     528                 :            :         try
     529                 :            :         {
     530                 :            :             ::com::sun::star::uno::Reference
     531                 :            :                 < ::com::sun::star::uri::XVndSunStarScriptUrl >
     532         [ #  # ]:          0 :                     xUrl( xFactory->parse( rScriptURL ),
     533 [ #  # ][ #  # ]:          0 :                         ::com::sun::star::uno::UNO_QUERY );
         [ #  # ][ #  # ]
     534                 :            : 
     535         [ #  # ]:          0 :             if ( xUrl.is() )
     536                 :            :             {
     537                 :          0 :                 result = sal_True;
     538                 :          0 :             }
     539                 :            :         }
     540         [ #  # ]:          0 :         catch (const ::com::sun::star::uno::RuntimeException&)
     541                 :            :         {
     542                 :            :             // ignore, will just return FALSE
     543                 :            :         }
     544                 :            :     }
     545                 :            : #endif
     546                 :          0 :     return result;
     547                 :            : }
     548                 :            : 
     549                 :            : ::rtl::OUString
     550                 :          0 : SfxApplication::ChooseScript()
     551                 :            : {
     552                 :          0 :     ::rtl::OUString aScriptURL;
     553                 :            : 
     554                 :            : #ifndef DISABLE_SCRIPTING
     555         [ #  # ]:          0 :     SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
     556         [ #  # ]:          0 :     if ( pFact )
     557                 :            :     {
     558                 :            :         OSL_TRACE("create selector dialog");
     559                 :            : 
     560         [ #  # ]:          0 :         const SfxViewFrame* pViewFrame = SfxViewFrame::Current();
     561 [ #  # ][ #  # ]:          0 :         const SfxFrame* pFrame = pViewFrame ? &pViewFrame->GetFrame() : NULL;
     562 [ #  # ][ #  # ]:          0 :         uno::Reference< frame::XFrame > xFrame( pFrame ? pFrame->GetFrameInterface() : uno::Reference< frame::XFrame >() );
     563                 :            : 
     564                 :            :           AbstractScriptSelectorDialog* pDlg =
     565         [ #  # ]:          0 :             pFact->CreateScriptSelectorDialog( NULL, sal_False, xFrame );
     566                 :            : 
     567                 :            :         OSL_TRACE("done, now exec it");
     568                 :            : 
     569         [ #  # ]:          0 :           sal_uInt16 nRet = pDlg->Execute();
     570                 :            : 
     571                 :            :         OSL_TRACE("has returned");
     572                 :            : 
     573         [ #  # ]:          0 :         if ( nRet == RET_OK )
     574                 :            :         {
     575 [ #  # ][ #  # ]:          0 :             aScriptURL = pDlg->GetScriptURL();
                 [ #  # ]
     576                 :            :         }
     577                 :            : 
     578 [ #  # ][ #  # ]:          0 :           delete pDlg;
     579                 :            :     }
     580                 :            : #endif
     581                 :          0 :     return aScriptURL;
     582                 :            : }
     583                 :            : 
     584                 :          0 : void SfxApplication::MacroOrganizer( sal_Int16 nTabId )
     585                 :            : {
     586                 :            : #ifdef DISABLE_SCRIPTING
     587                 :            :     (void) nTabId;
     588                 :            : #else
     589                 :            :     // get basctl dllname
     590 [ #  # ][ #  # ]:          0 :     static ::rtl::OUString aLibName( SVLIBRARY( "basctl"  ) );
     591                 :            : 
     592                 :            :     // load module
     593                 :            :     oslModule handleMod = osl_loadModuleRelative(
     594         [ #  # ]:          0 :         &thisModule, aLibName.pData, 0 );
     595                 :            : 
     596                 :            :     // get symbol
     597                 :          0 :     ::rtl::OUString aSymbol( "basicide_macro_organizer"  );
     598         [ #  # ]:          0 :     basicide_macro_organizer pSymbol = (basicide_macro_organizer) osl_getFunctionSymbol( handleMod, aSymbol.pData );
     599                 :            : 
     600                 :            :     // call basicide_choose_macro in basctl
     601         [ #  # ]:          0 :     pSymbol( nTabId );
     602                 :            : #endif
     603                 :          0 : }
     604                 :            : 
     605                 :          0 : ErrCode SfxApplication::CallBasic( const String& rCode, BasicManager* pMgr, SbxArray* pArgs, SbxValue* pRet )
     606                 :            : {
     607                 :            : #ifdef DISABLE_SCRIPTING
     608                 :            :     (void) rCode;
     609                 :            :     (void) pMgr;
     610                 :            :     (void) pArgs;
     611                 :            :     (void) pRet;
     612                 :            :     return ERRCODE_BASIC_CANNOT_LOAD;
     613                 :            : #else
     614                 :          0 :     return pMgr->ExecuteMacro( rCode, pArgs, pRet);
     615                 :            : #endif
     616                 :            : }
     617                 :            : 
     618                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10