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 :
20 : #ifndef INCLUDED_SVX_SVDOUNO_HXX
21 : #define INCLUDED_SVX_SVDOUNO_HXX
22 :
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 :
30 :
31 : // Vorausdeklarationen
32 :
33 :
34 : class SdrView;
35 : class SdrPageWindow;
36 : class SdrControlEventListenerImpl;
37 :
38 : namespace sdr { namespace contact {
39 : class ViewContactOfUnoControl;
40 : }}
41 :
42 :
43 : // SdrUnoObj
44 :
45 :
46 : struct SdrUnoObjDataHolder;
47 : class SVX_DLLPUBLIC SdrUnoObj : public SdrRectObj
48 : {
49 : friend class SdrPageView;
50 : friend class SdrControlEventListenerImpl;
51 :
52 : SdrUnoObjDataHolder* m_pImpl;
53 :
54 : OUString aUnoControlModelTypeName;
55 : OUString aUnoControlTypeName;
56 : bool bOwnUnoControlModel;
57 :
58 : protected:
59 : ::com::sun::star::uno::Reference< com::sun::star::awt::XControlModel > xUnoControlModel; // kann auch von aussen gesetzt werden
60 :
61 : private:
62 : SVX_DLLPRIVATE void CreateUnoControlModel(const OUString& rModelName);
63 : SVX_DLLPRIVATE void CreateUnoControlModel(const OUString& rModelName,
64 : const ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rxSFac );
65 :
66 : public:
67 : TYPEINFO_OVERRIDE();
68 :
69 : explicit SdrUnoObj(const OUString& rModelName, bool bOwnsModel = true);
70 : SdrUnoObj(const OUString& rModelName,
71 : const ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rxSFac,
72 : bool bOwnsModel = true);
73 : virtual ~SdrUnoObj();
74 :
75 : virtual void SetPage(SdrPage* pNewPage) SAL_OVERRIDE;
76 : virtual void SetModel(SdrModel* pModel) SAL_OVERRIDE;
77 :
78 : virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const SAL_OVERRIDE;
79 : virtual sal_uInt16 GetObjIdentifier() const SAL_OVERRIDE;
80 :
81 : virtual SdrUnoObj* Clone() const SAL_OVERRIDE;
82 : SdrUnoObj& operator= (const SdrUnoObj& rObj);
83 : virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) SAL_OVERRIDE;
84 : virtual void NbcSetLayer(SdrLayerID nLayer) SAL_OVERRIDE;
85 :
86 : // SpecialDrag support
87 : virtual bool hasSpecialDrag() const SAL_OVERRIDE;
88 :
89 : // FullDrag support
90 : virtual bool supportsFullDrag() const SAL_OVERRIDE;
91 : virtual SdrObject* getFullDragClone() const SAL_OVERRIDE;
92 :
93 : virtual OUString TakeObjNameSingul() const SAL_OVERRIDE;
94 : virtual OUString TakeObjNamePlural() const SAL_OVERRIDE;
95 :
96 : virtual void SetContextWritingMode( const sal_Int16 _nContextWritingMode ) SAL_OVERRIDE;
97 :
98 7845 : ::com::sun::star::uno::Reference< com::sun::star::awt::XControlModel > GetUnoControlModel() const {return xUnoControlModel;}
99 : ::com::sun::star::uno::Reference< com::sun::star::awt::XControl > GetUnoControl(const SdrView& _rView, const OutputDevice& _rOut) const;
100 :
101 : /** retrieves a temporary XControl instance for a given output device
102 :
103 : The method GetUnoControl, used to retrieve the XControl whose parent is a given device, only works
104 : if the SdrUnoObj has already been painted at least once onto this device. However, there are valid
105 : scenarios where you need certain information on how a control is painted onto a window, without
106 : actually painting it. For example, you might be interested in the DeviceInfo of an UNO control.
107 :
108 : For those cases, you can ontain an XControl which behaves as the control which *would* be used to
109 : paint onto a window.
110 :
111 : @param _rWindow
112 : the window for which should act as parent for the temporary control
113 : @param _inout_ControlContainer
114 : the control container belonging to the window, necessary as context
115 : for the newly created control. A control container is usually created by calling
116 : VCLUnoHelper::CreateControlContainer.
117 : If _inout_ControlContainer is <NULL/>, it will be created internally, and passed to the caller.
118 : In this case, the caller also takes ownership of the control container, and is responsible for
119 : disposing it when not needed anymore.
120 : @return
121 : The requested control. This control is temporary only, and the caller is responsible for it.
122 : In particular, the caller is required to dispose it when it's not needed anymore.
123 :
124 : */
125 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >
126 : GetTemporaryControlForWindow(
127 : const vcl::Window& _rWindow,
128 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >& _inout_ControlContainer
129 : ) const;
130 :
131 : const OUString& GetUnoControlModelTypeName() const { return aUnoControlTypeName; }
132 287 : const OUString& GetUnoControlTypeName() const { return aUnoControlTypeName; }
133 :
134 : virtual void SetUnoControlModel( const ::com::sun::star::uno::Reference< com::sun::star::awt::XControlModel >& xModel );
135 :
136 : protected:
137 : // SdrObject overridables
138 : virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact() SAL_OVERRIDE;
139 :
140 : private:
141 : /** retrieves the typed ViewContact for the object
142 : @param _out_rpContact
143 : Upon successful return, ->_out_rpContact contains the ViewContact.
144 : @return
145 : <TRUE/> if and only if the contact was successfully retrieved. In this case,
146 : ->_out_rpContact contains a pointer to this contact.
147 : A failure to retrieve the contact object fires an assertion in non-product builds.
148 : */
149 : SVX_DLLPRIVATE bool impl_getViewContact( sdr::contact::ViewContactOfUnoControl*& _out_rpContact ) const;
150 : };
151 :
152 :
153 : #endif // INCLUDED_SVX_SVDOUNO_HXX
154 :
155 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|