1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
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>
38 typedef ::std::multimap
< sal_Int16
, OUString
> IndexToNameMap
;
41 RPTUI_HINT_WINDOWSCROLLED
,
42 RPTUI_HINT_SELECTIONCHANGED
46 class REPORTDESIGN_DLLPUBLIC DlgEdHint
: public SfxHint
49 DlgEdHintKind eHintKind
;
51 DlgEdHint(DlgEdHint
&) = delete;
52 void operator =(DlgEdHint
&) = delete;
54 DlgEdHint( DlgEdHintKind eHint
);
55 virtual ~DlgEdHint() override
;
57 DlgEdHintKind
GetKind() const { return eHintKind
; }
62 class OPropertyMediator
;
64 class REPORTDESIGN_DLLPUBLIC OObjectBase
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
;
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
);
91 static void ensureSdrObjectOwnership(
92 const css::uno::Reference
< css::uno::XInterface
>& _rxShape
);
95 OObjectBase(const OObjectBase
&) = delete;
96 OObjectBase
& operator=(const OObjectBase
&) = delete;
97 void StartListening();
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
);
123 class REPORTDESIGN_DLLPUBLIC OCustomShape final
: public SdrObjCustomShape
, public OObjectBase
125 friend class OReportPage
;
126 friend class DlgEdFactory
;
129 // protected destructor - due to final, make private
130 virtual ~OCustomShape() override
;
133 static OCustomShape
* Create(
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
;
147 virtual void impl_setUnoShape( const css::uno::Reference
< css::uno::XInterface
>& rxUnoShape
) override
;
151 const css::uno::Reference
< css::report::XReportComponent
>& _xComponent
);
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
;
167 class REPORTDESIGN_DLLPUBLIC OOle2Obj final
: public SdrOle2Obj
, public OObjectBase
169 friend class OReportPage
;
170 friend class DlgEdFactory
;
173 // protected destructor - due to final, make private
174 virtual ~OOle2Obj() override
;
177 static OOle2Obj
* Create(
179 const css::uno::Reference
< css::report::XReportComponent
>& _xComponent
,
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
);
201 const css::uno::Reference
< css::report::XReportComponent
>& _xComponent
,
205 const OUString
& _sComponentName
,
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
;
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
;
233 OUnoObject(SdrModel
& rSdrModel
,
234 const OUString
& _sComponentName
,
235 const OUString
& rModelName
,
236 sal_uInt16 _nObjectType
);
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
;
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
);
274 virtual void impl_setUnoShape( const css::uno::Reference
< css::uno::XInterface
>& rxUnoShape
) override
;
275 void impl_setReportComponent_nothrow();
276 void impl_initializeModel_nothrow();
282 #endif // INCLUDED_REPORTDESIGN_INC_RPTOBJECT_HXX
284 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */