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