LCOV - code coverage report
Current view: top level - sfx2/source/appl - appbaslib.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 44 71 62.0 %
Date: 2012-08-25 Functions: 10 16 62.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 25 91 27.5 %

           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                 :            : 
      21                 :            : #include "appbaslib.hxx"
      22                 :            : 
      23                 :            : #include <sfx2/sfxuno.hxx>
      24                 :            : #include "sfxtypes.hxx"
      25                 :            : #include <sfx2/app.hxx>
      26                 :            : 
      27                 :            : #include <basic/basmgr.hxx>
      28                 :            : #include <tools/diagnose_ex.h>
      29                 :            : #include <comphelper/processfactory.hxx>
      30                 :            : 
      31                 :            : using namespace ::com::sun::star::uno;
      32                 :            : using namespace ::com::sun::star::lang;
      33                 :            : using namespace ::com::sun::star::script;
      34                 :            : using namespace ::com::sun::star::embed;
      35                 :            : using ::rtl::OUString;
      36                 :            : using ::osl::MutexGuard;
      37                 :            : using ::osl::Mutex;
      38                 :            : 
      39                 :            : //============================================================================
      40                 :       3264 : SfxBasicManagerHolder::SfxBasicManagerHolder()
      41                 :       3264 :     :mpBasicManager( NULL )
      42                 :            : {
      43                 :       3264 : }
      44                 :            : 
      45                 :       3749 : void SfxBasicManagerHolder::reset( BasicManager* _pBasicManager )
      46                 :            : {
      47                 :       3749 :     impl_releaseContainers();
      48                 :            : 
      49                 :            : #ifdef DISABLE_SCRIPTING
      50                 :            :     (void) _pBasicManager;
      51                 :            : #else
      52                 :            :     // Note: we do not delete the old BasicManager. BasicManager instances are
      53                 :            :     // nowadays obtained from the BasicManagerRepository, and the ownership is with
      54                 :            :     // the repository.
      55                 :            :     // @see basic::BasicManagerRepository::getApplicationBasicManager
      56                 :            :     // @see basic::BasicManagerRepository::getDocumentBasicManager
      57                 :       3749 :     mpBasicManager = _pBasicManager;
      58                 :            : 
      59         [ +  + ]:       3749 :     if ( mpBasicManager )
      60                 :            :     {
      61                 :            :         try
      62                 :            :         {
      63 [ +  - ][ +  - ]:        181 :             mxBasicContainer.set( mpBasicManager->GetScriptLibraryContainer(), UNO_QUERY_THROW );
      64 [ +  - ][ +  - ]:        181 :             mxDialogContainer.set( mpBasicManager->GetDialogLibraryContainer(), UNO_QUERY_THROW  );
      65                 :            :         }
      66                 :          0 :         catch( const Exception& )
      67                 :            :         {
      68                 :            :             DBG_UNHANDLED_EXCEPTION();
      69                 :            :         }
      70                 :            :     }
      71                 :            : #endif
      72         [ #  # ]:       3749 : }
      73                 :            : 
      74                 :         62 : void SfxBasicManagerHolder::storeAllLibraries()
      75                 :            : {
      76                 :            : #ifndef DISABLE_SCRIPTING
      77                 :            :     OSL_PRECOND( isValid(), "SfxBasicManagerHolder::storeAllLibraries: not initialized!" );
      78                 :            :     try
      79                 :            :     {
      80         [ +  - ]:         62 :         if ( mxBasicContainer.is() )
      81 [ +  - ][ +  - ]:         62 :             mxBasicContainer->storeLibraries();
      82         [ +  - ]:         62 :         if ( mxDialogContainer.is() )
      83 [ +  - ][ +  - ]:         62 :             mxDialogContainer->storeLibraries();
      84                 :            :     }
      85                 :          0 :     catch( const Exception& )
      86                 :            :     {
      87                 :            :         DBG_UNHANDLED_EXCEPTION();
      88                 :            :     }
      89                 :            : #endif
      90         [ #  # ]:         62 : }
      91                 :            : 
      92                 :        878 : void SfxBasicManagerHolder::setStorage( const Reference< XStorage >& _rxStorage )
      93                 :            : {
      94                 :            : #ifdef DISABLE_SCRIPTING
      95                 :            :     (void) _rxStorage;
      96                 :            : #else
      97                 :            :     try
      98                 :            :     {
      99         [ +  + ]:        878 :         if ( mxBasicContainer.is() )
     100 [ +  - ][ +  - ]:         18 :             mxBasicContainer->setRootStorage( _rxStorage );
     101         [ +  + ]:        878 :         if ( mxDialogContainer.is() )
     102 [ +  - ][ +  - ]:         18 :             mxDialogContainer->setRootStorage( _rxStorage );
     103                 :            :     }
     104                 :          0 :     catch( const Exception& )
     105                 :            :     {
     106                 :            :         DBG_UNHANDLED_EXCEPTION();
     107                 :            :     }
     108                 :            : #endif
     109         [ #  # ]:        878 : }
     110                 :            : 
     111                 :         28 : void SfxBasicManagerHolder::storeLibrariesToStorage( const Reference< XStorage >& _rxStorage )
     112                 :            : {
     113                 :            : #ifdef DISABLE_SCRIPTING
     114                 :            :     (void) _rxStorage;
     115                 :            : #else
     116                 :            :     OSL_PRECOND( isValid(), "SfxBasicManagerHolder::storeLibrariesToStorage: not initialized!" );
     117                 :            : 
     118         [ +  - ]:         28 :     if ( mxBasicContainer.is() )
     119                 :         28 :         mxBasicContainer->storeLibrariesToStorage( _rxStorage );
     120         [ +  - ]:         28 :     if ( mxDialogContainer.is() )
     121                 :         28 :         mxDialogContainer->storeLibrariesToStorage( _rxStorage );
     122                 :            : #endif
     123                 :         28 : }
     124                 :            : 
     125                 :         13 : Reference< XLibraryContainer > SfxBasicManagerHolder::getLibraryContainer( ContainerType _eType )
     126                 :            : {
     127                 :            :     OSL_PRECOND( isValid(), "SfxBasicManagerHolder::getLibraryContainer: not initialized!" );
     128                 :            : 
     129      [ +  -  - ]:         13 :     switch ( _eType )
     130                 :            :     {
     131         [ +  - ]:         13 :     case SCRIPTS:   return mxBasicContainer.get();
     132         [ #  # ]:          0 :     case DIALOGS:   return mxDialogContainer.get();
     133                 :            :     }
     134                 :            :     OSL_FAIL( "SfxBasicManagerHolder::getLibraryContainer: illegal container type!" );
     135                 :         13 :     return NULL;
     136                 :            : }
     137                 :            : 
     138                 :       3749 : void SfxBasicManagerHolder::impl_releaseContainers()
     139                 :            : {
     140                 :       3749 :     mxBasicContainer.clear();
     141                 :       3749 :     mxDialogContainer.clear();
     142                 :       3749 : }
     143                 :            : 
     144                 :            : sal_Bool
     145                 :         20 : SfxBasicManagerHolder::LegacyPsswdBinaryLimitExceeded( Sequence< rtl::OUString >& sModules )
     146                 :            : {
     147                 :            : #ifdef DISABLE_SCRIPTING
     148                 :            :     (void) sModules;
     149                 :            : #else
     150         [ +  - ]:         20 :     if ( mpBasicManager )
     151                 :         20 :         return mpBasicManager->LegacyPsswdBinaryLimitExceeded( sModules );
     152                 :            : #endif
     153                 :         20 :     return sal_True;
     154                 :            : }
     155                 :            : 
     156                 :            : //============================================================================
     157                 :            : // Service for application library container
     158 [ #  # ][ #  # ]:          0 : SFX_IMPL_ONEINSTANCEFACTORY( SfxApplicationDialogLibraryContainer )
                 [ #  # ]
     159                 :            : 
     160                 :          0 : Sequence< OUString > SfxApplicationDialogLibraryContainer::impl_getStaticSupportedServiceNames()
     161                 :            : {
     162 [ #  # ][ #  # ]:          0 :     static Sequence< OUString > seqServiceNames( 1 );
         [ #  # ][ #  # ]
     163                 :            :     static sal_Bool bNeedsInit = sal_True;
     164                 :            : 
     165 [ #  # ][ #  # ]:          0 :     MutexGuard aGuard( Mutex::getGlobalMutex() );
     166         [ #  # ]:          0 :     if( bNeedsInit )
     167                 :            :     {
     168         [ #  # ]:          0 :         OUString* pSeq = seqServiceNames.getArray();
     169                 :          0 :         pSeq[0] = OUString("com.sun.star.script.ApplicationDialogLibraryContainer");
     170                 :          0 :         bNeedsInit = sal_False;
     171                 :            :     }
     172 [ #  # ][ #  # ]:          0 :     return seqServiceNames;
     173                 :            : }
     174                 :            : 
     175                 :        546 : OUString SfxApplicationDialogLibraryContainer::impl_getStaticImplementationName()
     176                 :            : {
     177                 :        546 :     return OUString("com.sun.star.comp.sfx2.ApplicationDialogLibraryContainer");
     178                 :            : }
     179                 :            : 
     180                 :          0 : Reference< XInterface > SAL_CALL SfxApplicationDialogLibraryContainer::impl_createInstance
     181                 :            :     ( const Reference< XMultiServiceFactory >& )
     182                 :            :         throw( Exception )
     183                 :            : {
     184                 :          0 :     SFX_APP()->GetBasicManager();
     185                 :            :     Reference< XInterface > xRet =
     186         [ #  # ]:          0 :         Reference< XInterface >( SFX_APP()->GetDialogContainer(), UNO_QUERY );
     187                 :          0 :     return xRet;
     188                 :            : }
     189                 :            : 
     190                 :            : //============================================================================
     191                 :            : // Service for application library container
     192 [ #  # ][ #  # ]:          0 : SFX_IMPL_ONEINSTANCEFACTORY( SfxApplicationScriptLibraryContainer )
                 [ #  # ]
     193                 :            : 
     194                 :          0 : Sequence< OUString > SfxApplicationScriptLibraryContainer::impl_getStaticSupportedServiceNames()
     195                 :            : {
     196                 :          0 :     Sequence< OUString > seqServiceNames( 1 );
     197         [ #  # ]:          0 :     OUString* pSeq = seqServiceNames.getArray();
     198                 :          0 :     pSeq[0] = OUString("com.sun.star.script.ApplicationScriptLibraryContainer");
     199                 :          0 :     return seqServiceNames;
     200                 :            : }
     201                 :            : 
     202                 :        546 : OUString SfxApplicationScriptLibraryContainer::impl_getStaticImplementationName()
     203                 :            : {
     204                 :        546 :     return OUString("com.sun.star.comp.sfx2.ApplicationScriptLibraryContainer");
     205                 :            : }
     206                 :            : 
     207                 :          0 : Reference< XInterface > SAL_CALL SfxApplicationScriptLibraryContainer::impl_createInstance
     208                 :            :     ( const Reference< XMultiServiceFactory >& )
     209                 :            :         throw( Exception )
     210                 :            : {
     211                 :          0 :     SFX_APP()->GetBasicManager();
     212                 :            :     Reference< XInterface > xRet =
     213         [ #  # ]:          0 :         Reference< XInterface >( SFX_APP()->GetBasicContainer(), UNO_QUERY );
     214                 :          0 :     return xRet;
     215                 :            : }
     216                 :            : 
     217                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10