xref: /aoo41x/main/sc/source/ui/vba/vbaglobals.cxx (revision b3f79822)
1*b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b3f79822SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b3f79822SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b3f79822SAndrew Rist  * distributed with this work for additional information
6*b3f79822SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b3f79822SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b3f79822SAndrew Rist  * "License"); you may not use this file except in compliance
9*b3f79822SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*b3f79822SAndrew Rist  *
11*b3f79822SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*b3f79822SAndrew Rist  *
13*b3f79822SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b3f79822SAndrew Rist  * software distributed under the License is distributed on an
15*b3f79822SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b3f79822SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b3f79822SAndrew Rist  * specific language governing permissions and limitations
18*b3f79822SAndrew Rist  * under the License.
19*b3f79822SAndrew Rist  *
20*b3f79822SAndrew Rist  *************************************************************/
21*b3f79822SAndrew Rist 
22*b3f79822SAndrew Rist 
23cdf0e10cSrcweir #include <vbahelper/helperdecl.hxx>
24cdf0e10cSrcweir #include "vbaglobals.hxx"
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <comphelper/unwrapargs.hxx>
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <com/sun/star/lang/XMultiComponentFactory.hpp>
29cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
30cdf0e10cSrcweir #include <cppuhelper/component_context.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include "vbaapplication.hxx"
33cdf0e10cSrcweir #include "vbaworksheet.hxx"
34cdf0e10cSrcweir #include "vbarange.hxx"
35cdf0e10cSrcweir #include <cppuhelper/bootstrap.hxx>
36cdf0e10cSrcweir using namespace ::com::sun::star;
37cdf0e10cSrcweir using namespace ::com::sun::star::uno;
38cdf0e10cSrcweir using namespace ::ooo::vba;
39cdf0e10cSrcweir 
40cdf0e10cSrcweir 
41cdf0e10cSrcweir 
42cdf0e10cSrcweir // =============================================================================
43cdf0e10cSrcweir // ScVbaGlobals
44cdf0e10cSrcweir // =============================================================================
45cdf0e10cSrcweir 
46cdf0e10cSrcweir //ScVbaGlobals::ScVbaGlobals(  css::uno::Reference< css::uno::XComponentContext >const& rxContext,  ) : ScVbaGlobals_BASE( uno::Reference< XHelperInterface >(), rxContext )
47cdf0e10cSrcweir rtl::OUString sDocCtxName( RTL_CONSTASCII_USTRINGPARAM("ExcelDocumentContext") );
48cdf0e10cSrcweir 
ScVbaGlobals(uno::Sequence<uno::Any> const & aArgs,uno::Reference<uno::XComponentContext> const & rxContext)49cdf0e10cSrcweir ScVbaGlobals::ScVbaGlobals( uno::Sequence< uno::Any > const& aArgs, uno::Reference< uno::XComponentContext >const& rxContext ) : ScVbaGlobals_BASE( uno::Reference< XHelperInterface >(), rxContext, sDocCtxName )
50cdf0e10cSrcweir {
51cdf0e10cSrcweir 	OSL_TRACE("ScVbaGlobals::ScVbaGlobals()");
52cdf0e10cSrcweir 
53cdf0e10cSrcweir         uno::Sequence< beans::PropertyValue > aInitArgs( 2 );
54cdf0e10cSrcweir         aInitArgs[ 0 ].Name = rtl::OUString::createFromAscii("Application");
55cdf0e10cSrcweir         aInitArgs[ 0 ].Value = uno::makeAny( getApplication() );
56cdf0e10cSrcweir         aInitArgs[ 1 ].Name = sDocCtxName;
57cdf0e10cSrcweir         aInitArgs[ 1 ].Value = uno::makeAny( getXSomethingFromArgs< frame::XModel >( aArgs, 0 ) );
58cdf0e10cSrcweir 
59cdf0e10cSrcweir         init( aInitArgs );
60cdf0e10cSrcweir }
61cdf0e10cSrcweir 
~ScVbaGlobals()62cdf0e10cSrcweir ScVbaGlobals::~ScVbaGlobals()
63cdf0e10cSrcweir {
64cdf0e10cSrcweir 	OSL_TRACE("ScVbaGlobals::~ScVbaGlobals");
65cdf0e10cSrcweir }
66cdf0e10cSrcweir 
67cdf0e10cSrcweir // =============================================================================
68cdf0e10cSrcweir // XGlobals
69cdf0e10cSrcweir // =============================================================================
70cdf0e10cSrcweir uno::Reference<excel::XApplication >
getApplication()71cdf0e10cSrcweir ScVbaGlobals::getApplication() throw (uno::RuntimeException)
72cdf0e10cSrcweir {
73cdf0e10cSrcweir //	OSL_TRACE("In ScVbaGlobals::getApplication");
74cdf0e10cSrcweir         if ( !mxApplication.is() )
75cdf0e10cSrcweir 	    mxApplication.set( new ScVbaApplication( mxContext) );
76cdf0e10cSrcweir    	return mxApplication;
77cdf0e10cSrcweir }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 
80cdf0e10cSrcweir uno::Reference<excel::XApplication > SAL_CALL
getExcel()81cdf0e10cSrcweir ScVbaGlobals::getExcel() throw (uno::RuntimeException)
82cdf0e10cSrcweir {
83cdf0e10cSrcweir    	return getApplication();
84cdf0e10cSrcweir }
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 
88cdf0e10cSrcweir uno::Reference< excel::XWorkbook > SAL_CALL
getActiveWorkbook()89cdf0e10cSrcweir ScVbaGlobals::getActiveWorkbook() throw (uno::RuntimeException)
90cdf0e10cSrcweir {
91cdf0e10cSrcweir //	OSL_TRACE("In ScVbaGlobals::getActiveWorkbook");
92cdf0e10cSrcweir     uno::Reference< excel::XWorkbook > xWorkbook( getApplication()->getActiveWorkbook(), uno::UNO_QUERY);
93cdf0e10cSrcweir     if ( xWorkbook.is() )
94cdf0e10cSrcweir     {
95cdf0e10cSrcweir         return xWorkbook;
96cdf0e10cSrcweir     }
97cdf0e10cSrcweir // FIXME check if this is correct/desired behavior
98cdf0e10cSrcweir     throw uno::RuntimeException( rtl::OUString::createFromAscii(
99cdf0e10cSrcweir         "No activeWorkbook available" ), Reference< uno::XInterface >() );
100cdf0e10cSrcweir }
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 
103cdf0e10cSrcweir uno::Reference< excel::XWindow > SAL_CALL
getActiveWindow()104cdf0e10cSrcweir ScVbaGlobals::getActiveWindow() throw (uno::RuntimeException)
105cdf0e10cSrcweir {
106cdf0e10cSrcweir     return getApplication()->getActiveWindow();
107cdf0e10cSrcweir }
108cdf0e10cSrcweir 
109cdf0e10cSrcweir uno::Reference< excel::XWorksheet > SAL_CALL
getActiveSheet()110cdf0e10cSrcweir ScVbaGlobals::getActiveSheet() throw (uno::RuntimeException)
111cdf0e10cSrcweir {
112cdf0e10cSrcweir     return getApplication()->getActiveSheet();
113cdf0e10cSrcweir }
114cdf0e10cSrcweir 
115cdf0e10cSrcweir uno::Any SAL_CALL
WorkBooks(const uno::Any & aIndex)116cdf0e10cSrcweir ScVbaGlobals::WorkBooks( const uno::Any& aIndex ) throw (uno::RuntimeException)
117cdf0e10cSrcweir {
118cdf0e10cSrcweir 	return uno::Any( getApplication()->Workbooks(aIndex) );
119cdf0e10cSrcweir }
120cdf0e10cSrcweir 
121cdf0e10cSrcweir uno::Any SAL_CALL
WorkSheets(const uno::Any & aIndex)122cdf0e10cSrcweir ScVbaGlobals::WorkSheets(const uno::Any& aIndex) throw (uno::RuntimeException)
123cdf0e10cSrcweir {
124cdf0e10cSrcweir 	return getApplication()->Worksheets( aIndex );
125cdf0e10cSrcweir }
126cdf0e10cSrcweir uno::Any SAL_CALL
Sheets(const uno::Any & aIndex)127cdf0e10cSrcweir ScVbaGlobals::Sheets( const uno::Any& aIndex ) throw (uno::RuntimeException)
128cdf0e10cSrcweir {
129cdf0e10cSrcweir 	return WorkSheets( aIndex );
130cdf0e10cSrcweir }
131cdf0e10cSrcweir 
132cdf0e10cSrcweir uno::Any SAL_CALL
Range(const uno::Any & Cell1,const uno::Any & Cell2)133cdf0e10cSrcweir ScVbaGlobals::Range( const uno::Any& Cell1, const uno::Any& Cell2 ) throw (uno::RuntimeException)
134cdf0e10cSrcweir {
135cdf0e10cSrcweir 	return getApplication()->Range( Cell1, Cell2 );
136cdf0e10cSrcweir }
137cdf0e10cSrcweir 
138cdf0e10cSrcweir uno::Any SAL_CALL
Names(const css::uno::Any & aIndex)139cdf0e10cSrcweir ScVbaGlobals::Names( const css::uno::Any& aIndex ) throw ( uno::RuntimeException )
140cdf0e10cSrcweir {
141cdf0e10cSrcweir 	return getApplication()->Names( aIndex );
142cdf0e10cSrcweir }
143cdf0e10cSrcweir 
144cdf0e10cSrcweir uno::Reference< excel::XRange > SAL_CALL
getActiveCell()145cdf0e10cSrcweir ScVbaGlobals::getActiveCell() throw (uno::RuntimeException)
146cdf0e10cSrcweir {
147cdf0e10cSrcweir 	return getApplication()->getActiveCell();
148cdf0e10cSrcweir }
149cdf0e10cSrcweir 
150cdf0e10cSrcweir uno::Reference< XAssistant > SAL_CALL
getAssistant()151cdf0e10cSrcweir ScVbaGlobals::getAssistant() throw (uno::RuntimeException)
152cdf0e10cSrcweir {
153cdf0e10cSrcweir 	return getApplication()->getAssistant();
154cdf0e10cSrcweir }
155cdf0e10cSrcweir 
156cdf0e10cSrcweir uno::Any SAL_CALL
getSelection()157cdf0e10cSrcweir ScVbaGlobals::getSelection() throw (uno::RuntimeException)
158cdf0e10cSrcweir {
159cdf0e10cSrcweir 	return getApplication()->getSelection();
160cdf0e10cSrcweir }
161cdf0e10cSrcweir 
162cdf0e10cSrcweir uno::Reference< excel::XWorkbook > SAL_CALL
getThisWorkbook()163cdf0e10cSrcweir ScVbaGlobals::getThisWorkbook() throw (uno::RuntimeException)
164cdf0e10cSrcweir {
165cdf0e10cSrcweir 	return getApplication()->getThisWorkbook();
166cdf0e10cSrcweir }
167cdf0e10cSrcweir void SAL_CALL
Calculate()168cdf0e10cSrcweir ScVbaGlobals::Calculate()  throw (::com::sun::star::script::BasicErrorException, ::com::sun::star::uno::RuntimeException)
169cdf0e10cSrcweir {
170cdf0e10cSrcweir 	return getApplication()->Calculate();
171cdf0e10cSrcweir }
172cdf0e10cSrcweir 
173cdf0e10cSrcweir uno::Reference< excel::XRange > SAL_CALL
Cells(const uno::Any & RowIndex,const uno::Any & ColumnIndex)174cdf0e10cSrcweir ScVbaGlobals::Cells( const uno::Any& RowIndex, const uno::Any& ColumnIndex ) throw (uno::RuntimeException)
175cdf0e10cSrcweir {
176cdf0e10cSrcweir 	return getApplication()->getActiveSheet()->Cells( RowIndex, ColumnIndex );
177cdf0e10cSrcweir }
178cdf0e10cSrcweir uno::Reference< excel::XRange > SAL_CALL
Columns(const uno::Any & aIndex)179cdf0e10cSrcweir ScVbaGlobals::Columns( const uno::Any& aIndex ) throw (uno::RuntimeException)
180cdf0e10cSrcweir {
181cdf0e10cSrcweir 	return getApplication()->getActiveSheet()->Columns( aIndex );
182cdf0e10cSrcweir }
183cdf0e10cSrcweir 
184cdf0e10cSrcweir uno::Any SAL_CALL
CommandBars(const uno::Any & aIndex)185cdf0e10cSrcweir ScVbaGlobals::CommandBars( const uno::Any& aIndex ) throw (uno::RuntimeException)
186cdf0e10cSrcweir {
187cdf0e10cSrcweir 	uno::Reference< XApplicationBase > xBase( getApplication(), uno::UNO_QUERY_THROW );
188cdf0e10cSrcweir 	return xBase->CommandBars( aIndex );
189cdf0e10cSrcweir }
190cdf0e10cSrcweir 
191cdf0e10cSrcweir css::uno::Reference< ov::excel::XRange > SAL_CALL
Union(const css::uno::Reference<ov::excel::XRange> & Arg1,const css::uno::Reference<ov::excel::XRange> & Arg2,const css::uno::Any & Arg3,const css::uno::Any & Arg4,const css::uno::Any & Arg5,const css::uno::Any & Arg6,const css::uno::Any & Arg7,const css::uno::Any & Arg8,const css::uno::Any & Arg9,const css::uno::Any & Arg10,const css::uno::Any & Arg11,const css::uno::Any & Arg12,const css::uno::Any & Arg13,const css::uno::Any & Arg14,const css::uno::Any & Arg15,const css::uno::Any & Arg16,const css::uno::Any & Arg17,const css::uno::Any & Arg18,const css::uno::Any & Arg19,const css::uno::Any & Arg20,const css::uno::Any & Arg21,const css::uno::Any & Arg22,const css::uno::Any & Arg23,const css::uno::Any & Arg24,const css::uno::Any & Arg25,const css::uno::Any & Arg26,const css::uno::Any & Arg27,const css::uno::Any & Arg28,const css::uno::Any & Arg29,const css::uno::Any & Arg30)192cdf0e10cSrcweir ScVbaGlobals::Union( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
193cdf0e10cSrcweir {
194cdf0e10cSrcweir 	return getApplication()->Union(  Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10, Arg11, Arg12, Arg13, Arg14, Arg15, Arg16, Arg17, Arg18, Arg19, Arg20, Arg21, Arg22, Arg23, Arg24, Arg25, Arg26, Arg27, Arg28, Arg29, Arg30 );
195cdf0e10cSrcweir }
196cdf0e10cSrcweir css::uno::Reference< ov::excel::XRange > SAL_CALL
Intersect(const css::uno::Reference<ov::excel::XRange> & Arg1,const css::uno::Reference<ov::excel::XRange> & Arg2,const css::uno::Any & Arg3,const css::uno::Any & Arg4,const css::uno::Any & Arg5,const css::uno::Any & Arg6,const css::uno::Any & Arg7,const css::uno::Any & Arg8,const css::uno::Any & Arg9,const css::uno::Any & Arg10,const css::uno::Any & Arg11,const css::uno::Any & Arg12,const css::uno::Any & Arg13,const css::uno::Any & Arg14,const css::uno::Any & Arg15,const css::uno::Any & Arg16,const css::uno::Any & Arg17,const css::uno::Any & Arg18,const css::uno::Any & Arg19,const css::uno::Any & Arg20,const css::uno::Any & Arg21,const css::uno::Any & Arg22,const css::uno::Any & Arg23,const css::uno::Any & Arg24,const css::uno::Any & Arg25,const css::uno::Any & Arg26,const css::uno::Any & Arg27,const css::uno::Any & Arg28,const css::uno::Any & Arg29,const css::uno::Any & Arg30)197cdf0e10cSrcweir ScVbaGlobals::Intersect( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
198cdf0e10cSrcweir {
199cdf0e10cSrcweir 	return getApplication()->Intersect(  Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10, Arg11, Arg12, Arg13, Arg14, Arg15, Arg16, Arg17, Arg18, Arg19, Arg20, Arg21, Arg22, Arg23, Arg24, Arg25, Arg26, Arg27, Arg28, Arg29, Arg30 );
200cdf0e10cSrcweir }
201cdf0e10cSrcweir 
202cdf0e10cSrcweir uno::Any SAL_CALL
Evaluate(const::rtl::OUString & Name)203cdf0e10cSrcweir ScVbaGlobals::Evaluate( const ::rtl::OUString& Name ) throw (uno::RuntimeException)
204cdf0e10cSrcweir {
205cdf0e10cSrcweir 	return getApplication()->Evaluate( Name );
206cdf0e10cSrcweir }
207cdf0e10cSrcweir 
208cdf0e10cSrcweir css::uno::Any SAL_CALL
WorksheetFunction()209cdf0e10cSrcweir ScVbaGlobals::WorksheetFunction(  ) throw (css::uno::RuntimeException)
210cdf0e10cSrcweir {
211cdf0e10cSrcweir 	return getApplication()->WorksheetFunction();
212cdf0e10cSrcweir }
213cdf0e10cSrcweir 
214cdf0e10cSrcweir uno::Any SAL_CALL
Windows(const uno::Any & aIndex)215cdf0e10cSrcweir ScVbaGlobals::Windows( const uno::Any& aIndex ) throw (uno::RuntimeException)
216cdf0e10cSrcweir {
217cdf0e10cSrcweir 	return getApplication()->Windows( aIndex );
218cdf0e10cSrcweir }
219cdf0e10cSrcweir 
220cdf0e10cSrcweir uno::Reference< excel::XRange > SAL_CALL
Rows(const uno::Any & aIndex)221cdf0e10cSrcweir ScVbaGlobals::Rows( const uno::Any& aIndex ) throw (uno::RuntimeException)
222cdf0e10cSrcweir {
223cdf0e10cSrcweir 	return getApplication()->getActiveSheet()->Rows( aIndex );
224cdf0e10cSrcweir 
225cdf0e10cSrcweir }
226cdf0e10cSrcweir 
227cdf0e10cSrcweir 
228cdf0e10cSrcweir uno::Any SAL_CALL
getDebug()229cdf0e10cSrcweir ScVbaGlobals::getDebug() throw (uno::RuntimeException)
230cdf0e10cSrcweir {
231cdf0e10cSrcweir 	try // return empty object on error
232cdf0e10cSrcweir 	{
233cdf0e10cSrcweir 		uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW );
234cdf0e10cSrcweir 		uno::Reference< uno::XInterface > xVBADebug = xServiceManager->createInstanceWithContext(
235cdf0e10cSrcweir             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.Debug" ) ), mxContext );
236cdf0e10cSrcweir         return uno::Any( xVBADebug );
237cdf0e10cSrcweir 	}
238cdf0e10cSrcweir     catch( uno::Exception& )
239cdf0e10cSrcweir 	{
240cdf0e10cSrcweir 	}
241cdf0e10cSrcweir 	return uno::Any();
242cdf0e10cSrcweir }
243cdf0e10cSrcweir 
244cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL
getAvailableServiceNames()245cdf0e10cSrcweir ScVbaGlobals::getAvailableServiceNames(  ) throw (uno::RuntimeException)
246cdf0e10cSrcweir {
247cdf0e10cSrcweir     static bool bInit = false;
248cdf0e10cSrcweir     static uno::Sequence< rtl::OUString > serviceNames( ScVbaGlobals_BASE::getAvailableServiceNames() );
249cdf0e10cSrcweir     if ( !bInit )
250cdf0e10cSrcweir     {
251cdf0e10cSrcweir          rtl::OUString names[] = {
252cdf0e10cSrcweir             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Range" ) ),
253cdf0e10cSrcweir             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Workbook" ) ),
254cdf0e10cSrcweir             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Window" ) ),
255cdf0e10cSrcweir             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Worksheet" ) ),
256cdf0e10cSrcweir             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Application" ) ),
257cdf0e10cSrcweir             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Hyperlink" ) ),
258cdf0e10cSrcweir             ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.script.vba.VBASpreadsheetEventProcessor" ) )
259cdf0e10cSrcweir           };
260cdf0e10cSrcweir         sal_Int32 nExcelServices = ( sizeof( names )/ sizeof( names[0] ) );
261cdf0e10cSrcweir         sal_Int32 startIndex = serviceNames.getLength();
262cdf0e10cSrcweir         serviceNames.realloc( serviceNames.getLength() + nExcelServices );
263cdf0e10cSrcweir         for ( sal_Int32 index = 0; index < nExcelServices; ++index )
264cdf0e10cSrcweir              serviceNames[ startIndex + index ] = names[ index ];
265cdf0e10cSrcweir         bInit = true;
266cdf0e10cSrcweir     }
267cdf0e10cSrcweir     return serviceNames;
268cdf0e10cSrcweir }
269cdf0e10cSrcweir 
270cdf0e10cSrcweir rtl::OUString&
getServiceImplName()271cdf0e10cSrcweir ScVbaGlobals::getServiceImplName()
272cdf0e10cSrcweir {
273cdf0e10cSrcweir         static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaGlobals") );
274cdf0e10cSrcweir         return sImplName;
275cdf0e10cSrcweir }
276cdf0e10cSrcweir 
277cdf0e10cSrcweir uno::Sequence< rtl::OUString >
getServiceNames()278cdf0e10cSrcweir ScVbaGlobals::getServiceNames()
279cdf0e10cSrcweir {
280cdf0e10cSrcweir         static uno::Sequence< rtl::OUString > aServiceNames;
281cdf0e10cSrcweir         if ( aServiceNames.getLength() == 0 )
282cdf0e10cSrcweir         {
283cdf0e10cSrcweir                 aServiceNames.realloc( 1 );
284cdf0e10cSrcweir                 aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Globals" ) );
285cdf0e10cSrcweir         }
286cdf0e10cSrcweir         return aServiceNames;
287cdf0e10cSrcweir }
288cdf0e10cSrcweir 
289cdf0e10cSrcweir namespace globals
290cdf0e10cSrcweir {
291cdf0e10cSrcweir namespace sdecl = comphelper::service_decl;
292cdf0e10cSrcweir sdecl::vba_service_class_<ScVbaGlobals, sdecl::with_args<true> > serviceImpl;
293cdf0e10cSrcweir extern sdecl::ServiceDecl const serviceDecl(
294cdf0e10cSrcweir     serviceImpl,
295cdf0e10cSrcweir     "ScVbaGlobals",
296cdf0e10cSrcweir     "ooo.vba.excel.Globals" );
297cdf0e10cSrcweir }
298cdf0e10cSrcweir 
299