LibreOffice Module sc (master) 1
vbaglobals.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#include "vbaglobals.hxx"
20
21#include <com/sun/star/lang/XMultiComponentFactory.hpp>
23#include <com/sun/star/beans/PropertyValue.hpp>
24#include <com/sun/star/frame/XModel.hpp>
25
26#include "vbaapplication.hxx"
27
28using namespace ::com::sun::star;
29using namespace ::com::sun::star::uno;
30using namespace ::ooo::vba;
31
32// ScVbaGlobals
33
34//ScVbaGlobals::ScVbaGlobals( css::uno::Reference< css::uno::XComponentContext >const& rxContext, ) : ScVbaGlobals_BASE( uno::Reference< XHelperInterface >(), rxContext )
35
36ScVbaGlobals::ScVbaGlobals( uno::Sequence< uno::Any > const& aArgs, uno::Reference< uno::XComponentContext >const& rxContext ) : ScVbaGlobals_BASE( uno::Reference< XHelperInterface >(), rxContext, "ExcelDocumentContext" )
37{
38 uno::Sequence< beans::PropertyValue > aInitArgs( aArgs.hasElements() ? 2 : 1 );
39 auto pInitArgs = aInitArgs.getArray();
40 pInitArgs[ 0 ].Name = "Application";
41 pInitArgs[ 0 ].Value <<= getApplication();
42 if ( aArgs.hasElements() )
43 {
44 pInitArgs[ 1 ].Name = "ExcelDocumentContext";
45 pInitArgs[ 1 ].Value <<= getXSomethingFromArgs< frame::XModel >( aArgs, 0 );
46 }
47 init( aInitArgs );
48}
49
51{
52}
53
54// XGlobals
55
56uno::Reference<excel::XApplication > const &
58{
59 if ( !mxApplication.is() )
61 return mxApplication;
62}
63
64uno::Reference<excel::XApplication > SAL_CALL
66{
67 return getApplication();
68}
69
70uno::Reference< excel::XWorkbook > SAL_CALL
72{
73 uno::Reference< excel::XWorkbook > xWorkbook( getApplication()->getActiveWorkbook(), uno::UNO_SET_THROW);
74 return xWorkbook;
75}
76
77uno::Reference< excel::XWindow > SAL_CALL
79{
80 return getApplication()->getActiveWindow();
81}
82
83uno::Reference< excel::XWorksheet > SAL_CALL
85{
86 return getApplication()->getActiveSheet();
87}
88
89uno::Any SAL_CALL
91{
92 return getApplication()->Workbooks(aIndex);
93}
94
95uno::Any SAL_CALL
97{
98 return getApplication()->Worksheets( aIndex );
99}
100uno::Any SAL_CALL
102{
103 return WorkSheets( aIndex );
104}
105
106uno::Any SAL_CALL
107ScVbaGlobals::Range( const uno::Any& Cell1, const uno::Any& Cell2 )
108{
109 return getApplication()->Range( Cell1, Cell2 );
110}
111
112uno::Any SAL_CALL
113ScVbaGlobals::Names( const css::uno::Any& aIndex )
114{
115 return getApplication()->Names( aIndex );
116}
117
118uno::Reference< excel::XRange > SAL_CALL
120{
121 return getApplication()->getActiveCell();
122}
123
124uno::Reference< XAssistant > SAL_CALL
126{
127 return getApplication()->getAssistant();
128}
129
130uno::Any SAL_CALL
132{
133 return getApplication()->getSelection();
134}
135
136uno::Reference< excel::XWorkbook > SAL_CALL
138{
139 return getApplication()->getThisWorkbook();
140}
141void SAL_CALL
143{
144 return getApplication()->Calculate();
145}
146
147uno::Reference< excel::XRange > SAL_CALL
148ScVbaGlobals::Cells( const uno::Any& RowIndex, const uno::Any& ColumnIndex )
149{
150 return getApplication()->getActiveSheet()->Cells( RowIndex, ColumnIndex );
151}
152uno::Reference< excel::XRange > SAL_CALL
154{
155 return getApplication()->getActiveSheet()->Columns( aIndex );
156}
157
158uno::Any SAL_CALL
160{
161 uno::Reference< XApplicationBase > xBase( getApplication(), uno::UNO_QUERY_THROW );
162 return xBase->CommandBars( aIndex );
163}
164
165css::uno::Reference< ov::excel::XRange > SAL_CALL
166ScVbaGlobals::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 )
167{
168 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 );
169}
170css::uno::Reference< ov::excel::XRange > SAL_CALL
171ScVbaGlobals::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 )
172{
173 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 );
174}
175
176uno::Any SAL_CALL
177ScVbaGlobals::Evaluate( const OUString& Name )
178{
179 return getApplication()->Evaluate( Name );
180}
181
182css::uno::Any SAL_CALL
184{
185 return getApplication()->WorksheetFunction();
186}
187
188uno::Any SAL_CALL
190{
191 return getApplication()->Windows( aIndex );
192}
193
194uno::Reference< excel::XRange > SAL_CALL
196{
197 return getApplication()->getActiveSheet()->Rows( aIndex );
198
199}
200
201uno::Any SAL_CALL
203{
204 try // return empty object on error
205 {
206 uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW );
207 uno::Reference< uno::XInterface > xVBADebug = xServiceManager->createInstanceWithContext(
208 "ooo.vba.Debug", mxContext );
209 return uno::Any( xVBADebug );
210 }
211 catch( uno::Exception& )
212 {
213 }
214 return uno::Any();
215}
216
217uno::Any SAL_CALL
219{
220 return getApplication()->MenuBars(aIndex);
221}
222
223uno::Sequence< OUString > SAL_CALL
225{
226 static const uno::Sequence< OUString > serviceNames = comphelper::concatSequences(
227 ScVbaGlobals_BASE::getAvailableServiceNames(),
228 uno::Sequence< OUString >
229 {
230 "ooo.vba.excel.Range",
231 "ooo.vba.excel.Workbook",
232 "ooo.vba.excel.Window",
233 "ooo.vba.excel.Worksheet",
234 "ooo.vba.excel.Application",
235 "ooo.vba.excel.Hyperlink",
236 "com.sun.star.script.vba.VBASpreadsheetEventProcessor"
237 } );
238 return serviceNames;
239}
240
241OUString
243{
244 return "ScVbaGlobals";
245}
246
247uno::Sequence< OUString >
249{
250 static uno::Sequence< OUString > aServiceNames
251 {
252 "ooo.vba.excel.Globals"
253 };
254 return aServiceNames;
255}
256
257extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
259 css::uno::XComponentContext *context,
260 css::uno::Sequence<css::uno::Any> const &arguments)
261{
262 return cppu::acquire(new ScVbaGlobals(arguments, context));
263}
264
265/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
FILE * init(int, char **)
virtual css::uno::Reference< ov::excel::XWorksheet > SAL_CALL getActiveSheet() override
Definition: vbaglobals.cxx:84
virtual css::uno::Any SAL_CALL Range(const css::uno::Any &Cell1, const css::uno::Any &Cell2) override
Definition: vbaglobals.cxx:107
virtual css::uno::Any SAL_CALL MenuBars(const css::uno::Any &aIndex) override
Definition: vbaglobals.cxx:218
virtual 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) override
Definition: vbaglobals.cxx:171
ScVbaGlobals(css::uno::Sequence< css::uno::Any > const &aArgs, css::uno::Reference< css::uno::XComponentContext >const &rxContext)
Definition: vbaglobals.cxx:36
virtual css::uno::Any SAL_CALL Evaluate(const OUString &Name) override
Definition: vbaglobals.cxx:177
virtual css::uno::Any SAL_CALL Windows(const css::uno::Any &aIndex) override
Definition: vbaglobals.cxx:189
virtual css::uno::Reference< ov::excel::XWindow > SAL_CALL getActiveWindow() override
Definition: vbaglobals.cxx:78
virtual css::uno::Any SAL_CALL WorkBooks(const css::uno::Any &aIndex) override
Definition: vbaglobals.cxx:90
virtual css::uno::Any SAL_CALL WorkSheets(const css::uno::Any &aIndex) override
Definition: vbaglobals.cxx:96
virtual css::uno::Reference< ov::excel::XWorkbook > SAL_CALL getThisWorkbook() override
Definition: vbaglobals.cxx:137
virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Columns(const css::uno::Any &aIndex) override
Definition: vbaglobals.cxx:153
css::uno::Reference< ov::excel::XApplication > mxApplication
Definition: vbaglobals.hxx:36
virtual css::uno::Reference< ov::XAssistant > SAL_CALL getAssistant() override
Definition: vbaglobals.cxx:125
virtual css::uno::Reference< ::ooo::vba::excel::XRange > SAL_CALL Rows(const css::uno::Any &aIndex) override
Definition: vbaglobals.cxx:195
virtual css::uno::Any SAL_CALL getDebug() override
Definition: vbaglobals.cxx:202
virtual css::uno::Any SAL_CALL CommandBars(const css::uno::Any &aIndex) override
Definition: vbaglobals.cxx:159
virtual ~ScVbaGlobals() override
Definition: vbaglobals.cxx:50
virtual css::uno::Any SAL_CALL WorksheetFunction() override
Definition: vbaglobals.cxx:183
virtual OUString getServiceImplName() override
Definition: vbaglobals.cxx:242
virtual css::uno::Sequence< OUString > getServiceNames() override
Definition: vbaglobals.cxx:248
virtual css::uno::Any SAL_CALL Names(const css::uno::Any &aIndex) override
Definition: vbaglobals.cxx:113
css::uno::Reference< ov::excel::XApplication > const & getApplication()
Definition: vbaglobals.cxx:57
virtual css::uno::Reference< ov::excel::XRange > SAL_CALL getActiveCell() override
Definition: vbaglobals.cxx:119
virtual css::uno::Reference< ov::excel::XApplication > SAL_CALL getExcel() override
Definition: vbaglobals.cxx:65
virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Cells(const css::uno::Any &RowIndex, const css::uno::Any &ColumnIndex) override
Definition: vbaglobals.cxx:148
virtual css::uno::Any SAL_CALL Sheets(const css::uno::Any &aIndex) override
Definition: vbaglobals.cxx:101
virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override
Definition: vbaglobals.cxx:224
virtual void SAL_CALL Calculate() override
Definition: vbaglobals.cxx:142
virtual 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) override
Definition: vbaglobals.cxx:166
virtual css::uno::Reference< ov::excel::XWorkbook > SAL_CALL getActiveWorkbook() override
Definition: vbaglobals.cxx:71
virtual css::uno::Any SAL_CALL getSelection() override
Definition: vbaglobals.cxx:131
uno::Reference< uno::XComponentContext > mxContext
std::deque< AttacherIndex_Impl > aIndex
Sequence< OUString > aServiceNames
css::uno::Sequence< T > concatSequences(const css::uno::Sequence< T > &rS1, const Ss &... rSn)
Reference
OUString Name
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * ScVbaGlobals_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &arguments)
Definition: vbaglobals.cxx:258
::cppu::ImplInheritanceHelper< VbaGlobalsBase, ov::excel::XGlobals > ScVbaGlobals_BASE
Definition: vbaglobals.hxx:32