Impress Remote 1.0.5, tag sdremote-1.0.5
[LibreOffice.git] / sc / inc / chart2uno.hxx
blob6107e345245d1e9dca78d32fdfc96cc530ee30c4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef SC_CHART2UNO_HXX
21 #define SC_CHART2UNO_HXX
23 #include "cellsuno.hxx" // for XModifyListenerArr_Impl / ScLinkListener
24 #include "rangelst.hxx"
25 #include "externalrefmgr.hxx"
26 #include "token.hxx"
27 #include "chartlis.hxx"
29 #include <svl/lstner.hxx>
30 #include <com/sun/star/chart/ChartDataRowSource.hpp>
31 #include <com/sun/star/chart2/data/XDataProvider.hpp>
32 #include <com/sun/star/chart2/data/XSheetDataProvider.hpp>
33 #include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
34 #include <com/sun/star/chart2/data/XDataSource.hpp>
35 #include <com/sun/star/chart2/data/XDataSequence.hpp>
36 #include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
37 #include <com/sun/star/chart2/data/XNumericalDataSequence.hpp>
38 #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
39 #include <com/sun/star/chart2/data/DataSequenceRole.hpp>
40 #include <com/sun/star/lang/XServiceInfo.hpp>
41 #include <com/sun/star/beans/XPropertySet.hpp>
42 #include <com/sun/star/util/XCloneable.hpp>
43 #include <com/sun/star/util/XModifyBroadcaster.hpp>
44 #include <cppuhelper/implbase2.hxx>
45 #include <cppuhelper/implbase5.hxx>
46 #include <cppuhelper/implbase7.hxx>
47 #include <rtl/ustring.hxx>
48 #include <svl/itemprop.hxx>
50 #include <list>
51 #include <vector>
52 #include <memory>
53 #include <boost/shared_ptr.hpp>
54 #include <boost/unordered_set.hpp>
55 #include <boost/noncopyable.hpp>
56 #include <boost/scoped_ptr.hpp>
58 class ScDocument;
60 // DataProvider ==============================================================
62 class ScChart2DataProvider : public
63 ::cppu::WeakImplHelper5<
64 ::com::sun::star::chart2::data::XDataProvider,
65 ::com::sun::star::chart2::data::XSheetDataProvider,
66 ::com::sun::star::chart2::data::XRangeXMLConversion,
67 ::com::sun::star::beans::XPropertySet,
68 ::com::sun::star::lang::XServiceInfo>,
69 SfxListener
71 public:
73 explicit ScChart2DataProvider( ScDocument* pDoc );
74 virtual ~ScChart2DataProvider();
75 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
77 // XDataProvider ---------------------------------------------------------
79 virtual ::sal_Bool SAL_CALL createDataSourcePossible(
80 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArguments )
81 throw (::com::sun::star::uno::RuntimeException);
83 virtual ::com::sun::star::uno::Reference<
84 ::com::sun::star::chart2::data::XDataSource > SAL_CALL createDataSource(
85 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArguments )
86 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
88 virtual ::com::sun::star::uno::Sequence<
89 ::com::sun::star::beans::PropertyValue > SAL_CALL detectArguments(
90 const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource >& xDataSource )
91 throw (::com::sun::star::uno::RuntimeException);
93 virtual ::sal_Bool SAL_CALL createDataSequenceByRangeRepresentationPossible(
94 const ::rtl::OUString& aRangeRepresentation )
95 throw (::com::sun::star::uno::RuntimeException);
97 virtual ::com::sun::star::uno::Reference<
98 ::com::sun::star::chart2::data::XDataSequence > SAL_CALL createDataSequenceByRangeRepresentation(
99 const ::rtl::OUString& aRangeRepresentation )
100 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
102 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XRangeSelection > SAL_CALL getRangeSelection()
103 throw (::com::sun::star::uno::RuntimeException);
105 // XSheetDataProvider ----------------------------------------------------
107 virtual sal_Bool SAL_CALL createDataSequenceByFormulaTokensPossible(
108 const ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken >& aTokens )
109 throw (::com::sun::star::uno::RuntimeException);
111 virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence >
112 SAL_CALL createDataSequenceByFormulaTokens(
113 const ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken >& aTokens )
114 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
116 // XRangeXMLConversion ---------------------------------------------------
118 virtual ::rtl::OUString SAL_CALL convertRangeToXML( const ::rtl::OUString& sRangeRepresentation )
119 throw ( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException );
121 virtual ::rtl::OUString SAL_CALL convertRangeFromXML( const ::rtl::OUString& sXMLRange )
122 throw ( ::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::IllegalArgumentException );
124 // XPropertySet ----------------------------------------------------------
126 virtual ::com::sun::star::uno::Reference<
127 ::com::sun::star::beans::XPropertySetInfo> SAL_CALL
128 getPropertySetInfo() throw( ::com::sun::star::uno::RuntimeException);
130 virtual void SAL_CALL setPropertyValue(
131 const ::rtl::OUString& rPropertyName,
132 const ::com::sun::star::uno::Any& rValue)
133 throw( ::com::sun::star::beans::UnknownPropertyException,
134 ::com::sun::star::beans::PropertyVetoException,
135 ::com::sun::star::lang::IllegalArgumentException,
136 ::com::sun::star::lang::WrappedTargetException,
137 ::com::sun::star::uno::RuntimeException);
139 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
140 const ::rtl::OUString& rPropertyName)
141 throw( ::com::sun::star::beans::UnknownPropertyException,
142 ::com::sun::star::lang::WrappedTargetException,
143 ::com::sun::star::uno::RuntimeException);
145 virtual void SAL_CALL addPropertyChangeListener(
146 const ::rtl::OUString& rPropertyName,
147 const ::com::sun::star::uno::Reference<
148 ::com::sun::star::beans::XPropertyChangeListener>& xListener)
149 throw( ::com::sun::star::beans::UnknownPropertyException,
150 ::com::sun::star::lang::WrappedTargetException,
151 ::com::sun::star::uno::RuntimeException);
153 virtual void SAL_CALL removePropertyChangeListener(
154 const ::rtl::OUString& rPropertyName,
155 const ::com::sun::star::uno::Reference<
156 ::com::sun::star::beans::XPropertyChangeListener>& rListener)
157 throw( ::com::sun::star::beans::UnknownPropertyException,
158 ::com::sun::star::lang::WrappedTargetException,
159 ::com::sun::star::uno::RuntimeException);
161 virtual void SAL_CALL addVetoableChangeListener(
162 const ::rtl::OUString& rPropertyName,
163 const ::com::sun::star::uno::Reference<
164 ::com::sun::star::beans::XVetoableChangeListener>& rListener)
165 throw( ::com::sun::star::beans::UnknownPropertyException,
166 ::com::sun::star::lang::WrappedTargetException,
167 ::com::sun::star::uno::RuntimeException);
169 virtual void SAL_CALL removeVetoableChangeListener(
170 const ::rtl::OUString& rPropertyName,
171 const ::com::sun::star::uno::Reference<
172 ::com::sun::star::beans::XVetoableChangeListener>& rListener)
173 throw( ::com::sun::star::beans::UnknownPropertyException,
174 ::com::sun::star::lang::WrappedTargetException,
175 ::com::sun::star::uno::RuntimeException);
177 // XServiceInfo ----------------------------------------------------------
179 virtual ::rtl::OUString SAL_CALL getImplementationName() throw(
180 ::com::sun::star::uno::RuntimeException);
182 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString&
183 rServiceName) throw( ::com::sun::star::uno::RuntimeException);
185 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
186 getSupportedServiceNames() throw(
187 ::com::sun::star::uno::RuntimeException);
189 private:
191 ScDocument* m_pDocument;
192 SfxItemPropertySet m_aPropSet;
193 sal_Bool m_bIncludeHiddenCells;
197 // DataSource ================================================================
199 class ScChart2DataSource : public
200 ::cppu::WeakImplHelper2<
201 ::com::sun::star::chart2::data::XDataSource,
202 ::com::sun::star::lang::XServiceInfo>,
203 SfxListener
205 public:
207 explicit ScChart2DataSource( ScDocument* pDoc);
208 virtual ~ScChart2DataSource();
209 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
211 // XDataSource -----------------------------------------------------------
213 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference<
214 ::com::sun::star::chart2::data::XLabeledDataSequence > > SAL_CALL
215 getDataSequences() throw (::com::sun::star::uno::RuntimeException);
217 // XServiceInfo ----------------------------------------------------------
219 virtual ::rtl::OUString SAL_CALL getImplementationName() throw(
220 ::com::sun::star::uno::RuntimeException);
222 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString&
223 rServiceName) throw( ::com::sun::star::uno::RuntimeException);
225 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
226 getSupportedServiceNames() throw(
227 ::com::sun::star::uno::RuntimeException);
229 // implementation
231 void AddLabeledSequence(const com::sun::star::uno::Reference < com::sun::star::chart2::data::XLabeledDataSequence >& xNew);
233 private:
235 ScDocument* m_pDocument;
236 typedef std::list < com::sun::star::uno::Reference< com::sun::star::chart2::data::XLabeledDataSequence > > LabeledList;
237 LabeledList m_aLabeledSequences;
242 // DataSequence ==============================================================
244 class ScChart2DataSequence : public
245 ::cppu::WeakImplHelper7<
246 ::com::sun::star::chart2::data::XDataSequence,
247 ::com::sun::star::chart2::data::XTextualDataSequence,
248 ::com::sun::star::chart2::data::XNumericalDataSequence,
249 ::com::sun::star::util::XCloneable,
250 ::com::sun::star::util::XModifyBroadcaster,
251 ::com::sun::star::beans::XPropertySet,
252 ::com::sun::star::lang::XServiceInfo>,
253 SfxListener,
254 boost::noncopyable
256 public:
257 explicit ScChart2DataSequence( ScDocument* pDoc,
258 const com::sun::star::uno::Reference< com::sun::star::chart2::data::XDataProvider >& xDP,
259 ::std::vector<ScTokenRef>* pTokens, bool bIncludeHiddenCells );
261 virtual ~ScChart2DataSequence();
262 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
264 // XDataSequence ---------------------------------------------------------
266 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
267 SAL_CALL getData() throw (::com::sun::star::uno::RuntimeException);
268 virtual ::rtl::OUString SAL_CALL getSourceRangeRepresentation()
269 throw (::com::sun::star::uno::RuntimeException);
270 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
271 SAL_CALL generateLabel(::com::sun::star::chart2::data::LabelOrigin nOrigin)
272 throw (::com::sun::star::uno::RuntimeException);
273 virtual ::sal_Int32 SAL_CALL getNumberFormatKeyByIndex( ::sal_Int32 nIndex )
274 throw (::com::sun::star::lang::IndexOutOfBoundsException,
275 ::com::sun::star::uno::RuntimeException);
277 // XNumericalDataSequence --------------------------------------------------
279 virtual ::com::sun::star::uno::Sequence< double >
280 SAL_CALL getNumericalData( ) throw (::com::sun::star::uno::RuntimeException);
282 // XTextualDataSequence --------------------------------------------------
284 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
285 SAL_CALL getTextualData( ) throw (::com::sun::star::uno::RuntimeException);
287 // XPropertySet ----------------------------------------------------------
289 virtual ::com::sun::star::uno::Reference<
290 ::com::sun::star::beans::XPropertySetInfo> SAL_CALL
291 getPropertySetInfo() throw( ::com::sun::star::uno::RuntimeException);
293 virtual void SAL_CALL setPropertyValue(
294 const ::rtl::OUString& rPropertyName,
295 const ::com::sun::star::uno::Any& rValue)
296 throw( ::com::sun::star::beans::UnknownPropertyException,
297 ::com::sun::star::beans::PropertyVetoException,
298 ::com::sun::star::lang::IllegalArgumentException,
299 ::com::sun::star::lang::WrappedTargetException,
300 ::com::sun::star::uno::RuntimeException);
302 virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
303 const ::rtl::OUString& rPropertyName)
304 throw( ::com::sun::star::beans::UnknownPropertyException,
305 ::com::sun::star::lang::WrappedTargetException,
306 ::com::sun::star::uno::RuntimeException);
308 virtual void SAL_CALL addPropertyChangeListener(
309 const ::rtl::OUString& rPropertyName,
310 const ::com::sun::star::uno::Reference<
311 ::com::sun::star::beans::XPropertyChangeListener>& xListener)
312 throw( ::com::sun::star::beans::UnknownPropertyException,
313 ::com::sun::star::lang::WrappedTargetException,
314 ::com::sun::star::uno::RuntimeException);
316 virtual void SAL_CALL removePropertyChangeListener(
317 const ::rtl::OUString& rPropertyName,
318 const ::com::sun::star::uno::Reference<
319 ::com::sun::star::beans::XPropertyChangeListener>& rListener)
320 throw( ::com::sun::star::beans::UnknownPropertyException,
321 ::com::sun::star::lang::WrappedTargetException,
322 ::com::sun::star::uno::RuntimeException);
324 virtual void SAL_CALL addVetoableChangeListener(
325 const ::rtl::OUString& rPropertyName,
326 const ::com::sun::star::uno::Reference<
327 ::com::sun::star::beans::XVetoableChangeListener>& rListener)
328 throw( ::com::sun::star::beans::UnknownPropertyException,
329 ::com::sun::star::lang::WrappedTargetException,
330 ::com::sun::star::uno::RuntimeException);
332 virtual void SAL_CALL removeVetoableChangeListener(
333 const ::rtl::OUString& rPropertyName,
334 const ::com::sun::star::uno::Reference<
335 ::com::sun::star::beans::XVetoableChangeListener>& rListener)
336 throw( ::com::sun::star::beans::UnknownPropertyException,
337 ::com::sun::star::lang::WrappedTargetException,
338 ::com::sun::star::uno::RuntimeException);
340 // XCloneable ------------------------------------------------------------
342 virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone()
343 throw (::com::sun::star::uno::RuntimeException);
345 // XModifyBroadcaster ----------------------------------------------------
347 virtual void SAL_CALL addModifyListener(
348 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener )
349 throw (::com::sun::star::uno::RuntimeException);
350 virtual void SAL_CALL removeModifyListener(
351 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener )
352 throw (::com::sun::star::uno::RuntimeException);
354 // XServiceInfo ----------------------------------------------------------
356 virtual ::rtl::OUString SAL_CALL getImplementationName() throw(
357 ::com::sun::star::uno::RuntimeException);
359 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString&
360 rServiceName) throw( ::com::sun::star::uno::RuntimeException);
362 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
363 getSupportedServiceNames() throw(
364 ::com::sun::star::uno::RuntimeException);
366 private:
367 void setDataChangedHint(bool b);
369 // Implementation --------------------------------------------------------
371 void RefChanged();
372 DECL_LINK( ValueListenerHdl, SfxHint* );
374 private:
375 ScChart2DataSequence(); // disabled
376 ScChart2DataSequence(const ScChart2DataSequence& r); // disabled
378 class ExternalRefListener : public ScExternalRefManager::LinkListener
380 public:
381 ExternalRefListener(ScChart2DataSequence& rParent, ScDocument* pDoc);
382 virtual ~ExternalRefListener();
383 virtual void notify(sal_uInt16 nFileId, ScExternalRefManager::LinkUpdateType eType);
384 void addFileId(sal_uInt16 nFileId);
385 void removeFileId(sal_uInt16 nFileId);
386 const ::boost::unordered_set<sal_uInt16>& getAllFileIds();
388 private:
389 ExternalRefListener();
390 ExternalRefListener(const ExternalRefListener& r);
392 ScChart2DataSequence& mrParent;
393 ::boost::unordered_set<sal_uInt16> maFileIds;
394 ScDocument* mpDoc;
398 * Build an internal data array to cache the data ranges, and other
399 * information such as hidden values.
401 void BuildDataCache();
403 void RebuildDataCache();
405 sal_Int32 FillCacheFromExternalRef(const ScTokenRef& pToken);
407 void UpdateTokensFromRanges(const ScRangeList& rRanges);
409 ExternalRefListener* GetExtRefListener();
411 void StopListeningToAllExternalRefs();
413 void CopyData(const ScChart2DataSequence& r);
415 private:
417 // data array
418 struct Item
420 double mfValue;
421 ::rtl::OUString maString;
422 bool mbIsValue;
423 Item();
426 class HiddenRangeListener : public ScChartHiddenRangeListener
428 public:
429 HiddenRangeListener(ScChart2DataSequence& rParent);
430 virtual ~HiddenRangeListener();
432 virtual void notify();
434 private:
435 ScChart2DataSequence& mrParent;
438 ::std::list<Item> m_aDataArray;
441 * Cached data for getData. We may also need to cache data for the
442 * numerical and textural data series if they turn out to be bottlenecks
443 * under certain scenarios.
445 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > m_aMixedDataCache;
447 ::com::sun::star::uno::Sequence<sal_Int32> m_aHiddenValues;
449 // properties
450 ::com::sun::star::chart2::data::DataSequenceRole m_aRole;
451 sal_Bool m_bIncludeHiddenCells;
453 // internals
454 typedef boost::scoped_ptr<std::vector<ScTokenRef> > TokenListPtr;
455 typedef boost::scoped_ptr<std::vector<sal_uInt32> > RangeIndexMapPtr;
456 typedef boost::scoped_ptr<ExternalRefListener> ExtRefListenerPtr;
458 sal_Int64 m_nObjectId;
459 ScDocument* m_pDocument;
460 TokenListPtr m_pTokens;
461 RangeIndexMapPtr m_pRangeIndices;
462 ExtRefListenerPtr m_pExtRefListener;
463 com::sun::star::uno::Reference < com::sun::star::chart2::data::XDataProvider > m_xDataProvider;
464 SfxItemPropertySet m_aPropSet;
466 boost::scoped_ptr<HiddenRangeListener> m_pHiddenListener;
468 ScLinkListener* m_pValueListener;
469 XModifyListenerArr_Impl m_aValueListeners;
471 bool m_bGotDataChangedHint;
472 bool m_bExtDataRebuildQueued;
475 #endif // SC_CHART2UNO_HXX
477 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */