Update ooo320-m1
[ooovba.git] / chart2 / source / inc / InternalDataProvider.hxx
blobe1dac155ef9dfa4bdfa24b6ca257284497bcf758
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: InternalDataProvider.hxx,v $
10 * $Revision: 1.7 $
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 ************************************************************************/
30 #ifndef CHART2_INTERNALDATAPROVIDER_HXX
31 #define CHART2_INTERNALDATAPROVIDER_HXX
33 #include <com/sun/star/lang/XServiceInfo.hpp>
34 #include <com/sun/star/chart/XChartDataArray.hpp>
35 #include <com/sun/star/chart2/data/XDataProvider.hpp>
36 #include <com/sun/star/chart2/XInternalDataProvider.hpp>
37 #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
38 #include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
39 #include <com/sun/star/chart2/XChartDocument.hpp>
40 #include <com/sun/star/lang/XInitialization.hpp>
41 #include <com/sun/star/util/XCloneable.hpp>
42 #include <cppuhelper/implbase6.hxx>
43 #include "ServiceMacros.hxx"
45 #include "CachedDataSequence.hxx"
47 #include <map>
48 #include <memory>
50 namespace chart
53 namespace impl
55 class InternalData;
57 typedef ::cppu::WeakImplHelper6<
58 ::com::sun::star::chart2::XInternalDataProvider,
59 ::com::sun::star::chart2::data::XRangeXMLConversion,
60 ::com::sun::star::chart::XChartDataArray,
61 ::com::sun::star::util::XCloneable,
62 ::com::sun::star::lang::XInitialization,
63 ::com::sun::star::lang::XServiceInfo >
64 InternalDataProvider_Base;
67 /** Data provider that handles data internally. This is used for charts with
68 their own data.
70 <p>The format for single ranges is "categories|label n|n" where n is a
71 non-negative number. Meaning return all categories, the label of sequence n,
72 or the data of sequence n.</p>
74 <p>The format for a complete range is "all". (Do we need more than
75 that?)</p>
77 class InternalDataProvider :
78 public impl::InternalDataProvider_Base
80 public:
81 explicit InternalDataProvider();
82 explicit InternalDataProvider(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & _xContext);
83 /// sets the internal data to the given data
84 explicit InternalDataProvider(
85 const ::com::sun::star::uno::Reference<
86 ::com::sun::star::chart::XChartDataArray > & xDataToCopy );
87 /// copies the data from the given data provider for all given used ranges
88 explicit InternalDataProvider( const ::com::sun::star::uno::Reference<
89 ::com::sun::star::chart2::XChartDocument > & xChartDoc );
90 // copy-CTOR
91 explicit InternalDataProvider( const InternalDataProvider & rOther );
92 virtual ~InternalDataProvider();
94 void createDefaultData();
96 /// declare XServiceInfo methods
97 APPHELPER_XSERVICEINFO_DECL()
98 APPHELPER_SERVICE_FACTORY_HELPER(InternalDataProvider)
100 // ____ XInternalDataProvider ____
101 virtual ::sal_Bool SAL_CALL hasDataByRangeRepresentation( const ::rtl::OUString& aRange )
102 throw (::com::sun::star::uno::RuntimeException);
103 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL
104 getDataByRangeRepresentation( const ::rtl::OUString& aRange )
105 throw (::com::sun::star::uno::RuntimeException);
106 virtual void SAL_CALL setDataByRangeRepresentation(
107 const ::rtl::OUString& aRange,
108 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aNewData )
109 throw (::com::sun::star::uno::RuntimeException);
110 virtual void SAL_CALL insertSequence( ::sal_Int32 nAfterIndex )
111 throw (::com::sun::star::uno::RuntimeException);
112 virtual void SAL_CALL deleteSequence( ::sal_Int32 nAtIndex )
113 throw (::com::sun::star::uno::RuntimeException);
114 virtual void SAL_CALL appendSequence()
115 throw (::com::sun::star::uno::RuntimeException);
116 virtual void SAL_CALL insertDataPointForAllSequences( ::sal_Int32 nAfterIndex )
117 throw (::com::sun::star::uno::RuntimeException);
118 virtual void SAL_CALL deleteDataPointForAllSequences( ::sal_Int32 nAtIndex )
119 throw (::com::sun::star::uno::RuntimeException);
120 virtual void SAL_CALL swapDataPointWithNextOneForAllSequences( ::sal_Int32 nAtIndex )
121 throw (::com::sun::star::uno::RuntimeException);
122 virtual void SAL_CALL registerDataSequenceForChanges(
123 const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence >& xSeq )
124 throw (::com::sun::star::uno::RuntimeException);
126 // ____ XDataProvider (base of XInternalDataProvider) ____
127 virtual ::sal_Bool SAL_CALL createDataSourcePossible(
128 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArguments )
129 throw (::com::sun::star::uno::RuntimeException);
130 virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource > SAL_CALL createDataSource(
131 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArguments )
132 throw (::com::sun::star::lang::IllegalArgumentException,
133 ::com::sun::star::uno::RuntimeException);
134 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL detectArguments(
135 const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource >& xDataSource )
136 throw (::com::sun::star::uno::RuntimeException);
137 virtual ::sal_Bool SAL_CALL createDataSequenceByRangeRepresentationPossible(
138 const ::rtl::OUString& aRangeRepresentation )
139 throw (::com::sun::star::uno::RuntimeException);
140 virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence > SAL_CALL createDataSequenceByRangeRepresentation(
141 const ::rtl::OUString& aRangeRepresentation )
142 throw (::com::sun::star::lang::IllegalArgumentException,
143 ::com::sun::star::uno::RuntimeException);
144 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XRangeSelection > SAL_CALL getRangeSelection()
145 throw (::com::sun::star::uno::RuntimeException);
147 // ____ XRangeXMLConversion ____
148 virtual ::rtl::OUString SAL_CALL convertRangeToXML(
149 const ::rtl::OUString& aRangeRepresentation )
150 throw (::com::sun::star::lang::IllegalArgumentException,
151 ::com::sun::star::uno::RuntimeException);
152 virtual ::rtl::OUString SAL_CALL convertRangeFromXML(
153 const ::rtl::OUString& aXMLRange )
154 throw (::com::sun::star::lang::IllegalArgumentException,
155 ::com::sun::star::uno::RuntimeException);
157 // ____ XChartDataArray ____
158 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > > SAL_CALL getData()
159 throw (::com::sun::star::uno::RuntimeException);
160 virtual void SAL_CALL setData(
161 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& aData )
162 throw (::com::sun::star::uno::RuntimeException);
163 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getRowDescriptions()
164 throw (::com::sun::star::uno::RuntimeException);
165 virtual void SAL_CALL setRowDescriptions(
166 const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aRowDescriptions )
167 throw (::com::sun::star::uno::RuntimeException);
168 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getColumnDescriptions()
169 throw (::com::sun::star::uno::RuntimeException);
170 virtual void SAL_CALL setColumnDescriptions(
171 const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aColumnDescriptions )
172 throw (::com::sun::star::uno::RuntimeException);
174 // ____ XChartData (base of XChartDataArray) ____
175 virtual void SAL_CALL addChartDataChangeEventListener(
176 const ::com::sun::star::uno::Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& aListener )
177 throw (::com::sun::star::uno::RuntimeException);
178 virtual void SAL_CALL removeChartDataChangeEventListener(
179 const ::com::sun::star::uno::Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& aListener )
180 throw (::com::sun::star::uno::RuntimeException);
181 virtual double SAL_CALL getNotANumber()
182 throw (::com::sun::star::uno::RuntimeException);
183 virtual ::sal_Bool SAL_CALL isNotANumber(
184 double nNumber )
185 throw (::com::sun::star::uno::RuntimeException);
187 // ____ XCloneable ____
188 virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone()
189 throw (::com::sun::star::uno::RuntimeException);
190 // ::com::sun::star::lang::XInitialization:
191 virtual void SAL_CALL initialize(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > & aArguments)
192 throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::uno::Exception);
194 private:
195 impl::InternalData & getInternalData();
196 const impl::InternalData & getInternalData() const;
198 void addDataSequenceToMap(
199 const ::rtl::OUString & rRangeRepresentation,
200 const ::com::sun::star::uno::Reference<
201 ::com::sun::star::chart2::data::XDataSequence > & xSequence );
202 ::com::sun::star::uno::Reference<
203 ::com::sun::star::chart2::data::XDataSequence >
204 createDataSequenceAndAddToMap( const ::rtl::OUString & rRangeRepresentation,
205 const ::rtl::OUString & rRole );
206 ::com::sun::star::uno::Reference<
207 ::com::sun::star::chart2::data::XDataSequence >
208 createDataSequenceAndAddToMap( const ::rtl::OUString & rRangeRepresentation );
209 ::com::sun::star::uno::Reference<
210 ::com::sun::star::chart2::data::XDataSequence >
211 createErrorBarDataSequenceAndAddToMap( const ::rtl::OUString & rRangeRepresentation );
212 void deleteMapReferences( const ::rtl::OUString & rRangeRepresentation );
213 void adaptMapReferences(
214 const ::rtl::OUString & rOldRangeRepresentation,
215 const ::rtl::OUString & rNewRangeRepresentation );
216 void increaseMapReferences( sal_Int32 nBegin, sal_Int32 nEnd );
217 void decreaseMapReferences( sal_Int32 nBegin, sal_Int32 nEnd );
219 typedef ::std::multimap< ::rtl::OUString,
220 ::com::sun::star::uno::WeakReference< ::com::sun::star::chart2::data::XDataSequence > >
221 tSequenceMap;
222 typedef ::std::pair< tSequenceMap::iterator, tSequenceMap::iterator > tSequenceMapRange;
223 typedef ::std::pair< tSequenceMap::const_iterator, tSequenceMap::const_iterator > tConstSequenceMapRange;
225 /** cache for all sequences that have been returned.
227 If the range-representation of a sequence changes and it is still
228 referred to by some component (weak reference is valid), the range will
229 be adapted.
231 mutable tSequenceMap m_aSequenceMap;
232 mutable ::std::auto_ptr< impl::InternalData > m_apData;
233 bool m_bDataInColumns;
235 // typedef ::std::map< ::rtl::OUString,
236 // ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence > >
237 // tHardRefSequenceMap;
238 // tHardRefSequenceMap m_aErrorBarSequences;
241 } // namespace chart
243 // CHART2_INTERNALDATAPROVIDER_HXX
244 #endif