LCOV - code coverage report
Current view: top level - scripting/source/basprov - baslibnode.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 39 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 7 0.0 %
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 "baslibnode.hxx"
      21             : #include "basmodnode.hxx"
      22             : #include <com/sun/star/script/browse/BrowseNodeTypes.hpp>
      23             : #include <osl/mutex.hxx>
      24             : #include <vcl/svapp.hxx>
      25             : #include <basic/basmgr.hxx>
      26             : #include <basic/sbstar.hxx>
      27             : 
      28             : 
      29             : using namespace ::com::sun::star;
      30             : using namespace ::com::sun::star::lang;
      31             : using namespace ::com::sun::star::uno;
      32             : using namespace ::com::sun::star::script;
      33             : 
      34             : 
      35             : 
      36             : namespace basprov
      37             : {
      38             : 
      39             : 
      40             : 
      41             :     // BasicLibraryNodeImpl
      42             : 
      43             : 
      44           0 :     BasicLibraryNodeImpl::BasicLibraryNodeImpl( const Reference< XComponentContext >& rxContext,
      45             :          const OUString& sScriptingContext, BasicManager* pBasicManager,
      46             :         const Reference< script::XLibraryContainer >& xLibContainer, const OUString& sLibName, bool isAppScript )
      47             :         :m_xContext( rxContext )
      48             :     ,m_sScriptingContext( sScriptingContext )
      49             :         ,m_pBasicManager( pBasicManager )
      50             :         ,m_xLibContainer( xLibContainer )
      51             :         ,m_sLibName( sLibName )
      52           0 :         ,m_bIsAppScript( isAppScript )
      53             :     {
      54           0 :         if ( m_xLibContainer.is() )
      55             :         {
      56           0 :             Any aElement = m_xLibContainer->getByName( m_sLibName );
      57           0 :             aElement >>= m_xLibrary;
      58             :         }
      59           0 :     }
      60             : 
      61             : 
      62             : 
      63           0 :     BasicLibraryNodeImpl::~BasicLibraryNodeImpl()
      64             :     {
      65           0 :     }
      66             : 
      67             : 
      68             :     // XBrowseNode
      69             : 
      70             : 
      71           0 :     OUString BasicLibraryNodeImpl::getName(  ) throw (RuntimeException, std::exception)
      72             :     {
      73           0 :         SolarMutexGuard aGuard;
      74             : 
      75           0 :         return m_sLibName;
      76             :     }
      77             : 
      78             : 
      79             : 
      80           0 :     Sequence< Reference< browse::XBrowseNode > > BasicLibraryNodeImpl::getChildNodes(  ) throw (RuntimeException, std::exception)
      81             :     {
      82           0 :         SolarMutexGuard aGuard;
      83             : 
      84           0 :         Sequence< Reference< browse::XBrowseNode > > aChildNodes;
      85             : 
      86           0 :         if ( m_xLibContainer.is() && m_xLibContainer->hasByName( m_sLibName ) && !m_xLibContainer->isLibraryLoaded( m_sLibName ) )
      87           0 :             m_xLibContainer->loadLibrary( m_sLibName );
      88             : 
      89           0 :         if ( m_pBasicManager )
      90             :         {
      91           0 :             StarBASIC* pBasic = m_pBasicManager->GetLib( m_sLibName );
      92           0 :             if ( pBasic && m_xLibrary.is() )
      93             :             {
      94           0 :                 Sequence< OUString > aNames = m_xLibrary->getElementNames();
      95           0 :                 sal_Int32 nCount = aNames.getLength();
      96           0 :                 const OUString* pNames = aNames.getConstArray();
      97           0 :                 aChildNodes.realloc( nCount );
      98           0 :                 Reference< browse::XBrowseNode >* pChildNodes = aChildNodes.getArray();
      99             : 
     100           0 :                 for ( sal_Int32 i = 0 ; i < nCount ; ++i )
     101             :                 {
     102           0 :                     SbModule* pModule = pBasic->FindModule( pNames[i] );
     103           0 :                     if ( pModule )
     104           0 :                         pChildNodes[i] = static_cast< browse::XBrowseNode* >( new BasicModuleNodeImpl( m_xContext, m_sScriptingContext, pModule, m_bIsAppScript ) );
     105           0 :                 }
     106             :             }
     107             :         }
     108             : 
     109           0 :         return aChildNodes;
     110             :     }
     111             : 
     112             : 
     113             : 
     114           0 :     sal_Bool BasicLibraryNodeImpl::hasChildNodes(  ) throw (RuntimeException, std::exception)
     115             :     {
     116           0 :         SolarMutexGuard aGuard;
     117             : 
     118           0 :         bool bReturn = false;
     119           0 :         if ( m_xLibrary.is() )
     120           0 :             bReturn = m_xLibrary->hasElements();
     121             : 
     122           0 :         return bReturn;
     123             :     }
     124             : 
     125             : 
     126             : 
     127           0 :     sal_Int16 BasicLibraryNodeImpl::getType(  ) throw (RuntimeException, std::exception)
     128             :     {
     129           0 :         SolarMutexGuard aGuard;
     130             : 
     131           0 :         return browse::BrowseNodeTypes::CONTAINER;
     132             :     }
     133             : 
     134             : 
     135             : 
     136             : 
     137             : }   // namespace basprov
     138             : 
     139             : 
     140             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11