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