[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/inc sc/qa sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Mon Jul 22 10:09:33 PDT 2013
sc/inc/refdata.hxx | 9 ++++++
sc/qa/unit/ucalc_formula.cxx | 4 +--
sc/source/core/tool/refdata.cxx | 53 +++++++++++++++++++++++++++++++++++++---
sc/source/core/tool/token.cxx | 29 +--------------------
4 files changed, 63 insertions(+), 32 deletions(-)
New commits:
commit 263d7d0802e9970868404b0d75ecc135e5addc11
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Mon Jul 22 13:08:31 2013 -0400
Don't mark all of column, row, and sheet indices to be invalid in toAbs().
When only one of them is invalid. This messes up the displaying of an
invalid reference.
Change-Id: I2b5a614434417160d605dd889ca4d3b54fcaffc2
diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx
index 92bf5b9..259b63f 100644
--- a/sc/inc/refdata.hxx
+++ b/sc/inc/refdata.hxx
@@ -23,6 +23,7 @@
#include "global.hxx"
#include "address.hxx"
#include "scdllapi.h"
+#include "calcmacros.hxx"
/// Single reference (one address) into the sheet
struct SC_DLLPUBLIC ScSingleRefData
@@ -91,6 +92,10 @@ struct SC_DLLPUBLIC ScSingleRefData
void CalcAbsIfRel( const ScAddress& rPos );
bool operator==( const ScSingleRefData& ) const;
bool operator!=( const ScSingleRefData& ) const;
+
+#if DEBUG_FORMULA_COMPILER
+ void Dump() const;
+#endif
};
inline void ScSingleRefData::InitAddress( SCCOL nColP, SCROW nRowP, SCTAB nTabP )
@@ -178,6 +183,10 @@ struct ScComplexRefData
relative references. */
ScComplexRefData& Extend( const ScSingleRefData & rRef, const ScAddress & rPos );
ScComplexRefData& Extend( const ScComplexRefData & rRef, const ScAddress & rPos );
+
+#if DEBUG_FORMULA_COMPILER
+ void Dump() const;
+#endif
};
inline bool ScComplexRefData::ValidExternal() const
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index c400ae5..4181ec9 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -807,13 +807,13 @@ void Test::testFormulaRefUpdateSheets()
m_pDoc->DeleteTab(0);
m_pDoc->GetName(0, aName);
CPPUNIT_ASSERT_EQUAL(OUString("Sheet2"), aName);
-#if 0 // TODO: I'll look into this later.
+
if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "SUM(#REF!.B2:C3)"))
CPPUNIT_FAIL("Wrong formula in Sheet2.B2.");
if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "SUM(#REF!.$B$2:$C$3)"))
CPPUNIT_FAIL("Wrong formula in Sheet2.B3.");
-#endif
+
m_pDoc->DeleteTab(0);
}
diff --git a/sc/source/core/tool/refdata.cxx b/sc/source/core/tool/refdata.cxx
index 053f2a5..239fd6b 100644
--- a/sc/source/core/tool/refdata.cxx
+++ b/sc/source/core/tool/refdata.cxx
@@ -67,10 +67,18 @@ ScAddress ScSingleRefData::toAbs( const ScAddress& rPos ) const
SCROW nRetRow = Flags.bRowRel ? nRelRow + rPos.Row() : nRow;
SCTAB nRetTab = Flags.bTabRel ? nRelTab + rPos.Tab() : nTab;
- if (!ValidCol(nRetCol) || !ValidRow(nRetRow) || !ValidTab(nRetTab))
- return ScAddress(ScAddress::INITIALIZE_INVALID);
+ ScAddress aAbs(ScAddress::INITIALIZE_INVALID);
- return ScAddress(nRetCol, nRetRow, nRetTab);
+ if (ValidCol(nRetCol))
+ aAbs.SetCol(nRetCol);
+
+ if (ValidRow(nRetRow))
+ aAbs.SetRow(nRetRow);
+
+ if (ValidTab(nRetTab))
+ aAbs.SetTab(nRetTab);
+
+ return aAbs;
}
void ScSingleRefData::SetAddress( const ScAddress& rAddr, const ScAddress& rPos )
@@ -149,6 +157,20 @@ bool ScSingleRefData::operator!=( const ScSingleRefData& r ) const
return !operator==(r);
}
+#if DEBUG_FORMULA_COMPILER
+void ScSingleRefData::Dump() const
+{
+ cout << " address type column: " << (IsColRel()?"relative":"absolute")
+ << " row : " << (IsRowRel()?"relative":"absolute") << " sheet: "
+ << (IsTabRel()?"relative":"absolute") << endl;
+ cout << " deleted column: " << (IsColDeleted()?"yes":"no")
+ << " row : " << (IsRowDeleted()?"yes":"no") << " sheet: "
+ << (IsTabDeleted()?"yes":"no") << endl;
+ cout << " absolute pos column: " << nCol << " row: " << nRow << " sheet: " << nTab << endl;
+ cout << " relative pos column: " << nRelCol << " row: " << nRelRow << " sheet: " << nRelTab << endl;
+}
+#endif
+
static void lcl_putInOrder( ScSingleRefData & rRef1, ScSingleRefData & rRef2 )
{
SCCOL nCol1, nCol2;
@@ -330,4 +352,29 @@ void ScComplexRefData::SetRange( const ScRange& rRange, const ScAddress& rPos )
Ref2.SetAddress(rRange.aEnd, rPos);
}
+#if DEBUG_FORMULA_COMPILER
+void ScComplexRefData::Dump() const
+{
+ cout << " ref 1" << endl;
+ cout << " address type column: " << (Ref1.IsColRel()?"relative":"absolute")
+ << " row: " << (Ref1.IsRowRel()?"relative":"absolute")
+ << " sheet: " << (Ref1.IsTabRel()?"relative":"absolute") << endl;
+ cout << " deleted column: " << (Ref1.IsColDeleted()?"yes":"no")
+ << " row: " << (Ref1.IsRowDeleted()?"yes":"no")
+ << " sheet: " << (Ref1.IsTabDeleted()?"yes":"no") << endl;
+ cout << " absolute pos column: " << Ref1.nCol << " row: " << Ref1.nRow << " sheet: " << Ref1.nTab << endl;
+ cout << " relative pos column: " << Ref1.nRelCol << " row: " << Ref1.nRelRow << " sheet: " << Ref1.nRelTab << endl;
+
+ cout << " ref 2" << endl;
+ cout << " address type column: " << (Ref2.IsColRel()?"relative":"absolute")
+ << " row: " << (Ref2.IsRowRel()?"relative":"absolute")
+ << " sheet: " << (Ref2.IsTabRel()?"relative":"absolute") << endl;
+ cout << " deleted column: " << (Ref2.IsColDeleted()?"yes":"no")
+ << " row: " << (Ref2.IsRowDeleted()?"yes":"no")
+ << " sheet: " << (Ref2.IsTabDeleted()?"yes":"no") << endl;
+ cout << " absolute pos column: " << Ref2.nCol << " row: " << Ref2.nRow << " sheet: " << Ref2.nTab << endl;
+ cout << " relative pos column: " << Ref2.nRelCol << " row: " << Ref2.nRelRow << " sheet: " << Ref2.nRelTab << endl;
+}
+#endif
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 58696ba..4c8e595 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -751,14 +751,7 @@ bool ScSingleRefToken::operator==( const FormulaToken& r ) const
void ScSingleRefToken::Dump() const
{
cout << "-- ScSingleRefToken" << endl;
- cout << " address type column: " << (aSingleRef.IsColRel()?"relative":"absolute")
- << " row : " << (aSingleRef.IsRowRel()?"relative":"absolute") << " sheet: "
- << (aSingleRef.IsTabRel()?"relative":"absolute") << endl;
- cout << " deleted column: " << (aSingleRef.IsColDeleted()?"yes":"no")
- << " row : " << (aSingleRef.IsRowDeleted()?"yes":"no") << " sheet: "
- << (aSingleRef.IsTabDeleted()?"yes":"no") << endl;
- cout << " absolute pos column: " << aSingleRef.nCol << " row: " << aSingleRef.nRow << " sheet: " << aSingleRef.nTab << endl;
- cout << " relative pos column: " << aSingleRef.nRelCol << " row: " << aSingleRef.nRelRow << " sheet: " << aSingleRef.nRelTab << endl;
+ aSingleRef.Dump();
}
#endif
@@ -777,25 +770,7 @@ bool ScDoubleRefToken::operator==( const FormulaToken& r ) const
void ScDoubleRefToken::Dump() const
{
cout << "-- ScDoubleRefToken" << endl;
- cout << " ref 1" << endl;
- cout << " address type column: " << (aDoubleRef.Ref1.IsColRel()?"relative":"absolute")
- << " row: " << (aDoubleRef.Ref1.IsRowRel()?"relative":"absolute")
- << " sheet: " << (aDoubleRef.Ref1.IsTabRel()?"relative":"absolute") << endl;
- cout << " deleted column: " << (aDoubleRef.Ref1.IsColDeleted()?"yes":"no")
- << " row: " << (aDoubleRef.Ref1.IsRowDeleted()?"yes":"no")
- << " sheet: " << (aDoubleRef.Ref1.IsTabDeleted()?"yes":"no") << endl;
- cout << " absolute pos column: " << aDoubleRef.Ref1.nCol << " row: " << aDoubleRef.Ref1.nRow << " sheet: " << aDoubleRef.Ref1.nTab << endl;
- cout << " relative pos column: " << aDoubleRef.Ref1.nRelCol << " row: " << aDoubleRef.Ref1.nRelRow << " sheet: " << aDoubleRef.Ref1.nRelTab << endl;
-
- cout << " ref 2" << endl;
- cout << " address type column: " << (aDoubleRef.Ref2.IsColRel()?"relative":"absolute")
- << " row: " << (aDoubleRef.Ref2.IsRowRel()?"relative":"absolute")
- << " sheet: " << (aDoubleRef.Ref2.IsTabRel()?"relative":"absolute") << endl;
- cout << " deleted column: " << (aDoubleRef.Ref2.IsColDeleted()?"yes":"no")
- << " row: " << (aDoubleRef.Ref2.IsRowDeleted()?"yes":"no")
- << " sheet: " << (aDoubleRef.Ref2.IsTabDeleted()?"yes":"no") << endl;
- cout << " absolute pos column: " << aDoubleRef.Ref2.nCol << " row: " << aDoubleRef.Ref2.nRow << " sheet: " << aDoubleRef.Ref2.nTab << endl;
- cout << " relative pos column: " << aDoubleRef.Ref2.nRelCol << " row: " << aDoubleRef.Ref2.nRelRow << " sheet: " << aDoubleRef.Ref2.nRelTab << endl;
+ aDoubleRef.Dump();
}
#endif
More information about the Libreoffice-commits
mailing list