diff options
author | Jan Holesovsky <kendy@suse.cz> | 2011-03-18 15:33:40 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@suse.cz> | 2011-03-18 15:33:40 +0100 |
commit | e6064484fae8aa2797f86c68e9a8d23d2e213367 (patch) | |
tree | db2f4d140efca43ab01dee4fc053fff0829d106b /chart2/source/tools/InternalDataProvider.cxx | |
parent | 9e0a09e89c38774dd1af902387a8b25de158b634 (diff) | |
parent | 378c75a798c8baa34cb26e7f07fe28cb5ee2a85f (diff) |
Merge remote-tracking branch 'origin/integration/dev300_m101'
Conflicts:
chart2/source/controller/main/UndoManager.cxx
chart2/source/tools/RegressionCurveHelper.cxx
sc/inc/address.hxx
sc/inc/attrib.hxx
sc/inc/bigrange.hxx
sc/inc/callform.hxx
sc/inc/cell.hxx
sc/inc/chartarr.hxx
sc/inc/chartlis.hxx
sc/inc/chgtrack.hxx
sc/inc/collect.hxx
sc/inc/compiler.hxx
sc/inc/detdata.hxx
sc/inc/document.hxx
sc/inc/fillinfo.hxx
sc/inc/olinetab.hxx
sc/inc/prnsave.hxx
sc/inc/queryparam.hxx
sc/inc/sc.hrc
sc/inc/scabstdlg.hxx
sc/inc/table.hxx
sc/inc/validat.hxx
sc/inc/zforauto.hxx
sc/source/core/data/documen2.cxx
sc/source/core/data/document.cxx
sc/source/core/data/table1.cxx
sc/source/core/tool/address.cxx
sc/source/core/tool/token.cxx
sc/source/filter/excel/frmbase.cxx
sc/source/filter/excel/impop.cxx
sc/source/filter/excel/xename.cxx
sc/source/filter/inc/formel.hxx
sc/source/filter/inc/xename.hxx
sc/source/filter/xml/xmlexprt.cxx
sc/source/filter/xml/xmlnexpi.cxx
sc/source/filter/xml/xmlnexpi.hxx
sc/source/ui/dbgui/filtdlg.cxx
sc/source/ui/inc/docfunc.hxx
sc/source/ui/inc/namedlg.hxx
sc/source/ui/namedlg/namedlg.cxx
sc/source/ui/src/namedlg.src
Diffstat (limited to 'chart2/source/tools/InternalDataProvider.cxx')
-rwxr-xr-x[-rw-r--r--] | chart2/source/tools/InternalDataProvider.cxx | 355 |
1 files changed, 234 insertions, 121 deletions
diff --git a/chart2/source/tools/InternalDataProvider.cxx b/chart2/source/tools/InternalDataProvider.cxx index ab1a5bfe4ff6..4d57e9ae258d 100644..100755 --- a/chart2/source/tools/InternalDataProvider.cxx +++ b/chart2/source/tools/InternalDataProvider.cxx @@ -94,6 +94,24 @@ static const ::rtl::OUString lcl_aCompleteRange( typedef ::std::multimap< OUString, uno::WeakReference< chart2::data::XDataSequence > > lcl_tSequenceMap; +Sequence< OUString > lcl_AnyToStringSequence( const Sequence< uno::Any >& aAnySeq ) +{ + Sequence< OUString > aResult; + aResult.realloc( aAnySeq.getLength() ); + transform( aAnySeq.getConstArray(), aAnySeq.getConstArray() + aAnySeq.getLength(), + aResult.getArray(), CommonFunctors::AnyToString() ); + return aResult; +} + +Sequence< uno::Any > lcl_StringToAnySequence( const Sequence< OUString >& aStringSeq ) +{ + Sequence< uno::Any > aResult; + aResult.realloc( aStringSeq.getLength() ); + transform( aStringSeq.getConstArray(), aStringSeq.getConstArray() + aStringSeq.getLength(), + aResult.getArray(), CommonFunctors::makeAny< OUString >() ); + return aResult; +} + struct lcl_setModified : public ::std::unary_function< lcl_tSequenceMap, void > { void operator() ( const lcl_tSequenceMap::value_type & rMapEntry ) @@ -155,9 +173,9 @@ struct lcl_internalizeSeries : public ::std::unary_function< Reference< chart2:: if( xLabel.is() ) { if( m_bDataInColumns ) - m_rInternalData.setComplexColumnLabel( nNewIndex, ContainerHelper::SequenceToVector( xLabel->getTextualData() ) ); + m_rInternalData.setComplexColumnLabel( nNewIndex, ContainerHelper::SequenceToVector( lcl_StringToAnySequence( xLabel->getTextualData() ) ) ); else - m_rInternalData.setComplexRowLabel( nNewIndex, ContainerHelper::SequenceToVector( xLabel->getTextualData() ) ); + m_rInternalData.setComplexRowLabel( nNewIndex, ContainerHelper::SequenceToVector( lcl_StringToAnySequence( xLabel->getTextualData() ) ) ); if( m_bConnectToModel ) { Reference< chart2::data::XDataSequence > xNewLabel( @@ -188,37 +206,37 @@ private: bool m_bDataInColumns; }; -struct lcl_makeAnyFromLevelVector : public ::std::unary_function< vector< OUString >, uno::Any > +struct lcl_copyFromLevel : public ::std::unary_function< vector< uno::Any >, uno::Any > { public: - explicit lcl_makeAnyFromLevelVector( sal_Int32 nLevel ) : m_nLevel( nLevel ) + explicit lcl_copyFromLevel( sal_Int32 nLevel ) : m_nLevel( nLevel ) {} - uno::Any operator() ( const vector< OUString >& rVector ) + uno::Any operator() ( const vector< uno::Any >& rVector ) { - OUString aString; + uno::Any aRet; if( m_nLevel < static_cast< sal_Int32 >(rVector.size()) ) - aString = rVector[m_nLevel]; - return uno::makeAny( aString ); + aRet = rVector[m_nLevel]; + return aRet; } private: sal_Int32 m_nLevel; }; -struct lcl_getStringFromLevelVector : public ::std::unary_function< vector< OUString >, OUString > +struct lcl_getStringFromLevelVector : public ::std::unary_function< vector< uno::Any >, OUString > { public: explicit lcl_getStringFromLevelVector( sal_Int32 nLevel ) : m_nLevel( nLevel ) {} - OUString operator() ( const vector< OUString >& rVector ) + OUString operator() ( const vector< uno::Any >& rVector ) { OUString aString; if( m_nLevel < static_cast< sal_Int32 >(rVector.size()) ) - aString = rVector[m_nLevel]; + aString = CommonFunctors::AnyToString()(rVector[m_nLevel]); return aString; } @@ -227,19 +245,39 @@ private: }; -struct lcl_setStringAtLevel : public ::std::binary_function< vector< OUString >, OUString, vector< OUString > > +struct lcl_setAnyAtLevel : public ::std::binary_function< vector< uno::Any >, uno::Any, vector< uno::Any > > +{ +public: + + explicit lcl_setAnyAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel ) + {} + + vector< uno::Any > operator() ( const vector< uno::Any >& rVector, const uno::Any& rNewValue ) + { + vector< uno::Any > aRet( rVector ); + if( m_nLevel >= static_cast< sal_Int32 >(aRet.size()) ) + aRet.resize( m_nLevel+1 ); + aRet[ m_nLevel ]=rNewValue; + return aRet; + } + +private: + sal_Int32 m_nLevel; +}; + +struct lcl_setAnyAtLevelFromStringSequence : public ::std::binary_function< vector< uno::Any >, OUString, vector< uno::Any > > { public: - explicit lcl_setStringAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel ) + explicit lcl_setAnyAtLevelFromStringSequence( sal_Int32 nLevel ) : m_nLevel( nLevel ) {} - vector< OUString > operator() ( const vector< OUString >& rVector, const OUString& rNewText ) + vector< uno::Any > operator() ( const vector< uno::Any >& rVector, const OUString& rNewValue ) { - vector< OUString > aRet( rVector ); + vector< uno::Any > aRet( rVector ); if( m_nLevel >= static_cast< sal_Int32 >(aRet.size()) ) aRet.resize( m_nLevel+1 ); - aRet[ m_nLevel ]=rNewText; + aRet[ m_nLevel ]=uno::makeAny(rNewValue); return aRet; } @@ -247,42 +285,42 @@ private: sal_Int32 m_nLevel; }; -struct lcl_insertStringAtLevel : public ::std::unary_function< vector< OUString >, void > +struct lcl_insertAnyAtLevel : public ::std::unary_function< vector< uno::Any >, void > { public: - explicit lcl_insertStringAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel ) + explicit lcl_insertAnyAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel ) {} - void operator() ( vector< OUString >& rVector ) + void operator() ( vector< uno::Any >& rVector ) { if( m_nLevel > static_cast< sal_Int32 >(rVector.size()) ) rVector.resize( m_nLevel ); - vector< OUString >::iterator aIt( rVector.begin() ); - for( sal_Int32 nN=0; aIt<rVector.end(); ++aIt, ++nN) + vector< uno::Any >::iterator aIt( rVector.begin() ); + for( sal_Int32 nN=0; aIt<rVector.end(); aIt++, nN++) { if( nN==m_nLevel ) break; } - rVector.insert( aIt, OUString() ); + rVector.insert( aIt, uno::Any() ); } private: sal_Int32 m_nLevel; }; -struct lcl_removeStringAtLevel : public ::std::unary_function< vector< OUString >, void > +struct lcl_removeAnyAtLevel : public ::std::unary_function< vector< uno::Any >, void > { public: - explicit lcl_removeStringAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel ) + explicit lcl_removeAnyAtLevel( sal_Int32 nLevel ) : m_nLevel( nLevel ) {} - void operator() ( vector< OUString >& rVector ) + void operator() ( vector< uno::Any >& rVector ) { - vector< OUString >::iterator aIt( rVector.begin() ); - for( sal_Int32 nN=0; aIt<rVector.end(); ++aIt, ++nN) + vector< uno::Any >::iterator aIt( rVector.begin() ); + for( sal_Int32 nN=0; aIt<rVector.end(); aIt++, nN++) { if( nN==m_nLevel ) { @@ -296,23 +334,6 @@ private: sal_Int32 m_nLevel; }; -vector< OUString > lcl_AnyToStringVector( const Sequence< uno::Any >& aAnySeq ) -{ - vector< OUString > aStringVec; - transform( aAnySeq.getConstArray(), aAnySeq.getConstArray() + aAnySeq.getLength(), - back_inserter( aStringVec ), CommonFunctors::AnyToString() ); - return aStringVec; -} - -Sequence< OUString > lcl_AnyToStringSequence( const Sequence< uno::Any >& aAnySeq ) -{ - Sequence< OUString > aResult; - aResult.realloc( aAnySeq.getLength() ); - transform( aAnySeq.getConstArray(), aAnySeq.getConstArray() + aAnySeq.getLength(), - aResult.getArray(), CommonFunctors::AnyToString() ); - return aResult; -} - } // anonymous namespace // ================================================================================ @@ -342,9 +363,10 @@ InternalDataProvider::InternalDataProvider( const Reference< chart2::XChartDocum // categories { - vector< vector< OUString > > aNewCategories;//inner count is level + vector< vector< uno::Any > > aNewCategories;//inner count is level { ExplicitCategoriesProvider aExplicitCategoriesProvider( ChartModelHelper::getFirstCoordinateSystem(xChartModel), xChartModel ); + const Sequence< Reference< chart2::data::XLabeledDataSequence> >& rSplitCategoriesList( aExplicitCategoriesProvider.getSplitCategoriesList() ); sal_Int32 nLevelCount = rSplitCategoriesList.getLength(); for( sal_Int32 nL = 0; nL<nLevelCount; nL++ ) @@ -352,16 +374,18 @@ InternalDataProvider::InternalDataProvider( const Reference< chart2::XChartDocum Reference< chart2::data::XLabeledDataSequence > xLDS( rSplitCategoriesList[nL] ); if( !xLDS.is() ) continue; - Reference< chart2::data::XTextualDataSequence > xSeq( xLDS->getValues(), uno::UNO_QUERY ); - Sequence< OUString > aStringSeq; + Sequence< uno::Any > aDataSeq; + Reference< chart2::data::XDataSequence > xSeq( xLDS->getValues() ); if( xSeq.is() ) - aStringSeq = xSeq->getTextualData(); // @todo: be able to deal with XDataSequence, too - sal_Int32 nLength = aStringSeq.getLength(); - if( static_cast< sal_Int32 >(aNewCategories.size()) < nLength ) + aDataSeq = xSeq->getData(); + sal_Int32 nLength = aDataSeq.getLength(); + sal_Int32 nCatLength = static_cast< sal_Int32 >(aNewCategories.size()); + if( nCatLength < nLength ) aNewCategories.resize( nLength ); - - transform( aNewCategories.begin(), aNewCategories.end(), aStringSeq.getConstArray(), - aNewCategories.begin(), lcl_setStringAtLevel(nL) ); + else if( nLength < nCatLength ) + aDataSeq.realloc( nCatLength ); + transform( aNewCategories.begin(), aNewCategories.end(), aDataSeq.getConstArray(), + aNewCategories.begin(), lcl_setAnyAtLevel(nL) ); } if( !nLevelCount ) { @@ -370,9 +394,9 @@ InternalDataProvider::InternalDataProvider( const Reference< chart2::XChartDocum aNewCategories.reserve( nLength ); for( sal_Int32 nN=0; nN<nLength; nN++) { - vector< OUString > aStringVector(1); - aStringVector[0] = aSimplecategories[nN]; - aNewCategories.push_back( aStringVector ); + vector< uno::Any > aVector(1); + aVector[0] = uno::makeAny( aSimplecategories[nN] ); + aNewCategories.push_back( aVector ); } } } @@ -492,7 +516,7 @@ Reference< chart2::data::XDataSequence > InternalDataProvider::lcl_createDataSeq if( aRangeRepresentation.indexOf('{') >= 0 ) { ::std::vector< double > aNewData; - ::std::vector< OUString > aNewLabels; + ::std::vector< uno::Any > aNewLabels; OUString aToken; sal_Int32 nCategories = 0; sal_Int32 nIndex = 0; @@ -518,12 +542,12 @@ Reference< chart2::data::XDataSequence > InternalDataProvider::lcl_createDataSeq } else { - aNewLabels.push_back( aToken.replace('"', ' ').trim() ); + aNewLabels.push_back( uno::makeAny(aToken.replace('"', ' ').trim()) ); if( !nCategories && ( !m_aInternalData.getComplexColumnLabel(n).size() || - !m_aInternalData.getComplexColumnLabel(n).front().getLength() ) ) + !m_aInternalData.getComplexColumnLabel(n).front().hasValue() ) ) { - m_aInternalData.setComplexColumnLabel( n, aNewLabels ); + m_aInternalData.setComplexColumnLabel( n, aNewLabels ); bLabelSet = true; } else @@ -531,7 +555,7 @@ Reference< chart2::data::XDataSequence > InternalDataProvider::lcl_createDataSeq m_aInternalData.setComplexRowLabel(nCategories, aNewLabels); if(nCategories==1 && bLabelSet) { - ::std::vector< OUString > aLabels; + ::std::vector< uno::Any > aLabels; m_aInternalData.setComplexRowLabel( 0, m_aInternalData.getComplexColumnLabel( n ) ); m_aInternalData.setComplexColumnLabel( n, aLabels ); } @@ -589,14 +613,14 @@ void InternalDataProvider::createDefaultData() namespace { -sal_Int32 lcl_getInnerLevelCount( const vector< vector< OUString > >& rLabels ) +sal_Int32 lcl_getInnerLevelCount( const vector< vector< uno::Any > >& rLabels ) { sal_Int32 nCount = 1;//minimum is 1! - vector< vector< OUString > >::const_iterator aLevelIt( rLabels.begin() ); - vector< vector< OUString > >::const_iterator aLevelEnd( rLabels.end() ); + vector< vector< uno::Any > >::const_iterator aLevelIt( rLabels.begin() ); + vector< vector< uno::Any > >::const_iterator aLevelEnd( rLabels.end() ); for( ;aLevelIt!=aLevelEnd; ++aLevelIt ) { - const vector< ::rtl::OUString >& rCurrentLevelLabels = *aLevelIt; + const vector< uno::Any >& rCurrentLevelLabels = *aLevelIt; nCount = std::max<sal_Int32>( rCurrentLevelLabels.size(), nCount ); } return nCount; @@ -620,7 +644,7 @@ Reference< chart2::data::XDataSource > SAL_CALL InternalDataProvider::createData { //return split complex categories if we have any: ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aComplexCategories; - vector< vector< OUString > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels()); + vector< vector< uno::Any > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels()); if( bUseColumns==m_bDataInColumns ) { sal_Int32 nLevelCount = lcl_getInnerLevelCount( aCategories ); @@ -801,46 +825,48 @@ Sequence< uno::Any > SAL_CALL InternalDataProvider::getDataByRangeRepresentation if( aRange.match( lcl_aLabelRangePrefix ) ) { sal_Int32 nIndex = aRange.copy( lcl_aLabelRangePrefix.getLength()).toInt32(); - vector< OUString > aComplexLabel = m_bDataInColumns + vector< uno::Any > aComplexLabel = m_bDataInColumns ? m_aInternalData.getComplexColumnLabel( nIndex ) : m_aInternalData.getComplexRowLabel( nIndex ); if( !aComplexLabel.empty() ) - { - aResult.realloc( aComplexLabel.size() ); - transform( aComplexLabel.begin(), aComplexLabel.end(), - aResult.getArray(), CommonFunctors::makeAny< OUString >()); - } + aResult = ContainerHelper::ContainerToSequence(aComplexLabel); } else if( aRange.match( lcl_aCategoriesPointRangeNamePrefix ) ) { sal_Int32 nPointIndex = aRange.copy( lcl_aCategoriesPointRangeNamePrefix.getLength() ).toInt32(); - vector< OUString > aComplexCategory = m_bDataInColumns + vector< uno::Any > aComplexCategory = m_bDataInColumns ? m_aInternalData.getComplexRowLabel( nPointIndex ) : m_aInternalData.getComplexColumnLabel( nPointIndex ); if( !aComplexCategory.empty() ) - { - aResult.realloc( aComplexCategory.size() ); - transform( aComplexCategory.begin(), aComplexCategory.end(), - aResult.getArray(), CommonFunctors::makeAny< OUString >()); - } + aResult = ContainerHelper::ContainerToSequence(aComplexCategory); } else if( aRange.match( lcl_aCategoriesLevelRangeNamePrefix ) ) { sal_Int32 nLevel = aRange.copy( lcl_aCategoriesLevelRangeNamePrefix.getLength() ).toInt32(); - vector< vector< OUString > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels()); + vector< vector< uno::Any > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels()); if( nLevel < lcl_getInnerLevelCount( aCategories ) ) { aResult.realloc( aCategories.size() ); transform( aCategories.begin(), aCategories.end(), - aResult.getArray(), lcl_makeAnyFromLevelVector(nLevel) ); + aResult.getArray(), lcl_copyFromLevel(nLevel) ); } } else if( aRange.equals( lcl_aCategoriesRangeName ) ) { - Sequence< OUString > aLabels = m_bDataInColumns ? this->getRowDescriptions() : this->getColumnDescriptions(); - aResult.realloc( aLabels.getLength() ); - transform( aLabels.getConstArray(), aLabels.getConstArray() + aLabels.getLength(), - aResult.getArray(), CommonFunctors::makeAny< OUString >() ); + vector< vector< uno::Any > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels()); + sal_Int32 nLevelCount = lcl_getInnerLevelCount( aCategories ); + if( nLevelCount == 1 ) + { + sal_Int32 nL=0; + aResult = this->getDataByRangeRepresentation( lcl_aCategoriesLevelRangeNamePrefix + OUString::valueOf( nL ) ); + } + else + { + Sequence< OUString > aLabels = m_bDataInColumns ? this->getRowDescriptions() : this->getColumnDescriptions(); + aResult.realloc( aLabels.getLength() ); + transform( aLabels.getConstArray(), aLabels.getConstArray() + aLabels.getLength(), + aResult.getArray(), CommonFunctors::makeAny< OUString >() ); + } } else { @@ -868,38 +894,36 @@ void SAL_CALL InternalDataProvider::setDataByRangeRepresentation( const OUString& aRange, const Sequence< uno::Any >& aNewData ) throw (uno::RuntimeException) { + vector< uno::Any > aNewVector( ContainerHelper::SequenceToVector(aNewData) ); if( aRange.match( lcl_aLabelRangePrefix ) ) { - vector< OUString > aNewStrings( lcl_AnyToStringVector( aNewData ) ); sal_uInt32 nIndex = aRange.copy( lcl_aLabelRangePrefix.getLength()).toInt32(); if( m_bDataInColumns ) - m_aInternalData.setComplexColumnLabel( nIndex, aNewStrings ); + m_aInternalData.setComplexColumnLabel( nIndex, aNewVector ); else - m_aInternalData.setComplexRowLabel( nIndex, aNewStrings ); + m_aInternalData.setComplexRowLabel( nIndex, aNewVector ); } else if( aRange.match( lcl_aCategoriesPointRangeNamePrefix ) ) { - vector< OUString > aNewStrings( lcl_AnyToStringVector( aNewData ) ); sal_Int32 nPointIndex = aRange.copy( lcl_aCategoriesLevelRangeNamePrefix.getLength()).toInt32(); if( m_bDataInColumns ) - m_aInternalData.setComplexRowLabel( nPointIndex, aNewStrings ); + m_aInternalData.setComplexRowLabel( nPointIndex, aNewVector ); else - m_aInternalData.setComplexColumnLabel( nPointIndex, aNewStrings ); + m_aInternalData.setComplexColumnLabel( nPointIndex, aNewVector ); } else if( aRange.match( lcl_aCategoriesLevelRangeNamePrefix ) ) { - vector< OUString > aNewStrings( lcl_AnyToStringVector( aNewData ) ); sal_Int32 nLevel = aRange.copy( lcl_aCategoriesLevelRangeNamePrefix.getLength()).toInt32(); - vector< vector< OUString > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels(); + vector< vector< uno::Any > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels(); //ensure equal length - if( aNewStrings.size() > aComplexCategories.size() ) - aComplexCategories.resize( aNewStrings.size() ); - else if( aNewStrings.size() < aComplexCategories.size() ) - aNewStrings.resize( aComplexCategories.size() ); + if( aNewVector.size() > aComplexCategories.size() ) + aComplexCategories.resize( aNewVector.size() ); + else if( aNewVector.size() < aComplexCategories.size() ) + aNewVector.resize( aComplexCategories.size() ); - transform( aComplexCategories.begin(), aComplexCategories.end(), aNewStrings.begin(), - aComplexCategories.begin(), lcl_setStringAtLevel(nLevel) ); + transform( aComplexCategories.begin(), aComplexCategories.end(), aNewVector.begin(), + aComplexCategories.begin(), lcl_setAnyAtLevel(nLevel) ); if( m_bDataInColumns ) m_aInternalData.setComplexRowLabels( aComplexCategories ); @@ -908,10 +932,14 @@ void SAL_CALL InternalDataProvider::setDataByRangeRepresentation( } else if( aRange.equals( lcl_aCategoriesRangeName ) ) { + vector< vector< uno::Any > > aComplexCategories; + aComplexCategories.resize( aNewVector.size() ); + transform( aComplexCategories.begin(), aComplexCategories.end(), aNewVector.begin(), + aComplexCategories.begin(), lcl_setAnyAtLevel(0) ); if( m_bDataInColumns ) - this->setRowDescriptions( lcl_AnyToStringSequence(aNewData) ); + m_aInternalData.setComplexRowLabels( aComplexCategories ); else - this->setColumnDescriptions( lcl_AnyToStringSequence(aNewData) ); + m_aInternalData.setComplexColumnLabels( aComplexCategories ); } else { @@ -976,8 +1004,8 @@ void SAL_CALL InternalDataProvider::insertComplexCategoryLevel( sal_Int32 nLevel OSL_ENSURE( nLevel> 0, "you can only insert category levels > 0" );//the first categories level cannot be deleted, check the calling code for error if( nLevel>0 ) { - vector< vector< OUString > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels(); - ::std::for_each( aComplexCategories.begin(), aComplexCategories.end(), lcl_insertStringAtLevel(nLevel) ); + vector< vector< uno::Any > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels(); + ::std::for_each( aComplexCategories.begin(), aComplexCategories.end(), lcl_insertAnyAtLevel(nLevel) ); if( m_bDataInColumns ) m_aInternalData.setComplexRowLabels( aComplexCategories ); else @@ -993,8 +1021,8 @@ void SAL_CALL InternalDataProvider::deleteComplexCategoryLevel( sal_Int32 nLevel OSL_ENSURE( nLevel>0, "you can only delete category levels > 0" );//the first categories level cannot be deleted, check the calling code for error if( nLevel>0 ) { - vector< vector< OUString > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels(); - ::std::for_each( aComplexCategories.begin(), aComplexCategories.end(), lcl_removeStringAtLevel(nLevel) ); + vector< vector< uno::Any > > aComplexCategories = m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels(); + ::std::for_each( aComplexCategories.begin(), aComplexCategories.end(), lcl_removeAnyAtLevel(nLevel) ); if( m_bDataInColumns ) m_aInternalData.setComplexRowLabels( aComplexCategories ); else @@ -1204,7 +1232,36 @@ OUString SAL_CALL InternalDataProvider::convertRangeFromXML( const OUString& aXM namespace { -Sequence< Sequence< OUString > > lcl_convertComplexVectorToSequence( const vector< vector< OUString > >& rIn ) + +template< class Type > +Sequence< Sequence< Type > > lcl_convertVectorVectorToSequenceSequence( const vector< vector< Type > >& rIn ) +{ + Sequence< Sequence< Type > > aRet; + sal_Int32 nOuterCount = rIn.size(); + if( nOuterCount ) + { + aRet.realloc(nOuterCount); + for( sal_Int32 nN=0; nN<nOuterCount; nN++) + aRet[nN]= ContainerHelper::ContainerToSequence( rIn[nN] ); + } + return aRet; +} + +template< class Type > +vector< vector< Type > > lcl_convertSequenceSequenceToVectorVector( const Sequence< Sequence< Type > >& rIn ) +{ + vector< vector< Type > > aRet; + sal_Int32 nOuterCount = rIn.getLength(); + if( nOuterCount ) + { + aRet.resize(nOuterCount); + for( sal_Int32 nN=0; nN<nOuterCount; nN++) + aRet[nN]= ContainerHelper::SequenceToVector( rIn[nN] ); + } + return aRet; +} + +Sequence< Sequence< OUString > > lcl_convertComplexAnyVectorToStringSequence( const vector< vector< uno::Any > >& rIn ) { Sequence< Sequence< OUString > > aRet; sal_Int32 nOuterCount = rIn.size(); @@ -1212,17 +1269,17 @@ Sequence< Sequence< OUString > > lcl_convertComplexVectorToSequence( const vecto { aRet.realloc(nOuterCount); for( sal_Int32 nN=0; nN<nOuterCount; nN++) - aRet[nN]=ContainerHelper::ContainerToSequence( rIn[nN] ); + aRet[nN]= lcl_AnyToStringSequence( ContainerHelper::ContainerToSequence( rIn[nN] ) ); } return aRet; } -vector< vector< OUString > > lcl_convertComplexSequenceToVector( const Sequence< Sequence< OUString > >& rIn ) +vector< vector< uno::Any > > lcl_convertComplexStringSequenceToAnyVector( const Sequence< Sequence< OUString > >& rIn ) { - vector< vector< OUString > > aRet; + vector< vector< uno::Any > > aRet; sal_Int32 nOuterCount = rIn.getLength(); for( sal_Int32 nN=0; nN<nOuterCount; nN++) - aRet.push_back( ContainerHelper::SequenceToVector( rIn[nN] ) ); + aRet.push_back( ContainerHelper::SequenceToVector( lcl_StringToAnySequence( rIn[nN] ) ) ); return aRet; } @@ -1230,7 +1287,7 @@ class SplitCategoriesProvider_ForComplexDescriptions : public SplitCategoriesPro { public: - explicit SplitCategoriesProvider_ForComplexDescriptions( const ::std::vector< ::std::vector< ::rtl::OUString > >& rComplexDescriptions ) + explicit SplitCategoriesProvider_ForComplexDescriptions( const ::std::vector< ::std::vector< uno::Any > >& rComplexDescriptions ) : m_rComplexDescriptions( rComplexDescriptions ) {} virtual ~SplitCategoriesProvider_ForComplexDescriptions() @@ -1240,7 +1297,7 @@ public: virtual uno::Sequence< rtl::OUString > getStringsForLevel( sal_Int32 nIndex ) const; private: - const ::std::vector< ::std::vector< ::rtl::OUString > >& m_rComplexDescriptions; + const ::std::vector< ::std::vector< uno::Any > >& m_rComplexDescriptions; }; sal_Int32 SplitCategoriesProvider_ForComplexDescriptions::getLevelCount() const @@ -1261,22 +1318,78 @@ uno::Sequence< rtl::OUString > SplitCategoriesProvider_ForComplexDescriptions::g }//anonymous namespace +// ____ XDateCategories ____ +Sequence< double > SAL_CALL InternalDataProvider::getDateCategories() throw (uno::RuntimeException) +{ + double fNan = InternalDataProvider::getNotANumber(); + double fValue = fNan; + vector< vector< uno::Any > > aCategories( m_bDataInColumns ? m_aInternalData.getComplexRowLabels() : m_aInternalData.getComplexColumnLabels()); + sal_Int32 nCount = aCategories.size(); + Sequence< double > aDoubles( nCount ); + vector< vector< uno::Any > >::iterator aIt( aCategories.begin() ); + vector< vector< uno::Any > >::const_iterator aEnd( aCategories.end() ); + for(sal_Int32 nN=0; nN<nCount && aIt!=aEnd; ++nN, ++aIt ) + { + if( !( !aIt->empty() && ((*aIt)[0]>>=fValue) ) ) + fValue = fNan; + aDoubles[nN]=fValue; + } + return aDoubles; +} + +void SAL_CALL InternalDataProvider::setDateCategories( const Sequence< double >& rDates ) throw (uno::RuntimeException) +{ + sal_Int32 nCount = rDates.getLength(); + vector< vector< uno::Any > > aNewCategories; + aNewCategories.reserve(nCount); + vector< uno::Any > aSingleLabel(1); + + for(sal_Int32 nN=0; nN<nCount; ++nN ) + { + aSingleLabel[0]=uno::makeAny(rDates[nN]); + aNewCategories.push_back(aSingleLabel); + } + + if( m_bDataInColumns ) + m_aInternalData.setComplexRowLabels( aNewCategories ); + else + m_aInternalData.setComplexColumnLabels( aNewCategories ); +} + +// ____ XAnyDescriptionAccess ____ +Sequence< Sequence< uno::Any > > SAL_CALL InternalDataProvider::getAnyRowDescriptions() throw (uno::RuntimeException) +{ + return lcl_convertVectorVectorToSequenceSequence( m_aInternalData.getComplexRowLabels() ); +} +void SAL_CALL InternalDataProvider::setAnyRowDescriptions( const Sequence< Sequence< uno::Any > >& aRowDescriptions ) throw (uno::RuntimeException) +{ + m_aInternalData.setComplexRowLabels( lcl_convertSequenceSequenceToVectorVector( aRowDescriptions ) ); +} +Sequence< Sequence< uno::Any > > SAL_CALL InternalDataProvider::getAnyColumnDescriptions() throw (uno::RuntimeException) +{ + return lcl_convertVectorVectorToSequenceSequence( m_aInternalData.getComplexColumnLabels() ); +} +void SAL_CALL InternalDataProvider::setAnyColumnDescriptions( const Sequence< Sequence< uno::Any > >& aColumnDescriptions ) throw (uno::RuntimeException) +{ + m_aInternalData.setComplexColumnLabels( lcl_convertSequenceSequenceToVectorVector( aColumnDescriptions ) ); +} + // ____ XComplexDescriptionAccess ____ Sequence< Sequence< OUString > > SAL_CALL InternalDataProvider::getComplexRowDescriptions() throw (uno::RuntimeException) { - return lcl_convertComplexVectorToSequence( m_aInternalData.getComplexRowLabels() ); + return lcl_convertComplexAnyVectorToStringSequence( m_aInternalData.getComplexRowLabels() ); } void SAL_CALL InternalDataProvider::setComplexRowDescriptions( const Sequence< Sequence< ::rtl::OUString > >& aRowDescriptions ) throw (uno::RuntimeException) { - m_aInternalData.setComplexRowLabels( lcl_convertComplexSequenceToVector(aRowDescriptions) ); + m_aInternalData.setComplexRowLabels( lcl_convertComplexStringSequenceToAnyVector(aRowDescriptions) ); } Sequence< Sequence< ::rtl::OUString > > SAL_CALL InternalDataProvider::getComplexColumnDescriptions() throw (uno::RuntimeException) { - return lcl_convertComplexVectorToSequence( m_aInternalData.getComplexColumnLabels() ); + return lcl_convertComplexAnyVectorToStringSequence( m_aInternalData.getComplexColumnLabels() ); } void SAL_CALL InternalDataProvider::setComplexColumnDescriptions( const Sequence< Sequence< ::rtl::OUString > >& aColumnDescriptions ) throw (uno::RuntimeException) { - m_aInternalData.setComplexColumnLabels( lcl_convertComplexSequenceToVector(aColumnDescriptions) ); + m_aInternalData.setComplexColumnLabels( lcl_convertComplexStringSequenceToAnyVector(aColumnDescriptions) ); } // ____ XChartDataArray ____ @@ -1295,25 +1408,25 @@ void SAL_CALL InternalDataProvider::setData( const Sequence< Sequence< double > void SAL_CALL InternalDataProvider::setRowDescriptions( const Sequence< OUString >& aRowDescriptions ) throw (uno::RuntimeException) { - vector< vector< OUString > > aComplexDescriptions( aRowDescriptions.getLength() ); + vector< vector< uno::Any > > aComplexDescriptions( aRowDescriptions.getLength() ); transform( aComplexDescriptions.begin(), aComplexDescriptions.end(), aRowDescriptions.getConstArray(), - aComplexDescriptions.begin(), lcl_setStringAtLevel(0) ); + aComplexDescriptions.begin(), lcl_setAnyAtLevelFromStringSequence(0) ); m_aInternalData.setComplexRowLabels( aComplexDescriptions ); } void SAL_CALL InternalDataProvider::setColumnDescriptions( const Sequence< OUString >& aColumnDescriptions ) throw (uno::RuntimeException) { - vector< vector< OUString > > aComplexDescriptions( aColumnDescriptions.getLength() ); + vector< vector< uno::Any > > aComplexDescriptions( aColumnDescriptions.getLength() ); transform( aComplexDescriptions.begin(), aComplexDescriptions.end(), aColumnDescriptions.getConstArray(), - aComplexDescriptions.begin(), lcl_setStringAtLevel(0) ); + aComplexDescriptions.begin(), lcl_setAnyAtLevelFromStringSequence(0) ); m_aInternalData.setComplexColumnLabels( aComplexDescriptions ); } Sequence< OUString > SAL_CALL InternalDataProvider::getRowDescriptions() throw (uno::RuntimeException) { - vector< vector< OUString > > aComplexLabels( m_aInternalData.getComplexRowLabels() ); + vector< vector< uno::Any > > aComplexLabels( m_aInternalData.getComplexRowLabels() ); SplitCategoriesProvider_ForComplexDescriptions aProvider( aComplexLabels ); return ExplicitCategoriesProvider::getExplicitSimpleCategories( aProvider ); } @@ -1321,7 +1434,7 @@ Sequence< OUString > SAL_CALL InternalDataProvider::getRowDescriptions() Sequence< OUString > SAL_CALL InternalDataProvider::getColumnDescriptions() throw (uno::RuntimeException) { - vector< vector< OUString > > aComplexLabels( m_aInternalData.getComplexColumnLabels() ); + vector< vector< uno::Any > > aComplexLabels( m_aInternalData.getComplexColumnLabels() ); SplitCategoriesProvider_ForComplexDescriptions aProvider( aComplexLabels ); return ExplicitCategoriesProvider::getExplicitSimpleCategories( aProvider ); } |