update dev300-m58
[ooovba.git] / scripting / source / basprov / basmodnode.cxx
blobf9fe5a40a700b6e61e4081d770b2c150c5c8c2d4
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: basmodnode.cxx,v $
10 * $Revision: 1.11 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_scripting.hxx"
33 #include "basmodnode.hxx"
34 #include "basmethnode.hxx"
35 #include <com/sun/star/script/browse/BrowseNodeTypes.hpp>
36 #include <vos/mutex.hxx>
37 #include <vcl/svapp.hxx>
38 #include <basic/sbx.hxx>
39 #include <basic/sbstar.hxx>
40 #include <basic/sbmod.hxx>
41 #include <basic/sbmeth.hxx>
44 using namespace ::com::sun::star;
45 using namespace ::com::sun::star::lang;
46 using namespace ::com::sun::star::uno;
47 using namespace ::com::sun::star::script;
50 //.........................................................................
51 namespace basprov
53 //.........................................................................
55 // =============================================================================
56 // BasicModuleNodeImpl
57 // =============================================================================
59 BasicModuleNodeImpl::BasicModuleNodeImpl( const Reference< XComponentContext >& rxContext,
60 const ::rtl::OUString& sScriptingContext, SbModule* pModule, bool isAppScript )
61 :m_xContext( rxContext )
62 ,m_sScriptingContext( sScriptingContext )
63 ,m_pModule( pModule )
64 ,m_bIsAppScript( isAppScript )
68 // -----------------------------------------------------------------------------
70 BasicModuleNodeImpl::~BasicModuleNodeImpl()
74 // -----------------------------------------------------------------------------
75 // XBrowseNode
76 // -----------------------------------------------------------------------------
78 ::rtl::OUString BasicModuleNodeImpl::getName( ) throw (RuntimeException)
80 ::vos::OGuard aGuard( Application::GetSolarMutex() );
82 ::rtl::OUString sModuleName;
83 if ( m_pModule )
84 sModuleName = m_pModule->GetName();
86 return sModuleName;
89 // -----------------------------------------------------------------------------
91 Sequence< Reference< browse::XBrowseNode > > BasicModuleNodeImpl::getChildNodes( ) throw (RuntimeException)
93 ::vos::OGuard aGuard( Application::GetSolarMutex() );
95 Sequence< Reference< browse::XBrowseNode > > aChildNodes;
97 if ( m_pModule )
99 SbxArray* pMethods = m_pModule->GetMethods();
100 if ( pMethods )
102 sal_Int32 nCount = pMethods->Count();
103 aChildNodes.realloc( nCount );
104 Reference< browse::XBrowseNode >* pChildNodes = aChildNodes.getArray();
106 for ( sal_Int32 i = 0; i < nCount; ++i )
108 SbMethod* pMethod = static_cast< SbMethod* >( pMethods->Get( static_cast< USHORT >( i ) ) );
109 if ( pMethod )
110 pChildNodes[i] = static_cast< browse::XBrowseNode* >( new BasicMethodNodeImpl( m_xContext, m_sScriptingContext, pMethod, m_bIsAppScript ) );
115 return aChildNodes;
118 // -----------------------------------------------------------------------------
120 sal_Bool BasicModuleNodeImpl::hasChildNodes( ) throw (RuntimeException)
122 ::vos::OGuard aGuard( Application::GetSolarMutex() );
124 sal_Bool bReturn = sal_False;
125 if ( m_pModule )
127 SbxArray* pMethods = m_pModule->GetMethods();
128 if ( pMethods && pMethods->Count() > 0 )
129 bReturn = sal_True;
132 return bReturn;
135 // -----------------------------------------------------------------------------
137 sal_Int16 BasicModuleNodeImpl::getType( ) throw (RuntimeException)
139 ::vos::OGuard aGuard( Application::GetSolarMutex() );
141 return browse::BrowseNodeTypes::CONTAINER;
144 // -----------------------------------------------------------------------------
146 //.........................................................................
147 } // namespace basprov
148 //.........................................................................