1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef SC_VBA_CONTROL_HXX 24 #define SC_VBA_CONTROL_HXX 25 26 #include <cppuhelper/implbase1.hxx> 27 #include <com/sun/star/beans/XPropertySet.hpp> 28 #include <com/sun/star/uno/XComponentContext.hpp> 29 #include <com/sun/star/script/XDefaultProperty.hpp> 30 #include <com/sun/star/drawing/XControlShape.hpp> 31 #include <com/sun/star/awt/XControl.hpp> 32 #include <com/sun/star/awt/XWindowPeer.hpp> 33 #include <ooo/vba/msforms/XControl.hpp> 34 35 #include <vbahelper/vbahelper.hxx> 36 #include <vbahelper/vbahelperinterface.hxx> 37 #include <memory> 38 39 //typedef ::cppu::WeakImplHelper1< ov::msforms::XControl > ControlImpl_BASE; 40 //template SAL_DLLPUBLIC_IMPORT InheritedHelperInterfaceImpl1< ov::msforms::XControl >; 41 typedef InheritedHelperInterfaceImpl1< ov::msforms::XControl > ControlImpl_BASE; 42 43 class ScVbaControl : public ControlImpl_BASE 44 { 45 private: 46 com::sun::star::uno::Reference< com::sun::star::lang::XEventListener > m_xEventListener; 47 protected: 48 // awt control has nothing similar to Tag property of Mso controls, 49 // whether it is necessary is another question 50 ::rtl::OUString m_aControlTag; 51 52 std::auto_ptr< ov::AbstractGeometryAttributes > mpGeometryHelper; 53 css::uno::Reference< css::beans::XPropertySet > m_xProps; 54 css::uno::Reference< css::uno::XInterface > m_xControl; 55 css::uno::Reference< css::frame::XModel > m_xModel; 56 57 virtual css::uno::Reference< css::awt::XWindowPeer > getWindowPeer() throw (css::uno::RuntimeException); 58 public: 59 ScVbaControl( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, 60 const css::uno::Reference< css::uno::XInterface >& xControl, const css::uno::Reference< css::frame::XModel >& xModel, ov::AbstractGeometryAttributes* pHelper ); 61 virtual ~ScVbaControl(); 62 // This class will own the helper, so make sure it is allocated from 63 // the heap 64 void setGeometryHelper( ov::AbstractGeometryAttributes* pHelper ); 65 // XControl 66 virtual sal_Bool SAL_CALL getEnabled() throw (css::uno::RuntimeException); 67 virtual void SAL_CALL setEnabled( sal_Bool _enabled ) throw (css::uno::RuntimeException); 68 virtual sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException); 69 virtual void SAL_CALL setVisible( sal_Bool _visible ) throw (css::uno::RuntimeException); 70 virtual double SAL_CALL getHeight() throw (css::uno::RuntimeException); 71 virtual void SAL_CALL setHeight( double _height ) throw (css::uno::RuntimeException); 72 virtual double SAL_CALL getWidth() throw (css::uno::RuntimeException); 73 virtual void SAL_CALL setWidth( double _width ) throw (css::uno::RuntimeException); 74 virtual double SAL_CALL getLeft() throw (css::uno::RuntimeException); 75 virtual void SAL_CALL setLeft( double _left ) throw (css::uno::RuntimeException); 76 virtual double SAL_CALL getTop() throw (css::uno::RuntimeException); 77 virtual void SAL_CALL setTop( double _top ) throw (css::uno::RuntimeException); 78 virtual void SAL_CALL SetFocus( ) throw (css::uno::RuntimeException); 79 virtual void SAL_CALL Move( double Left, double Top, const ::com::sun::star::uno::Any& Width, const ::com::sun::star::uno::Any& Height ) throw (::com::sun::star::uno::RuntimeException); 80 81 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getObject() throw (css::uno::RuntimeException); 82 virtual rtl::OUString SAL_CALL getControlSource() throw (css::uno::RuntimeException); 83 virtual void SAL_CALL setControlSource( const rtl::OUString& _controlsource ) throw (css::uno::RuntimeException); 84 virtual rtl::OUString SAL_CALL getRowSource() throw (css::uno::RuntimeException); 85 virtual void SAL_CALL setRowSource( const rtl::OUString& _rowsource ) throw (css::uno::RuntimeException); 86 virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException); 87 virtual void SAL_CALL setName( const rtl::OUString& _name ) throw (css::uno::RuntimeException); 88 virtual rtl::OUString SAL_CALL getControlTipText() throw (css::uno::RuntimeException); 89 virtual void SAL_CALL setControlTipText( const rtl::OUString& ) throw (css::uno::RuntimeException); 90 virtual ::rtl::OUString SAL_CALL getTag() throw (css::uno::RuntimeException); 91 virtual void SAL_CALL setTag( const ::rtl::OUString& aTag ) throw (css::uno::RuntimeException); 92 virtual sal_Int32 SAL_CALL getTabIndex() throw (css::uno::RuntimeException); 93 virtual void SAL_CALL setTabIndex( sal_Int32 nTabIndex ) throw (css::uno::RuntimeException); 94 //remove resouce because ooo.vba.excel.XControl is a wrapper of com.sun.star.drawing.XControlShape 95 virtual void removeResouce() throw( css::uno::RuntimeException ); 96 //XHelperInterface 97 virtual rtl::OUString& getServiceImplName(); 98 virtual css::uno::Sequence<rtl::OUString> getServiceNames(); 99 }; 100 101 102 class ScVbaControlFactory 103 { 104 public: 105 static css::uno::Reference< ov::msforms::XControl > createShapeControl( 106 const css::uno::Reference< css::uno::XComponentContext >& xContext, 107 const css::uno::Reference< css::drawing::XControlShape >& xControlShape, 108 const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException); 109 110 static css::uno::Reference< ov::msforms::XControl > createUserformControl( 111 const css::uno::Reference< css::uno::XComponentContext >& xContext, 112 const css::uno::Reference< css::awt::XControl >& xControl, 113 const css::uno::Reference< css::awt::XControl >& xDialog, 114 const css::uno::Reference< css::frame::XModel >& xModel, 115 double fOffsetX, double fOffsetY ) throw (css::uno::RuntimeException); 116 117 private: 118 ScVbaControlFactory(); 119 ~ScVbaControlFactory(); 120 }; 121 122 #endif//SC_VBA_CONTROL_HXX 123