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