summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2013-10-09 16:16:46 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-10-11 12:14:25 -0400
commit512ccd16de2d64a1fd64da92eeb61680b43797ee (patch)
treef0423a82b60cc0fe0f22768ef36abacc8cdb45ca
parent0eabc71b59b97e51b8ee9630873dc8db3401f8f3 (diff)
Make the same change to the orcus interface & remove unused methods.
Change-Id: I1263026133b694e531c0a99b16d622e1ae12db48
-rw-r--r--sc/inc/tokenarray.hxx2
-rw-r--r--sc/source/filter/ftools/sharedformulagroups.cxx33
-rw-r--r--sc/source/filter/inc/sharedformulagroups.hxx23
-rw-r--r--sc/source/filter/orcus/interface.cxx51
4 files changed, 15 insertions, 94 deletions
diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index d926c9bb8c80..83a3988d4643 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 b80bdb50eb87..9a00ade2f0a8 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 0bd948427cef..37bda14d07a4 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 03346d55037f..df2da17ce4b7 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();