xref: /aoo4110/main/svx/inc/svx/svdouno.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SVDOUNO_HXX
25 #define _SVDOUNO_HXX
26 
27 #include <com/sun/star/awt/XControlModel.hpp>
28 #include <com/sun/star/awt/XControl.hpp>
29 #ifndef _COM_SUN_STAR_AWT_XMULTISERVICEFACTORY_HPP_
30 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
31 #endif
32 #include <com/sun/star/awt/XControlContainer.hpp>
33 #include "svx/svxdllapi.h"
34 #include <svx/svdorect.hxx>
35 
36 //************************************************************
37 //   Vorausdeklarationen
38 //************************************************************
39 
40 class SdrView;
41 class SdrPageWindow;
42 class SdrControlEventListenerImpl;
43 
44 namespace sdr { namespace contact {
45     class ViewContactOfUnoControl;
46 }}
47 
48 //************************************************************
49 //   SdrUnoObj
50 //************************************************************
51 
52 struct SdrUnoObjDataHolder;
53 class SVX_DLLPUBLIC SdrUnoObj : public SdrRectObj
54 {
55 	friend class				SdrPageView;
56 	friend class				SdrControlEventListenerImpl;
57 
58     SdrUnoObjDataHolder*        m_pImpl;
59 
60 	String						aUnoControlModelTypeName;
61 	String						aUnoControlTypeName;
62 	sal_Bool						bOwnUnoControlModel;
63 
64 protected:
65 	::com::sun::star::uno::Reference< com::sun::star::awt::XControlModel > xUnoControlModel; // kann auch von aussen gesetzt werden
66 
67 private:
68 	SVX_DLLPRIVATE void CreateUnoControlModel(const String& rModelName);
69 	SVX_DLLPRIVATE void CreateUnoControlModel(const String& rModelName,
70 		const ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rxSFac );
71 
72 public:
73 	TYPEINFO();
74 
75 	SdrUnoObj(const String& rModelName, sal_Bool bOwnsModel = sal_True);
76 	SdrUnoObj(const String& rModelName,
77 		const ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rxSFac,
78 		sal_Bool bOwnsModel = sal_True);
79 	virtual ~SdrUnoObj();
80 
81 	virtual void SetPage(SdrPage* pNewPage);
82 	virtual void SetModel(SdrModel* pModel);
83 
84 	virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const;
85 	virtual sal_uInt16 GetObjIdentifier() const;
86 
87 	virtual void operator = (const SdrObject& rObj);
88 	virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
89     virtual void NbcSetLayer(SdrLayerID nLayer);
90 
91     // SpecialDrag support
92 	virtual bool hasSpecialDrag() const;
93 
94     // FullDrag support
95 	virtual bool supportsFullDrag() const;
96 	virtual SdrObject* getFullDragClone() const;
97 
98 	virtual void TakeObjNameSingul(XubString& rName) const;
99 	virtual void TakeObjNamePlural(XubString& rName) const;
100 
101     virtual void SetContextWritingMode( const sal_Int16 _nContextWritingMode );
102 
GetUnoControlModel() const103 	::com::sun::star::uno::Reference< com::sun::star::awt::XControlModel > GetUnoControlModel() const {return xUnoControlModel;}
104     ::com::sun::star::uno::Reference< com::sun::star::awt::XControl > GetUnoControl(const SdrView& _rView, const OutputDevice& _rOut) const;
105 
106     /** retrieves a temporary XControl instance for a given output device
107 
108         The method GetUnoControl, used to retrieve the XControl whose parent is a given device, only works
109         if the SdrUnoObj has already been painted at least once onto this device. However, there are valid
110         scenarios where you need certain information on how a control is painted onto a window, without
111         actually painting it. For example, you might be interested in the DeviceInfo of an UNO control.
112 
113         For those cases, you can ontain an XControl which behaves as the control which *would* be used to
114         paint onto a window.
115 
116         @param  _rWindow
117             the window for which should act as parent for the temporary control
118         @param  _inout_ControlContainer
119             the control container belonging to the window, necessary as context
120             for the newly created control. A control container is usually created by calling
121             VCLUnoHelper::CreateControlContainer.
122             If _inout_ControlContainer is <NULL/>, it will be created internally, and passed to the caller.
123             In this case, the caller also takes ownership of the control container, and is responsible for
124             disposing it when not needed anymore.
125         @return
126             The requested control. This control is temporary only, and the caller is responsible for it.
127             In particular, the caller is required to dispose it when it's not needed anymore.
128 
129     */
130     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >
131         GetTemporaryControlForWindow(
132             const Window& _rWindow,
133             ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >& _inout_ControlContainer
134         ) const;
135 
GetUnoControlModelTypeName() const136 	const String& GetUnoControlModelTypeName() const { return aUnoControlTypeName; }
GetUnoControlTypeName() const137 	const String& GetUnoControlTypeName() const { return aUnoControlTypeName; }
138 
139 	virtual void SetUnoControlModel( const ::com::sun::star::uno::Reference< com::sun::star::awt::XControlModel >& xModel );
140 
141 protected:
142     // SdrObject overridables
143     virtual ::sdr::contact::ViewContact* CreateObjectSpecificViewContact();
144 
145 private:
146     /** retrieves the typed ViewContact for the object
147         @param _out_rpContact
148             Upon successfull return, ->_out_rpContact contains the ViewContact.
149         @return
150             <TRUE/> if and only if the contact was successfully retrieved. In this case,
151             ->_out_rpContact contains a pointer to this contact.
152             A failure to retrieve the contact object fires an assertion in non-product builds.
153     */
154     SVX_DLLPRIVATE  bool    impl_getViewContact( ::sdr::contact::ViewContactOfUnoControl*& _out_rpContact ) const;
155 };
156 
157 
158 #endif          // _SVDOUNO_HXX
159 
160