[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Fri Jul 19 20:20:49 PDT 2013
sc/source/core/tool/compiler.cxx | 18 ++++++------
sc/source/core/tool/token.cxx | 56 +++++++++++++++------------------------
2 files changed, 31 insertions(+), 43 deletions(-)
New commits:
commit cd4cd0bb0b68d92998148b83bdf8c9b98970f2ce
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri Jul 19 23:22:42 2013 -0400
More on removing use of CalcAbsIfRel().
Change-Id: I7706148d3a7376ca9b0c0d9c907559b384d57f14
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 0f4f484..f778321 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -4989,10 +4989,10 @@ void ScCompiler::CreateStringFromSingleRef(OUStringBuffer& rBuffer,FormulaToken*
aRef.Ref1 = aRef.Ref2 = rRef;
if ( eOp == ocColRowName )
{
- rRef.CalcAbsIfRel( aPos );
- if ( pDoc->HasStringData( rRef.nCol, rRef.nRow, rRef.nTab ) )
+ ScAddress aAbs = rRef.toAbs(aPos);
+ if (pDoc->HasStringData(aAbs.Col(), aAbs.Row(), aAbs.Tab()))
{
- String aStr = pDoc->GetString(rRef.nCol, rRef.nRow, rRef.nTab);
+ String aStr = pDoc->GetString(aAbs);
EnQuote( aStr );
rBuffer.append(aStr);
}
@@ -5111,16 +5111,16 @@ void ScCompiler::fillAddInToken(::std::vector< ::com::sun::star::sheet::FormulaO
bool ScCompiler::HandleSingleRef()
{
ScSingleRefData& rRef = static_cast<ScToken*>(mpToken.get())->GetSingleRef();
- rRef.CalcAbsIfRel( aPos );
- if ( !rRef.Valid() )
+ ScAddress aAbs = rRef.toAbs(aPos);
+ if (!ValidAddress(aAbs))
{
SetError( errNoRef );
return true;
}
- SCCOL nCol = rRef.nCol;
- SCROW nRow = rRef.nRow;
- SCTAB nTab = rRef.nTab;
- ScAddress aLook( nCol, nRow, nTab );
+ SCCOL nCol = aAbs.Col();
+ SCROW nRow = aAbs.Row();
+ SCTAB nTab = aAbs.Tab();
+ ScAddress aLook = aAbs;
bool bColName = rRef.IsColRel();
SCCOL nMyCol = aPos.Col();
SCROW nMyRow = aPos.Row();
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 6595881..0d3ff6b 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1890,40 +1890,34 @@ bool ScTokenArray::GetAdjacentExtendOfOuterFuncRefs( SCCOLROW& nExtend,
case svSingleRef :
{
ScSingleRefData& rRef = static_cast<ScToken*>(p)->GetSingleRef();
- rRef.CalcAbsIfRel( rPos );
+ ScAddress aAbs = rRef.toAbs(rPos);
switch ( eDir )
{
case DIR_BOTTOM :
- if ( rRef.nRow == nRow
- && rRef.nRow > nExtend )
+ if (aAbs.Row() == nRow && aAbs.Row() > nExtend)
{
- nExtend = rRef.nRow;
+ nExtend = aAbs.Row();
bRet = true;
}
break;
case DIR_RIGHT :
- if ( rRef.nCol == nCol
- && static_cast<SCCOLROW>(rRef.nCol)
- > nExtend )
+ if (aAbs.Col() == nCol && static_cast<SCCOLROW>(aAbs.Col()) > nExtend)
{
- nExtend = rRef.nCol;
+ nExtend = aAbs.Col();
bRet = true;
}
break;
case DIR_TOP :
- if ( rRef.nRow == nRow
- && rRef.nRow < nExtend )
+ if (aAbs.Row() == nRow && aAbs.Row() < nExtend)
{
- nExtend = rRef.nRow;
+ nExtend = aAbs.Row();
bRet = true;
}
break;
case DIR_LEFT :
- if ( rRef.nCol == nCol
- && static_cast<SCCOLROW>(rRef.nCol)
- < nExtend )
+ if (aAbs.Col() == nCol && static_cast<SCCOLROW>(aAbs.Col()) < nExtend)
{
- nExtend = rRef.nCol;
+ nExtend = aAbs.Col();
bRet = true;
}
break;
@@ -1933,40 +1927,34 @@ bool ScTokenArray::GetAdjacentExtendOfOuterFuncRefs( SCCOLROW& nExtend,
case svDoubleRef :
{
ScComplexRefData& rRef = static_cast<ScToken*>(p)->GetDoubleRef();
- rRef.CalcAbsIfRel( rPos );
+ ScRange aAbs = rRef.toAbs(rPos);
switch ( eDir )
{
case DIR_BOTTOM :
- if ( rRef.Ref1.nRow == nRow
- && rRef.Ref2.nRow > nExtend )
+ if (aAbs.aStart.Row() == nRow && aAbs.aEnd.Row() > nExtend)
{
- nExtend = rRef.Ref2.nRow;
+ nExtend = aAbs.aEnd.Row();
bRet = true;
}
break;
case DIR_RIGHT :
- if ( rRef.Ref1.nCol == nCol &&
- static_cast<SCCOLROW>(rRef.Ref2.nCol)
- > nExtend )
+ if (aAbs.aStart.Col() == nCol && static_cast<SCCOLROW>(aAbs.aEnd.Col()) > nExtend)
{
- nExtend = rRef.Ref2.nCol;
+ nExtend = aAbs.aEnd.Col();
bRet = true;
}
break;
case DIR_TOP :
- if ( rRef.Ref2.nRow == nRow
- && rRef.Ref1.nRow < nExtend )
+ if (aAbs.aEnd.Row() == nRow && aAbs.aStart.Row() < nExtend)
{
- nExtend = rRef.Ref1.nRow;
+ nExtend = aAbs.aStart.Row();
bRet = true;
}
break;
case DIR_LEFT :
- if ( rRef.Ref2.nCol == nCol &&
- static_cast<SCCOLROW>(rRef.Ref1.nCol)
- < nExtend )
+ if (aAbs.aEnd.Col() == nCol && static_cast<SCCOLROW>(aAbs.aStart.Col()) < nExtend)
{
- nExtend = rRef.Ref1.nCol;
+ nExtend = aAbs.aStart.Col();
bRet = true;
}
break;
@@ -2000,8 +1988,8 @@ void ScTokenArray::ReadjustRelative3DReferences( const ScAddress& rOldPos,
// Also adjust if the reference is of the form Sheet1.A2:A3
if ( rRef2.IsFlag3D() || static_cast<ScToken*>(pCode[j])->GetSingleRef().IsFlag3D() )
{
- rRef2.CalcAbsIfRel( rOldPos );
- rRef2.CalcRelFromAbs( rNewPos );
+ ScAddress aAbs = rRef2.toAbs(rOldPos);
+ rRef2.SetAddress(aAbs, rNewPos);
}
}
//! fallthru
@@ -2010,8 +1998,8 @@ void ScTokenArray::ReadjustRelative3DReferences( const ScAddress& rOldPos,
ScSingleRefData& rRef1 = static_cast<ScToken*>(pCode[j])->GetSingleRef();
if ( rRef1.IsFlag3D() )
{
- rRef1.CalcAbsIfRel( rOldPos );
- rRef1.CalcRelFromAbs( rNewPos );
+ ScAddress aAbs = rRef1.toAbs(rOldPos);
+ rRef1.SetAddress(aAbs, rNewPos);
}
}
break;
More information about the Libreoffice-commits
mailing list