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

Kohei Yoshida kohei.yoshida at gmail.com
Wed Jul 24 20:27:32 PDT 2013


 sc/Library_sc.mk                         |    1 
 sc/inc/address.hxx                       |    9 
 sc/inc/calcmacros.hxx                    |    6 
 sc/inc/colorscale.hxx                    |    2 
 sc/inc/column.hxx                        |   26 -
 sc/inc/compiler.hxx                      |    2 
 sc/inc/document.hxx                      |    9 
 sc/inc/formulacell.hxx                   |   23 
 sc/inc/refdata.hxx                       |  195 ++-----
 sc/inc/reftokenhelper.hxx                |    9 
 sc/inc/refupdatecontext.hxx              |   64 ++
 sc/inc/scopetools.hxx                    |    9 
 sc/inc/sharedformula.hxx                 |    9 
 sc/inc/table.hxx                         |   28 -
 sc/inc/token.hxx                         |   23 
 sc/inc/tokenarray.hxx                    |   41 +
 sc/qa/unit/ucalc.cxx                     |   23 
 sc/source/core/data/colorscale.cxx       |   32 -
 sc/source/core/data/column.cxx           |  127 ++--
 sc/source/core/data/column2.cxx          |    7 
 sc/source/core/data/column3.cxx          |  152 -----
 sc/source/core/data/conditio.cxx         |    4 
 sc/source/core/data/documen2.cxx         |   20 
 sc/source/core/data/documen3.cxx         |  164 +++---
 sc/source/core/data/documen4.cxx         |   52 +-
 sc/source/core/data/document.cxx         |  109 +++-
 sc/source/core/data/formulacell.cxx      |  797 +++++++++++++++++--------------
 sc/source/core/data/formulaiter.cxx      |   17 
 sc/source/core/data/refupdatecontext.cxx |   34 +
 sc/source/core/data/table1.cxx           |   25 
 sc/source/core/data/table2.cxx           |   20 
 sc/source/core/data/table5.cxx           |    5 
 sc/source/core/data/validat.cxx          |    3 
 sc/source/core/inc/refupdat.hxx          |   42 +
 sc/source/core/tool/address.cxx          |   18 
 sc/source/core/tool/chartlis.cxx         |    8 
 sc/source/core/tool/chgtrack.cxx         |   35 -
 sc/source/core/tool/compiler.cxx         |  471 +++++++-----------
 sc/source/core/tool/consoli.cxx          |   16 
 sc/source/core/tool/detfunc.cxx          |    8 
 sc/source/core/tool/interpr1.cxx         |   22 
 sc/source/core/tool/interpr2.cxx         |   43 -
 sc/source/core/tool/interpr4.cxx         |  173 +++---
 sc/source/core/tool/rangenam.cxx         |   50 -
 sc/source/core/tool/refdata.cxx          |  333 +++++++++---
 sc/source/core/tool/reftokenhelper.cxx   |   83 +--
 sc/source/core/tool/refupdat.cxx         |  375 ++++++++------
 sc/source/core/tool/scopetools.cxx       |   11 
 sc/source/core/tool/sharedformula.cxx    |  118 ++++
 sc/source/core/tool/token.cxx            |  645 ++++++++++++++++++++-----
 sc/source/filter/excel/excform.cxx       |   53 --
 sc/source/filter/excel/excform8.cxx      |   73 +-
 sc/source/filter/excel/xeformula.cxx     |   39 -
 sc/source/filter/excel/xelink.cxx        |   35 -
 sc/source/filter/excel/xichart.cxx       |    2 
 sc/source/filter/excel/xiname.cxx        |    4 
 sc/source/filter/inc/xelink.hxx          |    4 
 sc/source/filter/lotus/lotform.cxx       |   31 -
 sc/source/filter/qpro/qproform.cxx       |   30 -
 sc/source/ui/miscdlgs/anyrefdg.cxx       |    7 
 sc/source/ui/unoobj/chart2uno.cxx        |   42 -
 sc/source/ui/view/viewfun6.cxx           |    8 
 62 files changed, 2839 insertions(+), 1987 deletions(-)

New commits:
commit e46af009fcde4f1fa8228c46c39440a4c860dee2
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu Jul 11 00:46:46 2013 -0400

    Move UnshareFormulaCell() out of ScColumn into SharedFormulaUtil.
    
    This one too doesn't operate on column.
    
    Conflicts:
    	sc/source/core/data/column.cxx
    
    Change-Id: Ieb23641ca4860d6f137b266813ad56f4984e0523

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index ce8d4c9..f38c195 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -479,8 +479,6 @@ public:
 
     void DetachFormulaCells( const sc::CellStoreType::position_type& aPos, size_t nLength );
 
-    void UnshareFormulaCell( const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell ) const;
-
     /**
      * Regroup formula cells for the entire column.
      */
diff --git a/sc/inc/sharedformula.hxx b/sc/inc/sharedformula.hxx
index fa75e80..866c22f 100644
--- a/sc/inc/sharedformula.hxx
+++ b/sc/inc/sharedformula.hxx
@@ -83,6 +83,15 @@ public:
      * @param aPos position of cell to examine.
      */
     static void joinFormulaCellAbove(const CellStoreType::position_type& aPos);
+
+    /**
+     * Turn a shared formula cell into a non-shared one, and split it off from
+     * the adjacent formula cell groups.
+     *
+     * @param aPos position of cell to examine
+     * @param rCell formula cell instance
+     */
+    static void unshareFormulaCell(const CellStoreType::position_type& aPos, ScFormulaCell& rCell);
 };
 
 }
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 4257551..cbe0ebd 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2372,7 +2372,7 @@ public:
     {
         sc::CellStoreType::position_type aPos = mrColumn.GetCellStore().position(miPos, nRow);
         miPos = aPos.first;
-        mrColumn.UnshareFormulaCell(aPos, *pCell);
+        sc::SharedFormulaUtil::unshareFormulaCell(aPos, *pCell);
         pCell->UpdateTranspose(maSource, maDest, mpUndoDoc);
         mrColumn.JoinNewFormulaCell(aPos, *pCell);
     }
@@ -2395,7 +2395,7 @@ public:
     {
         sc::CellStoreType::position_type aPos = mrColumn.GetCellStore().position(miPos, nRow);
         miPos = aPos.first;
-        mrColumn.UnshareFormulaCell(aPos, *pCell);
+        sc::SharedFormulaUtil::unshareFormulaCell(aPos, *pCell);
         pCell->UpdateGrow(maArea, mnGrowX, mnGrowY);
         mrColumn.JoinNewFormulaCell(aPos, *pCell);
     }
@@ -2772,7 +2772,7 @@ public:
 
         sc::CellStoreType::position_type aPos = mrColumn.GetCellStore().position(miPos, nRow);
         miPos = aPos.first;
-        mrColumn.UnshareFormulaCell(aPos, *pCell);
+        sc::SharedFormulaUtil::unshareFormulaCell(aPos, *pCell);
         pCell->GetCode()->SetCodeError(0);
         OUStringBuffer aBuf;
         pCell->GetFormula(aBuf, meGram);
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 27f8cc2..cc51449 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -114,7 +114,7 @@ void ScColumn::Delete( SCROW nRow )
     {
         ScFormulaCell* p = sc::formula_block::at(*it->data, aPos.second);
         p->EndListeningTo(pDocument);
-        UnshareFormulaCell(aPos, *p);
+        sc::SharedFormulaUtil::unshareFormulaCell(aPos, *p);
     }
     maCells.set_empty(nRow, nRow);
     maCellTextAttrs.set_empty(nRow, nRow);
@@ -327,8 +327,7 @@ void ScColumn::DetachFormulaCell(
         // Have the dying formula cell stop listening.
         rCell.EndListeningTo(pDocument);
 
-    if (rCell.IsShared())
-        UnshareFormulaCell(aPos, rCell);
+    sc::SharedFormulaUtil::unshareFormulaCell(aPos, rCell);
 }
 
 namespace {
@@ -367,125 +366,6 @@ void ScColumn::DetachFormulaCells(
     sc::ProcessFormula(aPos.first, maCells, nRow, nNextTopRow-1, aFunc);
 }
 
-void ScColumn::UnshareFormulaCell(
-    const sc::CellStoreType::position_type& aPos, ScFormulaCell& rCell ) const
-{
-    if (!rCell.IsShared())
-        return;
-
-    ScFormulaCellGroupRef xNone;
-    sc::CellStoreType::iterator it = aPos.first;
-
-    // This formula cell is shared. Adjust the shared group.
-    if (rCell.aPos.Row() == rCell.GetSharedTopRow())
-    {
-        // Top of the shared range.
-        ScFormulaCellGroupRef xGroup = rCell.GetCellGroup();
-        if (xGroup->mnLength == 2)
-        {
-            // Group consists only only two cells. Mark the second one non-shared.
-#if DEBUG_COLUMN_STORAGE
-            if (aPos.second+1 >= aPos.first->size)
-            {
-                cerr << "ScColumn::UnshareFormulaCell: There is no next formula cell but there should be!" << endl;
-                cerr.flush();
-                abort();
-            }
-#endif
-            ScFormulaCell& rNext = *sc::formula_block::at(*it->data, aPos.second+1);
-            rNext.SetCellGroup(xNone);
-        }
-        else
-        {
-            // Move the top cell to the next formula cell down.
-            --xGroup->mnLength;
-            ++xGroup->mnStart;
-        }
-    }
-    else if (rCell.aPos.Row() == rCell.GetSharedTopRow() + rCell.GetSharedLength() - 1)
-    {
-        // Bottom of the shared range.
-        ScFormulaCellGroupRef xGroup = rCell.GetCellGroup();
-        if (xGroup->mnLength == 2)
-        {
-            // Mark the top cell non-shared.
-#if DEBUG_COLUMN_STORAGE
-            if (aPos.second == 0)
-            {
-                cerr << "ScColumn::UnshareFormulaCell: There is no previous formula cell but there should be!" << endl;
-                cerr.flush();
-                abort();
-            }
-#endif
-            ScFormulaCell& rPrev = *sc::formula_block::at(*it->data, aPos.second-1);
-            rPrev.SetCellGroup(xNone);
-        }
-        else
-        {
-            // Just shortern the shared range length by one.
-            --xGroup->mnLength;
-        }
-    }
-    else
-    {
-        // In the middle of the shared range. Split it into two groups.
-        ScFormulaCellGroupRef xGroup = rCell.GetCellGroup();
-        SCROW nEndRow = xGroup->mnStart + xGroup->mnLength - 1;
-        xGroup->mnLength = rCell.aPos.Row() - xGroup->mnStart; // Shorten the top group.
-        if (xGroup->mnLength == 1)
-        {
-            // Make the top cell non-shared.
-#if DEBUG_COLUMN_STORAGE
-            if (aPos.second == 0)
-            {
-                cerr << "ScColumn::UnshareFormulaCell: There is no previous formula cell but there should be!" << endl;
-                cerr.flush();
-                abort();
-            }
-#endif
-            ScFormulaCell& rPrev = *sc::formula_block::at(*it->data, aPos.second-1);
-            rPrev.SetCellGroup(xNone);
-        }
-
-        SCROW nLength2 = nEndRow - rCell.aPos.Row();
-        if (nLength2 >= 2)
-        {
-            ScFormulaCellGroupRef xGroup2;
-            xGroup2.reset(new ScFormulaCellGroup);
-            xGroup2->mnStart = rCell.aPos.Row() + 1;
-            xGroup2->mnLength = nLength2;
-            xGroup2->mbInvariant = xGroup->mbInvariant;
-#if DEBUG_COLUMN_STORAGE
-            if (xGroup2->mnStart + xGroup2->mnLength > it->position + it->size)
-            {
-                cerr << "ScColumn::UnshareFormulaCell: Shared formula region goes beyond the formula block. Not good." << endl;
-                cerr.flush();
-                abort();
-            }
-#endif
-            sc::formula_block::iterator itCell = sc::formula_block::begin(*it->data);
-            std::advance(itCell, aPos.second+1);
-            sc::formula_block::iterator itCellEnd = itCell;
-            std::advance(itCellEnd, xGroup2->mnLength);
-            for (; itCell != itCellEnd; ++itCell)
-            {
-                ScFormulaCell& rCell2 = **itCell;
-                rCell2.SetCellGroup(xGroup2);
-            }
-        }
-        else
-        {
-            // Make the next cell non-shared.
-            sc::formula_block::iterator itCell = sc::formula_block::begin(*it->data);
-            std::advance(itCell, aPos.second+1);
-            ScFormulaCell& rCell2 = **itCell;
-            rCell2.SetCellGroup(xNone);
-        }
-    }
-
-    rCell.SetCellGroup(xNone);
-}
-
 sc::CellStoreType::iterator ScColumn::GetPositionToInsert( const sc::CellStoreType::iterator& it, SCROW nRow )
 {
     // See if we are overwriting an existing formula cell.
@@ -657,7 +537,7 @@ class EmptyCells
         if (rPos.first->type == sc::element_type_formula)
         {
             ScFormulaCell& rCell = *sc::formula_block::at(*rPos.first->data, rPos.second);
-            mrColumn.UnshareFormulaCell(rPos, rCell);
+            sc::SharedFormulaUtil::unshareFormulaCell(rPos, rCell);
         }
     }
 
diff --git a/sc/source/core/tool/sharedformula.cxx b/sc/source/core/tool/sharedformula.cxx
index 5cdfc785..2ea5cf8 100644
--- a/sc/source/core/tool/sharedformula.cxx
+++ b/sc/source/core/tool/sharedformula.cxx
@@ -139,6 +139,124 @@ void SharedFormulaUtil::joinFormulaCellAbove(const CellStoreType::position_type&
     joinFormulaCells(aPosPrev, rPrev, rCell);
 }
 
+void SharedFormulaUtil::unshareFormulaCell(const CellStoreType::position_type& aPos, ScFormulaCell& rCell)
+{
+    if (!rCell.IsShared())
+        return;
+
+    ScFormulaCellGroupRef xNone;
+    sc::CellStoreType::iterator it = aPos.first;
+
+    // This formula cell is shared. Adjust the shared group.
+    if (rCell.aPos.Row() == rCell.GetSharedTopRow())
+    {
+        // Top of the shared range.
+        ScFormulaCellGroupRef xGroup = rCell.GetCellGroup();
+        if (xGroup->mnLength == 2)
+        {
+            // Group consists only only two cells. Mark the second one non-shared.
+#if DEBUG_COLUMN_STORAGE
+            if (aPos.second+1 >= aPos.first->size)
+            {
+                cerr << "ScColumn::UnshareFormulaCell: There is no next formula cell but there should be!" << endl;
+                cerr.flush();
+                abort();
+            }
+#endif
+            ScFormulaCell& rNext = *sc::formula_block::at(*it->data, aPos.second+1);
+            rNext.SetCellGroup(xNone);
+        }
+        else
+        {
+            // Move the top cell to the next formula cell down.
+            --xGroup->mnLength;
+            ++xGroup->mnStart;
+        }
+    }
+    else if (rCell.aPos.Row() == rCell.GetSharedTopRow() + rCell.GetSharedLength() - 1)
+    {
+        // Bottom of the shared range.
+        ScFormulaCellGroupRef xGroup = rCell.GetCellGroup();
+        if (xGroup->mnLength == 2)
+        {
+            // Mark the top cell non-shared.
+#if DEBUG_COLUMN_STORAGE
+            if (aPos.second == 0)
+            {
+                cerr << "ScColumn::UnshareFormulaCell: There is no previous formula cell but there should be!" << endl;
+                cerr.flush();
+                abort();
+            }
+#endif
+            ScFormulaCell& rPrev = *sc::formula_block::at(*it->data, aPos.second-1);
+            rPrev.SetCellGroup(xNone);
+        }
+        else
+        {
+            // Just shortern the shared range length by one.
+            --xGroup->mnLength;
+        }
+    }
+    else
+    {
+        // In the middle of the shared range. Split it into two groups.
+        ScFormulaCellGroupRef xGroup = rCell.GetCellGroup();
+        SCROW nEndRow = xGroup->mnStart + xGroup->mnLength - 1;
+        xGroup->mnLength = rCell.aPos.Row() - xGroup->mnStart; // Shorten the top group.
+        if (xGroup->mnLength == 1)
+        {
+            // Make the top cell non-shared.
+#if DEBUG_COLUMN_STORAGE
+            if (aPos.second == 0)
+            {
+                cerr << "ScColumn::UnshareFormulaCell: There is no previous formula cell but there should be!" << endl;
+                cerr.flush();
+                abort();
+            }
+#endif
+            ScFormulaCell& rPrev = *sc::formula_block::at(*it->data, aPos.second-1);
+            rPrev.SetCellGroup(xNone);
+        }
+
+        SCROW nLength2 = nEndRow - rCell.aPos.Row();
+        if (nLength2 >= 2)
+        {
+            ScFormulaCellGroupRef xGroup2;
+            xGroup2.reset(new ScFormulaCellGroup);
+            xGroup2->mnStart = rCell.aPos.Row() + 1;
+            xGroup2->mnLength = nLength2;
+            xGroup2->mbInvariant = xGroup->mbInvariant;
+#if DEBUG_COLUMN_STORAGE
+            if (xGroup2->mnStart + xGroup2->mnLength > it->position + it->size)
+            {
+                cerr << "ScColumn::UnshareFormulaCell: Shared formula region goes beyond the formula block. Not good." << endl;
+                cerr.flush();
+                abort();
+            }
+#endif
+            sc::formula_block::iterator itCell = sc::formula_block::begin(*it->data);
+            std::advance(itCell, aPos.second+1);
+            sc::formula_block::iterator itCellEnd = itCell;
+            std::advance(itCellEnd, xGroup2->mnLength);
+            for (; itCell != itCellEnd; ++itCell)
+            {
+                ScFormulaCell& rCell2 = **itCell;
+                rCell2.SetCellGroup(xGroup2);
+            }
+        }
+        else
+        {
+            // Make the next cell non-shared.
+            sc::formula_block::iterator itCell = sc::formula_block::begin(*it->data);
+            std::advance(itCell, aPos.second+1);
+            ScFormulaCell& rCell2 = **itCell;
+            rCell2.SetCellGroup(xNone);
+        }
+    }
+
+    rCell.SetCellGroup(xNone);
+}
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit e5ffe0b4669f07ae35147257f5bf6f4fab128192
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Wed Jul 24 22:28:01 2013 -0400

    These static_cast's are very significant. Don't remove these.
    
    This fixes the shared formula import from xls.
    
    Conflicts:
    	sc/qa/unit/filters-test.cxx
    
    Change-Id: I8790e642c3ef1a335694891eb574a68ae5270649

diff --git a/sc/source/filter/excel/excform8.cxx b/sc/source/filter/excel/excform8.cxx
index c4feda8..9251828 100644
--- a/sc/source/filter/excel/excform8.cxx
+++ b/sc/source/filter/excel/excform8.cxx
@@ -1433,9 +1433,9 @@ void ExcelToSc8::ExcRelToScRel8( sal_uInt16 nRow, sal_uInt16 nC, ScSingleRefData
     {
         // C O L
         if( bColRel )
-            rSRD.SetRelCol(nC);
+            rSRD.SetRelCol(static_cast<SCCOL>(static_cast<sal_Int8>(nC)));
         else
-            rSRD.SetAbsCol(nCol);
+            rSRD.SetAbsCol(static_cast<SCCOL>(nCol));
 
         // R O W
         if( bRowRel )
commit 53d27f96ffbc2972a9e3e8c193517cbd2eee3c8b
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Wed Jul 24 20:32:18 2013 -0400

    Work on remving direct access to ScSingleRefData's data members.
    
    This broke the shared formula import from xls and xlsx. Disabling the
    tests for now.
    
    Conflicts:
    	sc/qa/unit/filters-test.cxx
    	sc/qa/unit/ucalc_formula.cxx
    
    Change-Id: I75d802b00947b21083db19b5c07204a0c3d4f369

diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx
index b704d57..5b6a8fc 100644
--- a/sc/inc/refdata.hxx
+++ b/sc/inc/refdata.hxx
@@ -65,6 +65,13 @@ struct SC_DLLPUBLIC ScSingleRefData
     inline  void SetTabRel( bool bVal ) { Flags.bTabRel = (bVal ? true : false ); }
     inline  bool IsTabRel() const       { return Flags.bTabRel; }
 
+    void SetAbsCol( SCCOL nVal );
+    void SetRelCol( SCCOL nVal );
+    void SetAbsRow( SCROW nVal );
+    void SetRelRow( SCROW nVal );
+    void SetAbsTab( SCTAB nVal );
+    void SetRelTab( SCTAB nVal );
+
     void SetColDeleted( bool bVal );
     bool IsColDeleted() const;
     void SetRowDeleted( bool bVal );
@@ -84,9 +91,9 @@ struct SC_DLLPUBLIC ScSingleRefData
 
     ScAddress toAbs( const ScAddress& rPos ) const;
     void SetAddress( const ScAddress& rAddr, const ScAddress& rPos );
-    SCROW GetRow() const;
-    SCCOL GetCol() const;
-    SCTAB GetTab() const;
+    SCROW Row() const;
+    SCCOL Col() const;
+    SCTAB Tab() const;
 
             bool operator==( const ScSingleRefData& ) const;
             bool operator!=( const ScSingleRefData& ) const;
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 88028cf..b3d716d 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -1391,7 +1391,7 @@ void ScConditionEntry::SourceChanged( const ScAddress& rChanged )
                     SCsTAB nTab2;
 
                     if ( aProv.Ref1.IsColRel() )
-                        nCol2 = rChanged.Col() - aProv.Ref1.nRelCol;
+                        nCol2 = rChanged.Col() - aProv.Ref1.Col();
                     else
                     {
                         bHit &= ( rChanged.Col() >= aProv.Ref1.nCol );
@@ -1413,7 +1413,7 @@ void ScConditionEntry::SourceChanged( const ScAddress& rChanged )
                     }
 
                     if ( aProv.Ref2.IsColRel() )
-                        nCol1 = rChanged.Col() - aProv.Ref2.nRelCol;
+                        nCol1 = rChanged.Col() - aProv.Ref2.Col();
                     else
                     {
                         bHit &= ( rChanged.Col() <= aProv.Ref2.nCol );
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 57871f6..cfe17ac 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -2674,17 +2674,17 @@ void ScFormulaCell::TransposeReference()
             ScSingleRefData& rRef2 = (bDouble ? t->GetDoubleRef().Ref2 : rRef1);
             if ( !bDouble || (rRef2.IsColRel() && rRef2.IsRowRel()) )
             {
-                sal_Int16 nTemp;
+                SCCOLROW nTemp;
 
-                nTemp = rRef1.nRelCol;
-                rRef1.nRelCol = static_cast<SCCOL>(rRef1.nRelRow);
-                rRef1.nRelRow = static_cast<SCROW>(nTemp);
+                nTemp = rRef1.Col();
+                rRef1.SetRelCol(rRef1.Row());
+                rRef1.SetRelRow(nTemp);
 
                 if ( bDouble )
                 {
-                    nTemp = rRef2.nRelCol;
-                    rRef2.nRelCol = static_cast<SCCOL>(rRef2.nRelRow);
-                    rRef2.nRelRow = static_cast<SCROW>(nTemp);
+                    nTemp = rRef2.Col();
+                    rRef2.SetRelCol(rRef2.Row());
+                    rRef2.SetRelRow(nTemp);
                 }
 
                 bFound = true;
diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx
index 6b132ad..5265722 100644
--- a/sc/source/core/tool/chgtrack.cxx
+++ b/sc/source/core/tool/chgtrack.cxx
@@ -1977,19 +1977,16 @@ static void lcl_InvalidateReference( ScToken& rTok, const ScBigAddress& rPos )
     if ( rPos.Col() < 0 || MAXCOL < rPos.Col() )
     {
         rRef1.nCol = SCCOL_MAX;
-        rRef1.nRelCol = SCCOL_MAX;
         rRef1.SetColDeleted( true );
     }
     if ( rPos.Row() < 0 || MAXROW < rPos.Row() )
     {
         rRef1.nRow = SCROW_MAX;
-        rRef1.nRelRow = SCROW_MAX;
         rRef1.SetRowDeleted( true );
     }
     if ( rPos.Tab() < 0 || MAXTAB < rPos.Tab() )
     {
         rRef1.nTab = SCTAB_MAX;
-        rRef1.nRelTab = SCTAB_MAX;
         rRef1.SetTabDeleted( true );
     }
     if ( rTok.GetType() == formula::svDoubleRef )
@@ -1998,19 +1995,16 @@ static void lcl_InvalidateReference( ScToken& rTok, const ScBigAddress& rPos )
         if ( rPos.Col() < 0 || MAXCOL < rPos.Col() )
         {
             rRef2.nCol = SCCOL_MAX;
-            rRef2.nRelCol = SCCOL_MAX;
             rRef2.SetColDeleted( true );
         }
         if ( rPos.Row() < 0 || MAXROW < rPos.Row() )
         {
             rRef2.nRow = SCROW_MAX;
-            rRef2.nRelRow = SCROW_MAX;
             rRef2.SetRowDeleted( true );
         }
         if ( rPos.Tab() < 0 || MAXTAB < rPos.Tab() )
         {
             rRef2.nTab = SCTAB_MAX;
-            rRef2.nRelTab = SCTAB_MAX;
             rRef2.SetTabDeleted( true );
         }
     }
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index abcb92d..684790d 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -1448,8 +1448,9 @@ r1c1_add_col( OUStringBuffer &rBuf, const ScSingleRefData& rRef, const ScAddress
     rBuf.append( sal_Unicode( 'C' ) );
     if( rRef.IsColRel() )
     {
-        if (rRef.nRelCol != 0)
-            rBuf.append("[").append( OUString::number( rRef.nRelCol ) ).append("]");
+        SCCOL nCol = rRef.Col();
+        if (nCol != 0)
+            rBuf.append("[").append(OUString::number(nCol)).append("]");
     }
     else
         rBuf.append( OUString::number( rAbsRef.Col() + 1 ) );
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 861e015..e3536db 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -1152,17 +1152,20 @@ void ScInterpreter::SingleRefToVars( const ScSingleRefData & rRef,
 {
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::SingleRefToVars" );
     if ( rRef.IsColRel() )
-        rCol = aPos.Col() + rRef.nRelCol;
+        rCol = aPos.Col() + rRef.Col();
     else
-        rCol = rRef.nCol;
+        rCol = rRef.Col();
+
     if ( rRef.IsRowRel() )
-        rRow = aPos.Row() + rRef.nRelRow;
+        rRow = aPos.Row() + rRef.Row();
     else
-        rRow = rRef.nRow;
+        rRow = rRef.Row();
+
     if ( rRef.IsTabRel() )
-        rTab = aPos.Tab() + rRef.nRelTab;
+        rTab = aPos.Tab() + rRef.Tab();
     else
-        rTab = rRef.nTab;
+        rTab = rRef.Tab();
+
     if( !ValidCol( rCol) || rRef.IsColDeleted() )
         SetError( errNoRef ), rCol = 0;
     if( !ValidRow( rRow) || rRef.IsRowDeleted() )
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index 84c3fb9..51d402f 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -213,22 +213,22 @@ void ScRangeData::GuessPosition()
     while ( ( t = static_cast<ScToken*>(pCode->GetNextReference()) ) != NULL )
     {
         ScSingleRefData& rRef1 = t->GetSingleRef();
-        if ( rRef1.IsColRel() && rRef1.nRelCol < nMinCol )
-            nMinCol = rRef1.nRelCol;
-        if ( rRef1.IsRowRel() && rRef1.nRelRow < nMinRow )
-            nMinRow = rRef1.nRelRow;
-        if ( rRef1.IsTabRel() && rRef1.nRelTab < nMinTab )
-            nMinTab = rRef1.nRelTab;
+        if ( rRef1.IsColRel() && rRef1.Col() < nMinCol )
+            nMinCol = rRef1.Col();
+        if ( rRef1.IsRowRel() && rRef1.Row() < nMinRow )
+            nMinRow = rRef1.Row();
+        if ( rRef1.IsTabRel() && rRef1.Tab() < nMinTab )
+            nMinTab = rRef1.Tab();
 
         if ( t->GetType() == svDoubleRef )
         {
             ScSingleRefData& rRef2 = t->GetDoubleRef().Ref2;
-            if ( rRef2.IsColRel() && rRef2.nRelCol < nMinCol )
-                nMinCol = rRef2.nRelCol;
-            if ( rRef2.IsRowRel() && rRef2.nRelRow < nMinRow )
-                nMinRow = rRef2.nRelRow;
-            if ( rRef2.IsTabRel() && rRef2.nRelTab < nMinTab )
-                nMinTab = rRef2.nRelTab;
+            if ( rRef2.IsColRel() && rRef2.Col() < nMinCol )
+                nMinCol = rRef2.Col();
+            if ( rRef2.IsRowRel() && rRef2.Row() < nMinRow )
+                nMinRow = rRef2.Row();
+            if ( rRef2.IsTabRel() && rRef2.Tab() < nMinTab )
+                nMinTab = rRef2.Tab();
         }
     }
 
diff --git a/sc/source/core/tool/refdata.cxx b/sc/source/core/tool/refdata.cxx
index a804838..a4735dc 100644
--- a/sc/source/core/tool/refdata.cxx
+++ b/sc/source/core/tool/refdata.cxx
@@ -40,6 +40,42 @@ void ScSingleRefData::InitAddressRel( const ScAddress& rAdr, const ScAddress& rP
     SetAddress(rAdr, rPos);
 }
 
+void ScSingleRefData::SetAbsCol( SCCOL nVal )
+{
+    Flags.bColRel = false;
+    nCol = nVal;
+}
+
+void ScSingleRefData::SetRelCol( SCCOL nVal )
+{
+    Flags.bColRel = true;
+    nRelCol = nVal;
+}
+
+void ScSingleRefData::SetAbsRow( SCROW nVal )
+{
+    Flags.bRowRel = false;
+    nRow = nVal;
+}
+
+void ScSingleRefData::SetRelRow( SCROW nVal )
+{
+    Flags.bRowRel = true;
+    nRelRow = nVal;
+}
+
+void ScSingleRefData::SetAbsTab( SCTAB nVal )
+{
+    Flags.bTabRel = false;
+    nTab = nVal;
+}
+
+void ScSingleRefData::SetRelTab( SCTAB nVal )
+{
+    Flags.bTabRel = true;
+    nRelTab = nVal;
+}
+
 void ScSingleRefData::SetColDeleted( bool bVal )
 {
     Flags.bColDeleted = (bVal ? true : false );
@@ -127,21 +163,21 @@ void ScSingleRefData::SetAddress( const ScAddress& rAddr, const ScAddress& rPos
         nTab = rAddr.Tab();
 }
 
-SCROW ScSingleRefData::GetRow() const
+SCROW ScSingleRefData::Row() const
 {
     if (Flags.bRowDeleted)
         return -1;
     return Flags.bRowRel ? nRelRow : nRow;
 }
 
-SCCOL ScSingleRefData::GetCol() const
+SCCOL ScSingleRefData::Col() const
 {
     if (Flags.bColDeleted)
         return -1;
     return Flags.bColRel ? nRelCol : nCol;
 }
 
-SCTAB ScSingleRefData::GetTab() const
+SCTAB ScSingleRefData::Tab() const
 {
     if (Flags.bTabDeleted)
         return -1;
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index e1c60a5..a7d6252 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -55,13 +55,6 @@ namespace
     {
         rRef.InitFlags();
 
-        rRef.nCol    = static_cast<SCsCOL>(rAPI.Column);
-        rRef.nRow    = static_cast<SCsROW>(rAPI.Row);
-        rRef.nTab    = static_cast<SCsTAB>(rAPI.Sheet);
-        rRef.nRelCol = static_cast<SCsCOL>(rAPI.RelativeColumn);
-        rRef.nRelRow = static_cast<SCsROW>(rAPI.RelativeRow);
-        rRef.nRelTab = static_cast<SCsTAB>(rAPI.RelativeSheet);
-
         rRef.SetColRel(     ( rAPI.Flags & sheet::ReferenceFlags::COLUMN_RELATIVE ) != 0 );
         rRef.SetRowRel(     ( rAPI.Flags & sheet::ReferenceFlags::ROW_RELATIVE    ) != 0 );
         rRef.SetTabRel(     ( rAPI.Flags & sheet::ReferenceFlags::SHEET_RELATIVE  ) != 0 );
@@ -70,27 +63,47 @@ namespace
         rRef.SetTabDeleted( ( rAPI.Flags & sheet::ReferenceFlags::SHEET_DELETED   ) != 0 );
         rRef.SetFlag3D(     ( rAPI.Flags & sheet::ReferenceFlags::SHEET_3D        ) != 0 );
         rRef.SetRelName(    ( rAPI.Flags & sheet::ReferenceFlags::RELATIVE_NAME   ) != 0 );
+
+        if (rRef.IsColRel())
+            rRef.SetRelCol(static_cast<SCCOL>(rAPI.RelativeColumn));
+        else
+            rRef.SetAbsCol(static_cast<SCCOL>(rAPI.Column));
+
+        if (rRef.IsRowRel())
+            rRef.SetRelRow(static_cast<SCROW>(rAPI.RelativeRow));
+        else
+            rRef.SetAbsRow(static_cast<SCROW>(rAPI.Row));
+
+        if (rRef.IsTabRel())
+            rRef.SetRelTab(static_cast<SCsTAB>(rAPI.RelativeSheet));
+        else
+            rRef.SetAbsTab(static_cast<SCsTAB>(rAPI.Sheet));
     }
 
     void lcl_ExternalRefToCalc( ScSingleRefData& rRef, const sheet::SingleReference& rAPI )
     {
         rRef.InitFlags();
 
-        rRef.nCol    = static_cast<SCsCOL>(rAPI.Column);
-        rRef.nRow    = static_cast<SCsROW>(rAPI.Row);
-        rRef.nTab    = 0;
-        rRef.nRelCol = static_cast<SCsCOL>(rAPI.RelativeColumn);
-        rRef.nRelRow = static_cast<SCsROW>(rAPI.RelativeRow);
-        rRef.nRelTab = 0;
-
         rRef.SetColRel(     ( rAPI.Flags & sheet::ReferenceFlags::COLUMN_RELATIVE ) != 0 );
         rRef.SetRowRel(     ( rAPI.Flags & sheet::ReferenceFlags::ROW_RELATIVE    ) != 0 );
-        rRef.SetTabRel(     false );    // sheet index must be absolute for external refs
         rRef.SetColDeleted( ( rAPI.Flags & sheet::ReferenceFlags::COLUMN_DELETED  ) != 0 );
         rRef.SetRowDeleted( ( rAPI.Flags & sheet::ReferenceFlags::ROW_DELETED     ) != 0 );
         rRef.SetTabDeleted( false );    // sheet must not be deleted for external refs
         rRef.SetFlag3D(     ( rAPI.Flags & sheet::ReferenceFlags::SHEET_3D        ) != 0 );
         rRef.SetRelName(    false );
+
+        if (rRef.IsColRel())
+            rRef.SetRelCol(static_cast<SCCOL>(rAPI.RelativeColumn));
+        else
+            rRef.SetAbsCol(static_cast<SCCOL>(rAPI.Column));
+
+        if (rRef.IsRowRel())
+            rRef.SetRelRow(static_cast<SCROW>(rAPI.RelativeRow));
+        else
+            rRef.SetAbsRow(static_cast<SCROW>(rAPI.Row));
+
+        // sheet index must be absolute for external refs
+        rRef.SetAbsTab(0);
     }
 //
 } // namespace
@@ -449,9 +462,6 @@ static ScSingleRefData lcl_ScToken_InitSingleRef()
 {
     ScSingleRefData aRef;
     aRef.InitAddress( ScAddress() );
-    aRef.nRelCol = 0;
-    aRef.nRelRow = 0;
-    aRef.nRelTab = 0;
     return aRef;
 }
 
diff --git a/sc/source/filter/excel/excform.cxx b/sc/source/filter/excel/excform.cxx
index 4f255da..2a86d58 100644
--- a/sc/source/filter/excel/excform.cxx
+++ b/sc/source/filter/excel/excform.cxx
@@ -1593,57 +1593,48 @@ void ExcelToSc::ExcRelToScRel( sal_uInt16 nRow, sal_uInt8 nCol, ScSingleRefData
     {
         // C O L
         if( nRow & 0x4000 )
-        {//                                                         rel Col
-            rSRD.SetColRel( sal_True );
-            rSRD.nRelCol = static_cast<SCsCOL>(static_cast<sal_Int8>(nCol));
-        }
+            rSRD.SetRelCol(nCol);
         else
-        {//                                                         abs Col
-            rSRD.SetColRel( false );
-            rSRD.nCol = static_cast<SCCOL>(nCol);
-        }
+            rSRD.SetAbsCol(nCol);
 
         // R O W
         if( nRow & 0x8000 )
         {//                                                         rel Row
-            rSRD.SetRowRel( sal_True );
             if( nRow & 0x2000 ) // Bit 13 set?
-                //                                              -> Row negative
-                rSRD.nRelRow = static_cast<SCsROW>(static_cast<sal_Int16>(nRow | 0xC000));
+                // Row negative
+                rSRD.SetRelRow(nRow | 0xC000);
             else
-                //                                              -> Row positive
-                rSRD.nRelRow = static_cast<SCsROW>(nRow & nRowMask);
+                // Row positive
+                rSRD.SetRelRow(nRow & nRowMask);
         }
         else
         {//                                                         abs Row
-            rSRD.SetRowRel( false );
-            rSRD.nRow = static_cast<SCROW>(nRow & nRowMask);
+            rSRD.SetAbsRow(nRow & nRowMask);
         }
 
         // T A B
         // abs needed if rel in shared formula for ScCompiler UpdateNameReference
         if ( rSRD.IsTabRel() && !rSRD.IsFlag3D() )
-            rSRD.nTab = GetCurrScTab();
+            rSRD.SetAbsTab(GetCurrScTab());
     }
     else
     {
-        // C O L
-        rSRD.SetColRel( ( nRow & 0x4000 ) > 0 );
-        rSRD.nCol = static_cast<SCsCOL>(nCol);
+        bool bColRel = (nRow & 0x4000) > 0;
+        bool bRowRel = (nRow & 0x8000) > 0;
 
-        // R O W
-        rSRD.SetRowRel( ( nRow & 0x8000 ) > 0 );
-        rSRD.nRow = static_cast<SCsROW>(nRow & nRowMask);
+        if (bColRel)
+            rSRD.SetRelCol(nCol - aEingPos.Col());
+        else
+            rSRD.SetAbsCol(nCol);
 
-        if ( rSRD.IsColRel() )
-            rSRD.nRelCol = rSRD.nCol - aEingPos.Col();
-        if ( rSRD.IsRowRel() )
-            rSRD.nRelRow = rSRD.nRow - aEingPos.Row();
+        rSRD.SetAbsRow(nRow & nRowMask);
+        if (bRowRel)
+            rSRD.SetRelRow(rSRD.Row() - aEingPos.Row());
 
         // T A B
         // #i10184# abs needed if rel in shared formula for ScCompiler UpdateNameReference
         if ( rSRD.IsTabRel() && !rSRD.IsFlag3D() )
-            rSRD.nTab = GetCurrScTab() + rSRD.nRelTab;
+            rSRD.SetAbsTab(GetCurrScTab() + rSRD.Tab());
     }
 }
 
@@ -1755,9 +1746,9 @@ void ExcelToSc::SetComplCol( ScComplexRefData &rCRD )
 {
     ScSingleRefData &rSRD = rCRD.Ref2;
     if( rSRD.IsColRel() )
-        rSRD.nRelCol = MAXCOL - aEingPos.Col();
+        rSRD.SetRelCol(MAXCOL - aEingPos.Col());
     else
-        rSRD.nCol = MAXCOL;
+        rSRD.SetAbsCol(MAXCOL);
 }
 
 
@@ -1765,9 +1756,9 @@ void ExcelToSc::SetComplRow( ScComplexRefData &rCRD )
 {
     ScSingleRefData &rSRD = rCRD.Ref2;
     if( rSRD.IsRowRel() )
-        rSRD.nRelRow = MAXROW - aEingPos.Row();
+        rSRD.SetRelRow(MAXROW - aEingPos.Row());
     else
-        rSRD.nRow = MAXROW;
+        rSRD.SetAbsRow(MAXROW);
 }
 
 void ExcelToSc::ReadExtensionArray( unsigned int n, XclImpStream& aIn )
diff --git a/sc/source/filter/excel/excform8.cxx b/sc/source/filter/excel/excform8.cxx
index 024edea..c4feda8 100644
--- a/sc/source/filter/excel/excform8.cxx
+++ b/sc/source/filter/excel/excform8.cxx
@@ -1425,60 +1425,37 @@ ConvErr ExcelToSc8::ConvertExternName( const ScTokenArray*& rpArray, XclImpStrea
 
 void ExcelToSc8::ExcRelToScRel8( sal_uInt16 nRow, sal_uInt16 nC, ScSingleRefData &rSRD, const sal_Bool bName )
 {
-    const sal_Bool      bColRel = ( nC & 0x4000 ) != 0;
-    const sal_Bool      bRowRel = ( nC & 0x8000 ) != 0;
-    const sal_uInt8     nCol = static_cast<sal_uInt8>(nC);
-
-    rSRD.SetColRel( bColRel );
-    rSRD.SetRowRel( bRowRel );
+    const bool bColRel = ( nC & 0x4000 ) != 0;
+    const bool bRowRel = ( nC & 0x8000 ) != 0;
+    const sal_uInt8 nCol = static_cast<sal_uInt8>(nC);
 
     if( bName )
     {
         // C O L
         if( bColRel )
-            //                                                          rel Col
-            rSRD.nRelCol = static_cast<SCsCOL>(static_cast<sal_Int8>(nC));
+            rSRD.SetRelCol(nC);
         else
-            //                                                          abs Col
-            rSRD.nCol = static_cast<SCCOL>(nCol);
+            rSRD.SetAbsCol(nCol);
 
         // R O W
         if( bRowRel )
-            //                                                          rel Row
-            rSRD.nRelRow = static_cast<SCsROW>(static_cast<sal_Int16>(nRow));
+            rSRD.SetRelRow(nRow);
         else
-            //                                                          abs Row
-            rSRD.nRow = std::min( static_cast<SCROW>(nRow), MAXROW);
-
-        // T A B
-        // abs needed if rel in shared formula for ScCompiler UpdateNameReference
-        if ( rSRD.IsTabRel() && !rSRD.IsFlag3D() )
-            rSRD.nTab = GetCurrScTab();
+            rSRD.SetAbsRow(std::min( static_cast<SCROW>(nRow), MAXROW));
     }
     else
     {
         // C O L
         if ( bColRel )
-        {
-            rSRD.nRelCol = static_cast<SCsCOL>(nCol) - aEingPos.Col();
-            rSRD.nCol = rSRD.nRelCol;
-        }
+            rSRD.SetRelCol(static_cast<SCCOL>(nCol) - aEingPos.Col());
         else
-            rSRD.nCol = static_cast<SCCOL>(nCol);
+            rSRD.SetAbsCol(nCol);
 
         // R O W
         if ( bRowRel )
-        {
-            rSRD.nRelRow = static_cast<SCsROW>(nRow) - aEingPos.Row();
-            rSRD.nRow = rSRD.nRelRow;
-        }
+            rSRD.SetRelRow(static_cast<SCROW>(nRow) - aEingPos.Row());
         else
-            rSRD.nRow = static_cast<SCROW>(nRow);
-
-        // T A B
-        // #i10184# abs needed if rel in shared formula for ScCompiler UpdateNameReference
-        if ( rSRD.IsTabRel() && !rSRD.IsFlag3D() )
-            rSRD.nTab = GetCurrScTab() + rSRD.nRelTab;
+            rSRD.SetAbsRow(nRow);
     }
 }
 
diff --git a/sc/source/filter/lotus/lotform.cxx b/sc/source/filter/lotus/lotform.cxx
index 33e8456..75460cd 100644
--- a/sc/source/filter/lotus/lotform.cxx
+++ b/sc/source/filter/lotus/lotform.cxx
@@ -215,24 +215,22 @@ void LotusToSc::LotusRelToScRel( sal_uInt16 nCol, sal_uInt16 nRow, ScSingleRefDa
     // Col-Bemachung
     if( nCol & 0x8000 )
     {
-        rSRD.SetColRel( sal_True );
         if( nCol & 0x0080 )
             nCol |= 0xFF00;
         else
             nCol &= 0x00FF;
-        // #i36252# first cast unsigned 16-bit to signed 16-bit, and then to SCsCOL
-        rSRD.nRelCol = static_cast< SCsCOL >( static_cast< sal_Int16 >( nCol ) );
+        // #i36252# first cast unsigned 16-bit to signed 16-bit, and then to SCCOL
+        rSRD.SetRelCol(static_cast<SCCOL>(static_cast<sal_Int16>(nCol)));
     }
     else
     {
-        rSRD.SetColRel( false );
-        rSRD.nCol = static_cast< SCsCOL >( nCol & 0x00FF );
+        rSRD.SetAbsCol(static_cast<SCCOL>(nCol & 0x00FF));
     }
 
     // Row-Bemachung
     if( nRow & 0x8000 )
     {
-        rSRD.SetRowRel( sal_True );
+        rSRD.SetRowRel(true);
         // vorzeichenrichtige Erweiterung
         switch( eTyp )
         {
@@ -259,7 +257,7 @@ void LotusToSc::LotusRelToScRel( sal_uInt16 nCol, sal_uInt16 nRow, ScSingleRefDa
     }
     else
     {
-        rSRD.SetRowRel( false );
+        rSRD.SetRowRel(false);
         switch( eTyp )
         {
             // 5432 1098 7654 3210
@@ -279,10 +277,10 @@ void LotusToSc::LotusRelToScRel( sal_uInt16 nCol, sal_uInt16 nRow, ScSingleRefDa
     }
 
     if( rSRD.IsRowRel() )
-        // #i36252# first cast unsigned 16-bit to signed 16-bit, and then to SCsROW
-        rSRD.nRelRow = static_cast< SCsROW >( static_cast< sal_Int16 >( nRow ) );
+        // #i36252# first cast unsigned 16-bit to signed 16-bit, and then to SCROW
+        rSRD.SetRelRow(static_cast<SCROW>(static_cast<sal_Int16>(nRow)));
     else
-        rSRD.nRow = static_cast< SCsROW >( nRow );
+        rSRD.SetAbsRow(static_cast<SCROW>(nRow));
 }
 
 
diff --git a/sc/source/filter/qpro/qproform.cxx b/sc/source/filter/qpro/qproform.cxx
index 89c6c03..024a2a7 100644
--- a/sc/source/filter/qpro/qproform.cxx
+++ b/sc/source/filter/qpro/qproform.cxx
@@ -35,40 +35,34 @@ void QProToSc::ReadSRD( ScSingleRefData& rSRD, sal_Int8 nPage, sal_Int8 nCol, sa
     rSRD.InitAddress( ScAddress( nCol, (~nTmp + 1), 0 ) );
     if( nRelBit & 0x4000 )
     {
-        rSRD.nRelCol = nCol;
-        rSRD.SetColRel( sal_True );
+        rSRD.SetRelCol(nCol);
     }
     else
     {
-        rSRD.nCol = nCol;
-        rSRD.SetColRel( false );
+        rSRD.SetAbsCol(nCol);
     }
+
     if( nRelBit & 0x2000 )
     {
-        rSRD.nRelRow = (~nTmp + 1);
-        rSRD.nRelRow = (sal_Int16)(nTmp << 3);
-        rSRD.nRelRow /= 8;
-        rSRD.SetRowRel( sal_True );
+        SCROW nRelRow = (~nTmp + 1);
+        nRelRow = (sal_Int16)(nTmp << 3); // This looks weird... Mistake?
+        nRelRow /= 8;
+        rSRD.SetRelRow(nRelRow);
     }
     else
     {
-        rSRD.nRow = nTmp;
-        rSRD.SetRowRel( false );
+        rSRD.SetAbsRow(nTmp);
     }
     if( nRelBit & 0x8000 )
     {
-        rSRD.nRelTab = nPage;
-        rSRD.SetTabRel( sal_True );
-        // absolute tab needed in caller for comparison in case of DoubleRef
-        rSRD.nTab = aEingPos.Tab() + nPage;
+        rSRD.SetRelTab(nPage);
     }
     else
     {
-        rSRD.nTab = nPage;
-        rSRD.SetTabRel( false );
+        rSRD.SetAbsTab(nPage);
     }
-    if (rSRD.nTab != aEingPos.Tab())
-        rSRD.SetFlag3D( sal_True);
+    if (rSRD.toAbs(aEingPos).Tab() != aEingPos.Tab())
+        rSRD.SetFlag3D(true);
 }
 
 QProToSc::QProToSc( SvStream& rStream, const ScAddress& rRefPos ) :
commit b6070bba61f7de95cbe56ff2ac61a5912a40ba68
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Jul 23 23:58:11 2013 -0400

    There isn't much we have to do for copy.
    
    Change-Id: I4d297f15e8030fdf068c7e3102f9d03aff401cf9

diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index bd9a39a..57871f6 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -2460,85 +2460,32 @@ bool ScFormulaCell::UpdateReferenceOnCopy(
         // on reference update. Bail out.
         return false;
 
-    bool bCellStateChanged = false;
     boost::scoped_ptr<ScTokenArray> pOldCode;
     if (pUndoDoc)
         pOldCode.reset(pCode->Clone());
 
-    bool bValChanged = false;
-    bool bRangeModified = false;    // any range, not only shared formula
-    bool bRefSizeChanged = false;
-
-    if (bHasRefs)
-    {
-        // Update cell or range references.
-        ScCompiler aComp(pDocument, aPos, *pCode);
-        aComp.SetGrammar(pDocument->GetGrammar());
-        aComp.UpdateReference(
-            URM_COPY, aOldPos, rCxt.maRange, rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta,
-            bValChanged, bRefSizeChanged);
-        bRangeModified = aComp.HasModifiedRange();
-    }
-
-    bCellStateChanged |= bValChanged;
-
     if (bOnRefMove)
         // Cell may reference itself, e.g. ocColumn, ocRow without parameter
-        bOnRefMove = (bValChanged || (aPos != aOldPos));
-
-    bool bColRowNameCompile = false;
-    bool bNewListening = false;
-    bool bInDeleteUndo = false;
-
-    if (bHasRefs)
-    {
-        // Upon Insert ColRowNames have to be recompiled in case the
-        // insertion occurs right in front of the range.
-        if (bHasColRowNames)
-            bColRowNameCompile = checkCompileColRowName(rCxt, *pDocument, *pCode, aOldPos, aPos, bValChanged);
-
-        ScChangeTrack* pChangeTrack = pDocument->GetChangeTrack();
-        bInDeleteUndo = (pChangeTrack && pChangeTrack->IsInDeleteUndo());
+        bOnRefMove = (aPos != aOldPos);
 
-        // Reference changed and new listening needed?
-        // Except in Insert/Delete without specialties.
-        bNewListening =
-            (bRangeModified || bColRowNameCompile || (bValChanged && (bInDeleteUndo || bRefSizeChanged)));
+    bool bNeedDirty = bOnRefMove;
 
-        if ( bNewListening )
-            EndListeningTo(pDocument, pOldCode.get(), aOldPos);
-    }
-
-    bool bNeedDirty = false;
-    // NeedDirty for changes except for Copy and Move/Insert without RelNames
-    if ( bRangeModified || bColRowNameCompile || bOnRefMove)
-        bNeedDirty = true;
-
-    if (pUndoDoc && (bValChanged || bOnRefMove))
+    if (pUndoDoc && bOnRefMove)
         setOldCodeToUndo(pUndoDoc, aUndoPos, pOldCode.get(), eTempGrammar, cMatrixFlag);
 
-    bValChanged = false;
-
-    if ( ( bCompile = (bCompile || bValChanged || bRangeModified || bColRowNameCompile) ) != 0 )
+    if (bCompile)
     {
-        CompileTokenArray( bNewListening ); // no Listening
+        CompileTokenArray(false); // no Listening
         bNeedDirty = true;
     }
 
-    if ( !bInDeleteUndo )
-    {   // In ChangeTrack Delete-Reject listeners are established in
-        // InsertCol/InsertRow
-        if ( bNewListening )
-            StartListeningTo( pDocument );
-    }
-
     if (bNeedDirty)
     {   // Cut off references, invalid or similar?
         sc::AutoCalcSwitch(*pDocument, false);
         SetDirty();
     }
 
-    return bCellStateChanged;
+    return false;
 }
 
 bool ScFormulaCell::UpdateReference(
commit 30baaf425aabbf9d4ae396478cdee4875ca8c555
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Jul 23 22:33:27 2013 -0400

    Re-implement adjusting of references on move.
    
    Change-Id: I52a8b78ed072eb6bcd86b4f80936a869046cbc4d

diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index 5ff7da0..2ae6c90 100644
--- a/sc/inc/tokenarray.hxx
+++ b/sc/inc/tokenarray.hxx
@@ -129,6 +129,9 @@ public:
      */
     sc::RefUpdateResult AdjustReferenceOnShift( const sc::RefUpdateContext& rCxt, const ScAddress& rOldPos );
 
+    sc::RefUpdateResult AdjustReferenceOnMove(
+        const sc::RefUpdateContext& rCxt, const ScAddress& rOldPos, const ScAddress& rNewPos );
+
     /**
      * Adjust all references on sheet deletion.
      *
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 5caecc6..bd9a39a 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -2321,7 +2321,6 @@ bool ScFormulaCell::UpdateReferenceOnMove(
         aOldPos.Set(aPos.Col() - rCxt.mnColDelta, aPos.Row() - rCxt.mnRowDelta, aPos.Tab() - rCxt.mnTabDelta);
     }
 
-
     // Check presence of any references or column row names.
     pCode->Reset();
     bool bHasRefs = (pCode->GetNextReferenceRPN() != NULL);
@@ -2345,22 +2344,19 @@ bool ScFormulaCell::UpdateReferenceOnMove(
         pOldCode.reset(pCode->Clone());
 
     bool bValChanged = false;
-    bool bRangeModified = false;    // any range, not only shared formula
+    bool bRefModified = false;
     bool bRefSizeChanged = false;
 
     if (bHasRefs)
     {
         // Update cell or range references.
-        ScCompiler aComp(pDocument, aPos, *pCode);
-        aComp.SetGrammar(pDocument->GetGrammar());
-        aComp.UpdateReference(
-            URM_MOVE, aOldPos, rCxt.maRange,
-            rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta,
-            bValChanged, bRefSizeChanged);
-        bRangeModified = aComp.HasModifiedRange();
+        sc::RefUpdateResult aRes = pCode->AdjustReferenceOnMove(rCxt, aOldPos, aPos);
+        bRefModified = aRes.mbReferenceModified;
+        bValChanged = aRes.mbValueChanged;
     }
 
-    bCellStateChanged |= bValChanged;
+    if (bValChanged || bRefModified)
+        bCellStateChanged = true;
 
     if (bOnRefMove)
         // Cell may reference itself, e.g. ocColumn, ocRow without parameter
@@ -2385,7 +2381,7 @@ bool ScFormulaCell::UpdateReferenceOnMove(
         bHasRelName = HasRelNameReference();
         // Reference changed and new listening needed?
         // Except in Insert/Delete without specialties.
-        bNewListening = (bRangeModified || bColRowNameCompile
+        bNewListening = (bRefModified || bColRowNameCompile
                 || bValChanged || bHasRelName)
             // #i36299# Don't duplicate action during cut&paste / drag&drop
             // on a cell in the range moved, start/end listeners is done
@@ -2398,7 +2394,7 @@ bool ScFormulaCell::UpdateReferenceOnMove(
 
     bool bNeedDirty = false;
     // NeedDirty for changes except for Copy and Move/Insert without RelNames
-    if ( bRangeModified || bColRowNameCompile ||
+    if ( bRefModified || bColRowNameCompile ||
          (bValChanged && bHasRelName && (bHasRelName || bInDeleteUndo || bRefSizeChanged)) || bOnRefMove)
         bNeedDirty = true;
 
@@ -2407,7 +2403,7 @@ bool ScFormulaCell::UpdateReferenceOnMove(
 
     bValChanged = false;
 
-    if ( ( bCompile = (bCompile || bValChanged || bRangeModified || bColRowNameCompile) ) != 0 )
+    if ( ( bCompile = (bCompile || bValChanged || bRefModified || bColRowNameCompile) ) != 0 )
     {
         CompileTokenArray( bNewListening ); // no Listening
         bNeedDirty = true;
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 0b53a3b..e1c60a5 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2472,6 +2472,58 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnShift( const sc::RefUpdateCon
     return aRes;
 }
 
+sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMove(
+    const sc::RefUpdateContext& rCxt, const ScAddress& rOldPos, const ScAddress& rNewPos )
+{
+    // When moving, the range is the destination range. We need to use the old
+    // range prior to the move for hit analysis.
+    ScRange aOldRange = rCxt.maRange;
+    aOldRange.Move(-rCxt.mnColDelta, -rCxt.mnRowDelta, -rCxt.mnTabDelta);
+
+    sc::RefUpdateResult aRes;
+
+    FormulaToken** p = pCode;
+    FormulaToken** pEnd = p + static_cast<size_t>(nLen);
+    for (; p != pEnd; ++p)
+    {
+        switch ((*p)->GetType())
+        {
+            case svSingleRef:
+            {
+                ScToken* pToken = static_cast<ScToken*>(*p);
+                ScSingleRefData& rRef = pToken->GetSingleRef();
+                ScAddress aAbs = rRef.toAbs(rOldPos);
+                if (aOldRange.In(aAbs))
+                {
+                    aAbs.Move(rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta);
+                    aRes.mbReferenceModified = true;
+                }
+
+                rRef.SetAddress(aAbs, rNewPos);
+            }
+            break;
+            case svDoubleRef:
+            {
+                ScToken* pToken = static_cast<ScToken*>(*p);
+                ScComplexRefData& rRef = pToken->GetDoubleRef();
+                ScRange aAbs = rRef.toAbs(rOldPos);
+                if (aOldRange.In(aAbs))
+                {
+                    aAbs.Move(rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta);
+                    aRes.mbReferenceModified = true;
+                }
+
+                rRef.SetRange(aAbs, rNewPos);
+            }
+            break;
+            default:
+                ;
+        }
+    }
+
+    return aRes;
+}
+
 namespace {
 
 bool adjustSingleRef( ScSingleRefData& rRef, SCTAB nDelPos, SCTAB nSheets, const ScAddress& rOldPos, const ScAddress& rNewPos )
commit 46757f3c281d8f5acad4b08f845f1fa87e59bf57
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Jul 23 16:49:35 2013 -0400

    Broadcast on recalc-ref-on-move cells for the other 3 directions.
    
    Change-Id: I7794bd51c5fedb6c6c75f6910b7743df96d156c3

diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 7613aec..d0b86cd 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1116,6 +1116,36 @@ bool ScDocument::CanInsertRow( const ScRange& rRange ) const
     return bTest;
 }
 
+namespace {
+
+struct StartNeededListenersHandler : std::unary_function<ScTable*, void>
+{
+    void operator() (ScTable* p)
+    {
+        if (p)
+            p->StartNeededListeners();
+    }
+};
+
+struct SetRelNameDirtyHandler : std::unary_function<ScTable*, void>
+{
+    void operator() (ScTable* p)
+    {
+        if (p)
+            p->SetRelNameDirty();
+    }
+};
+
+struct BroadcastRecalcOnRefMoveHandler : std::unary_function<ScTable*, void>
+{
+    void operator() (ScTable* p)
+    {
+        if (p)
+            p->BroadcastRecalcOnRefMove();
+    }
+};
+
+}
 
 bool ScDocument::InsertRow( SCCOL nStartCol, SCTAB nStartTab,
                             SCCOL nEndCol,   SCTAB nEndTab,
@@ -1198,6 +1228,8 @@ bool ScDocument::InsertRow( SCCOL nStartCol, SCTAB nStartTab,
             for (; it != maTabs.end(); ++it)
                 if (*it)
                     (*it)->SetRelNameDirty();
+
+            std::for_each(maTabs.begin(), maTabs.end(), BroadcastRecalcOnRefMoveHandler());
         }
         bRet = true;
     }
@@ -1291,6 +1323,8 @@ void ScDocument::DeleteRow( SCCOL nStartCol, SCTAB nStartTab,
         for (; it != maTabs.end(); ++it)
             if (*it)
                 (*it)->SetRelNameDirty();
+
+        std::for_each(maTabs.begin(), maTabs.end(), BroadcastRecalcOnRefMoveHandler());
     }
 
     SetAutoCalc( bOldAutoCalc );
@@ -1328,37 +1362,6 @@ bool ScDocument::CanInsertCol( const ScRange& rRange ) const
     return bTest;
 }
 
-namespace {
-
-struct StartNeededListenersHandler : std::unary_function<ScTable*, void>
-{
-    void operator() (ScTable* p)
-    {
-        if (p)
-            p->StartNeededListeners();
-    }
-};
-
-struct SetRelNameDirtyHandler : std::unary_function<ScTable*, void>
-{
-    void operator() (ScTable* p)
-    {
-        if (p)
-            p->SetRelNameDirty();
-    }
-};
-
-struct BroadcastRecalcOnRefMoveHandler : std::unary_function<ScTable*, void>
-{
-    void operator() (ScTable* p)
-    {
-        if (p)
-            p->BroadcastRecalcOnRefMove();
-    }
-};
-
-}
-
 bool ScDocument::InsertCol( SCROW nStartRow, SCTAB nStartTab,
                             SCROW nEndRow,   SCTAB nEndTab,
                             SCCOL nStartCol, SCSIZE nSize, ScDocument* pRefUndoDoc,
@@ -1518,6 +1521,8 @@ void ScDocument::DeleteCol(SCROW nStartRow, SCTAB nStartTab, SCROW nEndRow, SCTA
         for (; it != maTabs.end(); ++it)
             if (*it)
                 (*it)->SetRelNameDirty();
+
+        std::for_each(maTabs.begin(), maTabs.end(), BroadcastRecalcOnRefMoveHandler());
     }
 
     SetAutoCalc( bOldAutoCalc );
commit abe4b83723aa39d36ebba62547cb02ee575a07ea
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Jul 23 16:02:37 2013 -0400

    Broadcast on formula cells containing COLUMN functions on column insertion.
    
    To ensure that the change gets propagated properly. This fixes
    testFuncCOLUMN() cppunit test.
    
    Change-Id: Ia1ffc2880b7dae530ceb11c617c3963f7bfaeb00

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 9f3c6f0..ce8d4c9 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -424,6 +424,7 @@ public:
     void        StartAllListeners();
     void        StartNeededListeners(); // only for cells where NeedsListening()==true
     void        SetRelNameDirty();
+    void BroadcastRecalcOnRefMove();
 
     void        CompileDBFormula();
     void        CompileDBFormula( bool bCreateFormulaString );
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 4c0b454..80bc488 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -856,6 +856,24 @@ public:
 
     void SetFormulaResults( SCCOL nCol, SCROW nRow, const double* pResults, size_t nLen );
 
+    /**
+     * Have formula cells with NeedsListening() == true start listening to the
+     * document.
+     */
+    void StartNeededListeners();
+
+    /**
+     * Mark dirty those formula cells that has named ranges with relative
+     * references.
+     */
+    void SetRelNameDirty();
+
+    /**
+     * Broadcast dirty formula cells that contain functions such as CELL(),
+     * COLUMN() or ROW() which may change its value on move.
+     */
+    void BroadcastRecalcOnRefMove();
+
 #if DEBUG_COLUMN_STORAGE
     void DumpFormulaGroups( SCCOL nCol ) const;
 #endif
@@ -962,8 +980,6 @@ private:
     void StartListening( sc::StartListeningContext& rCxt, SCCOL nCol, SCROW nRow, SvtListener& rListener );
     void EndListening( sc::EndListeningContext& rCxt, SCCOL nCol, SCROW nRow, SvtListener& rListener );
     void        StartAllListeners();
-    void        StartNeededListeners(); // only for cells where NeedsListening()==TRUE
-    void        SetRelNameDirty();
 
     void        SetLoadingMedium(bool bLoading);
 
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index fb307cc..4257551 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2144,6 +2144,7 @@ void resetColumnPosition(sc::CellStoreType& rCells, SCCOL nCol)
 
 void ScColumn::SwapCol(ScColumn& rCol)
 {
+    maBroadcasters.swap(rCol.maBroadcasters);
     maCells.swap(rCol.maCells);
     maCellTextAttrs.swap(rCol.maCellTextAttrs);
 
@@ -2163,7 +2164,6 @@ void ScColumn::SwapCol(ScColumn& rCol)
 
     CellStorageModified();
     rCol.CellStorageModified();
-
 }
 
 void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol)
@@ -2996,6 +2996,26 @@ void ScColumn::SetDirtyAfterLoad()
     sc::ProcessFormula(maCells, aFunc);
 }
 
+namespace {
+
+class RecalcOnRefMoveCollector
+{
+    std::vector<SCROW> maDirtyRows;
+public:
+    void operator() (size_t nRow, ScFormulaCell* pCell)
+    {
+        if (pCell->GetDirty() && pCell->GetCode()->IsRecalcModeOnRefMove())
+            maDirtyRows.push_back(nRow);
+    }
+
+    const std::vector<SCROW>& getDirtyRows() const
+    {
+        return maDirtyRows;
+    }
+};
+
+}
+
 void ScColumn::SetRelNameDirty()
 {
     sc::AutoCalcSwitch aSwitch(*pDocument, false);
@@ -3003,6 +3023,14 @@ void ScColumn::SetRelNameDirty()
     sc::ProcessFormula(maCells, aFunc);
 }
 
+void ScColumn::BroadcastRecalcOnRefMove()
+{
+    sc::AutoCalcSwitch aSwitch(*pDocument, false);
+    RecalcOnRefMoveCollector aFunc;
+    sc::ProcessFormula(maCells, aFunc);
+    BroadcastCells(aFunc.getDirtyRows());
+}
+
 void ScColumn::CalcAll()
 {
     CalcAllHandler aFunc;
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index c42b94e..7613aec 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1328,6 +1328,36 @@ bool ScDocument::CanInsertCol( const ScRange& rRange ) const
     return bTest;
 }
 
+namespace {
+
+struct StartNeededListenersHandler : std::unary_function<ScTable*, void>
+{
+    void operator() (ScTable* p)
+    {
+        if (p)
+            p->StartNeededListeners();
+    }
+};
+
+struct SetRelNameDirtyHandler : std::unary_function<ScTable*, void>
+{
+    void operator() (ScTable* p)
+    {
+        if (p)
+            p->SetRelNameDirty();
+    }
+};
+
+struct BroadcastRecalcOnRefMoveHandler : std::unary_function<ScTable*, void>
+{
+    void operator() (ScTable* p)
+    {
+        if (p)
+            p->BroadcastRecalcOnRefMove();
+    }
+};
+
+}
 
 bool ScDocument::InsertCol( SCROW nStartRow, SCTAB nStartTab,
                             SCROW nEndRow,   SCTAB nEndTab,
@@ -1388,17 +1418,15 @@ bool ScDocument::InsertCol( SCROW nStartRow, SCTAB nStartTab,
             StartAllListeners();
         }
         else
-        {// Listeners have been removed in UpdateReference
-            TableContainer::iterator it = maTabs.begin();
-            for (; it != maTabs.end(); ++it)
-                if (*it)
-                    (*it)->StartNeededListeners();
-            // at least all cells using range names pointing relative
-            // to the moved range must recalculate
-            it = maTabs.begin();
-            for (; it != maTabs.end(); ++it)
-                if (*it)
-                    (*it)->SetRelNameDirty();
+        {
+            // Listeners have been removed in UpdateReference
+            std::for_each(maTabs.begin(), maTabs.end(), StartNeededListenersHandler());
+            // at least all cells using range names pointing relative to the
+            // moved range must recalculate.
+            std::for_each(maTabs.begin(), maTabs.end(), SetRelNameDirtyHandler());
+            // Cells containing functions such as CELL, COLUMN or ROW may have
+            // changed their values on relocation. Broadcast them.
+            std::for_each(maTabs.begin(), maTabs.end(), BroadcastRecalcOnRefMoveHandler());
         }
         bRet = true;
     }
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 97a06c7..87a2da1 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -48,6 +48,7 @@
 #include "editutil.hxx"
 #include "mtvcellfunc.hxx"
 #include "refupdatecontext.hxx"
+#include "scopetools.hxx"
 
 #include "scitems.hxx"
 #include <editeng/boxitem.hxx>
@@ -1703,6 +1704,12 @@ void ScTable::SetRelNameDirty()
     pDocument->SetAutoCalc( bOldAutoCalc );
 }
 
+void ScTable::BroadcastRecalcOnRefMove()
+{
+    sc::AutoCalcSwitch aSwitch(*pDocument, false);
+    for (SCCOL i = 0; i <= MAXCOL; ++i)
+        aCol[i].BroadcastRecalcOnRefMove();
+}
 
 void ScTable::SetLoadingMedium(bool bLoading)
 {
commit 8b7b6074f49a3cf0706018c21b9cc40bdddcc641
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Jul 23 11:16:46 2013 -0400

    Make these non-inline.
    
    Conflicts:
    	sc/inc/refdata.hxx
    
    Change-Id: I99cf45edfe584f69fb6465de84cdcff5842e37a6

diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx
index 844c4e1..b704d57 100644
--- a/sc/inc/refdata.hxx
+++ b/sc/inc/refdata.hxx
@@ -78,9 +78,9 @@ struct SC_DLLPUBLIC ScSingleRefData
     inline  void SetRelName( bool bVal )    { Flags.bRelName = (bVal ? true : false ); }
     inline  bool IsRelName() const          { return Flags.bRelName; }
 
-    inline  bool Valid() const;
+    bool Valid() const;
     /// In external references nTab is -1
-    inline  bool ValidExternal() const;
+    bool ValidExternal() const;
 
     ScAddress toAbs( const ScAddress& rPos ) const;
     void SetAddress( const ScAddress& rAddr, const ScAddress& rPos );
@@ -96,22 +96,8 @@ struct SC_DLLPUBLIC ScSingleRefData
 #endif
 };
 
-inline bool ScSingleRefData::Valid() const
-{
-    return  nCol >= 0 && nCol <= MAXCOL &&
-            nRow >= 0 && nRow <= MAXROW &&
-            nTab >= 0 && nTab <= MAXTAB;
-}
-
-inline bool ScSingleRefData::ValidExternal() const
-{
-    return  nCol >= 0 && nCol <= MAXCOL &&
-            nRow >= 0 && nRow <= MAXROW &&
-            nTab == -1;
-}
-
-
-struct ScComplexRefData         // Complex reference (a range) into the sheet
+/// Complex reference (a range) into the sheet
+struct ScComplexRefData
 {
     ScSingleRefData Ref1;
     ScSingleRefData Ref2;
@@ -134,13 +120,13 @@ struct ScComplexRefData         // Complex reference (a range) into the sheet
             Ref1.InitAddress( nCol1, nRow1, nTab1 );
             Ref2.InitAddress( nCol2, nRow2, nTab2 );
         }
-    inline bool IsDeleted() const
-        { return Ref1.IsDeleted() || Ref2.IsDeleted(); }
-    inline bool Valid() const
-        { return Ref1.Valid() && Ref2.Valid(); }
+
+    bool IsDeleted() const;
+    bool Valid() const;
+
     /** In external references nTab is -1 for the start tab and -1 for the end
         tab if one sheet, or >=0 if more than one sheets. */
-    inline  bool ValidExternal() const;
+    bool ValidExternal() const;
 
     SC_DLLPUBLIC ScRange toAbs( const ScAddress& rPos ) const;
     void SetRange( const ScRange& rRange, const ScAddress& rPos );
@@ -160,14 +146,6 @@ struct ScComplexRefData         // Complex reference (a range) into the sheet
 #endif
 };
 
-inline bool ScComplexRefData::ValidExternal() const
-{
-    return Ref1.ValidExternal() &&
-        Ref2.nCol >= 0 && Ref2.nCol <= MAXCOL &&
-        Ref2.nRow >= 0 && Ref2.nRow <= MAXROW &&
-        Ref2.nTab >= Ref1.nTab;
-}
-
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/tool/refdata.cxx b/sc/source/core/tool/refdata.cxx
index 3d49fa8..a804838 100644
--- a/sc/source/core/tool/refdata.cxx
+++ b/sc/source/core/tool/refdata.cxx
@@ -75,6 +75,20 @@ bool ScSingleRefData::IsDeleted() const
     return IsColDeleted() || IsRowDeleted() || IsTabDeleted();
 }
 
+bool ScSingleRefData::Valid() const
+{
+    return  nCol >= 0 && nCol <= MAXCOL &&
+            nRow >= 0 && nRow <= MAXROW &&
+            nTab >= 0 && nTab <= MAXTAB;
+}
+
+bool ScSingleRefData::ValidExternal() const
+{
+    return  nCol >= 0 && nCol <= MAXCOL &&
+            nRow >= 0 && nRow <= MAXROW &&
+            nTab == -1;
+}
+
 ScAddress ScSingleRefData::toAbs( const ScAddress& rPos ) const
 {
     SCCOL nRetCol = Flags.bColRel ? nRelCol + rPos.Col() : nCol;
@@ -292,6 +306,24 @@ ScComplexRefData& ScComplexRefData::Extend( const ScComplexRefData & rRef, const
     return Extend( rRef.Ref1, rPos).Extend( rRef.Ref2, rPos);
 }
 
+bool ScComplexRefData::IsDeleted() const
+{
+    return Ref1.IsDeleted() || Ref2.IsDeleted();
+}
+
+bool ScComplexRefData::Valid() const
+{
+    return Ref1.Valid() && Ref2.Valid();
+}
+
+bool ScComplexRefData::ValidExternal() const
+{
+    return Ref1.ValidExternal() &&
+        Ref2.nCol >= 0 && Ref2.nCol <= MAXCOL &&
+        Ref2.nRow >= 0 && Ref2.nRow <= MAXROW &&
+        Ref2.nTab >= Ref1.nTab;
+}
+
 ScRange ScComplexRefData::toAbs( const ScAddress& rPos ) const
 {
     return ScRange(Ref1.toAbs(rPos), Ref2.toAbs(rPos));
commit dfff270b3bd21785c567bc821c84761037d669a0
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Jul 23 10:43:38 2013 -0400

    CalcRelFromAbs() is no more.
    
    Change-Id: I974d8282eaf49a6c6d56fe209012f5e54170acc2

diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx
index 5928532..844c4e1 100644
--- a/sc/inc/refdata.hxx
+++ b/sc/inc/refdata.hxx
@@ -88,7 +88,6 @@ struct SC_DLLPUBLIC ScSingleRefData
     SCCOL GetCol() const;
     SCTAB GetTab() const;
 
-            void CalcRelFromAbs( const ScAddress& rPos );
             bool operator==( const ScSingleRefData& ) const;
             bool operator!=( const ScSingleRefData& ) const;
 
@@ -135,8 +134,6 @@ struct ScComplexRefData         // Complex reference (a range) into the sheet
             Ref1.InitAddress( nCol1, nRow1, nTab1 );
             Ref2.InitAddress( nCol2, nRow2, nTab2 );
         }
-    inline void CalcRelFromAbs( const ScAddress& rPos )
-        { Ref1.CalcRelFromAbs( rPos ); Ref2.CalcRelFromAbs( rPos ); }
     inline bool IsDeleted() const
         { return Ref1.IsDeleted() || Ref2.IsDeleted(); }
     inline bool Valid() const
diff --git a/sc/source/core/tool/refdata.cxx b/sc/source/core/tool/refdata.cxx
index 439886e..3d49fa8 100644
--- a/sc/source/core/tool/refdata.cxx
+++ b/sc/source/core/tool/refdata.cxx
@@ -75,13 +75,6 @@ bool ScSingleRefData::IsDeleted() const
     return IsColDeleted() || IsRowDeleted() || IsTabDeleted();
 }
 
-void ScSingleRefData::CalcRelFromAbs( const ScAddress& rPos )
-{
-    nRelCol = nCol - rPos.Col();
-    nRelRow = nRow - rPos.Row();
-    nRelTab = nTab - rPos.Tab();
-}
-
 ScAddress ScSingleRefData::toAbs( const ScAddress& rPos ) const
 {
     SCCOL nRetCol = Flags.bColRel ? nRelCol + rPos.Col() : nCol;
diff --git a/sc/source/core/tool/refupdat.cxx b/sc/source/core/tool/refupdat.cxx
index 8ad478b..ca993bd 100644
--- a/sc/source/core/tool/refupdat.cxx
+++ b/sc/source/core/tool/refupdat.cxx
@@ -830,39 +830,47 @@ ScRefUpdateRes ScRefUpdate::Move(
 void ScRefUpdate::MoveRelWrap( ScDocument* pDoc, const ScAddress& rPos,
                                SCCOL nMaxCol, SCROW nMaxRow, ScComplexRefData& rRef )
 {
+    ScRange aAbsRange = rRef.toAbs(rPos);
     if( rRef.Ref1.IsColRel() )
     {
-        rRef.Ref1.nCol = rRef.Ref1.nRelCol + rPos.Col();
-        lcl_MoveItWrap( rRef.Ref1.nCol, static_cast<SCsCOL>(0), nMaxCol );
+        SCCOL nCol = aAbsRange.aStart.Col();
+        lcl_MoveItWrap(nCol, static_cast<SCsCOL>(0), nMaxCol);
+        aAbsRange.aStart.SetCol(nCol);
     }
     if( rRef.Ref2.IsColRel() )
     {
-        rRef.Ref2.nCol = rRef.Ref2.nRelCol + rPos.Col();
-        lcl_MoveItWrap( rRef.Ref2.nCol, static_cast<SCsCOL>(0), nMaxCol );
+        SCCOL nCol = aAbsRange.aEnd.Col();
+        lcl_MoveItWrap(nCol, static_cast<SCsCOL>(0), nMaxCol);
+        aAbsRange.aEnd.SetCol(nCol);
     }
     if( rRef.Ref1.IsRowRel() )
     {
-        rRef.Ref1.nRow = rRef.Ref1.nRelRow + rPos.Row();
-        lcl_MoveItWrap( rRef.Ref1.nRow, static_cast<SCsROW>(0), nMaxRow );
+        SCROW nRow = aAbsRange.aStart.Row();
+        lcl_MoveItWrap(nRow, static_cast<SCsROW>(0), nMaxRow);
+        aAbsRange.aStart.SetRow(nRow);
     }
     if( rRef.Ref2.IsRowRel() )
     {
-        rRef.Ref2.nRow = rRef.Ref2.nRelRow + rPos.Row();
-        lcl_MoveItWrap( rRef.Ref2.nRow, static_cast<SCsROW>(0), nMaxRow );
+        SCROW nRow = aAbsRange.aEnd.Row();
+        lcl_MoveItWrap(nRow, static_cast<SCsROW>(0), nMaxRow);
+        aAbsRange.aEnd.SetRow(nRow);
     }
     SCsTAB nMaxTab = (SCsTAB) pDoc->GetTableCount() - 1;
     if( rRef.Ref1.IsTabRel() )
     {
-        rRef.Ref1.nTab = rRef.Ref1.nRelTab + rPos.Tab();
-        lcl_MoveItWrap( rRef.Ref1.nTab, static_cast<SCsTAB>(0), static_cast<SCTAB>(nMaxTab) );
+        SCTAB nTab = aAbsRange.aStart.Tab();
+        lcl_MoveItWrap(nTab, static_cast<SCsTAB>(0), static_cast<SCTAB>(nMaxTab));
+        aAbsRange.aStart.SetTab(nTab);
     }
     if( rRef.Ref2.IsTabRel() )
     {
-        rRef.Ref2.nTab = rRef.Ref2.nRelTab + rPos.Tab();
-        lcl_MoveItWrap( rRef.Ref2.nTab, static_cast<SCsTAB>(0), static_cast<SCTAB>(nMaxTab) );
+        SCTAB nTab = aAbsRange.aEnd.Tab();
+        lcl_MoveItWrap(nTab, static_cast<SCsTAB>(0), static_cast<SCTAB>(nMaxTab));
+        aAbsRange.aEnd.SetTab(nTab);
     }
-    rRef.PutInOrder();
-    rRef.CalcRelFromAbs( rPos );
+
+    aAbsRange.PutInOrder();
+    rRef.SetRange(aAbsRange, rPos);
 }
 
 //------------------------------------------------------------------
commit f071d7c453301d922b755ffb576289aea6e90074
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Jul 23 09:50:10 2013 -0400

    More on removing use of CalcRelFromAbs().
    
    Some of them were called for all absolute references, which is not
    necessary.
    
    Change-Id: If19ee74731f40ca208e1cc1804c6b6e53073d891

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 3c67372..27f8cc2 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1042,7 +1042,6 @@ void ScColumn::CopyFromClip(
             aRef.nRow = nDestRow - nDy; // Source row
             aDestPos.SetRow( nDestRow );
 
-            aRef.CalcRelFromAbs( aDestPos );
             ScTokenArray aArr;
             aArr.AddSingleReference( aRef );
             SetFormulaCell(nDestRow, new ScFormulaCell(pDocument, aDestPos, &aArr));
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 3e0cb4f..97a06c7 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -973,7 +973,6 @@ void ScTable::TransposeClip( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
                 aRef.nTab = nTab;
                 aRef.InitFlags();                           // -> all absolute
                 aRef.SetFlag3D(true);
-                aRef.CalcRelFromAbs( aDestPos );
                 ScTokenArray aArr;
                 aArr.AddSingleReference( aRef );
 
diff --git a/sc/source/core/tool/consoli.cxx b/sc/source/core/tool/consoli.cxx
index 286261e..fdcc5f8 100644
--- a/sc/source/core/tool/consoli.cxx
+++ b/sc/source/core/tool/consoli.cxx
@@ -708,8 +708,8 @@ void ScConsData::OutputToDocument( ScDocument* pDestDoc, SCCOL nCol, SCROW nRow,
         String aString;
 
         ScSingleRefData aSRef;      // Daten fuer Referenz-Formelzellen
-        aSRef.InitFlags();
-        aSRef.SetFlag3D(sal_True);
+        aSRef.InitFlags(); // This reference is absolute at all times.
+        aSRef.SetFlag3D(true);
 
         ScComplexRefData aCRef;         // Daten fuer Summen-Zellen
         aCRef.InitFlags();
@@ -741,9 +741,7 @@ void ScConsData::OutputToDocument( ScDocument* pDestDoc, SCCOL nCol, SCROW nRow,
                                 {
                                     //  Referenz einfuegen (absolut, 3d)
 
-                                    aSRef.nCol = aRef.nCol;
-                                    aSRef.nRow = aRef.nRow;
-                                    aSRef.nTab = aRef.nTab;
+                                    aSRef.SetAddress(ScAddress(aRef.nCol,aRef.nRow,aRef.nTab), ScAddress());
 
                                     ScTokenArray aRefArr;
                                     aRefArr.AddSingleReference(aSRef);
@@ -760,11 +758,9 @@ void ScConsData::OutputToDocument( ScDocument* pDestDoc, SCCOL nCol, SCROW nRow,
                             ScAddress aDest( sal::static_int_cast<SCCOL>(nCol+nArrX),
                                              sal::static_int_cast<SCROW>(nRow+nArrY+nNeeded), nTab );
 
-                            aCRef.Ref1.nTab = aCRef.Ref2.nTab = nTab;
-                            aCRef.Ref1.nCol = aCRef.Ref2.nCol = sal::static_int_cast<SCsCOL>( nCol+nArrX );
-                            aCRef.Ref1.nRow = nRow+nArrY;
-                            aCRef.Ref2.nRow = nRow+nArrY+nNeeded-1;
-                            aCRef.CalcRelFromAbs( aDest );
+                            ScRange aRange(sal::static_int_cast<SCCOL>(nCol+nArrX), nRow+nArrY, nTab);
+                            aRange.aEnd.SetRow(nRow+nArrY+nNeeded-1);
+                            aCRef.SetRange(aRange, aDest);
 
                             ScTokenArray aArr;
                             aArr.AddOpCode(eOpCode);            // ausgewaehlte Funktion
commit ba6e02a18743aaaa96ab9ccacd3eccc7530099ae
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Jul 23 00:23:06 2013 -0400

    More on removing CalcRelFromAbs().
    
    Conflicts:
    	sc/inc/refdata.hxx
    
    Change-Id: I6474926d9cd8f9273bae3d8179bd14ee19422357

diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx
index 43c54eb..5928532 100644
--- a/sc/inc/refdata.hxx
+++ b/sc/inc/refdata.hxx
@@ -54,10 +54,10 @@ struct SC_DLLPUBLIC ScSingleRefData
     /// No default ctor, because used in ScRawToken union, set InitFlags!
     inline  void InitFlags() { mnFlagValue = 0; }    ///< all FALSE
     /// InitAddress: InitFlags and set address
-    inline  void InitAddress( const ScAddress& rAdr );
-    inline  void InitAddress( SCCOL nCol, SCROW nRow, SCTAB nTab );
-    // InitAddressRel: InitFlags and set address, everything relative to rPos
-    inline  void InitAddressRel( const ScAddress& rAdr, const ScAddress& rPos );
+    void InitAddress( const ScAddress& rAdr );
+    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 );
     inline  void SetColRel( bool bVal ) { Flags.bColRel = (bVal ? true : false ); }
     inline  bool IsColRel() const{ return Flags.bColRel; }
     inline  void SetRowRel( bool bVal ) { Flags.bRowRel = (bVal ? true : false ); }
@@ -97,29 +97,6 @@ struct SC_DLLPUBLIC ScSingleRefData
 #endif
 };
 
-inline void ScSingleRefData::InitAddress( SCCOL nColP, SCROW nRowP, SCTAB nTabP )
-{
-    InitFlags();
-    nCol = nColP;
-    nRow = nRowP;
-    nTab = nTabP;
-}
-
-inline void ScSingleRefData::InitAddress( const ScAddress& rAdr )
-{
-    InitAddress( rAdr.Col(), rAdr.Row(), rAdr.Tab());
-}
-
-inline void ScSingleRefData::InitAddressRel( const ScAddress& rAdr,
-                                            const ScAddress& rPos )
-{
-    InitAddress( rAdr.Col(), rAdr.Row(), rAdr.Tab());
-    SetColRel( true );
-    SetRowRel( true );
-    SetTabRel( true );
-    CalcRelFromAbs( rPos );
-}
-
 inline bool ScSingleRefData::Valid() const
 {
     return  nCol >= 0 && nCol <= MAXCOL &&
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 3d4daf7..abcb92d 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -5285,7 +5285,7 @@ bool ScCompiler::HandleSingleRef()
                     aRefData.SetColRel( true );
                 else
                     aRefData.SetRowRel( true );
-                aRefData.CalcRelFromAbs( aPos );
+                aRefData.SetAddress(aRange.aStart, aPos);
                 pNew->AddSingleReference( aRefData );
             }
             else
@@ -5302,7 +5302,7 @@ bool ScCompiler::HandleSingleRef()
                     aRefData.Ref1.SetRowRel( true );
                     aRefData.Ref2.SetRowRel( true );
                 }
-                aRefData.CalcRelFromAbs( aPos );
+                aRefData.SetRange(aRange, aPos);
                 if ( bInList )
                     pNew->AddDoubleReference( aRefData );
                 else
@@ -5329,13 +5329,10 @@ bool ScCompiler::HandleDbData()
     {
         ScComplexRefData aRefData;
         aRefData.InitFlags();
-        pDBData->GetArea(   (SCTAB&) aRefData.Ref1.nTab,
-                            (SCCOL&) aRefData.Ref1.nCol,
-                            (SCROW&) aRefData.Ref1.nRow,
-                            (SCCOL&) aRefData.Ref2.nCol,
-                            (SCROW&) aRefData.Ref2.nRow);
-        aRefData.Ref2.nTab    = aRefData.Ref1.nTab;
-        aRefData.CalcRelFromAbs( aPos );
+        ScRange aRange;
+        pDBData->GetArea(aRange);
+        aRange.aEnd.SetTab(aRange.aStart.Tab());
+        aRefData.SetRange(aRange, aPos);
         ScTokenArray* pNew = new ScTokenArray();
         pNew->AddDoubleReference( aRefData );
         PushTokenArray( pNew, true );
diff --git a/sc/source/core/tool/refdata.cxx b/sc/source/core/tool/refdata.cxx
index 3a7e2b0..439886e 100644
--- a/sc/source/core/tool/refdata.cxx
+++ b/sc/source/core/tool/refdata.cxx
@@ -19,6 +19,27 @@
 
 #include "refdata.hxx"
 
+void ScSingleRefData::InitAddress( const ScAddress& rAdr )
+{
+    InitAddress( rAdr.Col(), rAdr.Row(), rAdr.Tab());
+}
+
+void ScSingleRefData::InitAddress( SCCOL nColP, SCROW nRowP, SCTAB nTabP )
+{
+    InitFlags();
+    nCol = nColP;
+    nRow = nRowP;
+    nTab = nTabP;
+}
+
+void ScSingleRefData::InitAddressRel( const ScAddress& rAdr, const ScAddress& rPos )
+{
+    SetColRel(true);
+    SetRowRel(true);
+    SetTabRel(true);
+    SetAddress(rAdr, rPos);
+}
+
 void ScSingleRefData::SetColDeleted( bool bVal )
 {
     Flags.bColDeleted = (bVal ? true : false );
diff --git a/sc/source/filter/excel/excform8.cxx b/sc/source/filter/excel/excform8.cxx
index 4cd9dce..024edea 100644
--- a/sc/source/filter/excel/excform8.cxx
+++ b/sc/source/filter/excel/excform8.cxx
@@ -319,31 +319,33 @@ ConvErr ExcelToSc8::Convert( const ScTokenArray*& rpTokArray, XclImpStream& aIn,
                     case 0x03:              //  Col         4       -       ref
                     case 0x06:              //  RwV         4       -       val
                     case 0x07:              //  ColV        4       -       val
+                    {
                         aIn >> nRow >> nCol;
-
-                        aSRD.InitAddress( ScAddress( static_cast<SCCOL>(nCol & 0xFF), static_cast<SCROW>(nRow), aEingPos.Tab() ) );
+                        ScAddress aAddr(static_cast<SCCOL>(nCol & 0xFF), static_cast<SCROW>(nRow), aEingPos.Tab());
+                        aSRD.InitAddress(aAddr);
 
                         if( nEptg == 0x02 || nEptg == 0x06 )
-                            aSRD.SetRowRel( sal_True );
+                            aSRD.SetRowRel(true);
                         else
-                            aSRD.SetColRel( sal_True );
+                            aSRD.SetColRel(true);
 
-                        aSRD.CalcRelFromAbs( aEingPos );
+                        aSRD.SetAddress(aAddr, aEingPos);
 
                         aStack << aPool.StoreNlf( aSRD );
-                        break;
+                    }
+                    break;
                     case 0x0A:              //  Radical     13      -       ref
+                    {
                         aIn >> nRow >> nCol;
                         aIn.Ignore( 9 );
-
-                        aSRD.InitAddress( ScAddress( static_cast<SCCOL>(nCol & 0xFF), static_cast<SCROW>(nRow), aEingPos.Tab() ) );
-
-                        aSRD.SetColRel( sal_True );
-
-                        aSRD.CalcRelFromAbs( aEingPos );
+                        ScAddress aAddr(static_cast<SCCOL>(nCol & 0xFF), static_cast<SCROW>(nRow), aEingPos.Tab());
+                        aSRD.InitAddress(aAddr);
+                        aSRD.SetColRel(true);
+                        aSRD.SetAddress(aAddr, aEingPos);
 
                         aStack << aPool.StoreNlf( aSRD );
-                        break;
+                    }
+                    break;
                     case 0x0B:              //  RadicalS    13      x       ref
                         aIn.Ignore( 13 );
                         aExtensions.push_back( EXTENSION_NLR );
diff --git a/sc/source/filter/lotus/lotform.cxx b/sc/source/filter/lotus/lotform.cxx
index 0278c75..33e8456 100644
--- a/sc/source/filter/lotus/lotform.cxx
+++ b/sc/source/filter/lotus/lotform.cxx
@@ -295,20 +295,14 @@ void LotusToSc::ReadSRD( ScSingleRefData& rSRD, sal_uInt8 nRelBit )
     Read( nTab );
     Read( nCol );
 
-    sal_Bool b3D = ( static_cast< SCTAB >( nTab ) != aEingPos.Tab() );
+    bool b3D = (static_cast<SCTAB>(nTab) != aEingPos.Tab());
 
     rSRD.SetColRel( ( nRelBit & 0x01 ) != 0 );
-    rSRD.nCol = static_cast< SCsCOL >( nCol );
-
     rSRD.SetRowRel( ( nRelBit & 0x02 ) != 0 );
-    rSRD.nRow = static_cast< SCsROW >( nRow );
-
     rSRD.SetTabRel( ( ( nRelBit & 0x04) != 0 ) || !b3D );
-    rSRD.nTab = static_cast< SCsTAB >( nTab );
-
     rSRD.SetFlag3D( b3D );
 
-    rSRD.CalcRelFromAbs( aEingPos );
+    rSRD.SetAddress(ScAddress(nCol, nRow, nTab), aEingPos);
 }
 
 
commit 6d2acc5500a682789817abb4756d374a7bdafefd
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Jul 22 23:46:51 2013 -0400

    Work on removing CalcRelFromAbs().
    
    Change-Id: Ieb8b19821d778fa4596e680e73ba583667b5231a

diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index f1a206f..3d4daf7 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -2698,7 +2698,7 @@ bool ScCompiler::IsDoubleReference( const String& rName )
         if ( !(nFlags & SCA_VALID_TAB2) )
             aRef.Ref2.SetTabDeleted( true );        // #REF!
         aRef.Ref2.SetFlag3D( ( nFlags & SCA_TAB2_3D ) != 0 );
-        aRef.CalcRelFromAbs( aPos );
+        aRef.SetRange(aRange, aPos);
         if (aExtInfo.mbExternal)
         {
             ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager();
@@ -2746,7 +2746,7 @@ bool ScCompiler::IsSingleReference( const String& rName )
                 aRef.nTab = MAXTAB+3;
             nFlags |= SCA_VALID;
         }
-        aRef.CalcRelFromAbs( aPos );
+        aRef.SetAddress(aAddr, aPos);
 
         if (aExtInfo.mbExternal)
         {
@@ -3041,14 +3041,11 @@ bool ScCompiler::IsColRowName( const String& rName )
                         if ( ScGlobal::GetpTransliteration()->isEqual( aStr, aName ) )
                         {
                             aRef.InitFlags();
-                            aRef.nCol = aIter.GetPos().Col();
-                            aRef.nRow = aIter.GetPos().Row();
-                            aRef.nTab = aIter.GetPos().Tab();
                             if ( !jRow )
                                 aRef.SetColRel( true );     // ColName
                             else
                                 aRef.SetRowRel( true );     // RowName
-                            aRef.CalcRelFromAbs( aPos );
+                            aRef.SetAddress(aIter.GetPos(), aPos);
                             bInList = bFound = true;
                         }
                     }
@@ -3226,14 +3223,14 @@ bool ScCompiler::IsColRowName( const String& rName )
             else
                 aAdr = aOne;
             aRef.InitAddress( aAdr );
-            if ( (aRef.nRow != MAXROW && pDoc->HasStringData(
-                    aRef.nCol, aRef.nRow + 1, aRef.nTab ))
-              || (aRef.nRow != 0 && pDoc->HasStringData(
-                    aRef.nCol, aRef.nRow - 1, aRef.nTab )) )
+            if ( (aAdr.Row() != MAXROW && pDoc->HasStringData(
+                    aAdr.Col(), aAdr.Row() + 1, aAdr.Tab()))
+              || (aAdr.Row() != 0 && pDoc->HasStringData(
+                    aAdr.Col(), aAdr.Row() - 1, aAdr.Tab())))
                 aRef.SetRowRel( true );     // RowName
             else
                 aRef.SetColRel( true );     // ColName
-            aRef.CalcRelFromAbs( aPos );
+            aRef.SetAddress(aAdr, aPos);
         }
     }
     if ( bFound )
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 45ae6dd..861e015 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -3587,13 +3587,10 @@ void ScInterpreter::ScDBArea()
     {
         ScComplexRefData aRefData;
         aRefData.InitFlags();
-        pDBData->GetArea( (SCTAB&) aRefData.Ref1.nTab,
-                          (SCCOL&) aRefData.Ref1.nCol,
-                          (SCROW&) aRefData.Ref1.nRow,
-                          (SCCOL&) aRefData.Ref2.nCol,
-                          (SCROW&) aRefData.Ref2.nRow);
-        aRefData.Ref2.nTab    = aRefData.Ref1.nTab;
-        aRefData.CalcRelFromAbs( aPos );
+        ScRange aRange;
+        pDBData->GetArea(aRange);
+        aRange.aEnd.SetTab(aRange.aStart.Tab());
+        aRefData.SetRange(aRange, aPos);
         PushTempToken( new ScDoubleRefToken( aRefData ) );
     }
     else
commit a521b578ccb3757bf5cb725bc5c57dcaa23e8d22
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Jul 22 23:25:47 2013 -0400

    Remove CalcAbsIfRel() since nobody uses this anymore.
    
    Change-Id: Ie52e83b9e476b822e878488e231d60d0ce196cf4

diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx
index 35a6c33..43c54eb 100644
--- a/sc/inc/refdata.hxx
+++ b/sc/inc/refdata.hxx
@@ -89,7 +89,6 @@ struct SC_DLLPUBLIC ScSingleRefData
     SCTAB GetTab() const;
 
             void CalcRelFromAbs( const ScAddress& rPos );
-            void CalcAbsIfRel( const ScAddress& rPos );
             bool operator==( const ScSingleRefData& ) const;
             bool operator!=( const ScSingleRefData& ) const;
 
@@ -161,8 +160,6 @@ struct ScComplexRefData         // Complex reference (a range) into the sheet
         }
     inline void CalcRelFromAbs( const ScAddress& rPos )
         { Ref1.CalcRelFromAbs( rPos ); Ref2.CalcRelFromAbs( rPos ); }
-    inline void CalcAbsIfRel( const ScAddress& rPos )
-        { Ref1.CalcAbsIfRel( rPos ); Ref2.CalcAbsIfRel( rPos ); }
     inline bool IsDeleted() const
         { return Ref1.IsDeleted() || Ref2.IsDeleted(); }
     inline bool Valid() const
diff --git a/sc/source/core/tool/refdata.cxx b/sc/source/core/tool/refdata.cxx
index 2cb9105..3a7e2b0 100644
--- a/sc/source/core/tool/refdata.cxx
+++ b/sc/source/core/tool/refdata.cxx
@@ -120,30 +120,6 @@ SCTAB ScSingleRefData::GetTab() const
     return Flags.bTabRel ? nRelTab : nTab;
 }
 
-void ScSingleRefData::CalcAbsIfRel( const ScAddress& rPos )
-{
-    if ( Flags.bColRel )
-    {
-        nCol = nRelCol + rPos.Col();
-        if ( !ValidCol( nCol ) )
-            Flags.bColDeleted = sal_True;
-    }
-    if ( Flags.bRowRel )
-    {
-        nRow = nRelRow + rPos.Row();
-        if ( !ValidRow( nRow ) )
-            Flags.bRowDeleted = sal_True;
-    }
-    if ( Flags.bTabRel )
-    {
-        nTab = nRelTab + rPos.Tab();
-        if ( !ValidTab( nTab ) )
-            Flags.bTabDeleted = sal_True;
-    }
-}
-
-
-
 bool ScSingleRefData::operator==( const ScSingleRefData& r ) const
 {
     return mnFlagValue == r.mnFlagValue &&
commit 081df9a9b6146ed65bb5150b3715426247b3a115
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Jul 22 23:15:21 2013 -0400

    Remove CalcAbsIfRel() from ScComplexRefData::Extend().
    
    Change-Id: I917acbd2d2567542c6388e796fd49fe4bb48f5ae

diff --git a/sc/source/core/tool/refdata.cxx b/sc/source/core/tool/refdata.cxx
index 239fd6b..2cb9105 100644
--- a/sc/source/core/tool/refdata.cxx
+++ b/sc/source/core/tool/refdata.cxx
@@ -268,70 +268,31 @@ void ScComplexRefData::PutInOrder()
     lcl_putInOrder( Ref1, Ref2);
 }
 
-
-static void lcl_adjustInOrder( ScSingleRefData & rRef1, ScSingleRefData & rRef2, bool bFirstLeader )
+ScComplexRefData& ScComplexRefData::Extend( const ScSingleRefData & rRef, const ScAddress & rPos )
 {
-    // a1:a2:a3, bFirstLeader: rRef1==a1==r1, rRef2==a3==r2
-    //                   else: rRef1==a3==r2, rRef2==a2==r1
-    ScSingleRefData& r1 = (bFirstLeader ? rRef1 : rRef2);
-    ScSingleRefData& r2 = (bFirstLeader ? rRef2 : rRef1);
-    if (r1.Flags.bFlag3D && !r2.Flags.bFlag3D)
-    {
-        // [$]Sheet1.A5:A6 on Sheet2 do still refer only Sheet1.
-        r2.nTab = r1.nTab;
-        r2.nRelTab = r1.nRelTab;
-        r2.Flags.bTabRel = r1.Flags.bTabRel;
-    }
-    lcl_putInOrder( rRef1, rRef2);
-}
+    ScRange aAbsRange = toAbs(rPos);
+    ScAddress aAbs = rRef.toAbs(rPos);
 
+    if (aAbs.Col() < aAbsRange.aStart.Col())
+        aAbsRange.aStart.SetCol(aAbs.Col());
+
+    if (aAbs.Row() < aAbsRange.aStart.Row())
+        aAbsRange.aStart.SetRow(aAbs.Row());
+
+    if (aAbs.Tab() < aAbsRange.aStart.Tab())
+        aAbsRange.aStart.SetTab(aAbs.Tab());
+
+    if (aAbsRange.aEnd.Col() < aAbs.Col())
+        aAbsRange.aEnd.SetCol(aAbs.Col());
+
+    if (aAbsRange.aEnd.Row() < aAbs.Row())
+        aAbsRange.aEnd.SetRow(aAbs.Row());
+
+    if (aAbsRange.aEnd.Tab() < aAbs.Tab())
+        aAbsRange.aEnd.SetTab(aAbs.Tab());
+
+    SetRange(aAbsRange, rPos);
 
-ScComplexRefData& ScComplexRefData::Extend( const ScSingleRefData & rRef, const ScAddress & rPos )
-{
-    CalcAbsIfRel( rPos);
-    ScSingleRefData aRef = rRef;
-    aRef.CalcAbsIfRel( rPos);
-    bool bInherit3D = Ref1.IsFlag3D() && !Ref2.IsFlag3D();
-    bool bInherit3Dtemp = bInherit3D && !rRef.IsFlag3D();
-    if (aRef.nCol < Ref1.nCol || aRef.nRow < Ref1.nRow || aRef.nTab < Ref1.nTab)
-    {
-        lcl_adjustInOrder( Ref1, aRef, true);
-        aRef = rRef;
-        aRef.CalcAbsIfRel( rPos);
-    }
-    if (aRef.nCol > Ref2.nCol || aRef.nRow > Ref2.nRow || aRef.nTab > Ref2.nTab)
-    {
-        if (bInherit3D)
-            Ref2.SetFlag3D( true);
-        lcl_adjustInOrder( aRef, Ref2, false);
-        if (bInherit3Dtemp)
-            Ref2.SetFlag3D( false);
-        aRef = rRef;
-        aRef.CalcAbsIfRel( rPos);
-    }
-    // In Ref2 use absolute/relative addressing from non-extended parts if
-    // equal and therefor not adjusted.
-    // A$5:A5 => A$5:A$5:A5 => A$5:A5, and not A$5:A$5
-    // A$6:$A5 => A$6:A$6:$A5 => A5:$A$6
-    if (Ref2.nCol == aRef.nCol)
-        Ref2.SetColRel( aRef.IsColRel());
-    if (Ref2.nRow == aRef.nRow)
-        Ref2.SetRowRel( aRef.IsRowRel());
-    // $Sheet1.$A$5:$A$6 => $Sheet1.$A$5:$A$5:$A$6 => $Sheet1.$A$5:$A$6, and
-    // not $Sheet1.$A$5:Sheet1.$A$6 (with invisible second 3D, but relative).
-    if (Ref2.nTab == aRef.nTab)
-        Ref2.SetTabRel( bInherit3Dtemp ? Ref1.IsTabRel() : aRef.IsTabRel());
-    Ref2.CalcRelFromAbs( rPos);
-    // Force 3D if necessary. References to other sheets always.
-    if (Ref1.nTab != rPos.Tab())
-        Ref1.SetFlag3D( true);
-    // In the second part only if different sheet thus not inherited.
-    if (Ref2.nTab != Ref1.nTab)
-        Ref2.SetFlag3D( true);
-    // Merge Flag3D to Ref2 in case there was nothing to inherit and/or range
-    // wasn't extended as in A5:A5:Sheet1.A5 if on Sheet1.
-    if (rRef.IsFlag3D())
-        Ref2.SetFlag3D( true);
     return *this;
 }
 
commit b35b6ede0bfea4f4fbf46fd751d460fb12aabadc
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Jul 22 20:30:29 2013 -0400

    Modified reference shouldn't make the cell dirty.
    
    The 'value changed' flag is there for that purpose. Modified reference
    alone doesn't change the value of the cell.
    
    Change-Id: I9d7b4c7005603cd7bed8d90901f1fab0e0d49008

diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index c0807ee..5caecc6 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -2223,18 +2223,18 @@ bool ScFormulaCell::UpdateReferenceOnShift(
         pOldCode.reset(pCode->Clone());
 
     bool bValChanged = false;
-    bool bRangeModified = false;    // any range, not only shared formula
+    bool bRefModified = false;
     bool bRefSizeChanged = false;
 
     if (bHasRefs)
     {
         // Update cell or range references.
         sc::RefUpdateResult aRes = pCode->AdjustReferenceOnShift(rCxt, aOldPos);
-        bRangeModified = aRes.mbReferenceModified;
+        bRefModified = aRes.mbReferenceModified;
         bValChanged = aRes.mbValueChanged;
     }
 
-    if (bValChanged || bRangeModified)
+    if (bValChanged || bRefModified)
         bCellStateChanged = true;
 
     if (bOnRefMove)
@@ -2260,7 +2260,7 @@ bool ScFormulaCell::UpdateReferenceOnShift(
         bHasRelName = HasRelNameReference();
         // Reference changed and new listening needed?
         // Except in Insert/Delete without specialties.
-        bNewListening = (bRangeModified || bColRowNameCompile
+        bNewListening = (bRefModified || bColRowNameCompile
                 || (bValChanged && (bInDeleteUndo || bRefSizeChanged)) || bHasRelName);
 
         if ( bNewListening )
@@ -2268,12 +2268,12 @@ bool ScFormulaCell::UpdateReferenceOnShift(
     }
 
     // NeedDirty for changes except for Copy and Move/Insert without RelNames
-    bool bNeedDirty = (bRangeModified || bValChanged || bColRowNameCompile || bOnRefMove);
+    bool bNeedDirty = (bValChanged || bColRowNameCompile || bOnRefMove);
 
     if (pUndoDoc && (bValChanged || bOnRefMove))
         setOldCodeToUndo(pUndoDoc, aUndoPos, pOldCode.get(), eTempGrammar, cMatrixFlag);
 
-    if ( ( bCompile = (bCompile || bRangeModified || bColRowNameCompile) ) != 0 )
+    if ( (bCompile = (bCompile || bColRowNameCompile)) != 0 )
     {
         CompileTokenArray( bNewListening ); // no Listening
         bNeedDirty = true;
commit 032cf09ff7bd752b59da7b10220af6dbf16d57e3
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Jul 22 19:55:09 2013 -0400

    Flag cell state modified when a reference points to a different position.
    
    This fixes testStreamValid() test failure.
    
    Change-Id: Ife406957a723930efb419ba8c566485f4b089d97

diff --git a/sc/inc/refupdatecontext.hxx b/sc/inc/refupdatecontext.hxx
index 8067c3b..af47851 100644
--- a/sc/inc/refupdatecontext.hxx
+++ b/sc/inc/refupdatecontext.hxx
@@ -51,7 +51,7 @@ struct RefUpdateContext
 struct RefUpdateResult
 {
     bool mbValueChanged;
-    bool mbRangeSizeModified;
+    bool mbReferenceModified;
 
     RefUpdateResult();
     RefUpdateResult(const RefUpdateResult& r);
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 65f2daf..c0807ee 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -2230,11 +2230,12 @@ bool ScFormulaCell::UpdateReferenceOnShift(
     {
         // Update cell or range references.
         sc::RefUpdateResult aRes = pCode->AdjustReferenceOnShift(rCxt, aOldPos);
-        bRangeModified = aRes.mbRangeSizeModified;
+        bRangeModified = aRes.mbReferenceModified;
         bValChanged = aRes.mbValueChanged;
     }
 
-    bCellStateChanged |= bValChanged;
+    if (bValChanged || bRangeModified)
+        bCellStateChanged = true;
 
     if (bOnRefMove)
         // Cell may reference itself, e.g. ocColumn, ocRow without parameter
diff --git a/sc/source/core/data/refupdatecontext.cxx b/sc/source/core/data/refupdatecontext.cxx
index f1ad64c..67e1242 100644
--- a/sc/source/core/data/refupdatecontext.cxx
+++ b/sc/source/core/data/refupdatecontext.cxx
@@ -24,9 +24,9 @@ bool RefUpdateContext::isDeleted() const
     return (meMode == URM_INSDEL) && (mnColDelta < 0 || mnRowDelta < 0 || mnTabDelta < 0);
 }
 
-RefUpdateResult::RefUpdateResult() : mbValueChanged(false), mbRangeSizeModified(false) {}
+RefUpdateResult::RefUpdateResult() : mbValueChanged(false), mbReferenceModified(false) {}
 RefUpdateResult::RefUpdateResult(const RefUpdateResult& r) :
-    mbValueChanged(r.mbValueChanged), mbRangeSizeModified(r.mbRangeSizeModified) {}
+    mbValueChanged(r.mbValueChanged), mbReferenceModified(r.mbReferenceModified) {}
 
 }
 
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 37fb9aa..0b53a3b 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2392,7 +2392,10 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnShift( const sc::RefUpdateCon
                 }
 
                 if (rCxt.maRange.In(aAbs))
+                {
                     aAbs.Move(rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta);
+                    aRes.mbReferenceModified = true;
+                }
 
                 rRef.SetAddress(aAbs, aNewPos);
             }
@@ -2419,7 +2422,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnShift( const sc::RefUpdateCon
                             // The reference range has been shrunk.
                             rRef.SetRange(aAbs, aNewPos);
                             aRes.mbValueChanged = true;
-                            aRes.mbRangeSizeModified = true;
+                            aRes.mbReferenceModified = true;
                             break;
                         }
                     }
@@ -2432,7 +2435,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnShift( const sc::RefUpdateCon
                         // The reference range has been expanded.
                         rRef.SetRange(aAbs, aNewPos);
                         aRes.mbValueChanged = true;
-                        aRes.mbRangeSizeModified = true;
+                        aRes.mbReferenceModified = true;
                         break;
                     }
 
@@ -2441,13 +2444,16 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnShift( const sc::RefUpdateCon
                         // The reference range has been expanded on the edge.
                         rRef.SetRange(aAbs, aNewPos);
                         aRes.mbValueChanged = true;
-                        aRes.mbRangeSizeModified = true;
+                        aRes.mbReferenceModified = true;
                         break;
                     }
                 }
 
                 if (rCxt.maRange.In(aAbs))
+                {
                     aAbs.Move(rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta);
+                    aRes.mbReferenceModified = true;
+                }
                 else if (rCxt.maRange.Intersects(aAbs))
                 {
                     // Part of the referenced range is being shifted. This
commit ab9fe22139ba0faecf6a752633e4834f2b73e17e
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Mon Jul 22 13:08:31 2013 -0400

    Don't mark all of column, row, and sheet indices to be invalid in toAbs().
    
    When only one of them is invalid.  This messes up the displaying of an
    invalid reference.
    
    Conflicts:
    	sc/qa/unit/ucalc_formula.cxx
    
    Change-Id: I2b5a614434417160d605dd889ca4d3b54fcaffc2

diff --git a/sc/inc/refdata.hxx b/sc/inc/refdata.hxx
index 4accb54..35a6c33 100644
--- a/sc/inc/refdata.hxx
+++ b/sc/inc/refdata.hxx
@@ -23,6 +23,7 @@
 #include "global.hxx"
 #include "address.hxx"
 #include "scdllapi.h"
+#include "calcmacros.hxx"
 
 /// Single reference (one address) into the sheet
 struct SC_DLLPUBLIC ScSingleRefData
@@ -91,6 +92,10 @@ struct SC_DLLPUBLIC ScSingleRefData
             void CalcAbsIfRel( const ScAddress& rPos );
             bool operator==( const ScSingleRefData& ) const;
             bool operator!=( const ScSingleRefData& ) const;
+
+#if DEBUG_FORMULA_COMPILER
+    void Dump() const;
+#endif
 };
 
 inline void ScSingleRefData::InitAddress( SCCOL nColP, SCROW nRowP, SCTAB nTabP )
@@ -178,6 +183,10 @@ struct ScComplexRefData         // Complex reference (a range) into the sheet
         relative references. */
     ScComplexRefData& Extend( const ScSingleRefData & rRef, const ScAddress & rPos );
     ScComplexRefData& Extend( const ScComplexRefData & rRef, const ScAddress & rPos );
+
+#if DEBUG_FORMULA_COMPILER
+    void Dump() const;
+#endif
 };
 
 inline bool ScComplexRefData::ValidExternal() const
diff --git a/sc/source/core/tool/refdata.cxx b/sc/source/core/tool/refdata.cxx
index 053f2a5..239fd6b 100644
--- a/sc/source/core/tool/refdata.cxx
+++ b/sc/source/core/tool/refdata.cxx
@@ -67,10 +67,18 @@ ScAddress ScSingleRefData::toAbs( const ScAddress& rPos ) const
     SCROW nRetRow = Flags.bRowRel ? nRelRow + rPos.Row() : nRow;
     SCTAB nRetTab = Flags.bTabRel ? nRelTab + rPos.Tab() : nTab;
 
-    if (!ValidCol(nRetCol) || !ValidRow(nRetRow) || !ValidTab(nRetTab))
-        return ScAddress(ScAddress::INITIALIZE_INVALID);
+    ScAddress aAbs(ScAddress::INITIALIZE_INVALID);
 
-    return ScAddress(nRetCol, nRetRow, nRetTab);
+    if (ValidCol(nRetCol))
+        aAbs.SetCol(nRetCol);
+
+    if (ValidRow(nRetRow))
+        aAbs.SetRow(nRetRow);
+
+    if (ValidTab(nRetTab))
+        aAbs.SetTab(nRetTab);
+
+    return aAbs;
 }
 
 void ScSingleRefData::SetAddress( const ScAddress& rAddr, const ScAddress& rPos )
@@ -149,6 +157,20 @@ bool ScSingleRefData::operator!=( const ScSingleRefData& r ) const
     return !operator==(r);
 }
 
+#if DEBUG_FORMULA_COMPILER
+void ScSingleRefData::Dump() const
+{
+    cout << "  address type column: " << (IsColRel()?"relative":"absolute")
+        << "  row : " << (IsRowRel()?"relative":"absolute") << "  sheet: "
+        << (IsTabRel()?"relative":"absolute") << endl;
+    cout << "  deleted column: " << (IsColDeleted()?"yes":"no")
+        << "  row : " << (IsRowDeleted()?"yes":"no") << "  sheet: "
+        << (IsTabDeleted()?"yes":"no") << endl;
+    cout << "  absolute pos column: " << nCol << "  row: " << nRow << "  sheet: " << nTab << endl;
+    cout << "  relative pos column: " << nRelCol << "  row: " << nRelRow << "  sheet: " << nRelTab << endl;
+}
+#endif
+
 static void lcl_putInOrder( ScSingleRefData & rRef1, ScSingleRefData & rRef2 )
 {
     SCCOL nCol1, nCol2;
@@ -330,4 +352,29 @@ void ScComplexRefData::SetRange( const ScRange& rRange, const ScAddress& rPos )
     Ref2.SetAddress(rRange.aEnd, rPos);
 }
 
+#if DEBUG_FORMULA_COMPILER
+void ScComplexRefData::Dump() const
+{
+    cout << "  ref 1" << endl;

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list