LCOV - code coverage report
Current view: top level - sfx2/source/appl - appbaslib.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 39 55 70.9 %
Date: 2014-11-03 Functions: 10 12 83.3 %
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 "appbaslib.hxx"
      23             : 
      24             : #include <sfx2/sfxuno.hxx>
      25             : #include "sfxtypes.hxx"
      26             : #include <sfx2/app.hxx>
      27             : 
      28             : #include <basic/basmgr.hxx>
      29             : #include <tools/diagnose_ex.h>
      30             : #include <comphelper/processfactory.hxx>
      31             : #include <cppuhelper/weak.hxx>
      32             : 
      33             : using namespace ::com::sun::star::uno;
      34             : using namespace ::com::sun::star::lang;
      35             : using namespace ::com::sun::star::script;
      36             : using namespace ::com::sun::star::embed;
      37             : using ::osl::MutexGuard;
      38             : using ::osl::Mutex;
      39             : 
      40             : 
      41        8713 : SfxBasicManagerHolder::SfxBasicManagerHolder()
      42        8713 :     :mpBasicManager( NULL )
      43             : {
      44        8713 : }
      45             : 
      46       12373 : void SfxBasicManagerHolder::reset( BasicManager* _pBasicManager )
      47             : {
      48       12373 :     impl_releaseContainers();
      49             : 
      50             : #if !HAVE_FEATURE_SCRIPTING
      51             :     (void) _pBasicManager;
      52             : #else
      53             :     // Note: we do not delete the old BasicManager. BasicManager instances are
      54             :     // nowadays obtained from the BasicManagerRepository, and the ownership is with
      55             :     // the repository.
      56             :     // @see basic::BasicManagerRepository::getApplicationBasicManager
      57             :     // @see basic::BasicManagerRepository::getDocumentBasicManager
      58       12373 :     mpBasicManager = _pBasicManager;
      59             : 
      60       12373 :     if ( mpBasicManager )
      61             :     {
      62             :         try
      63             :         {
      64        3800 :             mxBasicContainer.set( mpBasicManager->GetScriptLibraryContainer(), UNO_QUERY_THROW );
      65        3800 :             mxDialogContainer.set( mpBasicManager->GetDialogLibraryContainer(), UNO_QUERY_THROW  );
      66             :         }
      67           0 :         catch( const Exception& )
      68             :         {
      69             :             DBG_UNHANDLED_EXCEPTION();
      70             :         }
      71             :     }
      72             : #endif
      73       12373 : }
      74             : 
      75          64 : void SfxBasicManagerHolder::storeAllLibraries()
      76             : {
      77             : #if HAVE_FEATURE_SCRIPTING
      78             :     OSL_PRECOND( isValid(), "SfxBasicManagerHolder::storeAllLibraries: not initialized!" );
      79             :     try
      80             :     {
      81          64 :         if ( mxBasicContainer.is() )
      82          64 :             mxBasicContainer->storeLibraries();
      83          64 :         if ( mxDialogContainer.is() )
      84          64 :             mxDialogContainer->storeLibraries();
      85             :     }
      86           0 :     catch( const Exception& )
      87             :     {
      88             :         DBG_UNHANDLED_EXCEPTION();
      89             :     }
      90             : #endif
      91          64 : }
      92             : 
      93        1158 : void SfxBasicManagerHolder::setStorage( const Reference< XStorage >& _rxStorage )
      94             : {
      95             : #if !HAVE_FEATURE_SCRIPTING
      96             :     (void) _rxStorage;
      97             : #else
      98             :     try
      99             :     {
     100        1158 :         if ( mxBasicContainer.is() )
     101        1148 :             mxBasicContainer->setRootStorage( _rxStorage );
     102        1158 :         if ( mxDialogContainer.is() )
     103        1148 :             mxDialogContainer->setRootStorage( _rxStorage );
     104             :     }
     105           0 :     catch( const Exception& )
     106             :     {
     107             :         DBG_UNHANDLED_EXCEPTION();
     108             :     }
     109             : #endif
     110        1158 : }
     111             : 
     112        1212 : void SfxBasicManagerHolder::storeLibrariesToStorage( const Reference< XStorage >& _rxStorage )
     113             : {
     114             : #if !HAVE_FEATURE_SCRIPTING
     115             :     (void) _rxStorage;
     116             : #else
     117             :     OSL_PRECOND( isValid(), "SfxBasicManagerHolder::storeLibrariesToStorage: not initialized!" );
     118             : 
     119        1212 :     if ( mxBasicContainer.is() )
     120        1212 :         mxBasicContainer->storeLibrariesToStorage( _rxStorage );
     121        1212 :     if ( mxDialogContainer.is() )
     122        1212 :         mxDialogContainer->storeLibrariesToStorage( _rxStorage );
     123             : #endif
     124        1212 : }
     125             : 
     126          96 : XLibraryContainer * SfxBasicManagerHolder::getLibraryContainer( ContainerType _eType )
     127             : {
     128             :     OSL_PRECOND( isValid(), "SfxBasicManagerHolder::getLibraryContainer: not initialized!" );
     129             : 
     130          96 :     switch ( _eType )
     131             :     {
     132          96 :     case SCRIPTS:   return mxBasicContainer.get();
     133           0 :     case DIALOGS:   return mxDialogContainer.get();
     134             :     }
     135             :     OSL_FAIL( "SfxBasicManagerHolder::getLibraryContainer: illegal container type!" );
     136           0 :     return NULL;
     137             : }
     138             : 
     139       12373 : void SfxBasicManagerHolder::impl_releaseContainers()
     140             : {
     141       12373 :     mxBasicContainer.clear();
     142       12373 :     mxDialogContainer.clear();
     143       12373 : }
     144             : 
     145          66 : bool SfxBasicManagerHolder::LegacyPsswdBinaryLimitExceeded( Sequence< OUString >& sModules )
     146             : {
     147             : #if !HAVE_FEATURE_SCRIPTING
     148             :     (void) sModules;
     149             : #else
     150          66 :     if ( mpBasicManager )
     151          66 :         return mpBasicManager->LegacyPsswdBinaryLimitExceeded( sModules );
     152             : #endif
     153           0 :     return true;
     154             : }
     155             : 
     156             : // Service for application library container
     157             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
     158           0 : com_sun_star_comp_sfx2_ApplicationDialogLibraryContainer_get_implementation(
     159             :     css::uno::XComponentContext *,
     160             :     css::uno::Sequence<css::uno::Any> const &)
     161             : {
     162           0 :     SfxGetpApp()->GetBasicManager();
     163           0 :     css::uno::XInterface* pRet = SfxGetpApp()->GetDialogContainer();
     164           0 :     pRet->acquire();
     165           0 :     return pRet;
     166             : }
     167             : 
     168             : // Service for application library container
     169             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
     170           0 : com_sun_star_comp_sfx2_ApplicationScriptLibraryContainer_get_implementation(
     171             :     css::uno::XComponentContext *,
     172             :     css::uno::Sequence<css::uno::Any> const &)
     173             : {
     174           0 :     SfxGetpApp()->GetBasicManager();
     175           0 :     css::uno::XInterface* pRet = SfxGetpApp()->GetBasicContainer();
     176           0 :     pRet->acquire();
     177           0 :     return pRet;
     178         951 : }
     179             : 
     180             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10