Kaydet (Commit) 9d269e18 authored tarafından Michael Meeks's avatar Michael Meeks Kaydeden (comit) Kohei Yoshida

use cell hashing algorithm for computing groups.

Update unit tests, dumb-down hashing to compare more for similiarity
rather than identicality - we want to use this down columns.

Change-Id: Icea731daeb301e1febb2df48b6b46c9faba74e9d
üst b13550ed
......@@ -1222,6 +1222,13 @@ void Test::testFormulaHashAndTag()
{ "=X20", "=X$20", false }, // absolute vs relative
{ "=X20", "=$X20", false }, // absolute vs relative
{ "=X$20", "=$X20", false }, // column absolute vs row absolute
// similar enough for merging ...
{ "=A1", "=B1", true },
{ "=$A$1", "=$B$1", true },
{ "=A1", "=C2", true },
{ "=SUM(A1)", "=SUM(B1)", true },
{ "=A1+3", "=B1+3", true },
{ "=A1+7", "=B1+42", false },
};
for (size_t i = 0; i < SAL_N_ELEMENTS(aHashTests); ++i)
......@@ -6221,14 +6228,14 @@ void Test::testFormulaGrouping()
const char *pFormula[3];
const bool bGroup[3];
} aGroupTests[] = {
{ { "=B1", "=C1", "" }, // single increments
{ true, true, false } },
{ { "=B1", "=D1", "=F1" }, // tripple increments
{ true, true, true } },
{ { "=B1", "", "=C1" }, // a gap
{ false, false, false } },
{ { "=B1", "=C1+3", "=C1+D1" }, // confusion: FIXME: =C1+7
{ false, false, false } },
{ { "=SUM(B1)", "=SUM(C1)", "" }, // single increments
{ true, true, false } },
{ { "=SUM(B1)", "=SUM(D1)", "=SUM(F1)" }, // tripple increments
{ true, true, true } },
{ { "=SUM(B1)", "", "=SUM(C1)" }, // a gap
{ false, false, false } },
{ { "=SUM(B1)", "=SUM(C1;3)", "=SUM(D1;3)" }, // similar foo
{ false, true, true } },
};
m_pDoc->InsertTab( 0, "sheet" );
......@@ -6259,7 +6266,7 @@ void Test::testFormulaGrouping()
if( !!pCur->GetCellGroup().get() ^ aGroupTests[i].bGroup[j] )
{
printf("expected group test %d at row %d to be %d but is %d\n",
i, j, !!pCur->GetCellGroup().get(), aGroupTests[i].bGroup[j]);
i, j, aGroupTests[i].bGroup[j], !!pCur->GetCellGroup().get());
CPPUNIT_ASSERT_MESSAGE("Failed", false);
}
}
......
......@@ -1722,10 +1722,9 @@ bool ScFormulaCellGroup::IsCompatible( ScSimilarFormulaDelta *pDelta )
/// formulae should produce pOther
ScSimilarFormulaDelta *ScFormulaCell::BuildDeltaTo( ScFormulaCell *pOtherCell )
{
// FIXME: TODO - M1
// if ( kohei_comparison_hash_not_equal( mnHash, pOther->mnHash )
// return NULL;
// are these formule at all similar ?
if ( GetHash() != pOtherCell->GetHash() )
return NULL;
FormulaToken **pThis = pCode->GetCode();
sal_uInt16 pThisLen = pCode->GetCodeLen();
......
......@@ -1348,19 +1348,16 @@ bool ScTokenArray::ImplGetReference( ScRange& rRange, bool bValidOnly ) const
namespace {
// we want to compare for similar not identical formulae
// so we can't use actual row & column indices.
size_t HashSingleRef( const ScSingleRefData& rRef )
{
SCsCOL nCol = rRef.Flags.bColRel ? rRef.nRelCol : rRef.nCol;
SCsROW nRow = rRef.Flags.bRowRel ? rRef.nRelRow : rRef.nRow;
SCsTAB nTab = rRef.Flags.bTabRel ? rRef.nRelTab : rRef.nTab;
size_t nVal = nCol;
nVal += (nRow << 8);
nVal += (nTab << 16);
size_t nVal = 0;
// Embed flag values too.
nVal += rRef.Flags.bColRel;
nVal += (rRef.Flags.bRowRel << 1);
nVal += (rRef.Flags.bTabRel << 2);
return nVal;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment