Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
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.
15 : : *
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).
21 : : *
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.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _REPORT_RPTUIOBJ_HXX
29 : : #define _REPORT_RPTUIOBJ_HXX
30 : :
31 : : #include "dllapi.h"
32 : : #include <svx/svdoole2.hxx>
33 : : #include <svx/svdouno.hxx>
34 : :
35 : :
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>
46 : :
47 : :
48 : : namespace rptui
49 : : {
50 : : typedef ::std::multimap< sal_Int16, ::rtl::OUString, ::std::less< sal_Int16 > > IndexToNameMap;
51 : : enum DlgEdHintKind
52 : : {
53 : : RPTUI_HINT_UNKNOWN,
54 : : RPTUI_HINT_WINDOWSCROLLED,
55 : : RPTUI_HINT_LAYERCHANGED,
56 : : RPTUI_HINT_OBJORDERCHANGED,
57 : : RPTUI_HINT_SELECTIONCHANGED
58 : : };
59 : :
60 : : class OUnoObject;
61 : : class REPORTDESIGN_DLLPUBLIC DlgEdHint: public SfxHint
62 : : {
63 : : private:
64 : : DlgEdHintKind eHintKind;
65 : : OUnoObject* pDlgEdObj;
66 : :
67 : : DlgEdHint(DlgEdHint&);
68 : : void operator =(DlgEdHint&);
69 : : public:
70 : : TYPEINFO();
71 : : DlgEdHint( DlgEdHintKind eHint );
72 : : virtual ~DlgEdHint();
73 : :
74 : 0 : inline DlgEdHintKind GetKind() const { return eHintKind; }
75 : : inline OUnoObject* GetObject() const { return pDlgEdObj; }
76 : : };
77 : :
78 : :
79 : : class OReportPage;
80 : : class OPropertyMediator;
81 : :
82 : : class REPORTDESIGN_DLLPUBLIC OObjectBase
83 : : {
84 : : public:
85 : : typedef ::comphelper::ImplementationReference<OPropertyMediator,::com::sun::star::beans::XPropertyChangeListener> TMediator;
86 : :
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;
97 : :
98 : : OObjectBase(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent);
99 : : OObjectBase(const ::rtl::OUString& _sComponentName);
100 : :
101 : : virtual ~OObjectBase();
102 : :
103 : 0 : inline sal_Bool isListening() const { return m_bIsListening; }
104 : :
105 : : void SetPropsFromRect(const Rectangle& _rRect);
106 : :
107 : : virtual void SetSnapRectImpl(const Rectangle& _rRect) = 0;
108 : : virtual SdrPage* GetImplPage() const = 0;
109 : : virtual void SetObjectItemHelper(const SfxPoolItem& rItem);
110 : :
111 : : /** called by instances of derived classes to implement their overloading of getUnoShape
112 : : */
113 : : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
114 : : getUnoShapeOf( SdrObject& _rSdrObject );
115 : :
116 : : private:
117 : : static void ensureSdrObjectOwnership(
118 : : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxShape );
119 : :
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 : 0 : virtual void initializeOle() {}
126 : :
127 : : sal_Bool supportsService( const ::rtl::OUString& _sServiceName ) const;
128 : :
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 : 0 : inline const ::rtl::OUString getServiceName() const { return m_sComponentName; }
135 : :
136 : : /** releases the reference to our UNO shape (m_xKeepShapeAlive)
137 : : */
138 : 0 : void releaseUnoShape() { m_xKeepShapeAlive.clear(); }
139 : :
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);
142 : : };
143 : : //============================================================================
144 : : // OCustomShape
145 : : //============================================================================
146 : : class REPORTDESIGN_DLLPUBLIC OCustomShape: public SdrObjCustomShape , public OObjectBase
147 : : {
148 : : friend class OReportPage;
149 : : friend class DlgEdFactory;
150 : :
151 : : public:
152 : 0 : static OCustomShape* Create( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent )
153 : : {
154 [ # # ]: 0 : return new OCustomShape( _xComponent );
155 : : }
156 : :
157 : : protected:
158 : : OCustomShape(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent);
159 : : OCustomShape(const ::rtl::OUString& _sComponentName);
160 : :
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);
165 : :
166 : : virtual void SetSnapRectImpl(const Rectangle& _rRect);
167 : : virtual SdrPage* GetImplPage() const;
168 : : void SetObjectItemHelper(const SfxPoolItem& rItem);
169 : :
170 : : public:
171 : : TYPEINFO();
172 : :
173 : : virtual ~OCustomShape();
174 : :
175 : : virtual sal_Int32 GetStep() const;
176 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getAwtComponent();
177 : :
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;
181 : : };
182 : :
183 : : //============================================================================
184 : : // OOle2Obj
185 : : //============================================================================
186 : : class REPORTDESIGN_DLLPUBLIC OOle2Obj: public SdrOle2Obj , public OObjectBase
187 : : {
188 : : friend class OReportPage;
189 : : friend class DlgEdFactory;
190 : :
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 : 0 : static OOle2Obj* Create( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent,sal_uInt16 _nType )
196 : : {
197 [ # # ]: 0 : return new OOle2Obj( _xComponent,_nType );
198 : : }
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);
202 : :
203 : :
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);
208 : :
209 : : virtual void SetSnapRectImpl(const Rectangle& _rRect);
210 : : virtual SdrPage* GetImplPage() const;
211 : :
212 : : public:
213 : : TYPEINFO();
214 : :
215 : : virtual ~OOle2Obj();
216 : :
217 : : virtual sal_Int32 GetStep() const;
218 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getAwtComponent();
219 : :
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();
226 : :
227 : : OOle2Obj& operator=(const OOle2Obj& rObj);
228 : :
229 : : void initializeChart( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel>& _xModel);
230 : : };
231 : :
232 : : //============================================================================
233 : : // OUnoObject
234 : : //============================================================================
235 : : class REPORTDESIGN_DLLPUBLIC OUnoObject: public SdrUnoObj , public OObjectBase
236 : : {
237 : : friend class OReportPage;
238 : : friend class OObjectBase;
239 : : friend class DlgEdFactory;
240 : :
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);
249 : :
250 : : virtual ~OUnoObject();
251 : :
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);
256 : :
257 : : virtual void SetSnapRectImpl(const Rectangle& _rRect);
258 : : virtual SdrPage* GetImplPage() const;
259 : :
260 : : public:
261 : : TYPEINFO();
262 : :
263 : : virtual sal_Int32 GetStep() const;
264 : : virtual void _propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException);
265 : :
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
268 : : */
269 : : void CreateMediator(sal_Bool _bReverse = sal_False);
270 : :
271 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getAwtComponent();
272 : :
273 : : static ::rtl::OUString GetDefaultName(const OUnoObject* _pObj);
274 : :
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;
279 : :
280 : : OUnoObject& operator=(const OUnoObject& rObj);
281 : :
282 : : private:
283 : : void impl_setReportComponent_nothrow();
284 : : void impl_initializeModel_nothrow();
285 : : };
286 : :
287 : : //============================================================================
288 : : } // rptui
289 : : //============================================================================
290 : : #endif // _REPORT_RPTUIOBJ_HXX
291 : :
292 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|