[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/source

Kohei Yoshida kohei.yoshida at gmail.com
Mon Apr 29 14:14:28 PDT 2013


 sc/inc/column.hxx                   |    6 +++++-
 sc/inc/document.hxx                 |    6 +++++-
 sc/inc/formulagroup.hxx             |   30 ++++++++++++++++++++++++++++++
 sc/inc/table.hxx                    |    7 ++++++-
 sc/source/core/data/column2.cxx     |    5 ++++-
 sc/source/core/data/document.cxx    |    5 +++--
 sc/source/core/data/formulacell.cxx |    5 ++++-
 sc/source/core/data/table1.cxx      |    5 +++--
 8 files changed, 60 insertions(+), 9 deletions(-)

New commits:
commit 7baf318bf56c8093fdbdeb4d54f56cbe9cadc81c
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Apr 29 17:15:32 2013 -0400

    Pass formula group context to FetchDoubleArray. Not yet used.
    
    In the future I'll use it to store temporary double array buffer here,
    in case the requested row span is over multiple arrays.
    
    Change-Id: Id4260ec4ced4c8c1ee718106f37a7374c62b204c

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 9b6e614..e70f108 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -45,6 +45,10 @@
 
 namespace editeng { class SvxBorderLine; }
 
+namespace sc {
+    struct FormulaGroupContext;
+}
+
 class Fraction;
 class OutputDevice;
 class SfxItemPoolCache;
@@ -460,7 +464,7 @@ public:
     ScFormulaVectorState GetFormulaVectorState( SCROW nRow ) const;
     formula::FormulaTokenRef ResolveStaticReference( SCROW nRow );
     bool ResolveStaticReference( ScMatrix& rMat, SCCOL nMatCol, SCROW nRow1, SCROW nRow2 );
-    const double* FetchDoubleArray( SCROW nRow1, SCROW nRow2 ) const;
+    const double* FetchDoubleArray( sc::FormulaGroupContext& rCxt, SCROW nRow1, SCROW nRow2 ) const;
 
     ScRefCellValue GetRefCellValue( SCROW );
 
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 876c9d7..0920dd5e 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -47,6 +47,9 @@
 #include <boost/scoped_ptr.hpp>
 
 namespace editeng { class SvxBorderLine; }
+namespace sc {
+    struct FormulaGroupContext;
+}
 class SvxFontItem;
 
 class KeyEvent;
@@ -1944,7 +1947,8 @@ public:
     formula::FormulaTokenRef ResolveStaticReference( const ScAddress& rPos );
     formula::FormulaTokenRef ResolveStaticReference( const ScRange& rRange );
 
-    const double* FetchDoubleArray( const ScAddress& rPos, SCROW nLength ) const;
+    const double* FetchDoubleArray(
+        sc::FormulaGroupContext& rCxt, const ScAddress& rPos, SCROW nLength ) const;
 
 private: // CLOOK-Impl-methods
 
diff --git a/sc/inc/formulagroup.hxx b/sc/inc/formulagroup.hxx
new file mode 100644
index 0000000..0a8e3f7
--- /dev/null
+++ b/sc/inc/formulagroup.hxx
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef SC_FORMULAGROUP_HXX
+#define SC_FORMULAGROUP_HXX
+
+#include <boost/noncopyable.hpp>
+#include <boost/ptr_container/ptr_vector.hpp>
+
+namespace sc {
+
+struct FormulaGroupContext : boost::noncopyable
+{
+    typedef std::vector<double> DoubleArrayType;
+    typedef boost::ptr_vector<DoubleArrayType> ArrayStoreType;
+
+    ArrayStoreType maArrays;
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 7c45a57..c090f8b 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -47,6 +47,10 @@ namespace com { namespace sun { namespace star {
     }
 } } }
 
+namespace sc {
+    struct FormulaGroupContext;
+}
+
 class SfxItemSet;
 class SfxStyleSheetBase;
 class SvxBoxInfoItem;
@@ -822,7 +826,8 @@ public:
     ScFormulaVectorState GetFormulaVectorState( SCCOL nCol, SCROW nRow ) const;
     formula::FormulaTokenRef ResolveStaticReference( SCCOL nCol, SCROW nRow );
     formula::FormulaTokenRef ResolveStaticReference( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
-    const double* FetchDoubleArray( SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
+    const double* FetchDoubleArray(
+        sc::FormulaGroupContext& rCxt, SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const;
 
     ScRefCellValue GetRefCellValue( SCCOL nCol, SCROW nRow );
 
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 434edad..2e20d0f 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -57,6 +57,7 @@
 #include "cellvalue.hxx"
 #include "tokenarray.hxx"
 #include "globalnames.hxx"
+#include "formulagroup.hxx"
 
 #include <math.h>
 
@@ -1661,8 +1662,10 @@ bool ScColumn::ResolveStaticReference( ScMatrix& rMat, SCCOL nMatCol, SCROW nRow
     return true;
 }
 
-const double* ScColumn::FetchDoubleArray( SCROW nRow1, SCROW nRow2 ) const
+const double* ScColumn::FetchDoubleArray( sc::FormulaGroupContext& /*rCxt*/, SCROW nRow1, SCROW nRow2 ) const
 {
+    // TODO: I'll use the context object later.
+
     if (nRow1 > nRow2)
         return NULL;
 
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index c4f93c6..3a07d3f 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1593,13 +1593,14 @@ formula::FormulaTokenRef ScDocument::ResolveStaticReference( const ScRange& rRan
         rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row());
 }
 
-const double* ScDocument::FetchDoubleArray( const ScAddress& rPos, SCROW nLength ) const
+const double* ScDocument::FetchDoubleArray(
+    sc::FormulaGroupContext& rCxt, const ScAddress& rPos, SCROW nLength ) const
 {
     SCTAB nTab = rPos.Tab();
     if (!TableExists(nTab))
         return NULL;
 
-    return maTabs[nTab]->FetchDoubleArray(rPos.Col(), rPos.Row(), rPos.Row()+nLength-1);
+    return maTabs[nTab]->FetchDoubleArray(rCxt, rPos.Col(), rPos.Row(), rPos.Row()+nLength-1);
 }
 
 bool ScDocument::CanFitBlock( const ScRange& rOld, const ScRange& rNew )
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 278a299..236474d 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -43,6 +43,7 @@
 #include "formula/vectortoken.hxx"
 #include "svl/intitem.hxx"
 #include "rtl/strbuf.hxx"
+#include "formulagroup.hxx"
 
 #include <boost/bind.hpp>
 
@@ -2968,6 +2969,8 @@ bool ScFormulaCell::InterpretFormulaGroup()
     if (xGroup->mbInvariant)
         return InterpretInvariantFormulaGroup();
 
+    sc::FormulaGroupContext aCxt;
+
     ScTokenArray aCode;
     pCode->Reset();
     for (const formula::FormulaToken* p = pCode->First(); p; p = pCode->Next())
@@ -2990,7 +2993,7 @@ bool ScFormulaCell::InterpretFormulaGroup()
                     // Fetch double array guarantees that the length of the
                     // returned array equals or greater than the requested
                     // length.
-                    const double* pArray = pDocument->FetchDoubleArray(aRefPos, xGroup->mnLength);
+                    const double* pArray = pDocument->FetchDoubleArray(aCxt, aRefPos, xGroup->mnLength);
                     if (!pArray)
                         return false;
 
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index a6c60425..34be0d1 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -2140,7 +2140,8 @@ formula::FormulaTokenRef ScTable::ResolveStaticReference( SCCOL nCol1, SCROW nRo
     return formula::FormulaTokenRef(new ScMatrixToken(pMat));
 }
 
-const double* ScTable::FetchDoubleArray( SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const
+const double* ScTable::FetchDoubleArray(
+    sc::FormulaGroupContext& rCxt, SCCOL nCol, SCROW nRow1, SCROW nRow2 ) const
 {
     if (nRow2 < nRow1)
         return NULL;
@@ -2148,7 +2149,7 @@ const double* ScTable::FetchDoubleArray( SCCOL nCol, SCROW nRow1, SCROW nRow2 )
     if (!ValidCol(nCol) || !ValidRow(nRow1) || !ValidRow(nRow2))
         return NULL;
 
-    return aCol[nCol].FetchDoubleArray(nRow1, nRow1);
+    return aCol[nCol].FetchDoubleArray(rCxt, nRow1, nRow1);
 }
 
 ScRefCellValue ScTable::GetRefCellValue( SCCOL nCol, SCROW nRow )


More information about the Libreoffice-commits mailing list