1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: chartlis.hxx,v $
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"
40 #include "externalrefmgr.hxx"
49 #include <com/sun/star/chart/XChartData.hpp>
50 #include <com/sun/star/chart/XChartDataChangeEventListener.hpp>
52 class SC_DLLPUBLIC ScChartListener
: public StrData
, public SvtListener
55 class ExternalRefListener
: public ScExternalRefManager::LinkListener
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();
66 ExternalRefListener();
67 ExternalRefListener(const ExternalRefListener
& r
);
69 ScChartListener
& mrParent
;
70 ::std::hash_set
<sal_uInt16
> maFileIds
;
76 ::std::auto_ptr
<ExternalRefListener
> mpExtRefListener
;
77 ::std::auto_ptr
< ::std::vector
<ScSharedTokenRef
> > mpTokens
;
79 ScChartUnoData
* pUnoData
;
81 BOOL bUsed
; // fuer ScChartListenerCollection::FreeUnused
83 BOOL bSeriesRangesScheduled
;
86 ScChartListener
& operator=( const ScChartListener
& );
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
);
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
140 ScChartHiddenRangeListener();
141 virtual ~ScChartHiddenRangeListener();
142 virtual void notify() = 0;
145 // ============================================================================
147 class ScChartListenerCollection
: public ScStrCollection
150 struct RangeListenerItem
153 ScChartHiddenRangeListener
* mpListener
;
154 explicit RangeListenerItem(const ScRange
& rRange
, ScChartHiddenRangeListener
* p
);
158 ::std::list
<RangeListenerItem
> maHiddenListeners
;
163 DECL_LINK( TimerHdl
, Timer
* );
166 ScChartListenerCollection
& operator=( const ScChartListenerCollection
& );
168 using ScStrCollection::operator==;
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!
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
);
188 void UpdateDirtyCharts();
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
& );
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
208 void StartListeningHiddenRange( const ScRange
& rRange
,
209 ScChartHiddenRangeListener
* pListener
);
212 * Remove all ranges associated with passed listener instance from the
213 * list of hidden range listeners. This does not delete the passed
216 void EndListeningHiddenRange( ScChartHiddenRangeListener
* pListener
);