Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "vbasheetobjects.hxx"
21 : #include <vector>
22 : #include <rtl/math.hxx>
23 : #include <com/sun/star/beans/XPropertySet.hpp>
24 : #include <com/sun/star/container/XIndexContainer.hpp>
25 : #include <com/sun/star/container/XNamed.hpp>
26 : #include <com/sun/star/drawing/XControlShape.hpp>
27 : #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
28 : #include <com/sun/star/drawing/XShapes.hpp>
29 : #include <com/sun/star/form/FormComponentType.hpp>
30 : #include <com/sun/star/form/XForm.hpp>
31 : #include <com/sun/star/form/XFormComponent.hpp>
32 : #include <com/sun/star/form/XFormsSupplier.hpp>
33 : #include "vbasheetobject.hxx"
34 :
35 : using namespace ::com::sun::star;
36 : using namespace ::ooo::vba;
37 :
38 : // ============================================================================
39 :
40 : namespace {
41 :
42 : template< typename Type >
43 0 : inline bool lclGetProperty( Type& orValue, const uno::Reference< beans::XPropertySet >& rxPropSet, const OUString& rPropName )
44 : {
45 : try
46 : {
47 0 : return rxPropSet->getPropertyValue( rPropName ) >>= orValue;
48 : }
49 0 : catch( uno::Exception& )
50 : {
51 : }
52 0 : return false;
53 : }
54 :
55 : /** Rounds the passed value to a multiple of 0.75 and converts it to 1/100 mm. */
56 0 : inline double lclPointsToHmm( const uno::Any& rPoints ) throw (uno::RuntimeException)
57 : {
58 0 : return PointsToHmm( ::rtl::math::approxFloor( rPoints.get< double >() / 0.75 ) * 0.75 );
59 : }
60 :
61 : } // namespace
62 :
63 : // ============================================================================
64 : // Base implementations
65 : // ============================================================================
66 :
67 : /** Container for a specific type of drawing object in a spreadsheet.
68 :
69 : Derived classes provide all required functionality specific to the type of
70 : shapes covered by the container.
71 : */
72 0 : class ScVbaObjectContainer : public ::cppu::WeakImplHelper1< container::XIndexAccess >
73 : {
74 : public:
75 : explicit ScVbaObjectContainer(
76 : const uno::Reference< XHelperInterface >& rxParent,
77 : const uno::Reference< uno::XComponentContext >& rxContext,
78 : const uno::Reference< frame::XModel >& rxModel,
79 : const uno::Reference< sheet::XSpreadsheet >& rxSheet,
80 : const uno::Type& rVbaType ) throw (uno::RuntimeException);
81 :
82 : /** Returns the VBA helper interface of the VBA collection object. */
83 0 : inline const uno::Reference< XHelperInterface >& getParent() const { return mxParent; }
84 : /** Returns the component context of the VBA collection object. */
85 0 : inline const uno::Reference< uno::XComponentContext >& getContext() const { return mxContext; }
86 : /** Returns the VBA type information of the objects in this container. */
87 0 : inline const uno::Type& getVbaType() const { return maVbaType; }
88 :
89 : /** Collects all shapes supported by this instance and inserts them into
90 : the internal shape vector. */
91 : void collectShapes() throw (uno::RuntimeException);
92 : /** Creates and returns a new UNO shape. */
93 : uno::Reference< drawing::XShape > createShape( const awt::Point& rPos, const awt::Size& rSize ) throw (uno::RuntimeException);
94 : /** Inserts the passed shape into the draw page and into this container, and returns its index in the draw page. */
95 : sal_Int32 insertShape( const uno::Reference< drawing::XShape >& rxShape ) throw (uno::RuntimeException);
96 : /** Creates and returns a new VBA implementation object for the passed shape. */
97 : ::rtl::Reference< ScVbaSheetObjectBase > createVbaObject( const uno::Reference< drawing::XShape >& rxShape ) throw (uno::RuntimeException);
98 : /** Creates and returns a new VBA implementation object for the passed shape in an Any. */
99 : uno::Any createCollectionObject( const uno::Any& rSource ) throw (uno::RuntimeException);
100 : /** Returns the VBA implementation object with the specified name. */
101 : uno::Any getItemByStringIndex( const OUString& rIndex ) throw (uno::RuntimeException);
102 :
103 : // XIndexAccess
104 : virtual sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException);
105 : virtual uno::Any SAL_CALL getByIndex( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException);
106 :
107 : // XElementAccess
108 : virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException);
109 : virtual sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException);
110 :
111 : protected:
112 : /** Derived classes return true, if the passed shape is supported by the instance. */
113 : virtual bool implPickShape( const uno::Reference< drawing::XShape >& rxShape ) const = 0;
114 : /** Derived classes create and return a new VBA implementation object for the passed shape. */
115 : virtual ScVbaSheetObjectBase* implCreateVbaObject( const uno::Reference< drawing::XShape >& rxShape ) throw (uno::RuntimeException) = 0;
116 : /** Derived classes return the service name of the UNO shape. */
117 : virtual OUString implGetShapeServiceName() const = 0;
118 :
119 : /** Returns the shape name via 'Name' property of the UNO shape. May be overwritten. */
120 : virtual OUString implGetShapeName( const uno::Reference< drawing::XShape >& rxShape ) const throw (uno::RuntimeException);
121 : /** Is called when a new UNO shape has been created but not yet inserted into the drawing page. */
122 : virtual void implOnShapeCreated( const uno::Reference< drawing::XShape >& rxShape ) throw (uno::RuntimeException);
123 :
124 : protected:
125 : uno::Reference< XHelperInterface > mxParent;
126 : uno::Reference< uno::XComponentContext > mxContext;
127 : uno::Reference< frame::XModel > mxModel;
128 : uno::Reference< lang::XMultiServiceFactory > mxFactory;
129 : uno::Reference< drawing::XShapes > mxShapes;
130 :
131 : private:
132 : typedef ::std::vector< uno::Reference< drawing::XShape > > ShapeVector;
133 : const uno::Type maVbaType;
134 : ShapeVector maShapes;
135 : };
136 :
137 : // ----------------------------------------------------------------------------
138 :
139 0 : ScVbaObjectContainer::ScVbaObjectContainer(
140 : const uno::Reference< XHelperInterface >& rxParent,
141 : const uno::Reference< uno::XComponentContext >& rxContext,
142 : const uno::Reference< frame::XModel >& rxModel,
143 : const uno::Reference< sheet::XSpreadsheet >& rxSheet,
144 : const uno::Type& rVbaType ) throw (uno::RuntimeException) :
145 : mxParent( rxParent ),
146 : mxContext( rxContext ),
147 : mxModel( rxModel, uno::UNO_SET_THROW ),
148 : mxFactory( rxModel, uno::UNO_QUERY_THROW ),
149 0 : maVbaType( rVbaType )
150 : {
151 0 : uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupp( rxSheet, uno::UNO_QUERY_THROW );
152 0 : mxShapes.set( xDrawPageSupp->getDrawPage(), uno::UNO_QUERY_THROW );
153 0 : }
154 :
155 0 : void ScVbaObjectContainer::collectShapes() throw (uno::RuntimeException)
156 : {
157 0 : maShapes.clear();
158 0 : for( sal_Int32 nIndex = 0, nCount = mxShapes->getCount(); nIndex < nCount; ++nIndex )
159 : {
160 0 : uno::Reference< drawing::XShape > xShape( mxShapes->getByIndex( nIndex ), uno::UNO_QUERY_THROW );
161 0 : if( implPickShape( xShape ) )
162 0 : maShapes.push_back( xShape );
163 0 : }
164 0 : }
165 :
166 0 : uno::Reference< drawing::XShape > ScVbaObjectContainer::createShape( const awt::Point& rPos, const awt::Size& rSize ) throw (uno::RuntimeException)
167 : {
168 0 : uno::Reference< drawing::XShape > xShape( mxFactory->createInstance( implGetShapeServiceName() ), uno::UNO_QUERY_THROW );
169 0 : xShape->setPosition( rPos );
170 0 : xShape->setSize( rSize );
171 0 : implOnShapeCreated( xShape );
172 0 : return xShape;
173 : }
174 :
175 0 : sal_Int32 ScVbaObjectContainer::insertShape( const uno::Reference< drawing::XShape >& rxShape ) throw (uno::RuntimeException)
176 : {
177 0 : mxShapes->add( rxShape );
178 0 : maShapes.push_back( rxShape );
179 0 : return mxShapes->getCount() - 1;
180 : }
181 :
182 0 : ::rtl::Reference< ScVbaSheetObjectBase > ScVbaObjectContainer::createVbaObject(
183 : const uno::Reference< drawing::XShape >& rxShape ) throw (uno::RuntimeException)
184 : {
185 0 : return implCreateVbaObject( rxShape );
186 : }
187 :
188 0 : uno::Any ScVbaObjectContainer::createCollectionObject( const uno::Any& rSource ) throw (uno::RuntimeException)
189 : {
190 0 : uno::Reference< drawing::XShape > xShape( rSource, uno::UNO_QUERY_THROW );
191 0 : uno::Reference< excel::XSheetObject > xSheetObject( implCreateVbaObject( xShape ) );
192 0 : return uno::Any( xSheetObject );
193 : }
194 :
195 0 : uno::Any ScVbaObjectContainer::getItemByStringIndex( const OUString& rIndex ) throw (uno::RuntimeException)
196 : {
197 0 : for( ShapeVector::iterator aIt = maShapes.begin(), aEnd = maShapes.end(); aIt != aEnd; ++aIt )
198 0 : if( rIndex == implGetShapeName( *aIt ) )
199 0 : return createCollectionObject( uno::Any( *aIt ) );
200 0 : throw uno::RuntimeException();
201 : }
202 :
203 : // XIndexAccess
204 :
205 0 : sal_Int32 SAL_CALL ScVbaObjectContainer::getCount() throw (uno::RuntimeException)
206 : {
207 0 : return static_cast< sal_Int32 >( maShapes.size() );
208 : }
209 :
210 0 : uno::Any SAL_CALL ScVbaObjectContainer::getByIndex( sal_Int32 nIndex )
211 : throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
212 : {
213 0 : if( (0 <= nIndex) && (nIndex < getCount()) )
214 0 : return uno::Any( maShapes[ static_cast< size_t >( nIndex ) ] );
215 0 : throw lang::IndexOutOfBoundsException();
216 : }
217 :
218 : // XElementAccess
219 :
220 0 : uno::Type SAL_CALL ScVbaObjectContainer::getElementType() throw (uno::RuntimeException)
221 : {
222 0 : return drawing::XShape::static_type( 0 );
223 : }
224 :
225 0 : sal_Bool SAL_CALL ScVbaObjectContainer::hasElements() throw (uno::RuntimeException)
226 : {
227 0 : return !maShapes.empty();
228 : }
229 :
230 : // private
231 :
232 0 : OUString ScVbaObjectContainer::implGetShapeName( const uno::Reference< drawing::XShape >& rxShape ) const throw (uno::RuntimeException)
233 : {
234 0 : uno::Reference< beans::XPropertySet > xPropSet( rxShape, uno::UNO_QUERY_THROW );
235 0 : return xPropSet->getPropertyValue( "Name" ).get< OUString >();
236 : }
237 :
238 0 : void ScVbaObjectContainer::implOnShapeCreated( const uno::Reference< drawing::XShape >& /*rxShape*/ ) throw (uno::RuntimeException)
239 : {
240 0 : }
241 :
242 : // ============================================================================
243 :
244 0 : class ScVbaObjectEnumeration : public SimpleEnumerationBase
245 : {
246 : public:
247 : explicit ScVbaObjectEnumeration( const ScVbaObjectContainerRef& rxContainer );
248 : virtual uno::Any createCollectionObject( const uno::Any& rSource );
249 :
250 : private:
251 : ScVbaObjectContainerRef mxContainer;
252 : };
253 :
254 : // ----------------------------------------------------------------------------
255 :
256 0 : ScVbaObjectEnumeration::ScVbaObjectEnumeration( const ScVbaObjectContainerRef& rxContainer ) :
257 0 : SimpleEnumerationBase( rxContainer->getParent(), rxContainer->getContext(), rxContainer.get() ),
258 0 : mxContainer( rxContainer )
259 : {
260 0 : }
261 :
262 0 : uno::Any ScVbaObjectEnumeration::createCollectionObject( const uno::Any& rSource )
263 : {
264 0 : return mxContainer->createCollectionObject( rSource );
265 : }
266 :
267 : // ============================================================================
268 :
269 0 : ScVbaSheetObjectsBase::ScVbaSheetObjectsBase( const ScVbaObjectContainerRef& rxContainer ) throw (css::uno::RuntimeException) :
270 0 : ScVbaSheetObjects_BASE( rxContainer->getParent(), rxContainer->getContext(), rxContainer.get() ),
271 0 : mxContainer( rxContainer )
272 : {
273 0 : mxContainer->collectShapes();
274 0 : }
275 :
276 0 : ScVbaSheetObjectsBase::~ScVbaSheetObjectsBase()
277 : {
278 0 : }
279 :
280 0 : void ScVbaSheetObjectsBase::collectShapes() throw (uno::RuntimeException)
281 : {
282 0 : mxContainer->collectShapes();
283 0 : }
284 :
285 : // XEnumerationAccess
286 :
287 0 : uno::Reference< container::XEnumeration > SAL_CALL ScVbaSheetObjectsBase::createEnumeration() throw (uno::RuntimeException)
288 : {
289 0 : return new ScVbaObjectEnumeration( mxContainer );
290 : }
291 :
292 : // XElementAccess
293 :
294 0 : uno::Type SAL_CALL ScVbaSheetObjectsBase::getElementType() throw (uno::RuntimeException)
295 : {
296 0 : return mxContainer->getVbaType();
297 : }
298 :
299 : // ScVbaCollectionBase
300 :
301 0 : uno::Any ScVbaSheetObjectsBase::createCollectionObject( const uno::Any& rSource )
302 : {
303 0 : return mxContainer->createCollectionObject( rSource );
304 : }
305 :
306 0 : uno::Any ScVbaSheetObjectsBase::getItemByStringIndex( const OUString& rIndex ) throw (uno::RuntimeException)
307 : {
308 0 : return mxContainer->getItemByStringIndex( rIndex );
309 : }
310 :
311 : // ============================================================================
312 : // Graphic object containers supporting ooo.vba.excel.XGraphicObject
313 : // ============================================================================
314 :
315 0 : ScVbaGraphicObjectsBase::ScVbaGraphicObjectsBase( const ScVbaObjectContainerRef& rxContainer ) throw (uno::RuntimeException) :
316 0 : ScVbaGraphicObjects_BASE( rxContainer )
317 : {
318 0 : }
319 :
320 : // XGraphicObjects
321 :
322 0 : uno::Any SAL_CALL ScVbaGraphicObjectsBase::Add( const uno::Any& rLeft, const uno::Any& rTop, const uno::Any& rWidth, const uno::Any& rHeight ) throw (uno::RuntimeException)
323 : {
324 : /* Extract double values from passed Anys (the lclPointsToHmm() helper
325 : function will throw a RuntimeException on any error), and convert from
326 : points to 1/100 mm. */
327 0 : awt::Point aPos( static_cast<sal_Int32>(lclPointsToHmm( rLeft )), static_cast<sal_Int32>(lclPointsToHmm( rTop )) );
328 0 : awt::Size aSize( static_cast<sal_Int32>(lclPointsToHmm( rWidth )), static_cast<sal_Int32>(lclPointsToHmm( rHeight )) );
329 : // TODO: translate coordinates for RTL sheets
330 0 : if( (aPos.X < 0) || (aPos.Y < 0) || (aSize.Width <= 0) || (aSize.Height <= 0) )
331 0 : throw uno::RuntimeException();
332 :
333 : // create the UNO shape
334 0 : uno::Reference< drawing::XShape > xShape( mxContainer->createShape( aPos, aSize ), uno::UNO_SET_THROW );
335 0 : sal_Int32 nIndex = mxContainer->insertShape( xShape );
336 :
337 : // create and return the VBA object
338 0 : ::rtl::Reference< ScVbaSheetObjectBase > xVbaObject = mxContainer->createVbaObject( xShape );
339 0 : xVbaObject->setDefaultProperties( nIndex );
340 0 : return uno::Any( uno::Reference< excel::XSheetObject >( xVbaObject.get() ) );
341 : }
342 :
343 : // ============================================================================
344 : // Drawing controls
345 : // ============================================================================
346 :
347 0 : class ScVbaControlContainer : public ScVbaObjectContainer
348 : {
349 : public:
350 : explicit ScVbaControlContainer(
351 : const uno::Reference< XHelperInterface >& rxParent,
352 : const uno::Reference< uno::XComponentContext >& rxContext,
353 : const uno::Reference< frame::XModel >& rxModel,
354 : const uno::Reference< sheet::XSpreadsheet >& rxSheet,
355 : const uno::Type& rVbaType,
356 : const OUString& rModelServiceName,
357 : sal_Int16 nComponentType ) throw (uno::RuntimeException);
358 :
359 : protected:
360 : uno::Reference< container::XIndexContainer > createForm() throw (uno::RuntimeException);
361 :
362 : virtual bool implPickShape( const uno::Reference< drawing::XShape >& rxShape ) const;
363 : virtual OUString implGetShapeServiceName() const;
364 : virtual bool implCheckProperties( const uno::Reference< beans::XPropertySet >& rxModelProps ) const;
365 : virtual OUString implGetShapeName( const uno::Reference< drawing::XShape >& rxShape ) const throw (uno::RuntimeException);
366 : virtual void implOnShapeCreated( const uno::Reference< drawing::XShape >& rxShape ) throw (uno::RuntimeException);
367 :
368 : protected:
369 : uno::Reference< container::XIndexContainer > mxFormIC;
370 : OUString maModelServiceName;
371 : sal_Int16 mnComponentType;
372 : };
373 :
374 : // ----------------------------------------------------------------------------
375 :
376 0 : ScVbaControlContainer::ScVbaControlContainer(
377 : const uno::Reference< XHelperInterface >& rxParent,
378 : const uno::Reference< uno::XComponentContext >& rxContext,
379 : const uno::Reference< frame::XModel >& rxModel,
380 : const uno::Reference< sheet::XSpreadsheet >& rxSheet,
381 : const uno::Type& rVbaType,
382 : const OUString& rModelServiceName,
383 : sal_Int16 nComponentType ) throw (uno::RuntimeException) :
384 : ScVbaObjectContainer( rxParent, rxContext, rxModel, rxSheet, rVbaType ),
385 : maModelServiceName( rModelServiceName ),
386 0 : mnComponentType( nComponentType )
387 : {
388 0 : }
389 :
390 0 : uno::Reference< container::XIndexContainer > ScVbaControlContainer::createForm() throw (uno::RuntimeException)
391 : {
392 0 : if( !mxFormIC.is() )
393 : {
394 0 : uno::Reference< form::XFormsSupplier > xFormsSupp( mxShapes, uno::UNO_QUERY_THROW );
395 0 : uno::Reference< container::XNameContainer > xFormsNC( xFormsSupp->getForms(), uno::UNO_SET_THROW );
396 0 : OUString aFormName = "Standard";
397 0 : if( xFormsNC->hasByName( aFormName ) )
398 : {
399 0 : mxFormIC.set( xFormsNC->getByName( aFormName ), uno::UNO_QUERY_THROW );
400 : }
401 : else
402 : {
403 0 : uno::Reference< form::XForm > xForm( mxFactory->createInstance( "com.sun.star.form.component.Form" ), uno::UNO_QUERY_THROW );
404 0 : xFormsNC->insertByName( aFormName, uno::Any( xForm ) );
405 0 : mxFormIC.set( xForm, uno::UNO_QUERY_THROW );
406 0 : }
407 : }
408 0 : return mxFormIC;
409 : }
410 :
411 0 : bool ScVbaControlContainer::implPickShape( const uno::Reference< drawing::XShape >& rxShape ) const
412 : {
413 : try
414 : {
415 0 : uno::Reference< drawing::XControlShape > xControlShape( rxShape, uno::UNO_QUERY_THROW );
416 0 : uno::Reference< beans::XPropertySet > xModelProps( xControlShape->getControl(), uno::UNO_QUERY_THROW );
417 0 : sal_Int16 nClassId = -1;
418 0 : return lclGetProperty( nClassId, xModelProps, "ClassId" ) &&
419 0 : (nClassId == mnComponentType) && implCheckProperties( xModelProps );
420 : }
421 0 : catch( uno::Exception& )
422 : {
423 : }
424 0 : return false;
425 : }
426 :
427 0 : OUString ScVbaControlContainer::implGetShapeServiceName() const
428 : {
429 0 : return OUString( "com.sun.star.drawing.ControlShape" );
430 : }
431 :
432 0 : bool ScVbaControlContainer::implCheckProperties( const uno::Reference< beans::XPropertySet >& /*rxModelProps*/ ) const
433 : {
434 0 : return true;
435 : }
436 :
437 0 : OUString ScVbaControlContainer::implGetShapeName( const uno::Reference< drawing::XShape >& rxShape ) const throw (uno::RuntimeException)
438 : {
439 0 : uno::Reference< drawing::XControlShape > xControlShape( rxShape, uno::UNO_QUERY_THROW );
440 0 : return uno::Reference< container::XNamed >( xControlShape->getControl(), uno::UNO_QUERY_THROW )->getName();
441 : }
442 :
443 0 : void ScVbaControlContainer::implOnShapeCreated( const uno::Reference< drawing::XShape >& rxShape ) throw (uno::RuntimeException)
444 : {
445 : // passed shape must be a control shape
446 0 : uno::Reference< drawing::XControlShape > xControlShape( rxShape, uno::UNO_QUERY_THROW );
447 :
448 : // create the UNO control model
449 0 : uno::Reference< form::XFormComponent > xFormComponent( mxFactory->createInstance( maModelServiceName ), uno::UNO_QUERY_THROW );
450 0 : uno::Reference< awt::XControlModel > xControlModel( xFormComponent, uno::UNO_QUERY_THROW );
451 :
452 : // insert the control model into the form and the shape
453 0 : createForm();
454 0 : mxFormIC->insertByIndex( mxFormIC->getCount(), uno::Any( xFormComponent ) );
455 0 : xControlShape->setControl( xControlModel );
456 0 : }
457 :
458 : // ============================================================================
459 : // Push button
460 : // ============================================================================
461 :
462 0 : class ScVbaButtonContainer : public ScVbaControlContainer
463 : {
464 : public:
465 : explicit ScVbaButtonContainer(
466 : const uno::Reference< XHelperInterface >& rxParent,
467 : const uno::Reference< uno::XComponentContext >& rxContext,
468 : const uno::Reference< frame::XModel >& rxModel,
469 : const uno::Reference< sheet::XSpreadsheet >& rxSheet ) throw (uno::RuntimeException);
470 :
471 : protected:
472 : virtual ScVbaSheetObjectBase* implCreateVbaObject( const uno::Reference< drawing::XShape >& rxShape ) throw (uno::RuntimeException);
473 : virtual bool implCheckProperties( const uno::Reference< beans::XPropertySet >& rxModelProps ) const;
474 : };
475 :
476 : // ----------------------------------------------------------------------------
477 :
478 0 : ScVbaButtonContainer::ScVbaButtonContainer(
479 : const uno::Reference< XHelperInterface >& rxParent,
480 : const uno::Reference< uno::XComponentContext >& rxContext,
481 : const uno::Reference< frame::XModel >& rxModel,
482 : const uno::Reference< sheet::XSpreadsheet >& rxSheet ) throw (uno::RuntimeException) :
483 : ScVbaControlContainer(
484 : rxParent, rxContext, rxModel, rxSheet,
485 0 : excel::XButton::static_type( 0 ),
486 : "com.sun.star.form.component.CommandButton",
487 0 : form::FormComponentType::COMMANDBUTTON )
488 : {
489 0 : }
490 :
491 0 : ScVbaSheetObjectBase* ScVbaButtonContainer::implCreateVbaObject( const uno::Reference< drawing::XShape >& rxShape ) throw (uno::RuntimeException)
492 : {
493 0 : uno::Reference< drawing::XControlShape > xControlShape( rxShape, uno::UNO_QUERY_THROW );
494 0 : return new ScVbaButton( mxParent, mxContext, mxModel, createForm(), xControlShape );
495 : }
496 :
497 0 : bool ScVbaButtonContainer::implCheckProperties( const uno::Reference< beans::XPropertySet >& rxModelProps ) const
498 : {
499 : // do not insert toggle buttons into the 'Buttons' collection
500 0 : bool bToggle = false;
501 0 : return lclGetProperty( bToggle, rxModelProps, "Toggle" ) && !bToggle;
502 : }
503 :
504 : // ============================================================================
505 :
506 0 : ScVbaButtons::ScVbaButtons(
507 : const uno::Reference< XHelperInterface >& rxParent,
508 : const uno::Reference< uno::XComponentContext >& rxContext,
509 : const uno::Reference< frame::XModel >& rxModel,
510 : const uno::Reference< sheet::XSpreadsheet >& rxSheet ) throw (uno::RuntimeException) :
511 0 : ScVbaGraphicObjectsBase( new ScVbaButtonContainer( rxParent, rxContext, rxModel, rxSheet ) )
512 : {
513 0 : }
514 :
515 6 : VBAHELPER_IMPL_XHELPERINTERFACE( ScVbaButtons, "ooo.vba.excel.Buttons" )
516 :
517 : // ============================================================================
518 :
519 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|