xref: /aoo41x/main/reportdesign/inc/RptObject.hxx (revision 9ee13d13)
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 #ifndef _REPORT_RPTUIOBJ_HXX
24 #define _REPORT_RPTUIOBJ_HXX
25 
26 #include "dllapi.h"
27 #include <svx/svdoole2.hxx>
28 #include <svx/svdouno.hxx>
29 
30 
31 #include <comphelper/processfactory.hxx>
32 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
33 #include <com/sun/star/container/XContainerListener.hpp>
34 #include <com/sun/star/report/XReportComponent.hpp>
35 #include <com/sun/star/report/XSection.hpp>
36 #include <svx/svdocirc.hxx>
37 #include <svx/svdogrp.hxx>
38 #include <svx/svdoashp.hxx>
39 #include <comphelper/stl_types.hxx>
40 #include <comphelper/implementationreference.hxx>
41 
42 
43 namespace rptui
44 {
45 typedef ::std::multimap< sal_Int16, ::rtl::OUString, ::std::less< sal_Int16 > > IndexToNameMap;
46     enum DlgEdHintKind
47 	{
48 		RPTUI_HINT_UNKNOWN,
49 		RPTUI_HINT_WINDOWSCROLLED,
50 		RPTUI_HINT_LAYERCHANGED,
51 		RPTUI_HINT_OBJORDERCHANGED,
52 		RPTUI_HINT_SELECTIONCHANGED
53 	};
54 
55 	class OUnoObject;
56 	class REPORTDESIGN_DLLPUBLIC DlgEdHint: public SfxHint
57 	{
58 	private:
59 		DlgEdHintKind	eHintKind;
60 		OUnoObject*		pDlgEdObj;
61 
62         DlgEdHint(DlgEdHint&);
63         void operator =(DlgEdHint&);
64 	public:
65 		TYPEINFO();
66 		DlgEdHint( DlgEdHintKind eHint );
67 		virtual ~DlgEdHint();
68 
GetKind() const69 		inline DlgEdHintKind	GetKind() const	{ return eHintKind; }
GetObject() const70 		inline OUnoObject*		GetObject() const { return pDlgEdObj; }
71 	};
72 
73 
74 class OReportPage;
75 class OPropertyMediator;
76 
77 class REPORTDESIGN_DLLPUBLIC OObjectBase
78 {
79 public:
80     typedef ::comphelper::ImplementationReference<OPropertyMediator,::com::sun::star::beans::XPropertyChangeListener> TMediator;
81 
82 protected:
83     mutable TMediator                                                                           m_xMediator;
84 	mutable ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener> m_xPropertyChangeListener;
85 	//mutable ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener>
86 	mutable ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>		m_xReportComponent;
87 	::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener>	        m_xContainerListener;
88 	::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>				        m_xSection;
89     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >                       m_xKeepShapeAlive;
90 	::rtl::OUString m_sComponentName;
91 	sal_Bool		m_bIsListening;
92 
93 	OObjectBase(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent);
94 	OObjectBase(const ::rtl::OUString& _sComponentName);
95 
96 	virtual ~OObjectBase();
97 
isListening() const98 	inline sal_Bool	isListening() const { return m_bIsListening; }
99 
100 	void SetPropsFromRect(const Rectangle& _rRect);
101 
102 	virtual void SetSnapRectImpl(const Rectangle& _rRect) = 0;
103 	virtual SdrPage* GetImplPage() const = 0;
104     virtual void SetObjectItemHelper(const SfxPoolItem& rItem);
105 
106     /** called by instances of derived classes to implement their overloading of getUnoShape
107     */
108     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
109             getUnoShapeOf( SdrObject& _rSdrObject );
110 
111 private:
112     static void    ensureSdrObjectOwnership(
113                     const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxShape );
114 
115 public:
116 	void StartListening();
117 	void EndListening(sal_Bool bRemoveListener = sal_True);
118 	// PropertyChangeListener
119 	virtual void _propertyChange( const  ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException);
initializeOle()120     virtual void initializeOle() {}
121 
122 	sal_Bool		supportsService( const ::rtl::OUString& _sServiceName ) const;
123 
124 	::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent> getReportComponent() const;
125     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getAwtComponent();
setOldParent(const::com::sun::star::uno::Reference<::com::sun::star::report::XSection> & _xSection)126 	inline void setOldParent(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection) { m_xSection = _xSection; }
getOldParent() const127 	inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection> getOldParent() const { return m_xSection;}
128     ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection> getSection() const;
getServiceName() const129     inline const ::rtl::OUString getServiceName() const { return m_sComponentName; }
130 
131     /** releases the reference to our UNO shape (m_xKeepShapeAlive)
132     */
releaseUnoShape()133     void    releaseUnoShape() { m_xKeepShapeAlive.clear(); }
134 
135     static SdrObject* createObject(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent);
136     static sal_uInt16 getObjectType(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent);
137 };
138 //============================================================================
139 // OCustomShape
140 //============================================================================
141 class REPORTDESIGN_DLLPUBLIC OCustomShape: public SdrObjCustomShape , public OObjectBase
142 {
143 	friend class OReportPage;
144     friend class DlgEdFactory;
145 
146 public:
Create(const::com::sun::star::uno::Reference<::com::sun::star::report::XReportComponent> & _xComponent)147     static OCustomShape* Create( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent )
148     {
149         return new OCustomShape( _xComponent );
150     }
151 
152 protected:
153 	OCustomShape(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent);
154 	OCustomShape(const ::rtl::OUString& _sComponentName);
155 
156 	virtual void NbcMove( const Size& rSize );
157 	virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
158     virtual void NbcSetLogicRect(const Rectangle& rRect);
159 	virtual FASTBOOL EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd);
160 
161 	virtual void SetSnapRectImpl(const Rectangle& _rRect);
162 	virtual SdrPage* GetImplPage() const;
163     void SetObjectItemHelper(const SfxPoolItem& rItem);
164 
165 public:
166 	TYPEINFO();
167 
168 	virtual ~OCustomShape();
169 
170 	virtual sal_Int32	GetStep() const;
171     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getAwtComponent();
172 
173     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getUnoShape();
174     virtual sal_uInt16 GetObjIdentifier() const;
175     virtual sal_uInt32 GetObjInventor() const;
176 };
177 
178 //============================================================================
179 // OOle2Obj
180 //============================================================================
181 class REPORTDESIGN_DLLPUBLIC OOle2Obj: public SdrOle2Obj , public OObjectBase
182 {
183 	friend class OReportPage;
184     friend class DlgEdFactory;
185 
186     sal_uInt16 m_nType;
187     bool    m_bOnlyOnce;
188     void impl_createDataProvider_nothrow( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel>& _xModel);
189 public:
Create(const::com::sun::star::uno::Reference<::com::sun::star::report::XReportComponent> & _xComponent,sal_uInt16 _nType)190     static OOle2Obj* Create( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent,sal_uInt16 _nType )
191     {
192         return new OOle2Obj( _xComponent,_nType );
193     }
194 protected:
195 	OOle2Obj(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent,sal_uInt16 _nType);
196 	OOle2Obj(const ::rtl::OUString& _sComponentName,sal_uInt16 _nType);
197 
198 
199 	virtual void NbcMove( const Size& rSize );
200 	virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
201     virtual void NbcSetLogicRect(const Rectangle& rRect);
202 	virtual FASTBOOL EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd);
203 
204 	virtual void SetSnapRectImpl(const Rectangle& _rRect);
205 	virtual SdrPage* GetImplPage() const;
206 
207 public:
208 	TYPEINFO();
209 
210 	virtual ~OOle2Obj();
211 
212 	virtual sal_Int32	GetStep() const;
213     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getAwtComponent();
214 
215     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getUnoShape();
216     virtual sal_uInt16 GetObjIdentifier() const;
217     virtual sal_uInt32 GetObjInventor() const;
218     // Clone() soll eine komplette Kopie des Objektes erzeugen.
219 	virtual SdrObject* Clone() const;
220     virtual void initializeOle();
221 
222     void initializeChart( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel>& _xModel);
223 };
224 
225 //============================================================================
226 // OUnoObject
227 //============================================================================
228 class REPORTDESIGN_DLLPUBLIC OUnoObject: public SdrUnoObj , public OObjectBase
229 {
230 	friend class OReportPage;
231 	friend class OObjectBase;
232     friend class DlgEdFactory;
233 
234     sal_uInt16   m_nObjectType;
235 protected:
236 	OUnoObject(const ::rtl::OUString& _sComponentName
237 				,const ::rtl::OUString& rModelName
238                 ,sal_uInt16   _nObjectType);
239     OUnoObject(	 const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent
240                 ,const ::rtl::OUString& rModelName
241                 ,sal_uInt16   _nObjectType);
242 
243 	virtual ~OUnoObject();
244 
245 	virtual void NbcMove( const Size& rSize );
246 	virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
247     virtual void NbcSetLogicRect(const Rectangle& rRect);
248 	virtual FASTBOOL EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd);
249 
250 	virtual void SetSnapRectImpl(const Rectangle& _rRect);
251 	virtual SdrPage* GetImplPage() const;
252 
253 public:
254 	TYPEINFO();
255 
256 	virtual sal_Int32	GetStep() const;
257     virtual void _propertyChange( const  ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException);
258 
259 	/** creates the m_xMediator when it doesn't already exist.
260 		@param	_bReverse	when set to <TRUE/> then the properties from the uno control will be copied into report control
261 	*/
262 	void CreateMediator(sal_Bool _bReverse = sal_False);
263 
264     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getAwtComponent();
265 
266     static ::rtl::OUString GetDefaultName(const OUnoObject* _pObj);
267 
268     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getUnoShape();
269     virtual sal_uInt16 GetObjIdentifier() const;
270     virtual sal_uInt32 GetObjInventor() const;
271     virtual SdrObject* Clone() const;
272 
273 private:
274     void    impl_setReportComponent_nothrow();
275     void    impl_initializeModel_nothrow();
276 };
277 
278 //============================================================================
279 } // rptui
280 //============================================================================
281 #endif // _REPORT_RPTUIOBJ_HXX
282 
283