Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / reportdesign / inc / RptObject.hxx
blobfdaf799f72853280af168a52f48872991cbb56f2
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/container/XContainerListener.hpp>
30 #include <com/sun/star/report/XReportComponent.hpp>
31 #include <com/sun/star/report/XSection.hpp>
32 #include <svx/svdocirc.hxx>
33 #include <svx/svdogrp.hxx>
34 #include <svx/svdoashp.hxx>
36 #include <map>
38 namespace rptui
40 typedef ::std::multimap< sal_Int16, OUString > IndexToNameMap;
41 enum DlgEdHintKind
43 RPTUI_HINT_WINDOWSCROLLED,
44 RPTUI_HINT_SELECTIONCHANGED
47 class OUnoObject;
48 class REPORTDESIGN_DLLPUBLIC DlgEdHint: public SfxHint
50 private:
51 DlgEdHintKind const eHintKind;
53 DlgEdHint(DlgEdHint const &) = delete;
54 void operator =(DlgEdHint const &) = delete;
55 public:
56 DlgEdHint( DlgEdHintKind eHint );
57 virtual ~DlgEdHint() override;
59 DlgEdHintKind GetKind() const { return eHintKind; }
63 class OReportPage;
64 class OPropertyMediator;
66 class REPORTDESIGN_DLLPUBLIC OObjectBase
68 protected:
69 mutable rtl::Reference<OPropertyMediator> m_xMediator;
70 mutable css::uno::Reference< css::beans::XPropertyChangeListener> m_xPropertyChangeListener;
71 mutable css::uno::Reference< css::report::XReportComponent> m_xReportComponent;
72 css::uno::Reference< css::uno::XInterface > m_xKeepShapeAlive;
73 OUString const m_sComponentName;
74 bool m_bIsListening;
76 OObjectBase(const css::uno::Reference< css::report::XReportComponent>& _xComponent);
77 OObjectBase(const OUString& _sComponentName);
79 virtual ~OObjectBase();
81 bool isListening() const { return m_bIsListening; }
83 void SetPropsFromRect(const tools::Rectangle& _rRect);
85 virtual SdrPage* GetImplPage() const = 0;
87 /** called by instances of derived classes to implement their overriding of getUnoShape
89 css::uno::Reference< css::uno::XInterface >
90 getUnoShapeOf( SdrObject& _rSdrObject );
92 private:
93 static void ensureSdrObjectOwnership(
94 const css::uno::Reference< css::uno::XInterface >& _rxShape );
96 public:
97 OObjectBase(const OObjectBase&) = delete;
98 OObjectBase& operator=(const OObjectBase&) = delete;
99 void StartListening();
100 void EndListening();
101 // PropertyChangeListener
102 /// @throws css::uno::RuntimeException
103 virtual void _propertyChange( const css::beans::PropertyChangeEvent& evt );
104 virtual void initializeOle() {}
106 bool supportsService( const OUString& _sServiceName ) const;
108 const css::uno::Reference< css::report::XReportComponent>& getReportComponent() const { return m_xReportComponent;}
109 virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent();
110 css::uno::Reference< css::report::XSection> getSection() const;
111 const OUString& getServiceName() const { return m_sComponentName; }
113 /** releases the reference to our UNO shape (m_xKeepShapeAlive)
115 void releaseUnoShape() { m_xKeepShapeAlive.clear(); }
117 static SdrObject* createObject(
118 SdrModel& rTargetModel,
119 const css::uno::Reference< css::report::XReportComponent>& _xComponent);
120 static sal_uInt16 getObjectType(const css::uno::Reference< css::report::XReportComponent>& _xComponent);
123 // OCustomShape
125 class REPORTDESIGN_DLLPUBLIC OCustomShape final : public SdrObjCustomShape , public OObjectBase
127 friend class OReportPage;
128 friend class DlgEdFactory;
130 private:
131 // protected destructor - due to final, make private
132 virtual ~OCustomShape() override;
134 public:
135 static OCustomShape* Create(
136 SdrModel& rSdrModel,
137 const css::uno::Reference< css::report::XReportComponent>& _xComponent)
139 return new OCustomShape(rSdrModel, _xComponent );
142 virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent() override;
144 virtual css::uno::Reference< css::uno::XInterface > getUnoShape() override;
145 virtual sal_uInt16 GetObjIdentifier() const override;
146 virtual SdrInventor GetObjInventor() const override;
148 private:
149 virtual void impl_setUnoShape( const css::uno::Reference< css::uno::XInterface >& rxUnoShape ) override;
151 OCustomShape(
152 SdrModel& rSdrModel,
153 const css::uno::Reference< css::report::XReportComponent>& _xComponent);
154 OCustomShape(
155 SdrModel& rSdrModel,
156 const OUString& _sComponentName);
158 virtual void NbcMove( const Size& rSize ) override;
159 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
160 virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override;
161 virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;
163 virtual SdrPage* GetImplPage() const override;
167 // OOle2Obj
169 class REPORTDESIGN_DLLPUBLIC OOle2Obj final : public SdrOle2Obj , public OObjectBase
171 friend class OReportPage;
172 friend class DlgEdFactory;
174 private:
175 // protected destructor - due to final, make private
176 virtual ~OOle2Obj() override;
178 public:
179 static OOle2Obj* Create(
180 SdrModel& rSdrModel,
181 const css::uno::Reference< css::report::XReportComponent>& _xComponent,
182 sal_uInt16 _nType)
184 return new OOle2Obj(rSdrModel, _xComponent, _nType);
187 virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent() override;
189 virtual css::uno::Reference< css::uno::XInterface > getUnoShape() override;
190 virtual sal_uInt16 GetObjIdentifier() const override;
191 virtual SdrInventor GetObjInventor() const override;
192 // Clone() should make a complete copy of the object.
193 virtual OOle2Obj* CloneSdrObject(SdrModel& rTargetModel) const override;
194 virtual void initializeOle() override;
196 OOle2Obj& operator=(const OOle2Obj& rObj);
198 void initializeChart( const css::uno::Reference< css::frame::XModel>& _xModel);
200 private:
201 OOle2Obj(
202 SdrModel& rSdrModel,
203 const css::uno::Reference< css::report::XReportComponent>& _xComponent,
204 sal_uInt16 _nType);
205 OOle2Obj(
206 SdrModel& rSdrModel,
207 const OUString& _sComponentName,
208 sal_uInt16 _nType);
210 virtual void NbcMove( const Size& rSize ) override;
211 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
212 virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override;
213 virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;
215 virtual SdrPage* GetImplPage() const override;
217 void impl_createDataProvider_nothrow( const css::uno::Reference< css::frame::XModel>& _xModel);
218 virtual void impl_setUnoShape( const css::uno::Reference< css::uno::XInterface >& rxUnoShape ) override;
220 sal_uInt16 const m_nType;
221 bool m_bOnlyOnce;
225 // OUnoObject
227 class REPORTDESIGN_DLLPUBLIC OUnoObject: public SdrUnoObj , public OObjectBase
229 friend class OReportPage;
230 friend class OObjectBase;
231 friend class DlgEdFactory;
233 sal_uInt16 const m_nObjectType;
234 // tdf#118730 remember if this object was created interactively (due to ::EndCreate being called)
235 bool m_bSetDefaultLabel;
237 protected:
238 OUnoObject(SdrModel& rSdrModel,
239 const OUString& _sComponentName,
240 const OUString& rModelName,
241 sal_uInt16 _nObjectType);
242 OUnoObject(
243 SdrModel& rSdrModel,
244 const css::uno::Reference< css::report::XReportComponent>& _xComponent,
245 const OUString& rModelName,
246 sal_uInt16 _nObjectType);
248 // protected destructor
249 virtual ~OUnoObject() override;
251 virtual void NbcMove( const Size& rSize ) override;
252 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
253 virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override;
254 virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;
256 virtual SdrPage* GetImplPage() const override;
258 public:
260 virtual void _propertyChange( const css::beans::PropertyChangeEvent& evt ) override;
262 /** creates the m_xMediator when it doesn't already exist.
263 @param _bReverse when set to <TRUE/> then the properties from the uno control will be copied into report control
265 void CreateMediator(bool _bReverse = false);
267 virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent() override;
269 static OUString GetDefaultName(const OUnoObject* _pObj);
271 virtual css::uno::Reference< css::uno::XInterface > getUnoShape() override;
272 virtual sal_uInt16 GetObjIdentifier() const override;
273 virtual SdrInventor GetObjInventor() const override;
274 virtual OUnoObject* CloneSdrObject(SdrModel& rTargetModel) const override;
276 OUnoObject& operator=(const OUnoObject& rObj);
278 private:
279 virtual void impl_setUnoShape( const css::uno::Reference< css::uno::XInterface >& rxUnoShape ) override;
280 void impl_initializeModel_nothrow();
284 } // rptui
286 #endif // INCLUDED_REPORTDESIGN_INC_RPTOBJECT_HXX
288 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */