1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: RptObject.hxx,v $
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>
51 typedef ::std::multimap
< sal_Int16
, ::rtl::OUString
, ::std::less
< sal_Int16
> > IndexToNameMap
;
55 RPTUI_HINT_WINDOWSCROLLED
,
56 RPTUI_HINT_LAYERCHANGED
,
57 RPTUI_HINT_OBJORDERCHANGED
,
58 RPTUI_HINT_SELECTIONCHANGED
62 class REPORTDESIGN_DLLPUBLIC DlgEdHint
: public SfxHint
65 DlgEdHintKind eHintKind
;
66 OUnoObject
* pDlgEdObj
;
68 DlgEdHint(DlgEdHint
&);
69 void operator =(DlgEdHint
&);
72 DlgEdHint( DlgEdHintKind eHint
);
75 inline DlgEdHintKind
GetKind() const { return eHintKind
; }
76 inline OUnoObject
* GetObject() const { return pDlgEdObj
; }
81 class OPropertyMediator
;
83 class REPORTDESIGN_DLLPUBLIC OObjectBase
86 typedef ::comphelper::ImplementationReference
<OPropertyMediator
,::com::sun::star::beans::XPropertyChangeListener
> TMediator
;
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
);
119 static void ensureSdrObjectOwnership(
120 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _rxShape
);
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 //============================================================================
146 //============================================================================
147 class REPORTDESIGN_DLLPUBLIC OCustomShape
: public SdrObjCustomShape
, public OObjectBase
149 friend class OReportPage
;
150 friend class DlgEdFactory
;
153 static OCustomShape
* Create( const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportComponent
>& _xComponent
)
155 return new OCustomShape( _xComponent
);
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
);
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 //============================================================================
188 //============================================================================
189 class REPORTDESIGN_DLLPUBLIC OOle2Obj
: public SdrOle2Obj
, public OObjectBase
191 friend class OReportPage
;
192 friend class DlgEdFactory
;
195 void impl_createDataProvider_nothrow( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& _xModel
);
197 static OOle2Obj
* Create( const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportComponent
>& _xComponent
,UINT16 _nType
)
199 return new OOle2Obj( _xComponent
,_nType
);
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;
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 //============================================================================
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
;
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;
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 //============================================================================
286 //============================================================================
287 #endif // _REPORT_RPTUIOBJ_HXX