/src/libreoffice/include/svx/svdouno.hxx
Line | Count | Source |
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 | | |
20 | | #pragma once |
21 | | |
22 | | #include <com/sun/star/awt/XControlModel.hpp> |
23 | | #include <com/sun/star/awt/XControl.hpp> |
24 | | #include <com/sun/star/lang/XMultiServiceFactory.hpp> |
25 | | #include <com/sun/star/awt/XControlContainer.hpp> |
26 | | #include <svx/svxdllapi.h> |
27 | | #include <svx/svdorect.hxx> |
28 | | #include <memory> |
29 | | |
30 | | |
31 | | // Forward declaration |
32 | | class SdrView; |
33 | | |
34 | | namespace sdr::contact { |
35 | | class ViewContactOfUnoControl; |
36 | | } |
37 | | |
38 | | |
39 | | // SdrUnoObj |
40 | | struct SdrUnoObjDataHolder; |
41 | | class SVXCORE_DLLPUBLIC SdrUnoObj : public SdrRectObj |
42 | | { |
43 | | friend class SdrPageView; |
44 | | friend class SdrControlEventListenerImpl; |
45 | | |
46 | | std::unique_ptr<SdrUnoObjDataHolder> m_pImpl; |
47 | | |
48 | | OUString m_aUnoControlModelTypeName; |
49 | | OUString m_aUnoControlTypeName; |
50 | | |
51 | | protected: |
52 | | css::uno::Reference< css::awt::XControlModel > m_xUnoControlModel; // Can also be set from outside |
53 | | |
54 | | private: |
55 | | SVX_DLLPRIVATE void CreateUnoControlModel(const OUString& rModelName); |
56 | | SVX_DLLPRIVATE void CreateUnoControlModel(const OUString& rModelName, |
57 | | const css::uno::Reference< css::lang::XMultiServiceFactory >& rxSFac ); |
58 | | |
59 | | public: |
60 | | explicit SdrUnoObj( |
61 | | SdrModel& rSdrModel, |
62 | | const OUString& rModelName); |
63 | | // Copy constructor |
64 | | SdrUnoObj(SdrModel& rSdrModel, SdrUnoObj const & rSource); |
65 | | SdrUnoObj( |
66 | | SdrModel& rSdrModel, |
67 | | const OUString& rModelName, |
68 | | const css::uno::Reference< css::lang::XMultiServiceFactory >& rxSFac); |
69 | | virtual ~SdrUnoObj() override; |
70 | | |
71 | | virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override; |
72 | | virtual SdrObjKind GetObjIdentifier() const override; |
73 | | |
74 | | virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override; |
75 | | virtual void NbcResize(const Point& rRef, double xFact, double yFact) override; |
76 | | virtual void NbcSetLayer(SdrLayerID nLayer) override; |
77 | | |
78 | | // SpecialDrag support |
79 | | virtual bool hasSpecialDrag() const override; |
80 | | |
81 | | virtual OUString TakeObjNameSingul() const override; |
82 | | virtual OUString TakeObjNamePlural() const override; |
83 | | |
84 | | virtual void SetContextWritingMode( const sal_Int16 _nContextWritingMode ) override; |
85 | | |
86 | 0 | const css::uno::Reference< css::awt::XControlModel >& GetUnoControlModel() const {return m_xUnoControlModel;} |
87 | | css::uno::Reference< css::awt::XControl > GetUnoControl(const SdrView& _rView, const OutputDevice& _rOut) const; |
88 | | |
89 | | /** Retrieves a temporary XControl instance for a given output device |
90 | | |
91 | | The method GetUnoControl, used to retrieve the XControl whose parent is a given device, only works |
92 | | if the SdrUnoObj has already been painted at least once onto this device. However, there are valid |
93 | | scenarios where you need certain information on how a control is painted onto a window, without |
94 | | actually painting it. For example, you might be interested in the DeviceInfo of a UNO control. |
95 | | |
96 | | For those cases, you can contain an XControl which behaves as the control which *would* be used to |
97 | | paint onto a window. |
98 | | |
99 | | @param _rWindow |
100 | | the window for which should act as parent for the temporary control |
101 | | @param _inout_ControlContainer |
102 | | the control container belonging to the window, necessary as context |
103 | | for the newly created control. A control container is usually created by calling |
104 | | VCLUnoHelper::CreateControlContainer. |
105 | | If _inout_ControlContainer is <NULL/>, it will be created internally, and passed to the caller. |
106 | | In this case, the caller also takes ownership of the control container, and is responsible for |
107 | | disposing it when not needed anymore. |
108 | | @return |
109 | | The requested control. This control is temporary only, and the caller is responsible for it. |
110 | | In particular, the caller is required to dispose it when it's not needed anymore. |
111 | | |
112 | | */ |
113 | | css::uno::Reference< css::awt::XControl > |
114 | | GetTemporaryControlForWindow( |
115 | | const vcl::Window& _rWindow, |
116 | | css::uno::Reference< css::awt::XControlContainer >& _inout_ControlContainer |
117 | | ) const; |
118 | | |
119 | 0 | const OUString& GetUnoControlTypeName() const { return m_aUnoControlTypeName; } |
120 | 0 | const OUString& getUnoControlModelTypeName() const { return m_aUnoControlModelTypeName; } |
121 | | |
122 | | virtual void SetUnoControlModel( const css::uno::Reference< css::awt::XControlModel >& xModel ); |
123 | | |
124 | | protected: |
125 | | // SdrObject overridables |
126 | | virtual std::unique_ptr<sdr::contact::ViewContact> CreateObjectSpecificViewContact() override; |
127 | | |
128 | | private: |
129 | | /** Retrieves the typed ViewContact for the object |
130 | | @param _out_rpContact |
131 | | Upon successful return, ->_out_rpContact contains the ViewContact. |
132 | | @return |
133 | | <TRUE/> if and only if the contact was successfully retrieved. In this case, |
134 | | ->_out_rpContact contains a pointer to this contact. |
135 | | A failure to retrieve the contact object fires an assertion in non-product builds. |
136 | | */ |
137 | | SVX_DLLPRIVATE bool impl_getViewContact( sdr::contact::ViewContactOfUnoControl*& _out_rpContact ) const; |
138 | | }; |
139 | | |
140 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |