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