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 inline 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 inline bool isListening() const { return m_bIsListening
; }
85 void SetPropsFromRect(const 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();
102 void EndListening(bool bRemoveListener
= true);
103 // PropertyChangeListener
104 virtual void _propertyChange( const css::beans::PropertyChangeEvent
& evt
) throw(css::uno::RuntimeException
);
105 virtual void initializeOle() {}
107 bool supportsService( const OUString
& _sServiceName
) const;
109 const css::uno::Reference
< css::report::XReportComponent
>& getReportComponent() const { return m_xReportComponent
;}
110 virtual css::uno::Reference
< css::beans::XPropertySet
> getAwtComponent();
111 css::uno::Reference
< css::report::XSection
> getSection() const;
112 const OUString
& getServiceName() const { return m_sComponentName
; }
114 /** releases the reference to our UNO shape (m_xKeepShapeAlive)
116 void releaseUnoShape() { m_xKeepShapeAlive
.clear(); }
118 static SdrObject
* createObject(const css::uno::Reference
< css::report::XReportComponent
>& _xComponent
);
119 static sal_uInt16
getObjectType(const css::uno::Reference
< css::report::XReportComponent
>& _xComponent
);
124 class REPORTDESIGN_DLLPUBLIC OCustomShape
: public SdrObjCustomShape
, public OObjectBase
126 friend class OReportPage
;
127 friend class DlgEdFactory
;
130 static OCustomShape
* Create( const css::uno::Reference
< css::report::XReportComponent
>& _xComponent
)
132 return new OCustomShape( _xComponent
);
136 OCustomShape(const css::uno::Reference
< css::report::XReportComponent
>& _xComponent
);
137 OCustomShape(const OUString
& _sComponentName
);
139 virtual void NbcMove( const Size
& rSize
) override
;
140 virtual void NbcResize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
) override
;
141 virtual void NbcSetLogicRect(const Rectangle
& rRect
) override
;
142 virtual bool EndCreate(SdrDragStat
& rStat
, SdrCreateCmd eCmd
) override
;
144 virtual SdrPage
* GetImplPage() const override
;
148 virtual ~OCustomShape() override
;
150 virtual css::uno::Reference
< css::beans::XPropertySet
> getAwtComponent() override
;
152 virtual css::uno::Reference
< css::uno::XInterface
> getUnoShape() override
;
153 virtual sal_uInt16
GetObjIdentifier() const override
;
154 virtual SdrInventor
GetObjInventor() const override
;
157 virtual void impl_setUnoShape( const css::uno::Reference
< css::uno::XInterface
>& rxUnoShape
) override
;
163 class REPORTDESIGN_DLLPUBLIC OOle2Obj
: public SdrOle2Obj
, public OObjectBase
165 friend class OReportPage
;
166 friend class DlgEdFactory
;
170 void impl_createDataProvider_nothrow( const css::uno::Reference
< css::frame::XModel
>& _xModel
);
171 virtual void impl_setUnoShape( const css::uno::Reference
< css::uno::XInterface
>& rxUnoShape
) override
;
174 static OOle2Obj
* Create( const css::uno::Reference
< css::report::XReportComponent
>& _xComponent
,sal_uInt16 _nType
)
176 return new OOle2Obj( _xComponent
,_nType
);
179 OOle2Obj(const css::uno::Reference
< css::report::XReportComponent
>& _xComponent
,sal_uInt16 _nType
);
180 OOle2Obj(const OUString
& _sComponentName
,sal_uInt16 _nType
);
183 virtual void NbcMove( const Size
& rSize
) override
;
184 virtual void NbcResize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
) override
;
185 virtual void NbcSetLogicRect(const Rectangle
& rRect
) override
;
186 virtual bool EndCreate(SdrDragStat
& rStat
, SdrCreateCmd eCmd
) override
;
188 virtual SdrPage
* GetImplPage() const override
;
192 virtual ~OOle2Obj() override
;
194 virtual css::uno::Reference
< css::beans::XPropertySet
> getAwtComponent() override
;
196 virtual css::uno::Reference
< css::uno::XInterface
> getUnoShape() override
;
197 virtual sal_uInt16
GetObjIdentifier() const override
;
198 virtual SdrInventor
GetObjInventor() const override
;
199 // Clone() should make a complete copy of the object.
200 virtual OOle2Obj
* Clone() const override
;
201 virtual void initializeOle() override
;
203 OOle2Obj
& operator=(const OOle2Obj
& rObj
);
205 void initializeChart( const css::uno::Reference
< css::frame::XModel
>& _xModel
);
211 class REPORTDESIGN_DLLPUBLIC OUnoObject
: public SdrUnoObj
, public OObjectBase
213 friend class OReportPage
;
214 friend class OObjectBase
;
215 friend class DlgEdFactory
;
217 sal_uInt16 m_nObjectType
;
219 OUnoObject(const OUString
& _sComponentName
220 ,const OUString
& rModelName
221 ,sal_uInt16 _nObjectType
);
222 OUnoObject( const css::uno::Reference
< css::report::XReportComponent
>& _xComponent
223 ,const OUString
& rModelName
224 ,sal_uInt16 _nObjectType
);
226 virtual ~OUnoObject() override
;
228 virtual void NbcMove( const Size
& rSize
) override
;
229 virtual void NbcResize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
) override
;
230 virtual void NbcSetLogicRect(const Rectangle
& rRect
) override
;
231 virtual bool EndCreate(SdrDragStat
& rStat
, SdrCreateCmd eCmd
) override
;
233 virtual SdrPage
* GetImplPage() const override
;
237 virtual void _propertyChange( const css::beans::PropertyChangeEvent
& evt
) throw(css::uno::RuntimeException
) override
;
239 /** creates the m_xMediator when it doesn't already exist.
240 @param _bReverse when set to <TRUE/> then the properties from the uno control will be copied into report control
242 void CreateMediator(bool _bReverse
= false);
244 virtual css::uno::Reference
< css::beans::XPropertySet
> getAwtComponent() override
;
246 static OUString
GetDefaultName(const OUnoObject
* _pObj
);
248 virtual css::uno::Reference
< css::uno::XInterface
> getUnoShape() override
;
249 virtual sal_uInt16
GetObjIdentifier() const override
;
250 virtual SdrInventor
GetObjInventor() const override
;
251 virtual OUnoObject
* Clone() const override
;
253 OUnoObject
& operator=(const OUnoObject
& rObj
);
256 virtual void impl_setUnoShape( const css::uno::Reference
< css::uno::XInterface
>& rxUnoShape
) override
;
257 void impl_setReportComponent_nothrow();
258 void impl_initializeModel_nothrow();
264 #endif // INCLUDED_REPORTDESIGN_INC_RPTOBJECT_HXX
266 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */