tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / vba / vbaglobals.cxx
blob36649602429589a4103af70e6eca27a8edc30ce7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #include "vbaglobals.hxx"
21 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
22 #include <comphelper/sequence.hxx>
23 #include <com/sun/star/beans/PropertyValue.hpp>
24 #include <com/sun/star/frame/XModel.hpp>
26 #include "vbaapplication.hxx"
28 using namespace ::com::sun::star;
29 using namespace ::com::sun::star::uno;
30 using namespace ::ooo::vba;
32 // ScVbaGlobals
34 //ScVbaGlobals::ScVbaGlobals( css::uno::Reference< css::uno::XComponentContext >const& rxContext, ) : ScVbaGlobals_BASE( uno::Reference< XHelperInterface >(), rxContext )
36 ScVbaGlobals::ScVbaGlobals( uno::Sequence< uno::Any > const& aArgs, uno::Reference< uno::XComponentContext >const& rxContext ) : ScVbaGlobals_BASE( uno::Reference< XHelperInterface >(), rxContext, "ExcelDocumentContext" )
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() )
44 pInitArgs[ 1 ].Name = "ExcelDocumentContext";
45 pInitArgs[ 1 ].Value <<= getXSomethingFromArgs< frame::XModel >( aArgs, 0 );
47 init( aInitArgs );
50 ScVbaGlobals::~ScVbaGlobals()
54 // XGlobals
56 uno::Reference<excel::XApplication > const &
57 ScVbaGlobals::getApplication()
59 if ( !mxApplication.is() )
60 mxApplication.set( new ScVbaApplication( mxContext) );
61 return mxApplication;
64 uno::Reference<excel::XApplication > SAL_CALL
65 ScVbaGlobals::getExcel()
67 return getApplication();
70 uno::Reference< excel::XWorkbook > SAL_CALL
71 ScVbaGlobals::getActiveWorkbook()
73 uno::Reference< excel::XWorkbook > xWorkbook( getApplication()->getActiveWorkbook(), uno::UNO_SET_THROW);
74 return xWorkbook;
77 uno::Reference< excel::XWindow > SAL_CALL
78 ScVbaGlobals::getActiveWindow()
80 return getApplication()->getActiveWindow();
83 uno::Reference< excel::XWorksheet > SAL_CALL
84 ScVbaGlobals::getActiveSheet()
86 return getApplication()->getActiveSheet();
89 uno::Any SAL_CALL
90 ScVbaGlobals::WorkBooks( const uno::Any& aIndex )
92 return getApplication()->Workbooks(aIndex);
95 uno::Any SAL_CALL
96 ScVbaGlobals::WorkSheets(const uno::Any& aIndex)
98 return getApplication()->Worksheets( aIndex );
100 uno::Any SAL_CALL
101 ScVbaGlobals::Sheets( const uno::Any& aIndex )
103 return WorkSheets( aIndex );
106 uno::Any SAL_CALL
107 ScVbaGlobals::Range( const uno::Any& Cell1, const uno::Any& Cell2 )
109 return getApplication()->Range( Cell1, Cell2 );
112 uno::Any SAL_CALL
113 ScVbaGlobals::Names( const css::uno::Any& aIndex )
115 return getApplication()->Names( aIndex );
118 uno::Reference< excel::XRange > SAL_CALL
119 ScVbaGlobals::getActiveCell()
121 return getApplication()->getActiveCell();
124 uno::Reference< XAssistant > SAL_CALL
125 ScVbaGlobals::getAssistant()
127 return getApplication()->getAssistant();
130 uno::Any SAL_CALL
131 ScVbaGlobals::getSelection()
133 return getApplication()->getSelection();
136 uno::Reference< excel::XWorkbook > SAL_CALL
137 ScVbaGlobals::getThisWorkbook()
139 return getApplication()->getThisWorkbook();
141 void SAL_CALL
142 ScVbaGlobals::Calculate()
144 return getApplication()->Calculate();
147 uno::Reference< excel::XRange > SAL_CALL
148 ScVbaGlobals::Cells( const uno::Any& RowIndex, const uno::Any& ColumnIndex )
150 return getApplication()->getActiveSheet()->Cells( RowIndex, ColumnIndex );
152 uno::Reference< excel::XRange > SAL_CALL
153 ScVbaGlobals::Columns( const uno::Any& aIndex )
155 return getApplication()->getActiveSheet()->Columns( aIndex );
158 uno::Any SAL_CALL
159 ScVbaGlobals::CommandBars( const uno::Any& aIndex )
161 uno::Reference< XApplicationBase > xBase( getApplication(), uno::UNO_QUERY_THROW );
162 return xBase->CommandBars( aIndex );
165 css::uno::Reference< ov::excel::XRange > SAL_CALL
166 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 )
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 );
170 css::uno::Reference< ov::excel::XRange > SAL_CALL
171 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 )
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 );
176 uno::Any SAL_CALL
177 ScVbaGlobals::Evaluate( const OUString& Name )
179 return getApplication()->Evaluate( Name );
182 css::uno::Any SAL_CALL
183 ScVbaGlobals::WorksheetFunction( )
185 return getApplication()->WorksheetFunction();
188 uno::Any SAL_CALL
189 ScVbaGlobals::Windows( const uno::Any& aIndex )
191 return getApplication()->Windows( aIndex );
194 uno::Reference< excel::XRange > SAL_CALL
195 ScVbaGlobals::Rows( const uno::Any& aIndex )
197 return getApplication()->getActiveSheet()->Rows( aIndex );
201 uno::Any SAL_CALL
202 ScVbaGlobals::getDebug()
204 try // return empty object on error
206 uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW );
207 uno::Reference< uno::XInterface > xVBADebug = xServiceManager->createInstanceWithContext(
208 u"ooo.vba.Debug"_ustr, mxContext );
209 return uno::Any( xVBADebug );
211 catch( uno::Exception& )
214 return uno::Any();
217 uno::Any SAL_CALL
218 ScVbaGlobals::MenuBars( const uno::Any& aIndex )
220 return getApplication()->MenuBars(aIndex);
223 uno::Sequence< OUString > SAL_CALL
224 ScVbaGlobals::getAvailableServiceNames( )
226 static const uno::Sequence< OUString > serviceNames = comphelper::concatSequences(
227 ScVbaGlobals_BASE::getAvailableServiceNames(),
228 std::initializer_list<OUString>
230 u"ooo.vba.excel.Range"_ustr,
231 u"ooo.vba.excel.Workbook"_ustr,
232 u"ooo.vba.excel.Window"_ustr,
233 u"ooo.vba.excel.Worksheet"_ustr,
234 u"ooo.vba.excel.Application"_ustr,
235 u"ooo.vba.excel.Hyperlink"_ustr,
236 u"com.sun.star.script.vba.VBASpreadsheetEventProcessor"_ustr
237 } );
238 return serviceNames;
241 OUString
242 ScVbaGlobals::getServiceImplName()
244 return u"ScVbaGlobals"_ustr;
247 uno::Sequence< OUString >
248 ScVbaGlobals::getServiceNames()
250 static uno::Sequence< OUString > aServiceNames
252 u"ooo.vba.excel.Globals"_ustr
254 return aServiceNames;
257 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
258 ScVbaGlobals_get_implementation(
259 css::uno::XComponentContext *context,
260 css::uno::Sequence<css::uno::Any> const &arguments)
262 return cppu::acquire(new ScVbaGlobals(arguments, context));
265 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */