summaryrefslogtreecommitdiff
path: root/sc/inc/chartlis.hxx
blob: 846259d678fa3699d824a5d6356572720ff324ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * 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 .
 */

#ifndef INCLUDED_SC_INC_CHARTLIS_HXX
#define INCLUDED_SC_INC_CHARTLIS_HXX

#include <vcl/idle.hxx>
#include <svl/listener.hxx>
#include "rangelst.hxx"
#include "externalrefmgr.hxx"

#include <memory>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <vector>

namespace com { namespace sun { namespace star { namespace chart { class XChartData; } } } }
namespace com { namespace sun { namespace star { namespace chart { class XChartDataChangeEventListener; } } } }

class Timer;
class ScDocument;
class ScChartUnoData;

class SC_DLLPUBLIC ScChartListener : public SvtListener
{
public:
    class ExternalRefListener : public ScExternalRefManager::LinkListener
    {
    public:
        ExternalRefListener(ScChartListener& rParent, ScDocument* pDoc);
        virtual ~ExternalRefListener() override;
        virtual void notify(sal_uInt16 nFileId, ScExternalRefManager::LinkUpdateType eType) override;
        void addFileId(sal_uInt16 nFileId);
        void removeFileId(sal_uInt16 nFileId);
        std::unordered_set<sal_uInt16>& getAllFileIds() { return maFileIds;}

    private:
        ExternalRefListener(const ExternalRefListener& r) = delete;

        ScChartListener& mrParent;
        std::unordered_set<sal_uInt16> maFileIds;
        ScDocument*                 mpDoc;
    };

private:

    std::unique_ptr<ExternalRefListener> mpExtRefListener;
    std::unique_ptr<std::vector<ScTokenRef> > mpTokens;

    OUString const maName;
    std::unique_ptr<ScChartUnoData> pUnoData;
    ScDocument*     mpDoc;
    bool            bUsed:1;  // for ScChartListenerCollection::FreeUnused
    bool            bDirty:1;

    ScChartListener& operator=( const ScChartListener& ) = delete;

public:
    ScChartListener( const OUString& rName, ScDocument* pDoc,
                     const ScRangeListRef& rRangeListRef );
    ScChartListener( const OUString& rName, ScDocument* pDoc,
                     std::unique_ptr<::std::vector<ScTokenRef>> pTokens );
    ScChartListener( const ScChartListener& ) = delete;
    virtual ~ScChartListener() override;

    const OUString& GetName() const { return maName;}

    void            SetUno( const css::uno::Reference< css::chart::XChartDataChangeEventListener >& rListener,
                            const css::uno::Reference< css::chart::XChartData >& rSource );
    css::uno::Reference< css::chart::XChartDataChangeEventListener >  GetUnoListener() const;
    css::uno::Reference< css::chart::XChartData >                     GetUnoSource() const;

    bool            IsUno() const   { return (pUnoData != nullptr); }

    virtual void Notify( const SfxHint& rHint ) override;
    void            StartListeningTo();
    void            EndListeningTo();
    void            ChangeListening( const ScRangeListRef& rRangeListRef,
                                    bool bDirty );
    void            Update();
    ScRangeListRef  GetRangeList() const;
    void            SetRangeList( const ScRangeListRef& rNew );
    bool            IsUsed() const { return bUsed; }
    void            SetUsed( bool bFlg ) { bUsed = bFlg; }
    bool            IsDirty() const { return bDirty; }
    void            SetDirty( bool bFlg ) { bDirty = bFlg; }

    void            UpdateChartIntersecting( const ScRange& rRange );

    ExternalRefListener* GetExtRefListener();
    void            SetUpdateQueue();

    bool operator==( const ScChartListener& ) const;
    bool operator!=( const ScChartListener& r ) const;
};

class SC_DLLPUBLIC ScChartHiddenRangeListener
{
public:
    ScChartHiddenRangeListener();
    virtual ~ScChartHiddenRangeListener();
    virtual void notify() = 0;
};

class SC_DLLPUBLIC ScChartListenerCollection final
{
public:
    typedef std::map<OUString, std::unique_ptr<ScChartListener>> ListenersType;
    typedef std::unordered_set<OUString> StringSetType;
private:
    ListenersType m_Listeners;
    enum UpdateStatus
    {
        SC_CLCUPDATE_NONE,
        SC_CLCUPDATE_RUNNING,
        SC_CLCUPDATE_MODIFIED
    } meModifiedDuringUpdate;

    std::unordered_multimap<ScChartHiddenRangeListener*, ScRange> maHiddenListeners;

    StringSetType maNonOleObjectNames;

    Idle            aIdle;
    ScDocument*     pDoc;

                    DECL_LINK(TimerHdl, Timer *, void);

    ScChartListenerCollection& operator=( const ScChartListenerCollection& ) = delete;

    void Init();

public:
    ScChartListenerCollection( ScDocument* pDoc );
    ScChartListenerCollection( const ScChartListenerCollection& );
    ~ScChartListenerCollection();

                    // only needed after copy-ctor, if newly added to doc
    void            StartAllListeners();

    void insert(ScChartListener* pListener);
    ScChartListener* findByName(const OUString& rName);
    const ScChartListener* findByName(const OUString& rName) const;
    bool hasListeners() const;

    void removeByName(const OUString& rName);

    const ListenersType& getListeners() const { return m_Listeners; }
    ListenersType& getListeners() { return m_Listeners; }
    StringSetType& getNonOleObjectNames() { return maNonOleObjectNames;}

    /**
     * Create a unique name that's not taken by any existing chart listener
     * objects.  The name consists of a prefix given followed by a number.
     */
    OUString getUniqueName(const OUString& rPrefix) const;

    void            ChangeListening( const OUString& rName,
                                    const ScRangeListRef& rRangeListRef );
    // use FreeUnused only the way it's used in ScDocument::UpdateChartListenerCollection
    void            FreeUnused();
    void            FreeUno( const css::uno::Reference< css::chart::XChartDataChangeEventListener >& rListener,
                             const css::uno::Reference< css::chart::XChartData >& rSource );
    void            StartTimer();
    void            UpdateDirtyCharts();
    void            SetDirty();
    void            SetDiffDirty( const ScChartListenerCollection&,
                        bool bSetChartRangeLists );

    void            SetRangeDirty( const ScRange& rRange );     // for example rows/columns

    void            UpdateChartsContainingTab( SCTAB nTab );

    bool operator==( const ScChartListenerCollection& r ) const;

    /**
     * Start listening on hide/show change within specified cell range.  A
     * single listener may listen on multiple ranges when the caller passes
     * the same pointer multiple times with different ranges.
     *
     * Note that the caller is responsible for managing the life-cycle of the
     * listener instance.
     */
    void            StartListeningHiddenRange( const ScRange& rRange,
                                               ScChartHiddenRangeListener* pListener );

    /**
     * Remove all ranges associated with passed listener instance from the
     * list of hidden range listeners.  This does not delete the passed
     * listener instance.
     */
    void            EndListeningHiddenRange( ScChartHiddenRangeListener* pListener );
};

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
td>ref-count SdrObjectNoel Grandin Which means we can get rid of the majestic hack of ScCaptionPtr Previously, SdrObject was manually managed, and the ownership passed around in very complicated fashion. Notes: (*) SvxShape has a strong reference to SdrObject, where previously it had a weak reference. It is now strong since otherwise the SdrObject will go away very eagerly. (*) SdrObject still has a weak reference to SvxShape (*) In the existing places that an SdrObject is being deleted, we now just clear the reference (*) instead of SwVirtFlyDrawObj removing itself from the page that contains inside it's destructor, make the call site do the removing from the page. (*) Needed to take the SolarMutex in UndoManagerHelper_Impl::impl_clear because this can be called from UNO (e.g. sfx2_complex JUnit test) and the SdrObjects need the SolarMutex when destructing. (*) handle a tricky situation with SwDrawVirtObj in the SwDrawModel destructor because the existing code wants mpDrawObj in SwAnchoredObject to be sometimes owning, sometimes not, which results in a cycle with the new code. Change-Id: I4d79df1660e386388e5d51030653755bca02a163 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138837 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> 2022-03-14lok: Set pasted text rect pos to 0, 0Mert Tumer Rect size change according to the length of the text however, this can make the text inserted in the negative coordinates and half of it becomes invisible. Signed-off-by: Mert Tumer <mert.tumer@collabora.com> Change-Id: Ibd4e6164c21088205efecf024c1888c55ac33f0e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128603 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131519 Tested-by: Jenkins 2022-01-07remove E3D_INVENTOR_FLAG and convert SdrObjKind to scoped enumNoel Grandin We don't need E3D_INVENTOR_FLAG, we can just check if the SdrObjKind is in the right range. Which exposes some dodgy code in DrawViewShell::GetMenuStateSel SfxItemState::DEFAULT == rSet.GetItemState( OBJ_TITLETEXT ) || SfxItemState::DEFAULT == rSet.GetItemState( OBJ_OUTLINETEXT ) || which has been there ever since commit f47a9d9db3d06927380bb79b04bb6d4721a92d2b Date: Mon Sep 18 16:07:07 2000 +0000 initial import just remove that. In SwFEShell::ImpEndCreate() move some logic around to avoid using an out-of-range SdrObjKind value Change-Id: I4620bfe61aca8f7415503debe3c84bfe5f4368a0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127763 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> 2021-12-23Split BasePrimitive2D UNO interface into separate objectNoel Grandin Rather than make all the BasePrimitive2D classes bear the cost of being an UNO object, we just wrap the top level BasePrimitive2D in this class when we need to pass them over UNO. This reduces the locking overhead when doing normal drawinglayer operations, and reduces the size of drawinglayer objects and the cost of initialising them, which shaves 5% off the load/display time of a large barchart. Add new drawinglayer::convertPrimitive2DContainerToBitmapEx utility method to avoid needing to convert to Sequence<XPrimitive2D> Change-Id: I553eaa4c16ba016b098cb21f6c55f5008f0d9b53 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126487 Tested-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> 2021-12-15Recheck include/[a-d]* with IWYUGabor Kelemen See tdf#42949 for motivation Change-Id: I42475b8e75951d5dcae2fe6b0ad0bca64441e7f5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126837 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com> 2021-12-04use visitor in getViewIndependentPrimitive2DContainerNoel Grandin to reduce intermediate temporary data creation Change-Id: I3f13b0e02c1fa374e8d70768ae47c7f6da254462 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126322 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> 2021-10-08loplugin:moveparam in svxNoel Grandin Change-Id: I92fe2882c948e7297e5d54963647b4aa054f8f89 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123241 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> 2021-06-16sw HTML export: allow larger bitmaps for shapes than the vcl defaultMiklos Vajna VCL default would be 500k pixels, i.e. a 2" x 1" shape at 600 dpi would be already truncated from 1200 pixels width to 1000 pixels. That's a bit too extreme, use a larger limit in the sw HTML export. Change-Id: I52b85d77cd27410d53c700a89190c99348de5e19 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117287 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins 2021-06-04sw HTML export: allow custom DPI for the bitmaps of shapesMiklos Vajna But leave the CSS pixel size of them unchanged in the HTML markup. Also add some documentation on the various options, so one doesn't have to dig them out from testcases. Change-Id: I6c6ee4e9c98d674f44e7c5835f2e6a6737e13f34 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116722 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins 2021-06-04sw HTML export: fix pixel size of shapesMiklos Vajna - the twips logic size was set, but it was consumed as mm100 logic size, so the pixel size was about half of the correct one - the HTML export didn't write a logic size ("CSS pixels size") for shapes Change-Id: I37f6b4acde9d1298fae81f9975e9db95485631ee Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116691 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins 2021-03-28drop operator bool and operator! from Bitmap and BitmapExNoel IRC chat: <quikee[m]> noelgrandin: doesn't adding operator bool to Bitmap has the same problem as Graphic and the reason why you dropped that commit 7334034ae93b49fc93b5859a3c047a319d138282 "drop Graphic::operator bool" <noelgrandin> quikee[m], hmmm, good point <noelgrandin> maybe I should just drop both operator bool and operator! in favor of IsEmpty <quikee[m]> noelgrandin: I don't remember what the problem is I just remembered we dropped it Graphic :) sure, dropping everything for IsEmpty is probably the best Change-Id: Ieae289cda64f0b8d8fdecd5ea9e6f2bb874ff4cd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113163 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> 2021-03-07ref-count SdrPageNoel which simplifies ownership handling, particularly with regard to undo/redo Change-Id: Ie8f300ebfdae6db3c06f78a87e35a07497d6b825 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111991 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> 2020-11-13Revert "remove BigInt::operator tools::Long()"Noel Grandin This reverts commit 1397a1c8e4995b0dd336478e564880fe8ad91d1d. Reason for revert: Some discussion required Change-Id: Id39ee8260790e0722c5bf8338b0b76ca34da83d7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105539 Tested-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> 2020-11-12remove BigInt::operator tools::Long()Noel which was introduced in commit adf0738d2dbfa742d0e9ef130954fb4638a8e90d Author: Noel Grandin <noel.grandin@collabora.co.uk> Date: Wed Jan 3 14:25:15 2018 +0200 long->sal_Int32 in BigInt presumably to make the conversion easier. Instead just fix the call-sites to select a better conversion, BigInt only returns 32-bits of precision anyway. Change-Id: I2e4354bcfded01763fe3312a715ef37800297876 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105602 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> 2020-10-26switching long to a 64-bit type on 64-bit windowsNoel (*) create a rewriting plugin to do most of the work, heavily based on the fakebool plugin (*) but there are still a number of "long"s in the codebase that will need to be done by hand (*) the plugin needs lots of handholding, due to needing to add #include and update macros Change-Id: I8184d7000ca482c0469514bb73178c3a1123b1e9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104203 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> 2020-03-10tdf#125520 create a persist correctly for OLEArmin Le Grand If the D&D-Start described as in the task is an OLE object we need to create a Persist-object to copy the included EmbeddedObjectContainer Change-Id: Ib8b9677bbc3e6c5b3895abc55e6da5b0a96e33d8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90263 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com> 2020-03-05Fix typoAndrea Gelmini Change-Id: I27f8bf818d130a17f459c86e74df05e9ed3b0d1b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90003 Tested-by: Julien Nabet <serval2412@yahoo.fr> Reviewed-by: Julien Nabet <serval2412@yahoo.fr> 2020-03-04tdf#125520 enhance internal OLE cloningArmin Le Grand For D&D/Copy&Paste te temp SdrModel had no IEmbeddedHelper/Persist, so use the one from the source SDrModel in the temporary one for transfer/cloning. Should be okay, the persist is part of the DocumentModels, handed to the SDrModel for usage and *not* destroyed when SdrModel gets destroyed Change-Id: I46e9e371ef8802d6c1c5bfe761b26651ae6e1f73 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89986 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com> 2020-03-02tdf#42949 Fix IWYU warnings in svx/source/s*/*cxxGabor Kelemen Except for already done svx/source/sdr/ Found with bin/find-unneeded-includes Only removal proposals are dealt with here. Change-Id: I1c4b34cf42aa9faa2f7de36fe1602059460c6c1f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89656 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com> 2020-02-12tdf#130614: Revert "tdf#125520 Fix OLE objects drag&drop with 'Insert as Copy'"Xisco Faulí This reverts commit e4cea049c80f4fd6d2a586e73fe9fa08ebd08371. Change-Id: Ic925cb5660df152208cdc63bfee62d82fe912717 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88493 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> 2020-02-12move some svx/ headers inside the moduleNoel Grandin Change-Id: I8d9a50039a8139caebb2cfb83ca476d39432f255 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88238 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> 2020-02-09Fix typoAndrea Gelmini Change-Id: Ibea0f9c3e5b82fc475de71c2964d8c89e16866c4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88319 Tested-by: Julien Nabet <serval2412@yahoo.fr> Reviewed-by: Julien Nabet <serval2412@yahoo.fr> 2020-01-28tdf#96505: Get rid of cargo cult long integer literalsOnur Yilmaz I checked return values. Long variables didn't affect the calculation. Change-Id: I0c33c20b872ff6b1dc6c87c4032ccf19705db8e2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87503 Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Stephan Bergmann <sbergman@redhat.com> 2019-10-28tdf#125191 Give object copies unique namesJim Raykowski This patch makes a unique name for a copy of an object having a user given name. Change-Id: I14a7f45cc02962fc34a1532dd5db1cb9657b41d3 Reviewed-on: https://gerrit.libreoffice.org/77500 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> 2019-09-08tdf#125520 Fix OLE objects drag&drop with 'Insert as Copy'Andrés Maldonado Change-Id: Ia4e6038c95d1388bdf7f9984b7cf4a69aead87a1 Reviewed-on: https://gerrit.libreoffice.org/73026 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> 2019-08-20loplugin:constvars in svxNoel Grandin Change-Id: I42d04c84c87a792456f36013e1f05159ccf7cd1e Reviewed-on: https://gerrit.libreoffice.org/77808 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> 2019-06-11tdf#42949 Fix IWYU warnings in include/svx/[sS][v-Z]*Gabor Kelemen Found with bin/find-unneeded-includes Only removal proposals are dealt with here. Change-Id: Ie2a4122d67d2d40732e6fd00b584f33edd802c5b Reviewed-on: https://gerrit.libreoffice.org/73476 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com> 2019-02-10loplugin:indentation in svxNoel Grandin Change-Id: Ifea8e24fb76025715ab2ff495d3949223584070a Reviewed-on: https://gerrit.libreoffice.org/67567 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>