Bump version to 6.0-36
[LibreOffice.git] / reportdesign / inc / RptObject.hxx
blob5a8e53d912d204555d4ff652d14261b4fbb33bc7
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 <comphelper/processfactory.hxx>
29 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
30 #include <com/sun/star/container/XContainerListener.hpp>
31 #include <com/sun/star/report/XReportComponent.hpp>
32 #include <com/sun/star/report/XSection.hpp>
33 #include <svx/svdocirc.hxx>
34 #include <svx/svdogrp.hxx>
35 #include <svx/svdoashp.hxx>
37 namespace rptui
39 typedef ::std::multimap< sal_Int16, OUString > IndexToNameMap;
40 enum DlgEdHintKind
42 RPTUI_HINT_WINDOWSCROLLED,
43 RPTUI_HINT_SELECTIONCHANGED
46 class OUnoObject;
47 class REPORTDESIGN_DLLPUBLIC DlgEdHint: public SfxHint
49 private:
50 DlgEdHintKind eHintKind;
52 DlgEdHint(DlgEdHint&) = delete;
53 void operator =(DlgEdHint&) = delete;
54 public:
55 DlgEdHint( DlgEdHintKind eHint );
56 virtual ~DlgEdHint() override;
58 DlgEdHintKind GetKind() const { return eHintKind; }
62 class OReportPage;
63 class OPropertyMediator;
65 class REPORTDESIGN_DLLPUBLIC OObjectBase
67 public:
68 typedef rtl::Reference<OPropertyMediator> TMediator;
70 protected:
71 mutable TMediator m_xMediator;
72 mutable css::uno::Reference< css::beans::XPropertyChangeListener> m_xPropertyChangeListener;
73 mutable css::uno::Reference< css::report::XReportComponent> m_xReportComponent;
74 css::uno::Reference< css::uno::XInterface > m_xKeepShapeAlive;
75 OUString m_sComponentName;
76 bool m_bIsListening;
78 OObjectBase(const css::uno::Reference< css::report::XReportComponent>& _xComponent);
79 OObjectBase(const OUString& _sComponentName);
81 virtual ~OObjectBase();
83 bool isListening() const { return m_bIsListening; }
85 void SetPropsFromRect(const tools::Rectangle& _rRect);
87 virtual SdrPage* GetImplPage() const = 0;
89 /** called by instances of derived classes to implement their overriding of getUnoShape
91 css::uno::Reference< css::uno::XInterface >
92 getUnoShapeOf( SdrObject& _rSdrObject );
94 private:
95 static void ensureSdrObjectOwnership(
96 const css::uno::Reference< css::uno::XInterface >& _rxShape );
98 public:
99 OObjectBase(const OObjectBase&) = delete;
100 OObjectBase& operator=(const OObjectBase&) = delete;
101 void StartListening();
102 void EndListening();
103 // PropertyChangeListener
104 /// @throws css::uno::RuntimeException
105 virtual void _propertyChange( const css::beans::PropertyChangeEvent& evt );
106 virtual void initializeOle() {}
108 bool supportsService( const OUString& _sServiceName ) const;
110 const css::uno::Reference< css::report::XReportComponent>& getReportComponent() const { return m_xReportComponent;}
111 virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent();
112 css::uno::Reference< css::report::XSection> getSection() const;
113 const OUString& getServiceName() const { return m_sComponentName; }
115 /** releases the reference to our UNO shape (m_xKeepShapeAlive)
117 void releaseUnoShape() { m_xKeepShapeAlive.clear(); }
119 static SdrObject* createObject(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;
129 public:
130 static OCustomShape* Create( const css::uno::Reference< css::report::XReportComponent>& _xComponent )
132 return new OCustomShape( _xComponent );
135 virtual ~OCustomShape() override;
137 virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent() override;
139 virtual css::uno::Reference< css::uno::XInterface > getUnoShape() override;
140 virtual sal_uInt16 GetObjIdentifier() const override;
141 virtual SdrInventor GetObjInventor() const override;
143 private:
144 virtual void impl_setUnoShape( const css::uno::Reference< css::uno::XInterface >& rxUnoShape ) override;
146 OCustomShape(const css::uno::Reference< css::report::XReportComponent>& _xComponent);
147 OCustomShape(const OUString& _sComponentName);
149 virtual void NbcMove( const Size& rSize ) override;
150 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
151 virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override;
152 virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;
154 virtual SdrPage* GetImplPage() const override;
158 // OOle2Obj
160 class REPORTDESIGN_DLLPUBLIC OOle2Obj final : public SdrOle2Obj , public OObjectBase
162 friend class OReportPage;
163 friend class DlgEdFactory;
164 public:
165 static OOle2Obj* Create( const css::uno::Reference< css::report::XReportComponent>& _xComponent,sal_uInt16 _nType )
167 return new OOle2Obj( _xComponent,_nType );
170 virtual ~OOle2Obj() override;
172 virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent() override;
174 virtual css::uno::Reference< css::uno::XInterface > getUnoShape() override;
175 virtual sal_uInt16 GetObjIdentifier() const override;
176 virtual SdrInventor GetObjInventor() const override;
177 // Clone() should make a complete copy of the object.
178 virtual OOle2Obj* Clone() const override;
179 virtual void initializeOle() override;
181 OOle2Obj& operator=(const OOle2Obj& rObj);
183 void initializeChart( const css::uno::Reference< css::frame::XModel>& _xModel);
185 private:
186 OOle2Obj(const css::uno::Reference< css::report::XReportComponent>& _xComponent,sal_uInt16 _nType);
187 OOle2Obj(const OUString& _sComponentName,sal_uInt16 _nType);
190 virtual void NbcMove( const Size& rSize ) override;
191 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
192 virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override;
193 virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;
195 virtual SdrPage* GetImplPage() const override;
197 void impl_createDataProvider_nothrow( const css::uno::Reference< css::frame::XModel>& _xModel);
198 virtual void impl_setUnoShape( const css::uno::Reference< css::uno::XInterface >& rxUnoShape ) override;
200 sal_uInt16 m_nType;
201 bool m_bOnlyOnce;
205 // OUnoObject
207 class REPORTDESIGN_DLLPUBLIC OUnoObject: public SdrUnoObj , public OObjectBase
209 friend class OReportPage;
210 friend class OObjectBase;
211 friend class DlgEdFactory;
213 sal_uInt16 m_nObjectType;
214 protected:
215 OUnoObject(const OUString& _sComponentName
216 ,const OUString& rModelName
217 ,sal_uInt16 _nObjectType);
218 OUnoObject( const css::uno::Reference< css::report::XReportComponent>& _xComponent
219 ,const OUString& rModelName
220 ,sal_uInt16 _nObjectType);
222 virtual ~OUnoObject() override;
224 virtual void NbcMove( const Size& rSize ) override;
225 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
226 virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override;
227 virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;
229 virtual SdrPage* GetImplPage() const override;
231 public:
233 virtual void _propertyChange( const css::beans::PropertyChangeEvent& evt ) override;
235 /** creates the m_xMediator when it doesn't already exist.
236 @param _bReverse when set to <TRUE/> then the properties from the uno control will be copied into report control
238 void CreateMediator(bool _bReverse = false);
240 virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent() override;
242 static OUString GetDefaultName(const OUnoObject* _pObj);
244 virtual css::uno::Reference< css::uno::XInterface > getUnoShape() override;
245 virtual sal_uInt16 GetObjIdentifier() const override;
246 virtual SdrInventor GetObjInventor() const override;
247 virtual OUnoObject* Clone() const override;
249 OUnoObject& operator=(const OUnoObject& rObj);
251 private:
252 virtual void impl_setUnoShape( const css::uno::Reference< css::uno::XInterface >& rxUnoShape ) override;
253 void impl_setReportComponent_nothrow();
254 void impl_initializeModel_nothrow();
258 } // rptui
260 #endif // INCLUDED_REPORTDESIGN_INC_RPTOBJECT_HXX
262 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */