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

Kohei Yoshida kohei.yoshida at gmail.com
Mon Mar 18 20:13:28 PDT 2013


 sc/Library_sc.mk                                  |    1 
 sc/inc/bigrange.hxx                               |   20 +-------------
 sc/inc/cell.hxx                                   |    2 +
 sc/inc/chgtrack.hxx                               |    3 +-
 sc/inc/column.hxx                                 |    5 +++
 sc/inc/document.hxx                               |    2 +
 sc/inc/table.hxx                                  |    3 ++
 sc/inc/tokenarray.hxx                             |   12 ++------
 sc/inc/types.hxx                                  |   13 +++++++++
 sc/qa/unit/helper/debughelper.hxx                 |    1 
 sc/qa/unit/ucalc.cxx                              |   12 ++++----
 sc/source/core/data/bigrange.cxx                  |   30 ++++++++++++++++++++++
 sc/source/core/data/cell.cxx                      |    5 +++
 sc/source/core/data/column2.cxx                   |   20 +++++++++++---
 sc/source/core/data/document.cxx                  |    9 ++++++
 sc/source/core/data/table1.cxx                    |    8 +++++
 sc/source/core/inc/interpre.hxx                   |    4 --
 sc/source/core/tool/chgviset.cxx                  |    1 
 sc/source/core/tool/interpr4.cxx                  |    4 ++
 sc/source/core/tool/token.cxx                     |   15 +++++++----
 sc/source/filter/inc/biff.hxx                     |    1 
 sc/source/filter/inc/qpro.hxx                     |    3 +-
 sc/source/filter/inc/qprostyle.hxx                |    4 ++
 sc/source/filter/xcl97/XclExpChangeTrack.cxx      |    1 
 sc/source/filter/xcl97/XclImpChangeTrack.cxx      |    1 
 sc/source/filter/xml/XMLTrackedChangesContext.cxx |    1 
 sc/source/ui/condformat/condformatmgr.cxx         |    1 
 sc/source/ui/inc/condformatmgr.hxx                |    1 
 sc/source/ui/view/viewutil.cxx                    |    1 
 29 files changed, 134 insertions(+), 50 deletions(-)

New commits:
commit 9b1f4267746ab3a3290d55c5a1e9c06af0350b56
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Mar 18 23:15:26 2013 -0400

    Reduce dependency on document.hxx. Prefer forward declaration.
    
    Change-Id: I9b0c86735284ec435cceb3acd9bad97a6e523a74

diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 066e0b6..48ebfd2 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -98,6 +98,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
 	sc/source/core/data/attrib \
 	sc/source/core/data/autonamecache \
 	sc/source/core/data/bcaslot \
+	sc/source/core/data/bigrange \
 	sc/source/core/data/cell \
 	sc/source/core/data/cell2 \
 	sc/source/core/data/clipparam \
diff --git a/sc/inc/bigrange.hxx b/sc/inc/bigrange.hxx
index 09aaf3b..d36fa9a 100644
--- a/sc/inc/bigrange.hxx
+++ b/sc/inc/bigrange.hxx
@@ -20,14 +20,12 @@
 #ifndef SC_BIGRANGE_HXX
 #define SC_BIGRANGE_HXX
 
-
 #include "global.hxx"
-#include "document.hxx"
-
 
 static const sal_Int32 nInt32Min = 0x80000000;
 static const sal_Int32 nInt32Max = 0x7fffffff;
 
+class ScDocument;
 
 class ScBigAddress
 {
@@ -61,7 +59,7 @@ public:
                 { nColP = nCol; nRowP = nRow; nTabP = nTab; }
 
     inline void     PutInOrder( ScBigAddress& r );
-    inline sal_Bool     IsValid( const ScDocument* ) const;
+    bool IsValid( const ScDocument* pDoc ) const;
     inline ScAddress    MakeAddress() const;
 
     ScBigAddress&   operator=( const ScBigAddress& r )
@@ -101,20 +99,6 @@ inline void ScBigAddress::PutInOrder( ScBigAddress& r )
     }
 }
 
-
-inline sal_Bool ScBigAddress::IsValid( const ScDocument* pDoc ) const
-{   // min/max interval bounds define whole col/row/tab
-    return
-        ((0 <= nCol && nCol <= MAXCOL)
-            || nCol == nInt32Min || nCol == nInt32Max) &&
-        ((0 <= nRow && nRow <= MAXROW)
-            || nRow == nInt32Min || nRow == nInt32Max) &&
-        ((0 <= nTab && nTab < pDoc->GetTableCount())
-            || nTab == nInt32Min || nTab == nInt32Max)
-        ;
-}
-
-
 inline ScAddress ScBigAddress::MakeAddress() const
 {
     SCCOL nColA;
diff --git a/sc/inc/chgtrack.hxx b/sc/inc/chgtrack.hxx
index 4c94932..c4c22a9 100644
--- a/sc/inc/chgtrack.hxx
+++ b/sc/inc/chgtrack.hxx
@@ -27,6 +27,7 @@
 
 #include <tools/datetime.hxx>
 #include <tools/mempool.hxx>
+#include "tools/link.hxx"
 #include <unotools/options.hxx>
 #include "global.hxx"
 #include "bigrange.hxx"
@@ -39,7 +40,7 @@
 
 class ScBaseCell;
 class ScDocument;
-
+class ScFormulaCell;
 
 enum ScChangeActionType
 {
diff --git a/sc/qa/unit/helper/debughelper.hxx b/sc/qa/unit/helper/debughelper.hxx
index 2a560c6..4de5c9d 100644
--- a/sc/qa/unit/helper/debughelper.hxx
+++ b/sc/qa/unit/helper/debughelper.hxx
@@ -36,7 +36,6 @@
 
 #include <rtl/strbuf.hxx>
 #include <rtl/ustring.hxx>
-#include "document.hxx"
 
 #ifdef WNT
 #if !defined NOMINMAX
diff --git a/sc/source/core/data/bigrange.cxx b/sc/source/core/data/bigrange.cxx
new file mode 100644
index 0000000..a48e020
--- /dev/null
+++ b/sc/source/core/data/bigrange.cxx
@@ -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_BIGRANGE_CXX__
+#define __SC_BIGRANGE_CXX__
+
+#include "bigrange.hxx"
+#include "document.hxx"
+
+bool ScBigAddress::IsValid( const ScDocument* pDoc ) const
+{   // min/max interval bounds define whole col/row/tab
+    return
+        ((0 <= nCol && nCol <= MAXCOL)
+            || nCol == nInt32Min || nCol == nInt32Max) &&
+        ((0 <= nRow && nRow <= MAXROW)
+            || nRow == nInt32Min || nRow == nInt32Max) &&
+        ((0 <= nTab && nTab < pDoc->GetTableCount())
+            || nTab == nInt32Min || nTab == nInt32Max)
+        ;
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 16eb22c..906f4d6 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -26,7 +26,6 @@
 #include "formula/errorcodes.hxx"
 #include "formula/tokenarray.hxx"
 #include "scdll.hxx"
-#include "document.hxx"
 #include "scmatrix.hxx"
 #include "externalrefmgr.hxx"
 #include "calcconfig.hxx"
@@ -189,8 +188,7 @@ double ConvertStringToValue( const String& );
 double GetCellValue( const ScAddress&, const ScBaseCell* );
 double GetCellValueOrZero( const ScAddress&, const ScBaseCell* );
 double GetValueCellValue( const ScAddress&, const ScValueCell* );
-ScBaseCell* GetCell( const ScAddress& rPos )
-    { return pDok->GetCell( rPos ); }
+ScBaseCell* GetCell( const ScAddress& rPos );
 void GetCellString( String& rStr, const ScBaseCell* pCell );
 sal_uInt16 GetCellErrCode( const ScBaseCell* pCell );
 CellType GetCellType( const ScBaseCell* pCell );
diff --git a/sc/source/core/tool/chgviset.cxx b/sc/source/core/tool/chgviset.cxx
index 1f8547f..2a63d4c 100644
--- a/sc/source/core/tool/chgviset.cxx
+++ b/sc/source/core/tool/chgviset.cxx
@@ -22,6 +22,7 @@
 #include "chgviset.hxx"
 #include "rechead.hxx"
 #include "chgtrack.hxx"
+#include "document.hxx"
 
 // -----------------------------------------------------------------------
 ScChangeViewSettings::~ScChangeViewSettings()
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 30e845f..a2f3e6b 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -545,6 +545,10 @@ double ScInterpreter::GetCellValueOrZero( const ScAddress& rPos, const ScBaseCel
     return fValue;
 }
 
+ScBaseCell* ScInterpreter::GetCell( const ScAddress& rPos )
+{
+    return pDok->GetCell( rPos );
+}
 
 void ScInterpreter::GetCellString( String& rStr, const ScBaseCell* pCell )
 {
diff --git a/sc/source/filter/inc/biff.hxx b/sc/source/filter/inc/biff.hxx
index 89ceb72..ed739df 100644
--- a/sc/source/filter/inc/biff.hxx
+++ b/sc/source/filter/inc/biff.hxx
@@ -23,7 +23,6 @@
 
 #include <sal/config.h>
 #include "filter.hxx"
-#include "document.hxx"
 
 #include "flttypes.hxx"
 #include "ftools.hxx"
diff --git a/sc/source/filter/inc/qpro.hxx b/sc/source/filter/inc/qpro.hxx
index 5133952..4e6d376 100644
--- a/sc/source/filter/inc/qpro.hxx
+++ b/sc/source/filter/inc/qpro.hxx
@@ -22,7 +22,6 @@
 
 #include <sal/config.h>
 #include "filter.hxx"
-#include "document.hxx"
 #include <tools/string.hxx>
 
 #include "flttypes.hxx"
@@ -30,6 +29,8 @@
 #include "qprostyle.hxx"
 #include "biff.hxx"
 
+class ScDocument;
+
 // Stream wrapper class
 class ScQProReader : public ScBiffReader
 {
diff --git a/sc/source/filter/inc/qprostyle.hxx b/sc/source/filter/inc/qprostyle.hxx
index 482687c..145d146 100644
--- a/sc/source/filter/inc/qprostyle.hxx
+++ b/sc/source/filter/inc/qprostyle.hxx
@@ -23,11 +23,13 @@
 
 #include <sal/config.h>
 #include "filter.hxx"
-#include "document.hxx"
 #include <tools/string.hxx>
 
 #include "flttypes.hxx"
 #include "ftools.hxx"
+#include "address.hxx"
+
+class ScDocument;
 
 class ScQProStyle
 {
diff --git a/sc/source/filter/xcl97/XclExpChangeTrack.cxx b/sc/source/filter/xcl97/XclExpChangeTrack.cxx
index 1c50a5c..f16483b 100644
--- a/sc/source/filter/xcl97/XclExpChangeTrack.cxx
+++ b/sc/source/filter/xcl97/XclExpChangeTrack.cxx
@@ -27,6 +27,7 @@
 #include "xeformula.hxx"
 #include "cell.hxx"
 #include "xcl97rec.hxx"
+#include "document.hxx"
 
 #include <oox/token/tokens.hxx>
 #include <rtl/strbuf.hxx>
diff --git a/sc/source/filter/xcl97/XclImpChangeTrack.cxx b/sc/source/filter/xcl97/XclImpChangeTrack.cxx
index 040b005..e3e31a6 100644
--- a/sc/source/filter/xcl97/XclImpChangeTrack.cxx
+++ b/sc/source/filter/xcl97/XclImpChangeTrack.cxx
@@ -27,6 +27,7 @@
 #include "xihelper.hxx"
 #include "xilink.hxx"
 #include "externalrefmgr.hxx"
+#include "document.hxx"
 
 //___________________________________________________________________
 // class XclImpChangeTrack
diff --git a/sc/source/filter/xml/XMLTrackedChangesContext.cxx b/sc/source/filter/xml/XMLTrackedChangesContext.cxx
index eea74ac..d3b67dd 100644
--- a/sc/source/filter/xml/XMLTrackedChangesContext.cxx
+++ b/sc/source/filter/xml/XMLTrackedChangesContext.cxx
@@ -25,6 +25,7 @@
 #include "cell.hxx"
 #include "textuno.hxx"
 #include "editutil.hxx"
+#include "document.hxx"
 #include <xmloff/xmltoken.hxx>
 #include <xmloff/xmlnmspe.hxx>
 #include <xmloff/nmspmap.hxx>
diff --git a/sc/source/ui/condformat/condformatmgr.cxx b/sc/source/ui/condformat/condformatmgr.cxx
index 977cc36..a18a0ca 100644
--- a/sc/source/ui/condformat/condformatmgr.cxx
+++ b/sc/source/ui/condformat/condformatmgr.cxx
@@ -32,6 +32,7 @@
 #include "globstr.hrc"
 #include "condformatdlg.hxx"
 #include "vcl/msgbox.hxx"
+#include "document.hxx"
 
 #define ITEMID_RANGE 1
 #define ITEMID_CONDITION 2
diff --git a/sc/source/ui/inc/condformatmgr.hxx b/sc/source/ui/inc/condformatmgr.hxx
index d3c9099..be73652 100644
--- a/sc/source/ui/inc/condformatmgr.hxx
+++ b/sc/source/ui/inc/condformatmgr.hxx
@@ -35,7 +35,6 @@
 #include <svtools/headbar.hxx>
 
 #include "conditio.hxx"
-#include "document.hxx"
 
 #include <map>
 
diff --git a/sc/source/ui/view/viewutil.cxx b/sc/source/ui/view/viewutil.cxx
index d24d080..9aa5068 100644
--- a/sc/source/ui/view/viewutil.cxx
+++ b/sc/source/ui/view/viewutil.cxx
@@ -44,6 +44,7 @@
 #include "chgtrack.hxx"
 #include "chgviset.hxx"
 #include "markdata.hxx"
+#include "document.hxx"
 
 #include <svx/svxdlg.hxx>
 #include <svx/dialogs.hrc>
commit 348727939dfa40ea873204f495585dad1173cd31
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Mar 18 22:55:26 2013 -0400

    Add accessor to ScDocument for formula cell's vectorization state.
    
    Change-Id: I3c781764c6375dadb173bc5ab3cfb79857e2aeca

diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index 944c8dc..a096c37 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -429,6 +429,8 @@ public:
 
     size_t GetHash() const;
 
+    ScFormulaVectorState GetVectorState() const;
+
     void            GetFormula( rtl::OUString& rFormula,
                                 const formula::FormulaGrammar::Grammar = formula::FormulaGrammar::GRAM_DEFAULT ) const;
     void            GetFormula( rtl::OUStringBuffer& rBuffer,
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 8147c06..18543f0 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -24,6 +24,7 @@
 #include "global.hxx"
 #include "address.hxx"
 #include "rangenam.hxx"
+#include "types.hxx"
 
 #include <set>
 #include <vector>
@@ -410,7 +411,11 @@ public:
 
     size_t GetFormulaHash( SCROW nRow ) const;
 
+    ScFormulaVectorState GetFormulaVectorState( SCROW nRow ) const;
+
 private:
+    const ScFormulaCell* FetchFormulaCell( SCROW nRow ) const;
+
     ScBaseCell* CloneCell(SCSIZE nIndex, sal_uInt16 nFlags, ScDocument& rDestDoc, const ScAddress& rDestPos) const;
 
     SCROW FindNextVisibleRowWithContent(SCROW nRow, bool bForward) const;
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 7d23b89..98b21eb 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1856,6 +1856,8 @@ public:
 
     size_t GetFormulaHash( const ScAddress& rPos ) const;
 
+    ScFormulaVectorState GetFormulaVectorState( const ScAddress& rPos ) const;
+
 private: // CLOOK-Impl-methods
 
     /**
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 2e8b697..036dcca 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -29,6 +29,7 @@
 #include "sortparam.hxx"
 #include "compressedarray.hxx"
 #include "postit.hxx"
+#include "types.hxx"
 
 #include <set>
 #include <map>
@@ -798,6 +799,8 @@ public:
 
     size_t GetFormulaHash( SCCOL nCol, SCROW nRow ) const;
 
+    ScFormulaVectorState GetFormulaVectorState( SCCOL nCol, SCROW nRow ) const;
+
 private:
     void        FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
                                 sal_uLong nFillCount, FillDir eFillDir, FillCmd eFillCmd,
diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index 5c09d28..2449074 100644
--- a/sc/inc/tokenarray.hxx
+++ b/sc/inc/tokenarray.hxx
@@ -24,6 +24,7 @@
 #include "scmatrix.hxx"
 #include <tools/solar.h>
 #include "scdllapi.h"
+#include "types.hxx"
 #include <formula/tokenarray.hxx>
 
 struct ScRawToken;
@@ -34,17 +35,10 @@ class SC_DLLPUBLIC ScTokenArray : public formula::FormulaTokenArray
 {
     friend class ScCompiler;
 
-    /**
-     * When vectorization is enabled, we could potentially mass-calculate a
-     * series of formula token arrays in adjacent formula cells in one step,
-     * provided that they all contain identical set of tokens.
-     */
-    enum VectorState { Disabled = 0, Enabled, CheckReference };
-
     bool                    ImplGetReference( ScRange& rRange, bool bValidOnly ) const;
 
     size_t mnHashValue;
-    VectorState meVectorState;
+    ScFormulaVectorState meVectorState;
 
 public:
     ScTokenArray();
@@ -56,6 +50,8 @@ public:
     void GenHash();
     size_t GetHash() const;
 
+    ScFormulaVectorState GetVectorState() const;
+
     /// Exactly and only one range (valid or deleted)
     bool    IsReference( ScRange& rRange ) const;
     /// Exactly and only one valid range (no #REF!s)
diff --git a/sc/inc/types.hxx b/sc/inc/types.hxx
index bb454a9..99d78f4 100644
--- a/sc/inc/types.hxx
+++ b/sc/inc/types.hxx
@@ -36,6 +36,19 @@ class ScMatrix;
 typedef ::boost::intrusive_ptr<ScMatrix>        ScMatrixRef;
 typedef ::boost::intrusive_ptr<const ScMatrix>  ScConstMatrixRef;
 
+/**
+ * When vectorization is enabled, we could potentially mass-calculate a
+ * series of formula token arrays in adjacent formula cells in one step,
+ * provided that they all contain identical set of tokens.
+ */
+enum ScFormulaVectorState
+{
+    FormulaVectorDisabled = 0,
+    FormulaVectorEnabled,
+    FormulaVectorCheckReference,
+    FormulaVectorUnknown
+};
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 6bde797..f255781 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1205,7 +1205,7 @@ void Test::testFormulaHashAndTag()
 
     struct {
         const char* pFormula1; const char* pFormula2; bool bEqual;
-    } aTests[] = {
+    } aHashTests[] = {
         { "=1", "=2", false }, // different constants
         { "=SUM(1;2;3;4;5)", "=AVERAGE(1;2;3;4;5)", false }, // different functions
         { "=C2*3", "=D2*3", true },  // relative references
@@ -1221,16 +1221,16 @@ void Test::testFormulaHashAndTag()
         { "=X$20", "=$X20", false }, // column absolute vs row absolute
     };
 
-    for (size_t i = 0; i < SAL_N_ELEMENTS(aTests); ++i)
+    for (size_t i = 0; i < SAL_N_ELEMENTS(aHashTests); ++i)
     {
-        m_pDoc->SetString(aPos1, OUString::createFromAscii(aTests[i].pFormula1));
-        m_pDoc->SetString(aPos2, OUString::createFromAscii(aTests[i].pFormula2));
+        m_pDoc->SetString(aPos1, OUString::createFromAscii(aHashTests[i].pFormula1));
+        m_pDoc->SetString(aPos2, OUString::createFromAscii(aHashTests[i].pFormula2));
         size_t nHashVal1 = m_pDoc->GetFormulaHash(aPos1);
         size_t nHashVal2 = m_pDoc->GetFormulaHash(aPos2);
 
         std::ostringstream os;
-        os << "(expr1:" << aTests[i].pFormula1 << "; expr2:" << aTests[i].pFormula2 << ")";
-        if (aTests[i].bEqual)
+        os << "(expr1:" << aHashTests[i].pFormula1 << "; expr2:" << aHashTests[i].pFormula2 << ")";
+        if (aHashTests[i].bEqual)
         {
             os << " Error: these hashes should be equal." << endl;
             CPPUNIT_ASSERT_MESSAGE(os.str().c_str(), nHashVal1 == nHashVal2);
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index c2247c1..5dfd8e5 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -889,6 +889,11 @@ size_t ScFormulaCell::GetHash() const
     return pCode->GetHash();
 }
 
+ScFormulaVectorState ScFormulaCell::GetVectorState() const
+{
+    return pCode->GetVectorState();
+}
+
 void ScFormulaCell::GetFormula( rtl::OUStringBuffer& rBuffer,
                                 const FormulaGrammar::Grammar eGrammar ) const
 {
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index ea4be5b..17d951d 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1527,20 +1527,32 @@ void ScColumn::SetScriptType( SCROW nRow, sal_uInt8 nType )
 
 size_t ScColumn::GetFormulaHash( SCROW nRow ) const
 {
+    const ScFormulaCell* pCell = FetchFormulaCell(nRow);
+    return pCell ? pCell->GetHash() : 0;
+}
+
+ScFormulaVectorState ScColumn::GetFormulaVectorState( SCROW nRow ) const
+{
+    const ScFormulaCell* pCell = FetchFormulaCell(nRow);
+    return pCell ? pCell->GetVectorState() : FormulaVectorUnknown;
+}
+
+const ScFormulaCell* ScColumn::FetchFormulaCell( SCROW nRow ) const
+{
     if (!ValidRow(nRow))
-        return 0;
+        return NULL;
 
     SCSIZE nIndex;
     if (!Search(nRow, nIndex))
         // cell not found.
-        return 0;
+        return NULL;
 
     const ScBaseCell* pCell = maItems[nIndex].pCell;
     if (pCell->GetCellType() != CELLTYPE_FORMULA)
         // Not a formula cell.
-        return 0;
+        return NULL;
 
-    return static_cast<const ScFormulaCell*>(pCell)->GetHash();
+    return static_cast<const ScFormulaCell*>(pCell);
 }
 
 void ScColumn::FindDataAreaPos(SCROW& rRow, bool bDown) const
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index ac5db47..90f90ce 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1561,6 +1561,15 @@ size_t ScDocument::GetFormulaHash( const ScAddress& rPos ) const
     return maTabs[nTab]->GetFormulaHash(rPos.Col(), rPos.Row());
 }
 
+ScFormulaVectorState ScDocument::GetFormulaVectorState( const ScAddress& rPos ) const
+{
+    SCTAB nTab = rPos.Tab();
+    if (!ValidTab(nTab) || static_cast<size_t>(nTab) >= maTabs.size() || !maTabs[nTab])
+        return FormulaVectorUnknown;
+
+    return maTabs[nTab]->GetFormulaVectorState(rPos.Col(), rPos.Row());
+}
+
 bool ScDocument::CanFitBlock( const ScRange& rOld, const ScRange& rNew )
 {
     if ( rOld == rNew )
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 309674c..c4c9d6a 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -2104,6 +2104,14 @@ size_t ScTable::GetFormulaHash( SCCOL nCol, SCROW nRow ) const
     return aCol[nCol].GetFormulaHash(nRow);
 }
 
+ScFormulaVectorState ScTable::GetFormulaVectorState( SCCOL nCol, SCROW nRow ) const
+{
+    if (!ValidCol(nCol))
+        return FormulaVectorUnknown;
+
+    return aCol[nCol].GetFormulaVectorState(nRow);
+}
+
 void ScTable::DeleteConditionalFormat( sal_uLong nIndex )
 {
     mpCondFormatList->erase(nIndex);
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index a5eb796..23a2241 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1249,7 +1249,7 @@ bool ScTokenArray::AddFormulaToken(const com::sun::star::sheet::FormulaToken& _a
 
 void ScTokenArray::CheckToken( const FormulaToken& r )
 {
-    if (meVectorState == Disabled)
+    if (meVectorState == FormulaVectorDisabled)
         // It's already disabled.  No more checking needed.
         return;
 
@@ -1270,7 +1270,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
                 // Don't change the state.
             break;
             default:
-                meVectorState = Disabled;
+                meVectorState = FormulaVectorDisabled;
         }
         return;
     }
@@ -1289,7 +1289,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case svSingleRef:
             case svDoubleRef:
                 // Depends on the reference state.
-                meVectorState = CheckReference;
+                meVectorState = FormulaVectorCheckReference;
             break;
             case svError:
             case svEmptyCell:
@@ -1311,7 +1311,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case svSubroutine:
             case svUnknown:
                 // We don't support vectorization on these.
-                meVectorState = Disabled;
+                meVectorState = FormulaVectorDisabled;
             default:
                 ;
         }
@@ -1438,6 +1438,11 @@ size_t ScTokenArray::GetHash() const
     return mnHashValue;
 }
 
+ScFormulaVectorState ScTokenArray::GetVectorState() const
+{
+    return meVectorState;
+}
+
 bool ScTokenArray::IsReference( ScRange& rRange ) const
 {
     return ImplGetReference( rRange, false );
@@ -1453,7 +1458,7 @@ bool ScTokenArray::IsValidReference( ScRange& rRange ) const
 ScTokenArray::ScTokenArray() :
     FormulaTokenArray(),
     mnHashValue(0),
-    meVectorState(Enabled)
+    meVectorState(FormulaVectorEnabled)
 {
 }
 


More information about the Libreoffice-commits mailing list