[Libreoffice-commits] .: Branch 'feature/calc-matrix-rework' - sc/inc sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Thu Dec 16 23:00:32 PST 2010


 sc/inc/addincol.hxx                         |    2 -
 sc/inc/document.hxx                         |    7 ++--
 sc/inc/scmatrix.hxx                         |   17 +++++++---
 sc/inc/token.hxx                            |    4 +-
 sc/inc/tokenarray.hxx                       |    3 +
 sc/source/core/data/cell.cxx                |    2 -
 sc/source/core/data/cell2.cxx               |    4 +-
 sc/source/core/data/documen8.cxx            |    4 +-
 sc/source/core/data/validat.cxx             |    2 -
 sc/source/core/inc/ddelink.hxx              |    4 +-
 sc/source/core/inc/interpre.hxx             |    8 ++--
 sc/source/core/inc/jumpmatrix.hxx           |    2 -
 sc/source/core/tool/addincol.cxx            |   15 +++------
 sc/source/core/tool/ddelink.cxx             |    4 +-
 sc/source/core/tool/interpr1.cxx            |    2 -
 sc/source/core/tool/interpr4.cxx            |   12 +++----
 sc/source/core/tool/interpr5.cxx            |   46 ++++++++++++----------------
 sc/source/core/tool/rangeseq.cxx            |   13 +++----
 sc/source/core/tool/token.cxx               |    8 ++--
 sc/source/filter/excel/excform.cxx          |    2 -
 sc/source/filter/xml/XMLDDELinksContext.cxx |    2 -
 sc/source/ui/docshell/externalrefmgr.cxx    |    9 +----
 sc/source/ui/unoobj/linkuno.cxx             |    2 -
 23 files changed, 87 insertions(+), 87 deletions(-)

New commits:
commit bfb303dadd859fcde5170f77adff15f9c1a75504
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Fri Dec 17 01:59:24 2010 -0500

    Implemented ScMatrixRef using boost::intrusive_ptr.

diff --git a/sc/inc/addincol.hxx b/sc/inc/addincol.hxx
index 7055f70..d67df1e 100644
--- a/sc/inc/addincol.hxx
+++ b/sc/inc/addincol.hxx
@@ -231,7 +231,7 @@ public:
 
     USHORT				GetErrCode() const		{ return nErrCode; }
     BOOL				HasString() const		{ return bHasString; }
-    BOOL				HasMatrix() const		{ return ( xMatrix.Is() ); }
+    bool                HasMatrix() const       { return xMatrix.get(); }
     BOOL				HasVarRes() const		{ return ( xVarRes.is() ); }
     double				GetValue() const		{ return fValue; }
     const String&		GetString() const		{ return aString; }
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 0a0f4e2..c7d792e 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -35,8 +35,9 @@
 #include <com/sun/star/uno/Reference.hxx>
 #include <rtl/ref.hxx>
 #include "scdllapi.h"
-#include "table.hxx"		// FastGetRowHeight (inline)
 #include "rangelst.hxx"
+#include "table.hxx"
+#include "scmatrix.hxx"
 #include "brdcst.hxx"
 #include "tabopparams.hxx"
 #include "formula/grammar.hxx"
@@ -681,12 +682,12 @@ public:
     /** Tries to find a DDE link or creates a new, if not extant.
         @param pResults  If not 0, sets the matrix as as DDE link result matrix (also for existing links).
         @return  true = DDE link found; false = Unpredictable error occurred, no DDE link created. */
-    SC_DLLPUBLIC bool            CreateDdeLink( const String& rAppl, const String& rTopic, const String& rItem, BYTE nMode, ScMatrix* pResults = NULL );
+    SC_DLLPUBLIC bool            CreateDdeLink( const String& rAppl, const String& rTopic, const String& rItem, BYTE nMode, ScMatrixRef pResults );
     /** Sets a result matrix for the specified DDE link.
         @param nDdePos  Index of the DDE link (does not include other links from link manager).
         @param pResults  The array containing all results of the DDE link (intrusive-ref-counted, do not delete).
         @return  true = DDE link found and matrix set. */
-    bool            SetDdeLinkResultMatrix( USHORT nDdePos, ScMatrix* pResults );
+    bool            SetDdeLinkResultMatrix( USHORT nDdePos, ScMatrixRef pResults );
 
 
     SfxBindings*	GetViewBindings();
diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index 6372c3c..5f9b9c9 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -30,11 +30,12 @@
 #define SC_MATRIX_HXX
 
 #include "global.hxx"
-#include "formula/intruref.hxx"
 #include "formula/errorcodes.hxx"
 #include <tools/string.hxx>
 #include "scdllapi.h"
 
+#include <boost/intrusive_ptr.hpp>
+
 class SvStream;
 class ScInterpreter;
 class SvNumberFormatter;
@@ -134,7 +135,7 @@ struct ScMatrixValue
 class SC_DLLPUBLIC ScMatrix
 {
     ScMatrixImpl*   pImpl;
-    mutable ULONG   nRefCnt;    // reference count
+    mutable size_t  nRefCnt;    // reference count
 
     // only delete via Delete()
     ~ScMatrix();
@@ -355,10 +356,18 @@ public:
     // to be numerically safe.
 };
 
+inline void intrusive_ptr_add_ref(const ScMatrix* p)
+{
+    p->IncRef();
+}
 
-typedef formula::SimpleIntrusiveReference< class ScMatrix > ScMatrixRef;
-typedef formula::SimpleIntrusiveReference< const class ScMatrix > ScConstMatrixRef;
+inline void intrusive_ptr_release(const ScMatrix* p)
+{
+    p->DecRef();
+}
 
+typedef ::boost::intrusive_ptr<ScMatrix> ScMatrixRef;
+typedef ::boost::intrusive_ptr<const ScMatrix> ScConstMatrixRef;
 
 #endif  // SC_MATRIX_HXX
 
diff --git a/sc/inc/token.hxx b/sc/inc/token.hxx
index 424e1e4..68ab308 100644
--- a/sc/inc/token.hxx
+++ b/sc/inc/token.hxx
@@ -175,7 +175,7 @@ class ScMatrixToken : public ScToken
 private:
             ScMatrixRef         pMatrix;
 public:
-                                ScMatrixToken( ScMatrix* p ) :
+                                ScMatrixToken( ScMatrixRef p ) :
                                     ScToken( formula::svMatrix ), pMatrix( p ) {}
                                 ScMatrixToken( const ScMatrixToken& r ) :
                                     ScToken( r ), pMatrix( r.pMatrix ) {}
@@ -327,7 +327,7 @@ protected:
             ScConstMatrixRef    xMatrix;
             formula::FormulaConstTokenRef     xUpperLeft;
 public:
-                                ScMatrixCellResultToken( ScMatrix* pMat, formula::FormulaToken* pUL ) :
+                                ScMatrixCellResultToken( const ScConstMatrixRef& pMat, formula::FormulaToken* pUL ) :
                                     ScToken( formula::svMatrixCell ),
                                     xMatrix( pMat), xUpperLeft( pUL) {}
                                 ScMatrixCellResultToken( const ScMatrixCellResultToken& r ) :
diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index 62be11a..686ba41 100644
--- a/sc/inc/tokenarray.hxx
+++ b/sc/inc/tokenarray.hxx
@@ -30,6 +30,7 @@
 #define SC_TOKENARRAY_HXX
 
 #include "formula/token.hxx"
+#include "scmatrix.hxx"
 #include <tools/solar.h>
 #include "scdllapi.h"
 #include <formula/tokenarray.hxx>
@@ -74,7 +75,7 @@ public:
     formula::FormulaToken* AddExternalName( sal_uInt16 nFileId, const String& rName );
     formula::FormulaToken* AddExternalSingleReference( sal_uInt16 nFileId, const String& rTabName, const ScSingleRefData& rRef );
     formula::FormulaToken* AddExternalDoubleReference( sal_uInt16 nFileId, const String& rTabName, const ScComplexRefData& rRef );
-    formula::FormulaToken* AddMatrix( ScMatrix* p );
+    formula::FormulaToken* AddMatrix( const ScMatrixRef& p );
     /** ScSingleRefOpToken with ocColRowName. */
     formula::FormulaToken* AddColRowName( const ScSingleRefData& rRef );
     virtual formula::FormulaToken* MergeArray( );
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index 2724df1..f5037c2 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -1716,7 +1716,7 @@ void ScFormulaCell::InterpretTail( ScInterpretTailParameter eTailParam )
             bDirty = FALSE;
             bTableOpDirty = FALSE;
         }
-        if( aResult.GetMatrix().Is() )
+        if( aResult.GetMatrix() )
         {
             // If the formula wasn't entered as a matrix formula, live on with
             // the upper left corner and let reference counting delete the matrix.
diff --git a/sc/source/core/data/cell2.cxx b/sc/source/core/data/cell2.cxx
index a83a63f..82dd020 100644
--- a/sc/source/core/data/cell2.cxx
+++ b/sc/source/core/data/cell2.cxx
@@ -538,12 +538,12 @@ const ScMatrix* ScFormulaCell::GetMatrix()
     {
         // Was stored !bDirty but an accompanying matrix cell was bDirty?
         // => we need to get the matrix.
-        if (!bDirty && cMatrixFlag == MM_FORMULA && !aResult.GetMatrix().Is())
+        if (!bDirty && cMatrixFlag == MM_FORMULA && !aResult.GetMatrix())
             bDirty = TRUE;
         if ( IsDirtyOrInTableOpDirty() )
             Interpret();
     }
-    return aResult.GetMatrix();
+    return aResult.GetMatrix().get();
 }
 
 BOOL ScFormulaCell::GetMatrixOrigin( ScAddress& rPos ) const
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index 1e9b4e1..ffc41b6 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -1286,7 +1286,7 @@ const ScMatrix* ScDocument::GetDdeLinkResultMatrix( USHORT nDdePos ) const
     return pDdeLink ? pDdeLink->GetResult() : NULL;
 }
 
-bool ScDocument::CreateDdeLink( const String& rAppl, const String& rTopic, const String& rItem, BYTE nMode, ScMatrix* pResults )
+bool ScDocument::CreateDdeLink( const String& rAppl, const String& rTopic, const String& rItem, BYTE nMode, ScMatrixRef pResults )
 {
     /*  Create a DDE link without updating it (i.e. for Excel import), to prevent
         unwanted connections. First try to find existing link. Set result array
@@ -1312,7 +1312,7 @@ bool ScDocument::CreateDdeLink( const String& rAppl, const String& rTopic, const
     return false;
 }
 
-bool ScDocument::SetDdeLinkResultMatrix( USHORT nDdePos, ScMatrix* pResults )
+bool ScDocument::SetDdeLinkResultMatrix( USHORT nDdePos, ScMatrixRef pResults )
 {
     if( ScDdeLink* pDdeLink = lclGetDdeLink( GetLinkManager(), nDdePos ) )
     {
diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index 26789aa..051a349 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -672,7 +672,7 @@ bool ScValidationData::GetSelectionFromFormula( TypedScStrCollection* pStrings,
             xMatRef->PutString( aStr, 0);
         }
 
-        pValues = xMatRef;
+        pValues = xMatRef.get();
     }
 
     // which index matched.  We will want it eventually to pre-select that item.
diff --git a/sc/source/core/inc/ddelink.hxx b/sc/source/core/inc/ddelink.hxx
index 48b9276..289fae7 100644
--- a/sc/source/core/inc/ddelink.hxx
+++ b/sc/source/core/inc/ddelink.hxx
@@ -76,8 +76,8 @@ public:
 
                                             // fuer Interpreter:
 
-    const ScMatrix* GetResult() const           { return pResult; }
-    void            SetResult( ScMatrix* pRes ) { pResult = pRes; }
+    const ScMatrix* GetResult() const           { return pResult.get(); }
+    void            SetResult( ScMatrixRef pRes ) { pResult = pRes; }
 
                                             // XML and Excel import after NewData()
     ScMatrixRef     GetModifiableResult()   { return pResult; }
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 07f95ba..91fcb31 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -340,7 +340,7 @@ void PushExternalSingleRef(sal_uInt16 nFileId, const String& rTabName,
 void PushExternalDoubleRef(sal_uInt16 nFileId, const String& rTabName,
                            SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
                            SCCOL nCol2, SCROW nRow2, SCTAB nTab2);
-void PushMatrix(ScMatrix* pMat);
+void PushMatrix(const ScMatrixRef& pMat);
 void PushError( USHORT nError );
 /// Raw stack type without default replacements.
 formula::StackVar GetRawStackType();
@@ -400,7 +400,7 @@ double Compare();
         NULL means case sensitivity document option is to be used!
  */
 ScMatrixRef CompareMat( ScCompareOptions* pOptions = NULL );
-ScMatrixRef QueryMat( ScMatrix* pMat, ScCompareOptions& rOptions );
+ScMatrixRef QueryMat( const ScMatrixRef& pMat, ScCompareOptions& rOptions );
 void ScEqual();
 void ScNotEqual();
 void ScLess();
@@ -663,14 +663,14 @@ void ScLCM();
 //-------------------------- Matrixfunktionen ---------------------------------
 
 void ScMatValue();
-void MEMat(ScMatrix* mM, SCSIZE n);
+void MEMat(const ScMatrixRef& mM, SCSIZE n);
 void ScMatDet();
 void ScMatInv();
 void ScMatMult();
 void ScMatTrans();
 void ScEMat();
 void ScMatRef();
-ScMatrixRef MatConcat(ScMatrix* pMat1, ScMatrix* pMat2);
+ScMatrixRef MatConcat(const ScMatrixRef& pMat1, const ScMatrixRef& pMat2);
 void ScSumProduct();
 void ScSumX2MY2();
 void ScSumX2DY2();
diff --git a/sc/source/core/inc/jumpmatrix.hxx b/sc/source/core/inc/jumpmatrix.hxx
index 351cbc6..46fe43f 100644
--- a/sc/source/core/inc/jumpmatrix.hxx
+++ b/sc/source/core/inc/jumpmatrix.hxx
@@ -162,7 +162,7 @@ public:
             void                SetJumpParameters( ScTokenVec* p )
                                     { pParams = p; }
             const ScTokenVec*   GetJumpParameters() const { return pParams; }
-            ScMatrix*           GetResultMatrix() const { return pMat; }
+            ScMatrix*           GetResultMatrix() const { return pMat.get(); }
             void                GetPos( SCSIZE& rCol, SCSIZE& rRow ) const
                                     {
                                         rCol = nCurCol;
diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx
index 16891aa..ed7eb29 100644
--- a/sc/source/core/tool/addincol.cxx
+++ b/sc/source/core/tool/addincol.cxx
@@ -1668,17 +1668,16 @@ void ScUnoAddInCall::SetResult( const uno::Any& rNewRes )
                         xMatrix = new ScMatrix(
                                 static_cast<SCSIZE>(nMaxColCount),
                                 static_cast<SCSIZE>(nRowCount) );
-                        ScMatrix* pMatrix = xMatrix;
                         for (nRow=0; nRow<nRowCount; nRow++)
                         {
                             long nColCount = pRowArr[nRow].getLength();
                             const INT32* pColArr = pRowArr[nRow].getConstArray();
                             for (nCol=0; nCol<nColCount; nCol++)
-                                pMatrix->PutDouble( pColArr[nCol],
+                                xMatrix->PutDouble( pColArr[nCol],
                                         static_cast<SCSIZE>(nCol),
                                         static_cast<SCSIZE>(nRow) );
                             for (nCol=nColCount; nCol<nMaxColCount; nCol++)
-                                pMatrix->PutDouble( 0.0,
+                                xMatrix->PutDouble( 0.0,
                                         static_cast<SCSIZE>(nCol),
                                         static_cast<SCSIZE>(nRow) );
                         }
@@ -1711,17 +1710,16 @@ void ScUnoAddInCall::SetResult( const uno::Any& rNewRes )
                         xMatrix = new ScMatrix(
                                 static_cast<SCSIZE>(nMaxColCount),
                                 static_cast<SCSIZE>(nRowCount) );
-                        ScMatrix* pMatrix = xMatrix;
                         for (nRow=0; nRow<nRowCount; nRow++)
                         {
                             long nColCount = pRowArr[nRow].getLength();
                             const double* pColArr = pRowArr[nRow].getConstArray();
                             for (nCol=0; nCol<nColCount; nCol++)
-                                pMatrix->PutDouble( pColArr[nCol],
+                                xMatrix->PutDouble( pColArr[nCol],
                                         static_cast<SCSIZE>(nCol),
                                         static_cast<SCSIZE>(nRow) );
                             for (nCol=nColCount; nCol<nMaxColCount; nCol++)
-                                pMatrix->PutDouble( 0.0,
+                                xMatrix->PutDouble( 0.0,
                                         static_cast<SCSIZE>(nCol),
                                         static_cast<SCSIZE>(nRow) );
                         }
@@ -1754,17 +1752,16 @@ void ScUnoAddInCall::SetResult( const uno::Any& rNewRes )
                         xMatrix = new ScMatrix(
                                 static_cast<SCSIZE>(nMaxColCount),
                                 static_cast<SCSIZE>(nRowCount) );
-                        ScMatrix* pMatrix = xMatrix;
                         for (nRow=0; nRow<nRowCount; nRow++)
                         {
                             long nColCount = pRowArr[nRow].getLength();
                             const rtl::OUString* pColArr = pRowArr[nRow].getConstArray();
                             for (nCol=0; nCol<nColCount; nCol++)
-                                pMatrix->PutString( String( pColArr[nCol] ),
+                                xMatrix->PutString( String( pColArr[nCol] ),
                                     static_cast<SCSIZE>(nCol),
                                     static_cast<SCSIZE>(nRow) );
                             for (nCol=nColCount; nCol<nMaxColCount; nCol++)
-                                pMatrix->PutString( EMPTY_STRING,
+                                xMatrix->PutString( EMPTY_STRING,
                                         static_cast<SCSIZE>(nCol),
                                         static_cast<SCSIZE>(nRow) );
                         }
diff --git a/sc/source/core/tool/ddelink.cxx b/sc/source/core/tool/ddelink.cxx
index c48b4c6..ad72372 100644
--- a/sc/source/core/tool/ddelink.cxx
+++ b/sc/source/core/tool/ddelink.cxx
@@ -166,7 +166,7 @@ void ScDdeLink::DataChanged( const String& rMimeType,
 
     if (!nRows || !nCols)				// keine Daten
     {
-        pResult.Clear();
+        pResult.reset();
     }
     else								// Daten aufteilen
     {
@@ -233,7 +233,7 @@ void ScDdeLink::DataChanged( const String& rMimeType,
 
 void ScDdeLink::ResetValue()
 {
-    pResult.Clear();
+    pResult.reset();
 
     //	Es hat sich was getan...
     //	Tracking, FID_DATACHANGED etc. passiert von aussen
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 52edb06..67ef1cf 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -957,7 +957,7 @@ ScMatrixRef ScInterpreter::CompareMat( ScCompareOptions* pOptions )
 }
 
 
-ScMatrixRef ScInterpreter::QueryMat( ScMatrix* pMat, ScCompareOptions& rOptions )
+ScMatrixRef ScInterpreter::QueryMat( const ScMatrixRef& pMat, ScCompareOptions& rOptions )
 {
     short nSaveCurFmtType = nCurFmtType;
     short nSaveFuncFmtType = nFuncFmtType;
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 1772815..31e9854 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -1917,7 +1917,7 @@ void ScInterpreter::PushExternalDoubleRef(
 }
 
 
-void ScInterpreter::PushMatrix(ScMatrix* pMat)
+void ScInterpreter::PushMatrix(const ScMatrixRef& pMat)
 {
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::PushMatrix" );
     pMat->SetErrorInterpreter( NULL);
@@ -2699,7 +2699,7 @@ void ScInterpreter::ScExternal()
                             }
                             break;
                         case svMatrix:
-                            if (!ScRangeToSequence::FillLongArray( aParam, PopMatrix() ))
+                            if (!ScRangeToSequence::FillLongArray( aParam, PopMatrix().get() ))
                                 SetError(errIllegalParameter);
                             break;
                         default:
@@ -2730,7 +2730,7 @@ void ScInterpreter::ScExternal()
                             }
                             break;
                         case svMatrix:
-                            if (!ScRangeToSequence::FillDoubleArray( aParam, PopMatrix() ))
+                            if (!ScRangeToSequence::FillDoubleArray( aParam, PopMatrix().get() ))
                                 SetError(errIllegalParameter);
                             break;
                         default:
@@ -2761,7 +2761,7 @@ void ScInterpreter::ScExternal()
                             }
                             break;
                         case svMatrix:
-                            if (!ScRangeToSequence::FillStringArray( aParam, PopMatrix(), pFormatter ))
+                            if (!ScRangeToSequence::FillStringArray( aParam, PopMatrix().get(), pFormatter ))
                                 SetError(errIllegalParameter);
                             break;
                         default:
@@ -2812,7 +2812,7 @@ void ScInterpreter::ScExternal()
                             }
                             break;
                         case svMatrix:
-                            if (!ScRangeToSequence::FillMixedArray( aParam, PopMatrix() ))
+                            if (!ScRangeToSequence::FillMixedArray( aParam, PopMatrix().get() ))
                                 SetError(errIllegalParameter);
                             break;
                         default:
@@ -2858,7 +2858,7 @@ void ScInterpreter::ScExternal()
                             }
                             break;
                         case svMatrix:
-                            if (!ScRangeToSequence::FillMixedArray( aParam, PopMatrix() ))
+                            if (!ScRangeToSequence::FillMixedArray( aParam, PopMatrix().get() ))
                                 SetError(errIllegalParameter);
                             break;
                         case svMissing:
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index ce4e761..780bdc0 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -622,7 +622,7 @@ void ScInterpreter::ScMatValue()
             case svMatrix:
             {
                 ScMatrixRef pMat = PopMatrix();
-                CalculateMatrixValue(pMat,nC,nR);
+                CalculateMatrixValue(pMat.get(),nC,nR);
             }
             break;
             default:
@@ -678,7 +678,7 @@ void ScInterpreter::ScEMat()
     }
 }
 
-void ScInterpreter::MEMat(ScMatrix* mM, SCSIZE n)
+void ScInterpreter::MEMat(const ScMatrixRef& mM, SCSIZE n)
 {
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::MEMat" );
     mM->FillDouble(0.0, 0, 0, n-1, n-1);
@@ -875,7 +875,7 @@ void ScInterpreter::ScMatDet()
             else
             {
                 ::std::vector< SCSIZE> P(nR);
-                int nDetSign = lcl_LUP_decompose( xLU, nR, P);
+                int nDetSign = lcl_LUP_decompose( xLU.get(), nR, P);
                 if (!nDetSign)
                     PushInt(0);     // singular matrix
                 else
@@ -883,9 +883,8 @@ void ScInterpreter::ScMatDet()
                     // In an LU matrix the determinant is simply the product of
                     // all diagonal elements.
                     double fDet = nDetSign;
-                    ScMatrix* pLU = xLU;
                     for (SCSIZE i=0; i < nR; ++i)
-                        fDet *= pLU->GetDouble( i, i);
+                        fDet *= xLU->GetDouble( i, i);
                     PushDouble( fDet);
                 }
             }
@@ -924,13 +923,12 @@ void ScInterpreter::ScMatInv()
             else
             {
                 ::std::vector< SCSIZE> P(nR);
-                int nDetSign = lcl_LUP_decompose( xLU, nR, P);
+                int nDetSign = lcl_LUP_decompose( xLU.get(), nR, P);
                 if (!nDetSign)
                     PushIllegalArgument();
                 else
                 {
                     // Solve equation for each column.
-                    ScMatrix* pY = xY;
                     ::std::vector< double> B(nR);
                     ::std::vector< double> X(nR);
                     for (SCSIZE j=0; j < nR; ++j)
@@ -938,9 +936,9 @@ void ScInterpreter::ScMatInv()
                         for (SCSIZE i=0; i < nR; ++i)
                             B[i] = 0.0;
                         B[j] = 1.0;
-                        lcl_LUP_solve( xLU, nR, P, B, X);
+                        lcl_LUP_solve( xLU.get(), nR, P, B, X);
                         for (SCSIZE i=0; i < nR; ++i)
-                            pY->PutDouble( X[i], j, i);
+                            xY->PutDouble( X[i], j, i);
                     }
 #if OSL_DEBUG_LEVEL > 1
                     /* Possible checks for ill-condition:
@@ -964,7 +962,7 @@ void ScInterpreter::ScMatInv()
                     if (xR)
                     {
                         ScMatrix* pR = xR;
-                        lcl_MFastMult( pMat, pY, pR, nR, nR, nR);
+                        lcl_MFastMult( pMat, xY.get(), pR, nR, nR, nR);
                         fprintf( stderr, "\n%s\n", "ScMatInv(): mult-identity");
                         for (SCSIZE i=0; i < nR; ++i)
                         {
@@ -986,7 +984,7 @@ void ScInterpreter::ScMatInv()
                     if (nGlobalError)
                         PushError( nGlobalError);
                     else
-                        PushMatrix( pY);
+                        PushMatrix( xY);
                 }
             }
         }
@@ -1098,7 +1096,6 @@ ScMatrixRef lcl_MatrixCalculation(const _Function& _pOperation,ScMatrix* pMat1,
     ScMatrixRef xResMat = _pIterpreter->GetNewMat(nMinC, nMinR);
     if (xResMat)
     {
-        ScMatrix* pResMat = xResMat;
         for (i = 0; i < nMinC; i++)
         {
             for (j = 0; j < nMinR; j++)
@@ -1106,17 +1103,17 @@ ScMatrixRef lcl_MatrixCalculation(const _Function& _pOperation,ScMatrix* pMat1,
                 if (pMat1->IsValueOrEmpty(i,j) && pMat2->IsValueOrEmpty(i,j))
                 {
                     double d = _pOperation(pMat1->GetDouble(i,j),pMat2->GetDouble(i,j));
-                    pResMat->PutDouble( d, i, j);
+                    xResMat->PutDouble( d, i, j);
                 }
                 else
-                    pResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), i, j);
+                    xResMat->PutString(ScGlobal::GetRscString(STR_NO_VALUE), i, j);
             }
         }
     }
     return xResMat;
 }
 
-ScMatrixRef ScInterpreter::MatConcat(ScMatrix* pMat1, ScMatrix* pMat2)
+ScMatrixRef ScInterpreter::MatConcat(const ScMatrixRef& pMat1, const ScMatrixRef& pMat2)
 {
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::MatConcat" );
     SCSIZE nC1, nC2, nMinC;
@@ -1129,7 +1126,6 @@ ScMatrixRef ScInterpreter::MatConcat(ScMatrix* pMat1, ScMatrix* pMat2)
     ScMatrixRef xResMat = GetNewMat(nMinC, nMinR);
     if (xResMat)
     {
-        ScMatrix* pResMat = xResMat;
         for (i = 0; i < nMinC; i++)
         {
             for (j = 0; j < nMinR; j++)
@@ -1138,12 +1134,12 @@ ScMatrixRef ScInterpreter::MatConcat(ScMatrix* pMat1, ScMatrix* pMat2)
                 if (!nErr)
                     nErr = pMat2->GetErrorIfNotString( i, j);
                 if (nErr)
-                    pResMat->PutError( nErr, i, j);
+                    xResMat->PutError( nErr, i, j);
                 else
                 {
                     String aTmp( pMat1->GetString( *pFormatter, i, j));
                     aTmp += pMat2->GetString( *pFormatter, i, j);
-                    pResMat->PutString( aTmp, i, j);
+                    xResMat->PutString( aTmp, i, j);
                 }
             }
         }
@@ -1244,12 +1240,12 @@ void ScInterpreter::CalculateAddSub(BOOL _bSub)
         if ( _bSub )
         {
             MatrixSub aSub;
-            pResMat = lcl_MatrixCalculation(aSub ,pMat1, pMat2,this);
+            pResMat = lcl_MatrixCalculation(aSub ,pMat1.get(), pMat2.get(),this);
         }
         else
         {
             MatrixAdd aAdd;
-            pResMat = lcl_MatrixCalculation(aAdd ,pMat1, pMat2,this);
+            pResMat = lcl_MatrixCalculation(aAdd ,pMat1.get(), pMat2.get(),this);
         }
 
         if (!pResMat)
@@ -1457,7 +1453,7 @@ void ScInterpreter::ScMul()
     if (pMat1 && pMat2)
     {
         MatrixMul aMul;
-        ScMatrixRef pResMat = lcl_MatrixCalculation(aMul,pMat1, pMat2,this);
+        ScMatrixRef pResMat = lcl_MatrixCalculation(aMul,pMat1.get(), pMat2.get(),this);
         if (!pResMat)
             PushNoValue();
         else
@@ -1532,7 +1528,7 @@ void ScInterpreter::ScDiv()
     if (pMat1 && pMat2)
     {
         MatrixDiv aDiv;
-        ScMatrixRef pResMat = lcl_MatrixCalculation(aDiv,pMat1, pMat2,this);
+        ScMatrixRef pResMat = lcl_MatrixCalculation(aDiv,pMat1.get(), pMat2.get(),this);
         if (!pResMat)
             PushNoValue();
         else
@@ -1614,7 +1610,7 @@ void ScInterpreter::ScPow()
     if (pMat1 && pMat2)
     {
         MatrixPow aPow;
-        ScMatrixRef pResMat = lcl_MatrixCalculation(aPow,pMat1, pMat2,this);
+        ScMatrixRef pResMat = lcl_MatrixCalculation(aPow,pMat1.get(), pMat2.get(),this);
         if (!pResMat)
             PushNoValue();
         else
@@ -1700,7 +1696,7 @@ void ScInterpreter::ScSumProduct()
             PushNoValue();
             return;
         }
-        ScMatrixRef pResMat = lcl_MatrixCalculation(aMul,pMat1, pMat,this);
+        ScMatrixRef pResMat = lcl_MatrixCalculation(aMul,pMat1.get(), pMat.get(),this);
         if (!pResMat)
         {
             PushNoValue();
@@ -1796,7 +1792,7 @@ void ScInterpreter::ScSumXMY2()
         return;
     } // if (nC1 != nC2 || nR1 != nR2)
     MatrixSub aSub;
-    ScMatrixRef pResMat = lcl_MatrixCalculation(aSub,pMat1, pMat2,this);
+    ScMatrixRef pResMat = lcl_MatrixCalculation(aSub,pMat1.get(), pMat2.get(),this);
     if (!pResMat)
     {
         PushNoValue();
diff --git a/sc/source/core/tool/rangeseq.cxx b/sc/source/core/tool/rangeseq.cxx
index 95ccdc7..8548ee8 100644
--- a/sc/source/core/tool/rangeseq.cxx
+++ b/sc/source/core/tool/rangeseq.cxx
@@ -401,9 +401,8 @@ ScMatrixRef ScSequenceToMatrix::CreateMixedMatrix( const com::sun::star::uno::An
             xMatrix = new ScMatrix(
                     static_cast<SCSIZE>(nMaxColCount),
                     static_cast<SCSIZE>(nRowCount) );
-            ScMatrix* pMatrix = xMatrix;
             SCSIZE nCols, nRows;
-            pMatrix->GetDimensions( nCols, nRows);
+            xMatrix->GetDimensions( nCols, nRows);
             if (nCols != static_cast<SCSIZE>(nMaxColCount) || nRows != static_cast<SCSIZE>(nRowCount))
             {
                 DBG_ERRORFILE( "ScSequenceToMatrix::CreateMixedMatrix: matrix exceeded max size, returning NULL matrix");
@@ -420,11 +419,11 @@ ScMatrixRef ScSequenceToMatrix::CreateMixedMatrix( const com::sun::star::uno::An
                     if (ScApiTypeConversion::ConvertAnyToDouble( fVal, eClass, pColArr[nCol]))
                     {
                         if (eClass == uno::TypeClass_BOOLEAN)
-                            pMatrix->PutBoolean( (fVal ? true : false),
+                            xMatrix->PutBoolean( (fVal ? true : false),
                                     static_cast<SCSIZE>(nCol),
                                     static_cast<SCSIZE>(nRow) );
                         else
-                            pMatrix->PutDouble( fVal,
+                            xMatrix->PutDouble( fVal,
                                     static_cast<SCSIZE>(nCol),
                                     static_cast<SCSIZE>(nRow) );
                     }
@@ -435,18 +434,18 @@ ScMatrixRef ScSequenceToMatrix::CreateMixedMatrix( const com::sun::star::uno::An
                         //Reflection* pRefl = pColArr[nCol].getReflection();
                         //if ( pRefl->equals( *OUString_getReflection() ) )
                         if ( pColArr[nCol] >>= aUStr )
-                            pMatrix->PutString( String( aUStr ),
+                            xMatrix->PutString( String( aUStr ),
                                     static_cast<SCSIZE>(nCol),
                                     static_cast<SCSIZE>(nRow) );
                         else
-                            pMatrix->PutEmpty(
+                            xMatrix->PutEmpty(
                                     static_cast<SCSIZE>(nCol),
                                     static_cast<SCSIZE>(nRow) );
                     }
                 }
                 for (nCol=nColCount; nCol<nMaxColCount; nCol++)
                 {
-                    pMatrix->PutEmpty(
+                    xMatrix->PutEmpty(
                             static_cast<SCSIZE>(nCol),
                             static_cast<SCSIZE>(nRow) );
                 }
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 481194b..5dc7877 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -789,8 +789,8 @@ BOOL ScRefListToken::operator==( const FormulaToken& r ) const
 }
 
 
-const ScMatrix* ScMatrixToken::GetMatrix() const        { return pMatrix; }
-ScMatrix*       ScMatrixToken::GetMatrix()              { return pMatrix; }
+const ScMatrix* ScMatrixToken::GetMatrix() const        { return pMatrix.get(); }
+ScMatrix*       ScMatrixToken::GetMatrix()              { return pMatrix.get(); }
 BOOL ScMatrixToken::operator==( const FormulaToken& r ) const
 {
     return FormulaToken::operator==( r ) && pMatrix == static_cast<const ScToken&>(r).GetMatrix();
@@ -1027,7 +1027,7 @@ BOOL ScEmptyCellToken::operator==( const FormulaToken& r ) const
 
 double          ScMatrixCellResultToken::GetDouble() const  { return xUpperLeft->GetDouble(); }
 const String &  ScMatrixCellResultToken::GetString() const  { return xUpperLeft->GetString(); }
-const ScMatrix* ScMatrixCellResultToken::GetMatrix() const  { return xMatrix; }
+const ScMatrix* ScMatrixCellResultToken::GetMatrix() const  { return xMatrix.get(); }
 // Non-const GetMatrix() is private and unused but must be implemented to
 // satisfy vtable linkage.
 ScMatrix* ScMatrixCellResultToken::GetMatrix()
@@ -1580,7 +1580,7 @@ FormulaToken* ScTokenArray::AddDoubleReference( const ScComplexRefData& rRef )
     return Add( new ScDoubleRefToken( rRef ) );
 }
 
-FormulaToken* ScTokenArray::AddMatrix( ScMatrix* p )
+FormulaToken* ScTokenArray::AddMatrix( const ScMatrixRef& p )
 {
     return Add( new ScMatrixToken( p ) );
 }
diff --git a/sc/source/filter/excel/excform.cxx b/sc/source/filter/excel/excform.cxx
index d064edd..5568b4c 100644
--- a/sc/source/filter/excel/excform.cxx
+++ b/sc/source/filter/excel/excform.cxx
@@ -696,7 +696,7 @@ ConvErr ExcelToSc::Convert( const ScTokenArray*& pErgebnis, XclImpStream& aIn, s
                         aPool	<< ocDde << ocOpen << nPar1 << ocSep << nPar2 << ocSep
                                 << nMerk0 << ocClose;
 
-                        GetDoc().CreateDdeLink( aAppl, aExtDoc, pExtName->aName, SC_DDE_DEFAULT );
+                        GetDoc().CreateDdeLink( aAppl, aExtDoc, pExtName->aName, SC_DDE_DEFAULT, ScMatrixRef() );
                     }
                     else
                         aPool << ocBad;
diff --git a/sc/source/filter/xml/XMLDDELinksContext.cxx b/sc/source/filter/xml/XMLDDELinksContext.cxx
index 269861a..4651389 100644
--- a/sc/source/filter/xml/XMLDDELinksContext.cxx
+++ b/sc/source/filter/xml/XMLDDELinksContext.cxx
@@ -137,7 +137,7 @@ void ScXMLDDELinkContext::CreateDDELink()
         String sAppl(sApplication);
         String sTop(sTopic);
         String sIt(sItem);
-        GetScImport().GetDocument()->CreateDdeLink(sAppl, sTop, sIt, nMode);
+        GetScImport().GetDocument()->CreateDdeLink(sAppl, sTop, sIt, nMode, ScMatrixRef());
         sal_uInt16 nPos;
         if(GetScImport().GetDocument()->FindDdeLink(sAppl, sTop, sIt, nMode, nPos))
             nPosition = nPos;
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index 85dbdbe..fa915e9 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -659,8 +659,7 @@ ScExternalRefCache::TokenArrayRef ScExternalRefCache::getCellRangeData(
         if (!bFirstTab)
             pArray->AddOpCode(ocSep);
 
-        ScMatrix* pMat2 = xMat;
-        ScMatrixToken aToken(pMat2);
+        ScMatrixToken aToken(xMat);
         if (!pArray)
             pArray.reset(new ScTokenArray);
         pArray->AddToken(aToken);
@@ -1464,8 +1463,7 @@ static ScTokenArray* lcl_convertToTokenArray(const ScDocument* pSrcDoc, ScRange&
         if (!bFirstTab)
             pArray->AddOpCode(ocSep);
 
-        ScMatrix* pMat2 = xMat;
-        ScMatrixToken aToken(pMat2);
+        ScMatrixToken aToken(xMat);
         pArray->AddToken(aToken);
 
         itrCache->mpRangeData = xMat;
@@ -1493,8 +1491,7 @@ static ScTokenArray* lcl_fillEmptyMatrix(const ScRange& rRange)
         for (SCSIZE j = 0; j < nR; ++j)
             xMat->PutEmpty(i, j);
 
-    ScMatrix* pMat2 = xMat;
-    ScMatrixToken aToken(pMat2);
+    ScMatrixToken aToken(xMat);
     auto_ptr<ScTokenArray> pArray(new ScTokenArray);
     pArray->AddToken(aToken);
     return pArray.release();
diff --git a/sc/source/ui/unoobj/linkuno.cxx b/sc/source/ui/unoobj/linkuno.cxx
index d4e30f4..a90817e 100644
--- a/sc/source/ui/unoobj/linkuno.cxx
+++ b/sc/source/ui/unoobj/linkuno.cxx
@@ -1474,7 +1474,7 @@ uno::Reference< sheet::XDDELink > ScDDELinksObj::addDDELink(
                     break;
             }
 
-            if ( pDoc->CreateDdeLink( aApplication, aTopic, aItem, nMod ) )
+            if ( pDoc->CreateDdeLink( aApplication, aTopic, aItem, nMod, ScMatrixRef() ) )
             {
                 const ::rtl::OUString aName( lcl_BuildDDEName( aApplication, aTopic, aItem ) );
                 xLink.set( GetObjectByName_Impl( aName ) );


More information about the Libreoffice-commits mailing list