1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_scripting.hxx" 30 #include "basmodnode.hxx" 31 #include "basmethnode.hxx" 32 #include <com/sun/star/script/browse/BrowseNodeTypes.hpp> 33 #include <vos/mutex.hxx> 34 #include <vcl/svapp.hxx> 35 #include <basic/sbx.hxx> 36 #include <basic/sbstar.hxx> 37 #include <basic/sbmod.hxx> 38 #include <basic/sbmeth.hxx> 39 40 41 using namespace ::com::sun::star; 42 using namespace ::com::sun::star::lang; 43 using namespace ::com::sun::star::uno; 44 using namespace ::com::sun::star::script; 45 46 47 //......................................................................... 48 namespace basprov 49 { 50 //......................................................................... 51 52 // ============================================================================= 53 // BasicModuleNodeImpl 54 // ============================================================================= 55 56 BasicModuleNodeImpl::BasicModuleNodeImpl( const Reference< XComponentContext >& rxContext, 57 const ::rtl::OUString& sScriptingContext, SbModule* pModule, bool isAppScript ) 58 :m_xContext( rxContext ) 59 ,m_sScriptingContext( sScriptingContext ) 60 ,m_pModule( pModule ) 61 ,m_bIsAppScript( isAppScript ) 62 { 63 } 64 65 // ----------------------------------------------------------------------------- 66 67 BasicModuleNodeImpl::~BasicModuleNodeImpl() 68 { 69 } 70 71 // ----------------------------------------------------------------------------- 72 // XBrowseNode 73 // ----------------------------------------------------------------------------- 74 75 ::rtl::OUString BasicModuleNodeImpl::getName( ) throw (RuntimeException) 76 { 77 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 78 79 ::rtl::OUString sModuleName; 80 if ( m_pModule ) 81 sModuleName = m_pModule->GetName(); 82 83 return sModuleName; 84 } 85 86 // ----------------------------------------------------------------------------- 87 88 Sequence< Reference< browse::XBrowseNode > > BasicModuleNodeImpl::getChildNodes( ) throw (RuntimeException) 89 { 90 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 91 92 Sequence< Reference< browse::XBrowseNode > > aChildNodes; 93 94 if ( m_pModule ) 95 { 96 SbxArray* pMethods = m_pModule->GetMethods(); 97 if ( pMethods ) 98 { 99 sal_Int32 nCount = pMethods->Count(); 100 sal_Int32 nRealCount = 0; 101 for ( sal_Int32 i = 0; i < nCount; ++i ) 102 { 103 SbMethod* pMethod = static_cast< SbMethod* >( pMethods->Get( static_cast< sal_uInt16 >( i ) ) ); 104 if ( pMethod && !pMethod->IsHidden() ) 105 ++nRealCount; 106 } 107 aChildNodes.realloc( nRealCount ); 108 Reference< browse::XBrowseNode >* pChildNodes = aChildNodes.getArray(); 109 110 sal_Int32 iTarget = 0; 111 for ( sal_Int32 i = 0; i < nCount; ++i ) 112 { 113 SbMethod* pMethod = static_cast< SbMethod* >( pMethods->Get( static_cast< sal_uInt16 >( i ) ) ); 114 if ( pMethod && !pMethod->IsHidden() ) 115 pChildNodes[iTarget++] = static_cast< browse::XBrowseNode* >( new BasicMethodNodeImpl( m_xContext, m_sScriptingContext, pMethod, m_bIsAppScript ) ); 116 } 117 } 118 } 119 120 return aChildNodes; 121 } 122 123 // ----------------------------------------------------------------------------- 124 125 sal_Bool BasicModuleNodeImpl::hasChildNodes( ) throw (RuntimeException) 126 { 127 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 128 129 sal_Bool bReturn = sal_False; 130 if ( m_pModule ) 131 { 132 SbxArray* pMethods = m_pModule->GetMethods(); 133 if ( pMethods && pMethods->Count() > 0 ) 134 bReturn = sal_True; 135 } 136 137 return bReturn; 138 } 139 140 // ----------------------------------------------------------------------------- 141 142 sal_Int16 BasicModuleNodeImpl::getType( ) throw (RuntimeException) 143 { 144 ::vos::OGuard aGuard( Application::GetSolarMutex() ); 145 146 return browse::BrowseNodeTypes::CONTAINER; 147 } 148 149 // ----------------------------------------------------------------------------- 150 151 //......................................................................... 152 } // namespace basprov 153 //......................................................................... 154