diff options
author | obo <obo@openoffice.org> | 2011-03-16 09:28:51 +0100 |
---|---|---|
committer | obo <obo@openoffice.org> | 2011-03-16 09:28:51 +0100 |
commit | 5feae0f6170f233e84a3b377eecccd505ff2832e (patch) | |
tree | 36020de9bb619efca8c23e57d828b88eb4955efa /xmloff | |
parent | f165e5b06c6c97b1f92ac314a66146af02ccb872 (diff) | |
parent | e12b6584f9ebcb0397f5965e8297295a27807675 (diff) |
CWS-TOOLING: integrate CWS chart51
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/chart/SchXMLExport.cxx | 135 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLSeries2Context.cxx | 9 | ||||
-rw-r--r-- | xmloff/source/chart/SchXMLTools.cxx | 2 | ||||
-rw-r--r-- | xmloff/source/draw/shapeexport.cxx | 2 |
4 files changed, 110 insertions, 38 deletions
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx index c74abe953d2f..a65f6b11780f 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -602,24 +602,20 @@ OUString lcl_flattenStringSequence( const Sequence< OUString > & rSequence ) return aResult.makeStringAndClear(); } -OUString lcl_getLabelString( const Reference< chart2::data::XDataSequence > & xLabelSeq ) +void lcl_getLabelStringSequence( Sequence< OUString >& rOutLabels, const Reference< chart2::data::XDataSequence > & xLabelSeq ) { - Sequence< OUString > aLabels; - uno::Reference< chart2::data::XTextualDataSequence > xTextualDataSequence( xLabelSeq, uno::UNO_QUERY ); if( xTextualDataSequence.is()) { - aLabels = xTextualDataSequence->getTextualData(); + rOutLabels = xTextualDataSequence->getTextualData(); } else if( xLabelSeq.is()) { Sequence< uno::Any > aAnies( xLabelSeq->getData()); - aLabels.realloc( aAnies.getLength()); + rOutLabels.realloc( aAnies.getLength()); for( sal_Int32 i=0; i<aAnies.getLength(); ++i ) - aAnies[i] >>= aLabels[i]; + aAnies[i] >>= rOutLabels[i]; } - - return lcl_flattenStringSequence( aLabels ); } sal_Int32 lcl_getMaxSequenceLength( @@ -639,46 +635,96 @@ sal_Int32 lcl_getMaxSequenceLength( return nResult; } -double lcl_getValueFromSequence( const Reference< chart2::data::XDataSequence > & xSeq, sal_Int32 nIndex ) +uno::Sequence< rtl::OUString > lcl_DataSequenceToStringSequence( + const uno::Reference< chart2::data::XDataSequence >& xDataSequence ) { - double fResult = 0.0; - ::rtl::math::setNan( &fResult ); - Reference< chart2::data::XNumericalDataSequence > xNumSeq( xSeq, uno::UNO_QUERY ); - if( xNumSeq.is()) + uno::Sequence< rtl::OUString > aResult; + if(!xDataSequence.is()) + return aResult; + + uno::Reference< chart2::data::XTextualDataSequence > xTextualDataSequence( xDataSequence, uno::UNO_QUERY ); + if( xTextualDataSequence.is() ) { - Sequence< double > aValues( xNumSeq->getNumericalData()); - if( nIndex < aValues.getLength() ) - fResult = aValues[nIndex]; + aResult = xTextualDataSequence->getTextualData(); } else { - Sequence< uno::Any > aAnies( xSeq->getData()); - if( nIndex < aAnies.getLength() ) - aAnies[nIndex] >>= fResult; + uno::Sequence< uno::Any > aValues = xDataSequence->getData(); + aResult.realloc(aValues.getLength()); + + for(sal_Int32 nN=aValues.getLength();nN--;) + aValues[nN] >>= aResult[nN]; } - return fResult; -} + return aResult; +} ::std::vector< double > lcl_getAllValuesFromSequence( const Reference< chart2::data::XDataSequence > & xSeq ) { double fNan = 0.0; ::rtl::math::setNan( &fNan ); ::std::vector< double > aResult; + if(!xSeq.is()) + return aResult; + uno::Sequence< double > aValuesSequence; Reference< chart2::data::XNumericalDataSequence > xNumSeq( xSeq, uno::UNO_QUERY ); - if( xNumSeq.is()) + if( xNumSeq.is() ) { - Sequence< double > aValues( xNumSeq->getNumericalData()); - ::std::copy( aValues.getConstArray(), aValues.getConstArray() + aValues.getLength(), - ::std::back_inserter( aResult )); + aValuesSequence = xNumSeq->getNumericalData(); } - else if( xSeq.is()) + else { - Sequence< uno::Any > aAnies( xSeq->getData()); - aResult.resize( aAnies.getLength(), fNan ); + Sequence< uno::Any > aAnies( xSeq->getData() ); + aValuesSequence.realloc( aAnies.getLength() ); for( sal_Int32 i=0; i<aAnies.getLength(); ++i ) - aAnies[i] >>= aResult[i]; + aAnies[i] >>= aValuesSequence[i]; + } + + //special handling for x-values (if x-values do point to categories, indices are used instead ) + Reference< beans::XPropertySet > xProp( xSeq, uno::UNO_QUERY ); + if( xProp.is() ) + { + OUString aRole; + xProp->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Role") ) ) >>= aRole; + if( aRole.match( OUString( RTL_CONSTASCII_USTRINGPARAM( "values-x") ) ) ) + { + //lcl_clearIfNoValuesButTextIsContained - replace by indices if the values are not appropriate + bool bHasValue=false; + bool bHasText=false; + sal_Int32 nCount = aValuesSequence.getLength(); + for( sal_Int32 j = 0; j < nCount; ++j ) + { + if( !::rtl::math::isNan( aValuesSequence[j] ) ) + { + bHasValue=true; + break; + } + } + if(!bHasValue) + { + //no double value is countained + //is there any text? + uno::Sequence< rtl::OUString > aStrings( lcl_DataSequenceToStringSequence( xSeq ) ); + sal_Int32 nTextCount = aStrings.getLength(); + for( sal_Int32 j = 0; j < nTextCount; ++j ) + { + if( aStrings[j].getLength() ) + { + bHasText=true; + break; + } + } + } + if( !bHasValue && bHasText ) + { + for( sal_Int32 j = 0; j < nCount; ++j ) + aValuesSequence[j] = j+1; + } + } } + + ::std::copy( aValuesSequence.getConstArray(), aValuesSequence.getConstArray() + aValuesSequence.getLength(), + ::std::back_inserter( aResult )); return aResult; } @@ -803,15 +849,20 @@ lcl_TableData lcl_getDataForLocalTable( Sequence< OUString > aSimpleCategories; if( xAnyDescriptionAccess.is() ) { + //categories if( bSeriesFromColumns ) + { aSimpleCategories = xAnyDescriptionAccess->getRowDescriptions(); + aResult.aComplexRowDescriptions = xAnyDescriptionAccess->getAnyRowDescriptions(); + } else + { aSimpleCategories = xAnyDescriptionAccess->getColumnDescriptions(); - - aResult.aComplexColumnDescriptions = xAnyDescriptionAccess->getAnyColumnDescriptions(); - aResult.aComplexRowDescriptions = xAnyDescriptionAccess->getAnyRowDescriptions(); + aResult.aComplexColumnDescriptions = xAnyDescriptionAccess->getAnyColumnDescriptions(); + } } + //series values and series labels SchXMLExportHelper_Impl::tDataSequenceCont::size_type nNumSequences = aSequencesToExport.size(); SchXMLExportHelper_Impl::tDataSequenceCont::const_iterator aBegin( aSequencesToExport.begin()); SchXMLExportHelper_Impl::tDataSequenceCont::const_iterator aEnd( aSequencesToExport.end()); @@ -856,19 +907,25 @@ lcl_TableData lcl_getDataForLocalTable( // iterate over all sequences size_t nSeqIdx = 0; + Sequence< Sequence< OUString > > aComplexLabels(nNumSequences); for( ; aIt != aEnd; ++aIt, ++nSeqIdx ) { OUString aRange; + Sequence< OUString >& rCurrentComplexLabel = aComplexLabels[nSeqIdx]; if( aIt->first.is()) { - rLabels[nSeqIdx] = lcl_getLabelString( aIt->first ); + lcl_getLabelStringSequence( rCurrentComplexLabel, aIt->first ); + rLabels[nSeqIdx] = lcl_flattenStringSequence( rCurrentComplexLabel ); aRange = aIt->first->getSourceRangeRepresentation(); if( xRangeConversion.is()) aRange = xRangeConversion->convertRangeToXML( aRange ); } else if( aIt->second.is()) - rLabels[nSeqIdx] = lcl_flattenStringSequence( + { + rCurrentComplexLabel.realloc(1); + rLabels[nSeqIdx] = rCurrentComplexLabel[0] = lcl_flattenStringSequence( aIt->second->generateLabel( chart2::data::LabelOrigin_SHORT_SIDE )); + } if( bSeriesFromColumns ) aResult.aColumnDescriptions_Ranges.push_back( aRange ); else @@ -896,6 +953,16 @@ lcl_TableData lcl_getDataForLocalTable( if( !lcl_SequenceHasUnhiddenData(aIt->first) && !lcl_SequenceHasUnhiddenData(aIt->second) ) aResult.aHiddenColumns.push_back(nSeqIdx); } + Sequence< Sequence< Any > >& rComplexAnyLabels = bSeriesFromColumns ? aResult.aComplexColumnDescriptions : aResult.aComplexRowDescriptions;//#i116544# + rComplexAnyLabels.realloc(aComplexLabels.getLength()); + for( sal_Int32 nN=0; nN<aComplexLabels.getLength();nN++ ) + { + Sequence< OUString >& rSource = aComplexLabels[nN]; + Sequence< Any >& rTarget = rComplexAnyLabels[nN]; + rTarget.realloc( rSource.getLength() ); + for( sal_Int32 i=0; i<rSource.getLength(); i++ ) + rTarget[i] = uno::makeAny( rSource[i] ); + } } catch( uno::Exception & rEx ) { diff --git a/xmloff/source/chart/SchXMLSeries2Context.cxx b/xmloff/source/chart/SchXMLSeries2Context.cxx index d106398a0fcd..f45f9a5e5f48 100644 --- a/xmloff/source/chart/SchXMLSeries2Context.cxx +++ b/xmloff/source/chart/SchXMLSeries2Context.cxx @@ -423,7 +423,7 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib // values Reference< chart2::data::XDataSequence > xSeq; - if( bHasRange ) + if( bHasRange && m_aSeriesRange.getLength() ) xSeq = SchXMLTools::CreateDataSequence( m_aSeriesRange, mxNewDoc ); Reference< beans::XPropertySet > xSeqProp( xSeq, uno::UNO_QUERY ); @@ -442,7 +442,7 @@ void SchXMLSeries2Context::StartElement( const uno::Reference< xml::sax::XAttrib tSchXMLIndexWithPart( m_rGlobalSeriesImportInfo.nCurrentDataIndex, SCH_XML_PART_VALUES ), xLabeledSeq )); // label - if( bHasLabelRange ) + if( bHasLabelRange && m_aSeriesLabelRange.getLength() ) { Reference< chart2::data::XDataSequence > xLabelSequence = SchXMLTools::CreateDataSequence( m_aSeriesLabelRange, mxNewDoc ); @@ -581,6 +581,11 @@ void SchXMLSeries2Context::EndElement() aDomainInfos.push_back( aDomainInfo ); m_rGlobalSeriesImportInfo.nCurrentDataIndex++; } + else if( m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress.getLength() ) + { + DomainInfo aDomainInfo( OUString::createFromAscii("values-y"), m_rGlobalSeriesImportInfo.aFirstFirstDomainAddress, m_rGlobalSeriesImportInfo.nFirstFirstDomainIndex ) ; + aDomainInfos.push_back( aDomainInfo ); + } } if( bDeleteSeries ) diff --git a/xmloff/source/chart/SchXMLTools.cxx b/xmloff/source/chart/SchXMLTools.cxx index a0be5f4ec6a8..2aed07dca617 100644 --- a/xmloff/source/chart/SchXMLTools.cxx +++ b/xmloff/source/chart/SchXMLTools.cxx @@ -419,7 +419,7 @@ Reference< chart2::data::XDataSequence > CreateDataSequence( DBG_ERROR( "could not create data sequence" ); } - if( !xRet.is() && !xChartDoc->hasInternalDataProvider() ) + if( !xRet.is() && !xChartDoc->hasInternalDataProvider() && rRange.getLength() ) { //#i103911# switch to internal data in case the parent cannot provide the requested data xChartDoc->createInternalDataProvider( sal_True /* bCloneExistingData */ ); diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx index aebd513995e3..a8f09f2d99bd 100644 --- a/xmloff/source/draw/shapeexport.cxx +++ b/xmloff/source/draw/shapeexport.cxx @@ -711,7 +711,7 @@ void XMLShapeExport::exportShape(const uno::Reference< drawing::XShape >& xShape if( xSet.is() && ( mrExport.getDefaultVersion() > SvtSaveOptions::ODFVER_012 ) ) { if( aShapeInfo.meShapeType != XmlShapeTypeDrawPageShape && aShapeInfo.meShapeType != XmlShapeTypePresPageShape && - aShapeInfo.meShapeType != XmlShapeTypeHandoutShape ) + aShapeInfo.meShapeType != XmlShapeTypeHandoutShape && aShapeInfo.meShapeType != XmlShapeTypeDrawChartShape ) try { |