bump product version to 7.2.5.1
[LibreOffice.git] / reportdesign / inc / RptObject.hxx
blobfe8b49d08738a9f7b68c4f18a4adb048d778f324
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_REPORTDESIGN_INC_RPTOBJECT_HXX
20 #define INCLUDED_REPORTDESIGN_INC_RPTOBJECT_HXX
22 #include "dllapi.h"
24 #include <svx/svdoole2.hxx>
25 #include <svx/svdouno.hxx>
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>
33 #include <map>
35 namespace rptui
37 typedef ::std::multimap< sal_Int16, OUString > IndexToNameMap;
38 enum DlgEdHintKind
40 RPTUI_HINT_WINDOWSCROLLED,
41 RPTUI_HINT_SELECTIONCHANGED
44 class OUnoObject;
45 class REPORTDESIGN_DLLPUBLIC DlgEdHint final : public SfxHint
47 private:
48 DlgEdHintKind eHintKind;
50 DlgEdHint(DlgEdHint const &) = delete;
51 void operator =(DlgEdHint const &) = delete;
52 public:
53 DlgEdHint( DlgEdHintKind eHint );
54 virtual ~DlgEdHint() override;
56 DlgEdHintKind GetKind() const { return eHintKind; }
60 class OReportPage;
61 class OPropertyMediator;
63 class REPORTDESIGN_DLLPUBLIC OObjectBase
65 protected:
66 mutable rtl::Reference<OPropertyMediator> m_xMediator;
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;
71 bool m_bIsListening;
73 OObjectBase(const css::uno::Reference< css::report::XReportComponent>& _xComponent);
74 OObjectBase(const OUString& _sComponentName);
76 virtual ~OObjectBase();
78 bool isListening() const { return m_bIsListening; }
80 void SetPropsFromRect(const tools::Rectangle& _rRect);
82 virtual SdrPage* GetImplPage() const = 0;
84 /** called by instances of derived classes to implement their overriding of getUnoShape
86 css::uno::Reference< css::uno::XInterface >
87 getUnoShapeOf( SdrObject& _rSdrObject );
89 private:
90 static void ensureSdrObjectOwnership(
91 const css::uno::Reference< css::uno::XInterface >& _rxShape );
93 public:
94 OObjectBase(const OObjectBase&) = delete;
95 OObjectBase& operator=(const OObjectBase&) = delete;
96 void StartListening();
97 void EndListening();
98 // PropertyChangeListener
99 /// @throws css::uno::RuntimeException
100 virtual void _propertyChange( const css::beans::PropertyChangeEvent& evt );
101 virtual void initializeOle() {}
103 bool supportsService( const OUString& _sServiceName ) const;
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; }
110 /** releases the reference to our UNO shape (m_xKeepShapeAlive)
112 void releaseUnoShape() { m_xKeepShapeAlive.clear(); }
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);
120 // OCustomShape
122 class REPORTDESIGN_DLLPUBLIC OCustomShape final : public SdrObjCustomShape , public OObjectBase
124 friend class OReportPage;
125 friend class DlgEdFactory;
127 private:
128 // protected destructor - due to final, make private
129 virtual ~OCustomShape() override;
131 public:
132 static OCustomShape* Create(
133 SdrModel& rSdrModel,
134 const css::uno::Reference< css::report::XReportComponent>& _xComponent)
136 return new OCustomShape(rSdrModel, _xComponent );
139 virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent() override;
141 virtual css::uno::Reference< css::uno::XInterface > getUnoShape() override;
142 virtual SdrObjKind GetObjIdentifier() const override;
143 virtual SdrInventor GetObjInventor() const override;
145 private:
146 virtual void impl_setUnoShape( const css::uno::Reference< css::uno::XInterface >& rxUnoShape ) override;
148 OCustomShape(
149 SdrModel& rSdrModel,
150 const css::uno::Reference< css::report::XReportComponent>& _xComponent);
151 OCustomShape(
152 SdrModel& rSdrModel,
153 const OUString& _sComponentName);
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;
160 virtual SdrPage* GetImplPage() const override;
164 // OOle2Obj
166 class REPORTDESIGN_DLLPUBLIC OOle2Obj final : public SdrOle2Obj , public OObjectBase
168 friend class OReportPage;
169 friend class DlgEdFactory;
171 private:
172 // protected destructor - due to final, make private
173 virtual ~OOle2Obj() override;
175 public:
176 static OOle2Obj* Create(
177 SdrModel& rSdrModel,
178 const css::uno::Reference< css::report::XReportComponent>& _xComponent,
179 SdrObjKind _nType)
181 return new OOle2Obj(rSdrModel, _xComponent, _nType);
184 virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent() override;
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;
193 void initializeChart( const css::uno::Reference< css::frame::XModel>& _xModel);
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);
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;
212 virtual SdrPage* GetImplPage() const override;
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;
217 SdrObjKind m_nType;
218 bool m_bOnlyOnce;
222 // OUnoObject
224 class REPORTDESIGN_DLLPUBLIC OUnoObject: public SdrUnoObj , public OObjectBase
226 friend class OReportPage;
227 friend class OObjectBase;
228 friend class DlgEdFactory;
230 SdrObjKind m_nObjectType;
231 // tdf#118730 remember if this object was created interactively (due to ::EndCreate being called)
232 bool m_bSetDefaultLabel;
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);
247 // protected destructor
248 virtual ~OUnoObject() override;
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;
255 virtual SdrPage* GetImplPage() const override;
257 public:
259 virtual void _propertyChange( const css::beans::PropertyChangeEvent& evt ) override;
261 /** creates the m_xMediator when it doesn't already exist.
262 @param _bReverse when set to <TRUE/> then the properties from the uno control will be copied into report control
264 void CreateMediator(bool _bReverse = false);
266 virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent() override;
268 static OUString GetDefaultName(const OUnoObject* _pObj);
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;
275 private:
276 virtual void impl_setUnoShape( const css::uno::Reference< css::uno::XInterface >& rxUnoShape ) override;
277 void impl_initializeModel_nothrow();
281 } // rptui
283 #endif // INCLUDED_REPORTDESIGN_INC_RPTOBJECT_HXX
285 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */