[Libreoffice-commits] .: sc/inc sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Tue Dec 21 14:43:44 PST 2010


 sc/inc/token.hxx                 |   13 ++++++++++++-
 sc/source/core/data/cell.cxx     |    8 ++++----
 sc/source/core/tool/compiler.cxx |    2 +-
 sc/source/core/tool/interpr1.cxx |    8 ++++----
 sc/source/core/tool/interpr2.cxx |   10 +++++-----
 sc/source/core/tool/interpr4.cxx |   10 +++++-----
 sc/source/core/tool/token.cxx    |    2 +-
 7 files changed, 32 insertions(+), 21 deletions(-)

New commits:
commit a2619bdd9b199d32911800fd38f264af909fcf7b
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Tue Dec 21 17:42:05 2010 -0500

    Adjusted for the new FormulaTokenRef now implemented by intrusive_ptr.
    
    Also, ScTokenRef is similarly now implemented by intrusive_ptr.

diff --git a/sc/inc/token.hxx b/sc/inc/token.hxx
index 68ab308..70fa424 100644
--- a/sc/inc/token.hxx
+++ b/sc/inc/token.hxx
@@ -32,6 +32,7 @@
 #include <memory>
 #include <vector>
 #include <boost/shared_ptr.hpp>
+#include <boost/intrusive_ptr.hpp>
 
 #include "formula/opcode.hxx"
 #include "refdata.hxx"
@@ -47,7 +48,7 @@ class ScJumpMatrix;
 class ScToken;
 
 typedef ::std::vector< ScComplexRefData > ScRefList;
-typedef formula::SimpleIntrusiveReference< class ScToken > ScTokenRef;
+typedef ::boost::intrusive_ptr<ScToken> ScTokenRef;
 
 /** 
  * Another ref-counted token type using shared_ptr.  <b>Be extra careful 
@@ -122,6 +123,16 @@ public:
     static  formula::FormulaTokenRef          ExtendRangeReference( formula::FormulaToken & rTok1, formula::FormulaToken & rTok2, const ScAddress & rPos, bool bReuseDoubleRef );
 };
 
+inline void intrusive_ptr_add_ref(const ScToken* p)
+{
+    p->IncRef();
+}
+
+inline void intrusive_ptr_release(const ScToken* p)
+{
+    p->DecRef();
+}
+
 class ScSingleRefToken : public ScToken
 {
 private:
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index f5037c2..aabf096 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -1648,7 +1648,7 @@ void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam )
 
             if ( !bContentChanged && pDocument->IsStreamValid(aPos.Tab()) )
             {
-                ScFormulaResult aNewResult( p->GetResultToken());
+                ScFormulaResult aNewResult( p->GetResultToken().get());
                 StackVar eOld = aResult.GetCellResultType();
                 StackVar eNew = aNewResult.GetCellResultType();
                 if ( eOld == svUnknown && ( eNew == svError || ( eNew == svDouble && aNewResult.GetDouble() == 0.0 ) ) )
@@ -1668,11 +1668,11 @@ void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam )
                 }
             }
 
-            aResult.SetToken( p->GetResultToken() );
+            aResult.SetToken( p->GetResultToken().get() );
         }
         else
         {
-            ScFormulaResult aNewResult( p->GetResultToken());
+            ScFormulaResult aNewResult( p->GetResultToken().get());
             StackVar eOld = aResult.GetCellResultType();
             StackVar eNew = aNewResult.GetCellResultType();
             bChanged = (eOld != eNew ||
@@ -1721,7 +1721,7 @@ void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam )
             // If the formula wasn't entered as a matrix formula, live on with
             // the upper left corner and let reference counting delete the matrix.
             if( cMatrixFlag != MM_FORMULA && !pCode->IsHyperLink() )
-                aResult.SetToken( aResult.GetCellResultToken());
+                aResult.SetToken( aResult.GetCellResultToken().get());
         }
         if ( aResult.IsValue() && !::rtl::math::isFinite( aResult.GetDouble() ) )
         {
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index 5e743c5..d12e2cc 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -5260,7 +5260,7 @@ void ScCompiler::fillAddInToken(::std::vector< ::com::sun::star::sheet::FormulaO
 // -----------------------------------------------------------------------------
 BOOL ScCompiler::HandleSingleRef()
 {
-    ScSingleRefData& rRef = static_cast<ScToken*>((FormulaToken*)pToken)->GetSingleRef();
+    ScSingleRefData& rRef = static_cast<ScToken*>(pToken.get())->GetSingleRef();
     rRef.CalcAbsIfRel( aPos );
     if ( !rRef.Valid() )
     {
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index ab698a4..1c890b5 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -179,7 +179,7 @@ void ScInterpreter::ScIfJump()
                     xNew = new ScJumpMatrixToken( pJumpMat );
                     GetTokenMatrixMap().insert( ScTokenMatrixMap::value_type(pCur, xNew));
                 }
-                PushTempToken( xNew);
+                PushTempToken( xNew.get());
                 // set endpoint of path for main code line
                 aCode.Jump( pJump[ nJumpCount ], pJump[ nJumpCount ] );
             }
@@ -293,7 +293,7 @@ void ScInterpreter::ScChoseJump()
                     GetTokenMatrixMap().insert( ScTokenMatrixMap::value_type(
                                 pCur, xNew));
                 }
-                PushTempToken( xNew);
+                PushTempToken( xNew.get());
                 // set endpoint of path for main code line
                 aCode.Jump( pJump[ nJumpCount ], pJump[ nJumpCount ] );
                 bHaveJump = true;
@@ -7347,7 +7347,7 @@ void ScInterpreter::ScText()
                     FormulaTokenRef xTok( PopToken());
                     if (!nGlobalError)
                     {
-                        PushTempToken( xTok);
+                        PushTempToken( xTok.get());
                         // Temporarily override the ConvertStringToValue()
                         // error for GetCellValue() / GetCellValueOrZero()
                         USHORT nSErr = mnStringNoValueError;
@@ -7358,7 +7358,7 @@ void ScInterpreter::ScText()
                         {
                             // Not numeric.
                             nGlobalError = 0;
-                            PushTempToken( xTok);
+                            PushTempToken( xTok.get());
                             aStr = GetString();
                             bString = true;
                         }
diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index 7c37084..40d7fcc 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -1895,7 +1895,7 @@ void ScInterpreter::ScIntersect()
                 PushTempToken( new ScDoubleRefToken( rRef));
         }
         else
-            PushTempToken( xRes);
+            PushTempToken( xRes.get());
     }
     else
     {
@@ -1966,7 +1966,7 @@ void ScInterpreter::ScRangeFunc()
     if (!xRes)
         PushIllegalArgument();
     else
-        PushTempToken( xRes);
+        PushTempToken( xRes.get());
 }
 
 
@@ -2044,7 +2044,7 @@ void ScInterpreter::ScUnionFunc()
         }
     }
     ValidateRef( *pRes);    // set #REF! if needed
-    PushTempToken( xRes);
+    PushTempToken( xRes.get());
 }
 
 
@@ -2054,8 +2054,8 @@ void ScInterpreter::ScCurrent()
     FormulaTokenRef xTok( PopToken());
     if (xTok)
     {
-        PushTempToken( xTok);
-        PushTempToken( xTok);
+        PushTempToken( xTok.get());
+        PushTempToken( xTok.get());
     }
     else
         PushError( errUnknownStackVariable);
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 31e9854..8d20022 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -1733,7 +1733,7 @@ bool ScInterpreter::ConvertMatrixParameters()
             GetTokenMatrixMap().insert( ScTokenMatrixMap::value_type( pCur,
                         xNew));
         }
-        PushTempToken( xNew);
+        PushTempToken( xNew.get());
         // set continuation point of path for main code line
         aCode.Jump( nNext, nNext);
         return true;
@@ -1783,14 +1783,14 @@ void ScInterpreter::QueryMatrixType(ScMatrixRef& xMat, short& rRetTypeExpr, ULON
             if ( xMat->IsEmptyPath( 0, 0))
             {   // result of empty FALSE jump path
                 FormulaTokenRef xRes = new FormulaDoubleToken( 0.0);
-                PushTempToken( new ScMatrixCellResultToken( xMat, xRes));
+                PushTempToken( new ScMatrixCellResultToken( xMat, xRes.get()));
                 rRetTypeExpr = NUMBERFORMAT_LOGICAL;
             }
             else
             {
                 String aStr( nMatVal.GetString());
                 FormulaTokenRef xRes = new FormulaStringToken( aStr);
-                PushTempToken( new ScMatrixCellResultToken( xMat, xRes));
+                PushTempToken( new ScMatrixCellResultToken( xMat, xRes.get()));
                 rRetTypeExpr = NUMBERFORMAT_TEXT;
             }
         }
@@ -1802,7 +1802,7 @@ void ScInterpreter::QueryMatrixType(ScMatrixRef& xMat, short& rRetTypeExpr, ULON
                 xRes = new FormulaErrorToken( nErr);
             else
                 xRes = new FormulaDoubleToken( nMatVal.fVal);
-            PushTempToken( new ScMatrixCellResultToken( xMat, xRes));
+            PushTempToken( new ScMatrixCellResultToken( xMat, xRes.get()));
             if ( rRetTypeExpr != NUMBERFORMAT_LOGICAL )
                 rRetTypeExpr = NUMBERFORMAT_NUMBER;
         }
@@ -3660,7 +3660,7 @@ StackVar ScInterpreter::Interpret()
             if ( nStackBase > sp )
                 nStackBase = sp;        // underflow?!?
             sp = nStackBase;
-            PushTempToken( (*aTokenMatrixMapIter).second);
+            PushTempToken( (*aTokenMatrixMapIter).second.get());
         }
         else
         {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 5dc7877..9dc0efc 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1551,7 +1551,7 @@ FormulaToken* ScTokenArray::MergeRangeReference( const ScAddress & rPos )
             p2->DecRef();
             p3->DecRef();
             nLen -= 2;
-            pCode[ nLen-1 ] = p;
+            pCode[ nLen-1 ] = p.get();
             nRefs--;
         }
     }


More information about the Libreoffice-commits mailing list