1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: basmodnode.cxx,v $
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 //.........................................................................
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
)
64 ,m_bIsAppScript( isAppScript
)
68 // -----------------------------------------------------------------------------
70 BasicModuleNodeImpl::~BasicModuleNodeImpl()
74 // -----------------------------------------------------------------------------
76 // -----------------------------------------------------------------------------
78 ::rtl::OUString
BasicModuleNodeImpl::getName( ) throw (RuntimeException
)
80 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
82 ::rtl::OUString sModuleName
;
84 sModuleName
= m_pModule
->GetName();
89 // -----------------------------------------------------------------------------
91 Sequence
< Reference
< browse::XBrowseNode
> > BasicModuleNodeImpl::getChildNodes( ) throw (RuntimeException
)
93 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
95 Sequence
< Reference
< browse::XBrowseNode
> > aChildNodes
;
99 SbxArray
* pMethods
= m_pModule
->GetMethods();
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
) ) );
110 pChildNodes
[i
] = static_cast< browse::XBrowseNode
* >( new BasicMethodNodeImpl( m_xContext
, m_sScriptingContext
, pMethod
, m_bIsAppScript
) );
118 // -----------------------------------------------------------------------------
120 sal_Bool
BasicModuleNodeImpl::hasChildNodes( ) throw (RuntimeException
)
122 ::vos::OGuard
aGuard( Application::GetSolarMutex() );
124 sal_Bool bReturn
= sal_False
;
127 SbxArray
* pMethods
= m_pModule
->GetMethods();
128 if ( pMethods
&& pMethods
->Count() > 0 )
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 //.........................................................................