xref: /AOO41X/main/chart2/source/tools/InternalDataProvider.cxx (revision cde9e8dc2218e857da4894ecba5c903312256674)
1*cde9e8dcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*cde9e8dcSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*cde9e8dcSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*cde9e8dcSAndrew Rist  * distributed with this work for additional information
6*cde9e8dcSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*cde9e8dcSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*cde9e8dcSAndrew Rist  * "License"); you may not use this file except in compliance
9*cde9e8dcSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*cde9e8dcSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*cde9e8dcSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*cde9e8dcSAndrew Rist  * software distributed under the License is distributed on an
15*cde9e8dcSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*cde9e8dcSAndrew Rist  * KIND, either express or implied.  See the License for the
17*cde9e8dcSAndrew Rist  * specific language governing permissions and limitations
18*cde9e8dcSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*cde9e8dcSAndrew Rist  *************************************************************/
21*cde9e8dcSAndrew Rist 
22*cde9e8dcSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir 
25cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
26cdf0e10cSrcweir #include "precompiled_chart2.hxx"
27cdf0e10cSrcweir #include <rtl/math.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <valarray>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include "InternalDataProvider.hxx"
32cdf0e10cSrcweir #include "LabeledDataSequence.hxx"
33cdf0e10cSrcweir #include "DataSource.hxx"
34cdf0e10cSrcweir #include "PropertyHelper.hxx"
35cdf0e10cSrcweir #include "macros.hxx"
36cdf0e10cSrcweir #include "XMLRangeHelper.hxx"
37cdf0e10cSrcweir #include "ContainerHelper.hxx"
38cdf0e10cSrcweir #include "CommonConverters.hxx"
39cdf0e10cSrcweir #include "CommonFunctors.hxx"
40cdf0e10cSrcweir #include "UncachedDataSequence.hxx"
41cdf0e10cSrcweir #include "DataSourceHelper.hxx"
42cdf0e10cSrcweir #include "ChartModelHelper.hxx"
43cdf0e10cSrcweir #include "DiagramHelper.hxx"
44cdf0e10cSrcweir #include "ExplicitCategoriesProvider.hxx"
45cdf0e10cSrcweir 
46cdf0e10cSrcweir #include <com/sun/star/chart2/XChartDocument.hpp>
47cdf0e10cSrcweir #include <com/sun/star/chart2/data/XDataSequence.hpp>
48cdf0e10cSrcweir #include <com/sun/star/chart/ChartDataRowSource.hpp>
49cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
50cdf0e10cSrcweir #include <unotools/charclass.hxx>
51cdf0e10cSrcweir #include <comphelper/sequenceashashmap.hxx>
52cdf0e10cSrcweir 
53cdf0e10cSrcweir #include <vector>
54cdf0e10cSrcweir #include <algorithm>
55cdf0e10cSrcweir 
56cdf0e10cSrcweir using namespace ::com::sun::star;
57cdf0e10cSrcweir using namespace ::std;
58cdf0e10cSrcweir 
59cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
60cdf0e10cSrcweir using ::com::sun::star::uno::Sequence;
61cdf0e10cSrcweir using ::rtl::OUString;
62cdf0e10cSrcweir using ::rtl::OUStringBuffer;
63cdf0e10cSrcweir 
64cdf0e10cSrcweir namespace chart
65cdf0e10cSrcweir {
66cdf0e10cSrcweir 
67cdf0e10cSrcweir // ================================================================================
68cdf0e10cSrcweir 
69cdf0e10cSrcweir namespace
70cdf0e10cSrcweir {
71cdf0e10cSrcweir 
72cdf0e10cSrcweir // note: in xmloff this name is used to indicate usage of own data
73cdf0e10cSrcweir static const ::rtl::OUString lcl_aServiceName(
74cdf0e10cSrcweir     RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.InternalDataProvider" ));
75cdf0e10cSrcweir 
76cdf0e10cSrcweir static const ::rtl::OUString lcl_aCategoriesRangeName(
77cdf0e10cSrcweir     RTL_CONSTASCII_USTRINGPARAM( "categories" ));
78cdf0e10cSrcweir static const ::rtl::OUString lcl_aCategoriesLevelRangeNamePrefix(
79cdf0e10cSrcweir     RTL_CONSTASCII_USTRINGPARAM( "categoriesL " )); //L <-> level
80cdf0e10cSrcweir static const ::rtl::OUString lcl_aCategoriesPointRangeNamePrefix(
81cdf0e10cSrcweir     RTL_CONSTASCII_USTRINGPARAM( "categoriesP " )); //P <-> point
82cdf0e10cSrcweir static const ::rtl::OUString lcl_aCategoriesRoleName(
83cdf0e10cSrcweir     RTL_CONSTASCII_USTRINGPARAM( "categories" ));
84cdf0e10cSrcweir static const ::rtl::OUString lcl_aLabelRangePrefix(
85cdf0e10cSrcweir     RTL_CONSTASCII_USTRINGPARAM( "label " ));
86cdf0e10cSrcweir static const ::rtl::OUString lcl_aCompleteRange(
87cdf0e10cSrcweir     RTL_CONSTASCII_USTRINGPARAM( "all" ));
88cdf0e10cSrcweir 
89cdf0e10cSrcweir typedef ::std::multimap< OUString, uno::WeakReference< chart2::data::XDataSequence > >
90cdf0e10cSrcweir     lcl_tSequenceMap;
91cdf0e10cSrcweir 
92cdf0e10cSrcweir Sequence< OUString > lcl_AnyToStringSequence( const Sequence< uno::Any >& aAnySeq )
93cdf0e10cSrcweir {
94cdf0e10cSrcweir     Sequence< OUString > aResult;
95cdf0e10cSrcweir     aResult.realloc( aAnySeq.getLength() );
96cdf0e10cSrcweir     transform( aAnySeq.getConstArray(), aAnySeq.getConstArray() + aAnySeq.getLength(),
97cdf0e10cSrcweir                aResult.getArray(), CommonFunctors::AnyToString() );
98cdf0e10cSrcweir     return aResult;
99cdf0e10cSrcweir }
100cdf0e10cSrcweir 
101cdf0e10cSrcweir Sequence< uno::Any > lcl_StringToAnySequence( const Sequence< OUString >& aStringSeq )
102cdf0e10cSrcweir {
103cdf0e10cSrcweir     Sequence< uno::Any > aResult;
104cdf0e10cSrcweir     aResult.realloc( aStringSeq.getLength() );
105cdf0e10cSrcweir     transform( aStringSeq.getConstArray(), aStringSeq.getConstArray() + aStringSeq.getLength(),
106cdf0e10cSrcweir                aResult.getArray(), CommonFunctors::makeAny< OUString >() );
107cdf0e10cSrcweir     return aResult;
108cdf0e10cSrcweir }
109cdf0e10cSrcweir 
110cdf0e10cSrcweir struct lcl_setModified : public ::std::unary_function< lcl_tSequenceMap, void >
111cdf0e10cSrcweir {
112cdf0e10cSrcweir     void operator() ( const lcl_tSequenceMap::value_type & rMapEntry )
113cdf0e10cSrcweir     {
114cdf0e10cSrcweir         // convert weak reference to reference
115cdf0e10cSrcweir         Reference< chart2::data::XDataSequence > xSeq( rMapEntry.second );
116cdf0e10cSrcweir         if( xSeq.is())
117cdf0e10cSrcweir         {
118cdf0e10cSrcweir             Reference< util::XModifiable > xMod( xSeq, uno::UNO_QUERY );
119cdf0e10cSrcweir             if( xMod.is())
120cdf0e10cSrcweir                 xMod->setModified( sal_True );
121cdf0e10cSrcweir         }
122cdf0e10cSrcweir     }
123cdf0e10cSrcweir };
124cdf0e10cSrcweir 
125cdf0e10cSrcweir struct lcl_internalizeSeries : public ::std::unary_function< Reference< chart2::XDataSeries >, void >
126cdf0e10cSrcweir {
127cdf0e10cSrcweir     lcl_internalizeSeries( InternalData & rInternalData,
128cdf0e10cSrcweir                            InternalDataProvider & rProvider,
129cdf0e10cSrcweir                            bool bConnectToModel, bool bDataInColumns ) :
130cdf0e10cSrcweir             m_rInternalData( rInternalData ),
131cdf0e10cSrcweir             m_rProvider( rProvider ),
132cdf0e10cSrcweir             m_bConnectToModel( bConnectToModel ),
133cdf0e10cSrcweir             m_bDataInColumns( bDataInColumns )
134cdf0e10cSrcweir     {}
135cdf0e10cSrcweir     void operator() ( const Reference< chart2::XDataSeries > & xSeries )
136cdf0e10cSrcweir     {
137cdf0e10cSrcweir         Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY );
138cdf0e10cSrcweir         Reference< chart2::data::XDataSink >   xSink(   xSeries, uno::UNO_QUERY );
139cdf0e10cSrcweir         if( xSource.is() && xSink.is() )
140cdf0e10cSrcweir         {
141cdf0e10cSrcweir             Sequence< Reference< chart2::data::XLabeledDataSequence > > aOldSeriesData = xSource->getDataSequences();
142cdf0e10cSrcweir             Sequence< Reference< chart2::data::XLabeledDataSequence > > aNewSeriesData( aOldSeriesData.getLength() );
143cdf0e10cSrcweir             for( sal_Int32 i=0; i<aOldSeriesData.getLength(); ++i )
144cdf0e10cSrcweir             {
145cdf0e10cSrcweir                 sal_Int32 nNewIndex( m_bDataInColumns ? m_rInternalData.appendColumn() : m_rInternalData.appendRow() );
146cdf0e10cSrcweir                 OUString aIdentifier( OUString::valueOf( nNewIndex ));
147cdf0e10cSrcweir                 //@todo: deal also with genericXDataSequence
148cdf0e10cSrcweir                 Reference< chart2::data::XNumericalDataSequence > xValues( aOldSeriesData[i]->getValues(), uno::UNO_QUERY );
149cdf0e10cSrcweir                 Reference< chart2::data::XTextualDataSequence > xLabel( aOldSeriesData[i]->getLabel(), uno::UNO_QUERY );
150cdf0e10cSrcweir                 Reference< chart2::data::XDataSequence > xNewValues;
151cdf0e10cSrcweir 
152cdf0e10cSrcweir                 if( xValues.is() )
153cdf0e10cSrcweir                 {
154cdf0e10cSrcweir                     ::std::vector< double > aValues( ContainerHelper::SequenceToVector( xValues->getNumericalData()));
155cdf0e10cSrcweir                     if( m_bDataInColumns )
156cdf0e10cSrcweir                         m_rInternalData.setColumnValues( nNewIndex, aValues );
157cdf0e10cSrcweir                     else
158cdf0e10cSrcweir                         m_rInternalData.setRowValues( nNewIndex, aValues );
159cdf0e10cSrcweir                     if( m_bConnectToModel )
160cdf0e10cSrcweir                     {
161cdf0e10cSrcweir                         xNewValues.set( m_rProvider.createDataSequenceByRangeRepresentation( aIdentifier ));
162cdf0e10cSrcweir                         comphelper::copyProperties(
163cdf0e10cSrcweir                             Reference< beans::XPropertySet >( xValues, uno::UNO_QUERY ),
164cdf0e10cSrcweir                             Reference< beans::XPropertySet >( xNewValues, uno::UNO_QUERY ));
165cdf0e10cSrcweir                     }
166cdf0e10cSrcweir                 }
167cdf0e10cSrcweir 
168cdf0e10cSrcweir                 if( xLabel.is() )
169cdf0e10cSrcweir                 {
170cdf0e10cSrcweir                     if( m_bDataInColumns )
171cdf0e10cSrcweir                         m_rInternalData.setComplexColumnLabel( nNewIndex, ContainerHelper::SequenceToVector( lcl_StringToAnySequence( xLabel->getTextualData() ) ) );
172cdf0e10cSrcweir                     else
173cdf0e10cSrcweir                         m_rInternalData.setComplexRowLabel( nNewIndex, ContainerHelper::SequenceToVector( lcl_StringToAnySequence( xLabel->getTextualData() ) ) );
174cdf0e10cSrcweir                     if( m_bConnectToModel )
175cdf0e10cSrcweir                     {
176cdf0e10cSrcweir                         Reference< chart2::data::XDataSequence > xNewLabel(
177cdf0e10cSrcweir                             m_rProvider.createDataSequenceByRangeRepresentation( lcl_aLabelRangePrefix + aIdentifier ));
178cdf0e10cSrcweir                         comphelper::copyProperties(
179cdf0e10cSrcweir                             Reference< beans::XPropertySet >( xLabel, uno::UNO_QUERY ),
180cdf0e10cSrcweir                             Reference< beans::XPropertySet >( xNewLabel, uno::UNO_QUERY ));
181cdf0e10cSrcweir                         aNewSeriesData[i] = Reference< chart2::data::XLabeledDataSequence >(
182cdf0e10cSrcweir                                 new LabeledDataSequence( xNewValues, xNewLabel ));
183cdf0e10cSrcweir                     }
184cdf0e10cSrcweir                 }
185cdf0e10cSrcweir                 else
186cdf0e10cSrcweir                 {
187cdf0e10cSrcweir                     if( m_bConnectToModel )
188cdf0e10cSrcweir                         aNewSeriesData[i] = Reference< chart2::data::XLabeledDataSequence >(
189cdf0e10cSrcweir                             new LabeledDataSequence( xNewValues ));
190cdf0e10cSrcweir                 }
191cdf0e10cSrcweir             }
192cdf0e10cSrcweir             if( m_bConnectToModel )
193cdf0e10cSrcweir                 xSink->setData( aNewSeriesData );
194cdf0e10cSrcweir         }
195cdf0e10cSrcweir      }
196cdf0e10cSrcweir 
197cdf0e10cSrcweir private:
198cdf0e10cSrcweir     InternalData &          m_rInternalData;
199cdf0e10cSrcweir     InternalDataProvider &  m_rProvider;
200cdf0e10cSrcweir     bool                    m_bConnectToModel;
201cdf0e10cSrcweir     bool                    m_bDataInColumns;
202cdf0e10cSrcweir };
203cdf0e10cSrcweir 
204cdf0e10cSrcweir struct lcl_copyFromLevel : public ::std::unary_function< vector< uno::Any >, uno::Any >
205cdf0e10cSrcweir {
206cdf0e10cSrcweir public:
207cdf0e10cSrcweir 
208cdf0e10cSrcweir     explicit lcl_copyFromLevel( sal_Int32 nLevel ) : m_nLevel( nLevel )
209cdf0e10cSrcweir     {}
210cdf0e10cSrcweir 
211cdf0e10cSrcweir     uno::Any operator() ( const vector< uno::Any >& rVector )
212cdf0e10cSrcweir     {
213cdf0e10cSrcweir         uno::Any aRet;
214cdf0e10cSrcweir         if( m_nLevel <  static_cast< sal_Int32 >(rVector.size()) )
215cdf0e10cSrcweir             aRet = rVector[m_nLevel];
216cdf0e10cSrcweir         return aRet;
217cdf0e10cSrcweir     }
218cdf0e10cSrcweir 
219cdf0e10cSrcweir private:
220cdf0e10cSrcweir     sal_Int32 m_nLevel;
221cdf0e10cSrcweir };
222cdf0e10cSrcweir 
223cdf0e10cSrcweir struct lcl_getStringFromLevelVector : public ::std::unary_function< vector< uno::Any >, OUString >
224cdf0e10cSrcweir {
225cdf0e10cSrcweir public:
226cdf0e10cSrcweir 
227cdf0e10cSrcweir     explicit lcl_getStringFromLevelVector( sal_Int32 nLevel ) : m_nLevel( nLevel )
228cdf0e10cSrcweir     {}
229cdf0e10cSrcweir 
230cdf0e10cSrcweir     OUString operator() ( const vector< uno::Any >& rVector )
231cdf0e10cSrcweir     {
232cdf0e10cSrcweir         OUString aString;
233cdf0e10cSrcweir         if( m_nLevel < static_cast< sal_Int32 >(rVector.size()) )
234cdf0e10cSrcweir             aString = CommonFunctors::AnyToString()(rVector[m_nLevel]);
235cdf0e10cSrcweir         return aString;
236cdf0e10cSrcweir     }
237cdf0e10cSrcweir 
238cdf0e10cSrcweir private:
239cdf0e10cSrcweir     sal_Int32 m_nLevel;
240cdf0e10cSrcweir };
241cdf0e10cSrcweir 
242cdf0e10cSrcweir 
243cdf0e10cSrcweir struct lcl_setAnyAtLevel : public ::std::binary_function< vector< uno::Any >, uno::Any, vector< uno::Any > >
244cdf0e10cSrcweir {
245cdf0e10cSrcweir public:
246cdf0e10cSrcweir 
247cdf0e10cSrcweir     explicit lcl_setAnyAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel )
248cdf0e10cSrcweir     {}
249cdf0e10cSrcweir 
250cdf0e10cSrcweir     vector< uno::Any > operator() ( const vector< uno::Any >& rVector, const uno::Any& rNewValue )
251cdf0e10cSrcweir     {
252cdf0e10cSrcweir         vector< uno::Any > aRet( rVector );
253cdf0e10cSrcweir         if( m_nLevel >= static_cast< sal_Int32 >(aRet.size()) )
254cdf0e10cSrcweir             aRet.resize( m_nLevel+1 );
255cdf0e10cSrcweir         aRet[ m_nLevel ]=rNewValue;
256cdf0e10cSrcweir         return aRet;
257cdf0e10cSrcweir     }
258cdf0e10cSrcweir 
259cdf0e10cSrcweir private:
260cdf0e10cSrcweir     sal_Int32 m_nLevel;
261cdf0e10cSrcweir };
262cdf0e10cSrcweir 
263cdf0e10cSrcweir struct lcl_setAnyAtLevelFromStringSequence : public ::std::binary_function< vector< uno::Any >, OUString, vector< uno::Any > >
264cdf0e10cSrcweir {
265cdf0e10cSrcweir public:
266cdf0e10cSrcweir 
267cdf0e10cSrcweir     explicit lcl_setAnyAtLevelFromStringSequence( sal_Int32 nLevel ) : m_nLevel( nLevel )
268cdf0e10cSrcweir     {}
269cdf0e10cSrcweir 
270cdf0e10cSrcweir     vector< uno::Any > operator() ( const vector< uno::Any >& rVector, const OUString& rNewValue )
271cdf0e10cSrcweir     {
272cdf0e10cSrcweir         vector< uno::Any > aRet( rVector );
273cdf0e10cSrcweir         if( m_nLevel >= static_cast< sal_Int32 >(aRet.size()) )
274cdf0e10cSrcweir             aRet.resize( m_nLevel+1 );
275cdf0e10cSrcweir         aRet[ m_nLevel ]=uno::makeAny(rNewValue);
276cdf0e10cSrcweir         return aRet;
277cdf0e10cSrcweir     }
278cdf0e10cSrcweir 
279cdf0e10cSrcweir private:
280cdf0e10cSrcweir     sal_Int32 m_nLevel;
281cdf0e10cSrcweir };
282cdf0e10cSrcweir 
283cdf0e10cSrcweir struct lcl_insertAnyAtLevel : public ::std::unary_function< vector< uno::Any >, void >
284cdf0e10cSrcweir {
285cdf0e10cSrcweir public:
286cdf0e10cSrcweir 
287cdf0e10cSrcweir     explicit lcl_insertAnyAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel )
288cdf0e10cSrcweir     {}
289cdf0e10cSrcweir 
290cdf0e10cSrcweir     void operator() ( vector< uno::Any >& rVector )
291cdf0e10cSrcweir     {
292cdf0e10cSrcweir         if( m_nLevel > static_cast< sal_Int32 >(rVector.size()) )
293cdf0e10cSrcweir             rVector.resize( m_nLevel );
294cdf0e10cSrcweir 
295cdf0e10cSrcweir         vector< uno::Any >::iterator aIt( rVector.begin() );
296cdf0e10cSrcweir         for( sal_Int32 nN=0; aIt<rVector.end(); aIt++, nN++)
297cdf0e10cSrcweir         {
298cdf0e10cSrcweir             if( nN==m_nLevel )
299cdf0e10cSrcweir                 break;
300cdf0e10cSrcweir         }
301cdf0e10cSrcweir         rVector.insert( aIt, uno::Any() );
302cdf0e10cSrcweir     }
303cdf0e10cSrcweir 
304cdf0e10cSrcweir private:
305cdf0e10cSrcweir     sal_Int32 m_nLevel;
306cdf0e10cSrcweir };
307cdf0e10cSrcweir 
308cdf0e10cSrcweir struct lcl_removeAnyAtLevel : public ::std::unary_function< vector< uno::Any >, void >
309cdf0e10cSrcweir {
310cdf0e10cSrcweir public:
311cdf0e10cSrcweir 
312cdf0e10cSrcweir     explicit lcl_removeAnyAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel )
313cdf0e10cSrcweir     {}
314cdf0e10cSrcweir 
315cdf0e10cSrcweir     void operator() ( vector< uno::Any >& rVector )
316cdf0e10cSrcweir     {
317cdf0e10cSrcweir         vector< uno::Any >::iterator aIt( rVector.begin() );
318cdf0e10cSrcweir         for( sal_Int32 nN=0; aIt<rVector.end(); aIt++, nN++)
319cdf0e10cSrcweir         {
320cdf0e10cSrcweir             if( nN==m_nLevel )
321cdf0e10cSrcweir             {
322cdf0e10cSrcweir                 rVector.erase( aIt );
323cdf0e10cSrcweir                 break;
324cdf0e10cSrcweir             }
325cdf0e10cSrcweir         }
326cdf0e10cSrcweir     }
327cdf0e10cSrcweir 
328cdf0e10cSrcweir private:
329cdf0e10cSrcweir     sal_Int32 m_nLevel;
330cdf0e10cSrcweir };
331cdf0e10cSrcweir 
332cdf0e10cSrcweir } // anonymous namespace
333cdf0e10cSrcweir 
334cdf0e10cSrcweir // ================================================================================
335cdf0e10cSrcweir 
336cdf0e10cSrcweir InternalDataProvider::InternalDataProvider( const Reference< uno::XComponentContext > & /*_xContext*/)
337cdf0e10cSrcweir     : m_bDataInColumns( true )
338cdf0e10cSrcweir {}
339cdf0e10cSrcweir 
340cdf0e10cSrcweir InternalDataProvider::InternalDataProvider( const Reference< chart2::XChartDocument > & xChartDoc, bool bConnectToModel )
341cdf0e10cSrcweir     : m_bDataInColumns( true )
342cdf0e10cSrcweir {
343cdf0e10cSrcweir     try
344cdf0e10cSrcweir     {
345cdf0e10cSrcweir         Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartDoc ) );
346cdf0e10cSrcweir         if( xDiagram.is())
347cdf0e10cSrcweir         {
348cdf0e10cSrcweir             Reference< frame::XModel > xChartModel( xChartDoc, uno::UNO_QUERY );
349cdf0e10cSrcweir 
350cdf0e10cSrcweir             //data in columns?
351cdf0e10cSrcweir             {
352cdf0e10cSrcweir                 ::rtl::OUString aRangeString;
353cdf0e10cSrcweir                 bool bFirstCellAsLabel = true;
354cdf0e10cSrcweir                 bool bHasCategories = true;
355cdf0e10cSrcweir                 uno::Sequence< sal_Int32 > aSequenceMapping;
356cdf0e10cSrcweir                 DataSourceHelper::detectRangeSegmentation( xChartModel, aRangeString, aSequenceMapping, m_bDataInColumns, bFirstCellAsLabel, bHasCategories );
357cdf0e10cSrcweir             }
358cdf0e10cSrcweir 
359cdf0e10cSrcweir             // categories
360cdf0e10cSrcweir             {
361cdf0e10cSrcweir                 vector< vector< uno::Any > > aNewCategories;//inner count is level
362cdf0e10cSrcweir                 {
363cdf0e10cSrcweir                     ExplicitCategoriesProvider aExplicitCategoriesProvider( ChartModelHelper::getFirstCoordinateSystem(xChartModel), xChartModel );
364cdf0e10cSrcweir 
365cdf0e10cSrcweir                     const Sequence< Reference< chart2::data::XLabeledDataSequence> >& rSplitCategoriesList( aExplicitCategoriesProvider.getSplitCategoriesList() );
366cdf0e10cSrcweir                     sal_Int32 nLevelCount = rSplitCategoriesList.getLength();
367cdf0e10cSrcweir                     for( sal_Int32 nL = 0; nL<nLevelCount; nL++ )
368cdf0e10cSrcweir                     {
369cdf0e10cSrcweir                         Reference< chart2::data::XLabeledDataSequence > xLDS( rSplitCategoriesList[nL] );
370cdf0e10cSrcweir                         if( !xLDS.is() )
371cdf0e10cSrcweir                             continue;
372cdf0e10cSrcweir                         Sequence< uno::Any > aDataSeq;
373cdf0e10cSrcweir                         Reference< chart2::data::XDataSequence > xSeq( xLDS->getValues() );
374cdf0e10cSrcweir                         if( xSeq.is() )
375cdf0e10cSrcweir                             aDataSeq = xSeq->getData();
376cdf0e10cSrcweir                         sal_Int32 nLength = aDataSeq.getLength();
377cdf0e10cSrcweir                         sal_Int32 nCatLength = static_cast< sal_Int32 >(aNewCategories.size());
378cdf0e10cSrcweir                         if( nCatLength < nLength )
379cdf0e10cSrcweir                             aNewCategories.resize( nLength );
380cdf0e10cSrcweir                         else if( nLength < nCatLength )
381cdf0e10cSrcweir                             aDataSeq.realloc( nCatLength );
382cdf0e10cSrcweir                         transform( aNewCategories.begin(), aNewCategories.end(), aDataSeq.getConstArray(),
383cdf0e10cSrcweir                             aNewCategories.begin(), lcl_setAnyAtLevel(nL) );
384cdf0e10cSrcweir                     }
385cdf0e10cSrcweir                     if( !nLevelCount )
386cdf0e10cSrcweir                     {
387cdf0e10cSrcweir                         Sequence< OUString > aSimplecategories = aExplicitCategoriesProvider.getSimpleCategories();
388cdf0e10cSrcweir                         sal_Int32 nLength = aSimplecategories.getLength();
389cdf0e10cSrcweir                         aNewCategories.reserve( nLength );
390cdf0e10cSrcweir                         for( sal_Int32 nN=0; nN<nLength; nN++)
391cdf0e10cSrcweir                         {
392cdf0e10cSrcweir                             vector< uno::Any > aVector(1);
393cdf0e10cSrcweir                             aVector[0] = uno::makeAny( aSimplecategories[nN] );
394cdf0e10cSrcweir                             aNewCategories.push_back( aVector );
395cdf0e10cSrcweir                         }
396cdf0e10cSrcweir                     }
397cdf0e10cSrcweir                 }
398cdf0e10cSrcweir 
399cdf0e10cSrcweir                 if( m_bDataInColumns )
400cdf0e10cSrcweir                     m_aInternalData.setComplexRowLabels( aNewCategories );
401cdf0e10cSrcweir                 else
402cdf0e10cSrcweir                     m_aInternalData.setComplexColumnLabels( aNewCategories );
403cdf0e10cSrcweir                 if( bConnectToModel )
404cdf0e10cSrcweir                     DiagramHelper::setCategoriesToDiagram( new LabeledDataSequence(
405cdf0e10cSrcweir                         createDataSequenceByRangeRepresentation( lcl_aCategoriesRangeName )), xDiagram );
406cdf0e10cSrcweir             }
407cdf0e10cSrcweir 
408cdf0e10cSrcweir             // data series
409cdf0e10cSrcweir             ::std::vector< Reference< chart2::XDataSeries > > aSeriesVector( ChartModelHelper::getDataSeries( xChartDoc ));
410cdf0e10cSrcweir             ::std::for_each( aSeriesVector.begin(), aSeriesVector.end(), lcl_internalizeSeries( m_aInternalData, *this, bConnectToModel, m_bDataInColumns ) );
411cdf0e10cSrcweir         }
412cdf0e10cSrcweir     }
413cdf0e10cSrcweir     catch( const uno::Exception & ex )
414cdf0e10cSrcweir     {
415cdf0e10cSrcweir         ASSERT_EXCEPTION( ex );
416cdf0e10cSrcweir     }
417cdf0e10cSrcweir }
418cdf0e10cSrcweir 
419cdf0e10cSrcweir // copy-CTOR
420cdf0e10cSrcweir InternalDataProvider::InternalDataProvider( const InternalDataProvider & rOther ) :
421cdf0e10cSrcweir         impl::InternalDataProvider_Base(),
422cdf0e10cSrcweir         m_aSequenceMap( rOther.m_aSequenceMap ),
423cdf0e10cSrcweir         m_aInternalData( rOther.m_aInternalData ),
424cdf0e10cSrcweir         m_bDataInColumns( rOther.m_bDataInColumns )
425cdf0e10cSrcweir {}
426cdf0e10cSrcweir 
427cdf0e10cSrcweir InternalDataProvider::~InternalDataProvider()
428cdf0e10cSrcweir {}
429cdf0e10cSrcweir 
430cdf0e10cSrcweir void InternalDataProvider::lcl_addDataSequenceToMap(
431cdf0e10cSrcweir     const OUString & rRangeRepresentation,
432cdf0e10cSrcweir     const Reference< chart2::data::XDataSequence > & xSequence )
433cdf0e10cSrcweir {
434cdf0e10cSrcweir     m_aSequenceMap.insert(
435cdf0e10cSrcweir         tSequenceMap::value_type(
436cdf0e10cSrcweir             rRangeRepresentation,
437cdf0e10cSrcweir             uno::WeakReference< chart2::data::XDataSequence >( xSequence )));
438cdf0e10cSrcweir }
439cdf0e10cSrcweir 
440cdf0e10cSrcweir void InternalDataProvider::lcl_deleteMapReferences( const OUString & rRangeRepresentation )
441cdf0e10cSrcweir {
442cdf0e10cSrcweir     // set sequence to deleted by setting its range to an empty string
443cdf0e10cSrcweir     tSequenceMapRange aRange( m_aSequenceMap.equal_range( rRangeRepresentation ));
444cdf0e10cSrcweir     for( tSequenceMap::iterator aIt( aRange.first ); aIt != aRange.second; ++aIt )
445cdf0e10cSrcweir     {
446cdf0e10cSrcweir         Reference< chart2::data::XDataSequence > xSeq( aIt->second );
447cdf0e10cSrcweir         if( xSeq.is())
448cdf0e10cSrcweir         {
449cdf0e10cSrcweir             Reference< container::XNamed > xNamed( xSeq, uno::UNO_QUERY );
450cdf0e10cSrcweir             if( xNamed.is())
451cdf0e10cSrcweir                 xNamed->setName( OUString());
452cdf0e10cSrcweir         }
453cdf0e10cSrcweir     }
454cdf0e10cSrcweir     // remove from map
455cdf0e10cSrcweir     m_aSequenceMap.erase( aRange.first, aRange.second );
456cdf0e10cSrcweir }
457cdf0e10cSrcweir 
458cdf0e10cSrcweir void InternalDataProvider::lcl_adaptMapReferences(
459cdf0e10cSrcweir     const OUString & rOldRangeRepresentation,
460cdf0e10cSrcweir     const OUString & rNewRangeRepresentation )
461cdf0e10cSrcweir {
462cdf0e10cSrcweir     tSequenceMapRange aRange( m_aSequenceMap.equal_range( rOldRangeRepresentation ));
463cdf0e10cSrcweir     tSequenceMap aNewElements;
464cdf0e10cSrcweir     for( tSequenceMap::iterator aIt( aRange.first ); aIt != aRange.second; ++aIt )
465cdf0e10cSrcweir     {
466cdf0e10cSrcweir         Reference< chart2::data::XDataSequence > xSeq( aIt->second );
467cdf0e10cSrcweir         if( xSeq.is())
468cdf0e10cSrcweir         {
469cdf0e10cSrcweir             Reference< container::XNamed > xNamed( xSeq, uno::UNO_QUERY );
470cdf0e10cSrcweir             if( xNamed.is())
471cdf0e10cSrcweir                 xNamed->setName( rNewRangeRepresentation );
472cdf0e10cSrcweir         }
473cdf0e10cSrcweir         aNewElements.insert( tSequenceMap::value_type( rNewRangeRepresentation, aIt->second ));
474cdf0e10cSrcweir     }
475cdf0e10cSrcweir     // erase map values for old index
476cdf0e10cSrcweir     m_aSequenceMap.erase( aRange.first, aRange.second );
477cdf0e10cSrcweir     // add new entries for values with new index
478cdf0e10cSrcweir     ::std::copy( aNewElements.begin(), aNewElements.end(),
479cdf0e10cSrcweir                  ::std::inserter( m_aSequenceMap,
480cdf0e10cSrcweir                                   m_aSequenceMap.upper_bound( rNewRangeRepresentation )));
481cdf0e10cSrcweir }
482cdf0e10cSrcweir 
483cdf0e10cSrcweir void InternalDataProvider::lcl_increaseMapReferences(
484cdf0e10cSrcweir     sal_Int32 nBegin, sal_Int32 nEnd )
485cdf0e10cSrcweir {
486cdf0e10cSrcweir     for( sal_Int32 nIndex = nEnd - 1; nIndex >= nBegin; --nIndex )
487cdf0e10cSrcweir     {
488cdf0e10cSrcweir         lcl_adaptMapReferences( OUString::valueOf( nIndex ),
489cdf0e10cSrcweir                             OUString::valueOf( nIndex + 1 ));
490cdf0e10cSrcweir         lcl_adaptMapReferences( lcl_aLabelRangePrefix + OUString::valueOf( nIndex ),
491cdf0e10cSrcweir                             lcl_aLabelRangePrefix + OUString::valueOf( nIndex + 1 ));
492cdf0e10cSrcweir     }
493cdf0e10cSrcweir }
494cdf0e10cSrcweir 
495cdf0e10cSrcweir void InternalDataProvider::lcl_decreaseMapReferences(
496cdf0e10cSrcweir     sal_Int32 nBegin, sal_Int32 nEnd )
497cdf0e10cSrcweir {
498cdf0e10cSrcweir     for( sal_Int32 nIndex = nBegin; nIndex < nEnd; ++nIndex )
499cdf0e10cSrcweir     {
500cdf0e10cSrcweir         lcl_adaptMapReferences( OUString::valueOf( nIndex ),
501cdf0e10cSrcweir                             OUString::valueOf( nIndex - 1 ));
502cdf0e10cSrcweir         lcl_adaptMapReferences( lcl_aLabelRangePrefix + OUString::valueOf( nIndex ),
503cdf0e10cSrcweir                             lcl_aLabelRangePrefix + OUString::valueOf( nIndex - 1 ));
504cdf0e10cSrcweir     }
505cdf0e10cSrcweir }
506cdf0e10cSrcweir 
507cdf0e10cSrcweir Reference< chart2::data::XDataSequence > InternalDataProvider::lcl_createDataSequenceAndAddToMap(
508cdf0e10cSrcweir     const OUString & rRangeRepresentation )
509cdf0e10cSrcweir {
510cdf0e10cSrcweir     Reference< chart2::data::XDataSequence > xSeq(
511cdf0e10cSrcweir         new UncachedDataSequence( this, rRangeRepresentation ));
512cdf0e10cSrcweir     lcl_addDataSequenceToMap( rRangeRepresentation, xSeq );
513cdf0e10cSrcweir     return xSeq;
514cdf0e10cSrcweir }
515cdf0e10cSrcweir 
516cdf0e10cSrcweir Reference< chart2::data::XDataSequence > InternalDataProvider::lcl_createDataSequenceAndAddToMap(
517cdf0e10cSrcweir     const OUString & rRangeRepresentation,
518cdf0e10cSrcweir     const OUString & rRole )
519cdf0e10cSrcweir {
520cdf0e10cSrcweir     Reference< chart2::data::XDataSequence > xSeq(
521cdf0e10cSrcweir         new UncachedDataSequence( this, rRangeRepresentation, rRole ));
522cdf0e10cSrcweir     lcl_addDataSequenceToMap( rRangeRepresentation, xSeq );
523cdf0e10cSrcweir     return xSeq;
524cdf0e10cSrcweir }
525cdf0e10cSrcweir 
526cdf0e10cSrcweir void InternalDataProvider::createDefaultData()
527cdf0e10cSrcweir {
528cdf0e10cSrcweir     m_aInternalData.createDefaultData();
529cdf0e10cSrcweir }
530cdf0e10cSrcweir 
531cdf0e10cSrcweir // ____ XDataProvider ____
532cdf0e10cSrcweir ::sal_Bool SAL_CALL InternalDataProvider::createDataSourcePossible( const Sequence< beans::PropertyValue >& /* aArguments */ )
533cdf0e10cSrcweir     throw (uno::RuntimeException)
534cdf0e10cSrcweir {
535cdf0e10cSrcweir     return true;
536cdf0e10cSrcweir }
537cdf0e10cSrcweir 
538cdf0e10cSrcweir namespace
539cdf0e10cSrcweir {
540cdf0e10cSrcweir 
541cdf0e10cSrcweir sal_Int32 lcl_getInnerLevelCount( const vector< vector< uno::Any > >& rLabels )
542cdf0e10cSrcweir {
543cdf0e10cSrcweir     sal_Int32 nCount = 1;//minimum is 1!
544cdf0e10cSrcweir     vector< vector< uno::Any > >::const_iterator aLevelIt( rLabels.begin() );
545cdf0e10cSrcweir     vector< vector< uno::Any > >::const_iterator aLevelEnd( rLabels.end() );
546cdf0e10cSrcweir     for( ;aLevelIt!=aLevelEnd; ++aLevelIt )
547cdf0e10cSrcweir     {
548cdf0e10cSrcweir         const vector< uno::Any >& rCurrentLevelLabels = *aLevelIt;
549cdf0e10cSrcweir         nCount = std::max<sal_Int32>( rCurrentLevelLabels.size(), nCount );
550cdf0e10cSrcweir     }
551cdf0e10cSrcweir     return nCount;
552cdf0e10cSrcweir }
553cdf0e10cSrcweir 
554cdf0e10cSrcweir }//end anonymous namespace
555cdf0e10cSrcweir 
556cdf0e10cSrcweir Reference< chart2::data::XDataSource > SAL_CALL InternalDataProvider::createDataSource(
557cdf0e10cSrcweir     const Sequence< beans::PropertyValue >& aArguments )
558cdf0e10cSrcweir     throw (lang::IllegalArgumentException,
559cdf0e10cSrcweir            uno::RuntimeException)
560cdf0e10cSrcweir {
561cdf0e10cSrcweir     OUString aRangeRepresentation;
562cdf0e10cSrcweir     bool bUseColumns = true;
563cdf0e10cSrcweir     bool bFirstCellAsLabel = true;
564cdf0e10cSrcweir     bool bHasCategories = true;
565cdf0e10cSrcweir     uno::Sequence< sal_Int32 > aSequenceMapping;
566cdf0e10cSrcweir     DataSourceHelper::readArguments( aArguments, aRangeRepresentation, aSequenceMapping, bUseColumns, bFirstCellAsLabel, bHasCategories );
567cdf0e10cSrcweir 
568cdf0e10cSrcweir     if( aRangeRepresentation.equals( lcl_aCategoriesRangeName ) )
569cdf0e10cSrcweir     {
570cdf0e10cSrcweir         //return split complex categories if we have any:
571cdf0e10cSrcweir         ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aComplexCategories;
572cdf0e10cSrcweir         vector< vector< uno::Any > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels());
573cdf0e10cSrcweir         if( bUseColumns==m_bDataInColumns )
574cdf0e10cSrcweir         {
575cdf0e10cSrcweir             sal_Int32 nLevelCount = lcl_getInnerLevelCount( aCategories );
576cdf0e10cSrcweir             for( sal_Int32 nL=0; nL<nLevelCount; nL++ )
577cdf0e10cSrcweir                 aComplexCategories.push_back( new LabeledDataSequence(
578cdf0e10cSrcweir                     new UncachedDataSequence( this
579cdf0e10cSrcweir                         , lcl_aCategoriesLevelRangeNamePrefix + OUString::valueOf( nL )
580cdf0e10cSrcweir                         , lcl_aCategoriesRoleName ) ) );
581cdf0e10cSrcweir         }
582cdf0e10cSrcweir         else
583cdf0e10cSrcweir         {
584cdf0e10cSrcweir             sal_Int32 nPointCount = m_bDataInColumns ? m_aInternalData.getRowCount() : m_aInternalData.getColumnCount();
585cdf0e10cSrcweir             for( sal_Int32 nP=0; nP<nPointCount; nP++ )
586cdf0e10cSrcweir                 aComplexCategories.push_back( new LabeledDataSequence(
587cdf0e10cSrcweir                     new UncachedDataSequence( this
588cdf0e10cSrcweir                         , lcl_aCategoriesPointRangeNamePrefix + OUString::valueOf( nP )
589cdf0e10cSrcweir                         , lcl_aCategoriesRoleName ) ) );
590cdf0e10cSrcweir         }
591cdf0e10cSrcweir         //don't add the created sequences to the map as they are used temporarily only ...
592cdf0e10cSrcweir         return new DataSource( ContainerHelper::ContainerToSequence(aComplexCategories) );
593cdf0e10cSrcweir     }
594cdf0e10cSrcweir 
595cdf0e10cSrcweir     OSL_ASSERT( aRangeRepresentation.equals( lcl_aCompleteRange ));
596cdf0e10cSrcweir 
597cdf0e10cSrcweir     ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aResultLSeqVec;
598cdf0e10cSrcweir 
599cdf0e10cSrcweir     // categories
600cdf0e10cSrcweir     if( bHasCategories )
601cdf0e10cSrcweir         aResultLSeqVec.push_back(
602cdf0e10cSrcweir             new LabeledDataSequence( lcl_createDataSequenceAndAddToMap( lcl_aCategoriesRangeName, lcl_aCategoriesRoleName ) ) );
603cdf0e10cSrcweir 
604cdf0e10cSrcweir     // data with labels
605cdf0e10cSrcweir     ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aDataVec;
606cdf0e10cSrcweir     const sal_Int32 nCount = (bUseColumns ? m_aInternalData.getColumnCount() : m_aInternalData.getRowCount());
607cdf0e10cSrcweir     for( sal_Int32 nIdx=0; nIdx<nCount; ++nIdx )
608cdf0e10cSrcweir     {
609cdf0e10cSrcweir         aDataVec.push_back(
610cdf0e10cSrcweir             new LabeledDataSequence(
611cdf0e10cSrcweir                 lcl_createDataSequenceAndAddToMap( OUString::valueOf( nIdx )),
612cdf0e10cSrcweir                 lcl_createDataSequenceAndAddToMap( lcl_aLabelRangePrefix + OUString::valueOf( nIdx ))));
613cdf0e10cSrcweir     }
614cdf0e10cSrcweir 
615cdf0e10cSrcweir     // attention: this data provider has the limitation that it stores
616cdf0e10cSrcweir     // internally if data comes from columns or rows. It is intended for
617cdf0e10cSrcweir     // creating only one used data source.
618cdf0e10cSrcweir     // @todo: add this information in the range representation strings
619cdf0e10cSrcweir     m_bDataInColumns = bUseColumns;
620cdf0e10cSrcweir 
621cdf0e10cSrcweir     //reorder labeled sequences according to aSequenceMapping; ignore categories
622cdf0e10cSrcweir     for( sal_Int32 nNewIndex = 0; nNewIndex < aSequenceMapping.getLength(); nNewIndex++ )
623cdf0e10cSrcweir     {
624cdf0e10cSrcweir         std::vector< LabeledDataSequence* >::size_type nOldIndex = aSequenceMapping[nNewIndex];
625cdf0e10cSrcweir         if( nOldIndex < aDataVec.size() )
626cdf0e10cSrcweir         {
627cdf0e10cSrcweir             if( aDataVec[nOldIndex].is() )
628cdf0e10cSrcweir             {
629cdf0e10cSrcweir                 aResultLSeqVec.push_back( aDataVec[nOldIndex] );
630cdf0e10cSrcweir                 aDataVec[nOldIndex] = 0;
631cdf0e10cSrcweir             }
632cdf0e10cSrcweir         }
633cdf0e10cSrcweir     }
634cdf0e10cSrcweir 
635cdf0e10cSrcweir     //add left over data sequences to result
636cdf0e10cSrcweir     ::std::vector< Reference< chart2::data::XLabeledDataSequence > >::iterator aIt(aDataVec.begin());
637cdf0e10cSrcweir     const ::std::vector< Reference< chart2::data::XLabeledDataSequence > >::const_iterator aEndIt(aDataVec.end());
638cdf0e10cSrcweir     for( ;aIt!=aEndIt; ++aIt)
639cdf0e10cSrcweir     {
640cdf0e10cSrcweir         if( aIt->is() )
641cdf0e10cSrcweir             aResultLSeqVec.push_back( *aIt );
642cdf0e10cSrcweir     }
643cdf0e10cSrcweir 
644cdf0e10cSrcweir     return new DataSource( ContainerHelper::ContainerToSequence(aResultLSeqVec) );
645cdf0e10cSrcweir }
646cdf0e10cSrcweir 
647cdf0e10cSrcweir Sequence< beans::PropertyValue > SAL_CALL InternalDataProvider::detectArguments(
648cdf0e10cSrcweir     const Reference< chart2::data::XDataSource >& /* xDataSource */ )
649cdf0e10cSrcweir     throw (uno::RuntimeException)
650cdf0e10cSrcweir {
651cdf0e10cSrcweir     Sequence< beans::PropertyValue > aArguments( 4 );
652cdf0e10cSrcweir     aArguments[0] = beans::PropertyValue(
653cdf0e10cSrcweir         C2U("CellRangeRepresentation"), -1, uno::makeAny( lcl_aCompleteRange ),
654cdf0e10cSrcweir         beans::PropertyState_DIRECT_VALUE );
655cdf0e10cSrcweir     aArguments[1] = beans::PropertyValue(
656cdf0e10cSrcweir         C2U("DataRowSource"), -1, uno::makeAny(
657cdf0e10cSrcweir             m_bDataInColumns
658cdf0e10cSrcweir             ? ::com::sun::star::chart::ChartDataRowSource_COLUMNS
659cdf0e10cSrcweir             : ::com::sun::star::chart::ChartDataRowSource_ROWS ),
660cdf0e10cSrcweir         beans::PropertyState_DIRECT_VALUE );
661cdf0e10cSrcweir     // internal data always contains labels and categories
662cdf0e10cSrcweir     aArguments[2] = beans::PropertyValue(
663cdf0e10cSrcweir         C2U("FirstCellAsLabel"), -1, uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE );
664cdf0e10cSrcweir     aArguments[3] = beans::PropertyValue(
665cdf0e10cSrcweir         C2U("HasCategories"), -1, uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE );
666cdf0e10cSrcweir 
667cdf0e10cSrcweir     // #i85913# Sequence Mapping is not needed for internal data, as it is
668cdf0e10cSrcweir     // applied to the data when the data source is created.
669cdf0e10cSrcweir 
670cdf0e10cSrcweir     return aArguments;
671cdf0e10cSrcweir }
672cdf0e10cSrcweir 
673cdf0e10cSrcweir ::sal_Bool SAL_CALL InternalDataProvider::createDataSequenceByRangeRepresentationPossible( const OUString& /* aRangeRepresentation */ )
674cdf0e10cSrcweir     throw (uno::RuntimeException)
675cdf0e10cSrcweir {
676cdf0e10cSrcweir     return true;
677cdf0e10cSrcweir }
678cdf0e10cSrcweir 
679cdf0e10cSrcweir Reference< chart2::data::XDataSequence > SAL_CALL InternalDataProvider::createDataSequenceByRangeRepresentation(
680cdf0e10cSrcweir     const OUString& aRangeRepresentation )
681cdf0e10cSrcweir     throw (lang::IllegalArgumentException,
682cdf0e10cSrcweir            uno::RuntimeException)
683cdf0e10cSrcweir {
684cdf0e10cSrcweir     if( aRangeRepresentation.match( lcl_aCategoriesRangeName ))
685cdf0e10cSrcweir     {
686cdf0e10cSrcweir         OSL_ASSERT( aRangeRepresentation.equals( lcl_aCategoriesRangeName ) );//it is not expected nor implmented that only parts of the categories are really requested
687cdf0e10cSrcweir 
688cdf0e10cSrcweir         // categories
689cdf0e10cSrcweir         return lcl_createDataSequenceAndAddToMap( lcl_aCategoriesRangeName, lcl_aCategoriesRoleName );
690cdf0e10cSrcweir     }
691cdf0e10cSrcweir     else if( aRangeRepresentation.match( lcl_aLabelRangePrefix ))
692cdf0e10cSrcweir     {
693cdf0e10cSrcweir         // label
694cdf0e10cSrcweir         sal_Int32 nIndex = aRangeRepresentation.copy( lcl_aLabelRangePrefix.getLength()).toInt32();
695cdf0e10cSrcweir         return lcl_createDataSequenceAndAddToMap( lcl_aLabelRangePrefix + OUString::valueOf( nIndex ));
696cdf0e10cSrcweir     }
697cdf0e10cSrcweir     else if( aRangeRepresentation.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "last" )))
698cdf0e10cSrcweir     {
699cdf0e10cSrcweir         sal_Int32 nIndex = (m_bDataInColumns
700cdf0e10cSrcweir                             ? m_aInternalData.getColumnCount()
701cdf0e10cSrcweir                             : m_aInternalData.getRowCount()) - 1;
702cdf0e10cSrcweir         return lcl_createDataSequenceAndAddToMap( OUString::valueOf( nIndex ));
703cdf0e10cSrcweir     }
704cdf0e10cSrcweir     else if( aRangeRepresentation.getLength())
705cdf0e10cSrcweir     {
706cdf0e10cSrcweir         // data
707cdf0e10cSrcweir         sal_Int32 nIndex = aRangeRepresentation.toInt32();
708cdf0e10cSrcweir         return lcl_createDataSequenceAndAddToMap( OUString::valueOf( nIndex ));
709cdf0e10cSrcweir     }
710cdf0e10cSrcweir 
711cdf0e10cSrcweir     return Reference< chart2::data::XDataSequence >();
712cdf0e10cSrcweir }
713cdf0e10cSrcweir 
714cdf0e10cSrcweir Reference< sheet::XRangeSelection > SAL_CALL InternalDataProvider::getRangeSelection()
715cdf0e10cSrcweir     throw (uno::RuntimeException)
716cdf0e10cSrcweir {
717cdf0e10cSrcweir     // there is no range selection component
718cdf0e10cSrcweir     return Reference< sheet::XRangeSelection >();
719cdf0e10cSrcweir }
720cdf0e10cSrcweir 
721cdf0e10cSrcweir // ____ XInternalDataProvider ____
722cdf0e10cSrcweir ::sal_Bool SAL_CALL InternalDataProvider::hasDataByRangeRepresentation( const OUString& aRange )
723cdf0e10cSrcweir     throw (uno::RuntimeException)
724cdf0e10cSrcweir {
725cdf0e10cSrcweir     sal_Bool bResult = false;
726cdf0e10cSrcweir 
727cdf0e10cSrcweir     if( aRange.match( lcl_aCategoriesRangeName ))
728cdf0e10cSrcweir     {
729cdf0e10cSrcweir         OSL_ASSERT( aRange.equals( lcl_aCategoriesRangeName ) );//it is not expected nor implmented that only parts of the categories are really requested
730cdf0e10cSrcweir         bResult = true;
731cdf0e10cSrcweir     }
732cdf0e10cSrcweir     else if( aRange.match( lcl_aLabelRangePrefix ))
733cdf0e10cSrcweir     {
734cdf0e10cSrcweir         sal_Int32 nIndex = aRange.copy( lcl_aLabelRangePrefix.getLength()).toInt32();
735cdf0e10cSrcweir         bResult = (nIndex < (m_bDataInColumns ? m_aInternalData.getColumnCount(): m_aInternalData.getRowCount()));
736cdf0e10cSrcweir     }
737cdf0e10cSrcweir     else
738cdf0e10cSrcweir     {
739cdf0e10cSrcweir         sal_Int32 nIndex = aRange.toInt32();
740cdf0e10cSrcweir         bResult = (nIndex < (m_bDataInColumns ? m_aInternalData.getColumnCount(): m_aInternalData.getRowCount()));
741cdf0e10cSrcweir     }
742cdf0e10cSrcweir 
743cdf0e10cSrcweir     return bResult;
744cdf0e10cSrcweir }
745cdf0e10cSrcweir 
746cdf0e10cSrcweir Sequence< uno::Any > SAL_CALL InternalDataProvider::getDataByRangeRepresentation( const OUString& aRange )
747cdf0e10cSrcweir     throw (uno::RuntimeException)
748cdf0e10cSrcweir {
749cdf0e10cSrcweir     Sequence< uno::Any > aResult;
750cdf0e10cSrcweir 
751cdf0e10cSrcweir     if( aRange.match( lcl_aLabelRangePrefix ) )
752cdf0e10cSrcweir     {
753cdf0e10cSrcweir         sal_Int32 nIndex = aRange.copy( lcl_aLabelRangePrefix.getLength()).toInt32();
754cdf0e10cSrcweir         vector< uno::Any > aComplexLabel = m_bDataInColumns
755cdf0e10cSrcweir             ? m_aInternalData.getComplexColumnLabel( nIndex )
756cdf0e10cSrcweir             : m_aInternalData.getComplexRowLabel( nIndex );
757cdf0e10cSrcweir         if( !aComplexLabel.empty() )
758cdf0e10cSrcweir             aResult = ContainerHelper::ContainerToSequence(aComplexLabel);
759cdf0e10cSrcweir     }
760cdf0e10cSrcweir     else if( aRange.match( lcl_aCategoriesPointRangeNamePrefix ) )
761cdf0e10cSrcweir     {
762cdf0e10cSrcweir         sal_Int32 nPointIndex = aRange.copy( lcl_aCategoriesPointRangeNamePrefix.getLength() ).toInt32();
763cdf0e10cSrcweir         vector< uno::Any > aComplexCategory = m_bDataInColumns
764cdf0e10cSrcweir             ? m_aInternalData.getComplexRowLabel( nPointIndex )
765cdf0e10cSrcweir             : m_aInternalData.getComplexColumnLabel( nPointIndex );
766cdf0e10cSrcweir         if( !aComplexCategory.empty() )
767cdf0e10cSrcweir             aResult = ContainerHelper::ContainerToSequence(aComplexCategory);
768cdf0e10cSrcweir     }
769cdf0e10cSrcweir     else if( aRange.match( lcl_aCategoriesLevelRangeNamePrefix ) )
770cdf0e10cSrcweir     {
771cdf0e10cSrcweir         sal_Int32 nLevel = aRange.copy( lcl_aCategoriesLevelRangeNamePrefix.getLength() ).toInt32();
772cdf0e10cSrcweir         vector< vector< uno::Any > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels());
773cdf0e10cSrcweir         if( nLevel < lcl_getInnerLevelCount( aCategories ) )
774cdf0e10cSrcweir         {
775cdf0e10cSrcweir             aResult.realloc( aCategories.size() );
776cdf0e10cSrcweir             transform( aCategories.begin(), aCategories.end(),
777cdf0e10cSrcweir                        aResult.getArray(), lcl_copyFromLevel(nLevel) );
778cdf0e10cSrcweir         }
779cdf0e10cSrcweir     }
780cdf0e10cSrcweir     else if( aRange.equals( lcl_aCategoriesRangeName ) )
781cdf0e10cSrcweir     {
782cdf0e10cSrcweir         vector< vector< uno::Any > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels());
783cdf0e10cSrcweir         sal_Int32 nLevelCount = lcl_getInnerLevelCount( aCategories );
784cdf0e10cSrcweir         if( nLevelCount == 1 )
785cdf0e10cSrcweir         {
786cdf0e10cSrcweir             sal_Int32 nL=0;
787cdf0e10cSrcweir             aResult = this->getDataByRangeRepresentation( lcl_aCategoriesLevelRangeNamePrefix + OUString::valueOf( nL ) );
788cdf0e10cSrcweir         }
789cdf0e10cSrcweir         else
790cdf0e10cSrcweir         {
791cdf0e10cSrcweir             Sequence< OUString > aLabels = m_bDataInColumns ? this->getRowDescriptions() : this->getColumnDescriptions();
792cdf0e10cSrcweir             aResult.realloc( aLabels.getLength() );
793cdf0e10cSrcweir             transform( aLabels.getConstArray(), aLabels.getConstArray() + aLabels.getLength(),
794cdf0e10cSrcweir                        aResult.getArray(), CommonFunctors::makeAny< OUString >() );
795cdf0e10cSrcweir         }
796cdf0e10cSrcweir     }
797cdf0e10cSrcweir     else
798cdf0e10cSrcweir     {
799cdf0e10cSrcweir         sal_Int32 nIndex = aRange.toInt32();
800cdf0e10cSrcweir         if( nIndex >= 0 )
801cdf0e10cSrcweir         {
802cdf0e10cSrcweir             Sequence< double > aData;
803cdf0e10cSrcweir             if( m_bDataInColumns )
804cdf0e10cSrcweir                 aData = m_aInternalData.getColumnValues(nIndex);
805cdf0e10cSrcweir             else
806cdf0e10cSrcweir                 aData = m_aInternalData.getRowValues(nIndex);
807cdf0e10cSrcweir             if( aData.getLength() )
808cdf0e10cSrcweir             {
809cdf0e10cSrcweir 			    aResult.realloc( aData.getLength());
810cdf0e10cSrcweir                 transform( aData.getConstArray(), aData.getConstArray() + aData.getLength(),
811cdf0e10cSrcweir                            aResult.getArray(), CommonFunctors::makeAny< double >());
812cdf0e10cSrcweir             }
813cdf0e10cSrcweir         }
814cdf0e10cSrcweir     }
815cdf0e10cSrcweir 
816cdf0e10cSrcweir     return aResult;
817cdf0e10cSrcweir }
818cdf0e10cSrcweir 
819cdf0e10cSrcweir void SAL_CALL InternalDataProvider::setDataByRangeRepresentation(
820cdf0e10cSrcweir     const OUString& aRange, const Sequence< uno::Any >& aNewData )
821cdf0e10cSrcweir     throw (uno::RuntimeException)
822cdf0e10cSrcweir {
823cdf0e10cSrcweir     vector< uno::Any > aNewVector( ContainerHelper::SequenceToVector(aNewData) );
824cdf0e10cSrcweir     if( aRange.match( lcl_aLabelRangePrefix ) )
825cdf0e10cSrcweir     {
826cdf0e10cSrcweir         sal_uInt32 nIndex = aRange.copy( lcl_aLabelRangePrefix.getLength()).toInt32();
827cdf0e10cSrcweir         if( m_bDataInColumns )
828cdf0e10cSrcweir             m_aInternalData.setComplexColumnLabel( nIndex, aNewVector );
829cdf0e10cSrcweir         else
830cdf0e10cSrcweir             m_aInternalData.setComplexRowLabel( nIndex, aNewVector );
831cdf0e10cSrcweir     }
832cdf0e10cSrcweir     else if( aRange.match( lcl_aCategoriesPointRangeNamePrefix ) )
833cdf0e10cSrcweir     {
834cdf0e10cSrcweir         sal_Int32 nPointIndex = aRange.copy( lcl_aCategoriesLevelRangeNamePrefix.getLength()).toInt32();
835cdf0e10cSrcweir         if( m_bDataInColumns )
836cdf0e10cSrcweir             m_aInternalData.setComplexRowLabel( nPointIndex, aNewVector );
837cdf0e10cSrcweir         else
838cdf0e10cSrcweir             m_aInternalData.setComplexColumnLabel( nPointIndex, aNewVector );
839cdf0e10cSrcweir     }
840cdf0e10cSrcweir     else if( aRange.match( lcl_aCategoriesLevelRangeNamePrefix ) )
841cdf0e10cSrcweir     {
842cdf0e10cSrcweir         sal_Int32 nLevel = aRange.copy( lcl_aCategoriesLevelRangeNamePrefix.getLength()).toInt32();
843cdf0e10cSrcweir         vector< vector< uno::Any > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels();
844cdf0e10cSrcweir 
845cdf0e10cSrcweir         //ensure equal length
846cdf0e10cSrcweir         if( aNewVector.size() > aComplexCategories.size() )
847cdf0e10cSrcweir             aComplexCategories.resize( aNewVector.size() );
848cdf0e10cSrcweir         else if( aNewVector.size() < aComplexCategories.size() )
849cdf0e10cSrcweir             aNewVector.resize( aComplexCategories.size() );
850cdf0e10cSrcweir 
851cdf0e10cSrcweir         transform( aComplexCategories.begin(), aComplexCategories.end(), aNewVector.begin(),
852cdf0e10cSrcweir                    aComplexCategories.begin(), lcl_setAnyAtLevel(nLevel) );
853cdf0e10cSrcweir 
854cdf0e10cSrcweir         if( m_bDataInColumns )
855cdf0e10cSrcweir             m_aInternalData.setComplexRowLabels( aComplexCategories );
856cdf0e10cSrcweir         else
857cdf0e10cSrcweir             m_aInternalData.setComplexColumnLabels( aComplexCategories );
858cdf0e10cSrcweir     }
859cdf0e10cSrcweir     else if( aRange.equals( lcl_aCategoriesRangeName ) )
860cdf0e10cSrcweir     {
861cdf0e10cSrcweir         vector< vector< uno::Any > > aComplexCategories;
862cdf0e10cSrcweir         aComplexCategories.resize( aNewVector.size() );
863cdf0e10cSrcweir         transform( aComplexCategories.begin(), aComplexCategories.end(), aNewVector.begin(),
864cdf0e10cSrcweir                             aComplexCategories.begin(), lcl_setAnyAtLevel(0) );
865cdf0e10cSrcweir         if( m_bDataInColumns )
866cdf0e10cSrcweir             m_aInternalData.setComplexRowLabels( aComplexCategories );
867cdf0e10cSrcweir         else
868cdf0e10cSrcweir             m_aInternalData.setComplexColumnLabels( aComplexCategories );
869cdf0e10cSrcweir     }
870cdf0e10cSrcweir     else
871cdf0e10cSrcweir     {
872cdf0e10cSrcweir         sal_Int32 nIndex = aRange.toInt32();
873cdf0e10cSrcweir         if( nIndex>=0 )
874cdf0e10cSrcweir         {
875cdf0e10cSrcweir             vector< double > aNewDataVec;
876cdf0e10cSrcweir             transform( aNewData.getConstArray(), aNewData.getConstArray() + aNewData.getLength(),
877cdf0e10cSrcweir                        back_inserter( aNewDataVec ), CommonFunctors::AnyToDouble());
878cdf0e10cSrcweir             if( m_bDataInColumns )
879cdf0e10cSrcweir                 m_aInternalData.setColumnValues( nIndex, aNewDataVec );
880cdf0e10cSrcweir             else
881cdf0e10cSrcweir                 m_aInternalData.setRowValues( nIndex, aNewDataVec );
882cdf0e10cSrcweir         }
883cdf0e10cSrcweir     }
884cdf0e10cSrcweir }
885cdf0e10cSrcweir 
886cdf0e10cSrcweir void SAL_CALL InternalDataProvider::insertSequence( ::sal_Int32 nAfterIndex )
887cdf0e10cSrcweir     throw (uno::RuntimeException)
888cdf0e10cSrcweir {
889cdf0e10cSrcweir     if( m_bDataInColumns )
890cdf0e10cSrcweir     {
891cdf0e10cSrcweir         lcl_increaseMapReferences( nAfterIndex + 1, m_aInternalData.getColumnCount());
892cdf0e10cSrcweir         m_aInternalData.insertColumn( nAfterIndex );
893cdf0e10cSrcweir     }
894cdf0e10cSrcweir     else
895cdf0e10cSrcweir     {
896cdf0e10cSrcweir         lcl_increaseMapReferences( nAfterIndex + 1, m_aInternalData.getRowCount());
897cdf0e10cSrcweir         m_aInternalData.insertRow( nAfterIndex );
898cdf0e10cSrcweir     }
899cdf0e10cSrcweir }
900cdf0e10cSrcweir 
901cdf0e10cSrcweir void SAL_CALL InternalDataProvider::deleteSequence( ::sal_Int32 nAtIndex )
902cdf0e10cSrcweir     throw (uno::RuntimeException)
903cdf0e10cSrcweir {
904cdf0e10cSrcweir     lcl_deleteMapReferences( OUString::valueOf( nAtIndex ));
905cdf0e10cSrcweir     lcl_deleteMapReferences( lcl_aLabelRangePrefix + OUString::valueOf( nAtIndex ));
906cdf0e10cSrcweir     if( m_bDataInColumns )
907cdf0e10cSrcweir     {
908cdf0e10cSrcweir         lcl_decreaseMapReferences( nAtIndex + 1, m_aInternalData.getColumnCount());
909cdf0e10cSrcweir         m_aInternalData.deleteColumn( nAtIndex );
910cdf0e10cSrcweir     }
911cdf0e10cSrcweir     else
912cdf0e10cSrcweir     {
913cdf0e10cSrcweir         lcl_decreaseMapReferences( nAtIndex + 1, m_aInternalData.getRowCount());
914cdf0e10cSrcweir         m_aInternalData.deleteRow( nAtIndex );
915cdf0e10cSrcweir     }
916cdf0e10cSrcweir }
917cdf0e10cSrcweir 
918cdf0e10cSrcweir void SAL_CALL InternalDataProvider::appendSequence()
919cdf0e10cSrcweir     throw (uno::RuntimeException)
920cdf0e10cSrcweir {
921cdf0e10cSrcweir     if( m_bDataInColumns )
922cdf0e10cSrcweir         m_aInternalData.appendColumn();
923cdf0e10cSrcweir     else
924cdf0e10cSrcweir         m_aInternalData.appendRow();
925cdf0e10cSrcweir }
926cdf0e10cSrcweir 
927cdf0e10cSrcweir void SAL_CALL InternalDataProvider::insertComplexCategoryLevel( sal_Int32 nLevel )
928cdf0e10cSrcweir         throw (uno::RuntimeException)
929cdf0e10cSrcweir {
930cdf0e10cSrcweir     OSL_ENSURE( nLevel> 0, "you can only insert category levels > 0" );//the first categories level cannot be deleted, check the calling code for error
931cdf0e10cSrcweir     if( nLevel>0 )
932cdf0e10cSrcweir     {
933cdf0e10cSrcweir         vector< vector< uno::Any > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels();
934cdf0e10cSrcweir         ::std::for_each( aComplexCategories.begin(), aComplexCategories.end(), lcl_insertAnyAtLevel(nLevel) );
935cdf0e10cSrcweir         if( m_bDataInColumns )
936cdf0e10cSrcweir             m_aInternalData.setComplexRowLabels( aComplexCategories );
937cdf0e10cSrcweir         else
938cdf0e10cSrcweir             m_aInternalData.setComplexColumnLabels( aComplexCategories );
939cdf0e10cSrcweir 
940cdf0e10cSrcweir         tSequenceMapRange aRange( m_aSequenceMap.equal_range( lcl_aCategoriesRangeName ));
941cdf0e10cSrcweir         ::std::for_each( aRange.first, aRange.second, lcl_setModified());
942cdf0e10cSrcweir     }
943cdf0e10cSrcweir }
944cdf0e10cSrcweir void SAL_CALL InternalDataProvider::deleteComplexCategoryLevel( sal_Int32 nLevel )
945cdf0e10cSrcweir         throw (uno::RuntimeException)
946cdf0e10cSrcweir {
947cdf0e10cSrcweir     OSL_ENSURE( nLevel>0, "you can only delete category levels > 0" );//the first categories level cannot be deleted, check the calling code for error
948cdf0e10cSrcweir     if( nLevel>0 )
949cdf0e10cSrcweir     {
950cdf0e10cSrcweir         vector< vector< uno::Any > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels();
951cdf0e10cSrcweir         ::std::for_each( aComplexCategories.begin(), aComplexCategories.end(), lcl_removeAnyAtLevel(nLevel) );
952cdf0e10cSrcweir         if( m_bDataInColumns )
953cdf0e10cSrcweir             m_aInternalData.setComplexRowLabels( aComplexCategories );
954cdf0e10cSrcweir         else
955cdf0e10cSrcweir             m_aInternalData.setComplexColumnLabels( aComplexCategories );
956cdf0e10cSrcweir 
957cdf0e10cSrcweir         tSequenceMapRange aRange( m_aSequenceMap.equal_range( lcl_aCategoriesRangeName ));
958cdf0e10cSrcweir         ::std::for_each( aRange.first, aRange.second, lcl_setModified());
959cdf0e10cSrcweir     }
960cdf0e10cSrcweir }
961cdf0e10cSrcweir 
962cdf0e10cSrcweir void SAL_CALL InternalDataProvider::insertDataPointForAllSequences( ::sal_Int32 nAfterIndex )
963cdf0e10cSrcweir     throw (uno::RuntimeException)
964cdf0e10cSrcweir {
965cdf0e10cSrcweir     sal_Int32 nMaxRep = 0;
966cdf0e10cSrcweir     if( m_bDataInColumns )
967cdf0e10cSrcweir     {
968cdf0e10cSrcweir         m_aInternalData.insertRow( nAfterIndex );
969cdf0e10cSrcweir         nMaxRep = m_aInternalData.getColumnCount();
970cdf0e10cSrcweir     }
971cdf0e10cSrcweir     else
972cdf0e10cSrcweir     {
973cdf0e10cSrcweir         m_aInternalData.insertColumn( nAfterIndex );
974cdf0e10cSrcweir         nMaxRep = m_aInternalData.getRowCount();
975cdf0e10cSrcweir     }
976cdf0e10cSrcweir 
977cdf0e10cSrcweir     // notify change to all affected ranges
978cdf0e10cSrcweir     tSequenceMap::const_iterator aBegin( m_aSequenceMap.lower_bound( C2U("0")));
979cdf0e10cSrcweir     tSequenceMap::const_iterator aEnd( m_aSequenceMap.upper_bound( OUString::valueOf( nMaxRep )));
980cdf0e10cSrcweir     ::std::for_each( aBegin, aEnd, lcl_setModified());
981cdf0e10cSrcweir 
982cdf0e10cSrcweir     tSequenceMapRange aRange( m_aSequenceMap.equal_range( lcl_aCategoriesRangeName ));
983cdf0e10cSrcweir     ::std::for_each( aRange.first, aRange.second, lcl_setModified());
984cdf0e10cSrcweir }
985cdf0e10cSrcweir 
986cdf0e10cSrcweir void SAL_CALL InternalDataProvider::deleteDataPointForAllSequences( ::sal_Int32 nAtIndex )
987cdf0e10cSrcweir     throw (uno::RuntimeException)
988cdf0e10cSrcweir {
989cdf0e10cSrcweir     sal_Int32 nMaxRep = 0;
990cdf0e10cSrcweir     if( m_bDataInColumns )
991cdf0e10cSrcweir     {
992cdf0e10cSrcweir         m_aInternalData.deleteRow( nAtIndex );
993cdf0e10cSrcweir         nMaxRep = m_aInternalData.getColumnCount();
994cdf0e10cSrcweir     }
995cdf0e10cSrcweir     else
996cdf0e10cSrcweir     {
997cdf0e10cSrcweir         m_aInternalData.deleteColumn( nAtIndex );
998cdf0e10cSrcweir         nMaxRep = m_aInternalData.getRowCount();
999cdf0e10cSrcweir     }
1000cdf0e10cSrcweir 
1001cdf0e10cSrcweir     // notify change to all affected ranges
1002cdf0e10cSrcweir     tSequenceMap::const_iterator aBegin( m_aSequenceMap.lower_bound( C2U("0")));
1003cdf0e10cSrcweir     tSequenceMap::const_iterator aEnd( m_aSequenceMap.upper_bound( OUString::valueOf( nMaxRep )));
1004cdf0e10cSrcweir     ::std::for_each( aBegin, aEnd, lcl_setModified());
1005cdf0e10cSrcweir 
1006cdf0e10cSrcweir     tSequenceMapRange aRange( m_aSequenceMap.equal_range( lcl_aCategoriesRangeName ));
1007cdf0e10cSrcweir     ::std::for_each( aRange.first, aRange.second, lcl_setModified());
1008cdf0e10cSrcweir }
1009cdf0e10cSrcweir 
1010cdf0e10cSrcweir void SAL_CALL InternalDataProvider::swapDataPointWithNextOneForAllSequences( ::sal_Int32 nAtIndex )
1011cdf0e10cSrcweir     throw (uno::RuntimeException)
1012cdf0e10cSrcweir {
1013cdf0e10cSrcweir     if( m_bDataInColumns )
1014cdf0e10cSrcweir         m_aInternalData.swapRowWithNext( nAtIndex );
1015cdf0e10cSrcweir     else
1016cdf0e10cSrcweir         m_aInternalData.swapColumnWithNext( nAtIndex );
1017cdf0e10cSrcweir     sal_Int32 nMaxRep = (m_bDataInColumns
1018cdf0e10cSrcweir                          ? m_aInternalData.getColumnCount()
1019cdf0e10cSrcweir                          : m_aInternalData.getRowCount());
1020cdf0e10cSrcweir 
1021cdf0e10cSrcweir     // notify change to all affected ranges
1022cdf0e10cSrcweir     tSequenceMap::const_iterator aBegin( m_aSequenceMap.lower_bound( C2U("0")));
1023cdf0e10cSrcweir     tSequenceMap::const_iterator aEnd( m_aSequenceMap.upper_bound( OUString::valueOf( nMaxRep )));
1024cdf0e10cSrcweir     ::std::for_each( aBegin, aEnd, lcl_setModified());
1025cdf0e10cSrcweir 
1026cdf0e10cSrcweir     tSequenceMapRange aRange( m_aSequenceMap.equal_range( lcl_aCategoriesRangeName ));
1027cdf0e10cSrcweir     ::std::for_each( aRange.first, aRange.second, lcl_setModified());
1028cdf0e10cSrcweir }
1029cdf0e10cSrcweir 
1030cdf0e10cSrcweir void SAL_CALL InternalDataProvider::registerDataSequenceForChanges( const Reference< chart2::data::XDataSequence >& xSeq )
1031cdf0e10cSrcweir     throw (uno::RuntimeException)
1032cdf0e10cSrcweir {
1033cdf0e10cSrcweir     if( xSeq.is())
1034cdf0e10cSrcweir         lcl_addDataSequenceToMap( xSeq->getSourceRangeRepresentation(), xSeq );
1035cdf0e10cSrcweir }
1036cdf0e10cSrcweir 
1037cdf0e10cSrcweir 
1038cdf0e10cSrcweir // ____ XRangeXMLConversion ____
1039cdf0e10cSrcweir OUString SAL_CALL InternalDataProvider::convertRangeToXML( const OUString& aRangeRepresentation )
1040cdf0e10cSrcweir     throw (lang::IllegalArgumentException,
1041cdf0e10cSrcweir            uno::RuntimeException)
1042cdf0e10cSrcweir {
1043cdf0e10cSrcweir     XMLRangeHelper::CellRange aRange;
1044cdf0e10cSrcweir     aRange.aTableName = OUString(RTL_CONSTASCII_USTRINGPARAM("local-table"));
1045cdf0e10cSrcweir 
1046cdf0e10cSrcweir     // attention: this data provider has the limitation that it stores
1047cdf0e10cSrcweir     // internally if data comes from columns or rows. It is intended for
1048cdf0e10cSrcweir     // creating only one used data source.
1049cdf0e10cSrcweir     // @todo: add this information in the range representation strings
1050cdf0e10cSrcweir     if( aRangeRepresentation.match( lcl_aCategoriesRangeName ))
1051cdf0e10cSrcweir     {
1052cdf0e10cSrcweir         OSL_ASSERT( aRangeRepresentation.equals( lcl_aCategoriesRangeName ) );//it is not expected nor implmented that only parts of the categories are really requested
1053cdf0e10cSrcweir         aRange.aUpperLeft.bIsEmpty = false;
1054cdf0e10cSrcweir         if( m_bDataInColumns )
1055cdf0e10cSrcweir         {
1056cdf0e10cSrcweir             aRange.aUpperLeft.nColumn = 0;
1057cdf0e10cSrcweir             aRange.aUpperLeft.nRow = 1;
1058cdf0e10cSrcweir             aRange.aLowerRight = aRange.aUpperLeft;
1059cdf0e10cSrcweir             aRange.aLowerRight.nRow = m_aInternalData.getRowCount();
1060cdf0e10cSrcweir         }
1061cdf0e10cSrcweir         else
1062cdf0e10cSrcweir         {
1063cdf0e10cSrcweir             aRange.aUpperLeft.nColumn = 1;
1064cdf0e10cSrcweir             aRange.aUpperLeft.nRow = 0;
1065cdf0e10cSrcweir             aRange.aLowerRight = aRange.aUpperLeft;
1066cdf0e10cSrcweir             aRange.aLowerRight.nColumn = m_aInternalData.getColumnCount();
1067cdf0e10cSrcweir         }
1068cdf0e10cSrcweir     }
1069cdf0e10cSrcweir     else if( aRangeRepresentation.match( lcl_aLabelRangePrefix ))
1070cdf0e10cSrcweir     {
1071cdf0e10cSrcweir         sal_Int32 nIndex = aRangeRepresentation.copy( lcl_aLabelRangePrefix.getLength()).toInt32();
1072cdf0e10cSrcweir         aRange.aUpperLeft.bIsEmpty = false;
1073cdf0e10cSrcweir         aRange.aLowerRight.bIsEmpty = true;
1074cdf0e10cSrcweir         if( m_bDataInColumns )
1075cdf0e10cSrcweir         {
1076cdf0e10cSrcweir             aRange.aUpperLeft.nColumn = nIndex + 1;
1077cdf0e10cSrcweir             aRange.aUpperLeft.nRow = 0;
1078cdf0e10cSrcweir         }
1079cdf0e10cSrcweir         else
1080cdf0e10cSrcweir         {
1081cdf0e10cSrcweir             aRange.aUpperLeft.nColumn = 0;
1082cdf0e10cSrcweir             aRange.aUpperLeft.nRow = nIndex + 1;
1083cdf0e10cSrcweir         }
1084cdf0e10cSrcweir     }
1085cdf0e10cSrcweir     else if( aRangeRepresentation.equals( lcl_aCompleteRange ))
1086cdf0e10cSrcweir     {
1087cdf0e10cSrcweir         aRange.aUpperLeft.bIsEmpty = false;
1088cdf0e10cSrcweir         aRange.aLowerRight.bIsEmpty = false;
1089cdf0e10cSrcweir         aRange.aUpperLeft.nColumn = 0;
1090cdf0e10cSrcweir         aRange.aUpperLeft.nRow = 0;
1091cdf0e10cSrcweir         aRange.aLowerRight.nColumn = m_aInternalData.getColumnCount();
1092cdf0e10cSrcweir         aRange.aLowerRight.nRow = m_aInternalData.getRowCount();
1093cdf0e10cSrcweir     }
1094cdf0e10cSrcweir     else
1095cdf0e10cSrcweir     {
1096cdf0e10cSrcweir         sal_Int32 nIndex = aRangeRepresentation.toInt32();
1097cdf0e10cSrcweir         aRange.aUpperLeft.bIsEmpty = false;
1098cdf0e10cSrcweir         if( m_bDataInColumns )
1099cdf0e10cSrcweir         {
1100cdf0e10cSrcweir             aRange.aUpperLeft.nColumn = nIndex + 1;
1101cdf0e10cSrcweir             aRange.aUpperLeft.nRow = 1;
1102cdf0e10cSrcweir             aRange.aLowerRight = aRange.aUpperLeft;
1103cdf0e10cSrcweir             aRange.aLowerRight.nRow = m_aInternalData.getRowCount();
1104cdf0e10cSrcweir         }
1105cdf0e10cSrcweir         else
1106cdf0e10cSrcweir         {
1107cdf0e10cSrcweir             aRange.aUpperLeft.nColumn = 1;
1108cdf0e10cSrcweir             aRange.aUpperLeft.nRow = nIndex + 1;
1109cdf0e10cSrcweir             aRange.aLowerRight = aRange.aUpperLeft;
1110cdf0e10cSrcweir             aRange.aLowerRight.nColumn = m_aInternalData.getColumnCount();
1111cdf0e10cSrcweir         }
1112cdf0e10cSrcweir     }
1113cdf0e10cSrcweir 
1114cdf0e10cSrcweir     return XMLRangeHelper::getXMLStringFromCellRange( aRange );
1115cdf0e10cSrcweir }
1116cdf0e10cSrcweir 
1117cdf0e10cSrcweir OUString SAL_CALL InternalDataProvider::convertRangeFromXML( const OUString& aXMLRange )
1118cdf0e10cSrcweir     throw (lang::IllegalArgumentException,
1119cdf0e10cSrcweir            uno::RuntimeException)
1120cdf0e10cSrcweir {
1121cdf0e10cSrcweir     XMLRangeHelper::CellRange aRange( XMLRangeHelper::getCellRangeFromXMLString( aXMLRange ));
1122cdf0e10cSrcweir     if( aRange.aUpperLeft.bIsEmpty )
1123cdf0e10cSrcweir     {
1124cdf0e10cSrcweir         OSL_ENSURE( aRange.aLowerRight.bIsEmpty, "Weird Range" );
1125cdf0e10cSrcweir         return OUString();
1126cdf0e10cSrcweir     }
1127cdf0e10cSrcweir 
1128cdf0e10cSrcweir     // "all"
1129cdf0e10cSrcweir     if( !aRange.aLowerRight.bIsEmpty &&
1130cdf0e10cSrcweir         ( aRange.aUpperLeft.nColumn != aRange.aLowerRight.nColumn ) &&
1131cdf0e10cSrcweir         ( aRange.aUpperLeft.nRow != aRange.aLowerRight.nRow ) )
1132cdf0e10cSrcweir         return lcl_aCompleteRange;
1133cdf0e10cSrcweir 
1134cdf0e10cSrcweir     // attention: this data provider has the limitation that it stores
1135cdf0e10cSrcweir     // internally if data comes from columns or rows. It is intended for
1136cdf0e10cSrcweir     // creating only one used data source.
1137cdf0e10cSrcweir     // @todo: add this information in the range representation strings
1138cdf0e10cSrcweir 
1139cdf0e10cSrcweir     // data in columns
1140cdf0e10cSrcweir     if( m_bDataInColumns )
1141cdf0e10cSrcweir     {
1142cdf0e10cSrcweir         if( aRange.aUpperLeft.nColumn == 0 )
1143cdf0e10cSrcweir             return lcl_aCategoriesRangeName;
1144cdf0e10cSrcweir         if( aRange.aUpperLeft.nRow == 0 )
1145cdf0e10cSrcweir             return lcl_aLabelRangePrefix + OUString::valueOf( aRange.aUpperLeft.nColumn - 1 );
1146cdf0e10cSrcweir 
1147cdf0e10cSrcweir         return OUString::valueOf( aRange.aUpperLeft.nColumn - 1 );
1148cdf0e10cSrcweir     }
1149cdf0e10cSrcweir 
1150cdf0e10cSrcweir     // data in rows
1151cdf0e10cSrcweir     if( aRange.aUpperLeft.nRow == 0 )
1152cdf0e10cSrcweir         return lcl_aCategoriesRangeName;
1153cdf0e10cSrcweir     if( aRange.aUpperLeft.nColumn == 0 )
1154cdf0e10cSrcweir         return lcl_aLabelRangePrefix + OUString::valueOf( aRange.aUpperLeft.nRow - 1 );
1155cdf0e10cSrcweir 
1156cdf0e10cSrcweir     return OUString::valueOf( aRange.aUpperLeft.nRow - 1 );
1157cdf0e10cSrcweir }
1158cdf0e10cSrcweir 
1159cdf0e10cSrcweir namespace
1160cdf0e10cSrcweir {
1161cdf0e10cSrcweir 
1162cdf0e10cSrcweir template< class Type >
1163cdf0e10cSrcweir Sequence< Sequence< Type > > lcl_convertVectorVectorToSequenceSequence( const vector< vector< Type > >& rIn )
1164cdf0e10cSrcweir {
1165cdf0e10cSrcweir     Sequence< Sequence< Type > > aRet;
1166cdf0e10cSrcweir     sal_Int32 nOuterCount = rIn.size();
1167cdf0e10cSrcweir     if( nOuterCount )
1168cdf0e10cSrcweir     {
1169cdf0e10cSrcweir         aRet.realloc(nOuterCount);
1170cdf0e10cSrcweir         for( sal_Int32 nN=0; nN<nOuterCount; nN++)
1171cdf0e10cSrcweir             aRet[nN]= ContainerHelper::ContainerToSequence( rIn[nN] );
1172cdf0e10cSrcweir     }
1173cdf0e10cSrcweir     return aRet;
1174cdf0e10cSrcweir }
1175cdf0e10cSrcweir 
1176cdf0e10cSrcweir template< class Type >
1177cdf0e10cSrcweir vector< vector< Type > > lcl_convertSequenceSequenceToVectorVector( const Sequence< Sequence< Type > >& rIn )
1178cdf0e10cSrcweir {
1179cdf0e10cSrcweir     vector< vector< Type > > aRet;
1180cdf0e10cSrcweir     sal_Int32 nOuterCount = rIn.getLength();
1181cdf0e10cSrcweir     if( nOuterCount )
1182cdf0e10cSrcweir     {
1183cdf0e10cSrcweir         aRet.resize(nOuterCount);
1184cdf0e10cSrcweir         for( sal_Int32 nN=0; nN<nOuterCount; nN++)
1185cdf0e10cSrcweir             aRet[nN]= ContainerHelper::SequenceToVector( rIn[nN] );
1186cdf0e10cSrcweir     }
1187cdf0e10cSrcweir     return aRet;
1188cdf0e10cSrcweir }
1189cdf0e10cSrcweir 
1190cdf0e10cSrcweir Sequence< Sequence< OUString > > lcl_convertComplexAnyVectorToStringSequence( const vector< vector< uno::Any > >& rIn )
1191cdf0e10cSrcweir {
1192cdf0e10cSrcweir     Sequence< Sequence< OUString > > aRet;
1193cdf0e10cSrcweir     sal_Int32 nOuterCount = rIn.size();
1194cdf0e10cSrcweir     if( nOuterCount )
1195cdf0e10cSrcweir     {
1196cdf0e10cSrcweir         aRet.realloc(nOuterCount);
1197cdf0e10cSrcweir         for( sal_Int32 nN=0; nN<nOuterCount; nN++)
1198cdf0e10cSrcweir             aRet[nN]= lcl_AnyToStringSequence( ContainerHelper::ContainerToSequence( rIn[nN] ) );
1199cdf0e10cSrcweir     }
1200cdf0e10cSrcweir     return aRet;
1201cdf0e10cSrcweir }
1202cdf0e10cSrcweir 
1203cdf0e10cSrcweir vector< vector< uno::Any > > lcl_convertComplexStringSequenceToAnyVector( const Sequence< Sequence< OUString > >& rIn )
1204cdf0e10cSrcweir {
1205cdf0e10cSrcweir     vector< vector< uno::Any > > aRet;
1206cdf0e10cSrcweir     sal_Int32 nOuterCount = rIn.getLength();
1207cdf0e10cSrcweir     for( sal_Int32 nN=0; nN<nOuterCount; nN++)
1208cdf0e10cSrcweir         aRet.push_back( ContainerHelper::SequenceToVector( lcl_StringToAnySequence( rIn[nN] ) ) );
1209cdf0e10cSrcweir     return aRet;
1210cdf0e10cSrcweir }
1211cdf0e10cSrcweir 
1212cdf0e10cSrcweir class SplitCategoriesProvider_ForComplexDescriptions : public SplitCategoriesProvider
1213cdf0e10cSrcweir {
1214cdf0e10cSrcweir public:
1215cdf0e10cSrcweir 
1216cdf0e10cSrcweir     explicit SplitCategoriesProvider_ForComplexDescriptions( const ::std::vector< ::std::vector< uno::Any > >& rComplexDescriptions )
1217cdf0e10cSrcweir         : m_rComplexDescriptions( rComplexDescriptions )
1218cdf0e10cSrcweir     {}
1219cdf0e10cSrcweir     virtual ~SplitCategoriesProvider_ForComplexDescriptions()
1220cdf0e10cSrcweir     {}
1221cdf0e10cSrcweir 
1222cdf0e10cSrcweir     virtual sal_Int32 getLevelCount() const;
1223cdf0e10cSrcweir     virtual uno::Sequence< rtl::OUString > getStringsForLevel( sal_Int32 nIndex ) const;
1224cdf0e10cSrcweir 
1225cdf0e10cSrcweir private:
1226cdf0e10cSrcweir     const ::std::vector< ::std::vector< uno::Any > >& m_rComplexDescriptions;
1227cdf0e10cSrcweir };
1228cdf0e10cSrcweir 
1229cdf0e10cSrcweir sal_Int32 SplitCategoriesProvider_ForComplexDescriptions::getLevelCount() const
1230cdf0e10cSrcweir {
1231cdf0e10cSrcweir     return lcl_getInnerLevelCount( m_rComplexDescriptions );
1232cdf0e10cSrcweir }
1233cdf0e10cSrcweir uno::Sequence< rtl::OUString > SplitCategoriesProvider_ForComplexDescriptions::getStringsForLevel( sal_Int32 nLevel ) const
1234cdf0e10cSrcweir {
1235cdf0e10cSrcweir     uno::Sequence< rtl::OUString > aResult;
1236cdf0e10cSrcweir     if( nLevel < lcl_getInnerLevelCount( m_rComplexDescriptions ) )
1237cdf0e10cSrcweir     {
1238cdf0e10cSrcweir         aResult.realloc( m_rComplexDescriptions.size() );
1239cdf0e10cSrcweir         transform( m_rComplexDescriptions.begin(), m_rComplexDescriptions.end(),
1240cdf0e10cSrcweir                    aResult.getArray(), lcl_getStringFromLevelVector(nLevel) );
1241cdf0e10cSrcweir     }
1242cdf0e10cSrcweir     return aResult;
1243cdf0e10cSrcweir }
1244cdf0e10cSrcweir 
1245cdf0e10cSrcweir }//anonymous namespace
1246cdf0e10cSrcweir 
1247cdf0e10cSrcweir // ____ XDateCategories ____
1248cdf0e10cSrcweir Sequence< double > SAL_CALL InternalDataProvider::getDateCategories() throw (uno::RuntimeException)
1249cdf0e10cSrcweir {
1250cdf0e10cSrcweir     double fNan = InternalDataProvider::getNotANumber();
1251cdf0e10cSrcweir     double fValue = fNan;
1252cdf0e10cSrcweir     vector< vector< uno::Any > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels());
1253cdf0e10cSrcweir     sal_Int32 nCount = aCategories.size();
1254cdf0e10cSrcweir     Sequence< double > aDoubles( nCount );
1255cdf0e10cSrcweir     vector< vector< uno::Any > >::iterator aIt( aCategories.begin() );
1256cdf0e10cSrcweir     vector< vector< uno::Any > >::const_iterator aEnd( aCategories.end() );
1257cdf0e10cSrcweir     for(sal_Int32 nN=0; nN<nCount && aIt!=aEnd; ++nN, ++aIt )
1258cdf0e10cSrcweir     {
1259cdf0e10cSrcweir         if( !( !aIt->empty() && ((*aIt)[0]>>=fValue) ) )
1260cdf0e10cSrcweir             fValue = fNan;
1261cdf0e10cSrcweir         aDoubles[nN]=fValue;
1262cdf0e10cSrcweir     }
1263cdf0e10cSrcweir     return aDoubles;
1264cdf0e10cSrcweir }
1265cdf0e10cSrcweir 
1266cdf0e10cSrcweir void SAL_CALL InternalDataProvider::setDateCategories( const Sequence< double >& rDates ) throw (uno::RuntimeException)
1267cdf0e10cSrcweir {
1268cdf0e10cSrcweir     sal_Int32 nCount = rDates.getLength();
1269cdf0e10cSrcweir     vector< vector< uno::Any > > aNewCategories;
1270cdf0e10cSrcweir     aNewCategories.reserve(nCount);
1271cdf0e10cSrcweir     vector< uno::Any > aSingleLabel(1);
1272cdf0e10cSrcweir 
1273cdf0e10cSrcweir     for(sal_Int32 nN=0; nN<nCount; ++nN )
1274cdf0e10cSrcweir     {
1275cdf0e10cSrcweir         aSingleLabel[0]=uno::makeAny(rDates[nN]);
1276cdf0e10cSrcweir         aNewCategories.push_back(aSingleLabel);
1277cdf0e10cSrcweir     }
1278cdf0e10cSrcweir 
1279cdf0e10cSrcweir     if( m_bDataInColumns )
1280cdf0e10cSrcweir         m_aInternalData.setComplexRowLabels( aNewCategories );
1281cdf0e10cSrcweir     else
1282cdf0e10cSrcweir         m_aInternalData.setComplexColumnLabels( aNewCategories );
1283cdf0e10cSrcweir }
1284cdf0e10cSrcweir 
1285cdf0e10cSrcweir // ____ XAnyDescriptionAccess ____
1286cdf0e10cSrcweir Sequence< Sequence< uno::Any > > SAL_CALL InternalDataProvider::getAnyRowDescriptions() throw (uno::RuntimeException)
1287cdf0e10cSrcweir {
1288cdf0e10cSrcweir     return lcl_convertVectorVectorToSequenceSequence( m_aInternalData.getComplexRowLabels() );
1289cdf0e10cSrcweir }
1290cdf0e10cSrcweir void SAL_CALL InternalDataProvider::setAnyRowDescriptions( const Sequence< Sequence< uno::Any > >& aRowDescriptions ) throw (uno::RuntimeException)
1291cdf0e10cSrcweir {
1292cdf0e10cSrcweir     m_aInternalData.setComplexRowLabels( lcl_convertSequenceSequenceToVectorVector( aRowDescriptions ) );
1293cdf0e10cSrcweir }
1294cdf0e10cSrcweir Sequence< Sequence< uno::Any > > SAL_CALL InternalDataProvider::getAnyColumnDescriptions() throw (uno::RuntimeException)
1295cdf0e10cSrcweir {
1296cdf0e10cSrcweir     return lcl_convertVectorVectorToSequenceSequence( m_aInternalData.getComplexColumnLabels() );
1297cdf0e10cSrcweir }
1298cdf0e10cSrcweir void SAL_CALL InternalDataProvider::setAnyColumnDescriptions( const Sequence< Sequence< uno::Any > >& aColumnDescriptions ) throw (uno::RuntimeException)
1299cdf0e10cSrcweir {
1300cdf0e10cSrcweir     m_aInternalData.setComplexColumnLabels( lcl_convertSequenceSequenceToVectorVector( aColumnDescriptions ) );
1301cdf0e10cSrcweir }
1302cdf0e10cSrcweir 
1303cdf0e10cSrcweir // ____ XComplexDescriptionAccess ____
1304cdf0e10cSrcweir Sequence< Sequence< OUString > > SAL_CALL InternalDataProvider::getComplexRowDescriptions() throw (uno::RuntimeException)
1305cdf0e10cSrcweir {
1306cdf0e10cSrcweir     return lcl_convertComplexAnyVectorToStringSequence( m_aInternalData.getComplexRowLabels() );
1307cdf0e10cSrcweir }
1308cdf0e10cSrcweir void SAL_CALL InternalDataProvider::setComplexRowDescriptions( const Sequence< Sequence< ::rtl::OUString > >& aRowDescriptions ) throw (uno::RuntimeException)
1309cdf0e10cSrcweir {
1310cdf0e10cSrcweir     m_aInternalData.setComplexRowLabels( lcl_convertComplexStringSequenceToAnyVector(aRowDescriptions) );
1311cdf0e10cSrcweir }
1312cdf0e10cSrcweir Sequence< Sequence< ::rtl::OUString > > SAL_CALL InternalDataProvider::getComplexColumnDescriptions() throw (uno::RuntimeException)
1313cdf0e10cSrcweir {
1314cdf0e10cSrcweir     return lcl_convertComplexAnyVectorToStringSequence( m_aInternalData.getComplexColumnLabels() );
1315cdf0e10cSrcweir }
1316cdf0e10cSrcweir void SAL_CALL InternalDataProvider::setComplexColumnDescriptions( const Sequence< Sequence< ::rtl::OUString > >& aColumnDescriptions ) throw (uno::RuntimeException)
1317cdf0e10cSrcweir {
1318cdf0e10cSrcweir     m_aInternalData.setComplexColumnLabels( lcl_convertComplexStringSequenceToAnyVector(aColumnDescriptions) );
1319cdf0e10cSrcweir }
1320cdf0e10cSrcweir 
1321cdf0e10cSrcweir // ____ XChartDataArray ____
1322cdf0e10cSrcweir Sequence< Sequence< double > > SAL_CALL InternalDataProvider::getData()
1323cdf0e10cSrcweir     throw (uno::RuntimeException)
1324cdf0e10cSrcweir {
1325cdf0e10cSrcweir     return m_aInternalData.getData();
1326cdf0e10cSrcweir }
1327cdf0e10cSrcweir 
1328cdf0e10cSrcweir void SAL_CALL InternalDataProvider::setData( const Sequence< Sequence< double > >& rDataInRows )
1329cdf0e10cSrcweir     throw (uno::RuntimeException)
1330cdf0e10cSrcweir {
1331cdf0e10cSrcweir     return m_aInternalData.setData( rDataInRows );
1332cdf0e10cSrcweir }
1333cdf0e10cSrcweir 
1334cdf0e10cSrcweir void SAL_CALL InternalDataProvider::setRowDescriptions( const Sequence< OUString >& aRowDescriptions )
1335cdf0e10cSrcweir     throw (uno::RuntimeException)
1336cdf0e10cSrcweir {
1337cdf0e10cSrcweir     vector< vector< uno::Any > > aComplexDescriptions( aRowDescriptions.getLength() );
1338cdf0e10cSrcweir     transform( aComplexDescriptions.begin(), aComplexDescriptions.end(), aRowDescriptions.getConstArray(),
1339cdf0e10cSrcweir                aComplexDescriptions.begin(), lcl_setAnyAtLevelFromStringSequence(0) );
1340cdf0e10cSrcweir     m_aInternalData.setComplexRowLabels( aComplexDescriptions );
1341cdf0e10cSrcweir }
1342cdf0e10cSrcweir 
1343cdf0e10cSrcweir void SAL_CALL InternalDataProvider::setColumnDescriptions( const Sequence< OUString >& aColumnDescriptions )
1344cdf0e10cSrcweir     throw (uno::RuntimeException)
1345cdf0e10cSrcweir {
1346cdf0e10cSrcweir     vector< vector< uno::Any > > aComplexDescriptions( aColumnDescriptions.getLength() );
1347cdf0e10cSrcweir     transform( aComplexDescriptions.begin(), aComplexDescriptions.end(), aColumnDescriptions.getConstArray(),
1348cdf0e10cSrcweir                aComplexDescriptions.begin(), lcl_setAnyAtLevelFromStringSequence(0) );
1349cdf0e10cSrcweir     m_aInternalData.setComplexColumnLabels( aComplexDescriptions );
1350cdf0e10cSrcweir }
1351cdf0e10cSrcweir 
1352cdf0e10cSrcweir Sequence< OUString > SAL_CALL InternalDataProvider::getRowDescriptions()
1353cdf0e10cSrcweir     throw (uno::RuntimeException)
1354cdf0e10cSrcweir {
1355cdf0e10cSrcweir     vector< vector< uno::Any > > aComplexLabels( m_aInternalData.getComplexRowLabels() );
1356cdf0e10cSrcweir     SplitCategoriesProvider_ForComplexDescriptions aProvider( aComplexLabels );
1357cdf0e10cSrcweir     return ExplicitCategoriesProvider::getExplicitSimpleCategories( aProvider );
1358cdf0e10cSrcweir }
1359cdf0e10cSrcweir 
1360cdf0e10cSrcweir Sequence< OUString > SAL_CALL InternalDataProvider::getColumnDescriptions()
1361cdf0e10cSrcweir     throw (uno::RuntimeException)
1362cdf0e10cSrcweir {
1363cdf0e10cSrcweir     vector< vector< uno::Any > > aComplexLabels( m_aInternalData.getComplexColumnLabels() );
1364cdf0e10cSrcweir     SplitCategoriesProvider_ForComplexDescriptions aProvider( aComplexLabels );
1365cdf0e10cSrcweir     return ExplicitCategoriesProvider::getExplicitSimpleCategories( aProvider );
1366cdf0e10cSrcweir }
1367cdf0e10cSrcweir 
1368cdf0e10cSrcweir // ____ XChartData (base of XChartDataArray) ____
1369cdf0e10cSrcweir void SAL_CALL InternalDataProvider::addChartDataChangeEventListener(
1370cdf0e10cSrcweir     const Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& )
1371cdf0e10cSrcweir     throw (uno::RuntimeException)
1372cdf0e10cSrcweir {
1373cdf0e10cSrcweir }
1374cdf0e10cSrcweir 
1375cdf0e10cSrcweir void SAL_CALL InternalDataProvider::removeChartDataChangeEventListener(
1376cdf0e10cSrcweir     const Reference< ::com::sun::star::chart::XChartDataChangeEventListener >& )
1377cdf0e10cSrcweir     throw (uno::RuntimeException)
1378cdf0e10cSrcweir {
1379cdf0e10cSrcweir }
1380cdf0e10cSrcweir 
1381cdf0e10cSrcweir double SAL_CALL InternalDataProvider::getNotANumber()
1382cdf0e10cSrcweir     throw (uno::RuntimeException)
1383cdf0e10cSrcweir {
1384cdf0e10cSrcweir     double fNan;
1385cdf0e10cSrcweir     ::rtl::math::setNan( & fNan );
1386cdf0e10cSrcweir     return fNan;
1387cdf0e10cSrcweir }
1388cdf0e10cSrcweir 
1389cdf0e10cSrcweir ::sal_Bool SAL_CALL InternalDataProvider::isNotANumber( double nNumber )
1390cdf0e10cSrcweir     throw (uno::RuntimeException)
1391cdf0e10cSrcweir {
1392cdf0e10cSrcweir     return ::rtl::math::isNan( nNumber )
1393cdf0e10cSrcweir         || ::rtl::math::isInf( nNumber );
1394cdf0e10cSrcweir }
1395cdf0e10cSrcweir // lang::XInitialization:
1396cdf0e10cSrcweir void SAL_CALL InternalDataProvider::initialize(const uno::Sequence< uno::Any > & _aArguments) throw (uno::RuntimeException, uno::Exception)
1397cdf0e10cSrcweir {
1398cdf0e10cSrcweir 	comphelper::SequenceAsHashMap aArgs(_aArguments);
1399cdf0e10cSrcweir     if ( aArgs.getUnpackedValueOrDefault(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CreateDefaultData")),sal_False) )
1400cdf0e10cSrcweir 		createDefaultData();
1401cdf0e10cSrcweir }
1402cdf0e10cSrcweir // ____ XCloneable ____
1403cdf0e10cSrcweir Reference< util::XCloneable > SAL_CALL InternalDataProvider::createClone()
1404cdf0e10cSrcweir     throw (uno::RuntimeException)
1405cdf0e10cSrcweir {
1406cdf0e10cSrcweir     return Reference< util::XCloneable >( new InternalDataProvider( *this ));
1407cdf0e10cSrcweir }
1408cdf0e10cSrcweir 
1409cdf0e10cSrcweir 
1410cdf0e10cSrcweir // ================================================================================
1411cdf0e10cSrcweir 
1412cdf0e10cSrcweir Sequence< OUString > InternalDataProvider::getSupportedServiceNames_Static()
1413cdf0e10cSrcweir {
1414cdf0e10cSrcweir     Sequence< OUString > aServices( 1 );
1415cdf0e10cSrcweir     aServices[ 0 ] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart2.data.DataProvider" ));
1416cdf0e10cSrcweir     return aServices;
1417cdf0e10cSrcweir }
1418cdf0e10cSrcweir 
1419cdf0e10cSrcweir // ================================================================================
1420cdf0e10cSrcweir 
1421cdf0e10cSrcweir APPHELPER_XSERVICEINFO_IMPL( InternalDataProvider, lcl_aServiceName );
1422cdf0e10cSrcweir 
1423cdf0e10cSrcweir } //  namespace chart
1424