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&) SAL_DELETED_FUNCTION;
58 : void operator =(DlgEdHint&) SAL_DELETED_FUNCTION;
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 overriding 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 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getAwtComponent() SAL_OVERRIDE;
165 :
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;
169 :
170 : private:
171 : virtual void impl_setUnoShape( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxUnoShape ) SAL_OVERRIDE;
172 : };
173 :
174 :
175 : // OOle2Obj
176 :
177 : class REPORTDESIGN_DLLPUBLIC OOle2Obj: public SdrOle2Obj , public OObjectBase
178 : {
179 : friend class OReportPage;
180 : friend class DlgEdFactory;
181 :
182 : sal_uInt16 m_nType;
183 : bool m_bOnlyOnce;
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;
186 :
187 : public:
188 0 : static OOle2Obj* Create( const ::com::sun::star::uno::Reference< ::com::sun::star::report::XReportComponent>& _xComponent,sal_uInt16 _nType )
189 : {
190 0 : return new OOle2Obj( _xComponent,_nType );
191 : }
192 : protected:
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);
195 :
196 :
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;
201 :
202 : virtual void SetSnapRectImpl(const Rectangle& _rRect) SAL_OVERRIDE;
203 : virtual SdrPage* GetImplPage() const SAL_OVERRIDE;
204 :
205 : public:
206 : TYPEINFO_OVERRIDE();
207 :
208 : virtual ~OOle2Obj();
209 :
210 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getAwtComponent() SAL_OVERRIDE;
211 :
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;
218 :
219 : OOle2Obj& operator=(const OOle2Obj& rObj);
220 :
221 : void initializeChart( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel>& _xModel);
222 : };
223 :
224 :
225 : // OUnoObject
226 :
227 : class REPORTDESIGN_DLLPUBLIC OUnoObject: public SdrUnoObj , public OObjectBase
228 : {
229 : friend class OReportPage;
230 : friend class OObjectBase;
231 : friend class DlgEdFactory;
232 :
233 : sal_uInt16 m_nObjectType;
234 : protected:
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);
241 :
242 : virtual ~OUnoObject();
243 :
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;
248 :
249 : virtual void SetSnapRectImpl(const Rectangle& _rRect) SAL_OVERRIDE;
250 : virtual SdrPage* GetImplPage() const SAL_OVERRIDE;
251 :
252 : public:
253 : TYPEINFO_OVERRIDE();
254 :
255 : virtual void _propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw(::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
256 :
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
259 : */
260 : void CreateMediator(bool _bReverse = false);
261 :
262 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> getAwtComponent() SAL_OVERRIDE;
263 :
264 : static OUString GetDefaultName(const OUnoObject* _pObj);
265 :
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;
270 :
271 : OUnoObject& operator=(const OUnoObject& rObj);
272 :
273 : private:
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();
277 : };
278 :
279 :
280 : } // rptui
281 :
282 : #endif // INCLUDED_REPORTDESIGN_INC_RPTOBJECT_HXX
283 :
284 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|