Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <vbahelper/helperdecl.hxx>
30 : : #include <cppuhelper/queryinterface.hxx>
31 : :
32 : : #include "vbaworksheet.hxx"
33 : : #include "vbanames.hxx"
34 : :
35 : : #include <com/sun/star/beans/XPropertySet.hpp>
36 : : #include <com/sun/star/beans/XIntrospectionAccess.hpp>
37 : : #include <com/sun/star/beans/XIntrospection.hpp>
38 : : #include <com/sun/star/container/XNamed.hpp>
39 : : #include <com/sun/star/util/XProtectable.hpp>
40 : : #include <com/sun/star/table/XCellRange.hpp>
41 : : #include <com/sun/star/sheet/XSpreadsheetView.hpp>
42 : : #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
43 : : #include <com/sun/star/sheet/XCalculatable.hpp>
44 : : #include <com/sun/star/sheet/XCellRangeAddressable.hpp>
45 : : #include <com/sun/star/sheet/XCellRangeReferrer.hpp>
46 : : #include <com/sun/star/sheet/XSheetCellRange.hpp>
47 : : #include <com/sun/star/sheet/XSheetCellCursor.hpp>
48 : : #include <com/sun/star/sheet/XSheetAnnotationsSupplier.hpp>
49 : : #include <com/sun/star/sheet/XUsedAreaCursor.hpp>
50 : : #include <com/sun/star/sheet/XSpreadsheets.hpp>
51 : : #include <com/sun/star/sheet/XSheetPastable.hpp>
52 : : #include <com/sun/star/sheet/XCellAddressable.hpp>
53 : : #include <com/sun/star/sheet/XSheetOutline.hpp>
54 : : #include <com/sun/star/sheet/XSheetPageBreak.hpp>
55 : : #include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp>
56 : : #include <com/sun/star/sheet/XNamedRanges.hpp>
57 : : #include <com/sun/star/util/XURLTransformer.hpp>
58 : : #include <com/sun/star/frame/XDispatchProvider.hpp>
59 : : #include <com/sun/star/frame/XComponentLoader.hpp>
60 : : #include <com/sun/star/table/XColumnRowRange.hpp>
61 : : #include <com/sun/star/table/XTableChartsSupplier.hpp>
62 : : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
63 : : #include <com/sun/star/drawing/XControlShape.hpp>
64 : : #include <com/sun/star/form/FormComponentType.hpp>
65 : : #include <com/sun/star/form/XFormsSupplier.hpp>
66 : : #include <ooo/vba/excel/XlEnableSelection.hpp>
67 : : #include <ooo/vba/excel/XlSheetVisibility.hpp>
68 : : #include <ooo/vba/excel/XWorkbook.hpp>
69 : : #include <ooo/vba/XControlProvider.hpp>
70 : :
71 : : #include <comphelper/processfactory.hxx>
72 : : #include <comphelper/servicehelper.hxx>
73 : : #include <vbahelper/vbashapes.hxx>
74 : :
75 : : #include <com/sun/star/script/vba/VBAEventId.hpp>
76 : : #include <com/sun/star/script/vba/XVBACompatibility.hpp>
77 : : #include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
78 : : #include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
79 : : #include <com/sun/star/script/ModuleInfo.hpp>
80 : : #include <com/sun/star/script/ModuleType.hpp>
81 : :
82 : : #include <tools/string.hxx>
83 : :
84 : : //zhangyun showdataform
85 : : #include <sfx2/sfxdlg.hxx>
86 : : #include "scabstdlg.hxx"
87 : : #include "tabvwsh.hxx"
88 : : #include "scitems.hxx"
89 : :
90 : : #include <svx/svdouno.hxx>
91 : : #include <svx/svdpage.hxx>
92 : :
93 : : #include "cellsuno.hxx"
94 : : #include "drwlayer.hxx"
95 : : #include "tabprotection.hxx"
96 : : #include "scextopt.hxx"
97 : : #include "vbaoutline.hxx"
98 : : #include "vbarange.hxx"
99 : : #include "vbacomments.hxx"
100 : : #include "vbachartobjects.hxx"
101 : : #include "vbapivottables.hxx"
102 : : #include "vbaoleobject.hxx"
103 : : #include "vbaoleobjects.hxx"
104 : : #include "vbapagesetup.hxx"
105 : : #include "vbapagebreaks.hxx"
106 : : #include "vbaworksheets.hxx"
107 : : #include "vbahyperlinks.hxx"
108 : : #include "vbasheetobjects.hxx"
109 : : #include "viewuno.hxx"
110 : : #include "markdata.hxx"
111 : : #include "dbdata.hxx"
112 : :
113 : : #include "attrib.hxx"
114 : :
115 : : #define STANDARDWIDTH 2267
116 : : #define STANDARDHEIGHT 427
117 : :
118 : : using namespace com::sun::star;
119 : : using namespace ooo::vba;
120 : :
121 : 0 : static void getNewSpreadsheetName (rtl::OUString &aNewName, rtl::OUString aOldName, uno::Reference <sheet::XSpreadsheetDocument>& xSpreadDoc )
122 : : {
123 [ # # ]: 0 : if (!xSpreadDoc.is())
124 [ # # ][ # # ]: 0 : throw lang::IllegalArgumentException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getNewSpreadsheetName() xSpreadDoc is null" ) ), uno::Reference< uno::XInterface >(), 1 );
125 [ # # ][ # # ]: 0 : static rtl::OUString aUnderScre( RTL_CONSTASCII_USTRINGPARAM( "_" ) );
[ # # ][ # # ]
126 : 0 : int currentNum =2;
127 [ # # ][ # # ]: 0 : aNewName = aOldName + aUnderScre+ String::CreateFromInt32(currentNum) ;
[ # # ]
128 : 0 : SCTAB nTab = 0;
129 [ # # ][ # # ]: 0 : while ( ScVbaWorksheets::nameExists(xSpreadDoc,aNewName, nTab ) )
130 : : {
131 : : aNewName = aOldName + aUnderScre +
132 [ # # ][ # # ]: 0 : String::CreateFromInt32(++currentNum) ;
[ # # ]
133 : : }
134 : 0 : }
135 : :
136 : 0 : static void removeAllSheets( uno::Reference <sheet::XSpreadsheetDocument>& xSpreadDoc, rtl::OUString aSheetName)
137 : : {
138 [ # # ]: 0 : if (!xSpreadDoc.is())
139 [ # # ][ # # ]: 0 : throw lang::IllegalArgumentException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "removeAllSheets() xSpreadDoc is null" ) ), uno::Reference< uno::XInterface >(), 1 );
140 [ # # ][ # # ]: 0 : uno::Reference<sheet::XSpreadsheets> xSheets = xSpreadDoc->getSheets();
141 [ # # ]: 0 : uno::Reference <container::XIndexAccess> xIndex( xSheets, uno::UNO_QUERY );
142 : :
143 [ # # ]: 0 : if ( xIndex.is() )
144 : : {
145 [ # # ]: 0 : uno::Reference<container::XNameContainer> xNameContainer(xSheets,uno::UNO_QUERY_THROW);
146 [ # # ][ # # ]: 0 : for (sal_Int32 i = xIndex->getCount() -1; i>= 1; i--)
[ # # ]
147 : : {
148 [ # # ][ # # ]: 0 : uno::Reference< sheet::XSpreadsheet > xSheet(xIndex->getByIndex(i), uno::UNO_QUERY);
[ # # ]
149 [ # # ]: 0 : uno::Reference< container::XNamed > xNamed( xSheet, uno::UNO_QUERY_THROW );
150 [ # # ]: 0 : if (xNamed.is())
151 : : {
152 [ # # ][ # # ]: 0 : xNameContainer->removeByName(xNamed->getName());
[ # # ][ # # ]
153 : : }
154 : 0 : }
155 : :
156 [ # # ][ # # ]: 0 : uno::Reference< sheet::XSpreadsheet > xSheet(xIndex->getByIndex(0), uno::UNO_QUERY);
[ # # ]
157 [ # # ]: 0 : uno::Reference< container::XNamed > xNamed( xSheet, uno::UNO_QUERY_THROW );
158 [ # # ]: 0 : if (xNamed.is())
159 : : {
160 [ # # ][ # # ]: 0 : xNamed->setName(aSheetName);
161 : 0 : }
162 : 0 : }
163 : 0 : }
164 : :
165 : : static uno::Reference<frame::XModel>
166 : 0 : openNewDoc(rtl::OUString aSheetName )
167 : : {
168 : 0 : uno::Reference<frame::XModel> xModel;
169 : : try
170 : : {
171 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
172 [ # # ][ # # ]: 0 : uno::Reference< uno::XComponentContext > xContext( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), uno::UNO_QUERY_THROW );
[ # # ][ # # ]
173 : : uno::Reference<lang::XMultiComponentFactory > xServiceManager(
174 [ # # ][ # # ]: 0 : xContext->getServiceManager(), uno::UNO_QUERY_THROW );
[ # # ]
175 : :
176 : : uno::Reference <frame::XComponentLoader > xComponentLoader(
177 [ # # ]: 0 : xServiceManager->createInstanceWithContext(
178 : : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) ),
179 [ # # ][ # # ]: 0 : xContext ), uno::UNO_QUERY_THROW );
[ # # ]
180 : :
181 [ # # ]: 0 : uno::Reference<lang::XComponent > xComponent( xComponentLoader->loadComponentFromURL(
182 : : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:factory/scalc" ) ),
183 : : rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_blank" ) ), 0,
184 [ # # ][ # # ]: 0 : uno::Sequence < ::com::sun::star::beans::PropertyValue >() ) );
[ # # ][ # # ]
[ # # ]
185 [ # # ]: 0 : uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( xComponent, uno::UNO_QUERY_THROW );
186 [ # # ]: 0 : if ( xSpreadDoc.is() )
187 : : {
188 [ # # ]: 0 : removeAllSheets(xSpreadDoc,aSheetName);
189 : : }
190 [ # # ][ # # ]: 0 : xModel.set(xSpreadDoc,uno::UNO_QUERY_THROW);
191 : : }
192 [ # # ]: 0 : catch ( uno::Exception & /*e*/ )
193 : : {
194 : : }
195 : 0 : return xModel;
196 : : }
197 : :
198 : 0 : ScVbaWorksheet::ScVbaWorksheet(const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext,
199 : : const uno::Reference< sheet::XSpreadsheet >& xSheet,
200 : 0 : const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) : WorksheetImpl_BASE( xParent, xContext ), mxSheet( xSheet ), mxModel(xModel)
201 : : {
202 : 0 : }
203 : :
204 : 12 : ScVbaWorksheet::ScVbaWorksheet( uno::Sequence< uno::Any> const & args,
205 [ + - ][ + - ]: 12 : uno::Reference< uno::XComponentContext> const & xContext ) throw ( lang::IllegalArgumentException ) : WorksheetImpl_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0 ), xContext ), mxModel( getXSomethingFromArgs< frame::XModel >( args, 1 ) ), mbVeryHidden( false )
206 : : {
207 [ - + ]: 12 : if ( args.getLength() < 3 )
208 [ # # ]: 0 : throw lang::IllegalArgumentException();
209 : :
210 : 12 : rtl::OUString sSheetName;
211 : 12 : args[2] >>= sSheetName;
212 : :
213 [ + - ]: 12 : uno::Reference< sheet::XSpreadsheetDocument > xSpreadDoc( mxModel, uno::UNO_QUERY_THROW );
214 [ + - ][ + - ]: 12 : uno::Reference< container::XNameAccess > xNameAccess( xSpreadDoc->getSheets(), uno::UNO_QUERY_THROW );
[ + - ]
215 [ + - ][ + - ]: 12 : mxSheet.set( xNameAccess->getByName( sSheetName ), uno::UNO_QUERY_THROW );
[ + - ]
216 : 12 : }
217 : :
218 : 0 : ScVbaWorksheet::~ScVbaWorksheet()
219 : : {
220 [ # # ]: 0 : }
221 : :
222 : : namespace
223 : : {
224 : : class theScVbaWorksheetUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theScVbaWorksheetUnoTunnelId > {};
225 : : }
226 : :
227 : 0 : const uno::Sequence<sal_Int8>& ScVbaWorksheet::getUnoTunnelId()
228 : : {
229 : 0 : return theScVbaWorksheetUnoTunnelId::get().getSeq();
230 : : }
231 : :
232 : : uno::Reference< ov::excel::XWorksheet >
233 : 0 : ScVbaWorksheet::createSheetCopyInNewDoc(rtl::OUString aCurrSheetName)
234 : : {
235 [ # # ][ # # ]: 0 : uno::Reference< sheet::XSheetCellCursor > xSheetCellCursor = getSheet()->createCursor( );
[ # # ]
236 [ # # ]: 0 : uno::Reference<sheet::XUsedAreaCursor> xUsedCursor(xSheetCellCursor,uno::UNO_QUERY_THROW);
237 [ # # ]: 0 : uno::Reference< table::XCellRange > xRange1( xSheetCellCursor, uno::UNO_QUERY);
238 [ # # ][ # # ]: 0 : uno::Reference<excel::XRange> xRange = new ScVbaRange( this, mxContext, xRange1);
[ # # ][ # # ]
239 [ # # ]: 0 : if (xRange.is())
240 [ # # ][ # # ]: 0 : xRange->Select();
241 [ # # ]: 0 : excel::implnCopy(mxModel);
242 [ # # ]: 0 : uno::Reference<frame::XModel> xModel = openNewDoc(aCurrSheetName);
243 [ # # ]: 0 : if (xModel.is())
244 : : {
245 [ # # ]: 0 : excel::implnPaste(xModel);
246 : : }
247 [ # # ]: 0 : uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( xModel, uno::UNO_QUERY_THROW );
248 [ # # ]: 0 : excel::setUpDocumentModules(xSpreadDoc);
249 [ # # ][ # # ]: 0 : uno::Reference <sheet::XSpreadsheets> xSheets( xSpreadDoc->getSheets(), uno::UNO_QUERY_THROW );
[ # # ]
250 [ # # ]: 0 : uno::Reference <container::XIndexAccess> xIndex( xSheets, uno::UNO_QUERY_THROW );
251 [ # # ][ # # ]: 0 : uno::Reference< sheet::XSpreadsheet > xSheet(xIndex->getByIndex(0), uno::UNO_QUERY_THROW);
[ # # ]
252 : :
253 [ # # ]: 0 : ScDocShell* pShell = excel::getDocShell( xModel );
254 : 0 : rtl::OUString aCodeName;
255 [ # # ]: 0 : pShell->GetDocument()->GetCodeName( 0, aCodeName );
256 [ # # ][ # # ]: 0 : return uno::Reference< excel::XWorksheet >( getUnoDocModule( aCodeName, pShell ), uno::UNO_QUERY_THROW );
[ # # ][ # # ]
257 : : }
258 : :
259 : : css::uno::Reference< ov::excel::XWorksheet >
260 : 0 : ScVbaWorksheet::createSheetCopy(uno::Reference<excel::XWorksheet> xSheet, bool bAfter)
261 : : {
262 [ # # ]: 0 : rtl::OUString aCurrSheetName = getName();
263 [ # # ]: 0 : ScVbaWorksheet* pDestSheet = excel::getImplFromDocModuleWrapper<ScVbaWorksheet>( xSheet );
264 : :
265 [ # # ][ # # ]: 0 : uno::Reference <sheet::XSpreadsheetDocument> xDestDoc( pDestSheet->getModel(), uno::UNO_QUERY );
266 [ # # ][ # # ]: 0 : uno::Reference <sheet::XSpreadsheetDocument> xSrcDoc( getModel(), uno::UNO_QUERY );
267 : :
268 : 0 : SCTAB nDest = 0;
269 : 0 : SCTAB nSrc = 0;
270 [ # # ][ # # ]: 0 : rtl::OUString aSheetName = xSheet->getName();
271 [ # # ][ # # ]: 0 : bool bSameDoc = ( pDestSheet->getModel() == getModel() );
[ # # ]
272 [ # # ]: 0 : bool bDestSheetExists = ScVbaWorksheets::nameExists (xDestDoc, aSheetName, nDest );
273 [ # # ]: 0 : bool bSheetExists = ScVbaWorksheets::nameExists (xSrcDoc, aCurrSheetName, nSrc );
274 : :
275 : : // set sheet name to be newSheet name
276 : 0 : aSheetName = aCurrSheetName;
277 [ # # ][ # # ]: 0 : if ( bSheetExists && bDestSheetExists )
278 : : {
279 : 0 : SCTAB nDummy=0;
280 [ # # ]: 0 : if(bAfter)
281 : 0 : nDest++;
282 [ # # ][ # # ]: 0 : uno::Reference<sheet::XSpreadsheets> xSheets = xDestDoc->getSheets();
283 [ # # ][ # # ]: 0 : if ( bSameDoc || ScVbaWorksheets::nameExists( xDestDoc, aCurrSheetName, nDummy ) )
[ # # ][ # # ]
284 [ # # ]: 0 : getNewSpreadsheetName(aSheetName,aCurrSheetName,xDestDoc);
285 [ # # ]: 0 : if ( bSameDoc )
286 [ # # ][ # # ]: 0 : xSheets->copyByName(aCurrSheetName,aSheetName,nDest);
287 : : else
288 : : {
289 [ # # ][ # # ]: 0 : ScDocShell* pDestDocShell = excel::getDocShell( pDestSheet->getModel() );
290 [ # # ][ # # ]: 0 : ScDocShell* pSrcDocShell = excel::getDocShell( getModel() );
291 [ # # ][ # # ]: 0 : if ( pDestDocShell && pSrcDocShell )
292 [ # # ]: 0 : pDestDocShell->TransferTab( *pSrcDocShell, static_cast<SCTAB>(nSrc), static_cast<SCTAB>(nDest), true, true );
293 : 0 : }
294 : : }
295 : : // return new sheet
296 [ # # ][ # # ]: 0 : uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
297 [ # # ][ # # ]: 0 : uno::Reference< excel::XWorksheet > xNewSheet( xApplication->Worksheets( uno::makeAny( aSheetName ) ), uno::UNO_QUERY_THROW );
[ # # ][ # # ]
298 : 0 : return xNewSheet;
299 : : }
300 : :
301 : : ::rtl::OUString
302 : 0 : ScVbaWorksheet::getName() throw (uno::RuntimeException)
303 : : {
304 [ # # ][ # # ]: 0 : uno::Reference< container::XNamed > xNamed( getSheet(), uno::UNO_QUERY_THROW );
305 [ # # ][ # # ]: 0 : return xNamed->getName();
306 : : }
307 : :
308 : : void
309 : 0 : ScVbaWorksheet::setName(const ::rtl::OUString &rName ) throw (uno::RuntimeException)
310 : : {
311 [ # # ][ # # ]: 0 : uno::Reference< container::XNamed > xNamed( getSheet(), uno::UNO_QUERY_THROW );
312 [ # # ][ # # ]: 0 : xNamed->setName( rName );
313 : 0 : }
314 : :
315 : : ::sal_Int32
316 : 0 : ScVbaWorksheet::getVisible() throw (uno::RuntimeException)
317 : : {
318 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySet > xProps( getSheet(), uno::UNO_QUERY_THROW );
319 [ # # ]: 0 : uno::Any aValue = xProps->getPropertyValue
320 [ # # ][ # # ]: 0 : (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsVisible" ) ) );
321 : 0 : sal_Bool bRet = false;
322 : 0 : aValue >>= bRet;
323 [ # # ]: 0 : if ( bRet )
324 : : {
325 : 0 : return excel::XlSheetVisibility::xlSheetVisible;
326 : : }
327 : : else
328 : : {
329 : 0 : return excel::XlSheetVisibility::xlSheetHidden;
330 : 0 : }
331 : : }
332 : :
333 : : void
334 : 0 : ScVbaWorksheet::setVisible( ::sal_Int32 nVisible ) throw (uno::RuntimeException)
335 : : {
336 : : using namespace ::ooo::vba::excel::XlSheetVisibility;
337 : 0 : bool bVisible = true;
338 [ # # # # ]: 0 : switch( nVisible )
339 : : {
340 : : case xlSheetVisible: case 1: // Excel accepts -1 and 1 for visible sheets
341 : 0 : bVisible = true;
342 : 0 : mbVeryHidden = false;
343 : 0 : break;
344 : : case xlSheetHidden:
345 : 0 : bVisible = false;
346 : 0 : mbVeryHidden = false;
347 : 0 : break;
348 : : case xlSheetVeryHidden:
349 : 0 : bVisible = false;
350 : 0 : mbVeryHidden = true;
351 : 0 : break;
352 : : default:
353 [ # # ]: 0 : throw uno::RuntimeException();
354 : : }
355 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySet > xProps( getSheet(), uno::UNO_QUERY_THROW );
356 [ # # ]: 0 : xProps->setPropertyValue
357 : : ( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsVisible" ) ),
358 [ # # ][ # # ]: 0 : uno::Any( bVisible ) );
[ # # ]
359 : 0 : }
360 : :
361 : : sal_Int16
362 : 6 : ScVbaWorksheet::getIndex() throw (uno::RuntimeException)
363 : : {
364 : 6 : return getSheetID() + 1;
365 : : }
366 : :
367 : : sal_Int32
368 : 0 : ScVbaWorksheet::getEnableSelection() throw (uno::RuntimeException)
369 : : {
370 [ # # ][ # # ]: 0 : uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( getModel(), uno::UNO_QUERY_THROW );
371 : 0 : SCTAB nTab = 0;
372 [ # # ][ # # ]: 0 : if ( ScVbaWorksheets::nameExists(xSpreadDoc, getName(), nTab) )
[ # # ]
373 : : {
374 [ # # ][ # # ]: 0 : uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
375 [ # # ]: 0 : ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument();
376 [ # # ]: 0 : ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
377 : 0 : sal_Bool bLockedCells = false;
378 : 0 : sal_Bool bUnlockedCells = false;
379 [ # # ]: 0 : if( pProtect )
380 : : {
381 [ # # ]: 0 : bLockedCells = pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
382 [ # # ]: 0 : bUnlockedCells = pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
383 : : }
384 [ # # ]: 0 : if( bLockedCells )
385 : 0 : return excel::XlEnableSelection::xlNoRestrictions;
386 [ # # ]: 0 : if( bUnlockedCells )
387 : 0 : return excel::XlEnableSelection::xlUnlockedCells;
388 : 0 : return excel::XlEnableSelection::xlNoSelection;
389 : : }
390 : : else
391 : : throw uno::RuntimeException(::rtl::OUString(
392 : : RTL_CONSTASCII_USTRINGPARAM( "Sheet Name does not exist. ") ),
393 [ # # ][ # # ]: 0 : uno::Reference< XInterface >() );
394 : : }
395 : :
396 : :
397 : : void
398 : 0 : ScVbaWorksheet::setEnableSelection( sal_Int32 nSelection ) throw (uno::RuntimeException)
399 : : {
400 [ # # ][ # # ]: 0 : if( (nSelection != excel::XlEnableSelection::xlNoRestrictions) &&
[ # # ]
401 : : (nSelection != excel::XlEnableSelection::xlUnlockedCells) &&
402 : : (nSelection != excel::XlEnableSelection::xlNoSelection) )
403 : : {
404 [ # # ]: 0 : DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
405 : : }
406 : :
407 [ # # ][ # # ]: 0 : uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( getModel(), uno::UNO_QUERY_THROW );
408 : 0 : SCTAB nTab = 0;
409 [ # # ][ # # ]: 0 : if ( ScVbaWorksheets::nameExists(xSpreadDoc, getName(), nTab) )
[ # # ]
410 : : {
411 [ # # ][ # # ]: 0 : uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
412 [ # # ]: 0 : ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument();
413 [ # # ]: 0 : ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
414 : : // default is xlNoSelection
415 : 0 : sal_Bool bLockedCells = false;
416 : 0 : sal_Bool bUnlockedCells = false;
417 [ # # ]: 0 : if( nSelection == excel::XlEnableSelection::xlNoRestrictions )
418 : : {
419 : 0 : bLockedCells = sal_True;
420 : 0 : bUnlockedCells = sal_True;
421 : : }
422 [ # # ]: 0 : else if( nSelection == excel::XlEnableSelection::xlUnlockedCells )
423 : : {
424 : 0 : bUnlockedCells = sal_True;
425 : : }
426 [ # # ]: 0 : if( pProtect )
427 : : {
428 [ # # ]: 0 : pProtect->setOption( ScTableProtection::SELECT_LOCKED_CELLS, bLockedCells );
429 [ # # ]: 0 : pProtect->setOption( ScTableProtection::SELECT_UNLOCKED_CELLS, bUnlockedCells );
430 : 0 : }
431 : : }
432 : : else
433 : : throw uno::RuntimeException(::rtl::OUString(
434 : : RTL_CONSTASCII_USTRINGPARAM( "Sheet Name does not exist. ") ),
435 [ # # ][ # # ]: 0 : uno::Reference< XInterface >() );
436 : :
437 : 0 : }
438 : :
439 : 0 : sal_Bool SAL_CALL ScVbaWorksheet::getAutoFilterMode() throw (uno::RuntimeException)
440 : : {
441 [ # # ][ # # ]: 0 : uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
442 [ # # ]: 0 : ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument();
443 [ # # ][ # # ]: 0 : ScDBData* pDBData = pDoc->GetAnonymousDBData(getSheetID());
444 [ # # ]: 0 : if (pDBData)
445 : 0 : return pDBData->HasAutoFilter();
446 : 0 : return false;
447 : : }
448 : :
449 : 0 : void SAL_CALL ScVbaWorksheet::setAutoFilterMode( sal_Bool bAutoFilterMode ) throw (uno::RuntimeException)
450 : : {
451 [ # # ][ # # ]: 0 : uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
452 [ # # ]: 0 : ScDocShell* pDocShell = excel::getDocShell( xModel );
453 : 0 : ScDocument* pDoc = pDocShell->GetDocument();
454 [ # # ][ # # ]: 0 : ScDBData* pDBData = pDoc->GetAnonymousDBData(getSheetID());
455 [ # # ]: 0 : if (pDBData)
456 : : {
457 : 0 : pDBData->SetAutoFilter(bAutoFilterMode);
458 : 0 : ScRange aRange;
459 [ # # ]: 0 : pDBData->GetArea(aRange);
460 [ # # ][ # # ]: 0 : if (bAutoFilterMode && pDoc)
461 : 0 : pDoc->ApplyFlagsTab( aRange.aStart.Col(), aRange.aStart.Row(),
462 : 0 : aRange.aEnd.Col(), aRange.aStart.Row(),
463 [ # # ]: 0 : aRange.aStart.Tab(), SC_MF_AUTO );
464 [ # # ][ # # ]: 0 : else if (!bAutoFilterMode && pDoc)
465 : 0 : pDoc->RemoveFlagsTab(aRange.aStart.Col(), aRange.aStart.Row(),
466 : 0 : aRange.aEnd.Col(), aRange.aStart.Row(),
467 [ # # ]: 0 : aRange.aStart.Tab(), SC_MF_AUTO );
468 : 0 : ScRange aPaintRange(aRange.aStart, aRange.aEnd);
469 : 0 : aPaintRange.aEnd.SetRow(aPaintRange.aStart.Row());
470 [ # # ][ # # ]: 0 : pDocShell->PostPaint(aPaintRange, PAINT_GRID);
[ # # ]
471 : 0 : }
472 : 0 : }
473 : :
474 : : uno::Reference< excel::XRange >
475 : 0 : ScVbaWorksheet::getUsedRange() throw (uno::RuntimeException)
476 : : {
477 [ # # ][ # # ]: 0 : uno::Reference< sheet::XSheetCellRange > xSheetCellRange(getSheet(), uno::UNO_QUERY_THROW );
478 [ # # ][ # # ]: 0 : uno::Reference< sheet::XSheetCellCursor > xSheetCellCursor( getSheet()->createCursorByRange( xSheetCellRange ), uno::UNO_QUERY_THROW );
[ # # ][ # # ]
479 [ # # ]: 0 : uno::Reference<sheet::XUsedAreaCursor> xUsedCursor(xSheetCellCursor,uno::UNO_QUERY_THROW);
480 [ # # ][ # # ]: 0 : xUsedCursor->gotoStartOfUsedArea( false );
481 [ # # ][ # # ]: 0 : xUsedCursor->gotoEndOfUsedArea( true );
482 [ # # ]: 0 : uno::Reference< table::XCellRange > xRange( xSheetCellCursor, uno::UNO_QUERY);
483 [ # # ][ # # ]: 0 : return new ScVbaRange(this, mxContext, xRange);
[ # # ][ # # ]
484 : : }
485 : :
486 : : uno::Reference< excel::XOutline >
487 : 0 : ScVbaWorksheet::Outline( ) throw (uno::RuntimeException)
488 : : {
489 [ # # ][ # # ]: 0 : uno::Reference<sheet::XSheetOutline> xOutline(getSheet(),uno::UNO_QUERY_THROW);
490 [ # # ][ # # ]: 0 : return new ScVbaOutline( this, mxContext, xOutline);
[ # # ][ # # ]
491 : : }
492 : :
493 : : uno::Reference< excel::XPageSetup >
494 : 0 : ScVbaWorksheet::PageSetup( ) throw (uno::RuntimeException)
495 : : {
496 [ # # ][ # # ]: 0 : return new ScVbaPageSetup( this, mxContext, getSheet(), getModel() );
[ # # ][ # # ]
[ # # ]
497 : : }
498 : :
499 : : uno::Any
500 : 0 : ScVbaWorksheet::HPageBreaks( const uno::Any& aIndex ) throw (uno::RuntimeException)
501 : : {
502 [ # # ][ # # ]: 0 : uno::Reference< sheet::XSheetPageBreak > xSheetPageBreak(getSheet(),uno::UNO_QUERY_THROW);
503 [ # # ][ # # ]: 0 : uno::Reference< excel::XHPageBreaks > xHPageBreaks( new ScVbaHPageBreaks( this, mxContext, xSheetPageBreak));
[ # # ][ # # ]
504 [ # # ]: 0 : if ( aIndex.hasValue() )
505 [ # # ][ # # ]: 0 : return xHPageBreaks->Item( aIndex, uno::Any());
506 [ # # ]: 0 : return uno::makeAny( xHPageBreaks );
507 : : }
508 : :
509 : : uno::Any
510 : 0 : ScVbaWorksheet::VPageBreaks( const uno::Any& aIndex ) throw ( uno::RuntimeException )
511 : : {
512 [ # # ][ # # ]: 0 : uno::Reference< sheet::XSheetPageBreak > xSheetPageBreak( getSheet(), uno::UNO_QUERY_THROW );
513 [ # # ][ # # ]: 0 : uno::Reference< excel::XVPageBreaks > xVPageBreaks( new ScVbaVPageBreaks( this, mxContext, xSheetPageBreak ) );
[ # # ][ # # ]
514 [ # # ]: 0 : if( aIndex.hasValue() )
515 [ # # ][ # # ]: 0 : return xVPageBreaks->Item( aIndex, uno::Any());
516 [ # # ]: 0 : return uno::makeAny( xVPageBreaks );
517 : : }
518 : :
519 : : sal_Int32
520 : 0 : ScVbaWorksheet::getStandardWidth() throw (uno::RuntimeException)
521 : : {
522 : 0 : return STANDARDWIDTH ;
523 : : }
524 : :
525 : : sal_Int32
526 : 0 : ScVbaWorksheet::getStandardHeight() throw (uno::RuntimeException)
527 : : {
528 : 0 : return STANDARDHEIGHT;
529 : : }
530 : :
531 : : sal_Bool
532 : 0 : ScVbaWorksheet::getProtectionMode() throw (uno::RuntimeException)
533 : : {
534 : 0 : return false;
535 : : }
536 : :
537 : : sal_Bool
538 : 0 : ScVbaWorksheet::getProtectContents()throw (uno::RuntimeException)
539 : : {
540 [ # # ][ # # ]: 0 : uno::Reference<util::XProtectable > xProtectable(getSheet(), uno::UNO_QUERY_THROW);
541 [ # # ][ # # ]: 0 : return xProtectable->isProtected();
542 : : }
543 : :
544 : : sal_Bool
545 : 0 : ScVbaWorksheet::getProtectDrawingObjects() throw (uno::RuntimeException)
546 : : {
547 : 0 : SCTAB nTab = 0;
548 [ # # ]: 0 : rtl::OUString aSheetName = getName();
549 [ # # ][ # # ]: 0 : uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( getModel(), uno::UNO_QUERY_THROW );
550 [ # # ]: 0 : bool bSheetExists = ScVbaWorksheets::nameExists (xSpreadDoc, aSheetName, nTab);
551 [ # # ]: 0 : if ( bSheetExists )
552 : : {
553 [ # # ][ # # ]: 0 : uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
554 [ # # ]: 0 : ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument();
555 [ # # ]: 0 : ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
556 [ # # ]: 0 : if ( pProtect )
557 [ # # ][ # # ]: 0 : return pProtect->isOptionEnabled( ScTableProtection::OBJECTS );
558 : : }
559 : 0 : return false;
560 : : }
561 : :
562 : : sal_Bool
563 : 0 : ScVbaWorksheet::getProtectScenarios() throw (uno::RuntimeException)
564 : : {
565 : 0 : return false;
566 : : }
567 : :
568 : : void
569 : 0 : ScVbaWorksheet::Activate() throw (uno::RuntimeException)
570 : : {
571 : : uno::Reference< sheet::XSpreadsheetView > xSpreadsheet(
572 [ # # ][ # # ]: 0 : getModel()->getCurrentController(), uno::UNO_QUERY_THROW );
[ # # ][ # # ]
573 [ # # ][ # # ]: 0 : xSpreadsheet->setActiveSheet(getSheet());
[ # # ]
574 : 0 : }
575 : :
576 : : // support expand (but not replace) the active sheet
577 : : void
578 : 0 : ScVbaWorksheet::Select(const css::uno::Any& aReplace) throw (uno::RuntimeException)
579 : : {
580 : 0 : sal_Bool bReplace = true;
581 [ # # ][ # # ]: 0 : if (aReplace.hasValue() && aReplace.getValueTypeClass() == uno::TypeClass_BOOLEAN)
[ # # ]
582 : : {
583 : 0 : aReplace >>= bReplace;
584 : : }
585 : :
586 : : uno::Reference< sheet::XSpreadsheetView > xSpreadsheet(
587 [ # # ][ # # ]: 0 : getModel()->getCurrentController(), uno::UNO_QUERY_THROW );
[ # # ][ # # ]
588 [ # # ][ # # ]: 0 : ScTabViewObj* pTabView = static_cast< ScTabViewObj* >( xSpreadsheet.get() );
589 : :
590 [ # # ]: 0 : if (bReplace)
591 : : {
592 [ # # ][ # # ]: 0 : pTabView->selectSheet(getSheet(), false);
593 : : }
594 : : else
595 : : {
596 [ # # ]: 0 : uno::Reference< sheet::XSpreadsheet > xOldActiveSheet = pTabView->getActiveSheet();
597 [ # # ][ # # ]: 0 : pTabView->selectSheet(getSheet(), true);
598 [ # # ]: 0 : pTabView->selectSheet(xOldActiveSheet, true);
599 : 0 : }
600 : 0 : }
601 : :
602 : : void
603 : 0 : ScVbaWorksheet::Move( const uno::Any& Before, const uno::Any& After ) throw (uno::RuntimeException)
604 : : {
605 : 0 : uno::Reference<excel::XWorksheet> xSheet;
606 [ # # ]: 0 : rtl::OUString aCurrSheetName = getName();
607 : :
608 [ # # ][ # # ]: 0 : if (!(Before >>= xSheet) && !(After >>=xSheet)&& !(Before.hasValue()) && !(After.hasValue()))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
609 : : {
610 [ # # ][ # # ]: 0 : uno::Reference< sheet::XSheetCellCursor > xSheetCellCursor = getSheet()->createCursor( );
[ # # ]
611 [ # # ]: 0 : uno::Reference<sheet::XUsedAreaCursor> xUsedCursor(xSheetCellCursor,uno::UNO_QUERY_THROW);
612 [ # # ]: 0 : uno::Reference< table::XCellRange > xRange1( xSheetCellCursor, uno::UNO_QUERY);
613 : : // #FIXME needs worksheet as parent
614 [ # # ][ # # ]: 0 : uno::Reference<excel::XRange> xRange = new ScVbaRange( this, mxContext, xRange1);
[ # # ][ # # ]
615 [ # # ]: 0 : if (xRange.is())
616 [ # # ][ # # ]: 0 : xRange->Select();
617 [ # # ]: 0 : excel::implnCopy(mxModel);
618 [ # # ]: 0 : uno::Reference<frame::XModel> xModel = openNewDoc(aCurrSheetName);
619 [ # # ]: 0 : if (xModel.is())
620 : : {
621 [ # # ]: 0 : excel::implnPaste(xModel);
622 [ # # ]: 0 : Delete();
623 : : }
624 : 0 : return ;
625 : : }
626 : :
627 [ # # ][ # # ]: 0 : uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( getModel(), uno::UNO_QUERY_THROW );
628 : 0 : SCTAB nDest = 0;
629 [ # # ][ # # ]: 0 : if ( ScVbaWorksheets::nameExists (xSpreadDoc, xSheet->getName(), nDest) )
[ # # ][ # # ]
630 : : {
631 : 0 : sal_Bool bAfter = After.hasValue();
632 [ # # ]: 0 : if (bAfter)
633 : 0 : nDest++;
634 [ # # ][ # # ]: 0 : uno::Reference<sheet::XSpreadsheets> xSheets = xSpreadDoc->getSheets();
635 [ # # ][ # # ]: 0 : xSheets->moveByName(aCurrSheetName,nDest);
636 [ # # ][ # # ]: 0 : }
637 : : }
638 : :
639 : : void
640 : 0 : ScVbaWorksheet::Copy( const uno::Any& Before, const uno::Any& After ) throw (uno::RuntimeException)
641 : : {
642 : 0 : uno::Reference<excel::XWorksheet> xSheet;
643 [ # # ][ # # ]: 0 : if (!(Before >>= xSheet) && !(After >>=xSheet)&& !(Before.hasValue()) && !(After.hasValue()))
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
644 : : {
645 [ # # ][ # # ]: 0 : createSheetCopyInNewDoc(getName());
646 : 0 : return;
647 : : }
648 : :
649 [ # # ]: 0 : uno::Reference<excel::XWorksheet> xNewSheet = createSheetCopy(xSheet, After.hasValue());
650 [ # # ][ # # ]: 0 : xNewSheet->Activate();
[ # # ]
651 : : }
652 : :
653 : :
654 : : void
655 : 0 : ScVbaWorksheet::Paste( const uno::Any& Destination, const uno::Any& /*Link*/ ) throw (uno::RuntimeException)
656 : : {
657 : : // #TODO# #FIXME# Link is not used
658 [ # # ]: 0 : uno::Reference<excel::XRange> xRange( Destination, uno::UNO_QUERY );
659 [ # # ]: 0 : if ( xRange.is() )
660 [ # # ][ # # ]: 0 : xRange->Select();
661 [ # # ]: 0 : excel::implnPaste( mxModel );
662 : 0 : }
663 : :
664 : : void
665 : 0 : ScVbaWorksheet::Delete() throw (uno::RuntimeException)
666 : : {
667 [ # # ][ # # ]: 0 : uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( getModel(), uno::UNO_QUERY_THROW );
668 [ # # ]: 0 : rtl::OUString aSheetName = getName();
669 [ # # ]: 0 : if ( xSpreadDoc.is() )
670 : : {
671 : 0 : SCTAB nTab = 0;
672 [ # # ][ # # ]: 0 : if (!ScVbaWorksheets::nameExists(xSpreadDoc, aSheetName, nTab ))
673 : : {
674 : 0 : return;
675 : : }
676 [ # # ][ # # ]: 0 : uno::Reference<sheet::XSpreadsheets> xSheets = xSpreadDoc->getSheets();
677 [ # # ]: 0 : uno::Reference<container::XNameContainer> xNameContainer(xSheets,uno::UNO_QUERY_THROW);
678 [ # # ][ # # ]: 0 : xNameContainer->removeByName(aSheetName);
679 : 0 : mxSheet.clear();
680 [ # # ][ # # ]: 0 : }
681 : : }
682 : :
683 : : uno::Reference< excel::XWorksheet >
684 : 0 : ScVbaWorksheet::getSheetAtOffset(SCTAB offset) throw (uno::RuntimeException)
685 : : {
686 [ # # ][ # # ]: 0 : uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( getModel(), uno::UNO_QUERY_THROW );
687 [ # # ][ # # ]: 0 : uno::Reference <sheet::XSpreadsheets> xSheets( xSpreadDoc->getSheets(), uno::UNO_QUERY_THROW );
[ # # ]
688 [ # # ]: 0 : uno::Reference <container::XIndexAccess> xIndex( xSheets, uno::UNO_QUERY_THROW );
689 : :
690 : 0 : SCTAB nIdx = 0;
691 [ # # ][ # # ]: 0 : if ( !ScVbaWorksheets::nameExists (xSpreadDoc, getName(), nIdx ) )
[ # # ]
692 : 0 : return uno::Reference< excel::XWorksheet >();
693 : 0 : nIdx = nIdx + offset;
694 [ # # ][ # # ]: 0 : uno::Reference< sheet::XSpreadsheet > xSheet(xIndex->getByIndex(nIdx), uno::UNO_QUERY_THROW);
[ # # ]
695 : : // parent will be the parent of 'this' worksheet
696 [ # # ][ # # ]: 0 : return new ScVbaWorksheet (getParent(), mxContext, xSheet, getModel());
[ # # ][ # # ]
[ # # ]
697 : : }
698 : :
699 : : uno::Reference< excel::XWorksheet >
700 : 0 : ScVbaWorksheet::getNext() throw (uno::RuntimeException)
701 : : {
702 : : // catch the exception for index out of bound
703 : : try{
704 [ # # ]: 0 : return getSheetAtOffset(static_cast<SCTAB>(1));
705 [ # # ]: 0 : }catch( lang::IndexOutOfBoundsException& /*e*/ )
706 : : {
707 [ # # ]: 0 : return NULL;
708 : : }
709 : : }
710 : :
711 : : uno::Reference< excel::XWorksheet >
712 : 0 : ScVbaWorksheet::getPrevious() throw (uno::RuntimeException)
713 : : {
714 : : // catch the exception for index out of bound
715 : : try{
716 [ # # ]: 0 : return getSheetAtOffset(-1);
717 [ # # ]: 0 : }catch( lang::IndexOutOfBoundsException& /*e*/ )
718 : : {
719 [ # # ]: 0 : return NULL;
720 : : }
721 : : }
722 : :
723 : :
724 : : void
725 : 0 : ScVbaWorksheet::Protect( const uno::Any& Password, const uno::Any& /*DrawingObjects*/, const uno::Any& /*Contents*/, const uno::Any& /*Scenarios*/, const uno::Any& /*UserInterfaceOnly*/ ) throw (uno::RuntimeException)
726 : : {
727 : : // #TODO# #FIXME# is there anything we can do witht the unused param
728 : : // can the implementation use anything else here
729 [ # # ][ # # ]: 0 : uno::Reference<util::XProtectable > xProtectable(getSheet(), uno::UNO_QUERY_THROW);
730 : 0 : ::rtl::OUString aPasswd;
731 : 0 : Password >>= aPasswd;
732 [ # # ][ # # ]: 0 : xProtectable->protect( aPasswd );
733 : 0 : }
734 : :
735 : : void
736 : 0 : ScVbaWorksheet::Unprotect( const uno::Any& Password ) throw (uno::RuntimeException)
737 : : {
738 [ # # ][ # # ]: 0 : uno::Reference<util::XProtectable > xProtectable(getSheet(), uno::UNO_QUERY_THROW);
739 : 0 : ::rtl::OUString aPasswd;
740 : 0 : Password >>= aPasswd;
741 [ # # ][ # # ]: 0 : xProtectable->unprotect( aPasswd );
742 : 0 : }
743 : :
744 : : void
745 : 0 : ScVbaWorksheet::Calculate() throw (uno::RuntimeException)
746 : : {
747 [ # # ][ # # ]: 0 : uno::Reference <sheet::XCalculatable> xReCalculate(getModel(), uno::UNO_QUERY_THROW);
748 [ # # ][ # # ]: 0 : xReCalculate->calculate();
749 : 0 : }
750 : :
751 : : uno::Reference< excel::XRange >
752 : 20 : ScVbaWorksheet::Range( const ::uno::Any& Cell1, const ::uno::Any& Cell2 ) throw (uno::RuntimeException)
753 : : {
754 : : uno::Reference< excel::XRange > xSheetRange( new ScVbaRange( this, mxContext
755 [ + - ][ + - ]: 20 : , uno::Reference< table::XCellRange >( getSheet(), uno::UNO_QUERY_THROW ) ) );
[ + - ][ + - ]
[ + - ][ + - ]
756 [ + - ][ + - ]: 20 : return xSheetRange->Range( Cell1, Cell2 );
757 : : }
758 : :
759 : : void
760 : 0 : ScVbaWorksheet::CheckSpelling( const uno::Any& /*CustomDictionary*/,const uno::Any& /*IgnoreUppercase*/,const uno::Any& /*AlwaysSuggest*/, const uno::Any& /*SpellingLang*/ ) throw (uno::RuntimeException)
761 : : {
762 : : // #TODO# #FIXME# unused params above, can we do anything with those
763 [ # # ]: 0 : rtl::OUString url = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:SpellDialog"));
764 [ # # ]: 0 : uno::Reference< frame::XModel > xModel( getModel() );
765 [ # # ]: 0 : dispatchRequests(xModel,url);
766 : 0 : }
767 : :
768 : : uno::Reference< excel::XRange >
769 : 12 : ScVbaWorksheet::getSheetRange() throw (uno::RuntimeException)
770 : : {
771 [ + - ][ + - ]: 12 : uno::Reference< table::XCellRange > xRange( getSheet(),uno::UNO_QUERY_THROW );
772 [ + - ][ + - ]: 12 : return uno::Reference< excel::XRange >( new ScVbaRange( this, mxContext, xRange ) );
[ + - ][ + - ]
773 : : }
774 : :
775 : : // These are hacks - we prolly (somehow) need to inherit
776 : : // the vbarange functionality here ...
777 : : uno::Reference< excel::XRange >
778 : 2 : ScVbaWorksheet::Cells( const ::uno::Any &nRow, const ::uno::Any &nCol )
779 : : throw (uno::RuntimeException)
780 : : {
781 : : // Performance optimization for often-called Cells method:
782 : : // Use a common helper method instead of creating a new ScVbaRange object
783 [ + - ][ + - ]: 2 : uno::Reference< table::XCellRange > xRange( getSheet(), uno::UNO_QUERY_THROW );
784 [ + - ][ + - ]: 2 : return ScVbaRange::CellsHelper( this, mxContext, xRange, nRow, nCol );
785 : : }
786 : :
787 : : uno::Reference< excel::XRange >
788 : 0 : ScVbaWorksheet::Rows(const uno::Any& aIndex ) throw (uno::RuntimeException)
789 : : {
790 [ # # ][ # # ]: 0 : return getSheetRange()->Rows( aIndex );
791 : : }
792 : :
793 : : uno::Reference< excel::XRange >
794 : 12 : ScVbaWorksheet::Columns( const uno::Any& aIndex ) throw (uno::RuntimeException)
795 : : {
796 [ + - ][ + - ]: 12 : return getSheetRange()->Columns( aIndex );
797 : : }
798 : :
799 : : uno::Any SAL_CALL
800 : 0 : ScVbaWorksheet::ChartObjects( const uno::Any& Index ) throw (uno::RuntimeException)
801 : : {
802 [ # # ]: 0 : if ( !mxCharts.is() )
803 : : {
804 [ # # ][ # # ]: 0 : uno::Reference< table::XTableChartsSupplier > xChartSupplier( getSheet(), uno::UNO_QUERY_THROW );
805 [ # # ][ # # ]: 0 : uno::Reference< table::XTableCharts > xTableCharts = xChartSupplier->getCharts();
806 : :
807 [ # # ][ # # ]: 0 : uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( getSheet(), uno::UNO_QUERY_THROW );
808 [ # # ][ # # ]: 0 : mxCharts = new ScVbaChartObjects( this, mxContext, xTableCharts, xDrawPageSupplier );
[ # # ][ # # ]
809 : : }
810 [ # # ]: 0 : if ( Index.hasValue() )
811 : : {
812 [ # # ]: 0 : uno::Reference< XCollection > xColl( mxCharts, uno::UNO_QUERY_THROW );
813 [ # # ][ # # ]: 0 : return xColl->Item( Index, uno::Any() );
814 : : }
815 : : else
816 : 0 : return uno::makeAny( mxCharts );
817 : :
818 : : }
819 : :
820 : : uno::Any SAL_CALL
821 : 0 : ScVbaWorksheet::PivotTables( const uno::Any& Index ) throw (uno::RuntimeException)
822 : : {
823 [ # # ]: 0 : uno::Reference< css::sheet::XSpreadsheet > xSheet = getSheet();
824 [ # # ]: 0 : uno::Reference< sheet::XDataPilotTablesSupplier > xTables(xSheet, uno::UNO_QUERY_THROW ) ;
825 [ # # ][ # # ]: 0 : uno::Reference< container::XIndexAccess > xIndexAccess( xTables->getDataPilotTables(), uno::UNO_QUERY_THROW );
[ # # ]
826 : :
827 [ # # ][ # # ]: 0 : uno::Reference< XCollection > xColl( new ScVbaPivotTables( this, mxContext, xIndexAccess ) );
[ # # ][ # # ]
828 [ # # ]: 0 : if ( Index.hasValue() )
829 [ # # ][ # # ]: 0 : return xColl->Item( Index, uno::Any() );
830 [ # # ]: 0 : return uno::makeAny( xColl );
831 : : }
832 : :
833 : : uno::Any SAL_CALL
834 : 0 : ScVbaWorksheet::Comments( const uno::Any& Index ) throw (uno::RuntimeException)
835 : : {
836 [ # # ]: 0 : uno::Reference< css::sheet::XSpreadsheet > xSheet = getSheet();
837 [ # # ]: 0 : uno::Reference< sheet::XSheetAnnotationsSupplier > xAnnosSupp( xSheet, uno::UNO_QUERY_THROW );
838 [ # # ][ # # ]: 0 : uno::Reference< sheet::XSheetAnnotations > xAnnos( xAnnosSupp->getAnnotations(), uno::UNO_QUERY_THROW );
[ # # ]
839 [ # # ]: 0 : uno::Reference< container::XIndexAccess > xIndexAccess( xAnnos, uno::UNO_QUERY_THROW );
840 [ # # ][ # # ]: 0 : uno::Reference< XCollection > xColl( new ScVbaComments( this, mxContext, mxModel, xIndexAccess ) );
[ # # ][ # # ]
841 [ # # ]: 0 : if ( Index.hasValue() )
842 [ # # ][ # # ]: 0 : return xColl->Item( Index, uno::Any() );
843 [ # # ]: 0 : return uno::makeAny( xColl );
844 : : }
845 : :
846 : : uno::Any SAL_CALL
847 : 0 : ScVbaWorksheet::Hyperlinks( const uno::Any& aIndex ) throw (uno::RuntimeException)
848 : : {
849 : : /* The worksheet always returns the same Hyperlinks object.
850 : : See vbahyperlinks.hxx for more details. */
851 [ # # ]: 0 : if( !mxHlinks.is() )
852 [ # # ][ # # ]: 0 : mxHlinks.set( new ScVbaHyperlinks( this, mxContext ) );
[ # # ]
853 [ # # ]: 0 : if( aIndex.hasValue() )
854 [ # # ][ # # ]: 0 : return uno::Reference< XCollection >( mxHlinks, uno::UNO_QUERY_THROW )->Item( aIndex, uno::Any() );
855 : 0 : return uno::Any( mxHlinks );
856 : : }
857 : :
858 : : uno::Any SAL_CALL
859 : 0 : ScVbaWorksheet::Names( const css::uno::Any& aIndex ) throw (uno::RuntimeException)
860 : : {
861 : : // fake sheet-local names by returning all global names
862 : : // #163498# initialize Names object with correct parent (this worksheet)
863 : : // TODO: real sheet-local names...
864 [ # # ]: 0 : uno::Reference< beans::XPropertySet > xProps( mxModel, uno::UNO_QUERY_THROW );
865 [ # # ][ # # ]: 0 : uno::Reference< sheet::XNamedRanges > xNamedRanges( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NamedRanges") ) ), uno::UNO_QUERY_THROW );
[ # # ][ # # ]
866 [ # # ][ # # ]: 0 : uno::Reference< XCollection > xNames( new ScVbaNames( this, mxContext, xNamedRanges, mxModel ) );
[ # # ][ # # ]
867 [ # # ]: 0 : if ( aIndex.hasValue() )
868 [ # # ][ # # ]: 0 : return uno::Any( xNames->Item( aIndex, uno::Any() ) );
869 [ # # ]: 0 : return uno::Any( xNames );
870 : : }
871 : :
872 : : uno::Any SAL_CALL
873 : 0 : ScVbaWorksheet::OLEObjects( const uno::Any& Index ) throw (uno::RuntimeException)
874 : : {
875 [ # # ][ # # ]: 0 : uno::Reference< sheet::XSpreadsheet > xSpreadsheet( getSheet(), uno::UNO_QUERY_THROW );
876 [ # # ]: 0 : uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( xSpreadsheet, uno::UNO_QUERY_THROW );
877 [ # # ][ # # ]: 0 : uno::Reference< drawing::XDrawPage > xDrawPage( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW );
[ # # ]
878 [ # # ]: 0 : uno::Reference< container::XIndexAccess > xIndexAccess( xDrawPage, uno::UNO_QUERY_THROW );
879 : :
880 [ # # ][ # # ]: 0 : uno::Reference< excel::XOLEObjects >xOleObjects( new ScVbaOLEObjects( this, mxContext, xIndexAccess ) );
[ # # ][ # # ]
881 [ # # ]: 0 : if( Index.hasValue() )
882 [ # # ][ # # ]: 0 : return xOleObjects->Item( Index, uno::Any() );
883 [ # # ]: 0 : return uno::Any( xOleObjects );
884 : : }
885 : :
886 : : uno::Any SAL_CALL
887 : 0 : ScVbaWorksheet::Shapes( const uno::Any& aIndex ) throw (uno::RuntimeException)
888 : : {
889 [ # # ][ # # ]: 0 : uno::Reference< sheet::XSpreadsheet > xSpreadsheet( getSheet(), uno::UNO_QUERY_THROW );
890 [ # # ]: 0 : uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( xSpreadsheet, uno::UNO_QUERY_THROW );
891 [ # # ][ # # ]: 0 : uno::Reference< drawing::XShapes > xShapes( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW );
[ # # ]
892 [ # # ]: 0 : uno::Reference< container::XIndexAccess > xIndexAccess( xShapes, uno::UNO_QUERY_THROW );
893 : :
894 [ # # ][ # # ]: 0 : uno::Reference< msforms::XShapes> xVbaShapes( new ScVbaShapes( this, mxContext, xIndexAccess, getModel() ) );
[ # # ][ # # ]
[ # # ]
895 [ # # ]: 0 : if ( aIndex.hasValue() )
896 [ # # ][ # # ]: 0 : return xVbaShapes->Item( aIndex, uno::Any() );
897 [ # # ]: 0 : return uno::makeAny( xVbaShapes );
898 : : }
899 : :
900 : : uno::Any SAL_CALL
901 : 0 : ScVbaWorksheet::Buttons( const uno::Any& rIndex ) throw (uno::RuntimeException)
902 : : {
903 [ # # ]: 0 : if( !mxButtons.is() )
904 [ # # ]: 0 : mxButtons.set( new ScVbaButtons( this, mxContext, mxModel, mxSheet ) );
905 : : else
906 : 0 : mxButtons->collectShapes();
907 [ # # ]: 0 : if( rIndex.hasValue() )
908 [ # # ]: 0 : return mxButtons->Item( rIndex, uno::Any() );
909 [ # # ][ # # ]: 0 : return uno::Any( uno::Reference< XCollection >( mxButtons.get() ) );
910 : : }
911 : :
912 : : uno::Any SAL_CALL
913 : 0 : ScVbaWorksheet::CheckBoxes( const uno::Any& /*rIndex*/ ) throw (uno::RuntimeException)
914 : : {
915 [ # # ]: 0 : throw uno::RuntimeException();
916 : : }
917 : :
918 : : uno::Any SAL_CALL
919 : 0 : ScVbaWorksheet::DropDowns( const uno::Any& /*rIndex*/ ) throw (uno::RuntimeException)
920 : : {
921 [ # # ]: 0 : throw uno::RuntimeException();
922 : : }
923 : :
924 : : uno::Any SAL_CALL
925 : 0 : ScVbaWorksheet::GroupBoxes( const uno::Any& /*rIndex*/ ) throw (uno::RuntimeException)
926 : : {
927 [ # # ]: 0 : throw uno::RuntimeException();
928 : : }
929 : :
930 : : uno::Any SAL_CALL
931 : 0 : ScVbaWorksheet::Labels( const uno::Any& /*rIndex*/ ) throw (uno::RuntimeException)
932 : : {
933 [ # # ]: 0 : throw uno::RuntimeException();
934 : : }
935 : :
936 : : uno::Any SAL_CALL
937 : 0 : ScVbaWorksheet::ListBoxes( const uno::Any& /*rIndex*/ ) throw (uno::RuntimeException)
938 : : {
939 [ # # ]: 0 : throw uno::RuntimeException();
940 : : }
941 : :
942 : : uno::Any SAL_CALL
943 : 0 : ScVbaWorksheet::OptionButtons( const uno::Any& /*rIndex*/ ) throw (uno::RuntimeException)
944 : : {
945 [ # # ]: 0 : throw uno::RuntimeException();
946 : : }
947 : :
948 : : uno::Any SAL_CALL
949 : 0 : ScVbaWorksheet::ScrollBars( const uno::Any& /*rIndex*/ ) throw (uno::RuntimeException)
950 : : {
951 [ # # ]: 0 : throw uno::RuntimeException();
952 : : }
953 : :
954 : : uno::Any SAL_CALL
955 : 0 : ScVbaWorksheet::Spinners( const uno::Any& /*rIndex*/ ) throw (uno::RuntimeException)
956 : : {
957 [ # # ]: 0 : throw uno::RuntimeException();
958 : : }
959 : :
960 : : void SAL_CALL
961 : 0 : ScVbaWorksheet::ShowDataForm( ) throw (uno::RuntimeException)
962 : : {
963 : : #ifdef VBA_OOBUILD_HACK
964 [ # # ][ # # ]: 0 : uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
965 [ # # ]: 0 : ScTabViewShell* pTabViewShell = excel::getBestViewShell( xModel );
966 : :
967 [ # # ]: 0 : ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
968 : : OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
969 : :
970 [ # # ][ # # ]: 0 : AbstractScDataFormDlg* pDlg = pFact->CreateScDataFormDlg( pTabViewShell->GetDialogParent(),RID_SCDLG_DATAFORM, pTabViewShell);
971 : : OSL_ENSURE(pDlg, "Dialog create fail!");
972 : :
973 [ # # ]: 0 : pDlg->Execute();
974 : : #else
975 : : throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
976 : : #endif
977 : 0 : }
978 : :
979 : : uno::Any SAL_CALL
980 : 0 : ScVbaWorksheet::Evaluate( const ::rtl::OUString& Name ) throw (uno::RuntimeException)
981 : : {
982 : : // #TODO Evaluate allows other things to be evaluated, e.g. functions
983 : : // I think ( like SIN(3) etc. ) need to investigate that
984 : : // named Ranges also? e.g. [MyRange] if so need a list of named ranges
985 : 0 : uno::Any aVoid;
986 [ # # ][ # # ]: 0 : return uno::Any( Range( uno::Any( Name ), aVoid ) );
[ # # ]
987 : : }
988 : :
989 : :
990 : : uno::Reference< beans::XIntrospectionAccess > SAL_CALL
991 : 0 : ScVbaWorksheet::getIntrospection( ) throw (uno::RuntimeException)
992 : : {
993 : 0 : return uno::Reference< beans::XIntrospectionAccess >();
994 : : }
995 : :
996 : : uno::Any SAL_CALL
997 : 0 : ScVbaWorksheet::invoke( const ::rtl::OUString& aFunctionName, const uno::Sequence< uno::Any >& /*aParams*/, uno::Sequence< ::sal_Int16 >& /*aOutParamIndex*/, uno::Sequence< uno::Any >& /*aOutParam*/ ) throw (lang::IllegalArgumentException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException)
998 : : {
999 : : OSL_TRACE("** ScVbaWorksheet::invoke( %s ), will barf",
1000 : : rtl::OUStringToOString( aFunctionName, RTL_TEXTENCODING_UTF8 ).getStr() );
1001 : :
1002 [ # # ]: 0 : throw uno::RuntimeException(); // unsupported operation
1003 : : }
1004 : :
1005 : : void SAL_CALL
1006 : 0 : ScVbaWorksheet::setValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException)
1007 : : {
1008 [ # # ][ # # ]: 0 : setDefaultPropByIntrospection( uno::makeAny( getValue( aPropertyName ) ), aValue );
1009 : 0 : }
1010 : : uno::Any SAL_CALL
1011 : 0 : ScVbaWorksheet::getValue( const ::rtl::OUString& aPropertyName ) throw (beans::UnknownPropertyException, uno::RuntimeException)
1012 : : {
1013 [ # # ][ # # ]: 0 : uno::Reference< drawing::XControlShape > xControlShape( getControlShape( aPropertyName ), uno::UNO_QUERY_THROW );
1014 : :
1015 [ # # ][ # # ]: 0 : uno::Reference<lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
[ # # ]
1016 [ # # ][ # # ]: 0 : uno::Reference< XControlProvider > xControlProvider( xServiceManager->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.ControlProvider" ) ), mxContext ), uno::UNO_QUERY_THROW );
[ # # ][ # # ]
1017 [ # # ][ # # ]: 0 : uno::Reference< msforms::XControl > xControl( xControlProvider->createControl( xControlShape, getModel() ) );
[ # # ]
1018 [ # # ]: 0 : return uno::makeAny( xControl );
1019 : : }
1020 : :
1021 : : ::sal_Bool SAL_CALL
1022 : 0 : ScVbaWorksheet::hasMethod( const ::rtl::OUString& /*aName*/ ) throw (uno::RuntimeException)
1023 : : {
1024 : 0 : return false;
1025 : : }
1026 : :
1027 : : uno::Reference< container::XNameAccess >
1028 : 0 : ScVbaWorksheet::getFormControls()
1029 : : {
1030 : 0 : uno::Reference< container::XNameAccess > xFormControls;
1031 : : try
1032 : : {
1033 [ # # ][ # # ]: 0 : uno::Reference< sheet::XSpreadsheet > xSpreadsheet( getSheet(), uno::UNO_QUERY_THROW );
1034 [ # # ]: 0 : uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( xSpreadsheet, uno::UNO_QUERY_THROW );
1035 [ # # ][ # # ]: 0 : uno::Reference< form::XFormsSupplier > xFormSupplier( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW );
[ # # ]
1036 [ # # ][ # # ]: 0 : uno::Reference< container::XIndexAccess > xIndexAccess( xFormSupplier->getForms(), uno::UNO_QUERY_THROW );
[ # # ]
1037 : : // get the www-standard container ( maybe we should access the
1038 : : // 'www-standard' by name rather than index, this seems an
1039 : : // implementation detail
1040 [ # # ][ # # ]: 0 : xFormControls.set( xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW );
[ # # ][ # # ]
1041 : :
1042 : : }
1043 [ # # ]: 0 : catch( uno::Exception& )
1044 : : {
1045 : : }
1046 : 0 : return xFormControls;
1047 : :
1048 : : }
1049 : : ::sal_Bool SAL_CALL
1050 : 0 : ScVbaWorksheet::hasProperty( const ::rtl::OUString& aName ) throw (uno::RuntimeException)
1051 : : {
1052 [ # # ]: 0 : uno::Reference< container::XNameAccess > xFormControls( getFormControls() );
1053 [ # # ]: 0 : if ( xFormControls.is() )
1054 [ # # ][ # # ]: 0 : return xFormControls->hasByName( aName );
1055 : 0 : return false;
1056 : : }
1057 : :
1058 : : uno::Any
1059 : 0 : ScVbaWorksheet::getControlShape( const ::rtl::OUString& sName )
1060 : : {
1061 : : // ideally we would get an XControl object but it appears an XControl
1062 : : // implementation only exists for a Control implementation optained from the
1063 : : // view ( e.g. in basic you would get this from
1064 : : // thiscomponent.currentcontroller.getControl( controlModel ) )
1065 : : // and the thing to realise is that it is only possible to get an XControl
1066 : : // for a currently displayed control :-( often we would want to modify
1067 : : // a control not on the active sheet. But.. you can always access the
1068 : : // XControlShape from the DrawPage whether that is the active drawpage or not
1069 : :
1070 [ # # ][ # # ]: 0 : uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( getSheet(), uno::UNO_QUERY_THROW );
1071 [ # # ][ # # ]: 0 : uno::Reference< container::XIndexAccess > xIndexAccess( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW );
[ # # ]
1072 : :
1073 [ # # ][ # # ]: 0 : sal_Int32 nCount = xIndexAccess->getCount();
1074 [ # # ]: 0 : for( int index = 0; index < nCount; index++ )
1075 : : {
1076 [ # # ][ # # ]: 0 : uno::Any aUnoObj = xIndexAccess->getByIndex( index );
1077 : : // It seems there are some drawing objects that can not query into Control shapes?
1078 [ # # ]: 0 : uno::Reference< drawing::XControlShape > xControlShape( aUnoObj, uno::UNO_QUERY );
1079 [ # # ]: 0 : if( xControlShape.is() )
1080 : : {
1081 [ # # ][ # # ]: 0 : uno::Reference< container::XNamed > xNamed( xControlShape->getControl(), uno::UNO_QUERY_THROW );
[ # # ]
1082 [ # # ][ # # ]: 0 : if( sName.equals( xNamed->getName() ))
[ # # ]
1083 : : {
1084 : 0 : return aUnoObj;
1085 [ # # ]: 0 : }
1086 : : }
1087 [ # # ][ # # ]: 0 : }
1088 : 0 : return uno::Any();
1089 : : }
1090 : :
1091 : :
1092 : : rtl::OUString
1093 : 0 : ScVbaWorksheet::getServiceImplName()
1094 : : {
1095 : 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScVbaWorksheet"));
1096 : : }
1097 : :
1098 : : void SAL_CALL
1099 : 0 : ScVbaWorksheet::setEnableCalculation( ::sal_Bool bEnableCalculation ) throw ( script::BasicErrorException, uno::RuntimeException)
1100 : : {
1101 [ # # ][ # # ]: 0 : uno::Reference <sheet::XCalculatable> xCalculatable(getModel(), uno::UNO_QUERY_THROW);
1102 [ # # ][ # # ]: 0 : xCalculatable->enableAutomaticCalculation( bEnableCalculation);
1103 : 0 : }
1104 : : ::sal_Bool SAL_CALL
1105 : 0 : ScVbaWorksheet::getEnableCalculation( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
1106 : : {
1107 [ # # ][ # # ]: 0 : uno::Reference <sheet::XCalculatable> xCalculatable(getModel(), uno::UNO_QUERY_THROW);
1108 [ # # ][ # # ]: 0 : return xCalculatable->isAutomaticCalculationEnabled();
1109 : : }
1110 : :
1111 : : uno::Sequence< rtl::OUString >
1112 : 0 : ScVbaWorksheet::getServiceNames()
1113 : : {
1114 [ # # ][ # # ]: 0 : static uno::Sequence< rtl::OUString > aServiceNames;
[ # # ][ # # ]
1115 [ # # ]: 0 : if ( aServiceNames.getLength() == 0 )
1116 : : {
1117 : 0 : aServiceNames.realloc( 1 );
1118 [ # # ]: 0 : aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Worksheet" ) );
1119 : : }
1120 : 0 : return aServiceNames;
1121 : : }
1122 : :
1123 : : rtl::OUString SAL_CALL
1124 : 0 : ScVbaWorksheet::getCodeName() throw (css::uno::RuntimeException)
1125 : : {
1126 [ # # ]: 0 : uno::Reference< beans::XPropertySet > xSheetProp( mxSheet, uno::UNO_QUERY_THROW );
1127 [ # # ][ # # ]: 0 : return xSheetProp->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CodeName" ) ) ).get< ::rtl::OUString >();
[ # # ][ # # ]
1128 : : }
1129 : :
1130 : : sal_Int16
1131 : 6 : ScVbaWorksheet::getSheetID() throw (uno::RuntimeException)
1132 : : {
1133 [ + - ][ + - ]: 6 : uno::Reference< sheet::XCellRangeAddressable > xAddressable( getSheet(), uno::UNO_QUERY_THROW ); // if ActiveSheet, mxSheet is null.
1134 [ + - ][ + - ]: 6 : return xAddressable->getRangeAddress().Sheet;
1135 : : }
1136 : :
1137 : : void SAL_CALL
1138 : 0 : ScVbaWorksheet::PrintOut( const uno::Any& From, const uno::Any& To, const uno::Any& Copies, const uno::Any& Preview, const uno::Any& ActivePrinter, const uno::Any& PrintToFile, const uno::Any& Collate, const uno::Any& PrToFileName, const uno::Any& IgnorePrintAreas ) throw (uno::RuntimeException)
1139 : : {
1140 : 0 : sal_Int32 nTo = 0;
1141 : 0 : sal_Int32 nFrom = 0;
1142 : 0 : sal_Int16 nCopies = 1;
1143 : 0 : sal_Bool bCollate = false;
1144 : 0 : sal_Bool bSelection = false;
1145 : 0 : sal_Bool bIgnorePrintAreas = false;
1146 : 0 : From >>= nFrom;
1147 : 0 : To >>= nTo;
1148 : 0 : Copies >>= nCopies;
1149 : 0 : IgnorePrintAreas >>= bIgnorePrintAreas;
1150 [ # # ]: 0 : if ( nCopies > 1 ) // Collate only useful when more that 1 copy
1151 : 0 : Collate >>= bCollate;
1152 : :
1153 [ # # ][ # # ]: 0 : if ( !( nFrom || nTo ) )
1154 : 0 : bSelection = sal_True;
1155 : :
1156 [ # # ][ # # ]: 0 : uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
1157 [ # # ][ # # ]: 0 : PrintOutHelper( excel::getBestViewShell( xModel ), From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, bSelection );
1158 : 0 : }
1159 : :
1160 : : sal_Int64 SAL_CALL
1161 : 0 : ScVbaWorksheet::getSomething(const uno::Sequence<sal_Int8 > & rId) throw(uno::RuntimeException)
1162 : : {
1163 [ # # # # ]: 0 : if (rId.getLength() == 16 &&
[ # # ]
1164 : 0 : 0 == memcmp( ScVbaWorksheet::getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ))
1165 : : {
1166 : 0 : return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
1167 : : }
1168 : 0 : return 0;
1169 : : }
1170 : :
1171 : : namespace worksheet
1172 : : {
1173 : : namespace sdecl = comphelper::service_decl;
1174 : 3 : sdecl::vba_service_class_<ScVbaWorksheet, sdecl::with_args<true> > serviceImpl;
1175 : 3 : extern sdecl::ServiceDecl const serviceDecl(
1176 : : serviceImpl,
1177 : : "ScVbaWorksheet",
1178 : : "ooo.vba.excel.Worksheet" );
1179 [ + - ][ + - ]: 9 : }
1180 : :
1181 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|