LibreOffice Module scripting (master) 1
basmodnode.cxx
Go to the documentation of this file.
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 "basmodnode.hxx"
21#include "basmethnode.hxx"
22#include <com/sun/star/script/browse/BrowseNodeTypes.hpp>
23#include <utility>
24#include <vcl/svapp.hxx>
25#include <basic/sbx.hxx>
26#include <basic/sbmod.hxx>
27#include <basic/sbmeth.hxx>
28
29
30using namespace ::com::sun::star;
31using namespace ::com::sun::star::lang;
32using namespace ::com::sun::star::uno;
33using namespace ::com::sun::star::script;
34
35
36namespace basprov
37{
38
39
40 // BasicModuleNodeImpl
41
42
43 BasicModuleNodeImpl::BasicModuleNodeImpl( const Reference< XComponentContext >& rxContext,
44 OUString sScriptingContext, SbModule* pModule, bool isAppScript )
45 :m_xContext( rxContext )
46 ,m_sScriptingContext(std::move( sScriptingContext ))
47 ,m_pModule( pModule )
48 ,m_bIsAppScript( isAppScript )
49 {
50 }
51
52
54 {
55 }
56
57
58 // XBrowseNode
59
60
62 {
63 SolarMutexGuard aGuard;
64
65 OUString sModuleName;
66 if ( m_pModule )
67 sModuleName = m_pModule->GetName();
68
69 return sModuleName;
70 }
71
72
73 Sequence< Reference< browse::XBrowseNode > > BasicModuleNodeImpl::getChildNodes( )
74 {
75 SolarMutexGuard aGuard;
76
77 Sequence< Reference< browse::XBrowseNode > > aChildNodes;
78
79 if ( m_pModule )
80 {
81 SbxArray* pMethods = m_pModule->GetMethods().get();
82 if ( pMethods )
83 {
84 sal_uInt32 nCount = pMethods->Count();
85 sal_Int32 nRealCount = 0;
86 for ( sal_uInt32 i = 0; i < nCount; ++i )
87 {
88 SbMethod* pMethod = static_cast<SbMethod*>(pMethods->Get(i));
89 if ( pMethod && !pMethod->IsHidden() )
90 ++nRealCount;
91 }
92 aChildNodes.realloc( nRealCount );
93 Reference< browse::XBrowseNode >* pChildNodes = aChildNodes.getArray();
94
95 sal_Int32 iTarget = 0;
96 for ( sal_uInt32 i = 0; i < nCount; ++i )
97 {
98 SbMethod* pMethod = static_cast<SbMethod*>(pMethods->Get(i));
99 if ( pMethod && !pMethod->IsHidden() )
100 pChildNodes[iTarget++] = new BasicMethodNodeImpl(
102 }
103 }
104 }
105
106 return aChildNodes;
107 }
108
109
111 {
112 SolarMutexGuard aGuard;
113
114 bool bReturn = false;
115 if ( m_pModule )
116 {
117 SbxArray* pMethods = m_pModule->GetMethods().get();
118 if (pMethods && pMethods->Count() > 0)
119 bReturn = true;
120 }
121
122 return bReturn;
123 }
124
125
127 {
128 return browse::BrowseNodeTypes::CONTAINER;
129 }
130
131
132} // namespace basprov
133
134
135/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XComponentContext > m_xContext
const SbxArrayRef & GetMethods() const
sal_uInt32 Count() const
SbxVariable * Get(sal_uInt32)
bool IsHidden() const
const OUString & GetName(SbxNameType=SbxNameType::NONE) const
virtual sal_Bool SAL_CALL hasChildNodes() override
Definition: basmodnode.cxx:110
virtual css::uno::Sequence< css::uno::Reference< css::script::browse::XBrowseNode > > SAL_CALL getChildNodes() override
Definition: basmodnode.cxx:73
virtual OUString SAL_CALL getName() override
Definition: basmodnode.cxx:61
virtual sal_Int16 SAL_CALL getType() override
Definition: basmodnode.cxx:126
BasicModuleNodeImpl(const css::uno::Reference< css::uno::XComponentContext > &rxContext, OUString sScriptingContext, SbModule *pModule, bool isAppScript)
Definition: basmodnode.cxx:43
virtual ~BasicModuleNodeImpl() override
Definition: basmodnode.cxx:53
css::uno::Reference< css::uno::XComponentContext > m_xContext
Definition: basmodnode.hxx:42
T * get() const
int nCount
int i
unsigned char sal_Bool