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