1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include <config_features.h>
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>
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>
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>
50 #include <PivotTableDataProvider.hxx>
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>
60 #include <vbahelper/vbaaccesshelper.hxx>
62 #include <comphelper/processfactory.hxx>
63 #include <basic/basmgr.hxx>
64 #include <sfx2/app.hxx>
66 #include <cppuhelper/implbase.hxx>
67 #include <com/sun/star/script/vba/XVBACompatibility.hpp>
69 using namespace ::com::sun::star
;
71 #if HAVE_FEATURE_SCRIPTING
73 static bool isInVBAMode( ScDocShell
& rDocSh
)
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();
86 #if HAVE_FEATURE_SCRIPTING
87 class ScVbaObjectForCodeNameProvider
: public ::cppu::WeakImplHelper
< container::XNameAccess
>
90 uno::Any maCachedObject
;
91 ScDocShell
* mpDocShell
;
93 explicit ScVbaObjectForCodeNameProvider( ScDocShell
* pDocShell
) : mpDocShell( pDocShell
)
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())))
100 maWorkbook
<<= ooo::vba::createVBAUnoAPIServiceWithArgs( mpDocShell
, "ooo.vba.excel.Workbook", aArgs
);
103 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
105 SolarMutexGuard aGuard
;
106 maCachedObject
= uno::Any(); // clear cached object
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
;
116 SCTAB nCount
= rDoc
.GetTableCount();
117 for( SCTAB i
= 0; i
< nCount
; i
++ )
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
) )
125 if( rDoc
.GetName( i
, sSheetName
) )
127 rtl::Reference
< ScModelObj
> xSpreadDoc( mpDocShell
->GetModel() );
128 uno::Reference
<sheet::XSpreadsheets
> xSheets( xSpreadDoc
->getSheets(), uno::UNO_SET_THROW
);
129 uno::Reference
< container::XIndexAccess
> xIndexAccess( xSheets
, uno::UNO_QUERY_THROW
);
130 uno::Reference
< sheet::XSpreadsheet
> xSheet( xIndexAccess
->getByIndex( i
), uno::UNO_QUERY_THROW
);
131 uno::Sequence
< uno::Any
> aArgs
{ maWorkbook
, uno::Any(uno::Reference
< frame::XModel
>(xSpreadDoc
)), uno::Any(sSheetName
) };
132 // use the convenience function
133 maCachedObject
<<= ooo::vba::createVBAUnoAPIServiceWithArgs( mpDocShell
, "ooo.vba.excel.Worksheet", aArgs
);
139 return maCachedObject
.hasValue();
142 css::uno::Any SAL_CALL
getByName( const OUString
& aName
) override
144 SolarMutexGuard aGuard
;
145 if ( !hasByName( aName
) )
146 throw css::container::NoSuchElementException();
147 return maCachedObject
;
149 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames( ) override
151 SolarMutexGuard aGuard
;
152 ScDocument
& rDoc
= mpDocShell
->GetDocument();
153 SCTAB nCount
= rDoc
.GetTableCount();
154 uno::Sequence
< OUString
> aNames( nCount
+ 1 );
155 auto pNames
= aNames
.getArray();
158 for( ; index
< nCount
; ++index
)
160 rDoc
.GetCodeName( index
, sCodeName
);
161 pNames
[ index
] = sCodeName
;
163 pNames
[ index
] = rDoc
.GetCodeName();
167 virtual css::uno::Type SAL_CALL
getElementType( ) override
{ return uno::Type(); }
168 virtual sal_Bool SAL_CALL
hasElements( ) override
{ return true; }
172 class ScVbaCodeNameProvider
: public ::cppu::WeakImplHelper
< document::XCodeNameQuery
>
174 ScDocShell
& mrDocShell
;
176 explicit ScVbaCodeNameProvider( ScDocShell
& rDocShell
) : mrDocShell(rDocShell
) {}
178 OUString SAL_CALL
getCodeNameForObject( const uno::Reference
< uno::XInterface
>& xIf
) override
180 SolarMutexGuard aGuard
;
183 // need to find the page ( and index ) for this control
184 uno::Reference
< container::XIndexAccess
> xIndex( mrDocShell
.GetModel()->getDrawPages(), uno::UNO_QUERY_THROW
);
185 sal_Int32 nLen
= xIndex
->getCount();
186 bool bMatched
= false;
187 for ( sal_Int32 index
= 0; index
< nLen
; ++index
)
191 uno::Reference
< form::XFormsSupplier
> xFormSupplier( xIndex
->getByIndex( index
), uno::UNO_QUERY_THROW
);
192 uno::Reference
< container::XIndexAccess
> xFormIndex( xFormSupplier
->getForms(), uno::UNO_QUERY_THROW
);
193 // get the www-standard container
194 uno::Reference
< container::XIndexAccess
> xFormControls( xFormIndex
->getByIndex(0), uno::UNO_QUERY_THROW
);
195 sal_Int32 nCntrls
= xFormControls
->getCount();
196 for( sal_Int32 cIndex
= 0; cIndex
< nCntrls
; ++cIndex
)
198 uno::Reference
< uno::XInterface
> xControl( xFormControls
->getByIndex( cIndex
), uno::UNO_QUERY_THROW
);
199 bMatched
= ( xControl
== xIf
);
203 mrDocShell
.GetDocument().GetCodeName( static_cast<SCTAB
>( index
), sName
);
208 catch( uno::Exception
& ) {}
212 // Probably should throw here ( if !bMatched )
216 OUString SAL_CALL
getCodeNameForContainer( const uno::Reference
<uno::XInterface
>& xContainer
) override
218 SolarMutexGuard aGuard
;
219 uno::Reference
<container::XIndexAccess
> xIndex(mrDocShell
.GetModel()->getDrawPages(), uno::UNO_QUERY_THROW
);
221 for (sal_Int32 i
= 0, n
= xIndex
->getCount(); i
< n
; ++i
)
225 uno::Reference
<form::XFormsSupplier
> xFormSupplier(xIndex
->getByIndex(i
), uno::UNO_QUERY_THROW
);
226 uno::Reference
<container::XIndexAccess
> xFormIndex(xFormSupplier
->getForms(), uno::UNO_QUERY_THROW
);
227 // get the www-standard container
228 uno::Reference
<container::XIndexAccess
> xFormControls(xFormIndex
->getByIndex(0), uno::UNO_QUERY_THROW
);
229 if (xFormControls
== xContainer
)
232 if (mrDocShell
.GetDocument().GetCodeName(static_cast<SCTAB
>(i
), aName
))
236 catch( uno::Exception
& ) {}
244 using Type
= ScServiceProvider::Type
;
246 struct ProvNamesId_Type
249 ScServiceProvider::Type nType
;
252 const ProvNamesId_Type aProvNamesId
[] =
254 { u
"com.sun.star.sheet.Spreadsheet"_ustr
, Type::SHEET
},
255 { u
"com.sun.star.text.TextField.URL"_ustr
, Type::URLFIELD
},
256 { u
"com.sun.star.text.TextField.PageNumber"_ustr
, Type::PAGEFIELD
},
257 { u
"com.sun.star.text.TextField.PageCount"_ustr
, Type::PAGESFIELD
},
258 { u
"com.sun.star.text.TextField.Date"_ustr
, Type::DATEFIELD
},
259 { u
"com.sun.star.text.TextField.Time"_ustr
, Type::TIMEFIELD
},
260 { u
"com.sun.star.text.TextField.DateTime"_ustr
, Type::EXT_TIMEFIELD
},
261 { u
"com.sun.star.text.TextField.DocInfo.Title"_ustr
, Type::TITLEFIELD
},
262 { u
"com.sun.star.text.TextField.FileName"_ustr
, Type::FILEFIELD
},
263 { u
"com.sun.star.text.TextField.SheetName"_ustr
, Type::SHEETFIELD
},
264 { u
"com.sun.star.style.CellStyle"_ustr
, Type::CELLSTYLE
},
265 { u
"com.sun.star.style.PageStyle"_ustr
, Type::PAGESTYLE
},
266 { u
"com.sun.star.style.GraphicStyle"_ustr
, Type::GRAPHICSTYLE
},
267 { u
"com.sun.star.sheet.TableAutoFormat"_ustr
, Type::AUTOFORMAT
},
268 { u
"com.sun.star.sheet.TableAutoFormats"_ustr
, Type::AUTOFORMATS
},
269 { u
"com.sun.star.sheet.SheetCellRanges"_ustr
, Type::CELLRANGES
},
270 { u
"com.sun.star.sheet.FunctionDescriptions"_ustr
, Type::FUNCTIONDESCRIPTIONS
},
271 { u
"com.sun.star.sheet.GlobalSheetSettings"_ustr
, Type::GLOBALSHEETSETTINGS
},
272 { u
"com.sun.star.sheet.RecentFunctions"_ustr
, Type::RECENTFUNCTIONS
},
273 { u
"com.sun.star.drawing.GradientTable"_ustr
, Type::GRADTAB
},
274 { u
"com.sun.star.drawing.HatchTable"_ustr
, Type::HATCHTAB
},
275 { u
"com.sun.star.drawing.BitmapTable"_ustr
, Type::BITMAPTAB
},
276 { u
"com.sun.star.drawing.TransparencyGradientTable"_ustr
, Type::TRGRADTAB
},
277 { u
"com.sun.star.drawing.MarkerTable"_ustr
, Type::MARKERTAB
},
278 { u
"com.sun.star.drawing.DashTable"_ustr
, Type::DASHTAB
},
279 { u
"com.sun.star.text.NumberingRules"_ustr
, Type::NUMRULES
},
280 { u
"com.sun.star.sheet.Defaults"_ustr
, Type::DOCDEFLTS
},
281 { u
"com.sun.star.drawing.Defaults"_ustr
, Type::DRAWDEFLTS
},
282 { u
"com.sun.star.comp.SpreadsheetSettings"_ustr
, Type::DOCSPRSETT
},
283 { u
"com.sun.star.document.Settings"_ustr
, Type::DOCCONF
},
284 { u
"com.sun.star.image.ImageMapRectangleObject"_ustr
, Type::IMAP_RECT
},
285 { u
"com.sun.star.image.ImageMapCircleObject"_ustr
, Type::IMAP_CIRC
},
286 { u
"com.sun.star.image.ImageMapPolygonObject"_ustr
, Type::IMAP_POLY
},
288 // Support creation of GraphicStorageHandler and EmbeddedObjectResolver
289 { u
"com.sun.star.document.ExportGraphicStorageHandler"_ustr
, Type::EXPORT_GRAPHIC_STORAGE_HANDLER
},
290 { u
"com.sun.star.document.ImportGraphicStorageHandler"_ustr
, Type::IMPORT_GRAPHIC_STORAGE_HANDLER
},
291 { u
"com.sun.star.document.ExportEmbeddedObjectResolver"_ustr
, Type::EXPORT_EOR
},
292 { u
"com.sun.star.document.ImportEmbeddedObjectResolver"_ustr
, Type::IMPORT_EOR
},
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
},
300 { u
"com.sun.star.sheet.DocumentSettings"_ustr
,Type::SHEETDOCSET
},
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 { u
"ooo.vba.VBAObjectModuleObjectProvider"_ustr
, Type::VBAOBJECTPROVIDER
},
307 { u
"ooo.vba.VBACodeNameProvider"_ustr
, Type::VBACODENAMEPROVIDER
},
308 { u
"ooo.vba.VBAGlobals"_ustr
, Type::VBAGLOBALS
},
310 // case-correct versions of the service names (#i102468#)
311 { u
"com.sun.star.text.textfield.URL"_ustr
, Type::URLFIELD
},
312 { u
"com.sun.star.text.textfield.PageNumber"_ustr
, Type::PAGEFIELD
},
313 { u
"com.sun.star.text.textfield.PageCount"_ustr
, Type::PAGESFIELD
},
314 { u
"com.sun.star.text.textfield.Date"_ustr
, Type::DATEFIELD
},
315 { u
"com.sun.star.text.textfield.Time"_ustr
, Type::TIMEFIELD
},
316 { u
"com.sun.star.text.textfield.DateTime"_ustr
, Type::EXT_TIMEFIELD
},
317 { u
"com.sun.star.text.textfield.docinfo.Title"_ustr
, Type::TITLEFIELD
},
318 { u
"com.sun.star.text.textfield.FileName"_ustr
, Type::FILEFIELD
},
319 { u
"com.sun.star.text.textfield.SheetName"_ustr
, Type::SHEETFIELD
},
320 { u
"ooo.vba.VBAGlobals"_ustr
, Type::VBAGLOBALS
},
323 // old service names that were in 567 still work in createInstance,
324 // in case some macro is still using them
325 const ProvNamesId_Type aOldNames
[] =
327 { u
"stardiv.one.text.TextField.URL"_ustr
, Type::URLFIELD
},
328 { u
"stardiv.one.text.TextField.PageNumber"_ustr
, Type::PAGEFIELD
},
329 { u
"stardiv.one.text.TextField.PageCount"_ustr
, Type::PAGESFIELD
},
330 { u
"stardiv.one.text.TextField.Date"_ustr
, Type::DATEFIELD
},
331 { u
"stardiv.one.text.TextField.Time"_ustr
, Type::TIMEFIELD
},
332 { u
"stardiv.one.text.TextField.DocumentTitle"_ustr
, Type::TITLEFIELD
},
333 { u
"stardiv.one.text.TextField.FileName"_ustr
, Type::FILEFIELD
},
334 { u
"stardiv.one.text.TextField.SheetName"_ustr
, Type::SHEETFIELD
},
335 { u
"stardiv.one.style.CellStyle"_ustr
, Type::CELLSTYLE
},
336 { u
"stardiv.one.style.PageStyle"_ustr
, Type::PAGESTYLE
},
339 sal_Int32
getFieldType(ScServiceProvider::Type nOldType
)
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
:
350 return text::textfield::Type::DATE
;
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
:
360 return text::textfield::Type::TABLE
;
365 return text::textfield::Type::URL
; // default to URL for no reason whatsoever.
371 ScServiceProvider::Type
ScServiceProvider::GetProviderType(std::u16string_view rServiceName
)
373 if (!rServiceName
.empty())
375 for (const ProvNamesId_Type
& i
: aProvNamesId
)
377 if (rServiceName
== i
.pName
)
383 for (const ProvNamesId_Type
& rOldName
: aOldNames
)
385 if (rServiceName
== rOldName
.pName
)
387 OSL_FAIL("old service name used");
388 return rOldName
.nType
;
392 return Type::INVALID
;
395 uno::Reference
<uno::XInterface
> ScServiceProvider::MakeInstance(
396 Type nType
, ScDocShell
* pDocShell
)
398 uno::Reference
<uno::XInterface
> xRet
;
403 // not inserted yet - DocShell=Null
404 xRet
.set(static_cast<sheet::XSpreadsheet
*>(new ScTableSheetObj(nullptr,0)));
407 case Type::PAGEFIELD
:
408 case Type::PAGESFIELD
:
409 case Type::DATEFIELD
:
410 case Type::TIMEFIELD
:
411 case Type::EXT_TIMEFIELD
:
412 case Type::TITLEFIELD
:
413 case Type::FILEFIELD
:
414 case Type::SHEETFIELD
:
416 uno::Reference
<text::XTextRange
> xNullContent
;
417 xRet
.set(static_cast<text::XTextField
*>(
418 new ScEditFieldObj(xNullContent
, nullptr, getFieldType(nType
), ESelection())));
420 case Type::CELLSTYLE
:
421 xRet
.set(static_cast<style::XStyle
*>(new ScStyleObj( nullptr, SfxStyleFamily::Para
, OUString() )));
423 case Type::PAGESTYLE
:
424 xRet
.set(static_cast<style::XStyle
*>(new ScStyleObj( nullptr, SfxStyleFamily::Page
, OUString() )));
426 case Type::GRAPHICSTYLE
:
429 pDocShell
->MakeDrawLayer();
430 xRet
.set(static_cast<style::XStyle
*>(new ScStyleObj( nullptr, SfxStyleFamily::Frame
, OUString() )));
433 case Type::AUTOFORMAT
:
434 xRet
.set(static_cast<container::XIndexAccess
*>(new ScAutoFormatObj( SC_AFMTOBJ_INVALID
)));
436 case Type::AUTOFORMATS
:
437 xRet
.set(static_cast<container::XIndexAccess
*>(new ScAutoFormatsObj()));
439 case Type::CELLRANGES
:
440 // isn't inserted, rather filled
441 // -> DocShell must be set, but empty ranges
443 xRet
.set(static_cast<sheet::XSheetCellRanges
*>(new ScCellRangesObj( pDocShell
, ScRangeList() )));
445 case Type::FUNCTIONDESCRIPTIONS
:
446 xRet
.set(static_cast<sheet::XFunctionDescriptions
*>(new ScFunctionListObj()));
448 case Type::GLOBALSHEETSETTINGS
:
449 xRet
.set(static_cast<sheet::XGlobalSheetSettings
*>(new ScSpreadsheetSettings()));
451 case Type::RECENTFUNCTIONS
:
452 xRet
.set(static_cast<sheet::XRecentFunctions
*>(new ScRecentFunctionsObj()));
454 case Type::DOCDEFLTS
:
456 xRet
.set(static_cast<beans::XPropertySet
*>(new ScDocDefaultsObj( pDocShell
)));
458 case Type::DRAWDEFLTS
:
460 xRet
.set(static_cast<beans::XPropertySet
*>(new ScDrawDefaultsObj( pDocShell
)));
463 // Drawing layer tables are not in SvxUnoDrawMSFactory,
464 // because SvxUnoDrawMSFactory doesn't have a SdrModel pointer.
465 // Drawing layer is always allocated if not there (MakeDrawLayer).
469 xRet
.set(SvxUnoGradientTable_createInstance( pDocShell
->MakeDrawLayer() ));
473 xRet
.set(SvxUnoHatchTable_createInstance( pDocShell
->MakeDrawLayer() ));
475 case Type::BITMAPTAB
:
477 xRet
.set(SvxUnoBitmapTable_createInstance( pDocShell
->MakeDrawLayer() ));
479 case Type::TRGRADTAB
:
481 xRet
.set(SvxUnoTransGradientTable_createInstance( pDocShell
->MakeDrawLayer() ));
483 case Type::MARKERTAB
:
485 xRet
.set(SvxUnoMarkerTable_createInstance( pDocShell
->MakeDrawLayer() ));
489 xRet
.set(SvxUnoDashTable_createInstance( pDocShell
->MakeDrawLayer() ));
493 xRet
.set(SvxCreateNumRule( pDocShell
->MakeDrawLayer() ));
495 case Type::DOCSPRSETT
:
496 case Type::SHEETDOCSET
:
499 xRet
.set(static_cast<beans::XPropertySet
*>(new ScDocumentConfiguration(pDocShell
)));
501 case Type::IMAP_RECT
:
502 xRet
.set(SvUnoImageMapRectangleObject_createInstance( ScShapeObj::GetSupportedMacroItems() ));
504 case Type::IMAP_CIRC
:
505 xRet
.set(SvUnoImageMapCircleObject_createInstance( ScShapeObj::GetSupportedMacroItems() ));
507 case Type::IMAP_POLY
:
508 xRet
.set(SvUnoImageMapPolygonObject_createInstance( ScShapeObj::GetSupportedMacroItems() ));
511 // Support creation of GraphicStorageHandler and EmbeddedObjectResolver
512 case Type::EXPORT_GRAPHIC_STORAGE_HANDLER
:
513 xRet
.set(getXWeak(new SvXMLGraphicHelper( SvXMLGraphicHelperMode::Write
)));
515 case Type::IMPORT_GRAPHIC_STORAGE_HANDLER
:
516 xRet
.set(getXWeak(new SvXMLGraphicHelper( SvXMLGraphicHelperMode::Read
)));
518 case Type::EXPORT_EOR
:
520 xRet
.set(getXWeak(new SvXMLEmbeddedObjectHelper( *pDocShell
, SvXMLEmbeddedObjectHelperMode::Write
)));
522 case Type::IMPORT_EOR
:
524 xRet
.set(getXWeak(new SvXMLEmbeddedObjectHelper( *pDocShell
, SvXMLEmbeddedObjectHelperMode::Read
)));
527 case Type::LISTCELLBIND
:
530 bool bListPos
= ( nType
== Type::LISTCELLBIND
);
531 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc( pDocShell
->GetBaseModel(), uno::UNO_QUERY
);
532 xRet
.set(*new calc::OCellValueBinding( xDoc
, bListPos
));
535 case Type::LISTSOURCE
:
538 uno::Reference
<sheet::XSpreadsheetDocument
> xDoc( pDocShell
->GetBaseModel(), uno::UNO_QUERY
);
539 xRet
.set(*new calc::OCellListSource( xDoc
));
542 case Type::CELLADDRESS
:
543 case Type::RANGEADDRESS
:
546 bool bIsRange
= ( nType
== Type::RANGEADDRESS
);
547 xRet
.set(*new ScAddressConversionObj( pDocShell
, bIsRange
));
550 case Type::CHDATAPROV
:
552 xRet
= *new ScChart2DataProvider( &pDocShell
->GetDocument() );
554 case Type::CHART_PIVOTTABLE_DATAPROVIDER
:
556 xRet
= *new sc::PivotTableDataProvider(pDocShell
->GetDocument());
558 case Type::FORMULAPARS
:
560 xRet
.set(static_cast<sheet::XFormulaParser
*>(new ScFormulaParserObj( pDocShell
)));
562 case Type::OPCODEMAPPER
:
565 ScDocument
& rDoc
= pDocShell
->GetDocument();
567 ScCompiler
* pComp
= new ScCompiler(rDoc
, aAddress
, rDoc
.GetGrammar());
568 xRet
.set(static_cast<sheet::XFormulaOpCodeMapper
*>(new ScFormulaOpCodeMapperObj(::std::unique_ptr
<formula::FormulaCompiler
> (pComp
))));
572 #if HAVE_FEATURE_SCRIPTING
573 case Type::VBAOBJECTPROVIDER
:
574 if (pDocShell
&& pDocShell
->GetDocument().IsInVBAMode())
576 xRet
.set(static_cast<container::XNameAccess
*>(new ScVbaObjectForCodeNameProvider( pDocShell
)));
579 case Type::VBACODENAMEPROVIDER
:
580 if ( pDocShell
&& isInVBAMode( *pDocShell
) )
582 xRet
.set(static_cast<document::XCodeNameQuery
*>(new ScVbaCodeNameProvider(*pDocShell
)));
585 case Type::VBAGLOBALS
:
589 if ( !pDocShell
->GetBasicManager()->GetGlobalUNOConstant( u
"VBAGlobals"_ustr
, aGlobs
) )
591 uno::Sequence
< uno::Any
> aArgs
{ uno::Any(uno::Reference(static_cast<css::sheet::XSpreadsheetDocument
*>(pDocShell
->GetModel()))) };
592 xRet
= ::comphelper::getProcessServiceFactory()->createInstanceWithArguments( u
"ooo.vba.excel.Globals"_ustr
, aArgs
);
593 pDocShell
->GetBasicManager()->SetGlobalUNOConstant( u
"VBAGlobals"_ustr
, uno::Any( xRet
) );
594 BasicManager
* pAppMgr
= SfxApplication::GetBasicManager();
596 pAppMgr
->SetGlobalUNOConstant( u
"ThisExcelDoc"_ustr
, aArgs
[ 0 ] );
598 // create the VBA document event processor
599 uno::Reference
< script::vba::XVBAEventProcessor
> xVbaEvents(
600 ::ooo::vba::createVBAUnoAPIServiceWithArgs( pDocShell
, "com.sun.star.script.vba.VBASpreadsheetEventProcessor", aArgs
), uno::UNO_QUERY
);
601 pDocShell
->GetDocument().SetVbaEventProcessor( xVbaEvents
);
613 uno::Sequence
<OUString
> ScServiceProvider::GetAllServiceNames()
615 const sal_uInt16 nEntries
= SAL_N_ELEMENTS(aProvNamesId
);
616 uno::Sequence
<OUString
> aRet(nEntries
);
617 OUString
* pArray
= aRet
.getArray();
618 for (sal_uInt16 i
= 0; i
< nEntries
; i
++)
620 pArray
[i
] = aProvNamesId
[i
].pName
;
625 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */