xref: /trunk/main/vbahelper/source/msforms/vbacontrol.hxx (revision 5ff86c373e050985902bb66fb34662d4d4f150f7)
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();
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();
67     virtual void SAL_CALL setEnabled( sal_Bool _enabled );
68     virtual sal_Bool SAL_CALL getVisible();
69     virtual void SAL_CALL setVisible( sal_Bool _visible );
70     virtual double SAL_CALL getHeight();
71     virtual void SAL_CALL setHeight( double _height );
72     virtual double SAL_CALL getWidth();
73     virtual void SAL_CALL setWidth( double _width );
74     virtual double SAL_CALL getLeft();
75     virtual void SAL_CALL setLeft( double _left );
76     virtual double SAL_CALL getTop();
77     virtual void SAL_CALL setTop( double _top );
78     virtual void SAL_CALL SetFocus(  );
79     virtual void SAL_CALL Move( double Left, double Top, const ::com::sun::star::uno::Any& Width, const ::com::sun::star::uno::Any& Height );
80 
81     virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getObject();
82     virtual rtl::OUString SAL_CALL getControlSource();
83     virtual void SAL_CALL setControlSource( const rtl::OUString& _controlsource );
84     virtual rtl::OUString SAL_CALL getRowSource();
85     virtual void SAL_CALL setRowSource( const rtl::OUString& _rowsource );
86     virtual rtl::OUString SAL_CALL getName();
87     virtual void SAL_CALL setName( const rtl::OUString& _name );
88     virtual rtl::OUString SAL_CALL getControlTipText();
89     virtual void SAL_CALL setControlTipText( const rtl::OUString& );
90     virtual ::rtl::OUString SAL_CALL getTag();
91     virtual void SAL_CALL setTag( const ::rtl::OUString& aTag );
92     virtual sal_Int32 SAL_CALL getTabIndex();
93     virtual void SAL_CALL setTabIndex( sal_Int32 nTabIndex );
94     //remove resource because ooo.vba.excel.XControl is a wrapper of com.sun.star.drawing.XControlShape
95     virtual void removeResource();
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 );
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 );
116 
117 private:
118     ScVbaControlFactory();
119     ~ScVbaControlFactory();
120 };
121 
122 #endif//SC_VBA_CONTROL_HXX
123