LibreOffice Module sc (master) 1
servuno.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 <memory>
21#include <config_features.h>
22
23#include <sal/macros.h>
24#include <svtools/unoimap.hxx>
25#include <svx/unofill.hxx>
26#include <vcl/svapp.hxx>
27#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
28#include <com/sun/star/container/XNameAccess.hpp>
29#include <com/sun/star/text/textfield/Type.hpp>
30
31#include <editsrc.hxx>
32#include <servuno.hxx>
33#include <unonames.hxx>
34#include <appluno.hxx>
35#include <cellsuno.hxx>
36#include <fielduno.hxx>
37#include <styleuno.hxx>
38#include <afmtuno.hxx>
39#include <defltuno.hxx>
40#include <drdefuno.hxx>
41#include <docsh.hxx>
42#include <drwlayer.hxx>
43#include <confuno.hxx>
44#include <shapeuno.hxx>
45#include "cellvaluebinding.hxx"
46#include "celllistsource.hxx"
47#include <addruno.hxx>
48#include <chart2uno.hxx>
49#include <tokenuno.hxx>
51
52// Support creation of GraphicStorageHandler and EmbeddedObjectResolver
53#include <svx/xmleohlp.hxx>
54#include <svx/xmlgrhlp.hxx>
55#include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
56#include <com/sun/star/document/XCodeNameQuery.hpp>
57#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
58#include <com/sun/star/form/XFormsSupplier.hpp>
59#include <svx/unomod.hxx>
61
63#include <basic/basmgr.hxx>
64#include <sfx2/app.hxx>
65
67#include <com/sun/star/script/vba/XVBACompatibility.hpp>
68
69using namespace ::com::sun::star;
70
71#if HAVE_FEATURE_SCRIPTING
72
73static bool isInVBAMode( ScDocShell& rDocSh )
74{
75 uno::Reference<script::XLibraryContainer> xLibContainer = rDocSh.GetBasicContainer();
76 uno::Reference<script::vba::XVBACompatibility> xVBACompat( xLibContainer, uno::UNO_QUERY );
77 if ( xVBACompat.is() )
78 return xVBACompat->getVBACompatibilityMode();
79 return false;
80}
81
82#endif
83
84namespace {
85
86#if HAVE_FEATURE_SCRIPTING
87class ScVbaObjectForCodeNameProvider : public ::cppu::WeakImplHelper< container::XNameAccess >
88{
89 uno::Any maWorkbook;
90 uno::Any maCachedObject;
91 ScDocShell* mpDocShell;
92public:
93 explicit ScVbaObjectForCodeNameProvider( ScDocShell* pDocShell ) : mpDocShell( pDocShell )
94 {
95 uno::Sequence< uno::Any > aArgs{
96 // access the application object ( parent for workbook )
97 uno::Any(ooo::vba::createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.Application", {} )),
98 uno::Any(uno::Reference(static_cast<css::sheet::XSpreadsheetDocument*>(mpDocShell->GetModel())))
99 };
100 maWorkbook <<= ooo::vba::createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.excel.Workbook", aArgs );
101 }
102
103 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override
104 {
105 SolarMutexGuard aGuard;
106 maCachedObject = uno::Any(); // clear cached object
107
108 ScDocument& rDoc = mpDocShell->GetDocument();
109 // aName is generated from the stream name which can be different ( case-wise )
110 // from the code name
111 if( aName.equalsIgnoreAsciiCase( rDoc.GetCodeName() ) )
112 maCachedObject = maWorkbook;
113 else
114 {
115 OUString sCodeName;
116 SCTAB nCount = rDoc.GetTableCount();
117 for( SCTAB i = 0; i < nCount; i++ )
118 {
119 rDoc.GetCodeName( i, sCodeName );
120 // aName is generated from the stream name which can be different ( case-wise )
121 // from the code name
122 if( sCodeName.equalsIgnoreAsciiCase( aName ) )
123 {
124 OUString sSheetName;
125 if( rDoc.GetName( i, sSheetName ) )
126 {
127 uno::Reference< frame::XModel > xModel( mpDocShell->GetModel() );
128 uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( xModel, uno::UNO_QUERY_THROW );
129 uno::Reference<sheet::XSpreadsheets > xSheets( xSpreadDoc->getSheets(), uno::UNO_SET_THROW );
130 uno::Reference< container::XIndexAccess > xIndexAccess( xSheets, uno::UNO_QUERY_THROW );
131 uno::Reference< sheet::XSpreadsheet > xSheet( xIndexAccess->getByIndex( i ), uno::UNO_QUERY_THROW );
132 uno::Sequence< uno::Any > aArgs{ maWorkbook, uno::Any(xModel), uno::Any(sSheetName) };
133 // use the convenience function
134 maCachedObject <<= ooo::vba::createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.excel.Worksheet", aArgs );
135 break;
136 }
137 }
138 }
139 }
140 return maCachedObject.hasValue();
141
142 }
143 css::uno::Any SAL_CALL getByName( const OUString& aName ) override
144 {
145 SolarMutexGuard aGuard;
146 if ( !hasByName( aName ) )
147 throw css::container::NoSuchElementException();
148 return maCachedObject;
149 }
150 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames( ) override
151 {
152 SolarMutexGuard aGuard;
153 ScDocument& rDoc = mpDocShell->GetDocument();
154 SCTAB nCount = rDoc.GetTableCount();
155 uno::Sequence< OUString > aNames( nCount + 1 );
156 auto pNames = aNames.getArray();
157 SCTAB index = 0;
158 OUString sCodeName;
159 for( ; index < nCount; ++index )
160 {
161 rDoc.GetCodeName( index, sCodeName );
162 pNames[ index ] = sCodeName;
163 }
164 pNames[ index ] = rDoc.GetCodeName();
165 return aNames;
166 }
167 // XElemenAccess
168 virtual css::uno::Type SAL_CALL getElementType( ) override { return uno::Type(); }
169 virtual sal_Bool SAL_CALL hasElements( ) override { return true; }
170
171};
172
173class ScVbaCodeNameProvider : public ::cppu::WeakImplHelper< document::XCodeNameQuery >
174{
175 ScDocShell& mrDocShell;
176public:
177 explicit ScVbaCodeNameProvider( ScDocShell& rDocShell ) : mrDocShell(rDocShell) {}
178 // XCodeNameQuery
179 OUString SAL_CALL getCodeNameForObject( const uno::Reference< uno::XInterface >& xIf ) override
180 {
181 SolarMutexGuard aGuard;
182 OUString sCodeName;
183
184 // need to find the page ( and index ) for this control
185 uno::Reference< container::XIndexAccess > xIndex( mrDocShell.GetModel()->getDrawPages(), uno::UNO_QUERY_THROW );
186 sal_Int32 nLen = xIndex->getCount();
187 bool bMatched = false;
188 for ( sal_Int32 index = 0; index < nLen; ++index )
189 {
190 try
191 {
192 uno::Reference< form::XFormsSupplier > xFormSupplier( xIndex->getByIndex( index ), uno::UNO_QUERY_THROW );
193 uno::Reference< container::XIndexAccess > xFormIndex( xFormSupplier->getForms(), uno::UNO_QUERY_THROW );
194 // get the www-standard container
195 uno::Reference< container::XIndexAccess > xFormControls( xFormIndex->getByIndex(0), uno::UNO_QUERY_THROW );
196 sal_Int32 nCntrls = xFormControls->getCount();
197 for( sal_Int32 cIndex = 0; cIndex < nCntrls; ++cIndex )
198 {
199 uno::Reference< uno::XInterface > xControl( xFormControls->getByIndex( cIndex ), uno::UNO_QUERY_THROW );
200 bMatched = ( xControl == xIf );
201 if ( bMatched )
202 {
203 OUString sName;
204 mrDocShell.GetDocument().GetCodeName( static_cast<SCTAB>( index ), sName );
205 sCodeName = sName;
206 }
207 }
208 }
209 catch( uno::Exception& ) {}
210 if ( bMatched )
211 break;
212 }
213 // Probably should throw here ( if !bMatched )
214 return sCodeName;
215 }
216
217 OUString SAL_CALL getCodeNameForContainer( const uno::Reference<uno::XInterface>& xContainer ) override
218 {
219 SolarMutexGuard aGuard;
220 uno::Reference<container::XIndexAccess> xIndex(mrDocShell.GetModel()->getDrawPages(), uno::UNO_QUERY_THROW);
221
222 for (sal_Int32 i = 0, n = xIndex->getCount(); i < n; ++i)
223 {
224 try
225 {
226 uno::Reference<form::XFormsSupplier> xFormSupplier(xIndex->getByIndex(i), uno::UNO_QUERY_THROW);
227 uno::Reference<container::XIndexAccess> xFormIndex(xFormSupplier->getForms(), uno::UNO_QUERY_THROW);
228 // get the www-standard container
229 uno::Reference<container::XIndexAccess> xFormControls(xFormIndex->getByIndex(0), uno::UNO_QUERY_THROW);
230 if (xFormControls == xContainer)
231 {
232 OUString aName;
233 if (mrDocShell.GetDocument().GetCodeName(static_cast<SCTAB>(i), aName))
234 return aName;
235 }
236 }
237 catch( uno::Exception& ) {}
238 }
239 return OUString();
240 }
241};
242
243#endif
244
246
247struct ProvNamesId_Type
248{
249 OUString pName;
251};
252
253const ProvNamesId_Type aProvNamesId[] =
254{
255 { "com.sun.star.sheet.Spreadsheet", Type::SHEET },
256 { "com.sun.star.text.TextField.URL", Type::URLFIELD },
257 { "com.sun.star.text.TextField.PageNumber", Type::PAGEFIELD },
258 { "com.sun.star.text.TextField.PageCount", Type::PAGESFIELD },
259 { "com.sun.star.text.TextField.Date", Type::DATEFIELD },
260 { "com.sun.star.text.TextField.Time", Type::TIMEFIELD },
261 { "com.sun.star.text.TextField.DateTime", Type::EXT_TIMEFIELD },
262 { "com.sun.star.text.TextField.DocInfo.Title", Type::TITLEFIELD },
263 { "com.sun.star.text.TextField.FileName", Type::FILEFIELD },
264 { "com.sun.star.text.TextField.SheetName", Type::SHEETFIELD },
265 { "com.sun.star.style.CellStyle", Type::CELLSTYLE },
266 { "com.sun.star.style.PageStyle", Type::PAGESTYLE },
267 { "com.sun.star.style.GraphicStyle", Type::GRAPHICSTYLE },
268 { "com.sun.star.sheet.TableAutoFormat", Type::AUTOFORMAT },
269 { "com.sun.star.sheet.TableAutoFormats", Type::AUTOFORMATS },
270 { "com.sun.star.sheet.SheetCellRanges", Type::CELLRANGES },
271 { "com.sun.star.sheet.FunctionDescriptions", Type::FUNCTIONDESCRIPTIONS },
272 { "com.sun.star.sheet.GlobalSheetSettings", Type::GLOBALSHEETSETTINGS },
273 { "com.sun.star.sheet.RecentFunctions", Type::RECENTFUNCTIONS },
274 { "com.sun.star.drawing.GradientTable", Type::GRADTAB },
275 { "com.sun.star.drawing.HatchTable", Type::HATCHTAB },
276 { "com.sun.star.drawing.BitmapTable", Type::BITMAPTAB },
277 { "com.sun.star.drawing.TransparencyGradientTable", Type::TRGRADTAB },
278 { "com.sun.star.drawing.MarkerTable", Type::MARKERTAB },
279 { "com.sun.star.drawing.DashTable", Type::DASHTAB },
280 { "com.sun.star.text.NumberingRules", Type::NUMRULES },
281 { "com.sun.star.sheet.Defaults", Type::DOCDEFLTS },
282 { "com.sun.star.drawing.Defaults", Type::DRAWDEFLTS },
283 { "com.sun.star.comp.SpreadsheetSettings", Type::DOCSPRSETT },
284 { "com.sun.star.document.Settings", Type::DOCCONF },
285 { "com.sun.star.image.ImageMapRectangleObject", Type::IMAP_RECT },
286 { "com.sun.star.image.ImageMapCircleObject", Type::IMAP_CIRC },
287 { "com.sun.star.image.ImageMapPolygonObject", Type::IMAP_POLY },
288
289 // Support creation of GraphicStorageHandler and EmbeddedObjectResolver
290 { "com.sun.star.document.ExportGraphicStorageHandler", Type::EXPORT_GRAPHIC_STORAGE_HANDLER },
291 { "com.sun.star.document.ImportGraphicStorageHandler", Type::IMPORT_GRAPHIC_STORAGE_HANDLER },
292 { "com.sun.star.document.ExportEmbeddedObjectResolver", Type::EXPORT_EOR },
293 { "com.sun.star.document.ImportEmbeddedObjectResolver", Type::IMPORT_EOR },
294
295 { SC_SERVICENAME_VALBIND, Type::VALBIND },
296 { SC_SERVICENAME_LISTCELLBIND, Type::LISTCELLBIND },
297 { SC_SERVICENAME_LISTSOURCE, Type::LISTSOURCE },
298 { SC_SERVICENAME_CELLADDRESS, Type::CELLADDRESS },
299 { SC_SERVICENAME_RANGEADDRESS, Type::RANGEADDRESS },
300
301 { "com.sun.star.sheet.DocumentSettings",Type::SHEETDOCSET },
302
303 { SC_SERVICENAME_CHDATAPROV, Type::CHDATAPROV },
304 { SC_SERVICENAME_CHART_PIVOTTABLE_DATAPROVIDER, Type::CHART_PIVOTTABLE_DATAPROVIDER },
305 { SC_SERVICENAME_FORMULAPARS, Type::FORMULAPARS },
306 { SC_SERVICENAME_OPCODEMAPPER, Type::OPCODEMAPPER },
307 { "ooo.vba.VBAObjectModuleObjectProvider", Type::VBAOBJECTPROVIDER },
308 { "ooo.vba.VBACodeNameProvider", Type::VBACODENAMEPROVIDER },
309 { "ooo.vba.VBAGlobals", Type::VBAGLOBALS },
310
311 // case-correct versions of the service names (#i102468#)
312 { "com.sun.star.text.textfield.URL", Type::URLFIELD },
313 { "com.sun.star.text.textfield.PageNumber", Type::PAGEFIELD },
314 { "com.sun.star.text.textfield.PageCount", Type::PAGESFIELD },
315 { "com.sun.star.text.textfield.Date", Type::DATEFIELD },
316 { "com.sun.star.text.textfield.Time", Type::TIMEFIELD },
317 { "com.sun.star.text.textfield.DateTime", Type::EXT_TIMEFIELD },
318 { "com.sun.star.text.textfield.docinfo.Title", Type::TITLEFIELD },
319 { "com.sun.star.text.textfield.FileName", Type::FILEFIELD },
320 { "com.sun.star.text.textfield.SheetName", Type::SHEETFIELD },
321 { "ooo.vba.VBAGlobals", Type::VBAGLOBALS },
322};
323
324// old service names that were in 567 still work in createInstance,
325// in case some macro is still using them
326const ProvNamesId_Type aOldNames[] =
327{
328 { "stardiv.one.text.TextField.URL", Type::URLFIELD },
329 { "stardiv.one.text.TextField.PageNumber", Type::PAGEFIELD },
330 { "stardiv.one.text.TextField.PageCount", Type::PAGESFIELD },
331 { "stardiv.one.text.TextField.Date", Type::DATEFIELD },
332 { "stardiv.one.text.TextField.Time", Type::TIMEFIELD },
333 { "stardiv.one.text.TextField.DocumentTitle", Type::TITLEFIELD },
334 { "stardiv.one.text.TextField.FileName", Type::FILEFIELD },
335 { "stardiv.one.text.TextField.SheetName", Type::SHEETFIELD },
336 { "stardiv.one.style.CellStyle", Type::CELLSTYLE },
337 { "stardiv.one.style.PageStyle", Type::PAGESTYLE },
338};
339
340sal_Int32 getFieldType(ScServiceProvider::Type nOldType)
341{
342 switch (nOldType)
343 {
344 case Type::URLFIELD:
345 return text::textfield::Type::URL;
346 case Type::PAGEFIELD:
347 return text::textfield::Type::PAGE;
348 case Type::PAGESFIELD:
349 return text::textfield::Type::PAGES;
350 case Type::DATEFIELD:
352 case Type::TIMEFIELD:
353 return text::textfield::Type::TIME;
354 case Type::EXT_TIMEFIELD:
355 return text::textfield::Type::EXTENDED_TIME;
356 case Type::TITLEFIELD:
357 return text::textfield::Type::DOCINFO_TITLE;
358 case Type::FILEFIELD:
359 return text::textfield::Type::EXTENDED_FILE;
360 case Type::SHEETFIELD:
362 default:
363 ;
364 }
365
366 return text::textfield::Type::URL; // default to URL for no reason whatsoever.
367}
368
369} // namespace
370
371
373{
374 if (!rServiceName.empty())
375 {
376 for (const ProvNamesId_Type & i : aProvNamesId)
377 {
378 if (rServiceName == i.pName)
379 {
380 return i.nType;
381 }
382 }
383
384 for (const ProvNamesId_Type & rOldName : aOldNames)
385 {
386 if (rServiceName == rOldName.pName)
387 {
388 OSL_FAIL("old service name used");
389 return rOldName.nType;
390 }
391 }
392 }
393 return Type::INVALID;
394}
395
396uno::Reference<uno::XInterface> ScServiceProvider::MakeInstance(
397 Type nType, ScDocShell* pDocShell )
398{
399 uno::Reference<uno::XInterface> xRet;
400
401 switch (nType)
402 {
403 case Type::SHEET:
404 // not inserted yet - DocShell=Null
405 xRet.set(static_cast<sheet::XSpreadsheet*>(new ScTableSheetObj(nullptr,0)));
406 break;
407 case Type::URLFIELD:
408 case Type::PAGEFIELD:
409 case Type::PAGESFIELD:
410 case Type::DATEFIELD:
411 case Type::TIMEFIELD:
413 case Type::TITLEFIELD:
414 case Type::FILEFIELD:
415 case Type::SHEETFIELD:
416 {
417 uno::Reference<text::XTextRange> xNullContent;
418 xRet.set(static_cast<text::XTextField*>(
419 new ScEditFieldObj(xNullContent, nullptr, getFieldType(nType), ESelection())));
420 } break;
421 case Type::CELLSTYLE:
422 xRet.set(static_cast<style::XStyle*>(new ScStyleObj( nullptr, SfxStyleFamily::Para, OUString() )));
423 break;
424 case Type::PAGESTYLE:
425 xRet.set(static_cast<style::XStyle*>(new ScStyleObj( nullptr, SfxStyleFamily::Page, OUString() )));
426 break;
428 if (pDocShell)
429 {
430 pDocShell->MakeDrawLayer();
431 xRet.set(static_cast<style::XStyle*>(new ScStyleObj( nullptr, SfxStyleFamily::Frame, OUString() )));
432 }
433 break;
434 case Type::AUTOFORMAT:
435 xRet.set(static_cast<container::XIndexAccess*>(new ScAutoFormatObj( SC_AFMTOBJ_INVALID )));
436 break;
438 xRet.set(static_cast<container::XIndexAccess*>(new ScAutoFormatsObj()));
439 break;
440 case Type::CELLRANGES:
441 // isn't inserted, rather filled
442 // -> DocShell must be set, but empty ranges
443 if (pDocShell)
444 xRet.set(static_cast<sheet::XSheetCellRanges*>(new ScCellRangesObj( pDocShell, ScRangeList() )));
445 break;
447 xRet.set(static_cast<sheet::XFunctionDescriptions*>(new ScFunctionListObj()));
448 break;
450 xRet.set(static_cast<sheet::XGlobalSheetSettings*>(new ScSpreadsheetSettings()));
451 break;
453 xRet.set(static_cast<sheet::XRecentFunctions*>(new ScRecentFunctionsObj()));
454 break;
455 case Type::DOCDEFLTS:
456 if (pDocShell)
457 xRet.set(static_cast<beans::XPropertySet*>(new ScDocDefaultsObj( pDocShell )));
458 break;
459 case Type::DRAWDEFLTS:
460 if (pDocShell)
461 xRet.set(static_cast<beans::XPropertySet*>(new ScDrawDefaultsObj( pDocShell )));
462 break;
463
464 // Drawing layer tables are not in SvxUnoDrawMSFactory,
465 // because SvxUnoDrawMSFactory doesn't have a SdrModel pointer.
466 // Drawing layer is always allocated if not there (MakeDrawLayer).
467
468 case Type::GRADTAB:
469 if (pDocShell)
470 xRet.set(SvxUnoGradientTable_createInstance( pDocShell->MakeDrawLayer() ));
471 break;
472 case Type::HATCHTAB:
473 if (pDocShell)
474 xRet.set(SvxUnoHatchTable_createInstance( pDocShell->MakeDrawLayer() ));
475 break;
476 case Type::BITMAPTAB:
477 if (pDocShell)
478 xRet.set(SvxUnoBitmapTable_createInstance( pDocShell->MakeDrawLayer() ));
479 break;
480 case Type::TRGRADTAB:
481 if (pDocShell)
483 break;
484 case Type::MARKERTAB:
485 if (pDocShell)
486 xRet.set(SvxUnoMarkerTable_createInstance( pDocShell->MakeDrawLayer() ));
487 break;
488 case Type::DASHTAB:
489 if (pDocShell)
490 xRet.set(SvxUnoDashTable_createInstance( pDocShell->MakeDrawLayer() ));
491 break;
492 case Type::NUMRULES:
493 if (pDocShell)
494 xRet.set(SvxCreateNumRule( pDocShell->MakeDrawLayer() ));
495 break;
496 case Type::DOCSPRSETT:
498 case Type::DOCCONF:
499 if (pDocShell)
500 xRet.set(static_cast<beans::XPropertySet*>(new ScDocumentConfiguration(pDocShell)));
501 break;
502 case Type::IMAP_RECT:
504 break;
505 case Type::IMAP_CIRC:
507 break;
508 case Type::IMAP_POLY:
510 break;
511
512 // Support creation of GraphicStorageHandler and EmbeddedObjectResolver
514 xRet.set(getXWeak(new SvXMLGraphicHelper( SvXMLGraphicHelperMode::Write )));
515 break;
517 xRet.set(getXWeak(new SvXMLGraphicHelper( SvXMLGraphicHelperMode::Read )));
518 break;
519 case Type::EXPORT_EOR:
520 if (pDocShell)
521 xRet.set(getXWeak(new SvXMLEmbeddedObjectHelper( *pDocShell, SvXMLEmbeddedObjectHelperMode::Write )));
522 break;
523 case Type::IMPORT_EOR:
524 if (pDocShell)
525 xRet.set(getXWeak(new SvXMLEmbeddedObjectHelper( *pDocShell, SvXMLEmbeddedObjectHelperMode::Read )));
526 break;
527 case Type::VALBIND:
529 if (pDocShell)
530 {
531 bool bListPos = ( nType == Type::LISTCELLBIND );
532 uno::Reference<sheet::XSpreadsheetDocument> xDoc( pDocShell->GetBaseModel(), uno::UNO_QUERY );
533 xRet.set(*new calc::OCellValueBinding( xDoc, bListPos ));
534 }
535 break;
536 case Type::LISTSOURCE:
537 if (pDocShell)
538 {
539 uno::Reference<sheet::XSpreadsheetDocument> xDoc( pDocShell->GetBaseModel(), uno::UNO_QUERY );
540 xRet.set(*new calc::OCellListSource( xDoc ));
541 }
542 break;
545 if (pDocShell)
546 {
547 bool bIsRange = ( nType == Type::RANGEADDRESS );
548 xRet.set(*new ScAddressConversionObj( pDocShell, bIsRange ));
549 }
550 break;
551 case Type::CHDATAPROV:
552 if (pDocShell)
553 xRet = *new ScChart2DataProvider( &pDocShell->GetDocument() );
554 break;
556 if (pDocShell)
557 xRet = *new sc::PivotTableDataProvider(pDocShell->GetDocument());
558 break;
560 if (pDocShell)
561 xRet.set(static_cast<sheet::XFormulaParser*>(new ScFormulaParserObj( pDocShell )));
562 break;
564 if (pDocShell)
565 {
566 ScDocument& rDoc = pDocShell->GetDocument();
567 ScAddress aAddress;
568 ScCompiler* pComp = new ScCompiler(rDoc, aAddress, rDoc.GetGrammar());
569 xRet.set(static_cast<sheet::XFormulaOpCodeMapper*>(new ScFormulaOpCodeMapperObj(::std::unique_ptr<formula::FormulaCompiler> (pComp))));
570 break;
571 }
572 break;
573#if HAVE_FEATURE_SCRIPTING
575 if (pDocShell && pDocShell->GetDocument().IsInVBAMode())
576 {
577 xRet.set(static_cast<container::XNameAccess*>(new ScVbaObjectForCodeNameProvider( pDocShell )));
578 }
579 break;
581 if ( pDocShell && isInVBAMode( *pDocShell ) )
582 {
583 xRet.set(static_cast<document::XCodeNameQuery*>(new ScVbaCodeNameProvider(*pDocShell)));
584 }
585 break;
586 case Type::VBAGLOBALS:
587 if (pDocShell)
588 {
589 uno::Any aGlobs;
590 if ( !pDocShell->GetBasicManager()->GetGlobalUNOConstant( "VBAGlobals", aGlobs ) )
591 {
592 uno::Sequence< uno::Any > aArgs{ uno::Any(uno::Reference(static_cast<css::sheet::XSpreadsheetDocument*>(pDocShell->GetModel()))) };
593 xRet = ::comphelper::getProcessServiceFactory()->createInstanceWithArguments( "ooo.vba.excel.Globals", aArgs );
594 pDocShell->GetBasicManager()->SetGlobalUNOConstant( "VBAGlobals", uno::Any( xRet ) );
596 if ( pAppMgr )
597 pAppMgr->SetGlobalUNOConstant( "ThisExcelDoc", aArgs[ 0 ] );
598
599 // create the VBA document event processor
600 uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents(
601 ::ooo::vba::createVBAUnoAPIServiceWithArgs( pDocShell, "com.sun.star.script.vba.VBASpreadsheetEventProcessor", aArgs ), uno::UNO_QUERY );
602 pDocShell->GetDocument().SetVbaEventProcessor( xVbaEvents );
603 }
604 }
605 break;
606#endif
607 default:
608 break;
609 }
610
611 return xRet;
612}
613
615{
616 const sal_uInt16 nEntries = SAL_N_ELEMENTS(aProvNamesId);
617 uno::Sequence<OUString> aRet(nEntries);
618 OUString* pArray = aRet.getArray();
619 for (sal_uInt16 i = 0; i < nEntries; i++)
620 {
621 pArray[i] = aProvNamesId[i].pName;
622 }
623 return aRet;
624}
625
626/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const char * pName
#define SC_AFMTOBJ_INVALID
Definition: afmtuno.hxx:38
void SetGlobalUNOConstant(const OUString &rName, const css::uno::Any &_rValue, css::uno::Any *pOldValue=nullptr)
bool GetGlobalUNOConstant(const OUString &rName, css::uno::Any &aOut)
const ScDocument & GetDocument() const
Definition: docsh.hxx:219
ScDrawLayer * MakeDrawLayer()
Definition: docsh2.cxx:169
ScModelObj * GetModel() const
Definition: docsh.hxx:432
void SetVbaEventProcessor(const css::uno::Reference< css::script::vba::XVBAEventProcessor > &rxVbaEvents)
Definition: document.hxx:2537
bool IsInVBAMode() const
Definition: document.cxx:6477
SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const
Definition: document.hxx:1010
const OUString & GetCodeName() const
Definition: document.hxx:609
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
Definition: document.cxx:204
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:297
virtual css::uno::Reference< css::drawing::XDrawPages > SAL_CALL getDrawPages() override
XDrawPagesSupplier.
Definition: docuno.cxx:2570
static css::uno::Sequence< OUString > GetAllServiceNames()
Definition: servuno.cxx:614
static css::uno::Reference< css::uno::XInterface > MakeInstance(Type nType, ScDocShell *pDocShell)
Definition: servuno.cxx:396
static Type GetProviderType(std::u16string_view rServiceName)
Definition: servuno.cxx:372
static const SvEventDescription * GetSupportedMacroItems()
Definition: shapeuno.cxx:69
static BasicManager * GetBasicManager()
css::uno::Reference< css::script::XLibraryContainer > GetBasicContainer()
BasicManager * GetBasicManager() const
css::uno::Reference< css::frame::XModel3 > GetBaseModel() const
int nCount
@ SHEET
Definition: document.hxx:272
OUString sName
OUString aName
#define SAL_N_ELEMENTS(arr)
Type
sal_Int32 getFieldType(guint nCol)
int i
index
css::uno::Reference< css::uno::XInterface > createVBAUnoAPIServiceWithArgs(SfxObjectShell const *pShell, const char *_pAsciiName, const css::uno::Sequence< css::uno::Any > &aArgs)
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
bool hasValue()
Reference< XModel > xModel
unsigned char sal_Bool
sal_Int16 SCTAB
Definition: types.hxx:22
const ProvNamesId_Type aProvNamesId[]
SVXCORE_DLLPUBLIC css::uno::Reference< css::uno::XInterface > SvxUnoDashTable_createInstance(SdrModel *pModel)
SVXCORE_DLLPUBLIC css::uno::Reference< css::uno::XInterface > SvxUnoGradientTable_createInstance(SdrModel *pModel)
SVXCORE_DLLPUBLIC css::uno::Reference< css::uno::XInterface > SvxUnoBitmapTable_createInstance(SdrModel *pModel)
SVXCORE_DLLPUBLIC css::uno::Reference< css::uno::XInterface > SvxUnoMarkerTable_createInstance(SdrModel *pModel)
SVXCORE_DLLPUBLIC css::uno::Reference< css::uno::XInterface > SvxUnoHatchTable_createInstance(SdrModel *pModel)
SVXCORE_DLLPUBLIC css::uno::Reference< css::uno::XInterface > SvxUnoTransGradientTable_createInstance(SdrModel *pModel)
SVT_DLLPUBLIC css::uno::Reference< css::uno::XInterface > SvUnoImageMapCircleObject_createInstance(const SvEventDescription *pSupportedMacroItems)
SVT_DLLPUBLIC css::uno::Reference< css::uno::XInterface > SvUnoImageMapPolygonObject_createInstance(const SvEventDescription *pSupportedMacroItems)
SVT_DLLPUBLIC css::uno::Reference< css::uno::XInterface > SvUnoImageMapRectangleObject_createInstance(const SvEventDescription *pSupportedMacroItems)
SVXCORE_DLLPUBLIC css::uno::Reference< css::container::XIndexReplace > SvxCreateNumRule(SdrModel *pModel)
constexpr OUStringLiteral SC_SERVICENAME_LISTCELLBIND
Definition: unonames.hxx:26
constexpr OUStringLiteral SC_SERVICENAME_CHDATAPROV
Definition: unonames.hxx:34
constexpr OUStringLiteral SC_SERVICENAME_RANGEADDRESS
Definition: unonames.hxx:29
constexpr OUStringLiteral SC_SERVICENAME_FORMULAPARS
Definition: unonames.hxx:31
constexpr OUStringLiteral SC_SERVICENAME_OPCODEMAPPER
Definition: unonames.hxx:32
constexpr OUStringLiteral SC_SERVICENAME_CELLADDRESS
Definition: unonames.hxx:28
constexpr OUStringLiteral SC_SERVICENAME_VALBIND
Definition: unonames.hxx:25
constexpr OUStringLiteral SC_SERVICENAME_LISTSOURCE
Definition: unonames.hxx:27
constexpr OUStringLiteral SC_SERVICENAME_CHART_PIVOTTABLE_DATAPROVIDER
Definition: unonames.hxx:36
constexpr OUStringLiteral CELLSTYLE
Definition: vbarange.cxx:681
@ TABLE
Definition: xmldpimp.hxx:43