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