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