Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef INCLUDED_REPORTDESIGN_INC_RPTOBJECT_HXX
20 : #define INCLUDED_REPORTDESIGN_INC_RPTOBJECT_HXX
21 :
22 : #include "dllapi.h"
23 :
24 : #include <boost/noncopyable.hpp>
25 : #include <svx/svdoole2.hxx>
26 : #include <svx/svdouno.hxx>
27 :
28 :
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>
37 :
38 : namespace rptui
39 : {
40 : typedef ::std::multimap< sal_Int16, OUString, ::std::less< sal_Int16 > > IndexToNameMap;
41 : enum DlgEdHintKind
42 : {
43 : RPTUI_HINT_UNKNOWN,
44 : RPTUI_HINT_WINDOWSCROLLED,
45 : RPTUI_HINT_LAYERCHANGED,
46 : RPTUI_HINT_OBJORDERCHANGED,
47 : RPTUI_HINT_SELECTIONCHANGED
48 : };
49 :
50 : class OUnoObject;
51 : class REPORTDESIGN_DLLPUBLIC DlgEdHint: public SfxHint
52 : {
53 : private:
54 : DlgEdHintKind eHintKind;
55 : OUnoObject* pDlgEdObj;
56 :
57 : DlgEdHint(DlgEdHint&);
58 : void operator =(DlgEdHint&);
59 : public:
60 : DlgEdHint( DlgEdHintKind eHint );
61 : virtual ~DlgEdHint();
62 :
63 0 : inline DlgEdHintKind GetKind() const { return eHintKind; }
64 : inline OUnoObject* GetObject() const { return pDlgEdObj; }
65 : };
66 :
67 :
68 : class OReportPage;
69 : class OPropertyMediator;
70 :
71 : class REPORTDESIGN_DLLPUBLIC OObjectBase: private boost::noncopyable
72 : {
73 : public:
74 : typedef rtl::Reference<OPropertyMediator> TMediator;
75 :
76 : protected:
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;
85 : bool m_bIsListening;
86 :
87 : OObjectBase(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent);
88 : OObjectBase(const OUString& _sComponentName);
89 :
90 : virtual ~OObjectBase();
91 :
92 0 : inline bool isListening() const { return m_bIsListening; }
93 :
94 : void SetPropsFromRect(const Rectangle& _rRect);
95 :
96 : virtual void SetSnapRectImpl(const Rectangle& _rRect) = 0;
97 : virtual SdrPage* GetImplPage() const = 0;
98 : virtual void SetObjectItemHelper(const SfxPoolItem& rItem);
99 :
100 : /** called by instances of derived classes to implement their overloading of getUnoShape
101 : */
102 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
103 : getUnoShapeOf( SdrObject& _rSdrObject );
104 :
105 : private:
106 : static void ensureSdrObjectOwnership(
107 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxShape );
108 :
109 : public:
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 0 : virtual void initializeOle() {}
115 :
116 : bool supportsService( const OUString& _sServiceName ) const;
117 :
118 0 : ::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 0 : inline const OUString getServiceName() const { return m_sComponentName; }
124 :
125 : /** releases the reference to our UNO shape (m_xKeepShapeAlive)
126 : */
127 0 : void releaseUnoShape() { m_xKeepShapeAlive.clear(); }
128 :
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);
131 : };
132 :
133 : // OCustomShape
134 :
135 : class REPORTDESIGN_DLLPUBLIC OCustomShape: public SdrObjCustomShape , public OObjectBase
136 : {
137 : friend class OReportPage;
138 : friend class DlgEdFactory;
139 :
140 : public:
141 0 : static OCustomShape* Create( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent )
142 : {
143 0 : return new OCustomShape( _xComponent );
144 : }
145 :
146 : protected:
147 : OCustomShape(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent);
148 : OCustomShape(const OUString& _sComponentName);
149 :
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;
154 :
155 : virtual void SetSnapRectImpl(const Rectangle& _rRect) SAL_OVERRIDE;
156 : virtual SdrPage* GetImplPage() const SAL_OVERRIDE;
157 : void SetObjectItemHelper(const SfxPoolItem& rItem) SAL_OVERRIDE;
158 :
159 : public:
160 : TYPEINFO_OVERRIDE();
161 :
162 : virtual ~OCustomShape();
163 :
164 : virtual sal_Int32 GetStep() const;
165 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getAwtComponent() SAL_OVERRIDE;
166 :
167 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getUnoShape() SAL_OVERRIDE;
168 : virtual sal_uInt16 GetObjIdentifier() const SAL_OVERRIDE;
169 : virtual sal_uInt32 GetObjInventor() const SAL_OVERRIDE;
170 :
171 : private:
172 : virtual void impl_setUnoShape( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxUnoShape ) SAL_OVERRIDE;
173 : };
174 :
175 :
176 : // OOle2Obj
177 :
178 : class REPORTDESIGN_DLLPUBLIC OOle2Obj: public SdrOle2Obj , public OObjectBase
179 : {
180 : friend class OReportPage;
181 : friend class DlgEdFactory;
182 :
183 : sal_uInt16 m_nType;
184 : bool m_bOnlyOnce;
185 : void impl_createDataProvider_nothrow( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel>& _xModel);
186 : virtual void impl_setUnoShape( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxUnoShape ) SAL_OVERRIDE;
187 :
188 : public:
189 0 : static OOle2Obj* Create( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent,sal_uInt16 _nType )
190 : {
191 0 : return new OOle2Obj( _xComponent,_nType );
192 : }
193 : protected:
194 : OOle2Obj(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent,sal_uInt16 _nType);
195 : OOle2Obj(const OUString& _sComponentName,sal_uInt16 _nType);
196 :
197 :
198 : virtual void NbcMove( const Size& rSize ) SAL_OVERRIDE;
199 : virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) SAL_OVERRIDE;
200 : virtual void NbcSetLogicRect(const Rectangle& rRect) SAL_OVERRIDE;
201 : virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) SAL_OVERRIDE;
202 :
203 : virtual void SetSnapRectImpl(const Rectangle& _rRect) SAL_OVERRIDE;
204 : virtual SdrPage* GetImplPage() const SAL_OVERRIDE;
205 :
206 : public:
207 : TYPEINFO_OVERRIDE();
208 :
209 : virtual ~OOle2Obj();
210 :
211 : virtual sal_Int32 GetStep() const;
212 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getAwtComponent() SAL_OVERRIDE;
213 :
214 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getUnoShape() SAL_OVERRIDE;
215 : virtual sal_uInt16 GetObjIdentifier() const SAL_OVERRIDE;
216 : virtual sal_uInt32 GetObjInventor() const SAL_OVERRIDE;
217 : // Clone() soll eine komplette Kopie des Objektes erzeugen.
218 : virtual OOle2Obj* Clone() const SAL_OVERRIDE;
219 : virtual void initializeOle() SAL_OVERRIDE;
220 :
221 : OOle2Obj& operator=(const OOle2Obj& rObj);
222 :
223 : void initializeChart( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel>& _xModel);
224 : };
225 :
226 :
227 : // OUnoObject
228 :
229 : class REPORTDESIGN_DLLPUBLIC OUnoObject: public SdrUnoObj , public OObjectBase
230 : {
231 : friend class OReportPage;
232 : friend class OObjectBase;
233 : friend class DlgEdFactory;
234 :
235 : sal_uInt16 m_nObjectType;
236 : protected:
237 : OUnoObject(const OUString& _sComponentName
238 : ,const OUString& rModelName
239 : ,sal_uInt16 _nObjectType);
240 : OUnoObject( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent
241 : ,const OUString& rModelName
242 : ,sal_uInt16 _nObjectType);
243 :
244 : virtual ~OUnoObject();
245 :
246 : virtual void NbcMove( const Size& rSize ) SAL_OVERRIDE;
247 : virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) SAL_OVERRIDE;
248 : virtual void NbcSetLogicRect(const Rectangle& rRect) SAL_OVERRIDE;
249 : virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) SAL_OVERRIDE;
250 :
251 : virtual void SetSnapRectImpl(const Rectangle& _rRect) SAL_OVERRIDE;
252 : virtual SdrPage* GetImplPage() const SAL_OVERRIDE;
253 :
254 : public:
255 : TYPEINFO_OVERRIDE();
256 :
257 : virtual sal_Int32 GetStep() const;
258 : virtual void _propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
259 :
260 : /** creates the m_xMediator when it doesn't already exist.
261 : @param _bReverse when set to <TRUE/> then the properties from the uno control will be copied into report control
262 : */
263 : void CreateMediator(bool _bReverse = false);
264 :
265 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getAwtComponent() SAL_OVERRIDE;
266 :
267 : static OUString GetDefaultName(const OUnoObject* _pObj);
268 :
269 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getUnoShape() SAL_OVERRIDE;
270 : virtual sal_uInt16 GetObjIdentifier() const SAL_OVERRIDE;
271 : virtual sal_uInt32 GetObjInventor() const SAL_OVERRIDE;
272 : virtual OUnoObject* Clone() const SAL_OVERRIDE;
273 :
274 : OUnoObject& operator=(const OUnoObject& rObj);
275 :
276 : private:
277 : virtual void impl_setUnoShape( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxUnoShape ) SAL_OVERRIDE;
278 : void impl_setReportComponent_nothrow();
279 : void impl_initializeModel_nothrow();
280 : };
281 :
282 :
283 : } // rptui
284 :
285 : #endif // INCLUDED_REPORTDESIGN_INC_RPTOBJECT_HXX
286 :
287 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|