RptObject.hxx 9.59 KB
Newer Older
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */
19 20
#ifndef INCLUDED_REPORTDESIGN_INC_RPTOBJECT_HXX
#define INCLUDED_REPORTDESIGN_INC_RPTOBJECT_HXX
Rüdiger Timm's avatar
Rüdiger Timm committed
21

22
#include "dllapi.h"
23

24
#include <svx/svdoole2.hxx>
Rüdiger Timm's avatar
Rüdiger Timm committed
25
#include <svx/svdouno.hxx>
26

Rüdiger Timm's avatar
Rüdiger Timm committed
27 28 29 30 31 32 33 34 35 36 37

#include <com/sun/star/beans/XPropertyChangeListener.hpp>
#include <com/sun/star/container/XContainerListener.hpp>
#include <com/sun/star/report/XReportComponent.hpp>
#include <com/sun/star/report/XSection.hpp>
#include <svx/svdocirc.hxx>
#include <svx/svdogrp.hxx>
#include <svx/svdoashp.hxx>

namespace rptui
{
38
typedef ::std::multimap< sal_Int16, OUString > IndexToNameMap;
Rüdiger Timm's avatar
Rüdiger Timm committed
39 40 41 42 43 44 45 46 47 48 49 50
    enum DlgEdHintKind
    {
        RPTUI_HINT_WINDOWSCROLLED,
        RPTUI_HINT_SELECTIONCHANGED
    };

    class OUnoObject;
    class REPORTDESIGN_DLLPUBLIC DlgEdHint: public SfxHint
    {
    private:
        DlgEdHintKind   eHintKind;

51 52
        DlgEdHint(DlgEdHint&) = delete;
        void operator =(DlgEdHint&) = delete;
Rüdiger Timm's avatar
Rüdiger Timm committed
53 54
    public:
        DlgEdHint( DlgEdHintKind eHint );
55
        virtual ~DlgEdHint() override;
Rüdiger Timm's avatar
Rüdiger Timm committed
56

57
        DlgEdHintKind    GetKind() const { return eHintKind; }
Rüdiger Timm's avatar
Rüdiger Timm committed
58 59 60 61 62 63
    };


class OReportPage;
class OPropertyMediator;

64
class REPORTDESIGN_DLLPUBLIC OObjectBase
Rüdiger Timm's avatar
Rüdiger Timm committed
65
{
66
protected:
Noel Grandin's avatar
Noel Grandin committed
67
    mutable rtl::Reference<OPropertyMediator>                         m_xMediator;
68 69 70
    mutable css::uno::Reference< css::beans::XPropertyChangeListener> m_xPropertyChangeListener;
    mutable css::uno::Reference< css::report::XReportComponent>       m_xReportComponent;
    css::uno::Reference< css::uno::XInterface >                       m_xKeepShapeAlive;
71
    OUString m_sComponentName;
72
    bool        m_bIsListening;
Rüdiger Timm's avatar
Rüdiger Timm committed
73

74
    OObjectBase(const css::uno::Reference< css::report::XReportComponent>& _xComponent);
75
    OObjectBase(const OUString& _sComponentName);
Rüdiger Timm's avatar
Rüdiger Timm committed
76 77 78

    virtual ~OObjectBase();

79
    bool isListening() const { return m_bIsListening; }
Rüdiger Timm's avatar
Rüdiger Timm committed
80

81
    void SetPropsFromRect(const tools::Rectangle& _rRect);
Rüdiger Timm's avatar
Rüdiger Timm committed
82 83 84

    virtual SdrPage* GetImplPage() const = 0;

85
    /** called by instances of derived classes to implement their overriding of getUnoShape
Rüdiger Timm's avatar
Rüdiger Timm committed
86
    */
87
    css::uno::Reference< css::uno::XInterface >
Rüdiger Timm's avatar
Rüdiger Timm committed
88 89
            getUnoShapeOf( SdrObject& _rSdrObject );

90 91
private:
    static void    ensureSdrObjectOwnership(
92
                    const css::uno::Reference< css::uno::XInterface >& _rxShape );
93

Rüdiger Timm's avatar
Rüdiger Timm committed
94
public:
95 96
    OObjectBase(const OObjectBase&) = delete;
    OObjectBase& operator=(const OObjectBase&) = delete;
Rüdiger Timm's avatar
Rüdiger Timm committed
97
    void StartListening();
98
    void EndListening();
Rüdiger Timm's avatar
Rüdiger Timm committed
99
    // PropertyChangeListener
100
    /// @throws css::uno::RuntimeException
101
    virtual void _propertyChange( const  css::beans::PropertyChangeEvent& evt );
102
    virtual void initializeOle() {}
Rüdiger Timm's avatar
Rüdiger Timm committed
103

104
    bool        supportsService( const OUString& _sServiceName ) const;
Rüdiger Timm's avatar
Rüdiger Timm committed
105

106
    const css::uno::Reference< css::report::XReportComponent>& getReportComponent() const { return m_xReportComponent;}
107 108
    virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent();
    css::uno::Reference< css::report::XSection> getSection() const;
109
    const OUString& getServiceName() const { return m_sComponentName; }
Rüdiger Timm's avatar
Rüdiger Timm committed
110 111 112 113 114

    /** releases the reference to our UNO shape (m_xKeepShapeAlive)
    */
    void    releaseUnoShape() { m_xKeepShapeAlive.clear(); }

115 116 117
    static SdrObject* createObject(
        SdrModel& rTargetModel,
        const css::uno::Reference< css::report::XReportComponent>& _xComponent);
118
    static sal_uInt16 getObjectType(const css::uno::Reference< css::report::XReportComponent>& _xComponent);
Rüdiger Timm's avatar
Rüdiger Timm committed
119
};
120

Rüdiger Timm's avatar
Rüdiger Timm committed
121
// OCustomShape
122

123
class REPORTDESIGN_DLLPUBLIC OCustomShape final : public SdrObjCustomShape , public OObjectBase
Rüdiger Timm's avatar
Rüdiger Timm committed
124 125 126
{
    friend class OReportPage;
    friend class DlgEdFactory;
127 128 129 130 131

private:
    // protected destructor - due to final, make private
    virtual ~OCustomShape() override;

132
public:
133 134 135
    static OCustomShape* Create(
        SdrModel& rSdrModel,
        const css::uno::Reference< css::report::XReportComponent>& _xComponent)
136
    {
137
        return new OCustomShape(rSdrModel, _xComponent );
138 139
    }

140
    virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent() override;
Rüdiger Timm's avatar
Rüdiger Timm committed
141

142
    virtual css::uno::Reference< css::uno::XInterface > getUnoShape() override;
143
    virtual sal_uInt16 GetObjIdentifier() const override;
144
    virtual SdrInventor GetObjInventor() const override;
145 146

private:
147
    virtual void impl_setUnoShape( const css::uno::Reference< css::uno::XInterface >& rxUnoShape ) override;
148

149 150 151 152 153 154
    OCustomShape(
        SdrModel& rSdrModel,
        const css::uno::Reference< css::report::XReportComponent>& _xComponent);
    OCustomShape(
        SdrModel& rSdrModel,
        const OUString& _sComponentName);
155 156 157 158 159 160 161

    virtual void NbcMove( const Size& rSize ) override;
    virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
    virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override;
    virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;

    virtual SdrPage* GetImplPage() const override;
Rüdiger Timm's avatar
Rüdiger Timm committed
162 163
};

164

165
// OOle2Obj
166

167
class REPORTDESIGN_DLLPUBLIC OOle2Obj final : public SdrOle2Obj , public OObjectBase
168 169 170
{
    friend class OReportPage;
    friend class DlgEdFactory;
171 172 173 174 175

private:
    // protected destructor - due to final, make private
    virtual ~OOle2Obj() override;

176
public:
177 178 179 180
    static OOle2Obj* Create(
        SdrModel& rSdrModel,
        const css::uno::Reference< css::report::XReportComponent>& _xComponent,
        sal_uInt16 _nType)
181
    {
182
        return new OOle2Obj(rSdrModel, _xComponent, _nType);
183 184
    }

185
    virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent() override;
186

187
    virtual css::uno::Reference< css::uno::XInterface > getUnoShape() override;
188
    virtual sal_uInt16 GetObjIdentifier() const override;
189
    virtual SdrInventor GetObjInventor() const override;
190
    // Clone() should make a complete copy of the object.
191
    virtual OOle2Obj* CloneSdrObject(SdrModel& rTargetModel) const override;
192
    virtual void initializeOle() override;
193

194 195
    OOle2Obj& operator=(const OOle2Obj& rObj);

196
    void initializeChart( const css::uno::Reference< css::frame::XModel>& _xModel);
197 198

private:
199 200 201 202 203 204 205 206
    OOle2Obj(
        SdrModel& rSdrModel,
        const css::uno::Reference< css::report::XReportComponent>& _xComponent,
        sal_uInt16 _nType);
    OOle2Obj(
        SdrModel& rSdrModel,
        const OUString& _sComponentName,
        sal_uInt16 _nType);
207 208 209 210 211 212 213 214 215 216 217 218 219

    virtual void NbcMove( const Size& rSize ) override;
    virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
    virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override;
    virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;

    virtual SdrPage* GetImplPage() const override;

    void impl_createDataProvider_nothrow( const css::uno::Reference< css::frame::XModel>& _xModel);
    virtual void impl_setUnoShape( const css::uno::Reference< css::uno::XInterface >& rxUnoShape ) override;

    sal_uInt16 m_nType;
    bool    m_bOnlyOnce;
220 221
};

222

Rüdiger Timm's avatar
Rüdiger Timm committed
223
// OUnoObject
224

Rüdiger Timm's avatar
Rüdiger Timm committed
225 226 227 228 229 230 231 232
class REPORTDESIGN_DLLPUBLIC OUnoObject: public SdrUnoObj , public OObjectBase
{
    friend class OReportPage;
    friend class OObjectBase;
    friend class DlgEdFactory;

    sal_uInt16   m_nObjectType;
protected:
233 234 235 236 237 238 239 240 241
    OUnoObject(SdrModel& rSdrModel,
        const OUString& _sComponentName,
        const OUString& rModelName,
        sal_uInt16   _nObjectType);
    OUnoObject(
        SdrModel& rSdrModel,
        const css::uno::Reference< css::report::XReportComponent>& _xComponent,
        const OUString& rModelName,
        sal_uInt16 _nObjectType);
Rüdiger Timm's avatar
Rüdiger Timm committed
242

243
    // protected destructor
244
    virtual ~OUnoObject() override;
Rüdiger Timm's avatar
Rüdiger Timm committed
245

246 247
    virtual void NbcMove( const Size& rSize ) override;
    virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
248
    virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override;
Rüdiger Timm's avatar
Rüdiger Timm committed
249

250
    virtual SdrPage* GetImplPage() const override;
Rüdiger Timm's avatar
Rüdiger Timm committed
251 252 253

public:

254
    virtual void _propertyChange( const  css::beans::PropertyChangeEvent& evt ) override;
Rüdiger Timm's avatar
Rüdiger Timm committed
255 256 257 258

    /** creates the m_xMediator when it doesn't already exist.
        @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);
Rüdiger Timm's avatar
Rüdiger Timm committed
260

261
    virtual css::uno::Reference< css::beans::XPropertySet> getAwtComponent() override;
Rüdiger Timm's avatar
Rüdiger Timm committed
262

263
    static OUString GetDefaultName(const OUnoObject* _pObj);
264

265
    virtual css::uno::Reference< css::uno::XInterface > getUnoShape() override;
266
    virtual sal_uInt16 GetObjIdentifier() const override;
267
    virtual SdrInventor GetObjInventor() const override;
268
    virtual OUnoObject* CloneSdrObject(SdrModel& rTargetModel) const override;
269

270 271
    OUnoObject& operator=(const OUnoObject& rObj);

272
private:
273
    virtual void impl_setUnoShape( const css::uno::Reference< css::uno::XInterface >& rxUnoShape ) override;
274
    void    impl_initializeModel_nothrow();
Rüdiger Timm's avatar
Rüdiger Timm committed
275 276
};

277

Rüdiger Timm's avatar
Rüdiger Timm committed
278
} // rptui
279

280
#endif // INCLUDED_REPORTDESIGN_INC_RPTOBJECT_HXX
Rüdiger Timm's avatar
Rüdiger Timm committed
281

282
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */