incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l...@apache.org
Subject svn commit: r1388440 - /incubator/ooo/trunk/main/sc/source/ui/unoobj/chart2uno.cxx
Date Fri, 21 Sep 2012 11:43:27 GMT
Author: leiw
Date: Fri Sep 21 11:43:27 2012
New Revision: 1388440

URL: http://svn.apache.org/viewvc?rev=1388440&view=rev
Log:
#i121058 To open a sample file contains chart with large data source can lead to AOO crash

          Patch by: Clarence GUO
          Review by: Wang Lei

Modified:
    incubator/ooo/trunk/main/sc/source/ui/unoobj/chart2uno.cxx

Modified: incubator/ooo/trunk/main/sc/source/ui/unoobj/chart2uno.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/ui/unoobj/chart2uno.cxx?rev=1388440&r1=1388439&r2=1388440&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/ui/unoobj/chart2uno.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/ui/unoobj/chart2uno.cxx Fri Sep 21 11:43:27 2012
@@ -3009,12 +3009,51 @@ uno::Sequence< double > SAL_CALL ScChart
     ::rtl::math::setNan(&fNAN);
 
     sal_Int32 nCount = m_aDataArray.size();
-    uno::Sequence<double> aSeq(nCount);
+    // i121058: if there's too many points need to be painted, it doens't need to get all
points for performance consideration
+    // and so many points are not useful for users to understand the chart. So only picked
some points to paint
+    sal_Int32 nStep = nCount >= 10000 ? 50 : 1;
+    nCount = nCount >= 10000 ? ((nCount - nCount % nStep) / nStep) : nCount;
+    sal_Int32 nRealCount = nStep == 1 ? nCount : nCount * 2;
+    uno::Sequence<double> aSeq(nRealCount);
     double* pArr = aSeq.getArray();
     ::std::list<Item>::const_iterator itr = m_aDataArray.begin(), itrEnd = m_aDataArray.end();
-    for (; itr != itrEnd; ++itr, ++pArr)
-        *pArr = itr->mbIsValue ? itr->mfValue : fNAN;
-
+    for (sal_Int32 i = 0; i < nCount; i++)
+    {
+        if (nStep == 1)
+        {
+            *pArr++ = itr->mbIsValue ? itr->mfValue : fNAN;
+            itr++;
+        }
+        else
+        {
+            sal_Int32 nMax = 0, nMin = 0, nMaxStep = 0, nMinStep = 0;
+            for (sal_Int32 j = 0; j < nStep; j++)
+            {
+                sal_Int32 nValue = itr->mbIsValue ? itr->mfValue : fNAN;
+                if (nValue > nMax)
+                {
+                    nMax = nValue;
+                    nMaxStep = j;
+                }
+                if (nValue < nMin)
+                {
+                    nMin = nValue;
+                    nMinStep = j;
+                }
+                itr++;
+            }
+            if (nMaxStep > nMinStep)
+            {
+                *pArr++ = nMin;
+                *pArr++ = nMax;
+            }
+            else
+            {
+                *pArr++ = nMax;
+                *pArr++ = nMin;
+            }
+        }
+    }
     return aSeq;
 }
 



Mime
View raw message