LibreOffice Module reportdesign (master)  1
RptObject.hxx
Go to the documentation of this file.
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 <svx/svdoole2.hxx>
25 #include <svx/svdouno.hxx>
26 
27 
28 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
29 #include <com/sun/star/report/XReportComponent.hpp>
30 #include <com/sun/star/report/XSection.hpp>
31 #include <svx/svdoashp.hxx>
32 
33 #include <map>
34 
35 namespace rptui
36 {
37 typedef ::std::multimap< sal_Int16, OUString > IndexToNameMap;
39  {
42  };
43 
44  class OUnoObject;
46  {
47  private:
49 
50  DlgEdHint(DlgEdHint const &) = delete;
51  void operator =(DlgEdHint const &) = delete;
52  public:
53  DlgEdHint( DlgEdHintKind eHint );
54  virtual ~DlgEdHint() override;
55 
56  DlgEdHintKind GetKind() const { return eHintKind; }
57  };
58 
59 
60 class OReportPage;
61 class OPropertyMediator;
62 
64 {
65 protected:
67  mutable css::uno::Reference< css::beans::XPropertyChangeListener> m_xPropertyChangeListener;
68  mutable css::uno::Reference< css::report::XReportComponent> m_xReportComponent;
69  css::uno::Reference< css::uno::XInterface > m_xKeepShapeAlive;
70  OUString m_sComponentName;
72 
73  OObjectBase(const css::uno::Reference< css::report::XReportComponent>& _xComponent);
74  OObjectBase(const OUString& _sComponentName);
75 
76  virtual ~OObjectBase();
77 
78  bool isListening() const { return m_bIsListening; }
79 
80  void SetPropsFromRect(const tools::Rectangle& _rRect);
81 
82  virtual SdrPage* GetImplPage() const = 0;
83 
86  css::uno::Reference< css::uno::XInterface >
87  getUnoShapeOf( SdrObject& _rSdrObject );
88 
89 private:
90  static void ensureSdrObjectOwnership(
91  const css::uno::Reference< css::uno::XInterface >& _rxShape );
92 
93 public:
94  OObjectBase(const OObjectBase&) = delete;
95  OObjectBase& operator=(const OObjectBase&) = delete;
96  void StartListening();
97  void EndListening();
98  // PropertyChangeListener
100  virtual void _propertyChange( const css::beans::PropertyChangeEvent& evt );
101  virtual void initializeOle() {}
102 
103  bool supportsService( const OUString& _sServiceName ) const;
104 
105  const css::uno::Reference< css::report::XReportComponent>& getReportComponent() const { return m_xReportComponent;}
106  virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent();
107  css::uno::Reference< css::report::XSection> getSection() const;
108  const OUString& getServiceName() const { return m_sComponentName; }
109 
112  void releaseUnoShape() { m_xKeepShapeAlive.clear(); }
113 
114  static SdrObject* createObject(
115  SdrModel& rTargetModel,
116  const css::uno::Reference< css::report::XReportComponent>& _xComponent);
117  static SdrObjKind getObjectType(const css::uno::Reference< css::report::XReportComponent>& _xComponent);
118 };
119 
120 // OCustomShape
121 
123 {
124  friend class OReportPage;
125  friend class DlgEdFactory;
126 
127 private:
128  // protected destructor - due to final, make private
129  virtual ~OCustomShape() override;
130 
131 public:
133  SdrModel& rSdrModel,
134  const css::uno::Reference< css::report::XReportComponent>& _xComponent)
135  {
136  return new OCustomShape(rSdrModel, _xComponent );
137  }
138 
139  virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent() override;
140 
141  virtual css::uno::Reference< css::uno::XInterface > getUnoShape() override;
142  virtual SdrObjKind GetObjIdentifier() const override;
143  virtual SdrInventor GetObjInventor() const override;
144 
145 private:
146  virtual void impl_setUnoShape( const css::uno::Reference< css::uno::XInterface >& rxUnoShape ) override;
147 
148  OCustomShape(
149  SdrModel& rSdrModel,
150  const css::uno::Reference< css::report::XReportComponent>& _xComponent);
151  OCustomShape(
152  SdrModel& rSdrModel,
153  const OUString& _sComponentName);
154 
155  virtual void NbcMove( const Size& rSize ) override;
156  virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
157  virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override;
158  virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;
159 
160  virtual SdrPage* GetImplPage() const override;
161 };
162 
163 
164 // OOle2Obj
165 
167 {
168  friend class OReportPage;
169  friend class DlgEdFactory;
170 
171 private:
172  // protected destructor - due to final, make private
173  virtual ~OOle2Obj() override;
174 
175 public:
176  static OOle2Obj* Create(
177  SdrModel& rSdrModel,
178  const css::uno::Reference< css::report::XReportComponent>& _xComponent,
179  SdrObjKind _nType)
180  {
181  return new OOle2Obj(rSdrModel, _xComponent, _nType);
182  }
183 
184  virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent() override;
185 
186  virtual css::uno::Reference< css::uno::XInterface > getUnoShape() override;
187  virtual SdrObjKind GetObjIdentifier() const override;
188  virtual SdrInventor GetObjInventor() const override;
189  // Clone() should make a complete copy of the object.
190  virtual OOle2Obj* CloneSdrObject(SdrModel& rTargetModel) const override;
191  virtual void initializeOle() override;
192 
193  void initializeChart( const css::uno::Reference< css::frame::XModel>& _xModel);
194 
195 private:
196  OOle2Obj(
197  SdrModel& rSdrModel,
198  const css::uno::Reference< css::report::XReportComponent>& _xComponent,
199  SdrObjKind _nType);
200  OOle2Obj(
201  SdrModel& rSdrModel,
202  const OUString& _sComponentName,
203  SdrObjKind _nType);
204  // copy constructor
205  OOle2Obj(SdrModel& rSdrModel, const OOle2Obj& rSource);
206 
207  virtual void NbcMove( const Size& rSize ) override;
208  virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
209  virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override;
210  virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;
211 
212  virtual SdrPage* GetImplPage() const override;
213 
214  void impl_createDataProvider_nothrow( const css::uno::Reference< css::frame::XModel>& _xModel);
215  virtual void impl_setUnoShape( const css::uno::Reference< css::uno::XInterface >& rxUnoShape ) override;
216 
219 };
220 
221 
222 // OUnoObject
223 
225 {
226  friend class OReportPage;
227  friend class OObjectBase;
228  friend class DlgEdFactory;
229 
231  // tdf#118730 remember if this object was created interactively (due to ::EndCreate being called)
233 
234 protected:
235  OUnoObject(SdrModel& rSdrModel,
236  const OUString& _sComponentName,
237  const OUString& rModelName,
238  SdrObjKind _nObjectType);
239  OUnoObject(
240  SdrModel& rSdrModel,
241  const css::uno::Reference< css::report::XReportComponent>& _xComponent,
242  const OUString& rModelName,
243  SdrObjKind _nObjectType);
244  // copy constructor
245  OUnoObject(SdrModel& rSdrModel, OUnoObject const & rSource);
246 
247  // protected destructor
248  virtual ~OUnoObject() override;
249 
250  virtual void NbcMove( const Size& rSize ) override;
251  virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
252  virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override;
253  virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;
254 
255  virtual SdrPage* GetImplPage() const override;
256 
257 public:
258 
259  virtual void _propertyChange( const css::beans::PropertyChangeEvent& evt ) override;
260 
264  void CreateMediator(bool _bReverse = false);
265 
266  virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent() override;
267 
268  static OUString GetDefaultName(const OUnoObject* _pObj);
269 
270  virtual css::uno::Reference< css::uno::XInterface > getUnoShape() override;
271  virtual SdrObjKind GetObjIdentifier() const override;
272  virtual SdrInventor GetObjInventor() const override;
273  virtual OUnoObject* CloneSdrObject(SdrModel& rTargetModel) const override;
274 
275 private:
276  virtual void impl_setUnoShape( const css::uno::Reference< css::uno::XInterface >& rxUnoShape ) override;
277  void impl_initializeModel_nothrow();
278 };
279 
280 
281 } // rptui
282 
283 #endif // INCLUDED_REPORTDESIGN_INC_RPTOBJECT_HXX
284 
285 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static OOle2Obj * Create(SdrModel &rSdrModel, const css::uno::Reference< css::report::XReportComponent > &_xComponent, SdrObjKind _nType)
Definition: RptObject.hxx:176
virtual void initializeOle()
Definition: RptObject.hxx:101
#define REPORTDESIGN_DLLPUBLIC
Definition: dllapi.h:28
SdrInventor
DlgEdHintKind GetKind() const
Definition: RptObject.hxx:56
css::uno::Reference< css::report::XReportComponent > m_xReportComponent
Definition: RptObject.hxx:68
SdrObjKind
const css::uno::Reference< css::report::XReportComponent > & getReportComponent() const
Definition: RptObject.hxx:105
static OCustomShape * Create(SdrModel &rSdrModel, const css::uno::Reference< css::report::XReportComponent > &_xComponent)
Definition: RptObject.hxx:132
SdrObjKind m_nType
Definition: RptObject.hxx:217
void releaseUnoShape()
releases the reference to our UNO shape (m_xKeepShapeAlive)
Definition: RptObject.hxx:112
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
OUString m_sComponentName
Definition: RptObject.hxx:70
rtl::Reference< OPropertyMediator > m_xMediator
Definition: RptObject.hxx:66
css::uno::Reference< css::beans::XPropertyChangeListener > m_xPropertyChangeListener
Definition: RptObject.hxx:67
::std::multimap< sal_Int16, OUString > IndexToNameMap
Definition: RptObject.hxx:37
const OUString & getServiceName() const
Definition: RptObject.hxx:108
DlgEdHintKind
Definition: RptObject.hxx:38
css::uno::Reference< css::uno::XInterface > m_xKeepShapeAlive
Definition: RptObject.hxx:69
DlgEdHintKind eHintKind
Definition: RptObject.hxx:48
bool isListening() const
Definition: RptObject.hxx:78
SdrCreateCmd
SdrObjKind m_nObjectType
Definition: RptObject.hxx:230