[Libreoffice-commits] .: 4 commits - sc/inc sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Fri Mar 16 06:37:12 PDT 2012


 sc/inc/dpcache.hxx                   |    2 -
 sc/source/core/data/dpcache.cxx      |   44 +++--------------------------------
 sc/source/core/data/dpcachetable.cxx |   17 +++----------
 3 files changed, 9 insertions(+), 54 deletions(-)

New commits:
commit 357059019541c36e5eb0bc3c98d5ed2f12d41371
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Mar 16 09:35:40 2012 -0400

    Prevent out-of-bound array access.
    
    Source range may not start from column 0.

diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx
index 111170c..3e5b433 100644
--- a/sc/source/core/data/dpcache.cxx
+++ b/sc/source/core/data/dpcache.cxx
@@ -370,7 +370,7 @@ bool ScDPCache::InitFromDoc(ScDocument* pDoc, const ScRange& rRange)
     for (sal_uInt16 nCol = nStartCol; nCol <= nEndCol; ++nCol)
     {
         AddLabel(createLabelString(pDoc, nCol, nStartRow, nDocTab));
-        Field& rField = maFields[nCol];
+        Field& rField = maFields[nCol-nStartCol];
         std::vector<Bucket> aBuckets;
         aBuckets.reserve(nEndRow-nStartRow); // skip the topmost label cell.
 
commit b41cf4c6153e9c4f7f56d0441a649664ffd4c7c2
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Mar 16 00:00:59 2012 -0400

    We shouldn't skip empty columns, or else column index becomes out of sync.

diff --git a/sc/source/core/data/dpcachetable.cxx b/sc/source/core/data/dpcachetable.cxx
index 4b7338f..dc7a63a 100644
--- a/sc/source/core/data/dpcachetable.cxx
+++ b/sc/source/core/data/dpcachetable.cxx
@@ -161,6 +161,7 @@ void ScDPCacheTable::fillTable(
     // Data rows
     for (SCCOL nCol = 0; nCol < nColCount; ++nCol)
     {
+        maFieldEntries.push_back( vector<SCROW>() );
         SCROW nMemCount = getCache()->GetDimMemberCount( nCol );
         if ( nMemCount )
         {
@@ -188,7 +189,6 @@ void ScDPCacheTable::fillTable(
 
                 aAdded[nOrder] = nIndex;
             }
-            maFieldEntries.push_back( vector<SCROW>() );
             for ( SCROW nRow = 0; nRow < nMemCount; nRow++ )
             {
                 if ( aAdded[nRow] != -1 )
@@ -216,6 +216,7 @@ void ScDPCacheTable::fillTable()
     // Data rows
     for (SCCOL nCol = 0; nCol < nColCount; ++nCol)
     {
+        maFieldEntries.push_back( vector<SCROW>() );
         SCROW nMemCount = getCache()->GetDimMemberCount( nCol );
         if ( nMemCount )
         {
@@ -234,7 +235,6 @@ void ScDPCacheTable::fillTable()
 
                 pAdded[nOrder] = nIndex;
             }
-            maFieldEntries.push_back( vector<SCROW>() );
             for ( SCROW nRow = 0; nRow < nMemCount; nRow++ )
             {
                 if ( pAdded[nRow] != -1 )
commit 9776cc1503690e4ccb0dd1d8d6cf6c35d5c8f01d
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu Mar 15 23:40:12 2012 -0400

    Check all this in one place i.e. in ValidQuery().

diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx
index 40ca039..111170c 100644
--- a/sc/source/core/data/dpcache.cxx
+++ b/sc/source/core/data/dpcache.cxx
@@ -471,8 +471,12 @@ bool ScDPCache::InitFromDataBase (const Reference<sdbc::XRowSet>& xRowSet, const
 
 bool ScDPCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam) const
 {
+    if (!rParam.GetEntryCount())
+        return true;
+
     if (!rParam.GetEntry(0).bDoQuery)
         return true;
+
     bool bMatchWholeCell = mpDoc->GetDocOptions().IsMatchWholeCell();
 
     SCSIZE nEntryCount = rParam.GetEntryCount();
diff --git a/sc/source/core/data/dpcachetable.cxx b/sc/source/core/data/dpcachetable.cxx
index c32d079..4b7338f 100644
--- a/sc/source/core/data/dpcachetable.cxx
+++ b/sc/source/core/data/dpcachetable.cxx
@@ -64,15 +64,6 @@ using ::com::sun::star::uno::UNO_QUERY;
 using ::com::sun::star::uno::UNO_QUERY_THROW;
 using ::com::sun::star::sheet::DataPilotFieldFilter;
 
-
-static sal_Bool lcl_HasQueryEntry( const ScQueryParam& rParam )
-{
-    return rParam.GetEntryCount() > 0 &&
-            rParam.GetEntry(0).bDoQuery;
-}
-
-// ----------------------------------------------------------------------------
-
 bool ScDPCacheTable::RowFlag::isActive() const
 {
     return mbShowByFilter && mbShowByPage;
@@ -186,9 +177,9 @@ void ScDPCacheTable::fillTable(
                     maRowFlags.back().mbShowByFilter = false;
                 }
 
-                if ( lcl_HasQueryEntry(rQuery) &&
-                    !getCache()->ValidQuery(nRow , rQuery) )
+                if (!getCache()->ValidQuery(nRow, rQuery))
                     continue;
+
                 if ( bIgnoreEmptyRows &&  getCache()->IsRowEmpty( nRow ) )
                     continue;
 
commit efdb67ca924dc0072c6984a68c9b97db260464b6
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu Mar 15 23:32:34 2012 -0400

    We don't ever compare equality of two caches.
    
    That'd be super-expensive anyway.

diff --git a/sc/inc/dpcache.hxx b/sc/inc/dpcache.hxx
index 1e26688..bd2fa5a 100644
--- a/sc/inc/dpcache.hxx
+++ b/sc/inc/dpcache.hxx
@@ -152,8 +152,6 @@ public:
 
     const ScDPItemData* GetItemDataById( long nDim, SCROW nId ) const;
 
-    bool operator== ( const ScDPCache& r ) const;
-
     ScDPCache(ScDocument* pDoc);
     ~ScDPCache();
 
diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx
index 928e511..40ca039 100644
--- a/sc/source/core/data/dpcache.cxx
+++ b/sc/source/core/data/dpcache.cxx
@@ -67,44 +67,6 @@ ScDPCache::GroupItems::GroupItems() {}
 ScDPCache::GroupItems::GroupItems(const ScDPNumGroupInfo& rInfo) :
     maInfo(rInfo) {}
 
-bool ScDPCache::operator== ( const ScDPCache& r ) const
-{
-    if ( GetColumnCount() == r.GetColumnCount() )
-    {
-        for ( SCCOL i = 0 ; i < GetColumnCount(); i++ )
-        {   //check dim names
-            if ( GetDimensionName( i ) != r.GetDimensionName( i ) )
-                return false;
-            //check rows count
-            if ( GetRowCount() != r.GetRowCount() )
-                return false;
-            //check dim member values
-            size_t nMembersCount = GetDimMemberValues( i ).size();
-            if ( GetDimMemberValues( i ).size() == r. GetDimMemberValues( i ).size() )
-            {
-                for ( size_t j = 0; j < nMembersCount; j++ )
-                {
-                    if (GetDimMemberValues(i)[j] == r.GetDimMemberValues(i)[j])
-                        continue;
-                    else
-                        return false;
-                }
-            }
-            else
-                return false;
-            //check source table index
-            for ( SCROW k=0 ; k < GetRowCount(); k ++ )
-            {
-                if ( GetItemDataId( i, k, false ) == r.GetItemDataId( i,k,false) )
-                    continue;
-                else
-                    return false;
-            }
-        }
-    }
-    return true;
-}
-
 ScDPCache::Field::Field() : mnNumFormat(0) {}
 
 ScDPCache::ScDPCache(ScDocument* pDoc) :


More information about the Libreoffice-commits mailing list