1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef _REPORT_RPTUIOBJ_HXX
20 #define _REPORT_RPTUIOBJ_HXX
23 #include <svx/svdoole2.hxx>
24 #include <svx/svdouno.hxx>
27 #include <comphelper/processfactory.hxx>
28 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
29 #include <com/sun/star/container/XContainerListener.hpp>
30 #include <com/sun/star/report/XReportComponent.hpp>
31 #include <com/sun/star/report/XSection.hpp>
32 #include <svx/svdocirc.hxx>
33 #include <svx/svdogrp.hxx>
34 #include <svx/svdoashp.hxx>
35 #include <comphelper/stl_types.hxx>
36 #include <comphelper/implementationreference.hxx>
41 typedef ::std::multimap
< sal_Int16
, OUString
, ::std::less
< sal_Int16
> > IndexToNameMap
;
45 RPTUI_HINT_WINDOWSCROLLED
,
46 RPTUI_HINT_LAYERCHANGED
,
47 RPTUI_HINT_OBJORDERCHANGED
,
48 RPTUI_HINT_SELECTIONCHANGED
52 class REPORTDESIGN_DLLPUBLIC DlgEdHint
: public SfxHint
55 DlgEdHintKind eHintKind
;
56 OUnoObject
* pDlgEdObj
;
58 DlgEdHint(DlgEdHint
&);
59 void operator =(DlgEdHint
&);
62 DlgEdHint( DlgEdHintKind eHint
);
65 inline DlgEdHintKind
GetKind() const { return eHintKind
; }
66 inline OUnoObject
* GetObject() const { return pDlgEdObj
; }
71 class OPropertyMediator
;
73 class REPORTDESIGN_DLLPUBLIC OObjectBase
76 typedef ::comphelper::ImplementationReference
<OPropertyMediator
,::com::sun::star::beans::XPropertyChangeListener
> TMediator
;
79 mutable TMediator m_xMediator
;
80 mutable ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyChangeListener
> m_xPropertyChangeListener
;
81 //mutable ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener>
82 mutable ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportComponent
> m_xReportComponent
;
83 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XContainerListener
> m_xContainerListener
;
84 ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
> m_xSection
;
85 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> m_xKeepShapeAlive
;
86 OUString m_sComponentName
;
87 sal_Bool m_bIsListening
;
89 OObjectBase(const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportComponent
>& _xComponent
);
90 OObjectBase(const OUString
& _sComponentName
);
92 virtual ~OObjectBase();
94 inline sal_Bool
isListening() const { return m_bIsListening
; }
96 void SetPropsFromRect(const Rectangle
& _rRect
);
98 virtual void SetSnapRectImpl(const Rectangle
& _rRect
) = 0;
99 virtual SdrPage
* GetImplPage() const = 0;
100 virtual void SetObjectItemHelper(const SfxPoolItem
& rItem
);
102 /** called by instances of derived classes to implement their overloading of getUnoShape
104 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>
105 getUnoShapeOf( SdrObject
& _rSdrObject
);
108 static void ensureSdrObjectOwnership(
109 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _rxShape
);
112 void StartListening();
113 void EndListening(sal_Bool bRemoveListener
= sal_True
);
114 // PropertyChangeListener
115 virtual void _propertyChange( const ::com::sun::star::beans::PropertyChangeEvent
& evt
) throw(::com::sun::star::uno::RuntimeException
);
116 virtual void initializeOle() {}
118 sal_Bool
supportsService( const OUString
& _sServiceName
) const;
120 ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportComponent
> getReportComponent() const;
121 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> getAwtComponent();
122 inline void setOldParent(const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
>& _xSection
) { m_xSection
= _xSection
; }
123 inline ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
> getOldParent() const { return m_xSection
;}
124 ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
> getSection() const;
125 inline const OUString
getServiceName() const { return m_sComponentName
; }
127 /** releases the reference to our UNO shape (m_xKeepShapeAlive)
129 void releaseUnoShape() { m_xKeepShapeAlive
.clear(); }
131 static SdrObject
* createObject(const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportComponent
>& _xComponent
);
132 static sal_uInt16
getObjectType(const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportComponent
>& _xComponent
);
134 //============================================================================
136 //============================================================================
137 class REPORTDESIGN_DLLPUBLIC OCustomShape
: public SdrObjCustomShape
, public OObjectBase
139 friend class OReportPage
;
140 friend class DlgEdFactory
;
143 static OCustomShape
* Create( const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportComponent
>& _xComponent
)
145 return new OCustomShape( _xComponent
);
149 OCustomShape(const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportComponent
>& _xComponent
);
150 OCustomShape(const OUString
& _sComponentName
);
152 virtual void NbcMove( const Size
& rSize
);
153 virtual void NbcResize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
);
154 virtual void NbcSetLogicRect(const Rectangle
& rRect
);
155 virtual bool EndCreate(SdrDragStat
& rStat
, SdrCreateCmd eCmd
);
157 virtual void SetSnapRectImpl(const Rectangle
& _rRect
);
158 virtual SdrPage
* GetImplPage() const;
159 void SetObjectItemHelper(const SfxPoolItem
& rItem
);
164 virtual ~OCustomShape();
166 virtual sal_Int32
GetStep() const;
167 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> getAwtComponent();
169 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> getUnoShape();
170 virtual sal_uInt16
GetObjIdentifier() const;
171 virtual sal_uInt32
GetObjInventor() const;
174 virtual void impl_setUnoShape( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& rxUnoShape
);
177 //============================================================================
179 //============================================================================
180 class REPORTDESIGN_DLLPUBLIC OOle2Obj
: public SdrOle2Obj
, public OObjectBase
182 friend class OReportPage
;
183 friend class DlgEdFactory
;
187 void impl_createDataProvider_nothrow( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& _xModel
);
188 virtual void impl_setUnoShape( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& rxUnoShape
);
191 static OOle2Obj
* Create( const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportComponent
>& _xComponent
,sal_uInt16 _nType
)
193 return new OOle2Obj( _xComponent
,_nType
);
196 OOle2Obj(const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportComponent
>& _xComponent
,sal_uInt16 _nType
);
197 OOle2Obj(const OUString
& _sComponentName
,sal_uInt16 _nType
);
200 virtual void NbcMove( const Size
& rSize
);
201 virtual void NbcResize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
);
202 virtual void NbcSetLogicRect(const Rectangle
& rRect
);
203 virtual bool EndCreate(SdrDragStat
& rStat
, SdrCreateCmd eCmd
);
205 virtual void SetSnapRectImpl(const Rectangle
& _rRect
);
206 virtual SdrPage
* GetImplPage() const;
213 virtual sal_Int32
GetStep() const;
214 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> getAwtComponent();
216 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> getUnoShape();
217 virtual sal_uInt16
GetObjIdentifier() const;
218 virtual sal_uInt32
GetObjInventor() const;
219 // Clone() soll eine komplette Kopie des Objektes erzeugen.
220 virtual OOle2Obj
* Clone() const;
221 virtual void initializeOle();
223 OOle2Obj
& operator=(const OOle2Obj
& rObj
);
225 void initializeChart( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& _xModel
);
228 //============================================================================
230 //============================================================================
231 class REPORTDESIGN_DLLPUBLIC OUnoObject
: public SdrUnoObj
, public OObjectBase
233 friend class OReportPage
;
234 friend class OObjectBase
;
235 friend class DlgEdFactory
;
237 sal_uInt16 m_nObjectType
;
239 OUnoObject(const OUString
& _sComponentName
240 ,const OUString
& rModelName
241 ,sal_uInt16 _nObjectType
);
242 OUnoObject( const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportComponent
>& _xComponent
243 ,const OUString
& rModelName
244 ,sal_uInt16 _nObjectType
);
246 virtual ~OUnoObject();
248 virtual void NbcMove( const Size
& rSize
);
249 virtual void NbcResize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
);
250 virtual void NbcSetLogicRect(const Rectangle
& rRect
);
251 virtual bool EndCreate(SdrDragStat
& rStat
, SdrCreateCmd eCmd
);
253 virtual void SetSnapRectImpl(const Rectangle
& _rRect
);
254 virtual SdrPage
* GetImplPage() const;
259 virtual sal_Int32
GetStep() const;
260 virtual void _propertyChange( const ::com::sun::star::beans::PropertyChangeEvent
& evt
) throw(::com::sun::star::uno::RuntimeException
);
262 /** creates the m_xMediator when it doesn't already exist.
263 @param _bReverse when set to <TRUE/> then the properties from the uno control will be copied into report control
265 void CreateMediator(sal_Bool _bReverse
= sal_False
);
267 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> getAwtComponent();
269 static OUString
GetDefaultName(const OUnoObject
* _pObj
);
271 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> getUnoShape();
272 virtual sal_uInt16
GetObjIdentifier() const;
273 virtual sal_uInt32
GetObjInventor() const;
274 virtual OUnoObject
* Clone() const;
276 OUnoObject
& operator=(const OUnoObject
& rObj
);
279 virtual void impl_setUnoShape( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& rxUnoShape
);
280 void impl_setReportComponent_nothrow();
281 void impl_initializeModel_nothrow();
284 //============================================================================
286 //============================================================================
287 #endif // _REPORT_RPTUIOBJ_HXX
289 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */