xref: /aoo41x/main/sc/source/ui/vba/vbaworkbook.cxx (revision c83e58a0)
1cdf0e10cSrcweir /*************************************************************************
2cdf0e10cSrcweir  *
3cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4cdf0e10cSrcweir  *
5cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6cdf0e10cSrcweir  *
7cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8cdf0e10cSrcweir  *
9cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10cdf0e10cSrcweir  *
11cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14cdf0e10cSrcweir  *
15cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20cdf0e10cSrcweir  *
21cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25cdf0e10cSrcweir  *
26cdf0e10cSrcweir  ************************************************************************/
27cdf0e10cSrcweir #include <vbahelper/helperdecl.hxx>
28cdf0e10cSrcweir #include <tools/urlobj.hxx>
29cdf0e10cSrcweir #include <comphelper/unwrapargs.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <com/sun/star/util/XModifiable.hpp>
32cdf0e10cSrcweir #include <com/sun/star/util/XProtectable.hpp>
33cdf0e10cSrcweir #include <com/sun/star/sheet/XSpreadsheetView.hpp>
34cdf0e10cSrcweir #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
35cdf0e10cSrcweir #include <com/sun/star/frame/XStorable.hpp>
36cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
37cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
38cdf0e10cSrcweir #include <ooo/vba/excel/XlFileFormat.hpp>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #include "scextopt.hxx"
41cdf0e10cSrcweir #include "vbaworksheet.hxx"
42cdf0e10cSrcweir #include "vbaworksheets.hxx"
43cdf0e10cSrcweir #include "vbaworkbook.hxx"
44cdf0e10cSrcweir #include "vbawindows.hxx"
45cdf0e10cSrcweir #include "vbastyles.hxx"
46cdf0e10cSrcweir #include "excelvbahelper.hxx"
47cdf0e10cSrcweir #include "vbapalette.hxx"
48cdf0e10cSrcweir #include <osl/file.hxx>
49cdf0e10cSrcweir #include <stdio.h>
50cdf0e10cSrcweir #include "vbanames.hxx"  // Amelia Wang
51cdf0e10cSrcweir #include "nameuno.hxx"
52cdf0e10cSrcweir #include "docoptio.hxx"
53cdf0e10cSrcweir #include "unonames.hxx"
54cdf0e10cSrcweir 
55cdf0e10cSrcweir // Much of the impl. for the equivalend UNO module is
56cdf0e10cSrcweir // sc/source/ui/unoobj/docuno.cxx, viewuno.cxx
57cdf0e10cSrcweir 
58cdf0e10cSrcweir using namespace ::ooo::vba;
59cdf0e10cSrcweir using namespace ::com::sun::star;
60cdf0e10cSrcweir 
61cdf0e10cSrcweir class ActiveSheet : public ScVbaWorksheet
62cdf0e10cSrcweir {
63cdf0e10cSrcweir protected:
64cdf0e10cSrcweir 	virtual uno::Reference< frame::XModel > getModel()
65cdf0e10cSrcweir 	{
66cdf0e10cSrcweir 		return getCurrentExcelDoc( mxContext );
67cdf0e10cSrcweir 	}
68cdf0e10cSrcweir 	virtual uno::Reference< sheet::XSpreadsheet > getSheet()
69cdf0e10cSrcweir 	{
70cdf0e10cSrcweir 		uno::Reference< frame::XModel > xModel = getModel();
71cdf0e10cSrcweir 		uno::Reference< sheet::XSpreadsheet > xSheet;
72cdf0e10cSrcweir 		if ( xModel.is() )
73cdf0e10cSrcweir 		{
74cdf0e10cSrcweir 			uno::Reference< sheet::XSpreadsheetView > xSpreadsheet(
75cdf0e10cSrcweir                         	xModel->getCurrentController(), uno::UNO_QUERY );
76cdf0e10cSrcweir 			if ( xSpreadsheet.is() )
77cdf0e10cSrcweir 				xSheet = xSpreadsheet->getActiveSheet();
78cdf0e10cSrcweir 		}
79cdf0e10cSrcweir 		return xSheet;
80cdf0e10cSrcweir 	}
81cdf0e10cSrcweir public:
82cdf0e10cSrcweir 	ActiveSheet( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext ) : ScVbaWorksheet( xParent, xContext ) {}
83cdf0e10cSrcweir 
84cdf0e10cSrcweir };
85cdf0e10cSrcweir 
86cdf0e10cSrcweir uno::Sequence< sal_Int32 > ScVbaWorkbook::ColorData;
87cdf0e10cSrcweir 
88cdf0e10cSrcweir void ScVbaWorkbook::initColorData( const uno::Sequence< sal_Int32 >& sColors )
89cdf0e10cSrcweir {
90cdf0e10cSrcweir 		const sal_Int32* pSource = sColors.getConstArray();
91cdf0e10cSrcweir 		sal_Int32* pDest = ColorData.getArray();
92cdf0e10cSrcweir 		const sal_Int32* pEnd = pSource + sColors.getLength();
93cdf0e10cSrcweir 		for ( ; pSource != pEnd; ++pSource, ++pDest )
94cdf0e10cSrcweir 			*pDest = *pSource;
95cdf0e10cSrcweir }
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 
98cdf0e10cSrcweir void SAL_CALL
99cdf0e10cSrcweir ScVbaWorkbook::ResetColors(  ) throw (::script::BasicErrorException, ::uno::RuntimeException)
100cdf0e10cSrcweir {
101cdf0e10cSrcweir 		uno::Reference< container::XIndexAccess > xIndexAccess( ScVbaPalette::getDefaultPalette(), uno::UNO_QUERY_THROW );
102cdf0e10cSrcweir 		sal_Int32 nLen = xIndexAccess->getCount();
103cdf0e10cSrcweir 		ColorData.realloc( nLen );
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 		uno::Sequence< sal_Int32 > dDefaultColors( nLen );
106cdf0e10cSrcweir 		sal_Int32* pDest = dDefaultColors.getArray();
107cdf0e10cSrcweir 		for ( sal_Int32 index=0; index < nLen; ++pDest, ++index )
108cdf0e10cSrcweir 			xIndexAccess->getByIndex( index )  >>= (*pDest);
109cdf0e10cSrcweir 		initColorData( dDefaultColors );
110cdf0e10cSrcweir }
111cdf0e10cSrcweir 
112cdf0e10cSrcweir ::uno::Any SAL_CALL
113cdf0e10cSrcweir ScVbaWorkbook::Colors( const ::uno::Any& Index ) throw (::script::BasicErrorException, ::uno::RuntimeException)
114cdf0e10cSrcweir {
115cdf0e10cSrcweir 	uno::Any aRet;
116cdf0e10cSrcweir 	if ( Index.getValue() )
117cdf0e10cSrcweir 	{
118cdf0e10cSrcweir 		sal_Int32 nIndex = 0;
119cdf0e10cSrcweir 		Index >>= nIndex;
120cdf0e10cSrcweir 		aRet = uno::makeAny( XLRGBToOORGB( ColorData[ --nIndex ] ) );
121cdf0e10cSrcweir 	}
122cdf0e10cSrcweir 	else
123cdf0e10cSrcweir 		aRet = uno::makeAny( ColorData );
124cdf0e10cSrcweir 	return aRet;
125cdf0e10cSrcweir }
126cdf0e10cSrcweir 
127cdf0e10cSrcweir ::sal_Int32 SAL_CALL
128cdf0e10cSrcweir ScVbaWorkbook::FileFormat(  ) throw (::script::BasicErrorException, ::uno::RuntimeException)
129cdf0e10cSrcweir {
130cdf0e10cSrcweir         sal_Int32 aFileFormat = 0;
131cdf0e10cSrcweir         rtl::OUString aFilterName;
132cdf0e10cSrcweir         uno::Sequence< beans::PropertyValue > aArgs = getModel()->getArgs();
133cdf0e10cSrcweir 
134cdf0e10cSrcweir 		// #FIXME - seems suspect should we not walk through the properties
135cdf0e10cSrcweir 		// to find the FilterName
136cdf0e10cSrcweir         if (aArgs[0].Name.equalsAscii( "FilterName")) {
137cdf0e10cSrcweir             aArgs[0].Value >>= aFilterName;
138cdf0e10cSrcweir         } else {
139cdf0e10cSrcweir            aArgs[1].Value >>= aFilterName;
140cdf0e10cSrcweir         }
141cdf0e10cSrcweir 
142cdf0e10cSrcweir         if (aFilterName.equalsAscii("Text - txt - csv (StarCalc)")) {
143cdf0e10cSrcweir             aFileFormat = excel::XlFileFormat::xlCSV; //xlFileFormat.
144cdf0e10cSrcweir         }
145cdf0e10cSrcweir 
146cdf0e10cSrcweir         if (aFilterName.equalsAscii("DBF")) {
147cdf0e10cSrcweir             aFileFormat = excel::XlFileFormat::xlDBF4;
148cdf0e10cSrcweir         }
149cdf0e10cSrcweir 
150cdf0e10cSrcweir         if (aFilterName.equalsAscii("DIF")) {
151cdf0e10cSrcweir             aFileFormat = excel::XlFileFormat::xlDIF;
152cdf0e10cSrcweir         }
153cdf0e10cSrcweir 
154cdf0e10cSrcweir         if (aFilterName.equalsAscii("Lotus")) {
155cdf0e10cSrcweir             aFileFormat = excel::XlFileFormat::xlWK3;
156cdf0e10cSrcweir         }
157cdf0e10cSrcweir 
158cdf0e10cSrcweir         if (aFilterName.equalsAscii("MS Excel 4.0")) {
159cdf0e10cSrcweir             aFileFormat = excel::XlFileFormat::xlExcel4Workbook;
160cdf0e10cSrcweir         }
161cdf0e10cSrcweir 
162cdf0e10cSrcweir         if (aFilterName.equalsAscii("MS Excel 5.0/95")) {
163cdf0e10cSrcweir             aFileFormat = excel::XlFileFormat::xlExcel5;
164cdf0e10cSrcweir         }
165cdf0e10cSrcweir 
166cdf0e10cSrcweir         if (aFilterName.equalsAscii("MS Excel 97")) {
167cdf0e10cSrcweir             aFileFormat = excel::XlFileFormat::xlExcel9795;
168cdf0e10cSrcweir         }
169cdf0e10cSrcweir 
170cdf0e10cSrcweir         if (aFilterName.equalsAscii("HTML (StarCalc)")) {
171cdf0e10cSrcweir             aFileFormat = excel::XlFileFormat::xlHtml;
172cdf0e10cSrcweir         }
173cdf0e10cSrcweir 
174cdf0e10cSrcweir         if (aFilterName.equalsAscii("calc_StarOffice_XML_Calc_Template")) {
175cdf0e10cSrcweir             aFileFormat = excel::XlFileFormat::xlTemplate;
176cdf0e10cSrcweir         }
177cdf0e10cSrcweir 
178cdf0e10cSrcweir         if (aFilterName.equalsAscii("StarOffice XML (Calc)")) {
179cdf0e10cSrcweir             aFileFormat = excel::XlFileFormat::xlWorkbookNormal;
180cdf0e10cSrcweir         }
181cdf0e10cSrcweir         if (aFilterName.equalsAscii("calc8")) {
182cdf0e10cSrcweir             aFileFormat = excel::XlFileFormat::xlWorkbookNormal;
183cdf0e10cSrcweir         }
184cdf0e10cSrcweir 
185cdf0e10cSrcweir         return aFileFormat;
186cdf0e10cSrcweir }
187cdf0e10cSrcweir 
188cdf0e10cSrcweir void
189cdf0e10cSrcweir ScVbaWorkbook::init()
190cdf0e10cSrcweir {
191cdf0e10cSrcweir 	if ( !ColorData.getLength() )
192cdf0e10cSrcweir 		ResetColors();
193cdf0e10cSrcweir }
194cdf0e10cSrcweir ScVbaWorkbook::ScVbaWorkbook( 	const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext) :ScVbaWorkbook_BASE( xParent, xContext )
195cdf0e10cSrcweir {
196cdf0e10cSrcweir 	//#FIXME this persists the color data per office instance and
197cdf0e10cSrcweir 	// not per workbook instance, need to hook the data into XModel
198cdf0e10cSrcweir 	// ( e.g. we already store the imported palette in there )
199cdf0e10cSrcweir 	// so we should,
200cdf0e10cSrcweir 	// a) make the class that does that a service
201cdf0e10cSrcweir 	// b) make that service implement XIndexContainer
202cdf0e10cSrcweir 	init();
203cdf0e10cSrcweir }
204cdf0e10cSrcweir 
205cdf0e10cSrcweir ScVbaWorkbook::ScVbaWorkbook( 	const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, css::uno::Reference< css::frame::XModel > xModel ) : ScVbaWorkbook_BASE( xParent, xContext, xModel )
206cdf0e10cSrcweir {
207cdf0e10cSrcweir 	init();
208cdf0e10cSrcweir }
209cdf0e10cSrcweir 
210cdf0e10cSrcweir ScVbaWorkbook::ScVbaWorkbook( uno::Sequence< uno::Any> const & args,
211cdf0e10cSrcweir     uno::Reference< uno::XComponentContext> const & xContext ) : ScVbaWorkbook_BASE( args, xContext )
212cdf0e10cSrcweir {
213cdf0e10cSrcweir 	init();
214cdf0e10cSrcweir }
215cdf0e10cSrcweir 
216cdf0e10cSrcweir uno::Reference< excel::XWorksheet >
217cdf0e10cSrcweir ScVbaWorkbook::getActiveSheet() throw (uno::RuntimeException)
218cdf0e10cSrcweir {
219cdf0e10cSrcweir 	uno::Reference< frame::XModel > xModel( getCurrentExcelDoc( mxContext ), uno::UNO_SET_THROW );
220cdf0e10cSrcweir 	uno::Reference< sheet::XSpreadsheetView > xView( xModel->getCurrentController(), uno::UNO_QUERY_THROW );
221cdf0e10cSrcweir     uno::Reference< sheet::XSpreadsheet > xSheet( xView->getActiveSheet(), uno::UNO_SET_THROW );
222cdf0e10cSrcweir     // #162503# return the original sheet module wrapper object, instead of a new instance
223*c83e58a0SMichael Stahl     uno::Reference< excel::XWorksheet > xWorksheet( excel::getUnoSheetModuleObj( xSheet ), uno::UNO_QUERY );
224*c83e58a0SMichael Stahl     if( xWorksheet.is() ) return xWorksheet;
225*c83e58a0SMichael Stahl     // #i116936# excel::getUnoSheetModuleObj() may return null in documents without global VBA mode enabled
226*c83e58a0SMichael Stahl     return new ScVbaWorksheet( this, mxContext, xSheet, xModel );
227cdf0e10cSrcweir }
228cdf0e10cSrcweir 
229cdf0e10cSrcweir uno::Any SAL_CALL
230cdf0e10cSrcweir ScVbaWorkbook::Sheets( const uno::Any& aIndex ) throw (uno::RuntimeException)
231cdf0e10cSrcweir {
232cdf0e10cSrcweir 	return Worksheets( aIndex );
233cdf0e10cSrcweir }
234cdf0e10cSrcweir 
235cdf0e10cSrcweir uno::Any SAL_CALL
236cdf0e10cSrcweir ScVbaWorkbook::Worksheets( const uno::Any& aIndex ) throw (uno::RuntimeException)
237cdf0e10cSrcweir {
238cdf0e10cSrcweir 	uno::Reference< frame::XModel > xModel( getModel() );
239cdf0e10cSrcweir 	uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( xModel, uno::UNO_QUERY_THROW );
240cdf0e10cSrcweir 	uno::Reference<container::XIndexAccess > xSheets( xSpreadDoc->getSheets(), uno::UNO_QUERY_THROW );
241cdf0e10cSrcweir 	uno::Reference< XCollection > xWorkSheets(  new ScVbaWorksheets( this, mxContext, xSheets, xModel ) );
242cdf0e10cSrcweir 	if (  aIndex.getValueTypeClass() == uno::TypeClass_VOID )
243cdf0e10cSrcweir 	{
244cdf0e10cSrcweir 		return uno::Any( xWorkSheets );
245cdf0e10cSrcweir 	}
246cdf0e10cSrcweir 	// pass on to collection
247cdf0e10cSrcweir 	return uno::Any( xWorkSheets->Item( aIndex, uno::Any() ) );
248cdf0e10cSrcweir }
249cdf0e10cSrcweir uno::Any SAL_CALL
250cdf0e10cSrcweir ScVbaWorkbook::Windows( const uno::Any& aIndex ) throw (uno::RuntimeException)
251cdf0e10cSrcweir {
252cdf0e10cSrcweir 
253cdf0e10cSrcweir 	uno::Reference< excel::XWindows >  xWindows( new ScVbaWindows( getParent(), mxContext ) );
254cdf0e10cSrcweir 	if ( aIndex.getValueTypeClass() == uno::TypeClass_VOID )
255cdf0e10cSrcweir 		return uno::Any( xWindows );
256cdf0e10cSrcweir 	return uno::Any( xWindows->Item( aIndex, uno::Any() ) );
257cdf0e10cSrcweir }
258cdf0e10cSrcweir 
259cdf0e10cSrcweir void SAL_CALL
260cdf0e10cSrcweir ScVbaWorkbook::Activate() throw (uno::RuntimeException)
261cdf0e10cSrcweir {
262cdf0e10cSrcweir     VbaDocumentBase::Activate();
263cdf0e10cSrcweir }
264cdf0e10cSrcweir 
265cdf0e10cSrcweir ::sal_Bool
266cdf0e10cSrcweir ScVbaWorkbook::getProtectStructure() throw (uno::RuntimeException)
267cdf0e10cSrcweir {
268cdf0e10cSrcweir 	uno::Reference< util::XProtectable > xProt( getModel(), uno::UNO_QUERY_THROW );
269cdf0e10cSrcweir 	return xProt->isProtected();
270cdf0e10cSrcweir }
271cdf0e10cSrcweir 
272cdf0e10cSrcweir ::sal_Bool SAL_CALL ScVbaWorkbook::getPrecisionAsDisplayed() throw (uno::RuntimeException)
273cdf0e10cSrcweir {
274cdf0e10cSrcweir     uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
275cdf0e10cSrcweir     ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument();
276cdf0e10cSrcweir     return pDoc->GetDocOptions().IsCalcAsShown();
277cdf0e10cSrcweir }
278cdf0e10cSrcweir 
279cdf0e10cSrcweir void SAL_CALL ScVbaWorkbook::setPrecisionAsDisplayed( sal_Bool _precisionAsDisplayed ) throw (uno::RuntimeException)
280cdf0e10cSrcweir {
281cdf0e10cSrcweir     uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
282cdf0e10cSrcweir     ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument();
283cdf0e10cSrcweir     ScDocOptions aOpt = pDoc->GetDocOptions();
284cdf0e10cSrcweir     aOpt.SetCalcAsShown( _precisionAsDisplayed );
285cdf0e10cSrcweir     pDoc->SetDocOptions( aOpt );
286cdf0e10cSrcweir }
287cdf0e10cSrcweir 
288cdf0e10cSrcweir void
289cdf0e10cSrcweir ScVbaWorkbook::SaveCopyAs( const rtl::OUString& sFileName ) throw ( uno::RuntimeException)
290cdf0e10cSrcweir {
291cdf0e10cSrcweir 	rtl::OUString aURL;
292cdf0e10cSrcweir 	osl::FileBase::getFileURLFromSystemPath( sFileName, aURL );
293cdf0e10cSrcweir 	uno::Reference< frame::XStorable > xStor( getModel(), uno::UNO_QUERY_THROW );
294cdf0e10cSrcweir 	uno::Sequence<  beans::PropertyValue > storeProps(1);
295cdf0e10cSrcweir 	storeProps[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterName" ) );
296cdf0e10cSrcweir 	storeProps[0].Value <<= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MS Excel 97" ) );
297cdf0e10cSrcweir 	xStor->storeToURL( aURL, storeProps );
298cdf0e10cSrcweir }
299cdf0e10cSrcweir 
300cdf0e10cSrcweir css::uno::Any SAL_CALL
301cdf0e10cSrcweir ScVbaWorkbook::Styles( const uno::Any& Item ) throw (uno::RuntimeException)
302cdf0e10cSrcweir {
303cdf0e10cSrcweir 	// quick look and Styles object doesn't seem to have a valid parent
304cdf0e10cSrcweir 	// or a least the object browser just shows an object that has no
305cdf0e10cSrcweir 	// variables ( therefore... leave as NULL for now )
306cdf0e10cSrcweir 	uno::Reference< XCollection > dStyles = new ScVbaStyles( uno::Reference< XHelperInterface >(), mxContext, getModel() );
307cdf0e10cSrcweir 	if ( Item.hasValue() )
308cdf0e10cSrcweir 		return dStyles->Item( Item, uno::Any() );
309cdf0e10cSrcweir 	return uno::makeAny( dStyles );
310cdf0e10cSrcweir }
311cdf0e10cSrcweir 
312cdf0e10cSrcweir // Amelia Wang
313cdf0e10cSrcweir uno::Any SAL_CALL
314cdf0e10cSrcweir ScVbaWorkbook::Names( const uno::Any& aIndex ) throw (uno::RuntimeException)
315cdf0e10cSrcweir {
316cdf0e10cSrcweir 	uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_SET_THROW );
317cdf0e10cSrcweir 	uno::Reference< beans::XPropertySet > xProps( xModel, uno::UNO_QUERY_THROW );
318cdf0e10cSrcweir 	uno::Reference< sheet::XNamedRanges > xNamedRanges(  xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NamedRanges") ) ), uno::UNO_QUERY_THROW );
319cdf0e10cSrcweir 	uno::Reference< XCollection > xNames( new ScVbaNames( this, mxContext, xNamedRanges, xModel ) );
320cdf0e10cSrcweir     if ( aIndex.hasValue() )
321cdf0e10cSrcweir         return uno::Any( xNames->Item( aIndex, uno::Any() ) );
322cdf0e10cSrcweir 	return uno::Any( xNames );
323cdf0e10cSrcweir }
324cdf0e10cSrcweir 
325cdf0e10cSrcweir rtl::OUString&
326cdf0e10cSrcweir ScVbaWorkbook::getServiceImplName()
327cdf0e10cSrcweir {
328cdf0e10cSrcweir 	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaWorkbook") );
329cdf0e10cSrcweir 	return sImplName;
330cdf0e10cSrcweir }
331cdf0e10cSrcweir 
332cdf0e10cSrcweir uno::Sequence< rtl::OUString >
333cdf0e10cSrcweir ScVbaWorkbook::getServiceNames()
334cdf0e10cSrcweir {
335cdf0e10cSrcweir 	static uno::Sequence< rtl::OUString > aServiceNames;
336cdf0e10cSrcweir 	if ( aServiceNames.getLength() == 0 )
337cdf0e10cSrcweir 	{
338cdf0e10cSrcweir 		aServiceNames.realloc( 1 );
339cdf0e10cSrcweir 		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Workbook" ) );
340cdf0e10cSrcweir 	}
341cdf0e10cSrcweir 	return aServiceNames;
342cdf0e10cSrcweir }
343cdf0e10cSrcweir 
344cdf0e10cSrcweir ::rtl::OUString SAL_CALL
345cdf0e10cSrcweir ScVbaWorkbook::getCodeName() throw (css::uno::RuntimeException)
346cdf0e10cSrcweir {
347cdf0e10cSrcweir     uno::Reference< beans::XPropertySet > xModelProp( getModel(), uno::UNO_QUERY_THROW );
348cdf0e10cSrcweir     return xModelProp->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CodeName" ) ) ).get< ::rtl::OUString >();
349cdf0e10cSrcweir }
350cdf0e10cSrcweir 
351cdf0e10cSrcweir namespace workbook
352cdf0e10cSrcweir {
353cdf0e10cSrcweir namespace sdecl = comphelper::service_decl;
354cdf0e10cSrcweir sdecl::vba_service_class_<ScVbaWorkbook, sdecl::with_args<true> > serviceImpl;
355cdf0e10cSrcweir extern sdecl::ServiceDecl const serviceDecl(
356cdf0e10cSrcweir     serviceImpl,
357cdf0e10cSrcweir     "ScVbaWorkbook",
358cdf0e10cSrcweir     "ooo.vba.excel.Workbook" );
359cdf0e10cSrcweir }
360