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

Kohei Yoshida kohei.yoshida at gmail.com
Mon Jul 15 22:36:47 PDT 2013


 sc/inc/tokenarray.hxx               |    6 +++---
 sc/source/core/data/formulaiter.cxx |   17 ++++++-----------
 sc/source/core/data/validat.cxx     |    3 +--
 sc/source/core/tool/rangenam.cxx    |   14 +++-----------
 sc/source/core/tool/token.cxx       |   20 ++++++++++----------
 sc/source/filter/excel/xiname.cxx   |    4 ++--
 sc/source/ui/vba/vbanames.cxx       |    2 +-
 7 files changed, 26 insertions(+), 40 deletions(-)

New commits:
commit 4e9d0c5ee1918a8ea730372d43c742ed687bb983
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Tue Jul 16 01:37:01 2013 -0400

    More of the same.
    
    Change-Id: I6a5f94723b5efb916abc88d0de9f972e142199df

diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index 4582c96..726dac6 100644
--- a/sc/inc/tokenarray.hxx
+++ b/sc/inc/tokenarray.hxx
@@ -34,7 +34,7 @@ class SC_DLLPUBLIC ScTokenArray : public formula::FormulaTokenArray
 {
     friend class ScCompiler;
 
-    bool                    ImplGetReference( ScRange& rRange, bool bValidOnly ) const;
+    bool ImplGetReference( ScRange& rRange, const ScAddress& rPos, bool bValidOnly ) const;
 
     size_t mnHashValue;
     ScFormulaVectorState meVectorState;
@@ -52,9 +52,9 @@ public:
     ScFormulaVectorState GetVectorState() const;
 
     /// Exactly and only one range (valid or deleted)
-    bool    IsReference( ScRange& rRange ) const;
+    bool IsReference( ScRange& rRange, const ScAddress& rPos ) const;
     /// Exactly and only one valid range (no #REF!s)
-    bool    IsValidReference( ScRange& rRange ) const;
+    bool IsValidReference( ScRange& rRange, const ScAddress& rPos ) const;
 
 
                             /** Determines the extent of direct adjacent
diff --git a/sc/source/core/data/formulaiter.cxx b/sc/source/core/data/formulaiter.cxx
index 5a7152d..f14817d 100644
--- a/sc/source/core/data/formulaiter.cxx
+++ b/sc/source/core/data/formulaiter.cxx
@@ -32,17 +32,17 @@ ScDetectiveRefIter::ScDetectiveRefIter( ScFormulaCell* pCell )
     aPos = pCell->aPos;
 }
 
-static bool lcl_ScDetectiveRefIter_SkipRef( ScToken* p )
+static bool lcl_ScDetectiveRefIter_SkipRef( ScToken* p, const ScAddress& rPos )
 {
     ScSingleRefData& rRef1 = p->GetSingleRef();
-    if ( rRef1.IsColDeleted() || rRef1.IsRowDeleted() || rRef1.IsTabDeleted()
-            || !rRef1.Valid() )
+    ScAddress aAbs1 = rRef1.toAbs(rPos);
+    if (!ValidAddress(aAbs1))
         return true;
     if ( p->GetType() == svDoubleRef || p->GetType() == svExternalDoubleRef )
     {
         ScSingleRefData& rRef2 = p->GetDoubleRef().Ref2;
-        if ( rRef2.IsColDeleted() || rRef2.IsRowDeleted() || rRef2.IsTabDeleted()
-                || !rRef2.Valid() )
+        ScAddress aAbs2 = rRef2.toAbs(rPos);
+        if (!ValidAddress(aAbs2))
             return true;
     }
     return false;
@@ -66,14 +66,9 @@ bool ScDetectiveRefIter::GetNextRef( ScRange& rRange )
 ScToken* ScDetectiveRefIter::GetNextRefToken()
 {
     ScToken* p = static_cast<ScToken*>(pCode->GetNextReferenceRPN());
-    if (p)
-        p->CalcAbsIfRel( aPos );
-
-    while ( p && lcl_ScDetectiveRefIter_SkipRef( p ) )
+    while (p && lcl_ScDetectiveRefIter_SkipRef(p, aPos))
     {
         p = static_cast<ScToken*>(pCode->GetNextReferenceRPN());
-        if (p)
-            p->CalcAbsIfRel( aPos );
     }
     return p;
 }
diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index 4d72c98..ea65bb5 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -704,8 +704,7 @@ bool ScValidationData::GetSelectionFromFormula(
         }
         else if (t->GetType() != svIndex)
         {
-            t->CalcAbsIfRel(rPos);
-            if (pArr->IsValidReference(aRange))
+            if (pArr->IsValidReference(aRange, rPos))
             {
                 bRef = true;
             }
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index 4d81099..42662ae 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -387,7 +387,7 @@ bool ScRangeData::IsRangeAtBlock( const ScRange& rBlock ) const
 bool ScRangeData::IsReference( ScRange& rRange ) const
 {
     if ( (eType & ( RT_ABSAREA | RT_REFAREA | RT_ABSPOS )) && pCode )
-        return pCode->IsReference( rRange );
+        return pCode->IsReference(rRange, aPos);
 
     return false;
 }
@@ -395,15 +395,7 @@ bool ScRangeData::IsReference( ScRange& rRange ) const
 bool ScRangeData::IsReference( ScRange& rRange, const ScAddress& rPos ) const
 {
     if ( (eType & ( RT_ABSAREA | RT_REFAREA | RT_ABSPOS ) ) && pCode )
-    {
-        SAL_WNODEPRECATED_DECLARATIONS_PUSH
-        ::std::auto_ptr<ScTokenArray> pTemp( pCode->Clone() );
-        SAL_WNODEPRECATED_DECLARATIONS_POP
-        ScCompiler aComp( pDoc, rPos, *pTemp);
-        aComp.SetGrammar(pDoc->GetGrammar());
-        aComp.MoveRelWrap(MAXCOL, MAXROW);
-        return pTemp->IsReference( rRange );
-    }
+        return pCode->IsReference(rRange, rPos);
 
     return false;
 }
@@ -411,7 +403,7 @@ bool ScRangeData::IsReference( ScRange& rRange, const ScAddress& rPos ) const
 bool ScRangeData::IsValidReference( ScRange& rRange ) const
 {
     if ( (eType & ( RT_ABSAREA | RT_REFAREA | RT_ABSPOS ) ) && pCode )
-        return pCode->IsValidReference( rRange );
+        return pCode->IsValidReference(rRange, aPos);
 
     return false;
 }
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 5dccc7c..8cc5313 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1364,7 +1364,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
     }
 }
 
-bool ScTokenArray::ImplGetReference( ScRange& rRange, bool bValidOnly ) const
+bool ScTokenArray::ImplGetReference( ScRange& rRange, const ScAddress& rPos, bool bValidOnly ) const
 {
     bool bIs = false;
     if ( pCode && nLen == 1 )
@@ -1375,17 +1375,17 @@ bool ScTokenArray::ImplGetReference( ScRange& rRange, bool bValidOnly ) const
             if ( pToken->GetType() == svSingleRef )
             {
                 const ScSingleRefData& rRef = ((const ScSingleRefToken*)pToken)->GetSingleRef();
-                rRange.aStart = rRange.aEnd = ScAddress( rRef.nCol, rRef.nRow, rRef.nTab );
-                bIs = !bValidOnly || !rRef.IsDeleted();
+                rRange.aStart = rRange.aEnd = rRef.toAbs(rPos);
+                bIs = !bValidOnly || ValidAddress(rRange.aStart);
             }
             else if ( pToken->GetType() == svDoubleRef )
             {
                 const ScComplexRefData& rCompl = ((const ScDoubleRefToken*)pToken)->GetDoubleRef();
                 const ScSingleRefData& rRef1 = rCompl.Ref1;
                 const ScSingleRefData& rRef2 = rCompl.Ref2;
-                rRange.aStart = ScAddress( rRef1.nCol, rRef1.nRow, rRef1.nTab );
-                rRange.aEnd   = ScAddress( rRef2.nCol, rRef2.nRow, rRef2.nTab );
-                bIs = !bValidOnly || (!rRef1.IsDeleted() && !rRef2.IsDeleted());
+                rRange.aStart = rRef1.toAbs(rPos);
+                rRange.aEnd   = rRef2.toAbs(rPos);
+                bIs = !bValidOnly || ValidRange(rRange);
             }
         }
     }
@@ -1489,14 +1489,14 @@ ScFormulaVectorState ScTokenArray::GetVectorState() const
     return meVectorState;
 }
 
-bool ScTokenArray::IsReference( ScRange& rRange ) const
+bool ScTokenArray::IsReference( ScRange& rRange, const ScAddress& rPos ) const
 {
-    return ImplGetReference( rRange, false );
+    return ImplGetReference(rRange, rPos, false);
 }
 
-bool ScTokenArray::IsValidReference( ScRange& rRange ) const
+bool ScTokenArray::IsValidReference( ScRange& rRange, const ScAddress& rPos ) const
 {
-    return ImplGetReference( rRange, true );
+    return ImplGetReference(rRange, rPos, true);
 }
 
 ////////////////////////////////////////////////////////////////////////////
diff --git a/sc/source/filter/excel/xiname.cxx b/sc/source/filter/excel/xiname.cxx
index 4eb6af7..c3a39c2 100644
--- a/sc/source/filter/excel/xiname.cxx
+++ b/sc/source/filter/excel/xiname.cxx
@@ -174,7 +174,7 @@ XclImpName::XclImpName( XclImpStream& rStrm, sal_uInt16 nXclNameIdx ) :
         if( (GetBiff() == EXC_BIFF8) && pTokArr && bBuiltIn )
         {
             ScRange aRange;
-            if( pTokArr->IsReference( aRange ) )
+            if (pTokArr->IsReference(aRange, ScAddress()))
             {
                 switch( mcBuiltIn )
                 {
@@ -186,7 +186,7 @@ XclImpName::XclImpName( XclImpStream& rStrm, sal_uInt16 nXclNameIdx ) :
                         meNameType |= RT_CRITERIA;
                     break;
                     case EXC_BUILTIN_EXTRACT:
-                        if( pTokArr->IsValidReference( aRange ) )
+                        if (pTokArr->IsValidReference(aRange, ScAddress()))
                             GetFilterManager().AddExtractPos( aRange );
                     break;
                 }
diff --git a/sc/source/ui/vba/vbanames.cxx b/sc/source/ui/vba/vbanames.cxx
index 4abdd11..c0a9615 100644
--- a/sc/source/ui/vba/vbanames.cxx
+++ b/sc/source/ui/vba/vbanames.cxx
@@ -163,7 +163,7 @@ ScVbaNames::Add( const css::uno::Any& Name ,
             {
                 ScRange aRange;
                 ScDocShell* pDocSh = excel::getDocShell(getModel());
-                if ( pTokens->IsValidReference( aRange ) )
+                if (pTokens->IsValidReference(aRange, aBlank))
                     xUnoRange =  new ScCellRangeObj( pDocSh, aRange );
                 else
                 {


More information about the Libreoffice-commits mailing list