1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #ifndef SC_VBA_CONTROL_HXX
28*cdf0e10cSrcweir #define SC_VBA_CONTROL_HXX
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
31*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/script/XDefaultProperty.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/drawing/XControlShape.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/awt/XControl.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/awt/XWindowPeer.hpp>
37*cdf0e10cSrcweir #include <ooo/vba/msforms/XControl.hpp>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #include <vbahelper/vbahelper.hxx>
40*cdf0e10cSrcweir #include <vbahelper/vbahelperinterface.hxx>
41*cdf0e10cSrcweir #include <memory>
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir //typedef ::cppu::WeakImplHelper1< ov::msforms::XControl > ControlImpl_BASE;
44*cdf0e10cSrcweir //template SAL_DLLPUBLIC_IMPORT InheritedHelperInterfaceImpl1< ov::msforms::XControl >;
45*cdf0e10cSrcweir typedef InheritedHelperInterfaceImpl1< ov::msforms::XControl > ControlImpl_BASE;
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir class ScVbaControl : public ControlImpl_BASE
48*cdf0e10cSrcweir {
49*cdf0e10cSrcweir private:
50*cdf0e10cSrcweir     com::sun::star::uno::Reference< com::sun::star::lang::XEventListener > m_xEventListener;
51*cdf0e10cSrcweir protected:
52*cdf0e10cSrcweir     // awt control has nothing similar to Tag property of Mso controls,
53*cdf0e10cSrcweir     // whether it is necessary is another question
54*cdf0e10cSrcweir     ::rtl::OUString m_aControlTag;
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir     std::auto_ptr< ov::AbstractGeometryAttributes > mpGeometryHelper;
57*cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySet > m_xProps;
58*cdf0e10cSrcweir     css::uno::Reference< css::uno::XInterface > m_xControl;
59*cdf0e10cSrcweir     css::uno::Reference< css::frame::XModel > m_xModel;
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir     virtual css::uno::Reference< css::awt::XWindowPeer > getWindowPeer() throw (css::uno::RuntimeException);
62*cdf0e10cSrcweir public:
63*cdf0e10cSrcweir     ScVbaControl( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext,
64*cdf0e10cSrcweir                     const css::uno::Reference< css::uno::XInterface >& xControl, const css::uno::Reference< css::frame::XModel >& xModel, ov::AbstractGeometryAttributes* pHelper );
65*cdf0e10cSrcweir     virtual ~ScVbaControl();
66*cdf0e10cSrcweir     // This class will own the helper, so make sure it is allocated from
67*cdf0e10cSrcweir     // the heap
68*cdf0e10cSrcweir     void setGeometryHelper( ov::AbstractGeometryAttributes* pHelper );
69*cdf0e10cSrcweir     // XControl
70*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL getEnabled() throw (css::uno::RuntimeException);
71*cdf0e10cSrcweir     virtual void SAL_CALL setEnabled( sal_Bool _enabled ) throw (css::uno::RuntimeException);
72*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException);
73*cdf0e10cSrcweir     virtual void SAL_CALL setVisible( sal_Bool _visible ) throw (css::uno::RuntimeException);
74*cdf0e10cSrcweir     virtual double SAL_CALL getHeight() throw (css::uno::RuntimeException);
75*cdf0e10cSrcweir     virtual void SAL_CALL setHeight( double _height ) throw (css::uno::RuntimeException);
76*cdf0e10cSrcweir     virtual double SAL_CALL getWidth() throw (css::uno::RuntimeException);
77*cdf0e10cSrcweir     virtual void SAL_CALL setWidth( double _width ) throw (css::uno::RuntimeException);
78*cdf0e10cSrcweir     virtual double SAL_CALL getLeft() throw (css::uno::RuntimeException);
79*cdf0e10cSrcweir     virtual void SAL_CALL setLeft( double _left ) throw (css::uno::RuntimeException);
80*cdf0e10cSrcweir     virtual double SAL_CALL getTop() throw (css::uno::RuntimeException);
81*cdf0e10cSrcweir     virtual void SAL_CALL setTop( double _top ) throw (css::uno::RuntimeException);
82*cdf0e10cSrcweir     virtual void SAL_CALL SetFocus(  ) throw (css::uno::RuntimeException);
83*cdf0e10cSrcweir     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);
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir     virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getObject() throw (css::uno::RuntimeException);
86*cdf0e10cSrcweir     virtual rtl::OUString SAL_CALL getControlSource() throw (css::uno::RuntimeException);
87*cdf0e10cSrcweir     virtual void SAL_CALL setControlSource( const rtl::OUString& _controlsource ) throw (css::uno::RuntimeException);
88*cdf0e10cSrcweir     virtual rtl::OUString SAL_CALL getRowSource() throw (css::uno::RuntimeException);
89*cdf0e10cSrcweir     virtual void SAL_CALL setRowSource( const rtl::OUString& _rowsource ) throw (css::uno::RuntimeException);
90*cdf0e10cSrcweir     virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
91*cdf0e10cSrcweir     virtual void SAL_CALL setName( const rtl::OUString& _name ) throw (css::uno::RuntimeException);
92*cdf0e10cSrcweir     virtual rtl::OUString SAL_CALL getControlTipText() throw (css::uno::RuntimeException);
93*cdf0e10cSrcweir     virtual void SAL_CALL setControlTipText( const rtl::OUString& ) throw (css::uno::RuntimeException);
94*cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getTag() throw (css::uno::RuntimeException);
95*cdf0e10cSrcweir     virtual void SAL_CALL setTag( const ::rtl::OUString& aTag ) throw (css::uno::RuntimeException);
96*cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getTabIndex() throw (css::uno::RuntimeException);
97*cdf0e10cSrcweir     virtual void SAL_CALL setTabIndex( sal_Int32 nTabIndex ) throw (css::uno::RuntimeException);
98*cdf0e10cSrcweir     //remove resouce because ooo.vba.excel.XControl is a wrapper of com.sun.star.drawing.XControlShape
99*cdf0e10cSrcweir     virtual void removeResouce() throw( css::uno::RuntimeException );
100*cdf0e10cSrcweir     //XHelperInterface
101*cdf0e10cSrcweir     virtual rtl::OUString& getServiceImplName();
102*cdf0e10cSrcweir     virtual css::uno::Sequence<rtl::OUString> getServiceNames();
103*cdf0e10cSrcweir };
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir class ScVbaControlFactory
107*cdf0e10cSrcweir {
108*cdf0e10cSrcweir public:
109*cdf0e10cSrcweir     static css::uno::Reference< ov::msforms::XControl > createShapeControl(
110*cdf0e10cSrcweir         const css::uno::Reference< css::uno::XComponentContext >& xContext,
111*cdf0e10cSrcweir         const css::uno::Reference< css::drawing::XControlShape >& xControlShape,
112*cdf0e10cSrcweir         const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException);
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir     static css::uno::Reference< ov::msforms::XControl > createUserformControl(
115*cdf0e10cSrcweir         const css::uno::Reference< css::uno::XComponentContext >& xContext,
116*cdf0e10cSrcweir         const css::uno::Reference< css::awt::XControl >& xControl,
117*cdf0e10cSrcweir         const css::uno::Reference< css::awt::XControl >& xDialog,
118*cdf0e10cSrcweir         const css::uno::Reference< css::frame::XModel >& xModel,
119*cdf0e10cSrcweir         double fOffsetX, double fOffsetY ) throw (css::uno::RuntimeException);
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir private:
122*cdf0e10cSrcweir     ScVbaControlFactory();
123*cdf0e10cSrcweir     ~ScVbaControlFactory();
124*cdf0e10cSrcweir };
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir #endif//SC_VBA_CONTROL_HXX
127