1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_scripting.hxx" 26 #include "basmodnode.hxx" 27 #include "basmethnode.hxx" 28 #include <com/sun/star/script/browse/BrowseNodeTypes.hpp> 29 #include <vos/mutex.hxx> 30 #include <vcl/svapp.hxx> 31 #include <basic/sbx.hxx> 32 #include <basic/sbstar.hxx> 33 #include <basic/sbmod.hxx> 34 #include <basic/sbmeth.hxx> 35 36 37 using namespace ::com::sun::star; 38 using namespace ::com::sun::star::lang; 39 using namespace ::com::sun::star::uno; 40 using namespace ::com::sun::star::script; 41 42 43 //......................................................................... 44 namespace basprov 45 { 46 //......................................................................... 47 48 // ============================================================================= 49 // BasicModuleNodeImpl 50 // ============================================================================= 51 BasicModuleNodeImpl(const Reference<XComponentContext> & rxContext,const::rtl::OUString & sScriptingContext,SbModule * pModule,bool isAppScript)52 BasicModuleNodeImpl::BasicModuleNodeImpl( const Reference< XComponentContext >& rxContext, 53 const ::rtl::OUString& sScriptingContext, SbModule* pModule, bool isAppScript ) 54 :m_xContext( rxContext ) 55 ,m_sScriptingContext( sScriptingContext ) 56 ,m_pModule( pModule ) 57 ,m_bIsAppScript( isAppScript ) 58 { 59 } 60 61 // ----------------------------------------------------------------------------- 62 ~BasicModuleNodeImpl()63 BasicModuleNodeImpl::~BasicModuleNodeImpl() 64 { 65 } 66 67 // ----------------------------------------------------------------------------- 68 // XBrowseNode 69 // ----------------------------------------------------------------------------- 70 getName()71 ::rtl::OUString BasicModuleNodeImpl::getName( ) throw (RuntimeException) 72 { 73 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 74 75 ::rtl::OUString sModuleName; 76 if ( m_pModule ) 77 sModuleName = m_pModule->GetName(); 78 79 return sModuleName; 80 } 81 82 // ----------------------------------------------------------------------------- 83 getChildNodes()84 Sequence< Reference< browse::XBrowseNode > > BasicModuleNodeImpl::getChildNodes( ) throw (RuntimeException) 85 { 86 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 87 88 Sequence< Reference< browse::XBrowseNode > > aChildNodes; 89 90 if ( m_pModule ) 91 { 92 SbxArray* pMethods = m_pModule->GetMethods(); 93 if ( pMethods ) 94 { 95 sal_Int32 nCount = pMethods->Count(); 96 sal_Int32 nRealCount = 0; 97 for ( sal_Int32 i = 0; i < nCount; ++i ) 98 { 99 SbMethod* pMethod = static_cast< SbMethod* >( pMethods->Get( static_cast< sal_uInt16 >( i ) ) ); 100 if ( pMethod && !pMethod->IsHidden() ) 101 ++nRealCount; 102 } 103 aChildNodes.realloc( nRealCount ); 104 Reference< browse::XBrowseNode >* pChildNodes = aChildNodes.getArray(); 105 106 sal_Int32 iTarget = 0; 107 for ( sal_Int32 i = 0; i < nCount; ++i ) 108 { 109 SbMethod* pMethod = static_cast< SbMethod* >( pMethods->Get( static_cast< sal_uInt16 >( i ) ) ); 110 if ( pMethod && !pMethod->IsHidden() ) 111 pChildNodes[iTarget++] = static_cast< browse::XBrowseNode* >( new BasicMethodNodeImpl( m_xContext, m_sScriptingContext, pMethod, m_bIsAppScript ) ); 112 } 113 } 114 } 115 116 return aChildNodes; 117 } 118 119 // ----------------------------------------------------------------------------- 120 hasChildNodes()121 sal_Bool BasicModuleNodeImpl::hasChildNodes( ) throw (RuntimeException) 122 { 123 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 124 125 sal_Bool bReturn = sal_False; 126 if ( m_pModule ) 127 { 128 SbxArray* pMethods = m_pModule->GetMethods(); 129 if ( pMethods && pMethods->Count() > 0 ) 130 bReturn = sal_True; 131 } 132 133 return bReturn; 134 } 135 136 // ----------------------------------------------------------------------------- 137 getType()138 sal_Int16 BasicModuleNodeImpl::getType( ) throw (RuntimeException) 139 { 140 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 141 142 return browse::BrowseNodeTypes::CONTAINER; 143 } 144 145 // ----------------------------------------------------------------------------- 146 147 //......................................................................... 148 } // namespace basprov 149 //......................................................................... 150