diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-07-25 20:46:52 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-07-25 23:04:50 -0400 |
commit | f350a71df9ca631c21cf6d2c981ddc717737c76f (patch) | |
tree | fabfdf3e221b8d12af2ef0618b55824d2b71c098 /xmloff | |
parent | pImplize XMLPropertyHandlerFactory. (diff) | |
download | core-f350a71df9ca631c21cf6d2c981ddc717737c76f.tar.gz core-f350a71df9ca631c21cf6d2c981ddc717737c76f.zip |
Reduce scope levels.
Change-Id: I64684a80c79c3c7f5a8f23b07703fbcee3fe5887
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/chart/SchXMLExport.cxx | 344 |
1 files changed, 172 insertions, 172 deletions
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx index fc52354c459f..84958d8f8c55 100644 --- a/xmloff/source/chart/SchXMLExport.cxx +++ b/xmloff/source/chart/SchXMLExport.cxx @@ -3287,225 +3287,225 @@ void SchXMLExportHelper_Impl::exportDataPoints( // do have own attributes. This increases the performance substantially. // more performant version for #93600# - if( mxExpPropMapper.is()) - { - uno::Reference< chart2::XDataSeries > xSeries( xSeriesProperties, uno::UNO_QUERY ); + if (!mxExpPropMapper.is()) + return; - std::vector< XMLPropertyState > aPropertyStates; + uno::Reference< chart2::XDataSeries > xSeries( xSeriesProperties, uno::UNO_QUERY ); - const OUString sNumFormat("NumberFormat"); - const OUString sPercentageNumFormat( "PercentageNumberFormat"); + std::vector< XMLPropertyState > aPropertyStates; - bool bVaryColorsByPoint = false; - Sequence< sal_Int32 > aDataPointSeq; - if( xSeriesProperties.is()) - { - Any aAny = xSeriesProperties->getPropertyValue( - OUString( "AttributedDataPoints" )); - aAny >>= aDataPointSeq; - xSeriesProperties->getPropertyValue( - OUString( "VaryColorsByPoint" )) >>= bVaryColorsByPoint; - } + const OUString sNumFormat("NumberFormat"); + const OUString sPercentageNumFormat( "PercentageNumberFormat"); - sal_Int32 nSize = aDataPointSeq.getLength(); - SAL_WARN_IF( nSize > nSeriesLength, "xmloff.chart", "Too many point attributes" ); + bool bVaryColorsByPoint = false; + Sequence< sal_Int32 > aDataPointSeq; + if( xSeriesProperties.is()) + { + Any aAny = xSeriesProperties->getPropertyValue( + OUString( "AttributedDataPoints" )); + aAny >>= aDataPointSeq; + xSeriesProperties->getPropertyValue( + OUString( "VaryColorsByPoint" )) >>= bVaryColorsByPoint; + } - const sal_Int32 * pPoints = aDataPointSeq.getConstArray(); - sal_Int32 nElement; - sal_Int32 nRepeat; - Reference< chart2::XColorScheme > xColorScheme; - if( xDiagram.is()) - xColorScheme.set( xDiagram->getDefaultColorScheme()); + sal_Int32 nSize = aDataPointSeq.getLength(); + SAL_WARN_IF( nSize > nSeriesLength, "xmloff.chart", "Too many point attributes" ); + + const sal_Int32 * pPoints = aDataPointSeq.getConstArray(); + sal_Int32 nElement; + sal_Int32 nRepeat; + Reference< chart2::XColorScheme > xColorScheme; + if( xDiagram.is()) + xColorScheme.set( xDiagram->getDefaultColorScheme()); - ::std::list< SchXMLDataPointStruct > aDataPointList; + ::std::list< SchXMLDataPointStruct > aDataPointList; - sal_Int32 nLastIndex = -1; - sal_Int32 nCurrIndex = 0; + sal_Int32 nLastIndex = -1; + sal_Int32 nCurrIndex = 0; - // collect elements - if( bVaryColorsByPoint && xColorScheme.is() ) + // collect elements + if( bVaryColorsByPoint && xColorScheme.is() ) + { + ::std::set< sal_Int32 > aAttrPointSet; + ::std::copy( pPoints, pPoints + aDataPointSeq.getLength(), + ::std::inserter( aAttrPointSet, aAttrPointSet.begin())); + const ::std::set< sal_Int32 >::const_iterator aEndIt( aAttrPointSet.end()); + for( nElement = 0; nElement < nSeriesLength; ++nElement ) { - ::std::set< sal_Int32 > aAttrPointSet; - ::std::copy( pPoints, pPoints + aDataPointSeq.getLength(), - ::std::inserter( aAttrPointSet, aAttrPointSet.begin())); - const ::std::set< sal_Int32 >::const_iterator aEndIt( aAttrPointSet.end()); - for( nElement = 0; nElement < nSeriesLength; ++nElement ) + aPropertyStates.clear(); + uno::Reference< beans::XPropertySet > xPropSet; + bool bExportNumFmt = false; + if( aAttrPointSet.find( nElement ) != aEndIt ) { - aPropertyStates.clear(); - uno::Reference< beans::XPropertySet > xPropSet; - bool bExportNumFmt = false; - if( aAttrPointSet.find( nElement ) != aEndIt ) + try { - try - { - xPropSet = SchXMLSeriesHelper::createOldAPIDataPointPropertySet( - xSeries, nElement, mrExport.GetModel() ); - bExportNumFmt = true; - } - catch( const uno::Exception & rEx ) - { - SAL_INFO("xmloff.chart", "Exception caught during Export of data point: " << rEx.Message ); - } + xPropSet = SchXMLSeriesHelper::createOldAPIDataPointPropertySet( + xSeries, nElement, mrExport.GetModel() ); + bExportNumFmt = true; } - else + catch( const uno::Exception & rEx ) { - // property set only containing the color - xPropSet.set( new ::xmloff::chart::ColorPropertySet( - xColorScheme->getColorByIndex( nElement ))); + SAL_INFO("xmloff.chart", "Exception caught during Export of data point: " << rEx.Message ); } - SAL_WARN_IF( !xPropSet.is(), "xmloff.chart", "Pie Segments should have properties" ); - if( xPropSet.is()) + } + else + { + // property set only containing the color + xPropSet.set( new ::xmloff::chart::ColorPropertySet( + xColorScheme->getColorByIndex( nElement ))); + } + SAL_WARN_IF( !xPropSet.is(), "xmloff.chart", "Pie Segments should have properties" ); + if( xPropSet.is()) + { + const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() ); + if( nCurrentODFVersion >= SvtSaveOptions::ODFVER_012 && bExportNumFmt ) { - const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() ); - if( nCurrentODFVersion >= SvtSaveOptions::ODFVER_012 && bExportNumFmt ) - { - lcl_exportNumberFormat( sNumFormat, xPropSet, mrExport ); - lcl_exportNumberFormat( sPercentageNumFormat, xPropSet, mrExport ); - } + lcl_exportNumberFormat( sNumFormat, xPropSet, mrExport ); + lcl_exportNumberFormat( sPercentageNumFormat, xPropSet, mrExport ); + } - aPropertyStates = mxExpPropMapper->Filter( xPropSet ); - if( !aPropertyStates.empty() ) + aPropertyStates = mxExpPropMapper->Filter( xPropSet ); + if( !aPropertyStates.empty() ) + { + if( bExportContent ) { - if( bExportContent ) - { - // write data-point with style - SAL_WARN_IF( maAutoStyleNameQueue.empty(), "xmloff.chart", "Autostyle queue empty!" ); + // write data-point with style + SAL_WARN_IF( maAutoStyleNameQueue.empty(), "xmloff.chart", "Autostyle queue empty!" ); - SchXMLDataPointStruct aPoint; - aPoint.maStyleName = maAutoStyleNameQueue.front(); - maAutoStyleNameQueue.pop(); - aDataPointList.push_back( aPoint ); - } - else - { - CollectAutoStyle( aPropertyStates ); - } + SchXMLDataPointStruct aPoint; + aPoint.maStyleName = maAutoStyleNameQueue.front(); + maAutoStyleNameQueue.pop(); + aDataPointList.push_back( aPoint ); + } + else + { + CollectAutoStyle( aPropertyStates ); } } } - SAL_WARN_IF( bExportContent && (static_cast<sal_Int32>(aDataPointList.size()) != nSeriesLength), "xmloff.chart", "not enough data points on content export" ); } - else + SAL_WARN_IF( bExportContent && (static_cast<sal_Int32>(aDataPointList.size()) != nSeriesLength), "xmloff.chart", "not enough data points on content export" ); + } + else + { + for( nElement = 0; nElement < nSize; ++nElement ) { - for( nElement = 0; nElement < nSize; ++nElement ) - { - aPropertyStates.clear(); - nCurrIndex = pPoints[ nElement ]; - //assuming sorted indices in pPoints + aPropertyStates.clear(); + nCurrIndex = pPoints[ nElement ]; + //assuming sorted indices in pPoints - if( nCurrIndex<0 || nCurrIndex>=nSeriesLength ) - break; + if( nCurrIndex<0 || nCurrIndex>=nSeriesLength ) + break; - // write leading empty data points - if( nCurrIndex - nLastIndex > 1 ) - { - SchXMLDataPointStruct aPoint; - aPoint.mnRepeat = nCurrIndex - nLastIndex - 1; - aDataPointList.push_back( aPoint ); - } + // write leading empty data points + if( nCurrIndex - nLastIndex > 1 ) + { + SchXMLDataPointStruct aPoint; + aPoint.mnRepeat = nCurrIndex - nLastIndex - 1; + aDataPointList.push_back( aPoint ); + } - uno::Reference< beans::XPropertySet > xPropSet; - // get property states - try - { - xPropSet = SchXMLSeriesHelper::createOldAPIDataPointPropertySet( - xSeries, nCurrIndex, mrExport.GetModel() ); - } - catch( const uno::Exception & rEx ) + uno::Reference< beans::XPropertySet > xPropSet; + // get property states + try + { + xPropSet = SchXMLSeriesHelper::createOldAPIDataPointPropertySet( + xSeries, nCurrIndex, mrExport.GetModel() ); + } + catch( const uno::Exception & rEx ) + { + SAL_INFO("xmloff.chart", "Exception caught during Export of data point: " << rEx.Message ); + } + if( xPropSet.is()) + { + const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() ); + if( nCurrentODFVersion >= SvtSaveOptions::ODFVER_012 ) { - SAL_INFO("xmloff.chart", "Exception caught during Export of data point: " << rEx.Message ); + lcl_exportNumberFormat( sNumFormat, xPropSet, mrExport ); + lcl_exportNumberFormat( sPercentageNumFormat, xPropSet, mrExport ); } - if( xPropSet.is()) + + aPropertyStates = mxExpPropMapper->Filter( xPropSet ); + if( !aPropertyStates.empty() ) { - const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion( SvtSaveOptions().GetODFDefaultVersion() ); - if( nCurrentODFVersion >= SvtSaveOptions::ODFVER_012 ) + if( bExportContent ) { - lcl_exportNumberFormat( sNumFormat, xPropSet, mrExport ); - lcl_exportNumberFormat( sPercentageNumFormat, xPropSet, mrExport ); + // write data-point with style + SAL_WARN_IF( maAutoStyleNameQueue.empty(), "xmloff.chart", "Autostyle queue empty!" ); + SchXMLDataPointStruct aPoint; + aPoint.maStyleName = maAutoStyleNameQueue.front(); + maAutoStyleNameQueue.pop(); + + aDataPointList.push_back( aPoint ); + nLastIndex = nCurrIndex; } - - aPropertyStates = mxExpPropMapper->Filter( xPropSet ); - if( !aPropertyStates.empty() ) + else { - if( bExportContent ) - { - // write data-point with style - SAL_WARN_IF( maAutoStyleNameQueue.empty(), "xmloff.chart", "Autostyle queue empty!" ); - SchXMLDataPointStruct aPoint; - aPoint.maStyleName = maAutoStyleNameQueue.front(); - maAutoStyleNameQueue.pop(); - - aDataPointList.push_back( aPoint ); - nLastIndex = nCurrIndex; - } - else - { - CollectAutoStyle( aPropertyStates ); - } - continue; + CollectAutoStyle( aPropertyStates ); } + continue; } + } - // if we get here the property states are empty - SchXMLDataPointStruct aPoint; - aDataPointList.push_back( aPoint ); + // if we get here the property states are empty + SchXMLDataPointStruct aPoint; + aDataPointList.push_back( aPoint ); - nLastIndex = nCurrIndex; - } - // final empty elements - nRepeat = nSeriesLength - nLastIndex - 1; - if( nRepeat > 0 ) - { - SchXMLDataPointStruct aPoint; - aPoint.mnRepeat = nRepeat; - aDataPointList.push_back( aPoint ); - } + nLastIndex = nCurrIndex; } - - if( bExportContent ) + // final empty elements + nRepeat = nSeriesLength - nLastIndex - 1; + if( nRepeat > 0 ) { - // write elements (merge equal ones) - ::std::list< SchXMLDataPointStruct >::iterator aIter = aDataPointList.begin(); SchXMLDataPointStruct aPoint; - SchXMLDataPointStruct aLastPoint; + aPoint.mnRepeat = nRepeat; + aDataPointList.push_back( aPoint ); + } + } - // initialize so that it doesn't matter if - // the element is counted in the first iteration - aLastPoint.mnRepeat = 0; + if (!bExportContent) + return; - for( ; aIter != aDataPointList.end(); ++aIter ) - { - aPoint = (*aIter); + // write elements (merge equal ones) + ::std::list< SchXMLDataPointStruct >::iterator aIter = aDataPointList.begin(); + SchXMLDataPointStruct aPoint; + SchXMLDataPointStruct aLastPoint; - if( aPoint.maStyleName == aLastPoint.maStyleName ) - aPoint.mnRepeat += aLastPoint.mnRepeat; - else if( aLastPoint.mnRepeat > 0 ) - { - // write last element - if( !aLastPoint.maStyleName.isEmpty() ) - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_STYLE_NAME, aLastPoint.maStyleName ); + // initialize so that it doesn't matter if + // the element is counted in the first iteration + aLastPoint.mnRepeat = 0; - if( aLastPoint.mnRepeat > 1 ) - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_REPEATED, - OUString::number( ( aLastPoint.mnRepeat ) )); + for( ; aIter != aDataPointList.end(); ++aIter ) + { + aPoint = (*aIter); - SvXMLElementExport aPointElem( mrExport, XML_NAMESPACE_CHART, XML_DATA_POINT, true, true ); - } - aLastPoint = aPoint; - } - // write last element if it hasn't been written in last iteration - if( aPoint.maStyleName == aLastPoint.maStyleName ) - { - if( !aLastPoint.maStyleName.isEmpty() ) - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_STYLE_NAME, aLastPoint.maStyleName ); + if( aPoint.maStyleName == aLastPoint.maStyleName ) + aPoint.mnRepeat += aLastPoint.mnRepeat; + else if( aLastPoint.mnRepeat > 0 ) + { + // write last element + if( !aLastPoint.maStyleName.isEmpty() ) + mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_STYLE_NAME, aLastPoint.maStyleName ); - if( aLastPoint.mnRepeat > 1 ) - mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_REPEATED, - OUString::number( ( aLastPoint.mnRepeat ) )); + if( aLastPoint.mnRepeat > 1 ) + mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_REPEATED, + OUString::number( ( aLastPoint.mnRepeat ) )); - SvXMLElementExport aPointElem( mrExport, XML_NAMESPACE_CHART, XML_DATA_POINT, true, true ); - } + SvXMLElementExport aPointElem( mrExport, XML_NAMESPACE_CHART, XML_DATA_POINT, true, true ); } + aLastPoint = aPoint; + } + // write last element if it hasn't been written in last iteration + if( aPoint.maStyleName == aLastPoint.maStyleName ) + { + if( !aLastPoint.maStyleName.isEmpty() ) + mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_STYLE_NAME, aLastPoint.maStyleName ); + + if( aLastPoint.mnRepeat > 1 ) + mrExport.AddAttribute( XML_NAMESPACE_CHART, XML_REPEATED, + OUString::number( ( aLastPoint.mnRepeat ) )); + + SvXMLElementExport aPointElem( mrExport, XML_NAMESPACE_CHART, XML_DATA_POINT, true, true ); } } |