1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include <com/sun/star/awt/XControl.hpp>
29 #include <com/sun/star/awt/XControlContainer.hpp>
30 #include <com/sun/star/awt/FontWeight.hpp>
31 #include <com/sun/star/awt/FontSlant.hpp>
32 #include <com/sun/star/awt/FontStrikeout.hpp>
33 #include <com/sun/star/awt/FontUnderline.hpp>
34 #include <com/sun/star/container/XNameContainer.hpp>
35 #include <com/sun/star/script/XInvocation.hpp>
36 #include <com/sun/star/lang/WrappedTargetException.hpp>
37 
38 #include "vbacontrols.hxx"
39 #include "vbacontrol.hxx"
40 #include <cppuhelper/implbase2.hxx>
41 #include <ooo/vba/XControlProvider.hpp>
42 #include <hash_map>
43 
44 using namespace com::sun::star;
45 using namespace ooo::vba;
46 
47 
48 typedef ::cppu::WeakImplHelper2< container::XNameAccess, container::XIndexAccess > ArrayWrapImpl;
49 
50 typedef  std::hash_map< rtl::OUString, sal_Int32, ::rtl::OUStringHash,
51     ::std::equal_to< ::rtl::OUString >  > ControlIndexMap;
52 typedef  std::vector< uno::Reference< awt::XControl > > ControlVec;
53 
54 class ControlArrayWrapper : public ArrayWrapImpl
55 {
56     uno::Reference< awt::XControlContainer > mxDialog;
57     uno::Sequence< ::rtl::OUString > msNames;
58     ControlVec mControls;
59     ControlIndexMap mIndices;
60 
61 private:
62     void SetArrayElementTo( const uno::Reference< awt::XControl >& xCtrl, sal_Int32 nIndex = -1 )
63     {
64         // initialize the element with specified index to the control
65         if ( xCtrl.is() )
66         {
67             if ( nIndex == -1 )
68                 nIndex = msNames.getLength();
69 
70             if ( nIndex >= msNames.getLength() )
71                 msNames.realloc( nIndex );
72 
73             msNames[ nIndex ] = getControlName( xCtrl );
74             mControls.push_back( xCtrl );
75             mIndices[ msNames[ nIndex ] ] = nIndex;
76         }
77     }
78 
79 public:
80     ControlArrayWrapper( const uno::Reference< awt::XControl >& xDialog )
81     {
82         try
83         {
84             mxDialog.set( xDialog, uno::UNO_QUERY_THROW );
85             uno::Sequence< uno::Reference< awt::XControl > > sXControls = mxDialog->getControls();
86 
87             msNames.realloc( sXControls.getLength() );
88             for ( sal_Int32 i = 0; i < sXControls.getLength(); ++i )
89                 SetArrayElementTo( sXControls[ i ], i );
90         }
91         catch( uno::Exception& )
92         {
93             // accept the case when the dialog already does not exist
94             // in this case the wrapper should work in dummy mode
95         }
96     }
97 
98     static rtl::OUString getControlName( const uno::Reference< awt::XControl >& xCtrl )
99     {
100         if ( !xCtrl.is() )
101             throw uno::RuntimeException();
102 
103         uno::Reference< beans::XPropertySet > xProp( xCtrl->getModel(), uno::UNO_QUERY_THROW );
104         rtl::OUString sName;
105         xProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Name" ) ) ) >>= sName;
106         return sName;
107     }
108 
109 
110     // XElementAccess
111     virtual uno::Type SAL_CALL getElementType(  ) throw (uno::RuntimeException)
112     {
113         return awt::XControl::static_type(0);
114     }
115 
116     virtual ::sal_Bool SAL_CALL hasElements(  ) throw (uno::RuntimeException)
117     {
118         return ( mControls.size() > 0 );
119     }
120 
121     // XNameAcess
122     virtual uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
123     {
124         if ( !hasByName( aName ) )
125             throw container::NoSuchElementException();
126         return getByIndex( mIndices[ aName ] );
127     }
128 
129     virtual uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames(  ) throw (uno::RuntimeException)
130     {
131         return msNames;
132     }
133 
134     virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException)
135     {
136         ControlIndexMap::iterator it = mIndices.find( aName );
137         return it != mIndices.end();
138     }
139 
140     // XElementAccess
141     virtual ::sal_Int32 SAL_CALL getCount(  ) throw (css::uno::RuntimeException)
142     {
143         return mControls.size();
144     }
145 
146     virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
147     {
148         if ( Index < 0 || Index >= static_cast< sal_Int32 >( mControls.size() ) )
149             throw lang::IndexOutOfBoundsException();
150         return uno::makeAny( mControls[ Index ] );
151     }
152 };
153 
154 
155 class ControlsEnumWrapper : public EnumerationHelper_BASE
156 {
157     uno::Reference<XHelperInterface > m_xParent;
158     uno::Reference<uno::XComponentContext > m_xContext;
159     uno::Reference<container::XIndexAccess > m_xIndexAccess;
160     uno::Reference<awt::XControl > m_xDlg;
161     uno::Reference< frame::XModel > m_xModel;
162     double mfOffsetX;
163     double mfOffsetY;
164     sal_Int32 nIndex;
165 
166 public:
167 
168     ControlsEnumWrapper(
169         const uno::Reference< XHelperInterface >& xParent,
170         const uno::Reference< uno::XComponentContext >& xContext,
171         const uno::Reference< container::XIndexAccess >& xIndexAccess,
172         const uno::Reference< awt::XControl >& xDlg,
173         const uno::Reference< frame::XModel >& xModel,
174         double fOffsetX, double fOffsetY ) :
175     m_xParent( xParent ),
176     m_xContext( xContext),
177     m_xIndexAccess( xIndexAccess ),
178     m_xDlg( xDlg ),
179     m_xModel( xModel ),
180     mfOffsetX( fOffsetX ),
181     mfOffsetY( fOffsetY ),
182     nIndex( 0 ) {}
183 
184     virtual ::sal_Bool SAL_CALL hasMoreElements(  ) throw (uno::RuntimeException)
185     {
186         return ( nIndex < m_xIndexAccess->getCount() );
187     }
188 
189     virtual uno::Any SAL_CALL nextElement(  ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
190     {
191         if ( nIndex < m_xIndexAccess->getCount() )
192         {
193             uno::Reference< awt::XControl > xControl;
194             m_xIndexAccess->getByIndex( nIndex++ ) >>= xControl;
195 
196             uno::Reference< msforms::XControl > xVBAControl;
197             if ( xControl.is() && m_xDlg.is() )
198             	xVBAControl = ScVbaControlFactory::createUserformControl( m_xContext, xControl, m_xDlg, m_xModel, mfOffsetX, mfOffsetY );
199             return uno::makeAny( xVBAControl );
200         }
201         throw container::NoSuchElementException();
202     }
203 
204 };
205 
206 
207 uno::Reference<container::XIndexAccess >
208 lcl_controlsWrapper( const uno::Reference< awt::XControl >& xDlg )
209 {
210     return new ControlArrayWrapper( xDlg );
211 }
212 
213 ScVbaControls::ScVbaControls(
214         const uno::Reference< XHelperInterface >& xParent,
215         const uno::Reference< uno::XComponentContext >& xContext,
216         const css::uno::Reference< awt::XControl >& xDialog,
217         const uno::Reference< frame::XModel >& xModel,
218         double fOffsetX, double fOffsetY ) :
219     ControlsImpl_BASE( xParent, xContext, lcl_controlsWrapper( xDialog  ) ),
220     mxDialog( xDialog ),
221     mxModel( xModel ),
222     mfOffsetX( fOffsetX ),
223     mfOffsetY( fOffsetY )
224 {
225 }
226 
227 uno::Reference< container::XEnumeration >
228 ScVbaControls::createEnumeration() throw (uno::RuntimeException)
229 {
230     uno::Reference< container::XEnumeration > xEnum( new ControlsEnumWrapper( mxParent, mxContext, m_xIndexAccess, mxDialog, mxModel, mfOffsetX, mfOffsetY ) );
231     if ( !xEnum.is() )
232         throw uno::RuntimeException();
233     return xEnum;
234 }
235 
236 uno::Any
237 ScVbaControls::createCollectionObject( const css::uno::Any& aSource )
238 {
239     // Create control from awt::XControl
240     uno::Reference< awt::XControl > xControl( aSource, uno::UNO_QUERY_THROW );
241 	uno::Reference< msforms::XControl > xVBAControl = ScVbaControlFactory::createUserformControl( mxContext, xControl, mxDialog, mxModel, mfOffsetX, mfOffsetY );
242     return uno::Any( xVBAControl );
243 }
244 
245 void SAL_CALL
246 ScVbaControls::Move( double cx, double cy ) throw (uno::RuntimeException)
247 {
248     uno::Reference< container::XEnumeration > xEnum( createEnumeration() );
249     while ( xEnum->hasMoreElements() )
250     {
251         uno::Reference< msforms::XControl > xControl( xEnum->nextElement(), uno::UNO_QUERY_THROW );
252         xControl->setLeft( xControl->getLeft() + cx );
253         xControl->setTop( xControl->getTop() + cy );
254     }
255 }
256 
257 uno::Any SAL_CALL ScVbaControls::Add( const uno::Any& Object, const uno::Any& StringKey, const uno::Any& /*Before*/, const uno::Any& /*After*/ )
258     throw (uno::RuntimeException)
259 {
260     uno::Any aResult;
261     ::rtl::OUString aComServiceName;
262 
263     try
264     {
265         if ( !mxDialog.is() )
266             throw uno::RuntimeException();
267 
268         uno::Reference< awt::XControl > xNewControl;
269         uno::Reference< lang::XMultiServiceFactory > xModelFactory( mxDialog->getModel(), uno::UNO_QUERY_THROW );
270 
271         uno::Reference< container::XNameContainer > xDialogContainer( xModelFactory, uno::UNO_QUERY_THROW );
272 
273         Object >>= aComServiceName;
274 
275         // TODO: Support Before and After?
276         ::rtl::OUString aNewName;
277         StringKey >>= aNewName;
278         if ( !aNewName.getLength() )
279         {
280             aNewName = aComServiceName;
281             if ( !aNewName.getLength() )
282                 aNewName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Control" ) );
283 
284             sal_Int32 nInd = 0;
285             while( xDialogContainer->hasByName( aNewName ) && (nInd < SAL_MAX_INT32) )
286             {
287                 aNewName = aComServiceName;
288                 aNewName += ::rtl::OUString::valueOf( nInd++ );
289             }
290         }
291 
292         double fDefWidth = 72.0, fDefHeight = 18.0;
293         if ( aComServiceName.getLength() )
294         {
295             // create a UNO control model based on the passed control type
296             uno::Reference< awt::XControlModel > xNewModel;
297             bool bFontSupport = false;
298             bool bNativeAX = false;
299             if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.CommandButton.1" ) ) )
300             {
301                 xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlButtonModel" ) ) ), uno::UNO_QUERY_THROW );
302                 fDefWidth = 72.0; fDefHeight = 24.0;
303                 bFontSupport = true;
304             }
305             else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.Label.1" ) ) )
306             {
307                 xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlFixedTextModel" ) ) ), uno::UNO_QUERY_THROW );
308                 fDefWidth = 72.0; fDefHeight = 18.0;
309                 bFontSupport = true;
310             }
311             else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.Image.1" ) ) )
312             {
313                 xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlImageControlModel" ) ) ), uno::UNO_QUERY_THROW );
314                 fDefWidth = 72.0; fDefHeight = 72.0;
315             }
316             else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.CheckBox.1" ) ) )
317             {
318                 xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlCheckBoxModel" ) ) ), uno::UNO_QUERY_THROW );
319                 fDefWidth = 108.0; fDefHeight = 18.0;
320                 bFontSupport = true;
321             }
322             else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.OptionButton.1" ) ) )
323             {
324                 xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlRadioButtonModel" ) ) ), uno::UNO_QUERY_THROW );
325                 fDefWidth = 108.0; fDefHeight = 18.0;
326                 bFontSupport = true;
327             }
328             else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.TextBox.1" ) ) )
329             {
330                 xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlEditModel" ) ) ), uno::UNO_QUERY_THROW );
331                 fDefWidth = 72.0; fDefHeight = 18.0;
332                 bFontSupport = true;
333             }
334             else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.ListBox.1" ) ) )
335             {
336                 xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlListBoxModel" ) ) ), uno::UNO_QUERY_THROW );
337                 fDefWidth = 72.0; fDefHeight = 18.0;
338                 bFontSupport = true;
339             }
340             else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.ComboBox.1" ) ) )
341             {
342                 xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlComboBoxModel" ) ) ), uno::UNO_QUERY_THROW );
343                 uno::Reference< beans::XPropertySet > xProps( xNewModel, uno::UNO_QUERY_THROW );
344                 xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Dropdown" ) ), uno::Any( true ) );
345                 fDefWidth = 72.0; fDefHeight = 18.0;
346                 bFontSupport = true;
347             }
348             else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.ToggleButton.1" ) ) )
349             {
350                 xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlButtonModel" ) ) ), uno::UNO_QUERY_THROW );
351                 uno::Reference< beans::XPropertySet > xProps( xNewModel, uno::UNO_QUERY_THROW );
352                 xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Toggle" ) ), uno::Any( true ) );
353                 fDefWidth = 72.0; fDefHeight = 18.0;
354                 bFontSupport = true;
355             }
356             else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.Frame.1" ) ) )
357             {
358                 xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlGroupBoxModel" ) ) ), uno::UNO_QUERY_THROW );
359                 fDefWidth = 216.0; fDefHeight = 144.0;
360                 bFontSupport = true;
361             }
362             else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.SpinButton.1" ) ) )
363             {
364                 xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlSpinButtonModel" ) ) ), uno::UNO_QUERY_THROW );
365                 fDefWidth = 12.75; fDefHeight = 25.5;
366             }
367             else if( aComServiceName.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM( "Forms.ScrollBar.1" ) ) )
368             {
369                 xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlScrollBarModel" ) ) ), uno::UNO_QUERY_THROW );
370                 fDefWidth = 12.75; fDefHeight = 63.8;
371             }
372             else
373             {
374                 xNewModel.set( xModelFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.custom.awt.UnoControlSystemAXContainerModel" ) ) ), uno::UNO_QUERY_THROW );
375                 fDefWidth = 72.0; fDefHeight = 18.0;
376                 bNativeAX = true;
377             }
378 
379             // need to set a few font properties to get rid of the default DONT_KNOW values
380             if( bFontSupport )
381             {
382                 uno::Reference< beans::XPropertySet > xModelProps( xNewModel, uno::UNO_QUERY_THROW );
383                 xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontName" ) ), uno::Any( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Tahoma" ) ) ) );
384                 xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontHeight" ) ), uno::Any( float( 8.0 ) ) );
385                 xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontWeight" ) ), uno::Any( awt::FontWeight::NORMAL ) );
386                 xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontSlant" ) ), uno::Any( awt::FontSlant_NONE ) );
387                 xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontUnderline" ) ), uno::Any( awt::FontUnderline::NONE ) );
388                 xModelProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FontStrikeout" ) ), uno::Any( awt::FontStrikeout::NONE ) );
389             }
390 
391             xDialogContainer->insertByName( aNewName, uno::makeAny( xNewModel ) );
392             uno::Reference< awt::XControlContainer > xControlContainer( mxDialog, uno::UNO_QUERY_THROW );
393             xNewControl = xControlContainer->getControl( aNewName );
394 
395             if( bNativeAX ) try
396             {
397                 uno::Reference< script::XInvocation > xControlInvoke( xNewControl, uno::UNO_QUERY_THROW );
398 
399                 uno::Sequence< uno::Any > aArgs( 1 );
400                 aArgs[0] <<= aComServiceName;
401                 uno::Sequence< sal_Int16 > aOutIDDummy;
402                 uno::Sequence< uno::Any > aOutDummy;
403                 xControlInvoke->invoke( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SOAddAXControl" ) ), aArgs, aOutIDDummy, aOutDummy );
404             }
405             catch( uno::Exception& )
406             {
407                 xDialogContainer->removeByName( aNewName );
408                 throw;
409             }
410         }
411 
412         if ( xNewControl.is() )
413         {
414             UpdateCollectionIndex( lcl_controlsWrapper( mxDialog  ) );
415             aResult <<= xNewControl;
416             aResult = createCollectionObject( aResult );
417             uno::Reference< msforms::XControl > xVBAControl( aResult, uno::UNO_QUERY_THROW );
418             if( fDefWidth > 0.0 )
419                 xVBAControl->setWidth( fDefWidth );
420             if( fDefHeight > 0.0 )
421                 xVBAControl->setHeight( fDefHeight );
422         }
423         else
424             throw uno::RuntimeException();
425     }
426     catch( uno::RuntimeException& )
427     {
428         throw;
429     }
430     catch( uno::Exception& e )
431     {
432         throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not create AXControl!" ) ),
433                 uno::Reference< uno::XInterface >(),
434                 uno::makeAny( e ) );
435     }
436 
437     return aResult;
438 }
439 
440 void SAL_CALL ScVbaControls::Remove( const uno::Any& StringKeyOrIndex )
441     throw (uno::RuntimeException)
442 {
443     ::rtl::OUString aControlName;
444     sal_Int32 nIndex = -1;
445 
446     try
447     {
448         if ( !mxDialog.is() )
449             throw uno::RuntimeException();
450 
451         uno::Reference< lang::XMultiServiceFactory > xModelFactory( mxDialog->getModel(), uno::UNO_QUERY_THROW );
452         uno::Reference< container::XNameContainer > xDialogContainer( xModelFactory, uno::UNO_QUERY_THROW );
453 
454         if ( !( ( StringKeyOrIndex >>= aControlName ) && aControlName.getLength() )
455           && !( ( StringKeyOrIndex >>= nIndex ) && nIndex >= 0 && nIndex < m_xIndexAccess->getCount() ) )
456             throw uno::RuntimeException();
457 
458         uno::Reference< awt::XControl > xControl;
459         if ( aControlName.getLength() )
460         {
461             uno::Reference< awt::XControlContainer > xControlContainer( mxDialog, uno::UNO_QUERY_THROW );
462             xControl = xControlContainer->getControl( aControlName );
463         }
464         else
465         {
466             m_xIndexAccess->getByIndex( nIndex ) >>= xControl;
467         }
468 
469         if ( !xControl.is() )
470             throw uno::RuntimeException();
471 
472         if ( !aControlName.getLength() )
473             aControlName = ControlArrayWrapper::getControlName( xControl );
474 
475         xDialogContainer->removeByName( aControlName );
476         xControl->dispose();
477     }
478     catch( uno::RuntimeException& )
479     {
480         // the exceptions are not rethrown, impossibility to find or remove the control is currently not reported
481         // since in most cases it means just that the controls is already not there, the VBA seems to do it in the same way
482 
483         // throw;
484     }
485     catch( uno::Exception& e )
486     {
487         // throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not create AXControl!" ) ),
488         //         uno::Reference< uno::XInterface >(),
489         //         uno::makeAny( e ) );
490     }
491 }
492 
493 
494 uno::Type
495 ScVbaControls::getElementType() throw (uno::RuntimeException)
496 {
497     return ooo::vba::msforms::XControl::static_type(0);
498 }
499 
500 VBAHELPER_IMPL_XHELPERINTERFACE( ScVbaControls, "ooo.vba.msforms.Controls" )
501