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.sheet.TableAutoFormat", Type::AUTOFORMAT },
268 { "com.sun.star.sheet.TableAutoFormats", Type::AUTOFORMATS },
269 { "com.sun.star.sheet.SheetCellRanges", Type::CELLRANGES },
270 { "com.sun.star.sheet.FunctionDescriptions", Type::FUNCTIONDESCRIPTIONS },
271 { "com.sun.star.sheet.GlobalSheetSettings", Type::GLOBALSHEETSETTINGS },
272 { "com.sun.star.sheet.RecentFunctions", Type::RECENTFUNCTIONS },
273 { "com.sun.star.drawing.GradientTable", Type::GRADTAB },
274 { "com.sun.star.drawing.HatchTable", Type::HATCHTAB },
275 { "com.sun.star.drawing.BitmapTable", Type::BITMAPTAB },
276 { "com.sun.star.drawing.TransparencyGradientTable", Type::TRGRADTAB },
277 { "com.sun.star.drawing.MarkerTable", Type::MARKERTAB },
278 { "com.sun.star.drawing.DashTable", Type::DASHTAB },
279 { "com.sun.star.text.NumberingRules", Type::NUMRULES },
280 { "com.sun.star.sheet.Defaults", Type::DOCDEFLTS },
281 { "com.sun.star.drawing.Defaults", Type::DRAWDEFLTS },
282 { "com.sun.star.comp.SpreadsheetSettings", Type::DOCSPRSETT },
283 { "com.sun.star.document.Settings", Type::DOCCONF },
284 { "com.sun.star.image.ImageMapRectangleObject", Type::IMAP_RECT },
285 { "com.sun.star.image.ImageMapCircleObject", Type::IMAP_CIRC },
286 { "com.sun.star.image.ImageMapPolygonObject", Type::IMAP_POLY },
287
288 // Support creation of GraphicStorageHandler and EmbeddedObjectResolver
289 { "com.sun.star.document.ExportGraphicStorageHandler", Type::EXPORT_GRAPHIC_STORAGE_HANDLER },
290 { "com.sun.star.document.ImportGraphicStorageHandler", Type::IMPORT_GRAPHIC_STORAGE_HANDLER },
291 { "com.sun.star.document.ExportEmbeddedObjectResolver", Type::EXPORT_EOR },
292 { "com.sun.star.document.ImportEmbeddedObjectResolver", Type::IMPORT_EOR },
293
294 { SC_SERVICENAME_VALBIND, Type::VALBIND },
295 { SC_SERVICENAME_LISTCELLBIND, Type::LISTCELLBIND },
296 { SC_SERVICENAME_LISTSOURCE, Type::LISTSOURCE },
297 { SC_SERVICENAME_CELLADDRESS, Type::CELLADDRESS },
298 { SC_SERVICENAME_RANGEADDRESS, Type::RANGEADDRESS },
299
300 { "com.sun.star.sheet.DocumentSettings",Type::SHEETDOCSET },
301
302 { SC_SERVICENAME_CHDATAPROV, Type::CHDATAPROV },
303 { SC_SERVICENAME_CHART_PIVOTTABLE_DATAPROVIDER, Type::CHART_PIVOTTABLE_DATAPROVIDER },
304 { SC_SERVICENAME_FORMULAPARS, Type::FORMULAPARS },
305 { SC_SERVICENAME_OPCODEMAPPER, Type::OPCODEMAPPER },
306 { "ooo.vba.VBAObjectModuleObjectProvider", Type::VBAOBJECTPROVIDER },
307 { "ooo.vba.VBACodeNameProvider", Type::VBACODENAMEPROVIDER },
308 { "ooo.vba.VBAGlobals", Type::VBAGLOBALS },
309
310 // case-correct versions of the service names (#i102468#)
311 { "com.sun.star.text.textfield.URL", Type::URLFIELD },
312 { "com.sun.star.text.textfield.PageNumber", Type::PAGEFIELD },
313 { "com.sun.star.text.textfield.PageCount", Type::PAGESFIELD },
314 { "com.sun.star.text.textfield.Date", Type::DATEFIELD },
315 { "com.sun.star.text.textfield.Time", Type::TIMEFIELD },
316 { "com.sun.star.text.textfield.DateTime", Type::EXT_TIMEFIELD },
317 { "com.sun.star.text.textfield.docinfo.Title", Type::TITLEFIELD },
318 { "com.sun.star.text.textfield.FileName", Type::FILEFIELD },
319 { "com.sun.star.text.textfield.SheetName", Type::SHEETFIELD },
320 { "ooo.vba.VBAGlobals", Type::VBAGLOBALS },
321};
322
323// old service names that were in 567 still work in createInstance,
324// in case some macro is still using them
325const ProvNamesId_Type aOldNames[] =
326{
327 { "stardiv.one.text.TextField.URL", Type::URLFIELD },
328 { "stardiv.one.text.TextField.PageNumber", Type::PAGEFIELD },
329 { "stardiv.one.text.TextField.PageCount", Type::PAGESFIELD },
330 { "stardiv.one.text.TextField.Date", Type::DATEFIELD },
331 { "stardiv.one.text.TextField.Time", Type::TIMEFIELD },
332 { "stardiv.one.text.TextField.DocumentTitle", Type::TITLEFIELD },
333 { "stardiv.one.text.TextField.FileName", Type::FILEFIELD },
334 { "stardiv.one.text.TextField.SheetName", Type::SHEETFIELD },
335 { "stardiv.one.style.CellStyle", Type::CELLSTYLE },
336 { "stardiv.one.style.PageStyle", Type::PAGESTYLE },
337};
338
339sal_Int32 getFieldType(ScServiceProvider::Type nOldType)
340{
341 switch (nOldType)
342 {
343 case Type::URLFIELD:
344 return text::textfield::Type::URL;
345 case Type::PAGEFIELD:
346 return text::textfield::Type::PAGE;
347 case Type::PAGESFIELD:
348 return text::textfield::Type::PAGES;
349 case Type::DATEFIELD:
351 case Type::TIMEFIELD:
352 return text::textfield::Type::TIME;
353 case Type::EXT_TIMEFIELD:
354 return text::textfield::Type::EXTENDED_TIME;
355 case Type::TITLEFIELD:
356 return text::textfield::Type::DOCINFO_TITLE;
357 case Type::FILEFIELD:
358 return text::textfield::Type::EXTENDED_FILE;
359 case Type::SHEETFIELD:
361 default:
362 ;
363 }
364
365 return text::textfield::Type::URL; // default to URL for no reason whatsoever.
366}
367
368} // namespace
369
370
372{
373 if (!rServiceName.empty())
374 {
375 for (const ProvNamesId_Type & i : aProvNamesId)
376 {
377 if (rServiceName == i.pName)
378 {
379 return i.nType;
380 }
381 }
382
383 for (const ProvNamesId_Type & rOldName : aOldNames)
384 {
385 if (rServiceName == rOldName.pName)
386 {
387 OSL_FAIL("old service name used");
388 return rOldName.nType;
389 }
390 }
391 }
392 return Type::INVALID;
393}
394
395uno::Reference<uno::XInterface> ScServiceProvider::MakeInstance(
396 Type nType, ScDocShell* pDocShell )
397{
398 uno::Reference<uno::XInterface> xRet;
399
400 switch (nType)
401 {
402 case Type::SHEET:
403 // not inserted yet - DocShell=Null
404 xRet.set(static_cast<sheet::XSpreadsheet*>(new ScTableSheetObj(nullptr,0)));
405 break;
406 case Type::URLFIELD:
407 case Type::PAGEFIELD:
408 case Type::PAGESFIELD:
409 case Type::DATEFIELD:
410 case Type::TIMEFIELD:
412 case Type::TITLEFIELD:
413 case Type::FILEFIELD:
414 case Type::SHEETFIELD:
415 {
416 uno::Reference<text::XTextRange> xNullContent;
417 xRet.set(static_cast<text::XTextField*>(
418 new ScEditFieldObj(xNullContent, nullptr, getFieldType(nType), ESelection())));
419 } break;
420 case Type::CELLSTYLE:
421 xRet.set(static_cast<style::XStyle*>(new ScStyleObj( nullptr, SfxStyleFamily::Para, OUString() )));
422 break;
423 case Type::PAGESTYLE:
424 xRet.set(static_cast<style::XStyle*>(new ScStyleObj( nullptr, SfxStyleFamily::Page, OUString() )));
425 break;
426 case Type::AUTOFORMAT:
427 xRet.set(static_cast<container::XIndexAccess*>(new ScAutoFormatObj( SC_AFMTOBJ_INVALID )));
428 break;
430 xRet.set(static_cast<container::XIndexAccess*>(new ScAutoFormatsObj()));
431 break;
432 case Type::CELLRANGES:
433 // isn't inserted, rather filled
434 // -> DocShell must be set, but empty ranges
435 if (pDocShell)
436 xRet.set(static_cast<sheet::XSheetCellRanges*>(new ScCellRangesObj( pDocShell, ScRangeList() )));
437 break;
439 xRet.set(static_cast<sheet::XFunctionDescriptions*>(new ScFunctionListObj()));
440 break;
442 xRet.set(static_cast<sheet::XGlobalSheetSettings*>(new ScSpreadsheetSettings()));
443 break;
445 xRet.set(static_cast<sheet::XRecentFunctions*>(new ScRecentFunctionsObj()));
446 break;
447 case Type::DOCDEFLTS:
448 if (pDocShell)
449 xRet.set(static_cast<beans::XPropertySet*>(new ScDocDefaultsObj( pDocShell )));
450 break;
451 case Type::DRAWDEFLTS:
452 if (pDocShell)
453 xRet.set(static_cast<beans::XPropertySet*>(new ScDrawDefaultsObj( pDocShell )));
454 break;
455
456 // Drawing layer tables are not in SvxUnoDrawMSFactory,
457 // because SvxUnoDrawMSFactory doesn't have a SdrModel pointer.
458 // Drawing layer is always allocated if not there (MakeDrawLayer).
459
460 case Type::GRADTAB:
461 if (pDocShell)
462 xRet.set(SvxUnoGradientTable_createInstance( pDocShell->MakeDrawLayer() ));
463 break;
464 case Type::HATCHTAB:
465 if (pDocShell)
466 xRet.set(SvxUnoHatchTable_createInstance( pDocShell->MakeDrawLayer() ));
467 break;
468 case Type::BITMAPTAB:
469 if (pDocShell)
470 xRet.set(SvxUnoBitmapTable_createInstance( pDocShell->MakeDrawLayer() ));
471 break;
472 case Type::TRGRADTAB:
473 if (pDocShell)
475 break;
476 case Type::MARKERTAB:
477 if (pDocShell)
478 xRet.set(SvxUnoMarkerTable_createInstance( pDocShell->MakeDrawLayer() ));
479 break;
480 case Type::DASHTAB:
481 if (pDocShell)
482 xRet.set(SvxUnoDashTable_createInstance( pDocShell->MakeDrawLayer() ));
483 break;
484 case Type::NUMRULES:
485 if (pDocShell)
486 xRet.set(SvxCreateNumRule( pDocShell->MakeDrawLayer() ));
487 break;
488 case Type::DOCSPRSETT:
490 case Type::DOCCONF:
491 if (pDocShell)
492 xRet.set(static_cast<beans::XPropertySet*>(new ScDocumentConfiguration(pDocShell)));
493 break;
494 case Type::IMAP_RECT:
496 break;
497 case Type::IMAP_CIRC:
499 break;
500 case Type::IMAP_POLY:
502 break;
503
504 // Support creation of GraphicStorageHandler and EmbeddedObjectResolver
506 xRet.set(static_cast<cppu::OWeakObject *>(new SvXMLGraphicHelper( SvXMLGraphicHelperMode::Write )));
507 break;
509 xRet.set(static_cast<cppu::OWeakObject *>(new SvXMLGraphicHelper( SvXMLGraphicHelperMode::Read )));
510 break;
511 case Type::EXPORT_EOR:
512 if (pDocShell)
513 xRet.set(static_cast<cppu::OWeakObject *>(new SvXMLEmbeddedObjectHelper( *pDocShell, SvXMLEmbeddedObjectHelperMode::Write )));
514 break;
515 case Type::IMPORT_EOR:
516 if (pDocShell)
517 xRet.set(static_cast<cppu::OWeakObject *>(new SvXMLEmbeddedObjectHelper( *pDocShell, SvXMLEmbeddedObjectHelperMode::Read )));
518 break;
519 case Type::VALBIND:
521 if (pDocShell)
522 {
523 bool bListPos = ( nType == Type::LISTCELLBIND );
524 uno::Reference<sheet::XSpreadsheetDocument> xDoc( pDocShell->GetBaseModel(), uno::UNO_QUERY );
525 xRet.set(*new calc::OCellValueBinding( xDoc, bListPos ));
526 }
527 break;
528 case Type::LISTSOURCE:
529 if (pDocShell)
530 {
531 uno::Reference<sheet::XSpreadsheetDocument> xDoc( pDocShell->GetBaseModel(), uno::UNO_QUERY );
532 xRet.set(*new calc::OCellListSource( xDoc ));
533 }
534 break;
537 if (pDocShell)
538 {
539 bool bIsRange = ( nType == Type::RANGEADDRESS );
540 xRet.set(*new ScAddressConversionObj( pDocShell, bIsRange ));
541 }
542 break;
543 case Type::CHDATAPROV:
544 if (pDocShell)
545 xRet = *new ScChart2DataProvider( &pDocShell->GetDocument() );
546 break;
548 if (pDocShell)
549 xRet = *new sc::PivotTableDataProvider(pDocShell->GetDocument());
550 break;
552 if (pDocShell)
553 xRet.set(static_cast<sheet::XFormulaParser*>(new ScFormulaParserObj( pDocShell )));
554 break;
556 if (pDocShell)
557 {
558 ScDocument& rDoc = pDocShell->GetDocument();
559 ScAddress aAddress;
560 ScCompiler* pComp = new ScCompiler(rDoc, aAddress, rDoc.GetGrammar());
561 xRet.set(static_cast<sheet::XFormulaOpCodeMapper*>(new ScFormulaOpCodeMapperObj(::std::unique_ptr<formula::FormulaCompiler> (pComp))));
562 break;
563 }
564 break;
565#if HAVE_FEATURE_SCRIPTING
567 if (pDocShell && pDocShell->GetDocument().IsInVBAMode())
568 {
569 xRet.set(static_cast<container::XNameAccess*>(new ScVbaObjectForCodeNameProvider( pDocShell )));
570 }
571 break;
573 if ( pDocShell && isInVBAMode( *pDocShell ) )
574 {
575 xRet.set(static_cast<document::XCodeNameQuery*>(new ScVbaCodeNameProvider(*pDocShell)));
576 }
577 break;
578 case Type::VBAGLOBALS:
579 if (pDocShell)
580 {
581 uno::Any aGlobs;
582 if ( !pDocShell->GetBasicManager()->GetGlobalUNOConstant( "VBAGlobals", aGlobs ) )
583 {
584 uno::Sequence< uno::Any > aArgs{ uno::Any(uno::Reference(static_cast<css::sheet::XSpreadsheetDocument*>(pDocShell->GetModel()))) };
585 xRet = ::comphelper::getProcessServiceFactory()->createInstanceWithArguments( "ooo.vba.excel.Globals", aArgs );
586 pDocShell->GetBasicManager()->SetGlobalUNOConstant( "VBAGlobals", uno::Any( xRet ) );
587 BasicManager* pAppMgr = SfxApplication::GetBasicManager();
588 if ( pAppMgr )
589 pAppMgr->SetGlobalUNOConstant( "ThisExcelDoc", aArgs[ 0 ] );
590
591 // create the VBA document event processor
592 uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents(
593 ::ooo::vba::createVBAUnoAPIServiceWithArgs( pDocShell, "com.sun.star.script.vba.VBASpreadsheetEventProcessor", aArgs ), uno::UNO_QUERY );
594 pDocShell->GetDocument().SetVbaEventProcessor( xVbaEvents );
595 }
596 }
597 break;
598#endif
599 default:
600 break;
601 }
602
603 return xRet;
604}
605
607{
608 const sal_uInt16 nEntries = SAL_N_ELEMENTS(aProvNamesId);
609 uno::Sequence<OUString> aRet(nEntries);
610 OUString* pArray = aRet.getArray();
611 for (sal_uInt16 i = 0; i < nEntries; i++)
612 {
613 pArray[i] = aProvNamesId[i].pName;
614 }
615 return aRet;
616}
617
618/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const char * pName
#define SC_AFMTOBJ_INVALID
Definition: afmtuno.hxx:38
const ScDocument & GetDocument() const
Definition: docsh.hxx:220
ScDrawLayer * MakeDrawLayer()
Definition: docsh2.cxx:169
ScModelObj * GetModel() const
Definition: docsh.hxx:434
void SetVbaEventProcessor(const css::uno::Reference< css::script::vba::XVBAEventProcessor > &rxVbaEvents)
Definition: document.hxx:2530
bool IsInVBAMode() const
Definition: document.cxx:6607
SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const
Definition: document.hxx:1008
const OUString & GetCodeName() const
Definition: document.hxx:608
SC_DLLPUBLIC bool GetName(SCTAB nTab, OUString &rName) const
Definition: document.cxx:217
SC_DLLPUBLIC SCTAB GetTableCount() const
Definition: document.cxx:317
virtual css::uno::Reference< css::drawing::XDrawPages > SAL_CALL getDrawPages() override
XDrawPagesSupplier.
Definition: docuno.cxx:2538
static css::uno::Sequence< OUString > GetAllServiceNames()
Definition: servuno.cxx:606
static css::uno::Reference< css::uno::XInterface > MakeInstance(Type nType, ScDocShell *pDocShell)
Definition: servuno.cxx:395
static Type GetProviderType(std::u16string_view rServiceName)
Definition: servuno.cxx:371
static const SvEventDescription * GetSupportedMacroItems()
Definition: shapeuno.cxx:66
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:271
OUString aName
#define SAL_N_ELEMENTS(arr)
const char * sName
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