1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBACONTROL_HXX
20 #define INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBACONTROL_HXX
22 #include <com/sun/star/beans/XPropertySet.hpp>
23 #include <com/sun/star/uno/XComponentContext.hpp>
24 #include <com/sun/star/script/XDefaultProperty.hpp>
25 #include <com/sun/star/drawing/XControlShape.hpp>
26 #include <com/sun/star/awt/XControl.hpp>
27 #include <com/sun/star/awt/XWindowPeer.hpp>
28 #include <com/sun/star/script/ScriptEvent.hpp>
29 #include <ooo/vba/msforms/XControl.hpp>
31 #include <vbahelper/vbahelper.hxx>
32 #include <vbahelper/vbahelperinterface.hxx>
35 typedef InheritedHelperInterfaceWeakImpl
< ov::msforms::XControl
> ControlImpl_BASE
;
37 class ScVbaControl
: public ControlImpl_BASE
40 css::uno::Reference
< css::lang::XEventListener
> m_xEventListener
;
41 css::uno::Reference
< css::awt::XControl
> m_xEmptyFormControl
;
43 // awt control has nothing similar to Tag property of Mso controls,
44 // whether it is necessary is another question
45 OUString m_aControlTag
;
47 OUString m_sLibraryAndCodeName
;
48 std::unique_ptr
< ov::AbstractGeometryAttributes
> mpGeometryHelper
;
49 css::uno::Reference
< css::beans::XPropertySet
> m_xProps
;
50 css::uno::Reference
< css::uno::XInterface
> m_xControl
;
51 css::uno::Reference
< css::frame::XModel
> m_xModel
;
53 /// @throws css::uno::RuntimeException
54 css::uno::Reference
< css::awt::XWindowPeer
> getWindowPeer();
55 void fireChangeEvent();
56 void fireClickEvent();
58 ScVbaControl( const css::uno::Reference
< ov::XHelperInterface
>& xParent
, const css::uno::Reference
< css::uno::XComponentContext
>& xContext
,
59 const css::uno::Reference
< css::uno::XInterface
>& xControl
, const css::uno::Reference
< css::frame::XModel
>& xModel
, std::unique_ptr
<ov::AbstractGeometryAttributes
> pHelper
);
60 virtual ~ScVbaControl() override
;
61 // This class will own the helper, so make sure it is allocated from
63 void setGeometryHelper( std::unique_ptr
<ov::AbstractGeometryAttributes
> pHelper
);
64 // sets the name of the associated library ( used for UserForm controls )
65 void setLibraryAndCodeName( const OUString
& sLibCodeName
) { m_sLibraryAndCodeName
= sLibCodeName
; }
68 virtual sal_Bool SAL_CALL
getEnabled() override
;
69 virtual void SAL_CALL
setEnabled( sal_Bool _enabled
) override
;
70 virtual sal_Bool SAL_CALL
getVisible() override
;
71 virtual void SAL_CALL
setVisible( sal_Bool _visible
) override
;
72 virtual double SAL_CALL
getHeight() override
;
73 virtual void SAL_CALL
setHeight( double _height
) override
;
74 virtual double SAL_CALL
getWidth() override
;
75 virtual void SAL_CALL
setWidth( double _width
) override
;
76 virtual double SAL_CALL
getLeft() override
;
77 virtual void SAL_CALL
setLeft( double _left
) override
;
78 virtual double SAL_CALL
getTop() override
;
79 virtual void SAL_CALL
setTop( double _top
) override
;
80 virtual void SAL_CALL
SetFocus( ) override
;
81 virtual void SAL_CALL
Move( double Left
, double Top
, const css::uno::Any
& Width
, const css::uno::Any
& Height
) override
;
82 virtual void SAL_CALL
fireEvent( const css::script::ScriptEvent
& evt
) override
;
84 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
getObject() override
;
85 virtual OUString SAL_CALL
getControlSource() override
;
86 virtual void SAL_CALL
setControlSource( const OUString
& _controlsource
) override
;
87 virtual OUString SAL_CALL
getRowSource() override
;
88 virtual void SAL_CALL
setRowSource( const OUString
& _rowsource
) override
;
89 virtual OUString SAL_CALL
getName() override
;
90 virtual void SAL_CALL
setName( const OUString
& _name
) override
;
91 virtual OUString SAL_CALL
getControlTipText() override
;
92 virtual void SAL_CALL
setControlTipText( const OUString
& ) override
;
93 virtual OUString SAL_CALL
getTag() override
;
94 virtual void SAL_CALL
setTag( const OUString
& aTag
) override
;
95 virtual sal_Int32 SAL_CALL
getTabIndex() override
;
96 virtual void SAL_CALL
setTabIndex( sal_Int32 nTabIndex
) override
;
97 virtual ::sal_Int32 SAL_CALL
getMousePointer() override
;
98 virtual void SAL_CALL
setMousePointer( ::sal_Int32 _mousepointer
) override
;
99 //remove resource because ooo.vba.excel.XControl is a wrapper of com.sun.star.drawing.XControlShape
100 /// @throws css::uno::RuntimeException
101 void removeResource();
102 /// @throws css::uno::RuntimeException
103 virtual ::sal_Int32 SAL_CALL
getForeColor();
105 virtual OUString
getServiceImplName() override
;
106 virtual css::uno::Sequence
<OUString
> getServiceNames() override
;
107 //General helper methods for properties (may or may not be relevant for all
109 /// @throws css::uno::RuntimeException
110 sal_Int32
getBackColor();
111 /// @throws css::uno::RuntimeException
112 void setBackColor( sal_Int32 nBackColor
);
113 /// @throws css::uno::RuntimeException
115 /// @throws css::uno::RuntimeException
116 void setAutoSize( bool bAutoSize
);
117 /// @throws css::uno::RuntimeException
119 /// @throws css::uno::RuntimeException
120 void setLocked( bool bAutoSize
);
124 namespace ScVbaControlFactory
126 /// @throws css::uno::RuntimeException
127 css::uno::Reference
< ov::msforms::XControl
> createShapeControl(
128 const css::uno::Reference
< css::uno::XComponentContext
>& xContext
,
129 const css::uno::Reference
< css::drawing::XControlShape
>& xControlShape
,
130 const css::uno::Reference
< css::frame::XModel
>& xModel
);
132 /// @throws css::uno::RuntimeException
133 css::uno::Reference
< ov::msforms::XControl
> createUserformControl(
134 const css::uno::Reference
< css::uno::XComponentContext
>& xContext
,
135 const css::uno::Reference
< css::awt::XControl
>& xControl
,
136 const css::uno::Reference
< css::awt::XControl
>& xDialog
,
137 const css::uno::Reference
< css::frame::XModel
>& xModel
,
138 double fOffsetX
, double fOffsetY
);
141 #endif // INCLUDED_VBAHELPER_SOURCE_MSFORMS_VBACONTROL_HXX
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */