Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / reportdesign / inc / RptObject.hxx
blob4084a4770e32fd8632840d69c30b12728908feb2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
28 #ifndef _REPORT_RPTUIOBJ_HXX
29 #define _REPORT_RPTUIOBJ_HXX
31 #include "dllapi.h"
32 #include <svx/svdoole2.hxx>
33 #include <svx/svdouno.hxx>
36 #include <comphelper/processfactory.hxx>
37 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
38 #include <com/sun/star/container/XContainerListener.hpp>
39 #include <com/sun/star/report/XReportComponent.hpp>
40 #include <com/sun/star/report/XSection.hpp>
41 #include <svx/svdocirc.hxx>
42 #include <svx/svdogrp.hxx>
43 #include <svx/svdoashp.hxx>
44 #include <comphelper/stl_types.hxx>
45 #include <comphelper/implementationreference.hxx>
48 namespace rptui
50 typedef ::std::multimap< sal_Int16, ::rtl::OUString, ::std::less< sal_Int16 > > IndexToNameMap;
51 enum DlgEdHintKind
53 RPTUI_HINT_UNKNOWN,
54 RPTUI_HINT_WINDOWSCROLLED,
55 RPTUI_HINT_LAYERCHANGED,
56 RPTUI_HINT_OBJORDERCHANGED,
57 RPTUI_HINT_SELECTIONCHANGED
60 class OUnoObject;
61 class REPORTDESIGN_DLLPUBLIC DlgEdHint: public SfxHint
63 private:
64 DlgEdHintKind eHintKind;
65 OUnoObject* pDlgEdObj;
67 DlgEdHint(DlgEdHint&);
68 void operator =(DlgEdHint&);
69 public:
70 TYPEINFO();
71 DlgEdHint( DlgEdHintKind eHint );
72 virtual ~DlgEdHint();
74 inline DlgEdHintKind GetKind() const { return eHintKind; }
75 inline OUnoObject* GetObject() const { return pDlgEdObj; }
79 class OReportPage;
80 class OPropertyMediator;
82 class REPORTDESIGN_DLLPUBLIC OObjectBase
84 public:
85 typedef ::comphelper::ImplementationReference<OPropertyMediator,::com::sun::star::beans::XPropertyChangeListener> TMediator;
87 protected:
88 mutable TMediator m_xMediator;
89 mutable ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener> m_xPropertyChangeListener;
90 //mutable ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener>
91 mutable ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent> m_xReportComponent;
92 ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener> m_xContainerListener;
93 ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection> m_xSection;
94 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xKeepShapeAlive;
95 ::rtl::OUString m_sComponentName;
96 sal_Bool m_bIsListening;
98 OObjectBase(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent);
99 OObjectBase(const ::rtl::OUString& _sComponentName);
101 virtual ~OObjectBase();
103 inline sal_Bool isListening() const { return m_bIsListening; }
105 void SetPropsFromRect(const Rectangle& _rRect);
107 virtual void SetSnapRectImpl(const Rectangle& _rRect) = 0;
108 virtual SdrPage* GetImplPage() const = 0;
109 virtual void SetObjectItemHelper(const SfxPoolItem& rItem);
111 /** called by instances of derived classes to implement their overloading of getUnoShape
113 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
114 getUnoShapeOf( SdrObject& _rSdrObject );
116 private:
117 static void ensureSdrObjectOwnership(
118 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxShape );
120 public:
121 void StartListening();
122 void EndListening(sal_Bool bRemoveListener = sal_True);
123 // PropertyChangeListener
124 virtual void _propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException);
125 virtual void initializeOle() {}
127 sal_Bool supportsService( const ::rtl::OUString& _sServiceName ) const;
129 ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent> getReportComponent() const;
130 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getAwtComponent();
131 inline void setOldParent(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection) { m_xSection = _xSection; }
132 inline ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection> getOldParent() const { return m_xSection;}
133 ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection> getSection() const;
134 inline const ::rtl::OUString getServiceName() const { return m_sComponentName; }
136 /** releases the reference to our UNO shape (m_xKeepShapeAlive)
138 void releaseUnoShape() { m_xKeepShapeAlive.clear(); }
140 static SdrObject* createObject(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent);
141 static sal_uInt16 getObjectType(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent);
143 //============================================================================
144 // OCustomShape
145 //============================================================================
146 class REPORTDESIGN_DLLPUBLIC OCustomShape: public SdrObjCustomShape , public OObjectBase
148 friend class OReportPage;
149 friend class DlgEdFactory;
151 public:
152 static OCustomShape* Create( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent )
154 return new OCustomShape( _xComponent );
157 protected:
158 OCustomShape(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent);
159 OCustomShape(const ::rtl::OUString& _sComponentName);
161 virtual void NbcMove( const Size& rSize );
162 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
163 virtual void NbcSetLogicRect(const Rectangle& rRect);
164 virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd);
166 virtual void SetSnapRectImpl(const Rectangle& _rRect);
167 virtual SdrPage* GetImplPage() const;
168 void SetObjectItemHelper(const SfxPoolItem& rItem);
170 public:
171 TYPEINFO();
173 virtual ~OCustomShape();
175 virtual sal_Int32 GetStep() const;
176 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getAwtComponent();
178 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getUnoShape();
179 virtual sal_uInt16 GetObjIdentifier() const;
180 virtual sal_uInt32 GetObjInventor() const;
183 //============================================================================
184 // OOle2Obj
185 //============================================================================
186 class REPORTDESIGN_DLLPUBLIC OOle2Obj: public SdrOle2Obj , public OObjectBase
188 friend class OReportPage;
189 friend class DlgEdFactory;
191 sal_uInt16 m_nType;
192 bool m_bOnlyOnce;
193 void impl_createDataProvider_nothrow( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel>& _xModel);
194 public:
195 static OOle2Obj* Create( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent,sal_uInt16 _nType )
197 return new OOle2Obj( _xComponent,_nType );
199 protected:
200 OOle2Obj(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent,sal_uInt16 _nType);
201 OOle2Obj(const ::rtl::OUString& _sComponentName,sal_uInt16 _nType);
204 virtual void NbcMove( const Size& rSize );
205 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
206 virtual void NbcSetLogicRect(const Rectangle& rRect);
207 virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd);
209 virtual void SetSnapRectImpl(const Rectangle& _rRect);
210 virtual SdrPage* GetImplPage() const;
212 public:
213 TYPEINFO();
215 virtual ~OOle2Obj();
217 virtual sal_Int32 GetStep() const;
218 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getAwtComponent();
220 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getUnoShape();
221 virtual sal_uInt16 GetObjIdentifier() const;
222 virtual sal_uInt32 GetObjInventor() const;
223 // Clone() soll eine komplette Kopie des Objektes erzeugen.
224 virtual OOle2Obj* Clone() const;
225 virtual void initializeOle();
227 OOle2Obj& operator=(const OOle2Obj& rObj);
229 void initializeChart( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel>& _xModel);
232 //============================================================================
233 // OUnoObject
234 //============================================================================
235 class REPORTDESIGN_DLLPUBLIC OUnoObject: public SdrUnoObj , public OObjectBase
237 friend class OReportPage;
238 friend class OObjectBase;
239 friend class DlgEdFactory;
241 sal_uInt16 m_nObjectType;
242 protected:
243 OUnoObject(const ::rtl::OUString& _sComponentName
244 ,const ::rtl::OUString& rModelName
245 ,sal_uInt16 _nObjectType);
246 OUnoObject( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent
247 ,const ::rtl::OUString& rModelName
248 ,sal_uInt16 _nObjectType);
250 virtual ~OUnoObject();
252 virtual void NbcMove( const Size& rSize );
253 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact);
254 virtual void NbcSetLogicRect(const Rectangle& rRect);
255 virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd);
257 virtual void SetSnapRectImpl(const Rectangle& _rRect);
258 virtual SdrPage* GetImplPage() const;
260 public:
261 TYPEINFO();
263 virtual sal_Int32 GetStep() const;
264 virtual void _propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException);
266 /** creates the m_xMediator when it doesn't already exist.
267 @param _bReverse when set to <TRUE/> then the properties from the uno control will be copied into report control
269 void CreateMediator(sal_Bool _bReverse = sal_False);
271 virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getAwtComponent();
273 static ::rtl::OUString GetDefaultName(const OUnoObject* _pObj);
275 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getUnoShape();
276 virtual sal_uInt16 GetObjIdentifier() const;
277 virtual sal_uInt32 GetObjInventor() const;
278 virtual OUnoObject* Clone() const;
280 OUnoObject& operator=(const OUnoObject& rObj);
282 private:
283 void impl_setReportComponent_nothrow();
284 void impl_initializeModel_nothrow();
287 //============================================================================
288 } // rptui
289 //============================================================================
290 #endif // _REPORT_RPTUIOBJ_HXX
292 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */