sync master with lastest vba changes
[ooovba.git] / reportdesign / inc / RptObject.hxx
blob73e4bd2d7a36e1d033d05ec64e6bb327d2e81d35
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 <svx/svdoole2.hxx>
34 #include <svx/svdouno.hxx>
37 #include <comphelper/processfactory.hxx>
38 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
39 #include <com/sun/star/container/XContainerListener.hpp>
40 #include <com/sun/star/report/XReportComponent.hpp>
41 #include <com/sun/star/report/XSection.hpp>
42 #include <svx/svdocirc.hxx>
43 #include <svx/svdogrp.hxx>
44 #include <svx/svdoashp.hxx>
45 #include <comphelper/stl_types.hxx>
46 #include <comphelper/implementationreference.hxx>
47 #include "dllapi.h"
49 namespace rptui
51 typedef ::std::multimap< sal_Int16, ::rtl::OUString, ::std::less< sal_Int16 > > IndexToNameMap;
52 enum DlgEdHintKind
54 RPTUI_HINT_UNKNOWN,
55 RPTUI_HINT_WINDOWSCROLLED,
56 RPTUI_HINT_LAYERCHANGED,
57 RPTUI_HINT_OBJORDERCHANGED,
58 RPTUI_HINT_SELECTIONCHANGED
61 class OUnoObject;
62 class REPORTDESIGN_DLLPUBLIC DlgEdHint: public SfxHint
64 private:
65 DlgEdHintKind eHintKind;
66 OUnoObject* pDlgEdObj;
68 DlgEdHint(DlgEdHint&);
69 void operator =(DlgEdHint&);
70 public:
71 TYPEINFO();
72 DlgEdHint( DlgEdHintKind eHint );
73 virtual ~DlgEdHint();
75 inline DlgEdHintKind GetKind() const { return eHintKind; }
76 inline OUnoObject* GetObject() const { return pDlgEdObj; }
80 class OReportPage;
81 class OPropertyMediator;
83 class REPORTDESIGN_DLLPUBLIC OObjectBase
85 public:
86 typedef ::comphelper::ImplementationReference<OPropertyMediator,::com::sun::star::beans::XPropertyChangeListener> TMediator;
88 protected:
89 mutable TMediator m_xMediator;
90 mutable ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener> m_xPropertyChangeListener;
91 //mutable ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener>
92 mutable ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent> m_xReportComponent;
93 ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener> m_xContainerListener;
94 ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection> m_xSection;
95 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xKeepShapeAlive;
96 ::rtl::OUString m_sComponentName;
97 sal_Bool m_bIsListening;
99 OObjectBase(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent);
100 OObjectBase(const ::rtl::OUString& _sComponentName);
102 virtual ~OObjectBase();
104 inline sal_Bool isListening() const { return m_bIsListening; }
106 void SetPropsFromRect(const Rectangle& _rRect);
108 virtual void SetSnapRectImpl(const Rectangle& _rRect) = 0;
109 virtual SdrPage* GetImplPage() const = 0;
110 virtual void SetObjectItemHelper(const SfxPoolItem& rItem);
111 sal_Bool IsInside(const Rectangle& _rRect,const Point& rPnt,USHORT nTol) const;
113 /** called by instances of derived classes to implement their overloading of getUnoShape
115 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
116 getUnoShapeOf( SdrObject& _rSdrObject );
118 private:
119 static void ensureSdrObjectOwnership(
120 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxShape );
122 public:
123 void StartListening();
124 void EndListening(sal_Bool bRemoveListener = sal_True);
125 // PropertyChangeListener
126 virtual void _propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException);
128 sal_Bool supportsService( const ::rtl::OUString& _sServiceName ) const;
130 ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent> getReportComponent() const;
131 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getAwtComponent();
132 inline void setOldParent(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection) { m_xSection = _xSection; }
133 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection> getOldParent() const { return m_xSection;}
134 ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection> getSection() const;
135 inline const ::rtl::OUString getServiceName() const { return m_sComponentName; }
137 /** releases the reference to our UNO shape (m_xKeepShapeAlive)
139 void releaseUnoShape() { m_xKeepShapeAlive.clear(); }
141 static SdrObject* createObject(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent);
142 static sal_uInt16 getObjectType(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent);
144 //============================================================================
145 // OCustomShape
146 //============================================================================
147 class REPORTDESIGN_DLLPUBLIC OCustomShape: public SdrObjCustomShape , public OObjectBase
149 friend class OReportPage;
150 friend class DlgEdFactory;
152 public:
153 static OCustomShape* Create( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent )
155 return new OCustomShape( _xComponent );
158 protected:
159 OCustomShape(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent);
160 OCustomShape(const ::rtl::OUString& _sComponentName);
162 virtual void NbcMove( const Size& rSize );
163 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
164 virtual void NbcSetLogicRect(const Rectangle& rRect);
165 virtual FASTBOOL EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd);
167 virtual void SetSnapRectImpl(const Rectangle& _rRect);
168 virtual SdrPage* GetImplPage() const;
169 void SetObjectItemHelper(const SfxPoolItem& rItem);
171 public:
172 TYPEINFO();
174 virtual ~OCustomShape();
176 virtual sal_Int32 GetStep() const;
178 virtual SdrObject* CheckHit(const Point& rPnt,USHORT nTol,const SetOfByte*) 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 void impl_createDataProvider_nothrow( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel>& _xModel);
196 public:
197 static OOle2Obj* Create( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent,UINT16 _nType )
199 return new OOle2Obj( _xComponent,_nType );
201 protected:
202 OOle2Obj(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent,UINT16 _nType);
203 OOle2Obj(const ::rtl::OUString& _sComponentName,UINT16 _nType);
206 virtual void NbcMove( const Size& rSize );
207 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
208 virtual void NbcSetLogicRect(const Rectangle& rRect);
209 virtual FASTBOOL EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd);
211 virtual void SetSnapRectImpl(const Rectangle& _rRect);
212 virtual SdrPage* GetImplPage() const;
214 public:
215 TYPEINFO();
217 virtual ~OOle2Obj();
219 virtual sal_Int32 GetStep() const;
221 virtual SdrObject* CheckHit(const Point& rPnt,USHORT nTol,const SetOfByte*) const;
222 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getAwtComponent();
224 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getUnoShape();
225 virtual UINT16 GetObjIdentifier() const;
226 virtual UINT32 GetObjInventor() const;
227 // Clone() soll eine komplette Kopie des Objektes erzeugen.
228 virtual SdrObject* Clone() const;
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;
266 virtual SdrObject* CheckHit(const Point& rPnt,USHORT nTol,const SetOfByte*) const;
267 virtual void _propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException);
269 /** creates the m_xMediator when it doesn't already exist.
270 @param _bReverse when set to <TRUE/> then the properties from the uno control will be copied into report control
272 void CreateMediator(sal_Bool _bReverse = sal_False);
274 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getAwtComponent();
276 static ::rtl::OUString GetDefaultName(const OUnoObject* _pObj);
278 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getUnoShape();
279 virtual UINT16 GetObjIdentifier() const;
280 virtual UINT32 GetObjInventor() const;
281 virtual SdrObject* Clone() const;
284 //============================================================================
285 } // rptui
286 //============================================================================
287 #endif // _REPORT_RPTUIOBJ_HXX