xref: /aoo42x/main/reportdesign/inc/RptObject.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _REPORT_RPTUIOBJ_HXX
28 #define _REPORT_RPTUIOBJ_HXX
29 
30 #include "dllapi.h"
31 #include <svx/svdoole2.hxx>
32 #include <svx/svdouno.hxx>
33 
34 
35 #include <comphelper/processfactory.hxx>
36 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
37 #include <com/sun/star/container/XContainerListener.hpp>
38 #include <com/sun/star/report/XReportComponent.hpp>
39 #include <com/sun/star/report/XSection.hpp>
40 #include <svx/svdocirc.hxx>
41 #include <svx/svdogrp.hxx>
42 #include <svx/svdoashp.hxx>
43 #include <comphelper/stl_types.hxx>
44 #include <comphelper/implementationreference.hxx>
45 
46 
47 namespace rptui
48 {
49 typedef ::std::multimap< sal_Int16, ::rtl::OUString, ::std::less< sal_Int16 > > IndexToNameMap;
50     enum DlgEdHintKind
51 	{
52 		RPTUI_HINT_UNKNOWN,
53 		RPTUI_HINT_WINDOWSCROLLED,
54 		RPTUI_HINT_LAYERCHANGED,
55 		RPTUI_HINT_OBJORDERCHANGED,
56 		RPTUI_HINT_SELECTIONCHANGED
57 	};
58 
59 	class OUnoObject;
60 	class REPORTDESIGN_DLLPUBLIC DlgEdHint: public SfxHint
61 	{
62 	private:
63 		DlgEdHintKind	eHintKind;
64 		OUnoObject*		pDlgEdObj;
65 
66         DlgEdHint(DlgEdHint&);
67         void operator =(DlgEdHint&);
68 	public:
69 		TYPEINFO();
70 		DlgEdHint( DlgEdHintKind eHint );
71 		virtual ~DlgEdHint();
72 
73 		inline DlgEdHintKind	GetKind() const	{ return eHintKind; }
74 		inline OUnoObject*		GetObject() const { return pDlgEdObj; }
75 	};
76 
77 
78 class OReportPage;
79 class OPropertyMediator;
80 
81 class REPORTDESIGN_DLLPUBLIC OObjectBase
82 {
83 public:
84     typedef ::comphelper::ImplementationReference<OPropertyMediator,::com::sun::star::beans::XPropertyChangeListener> TMediator;
85 
86 protected:
87     mutable TMediator                                                                           m_xMediator;
88 	mutable ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener> m_xPropertyChangeListener;
89 	//mutable ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener>
90 	mutable ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>		m_xReportComponent;
91 	::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener>	        m_xContainerListener;
92 	::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>				        m_xSection;
93     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >                       m_xKeepShapeAlive;
94 	::rtl::OUString m_sComponentName;
95 	sal_Bool		m_bIsListening;
96 
97 	OObjectBase(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent);
98 	OObjectBase(const ::rtl::OUString& _sComponentName);
99 
100 	virtual ~OObjectBase();
101 
102 	inline sal_Bool	isListening() const { return m_bIsListening; }
103 
104 	void SetPropsFromRect(const Rectangle& _rRect);
105 
106 	virtual void SetSnapRectImpl(const Rectangle& _rRect) = 0;
107 	virtual SdrPage* GetImplPage() const = 0;
108     virtual void SetObjectItemHelper(const SfxPoolItem& rItem);
109 
110     /** called by instances of derived classes to implement their overloading of getUnoShape
111     */
112     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
113             getUnoShapeOf( SdrObject& _rSdrObject );
114 
115 private:
116     static void    ensureSdrObjectOwnership(
117                     const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxShape );
118 
119 public:
120 	void StartListening();
121 	void EndListening(sal_Bool bRemoveListener = sal_True);
122 	// PropertyChangeListener
123 	virtual void _propertyChange( const  ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException);
124     virtual void initializeOle() {}
125 
126 	sal_Bool		supportsService( const ::rtl::OUString& _sServiceName ) const;
127 
128 	::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent> getReportComponent() const;
129     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getAwtComponent();
130 	inline void setOldParent(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection) { m_xSection = _xSection; }
131 	inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection> getOldParent() const { return m_xSection;}
132     ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection> getSection() const;
133     inline const ::rtl::OUString getServiceName() const { return m_sComponentName; }
134 
135     /** releases the reference to our UNO shape (m_xKeepShapeAlive)
136     */
137     void    releaseUnoShape() { m_xKeepShapeAlive.clear(); }
138 
139     static SdrObject* createObject(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent);
140     static sal_uInt16 getObjectType(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent);
141 };
142 //============================================================================
143 // OCustomShape
144 //============================================================================
145 class REPORTDESIGN_DLLPUBLIC OCustomShape: public SdrObjCustomShape , public OObjectBase
146 {
147 	friend class OReportPage;
148     friend class DlgEdFactory;
149 
150 public:
151     static OCustomShape* Create( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent )
152     {
153         return new OCustomShape( _xComponent );
154     }
155 
156 protected:
157 	OCustomShape(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent);
158 	OCustomShape(const ::rtl::OUString& _sComponentName);
159 
160 	virtual void NbcMove( const Size& rSize );
161 	virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
162     virtual void NbcSetLogicRect(const Rectangle& rRect);
163 	virtual FASTBOOL EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd);
164 
165 	virtual void SetSnapRectImpl(const Rectangle& _rRect);
166 	virtual SdrPage* GetImplPage() const;
167     void SetObjectItemHelper(const SfxPoolItem& rItem);
168 
169 public:
170 	TYPEINFO();
171 
172 	virtual ~OCustomShape();
173 
174 	virtual sal_Int32	GetStep() const;
175     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getAwtComponent();
176 
177     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getUnoShape();
178     virtual sal_uInt16 GetObjIdentifier() const;
179     virtual sal_uInt32 GetObjInventor() const;
180 };
181 
182 //============================================================================
183 // OOle2Obj
184 //============================================================================
185 class REPORTDESIGN_DLLPUBLIC OOle2Obj: public SdrOle2Obj , public OObjectBase
186 {
187 	friend class OReportPage;
188     friend class DlgEdFactory;
189 
190     sal_uInt16 m_nType;
191     bool    m_bOnlyOnce;
192     void impl_createDataProvider_nothrow( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel>& _xModel);
193 public:
194     static OOle2Obj* Create( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent,sal_uInt16 _nType )
195     {
196         return new OOle2Obj( _xComponent,_nType );
197     }
198 protected:
199 	OOle2Obj(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent,sal_uInt16 _nType);
200 	OOle2Obj(const ::rtl::OUString& _sComponentName,sal_uInt16 _nType);
201 
202 
203 	virtual void NbcMove( const Size& rSize );
204 	virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
205     virtual void NbcSetLogicRect(const Rectangle& rRect);
206 	virtual FASTBOOL EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd);
207 
208 	virtual void SetSnapRectImpl(const Rectangle& _rRect);
209 	virtual SdrPage* GetImplPage() const;
210 
211 public:
212 	TYPEINFO();
213 
214 	virtual ~OOle2Obj();
215 
216 	virtual sal_Int32	GetStep() const;
217     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getAwtComponent();
218 
219     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getUnoShape();
220     virtual sal_uInt16 GetObjIdentifier() const;
221     virtual sal_uInt32 GetObjInventor() const;
222     // Clone() soll eine komplette Kopie des Objektes erzeugen.
223 	virtual SdrObject* Clone() const;
224     virtual void initializeOle();
225 
226     void initializeChart( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel>& _xModel);
227 };
228 
229 //============================================================================
230 // OUnoObject
231 //============================================================================
232 class REPORTDESIGN_DLLPUBLIC OUnoObject: public SdrUnoObj , public OObjectBase
233 {
234 	friend class OReportPage;
235 	friend class OObjectBase;
236     friend class DlgEdFactory;
237 
238     sal_uInt16   m_nObjectType;
239 protected:
240 	OUnoObject(const ::rtl::OUString& _sComponentName
241 				,const ::rtl::OUString& rModelName
242                 ,sal_uInt16   _nObjectType);
243     OUnoObject(	 const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent
244                 ,const ::rtl::OUString& rModelName
245                 ,sal_uInt16   _nObjectType);
246 
247 	virtual ~OUnoObject();
248 
249 	virtual void NbcMove( const Size& rSize );
250 	virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
251     virtual void NbcSetLogicRect(const Rectangle& rRect);
252 	virtual FASTBOOL EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd);
253 
254 	virtual void SetSnapRectImpl(const Rectangle& _rRect);
255 	virtual SdrPage* GetImplPage() const;
256 
257 public:
258 	TYPEINFO();
259 
260 	virtual sal_Int32	GetStep() const;
261     virtual void _propertyChange( const  ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException);
262 
263 	/** creates the m_xMediator when it doesn't already exist.
264 		@param	_bReverse	when set to <TRUE/> then the properties from the uno control will be copied into report control
265 	*/
266 	void CreateMediator(sal_Bool _bReverse = sal_False);
267 
268     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getAwtComponent();
269 
270     static ::rtl::OUString GetDefaultName(const OUnoObject* _pObj);
271 
272     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getUnoShape();
273     virtual sal_uInt16 GetObjIdentifier() const;
274     virtual sal_uInt32 GetObjInventor() const;
275     virtual SdrObject* Clone() const;
276 
277 private:
278     void    impl_setReportComponent_nothrow();
279     void    impl_initializeModel_nothrow();
280 };
281 
282 //============================================================================
283 } // rptui
284 //============================================================================
285 #endif // _REPORT_RPTUIOBJ_HXX
286 
287