merge the formfield patch from ooo-build
[ooovba.git] / sc / source / ui / unoobj / servuno.cxx
blob809d1f863727e84f244314f18467fcb9b204d9b0
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: servuno.cxx,v $
10 * $Revision: 1.17.32.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 #include <tools/debug.hxx>
37 #include <svtools/unoimap.hxx>
38 #include <svx/unofill.hxx>
39 #include <svx/unonrule.hxx>
40 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
41 #include <com/sun/star/container/XNameAccess.hpp>
43 #include "servuno.hxx"
44 #include "unonames.hxx"
45 #include "cellsuno.hxx"
46 #include "fielduno.hxx"
47 #include "styleuno.hxx"
48 #include "afmtuno.hxx"
49 #include "defltuno.hxx"
50 #include "drdefuno.hxx"
51 #include "docsh.hxx"
52 #include "drwlayer.hxx"
53 #include "confuno.hxx"
54 #include "shapeuno.hxx"
55 #include "cellvaluebinding.hxx"
56 #include "celllistsource.hxx"
57 #include "addruno.hxx"
58 #include "chart2uno.hxx"
59 #include "tokenuno.hxx"
61 // #100263# Support creation of GraphicObjectResolver and EmbeddedObjectResolver
62 #include <svx/xmleohlp.hxx>
63 #include <svx/xmlgrhlp.hxx>
65 #include <comphelper/processfactory.hxx>
66 #include <com/sun/star/document/XCodeNameQuery.hpp>
67 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
68 #include <com/sun/star/form/XFormsSupplier.hpp>
69 #include <com/sun/star/script/ScriptEventDescriptor.hpp>
70 #include <comphelper/componentcontext.hxx>
71 #include <cppuhelper/component_context.hxx>
72 #include <vbahelper/vbahelper.hxx>
73 using namespace ::com::sun::star;
75 class ScVbaObjectForCodeNameProvider : public ::cppu::WeakImplHelper1< container::XNameAccess >
77 uno::Any maWorkbook;
78 uno::Any maCachedObject;
79 ScDocShell* mpDocShell;
80 public:
81 ScVbaObjectForCodeNameProvider( ScDocShell* pDocShell ) : mpDocShell( pDocShell )
83 ScDocument* pDoc = mpDocShell->GetDocument();
84 if ( !pDoc )
85 throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("")), uno::Reference< uno::XInterface >() );
87 uno::Sequence< uno::Any > aArgs(2);
88 aArgs[0] = uno::Any( uno::Reference< uno::XInterface >() );
89 aArgs[1] = uno::Any( mpDocShell->GetModel() );
90 maWorkbook <<= ov::createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.excel.Workbook", aArgs );
93 virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException )
95 maCachedObject = uno::Any(); // clear cached object
96 String sName = aName;
97 ScDocument* pDoc = mpDocShell->GetDocument();
98 if ( !pDoc )
99 throw uno::RuntimeException();
100 if ( sName == pDoc->GetCodeName() )
101 maCachedObject = maWorkbook;
102 else
104 String sCodeName;
105 SCTAB nCount = pDoc->GetTableCount();
106 for( SCTAB i = 0; i < nCount; i++ )
108 pDoc->GetCodeName( i, sCodeName );
109 if( sCodeName == sName )
111 String sSheetName;
112 if( pDoc->GetName( i, sSheetName ) )
114 uno::Reference< frame::XModel > xModel( mpDocShell->GetModel() );
115 uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( xModel, uno::UNO_QUERY_THROW );
116 uno::Reference<sheet::XSpreadsheets > xSheets( xSpreadDoc->getSheets(), uno::UNO_QUERY_THROW );
117 uno::Reference< container::XIndexAccess > xIndexAccess( xSheets, uno::UNO_QUERY_THROW );
118 uno::Reference< sheet::XSpreadsheet > xSheet( xIndexAccess->getByIndex( i ), uno::UNO_QUERY_THROW );
119 uno::Sequence< uno::Any > aArgs(3);
120 aArgs[0] = maWorkbook;
121 aArgs[1] = uno::Any( xModel );
122 aArgs[2] = uno::Any( rtl::OUString( sSheetName ) );
123 maCachedObject <<= ov::createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.excel.Worksheet", aArgs );
124 break;
129 return maCachedObject.hasValue();
132 ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
134 OSL_TRACE("ScVbaObjectForCodeNameProvider::getByName( %s )",
135 rtl::OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr() );
136 if ( !hasByName( aName ) )
137 throw ::com::sun::star::container::NoSuchElementException();
138 return maCachedObject;
140 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (::com::sun::star::uno::RuntimeException)
142 ScDocument* pDoc = mpDocShell->GetDocument();
143 if ( !pDoc )
144 throw uno::RuntimeException();
145 SCTAB nCount = pDoc->GetTableCount();
146 uno::Sequence< rtl::OUString > aNames( nCount + 1 );
147 SCTAB index = 0;
148 String sCodeName;
149 for( ; index < nCount; ++index )
151 pDoc->GetCodeName( index, sCodeName );
152 aNames[ index ] = sCodeName;
154 aNames[ index ] = pDoc->GetCodeName();
155 return aNames;
157 // XElemenAccess
158 virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException){ return uno::Type(); }
159 virtual ::sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException ) { return sal_True; }
163 class ScVbaCodeNameProvider : public ::cppu::WeakImplHelper1< document::XCodeNameQuery >
165 ScDocShell* mpDocShell;
166 public:
167 ScVbaCodeNameProvider( ScDocShell* pDocShell ) : mpDocShell( pDocShell ) {}
168 // XCodeNameQuery
169 rtl::OUString SAL_CALL getCodeNameForObject( const uno::Reference< uno::XInterface >& xIf ) throw( uno::RuntimeException )
171 rtl::OUString sCodeName;
172 if ( mpDocShell )
174 OSL_TRACE( "*** In ScVbaCodeNameProvider::getCodeNameForObject");
175 // need to find the page ( and index ) for this control
176 uno::Reference< drawing::XDrawPagesSupplier > xSupplier( mpDocShell->GetModel(), uno::UNO_QUERY_THROW );
177 uno::Reference< container::XIndexAccess > xIndex( xSupplier->getDrawPages(), uno::UNO_QUERY_THROW );
178 sal_Int32 nLen = xIndex->getCount();
179 bool bMatched = false;
180 uno::Sequence< script::ScriptEventDescriptor > aFakeEvents;
181 for ( sal_Int32 index = 0; index < nLen; ++index )
185 uno::Reference< form::XFormsSupplier > xFormSupplier( xIndex->getByIndex( index ), uno::UNO_QUERY_THROW );
186 uno::Reference< container::XIndexAccess > xFormIndex( xFormSupplier->getForms(), uno::UNO_QUERY_THROW );
187 // get the www-standard container
188 uno::Reference< container::XIndexAccess > xFormControls( xFormIndex->getByIndex(0), uno::UNO_QUERY_THROW );
189 sal_Int32 nCntrls = xFormControls->getCount();
190 for( sal_Int32 cIndex = 0; cIndex < nCntrls; ++cIndex )
192 uno::Reference< uno::XInterface > xControl( xFormControls->getByIndex( cIndex ), uno::UNO_QUERY_THROW );
193 bMatched = ( xControl == xIf );
194 if ( bMatched )
196 String sName;
197 mpDocShell->GetDocument()->GetCodeName( index, sName );
198 sCodeName = sName;
202 catch( uno::Exception& ) {}
203 if ( bMatched )
204 break;
207 // Probably should throw here ( if !bMatched )
208 return sCodeName;
213 //------------------------------------------------------------------------
215 struct ProvNamesId_Type
217 const char * pName;
218 sal_uInt16 nType;
221 static const ProvNamesId_Type __FAR_DATA aProvNamesId[] =
223 { "com.sun.star.sheet.Spreadsheet", SC_SERVICE_SHEET },
224 { "com.sun.star.text.TextField.URL", SC_SERVICE_URLFIELD },
225 { "com.sun.star.text.TextField.PageNumber", SC_SERVICE_PAGEFIELD },
226 { "com.sun.star.text.TextField.PageCount", SC_SERVICE_PAGESFIELD },
227 { "com.sun.star.text.TextField.Date", SC_SERVICE_DATEFIELD },
228 { "com.sun.star.text.TextField.Time", SC_SERVICE_TIMEFIELD },
229 { "com.sun.star.text.TextField.DocumentTitle", SC_SERVICE_TITLEFIELD },
230 { "com.sun.star.text.TextField.FileName", SC_SERVICE_FILEFIELD },
231 { "com.sun.star.text.TextField.SheetName", SC_SERVICE_SHEETFIELD },
232 { "com.sun.star.style.CellStyle", SC_SERVICE_CELLSTYLE },
233 { "com.sun.star.style.PageStyle", SC_SERVICE_PAGESTYLE },
234 { "com.sun.star.sheet.TableAutoFormat", SC_SERVICE_AUTOFORMAT },
235 { "com.sun.star.sheet.SheetCellRanges", SC_SERVICE_CELLRANGES },
236 { "com.sun.star.drawing.GradientTable", SC_SERVICE_GRADTAB },
237 { "com.sun.star.drawing.HatchTable", SC_SERVICE_HATCHTAB },
238 { "com.sun.star.drawing.BitmapTable", SC_SERVICE_BITMAPTAB },
239 { "com.sun.star.drawing.TransparencyGradientTable", SC_SERVICE_TRGRADTAB },
240 { "com.sun.star.drawing.MarkerTable", SC_SERVICE_MARKERTAB },
241 { "com.sun.star.drawing.DashTable", SC_SERVICE_DASHTAB },
242 { "com.sun.star.text.NumberingRules", SC_SERVICE_NUMRULES },
243 { "com.sun.star.sheet.Defaults", SC_SERVICE_DOCDEFLTS },
244 { "com.sun.star.drawing.Defaults", SC_SERVICE_DRAWDEFLTS },
245 { "com.sun.star.comp.SpreadsheetSettings", SC_SERVICE_DOCSPRSETT },
246 { "com.sun.star.document.Settings", SC_SERVICE_DOCCONF },
247 { "com.sun.star.image.ImageMapRectangleObject", SC_SERVICE_IMAP_RECT },
248 { "com.sun.star.image.ImageMapCircleObject", SC_SERVICE_IMAP_CIRC },
249 { "com.sun.star.image.ImageMapPolygonObject", SC_SERVICE_IMAP_POLY },
251 // #100263# Support creation of GraphicObjectResolver and EmbeddedObjectResolver
252 { "com.sun.star.document.ExportGraphicObjectResolver", SC_SERVICE_EXPORT_GOR },
253 { "com.sun.star.document.ImportGraphicObjectResolver", SC_SERVICE_IMPORT_GOR },
254 { "com.sun.star.document.ExportEmbeddedObjectResolver", SC_SERVICE_EXPORT_EOR },
255 { "com.sun.star.document.ImportEmbeddedObjectResolver", SC_SERVICE_IMPORT_EOR },
257 { SC_SERVICENAME_VALBIND, SC_SERVICE_VALBIND },
258 { SC_SERVICENAME_LISTCELLBIND, SC_SERVICE_LISTCELLBIND },
259 { SC_SERVICENAME_LISTSOURCE, SC_SERVICE_LISTSOURCE },
260 { SC_SERVICENAME_CELLADDRESS, SC_SERVICE_CELLADDRESS },
261 { SC_SERVICENAME_RANGEADDRESS, SC_SERVICE_RANGEADDRESS },
263 { "com.sun.star.sheet.DocumentSettings",SC_SERVICE_SHEETDOCSET },
265 { SC_SERVICENAME_CHDATAPROV, SC_SERVICE_CHDATAPROV },
266 { SC_SERVICENAME_FORMULAPARS, SC_SERVICE_FORMULAPARS },
267 { SC_SERVICENAME_OPCODEMAPPER, SC_SERVICE_OPCODEMAPPER },
268 { "ooo.vba.VBAObjectModuleObjectProvider", SC_SERVICE_VBAOBJECTPROVIDER },
269 { "ooo.vba.VBACodeNameProvider", SC_SERVICE_VBACODENAMEPROVIDER },
271 // case-correct versions of the service names (#i102468#)
272 { "com.sun.star.text.textfield.URL", SC_SERVICE_URLFIELD },
273 { "com.sun.star.text.textfield.PageNumber", SC_SERVICE_PAGEFIELD },
274 { "com.sun.star.text.textfield.PageCount", SC_SERVICE_PAGESFIELD },
275 { "com.sun.star.text.textfield.Date", SC_SERVICE_DATEFIELD },
276 { "com.sun.star.text.textfield.Time", SC_SERVICE_TIMEFIELD },
277 { "com.sun.star.text.textfield.DocumentTitle", SC_SERVICE_TITLEFIELD },
278 { "com.sun.star.text.textfield.FileName", SC_SERVICE_FILEFIELD },
279 { "com.sun.star.text.textfield.SheetName", SC_SERVICE_SHEETFIELD },
283 // old service names that were in 567 still work in createInstance,
284 // in case some macro is still using them
287 static const sal_Char* __FAR_DATA aOldNames[SC_SERVICE_COUNT] =
289 "", // SC_SERVICE_SHEET
290 "stardiv.one.text.TextField.URL", // SC_SERVICE_URLFIELD
291 "stardiv.one.text.TextField.PageNumber", // SC_SERVICE_PAGEFIELD
292 "stardiv.one.text.TextField.PageCount", // SC_SERVICE_PAGESFIELD
293 "stardiv.one.text.TextField.Date", // SC_SERVICE_DATEFIELD
294 "stardiv.one.text.TextField.Time", // SC_SERVICE_TIMEFIELD
295 "stardiv.one.text.TextField.DocumentTitle", // SC_SERVICE_TITLEFIELD
296 "stardiv.one.text.TextField.FileName", // SC_SERVICE_FILEFIELD
297 "stardiv.one.text.TextField.SheetName", // SC_SERVICE_SHEETFIELD
298 "stardiv.one.style.CellStyle", // SC_SERVICE_CELLSTYLE
299 "stardiv.one.style.PageStyle", // SC_SERVICE_PAGESTYLE
300 "", // SC_SERVICE_AUTOFORMAT
301 "", // SC_SERVICE_CELLRANGES
302 "", // SC_SERVICE_GRADTAB
303 "", // SC_SERVICE_HATCHTAB
304 "", // SC_SERVICE_BITMAPTAB
305 "", // SC_SERVICE_TRGRADTAB
306 "", // SC_SERVICE_MARKERTAB
307 "", // SC_SERVICE_DASHTAB
308 "", // SC_SERVICE_NUMRULES
309 "", // SC_SERVICE_DOCDEFLTS
310 "", // SC_SERVICE_DRAWDEFLTS
311 "", // SC_SERVICE_DOCSPRSETT
312 "", // SC_SERVICE_DOCCONF
313 "", // SC_SERVICE_IMAP_RECT
314 "", // SC_SERVICE_IMAP_CIRC
315 "", // SC_SERVICE_IMAP_POLY
317 // #100263# Support creation of GraphicObjectResolver and EmbeddedObjectResolver
318 "", // SC_SERVICE_EXPORT_GOR
319 "", // SC_SERVICE_IMPORT_GOR
320 "", // SC_SERVICE_EXPORT_EOR
321 "", // SC_SERVICE_IMPORT_EOR
323 "", // SC_SERVICE_VALBIND
324 "", // SC_SERVICE_LISTCELLBIND
325 "", // SC_SERVICE_LISTSOURCE
326 "", // SC_SERVICE_CELLADDRESS
327 "", // SC_SERVICE_RANGEADDRESS
328 "", // SC_SERVICE_SHEETDOCSET
329 "", // SC_SERVICE_CHDATAPROV
330 "", // SC_SERVICE_FORMULAPARS
331 "", // SC_SERVICE_OPCODEMAPPER
332 "", // SC_SERVICE_VBAOBJECTPROVIDER
333 "", // SC_SERVICE_VBACODENAMEPROVIDER
339 //------------------------------------------------------------------------
341 // alles static
343 //UNUSED2008-05 String ScServiceProvider::GetProviderName(sal_uInt16 nObjectType)
344 //UNUSED2008-05 {
345 //UNUSED2008-05 String sRet;
346 //UNUSED2008-05 if (nObjectType < SC_SERVICE_COUNT)
347 //UNUSED2008-05 sRet = String::CreateFromAscii( aProvNames[nObjectType] );
348 //UNUSED2008-05 return sRet;
349 //UNUSED2008-05 }
351 sal_uInt16 ScServiceProvider::GetProviderType(const String& rServiceName)
353 if (rServiceName.Len())
355 const sal_uInt16 nEntries =
356 sizeof(aProvNamesId) / sizeof(aProvNamesId[0]);
357 for (sal_uInt16 i = 0; i < nEntries; i++)
359 if (rServiceName.EqualsAscii( aProvNamesId[i].pName ))
361 return aProvNamesId[i].nType;
365 USHORT i;
366 for (i=0; i<SC_SERVICE_COUNT; i++)
368 DBG_ASSERT( aOldNames[i], "ScServiceProvider::GetProviderType: no oldname => crash");
369 if (rServiceName.EqualsAscii( aOldNames[i] ))
371 DBG_ERROR("old service name used");
372 return i;
376 return SC_SERVICE_INVALID;
379 uno::Reference<uno::XInterface> ScServiceProvider::MakeInstance(
380 sal_uInt16 nType, ScDocShell* pDocShell )
382 uno::Reference<uno::XInterface> xRet;
383 switch (nType)
385 case SC_SERVICE_SHEET:
386 // noch nicht eingefuegt - DocShell=Null
387 xRet.set((sheet::XSpreadsheet*)new ScTableSheetObj(NULL,0));
388 break;
389 case SC_SERVICE_URLFIELD:
390 xRet.set((text::XTextField*)new ScCellFieldObj( NULL, ScAddress(), ESelection() ));
391 break;
392 case SC_SERVICE_PAGEFIELD:
393 case SC_SERVICE_PAGESFIELD:
394 case SC_SERVICE_DATEFIELD:
395 case SC_SERVICE_TIMEFIELD:
396 case SC_SERVICE_TITLEFIELD:
397 case SC_SERVICE_FILEFIELD:
398 case SC_SERVICE_SHEETFIELD:
399 xRet.set((text::XTextField*)new ScHeaderFieldObj( NULL, 0, nType, ESelection() ));
400 break;
401 case SC_SERVICE_CELLSTYLE:
402 xRet.set((style::XStyle*)new ScStyleObj( NULL, SFX_STYLE_FAMILY_PARA, String() ));
403 break;
404 case SC_SERVICE_PAGESTYLE:
405 xRet.set((style::XStyle*)new ScStyleObj( NULL, SFX_STYLE_FAMILY_PAGE, String() ));
406 break;
407 case SC_SERVICE_AUTOFORMAT:
408 xRet.set((container::XIndexAccess*)new ScAutoFormatObj( SC_AFMTOBJ_INVALID ));
409 break;
410 case SC_SERVICE_CELLRANGES:
411 // wird nicht eingefuegt, sondern gefuellt
412 // -> DocShell muss gesetzt sein, aber leere Ranges
413 if (pDocShell)
414 xRet.set((sheet::XSheetCellRanges*)new ScCellRangesObj( pDocShell, ScRangeList() ));
415 break;
417 case SC_SERVICE_DOCDEFLTS:
418 if (pDocShell)
419 xRet.set((beans::XPropertySet*)new ScDocDefaultsObj( pDocShell ));
420 break;
421 case SC_SERVICE_DRAWDEFLTS:
422 if (pDocShell)
423 xRet.set((beans::XPropertySet*)new ScDrawDefaultsObj( pDocShell ));
424 break;
426 // Drawing layer tables are not in SvxUnoDrawMSFactory,
427 // because SvxUnoDrawMSFactory doesn't have a SdrModel pointer.
428 // Drawing layer is always allocated if not there (MakeDrawLayer).
430 case SC_SERVICE_GRADTAB:
431 if (pDocShell)
432 xRet.set(SvxUnoGradientTable_createInstance( pDocShell->MakeDrawLayer() ));
433 break;
434 case SC_SERVICE_HATCHTAB:
435 if (pDocShell)
436 xRet.set(SvxUnoHatchTable_createInstance( pDocShell->MakeDrawLayer() ));
437 break;
438 case SC_SERVICE_BITMAPTAB:
439 if (pDocShell)
440 xRet.set(SvxUnoBitmapTable_createInstance( pDocShell->MakeDrawLayer() ));
441 break;
442 case SC_SERVICE_TRGRADTAB:
443 if (pDocShell)
444 xRet.set(SvxUnoTransGradientTable_createInstance( pDocShell->MakeDrawLayer() ));
445 break;
446 case SC_SERVICE_MARKERTAB:
447 if (pDocShell)
448 xRet.set(SvxUnoMarkerTable_createInstance( pDocShell->MakeDrawLayer() ));
449 break;
450 case SC_SERVICE_DASHTAB:
451 if (pDocShell)
452 xRet.set(SvxUnoDashTable_createInstance( pDocShell->MakeDrawLayer() ));
453 break;
454 case SC_SERVICE_NUMRULES:
455 if (pDocShell)
456 xRet.set(SvxCreateNumRule( pDocShell->MakeDrawLayer() ));
457 break;
458 case SC_SERVICE_DOCSPRSETT:
459 case SC_SERVICE_SHEETDOCSET:
460 case SC_SERVICE_DOCCONF:
461 if (pDocShell)
462 xRet.set((beans::XPropertySet*)new ScDocumentConfiguration(pDocShell));
463 break;
465 case SC_SERVICE_IMAP_RECT:
466 xRet.set(SvUnoImageMapRectangleObject_createInstance( ScShapeObj::GetSupportedMacroItems() ));
467 break;
468 case SC_SERVICE_IMAP_CIRC:
469 xRet.set(SvUnoImageMapCircleObject_createInstance( ScShapeObj::GetSupportedMacroItems() ));
470 break;
471 case SC_SERVICE_IMAP_POLY:
472 xRet.set(SvUnoImageMapPolygonObject_createInstance( ScShapeObj::GetSupportedMacroItems() ));
473 break;
475 // #100263# Support creation of GraphicObjectResolver and EmbeddedObjectResolver
476 case SC_SERVICE_EXPORT_GOR:
477 xRet.set((::cppu::OWeakObject * )new SvXMLGraphicHelper( GRAPHICHELPER_MODE_WRITE ));
478 break;
480 case SC_SERVICE_IMPORT_GOR:
481 xRet.set((::cppu::OWeakObject * )new SvXMLGraphicHelper( GRAPHICHELPER_MODE_READ ));
482 break;
484 case SC_SERVICE_EXPORT_EOR:
485 if (pDocShell)
486 xRet.set((::cppu::OWeakObject * )new SvXMLEmbeddedObjectHelper( *pDocShell, EMBEDDEDOBJECTHELPER_MODE_WRITE ));
487 break;
489 case SC_SERVICE_IMPORT_EOR:
490 if (pDocShell)
491 xRet.set((::cppu::OWeakObject * )new SvXMLEmbeddedObjectHelper( *pDocShell, EMBEDDEDOBJECTHELPER_MODE_READ ));
492 break;
494 case SC_SERVICE_VALBIND:
495 case SC_SERVICE_LISTCELLBIND:
496 if (pDocShell)
498 sal_Bool bListPos = ( nType == SC_SERVICE_LISTCELLBIND );
499 uno::Reference<sheet::XSpreadsheetDocument> xDoc( pDocShell->GetBaseModel(), uno::UNO_QUERY );
500 xRet.set(*new calc::OCellValueBinding( xDoc, bListPos ));
502 break;
503 case SC_SERVICE_LISTSOURCE:
504 if (pDocShell)
506 uno::Reference<sheet::XSpreadsheetDocument> xDoc( pDocShell->GetBaseModel(), uno::UNO_QUERY );
507 xRet.set(*new calc::OCellListSource( xDoc ));
509 break;
510 case SC_SERVICE_CELLADDRESS:
511 case SC_SERVICE_RANGEADDRESS:
512 if (pDocShell)
514 sal_Bool bRange = ( nType == SC_SERVICE_RANGEADDRESS );
515 xRet.set(*new ScAddressConversionObj( pDocShell, bRange ));
517 break;
519 case SC_SERVICE_CHDATAPROV:
520 if (pDocShell && pDocShell->GetDocument())
521 xRet = *new ScChart2DataProvider( pDocShell->GetDocument() );
522 break;
524 case SC_SERVICE_FORMULAPARS:
525 if (pDocShell)
526 xRet.set(static_cast<sheet::XFormulaParser*>(new ScFormulaParserObj( pDocShell )));
527 break;
529 case SC_SERVICE_OPCODEMAPPER:
531 ScDocument* pDoc = pDocShell->GetDocument();
532 ScAddress aAddress;
533 ScCompiler* pComp = new ScCompiler(pDoc,aAddress);
534 pComp->SetGrammar( pDoc->GetGrammar() );
535 xRet.set(static_cast<sheet::XFormulaOpCodeMapper*>(new ScFormulaOpCodeMapperObj(::std::auto_ptr<formula::FormulaCompiler> (pComp))));
537 break;
538 case SC_SERVICE_VBAOBJECTPROVIDER:
539 xRet.set(static_cast<container::XNameAccess*>(new ScVbaObjectForCodeNameProvider( pDocShell )));
540 break;
541 case SC_SERVICE_VBACODENAMEPROVIDER:
542 xRet.set(static_cast<document::XCodeNameQuery*>(new ScVbaCodeNameProvider( pDocShell )));
543 break;
545 return xRet;
548 uno::Sequence<rtl::OUString> ScServiceProvider::GetAllServiceNames()
550 const sal_uInt16 nEntries = sizeof(aProvNamesId) / sizeof(aProvNamesId[0]);
551 uno::Sequence<rtl::OUString> aRet(nEntries);
552 rtl::OUString* pArray = aRet.getArray();
553 for (sal_uInt16 i = 0; i < nEntries; i++)
555 pArray[i] = rtl::OUString::createFromAscii( aProvNamesId[i].pName );
557 return aRet;