update dev300-m57
[ooovba.git] / sc / inc / chartlis.hxx
bloba8a97d3b43e7409110c420fc3df6ba097fc0b8fe
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: chartlis.hxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_CHARTLIS_HXX
32 #define SC_CHARTLIS_HXX
35 #include <vcl/timer.hxx>
36 #include <svtools/listener.hxx>
37 #include "collect.hxx"
38 #include "rangelst.hxx"
39 #include "token.hxx"
40 #include "externalrefmgr.hxx"
42 #include <memory>
43 #include <vector>
44 #include <list>
45 #include <hash_set>
47 class ScDocument;
48 class ScChartUnoData;
49 #include <com/sun/star/chart/XChartData.hpp>
50 #include <com/sun/star/chart/XChartDataChangeEventListener.hpp>
52 class ScChartListener : public StrData, public SvtListener
54 public:
55 class ExternalRefListener : public ScExternalRefManager::LinkListener
57 public:
58 ExternalRefListener(ScChartListener& rParent, ScDocument* pDoc);
59 virtual ~ExternalRefListener();
60 virtual void notify(sal_uInt16 nFileId, ScExternalRefManager::LinkUpdateType eType);
61 void addFileId(sal_uInt16 nFileId);
62 void removeFileId(sal_uInt16 nFileId);
63 ::std::hash_set<sal_uInt16>& getAllFileIds();
65 private:
66 ExternalRefListener();
67 ExternalRefListener(const ExternalRefListener& r);
69 ScChartListener& mrParent;
70 ::std::hash_set<sal_uInt16> maFileIds;
71 ScDocument* mpDoc;
74 private:
76 ::std::auto_ptr<ExternalRefListener> mpExtRefListener;
77 ::std::auto_ptr< ::std::vector<ScSharedTokenRef> > mpTokens;
79 ScChartUnoData* pUnoData;
80 ScDocument* pDoc;
81 BOOL bUsed; // fuer ScChartListenerCollection::FreeUnused
82 BOOL bDirty;
83 BOOL bSeriesRangesScheduled;
85 // not implemented
86 ScChartListener& operator=( const ScChartListener& );
88 public:
89 ScChartListener( const String& rName, ScDocument* pDoc,
90 const ScRange& rRange );
91 ScChartListener( const String& rName, ScDocument* pDoc,
92 const ScRangeListRef& rRangeListRef );
93 ScChartListener( const String& rName, ScDocument* pDoc,
94 ::std::vector<ScSharedTokenRef>* pTokens );
95 ScChartListener( const ScChartListener& );
96 virtual ~ScChartListener();
97 virtual ScDataObject* Clone() const;
99 void SetUno( const com::sun::star::uno::Reference< com::sun::star::chart::XChartDataChangeEventListener >& rListener,
100 const com::sun::star::uno::Reference< com::sun::star::chart::XChartData >& rSource );
101 com::sun::star::uno::Reference< com::sun::star::chart::XChartDataChangeEventListener > GetUnoListener() const;
102 com::sun::star::uno::Reference< com::sun::star::chart::XChartData > GetUnoSource() const;
104 BOOL IsUno() const { return (pUnoData != NULL); }
106 virtual void Notify( SvtBroadcaster& rBC, const SfxHint& rHint );
107 void StartListeningTo();
108 void EndListeningTo();
109 void ChangeListening( const ScRangeListRef& rRangeListRef,
110 BOOL bDirty = FALSE );
111 void Update();
112 ScRangeListRef GetRangeList() const;
113 void SetRangeList( const ScRangeListRef& rNew );
114 void SetRangeList( const ScRange& rNew );
115 BOOL IsUsed() const { return bUsed; }
116 void SetUsed( BOOL bFlg ) { bUsed = bFlg; }
117 BOOL IsDirty() const { return bDirty; }
118 void SetDirty( BOOL bFlg ) { bDirty = bFlg; }
120 void UpdateChartIntersecting( const ScRange& rRange );
122 // if chart series ranges are to be updated later on (e.g. DeleteTab, InsertTab)
123 void ScheduleSeriesRanges() { bSeriesRangesScheduled = TRUE; }
124 void UpdateScheduledSeriesRanges();
125 void UpdateSeriesRanges();
127 ExternalRefListener* GetExtRefListener();
128 void SetUpdateQueue();
130 BOOL operator==( const ScChartListener& );
131 BOOL operator!=( const ScChartListener& r )
132 { return !operator==( r ); }
135 // ============================================================================
137 class ScChartHiddenRangeListener
139 public:
140 ScChartHiddenRangeListener();
141 virtual ~ScChartHiddenRangeListener();
142 virtual void notify() = 0;
145 // ============================================================================
147 class ScChartListenerCollection : public ScStrCollection
149 public:
150 struct RangeListenerItem
152 ScRange maRange;
153 ScChartHiddenRangeListener* mpListener;
154 explicit RangeListenerItem(const ScRange& rRange, ScChartHiddenRangeListener* p);
157 private:
158 ::std::list<RangeListenerItem> maHiddenListeners;
160 Timer aTimer;
161 ScDocument* pDoc;
163 DECL_LINK( TimerHdl, Timer* );
165 // not implemented
166 ScChartListenerCollection& operator=( const ScChartListenerCollection& );
168 using ScStrCollection::operator==;
170 public:
171 ScChartListenerCollection( ScDocument* pDoc );
172 ScChartListenerCollection( const ScChartListenerCollection& );
173 virtual ScDataObject* Clone() const;
175 virtual ~ScChartListenerCollection();
177 // nur nach copy-ctor noetig, wenn neu ins Dok gehaengt
178 void StartAllListeners();
180 void ChangeListening( const String& rName,
181 const ScRangeListRef& rRangeListRef,
182 BOOL bDirty = FALSE );
183 // FreeUnused nur wie in ScDocument::UpdateChartListenerCollection verwenden!
184 void FreeUnused();
185 void FreeUno( const com::sun::star::uno::Reference< com::sun::star::chart::XChartDataChangeEventListener >& rListener,
186 const com::sun::star::uno::Reference< com::sun::star::chart::XChartData >& rSource );
187 void StartTimer();
188 void UpdateDirtyCharts();
189 void SetDirty();
190 void SetDiffDirty( const ScChartListenerCollection&,
191 BOOL bSetChartRangeLists = FALSE );
193 void SetRangeDirty( const ScRange& rRange ); // z.B. Zeilen/Spalten
195 void UpdateScheduledSeriesRanges();
196 void UpdateChartsContainingTab( SCTAB nTab );
198 BOOL operator==( const ScChartListenerCollection& );
200 /**
201 * Start listening on hide/show change within specified cell range. A
202 * single listener may listen on multiple ranges when the caller passes
203 * the same pointer multiple times with different ranges.
205 * Note that the caller is responsible for managing the life-cycle of the
206 * listener instance.
208 void StartListeningHiddenRange( const ScRange& rRange,
209 ScChartHiddenRangeListener* pListener );
211 /**
212 * Remove all ranges associated with passed listener instance from the
213 * list of hidden range listeners. This does not delete the passed
214 * listener instance.
216 void EndListeningHiddenRange( ScChartHiddenRangeListener* pListener );
220 #endif