[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 3 commits - sc/inc sc/qa sc/source

Kohei Yoshida kohei.yoshida at gmail.com
Thu Jul 25 12:59:20 PDT 2013


 sc/inc/calcmacros.hxx                |    2 
 sc/inc/tokenarray.hxx                |    2 
 sc/qa/unit/ucalc.cxx                 |    4 -
 sc/qa/unit/ucalc_formula.cxx         |   37 ++++++++++++++---
 sc/source/core/data/conditio.cxx     |   32 +++++++--------
 sc/source/core/data/documen4.cxx     |    2 
 sc/source/core/data/formulacell.cxx  |   41 ++++++-------------
 sc/source/core/tool/compiler.cxx     |    6 +-
 sc/source/core/tool/token.cxx        |   66 ++++++++++++++++++++++++++++++--
 sc/source/filter/excel/excform.cxx   |   32 +++++----------
 sc/source/filter/excel/excform8.cxx  |   32 +++++----------
 sc/source/filter/excel/xeformula.cxx |   26 +++++++-----
 sc/source/filter/excel/xelink.cxx    |   12 ++---
 sc/source/filter/lotus/lotform.cxx   |    4 -
 sc/source/filter/lotus/tool.cxx      |    6 --
 sc/source/ui/unoobj/tokenuno.cxx     |   72 +++++++++++++++++++++++++++--------
 16 files changed, 234 insertions(+), 142 deletions(-)

New commits:
commit 7f78d759afc1cd05f25b37ee994b649351dad9dc
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu Jul 25 15:59:00 2013 -0400

    Re-work reference update on sheet insertion & fix one bug on sheet deletion.
    
    Change-Id: I1405eb54c3c530e2c22be1f1d7728fa0d84ad447

diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index 2ae6c90..1e8ced1 100644
--- a/sc/inc/tokenarray.hxx
+++ b/sc/inc/tokenarray.hxx
@@ -143,6 +143,8 @@ public:
      */
     bool AdjustReferenceOnDeletedTab( SCTAB nDelPos, SCTAB nSheets, const ScAddress& rOldPos );
 
+    bool AdjustReferenceOnInsertedTab( SCTAB nInsPos, SCTAB nSheets, const ScAddress& rOldPos );
+
 #if DEBUG_FORMULA_COMPILER
     void Dump() const;
 #endif
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 6407b72..531d1d3 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -765,12 +765,12 @@ void Test::testFormulaRefUpdateSheets()
 
     // Set formulas to B2 and B3 on sheet Sheet2.
     m_pDoc->SetString(ScAddress(1,1,1), "=SUM(Sheet1.B2:C3)");
-    m_pDoc->SetString(ScAddress(1,2,1), "=SUM(Sheet1.$B$2:$C$3)");
+    m_pDoc->SetString(ScAddress(1,2,1), "=SUM($Sheet1.$B$2:$C$3)");
 
     if (!checkFormula(*m_pDoc, ScAddress(1,1,1), "SUM(Sheet1.B2:C3)"))
         CPPUNIT_FAIL("Wrong formula in Sheet2.B2.");
 
-    if (!checkFormula(*m_pDoc, ScAddress(1,2,1), "SUM(Sheet1.$B$2:$C$3)"))
+    if (!checkFormula(*m_pDoc, ScAddress(1,2,1), "SUM($Sheet1.$B$2:$C$3)"))
         CPPUNIT_FAIL("Wrong formula in Sheet2.B3.");
 
     // Swap the sheets.
@@ -783,7 +783,7 @@ void Test::testFormulaRefUpdateSheets()
     if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "SUM(Sheet1.B2:C3)"))
         CPPUNIT_FAIL("Wrong formula in Sheet2.B2.");
 
-    if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "SUM(Sheet1.$B$2:$C$3)"))
+    if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "SUM($Sheet1.$B$2:$C$3)"))
         CPPUNIT_FAIL("Wrong formula in Sheet2.B3.");
 
     // Swap back.
@@ -796,7 +796,7 @@ void Test::testFormulaRefUpdateSheets()
     if (!checkFormula(*m_pDoc, ScAddress(1,1,1), "SUM(Sheet1.B2:C3)"))
         CPPUNIT_FAIL("Wrong formula in Sheet2.B2.");
 
-    if (!checkFormula(*m_pDoc, ScAddress(1,2,1), "SUM(Sheet1.$B$2:$C$3)"))
+    if (!checkFormula(*m_pDoc, ScAddress(1,2,1), "SUM($Sheet1.$B$2:$C$3)"))
         CPPUNIT_FAIL("Wrong formula in Sheet2.B3.");
 
     // Insert a new sheet between the two.
@@ -810,7 +810,7 @@ void Test::testFormulaRefUpdateSheets()
     if (!checkFormula(*m_pDoc, ScAddress(1,1,2), "SUM(Sheet1.B2:C3)"))
         CPPUNIT_FAIL("Wrong formula in Sheet2.B2.");
 
-    if (!checkFormula(*m_pDoc, ScAddress(1,2,2), "SUM(Sheet1.$B$2:$C$3)"))
+    if (!checkFormula(*m_pDoc, ScAddress(1,2,2), "SUM($Sheet1.$B$2:$C$3)"))
         CPPUNIT_FAIL("Wrong formula in Sheet2.B3.");
 
     // Delete the temporary sheet.
@@ -822,7 +822,30 @@ void Test::testFormulaRefUpdateSheets()
     if (!checkFormula(*m_pDoc, ScAddress(1,1,1), "SUM(Sheet1.B2:C3)"))
         CPPUNIT_FAIL("Wrong formula in Sheet2.B2.");
 
-    if (!checkFormula(*m_pDoc, ScAddress(1,2,1), "SUM(Sheet1.$B$2:$C$3)"))
+    if (!checkFormula(*m_pDoc, ScAddress(1,2,1), "SUM($Sheet1.$B$2:$C$3)"))
+        CPPUNIT_FAIL("Wrong formula in Sheet2.B3.");
+
+    // Insert a new sheet before the first one.
+    m_pDoc->InsertTab(0, "Temp");
+
+    m_pDoc->GetName(1, aName);
+    CPPUNIT_ASSERT_EQUAL(OUString("Sheet1"), aName);
+    m_pDoc->GetName(2, aName);
+    CPPUNIT_ASSERT_EQUAL(OUString("Sheet2"), aName);
+
+    if (!checkFormula(*m_pDoc, ScAddress(1,1,2), "SUM(Sheet1.B2:C3)"))
+        CPPUNIT_FAIL("Wrong formula in Sheet2.B2.");
+
+    if (!checkFormula(*m_pDoc, ScAddress(1,2,2), "SUM($Sheet1.$B$2:$C$3)"))
+        CPPUNIT_FAIL("Wrong formula in Sheet2.B3.");
+
+    // Delete the temporary sheet.
+    m_pDoc->DeleteTab(0);
+
+    if (!checkFormula(*m_pDoc, ScAddress(1,1,1), "SUM(Sheet1.B2:C3)"))
+        CPPUNIT_FAIL("Wrong formula in Sheet2.B2.");
+
+    if (!checkFormula(*m_pDoc, ScAddress(1,2,1), "SUM($Sheet1.$B$2:$C$3)"))
         CPPUNIT_FAIL("Wrong formula in Sheet2.B3.");
 
     // Delete Sheet1.
@@ -833,7 +856,7 @@ void Test::testFormulaRefUpdateSheets()
     if (!checkFormula(*m_pDoc, ScAddress(1,1,0), "SUM(#REF!.B2:C3)"))
         CPPUNIT_FAIL("Wrong formula in Sheet2.B2.");
 
-    if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "SUM(#REF!.$B$2:$C$3)"))
+    if (!checkFormula(*m_pDoc, ScAddress(1,2,0), "SUM($#REF!.$B$2:$C$3)"))
         CPPUNIT_FAIL("Wrong formula in Sheet2.B3.");
 
     m_pDoc->DeleteTab(0);
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 694b81d..c6fb301 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -2555,37 +2555,24 @@ bool ScFormulaCell::UpdateReference(
 
 void ScFormulaCell::UpdateInsertTab(SCTAB nTable, SCTAB nNewSheets)
 {
-    bool bPosChanged = ( aPos.Tab() >= nTable ? true : false );
+    bool bPosChanged = (nTable <= aPos.Tab());
     pCode->Reset();
-    if( pCode->GetNextReferenceRPN() && !pDocument->IsClipOrUndo() )
+    if (pDocument->IsClipOrUndo() || !pCode->GetNextReferenceRPN())
     {
-        EndListeningTo( pDocument );
-        // IncTab _after_ EndListeningTo and _before_ Compiler UpdateInsertTab!
-        if ( bPosChanged )
+        if (bPosChanged)
             aPos.IncTab(nNewSheets);
-        ScRangeData* pRangeData;
-        ScCompiler aComp(pDocument, aPos, *pCode);
-        aComp.SetGrammar(pDocument->GetGrammar());
-        pRangeData = aComp.UpdateInsertTab( nTable, false, nNewSheets );
-        if (pRangeData) // Exchange Shared Formula with real Formula
-        {
-            bool bRefChanged;
-            pDocument->RemoveFromFormulaTree( this );   // update formula count
-            delete pCode;
-            pCode = new ScTokenArray( *pRangeData->GetCode() );
-            ScCompiler aComp2(pDocument, aPos, *pCode);
-            aComp2.SetGrammar(pDocument->GetGrammar());
-            aComp2.MoveRelWrap(pRangeData->GetMaxCol(), pRangeData->GetMaxRow());
-            aComp2.UpdateInsertTab( nTable, false, nNewSheets );
-            // If the shared formula contained a named range/formula containing
-            // an absolute reference to a sheet, those have to be readjusted.
-            aComp2.UpdateDeleteTab( nTable, false, true, bRefChanged, nNewSheets );
-            bCompile = true;
-        }
-        // no StartListeningTo because pTab[nTab] does not exsist!
+
+        return;
     }
-    else if ( bPosChanged )
-        aPos.IncTab();
+
+    EndListeningTo( pDocument );
+    ScAddress aOldPos = aPos;
+    // IncTab _after_ EndListeningTo and _before_ Compiler UpdateInsertTab!
+    if (bPosChanged)
+        aPos.IncTab(nNewSheets);
+
+    pCode->AdjustReferenceOnInsertedTab(nTable, nNewSheets, aOldPos);
+    // no StartListeningTo because the new sheets have not been inserted yet.
 }
 
 bool ScFormulaCell::UpdateDeleteTab(SCTAB nTable, bool /*bIsMove*/, SCTAB nSheets)
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 18a16cd..77793da 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -771,7 +771,7 @@ struct ConventionOOO_A1 : public Convention_A1
     {
         if( rRef.IsFlag3D() || bForceTab )
         {
-            if (!ValidTab(rAbsRef.Tab()))
+            if (!ValidTab(rAbsRef.Tab()) || rRef.IsTabDeleted())
             {
                 if (!rRef.IsTabRel())
                     rBuffer.append(sal_Unicode('$'));
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 53172ce..e5381aa 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -2536,7 +2536,7 @@ sc::RefUpdateResult ScTokenArray::AdjustReferenceOnMove(
 
 namespace {
 
-bool adjustSingleRef( ScSingleRefData& rRef, SCTAB nDelPos, SCTAB nSheets, const ScAddress& rOldPos, const ScAddress& rNewPos )
+bool adjustSingleRefOnDeletedTab( ScSingleRefData& rRef, SCTAB nDelPos, SCTAB nSheets, const ScAddress& rOldPos, const ScAddress& rNewPos )
 {
     ScAddress aAbs = rRef.toAbs(rOldPos);
     if (nDelPos <= aAbs.Tab() && aAbs.Tab() < nDelPos + nSheets)
@@ -2562,6 +2562,26 @@ bool adjustSingleRef( ScSingleRefData& rRef, SCTAB nDelPos, SCTAB nSheets, const
     return false;
 }
 
+bool adjustSingleRefOnInsertedTab( ScSingleRefData& rRef, SCTAB nInsPos, SCTAB nSheets, const ScAddress& rOldPos, const ScAddress& rNewPos )
+{
+    ScAddress aAbs = rRef.toAbs(rOldPos);
+    if (nInsPos <= aAbs.Tab())
+    {
+        // Reference sheet needs to be adjusted.
+        aAbs.IncTab(nSheets);
+        rRef.SetAddress(aAbs, rNewPos);
+        return true;
+    }
+    else if (rOldPos.Tab() != rNewPos.Tab())
+    {
+        // Cell itself has moved.
+        rRef.SetAddress(aAbs, rNewPos);
+        return true;
+    }
+
+    return false;
+}
+
 }
 
 bool ScTokenArray::AdjustReferenceOnDeletedTab( SCTAB nDelPos, SCTAB nSheets, const ScAddress& rOldPos )
@@ -2581,7 +2601,45 @@ bool ScTokenArray::AdjustReferenceOnDeletedTab( SCTAB nDelPos, SCTAB nSheets, co
             {
                 ScToken* pToken = static_cast<ScToken*>(*p);
                 ScSingleRefData& rRef = pToken->GetSingleRef();
-                if (adjustSingleRef(rRef, nDelPos, nSheets, rOldPos, aNewPos))
+                if (adjustSingleRefOnDeletedTab(rRef, nDelPos, nSheets, rOldPos, aNewPos))
+                    bRefChanged = true;
+            }
+            break;
+            case svDoubleRef:
+            {
+                ScToken* pToken = static_cast<ScToken*>(*p);
+                ScComplexRefData& rRef = pToken->GetDoubleRef();
+                if (adjustSingleRefOnDeletedTab(rRef.Ref1, nDelPos, nSheets, rOldPos, aNewPos))
+                    bRefChanged = true;
+                if (adjustSingleRefOnDeletedTab(rRef.Ref2, nDelPos, nSheets, rOldPos, aNewPos))
+                    bRefChanged = true;
+            }
+            break;
+            default:
+                ;
+        }
+    }
+    return bRefChanged;
+}
+
+bool ScTokenArray::AdjustReferenceOnInsertedTab( SCTAB nInsPos, SCTAB nSheets, const ScAddress& rOldPos )
+{
+    bool bRefChanged = false;
+    ScAddress aNewPos = rOldPos;
+    if (nInsPos <= rOldPos.Tab())
+        aNewPos.IncTab(nSheets);
+
+    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();
+                if (adjustSingleRefOnInsertedTab(rRef, nInsPos, nSheets, rOldPos, aNewPos))
                     bRefChanged = true;
             }
             break;
@@ -2589,9 +2647,9 @@ bool ScTokenArray::AdjustReferenceOnDeletedTab( SCTAB nDelPos, SCTAB nSheets, co
             {
                 ScToken* pToken = static_cast<ScToken*>(*p);
                 ScComplexRefData& rRef = pToken->GetDoubleRef();
-                if (adjustSingleRef(rRef.Ref1, nDelPos, nSheets, rOldPos, aNewPos))
+                if (adjustSingleRefOnInsertedTab(rRef.Ref1, nInsPos, nSheets, rOldPos, aNewPos))
                     bRefChanged = true;
-                if (adjustSingleRef(rRef.Ref2, nDelPos, nSheets, rOldPos, aNewPos))
+                if (adjustSingleRefOnInsertedTab(rRef.Ref2, nInsPos, nSheets, rOldPos, aNewPos))
                     bRefChanged = true;
             }
             break;
commit efd3828fe240064145035c403cf71a172ffbef9c
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu Jul 25 14:36:07 2013 -0400

    More on removing direct access to reference position members.
    
    Change-Id: I7ca5cd0aefbcbda5d89116aca90e974b4bed6ca0

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 7d081bc..fee03b5 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -872,13 +872,13 @@ bool checkRelativeRefToken(ScDocument& rDoc, const ScAddress& rPos, SCsCOL nRelC
         return false;
 
     ScSingleRefData& rRef = pToken->GetSingleRef();
-    if (!rRef.IsColRel() || rRef.nRelCol != nRelCol)
+    if (!rRef.IsColRel() || rRef.Col() != nRelCol)
     {
         cerr << "Unexpected relative column address." << endl;
         return false;
     }
 
-    if (!rRef.IsRowRel() || rRef.nRelRow != nRelRow)
+    if (!rRef.IsRowRel() || rRef.Row() != nRelRow)
     {
         cerr << "Unexpected relative row address." << endl;
         return false;
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index fe438af..9f1db33 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -493,7 +493,7 @@ void ScConditionEntry::SetFormula2( const ScTokenArray& rArray )
     }
 }
 
-static void lcl_CondUpdateInsertTab( ScTokenArray& rCode, SCTAB nInsTab, SCTAB nPosTab, bool& rChanged, SCTAB nTabs )
+static void lcl_CondUpdateInsertTab( ScTokenArray& rCode, SCTAB nInsTab, bool& rChanged, SCTAB nTabs )
 {
     //  Insert table: only update absolute table references.
     //  (Similar to ScCompiler::UpdateInsertTab with bIsName=true, result is the same as for named ranges)
@@ -504,19 +504,17 @@ static void lcl_CondUpdateInsertTab( ScTokenArray& rCode, SCTAB nInsTab, SCTAB n
     while( p )
     {
         ScSingleRefData& rRef1 = p->GetSingleRef();
-        if ( !rRef1.IsTabRel() && nInsTab <= rRef1.nTab )
+        if (!rRef1.IsTabRel() && nInsTab <= rRef1.Tab())
         {
-            rRef1.nTab += nTabs;
-            rRef1.nRelTab = rRef1.nTab - nPosTab;
+            rRef1.SetAbsTab(rRef1.Tab() + nTabs);
             rChanged = true;
         }
         if( p->GetType() == svDoubleRef )
         {
             ScSingleRefData& rRef2 = p->GetDoubleRef().Ref2;
-            if ( !rRef2.IsTabRel() && nInsTab <= rRef2.nTab )
+            if (!rRef2.IsTabRel() && nInsTab <= rRef2.Tab())
             {
-                rRef2.nTab += nTabs;
-                rRef2.nRelTab = rRef2.nTab - nPosTab;
+                rRef2.SetAbsTab(rRef2.Tab() + nTabs);
                 rChanged = true;
             }
         }
@@ -543,7 +541,7 @@ void ScConditionEntry::UpdateReference( UpdateRefMode eUpdateRefMode,
     {
         bool bChanged1 = false;
         if ( bInsertTab )
-            lcl_CondUpdateInsertTab( *pFormula1, rRange.aStart.Tab(), aOldSrcPos.Tab(), bChanged1, nDz );
+            lcl_CondUpdateInsertTab( *pFormula1, rRange.aStart.Tab(), bChanged1, nDz );
         else
         {
             ScCompiler aComp( mpDoc, aSrcPos, *pFormula1 );
@@ -565,7 +563,7 @@ void ScConditionEntry::UpdateReference( UpdateRefMode eUpdateRefMode,
     {
         bool bChanged2 = false;
         if ( bInsertTab )
-            lcl_CondUpdateInsertTab( *pFormula2, rRange.aStart.Tab(), aOldSrcPos.Tab(), bChanged2, nDz );
+            lcl_CondUpdateInsertTab( *pFormula2, rRange.aStart.Tab(), bChanged2, nDz );
         else
         {
             ScCompiler aComp( mpDoc, aSrcPos, *pFormula2);
@@ -1398,17 +1396,17 @@ void ScConditionEntry::SourceChanged( const ScAddress& rChanged )
                         nCol2 = MAXCOL;
                     }
                     if ( aProv.Ref1.IsRowRel() )
-                        nRow2 = rChanged.Row() - aProv.Ref1.nRelRow;
+                        nRow2 = rChanged.Row() - aProv.Ref1.Row();
                     else
                     {
-                        bHit &= ( rChanged.Row() >= aProv.Ref1.nRow );
+                        bHit &= ( rChanged.Row() >= aProv.Ref1.Row() );
                         nRow2 = MAXROW;
                     }
                     if ( aProv.Ref1.IsTabRel() )
-                        nTab2 = rChanged.Tab() - aProv.Ref1.nRelTab;
+                        nTab2 = rChanged.Tab() - aProv.Ref1.Tab();
                     else
                     {
-                        bHit &= ( rChanged.Tab() >= aProv.Ref1.nTab );
+                        bHit &= (rChanged.Tab() >= aProv.Ref1.Tab());
                         nTab2 = MAXTAB;
                     }
 
@@ -1420,17 +1418,17 @@ void ScConditionEntry::SourceChanged( const ScAddress& rChanged )
                         nCol1 = 0;
                     }
                     if ( aProv.Ref2.IsRowRel() )
-                        nRow1 = rChanged.Row() - aProv.Ref2.nRelRow;
+                        nRow1 = rChanged.Row() - aProv.Ref2.Row();
                     else
                     {
-                        bHit &= ( rChanged.Row() <= aProv.Ref2.nRow );
+                        bHit &= (rChanged.Row() <= aProv.Ref2.Row());
                         nRow1 = 0;
                     }
                     if ( aProv.Ref2.IsTabRel() )
-                        nTab1 = rChanged.Tab() - aProv.Ref2.nRelTab;
+                        nTab1 = rChanged.Tab() - aProv.Ref2.Tab();
                     else
                     {
-                        bHit &= ( rChanged.Tab() <= aProv.Ref2.nTab );
+                        bHit &= (rChanged.Tab() <= aProv.Ref2.Tab());
                         nTab1 = 0;
                     }
 
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index 54f4325..9499fa0 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -176,7 +176,7 @@ void ScDocument::InsertMatrixFormula(SCCOL nCol1, SCROW nRow1,
 
         if (nTab != nTab1)
         {
-            aRefData.nRelTab = nTab - aBasePos.Tab();
+            aRefData.SetRelTab(nTab - aBasePos.Tab());
             t->GetSingleRef() = aRefData;
         }
 
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index cfee0cd..18a16cd 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -1461,9 +1461,9 @@ r1c1_add_row( OUStringBuffer &rBuf, const ScSingleRefData& rRef, const ScAddress
     rBuf.append( sal_Unicode( 'R' ) );
     if( rRef.IsRowRel() )
     {
-        if (rRef.nRelRow != 0)
+        if (rRef.Row() != 0)
         {
-            rBuf.append("[").append( OUString::number( rRef.nRelRow ) ).append("]");
+            rBuf.append("[").append( OUString::number(rRef.Row()) ).append("]");
         }
     }
     else
diff --git a/sc/source/filter/excel/excform.cxx b/sc/source/filter/excel/excform.cxx
index 1080b4b..c5aaf3c 100644
--- a/sc/source/filter/excel/excform.cxx
+++ b/sc/source/filter/excel/excform.cxx
@@ -521,8 +521,7 @@ ConvErr ExcelToSc::Convert( const ScTokenArray*& pErgebnis, XclImpStream& aIn, s
                 aIn >> nUINT16 >> nByte;
                 aSRD.nCol = static_cast<SCsCOL>(nByte);
                 aSRD.nRow = nUINT16 & 0x3FFF;
-                aSRD.nRelTab = 0;
-                aSRD.SetTabRel( sal_True );
+                aSRD.SetRelTab(0);
                 aSRD.SetFlag3D( bRangeName );
 
                 ExcRelToScRel( nUINT16, nByte, aSRD, bRangeName );
@@ -553,9 +552,8 @@ ConvErr ExcelToSc::Convert( const ScTokenArray*& pErgebnis, XclImpStream& aIn, s
 
                 aIn >> nRowFirst >> nRowLast >> nColFirst >> nColLast;
 
-                rSRef1.nRelTab = rSRef2.nRelTab = 0;
-                rSRef1.SetTabRel( sal_True );
-                rSRef2.SetTabRel( sal_True );
+                rSRef1.SetRelTab(0);
+                rSRef2.SetRelTab(0);
                 rSRef1.SetFlag3D( bRangeName );
                 rSRef2.SetFlag3D( bRangeName );
 
@@ -603,8 +601,7 @@ ConvErr ExcelToSc::Convert( const ScTokenArray*& pErgebnis, XclImpStream& aIn, s
             {
                 aIn >> nUINT16 >> nByte;    // >> Attribute, Row >> Col
 
-                aSRD.nRelTab = 0;
-                aSRD.SetTabRel( sal_True );
+                aSRD.SetRelTab(0);
                 aSRD.SetFlag3D( bRangeName );
 
                 ExcRelToScRel( nUINT16, nByte, aSRD, bRNorSF );
@@ -619,9 +616,8 @@ ConvErr ExcelToSc::Convert( const ScTokenArray*& pErgebnis, XclImpStream& aIn, s
                 sal_uInt16                  nRowFirst, nRowLast;
                 sal_uInt8                   nColFirst, nColLast;
 
-                aCRD.Ref1.nRelTab = aCRD.Ref2.nRelTab = 0;
-                aCRD.Ref1.SetTabRel( sal_True );
-                aCRD.Ref2.SetTabRel( sal_True );
+                aCRD.Ref1.SetRelTab(0);
+                aCRD.Ref2.SetRelTab(0);
                 aCRD.Ref1.SetFlag3D( bRangeName );
                 aCRD.Ref2.SetFlag3D( bRangeName );
 
@@ -1036,8 +1032,7 @@ ConvErr ExcelToSc::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sal
                 aIn >> nUINT16 >> nByte;
                 aSRD.nCol = static_cast<SCsCOL>(nByte);
                 aSRD.nRow = nUINT16 & 0x3FFF;
-                aSRD.nRelTab = 0;
-                aSRD.SetTabRel( sal_True );
+                aSRD.SetRelTab(0);
                 aSRD.SetFlag3D( bRangeName );
 
                 ExcRelToScRel( nUINT16, nByte, aSRD, bRangeName );
@@ -1055,9 +1050,8 @@ ConvErr ExcelToSc::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sal
 
                 aIn >> nRowFirst >> nRowLast >> nColFirst >> nColLast;
 
-                rSRef1.nRelTab = rSRef2.nRelTab = 0;
-                rSRef1.SetTabRel( sal_True );
-                rSRef2.SetTabRel( sal_True );
+                rSRef1.SetRelTab(0);
+                rSRef2.SetRelTab(0);
                 rSRef1.SetFlag3D( bRangeName );
                 rSRef2.SetFlag3D( bRangeName );
 
@@ -1100,8 +1094,7 @@ ConvErr ExcelToSc::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sal
             {
                 aIn >> nUINT16 >> nByte;    // >> Attribute, Row >> Col
 
-                aSRD.nRelTab = 0;
-                aSRD.SetTabRel( sal_True );
+                aSRD.SetRelTab(0);
                 aSRD.SetFlag3D( bRangeName );
 
                 ExcRelToScRel( nUINT16, nByte, aSRD, bRNorSF );
@@ -1116,9 +1109,8 @@ ConvErr ExcelToSc::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sal
                 sal_uInt16                  nRowFirst, nRowLast;
                 sal_uInt8                   nColFirst, nColLast;
 
-                aCRD.Ref1.nRelTab = aCRD.Ref2.nRelTab = 0;
-                aCRD.Ref1.SetTabRel( sal_True );
-                aCRD.Ref2.SetTabRel( sal_True );
+                aCRD.Ref1.SetRelTab(0);
+                aCRD.Ref2.SetRelTab(0);
                 aCRD.Ref1.SetFlag3D( bRangeName );
                 aCRD.Ref2.SetFlag3D( bRangeName );
 
diff --git a/sc/source/filter/excel/excform8.cxx b/sc/source/filter/excel/excform8.cxx
index 4810a7e..7241901 100644
--- a/sc/source/filter/excel/excform8.cxx
+++ b/sc/source/filter/excel/excform8.cxx
@@ -500,8 +500,7 @@ ConvErr ExcelToSc8::Convert( const ScTokenArray*& rpTokArray, XclImpStream& aIn,
 
                 aSRD.nCol = static_cast<SCCOL>(nCol);
                 aSRD.nRow = nRow & 0x3FFF;
-                aSRD.nRelTab = 0;
-                aSRD.SetTabRel( sal_True );
+                aSRD.SetRelTab(0);
                 aSRD.SetFlag3D( bRangeName && !bCondFormat );
 
                 ExcRelToScRel8( nRow, nCol, aSRD, bRangeName );
@@ -533,9 +532,8 @@ ConvErr ExcelToSc8::Convert( const ScTokenArray*& rpTokArray, XclImpStream& aIn,
 
                 aIn >> nRowFirst >> nRowLast >> nColFirst >> nColLast;
 
-                rSRef1.nRelTab = rSRef2.nRelTab = 0;
-                rSRef1.SetTabRel( sal_True );
-                rSRef2.SetTabRel( sal_True );
+                rSRef1.SetRelTab(0);
+                rSRef2.SetRelTab(0);
                 rSRef1.SetFlag3D( bRangeName && !bCondFormat );
                 rSRef2.SetFlag3D( bRangeName && !bCondFormat );
 
@@ -592,8 +590,7 @@ ConvErr ExcelToSc8::Convert( const ScTokenArray*& rpTokArray, XclImpStream& aIn,
 
                 aIn >> nRow >> nCol;
 
-                aSRD.nRelTab = 0;
-                aSRD.SetTabRel( sal_True );
+                aSRD.SetRelTab(0);
                 aSRD.SetFlag3D( bRangeName );
 
                 ExcRelToScRel8( nRow, nCol, aSRD, bRNorSF );
@@ -608,9 +605,8 @@ ConvErr ExcelToSc8::Convert( const ScTokenArray*& rpTokArray, XclImpStream& aIn,
                 sal_uInt16                  nRowFirst, nRowLast;
                 sal_uInt16                  nColFirst, nColLast;
 
-                aCRD.Ref1.nRelTab = aCRD.Ref2.nRelTab = 0;
-                aCRD.Ref1.SetTabRel( sal_True );
-                aCRD.Ref2.SetTabRel( sal_True );
+                aCRD.Ref1.SetRelTab(0);
+                aCRD.Ref2.SetRelTab(0);
                 aCRD.Ref1.SetFlag3D( bRangeName );
                 aCRD.Ref2.SetFlag3D( bRangeName );
 
@@ -1056,8 +1052,7 @@ ConvErr ExcelToSc8::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sa
 
                 aSRD.nCol = static_cast<SCCOL>(nCol);
                 aSRD.nRow = nRow & 0x3FFF;
-                aSRD.nRelTab = 0;
-                aSRD.SetTabRel( sal_True );
+                aSRD.SetRelTab(0);
                 aSRD.SetFlag3D( bRangeName && !bCondFormat );
 
                 ExcRelToScRel8( nRow, nCol, aSRD, bRangeName );
@@ -1076,9 +1071,8 @@ ConvErr ExcelToSc8::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sa
 
                 aIn >> nRowFirst >> nRowLast >> nColFirst >> nColLast;
 
-                rSRef1.nRelTab = rSRef2.nRelTab = 0;
-                rSRef1.SetTabRel( sal_True );
-                rSRef2.SetTabRel( sal_True );
+                rSRef1.SetRelTab(0);
+                rSRef2.SetRelTab(0);
                 rSRef1.SetFlag3D( bRangeName && !bCondFormat );
                 rSRef2.SetFlag3D( bRangeName && !bCondFormat );
 
@@ -1128,8 +1122,7 @@ ConvErr ExcelToSc8::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sa
 
                 aIn >> nRow >> nCol;
 
-                aSRD.nRelTab = 0;
-                aSRD.SetTabRel( sal_True );
+                aSRD.SetRelTab(0);
                 aSRD.SetFlag3D( bRangeName );
 
                 ExcRelToScRel8( nRow, nCol, aSRD, bRNorSF );
@@ -1144,9 +1137,8 @@ ConvErr ExcelToSc8::Convert( _ScRangeListTabs& rRangeList, XclImpStream& aIn, sa
                 sal_uInt16                  nRowFirst, nRowLast;
                 sal_uInt16                  nColFirst, nColLast;
 
-                aCRD.Ref1.nRelTab = aCRD.Ref2.nRelTab = 0;
-                aCRD.Ref1.SetTabRel( sal_True );
-                aCRD.Ref2.SetTabRel( sal_True );
+                aCRD.Ref1.SetRelTab(0);
+                aCRD.Ref2.SetRelTab(0);
                 aCRD.Ref1.SetFlag3D( bRangeName );
                 aCRD.Ref2.SetFlag3D( bRangeName );
 
diff --git a/sc/source/filter/excel/xeformula.cxx b/sc/source/filter/excel/xeformula.cxx
index a862ae4..32d3d75 100644
--- a/sc/source/filter/excel/xeformula.cxx
+++ b/sc/source/filter/excel/xeformula.cxx
@@ -1801,8 +1801,17 @@ bool XclExpFmlaCompImpl::IsRef2D( const ScSingleRefData& rRefData ) const
     /*  rRefData.IsFlag3D() determines if sheet name is always visible, even on
         the own sheet. If 3D references are allowed, the passed reference does
         not count as 2D reference. */
-    return (!mxData->mpLinkMgr || !rRefData.IsFlag3D()) && !rRefData.IsTabDeleted() &&
-        (rRefData.IsTabRel() ? (rRefData.nRelTab == 0) : (static_cast< SCTAB >( rRefData.nTab ) == GetCurrScTab()));
+
+    if (mxData->mpLinkMgr && rRefData.IsFlag3D())
+        return false;
+
+    if (rRefData.IsTabDeleted())
+        return false;
+
+    if (rRefData.IsTabRel())
+        return rRefData.Tab() == 0;
+    else
+        return rRefData.Tab() == GetCurrScTab();
 }
 
 bool XclExpFmlaCompImpl::IsRef2D( const ScComplexRefData& rRefData ) const
@@ -1841,16 +1850,12 @@ void XclExpFmlaCompImpl::ConvertRefData(
         // *** no reference position (shared, names, condfmt) - use relative values ***
 
         // convert column index (2-step-cast ScsCOL->sal_Int16->sal_uInt16 to get all bits correctly)
-        sal_Int16 nXclRelCol = static_cast< sal_Int16 >( rRefData.IsColRel() ? rRefData.nRelCol : rRefData.nCol );
+        sal_Int16 nXclRelCol = static_cast<sal_Int16>(rRefData.Col());
         rXclPos.mnCol = static_cast< sal_uInt16 >( nXclRelCol ) & mnMaxColMask;
 
         // convert row index (2-step-cast ScsROW->sal_Int16->sal_uInt16 to get all bits correctly)
-        sal_Int16 nXclRelRow = static_cast< sal_Int32 >( rRefData.IsRowRel() ? rRefData.nRelRow : rRefData.nRow );
+        sal_Int16 nXclRelRow = static_cast<sal_Int32>(rRefData.Row());
         rXclPos.mnRow = static_cast< sal_uInt32 >( nXclRelRow ) & mnMaxRowMask;
-
-        // resolve relative tab index if possible
-        if( rRefData.IsTabRel() && !IsInGlobals() && (GetCurrScTab() < GetDoc().GetTableCount()) )
-            rRefData.nTab = static_cast< SCsTAB >( GetCurrScTab() + rRefData.nRelTab );
     }
 
     // flags for relative column and row
@@ -2536,12 +2541,11 @@ void lclInitOwnTab( ScSingleRefData& rRef, const ScAddress& rScPos, SCTAB nCurrS
     if( b3DRefOnly )
     {
         // no reduction to 2D reference, if global link manager is used
-        rRef.SetFlag3D( sal_True );
+        rRef.SetFlag3D(true);
     }
     else if( rScPos.Tab() == nCurrScTab )
     {
-        rRef.SetTabRel( sal_True );
-        rRef.nRelTab = 0;
+        rRef.SetRelTab(0);
     }
 }
 
diff --git a/sc/source/filter/excel/xelink.cxx b/sc/source/filter/excel/xelink.cxx
index 90ea02c..8c1e16b 100644
--- a/sc/source/filter/excel/xelink.cxx
+++ b/sc/source/filter/excel/xelink.cxx
@@ -965,8 +965,8 @@ void XclExpExtName::WriteAddData( XclExpStream& rStrm )
 
                 bool bColRel = rRef.IsColRel();
                 bool bRowRel = rRef.IsRowRel();
-                sal_uInt16 nCol = static_cast< sal_uInt16 >( bColRel ? rRef.nRelCol : rRef.nCol );
-                sal_uInt16 nRow = static_cast< sal_uInt16 >( bRowRel ? rRef.nRelRow : rRef.nRow );
+                sal_uInt16 nCol = static_cast<sal_uInt16>(rRef.Col());
+                sal_uInt16 nRow = static_cast<sal_uInt16>(rRef.Row());
                 if (bColRel) nCol |= 0x4000;
                 if (bRowRel) nCol |= 0x8000;
 
@@ -996,10 +996,10 @@ void XclExpExtName::WriteAddData( XclExpStream& rStrm )
                 bool bCol2Rel = r2.IsColRel();
                 bool bRow2Rel = r2.IsRowRel();
 
-                sal_uInt16 nCol1 = static_cast< sal_uInt16 >( bCol1Rel ? r1.nRelCol : r1.nCol );
-                sal_uInt16 nCol2 = static_cast< sal_uInt16 >( bCol2Rel ? r2.nRelCol : r2.nCol );
-                sal_uInt16 nRow1 = static_cast< sal_uInt16 >( bRow1Rel ? r1.nRelRow : r1.nRow );
-                sal_uInt16 nRow2 = static_cast< sal_uInt16 >( bRow2Rel ? r2.nRelRow : r2.nRow );
+                sal_uInt16 nCol1 = static_cast<sal_uInt16>(r1.Col());
+                sal_uInt16 nCol2 = static_cast<sal_uInt16>(r2.Col());
+                sal_uInt16 nRow1 = static_cast<sal_uInt16>(r1.Row());
+                sal_uInt16 nRow2 = static_cast<sal_uInt16>(r2.Row());
                 if (bCol1Rel) nCol1 |= 0x4000;
                 if (bRow1Rel) nCol1 |= 0x8000;
                 if (bCol2Rel) nCol2 |= 0x4000;
diff --git a/sc/source/filter/lotus/lotform.cxx b/sc/source/filter/lotus/lotform.cxx
index 75460cd..ed4d076 100644
--- a/sc/source/filter/lotus/lotform.cxx
+++ b/sc/source/filter/lotus/lotform.cxx
@@ -395,9 +395,7 @@ ConvErr LotusToSc::Convert( const ScTokenArray*& rpErg, sal_Int32& rRest,
         pIndexToType = IndexToType;
         pIndexToToken = IndexToToken;
 
-        rR.SetTabRel( sal_True );
-        rR.nTab = aEingPos.Tab();
-        rR.nRelTab = 0;
+        rR.SetRelTab(0);
         rR.SetFlag3D( false );
     }
 
diff --git a/sc/source/filter/lotus/tool.cxx b/sc/source/filter/lotus/tool.cxx
index d6f4fcf..020b582 100644
--- a/sc/source/filter/lotus/tool.cxx
+++ b/sc/source/filter/lotus/tool.cxx
@@ -424,17 +424,15 @@ LotusRangeList::LotusRangeList( void )
     nIdCnt = 1;
 
     pSingRef = &aComplRef.Ref1;
-    pSingRef->nTab = pSingRef->nRelTab = 0;
+    pSingRef->SetRelTab(0);
     pSingRef->SetColRel( false );
     pSingRef->SetRowRel( false );
-    pSingRef->SetTabRel( sal_True );
     pSingRef->SetFlag3D( false );
 
     pSingRef = &aComplRef.Ref2;
-    pSingRef->nTab = pSingRef->nRelTab = 0;
+    pSingRef->SetRelTab(0);
     pSingRef->SetColRel( false );
     pSingRef->SetRowRel( false );
-    pSingRef->SetTabRel( sal_True );
     pSingRef->SetFlag3D( false );
 }
 
diff --git a/sc/source/ui/unoobj/tokenuno.cxx b/sc/source/ui/unoobj/tokenuno.cxx
index f4d53d5..a08cd3b 100644
--- a/sc/source/ui/unoobj/tokenuno.cxx
+++ b/sc/source/ui/unoobj/tokenuno.cxx
@@ -288,16 +288,30 @@ SC_IMPL_DUMMY_PROPERTY_LISTENER( ScFormulaParserObj )
 
 static void lcl_ExternalRefToApi( sheet::SingleReference& rAPI, const ScSingleRefData& rRef )
 {
-    rAPI.Column         = rRef.nCol;
-    rAPI.Row            = rRef.nRow;
+    rAPI.Column         = 0;
+    rAPI.Row            = 0;
     rAPI.Sheet          = 0;
-    rAPI.RelativeColumn = rRef.nRelCol;
-    rAPI.RelativeRow    = rRef.nRelRow;
+    rAPI.RelativeColumn = 0;
+    rAPI.RelativeRow    = 0;
     rAPI.RelativeSheet  = 0;
 
     sal_Int32 nFlags = 0;
-    if ( rRef.IsColRel() )     nFlags |= sheet::ReferenceFlags::COLUMN_RELATIVE;
-    if ( rRef.IsRowRel() )     nFlags |= sheet::ReferenceFlags::ROW_RELATIVE;
+    if ( rRef.IsColRel() )
+    {
+        nFlags |= sheet::ReferenceFlags::COLUMN_RELATIVE;
+        rAPI.RelativeColumn = rRef.Col();
+    }
+    else
+        rAPI.Column = rRef.Col();
+
+    if ( rRef.IsRowRel() )
+    {
+        nFlags |= sheet::ReferenceFlags::ROW_RELATIVE;
+        rAPI.RelativeRow = rRef.Row();
+    }
+    else
+        rAPI.Row = rRef.Row();
+
     if ( rRef.IsColDeleted() ) nFlags |= sheet::ReferenceFlags::COLUMN_DELETED;
     if ( rRef.IsRowDeleted() ) nFlags |= sheet::ReferenceFlags::ROW_DELETED;
     if ( rRef.IsFlag3D() )     nFlags |= sheet::ReferenceFlags::SHEET_3D;
@@ -307,17 +321,43 @@ static void lcl_ExternalRefToApi( sheet::SingleReference& rAPI, const ScSingleRe
 
 static void lcl_SingleRefToApi( sheet::SingleReference& rAPI, const ScSingleRefData& rRef )
 {
-    rAPI.Column         = rRef.nCol;
-    rAPI.Row            = rRef.nRow;
-    rAPI.Sheet          = rRef.nTab;
-    rAPI.RelativeColumn = rRef.nRelCol;
-    rAPI.RelativeRow    = rRef.nRelRow;
-    rAPI.RelativeSheet  = rRef.nRelTab;
-
     sal_Int32 nFlags = 0;
-    if ( rRef.IsColRel() )     nFlags |= sheet::ReferenceFlags::COLUMN_RELATIVE;
-    if ( rRef.IsRowRel() )     nFlags |= sheet::ReferenceFlags::ROW_RELATIVE;
-    if ( rRef.IsTabRel() )     nFlags |= sheet::ReferenceFlags::SHEET_RELATIVE;
+    if ( rRef.IsColRel() )
+    {
+        nFlags |= sheet::ReferenceFlags::COLUMN_RELATIVE;
+        rAPI.RelativeColumn = rRef.Col();
+        rAPI.Column = 0;
+    }
+    else
+    {
+        rAPI.RelativeColumn = 0;
+        rAPI.Column = rRef.Col();
+    }
+
+    if ( rRef.IsRowRel() )
+    {
+        nFlags |= sheet::ReferenceFlags::ROW_RELATIVE;
+        rAPI.RelativeRow = rRef.Row();
+        rAPI.Row = 0;
+    }
+    else
+    {
+        rAPI.RelativeRow = 0;
+        rAPI.Row = rRef.Row();
+    }
+
+    if ( rRef.IsTabRel() )
+    {
+        nFlags |= sheet::ReferenceFlags::SHEET_RELATIVE;
+        rAPI.RelativeSheet = rRef.Tab();
+        rAPI.Sheet = 0;
+    }
+    else
+    {
+        rAPI.RelativeSheet = 0;
+        rAPI.Sheet = rRef.Tab();
+    }
+
     if ( rRef.IsColDeleted() ) nFlags |= sheet::ReferenceFlags::COLUMN_DELETED;
     if ( rRef.IsRowDeleted() ) nFlags |= sheet::ReferenceFlags::ROW_DELETED;
     if ( rRef.IsTabDeleted() ) nFlags |= sheet::ReferenceFlags::SHEET_DELETED;
commit fef6d6ff18bb4b5bdf824f5547161e906035cf9e
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu Jul 25 09:37:54 2013 -0400

    I forgot to turn this off.
    
    Change-Id: I86f60ee3ae748abd6ec2e8308ba067b836aa3ab4

diff --git a/sc/inc/calcmacros.hxx b/sc/inc/calcmacros.hxx
index 21a51fb..9516522 100644
--- a/sc/inc/calcmacros.hxx
+++ b/sc/inc/calcmacros.hxx
@@ -12,7 +12,7 @@
 
 #define DEBUG_COLUMN_STORAGE 0
 #define DEBUG_PIVOT_TABLE 0
-#define DEBUG_FORMULA_COMPILER 1
+#define DEBUG_FORMULA_COMPILER 0
 
 #if DEBUG_PIVOT_TABLE || DEBUG_COLUMN_STORAGE || DEBUG_FORMULA_COMPILER
 #include <iostream>


More information about the Libreoffice-commits mailing list