Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / reportdesign / inc / RptObject.hxx
blobb078e1f7d143546d446da3a3ff0e0fb72730b540
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 namespace rptui
38 typedef ::std::multimap< sal_Int16, OUString > IndexToNameMap;
39 enum DlgEdHintKind
41 RPTUI_HINT_WINDOWSCROLLED,
42 RPTUI_HINT_SELECTIONCHANGED
45 class OUnoObject;
46 class REPORTDESIGN_DLLPUBLIC DlgEdHint: public SfxHint
48 private:
49 DlgEdHintKind eHintKind;
51 DlgEdHint(DlgEdHint&) = delete;
52 void operator =(DlgEdHint&) = delete;
53 public:
54 DlgEdHint( DlgEdHintKind eHint );
55 virtual ~DlgEdHint() override;
57 DlgEdHintKind GetKind() const { return eHintKind; }
61 class OReportPage;
62 class OPropertyMediator;
64 class REPORTDESIGN_DLLPUBLIC OObjectBase
66 protected:
67 mutable rtl::Reference<OPropertyMediator> m_xMediator;
68 mutable css::uno::Reference< css::beans::XPropertyChangeListener> m_xPropertyChangeListener;
69 mutable css::uno::Reference< css::report::XReportComponent> m_xReportComponent;
70 css::uno::Reference< css::uno::XInterface > m_xKeepShapeAlive;
71 OUString m_sComponentName;
72 bool m_bIsListening;
74 OObjectBase(const css::uno::Reference< css::report::XReportComponent>& _xComponent);
75 OObjectBase(const OUString& _sComponentName);
77 virtual ~OObjectBase();
79 bool isListening() const { return m_bIsListening; }
81 void SetPropsFromRect(const tools::Rectangle& _rRect);
83 virtual SdrPage* GetImplPage() const = 0;
85 /** called by instances of derived classes to implement their overriding of getUnoShape
87 css::uno::Reference< css::uno::XInterface >
88 getUnoShapeOf( SdrObject& _rSdrObject );
90 private:
91 static void ensureSdrObjectOwnership(
92 const css::uno::Reference< css::uno::XInterface >& _rxShape );
94 public:
95 OObjectBase(const OObjectBase&) = delete;
96 OObjectBase& operator=(const OObjectBase&) = delete;
97 void StartListening();
98 void EndListening();
99 // PropertyChangeListener
100 /// @throws css::uno::RuntimeException
101 virtual void _propertyChange( const css::beans::PropertyChangeEvent& evt );
102 virtual void initializeOle() {}
104 bool supportsService( const OUString& _sServiceName ) const;
106 const css::uno::Reference< css::report::XReportComponent>& getReportComponent() const { return m_xReportComponent;}
107 virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent();
108 css::uno::Reference< css::report::XSection> getSection() const;
109 const OUString& getServiceName() const { return m_sComponentName; }
111 /** releases the reference to our UNO shape (m_xKeepShapeAlive)
113 void releaseUnoShape() { m_xKeepShapeAlive.clear(); }
115 static SdrObject* createObject(
116 SdrModel& rTargetModel,
117 const css::uno::Reference< css::report::XReportComponent>& _xComponent);
118 static sal_uInt16 getObjectType(const css::uno::Reference< css::report::XReportComponent>& _xComponent);
121 // OCustomShape
123 class REPORTDESIGN_DLLPUBLIC OCustomShape final : public SdrObjCustomShape , public OObjectBase
125 friend class OReportPage;
126 friend class DlgEdFactory;
128 private:
129 // protected destructor - due to final, make private
130 virtual ~OCustomShape() override;
132 public:
133 static OCustomShape* Create(
134 SdrModel& rSdrModel,
135 const css::uno::Reference< css::report::XReportComponent>& _xComponent)
137 return new OCustomShape(rSdrModel, _xComponent );
140 virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent() override;
142 virtual css::uno::Reference< css::uno::XInterface > getUnoShape() override;
143 virtual sal_uInt16 GetObjIdentifier() const override;
144 virtual SdrInventor GetObjInventor() const override;
146 private:
147 virtual void impl_setUnoShape( const css::uno::Reference< css::uno::XInterface >& rxUnoShape ) override;
149 OCustomShape(
150 SdrModel& rSdrModel,
151 const css::uno::Reference< css::report::XReportComponent>& _xComponent);
152 OCustomShape(
153 SdrModel& rSdrModel,
154 const OUString& _sComponentName);
156 virtual void NbcMove( const Size& rSize ) override;
157 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
158 virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override;
159 virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;
161 virtual SdrPage* GetImplPage() const override;
165 // OOle2Obj
167 class REPORTDESIGN_DLLPUBLIC OOle2Obj final : public SdrOle2Obj , public OObjectBase
169 friend class OReportPage;
170 friend class DlgEdFactory;
172 private:
173 // protected destructor - due to final, make private
174 virtual ~OOle2Obj() override;
176 public:
177 static OOle2Obj* Create(
178 SdrModel& rSdrModel,
179 const css::uno::Reference< css::report::XReportComponent>& _xComponent,
180 sal_uInt16 _nType)
182 return new OOle2Obj(rSdrModel, _xComponent, _nType);
185 virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent() override;
187 virtual css::uno::Reference< css::uno::XInterface > getUnoShape() override;
188 virtual sal_uInt16 GetObjIdentifier() const override;
189 virtual SdrInventor GetObjInventor() const override;
190 // Clone() should make a complete copy of the object.
191 virtual OOle2Obj* CloneSdrObject(SdrModel& rTargetModel) const override;
192 virtual void initializeOle() override;
194 OOle2Obj& operator=(const OOle2Obj& rObj);
196 void initializeChart( const css::uno::Reference< css::frame::XModel>& _xModel);
198 private:
199 OOle2Obj(
200 SdrModel& rSdrModel,
201 const css::uno::Reference< css::report::XReportComponent>& _xComponent,
202 sal_uInt16 _nType);
203 OOle2Obj(
204 SdrModel& rSdrModel,
205 const OUString& _sComponentName,
206 sal_uInt16 _nType);
208 virtual void NbcMove( const Size& rSize ) override;
209 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
210 virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override;
211 virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;
213 virtual SdrPage* GetImplPage() const override;
215 void impl_createDataProvider_nothrow( const css::uno::Reference< css::frame::XModel>& _xModel);
216 virtual void impl_setUnoShape( const css::uno::Reference< css::uno::XInterface >& rxUnoShape ) override;
218 sal_uInt16 m_nType;
219 bool m_bOnlyOnce;
223 // OUnoObject
225 class REPORTDESIGN_DLLPUBLIC OUnoObject: public SdrUnoObj , public OObjectBase
227 friend class OReportPage;
228 friend class OObjectBase;
229 friend class DlgEdFactory;
231 sal_uInt16 m_nObjectType;
232 protected:
233 OUnoObject(SdrModel& rSdrModel,
234 const OUString& _sComponentName,
235 const OUString& rModelName,
236 sal_uInt16 _nObjectType);
237 OUnoObject(
238 SdrModel& rSdrModel,
239 const css::uno::Reference< css::report::XReportComponent>& _xComponent,
240 const OUString& rModelName,
241 sal_uInt16 _nObjectType);
243 // protected destructor
244 virtual ~OUnoObject() override;
246 virtual void NbcMove( const Size& rSize ) override;
247 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
248 virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override;
249 virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;
251 virtual SdrPage* GetImplPage() const override;
253 public:
255 virtual void _propertyChange( const css::beans::PropertyChangeEvent& evt ) override;
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
260 void CreateMediator(bool _bReverse = false);
262 virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent() override;
264 static OUString GetDefaultName(const OUnoObject* _pObj);
266 virtual css::uno::Reference< css::uno::XInterface > getUnoShape() override;
267 virtual sal_uInt16 GetObjIdentifier() const override;
268 virtual SdrInventor GetObjInventor() const override;
269 virtual OUnoObject* CloneSdrObject(SdrModel& rTargetModel) const override;
271 OUnoObject& operator=(const OUnoObject& rObj);
273 private:
274 virtual void impl_setUnoShape( const css::uno::Reference< css::uno::XInterface >& rxUnoShape ) override;
275 void impl_setReportComponent_nothrow();
276 void impl_initializeModel_nothrow();
280 } // rptui
282 #endif // INCLUDED_REPORTDESIGN_INC_RPTOBJECT_HXX
284 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */