Fix CppunitTest_sc_subsequent_filters_test2 on non-default DPI
[LibreOffice.git] / reportdesign / inc / RptObject.hxx
blob566dc20a13fc10e2d13dc47ce8fe6bfcda1c029d
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 <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>
33 #include <map>
35 namespace rptui
37 typedef ::std::multimap< sal_Int16, OUString > IndexToNameMap;
38 enum DlgEdHintKind
40 RPTUI_HINT_WINDOWSCROLLED,
41 RPTUI_HINT_SELECTIONCHANGED
44 class OUnoObject;
45 class REPORTDESIGN_DLLPUBLIC DlgEdHint final : public SfxHint
47 private:
48 DlgEdHintKind eHintKind;
50 DlgEdHint(DlgEdHint const &) = delete;
51 void operator =(DlgEdHint const &) = delete;
52 public:
53 DlgEdHint( DlgEdHintKind eHint );
54 virtual ~DlgEdHint() override;
56 DlgEdHintKind GetKind() const { return eHintKind; }
60 class OReportPage;
61 class OPropertyMediator;
63 class REPORTDESIGN_DLLPUBLIC OObjectBase
65 protected:
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 OUString m_sComponentName;
70 bool m_bIsListening;
72 OObjectBase(const css::uno::Reference< css::report::XReportComponent>& _xComponent);
73 OObjectBase(OUString _sComponentName);
75 virtual ~OObjectBase();
77 bool isListening() const { return m_bIsListening; }
79 void SetPropsFromRect(const tools::Rectangle& _rRect);
81 virtual SdrPage* GetImplPage() const = 0;
83 /** called by instances of derived classes to implement their overriding of getUnoShape
85 static css::uno::Reference< css::drawing::XShape >
86 getUnoShapeOf( SdrObject& _rSdrObject );
88 public:
89 OObjectBase(const OObjectBase&) = delete;
90 OObjectBase& operator=(const OObjectBase&) = delete;
91 void StartListening();
92 void EndListening();
93 // PropertyChangeListener
94 /// @throws css::uno::RuntimeException
95 virtual void _propertyChange( const css::beans::PropertyChangeEvent& evt );
96 virtual void initializeOle() {}
98 bool supportsService( const OUString& _sServiceName ) const;
100 const css::uno::Reference< css::report::XReportComponent>& getReportComponent() const { return m_xReportComponent;}
101 virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent();
102 css::uno::Reference< css::report::XSection> getSection() const;
103 const OUString& getServiceName() const { return m_sComponentName; }
105 static rtl::Reference<SdrObject> createObject(
106 SdrModel& rTargetModel,
107 const css::uno::Reference< css::report::XReportComponent>& _xComponent);
108 static SdrObjKind getObjectType(const css::uno::Reference< css::report::XReportComponent>& _xComponent);
111 // OCustomShape
113 class REPORTDESIGN_DLLPUBLIC OCustomShape final : public SdrObjCustomShape , public OObjectBase
115 friend class OReportPage;
116 friend class DlgEdFactory;
118 private:
119 // protected destructor - due to final, make private
120 virtual ~OCustomShape() override;
122 public:
123 static rtl::Reference<OCustomShape> Create(
124 SdrModel& rSdrModel,
125 const css::uno::Reference< css::report::XReportComponent>& _xComponent)
127 return new OCustomShape(rSdrModel, _xComponent );
130 virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent() override;
132 virtual css::uno::Reference< css::drawing::XShape > getUnoShape() override;
133 virtual SdrObjKind GetObjIdentifier() const override;
134 virtual SdrInventor GetObjInventor() const override;
136 private:
137 virtual void setUnoShape( const css::uno::Reference< css::drawing::XShape >& rxUnoShape ) override;
139 OCustomShape(
140 SdrModel& rSdrModel,
141 const css::uno::Reference< css::report::XReportComponent>& _xComponent);
142 OCustomShape(
143 SdrModel& rSdrModel,
144 const OUString& _sComponentName);
146 virtual void NbcMove( const Size& rSize ) override;
147 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
148 virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override;
149 virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;
151 virtual SdrPage* GetImplPage() const override;
155 // OOle2Obj
157 class REPORTDESIGN_DLLPUBLIC OOle2Obj final : public SdrOle2Obj , public OObjectBase
159 friend class OReportPage;
160 friend class DlgEdFactory;
162 private:
163 // protected destructor - due to final, make private
164 virtual ~OOle2Obj() override;
166 public:
167 static rtl::Reference<OOle2Obj> Create(
168 SdrModel& rSdrModel,
169 const css::uno::Reference< css::report::XReportComponent>& _xComponent,
170 SdrObjKind _nType)
172 return new OOle2Obj(rSdrModel, _xComponent, _nType);
175 virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent() override;
177 virtual css::uno::Reference< css::drawing::XShape > getUnoShape() override;
178 virtual SdrObjKind GetObjIdentifier() const override;
179 virtual SdrInventor GetObjInventor() const override;
180 // Clone() should make a complete copy of the object.
181 virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
182 virtual void initializeOle() override;
184 void initializeChart( const css::uno::Reference< css::frame::XModel>& _xModel);
186 private:
187 OOle2Obj(
188 SdrModel& rSdrModel,
189 const css::uno::Reference< css::report::XReportComponent>& _xComponent,
190 SdrObjKind _nType);
191 OOle2Obj(
192 SdrModel& rSdrModel,
193 const OUString& _sComponentName,
194 SdrObjKind _nType);
195 // copy constructor
196 OOle2Obj(SdrModel& rSdrModel, const OOle2Obj& rSource);
198 virtual void NbcMove( const Size& rSize ) override;
199 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
200 virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override;
201 virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;
203 virtual SdrPage* GetImplPage() const override;
205 void impl_createDataProvider_nothrow( const css::uno::Reference< css::frame::XModel>& _xModel);
206 virtual void setUnoShape( const css::uno::Reference< css::drawing::XShape >& rxUnoShape ) override;
208 SdrObjKind m_nType;
209 bool m_bOnlyOnce;
213 // OUnoObject
215 class REPORTDESIGN_DLLPUBLIC OUnoObject final : public SdrUnoObj , public OObjectBase
217 friend class OReportPage;
218 friend class OObjectBase;
219 friend class DlgEdFactory;
221 SdrObjKind m_nObjectType;
222 // tdf#118730 remember if this object was created interactively (due to ::EndCreate being called)
223 bool m_bSetDefaultLabel;
225 OUnoObject(SdrModel& rSdrModel,
226 const OUString& _sComponentName,
227 const OUString& rModelName,
228 SdrObjKind _nObjectType);
229 OUnoObject(
230 SdrModel& rSdrModel,
231 const css::uno::Reference< css::report::XReportComponent>& _xComponent,
232 const OUString& rModelName,
233 SdrObjKind _nObjectType);
234 // copy constructor
235 OUnoObject(SdrModel& rSdrModel, OUnoObject const & rSource);
237 // protected destructor
238 virtual ~OUnoObject() override;
240 virtual void NbcMove( const Size& rSize ) override;
241 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
242 virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override;
243 virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;
245 virtual SdrPage* GetImplPage() const override;
247 public:
249 virtual void _propertyChange( const css::beans::PropertyChangeEvent& evt ) override;
251 /** creates the m_xMediator when it doesn't already exist.
252 @param _bReverse when set to <TRUE/> then the properties from the uno control will be copied into report control
254 void CreateMediator(bool _bReverse = false);
256 virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent() override;
258 static OUString GetDefaultName(const OUnoObject* _pObj);
260 virtual css::uno::Reference< css::drawing::XShape > getUnoShape() override;
261 virtual SdrObjKind GetObjIdentifier() const override;
262 virtual SdrInventor GetObjInventor() const override;
263 virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
265 private:
266 void impl_initializeModel_nothrow();
270 } // rptui
272 #endif // INCLUDED_REPORTDESIGN_INC_RPTOBJECT_HXX
274 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */