1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 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/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 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 . 18 */ 19 #ifndef INCLUDED_REPORTDESIGN_INC_RPTOBJECT_HXX 20 #define INCLUDED_REPORTDESIGN_INC_RPTOBJECT_HXX 21 22 #include "dllapi.h" 23 24 #include <svx/svdoole2.hxx> 25 #include <svx/svdouno.hxx> 26 27 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> 32 33 #include <map> 34 35 namespace rptui 36 { 37 class OObjectListener; 38 39 typedef ::std::multimap< sal_Int16, OUString > IndexToNameMap; 40 enum DlgEdHintKind 41 { 42 RPTUI_HINT_WINDOWSCROLLED, 43 RPTUI_HINT_SELECTIONCHANGED 44 }; 45 46 class UNLESS_MERGELIBS_MORE(REPORTDESIGN_DLLPUBLIC) DlgEdHint final : public SfxHint 47 { 48 private: 49 DlgEdHintKind eHintKind; 50 51 DlgEdHint(DlgEdHint const &) = delete; 52 void operator =(DlgEdHint const &) = delete; 53 public: 54 DlgEdHint( DlgEdHintKind eHint ); 55 virtual ~DlgEdHint() override; 56 57 DlgEdHintKind GetKind() const { return eHintKind; } 58 }; 59 60 61 class OPropertyMediator; 62 63 class UNLESS_MERGELIBS_MORE(REPORTDESIGN_DLLPUBLIC) SAL_LOPLUGIN_ANNOTATE("crosscast") OObjectBase 64 { 65 protected: 66 mutable rtl::Reference<OPropertyMediator> m_xMediator; 67 mutable rtl::Reference< OObjectListener > 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; 71 bool m_bIsListening; 72 73 OObjectBase(const css::uno::Reference< css::report::XReportComponent>& _xComponent); 74 OObjectBase(OUString _sComponentName); 75 76 virtual ~OObjectBase(); 77 78 bool isListening() const { return m_bIsListening; } 79 80 void SetPropsFromRect(const tools::Rectangle& _rRect); 81 82 virtual SdrPage* GetImplPage() const = 0; 83 84 /** called by instances of derived classes to implement their overriding of getUnoShape 85 */ 86 css::uno::Reference< css::drawing::XShape > 87 getUnoShapeOf( SdrObject& _rSdrObject ); 88 89 public: 90 OObjectBase(const OObjectBase&) = delete; 91 OObjectBase& operator=(const OObjectBase&) = delete; 92 void StartListening(); 93 void EndListening(); 94 // PropertyChangeListener 95 /// @throws css::uno::RuntimeException 96 virtual void _propertyChange( const css::beans::PropertyChangeEvent& evt ); 97 virtual void initializeOle() {} 98 99 bool supportsService( const OUString& _sServiceName ) const; 100 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; } 105 106 /** releases the reference to our UNO shape (m_xKeepShapeAlive) 107 */ 108 void releaseUnoShape() { m_xKeepShapeAlive.clear(); } 109 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); 114 }; 115 116 // OCustomShape 117 118 class UNLESS_MERGELIBS_MORE(REPORTDESIGN_DLLPUBLIC) OCustomShape final : public SdrObjCustomShape , public OObjectBase 119 { 120 friend class OReportPage; 121 friend class DlgEdFactory; 122 123 private: 124 // protected destructor - due to final, make private 125 virtual ~OCustomShape() override; 126 127 public: 128 static rtl::Reference<OCustomShape> Create( 129 SdrModel& rSdrModel, 130 const css::uno::Reference< css::report::XReportComponent>& _xComponent) 131 { 132 return new OCustomShape(rSdrModel, _xComponent ); 133 } 134 135 virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent() override; 136 137 virtual css::uno::Reference< css::drawing::XShape > getUnoShape() override; 138 virtual SdrObjKind GetObjIdentifier() const override; 139 virtual SdrInventor GetObjInventor() const override; 140 141 private: 142 virtual void setUnoShape( const css::uno::Reference< css::drawing::XShape >& rxUnoShape ) override; 143 144 OCustomShape( 145 SdrModel& rSdrModel, 146 const css::uno::Reference< css::report::XReportComponent>& _xComponent); 147 OCustomShape( 148 SdrModel& rSdrModel); 149 150 virtual void NbcMove( const Size& rSize ) override; 151 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override; 152 virtual void NbcSetLogicRect(const tools::Rectangle& rRect, bool bAdaptTextMinSize = true) override; 153 virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override; 154 155 virtual SdrPage* GetImplPage() const override; 156 }; 157 158 159 // OOle2Obj 160 161 class UNLESS_MERGELIBS_MORE(REPORTDESIGN_DLLPUBLIC) OOle2Obj final : public SdrOle2Obj , public OObjectBase 162 { 163 friend class OReportPage; 164 friend class DlgEdFactory; 165 166 private: 167 // protected destructor - due to final, make private 168 virtual ~OOle2Obj() override; 169 170 public: 171 static rtl::Reference<OOle2Obj> Create( 172 SdrModel& rSdrModel, 173 const css::uno::Reference< css::report::XReportComponent>& _xComponent, 174 SdrObjKind _nType) 175 { 176 return new OOle2Obj(rSdrModel, _xComponent, _nType); 177 } 178 179 virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent() override; 180 181 virtual css::uno::Reference< css::drawing::XShape > getUnoShape() override; 182 virtual SdrObjKind GetObjIdentifier() const override; 183 virtual SdrInventor GetObjInventor() const override; 184 // Clone() should make a complete copy of the object. 185 virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override; 186 virtual void initializeOle() override; 187 188 void initializeChart( const css::uno::Reference< css::frame::XModel>& _xModel); 189 190 private: 191 OOle2Obj( 192 SdrModel& rSdrModel, 193 const css::uno::Reference< css::report::XReportComponent>& _xComponent, 194 SdrObjKind _nType); 195 OOle2Obj( 196 SdrModel& rSdrModel, 197 SdrObjKind _nType); 198 // copy constructor 199 OOle2Obj(SdrModel& rSdrModel, const OOle2Obj& rSource); 200 201 virtual void NbcMove( const Size& rSize ) override; 202 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override; 203 virtual void NbcSetLogicRect(const tools::Rectangle& rRect, bool bAdaptTextMinSize = true) override; 204 virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override; 205 206 virtual SdrPage* GetImplPage() const override; 207 208 void impl_createDataProvider_nothrow( const css::uno::Reference< css::frame::XModel>& _xModel); 209 virtual void setUnoShape( const css::uno::Reference< css::drawing::XShape >& rxUnoShape ) override; 210 211 SdrObjKind m_nType; 212 bool m_bOnlyOnce; 213 }; 214 215 216 // OUnoObject 217 218 class UNLESS_MERGELIBS_MORE(REPORTDESIGN_DLLPUBLIC) OUnoObject final : public SdrUnoObj , public OObjectBase 219 { 220 friend class OReportPage; 221 friend class OObjectBase; 222 friend class DlgEdFactory; 223 224 SdrObjKind m_nObjectType; 225 // tdf#118730 remember if this object was created interactively (due to ::EndCreate being called) 226 bool m_bSetDefaultLabel; 227 228 OUnoObject(SdrModel& rSdrModel, 229 const OUString& rModelName, 230 SdrObjKind _nObjectType); 231 OUnoObject( 232 SdrModel& rSdrModel, 233 const css::uno::Reference< css::report::XReportComponent>& _xComponent, 234 const OUString& rModelName, 235 SdrObjKind _nObjectType); 236 // copy constructor 237 OUnoObject(SdrModel& rSdrModel, OUnoObject const & rSource); 238 239 // protected destructor 240 virtual ~OUnoObject() override; 241 242 virtual void NbcMove( const Size& rSize ) override; 243 virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override; 244 virtual void NbcSetLogicRect(const tools::Rectangle& rRect, bool bAdaptTextMinSize = true) override; 245 virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override; 246 247 virtual SdrPage* GetImplPage() const override; 248 249 public: 250 251 virtual void _propertyChange( const css::beans::PropertyChangeEvent& evt ) override; 252 253 /** creates the m_xMediator when it doesn't already exist. 254 @param _bReverse when set to <TRUE/> then the properties from the uno control will be copied into report control 255 */ 256 void CreateMediator(bool _bReverse = false); 257 258 virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent() override; 259 260 static OUString GetDefaultName(const OUnoObject* _pObj); 261 262 virtual css::uno::Reference< css::drawing::XShape > getUnoShape() override; 263 virtual SdrObjKind GetObjIdentifier() const override; 264 virtual SdrInventor GetObjInventor() const override; 265 virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override; 266 267 private: 268 virtual void setUnoShape( const css::uno::Reference< css::drawing::XShape >& rxUnoShape ) override; 269 void impl_initializeModel_nothrow(); 270 }; 271 272 273 } // rptui 274 275 #endif // INCLUDED_REPORTDESIGN_INC_RPTOBJECT_HXX 276 277 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 278
