Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBACONTROL_HXX
20 : #define INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBACONTROL_HXX
21 :
22 : #include <cppuhelper/implbase1.hxx>
23 : #include <com/sun/star/beans/XPropertySet.hpp>
24 : #include <com/sun/star/uno/XComponentContext.hpp>
25 : #include <com/sun/star/script/XDefaultProperty.hpp>
26 : #include <com/sun/star/drawing/XControlShape.hpp>
27 : #include <com/sun/star/awt/XControl.hpp>
28 : #include <com/sun/star/awt/XWindowPeer.hpp>
29 : #include <com/sun/star/script/ScriptEvent.hpp>
30 : #include <ooo/vba/msforms/XControl.hpp>
31 :
32 : #include <vbahelper/vbahelper.hxx>
33 : #include <vbahelper/vbahelperinterface.hxx>
34 : #include <memory>
35 :
36 : //typedef ::cppu::WeakImplHelper1< ov::msforms::XControl > ControlImpl_BASE;
37 : //template SAL_DLLPUBLIC_IMPORT InheritedHelperInterfaceImpl1< ov::msforms::XControl >;
38 : typedef InheritedHelperInterfaceImpl1< ov::msforms::XControl > ControlImpl_BASE;
39 :
40 : class ScVbaControl : public ControlImpl_BASE
41 : {
42 : private:
43 : com::sun::star::uno::Reference< com::sun::star::lang::XEventListener > m_xEventListener;
44 : com::sun::star::uno::Reference< com::sun::star::awt::XControl > m_xEmptyFormControl;
45 : protected:
46 : // awt control has nothing similar to Tag property of Mso controls,
47 : // whether it is necessary is another question
48 : OUString m_aControlTag;
49 :
50 : bool bIsDialog;
51 : OUString m_sLibraryAndCodeName;
52 : std::unique_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 : void fireChangeEvent();
59 : void fireClickEvent();
60 : public:
61 : ScVbaControl( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext,
62 : const css::uno::Reference< css::uno::XInterface >& xControl, const css::uno::Reference< css::frame::XModel >& xModel, ov::AbstractGeometryAttributes* pHelper );
63 : virtual ~ScVbaControl();
64 : // This class will own the helper, so make sure it is allocated from
65 : // the heap
66 : void setGeometryHelper( ov::AbstractGeometryAttributes* pHelper );
67 : // sets the name of the associated library ( used for UserForm controls )
68 102 : void setLibraryAndCodeName( const OUString& sLibCodeName ) { m_sLibraryAndCodeName = sLibCodeName; }
69 : OUString getLibraryAndCodeName() const { return m_sLibraryAndCodeName; }
70 :
71 : // XControl
72 : virtual sal_Bool SAL_CALL getEnabled() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
73 : virtual void SAL_CALL setEnabled( sal_Bool _enabled ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
74 : virtual sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
75 : virtual void SAL_CALL setVisible( sal_Bool _visible ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
76 : virtual double SAL_CALL getHeight() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
77 : virtual void SAL_CALL setHeight( double _height ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
78 : virtual double SAL_CALL getWidth() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
79 : virtual void SAL_CALL setWidth( double _width ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
80 : virtual double SAL_CALL getLeft() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
81 : virtual void SAL_CALL setLeft( double _left ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
82 : virtual double SAL_CALL getTop() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
83 : virtual void SAL_CALL setTop( double _top ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
84 : virtual void SAL_CALL SetFocus( ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
85 : 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, std::exception) SAL_OVERRIDE;
86 : virtual void SAL_CALL fireEvent( const css::script::ScriptEvent& evt ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
87 :
88 : virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getObject() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
89 : virtual OUString SAL_CALL getControlSource() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
90 : virtual void SAL_CALL setControlSource( const OUString& _controlsource ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
91 : virtual OUString SAL_CALL getRowSource() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
92 : virtual void SAL_CALL setRowSource( const OUString& _rowsource ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
93 : virtual OUString SAL_CALL getName() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
94 : virtual void SAL_CALL setName( const OUString& _name ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
95 : virtual OUString SAL_CALL getControlTipText() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
96 : virtual void SAL_CALL setControlTipText( const OUString& ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
97 : virtual OUString SAL_CALL getTag() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
98 : virtual void SAL_CALL setTag( const OUString& aTag ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
99 : virtual sal_Int32 SAL_CALL getTabIndex() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
100 : virtual void SAL_CALL setTabIndex( sal_Int32 nTabIndex ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
101 : virtual ::sal_Int32 SAL_CALL getMousePointer() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
102 : virtual void SAL_CALL setMousePointer( ::sal_Int32 _mousepointer ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
103 : //remove resouce because ooo.vba.excel.XControl is a wrapper of com.sun.star.drawing.XControlShape
104 : virtual void removeResouce() throw( css::uno::RuntimeException );
105 : virtual ::sal_Int32 SAL_CALL getForeColor() throw (::com::sun::star::uno::RuntimeException);
106 : virtual void SAL_CALL setForeColor( ::sal_Int32 _forecolor ) throw (::com::sun::star::uno::RuntimeException);
107 : //XHelperInterface
108 : virtual OUString getServiceImplName() SAL_OVERRIDE;
109 : virtual css::uno::Sequence<OUString> getServiceNames() SAL_OVERRIDE;
110 : //General helper methods for properties ( may or maynot be relevant for all
111 : //controls
112 : sal_Int32 getBackColor() throw (css::uno::RuntimeException);
113 : void setBackColor( sal_Int32 nBackColor ) throw (css::uno::RuntimeException);
114 : bool getAutoSize() throw (css::uno::RuntimeException);
115 : void setAutoSize( bool bAutoSize ) throw (css::uno::RuntimeException);
116 : bool getLocked() throw (css::uno::RuntimeException);
117 : void setLocked( bool bAutoSize ) throw (css::uno::RuntimeException);
118 : };
119 :
120 :
121 : class ScVbaControlFactory
122 : {
123 : public:
124 : static css::uno::Reference< ov::msforms::XControl > createShapeControl(
125 : const css::uno::Reference< css::uno::XComponentContext >& xContext,
126 : const css::uno::Reference< css::drawing::XControlShape >& xControlShape,
127 : const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException);
128 :
129 : static css::uno::Reference< ov::msforms::XControl > createUserformControl(
130 : const css::uno::Reference< css::uno::XComponentContext >& xContext,
131 : const css::uno::Reference< css::awt::XControl >& xControl,
132 : const css::uno::Reference< css::awt::XControl >& xDialog,
133 : const css::uno::Reference< css::frame::XModel >& xModel,
134 : double fOffsetX, double fOffsetY ) throw (css::uno::RuntimeException);
135 :
136 : private:
137 : ScVbaControlFactory();
138 : ~ScVbaControlFactory();
139 : };
140 :
141 : #endif // INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBACONTROL_HXX
142 :
143 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|