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/report/XReportComponent.hpp>
30 #include <com/sun/star/report/XSection.hpp>
31 #include <svx/svdoashp.hxx>
37 typedef ::std::multimap
< sal_Int16
, OUString
> IndexToNameMap
;
40 RPTUI_HINT_WINDOWSCROLLED
,
41 RPTUI_HINT_SELECTIONCHANGED
45 class REPORTDESIGN_DLLPUBLIC DlgEdHint final
: public SfxHint
48 DlgEdHintKind eHintKind
;
50 DlgEdHint(DlgEdHint
const &) = delete;
51 void operator =(DlgEdHint
const &) = delete;
53 DlgEdHint( DlgEdHintKind eHint
);
54 virtual ~DlgEdHint() override
;
56 DlgEdHintKind
GetKind() const { return eHintKind
; }
61 class OPropertyMediator
;
63 class REPORTDESIGN_DLLPUBLIC
SAL_LOPLUGIN_ANNOTATE("crosscast") OObjectBase
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
;
73 OObjectBase(const css::uno::Reference
< css::report::XReportComponent
>& _xComponent
);
74 OObjectBase(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::drawing::XShape
>
87 getUnoShapeOf( SdrObject
& _rSdrObject
);
90 OObjectBase(const OObjectBase
&) = delete;
91 OObjectBase
& operator=(const OObjectBase
&) = delete;
92 void StartListening();
94 // PropertyChangeListener
95 /// @throws css::uno::RuntimeException
96 virtual void _propertyChange( const css::beans::PropertyChangeEvent
& evt
);
97 virtual void initializeOle() {}
99 bool supportsService( const OUString
& _sServiceName
) const;
101 const css::uno::Reference
< css::report::XReportComponent
>& getReportComponent() const { return m_xReportComponent
;}
102 virtual css::uno::Reference
< css::beans::XPropertySet
> getAwtComponent();
103 css::uno::Reference
< css::report::XSection
> getSection() const;
104 const OUString
& getServiceName() const { return m_sComponentName
; }
106 /** releases the reference to our UNO shape (m_xKeepShapeAlive)
108 void releaseUnoShape() { m_xKeepShapeAlive
.clear(); }
110 static rtl::Reference
<SdrObject
> createObject(
111 SdrModel
& rTargetModel
,
112 const css::uno::Reference
< css::report::XReportComponent
>& _xComponent
);
113 static SdrObjKind
getObjectType(const css::uno::Reference
< css::report::XReportComponent
>& _xComponent
);
118 class REPORTDESIGN_DLLPUBLIC OCustomShape final
: public SdrObjCustomShape
, public OObjectBase
120 friend class OReportPage
;
121 friend class DlgEdFactory
;
124 // protected destructor - due to final, make private
125 virtual ~OCustomShape() override
;
128 static rtl::Reference
<OCustomShape
> Create(
130 const css::uno::Reference
< css::report::XReportComponent
>& _xComponent
)
132 return new OCustomShape(rSdrModel
, _xComponent
);
135 virtual css::uno::Reference
< css::beans::XPropertySet
> getAwtComponent() override
;
137 virtual css::uno::Reference
< css::drawing::XShape
> getUnoShape() override
;
138 virtual SdrObjKind
GetObjIdentifier() const override
;
139 virtual SdrInventor
GetObjInventor() const override
;
142 virtual void setUnoShape( const css::uno::Reference
< css::drawing::XShape
>& rxUnoShape
) override
;
146 const css::uno::Reference
< css::report::XReportComponent
>& _xComponent
);
149 const OUString
& _sComponentName
);
151 virtual void NbcMove( const Size
& rSize
) override
;
152 virtual void NbcResize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
) override
;
153 virtual void NbcSetLogicRect(const tools::Rectangle
& rRect
) override
;
154 virtual bool EndCreate(SdrDragStat
& rStat
, SdrCreateCmd eCmd
) override
;
156 virtual SdrPage
* GetImplPage() const override
;
162 class REPORTDESIGN_DLLPUBLIC OOle2Obj final
: public SdrOle2Obj
, public OObjectBase
164 friend class OReportPage
;
165 friend class DlgEdFactory
;
168 // protected destructor - due to final, make private
169 virtual ~OOle2Obj() override
;
172 static rtl::Reference
<OOle2Obj
> Create(
174 const css::uno::Reference
< css::report::XReportComponent
>& _xComponent
,
177 return new OOle2Obj(rSdrModel
, _xComponent
, _nType
);
180 virtual css::uno::Reference
< css::beans::XPropertySet
> getAwtComponent() override
;
182 virtual css::uno::Reference
< css::drawing::XShape
> getUnoShape() override
;
183 virtual SdrObjKind
GetObjIdentifier() const override
;
184 virtual SdrInventor
GetObjInventor() const override
;
185 // Clone() should make a complete copy of the object.
186 virtual rtl::Reference
<SdrObject
> CloneSdrObject(SdrModel
& rTargetModel
) const override
;
187 virtual void initializeOle() override
;
189 void initializeChart( const css::uno::Reference
< css::frame::XModel
>& _xModel
);
194 const css::uno::Reference
< css::report::XReportComponent
>& _xComponent
,
198 const OUString
& _sComponentName
,
201 OOle2Obj(SdrModel
& rSdrModel
, const OOle2Obj
& rSource
);
203 virtual void NbcMove( const Size
& rSize
) override
;
204 virtual void NbcResize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
) override
;
205 virtual void NbcSetLogicRect(const tools::Rectangle
& rRect
) override
;
206 virtual bool EndCreate(SdrDragStat
& rStat
, SdrCreateCmd eCmd
) override
;
208 virtual SdrPage
* GetImplPage() const override
;
210 void impl_createDataProvider_nothrow( const css::uno::Reference
< css::frame::XModel
>& _xModel
);
211 virtual void setUnoShape( const css::uno::Reference
< css::drawing::XShape
>& rxUnoShape
) override
;
220 class REPORTDESIGN_DLLPUBLIC OUnoObject final
: public SdrUnoObj
, public OObjectBase
222 friend class OReportPage
;
223 friend class OObjectBase
;
224 friend class DlgEdFactory
;
226 SdrObjKind m_nObjectType
;
227 // tdf#118730 remember if this object was created interactively (due to ::EndCreate being called)
228 bool m_bSetDefaultLabel
;
230 OUnoObject(SdrModel
& rSdrModel
,
231 const OUString
& _sComponentName
,
232 const OUString
& rModelName
,
233 SdrObjKind _nObjectType
);
236 const css::uno::Reference
< css::report::XReportComponent
>& _xComponent
,
237 const OUString
& rModelName
,
238 SdrObjKind _nObjectType
);
240 OUnoObject(SdrModel
& rSdrModel
, OUnoObject
const & rSource
);
242 // protected destructor
243 virtual ~OUnoObject() override
;
245 virtual void NbcMove( const Size
& rSize
) override
;
246 virtual void NbcResize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
) override
;
247 virtual void NbcSetLogicRect(const tools::Rectangle
& rRect
) override
;
248 virtual bool EndCreate(SdrDragStat
& rStat
, SdrCreateCmd eCmd
) override
;
250 virtual SdrPage
* GetImplPage() const override
;
254 virtual void _propertyChange( const css::beans::PropertyChangeEvent
& evt
) override
;
256 /** creates the m_xMediator when it doesn't already exist.
257 @param _bReverse when set to <TRUE/> then the properties from the uno control will be copied into report control
259 void CreateMediator(bool _bReverse
= false);
261 virtual css::uno::Reference
< css::beans::XPropertySet
> getAwtComponent() override
;
263 static OUString
GetDefaultName(const OUnoObject
* _pObj
);
265 virtual css::uno::Reference
< css::drawing::XShape
> getUnoShape() override
;
266 virtual SdrObjKind
GetObjIdentifier() const override
;
267 virtual SdrInventor
GetObjInventor() const override
;
268 virtual rtl::Reference
<SdrObject
> CloneSdrObject(SdrModel
& rTargetModel
) const override
;
271 virtual void setUnoShape( const css::uno::Reference
< css::drawing::XShape
>& rxUnoShape
) override
;
272 void impl_initializeModel_nothrow();
278 #endif // INCLUDED_REPORTDESIGN_INC_RPTOBJECT_HXX
280 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */