[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 6 commits - sc/inc sc/qa sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Mon Jul 22 21:22:51 PDT 2013
sc/inc/refdata.hxx | 32 ---------
sc/qa/unit/ucalc.hxx | 2
sc/qa/unit/ucalc_formula.cxx | 69 +++++++++++++++----
sc/source/core/tool/compiler.cxx | 34 +++------
sc/source/core/tool/interpr4.cxx | 11 +--
sc/source/core/tool/refdata.cxx | 128 ++++++++++++------------------------
sc/source/filter/excel/excform8.cxx | 28 ++++---
sc/source/filter/lotus/lotform.cxx | 10 --
8 files changed, 138 insertions(+), 176 deletions(-)
New commits:
commit 15d3e71f26f34a41f49e857ec924ae95a8deb23a
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue Jul 23 00:23:06 2013 -0400
More on removing CalcRelFromAbs().
Change-Id: I6474926d9cd8f9273bae3d8179bd14ee19422357
diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx
index 848bbd6..07ea7ef 100644
--- a/sc/inc/refdata.hxx
+++ b/sc/inc/refdata.hxx
@@ -54,10 +54,10 @@ struct SC_DLLPUBLIC ScSingleRefData
/// No default ctor, because used in ScRawToken union, set InitFlags!
inline void InitFlags() { mnFlagValue = 0; } ///< all FALSE
/// InitAddress: InitFlags and set address
- inline void InitAddress( const ScAddress& rAdr );
- inline void InitAddress( SCCOL nCol, SCROW nRow, SCTAB nTab );
+ void InitAddress( const ScAddress& rAdr );
+ void InitAddress( SCCOL nCol, SCROW nRow, SCTAB nTab );
/// InitAddressRel: InitFlags and set address, everything relative to rPos
- inline void InitAddressRel( const ScAddress& rAdr, const ScAddress& rPos );
+ void InitAddressRel( const ScAddress& rAdr, const ScAddress& rPos );
inline void SetColRel( bool bVal ) { Flags.bColRel = (bVal ? true : false ); }
inline bool IsColRel() const{ return Flags.bColRel; }
inline void SetRowRel( bool bVal ) { Flags.bRowRel = (bVal ? true : false ); }
@@ -97,29 +97,6 @@ struct SC_DLLPUBLIC ScSingleRefData
#endif
};
-inline void ScSingleRefData::InitAddress( SCCOL nColP, SCROW nRowP, SCTAB nTabP )
-{
- InitFlags();
- nCol = nColP;
- nRow = nRowP;
- nTab = nTabP;
-}
-
-inline void ScSingleRefData::InitAddress( const ScAddress& rAdr )
-{
- InitAddress( rAdr.Col(), rAdr.Row(), rAdr.Tab());
-}
-
-inline void ScSingleRefData::InitAddressRel( const ScAddress& rAdr,
- const ScAddress& rPos )
-{
- InitAddress( rAdr.Col(), rAdr.Row(), rAdr.Tab());
- SetColRel( true );
- SetRowRel( true );
- SetTabRel( true );
- CalcRelFromAbs( rPos );
-}
-
inline bool ScSingleRefData::Valid() const
{
return nCol >= 0 && nCol <= MAXCOL &&
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index c63921f..4a87147 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -5284,7 +5284,7 @@ bool ScCompiler::HandleSingleRef()
aRefData.SetColRel( true );
else
aRefData.SetRowRel( true );
- aRefData.CalcRelFromAbs( aPos );
+ aRefData.SetAddress(aRange.aStart, aPos);
pNew->AddSingleReference( aRefData );
}
else
@@ -5301,7 +5301,7 @@ bool ScCompiler::HandleSingleRef()
aRefData.Ref1.SetRowRel( true );
aRefData.Ref2.SetRowRel( true );
}
- aRefData.CalcRelFromAbs( aPos );
+ aRefData.SetRange(aRange, aPos);
if ( bInList )
pNew->AddDoubleReference( aRefData );
else
@@ -5328,13 +5328,10 @@ bool ScCompiler::HandleDbData()
{
ScComplexRefData aRefData;
aRefData.InitFlags();
- pDBData->GetArea( (SCTAB&) aRefData.Ref1.nTab,
- (SCCOL&) aRefData.Ref1.nCol,
- (SCROW&) aRefData.Ref1.nRow,
- (SCCOL&) aRefData.Ref2.nCol,
- (SCROW&) aRefData.Ref2.nRow);
- aRefData.Ref2.nTab = aRefData.Ref1.nTab;
- aRefData.CalcRelFromAbs( aPos );
+ ScRange aRange;
+ pDBData->GetArea(aRange);
+ aRange.aEnd.SetTab(aRange.aStart.Tab());
+ aRefData.SetRange(aRange, aPos);
ScTokenArray* pNew = new ScTokenArray();
pNew->AddDoubleReference( aRefData );
PushTokenArray( pNew, true );
diff --git a/sc/source/core/tool/refdata.cxx b/sc/source/core/tool/refdata.cxx
index 3a7e2b0..439886e 100644
--- a/sc/source/core/tool/refdata.cxx
+++ b/sc/source/core/tool/refdata.cxx
@@ -19,6 +19,27 @@
#include "refdata.hxx"
+void ScSingleRefData::InitAddress( const ScAddress& rAdr )
+{
+ InitAddress( rAdr.Col(), rAdr.Row(), rAdr.Tab());
+}
+
+void ScSingleRefData::InitAddress( SCCOL nColP, SCROW nRowP, SCTAB nTabP )
+{
+ InitFlags();
+ nCol = nColP;
+ nRow = nRowP;
+ nTab = nTabP;
+}
+
+void ScSingleRefData::InitAddressRel( const ScAddress& rAdr, const ScAddress& rPos )
+{
+ SetColRel(true);
+ SetRowRel(true);
+ SetTabRel(true);
+ SetAddress(rAdr, rPos);
+}
+
void ScSingleRefData::SetColDeleted( bool bVal )
{
Flags.bColDeleted = (bVal ? true : false );
diff --git a/sc/source/filter/excel/excform8.cxx b/sc/source/filter/excel/excform8.cxx
index 8efbc1a..3eec9ba 100644
--- a/sc/source/filter/excel/excform8.cxx
+++ b/sc/source/filter/excel/excform8.cxx
@@ -319,31 +319,33 @@ ConvErr ExcelToSc8::Convert( const ScTokenArray*& rpTokArray, XclImpStream& aIn,
case 0x03: // Col 4 - ref
case 0x06: // RwV 4 - val
case 0x07: // ColV 4 - val
+ {
aIn >> nRow >> nCol;
-
- aSRD.InitAddress( ScAddress( static_cast<SCCOL>(nCol & 0xFF), static_cast<SCROW>(nRow), aEingPos.Tab() ) );
+ ScAddress aAddr(static_cast<SCCOL>(nCol & 0xFF), static_cast<SCROW>(nRow), aEingPos.Tab());
+ aSRD.InitAddress(aAddr);
if( nEptg == 0x02 || nEptg == 0x06 )
- aSRD.SetRowRel( sal_True );
+ aSRD.SetRowRel(true);
else
- aSRD.SetColRel( sal_True );
+ aSRD.SetColRel(true);
- aSRD.CalcRelFromAbs( aEingPos );
+ aSRD.SetAddress(aAddr, aEingPos);
aStack << aPool.StoreNlf( aSRD );
- break;
+ }
+ break;
case 0x0A: // Radical 13 - ref
+ {
aIn >> nRow >> nCol;
aIn.Ignore( 9 );
-
- aSRD.InitAddress( ScAddress( static_cast<SCCOL>(nCol & 0xFF), static_cast<SCROW>(nRow), aEingPos.Tab() ) );
-
- aSRD.SetColRel( sal_True );
-
- aSRD.CalcRelFromAbs( aEingPos );
+ ScAddress aAddr(static_cast<SCCOL>(nCol & 0xFF), static_cast<SCROW>(nRow), aEingPos.Tab());
+ aSRD.InitAddress(aAddr);
+ aSRD.SetColRel(true);
+ aSRD.SetAddress(aAddr, aEingPos);
aStack << aPool.StoreNlf( aSRD );
- break;
+ }
+ break;
case 0x0B: // RadicalS 13 x ref
aIn.Ignore( 13 );
aExtensions.push_back( EXTENSION_NLR );
diff --git a/sc/source/filter/lotus/lotform.cxx b/sc/source/filter/lotus/lotform.cxx
index 0278c75..33e8456 100644
--- a/sc/source/filter/lotus/lotform.cxx
+++ b/sc/source/filter/lotus/lotform.cxx
@@ -295,20 +295,14 @@ void LotusToSc::ReadSRD( ScSingleRefData& rSRD, sal_uInt8 nRelBit )
Read( nTab );
Read( nCol );
- sal_Bool b3D = ( static_cast< SCTAB >( nTab ) != aEingPos.Tab() );
+ bool b3D = (static_cast<SCTAB>(nTab) != aEingPos.Tab());
rSRD.SetColRel( ( nRelBit & 0x01 ) != 0 );
- rSRD.nCol = static_cast< SCsCOL >( nCol );
-
rSRD.SetRowRel( ( nRelBit & 0x02 ) != 0 );
- rSRD.nRow = static_cast< SCsROW >( nRow );
-
rSRD.SetTabRel( ( ( nRelBit & 0x04) != 0 ) || !b3D );
- rSRD.nTab = static_cast< SCsTAB >( nTab );
-
rSRD.SetFlag3D( b3D );
- rSRD.CalcRelFromAbs( aEingPos );
+ rSRD.SetAddress(ScAddress(nCol, nRow, nTab), aEingPos);
}
commit cb8b67d59bc83bc93627dcc23b93393397aec55f
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Mon Jul 22 23:46:51 2013 -0400
Work on removing CalcRelFromAbs().
Change-Id: Ieb8b19821d778fa4596e680e73ba583667b5231a
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index f778321..c63921f 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -2697,7 +2697,7 @@ bool ScCompiler::IsDoubleReference( const String& rName )
if ( !(nFlags & SCA_VALID_TAB2) )
aRef.Ref2.SetTabDeleted( true ); // #REF!
aRef.Ref2.SetFlag3D( ( nFlags & SCA_TAB2_3D ) != 0 );
- aRef.CalcRelFromAbs( aPos );
+ aRef.SetRange(aRange, aPos);
if (aExtInfo.mbExternal)
{
ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager();
@@ -2745,7 +2745,7 @@ bool ScCompiler::IsSingleReference( const String& rName )
aRef.nTab = MAXTAB+3;
nFlags |= SCA_VALID;
}
- aRef.CalcRelFromAbs( aPos );
+ aRef.SetAddress(aAddr, aPos);
if (aExtInfo.mbExternal)
{
@@ -3040,14 +3040,11 @@ bool ScCompiler::IsColRowName( const String& rName )
if ( ScGlobal::GetpTransliteration()->isEqual( aStr, aName ) )
{
aRef.InitFlags();
- aRef.nCol = aIter.GetPos().Col();
- aRef.nRow = aIter.GetPos().Row();
- aRef.nTab = aIter.GetPos().Tab();
if ( !jRow )
aRef.SetColRel( true ); // ColName
else
aRef.SetRowRel( true ); // RowName
- aRef.CalcRelFromAbs( aPos );
+ aRef.SetAddress(aIter.GetPos(), aPos);
bInList = bFound = true;
}
}
@@ -3225,14 +3222,14 @@ bool ScCompiler::IsColRowName( const String& rName )
else
aAdr = aOne;
aRef.InitAddress( aAdr );
- if ( (aRef.nRow != MAXROW && pDoc->HasStringData(
- aRef.nCol, aRef.nRow + 1, aRef.nTab ))
- || (aRef.nRow != 0 && pDoc->HasStringData(
- aRef.nCol, aRef.nRow - 1, aRef.nTab )) )
+ if ( (aAdr.Row() != MAXROW && pDoc->HasStringData(
+ aAdr.Col(), aAdr.Row() + 1, aAdr.Tab()))
+ || (aAdr.Row() != 0 && pDoc->HasStringData(
+ aAdr.Col(), aAdr.Row() - 1, aAdr.Tab())))
aRef.SetRowRel( true ); // RowName
else
aRef.SetColRel( true ); // ColName
- aRef.CalcRelFromAbs( aPos );
+ aRef.SetAddress(aAdr, aPos);
}
}
if ( bFound )
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index f55d22f..16b2423 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -3601,13 +3601,10 @@ void ScInterpreter::ScDBArea()
{
ScComplexRefData aRefData;
aRefData.InitFlags();
- pDBData->GetArea( (SCTAB&) aRefData.Ref1.nTab,
- (SCCOL&) aRefData.Ref1.nCol,
- (SCROW&) aRefData.Ref1.nRow,
- (SCCOL&) aRefData.Ref2.nCol,
- (SCROW&) aRefData.Ref2.nRow);
- aRefData.Ref2.nTab = aRefData.Ref1.nTab;
- aRefData.CalcRelFromAbs( aPos );
+ ScRange aRange;
+ pDBData->GetArea(aRange);
+ aRange.aEnd.SetTab(aRange.aStart.Tab());
+ aRefData.SetRange(aRange, aPos);
PushTempToken( new ScDoubleRefToken( aRefData ) );
}
else
commit 39c1c4d577a56ed139b721c567c92fb60d398c9b
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Mon Jul 22 23:25:47 2013 -0400
Remove CalcAbsIfRel() since nobody uses this anymore.
Change-Id: Ie52e83b9e476b822e878488e231d60d0ce196cf4
diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx
index 259b63f..848bbd6 100644
--- a/sc/inc/refdata.hxx
+++ b/sc/inc/refdata.hxx
@@ -89,7 +89,6 @@ struct SC_DLLPUBLIC ScSingleRefData
SCTAB GetTab() const;
void CalcRelFromAbs( const ScAddress& rPos );
- void CalcAbsIfRel( const ScAddress& rPos );
bool operator==( const ScSingleRefData& ) const;
bool operator!=( const ScSingleRefData& ) const;
@@ -161,8 +160,6 @@ struct ScComplexRefData
}
inline void CalcRelFromAbs( const ScAddress& rPos )
{ Ref1.CalcRelFromAbs( rPos ); Ref2.CalcRelFromAbs( rPos ); }
- inline void CalcAbsIfRel( const ScAddress& rPos )
- { Ref1.CalcAbsIfRel( rPos ); Ref2.CalcAbsIfRel( rPos ); }
inline bool IsDeleted() const
{ return Ref1.IsDeleted() || Ref2.IsDeleted(); }
inline bool Valid() const
diff --git a/sc/source/core/tool/refdata.cxx b/sc/source/core/tool/refdata.cxx
index 2cb9105..3a7e2b0 100644
--- a/sc/source/core/tool/refdata.cxx
+++ b/sc/source/core/tool/refdata.cxx
@@ -120,30 +120,6 @@ SCTAB ScSingleRefData::GetTab() const
return Flags.bTabRel ? nRelTab : nTab;
}
-void ScSingleRefData::CalcAbsIfRel( const ScAddress& rPos )
-{
- if ( Flags.bColRel )
- {
- nCol = nRelCol + rPos.Col();
- if ( !ValidCol( nCol ) )
- Flags.bColDeleted = sal_True;
- }
- if ( Flags.bRowRel )
- {
- nRow = nRelRow + rPos.Row();
- if ( !ValidRow( nRow ) )
- Flags.bRowDeleted = sal_True;
- }
- if ( Flags.bTabRel )
- {
- nTab = nRelTab + rPos.Tab();
- if ( !ValidTab( nTab ) )
- Flags.bTabDeleted = sal_True;
- }
-}
-
-
-
bool ScSingleRefData::operator==( const ScSingleRefData& r ) const
{
return mnFlagValue == r.mnFlagValue &&
commit 40cd808fafeb1bd6fc1a4d317d8636ffaa7084dc
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Mon Jul 22 23:15:21 2013 -0400
Remove CalcAbsIfRel() from ScComplexRefData::Extend().
Change-Id: I917acbd2d2567542c6388e796fd49fe4bb48f5ae
diff --git a/sc/source/core/tool/refdata.cxx b/sc/source/core/tool/refdata.cxx
index 239fd6b..2cb9105 100644
--- a/sc/source/core/tool/refdata.cxx
+++ b/sc/source/core/tool/refdata.cxx
@@ -268,70 +268,31 @@ void ScComplexRefData::PutInOrder()
lcl_putInOrder( Ref1, Ref2);
}
-
-static void lcl_adjustInOrder( ScSingleRefData & rRef1, ScSingleRefData & rRef2, bool bFirstLeader )
+ScComplexRefData& ScComplexRefData::Extend( const ScSingleRefData & rRef, const ScAddress & rPos )
{
- // a1:a2:a3, bFirstLeader: rRef1==a1==r1, rRef2==a3==r2
- // else: rRef1==a3==r2, rRef2==a2==r1
- ScSingleRefData& r1 = (bFirstLeader ? rRef1 : rRef2);
- ScSingleRefData& r2 = (bFirstLeader ? rRef2 : rRef1);
- if (r1.Flags.bFlag3D && !r2.Flags.bFlag3D)
- {
- // [$]Sheet1.A5:A6 on Sheet2 do still refer only Sheet1.
- r2.nTab = r1.nTab;
- r2.nRelTab = r1.nRelTab;
- r2.Flags.bTabRel = r1.Flags.bTabRel;
- }
- lcl_putInOrder( rRef1, rRef2);
-}
+ ScRange aAbsRange = toAbs(rPos);
+ ScAddress aAbs = rRef.toAbs(rPos);
+ if (aAbs.Col() < aAbsRange.aStart.Col())
+ aAbsRange.aStart.SetCol(aAbs.Col());
+
+ if (aAbs.Row() < aAbsRange.aStart.Row())
+ aAbsRange.aStart.SetRow(aAbs.Row());
+
+ if (aAbs.Tab() < aAbsRange.aStart.Tab())
+ aAbsRange.aStart.SetTab(aAbs.Tab());
+
+ if (aAbsRange.aEnd.Col() < aAbs.Col())
+ aAbsRange.aEnd.SetCol(aAbs.Col());
+
+ if (aAbsRange.aEnd.Row() < aAbs.Row())
+ aAbsRange.aEnd.SetRow(aAbs.Row());
+
+ if (aAbsRange.aEnd.Tab() < aAbs.Tab())
+ aAbsRange.aEnd.SetTab(aAbs.Tab());
+
+ SetRange(aAbsRange, rPos);
-ScComplexRefData& ScComplexRefData::Extend( const ScSingleRefData & rRef, const ScAddress & rPos )
-{
- CalcAbsIfRel( rPos);
- ScSingleRefData aRef = rRef;
- aRef.CalcAbsIfRel( rPos);
- bool bInherit3D = Ref1.IsFlag3D() && !Ref2.IsFlag3D();
- bool bInherit3Dtemp = bInherit3D && !rRef.IsFlag3D();
- if (aRef.nCol < Ref1.nCol || aRef.nRow < Ref1.nRow || aRef.nTab < Ref1.nTab)
- {
- lcl_adjustInOrder( Ref1, aRef, true);
- aRef = rRef;
- aRef.CalcAbsIfRel( rPos);
- }
- if (aRef.nCol > Ref2.nCol || aRef.nRow > Ref2.nRow || aRef.nTab > Ref2.nTab)
- {
- if (bInherit3D)
- Ref2.SetFlag3D( true);
- lcl_adjustInOrder( aRef, Ref2, false);
- if (bInherit3Dtemp)
- Ref2.SetFlag3D( false);
- aRef = rRef;
- aRef.CalcAbsIfRel( rPos);
- }
- // In Ref2 use absolute/relative addressing from non-extended parts if
- // equal and therefor not adjusted.
- // A$5:A5 => A$5:A$5:A5 => A$5:A5, and not A$5:A$5
- // A$6:$A5 => A$6:A$6:$A5 => A5:$A$6
- if (Ref2.nCol == aRef.nCol)
- Ref2.SetColRel( aRef.IsColRel());
- if (Ref2.nRow == aRef.nRow)
- Ref2.SetRowRel( aRef.IsRowRel());
- // $Sheet1.$A$5:$A$6 => $Sheet1.$A$5:$A$5:$A$6 => $Sheet1.$A$5:$A$6, and
- // not $Sheet1.$A$5:Sheet1.$A$6 (with invisible second 3D, but relative).
- if (Ref2.nTab == aRef.nTab)
- Ref2.SetTabRel( bInherit3Dtemp ? Ref1.IsTabRel() : aRef.IsTabRel());
- Ref2.CalcRelFromAbs( rPos);
- // Force 3D if necessary. References to other sheets always.
- if (Ref1.nTab != rPos.Tab())
- Ref1.SetFlag3D( true);
- // In the second part only if different sheet thus not inherited.
- if (Ref2.nTab != Ref1.nTab)
- Ref2.SetFlag3D( true);
- // Merge Flag3D to Ref2 in case there was nothing to inherit and/or range
- // wasn't extended as in A5:A5:Sheet1.A5 if on Sheet1.
- if (rRef.IsFlag3D())
- Ref2.SetFlag3D( true);
return *this;
}
commit f85bb0a1569ea5c094c8132d029a3b4e94744ffd
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Mon Jul 22 23:13:57 2013 -0400
Add test for extending range reference.
Change-Id: I882f312fd0908d83203da5b48d9c3f4d002e8dd0
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index b2739d1..0aee2eb 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -117,20 +117,40 @@ void Test::testFormulaHashAndTag()
void Test::testFormulaRefData()
{
ScAddress aAddr(4,5,3), aPos(2,2,2);
- ScSingleRefData aRefData;
- aRefData.InitAddress(aAddr);
- CPPUNIT_ASSERT_MESSAGE("Wrong ref data state.", !aRefData.IsRowRel() && !aRefData.IsColRel() && !aRefData.IsTabRel());
- ASSERT_EQUAL_TYPE(SCCOL, 4, aRefData.GetCol());
- ASSERT_EQUAL_TYPE(SCROW, 5, aRefData.GetRow());
- ASSERT_EQUAL_TYPE(SCTAB, 3, aRefData.GetTab());
-
- aRefData.SetRowRel(true);
- aRefData.SetColRel(true);
- aRefData.SetTabRel(true);
- aRefData.SetAddress(aAddr, aPos);
- ASSERT_EQUAL_TYPE(SCCOL, 2, aRefData.GetCol());
- ASSERT_EQUAL_TYPE(SCROW, 3, aRefData.GetRow());
- ASSERT_EQUAL_TYPE(SCTAB, 1, aRefData.GetTab());
+ ScSingleRefData aRef;
+ aRef.InitAddress(aAddr);
+ CPPUNIT_ASSERT_MESSAGE("Wrong ref data state.", !aRef.IsRowRel() && !aRef.IsColRel() && !aRef.IsTabRel());
+ ASSERT_EQUAL_TYPE(SCCOL, 4, aRef.GetCol());
+ ASSERT_EQUAL_TYPE(SCROW, 5, aRef.GetRow());
+ ASSERT_EQUAL_TYPE(SCTAB, 3, aRef.GetTab());
+
+ aRef.SetRowRel(true);
+ aRef.SetColRel(true);
+ aRef.SetTabRel(true);
+ aRef.SetAddress(aAddr, aPos);
+ ASSERT_EQUAL_TYPE(SCCOL, 2, aRef.GetCol());
+ ASSERT_EQUAL_TYPE(SCROW, 3, aRef.GetRow());
+ ASSERT_EQUAL_TYPE(SCTAB, 1, aRef.GetTab());
+
+ // Test extension of range reference.
+
+ ScComplexRefData aDoubleRef;
+ aDoubleRef.InitRange(ScRange(2,2,0,4,4,0));
+
+ aRef.InitAddress(ScAddress(6,5,0));
+
+ aDoubleRef.Extend(aRef, ScAddress());
+ ScRange aTest = aDoubleRef.toAbs(ScAddress());
+ CPPUNIT_ASSERT_MESSAGE("Wrong start position of extended range.", aTest.aStart == ScAddress(2,2,0));
+ CPPUNIT_ASSERT_MESSAGE("Wrong end position of extended range.", aTest.aEnd == ScAddress(6,5,0));
+
+ ScComplexRefData aDoubleRef2;
+ aDoubleRef2.InitRangeRel(ScRange(1,2,0,8,6,0), ScAddress(5,5,0));
+ aDoubleRef.Extend(aDoubleRef2, ScAddress(5,5,0));
+ aTest = aDoubleRef.toAbs(ScAddress(5,5,0));
+
+ CPPUNIT_ASSERT_MESSAGE("Wrong start position of extended range.", aTest.aStart == ScAddress(1,2,0));
+ CPPUNIT_ASSERT_MESSAGE("Wrong end position of extended range.", aTest.aEnd == ScAddress(8,6,0));
}
namespace {
commit f4a7b85b6248e838d1269abe977825118927a556
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Mon Jul 22 20:51:06 2013 -0400
Add test for cell function COLUMN.
This currently fails.
Change-Id: I6a73bc5a3e966542f4dcc88fc644110ec164dcb3
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 478c5bc..71a3268 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -89,6 +89,7 @@ public:
void testFormulaRefUpdate();
void testFormulaRefUpdateRange();
void testFormulaRefUpdateSheets();
+ void testFuncCOLUMN();
void testFuncSUM();
void testFuncPRODUCT();
void testFuncN();
@@ -278,6 +279,7 @@ public:
CPPUNIT_TEST(testFormulaRefUpdate);
CPPUNIT_TEST(testFormulaRefUpdateRange);
CPPUNIT_TEST(testFormulaRefUpdateSheets);
+ CPPUNIT_TEST(testFuncCOLUMN);
CPPUNIT_TEST(testFuncSUM);
CPPUNIT_TEST(testFuncPRODUCT);
CPPUNIT_TEST(testFuncN);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 4181ec9..b2739d1 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -817,6 +817,27 @@ void Test::testFormulaRefUpdateSheets()
m_pDoc->DeleteTab(0);
}
+void Test::testFuncCOLUMN()
+{
+ m_pDoc->InsertTab(0, "Formula");
+ sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+
+ m_pDoc->SetString(ScAddress(5,10,0), "=COLUMN()");
+ CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(5,10,0)));
+
+ m_pDoc->SetString(ScAddress(0,1,0), "=F11");
+ CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(0,1,0)));
+
+ // Move the formula cell with COLUMN() function to change its value.
+ m_pDoc->InsertCol(ScRange(5,0,0,5,MAXROW,0));
+ CPPUNIT_ASSERT_EQUAL(7.0, m_pDoc->GetValue(ScAddress(6,10,0)));
+
+ // The cell that references the moved cell should update its value as well.
+ CPPUNIT_ASSERT_EQUAL(7.0, m_pDoc->GetValue(ScAddress(0,1,0)));
+
+ m_pDoc->DeleteTab(0);
+}
+
void Test::testFuncSUM()
{
OUString aTabName("foo");
More information about the Libreoffice-commits
mailing list