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 INCLUDED_REPORTDESIGN_INC_RPTOBJECT_HXX
20 #define INCLUDED_REPORTDESIGN_INC_RPTOBJECT_HXX
24 #include <boost/noncopyable.hpp>
25 #include <svx/svdoole2.hxx>
26 #include <svx/svdouno.hxx>
29 #include <comphelper/processfactory.hxx>
30 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
31 #include <com/sun/star/container/XContainerListener.hpp>
32 #include <com/sun/star/report/XReportComponent.hpp>
33 #include <com/sun/star/report/XSection.hpp>
34 #include <svx/svdocirc.hxx>
35 #include <svx/svdogrp.hxx>
36 #include <svx/svdoashp.hxx>
40 typedef ::std::multimap
< sal_Int16
, OUString
, ::std::less
< sal_Int16
> > IndexToNameMap
;
44 RPTUI_HINT_WINDOWSCROLLED
,
45 RPTUI_HINT_LAYERCHANGED
,
46 RPTUI_HINT_OBJORDERCHANGED
,
47 RPTUI_HINT_SELECTIONCHANGED
51 class REPORTDESIGN_DLLPUBLIC DlgEdHint
: public SfxHint
54 DlgEdHintKind eHintKind
;
55 OUnoObject
* pDlgEdObj
;
57 DlgEdHint(DlgEdHint
&) SAL_DELETED_FUNCTION
;
58 void operator =(DlgEdHint
&) SAL_DELETED_FUNCTION
;
60 DlgEdHint( DlgEdHintKind eHint
);
63 inline DlgEdHintKind
GetKind() const { return eHintKind
; }
64 inline OUnoObject
* GetObject() const { return pDlgEdObj
; }
69 class OPropertyMediator
;
71 class REPORTDESIGN_DLLPUBLIC OObjectBase
: private boost::noncopyable
74 typedef rtl::Reference
<OPropertyMediator
> TMediator
;
77 mutable TMediator m_xMediator
;
78 mutable ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertyChangeListener
> m_xPropertyChangeListener
;
79 //mutable ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener>
80 mutable ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportComponent
> m_xReportComponent
;
81 ::com::sun::star::uno::Reference
< ::com::sun::star::container::XContainerListener
> m_xContainerListener
;
82 ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
> m_xSection
;
83 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> m_xKeepShapeAlive
;
84 OUString m_sComponentName
;
87 OObjectBase(const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportComponent
>& _xComponent
);
88 OObjectBase(const OUString
& _sComponentName
);
90 virtual ~OObjectBase();
92 inline bool isListening() const { return m_bIsListening
; }
94 void SetPropsFromRect(const Rectangle
& _rRect
);
96 virtual void SetSnapRectImpl(const Rectangle
& _rRect
) = 0;
97 virtual SdrPage
* GetImplPage() const = 0;
98 virtual void SetObjectItemHelper(const SfxPoolItem
& rItem
);
100 /** called by instances of derived classes to implement their overriding of getUnoShape
102 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>
103 getUnoShapeOf( SdrObject
& _rSdrObject
);
106 static void ensureSdrObjectOwnership(
107 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& _rxShape
);
110 void StartListening();
111 void EndListening(bool bRemoveListener
= true);
112 // PropertyChangeListener
113 virtual void _propertyChange( const ::com::sun::star::beans::PropertyChangeEvent
& evt
) throw(::com::sun::star::uno::RuntimeException
);
114 virtual void initializeOle() {}
116 bool supportsService( const OUString
& _sServiceName
) const;
118 ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportComponent
> getReportComponent() const { return m_xReportComponent
;}
119 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> getAwtComponent();
120 inline void setOldParent(const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
>& _xSection
) { m_xSection
= _xSection
; }
121 inline ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
> getOldParent() const { return m_xSection
;}
122 ::com::sun::star::uno::Reference
< ::com::sun::star::report::XSection
> getSection() const;
123 inline const OUString
getServiceName() const { return m_sComponentName
; }
125 /** releases the reference to our UNO shape (m_xKeepShapeAlive)
127 void releaseUnoShape() { m_xKeepShapeAlive
.clear(); }
129 static SdrObject
* createObject(const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportComponent
>& _xComponent
);
130 static sal_uInt16
getObjectType(const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportComponent
>& _xComponent
);
135 class REPORTDESIGN_DLLPUBLIC OCustomShape
: public SdrObjCustomShape
, public OObjectBase
137 friend class OReportPage
;
138 friend class DlgEdFactory
;
141 static OCustomShape
* Create( const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportComponent
>& _xComponent
)
143 return new OCustomShape( _xComponent
);
147 OCustomShape(const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportComponent
>& _xComponent
);
148 OCustomShape(const OUString
& _sComponentName
);
150 virtual void NbcMove( const Size
& rSize
) SAL_OVERRIDE
;
151 virtual void NbcResize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
) SAL_OVERRIDE
;
152 virtual void NbcSetLogicRect(const Rectangle
& rRect
) SAL_OVERRIDE
;
153 virtual bool EndCreate(SdrDragStat
& rStat
, SdrCreateCmd eCmd
) SAL_OVERRIDE
;
155 virtual void SetSnapRectImpl(const Rectangle
& _rRect
) SAL_OVERRIDE
;
156 virtual SdrPage
* GetImplPage() const SAL_OVERRIDE
;
157 void SetObjectItemHelper(const SfxPoolItem
& rItem
) SAL_OVERRIDE
;
162 virtual ~OCustomShape();
164 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> getAwtComponent() SAL_OVERRIDE
;
166 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> getUnoShape() SAL_OVERRIDE
;
167 virtual sal_uInt16
GetObjIdentifier() const SAL_OVERRIDE
;
168 virtual sal_uInt32
GetObjInventor() const SAL_OVERRIDE
;
171 virtual void impl_setUnoShape( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& rxUnoShape
) SAL_OVERRIDE
;
177 class REPORTDESIGN_DLLPUBLIC OOle2Obj
: public SdrOle2Obj
, public OObjectBase
179 friend class OReportPage
;
180 friend class DlgEdFactory
;
184 void impl_createDataProvider_nothrow( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& _xModel
);
185 virtual void impl_setUnoShape( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& rxUnoShape
) SAL_OVERRIDE
;
188 static OOle2Obj
* Create( const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportComponent
>& _xComponent
,sal_uInt16 _nType
)
190 return new OOle2Obj( _xComponent
,_nType
);
193 OOle2Obj(const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportComponent
>& _xComponent
,sal_uInt16 _nType
);
194 OOle2Obj(const OUString
& _sComponentName
,sal_uInt16 _nType
);
197 virtual void NbcMove( const Size
& rSize
) SAL_OVERRIDE
;
198 virtual void NbcResize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
) SAL_OVERRIDE
;
199 virtual void NbcSetLogicRect(const Rectangle
& rRect
) SAL_OVERRIDE
;
200 virtual bool EndCreate(SdrDragStat
& rStat
, SdrCreateCmd eCmd
) SAL_OVERRIDE
;
202 virtual void SetSnapRectImpl(const Rectangle
& _rRect
) SAL_OVERRIDE
;
203 virtual SdrPage
* GetImplPage() const SAL_OVERRIDE
;
210 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> getAwtComponent() SAL_OVERRIDE
;
212 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> getUnoShape() SAL_OVERRIDE
;
213 virtual sal_uInt16
GetObjIdentifier() const SAL_OVERRIDE
;
214 virtual sal_uInt32
GetObjInventor() const SAL_OVERRIDE
;
215 // Clone() soll eine komplette Kopie des Objektes erzeugen.
216 virtual OOle2Obj
* Clone() const SAL_OVERRIDE
;
217 virtual void initializeOle() SAL_OVERRIDE
;
219 OOle2Obj
& operator=(const OOle2Obj
& rObj
);
221 void initializeChart( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& _xModel
);
227 class REPORTDESIGN_DLLPUBLIC OUnoObject
: public SdrUnoObj
, public OObjectBase
229 friend class OReportPage
;
230 friend class OObjectBase
;
231 friend class DlgEdFactory
;
233 sal_uInt16 m_nObjectType
;
235 OUnoObject(const OUString
& _sComponentName
236 ,const OUString
& rModelName
237 ,sal_uInt16 _nObjectType
);
238 OUnoObject( const ::com::sun::star::uno::Reference
< ::com::sun::star::report::XReportComponent
>& _xComponent
239 ,const OUString
& rModelName
240 ,sal_uInt16 _nObjectType
);
242 virtual ~OUnoObject();
244 virtual void NbcMove( const Size
& rSize
) SAL_OVERRIDE
;
245 virtual void NbcResize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
) SAL_OVERRIDE
;
246 virtual void NbcSetLogicRect(const Rectangle
& rRect
) SAL_OVERRIDE
;
247 virtual bool EndCreate(SdrDragStat
& rStat
, SdrCreateCmd eCmd
) SAL_OVERRIDE
;
249 virtual void SetSnapRectImpl(const Rectangle
& _rRect
) SAL_OVERRIDE
;
250 virtual SdrPage
* GetImplPage() const SAL_OVERRIDE
;
255 virtual void _propertyChange( const ::com::sun::star::beans::PropertyChangeEvent
& evt
) throw(::com::sun::star::uno::RuntimeException
) SAL_OVERRIDE
;
257 /** creates the m_xMediator when it doesn't already exist.
258 @param _bReverse when set to <TRUE/> then the properties from the uno control will be copied into report control
260 void CreateMediator(bool _bReverse
= false);
262 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> getAwtComponent() SAL_OVERRIDE
;
264 static OUString
GetDefaultName(const OUnoObject
* _pObj
);
266 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> getUnoShape() SAL_OVERRIDE
;
267 virtual sal_uInt16
GetObjIdentifier() const SAL_OVERRIDE
;
268 virtual sal_uInt32
GetObjInventor() const SAL_OVERRIDE
;
269 virtual OUnoObject
* Clone() const SAL_OVERRIDE
;
271 OUnoObject
& operator=(const OUnoObject
& rObj
);
274 virtual void impl_setUnoShape( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& rxUnoShape
) SAL_OVERRIDE
;
275 void impl_setReportComponent_nothrow();
276 void impl_initializeModel_nothrow();
282 #endif // INCLUDED_REPORTDESIGN_INC_RPTOBJECT_HXX
284 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */