[Libreoffice-commits] core.git: 2 commits - xmloff/source

Kohei Yoshida kohei.yoshida at collabora.com
Fri Jul 25 20:03:02 PDT 2014


 xmloff/source/chart/SchXMLExport.cxx |  341 +++++++++++++++++------------------
 1 file changed, 169 insertions(+), 172 deletions(-)

New commits:
commit fed7294029f07ff407765b568266084d9e8d365c
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Jul 25 23:03:17 2014 -0400

    Simplify.
    
    Change-Id: Id7826839a6177532bb4c3885e798ac5feb95eaca

diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index 84958d8..9652641 100644
--- a/xmloff/source/chart/SchXMLExport.cxx
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -3301,11 +3301,8 @@ void SchXMLExportHelper_Impl::exportDataPoints(
     Sequence< sal_Int32 > aDataPointSeq;
     if( xSeriesProperties.is())
     {
-        Any aAny = xSeriesProperties->getPropertyValue(
-            OUString(  "AttributedDataPoints" ));
-        aAny >>= aDataPointSeq;
-        xSeriesProperties->getPropertyValue(
-            OUString(  "VaryColorsByPoint" )) >>= bVaryColorsByPoint;
+        xSeriesProperties->getPropertyValue("AttributedDataPoints") >>= aDataPointSeq;
+        xSeriesProperties->getPropertyValue("VaryColorsByPoint") >>= bVaryColorsByPoint;
     }
 
     sal_Int32 nSize = aDataPointSeq.getLength();
commit f350a71df9ca631c21cf6d2c981ddc717737c76f
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Jul 25 20:46:52 2014 -0400

    Reduce scope levels.
    
    Change-Id: I64684a80c79c3c7f5a8f23b07703fbcee3fe5887

diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index fc52354..84958d8 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 );
     }
 }
 


More information about the Libreoffice-commits mailing list