[Libreoffice-commits] core.git: Branch 'private/kohei/calc-shared-string' - sc/inc sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Wed Oct 9 13:15:37 PDT 2013


 sc/inc/tokenarray.hxx                           |    2 
 sc/source/filter/ftools/sharedformulagroups.cxx |   33 ---------------
 sc/source/filter/inc/sharedformulagroups.hxx    |   23 ----------
 sc/source/filter/orcus/interface.cxx            |   51 ++++++------------------
 4 files changed, 15 insertions(+), 94 deletions(-)

New commits:
commit 4f67596aaaa313dc56564a7e08a6f75306c47900
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Wed Oct 9 16:16:46 2013 -0400

    Make the same change to the orcus interface & remove unused methods.
    
    Change-Id: I1263026133b694e531c0a99b16d622e1ae12db48

diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index d926c9b..83a3988 100644
--- a/sc/inc/tokenarray.hxx
+++ b/sc/inc/tokenarray.hxx
@@ -25,6 +25,8 @@
 #include "scdllapi.h"
 #include "types.hxx"
 #include "calcmacros.hxx"
+#include "address.hxx"
+#include "global.hxx"
 #include <formula/tokenarray.hxx>
 
 namespace sc {
diff --git a/sc/source/filter/ftools/sharedformulagroups.cxx b/sc/source/filter/ftools/sharedformulagroups.cxx
index b80bdb5..9a00ade 100644
--- a/sc/source/filter/ftools/sharedformulagroups.cxx
+++ b/sc/source/filter/ftools/sharedformulagroups.cxx
@@ -11,50 +11,17 @@
 
 namespace sc {
 
-SharedFormulaGroups::Key::Key(size_t nId, SCCOL nCol) : mnId(nId), mnCol(nCol) {}
-
-bool SharedFormulaGroups::Key::operator== ( const Key& rOther ) const
-{
-    return mnId == rOther.mnId && mnCol == rOther.mnCol;
-}
-
-bool SharedFormulaGroups::Key::operator!= ( const Key& rOther ) const
-{
-    return !operator==(rOther);
-}
-
-size_t SharedFormulaGroups::KeyHash::operator ()( const Key& rKey ) const
-{
-    double nVal = rKey.mnId;
-    nVal *= 256.0;
-    nVal += rKey.mnCol;
-    return static_cast<size_t>(nVal);
-}
-
 void SharedFormulaGroups::set( size_t nSharedId, ScTokenArray* pArray )
 {
     maStore.insert(nSharedId, pArray);
 }
 
-void SharedFormulaGroups::set( size_t nSharedId, SCCOL nCol, const ScFormulaCellGroupRef& xGroup )
-{
-    Key aKey(nSharedId, nCol);
-    maColStore.insert(ColStoreType::value_type(aKey, xGroup));
-}
-
 const ScTokenArray* SharedFormulaGroups::get( size_t nSharedId ) const
 {
     StoreType::const_iterator it = maStore.find(nSharedId);
     return it == maStore.end() ? NULL : it->second;
 }
 
-ScFormulaCellGroupRef SharedFormulaGroups::get( size_t nSharedId, SCCOL nCol ) const
-{
-    Key aKey(nSharedId, nCol);
-    ColStoreType::const_iterator it = maColStore.find(aKey);
-    return it == maColStore.end() ? ScFormulaCellGroupRef() : it->second;
-}
-
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/inc/sharedformulagroups.hxx b/sc/source/filter/inc/sharedformulagroups.hxx
index 0bd9484..37bda14 100644
--- a/sc/source/filter/inc/sharedformulagroups.hxx
+++ b/sc/source/filter/inc/sharedformulagroups.hxx
@@ -10,43 +10,20 @@
 #ifndef SC_FILTER_SHAREDFORMULAGROUPS_HXX
 #define SC_FILTER_SHAREDFORMULAGROUPS_HXX
 
-#include "address.hxx"
-#include "formulacell.hxx"
 #include "tokenarray.hxx"
 
 #include <boost/ptr_container/ptr_map.hpp>
-#include <boost/unordered_map.hpp>
 
 namespace sc {
 
 class SharedFormulaGroups
 {
-    struct Key
-    {
-        size_t mnId;
-        SCCOL mnCol;
-
-        Key(size_t nId, SCCOL nCol);
-
-        bool operator== ( const Key& rOther ) const;
-        bool operator!= ( const Key& rOther ) const;
-    };
-
-    struct KeyHash
-    {
-        size_t operator() ( const Key& rKey ) const;
-    };
-
     typedef boost::ptr_map<size_t, ScTokenArray> StoreType;
-    typedef boost::unordered_map<Key, ScFormulaCellGroupRef, KeyHash> ColStoreType;
-    ColStoreType maColStore;
     StoreType maStore;
 public:
 
     void set( size_t nSharedId, ScTokenArray* pArray );
-    void set( size_t nSharedId, SCCOL nCol, const ScFormulaCellGroupRef& xGroup );
     const ScTokenArray* get( size_t nSharedId ) const;
-    ScFormulaCellGroupRef get( size_t nSharedId, SCCOL nCol ) const;
 };
 
 }
diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx
index 03346d5..df2da17 100644
--- a/sc/source/filter/orcus/interface.cxx
+++ b/sc/source/filter/orcus/interface.cxx
@@ -341,28 +341,12 @@ void ScOrcusSheet::set_formula_result(os::row_t row, os::col_t col, const char*
 }
 
 void ScOrcusSheet::set_shared_formula(
-    os::row_t /*row*/, os::col_t /*col*/, os::formula_grammar_t /*grammar*/, size_t /*sindex*/,
-    const char* /*p_formula*/, size_t /*n_formula*/)
-{
-    // TODO: We need to revise this interface in orcus.
-}
-
-void ScOrcusSheet::set_shared_formula(
     os::row_t row, os::col_t col, os::formula_grammar_t grammar, size_t sindex,
-    const char* p_formula, size_t n_formula, const char* p_range, size_t n_range)
+    const char* p_formula, size_t n_formula)
 {
     ScAddress aPos(col, row, mnTab);
     OUString aFormula(p_formula, n_formula, RTL_TEXTENCODING_UTF8);
-    OUString aRangeStr(p_range, n_range, RTL_TEXTENCODING_UTF8);
     formula::FormulaGrammar::Grammar eGram = getCalcGrammarFromOrcus(grammar);
-    formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::extractRefConvention(eGram);
-
-    // Convert the shared formula range.
-    ScRange aRange;
-    sal_uInt16 nRes = aRange.Parse(aRangeStr, &mrDoc.getDoc(), eConv);
-    if (!(nRes & SCA_VALID))
-        // Conversion failed.
-        return;
 
     // Compile the formula expression into tokens.
     ScCompiler aComp(&mrDoc.getDoc(), aPos);
@@ -372,24 +356,9 @@ void ScOrcusSheet::set_shared_formula(
         // Tokenization failed.
         return;
 
-    for (sal_Int32 nCol = aRange.aStart.Col(); nCol <= aRange.aEnd.Col(); ++nCol)
-    {
-        // Create one group per column, since Calc doesn't support shared
-        // formulas across multiple columns.
-        ScFormulaCellGroupRef xNewGroup(new ScFormulaCellGroup);
-        xNewGroup->mnStart = aRange.aStart.Row();
-        xNewGroup->mnLength = 1;
-        xNewGroup->setCode(*pArray);
-        maFormulaGroups.set(sindex, nCol, xNewGroup);
-    }
-
-    ScFormulaCellGroupRef xGroup = maFormulaGroups.get(sindex, aPos.Col());
-    if (!xGroup)
-        return;
+    maFormulaGroups.set(sindex, pArray);
 
-    // Generate code for the top cell only.
-    xGroup->compileCode(mrDoc.getDoc(), aPos, formula::FormulaGrammar::GRAM_DEFAULT);
-    ScFormulaCell* pCell = new ScFormulaCell(&mrDoc.getDoc(), aPos, xGroup);
+    ScFormulaCell* pCell = new ScFormulaCell(&mrDoc.getDoc(), aPos, pArray);
     mrDoc.setFormulaCell(aPos, pCell);
     cellInserted();
 
@@ -398,16 +367,22 @@ void ScOrcusSheet::set_shared_formula(
     pCell->StartListeningTo(&mrDoc.getDoc());
 }
 
+void ScOrcusSheet::set_shared_formula(
+    os::row_t row, os::col_t col, os::formula_grammar_t grammar, size_t sindex,
+    const char* p_formula, size_t n_formula, const char* /*p_range*/, size_t /*n_range*/)
+{
+    set_shared_formula(row, col, grammar, sindex, p_formula, n_formula);
+}
+
 void ScOrcusSheet::set_shared_formula(os::row_t row, os::col_t col, size_t sindex)
 {
     ScAddress aPos(col, row, mnTab);
 
-    ScFormulaCellGroupRef xGroup = maFormulaGroups.get(sindex, aPos.Col());
-    if (!xGroup)
+    const ScTokenArray* pArray = maFormulaGroups.get(sindex);
+    if (!pArray)
         return;
 
-    xGroup->mnLength = aPos.Row() - xGroup->mnStart + 1;
-    ScFormulaCell* pCell = new ScFormulaCell(&mrDoc.getDoc(), aPos, xGroup);
+    ScFormulaCell* pCell = new ScFormulaCell(&mrDoc.getDoc(), aPos, pArray);
     mrDoc.setFormulaCell(aPos, pCell);
     cellInserted();
 


More information about the Libreoffice-commits mailing list