[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter' - 19 commits - sc/inc sc/qa sc/source

Kohei Yoshida kohei.yoshida at gmail.com
Tue Jul 30 20:48:02 PDT 2013


 sc/inc/colorscale.hxx                    |   27 -
 sc/inc/column.hxx                        |   11 
 sc/inc/compiler.hxx                      |   22 
 sc/inc/conditio.hxx                      |   44 +
 sc/inc/document.hxx                      |    4 
 sc/inc/formulacell.hxx                   |    9 
 sc/inc/rangenam.hxx                      |   32 -
 sc/inc/refdata.hxx                       |   49 +
 sc/inc/refupdatecontext.hxx              |   55 ++
 sc/inc/table.hxx                         |   12 
 sc/inc/tokenarray.hxx                    |   19 
 sc/inc/validat.hxx                       |   13 
 sc/qa/unit/ucalc.cxx                     |    4 
 sc/source/core/data/colorscale.cxx       |  125 +++-
 sc/source/core/data/column.cxx           |   52 --
 sc/source/core/data/column3.cxx          |    7 
 sc/source/core/data/conditio.cxx         |  255 ++++------
 sc/source/core/data/documen2.cxx         |   46 -
 sc/source/core/data/documen3.cxx         |    6 
 sc/source/core/data/documen4.cxx         |   25 
 sc/source/core/data/document.cxx         |   59 +-
 sc/source/core/data/formulacell.cxx      |  188 +++----
 sc/source/core/data/formulaiter.cxx      |    4 
 sc/source/core/data/refupdatecontext.cxx |   70 ++
 sc/source/core/data/table1.cxx           |   79 +--
 sc/source/core/data/table2.cxx           |   13 
 sc/source/core/data/table3.cxx           |   12 
 sc/source/core/data/validat.cxx          |   23 
 sc/source/core/inc/refupdat.hxx          |   26 -
 sc/source/core/tool/chgtrack.cxx         |    6 
 sc/source/core/tool/compiler.cxx         |  787 -------------------------------
 sc/source/core/tool/interpr1.cxx         |   17 
 sc/source/core/tool/interpr4.cxx         |   26 -
 sc/source/core/tool/rangenam.cxx         |  166 +++---
 sc/source/core/tool/refdata.cxx          |  284 ++++-------
 sc/source/core/tool/reftokenhelper.cxx   |   21 
 sc/source/core/tool/refupdat.cxx         |  347 -------------
 sc/source/core/tool/token.cxx            |  320 +++++++++++-
 sc/source/filter/excel/excform.cxx       |   89 +--
 sc/source/filter/excel/excform8.cxx      |   96 +--
 sc/source/filter/excel/frmbase.cxx       |   85 +--
 sc/source/filter/excel/xechart.cxx       |   28 -
 sc/source/filter/excel/xeformula.cxx     |   47 +
 sc/source/filter/excel/xelink.cxx        |   48 -
 sc/source/filter/excel/xetable.cxx       |   33 -
 sc/source/filter/excel/xichart.cxx       |   10 
 sc/source/filter/excel/xlformula.cxx     |   17 
 sc/source/filter/inc/formel.hxx          |    4 
 sc/source/filter/inc/namebuff.hxx        |   25 
 sc/source/filter/inc/xelink.hxx          |    4 
 sc/source/filter/inc/xetable.hxx         |    2 
 sc/source/filter/inc/xlformula.hxx       |    2 
 sc/source/filter/lotus/lotform.cxx       |    9 
 sc/source/filter/lotus/tool.cxx          |   25 
 sc/source/filter/qpro/qproform.cxx       |    2 
 sc/source/ui/docshell/externalrefmgr.cxx |    4 
 sc/source/ui/unoobj/chart2uno.cxx        |  229 ++++-----
 sc/source/ui/unoobj/funcuno.cxx          |    8 
 sc/source/ui/unoobj/tokenuno.cxx         |   76 ++
 59 files changed, 1661 insertions(+), 2447 deletions(-)

New commits:
commit cb94712f92be329488b255de12098c107733bd97
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Jul 30 23:48:16 2013 -0400

    Fix quite a bit to get it to build after the backport.
    
    Change-Id: I2fb845e497f791cd249c7da77b7ea9d7b494d6dc

diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx
index 159750d..2d94299 100644
--- a/sc/inc/refdata.hxx
+++ b/sc/inc/refdata.hxx
@@ -68,10 +68,13 @@ public:
 
     void SetAbsCol( SCCOL nVal );
     void SetRelCol( SCCOL nVal );
+    void IncCol( SCCOL nInc );
     void SetAbsRow( SCROW nVal );
     void SetRelRow( SCROW nVal );
+    void IncRow( SCROW nInc );
     void SetAbsTab( SCTAB nVal );
     void SetRelTab( SCTAB nVal );
+    void IncTab( SCTAB nInc );
 
     void SetColDeleted( bool bVal );
     bool IsColDeleted() const;
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 4127c47..675e0dba 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -2010,13 +2010,13 @@ bool checkRelativeRefToken(ScDocument& rDoc, const ScAddress& rPos, SCsCOL nRelC
         return false;
 
     ScSingleRefData& rRef = pToken->GetSingleRef();
-    if (!rRef.IsColRel() || rRef.nRelCol != nRelCol)
+    if (!rRef.IsColRel() || rRef.Col() != nRelCol)
     {
         cerr << "Unexpected relative column address." << endl;
         return false;
     }
 
-    if (!rRef.IsRowRel() || rRef.nRelRow != nRelRow)
+    if (!rRef.IsRowRel() || rRef.Row() != nRelRow)
     {
         cerr << "Unexpected relative row address." << endl;
         return false;
diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx
index c61c1aa..aeea835 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -119,7 +119,6 @@ void ScColorScaleEntry::UpdateMoveTab( SCTAB nOldTab, SCTAB nNewTab, SCTAB nTabN
     {
         sc::RefUpdateMoveTabContext aCxt(nOldTab, nNewTab);
         mpCell->UpdateMoveTab(aCxt, nTabNo);
-        mpListener.reset(new ScFormulaListener(mpCell.get()));
     }
 }
 
@@ -129,7 +128,6 @@ void ScColorScaleEntry::UpdateReference( sc::RefUpdateContext& rCxt )
         return;
 
     mpCell->UpdateReference(rCxt);
-    mpListener.reset(new ScFormulaListener(mpCell.get()));
 }
 
 void ScColorScaleEntry::UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt )
@@ -138,7 +136,6 @@ void ScColorScaleEntry::UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt )
         return;
 
     mpCell->UpdateInsertTab(rCxt);
-    mpListener.reset(new ScFormulaListener(mpCell.get()));
 }
 
 void ScColorScaleEntry::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt )
@@ -147,7 +144,6 @@ void ScColorScaleEntry::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt )
         return;
 
     mpCell->UpdateDeleteTab(rCxt);
-    mpListener.reset(new ScFormulaListener(mpCell.get()));
 }
 
 void ScColorScaleEntry::UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt )
@@ -157,15 +153,6 @@ void ScColorScaleEntry::UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt )
 
     SCTAB nTabNo = rCxt.getNewTab(mpCell->aPos.Tab());
     mpCell->UpdateMoveTab(rCxt, nTabNo);
-    mpListener.reset(new ScFormulaListener(mpCell.get()));
-}
-
-bool ScColorScaleEntry::NeedsRepaint() const
-{
-    if(mpListener)
-        return mpListener->NeedsRepaint();
-
-    return false;
 }
 
 const Color& ScColorScaleEntry::GetColor() const
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 6b394f6..5687836 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2444,7 +2444,6 @@ class DeleteTabUpdater
     SCTAB mnDelPos;
     SCTAB mnSheets;
     SCTAB mnTab;
-    bool mbIsMove;
     bool mbModified;
 public:
     DeleteTabUpdater(sc::RefUpdateDeleteTabContext& rCxt, sc::CellTextAttrStoreType& rTextAttrs, SCTAB nTab) :
@@ -2452,7 +2451,6 @@ public:
         mrTextAttrs(rTextAttrs),
         miAttrPos(rTextAttrs.begin()),
         mnTab(nTab),
-        mbIsMove(bIsMove),
         mbModified(false) {}
 
     void operator() (size_t, ScFormulaCell* pCell)
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index cc51449..fd8d8f7 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -911,15 +911,14 @@ void ScColumn::CopyFromClip(
 
         //  Create reference (Source Position)
         ScSingleRefData aRef;
-        aRef.nCol = rColumn.nCol;
-        //  Adapt nRow
-        aRef.nTab = rColumn.nTab;
         aRef.InitFlags(); // -> All absolute
+        aRef.SetAbsCol(rColumn.nCol);
+        aRef.SetAbsTab(rColumn.nTab);
         aRef.SetFlag3D(true);
 
         for (SCROW nDestRow = nRow1; nDestRow <= nRow2; nDestRow++)
         {
-            aRef.nRow = nDestRow - nDy; // Source row
+            aRef.SetAbsRow(nDestRow - nDy); // Source row
             aDestPos.SetRow( nDestRow );
 
             ScTokenArray aArr;
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index ba19573..e4dce91 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -1355,21 +1355,21 @@ void ScConditionEntry::SourceChanged( const ScAddress& rChanged )
                         nCol2 = rChanged.Col() - aProv.Ref1.Col();
                     else
                     {
-                        bHit &= ( rChanged.Col() >= aProv.Ref1.nCol );
+                        bHit &= (rChanged.Col() >= aProv.Ref1.Col());
                         nCol2 = MAXCOL;
                     }
                     if ( aProv.Ref1.IsRowRel() )
-                        nRow2 = rChanged.Row() - aProv.Ref1.nRelRow;
+                        nRow2 = rChanged.Row() - aProv.Ref1.Row();
                     else
                     {
-                        bHit &= ( rChanged.Row() >= aProv.Ref1.nRow );
+                        bHit &= ( rChanged.Row() >= aProv.Ref1.Row() );
                         nRow2 = MAXROW;
                     }
                     if ( aProv.Ref1.IsTabRel() )
-                        nTab2 = rChanged.Tab() - aProv.Ref1.nRelTab;
+                        nTab2 = rChanged.Tab() - aProv.Ref1.Tab();
                     else
                     {
-                        bHit &= ( rChanged.Tab() >= aProv.Ref1.nTab );
+                        bHit &= (rChanged.Tab() >= aProv.Ref1.Tab());
                         nTab2 = MAXTAB;
                     }
 
@@ -1377,21 +1377,21 @@ void ScConditionEntry::SourceChanged( const ScAddress& rChanged )
                         nCol1 = rChanged.Col() - aProv.Ref2.Col();
                     else
                     {
-                        bHit &= ( rChanged.Col() <= aProv.Ref2.nCol );
+                        bHit &= ( rChanged.Col() <= aProv.Ref2.Col() );
                         nCol1 = 0;
                     }
                     if ( aProv.Ref2.IsRowRel() )
-                        nRow1 = rChanged.Row() - aProv.Ref2.nRelRow;
+                        nRow1 = rChanged.Row() - aProv.Ref2.Row();
                     else
                     {
-                        bHit &= ( rChanged.Row() <= aProv.Ref2.nRow );
+                        bHit &= (rChanged.Row() <= aProv.Ref2.Row());
                         nRow1 = 0;
                     }
                     if ( aProv.Ref2.IsTabRel() )
-                        nTab1 = rChanged.Tab() - aProv.Ref2.nRelTab;
+                        nTab1 = rChanged.Tab() - aProv.Ref2.Tab();
                     else
                     {
-                        bHit &= ( rChanged.Tab() <= aProv.Ref2.nTab );
+                        bHit &= (rChanged.Tab() <= aProv.Ref2.Tab());
                         nTab1 = 0;
                     }
 
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index af1b121..6abc607 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -74,9 +74,9 @@ bool ScDocument::Solver(SCCOL nFCol, SCROW nFRow, SCTAB nFTab,
         {
             ScSingleRefData aRefData;
             aRefData.InitFlags();
-            aRefData.nCol = nVCol;
-            aRefData.nRow = nVRow;
-            aRefData.nTab = nVTab;
+            aRefData.SetAbsCol(nVCol);
+            aRefData.SetAbsRow(nVRow);
+            aRefData.SetAbsTab(nVTab);
 
             ScTokenArray aArr;
             aArr.AddOpCode( ocBackSolver );
@@ -84,9 +84,9 @@ bool ScDocument::Solver(SCCOL nFCol, SCROW nFRow, SCTAB nFTab,
             aArr.AddSingleReference( aRefData );
             aArr.AddOpCode( ocSep );
 
-            aRefData.nCol = nFCol;
-            aRefData.nRow = nFRow;
-            aRefData.nTab = nFTab;
+            aRefData.SetAbsCol(nFCol);
+            aRefData.SetAbsRow(nFRow);
+            aRefData.SetAbsTab(nFTab);
 
             aArr.AddSingleReference( aRefData );
             aArr.AddOpCode( ocSep );
@@ -176,7 +176,7 @@ void ScDocument::InsertMatrixFormula(SCCOL nCol1, SCROW nRow1,
 
         if (nTab != nTab1)
         {
-            aRefData.nRelTab = nTab - aBasePos.Tab();
+            aRefData.SetRelTab(nTab - aBasePos.Tab());
             t->GetSingleRef() = aRefData;
         }
 
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 285aea1..820e9ba 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -603,7 +603,7 @@ bool ScDocument::InsertTabs( SCTAB nPos, const std::vector<OUString>& rNames,
 }
 
 
-bool ScDocument::DeleteTab( SCTAB nTab, ScDocument* pRefUndoDoc )
+bool ScDocument::DeleteTab( SCTAB nTab, ScDocument* /*pRefUndoDoc*/ )
 {
     bool bValid = false;
     if (ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()))
@@ -687,7 +687,7 @@ bool ScDocument::DeleteTab( SCTAB nTab, ScDocument* pRefUndoDoc )
 }
 
 
-bool ScDocument::DeleteTabs( SCTAB nTab, SCTAB nSheets, ScDocument* pRefUndoDoc )
+bool ScDocument::DeleteTabs( SCTAB nTab, SCTAB nSheets, ScDocument* /*pRefUndoDoc*/ )
 {
     bool bValid = false;
     if (ValidTab(nTab) && (nTab + nSheets) < static_cast<SCTAB>(maTabs.size()))
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index f3355ac..50b7f03 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -2566,28 +2566,10 @@ bool ScFormulaCell::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt )
 void ScFormulaCell::UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt, SCTAB nTabNo )
 {
     pCode->Reset();
-    if( pCode->GetNextReferenceRPN() && !pDocument->IsClipOrUndo() )
+    if (!pCode->GetNextReferenceRPN() || pDocument->IsClipOrUndo())
     {
-        EndListeningTo( pDocument );
-        // SetTab _after_ EndListeningTo und _before_ Compiler UpdateMoveTab !
-        aPos.SetTab( nTabNo );
-        ScRangeData* pRangeData;
-        ScCompiler aComp(pDocument, aPos, *pCode);
-        aComp.SetGrammar(pDocument->GetGrammar());
-        pRangeData = aComp.UpdateMoveTab( nOldPos, nNewPos, false );
-        if (pRangeData) // Exchange Shared Formula with real Formula
-        {
-            pDocument->RemoveFromFormulaTree( this );   // update formula count
-            delete pCode;
-            pCode = pRangeData->GetCode()->Clone();
-            ScCompiler aComp2(pDocument, aPos, *pCode);
-            aComp2.SetGrammar(pDocument->GetGrammar());
-            aComp2.CompileTokenArray();
-            aComp2.MoveRelWrap(pRangeData->GetMaxCol(), pRangeData->GetMaxRow());
-            aComp2.UpdateMoveTab( nOldPos, nNewPos, true );
-            bCompile = true;
-        }
-        // no StartListeningTo because pTab[nTab] not yet correct!
+        aPos.SetTab(nTabNo);
+        return;
     }
 
     EndListeningTo(pDocument);
diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx
index 5265722..e4bb249 100644
--- a/sc/source/core/tool/chgtrack.cxx
+++ b/sc/source/core/tool/chgtrack.cxx
@@ -1976,17 +1976,14 @@ static void lcl_InvalidateReference( ScToken& rTok, const ScBigAddress& rPos )
     ScSingleRefData& rRef1 = rTok.GetSingleRef();
     if ( rPos.Col() < 0 || MAXCOL < rPos.Col() )
     {
-        rRef1.nCol = SCCOL_MAX;
         rRef1.SetColDeleted( true );
     }
     if ( rPos.Row() < 0 || MAXROW < rPos.Row() )
     {
-        rRef1.nRow = SCROW_MAX;
         rRef1.SetRowDeleted( true );
     }
     if ( rPos.Tab() < 0 || MAXTAB < rPos.Tab() )
     {
-        rRef1.nTab = SCTAB_MAX;
         rRef1.SetTabDeleted( true );
     }
     if ( rTok.GetType() == formula::svDoubleRef )
@@ -1994,17 +1991,14 @@ static void lcl_InvalidateReference( ScToken& rTok, const ScBigAddress& rPos )
         ScSingleRefData& rRef2 = rTok.GetDoubleRef().Ref2;
         if ( rPos.Col() < 0 || MAXCOL < rPos.Col() )
         {
-            rRef2.nCol = SCCOL_MAX;
             rRef2.SetColDeleted( true );
         }
         if ( rPos.Row() < 0 || MAXROW < rPos.Row() )
         {
-            rRef2.nRow = SCROW_MAX;
             rRef2.SetRowDeleted( true );
         }
         if ( rPos.Tab() < 0 || MAXTAB < rPos.Tab() )
         {
-            rRef2.nTab = SCTAB_MAX;
             rRef2.SetTabDeleted( true );
         }
     }
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index e4fc98c..a420e7a 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -1461,9 +1461,9 @@ r1c1_add_row( OUStringBuffer &rBuf, const ScSingleRefData& rRef, const ScAddress
     rBuf.append( sal_Unicode( 'R' ) );
     if( rRef.IsRowRel() )
     {
-        if (rRef.nRelRow != 0)
+        if (rRef.Row() != 0)
         {
-            rBuf.append("[").append( OUString::number( rRef.nRelRow ) ).append("]");
+            rBuf.append("[").append( OUString::number(rRef.Row()) ).append("]");
         }
     }
     else
@@ -2740,11 +2740,11 @@ bool ScCompiler::IsSingleReference( const String& rName )
         if( !( nFlags & SCA_VALID ) )
         {
             if( !( nFlags & SCA_VALID_COL ) )
-                aRef.nCol = MAXCOL+1;
+                aRef.SetColDeleted(true);
             if( !( nFlags & SCA_VALID_ROW ) )
-                aRef.nRow = MAXROW+1;
+                aRef.SetRowDeleted(true);
             if( !( nFlags & SCA_VALID_TAB ) )
-                aRef.nTab = MAXTAB+3;
+                aRef.SetTabDeleted(true);
             nFlags |= SCA_VALID;
         }
         aRef.SetAddress(aAddr, aPos);
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 51a994e..93cf603 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2665,6 +2665,26 @@ bool adjustSingleRefOnDeletedTab( ScSingleRefData& rRef, SCTAB nDelPos, SCTAB nS
     return false;
 }
 
+bool adjustSingleRefOnInsertedTab( ScSingleRefData& rRef, SCTAB nInsPos, SCTAB nSheets, const ScAddress& rOldPos, const ScAddress& rNewPos )
+{
+    ScAddress aAbs = rRef.toAbs(rOldPos);
+    if (nInsPos <= aAbs.Tab())
+    {
+        // Reference sheet needs to be adjusted.
+        aAbs.IncTab(nSheets);
+        rRef.SetAddress(aAbs, rNewPos);
+        return true;
+    }
+    else if (rOldPos.Tab() != rNewPos.Tab())
+    {
+        // Cell itself has moved.
+        rRef.SetAddress(aAbs, rNewPos);
+        return true;
+    }
+
+    return false;
+}
+
 }
 
 sc::RefUpdateResult ScTokenArray::AdjustReferenceOnDeletedTab( sc::RefUpdateDeleteTabContext& rCxt, const ScAddress& rOldPos )
diff --git a/sc/source/filter/excel/excform.cxx b/sc/source/filter/excel/excform.cxx
index c5b9ebc..7c7c44b 100644
--- a/sc/source/filter/excel/excform.cxx
+++ b/sc/source/filter/excel/excform.cxx
@@ -518,10 +518,9 @@ ConvErr ExcelToSc::Convert( const ScTokenArray*& pErgebnis, XclImpStream& aIn, s
             case 0x6A:
             case 0x2A: // Deleted Cell Reference                [323 273]
                 aIn >> nUINT16 >> nByte;
-                aSRD.nCol = static_cast<SCsCOL>(nByte);
-                aSRD.nRow = nUINT16 & 0x3FFF;
-                aSRD.nRelTab = 0;
-                aSRD.SetTabRel( sal_True );
+                aSRD.SetAbsCol(static_cast<SCsCOL>(nByte));
+                aSRD.SetAbsRow(nUINT16 & 0x3FFF);
+                aSRD.SetRelTab(0);
                 aSRD.SetFlag3D( bRangeName );
 
                 ExcRelToScRel( nUINT16, nByte, aSRD, bRangeName );
@@ -552,9 +551,8 @@ ConvErr ExcelToSc::Convert( const ScTokenArray*& pErgebnis, XclImpStream& aIn, s
 
                 aIn >> nRowFirst >> nRowLast >> nColFirst >> nColLast;
 
-                rSRef1.nRelTab = rSRef2.nRelTab = 0;
-                rSRef1.SetTabRel( sal_True );
-                rSRef2.SetTabRel( sal_True );
+                rSRef1.SetRelTab(0);
+                rSRef2.SetRelTab(0);
                 rSRef1.SetFlag3D( bRangeName );
                 rSRef2.SetFlag3D( bRangeName );
 
@@ -602,8 +600,7 @@ ConvErr ExcelToSc::Convert( const ScTokenArray*& pErgebnis, XclImpStream& aIn, s
             {
                 aIn >> nUINT16 >> nByte;    // >> Attribute, Row >> Col
 
-                aSRD.nRelTab = 0;
-                aSRD.SetTabRel( sal_True );
+                aSRD.SetRelTab(0);
                 aSRD.SetFlag3D( bRangeName );
 
                 ExcRelToScRel( nUINT16, nByte, aSRD, bRNorSF );
@@ -618,9 +615,8 @@ ConvErr ExcelToSc::Convert( const ScTokenArray*& pErgebnis, XclImpStream& aIn, s
                 sal_uInt16                  nRowFirst, nRowLast;
                 sal_uInt8                   nColFirst, nColLast;
 
-                aCRD.Ref1.nRelTab = aCRD.Ref2.nRelTab = 0;
-                aCRD.Ref1.SetTabRel( sal_True );
-                aCRD.Ref2.SetTabRel( sal_True );
+                aCRD.Ref1.SetRelTab(0);
+                aCRD.Ref2.SetRelTab(0);
                 aCRD.Ref1.SetFlag3D( bRangeName );
                 aCRD.Ref2.SetFlag3D( bRangeName );
 
@@ -1031,10 +1027,9 @@ ConvErr ExcelToSc::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sal
             case 0x64:
             case 0x24: // Cell Reference                        [319 270]
                 aIn >> nUINT16 >> nByte;
-                aSRD.nCol = static_cast<SCsCOL>(nByte);
-                aSRD.nRow = nUINT16 & 0x3FFF;
-                aSRD.nRelTab = 0;
-                aSRD.SetTabRel( sal_True );
+                aSRD.SetAbsCol(static_cast<SCsCOL>(nByte));
+                aSRD.SetAbsRow(nUINT16 & 0x3FFF);
+                aSRD.SetRelTab(0);
                 aSRD.SetFlag3D( bRangeName );
 
                 ExcRelToScRel( nUINT16, nByte, aSRD, bRangeName );
@@ -1052,9 +1047,8 @@ ConvErr ExcelToSc::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sal
 
                 aIn >> nRowFirst >> nRowLast >> nColFirst >> nColLast;
 
-                rSRef1.nRelTab = rSRef2.nRelTab = 0;
-                rSRef1.SetTabRel( sal_True );
-                rSRef2.SetTabRel( sal_True );
+                rSRef1.SetRelTab(0);
+                rSRef2.SetRelTab(0);
                 rSRef1.SetFlag3D( bRangeName );
                 rSRef2.SetFlag3D( bRangeName );
 
@@ -1097,8 +1091,7 @@ ConvErr ExcelToSc::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sal
             {
                 aIn >> nUINT16 >> nByte;    // >> Attribute, Row >> Col
 
-                aSRD.nRelTab = 0;
-                aSRD.SetTabRel( sal_True );
+                aSRD.SetRelTab(0);
                 aSRD.SetFlag3D( bRangeName );
 
                 ExcRelToScRel( nUINT16, nByte, aSRD, bRNorSF );
@@ -1113,9 +1106,8 @@ ConvErr ExcelToSc::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sal
                 sal_uInt16                  nRowFirst, nRowLast;
                 sal_uInt8                   nColFirst, nColLast;
 
-                aCRD.Ref1.nRelTab = aCRD.Ref2.nRelTab = 0;
-                aCRD.Ref1.SetTabRel( sal_True );
-                aCRD.Ref2.SetTabRel( sal_True );
+                aCRD.Ref1.SetRelTab(0);
+                aCRD.Ref2.SetRelTab(0);
                 aCRD.Ref1.SetFlag3D( bRangeName );
                 aCRD.Ref2.SetFlag3D( bRangeName );
 
@@ -1192,9 +1184,8 @@ ConvErr ExcelToSc::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sal
                     if( nTabLast != nTabFirst )
                     {
                         aCRD.Ref1 = aSRD;
-                        aCRD.Ref2.nCol = aSRD.nCol;
-                        aCRD.Ref2.nRow = aSRD.nRow;
-                        aCRD.Ref2.nTab = static_cast<SCTAB>(nTabLast);
+                        aCRD.Ref2 = aSRD;
+                        aCRD.Ref2.SetAbsTab(static_cast<SCTAB>(nTabLast));
                         b3D = ( static_cast<SCTAB>(nTabLast) != aEingPos.Tab() );
                         aCRD.Ref2.SetFlag3D( b3D );
                         rRangeList.Append(aCRD.toAbs(aEingPos), nTab);
diff --git a/sc/source/filter/excel/excform8.cxx b/sc/source/filter/excel/excform8.cxx
index e4ee733..a916360 100644
--- a/sc/source/filter/excel/excform8.cxx
+++ b/sc/source/filter/excel/excform8.cxx
@@ -530,9 +530,8 @@ ConvErr ExcelToSc8::Convert( const ScTokenArray*& rpTokArray, XclImpStream& aIn,
 
                 aIn >> nRowFirst >> nRowLast >> nColFirst >> nColLast;
 
-                rSRef1.nRelTab = rSRef2.nRelTab = 0;
-                rSRef1.SetTabRel( sal_True );
-                rSRef2.SetTabRel( sal_True );
+                rSRef1.SetRelTab(0);
+                rSRef2.SetRelTab(0);
                 rSRef1.SetFlag3D( bRangeName && !bCondFormat );
                 rSRef2.SetFlag3D( bRangeName && !bCondFormat );
 
@@ -589,8 +588,7 @@ ConvErr ExcelToSc8::Convert( const ScTokenArray*& rpTokArray, XclImpStream& aIn,
 
                 aIn >> nRow >> nCol;
 
-                aSRD.nRelTab = 0;
-                aSRD.SetTabRel( sal_True );
+                aSRD.SetRelTab(0);
                 aSRD.SetFlag3D( bRangeName );
 
                 ExcRelToScRel8( nRow, nCol, aSRD, bRNorSF );
@@ -605,9 +603,8 @@ ConvErr ExcelToSc8::Convert( const ScTokenArray*& rpTokArray, XclImpStream& aIn,
                 sal_uInt16                  nRowFirst, nRowLast;
                 sal_uInt16                  nColFirst, nColLast;
 
-                aCRD.Ref1.nRelTab = aCRD.Ref2.nRelTab = 0;
-                aCRD.Ref1.SetTabRel( sal_True );
-                aCRD.Ref2.SetTabRel( sal_True );
+                aCRD.Ref1.SetRelTab(0);
+                aCRD.Ref2.SetRelTab(0);
                 aCRD.Ref1.SetFlag3D( bRangeName );
                 aCRD.Ref2.SetFlag3D( bRangeName );
 
@@ -1067,9 +1064,8 @@ ConvErr ExcelToSc8::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sa
 
                 aIn >> nRowFirst >> nRowLast >> nColFirst >> nColLast;
 
-                rSRef1.nRelTab = rSRef2.nRelTab = 0;
-                rSRef1.SetTabRel( sal_True );
-                rSRef2.SetTabRel( sal_True );
+                rSRef1.SetRelTab(0);
+                rSRef2.SetRelTab(0);
                 rSRef1.SetFlag3D( bRangeName && !bCondFormat );
                 rSRef2.SetFlag3D( bRangeName && !bCondFormat );
 
@@ -1119,8 +1115,7 @@ ConvErr ExcelToSc8::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sa
 
                 aIn >> nRow >> nCol;
 
-                aSRD.nRelTab = 0;
-                aSRD.SetTabRel( sal_True );
+                aSRD.SetRelTab(0);
                 aSRD.SetFlag3D( bRangeName );
 
                 ExcRelToScRel8( nRow, nCol, aSRD, bRNorSF );
@@ -1135,9 +1130,8 @@ ConvErr ExcelToSc8::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sa
                 sal_uInt16                  nRowFirst, nRowLast;
                 sal_uInt16                  nColFirst, nColLast;
 
-                aCRD.Ref1.nRelTab = aCRD.Ref2.nRelTab = 0;
-                aCRD.Ref1.SetTabRel( sal_True );
-                aCRD.Ref2.SetTabRel( sal_True );
+                aCRD.Ref1.SetRelTab(0);
+                aCRD.Ref2.SetRelTab(0);
                 aCRD.Ref1.SetFlag3D( bRangeName );
                 aCRD.Ref2.SetFlag3D( bRangeName );
 
diff --git a/sc/source/filter/excel/xechart.cxx b/sc/source/filter/excel/xechart.cxx
index 5c68b83..edea64a 100644
--- a/sc/source/filter/excel/xechart.cxx
+++ b/sc/source/filter/excel/xechart.cxx
@@ -877,14 +877,8 @@ void lclAddDoubleRefData(
         SCsTAB nScTab2, SCsCOL nScCol2, SCsROW nScRow2 )
 {
     ScComplexRefData aComplexRef;
-    aComplexRef.InitFlags();
+    aComplexRef.InitRange(ScRange(nScCol1,nScRow1,nScTab1,nScCol2,nScRow2,nScTab2));
     aComplexRef.Ref1.SetFlag3D( true );
-    aComplexRef.Ref1.nTab = nScTab1;
-    aComplexRef.Ref1.nCol = nScCol1;
-    aComplexRef.Ref1.nRow = nScRow1;
-    aComplexRef.Ref2.nTab = nScTab2;
-    aComplexRef.Ref2.nCol = nScCol2;
-    aComplexRef.Ref2.nRow = nScRow2;
 
     if( orArray.GetLen() > 0 )
         orArray.AddOpCode( ocUnion );
diff --git a/sc/source/filter/excel/xeformula.cxx b/sc/source/filter/excel/xeformula.cxx
index d79b0b2..ee28265 100644
--- a/sc/source/filter/excel/xeformula.cxx
+++ b/sc/source/filter/excel/xeformula.cxx
@@ -1810,8 +1810,17 @@ bool XclExpFmlaCompImpl::IsRef2D( const ScSingleRefData& rRefData ) const
     /*  rRefData.IsFlag3D() determines if sheet name is always visible, even on
         the own sheet. If 3D references are allowed, the passed reference does
         not count as 2D reference. */
-    return (!mxData->mpLinkMgr || !rRefData.IsFlag3D()) && !rRefData.IsTabDeleted() &&
-        (rRefData.IsTabRel() ? (rRefData.nRelTab == 0) : (static_cast< SCTAB >( rRefData.nTab ) == GetCurrScTab()));
+
+    if (mxData->mpLinkMgr && rRefData.IsFlag3D())
+        return false;
+
+    if (rRefData.IsTabDeleted())
+        return false;
+
+    if (rRefData.IsTabRel())
+        return rRefData.Tab() == 0;
+    else
+        return rRefData.Tab() == GetCurrScTab();
 }
 
 bool XclExpFmlaCompImpl::IsRef2D( const ScComplexRefData& rRefData ) const
@@ -1850,16 +1859,12 @@ void XclExpFmlaCompImpl::ConvertRefData(
         // *** no reference position (shared, names, condfmt) - use relative values ***
 
         // convert column index (2-step-cast ScsCOL->sal_Int16->sal_uInt16 to get all bits correctly)
-        sal_Int16 nXclRelCol = static_cast< sal_Int16 >( rRefData.IsColRel() ? rRefData.nRelCol : rRefData.nCol );
+        sal_Int16 nXclRelCol = static_cast<sal_Int16>(rRefData.Col());
         rXclPos.mnCol = static_cast< sal_uInt16 >( nXclRelCol ) & mnMaxColMask;
 
         // convert row index (2-step-cast ScsROW->sal_Int16->sal_uInt16 to get all bits correctly)
-        sal_Int16 nXclRelRow = static_cast< sal_Int32 >( rRefData.IsRowRel() ? rRefData.nRelRow : rRefData.nRow );
+        sal_Int16 nXclRelRow = static_cast<sal_Int32>(rRefData.Row());
         rXclPos.mnRow = static_cast< sal_uInt32 >( nXclRelRow ) & mnMaxRowMask;
-
-        // resolve relative tab index if possible
-        if( rRefData.IsTabRel() && !IsInGlobals() && (GetCurrScTab() < GetDoc().GetTableCount()) )
-            rRefData.nTab = static_cast< SCsTAB >( GetCurrScTab() + rRefData.nRelTab );
     }
 
     // flags for relative column and row
@@ -2549,8 +2554,7 @@ void lclInitOwnTab( ScSingleRefData& rRef, const ScAddress& rScPos, SCTAB nCurrS
     }
     else if( rScPos.Tab() == nCurrScTab )
     {
-        rRef.SetTabRel( sal_True );
-        rRef.nRelTab = 0;
+        rRef.SetRelTab(0);
     }
 }
 
diff --git a/sc/source/filter/excel/xelink.cxx b/sc/source/filter/excel/xelink.cxx
index abd41dd..d603145 100644
--- a/sc/source/filter/excel/xelink.cxx
+++ b/sc/source/filter/excel/xelink.cxx
@@ -965,8 +965,8 @@ void XclExpExtName::WriteAddData( XclExpStream& rStrm )
 
                 bool bColRel = rRef.IsColRel();
                 bool bRowRel = rRef.IsRowRel();
-                sal_uInt16 nCol = static_cast< sal_uInt16 >( bColRel ? rRef.nRelCol : rRef.nCol );
-                sal_uInt16 nRow = static_cast< sal_uInt16 >( bRowRel ? rRef.nRelRow : rRef.nRow );
+                sal_uInt16 nCol = static_cast<sal_uInt16>(rRef.Col());
+                sal_uInt16 nRow = static_cast<sal_uInt16>(rRef.Row());
                 if (bColRel) nCol |= 0x4000;
                 if (bRowRel) nCol |= 0x8000;
 
@@ -996,10 +996,10 @@ void XclExpExtName::WriteAddData( XclExpStream& rStrm )
                 bool bCol2Rel = r2.IsColRel();
                 bool bRow2Rel = r2.IsRowRel();
 
-                sal_uInt16 nCol1 = static_cast< sal_uInt16 >( bCol1Rel ? r1.nRelCol : r1.nCol );
-                sal_uInt16 nCol2 = static_cast< sal_uInt16 >( bCol2Rel ? r2.nRelCol : r2.nCol );
-                sal_uInt16 nRow1 = static_cast< sal_uInt16 >( bRow1Rel ? r1.nRelRow : r1.nRow );
-                sal_uInt16 nRow2 = static_cast< sal_uInt16 >( bRow2Rel ? r2.nRelRow : r2.nRow );
+                sal_uInt16 nCol1 = static_cast<sal_uInt16>(r1.Col());
+                sal_uInt16 nCol2 = static_cast<sal_uInt16>(r2.Col());
+                sal_uInt16 nRow1 = static_cast<sal_uInt16>(r1.Row());
+                sal_uInt16 nRow2 = static_cast<sal_uInt16>(r2.Row());
                 if (bCol1Rel) nCol1 |= 0x4000;
                 if (bRow1Rel) nCol1 |= 0x8000;
                 if (bCol2Rel) nCol2 |= 0x4000;
diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx
index edaa5fa..b436a3d 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -148,23 +148,24 @@ XclExpArrayRef XclExpArrayBuffer::CreateArray( const ScTokenArray& rScTokArr, co
     return rxRec;
 }
 
-XclExpArrayRef XclExpArrayBuffer::FindArray( const ScTokenArray& rScTokArr ) const
+XclExpArrayRef XclExpArrayBuffer::FindArray( const ScTokenArray& rScTokArr, const ScAddress& rBasePos ) const
 {
     XclExpArrayRef xRec;
     // try to extract a matrix reference token
-    if( rScTokArr.GetLen() == 1 )
-    {
-        const formula::FormulaToken* pToken = rScTokArr.GetArray()[ 0 ];
-        if( pToken && (pToken->GetOpCode() == ocMatRef) )
-        {
-            const ScSingleRefData& rRef = static_cast<const ScToken*>(pToken)->GetSingleRef();
-            ScAddress aBasePos( rRef.nCol, rRef.nRow, GetCurrScTab() );
-            XclExpArrayMap::const_iterator aIt = maRecMap.find( aBasePos );
-            if( aIt != maRecMap.end() )
-                xRec = aIt->second;
-        }
-    }
-    return xRec;
+    if (rScTokArr.GetLen() != 1)
+        // Must consist of a single reference token.
+        return xRec;
+
+    const formula::FormulaToken* pToken = rScTokArr.GetArray()[0];
+    if (!pToken || pToken->GetOpCode() != ocMatRef)
+        // not a matrix reference token.
+        return xRec;
+
+    const ScSingleRefData& rRef = static_cast<const ScToken*>(pToken)->GetSingleRef();
+    ScAddress aAbsPos = rRef.toAbs(rBasePos);
+    XclExpArrayMap::const_iterator it = maRecMap.find(aAbsPos);
+
+    return (it == maRecMap.end()) ? xRec : xRec = it->second;
 }
 
 // Shared formulas ============================================================
@@ -840,7 +841,7 @@ XclExpFormulaCell::XclExpFormulaCell(
         case MM_REFERENCE:
         {
             // other formula cell covered by a matrix - find the ARRAY record
-            mxAddRec = rArrayBfr.FindArray( rScTokArr );
+            mxAddRec = rArrayBfr.FindArray(rScTokArr, aScPos);
             // should always be found, if Calc document is not broken
             OSL_ENSURE( mxAddRec, "XclExpFormulaCell::XclExpFormulaCell - no matrix found" );
         }
diff --git a/sc/source/filter/inc/xetable.hxx b/sc/source/filter/inc/xetable.hxx
index 655d6ea..533d2ec 100644
--- a/sc/source/filter/inc/xetable.hxx
+++ b/sc/source/filter/inc/xetable.hxx
@@ -135,7 +135,7 @@ public:
     /** Inserts a new ARRAY record into the buffer and returns it. */
     XclExpArrayRef      CreateArray( const ScTokenArray& rScTokArr, const ScRange& rScRange );
     /** Tries to find an ARRAY record that corresponds to an ocMatRef token. */
-    XclExpArrayRef      FindArray( const ScTokenArray& rScTokArr ) const;
+    XclExpArrayRef FindArray( const ScTokenArray& rScTokArr, const ScAddress& rBasePos ) const;
 
 private:
     typedef ::std::map< ScAddress, XclExpArrayRef > XclExpArrayMap;
diff --git a/sc/source/filter/lotus/lotform.cxx b/sc/source/filter/lotus/lotform.cxx
index 6ee5c69..aaca8d2 100644
--- a/sc/source/filter/lotus/lotform.cxx
+++ b/sc/source/filter/lotus/lotform.cxx
@@ -395,9 +395,7 @@ ConvErr LotusToSc::Convert( const ScTokenArray*& rpErg, sal_Int32& rRest,
         pIndexToType = IndexToType;
         pIndexToToken = IndexToToken;
 
-        rR.SetTabRel( sal_True );
-        rR.nTab = aEingPos.Tab();
-        rR.nRelTab = 0;
+        rR.SetRelTab(0);
         rR.SetFlag3D( false );
     }
 
diff --git a/sc/source/filter/lotus/tool.cxx b/sc/source/filter/lotus/tool.cxx
index 886622a..3fc0c6e 100644
--- a/sc/source/filter/lotus/tool.cxx
+++ b/sc/source/filter/lotus/tool.cxx
@@ -424,17 +424,15 @@ LotusRangeList::LotusRangeList( void )
     nIdCnt = 1;
 
     pSingRef = &aComplRef.Ref1;
-    pSingRef->nTab = pSingRef->nRelTab = 0;
+    pSingRef->SetRelTab(0);
     pSingRef->SetColRel( false );
     pSingRef->SetRowRel( false );
-    pSingRef->SetTabRel( sal_True );
     pSingRef->SetFlag3D( false );
 
     pSingRef = &aComplRef.Ref2;
-    pSingRef->nTab = pSingRef->nRelTab = 0;
+    pSingRef->SetRelTab(0);
     pSingRef->SetColRel( false );
     pSingRef->SetRowRel( false );
-    pSingRef->SetTabRel( sal_True );
     pSingRef->SetFlag3D( false );
 }
 
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index 1f13027..14ea95c 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -77,7 +77,7 @@ namespace
 {
 const SfxItemPropertyMapEntry* lcl_GetDataProviderPropertyMap()
 {
-    static SfxItemPropertyMapEntry aDataProviderPropertyMap_Impl[] =
+    static const SfxItemPropertyMapEntry aDataProviderPropertyMap_Impl[] =
     {
         { MAP_CHAR_LEN(SC_UNONAME_INCLUDEHIDDENCELLS), 0, &getBooleanCppuType(), 0, 0 },
         { MAP_CHAR_LEN(SC_UNONAME_USE_INTERNAL_DATA_PROVIDER), 0, &getBooleanCppuType(), 0, 0 },
@@ -88,7 +88,7 @@ const SfxItemPropertyMapEntry* lcl_GetDataProviderPropertyMap()
 
 const SfxItemPropertyMapEntry* lcl_GetDataSequencePropertyMap()
 {
-    static SfxItemPropertyMapEntry aDataSequencePropertyMap_Impl[] =
+    static const SfxItemPropertyMapEntry aDataSequencePropertyMap_Impl[] =
     {
         {MAP_CHAR_LEN(SC_UNONAME_HIDDENVALUES), 0, &getCppuType((uno::Sequence<sal_Int32>*)0 ),                 0, 0 },
         {MAP_CHAR_LEN(SC_UNONAME_ROLE), 0, &getCppuType((::com::sun::star::chart2::data::DataSequenceRole*)0),                  0, 0 },
@@ -127,7 +127,7 @@ OUString lcl_createTableNumberList( const ::std::list< SCTAB > & rTableList )
     OUStringBuffer aBuffer;
     ::std::for_each( rTableList.begin(), rTableList.end(), lcl_appendTableNumber( aBuffer ));
     // remove last trailing ' '
-    if( aBuffer.getLength() > 0 )
+    if( !aBuffer.isEmpty() )
         aBuffer.setLength( aBuffer.getLength() - 1 );
     return aBuffer.makeStringAndClear();
 }
@@ -519,12 +519,12 @@ void Chart2Positioner::glueState()
         ScComplexRefData aData;
         if (ScRefTokenHelper::getDoubleRefDataFromToken(aData, p))
         {
-            if (aData.Ref1.nTab == aData.Ref2.nTab)
+            if (aData.Ref1.Tab() == aData.Ref2.Tab())
                 meGlue = GLUETYPE_NONE;
             else
                 meGlue = GLUETYPE_COLS;
-            mnStartCol = aData.Ref1.nCol;
-            mnStartRow = aData.Ref1.nRow;
+            mnStartCol = aData.Ref1.Col();
+            mnStartRow = aData.Ref1.Row();
         }
         else
         {
@@ -537,8 +537,8 @@ void Chart2Positioner::glueState()
 
     ScComplexRefData aData;
     ScRefTokenHelper::getDoubleRefDataFromToken(aData, mrRefTokens.front());
-    mnStartCol = aData.Ref1.nCol;
-    mnStartRow = aData.Ref1.nRow;
+    mnStartCol = aData.Ref1.Col();
+    mnStartRow = aData.Ref1.Row();
 
     SCCOL nEndCol = 0;
     SCROW nEndRow = 0;
@@ -546,8 +546,8 @@ void Chart2Positioner::glueState()
          ; itr != itrEnd; ++itr)
     {
         ScRefTokenHelper::getDoubleRefDataFromToken(aData, *itr);
-        SCCOLROW n1 = aData.Ref1.nCol;
-        SCCOLROW n2 = aData.Ref2.nCol;
+        SCCOLROW n1 = aData.Ref1.Col();
+        SCCOLROW n2 = aData.Ref2.Col();
         if (n1 > MAXCOL)
             n1 = MAXCOL;
         if (n2 > MAXCOL)
@@ -620,10 +620,10 @@ void Chart2Positioner::calcGlueState(SCCOL nColSize, SCROW nRowSize)
     {
         ScComplexRefData aData;
         ScRefTokenHelper::getDoubleRefDataFromToken(aData, *itr);
-        SCCOL nCol1 = static_cast<SCCOL>(aData.Ref1.nCol) - mnStartCol;
-        SCCOL nCol2 = static_cast<SCCOL>(aData.Ref2.nCol) - mnStartCol;
-        SCROW nRow1 = static_cast<SCROW>(aData.Ref1.nRow) - mnStartRow;
-        SCROW nRow2 = static_cast<SCROW>(aData.Ref2.nRow) - mnStartRow;
+        SCCOL nCol1 = aData.Ref1.Col() - mnStartCol;
+        SCCOL nCol2 = aData.Ref2.Col() - mnStartCol;
+        SCROW nRow1 = aData.Ref1.Row() - mnStartRow;
+        SCROW nRow2 = aData.Ref2.Row() - mnStartRow;
         for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
             for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow)
             {
@@ -739,9 +739,9 @@ void Chart2Positioner::createPositionMap()
             break;
         const ScSingleRefData& s = aData.Ref1;
         const ScSingleRefData& e = aData.Ref2;
-        SCCOL nCol1 = s.nCol, nCol2 = e.nCol;
-        SCROW nRow1 = s.nRow, nRow2 = e.nRow;
-        SCTAB nTab1 = s.nTab, nTab2 = e.nTab;
+        SCCOL nCol1 = s.Col(), nCol2 = e.Col();
+        SCROW nRow1 = s.Row(), nRow2 = e.Row();
+        SCTAB nTab1 = s.Tab(), nTab2 = e.Tab();
 
         for (SCTAB nTab = nTab1; nTab <= nTab2; ++nTab)
         {
@@ -771,9 +771,9 @@ void Chart2Positioner::createPositionMap()
                     aCellData.SetColRel(false);
                     aCellData.SetRowRel(false);
                     aCellData.SetTabRel(false);
-                    aCellData.nCol = nCol;
-                    aCellData.nRow = nRow;
-                    aCellData.nTab = nTab;
+                    aCellData.SetAbsCol(nCol);
+                    aCellData.SetAbsRow(nRow);
+                    aCellData.SetAbsTab(nTab);
 
                     if (pCol->find(nInsRow) == pCol->end())
                     {
@@ -1135,31 +1135,31 @@ bool lcl_addUpperLeftCornerIfMissing(vector<ScTokenRef>& rRefTokens,
         case svSingleRef:
         {
             const ScSingleRefData& rData = pToken->GetSingleRef();
-            nMinCol = rData.nCol;
-            nMinRow = rData.nRow;
-            nMaxCol = rData.nCol;
-            nMaxRow = rData.nRow;
-            nTab = rData.nTab;
+            nMinCol = rData.Col();
+            nMinRow = rData.Row();
+            nMaxCol = rData.Col();
+            nMaxRow = rData.Row();
+            nTab = rData.Tab();
         }
         break;
         case svDoubleRef:
         {
             const ScComplexRefData& rData = pToken->GetDoubleRef();
-            nMinCol = min(rData.Ref1.nCol, rData.Ref2.nCol);
-            nMinRow = min(rData.Ref1.nRow, rData.Ref2.nRow);
-            nMaxCol = max(rData.Ref1.nCol, rData.Ref2.nCol);
-            nMaxRow = max(rData.Ref1.nRow, rData.Ref2.nRow);
-            nTab = rData.Ref1.nTab;
+            nMinCol = min(rData.Ref1.Col(), rData.Ref2.Col());
+            nMinRow = min(rData.Ref1.Row(), rData.Ref2.Row());
+            nMaxCol = max(rData.Ref1.Col(), rData.Ref2.Col());
+            nMaxRow = max(rData.Ref1.Row(), rData.Ref2.Row());
+            nTab = rData.Ref1.Tab();
         }
         break;
         case svExternalSingleRef:
         {
             const ScSingleRefData& rData = pToken->GetSingleRef();
-            nMinCol = rData.nCol;
-            nMinRow = rData.nRow;
-            nMaxCol = rData.nCol;
-            nMaxRow = rData.nRow;
-            nTab = rData.nTab;
+            nMinCol = rData.Col();
+            nMinRow = rData.Row();
+            nMaxCol = rData.Col();
+            nMaxRow = rData.Row();
+            nTab = rData.Tab();
             nFileId = pToken->GetIndex();
             aExtTabName = pToken->GetString();
             bExternal = true;
@@ -1168,11 +1168,11 @@ bool lcl_addUpperLeftCornerIfMissing(vector<ScTokenRef>& rRefTokens,
         case svExternalDoubleRef:
         {
             const ScComplexRefData& rData = pToken->GetDoubleRef();
-            nMinCol = min(rData.Ref1.nCol, rData.Ref2.nCol);
-            nMinRow = min(rData.Ref1.nRow, rData.Ref2.nRow);
-            nMaxCol = max(rData.Ref1.nCol, rData.Ref2.nCol);
-            nMaxRow = max(rData.Ref1.nRow, rData.Ref2.nRow);
-            nTab = rData.Ref1.nTab;
+            nMinCol = min(rData.Ref1.Col(), rData.Ref2.Col());
+            nMinRow = min(rData.Ref1.Row(), rData.Ref2.Row());
+            nMaxCol = max(rData.Ref1.Col(), rData.Ref2.Col());
+            nMaxRow = max(rData.Ref1.Row(), rData.Ref2.Row());
+            nTab = rData.Ref1.Tab();
             nFileId = pToken->GetIndex();
             aExtTabName = pToken->GetString();
             bExternal = true;
@@ -1194,11 +1194,11 @@ bool lcl_addUpperLeftCornerIfMissing(vector<ScTokenRef>& rRefTokens,
             {
                 const ScSingleRefData& rData = pToken->GetSingleRef();
 
-                nMinCol = min(nMinCol, rData.nCol);
-                nMinRow = min(nMinRow, rData.nRow);
-                nMaxCol = max(nMaxCol, rData.nCol);
-                nMaxRow = max(nMaxRow, rData.nRow);
-                if (nTab != rData.nTab || bExternal)
+                nMinCol = min(nMinCol, rData.Col());
+                nMinRow = min(nMinRow, rData.Row());
+                nMaxCol = max(nMaxCol, rData.Col());
+                nMaxRow = max(nMaxRow, rData.Row());
+                if (nTab != rData.Tab() || bExternal)
                     return false;
             }
             break;
@@ -1206,17 +1206,17 @@ bool lcl_addUpperLeftCornerIfMissing(vector<ScTokenRef>& rRefTokens,
             {
                 const ScComplexRefData& rData = pToken->GetDoubleRef();
 
-                nMinCol = min(nMinCol, rData.Ref1.nCol);
-                nMinCol = min(nMinCol, rData.Ref2.nCol);
-                nMinRow = min(nMinRow, rData.Ref1.nRow);
-                nMinRow = min(nMinRow, rData.Ref2.nRow);
+                nMinCol = min(nMinCol, rData.Ref1.Col());
+                nMinCol = min(nMinCol, rData.Ref2.Col());
+                nMinRow = min(nMinRow, rData.Ref1.Row());
+                nMinRow = min(nMinRow, rData.Ref2.Row());
 
-                nMaxCol = max(nMaxCol, rData.Ref1.nCol);
-                nMaxCol = max(nMaxCol, rData.Ref2.nCol);
-                nMaxRow = max(nMaxRow, rData.Ref1.nRow);
-                nMaxRow = max(nMaxRow, rData.Ref2.nRow);
+                nMaxCol = max(nMaxCol, rData.Ref1.Col());
+                nMaxCol = max(nMaxCol, rData.Ref2.Col());
+                nMaxRow = max(nMaxRow, rData.Ref1.Row());
+                nMaxRow = max(nMaxRow, rData.Ref2.Row());
 
-                if (nTab != rData.Ref1.nTab || bExternal)
+                if (nTab != rData.Ref1.Tab() || bExternal)
                     return false;
             }
             break;
@@ -1230,10 +1230,10 @@ bool lcl_addUpperLeftCornerIfMissing(vector<ScTokenRef>& rRefTokens,
 
                 const ScSingleRefData& rData = pToken->GetSingleRef();
 
-                nMinCol = min(nMinCol, rData.nCol);
-                nMinRow = min(nMinRow, rData.nRow);
-                nMaxCol = max(nMaxCol, rData.nCol);
-                nMaxRow = max(nMaxRow, rData.nRow);
+                nMinCol = min(nMinCol, rData.Col());
+                nMinRow = min(nMinRow, rData.Row());
+                nMaxCol = max(nMaxCol, rData.Col());
+                nMaxRow = max(nMaxRow, rData.Row());
             }
             break;
             case svExternalDoubleRef:
@@ -1246,15 +1246,15 @@ bool lcl_addUpperLeftCornerIfMissing(vector<ScTokenRef>& rRefTokens,
 
                 const ScComplexRefData& rData = pToken->GetDoubleRef();
 
-                nMinCol = min(nMinCol, rData.Ref1.nCol);
-                nMinCol = min(nMinCol, rData.Ref2.nCol);
-                nMinRow = min(nMinRow, rData.Ref1.nRow);
-                nMinRow = min(nMinRow, rData.Ref2.nRow);
+                nMinCol = min(nMinCol, rData.Ref1.Col());
+                nMinCol = min(nMinCol, rData.Ref2.Col());
+                nMinRow = min(nMinRow, rData.Ref1.Row());
+                nMinRow = min(nMinRow, rData.Ref2.Row());
 
-                nMaxCol = max(nMaxCol, rData.Ref1.nCol);
-                nMaxCol = max(nMaxCol, rData.Ref2.nCol);
-                nMaxRow = max(nMaxRow, rData.Ref1.nRow);
-                nMaxRow = max(nMaxRow, rData.Ref2.nRow);
+                nMaxCol = max(nMaxCol, rData.Ref1.Col());
+                nMaxCol = max(nMaxCol, rData.Ref2.Col());
+                nMaxRow = max(nMaxRow, rData.Ref1.Row());
+                nMaxRow = max(nMaxRow, rData.Ref2.Row());
             }
             break;
             default:
@@ -1285,17 +1285,17 @@ bool lcl_addUpperLeftCornerIfMissing(vector<ScTokenRef>& rRefTokens,
             case svExternalSingleRef:
             {
                 const ScSingleRefData& rData = pToken->GetSingleRef();
-                if (rData.nCol == nMinCol && rData.nRow == nMinRow)
+                if (rData.Col() == nMinCol && rData.Row() == nMinRow)
                     // The corner cell is contained.
                     return false;
 
-                if (rData.nCol == nMinCol+nCornerColumnCount && rData.nRow == nMinRow)
+                if (rData.Col() == nMinCol+nCornerColumnCount && rData.Row() == nMinRow)
                     bRight = true;
 
-                if (rData.nCol == nMinCol && rData.nRow == nMinRow+nCornerRowCount)
+                if (rData.Col() == nMinCol && rData.Row() == nMinRow+nCornerRowCount)
                     bBottom = true;
 
-                if (rData.nCol == nMinCol+nCornerColumnCount && rData.nRow == nMinRow+nCornerRowCount)
+                if (rData.Col() == nMinCol+nCornerColumnCount && rData.Row() == nMinRow+nCornerRowCount)
                     bDiagonal = true;
             }
             break;
@@ -1305,21 +1305,21 @@ bool lcl_addUpperLeftCornerIfMissing(vector<ScTokenRef>& rRefTokens,
                 const ScComplexRefData& rData = pToken->GetDoubleRef();
                 const ScSingleRefData& r1 = rData.Ref1;
                 const ScSingleRefData& r2 = rData.Ref2;
-                if (r1.nCol <= nMinCol && nMinCol <= r2.nCol &&
-                    r1.nRow <= nMinRow && nMinRow <= r2.nRow)
+                if (r1.Col() <= nMinCol && nMinCol <= r2.Col() &&
+                    r1.Row() <= nMinRow && nMinRow <= r2.Row())
                     // The corner cell is contained.
                     return false;
 
-                if (r1.nCol <= nMinCol+nCornerColumnCount && nMinCol+nCornerColumnCount <= r2.nCol &&
-                    r1.nRow <= nMinRow && nMinRow <= r2.nRow)
+                if (r1.Col() <= nMinCol+nCornerColumnCount && nMinCol+nCornerColumnCount <= r2.Col() &&
+                    r1.Row() <= nMinRow && nMinRow <= r2.Row())
                     bRight = true;
 
-                if (r1.nCol <= nMinCol && nMinCol <= r2.nCol &&
-                    r1.nRow <= nMinRow+nCornerRowCount && nMinRow+nCornerRowCount <= r2.nRow)
+                if (r1.Col() <= nMinCol && nMinCol <= r2.Col() &&
+                    r1.Row() <= nMinRow+nCornerRowCount && nMinRow+nCornerRowCount <= r2.Row())
                     bBottom = true;
 
-                if (r1.nCol <= nMinCol+nCornerColumnCount && nMinCol+nCornerColumnCount <= r2.nCol &&
-                    r1.nRow <= nMinRow+nCornerRowCount && nMinRow+nCornerRowCount <= r2.nRow)
+                if (r1.Col() <= nMinCol+nCornerColumnCount && nMinCol+nCornerColumnCount <= r2.Col() &&
+                    r1.Row() <= nMinRow+nCornerRowCount && nMinRow+nCornerRowCount <= r2.Row())
                     bDiagonal = true;
             }
             break;
@@ -1335,12 +1335,9 @@ bool lcl_addUpperLeftCornerIfMissing(vector<ScTokenRef>& rRefTokens,
     ScSingleRefData aData;
     aData.InitFlags();
     aData.SetFlag3D(true);
-    aData.SetColRel(false);
-    aData.SetRowRel(false);
-    aData.SetTabRel(false);
-    aData.nCol = nMinCol;
-    aData.nRow = nMinRow;
-    aData.nTab = nTab;
+    aData.SetAbsCol(nMinCol);
+    aData.SetAbsRow(nMinRow);
+    aData.SetAbsTab(nTab);
 
     if( nCornerRowCount==1 && nCornerColumnCount==1 )
     {
@@ -1359,8 +1356,8 @@ bool lcl_addUpperLeftCornerIfMissing(vector<ScTokenRef>& rRefTokens,
     else
     {
         ScSingleRefData aDataEnd(aData);
-        aDataEnd.nCol += (nCornerColumnCount-1);
-        aDataEnd.nRow += (nCornerRowCount-1);
+        aDataEnd.IncCol(nCornerColumnCount-1);
+        aDataEnd.IncRow(nCornerRowCount-1);
         ScComplexRefData r;
         r.Ref1=aData;
         r.Ref2=aDataEnd;
@@ -1403,7 +1400,7 @@ public:
         SCROW nMinRow = MAXROW, nMaxRow = 0;
 
         // Determine the smallest range that encompasses the data ranges of all sheets.
-        SCTAB nTab1 = s.nTab, nTab2 = e.nTab;
+        SCTAB nTab1 = s.Tab(), nTab2 = e.Tab();
         for (SCTAB nTab = nTab1; nTab <= nTab2; ++nTab)
         {
             SCCOL nCol1 = 0, nCol2 = MAXCOL;
@@ -1416,14 +1413,14 @@ public:
         }
 
         // Shrink range to the data range if applicable.
-        if (s.nCol < nMinCol)
-            s.nCol = nMinCol;
-        if (s.nRow < nMinRow)
-            s.nRow = nMinRow;
-        if (e.nCol > nMaxCol)
-            e.nCol = nMaxCol;
-        if (e.nRow > nMaxRow)
-            e.nRow = nMaxRow;
+        if (s.Col() < nMinCol)
+            s.SetAbsCol(nMinCol);
+        if (s.Row() < nMinRow)
+            s.SetAbsRow(nMinRow);
+        if (e.Col() > nMaxCol)
+            e.SetAbsCol(nMaxCol);
+        if (e.Row() > nMaxRow)
+            e.SetAbsRow(nMaxRow);
     }
 };
 
@@ -1689,16 +1686,16 @@ void RangeAnalyzer::initRangeAnalyzer( const vector<ScTokenRef>& rTokens )
             const ScComplexRefData& r = aRefToken->GetDoubleRef();
             if (r.Ref1.Tab() == r.Ref2.Tab())
             {
-                mnColumnCount = std::max<SCCOL>( mnColumnCount, static_cast<SCCOL>(abs(r.Ref2.nCol - r.Ref1.nCol)+1) );
-                mnRowCount = std::max<SCROW>( mnRowCount, static_cast<SCROW>(abs(r.Ref2.nRow - r.Ref1.nRow)+1) );
+                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));
                 if( mnStartColumn == -1 )
                 {
-                    mnStartColumn = r.Ref1.nCol;
-                    mnStartRow = r.Ref1.nRow;
+                    mnStartColumn = r.Ref1.Col();
+                    mnStartRow = r.Ref1.Row();
                 }
                 else
                 {
-                    if( mnStartColumn != r.Ref1.nCol && mnStartRow != r.Ref1.nRow )
+                    if (mnStartColumn != r.Ref1.Col() && mnStartRow != r.Ref1.Row())
                         mbAmbiguous=true;
                 }
             }
@@ -1712,12 +1709,12 @@ void RangeAnalyzer::initRangeAnalyzer( const vector<ScTokenRef>& rTokens )
             mnRowCount = std::max<SCROW>( mnRowCount, 1);
             if( mnStartColumn == -1 )
             {
-                mnStartColumn = r.nCol;
-                mnStartRow = r.nRow;
+                mnStartColumn = r.Col();
+                mnStartRow = r.Row();
             }
             else
             {
-                if( mnStartColumn != r.nCol && mnStartRow != r.nRow )
+                if (mnStartColumn != r.Col() && mnStartRow != r.Row())
                     mbAmbiguous=true;
             }
         }
@@ -1803,7 +1800,7 @@ uno::Sequence< beans::PropertyValue > SAL_CALL ScChart2DataProvider::detectArgum
                 {
                     Reference< beans::XPropertySet > xSeqProp( xLS->getValues(), uno::UNO_QUERY );
                     OUString aRole;
-                    if( xSeqProp.is() && (xSeqProp->getPropertyValue(OUString("Role")) >>= aRole) &&
+                    if( xSeqProp.is() && (xSeqProp->getPropertyValue("Role") >>= aRole) &&
                         aRole.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("categories")) )
                         bThisIsCategories = bHasCategories = true;
                 }
@@ -2278,7 +2275,7 @@ OUString SAL_CALL ScChart2DataProvider::convertRangeFromXML( const OUString& sXM
                 if ( aUIString.GetChar(0) == (sal_Unicode) '.' )
                     aUIString.Erase( 0, 1 );
 
-                if( sRet.getLength() )
+                if( !sRet.isEmpty() )
                     sRet.append( (sal_Unicode) ';' );
                 sRet.append( aUIString );
             }
@@ -2707,7 +2704,7 @@ sal_Int32 ScChart2DataSequence::FillCacheFromExternalRef(const ScTokenRef& pToke
                     SvNumberFormatter* pFormatter = m_pDocument->GetFormatTable();
                     if (pFormatter)
                     {
-                        String aStr;
+                        OUString aStr;
                         const double fVal = rItem.mfValue;
                         Color* pColor = NULL;
                         sal_uInt32 nFmt = 0;
@@ -3255,17 +3252,7 @@ namespace {
 sal_uLong getDisplayNumberFormat(ScDocument* pDoc, const ScAddress& rPos)
 {
     sal_uLong nFormat = pDoc->GetNumberFormat(rPos); // original format from cell.
-    SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
-    if (!pFormatter)
-        return nFormat;
-
-    ScRefCellValue aCell;
-    aCell.assign(*pDoc, rPos);
-    if (aCell.isEmpty() || aCell.meType != CELLTYPE_FORMULA || nFormat)
-        return nFormat;
-
-    // With formula cell, the format may be inferred from the formula result.
-    return aCell.mpFormula->GetStandardFormat(*pFormatter, nFormat);
+    return nFormat;
 }
 
 }
diff --git a/sc/source/ui/unoobj/tokenuno.cxx b/sc/source/ui/unoobj/tokenuno.cxx
index 30ce53c..dc85d82 100644
--- a/sc/source/ui/unoobj/tokenuno.cxx
+++ b/sc/source/ui/unoobj/tokenuno.cxx
@@ -288,16 +288,30 @@ SC_IMPL_DUMMY_PROPERTY_LISTENER( ScFormulaParserObj )
 
 static void lcl_ExternalRefToApi( sheet::SingleReference& rAPI, const ScSingleRefData& rRef )
 {
-    rAPI.Column         = rRef.nCol;
-    rAPI.Row            = rRef.nRow;
+    rAPI.Column         = 0;
+    rAPI.Row            = 0;
     rAPI.Sheet          = 0;
-    rAPI.RelativeColumn = rRef.nRelCol;
-    rAPI.RelativeRow    = rRef.nRelRow;
+    rAPI.RelativeColumn = 0;
+    rAPI.RelativeRow    = 0;
     rAPI.RelativeSheet  = 0;
 
     sal_Int32 nFlags = 0;
-    if ( rRef.IsColRel() )     nFlags |= sheet::ReferenceFlags::COLUMN_RELATIVE;
-    if ( rRef.IsRowRel() )     nFlags |= sheet::ReferenceFlags::ROW_RELATIVE;
+    if ( rRef.IsColRel() )
+    {
+        nFlags |= sheet::ReferenceFlags::COLUMN_RELATIVE;
+        rAPI.RelativeColumn = rRef.Col();
+    }
+    else
+        rAPI.Column = rRef.Col();
+
+    if ( rRef.IsRowRel() )
+    {
+        nFlags |= sheet::ReferenceFlags::ROW_RELATIVE;
+        rAPI.RelativeRow = rRef.Row();
+    }
+    else
+        rAPI.Row = rRef.Row();
+
     if ( rRef.IsColDeleted() ) nFlags |= sheet::ReferenceFlags::COLUMN_DELETED;
     if ( rRef.IsRowDeleted() ) nFlags |= sheet::ReferenceFlags::ROW_DELETED;
     if ( rRef.IsFlag3D() )     nFlags |= sheet::ReferenceFlags::SHEET_3D;
@@ -307,17 +321,43 @@ static void lcl_ExternalRefToApi( sheet::SingleReference& rAPI, const ScSingleRe
 
 static void lcl_SingleRefToApi( sheet::SingleReference& rAPI, const ScSingleRefData& rRef )
 {
-    rAPI.Column         = rRef.nCol;
-    rAPI.Row            = rRef.nRow;
-    rAPI.Sheet          = rRef.nTab;
-    rAPI.RelativeColumn = rRef.nRelCol;
-    rAPI.RelativeRow    = rRef.nRelRow;
-    rAPI.RelativeSheet  = rRef.nRelTab;
-
     sal_Int32 nFlags = 0;
-    if ( rRef.IsColRel() )     nFlags |= sheet::ReferenceFlags::COLUMN_RELATIVE;
-    if ( rRef.IsRowRel() )     nFlags |= sheet::ReferenceFlags::ROW_RELATIVE;
-    if ( rRef.IsTabRel() )     nFlags |= sheet::ReferenceFlags::SHEET_RELATIVE;
+    if ( rRef.IsColRel() )
+    {
+        nFlags |= sheet::ReferenceFlags::COLUMN_RELATIVE;
+        rAPI.RelativeColumn = rRef.Col();
+        rAPI.Column = 0;
+    }
+    else
+    {
+        rAPI.RelativeColumn = 0;
+        rAPI.Column = rRef.Col();
+    }
+
+    if ( rRef.IsRowRel() )
+    {
+        nFlags |= sheet::ReferenceFlags::ROW_RELATIVE;
+        rAPI.RelativeRow = rRef.Row();
+        rAPI.Row = 0;
+    }
+    else
+    {
+        rAPI.RelativeRow = 0;
+        rAPI.Row = rRef.Row();
+    }
+
+    if ( rRef.IsTabRel() )
+    {
+        nFlags |= sheet::ReferenceFlags::SHEET_RELATIVE;
+        rAPI.RelativeSheet = rRef.Tab();
+        rAPI.Sheet = 0;
+    }
+    else
+    {
+        rAPI.RelativeSheet = 0;
+        rAPI.Sheet = rRef.Tab();
+    }
+
     if ( rRef.IsColDeleted() ) nFlags |= sheet::ReferenceFlags::COLUMN_DELETED;
     if ( rRef.IsRowDeleted() ) nFlags |= sheet::ReferenceFlags::ROW_DELETED;
     if ( rRef.IsTabDeleted() ) nFlags |= sheet::ReferenceFlags::SHEET_DELETED;
commit d031ba1261e791695dcf90ce181383b87791dd25
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.
    
    Conflicts:
    	sc/inc/refdata.hxx
    	sc/source/core/tool/refdata.cxx
    
    Change-Id: I0e8d3064d1ea52c8d502d89f322b41435284d717

diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx
index 588ce6f..159750d 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 735d262..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,42 +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 )
+{
+    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 )
+{
+    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 )
+{
+    mnTab += nInc;
 }
 
 void ScSingleRefData::SetColDeleted( bool bVal )
 {
-    Flags.bColDeleted = (bVal ? true : false );
+    Flags.bColDeleted = bVal;
 }
 
 bool ScSingleRefData::IsColDeleted() const
@@ -93,7 +108,7 @@ bool ScSingleRefData::IsColDeleted() const
 
 void ScSingleRefData::SetRowDeleted( bool bVal )
 {
-    Flags.bRowDeleted = (bVal ? true : false );
+    Flags.bRowDeleted = bVal;
 }
 
 bool ScSingleRefData::IsRowDeleted() const
@@ -103,7 +118,7 @@ bool ScSingleRefData::IsRowDeleted() const
 
 void ScSingleRefData::SetTabDeleted( bool bVal )
 {
-    Flags.bTabDeleted = (bVal ? true : false );
+    Flags.bTabDeleted = bVal;
 }
 
 bool ScSingleRefData::IsTabDeleted() const
@@ -125,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;
     }
 
@@ -141,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;
     }
 
@@ -157,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;
     }
 
@@ -171,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);
 
@@ -197,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
@@ -259,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 72fb1d1875add6b61cdb315188bd0e297e0d5ae0
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 34bd67b..588ce6f 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 );
@@ -84,10 +84,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;
@@ -102,8 +102,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 016273a5e28f8afba304818e5bf2c285a7137ad0
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.
    
    Conflicts:
    	sc/inc/refdata.hxx
    
    Change-Id: If4499dbee52532cc8a95c380bbe840719fe9279b

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 61188c1..05634ad 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -654,7 +654,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 0bcb9c0..34bd67b 100644
--- a/sc/inc/refdata.hxx
+++ b/sc/inc/refdata.hxx
@@ -28,7 +28,8 @@
 /// Single reference (one address) into the sheet
 struct SC_DLLPUBLIC ScSingleRefData
 {
-    SCsCOL  nCol;       // Absolute values
+private:
+    SCsCOL  nCol;       ///< Absolute values
     SCsROW  nRow;
     SCsTAB  nTab;
     SCsCOL  nRelCol;    // Values relative to the position
@@ -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 ); }
@@ -86,6 +90,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;
 
@@ -138,8 +145,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 5184da0..ba19573 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -1475,7 +1475,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 54f4325..af1b121 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 d1517b6..f3355ac 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -909,7 +909,7 @@ void ScFormulaCell::CalcAfterLoad()
 
 bool ScFormulaCell::MarkUsedExternalReferences()
 {
-    return pCode && pDocument->MarkUsedExternalReferences( *pCode);
+    return pCode && pDocument->MarkUsedExternalReferences(*pCode, aPos);
 }
 
 
@@ -2604,56 +2604,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 afb761b..e4fc98c 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 334dd97..419196e 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -2629,14 +2629,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();
@@ -4139,8 +4139,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:
@@ -4193,7 +4194,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 a038a5f..735d262 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;
@@ -113,16 +118,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
@@ -216,103 +265,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);
@@ -359,10 +311,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 b5c5072f..51a994e 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 2966e65..c5b9ebc 100644
--- a/sc/source/filter/excel/excform.cxx
+++ b/sc/source/filter/excel/excform.cxx
@@ -723,9 +723,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 );
 
@@ -744,7 +743,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 );
                     }
@@ -792,12 +791,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 );
@@ -889,7 +886,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;
 
@@ -1185,10 +1183,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 );
 
@@ -1243,12 +1240,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 6dabb30..e4ee733 100644
--- a/sc/source/filter/excel/excform8.cxx
+++ b/sc/source/filter/excel/excform8.cxx
@@ -773,9 +773,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 );
 
@@ -800,7 +799,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
@@ -814,7 +813,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 );
                     }
@@ -845,12 +844,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 );
@@ -1184,9 +1181,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 );
 
@@ -1216,12 +1212,10 @@ ConvErr ExcelToSc8::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sa
                     ScSingleRefData &rR1 = aCRD.Ref1;
                     ScSingleRefData &rR2 = aCRD.Ref2;
 
-                    rR1.nTab = nFirstScTab;
-                    rR2.nTab = nLastScTab;

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list