merged tag ooo/OOO330_m14
[LibreOffice.git] / chart2 / source / inc / InternalDataProvider.hxx
blobf5e12f87f5056a59027c5ffd0be80e828a78ac58
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
27 #ifndef CHART2_INTERNALDATAPROVIDER_HXX
28 #define CHART2_INTERNALDATAPROVIDER_HXX
30 #include "InternalData.hxx"
32 #include <com/sun/star/lang/XServiceInfo.hpp>
33 #include <com/sun/star/chart/XComplexDescriptionAccess.hpp>
34 #include <com/sun/star/chart2/data/XDataProvider.hpp>
35 #include <com/sun/star/chart2/XInternalDataProvider.hpp>
36 #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
37 #include <com/sun/star/chart2/data/XRangeXMLConversion.hpp>
38 #include <com/sun/star/chart2/XChartDocument.hpp>
39 #include <com/sun/star/lang/XInitialization.hpp>
40 #include <com/sun/star/util/XCloneable.hpp>
41 #include <cppuhelper/implbase6.hxx>
42 #include "ServiceMacros.hxx"
44 #include "CachedDataSequence.hxx"
46 #include <map>
47 #include <memory>
49 namespace chart
52 namespace impl
55 typedef ::cppu::WeakImplHelper6<
56 ::com::sun::star::chart2::XInternalDataProvider,
57 ::com::sun::star::chart2::data::XRangeXMLConversion,
58 ::com::sun::star::chart::XComplexDescriptionAccess,
59 ::com::sun::star::util::XCloneable,
60 ::com::sun::star::lang::XInitialization,
61 ::com::sun::star::lang::XServiceInfo >
62 InternalDataProvider_Base;
65 /** Data provider that handles data internally. This is used for charts with
66 their own data.
68 <p>The format for single ranges is "categories|label n|n" where n is a
69 non-negative number. Meaning return all categories, the label of sequence n,
70 or the data of sequence n.</p>
72 <p>The format for a complete range is "all". (Do we need more than
73 that?)</p>
75 class InternalDataProvider :
76 public impl::InternalDataProvider_Base
78 public:
79 explicit InternalDataProvider(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & _xContext);
80 explicit InternalDataProvider( const ::com::sun::star::uno::Reference<
81 ::com::sun::star::chart2::XChartDocument > & xChartDoc, bool bConnectToModel );
82 explicit InternalDataProvider( const InternalDataProvider & rOther );
83 virtual ~InternalDataProvider();
85 void createDefaultData();
87 /// declare XServiceInfo methods
88 APPHELPER_XSERVICEINFO_DECL()
89 APPHELPER_SERVICE_FACTORY_HELPER(InternalDataProvider)
91 // ____ XInternalDataProvider ____
92 virtual ::sal_Bool SAL_CALL hasDataByRangeRepresentation( const ::rtl::OUString& aRange )
93 throw (::com::sun::star::uno::RuntimeException);
94 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL
95 getDataByRangeRepresentation( const ::rtl::OUString& aRange )
96 throw (::com::sun::star::uno::RuntimeException);
97 virtual void SAL_CALL setDataByRangeRepresentation(
98 const ::rtl::OUString& aRange,
99 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aNewData )
100 throw (::com::sun::star::uno::RuntimeException);
101 virtual void SAL_CALL insertSequence( ::sal_Int32 nAfterIndex )
102 throw (::com::sun::star::uno::RuntimeException);
103 virtual void SAL_CALL deleteSequence( ::sal_Int32 nAtIndex )
104 throw (::com::sun::star::uno::RuntimeException);
105 virtual void SAL_CALL appendSequence()
106 throw (::com::sun::star::uno::RuntimeException);
107 virtual void SAL_CALL insertComplexCategoryLevel( ::sal_Int32 nLevel )
108 throw (::com::sun::star::uno::RuntimeException);
109 virtual void SAL_CALL deleteComplexCategoryLevel( ::sal_Int32 nLevel )
110 throw (::com::sun::star::uno::RuntimeException);
111 virtual void SAL_CALL insertDataPointForAllSequences( ::sal_Int32 nAfterIndex )
112 throw (::com::sun::star::uno::RuntimeException);
113 virtual void SAL_CALL deleteDataPointForAllSequences( ::sal_Int32 nAtIndex )
114 throw (::com::sun::star::uno::RuntimeException);
115 virtual void SAL_CALL swapDataPointWithNextOneForAllSequences( ::sal_Int32 nAtIndex )
116 throw (::com::sun::star::uno::RuntimeException);
117 virtual void SAL_CALL registerDataSequenceForChanges(
118 const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence >& xSeq )
119 throw (::com::sun::star::uno::RuntimeException);
121 // ____ XDataProvider (base of XInternalDataProvider) ____
122 virtual ::sal_Bool SAL_CALL createDataSourcePossible(
123 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArguments )
124 throw (::com::sun::star::uno::RuntimeException);
125 virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource > SAL_CALL createDataSource(
126 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArguments )
127 throw (::com::sun::star::lang::IllegalArgumentException,
128 ::com::sun::star::uno::RuntimeException);
129 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL detectArguments(
130 const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSource >& xDataSource )
131 throw (::com::sun::star::uno::RuntimeException);
132 virtual ::sal_Bool SAL_CALL createDataSequenceByRangeRepresentationPossible(
133 const ::rtl::OUString& aRangeRepresentation )
134 throw (::com::sun::star::uno::RuntimeException);
135 virtual ::com::sun::star::uno::Reference< ::com::sun::star::chart2::data::XDataSequence > SAL_CALL createDataSequenceByRangeRepresentation(
136 const ::rtl::OUString& aRangeRepresentation )
137 throw (::com::sun::star::lang::IllegalArgumentException,
138 ::com::sun::star::uno::RuntimeException);
139 virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XRangeSelection > SAL_CALL getRangeSelection()
140 throw (::com::sun::star::uno::RuntimeException);
142 // ____ XRangeXMLConversion ____
143 virtual ::rtl::OUString SAL_CALL convertRangeToXML(
144 const ::rtl::OUString& aRangeRepresentation )
145 throw (::com::sun::star::lang::IllegalArgumentException,
146 ::com::sun::star::uno::RuntimeException);
147 virtual ::rtl::OUString SAL_CALL convertRangeFromXML(
148 const ::rtl::OUString& aXMLRange )
149 throw (::com::sun::star::lang::IllegalArgumentException,
150 ::com::sun::star::uno::RuntimeException);
152 // ____ XComplexDescriptionAccess ____
153 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL
154 getComplexRowDescriptions() throw (::com::sun::star::uno::RuntimeException);
155 virtual void SAL_CALL setComplexRowDescriptions(
156 const ::com::sun::star::uno::Sequence<
157 ::com::sun::star::uno::Sequence< ::rtl::OUString > >& aRowDescriptions )
158 throw (::com::sun::star::uno::RuntimeException);
159 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > > SAL_CALL
160 getComplexColumnDescriptions() throw (::com::sun::star::uno::RuntimeException);
161 virtual void SAL_CALL setComplexColumnDescriptions(
162 const ::com::sun::star::uno::Sequence<
163 ::com::sun::star::uno::Sequence< ::rtl::OUString > >& aColumnDescriptions )
164 throw (::com::sun::star::uno::RuntimeException);
166 // ____ XChartDataArray (base of XComplexDescriptionAccess) ____
167 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > > SAL_CALL getData()
168 throw (::com::sun::star::uno::RuntimeException);
169 virtual void SAL_CALL setData(
170 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& aData )
171 throw (::com::sun::star::uno::RuntimeException);
172 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getRowDescriptions()
173 throw (::com::sun::star::uno::RuntimeException);
174 virtual void SAL_CALL setRowDescriptions(
175 const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aRowDescriptions )
176 throw (::com::sun::star::uno::RuntimeException);
177 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getColumnDescriptions()
178 throw (::com::sun::star::uno::RuntimeException);
179 virtual void SAL_CALL setColumnDescriptions(
180 const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aColumnDescriptions )
181 throw (::com::sun::star::uno::RuntimeException);
183 // ____ XChartData (base of XChartDataArray) ____
184 virtual void SAL_CALL addChartDataChangeEventListener(
185 const ::com::sun::star::uno::Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& aListener )
186 throw (::com::sun::star::uno::RuntimeException);
187 virtual void SAL_CALL removeChartDataChangeEventListener(
188 const ::com::sun::star::uno::Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& aListener )
189 throw (::com::sun::star::uno::RuntimeException);
190 virtual double SAL_CALL getNotANumber()
191 throw (::com::sun::star::uno::RuntimeException);
192 virtual ::sal_Bool SAL_CALL isNotANumber(
193 double nNumber )
194 throw (::com::sun::star::uno::RuntimeException);
196 // ____ XCloneable ____
197 virtual ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloneable > SAL_CALL createClone()
198 throw (::com::sun::star::uno::RuntimeException);
199 // ::com::sun::star::lang::XInitialization:
200 virtual void SAL_CALL initialize(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > & aArguments)
201 throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::uno::Exception);
203 private:
204 void lcl_addDataSequenceToMap(
205 const ::rtl::OUString & rRangeRepresentation,
206 const ::com::sun::star::uno::Reference<
207 ::com::sun::star::chart2::data::XDataSequence > & xSequence );
209 ::com::sun::star::uno::Reference<
210 ::com::sun::star::chart2::data::XDataSequence >
211 lcl_createDataSequenceAndAddToMap( const ::rtl::OUString & rRangeRepresentation,
212 const ::rtl::OUString & rRole );
213 ::com::sun::star::uno::Reference<
214 ::com::sun::star::chart2::data::XDataSequence >
215 lcl_createDataSequenceAndAddToMap( const ::rtl::OUString & rRangeRepresentation );
217 void lcl_deleteMapReferences( const ::rtl::OUString & rRangeRepresentation );
219 void lcl_adaptMapReferences(
220 const ::rtl::OUString & rOldRangeRepresentation,
221 const ::rtl::OUString & rNewRangeRepresentation );
223 void lcl_increaseMapReferences( sal_Int32 nBegin, sal_Int32 nEnd );
224 void lcl_decreaseMapReferences( sal_Int32 nBegin, sal_Int32 nEnd );
226 typedef ::std::multimap< ::rtl::OUString,
227 ::com::sun::star::uno::WeakReference< ::com::sun::star::chart2::data::XDataSequence > >
228 tSequenceMap;
229 typedef ::std::pair< tSequenceMap::iterator, tSequenceMap::iterator > tSequenceMapRange;
230 typedef ::std::pair< tSequenceMap::const_iterator, tSequenceMap::const_iterator > tConstSequenceMapRange;
232 /** cache for all sequences that have been returned.
234 If the range-representation of a sequence changes and it is still
235 referred to by some component (weak reference is valid), the range will
236 be adapted.
238 tSequenceMap m_aSequenceMap;
239 InternalData m_aInternalData;
240 bool m_bDataInColumns;
243 } // namespace chart
245 // CHART2_INTERNALDATAPROVIDER_HXX
246 #endif