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