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

Kohei Yoshida kohei.yoshida at gmail.com
Fri Jul 26 13:11:34 PDT 2013


 sc/source/filter/excel/xetable.cxx   |    2 +-
 sc/source/filter/excel/xlformula.cxx |   17 +++++++++--------
 sc/source/filter/inc/xlformula.hxx   |    2 +-
 sc/source/filter/lotus/tool.cxx      |   15 ++++++++-------
 4 files changed, 19 insertions(+), 17 deletions(-)

New commits:
commit a03cf8933c7a1060bc43acaa5cc1c1a434916dca
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Jul 26 16:12:07 2013 -0400

    More of the same.
    
    Change-Id: I29c60f2f7a31b69b224d4c910392c88990b48572

diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx
index 9ef8202..99313ea 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -399,7 +399,7 @@ XclExpTableopRef XclExpTableopBuffer::CreateOrExtendTableop(
 
     // try to extract cell references of a multiple operations formula
     XclMultipleOpRefs aRefs;
-    if( XclTokenArrayHelper::GetMultipleOpRefs( aRefs, rScTokArr ) )
+    if (XclTokenArrayHelper::GetMultipleOpRefs(aRefs, rScTokArr, rScPos))
     {
         // try to find an existing TABLEOP record for this cell position
         for( size_t nPos = 0, nSize = maTableopList.GetSize(); !xRec && (nPos < nSize); ++nPos )
diff --git a/sc/source/filter/excel/xlformula.cxx b/sc/source/filter/excel/xlformula.cxx
index 337b971..94d9594 100644
--- a/sc/source/filter/excel/xlformula.cxx
+++ b/sc/source/filter/excel/xlformula.cxx
@@ -780,14 +780,14 @@ const ScTokenArray* XclTokenArrayHelper::GetSharedFormula( const XclRoot& rRoot,
 
 namespace {
 
-inline bool lclGetAddress( ScAddress& rAddress, const FormulaToken& rToken )
+inline bool lclGetAddress( ScAddress& rAddress, const FormulaToken& rToken, const ScAddress& rPos )
 {
     OpCode eOpCode = rToken.GetOpCode();
     bool bIsSingleRef = (eOpCode == ocPush) && (rToken.GetType() == svSingleRef);
     if( bIsSingleRef )
     {
         const ScSingleRefData& rRef = static_cast<const ScToken&>(rToken).GetSingleRef();
-        rAddress.Set( rRef.nCol, rRef.nRow, rRef.nTab );
+        rAddress = rRef.toAbs(rPos);
         bIsSingleRef = !rRef.IsDeleted();
     }
     return bIsSingleRef;
@@ -795,7 +795,8 @@ inline bool lclGetAddress( ScAddress& rAddress, const FormulaToken& rToken )
 
 } // namespace
 
-bool XclTokenArrayHelper::GetMultipleOpRefs( XclMultipleOpRefs& rRefs, const ScTokenArray& rScTokArr )
+bool XclTokenArrayHelper::GetMultipleOpRefs(
+    XclMultipleOpRefs& rRefs, const ScTokenArray& rScTokArr, const ScAddress& rScPos )
 {
     rRefs.mbDblRefMode = false;
     enum
@@ -817,32 +818,32 @@ bool XclTokenArrayHelper::GetMultipleOpRefs( XclMultipleOpRefs& rRefs, const ScT
                 eState = (eOpCode == ocOpen) ? stOpen : stError;
             break;
             case stOpen:
-                eState = lclGetAddress( rRefs.maFmlaScPos, *aIt ) ? stFormula : stError;
+                eState = lclGetAddress(rRefs.maFmlaScPos, *aIt, rScPos) ? stFormula : stError;
             break;
             case stFormula:
                 eState = bIsSep ? stFormulaSep : stError;
             break;
             case stFormulaSep:
-                eState = lclGetAddress( rRefs.maColFirstScPos, *aIt ) ? stColFirst : stError;
+                eState = lclGetAddress(rRefs.maColFirstScPos, *aIt, rScPos) ? stColFirst : stError;
             break;
             case stColFirst:
                 eState = bIsSep ? stColFirstSep : stError;
             break;
             case stColFirstSep:
-                eState = lclGetAddress( rRefs.maColRelScPos, *aIt ) ? stColRel : stError;
+                eState = lclGetAddress(rRefs.maColRelScPos, *aIt, rScPos) ? stColRel : stError;
             break;
             case stColRel:
                 eState = bIsSep ? stColRelSep : ((eOpCode == ocClose) ? stClose : stError);
             break;
             case stColRelSep:
-                eState = lclGetAddress( rRefs.maRowFirstScPos, *aIt ) ? stRowFirst : stError;
+                eState = lclGetAddress(rRefs.maRowFirstScPos, *aIt, rScPos) ? stRowFirst : stError;
                 rRefs.mbDblRefMode = true;
             break;
             case stRowFirst:
                 eState = bIsSep ? stRowFirstSep : stError;
             break;
             case stRowFirstSep:
-                eState = lclGetAddress( rRefs.maRowRelScPos, *aIt ) ? stRowRel : stError;
+                eState = lclGetAddress(rRefs.maRowRelScPos, *aIt, rScPos) ? stRowRel : stError;
             break;
             case stRowRel:
                 eState = (eOpCode == ocClose) ? stClose : stError;
diff --git a/sc/source/filter/inc/xlformula.hxx b/sc/source/filter/inc/xlformula.hxx
index 7768769..fdf395e 100644
--- a/sc/source/filter/inc/xlformula.hxx
+++ b/sc/source/filter/inc/xlformula.hxx
@@ -537,7 +537,7 @@ public:
         @descr  Requires that the formula contains a single MULTIPLE.OPERATION function call.
         Spaces in the formula are silently ignored.
         @return  true = Multiple operation found, and all references successfully extracted. */
-    static bool         GetMultipleOpRefs( XclMultipleOpRefs& rRefs, const ScTokenArray& rScTokArr );
+    static bool GetMultipleOpRefs( XclMultipleOpRefs& rRefs, const ScTokenArray& rScTokArr, const ScAddress& rScPos );
 };
 
 // ----------------------------------------------------------------------------
diff --git a/sc/source/filter/lotus/tool.cxx b/sc/source/filter/lotus/tool.cxx
index 020b582..3fc0c6e 100644
--- a/sc/source/filter/lotus/tool.cxx
+++ b/sc/source/filter/lotus/tool.cxx
@@ -465,16 +465,16 @@ void LotusRangeList::Append( LotusRange* pLR, const String& rName )
 
     ScSingleRefData*    pSingRef = &aComplRef.Ref1;
 
-    pSingRef->nCol = pLR->nColStart;
-    pSingRef->nRow = pLR->nRowStart;
+    pSingRef->SetAbsCol(pLR->nColStart);
+    pSingRef->SetAbsRow(pLR->nRowStart);
 
     if( pLR->IsSingle() )
         aTokArray.AddSingleReference( *pSingRef );
     else
     {
         pSingRef = &aComplRef.Ref2;
-        pSingRef->nCol = pLR->nColEnd;
-        pSingRef->nRow = pLR->nRowEnd;
+        pSingRef->SetAbsCol(pLR->nColEnd);
+        pSingRef->SetAbsRow(pLR->nRowEnd);
         aTokArray.AddDoubleReference( aComplRef );
     }
 
@@ -515,11 +515,12 @@ void RangeNameBufferWK3::Add( const String& rOrgName, const ScComplexRefData& rC
 
     const ScSingleRefData& rRef1 = rCRD.Ref1;
     const ScSingleRefData& rRef2 = rCRD.Ref2;
-
-    if( rRef1.nCol == rRef2.nCol && rRef1.nRow == rRef2.nRow && rRef1.nTab == rRef2.nTab )
+    ScAddress aAbs1 = rRef1.toAbs(ScAddress());
+    ScAddress aAbs2 = rRef2.toAbs(ScAddress());
+    if (aAbs1 == aAbs2)
     {
         pScTokenArray->AddSingleReference( rCRD.Ref1 );
-        aInsert.bSingleRef = sal_True;
+        aInsert.bSingleRef = true;
     }
     else
     {


More information about the Libreoffice-commits mailing list