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 <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>
39 typedef ::std::multimap
< sal_Int16
, OUString
> IndexToNameMap
;
42 RPTUI_HINT_WINDOWSCROLLED
,
43 RPTUI_HINT_SELECTIONCHANGED
47 class REPORTDESIGN_DLLPUBLIC DlgEdHint
: public SfxHint
50 DlgEdHintKind eHintKind
;
52 DlgEdHint(DlgEdHint
&) = delete;
53 void operator =(DlgEdHint
&) = delete;
55 DlgEdHint( DlgEdHintKind eHint
);
56 virtual ~DlgEdHint() override
;
58 DlgEdHintKind
GetKind() const { return eHintKind
; }
63 class OPropertyMediator
;
65 class REPORTDESIGN_DLLPUBLIC OObjectBase
68 typedef rtl::Reference
<OPropertyMediator
> TMediator
;
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
;
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
);
95 static void ensureSdrObjectOwnership(
96 const css::uno::Reference
< css::uno::XInterface
>& _rxShape
);
99 OObjectBase(const OObjectBase
&) = delete;
100 OObjectBase
& operator=(const OObjectBase
&) = delete;
101 void StartListening();
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
);
125 class REPORTDESIGN_DLLPUBLIC OCustomShape
: public SdrObjCustomShape
, public OObjectBase
127 friend class OReportPage
;
128 friend class DlgEdFactory
;
131 static OCustomShape
* Create( const css::uno::Reference
< css::report::XReportComponent
>& _xComponent
)
133 return new OCustomShape( _xComponent
);
137 OCustomShape(const css::uno::Reference
< css::report::XReportComponent
>& _xComponent
);
138 OCustomShape(const OUString
& _sComponentName
);
140 virtual void NbcMove( const Size
& rSize
) override
;
141 virtual void NbcResize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
) override
;
142 virtual void NbcSetLogicRect(const tools::Rectangle
& rRect
) override
;
143 virtual bool EndCreate(SdrDragStat
& rStat
, SdrCreateCmd eCmd
) override
;
145 virtual SdrPage
* GetImplPage() const override
;
149 virtual ~OCustomShape() override
;
151 virtual css::uno::Reference
< css::beans::XPropertySet
> getAwtComponent() override
;
153 virtual css::uno::Reference
< css::uno::XInterface
> getUnoShape() override
;
154 virtual sal_uInt16
GetObjIdentifier() const override
;
155 virtual SdrInventor
GetObjInventor() const override
;
158 virtual void impl_setUnoShape( const css::uno::Reference
< css::uno::XInterface
>& rxUnoShape
) override
;
164 class REPORTDESIGN_DLLPUBLIC OOle2Obj
: public SdrOle2Obj
, public OObjectBase
166 friend class OReportPage
;
167 friend class DlgEdFactory
;
171 void impl_createDataProvider_nothrow( const css::uno::Reference
< css::frame::XModel
>& _xModel
);
172 virtual void impl_setUnoShape( const css::uno::Reference
< css::uno::XInterface
>& rxUnoShape
) override
;
175 static OOle2Obj
* Create( const css::uno::Reference
< css::report::XReportComponent
>& _xComponent
,sal_uInt16 _nType
)
177 return new OOle2Obj( _xComponent
,_nType
);
180 OOle2Obj(const css::uno::Reference
< css::report::XReportComponent
>& _xComponent
,sal_uInt16 _nType
);
181 OOle2Obj(const OUString
& _sComponentName
,sal_uInt16 _nType
);
184 virtual void NbcMove( const Size
& rSize
) override
;
185 virtual void NbcResize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
) override
;
186 virtual void NbcSetLogicRect(const tools::Rectangle
& rRect
) override
;
187 virtual bool EndCreate(SdrDragStat
& rStat
, SdrCreateCmd eCmd
) override
;
189 virtual SdrPage
* GetImplPage() const override
;
193 virtual ~OOle2Obj() override
;
195 virtual css::uno::Reference
< css::beans::XPropertySet
> getAwtComponent() override
;
197 virtual css::uno::Reference
< css::uno::XInterface
> getUnoShape() override
;
198 virtual sal_uInt16
GetObjIdentifier() const override
;
199 virtual SdrInventor
GetObjInventor() const override
;
200 // Clone() should make a complete copy of the object.
201 virtual OOle2Obj
* Clone() const override
;
202 virtual void initializeOle() override
;
204 OOle2Obj
& operator=(const OOle2Obj
& rObj
);
206 void initializeChart( const css::uno::Reference
< css::frame::XModel
>& _xModel
);
212 class REPORTDESIGN_DLLPUBLIC OUnoObject
: public SdrUnoObj
, public OObjectBase
214 friend class OReportPage
;
215 friend class OObjectBase
;
216 friend class DlgEdFactory
;
218 sal_uInt16 m_nObjectType
;
220 OUnoObject(const OUString
& _sComponentName
221 ,const OUString
& rModelName
222 ,sal_uInt16 _nObjectType
);
223 OUnoObject( const css::uno::Reference
< css::report::XReportComponent
>& _xComponent
224 ,const OUString
& rModelName
225 ,sal_uInt16 _nObjectType
);
227 virtual ~OUnoObject() override
;
229 virtual void NbcMove( const Size
& rSize
) override
;
230 virtual void NbcResize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
) override
;
231 virtual void NbcSetLogicRect(const tools::Rectangle
& rRect
) override
;
232 virtual bool EndCreate(SdrDragStat
& rStat
, SdrCreateCmd eCmd
) override
;
234 virtual SdrPage
* GetImplPage() const override
;
238 virtual void _propertyChange( const css::beans::PropertyChangeEvent
& evt
) override
;
240 /** creates the m_xMediator when it doesn't already exist.
241 @param _bReverse when set to <TRUE/> then the properties from the uno control will be copied into report control
243 void CreateMediator(bool _bReverse
= false);
245 virtual css::uno::Reference
< css::beans::XPropertySet
> getAwtComponent() override
;
247 static OUString
GetDefaultName(const OUnoObject
* _pObj
);
249 virtual css::uno::Reference
< css::uno::XInterface
> getUnoShape() override
;
250 virtual sal_uInt16
GetObjIdentifier() const override
;
251 virtual SdrInventor
GetObjInventor() const override
;
252 virtual OUnoObject
* Clone() const override
;
254 OUnoObject
& operator=(const OUnoObject
& rObj
);
257 virtual void impl_setUnoShape( const css::uno::Reference
< css::uno::XInterface
>& rxUnoShape
) override
;
258 void impl_setReportComponent_nothrow();
259 void impl_initializeModel_nothrow();
265 #endif // INCLUDED_REPORTDESIGN_INC_RPTOBJECT_HXX
267 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */