[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 3 commits - sc/inc sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Tue Jul 30 18:56:57 PDT 2013
sc/inc/document.hxx | 2
sc/inc/refdata.hxx | 42 ++---
sc/source/core/data/conditio.cxx | 2
sc/source/core/data/documen4.cxx | 11 -
sc/source/core/data/formulacell.cxx | 70 ++++-----
sc/source/core/data/table1.cxx | 1
sc/source/core/tool/compiler.cxx | 6
sc/source/core/tool/interpr1.cxx | 12 -
sc/source/core/tool/rangenam.cxx | 54 +++++--
sc/source/core/tool/refdata.cxx | 234 +++++++++++--------------------
sc/source/core/tool/reftokenhelper.cxx | 5
sc/source/core/tool/token.cxx | 15 +
sc/source/filter/excel/excform.cxx | 29 +--
sc/source/filter/excel/excform8.cxx | 41 ++---
sc/source/filter/excel/xeformula.cxx | 15 +
sc/source/filter/excel/xelink.cxx | 4
sc/source/filter/qpro/qproform.cxx | 2
sc/source/ui/docshell/externalrefmgr.cxx | 4
sc/source/ui/unoobj/chart2uno.cxx | 8 -
sc/source/ui/unoobj/tokenuno.cxx | 4
20 files changed, 262 insertions(+), 299 deletions(-)
New commits:
commit 3084d046891f78c61747ae16996c98b63dd2a10e
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue Jul 30 21:54:00 2013 -0400
Now the reference object no longer stores both absolute and relative.
This is exactly what we needed.
Change-Id: I0e8d3064d1ea52c8d502d89f322b41435284d717
diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx
index 0d077ce..2d94299 100644
--- a/sc/inc/refdata.hxx
+++ b/sc/inc/refdata.hxx
@@ -29,12 +29,9 @@
struct SC_DLLPUBLIC ScSingleRefData
{
private:
- SCsCOL nCol; ///< Absolute values
- SCsROW nRow;
- SCsTAB nTab;
- SCsCOL nRelCol; ///< Values relative to the position
- SCsROW nRelRow;
- SCsTAB nRelTab;
+ SCCOL mnCol;
+ SCROW mnRow;
+ SCTAB mnTab;
union
{
diff --git a/sc/source/core/tool/refdata.cxx b/sc/source/core/tool/refdata.cxx
index dec9683..d830be9 100644
--- a/sc/source/core/tool/refdata.cxx
+++ b/sc/source/core/tool/refdata.cxx
@@ -27,9 +27,9 @@ void ScSingleRefData::InitAddress( const ScAddress& rAdr )
void ScSingleRefData::InitAddress( SCCOL nColP, SCROW nRowP, SCTAB nTabP )
{
InitFlags();
- nCol = nColP;
- nRow = nRowP;
- nTab = nTabP;
+ mnCol = nColP;
+ mnRow = nRowP;
+ mnTab = nTabP;
}
void ScSingleRefData::InitAddressRel( const ScAddress& rAdr, const ScAddress& rPos )
@@ -48,66 +48,57 @@ sal_uInt8 ScSingleRefData::FlagValue() const
void ScSingleRefData::SetAbsCol( SCCOL nVal )
{
Flags.bColRel = false;
- nCol = nVal;
+ mnCol = nVal;
}
void ScSingleRefData::SetRelCol( SCCOL nVal )
{
Flags.bColRel = true;
- nRelCol = nVal;
+ mnCol = nVal;
}
void ScSingleRefData::IncCol( SCCOL nInc )
{
- if (Flags.bColRel)
- nRelCol += nInc;
- else
- nCol += nInc;
+ mnCol += nInc;
}
void ScSingleRefData::SetAbsRow( SCROW nVal )
{
Flags.bRowRel = false;
- nRow = nVal;
+ mnRow = nVal;
}
void ScSingleRefData::SetRelRow( SCROW nVal )
{
Flags.bRowRel = true;
- nRelRow = nVal;
+ mnRow = nVal;
}
void ScSingleRefData::IncRow( SCROW nInc )
{
- if (Flags.bRowRel)
- nRelRow += nInc;
- else
- nRow += nInc;
+ mnRow += nInc;
}
void ScSingleRefData::SetAbsTab( SCTAB nVal )
{
Flags.bTabRel = false;
- nTab = nVal;
+ mnTab = nVal;
}
void ScSingleRefData::SetRelTab( SCTAB nVal )
{
Flags.bTabRel = true;
- nRelTab = nVal;
+ mnTab = nVal;
}
void ScSingleRefData::IncTab( SCTAB nInc )
{
- if (Flags.bTabRel)
- nRelTab += nInc;
- else
- nTab += nInc;
+ mnTab += nInc;
}
void ScSingleRefData::SetColDeleted( bool bVal )
{
- Flags.bColDeleted = (bVal ? true : false );
+ Flags.bColDeleted = bVal;
}
bool ScSingleRefData::IsColDeleted() const
@@ -117,7 +108,7 @@ bool ScSingleRefData::IsColDeleted() const
void ScSingleRefData::SetRowDeleted( bool bVal )
{
- Flags.bRowDeleted = (bVal ? true : false );
+ Flags.bRowDeleted = bVal;
}
bool ScSingleRefData::IsRowDeleted() const
@@ -127,7 +118,7 @@ bool ScSingleRefData::IsRowDeleted() const
void ScSingleRefData::SetTabDeleted( bool bVal )
{
- Flags.bTabDeleted = (bVal ? true : false );
+ Flags.bTabDeleted = bVal;
}
bool ScSingleRefData::IsTabDeleted() const
@@ -149,12 +140,12 @@ bool ScSingleRefData::ColValid() const
{
if (Flags.bColRel)
{
- if (nRelCol < -MAXCOL || MAXCOL < nRelCol)
+ if (mnCol < -MAXCOL || MAXCOL < mnCol)
return false;
}
else
{
- if (nCol < 0 || MAXCOL < nCol)
+ if (mnCol < 0 || MAXCOL < mnCol)
return false;
}
@@ -165,12 +156,12 @@ bool ScSingleRefData::RowValid() const
{
if (Flags.bRowRel)
{
- if (nRelRow < -MAXROW || MAXROW < nRelRow)
+ if (mnRow < -MAXROW || MAXROW < mnRow)
return false;
}
else
{
- if (nRow < 0 || MAXROW < nRow)
+ if (mnRow < 0 || MAXROW < mnRow)
return false;
}
@@ -181,12 +172,12 @@ bool ScSingleRefData::TabValid() const
{
if (Flags.bTabRel)
{
- if (nRelTab < -MAXTAB || MAXTAB < nRelTab)
+ if (mnTab < -MAXTAB || MAXTAB < mnTab)
return false;
}
else
{
- if (nTab < 0 || MAXTAB < nTab)
+ if (mnTab < 0 || MAXTAB < mnTab)
return false;
}
@@ -195,14 +186,14 @@ bool ScSingleRefData::TabValid() const
bool ScSingleRefData::ValidExternal() const
{
- return ColValid() && RowValid() && nTab == -1;
+ return ColValid() && RowValid() && mnTab == -1;
}
ScAddress ScSingleRefData::toAbs( const ScAddress& rPos ) const
{
- SCCOL nRetCol = Flags.bColRel ? nRelCol + rPos.Col() : nCol;
- SCROW nRetRow = Flags.bRowRel ? nRelRow + rPos.Row() : nRow;
- SCTAB nRetTab = Flags.bTabRel ? nRelTab + rPos.Tab() : nTab;
+ SCCOL nRetCol = Flags.bColRel ? mnCol + rPos.Col() : mnCol;
+ SCROW nRetRow = Flags.bRowRel ? mnRow + rPos.Row() : mnRow;
+ SCTAB nRetTab = Flags.bTabRel ? mnTab + rPos.Tab() : mnTab;
ScAddress aAbs(ScAddress::INITIALIZE_INVALID);
@@ -221,48 +212,45 @@ ScAddress ScSingleRefData::toAbs( const ScAddress& rPos ) const
void ScSingleRefData::SetAddress( const ScAddress& rAddr, const ScAddress& rPos )
{
if (Flags.bColRel)
- nRelCol = rAddr.Col() - rPos.Col();
+ mnCol = rAddr.Col() - rPos.Col();
else
- nCol = rAddr.Col();
+ mnCol = rAddr.Col();
if (Flags.bRowRel)
- nRelRow = rAddr.Row() - rPos.Row();
+ mnRow = rAddr.Row() - rPos.Row();
else
- nRow = rAddr.Row();
+ mnRow = rAddr.Row();
if (Flags.bTabRel)
- nRelTab = rAddr.Tab() - rPos.Tab();
+ mnTab = rAddr.Tab() - rPos.Tab();
else
- nTab = rAddr.Tab();
+ mnTab = rAddr.Tab();
}
SCROW ScSingleRefData::Row() const
{
if (Flags.bRowDeleted)
return -1;
- return Flags.bRowRel ? nRelRow : nRow;
+ return mnRow;
}
SCCOL ScSingleRefData::Col() const
{
if (Flags.bColDeleted)
return -1;
- return Flags.bColRel ? nRelCol : nCol;
+ return mnCol;
}
SCTAB ScSingleRefData::Tab() const
{
if (Flags.bTabDeleted)
return -1;
- return Flags.bTabRel ? nRelTab : nTab;
+ return mnTab;
}
bool ScSingleRefData::operator==( const ScSingleRefData& r ) const
{
- return mnFlagValue == r.mnFlagValue &&
- (Flags.bColRel ? nRelCol == r.nRelCol : nCol == r.nCol) &&
- (Flags.bRowRel ? nRelRow == r.nRelRow : nRow == r.nRow) &&
- (Flags.bTabRel ? nRelTab == r.nRelTab : nTab == r.nTab);
+ return mnFlagValue == r.mnFlagValue && mnCol == r.mnCol && mnRow == r.mnRow && mnTab == r.mnTab;
}
bool ScSingleRefData::operator!=( const ScSingleRefData& r ) const
@@ -283,8 +271,7 @@ void ScSingleRefData::Dump( int nIndent ) const
cout << aIndent << "deleted column: " << (IsColDeleted()?"yes":"no")
<< " row : " << (IsRowDeleted()?"yes":"no") << " sheet: "
<< (IsTabDeleted()?"yes":"no") << endl;
- cout << aIndent << "absolute pos column: " << nCol << " row: " << nRow << " sheet: " << nTab << endl;
- cout << aIndent << "relative pos column: " << nRelCol << " row: " << nRelRow << " sheet: " << nRelTab << endl;
+ cout << aIndent << "column: " << mnCol << " row: " << mnRow << " sheet: " << mnTab << endl;
cout << aIndent << "3d ref: " << (IsFlag3D()?"yes":"no") << endl;
}
#endif
commit 47636ee905da7c0b61470ccd343cf57a2b6a5e1a
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue Jul 30 21:36:50 2013 -0400
Clean this up a bit.
Change-Id: Ia984c17eda507dc625e2b038818abd2d4e9e5103
diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx
index 10c7a63..0d077ce 100644
--- a/sc/inc/refdata.hxx
+++ b/sc/inc/refdata.hxx
@@ -62,12 +62,12 @@ public:
void InitAddressRel( const ScAddress& rAdr, const ScAddress& rPos );
sal_uInt8 FlagValue() const;
- 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 ); }
- inline bool IsRowRel() const { return Flags.bRowRel; }
- inline void SetTabRel( bool bVal ) { Flags.bTabRel = (bVal ? true : false ); }
- inline bool IsTabRel() const { return Flags.bTabRel; }
+ void SetColRel( bool bVal ) { Flags.bColRel = bVal; }
+ bool IsColRel() const { return Flags.bColRel; }
+ void SetRowRel( bool bVal ) { Flags.bRowRel = bVal; }
+ bool IsRowRel() const { return Flags.bRowRel; }
+ void SetTabRel( bool bVal ) { Flags.bTabRel = bVal; }
+ bool IsTabRel() const { return Flags.bTabRel; }
void SetAbsCol( SCCOL nVal );
void SetRelCol( SCCOL nVal );
@@ -87,10 +87,10 @@ public:
bool IsTabDeleted() const;
bool IsDeleted() const;
- inline void SetFlag3D( bool bVal ) { Flags.bFlag3D = (bVal ? true : false ); }
- inline bool IsFlag3D() const { return Flags.bFlag3D; }
- inline void SetRelName( bool bVal ) { Flags.bRelName = (bVal ? true : false ); }
- inline bool IsRelName() const { return Flags.bRelName; }
+ void SetFlag3D( bool bVal ) { Flags.bFlag3D = bVal; }
+ bool IsFlag3D() const { return Flags.bFlag3D; }
+ void SetRelName( bool bVal ) { Flags.bRelName = bVal; }
+ bool IsRelName() const { return Flags.bRelName; }
bool Valid() const;
bool ColValid() const;
@@ -105,8 +105,8 @@ public:
SCCOL Col() const;
SCTAB Tab() const;
- bool operator==( const ScSingleRefData& ) const;
- bool operator!=( const ScSingleRefData& ) const;
+ bool operator==( const ScSingleRefData& ) const;
+ bool operator!=( const ScSingleRefData& ) const;
#if DEBUG_FORMULA_COMPILER
void Dump( int nIndent = 0 ) const;
commit 01c1638f30069d29574b70a5dbbea30e4846c256
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Tue Jul 30 21:27:21 2013 -0400
Now nobody accesses reference members directly. Make them private.
Change-Id: If4499dbee52532cc8a95c380bbe840719fe9279b
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index ea2d65f..9c30744 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -647,7 +647,7 @@ public:
SC_DLLPUBLIC ScExternalRefManager* GetExternalRefManager() const;
bool IsInExternalReferenceMarking() const;
void MarkUsedExternalReferences();
- bool MarkUsedExternalReferences( ScTokenArray & rArr );
+ bool MarkUsedExternalReferences( ScTokenArray& rArr, const ScAddress& rPos );
/** Returns the pool containing external formula parsers. Creates the pool
on first call. */
diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx
index 653d1a0..10c7a63 100644
--- a/sc/inc/refdata.hxx
+++ b/sc/inc/refdata.hxx
@@ -28,6 +28,7 @@
/// Single reference (one address) into the sheet
struct SC_DLLPUBLIC ScSingleRefData
{
+private:
SCsCOL nCol; ///< Absolute values
SCsROW nRow;
SCsTAB nTab;
@@ -51,6 +52,7 @@ struct SC_DLLPUBLIC ScSingleRefData
} Flags;
};
+public:
/// No default ctor, because used in ScRawToken union, set InitFlags!
inline void InitFlags() { mnFlagValue = 0; } ///< all FALSE
/// InitAddress: InitFlags and set address
@@ -58,6 +60,8 @@ struct SC_DLLPUBLIC ScSingleRefData
void InitAddress( SCCOL nCol, SCROW nRow, SCTAB nTab );
/// InitAddressRel: InitFlags and set address, everything relative to rPos
void InitAddressRel( const ScAddress& rAdr, const ScAddress& rPos );
+ sal_uInt8 FlagValue() const;
+
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 ); }
@@ -89,6 +93,9 @@ struct SC_DLLPUBLIC ScSingleRefData
inline bool IsRelName() const { return Flags.bRelName; }
bool Valid() const;
+ bool ColValid() const;
+ bool RowValid() const;
+ bool TabValid() const;
/// In external references nTab is -1
bool ValidExternal() const;
@@ -141,8 +148,6 @@ struct ScComplexRefData
SC_DLLPUBLIC ScRange toAbs( const ScAddress& rPos ) const;
void SetRange( const ScRange& rRange, const ScAddress& rPos );
- /// Absolute references have to be up-to-date when calling this!
- void PutInOrder();
inline bool operator==( const ScComplexRefData& r ) const
{ return Ref1 == r.Ref1 && Ref2 == r.Ref2; }
/** Enlarge range if reference passed is not within existing range.
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index c0939ff..993058e 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -1476,7 +1476,7 @@ bool ScConditionEntry::MarkUsedExternalReferences() const
{
ScTokenArray* pFormula = nPass ? pFormula2 : pFormula1;
if (pFormula)
- bAllMarked = mpDoc->MarkUsedExternalReferences( *pFormula);
+ bAllMarked = mpDoc->MarkUsedExternalReferences(*pFormula, aSrcPos);
}
return bAllMarked;
}
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index 38f012a..6abc607 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -295,7 +295,7 @@ void ScDocument::InsertTableOp(const ScTabOpParam& rParam, // Mehrfachopera
namespace {
-bool setCacheTableReferenced(ScToken& rToken, ScExternalRefManager& rRefMgr)
+bool setCacheTableReferenced(ScToken& rToken, ScExternalRefManager& rRefMgr, const ScAddress& rPos)
{
switch (rToken.GetType())
{
@@ -305,7 +305,8 @@ bool setCacheTableReferenced(ScToken& rToken, ScExternalRefManager& rRefMgr)
case svExternalDoubleRef:
{
const ScComplexRefData& rRef = rToken.GetDoubleRef();
- size_t nSheets = rRef.Ref2.nTab - rRef.Ref1.nTab + 1;
+ ScRange aAbs = rRef.toAbs(rPos);
+ size_t nSheets = aAbs.aEnd.Tab() - aAbs.aStart.Tab() + 1;
return rRefMgr.setCacheTableReferenced(
rToken.GetIndex(), rToken.GetString(), nSheets);
}
@@ -322,7 +323,7 @@ bool setCacheTableReferenced(ScToken& rToken, ScExternalRefManager& rRefMgr)
}
-bool ScDocument::MarkUsedExternalReferences( ScTokenArray & rArr )
+bool ScDocument::MarkUsedExternalReferences( ScTokenArray& rArr, const ScAddress& rPos )
{
if (!rArr.GetLen())
return false;
@@ -338,7 +339,7 @@ bool ScDocument::MarkUsedExternalReferences( ScTokenArray & rArr )
if (!pRefMgr)
pRefMgr = GetExternalRefManager();
- bAllMarked = setCacheTableReferenced(*t, *pRefMgr);
+ bAllMarked = setCacheTableReferenced(*t, *pRefMgr, rPos);
}
else if (t->GetType() == svIndex)
{
@@ -357,7 +358,7 @@ bool ScDocument::MarkUsedExternalReferences( ScTokenArray & rArr )
if (!pRefMgr)
pRefMgr = GetExternalRefManager();
- bAllMarked = setCacheTableReferenced(*t, *pRefMgr);
+ bAllMarked = setCacheTableReferenced(*t, *pRefMgr, rPos);
}
}
}
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index baec27d..0ad7cb6 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -913,7 +913,7 @@ void ScFormulaCell::CalcAfterLoad()
bool ScFormulaCell::MarkUsedExternalReferences()
{
- return pCode && pDocument->MarkUsedExternalReferences( *pCode);
+ return pCode && pDocument->MarkUsedExternalReferences(*pCode, aPos);
}
@@ -2630,56 +2630,56 @@ void ScFormulaCell::UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt, SCTAB nTab
void ScFormulaCell::UpdateInsertTabAbs(SCTAB nTable)
{
- if( !pDocument->IsClipOrUndo() )
+ if (pDocument->IsClipOrUndo())
+ return;
+
+ pCode->Reset();
+ ScToken* p = static_cast<ScToken*>(pCode->GetNextReferenceRPN());
+ while (p)
{
- pCode->Reset();
- ScToken* p = static_cast<ScToken*>(pCode->GetNextReferenceRPN());
- while( p )
+ ScSingleRefData& rRef1 = p->GetSingleRef();
+ if (!rRef1.IsTabRel() && nTable <= rRef1.Tab())
+ rRef1.IncTab(1);
+ if (p->GetType() == formula::svDoubleRef)
{
- ScSingleRefData& rRef1 = p->GetSingleRef();
- if( !rRef1.IsTabRel() && (SCsTAB) nTable <= rRef1.nTab )
- rRef1.nTab++;
- if( p->GetType() == formula::svDoubleRef )
- {
- ScSingleRefData& rRef2 = p->GetDoubleRef().Ref2;
- if( !rRef2.IsTabRel() && (SCsTAB) nTable <= rRef2.nTab )
- rRef2.nTab++;
- }
- p = static_cast<ScToken*>(pCode->GetNextReferenceRPN());
+ ScSingleRefData& rRef2 = p->GetDoubleRef().Ref2;
+ if (!rRef2.IsTabRel() && nTable <= rRef2.Tab())
+ rRef2.IncTab(1);
}
+ p = static_cast<ScToken*>(pCode->GetNextReferenceRPN());
}
}
bool ScFormulaCell::TestTabRefAbs(SCTAB nTable)
{
+ if (pDocument->IsClipOrUndo())
+ return false;
+
bool bRet = false;
- if( !pDocument->IsClipOrUndo() )
+ pCode->Reset();
+ ScToken* p = static_cast<ScToken*>(pCode->GetNextReferenceRPN());
+ while (p)
{
- pCode->Reset();
- ScToken* p = static_cast<ScToken*>(pCode->GetNextReferenceRPN());
- while( p )
+ ScSingleRefData& rRef1 = p->GetSingleRef();
+ if (!rRef1.IsTabRel())
{
- ScSingleRefData& rRef1 = p->GetSingleRef();
- if( !rRef1.IsTabRel() )
+ if (nTable != rRef1.Tab())
+ bRet = true;
+ else if (nTable != aPos.Tab())
+ rRef1.SetAbsTab(aPos.Tab());
+ }
+ if (p->GetType() == formula::svDoubleRef)
+ {
+ ScSingleRefData& rRef2 = p->GetDoubleRef().Ref2;
+ if (!rRef2.IsTabRel())
{
- if( (SCsTAB) nTable != rRef1.nTab )
+ if(nTable != rRef2.Tab())
bRet = true;
else if (nTable != aPos.Tab())
- rRef1.nTab = aPos.Tab();
- }
- if( p->GetType() == formula::svDoubleRef )
- {
- ScSingleRefData& rRef2 = p->GetDoubleRef().Ref2;
- if( !rRef2.IsTabRel() )
- {
- if( (SCsTAB) nTable != rRef2.nTab )
- bRet = true;
- else if (nTable != aPos.Tab())
- rRef2.nTab = aPos.Tab();
- }
+ rRef2.SetAbsTab(aPos.Tab());
}
- p = static_cast<ScToken*>(pCode->GetNextReferenceRPN());
}
+ p = static_cast<ScToken*>(pCode->GetNextReferenceRPN());
}
return bRet;
}
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index b3d1d28..5f409ba 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -1464,7 +1464,6 @@ void ScTable::UpdateReference(
iMax = MAXCOL;
}
- ScRange aRange = rCxt.maRange;
UpdateRefMode eUpdateRefMode = rCxt.meMode;
SCCOL nDx = rCxt.mnColDelta;
SCROW nDy = rCxt.mnRowDelta;
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 55668cc..4d140ba 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -1068,8 +1068,8 @@ struct ConventionXL
rDocName.Erase();
OUString aTmp;
- if (rRef.IsTabDeleted() ||
- !rComp.GetDoc()->GetName( rRef.nTab, aTmp ))
+ ScAddress aAbs = rRef.toAbs(rComp.GetPos());
+ if (rRef.IsTabDeleted() || !rComp.GetDoc()->GetName(aAbs.Tab(), aTmp))
{
rTabName = ScGlobal::GetRscString( STR_NO_REF_TABLE );
return false;
@@ -1320,7 +1320,7 @@ struct ConventionXL_A1 : public Convention_A1, public ConventionXL
return;
}
- if( aRef.Ref1.nRow == 0 && aRef.Ref2.nRow >= MAXROW )
+ if (aAbs1.Row() == 0 && aAbs2.Row() >= MAXROW)
{
if (!aRef.Ref1.IsColRel())
rBuf.append(sal_Unicode( '$' ));
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index f9c3a4c..4fc860c 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -2571,14 +2571,14 @@ void ScInterpreter::ScCellExternal()
SCCOL nCol;
SCROW nRow;
SCTAB nTab;
- aRef.nTab = 0; // external ref has a tab index of -1, which SingleRefToVars() don't like.
+ aRef.SetAbsTab(0); // external ref has a tab index of -1, which SingleRefToVars() don't like.
SingleRefToVars(aRef, nCol, nRow, nTab);
if (nGlobalError)
{
PushIllegalParameter();
return;
}
- aRef.nTab = -1; // revert the value.
+ aRef.SetAbsTab(-1); // revert the value.
ScCellKeywordTranslator::transKeyword(aInfoType, ScGlobal::GetLocale(), ocCell);
ScExternalRefManager* pRefMgr = pDok->GetExternalRefManager();
@@ -4047,8 +4047,9 @@ void ScInterpreter::ScRows()
String aTabName;
ScComplexRefData aRef;
PopExternalDoubleRef( nFileId, aTabName, aRef);
- nVal += static_cast<sal_uLong>(aRef.Ref2.nTab - aRef.Ref1.nTab + 1) *
- static_cast<sal_uLong>(aRef.Ref2.nRow - aRef.Ref1.nRow + 1);
+ ScRange aAbs = aRef.toAbs(aPos);
+ nVal += static_cast<sal_uLong>(aAbs.aEnd.Tab() - aAbs.aStart.Tab() + 1) *
+ static_cast<sal_uLong>(aAbs.aEnd.Row() - aAbs.aStart.Row() + 1);
}
break;
default:
@@ -4100,7 +4101,8 @@ void ScInterpreter::ScTables()
String aTabName;
ScComplexRefData aRef;
PopExternalDoubleRef( nFileId, aTabName, aRef);
- nVal += static_cast<sal_uLong>(aRef.Ref2.nTab - aRef.Ref1.nTab + 1);
+ ScRange aAbs = aRef.toAbs(aPos);
+ nVal += static_cast<sal_uLong>(aAbs.aEnd.Tab() - aAbs.aStart.Tab() + 1);
}
break;
default:
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index aae97ed..5df9813 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -548,22 +548,24 @@ void ScRangeData::ValidateTabRefs()
while ( ( t = static_cast<ScToken*>(pCode->GetNextReference()) ) != NULL )
{
ScSingleRefData& rRef1 = t->GetSingleRef();
+ ScAddress aAbs = rRef1.toAbs(aPos);
if ( rRef1.IsTabRel() && !rRef1.IsTabDeleted() )
{
- if ( rRef1.nTab < nMinTab )
- nMinTab = rRef1.nTab;
- if ( rRef1.nTab > nMaxTab )
- nMaxTab = rRef1.nTab;
+ if (aAbs.Tab() < nMinTab)
+ nMinTab = aAbs.Tab();
+ if (aAbs.Tab() > nMaxTab)
+ nMaxTab = aAbs.Tab();
}
if ( t->GetType() == svDoubleRef )
{
ScSingleRefData& rRef2 = t->GetDoubleRef().Ref2;
+ aAbs = rRef2.toAbs(aPos);
if ( rRef2.IsTabRel() && !rRef2.IsTabDeleted() )
{
- if ( rRef2.nTab < nMinTab )
- nMinTab = rRef2.nTab;
- if ( rRef2.nTab > nMaxTab )
- nMaxTab = rRef2.nTab;
+ if (aAbs.Tab() < nMinTab)
+ nMinTab = aAbs.Tab();
+ if (aAbs.Tab() > nMaxTab)
+ nMaxTab = aAbs.Tab();
}
}
}
@@ -575,19 +577,41 @@ void ScRangeData::ValidateTabRefs()
// The formulas that use the name are not changed by this
SCTAB nMove = nMinTab;
+ ScAddress aOldPos = aPos;
aPos.SetTab( aPos.Tab() - nMove );
pCode->Reset();
while ( ( t = static_cast<ScToken*>(pCode->GetNextReference()) ) != NULL )
{
- ScSingleRefData& rRef1 = t->GetSingleRef();
- if ( rRef1.IsTabRel() && !rRef1.IsTabDeleted() )
- rRef1.nTab = sal::static_int_cast<SCsTAB>( rRef1.nTab - nMove );
- if ( t->GetType() == svDoubleRef )
+ switch (t->GetType())
{
- ScSingleRefData& rRef2 = t->GetDoubleRef().Ref2;
- if ( rRef2.IsTabRel() && !rRef2.IsTabDeleted() )
- rRef2.nTab = sal::static_int_cast<SCsTAB>( rRef2.nTab - nMove );
+ case svSingleRef:
+ {
+ ScSingleRefData& rRef = t->GetSingleRef();
+ if (!rRef.IsTabDeleted())
+ {
+ ScAddress aAbs = rRef.toAbs(aOldPos);
+ rRef.SetAddress(aAbs, aPos);
+ }
+ }
+ break;
+ case svDoubleRef:
+ {
+ ScComplexRefData& rRef = t->GetDoubleRef();
+ if (!rRef.Ref1.IsTabDeleted())
+ {
+ ScAddress aAbs = rRef.Ref1.toAbs(aOldPos);
+ rRef.Ref1.SetAddress(aAbs, aPos);
+ }
+ if (!rRef.Ref2.IsTabDeleted())
+ {
+ ScAddress aAbs = rRef.Ref2.toAbs(aOldPos);
+ rRef.Ref2.SetAddress(aAbs, aPos);
+ }
+ }
+ break;
+ default:
+ ;
}
}
}
diff --git a/sc/source/core/tool/refdata.cxx b/sc/source/core/tool/refdata.cxx
index 5969c88..dec9683 100644
--- a/sc/source/core/tool/refdata.cxx
+++ b/sc/source/core/tool/refdata.cxx
@@ -40,6 +40,11 @@ void ScSingleRefData::InitAddressRel( const ScAddress& rAdr, const ScAddress& rP
SetAddress(rAdr, rPos);
}
+sal_uInt8 ScSingleRefData::FlagValue() const
+{
+ return mnFlagValue;
+}
+
void ScSingleRefData::SetAbsCol( SCCOL nVal )
{
Flags.bColRel = false;
@@ -137,16 +142,60 @@ bool ScSingleRefData::IsDeleted() const
bool ScSingleRefData::Valid() const
{
- return nCol >= 0 && nCol <= MAXCOL &&
- nRow >= 0 && nRow <= MAXROW &&
- nTab >= 0 && nTab <= MAXTAB;
+ return ColValid() && RowValid() && TabValid();
+}
+
+bool ScSingleRefData::ColValid() const
+{
+ if (Flags.bColRel)
+ {
+ if (nRelCol < -MAXCOL || MAXCOL < nRelCol)
+ return false;
+ }
+ else
+ {
+ if (nCol < 0 || MAXCOL < nCol)
+ return false;
+ }
+
+ return true;
+}
+
+bool ScSingleRefData::RowValid() const
+{
+ if (Flags.bRowRel)
+ {
+ if (nRelRow < -MAXROW || MAXROW < nRelRow)
+ return false;
+ }
+ else
+ {
+ if (nRow < 0 || MAXROW < nRow)
+ return false;
+ }
+
+ return true;
+}
+
+bool ScSingleRefData::TabValid() const
+{
+ if (Flags.bTabRel)
+ {
+ if (nRelTab < -MAXTAB || MAXTAB < nRelTab)
+ return false;
+ }
+ else
+ {
+ if (nTab < 0 || MAXTAB < nTab)
+ return false;
+ }
+
+ return true;
}
bool ScSingleRefData::ValidExternal() const
{
- return nCol >= 0 && nCol <= MAXCOL &&
- nRow >= 0 && nRow <= MAXROW &&
- nTab == -1;
+ return ColValid() && RowValid() && nTab == -1;
}
ScAddress ScSingleRefData::toAbs( const ScAddress& rPos ) const
@@ -240,103 +289,6 @@ void ScSingleRefData::Dump( int nIndent ) const
}
#endif
-static void lcl_putInOrder( ScSingleRefData & rRef1, ScSingleRefData & rRef2 )
-{
- SCCOL nCol1, nCol2;
- SCROW nRow1, nRow2;
- SCTAB nTab1, nTab2;
- bool bTmp;
- sal_uInt8 nRelState1, nRelState2;
- if ( rRef1.Flags.bRelName )
- nRelState1 =
- ((rRef1.Flags.bTabRel & 0x01) << 2)
- | ((rRef1.Flags.bRowRel & 0x01) << 1)
- | ((rRef1.Flags.bColRel & 0x01));
- else
- nRelState1 = 0;
- if ( rRef2.Flags.bRelName )
- nRelState2 =
- ((rRef2.Flags.bTabRel & 0x01) << 2)
- | ((rRef2.Flags.bRowRel & 0x01) << 1)
- | ((rRef2.Flags.bColRel & 0x01));
- else
- nRelState2 = 0;
- if ( (nCol1 = rRef1.nCol) > (nCol2 = rRef2.nCol) )
- {
- rRef1.nCol = nCol2;
- rRef2.nCol = nCol1;
- nCol1 = rRef1.nRelCol;
- rRef1.nRelCol = rRef2.nRelCol;
- rRef2.nRelCol = nCol1;
- if ( rRef1.Flags.bRelName && rRef1.Flags.bColRel )
- nRelState2 |= 1;
- else
- nRelState2 &= ~1;
- if ( rRef2.Flags.bRelName && rRef2.Flags.bColRel )
- nRelState1 |= 1;
- else
- nRelState1 &= ~1;
- bTmp = rRef1.Flags.bColRel;
- rRef1.Flags.bColRel = rRef2.Flags.bColRel;
- rRef2.Flags.bColRel = bTmp;
- bTmp = rRef1.Flags.bColDeleted;
- rRef1.Flags.bColDeleted = rRef2.Flags.bColDeleted;
- rRef2.Flags.bColDeleted = bTmp;
- }
- if ( (nRow1 = rRef1.nRow) > (nRow2 = rRef2.nRow) )
- {
- rRef1.nRow = nRow2;
- rRef2.nRow = nRow1;
- nRow1 = rRef1.nRelRow;
- rRef1.nRelRow = rRef2.nRelRow;
- rRef2.nRelRow = nRow1;
- if ( rRef1.Flags.bRelName && rRef1.Flags.bRowRel )
- nRelState2 |= 2;
- else
- nRelState2 &= ~2;
- if ( rRef2.Flags.bRelName && rRef2.Flags.bRowRel )
- nRelState1 |= 2;
- else
- nRelState1 &= ~2;
- bTmp = rRef1.Flags.bRowRel;
- rRef1.Flags.bRowRel = rRef2.Flags.bRowRel;
- rRef2.Flags.bRowRel = bTmp;
- bTmp = rRef1.Flags.bRowDeleted;
- rRef1.Flags.bRowDeleted = rRef2.Flags.bRowDeleted;
- rRef2.Flags.bRowDeleted = bTmp;
- }
- if ( (nTab1 = rRef1.nTab) > (nTab2 = rRef2.nTab) )
- {
- rRef1.nTab = nTab2;
- rRef2.nTab = nTab1;
- nTab1 = rRef1.nRelTab;
- rRef1.nRelTab = rRef2.nRelTab;
- rRef2.nRelTab = nTab1;
- if ( rRef1.Flags.bRelName && rRef1.Flags.bTabRel )
- nRelState2 |= 4;
- else
- nRelState2 &= ~4;
- if ( rRef2.Flags.bRelName && rRef2.Flags.bTabRel )
- nRelState1 |= 4;
- else
- nRelState1 &= ~4;
- bTmp = rRef1.Flags.bTabRel;
- rRef1.Flags.bTabRel = rRef2.Flags.bTabRel;
- rRef2.Flags.bTabRel = bTmp;
- bTmp = rRef1.Flags.bTabDeleted;
- rRef1.Flags.bTabDeleted = rRef2.Flags.bTabDeleted;
- rRef2.Flags.bTabDeleted = bTmp;
- }
- rRef1.Flags.bRelName = ( nRelState1 ? sal_True : false );
- rRef2.Flags.bRelName = ( nRelState2 ? sal_True : false );
-}
-
-
-void ScComplexRefData::PutInOrder()
-{
- lcl_putInOrder( Ref1, Ref2);
-}
-
ScComplexRefData& ScComplexRefData::Extend( const ScSingleRefData & rRef, const ScAddress & rPos )
{
ScRange aAbsRange = toAbs(rPos);
@@ -383,10 +335,7 @@ bool ScComplexRefData::Valid() const
bool ScComplexRefData::ValidExternal() const
{
- return Ref1.ValidExternal() &&
- Ref2.nCol >= 0 && Ref2.nCol <= MAXCOL &&
- Ref2.nRow >= 0 && Ref2.nRow <= MAXROW &&
- Ref2.nTab >= Ref1.nTab;
+ return Ref1.ValidExternal() && Ref2.ColValid() && Ref2.RowValid() && Ref1.Tab() <= Ref2.Tab();
}
ScRange ScComplexRefData::toAbs( const ScAddress& rPos ) const
diff --git a/sc/source/core/tool/reftokenhelper.cxx b/sc/source/core/tool/reftokenhelper.cxx
index 6b8d288..e6687ba 100644
--- a/sc/source/core/tool/reftokenhelper.cxx
+++ b/sc/source/core/tool/reftokenhelper.cxx
@@ -352,11 +352,12 @@ private:
if (!ScRefTokenHelper::getDoubleRefDataFromToken(aOldData, pOldToken))
continue;
- if (aData.Ref1.nTab != aOldData.Ref1.nTab || aData.Ref2.nTab != aOldData.Ref2.nTab)
+ ScRange aOld = aOldData.toAbs(rPos), aNew = aData.toAbs(rPos);
+
+ if (aNew.aStart.Tab() != aOld.aStart.Tab() || aNew.aEnd.Tab() != aOld.aEnd.Tab())
// Sheet ranges differ.
continue;
- ScRange aOld = aOldData.toAbs(rPos), aNew = aData.toAbs(rPos);
if (aOld.In(aNew))
// This new range is part of an existing range. Skip it.
return;
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 96e389f..83094d2 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -511,7 +511,7 @@ bool ScToken::TextEqual( const FormulaToken& _rToken ) const
// memcmp doesn't work because of the alignment byte after bFlags.
// After SmartRelAbs only absolute parts have to be compared.
- return aRange1 == aRange2 && aTemp1.Ref1.mnFlagValue == aTemp2.Ref1.mnFlagValue && aTemp1.Ref2.mnFlagValue == aTemp2.Ref2.mnFlagValue;
+ return aRange1 == aRange2 && aTemp1.Ref1.FlagValue() == aTemp2.Ref1.FlagValue() && aTemp1.Ref2.FlagValue() == aTemp2.Ref2.FlagValue();
}
else
return *this == _rToken; // else normal operator==
@@ -1226,7 +1226,8 @@ bool ScTokenArray::AddFormulaToken(const com::sun::star::sheet::FormulaToken& _a
lcl_ExternalRefToCalc( aComplRef.Ref1, aApiCRef.Reference1 );
lcl_ExternalRefToCalc( aComplRef.Ref2, aApiCRef.Reference2 );
// NOTE: This assumes that cached sheets are in consecutive order!
- aComplRef.Ref2.nTab = aComplRef.Ref1.nTab + static_cast<SCsTAB>(aApiCRef.Reference2.Sheet - aApiCRef.Reference1.Sheet);
+ aComplRef.Ref2.SetAbsTab(
+ aComplRef.Ref1.Tab() + static_cast<SCTAB>(aApiCRef.Reference2.Sheet - aApiCRef.Reference1.Sheet));
AddExternalDoubleReference( nFileId, aTabName, aComplRef );
}
else
@@ -1384,9 +1385,9 @@ size_t HashSingleRef( const ScSingleRefData& rRef )
{
size_t nVal = 0;
- nVal += rRef.Flags.bColRel;
- nVal += (rRef.Flags.bRowRel << 1);
- nVal += (rRef.Flags.bTabRel << 2);
+ nVal += rRef.IsColRel();
+ nVal += (rRef.IsRowRel() << 1);
+ nVal += (rRef.IsTabRel() << 2);
return nVal;
}
@@ -2100,7 +2101,7 @@ void ScTokenArray::ReadjustAbsolute3DReferences( const ScDocument* pOldDoc, cons
{
OUString aTabName;
sal_uInt16 nFileId;
- GetExternalTableData(pOldDoc, pNewDoc, rRef1.nTab, aTabName, nFileId);
+ GetExternalTableData(pOldDoc, pNewDoc, rRef1.Tab(), aTabName, nFileId);
pCode[j]->DecRef();
ScExternalDoubleRefToken* pToken = new ScExternalDoubleRefToken(nFileId, aTabName, rRef);
pToken->IncRef();
@@ -2119,7 +2120,7 @@ void ScTokenArray::ReadjustAbsolute3DReferences( const ScDocument* pOldDoc, cons
{
OUString aTabName;
sal_uInt16 nFileId;
- GetExternalTableData(pOldDoc, pNewDoc, rRef.nTab, aTabName, nFileId);
+ GetExternalTableData(pOldDoc, pNewDoc, rRef.Tab(), aTabName, nFileId);
//replace with ScExternalSingleRefToken and adjust references
pCode[j]->DecRef();
ScExternalSingleRefToken* pToken = new ScExternalSingleRefToken(nFileId, aTabName, rRef);
diff --git a/sc/source/filter/excel/excform.cxx b/sc/source/filter/excel/excform.cxx
index 7918bad..b2a1619 100644
--- a/sc/source/filter/excel/excform.cxx
+++ b/sc/source/filter/excel/excform.cxx
@@ -720,9 +720,8 @@ ConvErr ExcelToSc::Convert( const ScTokenArray*& pErgebnis, XclImpStream& aIn, s
if( nExtSheet <= 0 )
{ // in current Workbook
- aSRD.nTab = static_cast<SCTAB>(nTabFirst);
- aSRD.SetFlag3D( sal_True );
- aSRD.SetTabRel( false );
+ aSRD.SetAbsTab(nTabFirst);
+ aSRD.SetFlag3D(true);
ExcRelToScRel( nRow, nCol, aSRD, bRangeName );
@@ -741,7 +740,7 @@ ConvErr ExcelToSc::Convert( const ScTokenArray*& pErgebnis, XclImpStream& aIn, s
if( nTabLast != nTabFirst )
{
aCRD.Ref1 = aCRD.Ref2 = aSRD;
- aCRD.Ref2.nTab = static_cast<SCTAB>(nTabLast);
+ aCRD.Ref2.SetAbsTab(nTabLast);
aCRD.Ref2.SetTabDeleted( !ValidTab(static_cast<SCTAB>(nTabLast)) );
aStack << aPool.Store( aCRD );
}
@@ -789,12 +788,10 @@ ConvErr ExcelToSc::Convert( const ScTokenArray*& pErgebnis, XclImpStream& aIn, s
ScSingleRefData& rR1 = aCRD.Ref1;
ScSingleRefData& rR2 = aCRD.Ref2;
- rR1.nTab = static_cast<SCTAB>(nTabFirst);
- rR2.nTab = static_cast<SCTAB>(nTabLast);
- rR1.SetFlag3D( sal_True );
- rR1.SetTabRel( false );
+ rR1.SetAbsTab(nTabFirst);
+ rR2.SetAbsTab(nTabLast);
+ rR1.SetFlag3D(true);
rR2.SetFlag3D( nTabFirst != nTabLast );
- rR2.SetTabRel( false );
ExcRelToScRel( nRowFirst, nColFirst, aCRD.Ref1, bRangeName );
ExcRelToScRel( nRowLast, nColLast, aCRD.Ref2, bRangeName );
@@ -886,7 +883,8 @@ ConvErr ExcelToSc::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sal
ScSingleRefData aSRD;
ScComplexRefData aCRD;
- aCRD.Ref1.nTab = aCRD.Ref2.nTab = aEingPos.Tab();
+ aCRD.Ref1.SetAbsTab(aEingPos.Tab());
+ aCRD.Ref2.SetAbsTab(aEingPos.Tab());
bExternName = false;
@@ -1178,10 +1176,9 @@ ConvErr ExcelToSc::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sal
if( nExtSheet <= 0 )
{// in current Workbook
- sal_Bool b3D = ( static_cast<SCTAB>(nTabFirst) != aEingPos.Tab() ) || bRangeName;
- aSRD.nTab = static_cast<SCTAB>(nTabFirst);
+ bool b3D = ( static_cast<SCTAB>(nTabFirst) != aEingPos.Tab() ) || bRangeName;
+ aSRD.SetAbsTab(nTabFirst);
aSRD.SetFlag3D( b3D );
- aSRD.SetTabRel( false );
ExcRelToScRel( nRow, nCol, aSRD, bRangeName );
@@ -1235,12 +1232,10 @@ ConvErr ExcelToSc::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sal
ScSingleRefData &rR1 = aCRD.Ref1;
ScSingleRefData &rR2 = aCRD.Ref2;
- rR1.nTab = static_cast<SCTAB>(nTabFirst);
- rR2.nTab = static_cast<SCTAB>(nTabLast);
+ rR1.SetAbsTab(nTabFirst);
+ rR2.SetAbsTab(nTabLast);
rR1.SetFlag3D( ( static_cast<SCTAB>(nTabFirst) != aEingPos.Tab() ) || bRangeName );
- rR1.SetTabRel( false );
rR2.SetFlag3D( ( static_cast<SCTAB>(nTabLast) != aEingPos.Tab() ) || bRangeName );
- rR2.SetTabRel( false );
ExcRelToScRel( nRowFirst, nColFirst, aCRD.Ref1, bRangeName );
ExcRelToScRel( nRowLast, nColLast, aCRD.Ref2, bRangeName );
diff --git a/sc/source/filter/excel/excform8.cxx b/sc/source/filter/excel/excform8.cxx
index 7e72b04..35de70f 100644
--- a/sc/source/filter/excel/excform8.cxx
+++ b/sc/source/filter/excel/excform8.cxx
@@ -770,9 +770,8 @@ ConvErr ExcelToSc8::Convert( const ScTokenArray*& rpTokArray, XclImpStream& aIn,
break;
}
- aSRD.nTab = nTabFirst;
- aSRD.SetFlag3D( sal_True );
- aSRD.SetTabRel( false );
+ aSRD.SetAbsTab(nTabFirst);
+ aSRD.SetFlag3D(true);
ExcRelToScRel8( nRw, nGrbitCol, aSRD, bRangeName );
@@ -797,7 +796,7 @@ ConvErr ExcelToSc8::Convert( const ScTokenArray*& rpTokArray, XclImpStream& aIn,
if (nTabLast != nTabFirst)
{
aCRD.Ref1 = aCRD.Ref2 = aSRD;
- aCRD.Ref2.nTab = nTabLast;
+ aCRD.Ref2.SetAbsTab(nTabLast);
aStack << aPool.StoreExtRef(aExtInfo.mnFileId, aExtInfo.maTabName, aCRD);
}
else
@@ -811,7 +810,7 @@ ConvErr ExcelToSc8::Convert( const ScTokenArray*& rpTokArray, XclImpStream& aIn,
if( nTabLast != nTabFirst )
{
aCRD.Ref1 = aCRD.Ref2 = aSRD;
- aCRD.Ref2.nTab = nTabLast;
+ aCRD.Ref2.SetAbsTab(nTabLast);
aCRD.Ref2.SetTabDeleted( !ValidTab(nTabLast) );
aStack << aPool.Store( aCRD );
}
@@ -842,12 +841,10 @@ ConvErr ExcelToSc8::Convert( const ScTokenArray*& rpTokArray, XclImpStream& aIn,
ScSingleRefData &rR2 = aCRD.Ref2;
- rR1.nTab = nTabFirst;
- rR2.nTab = nTabLast;
- rR1.SetFlag3D( sal_True );
- rR1.SetTabRel( false );
+ rR1.SetAbsTab(nTabFirst);
+ rR2.SetAbsTab(nTabLast);
+ rR1.SetFlag3D(true);
rR2.SetFlag3D( nTabFirst != nTabLast );
- rR2.SetTabRel( false );
ExcRelToScRel8( nRw1, nGrbitCol1, aCRD.Ref1, bRangeName );
ExcRelToScRel8( nRw2, nGrbitCol2, aCRD.Ref2, bRangeName );
@@ -1178,9 +1175,8 @@ ConvErr ExcelToSc8::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sa
SCTAB nFirstScTab, nLastScTab;
if( rLinkMan.GetScTabRange( nFirstScTab, nLastScTab, nIxti ) )
{
- aSRD.nTab = nFirstScTab;
- aSRD.SetFlag3D( sal_True );
- aSRD.SetTabRel( false );
+ aSRD.SetAbsTab(nFirstScTab);
+ aSRD.SetFlag3D(true);
ExcRelToScRel8( nRw, nGrbitCol, aSRD, bRangeName );
@@ -1210,12 +1206,10 @@ ConvErr ExcelToSc8::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sa
ScSingleRefData &rR1 = aCRD.Ref1;
ScSingleRefData &rR2 = aCRD.Ref2;
- rR1.nTab = nFirstScTab;
- rR2.nTab = nLastScTab;
- rR1.SetFlag3D( sal_True );
- rR1.SetTabRel( false );
+ rR1.SetAbsTab(nFirstScTab);
+ rR2.SetAbsTab(nLastScTab);
+ rR1.SetFlag3D(true);
rR2.SetFlag3D( nFirstScTab != nLastScTab );
- rR2.SetTabRel( false );
ExcRelToScRel8( nRw1, nGrbitCol1, aCRD.Ref1, bRangeName );
ExcRelToScRel8( nRw2, nGrbitCol2, aCRD.Ref2, bRangeName );
@@ -1336,9 +1330,8 @@ ConvErr ExcelToSc8::ConvertExternName( const ScTokenArray*& rpArray, XclImpStrea
break;
}
- aSRD.nTab = nExtTab1;
+ aSRD.SetAbsTab(nExtTab1);
aSRD.SetFlag3D(true);
- aSRD.SetTabRel(false);
ExcRelToScRel8(nRow, nGrbitCol, aSRD, true);
aCRD.Ref1 = aCRD.Ref2 = aSRD;
String aTabName = rTabNames[nExtTab1];
@@ -1351,7 +1344,7 @@ ConvErr ExcelToSc8::ConvertExternName( const ScTokenArray*& rpArray, XclImpStrea
else
{
// area reference
- aCRD.Ref2.nTab = nExtTab2;
+ aCRD.Ref2.SetAbsTab(nExtTab2);
aStack << aPool.StoreExtRef(nFileId, aTabName, aCRD);
}
}
@@ -1364,14 +1357,12 @@ ConvErr ExcelToSc8::ConvertExternName( const ScTokenArray*& rpArray, XclImpStrea
ScSingleRefData& rR1 = aCRD.Ref1;
ScSingleRefData& rR2 = aCRD.Ref2;
- rR1.nTab = nExtTab1;
+ rR1.SetAbsTab(nExtTab1);
rR1.SetFlag3D(true);
- rR1.SetTabRel(false);
ExcRelToScRel8(nRow1, nGrbitCol1, rR1, true);
- rR2.nTab = nExtTab2;
+ rR2.SetAbsTab(nExtTab2);
rR2.SetFlag3D(true);
- rR2.SetTabRel(false);
ExcRelToScRel8(nRow2, nGrbitCol2, rR2, true);
String aTabName = rTabNames[nExtTab1];
diff --git a/sc/source/filter/excel/xeformula.cxx b/sc/source/filter/excel/xeformula.cxx
index a803002..7db3bb5 100644
--- a/sc/source/filter/excel/xeformula.cxx
+++ b/sc/source/filter/excel/xeformula.cxx
@@ -1792,8 +1792,17 @@ inline bool lclIsRefDel2D( const ScComplexRefData& rRefData )
SCTAB XclExpFmlaCompImpl::GetScTab( const ScSingleRefData& rRefData ) const
{
- bool bInvTab = rRefData.IsTabDeleted() || (!mxData->mpScBasePos && IsInGlobals() && rRefData.IsTabRel());
- return bInvTab ? SCTAB_INVALID : static_cast< SCTAB >( rRefData.nTab );
+ if (rRefData.IsTabDeleted())
+ return SCTAB_INVALID;
+
+ if (!rRefData.IsTabRel())
+ // absolute address
+ return rRefData.Tab();
+
+ if (!mxData->mpScBasePos)
+ return SCTAB_INVALID;
+
+ return rRefData.toAbs(*mxData->mpScBasePos).Tab();
}
bool XclExpFmlaCompImpl::IsRef2D( const ScSingleRefData& rRefData ) const
@@ -2050,7 +2059,7 @@ void XclExpFmlaCompImpl::ProcessExternalRangeRef( const XclExpScToken& rTokData
// 1-based EXTERNSHEET index and 0-based Excel sheet indexes
sal_uInt16 nExtSheet, nFirstSBTab, nLastSBTab;
- sal_uInt16 nTabSpan = static_cast< sal_uInt16 >( aRefData.Ref2.nTab - aRefData.Ref1.nTab + 1 );
+ sal_uInt16 nTabSpan = static_cast<sal_uInt16>(aRefData.Ref2.Tab() - aRefData.Ref1.Tab() + 1);
mxData->mpLinkMgr->FindExtSheet( nFileId, rTabName, nTabSpan, nExtSheet, nFirstSBTab, nLastSBTab, GetNewRefLogEntry() );
// write the token
sal_uInt8 nBaseId = lclIsRefDel2D( aRefData ) ? EXC_TOKID_AREAERR3D : EXC_TOKID_AREA3D;
diff --git a/sc/source/filter/excel/xelink.cxx b/sc/source/filter/excel/xelink.cxx
index 2c00f9f..c1cd9a4 100644
--- a/sc/source/filter/excel/xelink.cxx
+++ b/sc/source/filter/excel/xelink.cxx
@@ -989,8 +989,8 @@ void XclExpExtName::WriteAddData( XclExpStream& rStrm )
if (r1.IsTabRel() || r2.IsTabRel())
break;
- sal_uInt16 nTab1 = r1.nTab;
- sal_uInt16 nTab2 = r2.nTab;
+ sal_uInt16 nTab1 = r1.Tab();
+ sal_uInt16 nTab2 = r2.Tab();
bool bCol1Rel = r1.IsColRel();
bool bRow1Rel = r1.IsRowRel();
bool bCol2Rel = r2.IsColRel();
diff --git a/sc/source/filter/qpro/qproform.cxx b/sc/source/filter/qpro/qproform.cxx
index 024a2a7..65984ef 100644
--- a/sc/source/filter/qpro/qproform.cxx
+++ b/sc/source/filter/qpro/qproform.cxx
@@ -308,7 +308,7 @@ ConvErr QProToSc::Convert( const ScTokenArray*& pArray, sal_uInt16 /*nLen*/, con
maIn >> nCol >> nPage >> nRelBits;
ReadSRD( aCRD.Ref2, nPage, nCol, nRelBits );
// Sheet name of second corner is not displayed if identical
- if (aCRD.Ref1.IsFlag3D() && aCRD.Ref1.nTab == aCRD.Ref2.nTab &&
+ if (aCRD.Ref1.IsFlag3D() && aCRD.Ref1.Tab() == aCRD.Ref2.Tab() &&
aCRD.Ref1.IsTabRel() == aCRD.Ref2.IsTabRel())
aCRD.Ref2.SetFlag3D( false);
aStack << aPool.Store( aCRD );
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index 87a9b16..47871f0 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -1981,7 +1981,7 @@ ScExternalRefCache::TokenArrayRef ScExternalRefManager::getRangeNameTokensFromSr
{
const ScSingleRefData& rRef = static_cast<const ScToken*>(pToken)->GetSingleRef();
OUString aTabName;
- pSrcDoc->GetName(rRef.nTab, aTabName);
+ pSrcDoc->GetName(rRef.Tab(), aTabName);
ScExternalSingleRefToken aNewToken(nFileId, aTabName, static_cast<const ScToken*>(pToken)->GetSingleRef());
pNew->AddToken(aNewToken);
bTokenAdded = true;
@@ -1991,7 +1991,7 @@ ScExternalRefCache::TokenArrayRef ScExternalRefManager::getRangeNameTokensFromSr
{
const ScSingleRefData& rRef = static_cast<const ScToken*>(pToken)->GetSingleRef();
OUString aTabName;
- pSrcDoc->GetName(rRef.nTab, aTabName);
+ pSrcDoc->GetName(rRef.Tab(), aTabName);
ScExternalDoubleRefToken aNewToken(nFileId, aTabName, static_cast<const ScToken*>(pToken)->GetDoubleRef());
pNew->AddToken(aNewToken);
bTokenAdded = true;
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index 628c5c9..14ea95c 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -557,8 +557,8 @@ void Chart2Positioner::glueState()
if (n2 > nEndCol)
nEndCol = static_cast<SCCOL>(n2);
- n1 = aData.Ref1.nRow;
- n2 = aData.Ref2.nRow;
+ n1 = aData.Ref1.Row();
+ n2 = aData.Ref2.Row();
if (n1 > MAXROW)
n1 = MAXROW;
if (n2 > MAXROW)
@@ -1619,7 +1619,7 @@ public:
return;
const ScSingleRefData& r = pToken->GetSingleRef();
- mpTabNumList->push_back(r.nTab);
+ mpTabNumList->push_back(r.Tab());
}
void getList(list<SCTAB>& rList)
@@ -1684,7 +1684,7 @@ void RangeAnalyzer::initRangeAnalyzer( const vector<ScTokenRef>& rTokens )
if (eVar == svDoubleRef || eVar == svExternalDoubleRef)
{
const ScComplexRefData& r = aRefToken->GetDoubleRef();
- if (r.Ref1.nTab == r.Ref2.nTab)
+ if (r.Ref1.Tab() == r.Ref2.Tab())
{
mnColumnCount = std::max<SCCOL>(mnColumnCount, static_cast<SCCOL>(abs(r.Ref2.Col() - r.Ref1.Col())+1));
mnRowCount = std::max<SCROW>(mnRowCount, static_cast<SCROW>(abs(r.Ref2.Row() - r.Ref1.Row())+1));
diff --git a/sc/source/ui/unoobj/tokenuno.cxx b/sc/source/ui/unoobj/tokenuno.cxx
index a08cd3b..4271ce8 100644
--- a/sc/source/ui/unoobj/tokenuno.cxx
+++ b/sc/source/ui/unoobj/tokenuno.cxx
@@ -459,7 +459,9 @@ bool ScTokenConversion::ConvertToTokenSequence( ScDocument& rDoc,
rDoc.GetExternalRefManager()->getCacheTable( rToken.GetIndex(), rToken.GetString(), false, &nCacheId );
aComplRef.Reference1.Sheet = static_cast< sal_Int32 >( nCacheId );
// NOTE: This assumes that cached sheets are in consecutive order!
- aComplRef.Reference2.Sheet = aComplRef.Reference1.Sheet + (static_cast<const ScToken&>(rToken).GetSingleRef2().nTab - static_cast<const ScToken&>(rToken).GetSingleRef().nTab);
+ aComplRef.Reference2.Sheet =
+ aComplRef.Reference1.Sheet +
+ (static_cast<const ScToken&>(rToken).GetSingleRef2().Tab() - static_cast<const ScToken&>(rToken).GetSingleRef().Tab());
sheet::ExternalReference aExtRef;
aExtRef.Index = rToken.GetIndex();
aExtRef.Reference <<= aComplRef;
More information about the Libreoffice-commits
mailing list