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

Kohei Yoshida kohei at kemper.freedesktop.org
Sat Nov 6 22:42:49 PDT 2010


 sc/inc/scmatrix.hxx                        |   87 ++++++---
 sc/source/core/data/cell.cxx               |   14 -
 sc/source/core/data/validat.cxx            |   18 -
 sc/source/core/inc/jumpmatrix.hxx          |    2 
 sc/source/core/tool/compiler.cxx           |   15 -
 sc/source/core/tool/ddelink.cxx            |    3 
 sc/source/core/tool/interpr1.cxx           |  203 ++++++++++++++--------
 sc/source/core/tool/interpr3.cxx           |   28 +--
 sc/source/core/tool/interpr4.cxx           |   83 ++++-----
 sc/source/core/tool/interpr5.cxx           |  125 +++++++------
 sc/source/core/tool/makefile.mk            |    1 
 sc/source/core/tool/scmatrix.cxx           |  266 ++++++++++-------------------
 sc/source/filter/excel/xeformula.cxx       |   17 -
 sc/source/filter/excel/xehelper.cxx        |   17 -
 sc/source/filter/xml/XMLExportDDELinks.cxx |  143 +++++----------
 sc/source/filter/xml/XMLExportDDELinks.hxx |    7 
 16 files changed, 499 insertions(+), 530 deletions(-)

New commits:
commit ff44d24bae54794f1d66b14674f888b3eefa9122
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Sun Nov 7 01:39:29 2010 -0400

    Fixed all build breaks.  sc is again buildable.

diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index f3bf4f5..2d1de85 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -226,6 +226,7 @@ public:
     ScMatrix( SCSIZE nC, SCSIZE nR, DensityType eType = FILLED_ZERO);
 
     /** Clone the matrix. */
+    ScMatrix* Clone() const;
     ScMatrix* Clone( DensityType eType) const;
 
     /** Clone the matrix if mbCloneIfConst (immutable) is set, otherwise 
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index 8b0a631..113c9cc 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -1780,42 +1780,37 @@ void ScInterpreter::QueryMatrixType(ScMatrixRef& xMat, short& rRetTypeExpr, ULON
 {
     if (xMat)
     {
-        ScMatValType nMatValType;
-        const ScMatrixValue* pMatVal = xMat->Get(0, 0, nMatValType);
-        if ( pMatVal )
+        ScMatrixValue nMatVal = xMat->Get(0, 0);
+        ScMatValType nMatValType = nMatVal.nType;
+        if (ScMatrix::IsNonValueType( nMatValType))
         {
-            if (ScMatrix::IsNonValueType( nMatValType))
-            {
-                if ( xMat->IsEmptyPath( 0, 0))
-                {   // result of empty FALSE jump path
-                    FormulaTokenRef xRes = new FormulaDoubleToken( 0.0);
-                    PushTempToken( new ScMatrixCellResultToken( xMat, xRes));
-                    rRetTypeExpr = NUMBERFORMAT_LOGICAL;
-                }
-                else
-                {
-                    String aStr( pMatVal->GetString());
-                    FormulaTokenRef xRes = new FormulaStringToken( aStr);
-                    PushTempToken( new ScMatrixCellResultToken( xMat, xRes));
-                    rRetTypeExpr = NUMBERFORMAT_TEXT;
-                }
+            if ( xMat->IsEmptyPath( 0, 0))
+            {   // result of empty FALSE jump path
+                FormulaTokenRef xRes = new FormulaDoubleToken( 0.0);
+                PushTempToken( new ScMatrixCellResultToken( xMat, xRes));
+                rRetTypeExpr = NUMBERFORMAT_LOGICAL;
             }
             else
             {
-                USHORT nErr = GetDoubleErrorValue( pMatVal->fVal);
-                FormulaTokenRef xRes;
-                if (nErr)
-                    xRes = new FormulaErrorToken( nErr);
-                else
-                    xRes = new FormulaDoubleToken( pMatVal->fVal);
+                String aStr( nMatVal.GetString());
+                FormulaTokenRef xRes = new FormulaStringToken( aStr);
                 PushTempToken( new ScMatrixCellResultToken( xMat, xRes));
-                if ( rRetTypeExpr != NUMBERFORMAT_LOGICAL )
-                    rRetTypeExpr = NUMBERFORMAT_NUMBER;
+                rRetTypeExpr = NUMBERFORMAT_TEXT;
             }
-            rRetIndexExpr = 0;
         }
         else
-            SetError( errUnknownStackVariable);
+        {
+            USHORT nErr = GetDoubleErrorValue( nMatVal.fVal);
+            FormulaTokenRef xRes;
+            if (nErr)
+                xRes = new FormulaErrorToken( nErr);
+            else
+                xRes = new FormulaDoubleToken( nMatVal.fVal);
+            PushTempToken( new ScMatrixCellResultToken( xMat, xRes));
+            if ( rRetTypeExpr != NUMBERFORMAT_LOGICAL )
+                rRetTypeExpr = NUMBERFORMAT_NUMBER;
+        }
+        rRetIndexExpr = 0;
         xMat->SetErrorInterpreter( NULL);
     }
     else
diff --git a/sc/source/core/tool/makefile.mk b/sc/source/core/tool/makefile.mk
index e33ec81..15ec283 100644
--- a/sc/source/core/tool/makefile.mk
+++ b/sc/source/core/tool/makefile.mk
@@ -105,7 +105,6 @@ EXCEPTIONSFILES= \
         $(SLO)$/reftokenhelper.obj \
         $(SLO)$/scmatrix.obj \
         $(SLO)$/refupdat.obj \
-        $(SLO)$/scmatrix.obj \
         $(SLO)$/simplerangelist.obj \
         $(SLO)$/stringutil.obj \
         $(SLO)$/subtotal.obj \
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 3e3c9cc..d30eb3d 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -42,7 +42,7 @@
 
 #include <math.h>
 
-#define _MDDS_HASH_CONTAINER_COMPAT 1
+#define MDDS_HASH_CONTAINER_STLPORT 1
 #include <mdds/quad_type_matrix.hpp>
 
 using ::std::pair;
commit b6370c9a92fe473f35d4cb13cce942e4c2600ea0
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Tue Jun 29 23:32:33 2010 -0400

    More of the same.

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 41cca73..fe92da7 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -4093,6 +4093,13 @@ public:
         return mbColVec ? mrMat.GetString(0, i) : mrMat.GetString(i, 0);
     }
 
+    SCSIZE GetElementCount() const
+    {
+        SCSIZE nC, nR;
+        mrMat.GetDimensions(nC, nR);
+        return mbColVec ? nR : nC;
+    }
+
 private:
     const ScMatrix& mrMat;
     bool mbColVec;
@@ -5444,11 +5451,12 @@ void ScInterpreter::ScLookup()
 
         if (bFound)
         {
+            VectorMatrixAccessor aMatAcc(*pDataMat, bVertical);
             SCCOLROW i = nDelta;
-            SCSIZE n = pDataMat->GetElementCount();
+            SCSIZE n = aMatAcc.GetElementCount();
             if (static_cast<SCSIZE>(i) >= n)
                 i = static_cast<SCCOLROW>(n);
-            if (bool(rEntry.bQueryByString) == bool(pDataMat->IsValue(i)))
+            if (static_cast<bool>(rEntry.bQueryByString) == aMatAcc.IsValue(i))
                 bFound = false;
         }
 
@@ -5462,16 +5470,17 @@ void ScInterpreter::ScLookup()
 
         if (pResMat)
         {
+            VectorMatrixAccessor aResMatAcc(*pResMat, bVertical);
             // result array is matrix.
-            if (static_cast<SCSIZE>(nDelta) >= pResMat->GetElementCount())
+            if (static_cast<SCSIZE>(nDelta) >= aResMatAcc.GetElementCount())
             {
                 PushNA();
                 return;
             }
-            if (pResMat->IsValue(nDelta))
-                PushDouble(pResMat->GetDouble(nDelta));
+            if (aResMatAcc.IsValue(nDelta))
+                PushDouble(aResMatAcc.GetDouble(nDelta));
             else
-                PushString(pResMat->GetString(nDelta));
+                PushString(aResMatAcc.GetString(nDelta));
         }
         else if (nParamCount == 3)
         {
@@ -5556,11 +5565,12 @@ void ScInterpreter::ScLookup()
 
     if (pResMat)
     {
+        VectorMatrixAccessor aResMatAcc(*pResMat, bVertical);
         // Use the matrix result array.
-        if (pResMat->IsValue(nDelta))
-            PushDouble(pResMat->GetDouble(nDelta));
+        if (aResMatAcc.IsValue(nDelta))
+            PushDouble(aResMatAcc.GetDouble(nDelta));
         else
-            PushString(pResMat->GetString(nDelta));
+            PushString(aResMatAcc.GetString(nDelta));
     }
     else if (nParamCount == 3)
     {
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index 08f0481..9fad3c8 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -3918,24 +3918,26 @@ void ScInterpreter::ScProbability()
             double fRes = 0.0;
             BOOL bStop = FALSE;
             double fP, fW;
-            SCSIZE nCount1 = nC1 * nR1;
-            for ( SCSIZE i = 0; i < nCount1 && !bStop; i++ )
+            for ( SCSIZE i = 0; i < nC1 && !bStop; i++ )
             {
-                if (pMatP->IsValue(i) && pMatW->IsValue(i))
+                for (SCSIZE j = 0; j < nR1 && !bStop; ++j )
                 {
-                    fP = pMatP->GetDouble(i);
-                    fW = pMatW->GetDouble(i);
-                    if (fP < 0.0 || fP > 1.0)
-                        bStop = TRUE;
-                    else
+                    if (pMatP->IsValue(i,j) && pMatW->IsValue(i,j))
                     {
-                        fSum += fP;
-                        if (fW >= fLo && fW <= fUp)
-                            fRes += fP;
+                        fP = pMatP->GetDouble(i,j);
+                        fW = pMatW->GetDouble(i,j);
+                        if (fP < 0.0 || fP > 1.0)
+                            bStop = TRUE;
+                        else
+                        {
+                            fSum += fP;
+                            if (fW >= fLo && fW <= fUp)
+                                fRes += fP;
+                        }
                     }
+                    else
+                        SetError( errIllegalArgument);
                 }
-                else
-                    SetError( errIllegalArgument);
             }
             if (bStop || fabs(fSum -1.0) > 1.0E-7)
                 PushNoValue();
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index b8481e1..1dc9fbc 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -182,21 +182,23 @@ void ScInterpreter::ScGCD()
                             SetError(errIllegalArgument);
                         else
                         {
-                            SCSIZE nCount = nC * nR;
-                            for ( SCSIZE j = 0; j < nCount; j++ )
+                            for ( SCSIZE j = 0; j < nC; j++ )
                             {
-                                if (!pMat->IsValue(j))
+                                for (SCSIZE k = 0; k < nR; ++k)
                                 {
-                                    PushIllegalArgument();
-                                    return;
+                                    if (!pMat->IsValue(j,k))
+                                    {
+                                        PushIllegalArgument();
+                                        return;
+                                    }
+                                    fx = ::rtl::math::approxFloor( pMat->GetDouble(j,k));
+                                    if (fx < 0.0)
+                                    {
+                                        PushIllegalArgument();
+                                        return;
+                                    }
+                                    fy = ScGetGCD(fx, fy);
                                 }
-                                fx = ::rtl::math::approxFloor( pMat->GetDouble(j));
-                                if (fx < 0.0)
-                                {
-                                    PushIllegalArgument();
-                                    return;
-                                }
-                                fy = ScGetGCD(fx, fy);
                             }
                         }
                     }
@@ -274,24 +276,26 @@ void ScInterpreter:: ScLCM()
                             SetError(errIllegalArgument);
                         else
                         {
-                            SCSIZE nCount = nC * nR;
-                            for ( SCSIZE j = 0; j < nCount; j++ )
+                            for ( SCSIZE j = 0; j < nC; j++ )
                             {
-                                if (!pMat->IsValue(j))
-                                {
-                                    PushIllegalArgument();
-                                    return;
-                                }
-                                fx = ::rtl::math::approxFloor( pMat->GetDouble(j));
-                                if (fx < 0.0)
+                                for (SCSIZE k = 0; k < nR; ++k)
                                 {
-                                    PushIllegalArgument();
-                                    return;
+                                    if (!pMat->IsValue(j,k))
+                                    {
+                                        PushIllegalArgument();
+                                        return;
+                                    }
+                                    fx = ::rtl::math::approxFloor( pMat->GetDouble(j,k));
+                                    if (fx < 0.0)
+                                    {
+                                        PushIllegalArgument();
+                                        return;
+                                    }
+                                    if (fx == 0.0 || fy == 0.0)
+                                        fy = 0.0;
+                                    else
+                                        fy = fx * fy / ScGetGCD(fx, fy);
                                 }
-                                if (fx == 0.0 || fy == 0.0)
-                                    fy = 0.0;
-                                else
-                                    fy = fx * fy / ScGetGCD(fx, fy);
                             }
                         }
                     }
commit 44af511f7ac5e0ce06096d9c108b5e0c4b6a2824
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Sun Nov 7 00:20:50 2010 -0400

    More of the same.

diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index 85e92f1..f3bf4f5 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -343,17 +343,11 @@ public:
     BOOL IsString( SCSIZE nC, SCSIZE nR ) const;
 
     /// @return <TRUE/> if empty or empty path.
-    BOOL IsEmpty( SCSIZE nIndex ) const;
-
-    /// @return <TRUE/> if empty or empty path.
     BOOL IsEmpty( SCSIZE nC, SCSIZE nR ) const;
 
     /// @return <TRUE/> if empty path.
     BOOL IsEmptyPath( SCSIZE nC, SCSIZE nR ) const;
 
-    /// @return <TRUE/> if empty path.
-    BOOL IsEmptyPath( SCSIZE nIndex ) const;
-
     /// @return <TRUE/> if value or boolean.
     BOOL IsValue( SCSIZE nIndex ) const;
 
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 3aaca33..41cca73 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -1635,7 +1635,7 @@ void ScInterpreter::ScIsEmpty()
             if ( !pMat )
                 ;   // nothing
             else if ( !pJumpMatrix )
-                nRes = pMat->IsEmpty( 0 );
+                nRes = pMat->IsEmpty( 0, 0);
             else
             {
                 SCSIZE nCols, nRows, nC, nR;
@@ -1697,7 +1697,7 @@ short ScInterpreter::IsString()
             if ( !pMat )
                 ;   // nothing
             else if ( !pJumpMatrix )
-                nRes = pMat->IsString(0) && !pMat->IsEmpty(0);
+                nRes = pMat->IsString(0, 0) && !pMat->IsEmpty(0, 0);
             else
             {
                 SCSIZE nCols, nRows, nC, nR;
@@ -5306,10 +5306,10 @@ void ScInterpreter::ScLookup()
 
         if (pResMat)
         {
-            if (pResMat->IsValue( 0 ))
-                PushDouble(pResMat->GetDouble( 0 ));
+            if (pResMat->IsValue( 0, 0 ))
+                PushDouble(pResMat->GetDouble( 0, 0 ));
             else
-                PushString(pResMat->GetString( 0 ));
+                PushString(pResMat->GetString( 0, 0 ));
         }
         else if (nParamCount == 3)
         {
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index e57c497..3e3c9cc 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -192,10 +192,8 @@ public:
     ScMatrixValue Get(SCSIZE nC, SCSIZE nR) const;
     BOOL IsString( SCSIZE nIndex ) const;
     BOOL IsString( SCSIZE nC, SCSIZE nR ) const;
-    BOOL IsEmpty( SCSIZE nIndex ) const;
     BOOL IsEmpty( SCSIZE nC, SCSIZE nR ) const;
     BOOL IsEmptyPath( SCSIZE nC, SCSIZE nR ) const;
-    BOOL IsEmptyPath( SCSIZE nIndex ) const;
     BOOL IsValue( SCSIZE nIndex ) const;
     BOOL IsValue( SCSIZE nC, SCSIZE nR ) const;
     BOOL IsValueOrEmpty( SCSIZE nC, SCSIZE nR ) const;
@@ -499,7 +497,6 @@ String ScMatrixImpl::GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSIZE
     return aStr;
 }
 
-
 ScMatrixValue ScMatrixImpl::Get(SCSIZE nC, SCSIZE nR) const
 {
     ScMatrixValue aVal;
@@ -552,12 +549,6 @@ BOOL ScMatrixImpl::IsString( SCSIZE nC, SCSIZE nR ) const
     }
     return false;
 }
-BOOL ScMatrixImpl::IsEmpty( SCSIZE nIndex ) const
-{
-    SCSIZE nC, nR;
-    CalcPosition(nIndex, nC, nR);
-    return IsEmpty(nC, nR);
-}
 
 BOOL ScMatrixImpl::IsEmpty( SCSIZE nC, SCSIZE nR ) const
 {
@@ -574,13 +565,6 @@ BOOL ScMatrixImpl::IsEmptyPath( SCSIZE nC, SCSIZE nR ) const
     return maMat.get_type(nR, nC) == ::mdds::element_empty && maMat.get_flag(nR, nC) != 0;
 }
 
-BOOL ScMatrixImpl::IsEmptyPath( SCSIZE nIndex ) const
-{
-    SCSIZE nC, nR;
-    CalcPosition(nIndex, nC, nR);
-    return IsEmptyPath(nC, nR);
-}
-
 BOOL ScMatrixImpl::IsValue( SCSIZE nIndex ) const
 {
     SCSIZE nC, nR;
@@ -927,11 +911,6 @@ BOOL ScMatrix::IsString( SCSIZE nC, SCSIZE nR ) const
     return pImpl->IsString(nC, nR);
 }
 
-BOOL ScMatrix::IsEmpty( SCSIZE nIndex ) const
-{
-    return pImpl->IsEmpty(nIndex);
-}
-
 BOOL ScMatrix::IsEmpty( SCSIZE nC, SCSIZE nR ) const
 {
     return pImpl->IsEmpty(nC, nR);
@@ -942,11 +921,6 @@ BOOL ScMatrix::IsEmptyPath( SCSIZE nC, SCSIZE nR ) const
     return pImpl->IsEmptyPath(nC, nR);
 }
 
-BOOL ScMatrix::IsEmptyPath( SCSIZE nIndex ) const
-{
-    return pImpl->IsEmptyPath(nIndex);
-}
-
 BOOL ScMatrix::IsValue( SCSIZE nIndex ) const
 {
     return pImpl->IsValue(nIndex);
commit cb3ff6836e826c3cd97158bd82c535da6da173da
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Tue Jun 29 23:07:23 2010 -0400

    Use vector matrix accessor wrapper to resolve single-param access to matrix.

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 4c32894..3aaca33 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -930,22 +930,25 @@ ScMatrixRef ScInterpreter::CompareMat( ScCompareOptions* pOptions )
             pResMat = GetNewMat( nC, nR);
             if ( !pResMat )
                 return NULL;
-            SCSIZE n = nC * nR;
-            for ( SCSIZE j=0; j<n; j++ )
+
+            for (SCSIZE j = 0; j < nC; ++j)
             {
-                if ( pMat[i]->IsValue(j) )
+                for (SCSIZE k = 0; k < nR; ++k)
                 {
-                    aComp.bVal[i] = TRUE;
-                    aComp.nVal[i] = pMat[i]->GetDouble(j);
-                    aComp.bEmpty[i] = FALSE;
-                }
-                else
-                {
-                    aComp.bVal[i] = FALSE;
-                    *aComp.pVal[i] = pMat[i]->GetString(j);
-                    aComp.bEmpty[i] = pMat[i]->IsEmpty(j);
+                    if ( pMat[i]->IsValue(j,k) )
+                    {
+                        aComp.bVal[i] = TRUE;
+                        aComp.nVal[i] = pMat[i]->GetDouble(j,k);
+                        aComp.bEmpty[i] = FALSE;
+                    }
+                    else
+                    {
+                        aComp.bVal[i] = FALSE;
+                        *aComp.pVal[i] = pMat[i]->GetString(j,k);
+                        aComp.bEmpty[i] = pMat[i]->IsEmpty(j,k);
+                    }
+                    pResMat->PutDouble( CompareFunc(aComp, pOptions), j, k);
                 }
-                pResMat->PutDouble( CompareFunc( aComp, pOptions ), j );
             }
         }
     }
@@ -2430,9 +2433,9 @@ short ScInterpreter::IsEven()
                 ;   // nothing
             else if ( !pJumpMatrix )
             {
-                nRes = pMat->IsValue( 0 );
+                nRes = pMat->IsValue( 0, 0);
                 if ( nRes )
-                    fVal = pMat->GetDouble( 0 );
+                    fVal = pMat->GetDouble( 0, 0);
             }
             else
             {
@@ -4052,11 +4055,54 @@ void ScInterpreter::ScTable()
     }
 }
 
+namespace {
+
+class VectorMatrixAccessor
+{
+public:
+    VectorMatrixAccessor(const ScMatrix& rMat, bool bColVec) : 
+        mrMat(rMat), mbColVec(bColVec) {}
+
+    bool IsEmpty(SCSIZE i) const
+    {
+        return mbColVec ? mrMat.IsEmpty(0, i) : mrMat.IsEmpty(i, 0);
+    }
+
+    bool IsEmptyPath(SCSIZE i) const
+    {
+        return mbColVec ? mrMat.IsEmptyPath(0, i) : mrMat.IsEmptyPath(i, 0);
+    }
+
+    bool IsValue(SCSIZE i) const
+    {
+        return mbColVec ? mrMat.IsValue(0, i) : mrMat.IsValue(i, 0);
+    }
+
+    bool IsString(SCSIZE i) const
+    {
+        return mbColVec ? mrMat.IsString(0, i) : mrMat.IsString(i, 0);
+    }
+
+    double GetDouble(SCSIZE i) const
+    {
+        return mbColVec ? mrMat.GetDouble(0, i) : mrMat.GetDouble(i, 0);
+    }
+
+    const String& GetString(SCSIZE i) const
+    {
+        return mbColVec ? mrMat.GetString(0, i) : mrMat.GetString(i, 0);
+    }
+
+private:
+    const ScMatrix& mrMat;
+    bool mbColVec;
+};
+
 /** returns -1 when the matrix value is smaller than the query value, 0 when
     they are equal, and 1 when the matrix value is larger than the query
     value. */
-static sal_Int32 lcl_CompareMatrix2Query( SCSIZE i, const ScMatrix& rMat,
-        const ScQueryEntry& rEntry)
+static sal_Int32 lcl_CompareMatrix2Query(
+    SCSIZE i, const VectorMatrixAccessor& rMat, const ScQueryEntry& rEntry)
 {
     if (rMat.IsEmpty(i))
     {
@@ -4096,7 +4142,7 @@ static sal_Int32 lcl_CompareMatrix2Query( SCSIZE i, const ScMatrix& rMat,
 
 /** returns the last item with the identical value as the original item
     value. */
-static void lcl_GetLastMatch( SCSIZE& rIndex, const ScMatrix& rMat,
+static void lcl_GetLastMatch( SCSIZE& rIndex, const VectorMatrixAccessor& rMat,
         SCSIZE nMatCount, bool bReverse)
 {
     if (rMat.IsValue(rIndex))
@@ -4148,6 +4194,8 @@ static void lcl_GetLastMatch( SCSIZE& rIndex, const ScMatrix& rMat,
     }
 }
 
+}
+
 void ScInterpreter::ScMatch()
 {
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScMatch" );
@@ -4320,6 +4368,7 @@ void ScInterpreter::ScMatch()
                     return;
                 }
                 SCSIZE nMatCount = (nC == 1) ? nR : nC;
+                VectorMatrixAccessor aMatAcc(*pMatSrc, nC == 1);
 
                 // simple serial search for equality mode (source data doesn't
                 // need to be sorted).
@@ -4328,7 +4377,7 @@ void ScInterpreter::ScMatch()
                 {
                     for (SCSIZE i = 0; i < nMatCount; ++i)
                     {
-                        if (lcl_CompareMatrix2Query( i, *pMatSrc, rEntry) == 0)
+                        if (lcl_CompareMatrix2Query( i, aMatAcc, rEntry) == 0)
                         {
                             PushDouble(i+1); // found !
                             return;
@@ -4346,11 +4395,11 @@ void ScInterpreter::ScMatch()
                 for (SCSIZE nLen = nLast-nFirst; nLen > 0; nLen = nLast-nFirst)
                 {
                     SCSIZE nMid = nFirst + nLen/2;
-                    sal_Int32 nCmp = lcl_CompareMatrix2Query( nMid, *pMatSrc, rEntry);
+                    sal_Int32 nCmp = lcl_CompareMatrix2Query( nMid, aMatAcc, rEntry);
                     if (nCmp == 0)
                     {
                         // exact match.  find the last item with the same value.
-                        lcl_GetLastMatch( nMid, *pMatSrc, nMatCount, !bAscOrder);
+                        lcl_GetLastMatch( nMid, aMatAcc, nMatCount, !bAscOrder);
                         PushDouble( nMid+1);
                         return;
                     }
@@ -4382,7 +4431,7 @@ void ScInterpreter::ScMatch()
 
                 if (nHitIndex == nMatCount-1) // last item
                 {
-                    sal_Int32 nCmp = lcl_CompareMatrix2Query( nHitIndex, *pMatSrc, rEntry);
+                    sal_Int32 nCmp = lcl_CompareMatrix2Query( nHitIndex, aMatAcc, rEntry);
                     if ((bAscOrder && nCmp <= 0) || (!bAscOrder && nCmp >= 0))
                     {
                         // either the last item is an exact match or the real
@@ -5337,6 +5386,8 @@ void ScInterpreter::ScLookup()
             pDataMat2 = pTempMat;
         }
 
+        VectorMatrixAccessor aMatAcc2(*pDataMat2, bVertical);
+
         // binary search for non-equality mode (the source data is
         // assumed to be sorted in ascending order).
 
@@ -5346,11 +5397,11 @@ void ScInterpreter::ScLookup()
         for (SCSIZE nLen = nLast-nFirst; nLen > 0; nLen = nLast-nFirst)
         {
             SCSIZE nMid = nFirst + nLen/2;
-            sal_Int32 nCmp = lcl_CompareMatrix2Query( nMid, *pDataMat2, rEntry);
+            sal_Int32 nCmp = lcl_CompareMatrix2Query( nMid, aMatAcc2, rEntry);
             if (nCmp == 0)
             {
                 // exact match.  find the last item with the same value.
-                lcl_GetLastMatch( nMid, *pDataMat2, nLenMajor, false);
+                lcl_GetLastMatch( nMid, aMatAcc2, nLenMajor, false);
                 nDelta = nMid;
                 bFound = true;
                 break;
@@ -5372,7 +5423,7 @@ void ScInterpreter::ScLookup()
 
         if (nDelta == static_cast<SCCOLROW>(nLenMajor-2)) // last item
         {
-            sal_Int32 nCmp = lcl_CompareMatrix2Query(nDelta+1, *pDataMat2, rEntry);
+            sal_Int32 nCmp = lcl_CompareMatrix2Query(nDelta+1, aMatAcc2, rEntry);
             if (nCmp <= 0)
             {
                 // either the last item is an exact match or the real
commit 1652ca31cda76aabd1b018ddbac57cde61ef7a86
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Sun Nov 7 00:18:00 2010 -0400

    More on one-param method removal.

diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index f71e1c2..85e92f1 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -331,7 +331,6 @@ public:
         string is returned; an empty string for empty, a "FALSE" string for
         empty path. */
     String GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSIZE nR) const;
-    String GetString( SvNumberFormatter& rFormatter, SCSIZE nIndex) const;
 
     /// @ATTENTION: If bString the ScMatrixValue->pS may still be NULL to indicate
     /// an empty string!
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index a732be1..e57c497 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -188,7 +188,6 @@ public:
     double GetDouble( SCSIZE nIndex) const;
     const String& GetString(SCSIZE nC, SCSIZE nR) const;
     const String& GetString( SCSIZE nIndex) const;
-    String GetString( SvNumberFormatter& rFormatter, SCSIZE nIndex) const;
     String GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSIZE nR) const;
     ScMatrixValue Get(SCSIZE nC, SCSIZE nR) const;
     BOOL IsString( SCSIZE nIndex ) const;
@@ -463,14 +462,6 @@ const String& ScMatrixImpl::GetString( SCSIZE nIndex) const
     return GetString(nC, nR);
 }
 
-String ScMatrixImpl::GetString( SvNumberFormatter& rFormatter, SCSIZE nIndex) const
-{
-    SCSIZE nC, nR;
-    CalcPosition(nIndex, nC, nR);
-    return GetString(rFormatter, nC, nR);
-}
-
-
 String ScMatrixImpl::GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSIZE nR) const
 {
     if (!ValidColRowOrReplicated( nC, nR ))
@@ -916,11 +907,6 @@ const String& ScMatrix::GetString( SCSIZE nIndex) const
     return pImpl->GetString(nIndex);
 }
 
-String ScMatrix::GetString( SvNumberFormatter& rFormatter, SCSIZE nIndex) const
-{
-    return pImpl->GetString(rFormatter, nIndex);
-}
-
 String ScMatrix::GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSIZE nR) const
 {
     return pImpl->GetString(rFormatter, nC, nR);
commit d09bc08ba436dbd3a6e4a9c8c11f2b77c14d2b72
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Sun Nov 7 00:17:33 2010 -0400

    More on removal of methods that take nIndex.

diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index 3072a5b..f71e1c2 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -310,7 +310,6 @@ public:
                     Use GetErrorIfNotString() instead if not sure.
         @returns 0 if no error, else one of err... constants */
     USHORT GetError( SCSIZE nC, SCSIZE nR) const;
-    USHORT GetError( SCSIZE nIndex) const;
 
     /** Use in ScInterpreter to obtain the error code, if any.
         @returns 0 if no error or string element, else one of err... constants */
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index ecf9468..a732be1 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -184,7 +184,6 @@ public:
     void PutError( USHORT nErrorCode, SCSIZE nC, SCSIZE nR );
     void PutBoolean(bool bVal, SCSIZE nC, SCSIZE nR);
     USHORT GetError( SCSIZE nC, SCSIZE nR) const;
-    USHORT GetError( SCSIZE nIndex) const;
     double GetDouble(SCSIZE nC, SCSIZE nR) const;
     double GetDouble( SCSIZE nIndex) const;
     const String& GetString(SCSIZE nC, SCSIZE nR) const;
@@ -411,13 +410,6 @@ USHORT ScMatrixImpl::GetError( SCSIZE nC, SCSIZE nR) const
     }
 }
 
-USHORT ScMatrixImpl::GetError( SCSIZE nIndex) const
-{
-    SCSIZE nC, nR;
-    CalcPosition(nIndex, nC, nR);
-    return GetError(nC, nR);
-}
-
 double ScMatrixImpl::GetDouble(SCSIZE nC, SCSIZE nR) const
 {
     if (ValidColRowOrReplicated( nC, nR ))
@@ -473,9 +465,23 @@ const String& ScMatrixImpl::GetString( SCSIZE nIndex) const
 
 String ScMatrixImpl::GetString( SvNumberFormatter& rFormatter, SCSIZE nIndex) const
 {
-    if (IsString( nIndex))
+    SCSIZE nC, nR;
+    CalcPosition(nIndex, nC, nR);
+    return GetString(rFormatter, nC, nR);
+}
+
+
+String ScMatrixImpl::GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSIZE nR) const
+{
+    if (!ValidColRowOrReplicated( nC, nR ))
     {
-        if (IsEmptyPath( nIndex))
+        DBG_ERRORFILE("ScMatrixImpl::GetString: dimension error");
+        return String();
+    }
+
+    if (IsString( nC, nR))
+    {
+        if (IsEmptyPath( nC, nR))
         {   // result of empty FALSE jump path
             ULONG nKey = rFormatter.GetStandardFormat( NUMBERFORMAT_LOGICAL,
                     ScGlobal::eLnge);
@@ -484,17 +490,17 @@ String ScMatrixImpl::GetString( SvNumberFormatter& rFormatter, SCSIZE nIndex) co
             rFormatter.GetOutputString( 0.0, nKey, aStr, &pColor);
             return aStr;
         }
-        return GetString( nIndex );
+        return GetString( nC, nR);
     }
 
-    USHORT nError = GetError( nIndex);
+    USHORT nError = GetError( nC, nR);
     if (nError)
     {
         SetErrorAtInterpreter( nError);
         return ScGlobal::GetErrorString( nError);
     }
 
-    double fVal= GetDouble( nIndex);
+    double fVal= GetDouble( nC, nR);
     ULONG nKey = rFormatter.GetStandardFormat( NUMBERFORMAT_NUMBER,
             ScGlobal::eLnge);
     String aStr;
@@ -502,19 +508,6 @@ String ScMatrixImpl::GetString( SvNumberFormatter& rFormatter, SCSIZE nIndex) co
     return aStr;
 }
 
-String ScMatrixImpl::GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSIZE nR) const
-{
-    if (ValidColRowOrReplicated( nC, nR ))
-    {
-        SCSIZE nIndex = CalcOffset( nC, nR);
-        return GetString( rFormatter, nIndex);
-    }
-    else
-    {
-        DBG_ERRORFILE("ScMatrixImpl::GetString: dimension error");
-    }
-    return String();
-}
 
 ScMatrixValue ScMatrixImpl::Get(SCSIZE nC, SCSIZE nR) const
 {
@@ -903,11 +896,6 @@ USHORT ScMatrix::GetError( SCSIZE nC, SCSIZE nR) const
     return pImpl->GetError(nC, nR);
 }
 
-USHORT ScMatrix::GetError( SCSIZE nIndex) const
-{
-    return pImpl->GetError(nIndex);
-}
-
 double ScMatrix::GetDouble(SCSIZE nC, SCSIZE nR) const
 {
     return pImpl->GetDouble(nC, nR);
commit d7fc120eb1427e847cfdbe6b4419fd3dd1e19ce4
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Sun Nov 7 00:16:35 2010 -0400

    No more PutBoolean(SCSIZE nIndex).

diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index 148f1db..3072a5b 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -300,7 +300,6 @@ public:
     void PutEmptyPath( SCSIZE nC, SCSIZE nR);
     void PutError( USHORT nErrorCode, SCSIZE nC, SCSIZE nR );
     void PutBoolean( bool bVal, SCSIZE nC, SCSIZE nR);
-    void PutBoolean( bool bVal, SCSIZE nIndex);
 
     void FillDouble( double fVal,
             SCSIZE nC1, SCSIZE nR1, SCSIZE nC2, SCSIZE nR2 );
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 7bcf781..ecf9468 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -183,7 +183,6 @@ public:
     void PutEmptyPath(SCSIZE nC, SCSIZE nR);
     void PutError( USHORT nErrorCode, SCSIZE nC, SCSIZE nR );
     void PutBoolean(bool bVal, SCSIZE nC, SCSIZE nR);
-    void PutBoolean( bool bVal, SCSIZE nIndex);
     USHORT GetError( SCSIZE nC, SCSIZE nR) const;
     USHORT GetError( SCSIZE nIndex) const;
     double GetDouble(SCSIZE nC, SCSIZE nR) const;
@@ -398,13 +397,6 @@ void ScMatrixImpl::PutBoolean(bool bVal, SCSIZE nC, SCSIZE nR)
     }
 }
 
-void ScMatrixImpl::PutBoolean( bool bVal, SCSIZE nIndex)
-{
-    SCSIZE nC, nR;
-    CalcPosition(nIndex, nC, nR);
-    PutBoolean(bVal, nC, nR);
-}
-
 USHORT ScMatrixImpl::GetError( SCSIZE nC, SCSIZE nR) const
 {
     if (ValidColRowOrReplicated( nC, nR ))
@@ -906,11 +898,6 @@ void ScMatrix::PutBoolean(bool bVal, SCSIZE nC, SCSIZE nR)
     pImpl->PutBoolean(bVal, nC, nR);
 }
 
-void ScMatrix::PutBoolean( bool bVal, SCSIZE nIndex)
-{
-    pImpl->PutBoolean(bVal, nIndex);
-}
-
 USHORT ScMatrix::GetError( SCSIZE nC, SCSIZE nR) const
 {
     return pImpl->GetError(nC, nR);
commit a2abbb94d374ce396d7500f38d0742b6f708b1f1
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Sun Nov 7 00:15:52 2010 -0400

    More elimination of single-parameter methods from ScMatrix.

diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index 3fa9409..148f1db 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -298,9 +298,7 @@ public:
     void PutEmpty( SCSIZE nC, SCSIZE nR);
     /// Jump FALSE without path
     void PutEmptyPath( SCSIZE nC, SCSIZE nR);
-    void PutEmptyPath( SCSIZE nIndex);
     void PutError( USHORT nErrorCode, SCSIZE nC, SCSIZE nR );
-    void PutError( USHORT nErrorCode, SCSIZE nIndex );
     void PutBoolean( bool bVal, SCSIZE nC, SCSIZE nR);
     void PutBoolean( bool bVal, SCSIZE nIndex);
 
@@ -319,8 +317,6 @@ public:
         @returns 0 if no error or string element, else one of err... constants */
     USHORT GetErrorIfNotString( SCSIZE nC, SCSIZE nR) const
         { return IsValue( nC, nR) ? GetError( nC, nR) : 0; }
-    USHORT GetErrorIfNotString( SCSIZE nIndex) const
-        { return IsValue( nIndex) ? GetError( nIndex) : 0; }
 
     /// @return 0.0 if empty or empty path, else value or DoubleError.
     double GetDouble( SCSIZE nC, SCSIZE nR) const;
diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index 9a7540a..ccd812d 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -660,7 +660,7 @@ bool ScValidationData::GetSelectionFromFormula( TypedScStrCollection* pStrings,
              * rStrResult += ScGlobal::GetLongErrorString(nErrCode);
              */
 
-            xMatRef->PutError( nErrCode, 0);
+            xMatRef->PutError( nErrCode, 0, 0);
             bOk = false;
         }
         else if (aValidationSrc.HasValueData())
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index f42f3dc..4c32894 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -2144,8 +2144,8 @@ void ScInterpreter::ScIsValue()
                 ;   // nothing
             else if ( !pJumpMatrix )
             {
-                if (pMat->GetErrorIfNotString( 0 ) == 0)
-                    nRes = pMat->IsValue( 0 );
+                if (pMat->GetErrorIfNotString( 0, 0) == 0)
+                    nRes = pMat->IsValue( 0, 0);
             }
             else
             {
@@ -2250,7 +2250,7 @@ void ScInterpreter::ScIsNV()
             if ( !pMat )
                 ;   // nothing
             else if ( !pJumpMatrix )
-                nRes = (pMat->GetErrorIfNotString( 0 ) == NOTAVAILABLE);
+                nRes = (pMat->GetErrorIfNotString( 0, 0) == NOTAVAILABLE);
             else
             {
                 SCSIZE nCols, nRows, nC, nR;
@@ -2300,7 +2300,7 @@ void ScInterpreter::ScIsErr()
                 nRes = ((nGlobalError && nGlobalError != NOTAVAILABLE) || !pMat);
             else if ( !pJumpMatrix )
             {
-                USHORT nErr = pMat->GetErrorIfNotString( 0 );
+                USHORT nErr = pMat->GetErrorIfNotString( 0, 0);
                 nRes = (nErr && nErr != NOTAVAILABLE);
             }
             else
@@ -2357,7 +2357,7 @@ void ScInterpreter::ScIsError()
             if ( nGlobalError || !pMat )
                 nRes = 1;
             else if ( !pJumpMatrix )
-                nRes = (pMat->GetErrorIfNotString( 0 ) != 0);
+                nRes = (pMat->GetErrorIfNotString( 0, 0) != 0);
             else
             {
                 SCSIZE nCols, nRows, nC, nR;
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index fdae46e..b8481e1 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -1339,41 +1339,43 @@ void ScInterpreter::ScAmpersand()
         ScMatrixRef pResMat = GetNewMat(nC, nR);
         if (pResMat)
         {
-            SCSIZE nCount = nC * nR;
             if (nGlobalError)
             {
-                for ( SCSIZE i = 0; i < nCount; i++ )
-                    pResMat->PutError( nGlobalError, i);
+                for (SCSIZE i = 0; i < nC; ++i)
+                    for (SCSIZE j = 0; j < nR; ++j)
+                        pResMat->PutError( nGlobalError, i, j);
             }
             else if (bFlag)
             {
-                for ( SCSIZE i = 0; i < nCount; i++ )
-                {
-                    USHORT nErr = pMat->GetErrorIfNotString( i);
-                    if (nErr)
-                        pResMat->PutError( nErr, i);
-                    else
+                for (SCSIZE i = 0; i < nC; ++i)
+                    for (SCSIZE j = 0; j < nR; ++j)
                     {
-                        String aTmp( sStr);
-                        aTmp += pMat->GetString( *pFormatter, i);
-                        pResMat->PutString( aTmp, i);
+                        USHORT nErr = pMat->GetErrorIfNotString( i, j);
+                        if (nErr)
+                            pResMat->PutError( nErr, i, j);
+                        else
+                        {
+                            String aTmp( sStr);
+                            aTmp += pMat->GetString( *pFormatter, i, j);
+                            pResMat->PutString( aTmp, i, j);
+                        }
                     }
-                }
             }
             else
             {
-                for ( SCSIZE i = 0; i < nCount; i++ )
-                {
-                    USHORT nErr = pMat->GetErrorIfNotString( i);
-                    if (nErr)
-                        pResMat->PutError( nErr, i);
-                    else
+                for (SCSIZE i = 0; i < nC; ++i)
+                    for (SCSIZE j = 0; j < nR; ++j)
                     {
-                        String aTmp( pMat->GetString( *pFormatter, i));
-                        aTmp += sStr;
-                        pResMat->PutString( aTmp, i);
+                        USHORT nErr = pMat->GetErrorIfNotString( i, j);
+                        if (nErr)
+                            pResMat->PutError( nErr, i, j);
+                        else
+                        {
+                            String aTmp( pMat->GetString( *pFormatter, i, j));
+                            aTmp += sStr;
+                            pResMat->PutString( aTmp, i, j);
+                        }
                     }
-                }
             }
             PushMatrix(pResMat);
         }
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 36e71c4..7bcf781 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -181,9 +181,7 @@ public:
 
     void PutEmpty(SCSIZE nC, SCSIZE nR);
     void PutEmptyPath(SCSIZE nC, SCSIZE nR);
-    void PutEmptyPath(SCSIZE nIndex);
     void PutError( USHORT nErrorCode, SCSIZE nC, SCSIZE nR );
-    void PutError( USHORT nErrorCode, SCSIZE nIndex );
     void PutBoolean(bool bVal, SCSIZE nC, SCSIZE nR);
     void PutBoolean( bool bVal, SCSIZE nIndex);
     USHORT GetError( SCSIZE nC, SCSIZE nR) const;
@@ -385,25 +383,11 @@ void ScMatrixImpl::PutEmptyPath(SCSIZE nC, SCSIZE nR)
     }
 }
 
-void ScMatrixImpl::PutEmptyPath(SCSIZE nIndex)
-{
-    SCSIZE nC, nR;
-    CalcPosition(nIndex, nC, nR);
-    PutEmptyPath(nC, nR);
-}
-
 void ScMatrixImpl::PutError( USHORT nErrorCode, SCSIZE nC, SCSIZE nR )
 {
     maMat.set_numeric(nR, nC, CreateDoubleError(nErrorCode));
 }
 
-void ScMatrixImpl::PutError( USHORT nErrorCode, SCSIZE nIndex )
-{
-    SCSIZE nC, nR;
-    CalcPosition(nIndex, nC, nR);
-    PutError(nErrorCode, nC, nR);
-}
-
 void ScMatrixImpl::PutBoolean(bool bVal, SCSIZE nC, SCSIZE nR)
 {
     if (ValidColRow( nC, nR))
@@ -912,21 +896,11 @@ void ScMatrix::PutEmptyPath(SCSIZE nC, SCSIZE nR)
     pImpl->PutEmptyPath(nC, nR);
 }
 
-void ScMatrix::PutEmptyPath(SCSIZE nIndex)
-{
-    pImpl->PutEmptyPath(nIndex);
-}
-
 void ScMatrix::PutError( USHORT nErrorCode, SCSIZE nC, SCSIZE nR )
 {
     pImpl->PutError(nErrorCode, nC, nR);
 }
 
-void ScMatrix::PutError( USHORT nErrorCode, SCSIZE nIndex )
-{
-    pImpl->PutError(nErrorCode, nIndex);
-}
-
 void ScMatrix::PutBoolean(bool bVal, SCSIZE nC, SCSIZE nR)
 {
     pImpl->PutBoolean(bVal, nC, nR);
commit 20010cd245a3897e36fde4d15ef0703f8eeefa4b
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Sun Nov 7 00:15:19 2010 -0400

    Removed the one parameter version of IsValueOrEmpty() method.

diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index c821bf0..3fa9409 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -368,9 +368,6 @@ public:
     BOOL IsValue( SCSIZE nC, SCSIZE nR ) const;
 
     /// @return <TRUE/> if value or boolean or empty or empty path.
-    BOOL IsValueOrEmpty( SCSIZE nIndex ) const;
-
-    /// @return <TRUE/> if value or boolean or empty or empty path.
     BOOL IsValueOrEmpty( SCSIZE nC, SCSIZE nR ) const;
 
     /// @return <TRUE/> if boolean.
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 2a82e17..f42f3dc 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -1333,14 +1333,16 @@ void ScInterpreter::ScNeg()
                     PushIllegalArgument();
                 else
                 {
-                    SCSIZE nCount = nC * nR;
-                    for ( SCSIZE j=0; j<nCount; ++j )
+                    for (SCSIZE i = 0; i < nC; ++i)
                     {
-                        if ( pMat->IsValueOrEmpty(j) )
-                            pResMat->PutDouble( -pMat->GetDouble(j), j );
-                        else
-                            pResMat->PutString(
-                                ScGlobal::GetRscString( STR_NO_VALUE ), j );
+                        for (SCSIZE j = 0; j < nR; ++j)
+                        {
+                            if ( pMat->IsValueOrEmpty(i,j) )
+                                pResMat->PutDouble( -pMat->GetDouble(i,j), i, j );
+                            else
+                                pResMat->PutString(
+                                    ScGlobal::GetRscString( STR_NO_VALUE ), i, j );
+                        }
                     }
                     PushMatrix( pResMat );
                 }
@@ -1389,14 +1391,16 @@ void ScInterpreter::ScNot()
                     PushIllegalArgument();
                 else
                 {
-                    SCSIZE nCount = nC * nR;
-                    for ( SCSIZE j=0; j<nCount; ++j )
+                    for (SCSIZE i = 0; i < nC; ++i)
                     {
-                        if ( pMat->IsValueOrEmpty(j) )
-                            pResMat->PutDouble( (pMat->GetDouble(j) == 0.0), j );
-                        else
-                            pResMat->PutString(
-                                ScGlobal::GetRscString( STR_NO_VALUE ), j );
+                        for (SCSIZE j = 0; j < nR; ++j)
+                        {
+                            if ( pMat->IsValueOrEmpty(i,j) )
+                                pResMat->PutDouble( (pMat->GetDouble(i,j) == 0.0), i, j );
+                            else
+                                pResMat->PutString(
+                                    ScGlobal::GetRscString( STR_NO_VALUE ), i, j );
+                        }
                     }
                     PushMatrix( pResMat );
                 }
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 1a4a6a1..36e71c4 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -203,7 +203,6 @@ public:
     BOOL IsEmptyPath( SCSIZE nIndex ) const;
     BOOL IsValue( SCSIZE nIndex ) const;
     BOOL IsValue( SCSIZE nC, SCSIZE nR ) const;
-    BOOL IsValueOrEmpty( SCSIZE nIndex ) const;
     BOOL IsValueOrEmpty( SCSIZE nC, SCSIZE nR ) const;
     BOOL IsBoolean( SCSIZE nC, SCSIZE nR ) const;
     BOOL IsNumeric() const;
@@ -643,13 +642,6 @@ BOOL ScMatrixImpl::IsValue( SCSIZE nC, SCSIZE nR ) const
     return false;
 }
 
-BOOL ScMatrixImpl::IsValueOrEmpty( SCSIZE nIndex ) const
-{
-    SCSIZE nC, nR;
-    CalcPosition(nIndex, nC, nR);
-    return IsValueOrEmpty(nC, nR);
-}
-
 BOOL ScMatrixImpl::IsValueOrEmpty( SCSIZE nC, SCSIZE nR ) const
 {
     ValidColRowReplicated(nC, nR);
@@ -1030,11 +1022,6 @@ BOOL ScMatrix::IsValue( SCSIZE nC, SCSIZE nR ) const
     return pImpl->IsValue(nC, nR);
 }
 
-BOOL ScMatrix::IsValueOrEmpty( SCSIZE nIndex ) const
-{
-    return pImpl->IsValueOrEmpty(nIndex);
-}
-
 BOOL ScMatrix::IsValueOrEmpty( SCSIZE nC, SCSIZE nR ) const
 {
     return pImpl->IsValueOrEmpty(nC, nR);
commit a96a519c1fe1729c4b5647cf25be92de44324108
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Sun Nov 7 00:14:45 2010 -0400

    Removed the single-parameter version of IsBoolean().

diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index 67765a5..c821bf0 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -374,9 +374,6 @@ public:
     BOOL IsValueOrEmpty( SCSIZE nC, SCSIZE nR ) const;
 
     /// @return <TRUE/> if boolean.
-    BOOL IsBoolean( SCSIZE nIndex ) const;
-
-    /// @return <TRUE/> if boolean.
     BOOL IsBoolean( SCSIZE nC, SCSIZE nR ) const;
 
     /// @return <TRUE/> if entire matrix is numeric, including booleans, with no strings or empties
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index d44ca8d..1a4a6a1 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -205,7 +205,6 @@ public:
     BOOL IsValue( SCSIZE nC, SCSIZE nR ) const;
     BOOL IsValueOrEmpty( SCSIZE nIndex ) const;
     BOOL IsValueOrEmpty( SCSIZE nC, SCSIZE nR ) const;
-    BOOL IsBoolean( SCSIZE nIndex ) const;
     BOOL IsBoolean( SCSIZE nC, SCSIZE nR ) const;
     BOOL IsNumeric() const;
     void MatCopy(ScMatrixImpl& mRes) const;
@@ -665,12 +664,6 @@ BOOL ScMatrixImpl::IsValueOrEmpty( SCSIZE nC, SCSIZE nR ) const
     }
     return false;
 }
-BOOL ScMatrixImpl::IsBoolean( SCSIZE nIndex ) const
-{
-    SCSIZE nC, nR;
-    CalcPosition(nIndex, nC, nR);
-    return IsBoolean(nC, nR);
-}
 
 BOOL ScMatrixImpl::IsBoolean( SCSIZE nC, SCSIZE nR ) const
 {
@@ -1047,11 +1040,6 @@ BOOL ScMatrix::IsValueOrEmpty( SCSIZE nC, SCSIZE nR ) const
     return pImpl->IsValueOrEmpty(nC, nR);
 }
 
-BOOL ScMatrix::IsBoolean( SCSIZE nIndex ) const
-{
-    return pImpl->IsBoolean(nIndex);
-}
-
 BOOL ScMatrix::IsBoolean( SCSIZE nC, SCSIZE nR ) const
 {
     return pImpl->IsBoolean(nC, nR);
commit 256716de936822998255e186f26aae5fd4cea900
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Sun Nov 7 00:13:38 2010 -0400

    Removed PutEmpty(index).
    
    The one-argument version makes no sense since the internal storage
    is no longer linear.

diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index 2e5be0c..67765a5 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -296,7 +296,6 @@ public:
     void PutString( const String& rStr, SCSIZE nC, SCSIZE nR);
     void PutString( const String& rStr, SCSIZE nIndex);
     void PutEmpty( SCSIZE nC, SCSIZE nR);
-    void PutEmpty( SCSIZE nIndex);
     /// Jump FALSE without path
     void PutEmptyPath( SCSIZE nC, SCSIZE nR);
     void PutEmptyPath( SCSIZE nIndex);
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index 6098751..fdae46e 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -466,7 +466,7 @@ ScMatrixRef ScInterpreter::GetMatrix()
             {
                 ScBaseCell* pCell = GetCell( aAdr );
                 if (HasCellEmptyData(pCell))
-                    pMat->PutEmpty( 0 );
+                    pMat->PutEmpty(0, 0);
                 else if (HasCellValueData(pCell))
                     pMat->PutDouble(GetCellValue(aAdr, pCell), 0);
                 else
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index a9ab540..d44ca8d 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -128,13 +128,13 @@ void compareMatrix(MatrixImplType& rMat)
 {
     switch (eType)
     {
-        case FILLED_EMPTY:
+        case ScMatrix::FILLED_EMPTY:
             return mdds::matrix_density_filled_empty;
-        case FILLED_ZERO:
+        case ScMatrix::FILLED_ZERO:
             return mdds::matrix_density_filled_zero;
-        case SPARSE_EMPTY:
+        case ScMatrix::SPARSE_EMPTY:
             return mdds::matrix_density_sparse_empty;
-        case SPARSE_ZERO:
+        case ScMatrix::SPARSE_ZERO:
             return mdds::matrix_density_sparse_zero;
         default:
             ;
@@ -180,7 +180,6 @@ public:
     void PutString(const String& rStr, SCSIZE nIndex);
 
     void PutEmpty(SCSIZE nC, SCSIZE nR);
-    void PutEmpty(SCSIZE nIndex);
     void PutEmptyPath(SCSIZE nC, SCSIZE nR);
     void PutEmptyPath(SCSIZE nIndex);
     void PutError( USHORT nErrorCode, SCSIZE nC, SCSIZE nR );
@@ -367,7 +366,7 @@ void ScMatrixImpl::PutEmpty(SCSIZE nC, SCSIZE nR)
     if (ValidColRow( nC, nR))
     {
         maMat.set_empty(nR, nC);
-        maMat.clear_flag(nR, nC);
+        maMat.clear_flag(nR, nC); // zero flag to indicate that this is 'empty', not 'empty path'.
     }
     else
     {
@@ -375,13 +374,6 @@ void ScMatrixImpl::PutEmpty(SCSIZE nC, SCSIZE nR)
     }
 }
 
-void ScMatrixImpl::PutEmpty(SCSIZE nIndex)
-{
-    SCSIZE nC, nR;
-    CalcPosition(nIndex, nC, nR);
-    PutEmpty(nC, nR);
-}
-
 void ScMatrixImpl::PutEmptyPath(SCSIZE nC, SCSIZE nR)
 {
     if (ValidColRow( nC, nR))
@@ -930,11 +922,6 @@ void ScMatrix::PutEmpty(SCSIZE nC, SCSIZE nR)
     pImpl->PutEmpty(nC, nR);
 }
 
-void ScMatrix::PutEmpty(SCSIZE nIndex)
-{
-    pImpl->PutEmpty(nIndex);
-}
-
 void ScMatrix::PutEmptyPath(SCSIZE nC, SCSIZE nR)
 {
     pImpl->PutEmptyPath(nC, nR);
commit 02f9a72f7f27fbd425526624b73aadbf1b0962f5
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Sun Nov 7 00:10:39 2010 -0400

    Support different density types for ScMatrix instances.

diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index 5f64433..2e5be0c 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -163,6 +163,13 @@ class SC_DLLPUBLIC ScMatrix
     ScMatrix& operator=( const ScMatrix&);
 
 public:
+    enum DensityType
+    {
+        FILLED_ZERO,
+        FILLED_EMPTY,
+        SPARSE_ZERO,
+        SPARSE_EMPTY
+    };
 
     /// The maximum number of elements a matrix may have at runtime.
     inline static size_t GetElementsMax()
@@ -216,10 +223,10 @@ public:
     /** If nC*nR results in more than GetElementsMax() entries, a 1x1 matrix is
         created instead and a double error value (errStackOverflow) is set.
         Compare nC and nR with a GetDimensions() call to check. */
-    ScMatrix( SCSIZE nC, SCSIZE nR);
+    ScMatrix( SCSIZE nC, SCSIZE nR, DensityType eType = FILLED_ZERO);
 
     /** Clone the matrix. */
-    ScMatrix* Clone() const;
+    ScMatrix* Clone( DensityType eType) const;
 
     /** Clone the matrix if mbCloneIfConst (immutable) is set, otherwise 
         return _this_ matrix, to be assigned to a ScMatrixRef. */
@@ -237,7 +244,7 @@ public:
 
     /** Clone the matrix and extend it to the new size. nNewCols and nNewRows
         MUST be at least of the size of the original matrix. */
-    ScMatrix* CloneAndExtend( SCSIZE nNewCols, SCSIZE nNewRows ) const;
+    ScMatrix* CloneAndExtend( SCSIZE nNewCols, SCSIZE nNewRows, DensityType eType) const;
 
     /// Disable refcounting forever, may only be deleted via Delete() afterwards.
     inline  void    SetEternalRef()         { nRefCnt = ULONG_MAX; }
@@ -261,6 +268,7 @@ public:
             --nRefCnt;
     }
 
+    DensityType GetDensityType() const;
     void SetErrorInterpreter( ScInterpreter* p);
     void GetDimensions( SCSIZE& rC, SCSIZE& rR) const;
     SCSIZE GetElementCount() const;
diff --git a/sc/source/core/inc/jumpmatrix.hxx b/sc/source/core/inc/jumpmatrix.hxx
index 38e2480..351cbc6 100644
--- a/sc/source/core/inc/jumpmatrix.hxx
+++ b/sc/source/core/inc/jumpmatrix.hxx
@@ -195,7 +195,7 @@ public:
                                     {
                                         if ( nNewCols > nResMatCols || nNewRows > nResMatRows )
                                         {
-                                            pMat = pMat->CloneAndExtend( nNewCols, nNewRows );
+                                            pMat = pMat->CloneAndExtend( nNewCols, nNewRows, pMat->GetDensityType() );
                                             if ( nResMatCols < nNewCols )
                                             {
                                                 pMat->FillDouble( CreateDoubleError(
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index cbf786d..a9ab540 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -124,22 +124,46 @@ void compareMatrix(MatrixImplType& rMat)
     }
 }
 
+::mdds::matrix_density_t toMddsDensityType(ScMatrix::DensityType eType)
+{
+    switch (eType)
+    {
+        case FILLED_EMPTY:
+            return mdds::matrix_density_filled_empty;
+        case FILLED_ZERO:
+            return mdds::matrix_density_filled_zero;
+        case SPARSE_EMPTY:
+            return mdds::matrix_density_sparse_empty;
+        case SPARSE_ZERO:
+            return mdds::matrix_density_sparse_zero;
+        default:
+            ;
+    }
+
+    // default density type
+    return mdds::matrix_density_filled_zero;
+}
+
 }
 
 class ScMatrixImpl
 {
     MatrixImplType maMat;
+    ScMatrix::DensityType meType;
     ScInterpreter* pErrorInterpreter;
     bool            mbCloneIfConst; // Whether the matrix is cloned with a CloneIfConst() call.
 
+    ScMatrixImpl();
+    ScMatrixImpl(const ScMatrixImpl&);
 public:
-    ScMatrixImpl(SCSIZE nC, SCSIZE nR);
+    ScMatrixImpl(SCSIZE nC, SCSIZE nR, ScMatrix::DensityType eType);
     ~ScMatrixImpl();
 
     void Clear();
     void SetImmutable(bool bVal);
     bool IsImmutable() const;
     void Resize(SCSIZE nC, SCSIZE nR);
+    ScMatrix::DensityType GetDensityType() const;
     void SetErrorInterpreter( ScInterpreter* p);
     ScInterpreter* GetErrorInterpreter() const { return pErrorInterpreter; }
 
@@ -201,8 +225,9 @@ private:
     void CalcPosition(SCSIZE nIndex, SCSIZE& rC, SCSIZE& rR) const;
 };
 
-ScMatrixImpl::ScMatrixImpl(SCSIZE nC, SCSIZE nR) :
-    maMat(nR, nC, ::mdds::matrix_density_filled_zero),
+ScMatrixImpl::ScMatrixImpl(SCSIZE nC, SCSIZE nR, ScMatrix::DensityType eType) :
+    maMat(nR, nC, toMddsDensityType(eType)),
+    meType(eType),
     mbCloneIfConst(true)
 {
 }
@@ -233,6 +258,11 @@ void ScMatrixImpl::Resize(SCSIZE nC, SCSIZE nR)
     Clear();
 }
 
+ScMatrix::DensityType ScMatrixImpl::GetDensityType() const
+{
+    return meType;
+}
+
 void ScMatrixImpl::SetErrorInterpreter( ScInterpreter* p)
 {
     pErrorInterpreter = p;
@@ -787,12 +817,11 @@ void ScMatrixImpl::CalcPosition(SCSIZE nIndex, SCSIZE& rC, SCSIZE& rR) const
 
 // ============================================================================
 
-ScMatrix::ScMatrix( SCSIZE nC, SCSIZE nR) :
-    pImpl(new ScMatrixImpl(nC, nR)),
+ScMatrix::ScMatrix( SCSIZE nC, SCSIZE nR, DensityType eType) :
+    pImpl(new ScMatrixImpl(nC, nR, eType)),
     nRefCnt(0)
 {
 }
-
 ScMatrix::~ScMatrix()
 {
     delete pImpl;
@@ -800,9 +829,14 @@ ScMatrix::~ScMatrix()
 
 ScMatrix* ScMatrix::Clone() const
 {
+    return Clone(GetDensityType());
+}
+
+ScMatrix* ScMatrix::Clone( DensityType eType) const
+{
     SCSIZE nC, nR;
     pImpl->GetDimensions(nC, nR);
-    ScMatrix* pScMat = new ScMatrix(nC, nR);
+    ScMatrix* pScMat = new ScMatrix(nC, nR, eType);
     MatCopy(*pScMat);
     pScMat->SetErrorInterpreter(pImpl->GetErrorInterpreter());    // TODO: really?
     return pScMat;
@@ -823,14 +857,19 @@ void ScMatrix::Resize( SCSIZE nC, SCSIZE nR)
     pImpl->Resize(nC, nR);
 }
 
-ScMatrix* ScMatrix::CloneAndExtend( SCSIZE nNewCols, SCSIZE nNewRows ) const
+ScMatrix* ScMatrix::CloneAndExtend( SCSIZE nNewCols, SCSIZE nNewRows, DensityType eType ) const
 {
-    ScMatrix* pScMat = new ScMatrix( nNewCols, nNewRows);
+    ScMatrix* pScMat = new ScMatrix( nNewCols, nNewRows, eType);
     MatCopy(*pScMat);
     pScMat->SetErrorInterpreter(pImpl->GetErrorInterpreter());
     return pScMat;
 }
 
+ScMatrix::DensityType ScMatrix::GetDensityType() const
+{
+    return pImpl->GetDensityType();
+}
+
 void ScMatrix::SetErrorInterpreter( ScInterpreter* p)
 {
     pImpl->SetErrorInterpreter(p);
commit 3d7a91cd07186c0886fc4fa54a1f55e9f504cd3a
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Sun Nov 7 00:03:53 2010 -0400

    When pulling data via DDE, empty string means empty cells.
    
    Empty cells need to be represented by empty matrix elements, not
    string elements with 0-length strings.

diff --git a/sc/source/core/tool/ddelink.cxx b/sc/source/core/tool/ddelink.cxx
index ddda951..b3d97b3 100644
--- a/sc/source/core/tool/ddelink.cxx
+++ b/sc/source/core/tool/ddelink.cxx
@@ -200,6 +200,9 @@ void __EXPORT ScDdeLink::DataChanged( const String& rMimeType,
                 double fVal;
                 if ( nMode != SC_DDE_TEXT && pFormatter->IsNumberFormat( aEntry, nIndex, fVal ) )
                     pResult->PutDouble( fVal, nC, nR );
+                else if (aEntry.Len() == 0)
+                    // empty cell
+                    pResult->PutEmpty(nC, nR);
                 else
                     pResult->PutString( aEntry, nC, nR );
             }
diff --git a/sc/source/filter/xml/XMLExportDDELinks.cxx b/sc/source/filter/xml/XMLExportDDELinks.cxx
index a2e1694..4b4ff7a 100644
--- a/sc/source/filter/xml/XMLExportDDELinks.cxx
+++ b/sc/source/filter/xml/XMLExportDDELinks.cxx
@@ -61,7 +61,7 @@ namespace {
 void WriteCell(ScXMLExport& rExport, const ScMatrixValue& aVal, sal_Int32 nRepeat)
 {
     bool bString = ScMatrix::IsNonValueType(aVal.nType);
-    bool bEmpty = ScMatrix::IsEmptyType(aVal.nType) || (bString && aVal.GetString().Len() == 0);
+    bool bEmpty = ScMatrix::IsEmptyType(aVal.nType);
 
     if (!bEmpty)
     {
commit c93b48f14fa2f281ddef535dfb799ae83756c737
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Tue Jun 29 15:38:57 2010 -0400

    Add in-line comment.

diff --git a/sc/source/filter/xml/XMLExportDDELinks.cxx b/sc/source/filter/xml/XMLExportDDELinks.cxx
index 56f3b7b..a2e1694 100644
--- a/sc/source/filter/xml/XMLExportDDELinks.cxx
+++ b/sc/source/filter/xml/XMLExportDDELinks.cxx
@@ -124,6 +124,7 @@ void ScXMLExportDDELinks::WriteTable(const sal_Int32 nPos)
             ScMatrixValue aVal = pMatrix->Get(nCol, nRow);
             if (nCol > 0 && aVal != aPrevVal)
             {
+                // Cell value differs.  Flush the cell content.
                 WriteCell(rExport, aPrevVal, nRepeat);
                 nRepeat = 0;
             }
commit 4c51dd1e35928dec135f561b84560e0d19a5cef6
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Sun Nov 7 00:02:48 2010 -0400

    Fixed export of DDE links which use matrix objects.

diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index 89d88a0..5f64433 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -79,6 +79,46 @@ struct ScMatrixValue
                 pS = r.pS;
         }
     }
+
+    bool operator== (const ScMatrixValue& r) const
+    {
+        if (nType != r.nType)
+            return false;
+
+        switch (nType)
+        {
+            case SC_MATVAL_VALUE:
+            case SC_MATVAL_BOOLEAN:
+                return fVal == r.fVal;
+            break;
+            default:
+                ;
+        }
+        if (!pS)
+            return r.pS == NULL;
+
+        return GetString().Equals(r.GetString());
+    }
+
+    bool operator!= (const ScMatrixValue& r) const
+    {
+        return !operator==(r);
+    }
+
+    ScMatrixValue& operator= (const ScMatrixValue& r)
+    {
+        nType = r.nType;
+        switch (nType)
+        {
+            case SC_MATVAL_VALUE:
+            case SC_MATVAL_BOOLEAN:
+                fVal = r.fVal;
+            break;
+            default:
+                pS = r.pS;
+        }
+        return *this;
+    }
 };
 
 /** Matrix representation of double values and strings.
diff --git a/sc/source/filter/xml/XMLExportDDELinks.cxx b/sc/source/filter/xml/XMLExportDDELinks.cxx
index 3696f84..56f3b7b 100644
--- a/sc/source/filter/xml/XMLExportDDELinks.cxx
+++ b/sc/source/filter/xml/XMLExportDDELinks.cxx
@@ -2,7 +2,7 @@
 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2000, 2010 Oracle and/or its affiliates.
  *
  * OpenOffice.org - a multi-platform office productivity suite
@@ -29,8 +29,6 @@
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_sc.hxx"
 
-
-
 // INCLUDE ---------------------------------------------------------------
 #include "XMLExportDDELinks.hxx"
 #include <xmloff/xmltoken.hxx>
@@ -47,6 +45,7 @@ class ScMatrix;
 
 using namespace com::sun::star;
 using namespace xmloff::token;
+using ::rtl::OUStringBuffer;
 
 ScXMLExportDDELinks::ScXMLExportDDELinks(ScXMLExport& rTempExport)
     : rExport(rTempExport)
@@ -57,121 +56,81 @@ ScXMLExportDDELinks::~ScXMLExportDDELinks()
 {
 }
 
-bool ScXMLExportDDELinks::CellsEqual(
-    const bool bPrevEmpty, const bool bPrevString, const String& sPrevValue, double fPrevValue,
-    const bool bEmpty, const bool bString, const String& sValue, double fValue)
-{
-    if (bEmpty == bPrevEmpty)
-        if (bEmpty)
-            return sal_True;
-        else if (bString == bPrevString)
-            if (bString)
-                return (sPrevValue == sValue);
-            else
-                return (fPrevValue == fValue);
-        else
-            return sal_False;
-    else
-        return sal_False;
-}
+namespace {
 
-void ScXMLExportDDELinks::WriteCell(
-    const bool bEmpty, const bool bString, const String& sValue, double fValue, const sal_Int32 nRepeat)
+void WriteCell(ScXMLExport& rExport, const ScMatrixValue& aVal, sal_Int32 nRepeat)
 {
-    rtl::OUStringBuffer sBuffer;
+    bool bString = ScMatrix::IsNonValueType(aVal.nType);
+    bool bEmpty = ScMatrix::IsEmptyType(aVal.nType) || (bString && aVal.GetString().Len() == 0);
+
     if (!bEmpty)
     {
         if (bString)
         {
             rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_STRING);
-            rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_STRING_VALUE, rtl::OUString(sValue));
+            rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_STRING_VALUE, aVal.GetString());
         }
         else
         {
+            OUStringBuffer aBuf;
             rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_FLOAT);
-            rExport.GetMM100UnitConverter().convertDouble(sBuffer, fValue);
-            rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE, sBuffer.makeStringAndClear());
+            rExport.GetMM100UnitConverter().convertDouble(aBuf, aVal.fVal);
+            rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE, aBuf.makeStringAndClear());
         }
     }
+
     if (nRepeat > 1)
     {
-        rExport.GetMM100UnitConverter().convertNumber(sBuffer, nRepeat);
-        rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, sBuffer.makeStringAndClear());
+        OUStringBuffer aBuf;
+        rExport.GetMM100UnitConverter().convertNumber(aBuf, nRepeat);
+        rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, aBuf.makeStringAndClear());
     }
     SvXMLElementExport(rExport, XML_NAMESPACE_TABLE, XML_TABLE_CELL, sal_True, sal_True);
 }
 
+}
+
 void ScXMLExportDDELinks::WriteTable(const sal_Int32 nPos)
 {
-    const ScMatrix* pMatrix(NULL);
-    if (rExport.GetDocument())
-        pMatrix = rExport.GetDocument()->GetDdeLinkResultMatrix( static_cast<USHORT>(nPos) );
-    if (pMatrix)
+    ScDocument* pDoc = rExport.GetDocument();
+    if (!pDoc)
+        return;
+
+    const ScMatrix* pMatrix = pDoc->GetDdeLinkResultMatrix(static_cast<USHORT>(nPos));
+    if (!pMatrix)
+        return;
+
+    SCSIZE nCols, nRows;
+    pMatrix->GetDimensions(nCols, nRows);
+
+    SvXMLElementExport aTableElem(rExport, XML_NAMESPACE_TABLE, XML_TABLE, sal_True, sal_True);
+    if (nCols > 1)
     {
-        SCSIZE nuCol;
-        SCSIZE nuRow;
-        pMatrix->GetDimensions( nuCol, nuRow );
-        sal_Int32 nRowCount = static_cast<sal_Int32>(nuRow);
-        sal_Int32 nColCount = static_cast<sal_Int32>(nuCol);
-        SvXMLElementExport aTableElem(rExport, XML_NAMESPACE_TABLE, XML_TABLE, sal_True, sal_True);
-        rtl::OUStringBuffer sBuffer;
-        if (nColCount > 1)
-        {
-            rExport.GetMM100UnitConverter().convertNumber(sBuffer, nColCount);
-            rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, sBuffer.makeStringAndClear());
-        }
-        {
-            SvXMLElementExport aElemCol(rExport, XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, sal_True, sal_True);
-        }
-        bool bPrevString = true;
-        bool bPrevEmpty = true;
-        double fPrevValue;
-        String sPrevValue;
-        sal_Int32 nRepeatColsCount(1);
-        for(sal_Int32 nRow = 0; nRow < nRowCount; ++nRow)
+        OUStringBuffer aBuf;
+        rExport.GetMM100UnitConverter().convertNumber(aBuf, static_cast<sal_Int32>(nCols));
+        rExport.AddAttribute(XML_NAMESPACE_TABLE, XML_NUMBER_COLUMNS_REPEATED, aBuf.makeStringAndClear());
+    }
+    {
+        SvXMLElementExport aElemCol(rExport, XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, sal_True, sal_True);
+    }
+
+    for (SCSIZE nRow = 0; nRow < nRows; ++nRow)
+    {
+        sal_Int32 nRepeat = 0;
+        ScMatrixValue aPrevVal;
+        SvXMLElementExport aElemRow(rExport, XML_NAMESPACE_TABLE, XML_TABLE_ROW, sal_True, sal_True);
+        for (SCSIZE nCol = 0; nCol < nCols; ++nCol, ++nRepeat)
         {
-            SvXMLElementExport aElemRow(rExport, XML_NAMESPACE_TABLE, XML_TABLE_ROW, sal_True, sal_True);
-            for(sal_Int32 nColumn = 0; nColumn < nColCount; ++nColumn)
+            ScMatrixValue aVal = pMatrix->Get(nCol, nRow);
+            if (nCol > 0 && aVal != aPrevVal)
             {
-                ScMatrixValue nMatVal = pMatrix->Get( static_cast<SCSIZE>(nColumn), static_cast<SCSIZE>(nRow) );
-                bool bIsString = ScMatrix::IsNonValueType( nMatVal.nType);
-
-                if (nColumn == 0)
-                {
-                    bPrevEmpty = nMatVal.nType == SC_MATVAL_EMPTY;
-                    bPrevString = bIsString;
-                    if( bIsString )
-                        sPrevValue = nMatVal.GetString();
-                    else
-                        fPrevValue = nMatVal.fVal;
-                }
-                else
-                {
-                    double fValue;
-                    String sValue;
-                    bool bEmpty = nMatVal.nType == SC_MATVAL_EMPTY;
-                    bool bString = bIsString;
-                    if( bIsString )
-                        sValue = nMatVal.GetString();
-                    else
-                        fValue = nMatVal.fVal;
-
-                    if (CellsEqual(bPrevEmpty, bPrevString, sPrevValue, fPrevValue,
-                                bEmpty, bString, sValue, fValue))
-                        ++nRepeatColsCount;
-                    else
-                    {
-                        WriteCell(bPrevEmpty, bPrevString, sPrevValue, fPrevValue, nRepeatColsCount);
-                        nRepeatColsCount = 1;
-                        bPrevEmpty = bEmpty;
-                        fPrevValue = fValue;
-                        sPrevValue = sValue;
-                    }
-                }
+                WriteCell(rExport, aPrevVal, nRepeat);
+                nRepeat = 0;
             }
-            WriteCell(bPrevEmpty, bPrevString, sPrevValue, fPrevValue, nRepeatColsCount);
-            nRepeatColsCount = 1;
+            aPrevVal = aVal;
         }
+
+        WriteCell(rExport, aPrevVal, nRepeat);
     }
 }
 
diff --git a/sc/source/filter/xml/XMLExportDDELinks.hxx b/sc/source/filter/xml/XMLExportDDELinks.hxx
index d333dab..8b94dba 100644
--- a/sc/source/filter/xml/XMLExportDDELinks.hxx
+++ b/sc/source/filter/xml/XMLExportDDELinks.hxx
@@ -38,9 +38,6 @@ class ScXMLExportDDELinks
 {
     ScXMLExport&        rExport;
 
-    bool                CellsEqual(const bool bPrevEmpty, const bool bPrevString, const String& sPrevValue, double fPrevValue,
-                               const bool bEmpty, const bool bString, const String& sValue, double fValue);
-    void                WriteCell(const bool bEmpty, const bool bString, const String& sValue, double fValue, const sal_Int32 nRepeat);
     void                WriteTable(const sal_Int32 nPos);
 public:
     ScXMLExportDDELinks(ScXMLExport& rExport);
commit 93bc2bd65c120c55ccdf2f1dcaaf4bbb18b6ee10
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Tue Jun 29 10:06:03 2010 -0400

    ScMatrixValue should be a struct now that it stores value type.

diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index b540fb9..89d88a0 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -48,22 +48,24 @@ const ScMatValType SC_MATVAL_EMPTY     = SC_MATVAL_STRING | 0x04; // STRING plus
 const ScMatValType SC_MATVAL_EMPTYPATH = SC_MATVAL_EMPTY | 0x08;  // EMPTY plus flag
 const ScMatValType SC_MATVAL_NONVALUE  = SC_MATVAL_EMPTYPATH;     // mask of all non-value bits
 
-union ScMatrixValue
+struct ScMatrixValue
 {
-    double fVal;
-    const String* pS;
+    union {
+        double fVal;
+        const String* pS;
+    };
     ScMatValType nType;
 
     /// Only valid if ScMatrix methods indicate so!
-    const String& GetString() const     { return pS ? *pS : EMPTY_STRING; }
+    const String& GetString() const { return pS ? *pS : EMPTY_STRING; }
 
     /// Only valid if ScMatrix methods indicate that this is no string!
     USHORT GetError() const         { return GetDoubleErrorValue( fVal); }
 
     /// Only valid if ScMatrix methods indicate that this is a boolean
-    bool GetBoolean() const         { return fVal != 0.; }
+    bool GetBoolean() const         { return fVal != 0.0; }
 
-    ScMatrixValue() : nType(SC_MATVAL_EMPTY) {}
+    ScMatrixValue() : pS(NULL), nType(SC_MATVAL_EMPTY) {}
 
     ScMatrixValue(const ScMatrixValue& r) : nType(r.nType)
     {
commit 3b5ff23297b05bb958684be0a2866070e93fd209
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Sun Nov 7 00:01:45 2010 -0400

    Swapped nC and nR.
    
    Quad type matrix takes row as the 1st arg and column as the 2nd.

diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 9a16232..cbf786d 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -202,7 +202,7 @@ private:
 };
 
 ScMatrixImpl::ScMatrixImpl(SCSIZE nC, SCSIZE nR) :
-    maMat(nC, nR, ::mdds::matrix_density_filled_zero),
+    maMat(nR, nC, ::mdds::matrix_density_filled_zero),
     mbCloneIfConst(true)
 {
 }
@@ -229,7 +229,7 @@ bool ScMatrixImpl::IsImmutable() const
 
 void ScMatrixImpl::Resize(SCSIZE nC, SCSIZE nR)
 {
-    maMat.resize(nC, nR);
+    maMat.resize(nR, nC);
     Clear();
 }
 
commit ba06e7ec9f40ee4304f2ce54058ecb3de6b51a9a
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Sat Nov 6 23:57:42 2010 -0400

    Use flag value to differentiate empty elements from empty-path elements.

diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 411a9c9..9a16232 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -335,7 +335,10 @@ void ScMatrixImpl::PutString(const String& rStr, SCSIZE nIndex)
 void ScMatrixImpl::PutEmpty(SCSIZE nC, SCSIZE nR)
 {
     if (ValidColRow( nC, nR))
+    {
         maMat.set_empty(nR, nC);
+        maMat.clear_flag(nR, nC);
+    }
     else
     {
         DBG_ERRORFILE("ScMatrixImpl::PutEmpty: dimension error");
@@ -352,7 +355,10 @@ void ScMatrixImpl::PutEmpty(SCSIZE nIndex)
 void ScMatrixImpl::PutEmptyPath(SCSIZE nC, SCSIZE nR)
 {
     if (ValidColRow( nC, nR))
+    {
         maMat.set_empty(nR, nC);
+        maMat.set_flag(nR, nC, 1); // non-zero flag to indicate empty 'path'.
+    }
     else
     {
         DBG_ERRORFILE("ScMatrixImpl::PutEmptyPath: dimension error");
@@ -575,16 +581,17 @@ BOOL ScMatrixImpl::IsEmpty( SCSIZE nIndex ) const
 
 BOOL ScMatrixImpl::IsEmpty( SCSIZE nC, SCSIZE nR ) const
 {
+    // Flag must be zero for this to be an empty element, instead of being an
+    // empty path element.
     ValidColRowReplicated( nC, nR );
-    return maMat.get_type(nR, nC) == ::mdds::element_empty;
+    return maMat.get_type(nR, nC) == ::mdds::element_empty && maMat.get_flag(nR, nC) == 0;
 }
 
 BOOL ScMatrixImpl::IsEmptyPath( SCSIZE nC, SCSIZE nR ) const
 {
+    // 'Empty path' is empty plus non-zero flag.
     ValidColRowReplicated( nC, nR );
-    return maMat.get_type(nR, nC) == ::mdds::element_empty;
-    // TODO: we need to differentiate empty and empty path.  'Empty path' is
-    // empty plus extra bit.
+    return maMat.get_type(nR, nC) == ::mdds::element_empty && maMat.get_flag(nR, nC) != 0;
 }
 
 BOOL ScMatrixImpl::IsEmptyPath( SCSIZE nIndex ) const
commit 05e1c6f7f4e34fa1ebc18ee317dd6117cff82664
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Sat Nov 6 23:56:56 2010 -0400

    sal_Bool to bool, also don't use const reference for primitive types.

diff --git a/sc/source/filter/xml/XMLExportDDELinks.cxx b/sc/source/filter/xml/XMLExportDDELinks.cxx
index 8b3b51c..3696f84 100644
--- a/sc/source/filter/xml/XMLExportDDELinks.cxx
+++ b/sc/source/filter/xml/XMLExportDDELinks.cxx
@@ -57,8 +57,9 @@ ScXMLExportDDELinks::~ScXMLExportDDELinks()
 {
 }
 
-sal_Bool ScXMLExportDDELinks::CellsEqual(const sal_Bool bPrevEmpty, const sal_Bool bPrevString, const String& sPrevValue, double fPrevValue,
-                    const sal_Bool bEmpty, const sal_Bool bString, const String& sValue, double fValue)
+bool ScXMLExportDDELinks::CellsEqual(
+    const bool bPrevEmpty, const bool bPrevString, const String& sPrevValue, double fPrevValue,
+    const bool bEmpty, const bool bString, const String& sValue, double fValue)
 {
     if (bEmpty == bPrevEmpty)
         if (bEmpty)
@@ -74,7 +75,8 @@ sal_Bool ScXMLExportDDELinks::CellsEqual(const sal_Bool bPrevEmpty, const sal_Bo
         return sal_False;
 }
 
-void ScXMLExportDDELinks::WriteCell(const sal_Bool bEmpty, const sal_Bool bString, const String& sValue, const double& fValue, const sal_Int32 nRepeat)
+void ScXMLExportDDELinks::WriteCell(
+    const bool bEmpty, const bool bString, const String& sValue, double fValue, const sal_Int32 nRepeat)
 {
     rtl::OUStringBuffer sBuffer;
     if (!bEmpty)
diff --git a/sc/source/filter/xml/XMLExportDDELinks.hxx b/sc/source/filter/xml/XMLExportDDELinks.hxx
index 4ecb6a4..d333dab 100644
--- a/sc/source/filter/xml/XMLExportDDELinks.hxx
+++ b/sc/source/filter/xml/XMLExportDDELinks.hxx
@@ -38,9 +38,9 @@ class ScXMLExportDDELinks
 {
     ScXMLExport&        rExport;
 
-    sal_Bool            CellsEqual(const sal_Bool bPrevEmpty, const sal_Bool bPrevString, const String& sPrevValue, double fPrevValue,
-                                    const sal_Bool bEmpty, const sal_Bool bString, const String& sValue, double fValue);
-    void                WriteCell(const sal_Bool bEmpty, const sal_Bool bString, const String& sValue, const double& fValue, const sal_Int32 nRepeat);
+    bool                CellsEqual(const bool bPrevEmpty, const bool bPrevString, const String& sPrevValue, double fPrevValue,
+                               const bool bEmpty, const bool bString, const String& sValue, double fValue);
+    void                WriteCell(const bool bEmpty, const bool bString, const String& sValue, double fValue, const sal_Int32 nRepeat);
     void                WriteTable(const sal_Int32 nPos);
 public:
     ScXMLExportDDELinks(ScXMLExport& rExport);
commit 1635a90e903c4753737b62e2f453eec5541acbf8
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Sat Nov 6 23:54:10 2010 -0400

    Fixed all build breakages.

diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index d437593..1ffc6e2 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -1997,16 +1997,12 @@ void ScFormulaCell::GetURLResult( String& rURL, String& rCellText )
     ScConstMatrixRef xMat( aResult.GetMatrix());
     if (xMat)
     {
-        ScMatValType nMatValType;
         // determine if the matrix result is a string or value.
-        const ScMatrixValue* pMatVal = xMat->Get(0, 1, nMatValType);
-        if (pMatVal)
-        {
-            if (!ScMatrix::IsValueType( nMatValType))
-                rURL = pMatVal->GetString();
-            else
-                pFormatter->GetOutputString( pMatVal->fVal, nURLFormat, rURL, &pColor );
-        }
+        ScMatrixValue nMatVal = xMat->Get(0, 1);
+        if (!ScMatrix::IsValueType( nMatVal.nType))
+            rURL = nMatVal.GetString();
+        else
+            pFormatter->GetOutputString( nMatVal.fVal, nURLFormat, rURL, &pColor );
     }
 
     if(!rURL.Len())
diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index cf79251..9a7540a 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -730,15 +730,13 @@ bool ScValidationData::GetSelectionFromFormula( TypedScStrCollection* pStrings,
         {
             ScTokenArray         aCondTokArr;
             TypedStrData*        pEntry = NULL;
-            ScMatValType         nMatValType;
             String               aValStr;
-            const ScMatrixValue* pMatVal = pValues->Get( nCol, nRow, nMatValType);
+            ScMatrixValue nMatVal = pValues->Get( nCol, nRow);
 
             // strings and empties
-            if( NULL == pMatVal || ScMatrix::IsNonValueType( nMatValType ) )
+            if( ScMatrix::IsNonValueType( nMatVal.nType ) )
             {
-                if( NULL != pMatVal )
-                    aValStr = pMatVal->GetString();
+                aValStr = nMatVal.GetString();
 
                 if( NULL != pStrings )
                     pEntry = new TypedStrData( aValStr, 0.0, SC_STRTYPE_STANDARD);
@@ -748,7 +746,7 @@ bool ScValidationData::GetSelectionFromFormula( TypedScStrCollection* pStrings,
             }
             else
             {
-                USHORT nErr = pMatVal->GetError();
+                USHORT nErr = nMatVal.GetError();
 
                 if( 0 != nErr )
                 {
@@ -766,17 +764,17 @@ bool ScValidationData::GetSelectionFromFormula( TypedScStrCollection* pStrings,
                             (SCROW)(nRow+aRange.aStart.Row()), aRange.aStart.Tab() , aValStr);
                     }
                     else
-                        pFormatter->GetInputLineString( pMatVal->fVal, 0, aValStr );
+                        pFormatter->GetInputLineString( nMatVal.fVal, 0, aValStr );
                 }
 
                 if( pCell && rMatch < 0 )
                 {
                     // I am not sure errors will work here, but a user can no
                     // manually enter an error yet so the point is somewhat moot.
-                    aCondTokArr.AddDouble( pMatVal->fVal );
+                    aCondTokArr.AddDouble( nMatVal.fVal );
                 }
                 if( NULL != pStrings )
-                    pEntry = new TypedStrData( aValStr, pMatVal->fVal, SC_STRTYPE_VALUE);
+                    pEntry = new TypedStrData( aValStr, nMatVal.fVal, SC_STRTYPE_VALUE);
             }
 
             if( rMatch < 0 && NULL != pCell && IsEqualToTokenArray( pCell, rPos, aCondTokArr ) )
diff --git a/sc/source/filter/excel/xeformula.cxx b/sc/source/filter/excel/xeformula.cxx
index afa1dd7..3a3f87e 100644
--- a/sc/source/filter/excel/xeformula.cxx
+++ b/sc/source/filter/excel/xeformula.cxx
@@ -1317,18 +1317,17 @@ void XclExpFmlaCompImpl::ProcessMatrix( const XclExpScToken& rTokData )
         {
             for( SCSIZE nScCol = 0; nScCol < nScCols; ++nScCol )
             {
-                ScMatValType nType;
-                const ScMatrixValue* pMatVal = pMatrix->Get( nScCol, nScRow, nType );
-                DBG_ASSERT( pMatVal, "XclExpFmlaCompImpl::ProcessMatrix - missing matrix value" );
-                if( ScMatrix::IsValueType( nType ) )    // value, boolean, or error
+                ScMatrixValue nMatVal = pMatrix->Get( nScCol, nScRow );
+                DBG_ASSERT( nMatVal, "XclExpFmlaCompImpl::ProcessMatrix - missing matrix value" );
+                if( ScMatrix::IsValueType( nMatVal.nType ) )    // value, boolean, or error
                 {
-                    if( ScMatrix::IsBooleanType( nType ) )
+                    if( ScMatrix::IsBooleanType( nMatVal.nType ) )
                     {
                         AppendExt( EXC_CACHEDVAL_BOOL );
-                        AppendExt( static_cast< sal_uInt8 >( pMatVal->GetBoolean() ? 1 : 0 ) );
+                        AppendExt( static_cast< sal_uInt8 >( nMatVal.GetBoolean() ? 1 : 0 ) );
                         AppendExt( 0, 7 );
                     }
-                    else if( USHORT nErr = pMatVal->GetError() )
+                    else if( USHORT nErr = nMatVal.GetError() )
                     {
                         AppendExt( EXC_CACHEDVAL_ERROR );
                         AppendExt( XclTools::GetXclErrorCode( nErr ) );
@@ -1337,12 +1336,12 @@ void XclExpFmlaCompImpl::ProcessMatrix( const XclExpScToken& rTokData )
                     else
                     {
                         AppendExt( EXC_CACHEDVAL_DOUBLE );
-                        AppendExt( pMatVal->fVal );
+                        AppendExt( nMatVal.fVal );
                     }
                 }
                 else    // string or empty
                 {
-                    const String& rStr = pMatVal->GetString();
+                    const String& rStr = nMatVal.GetString();
                     if( rStr.Len() == 0 )
                     {
                         AppendExt( EXC_CACHEDVAL_EMPTY );
diff --git a/sc/source/filter/excel/xehelper.cxx b/sc/source/filter/excel/xehelper.cxx
index 335f3d0..c7c4fb3 100644
--- a/sc/source/filter/excel/xehelper.cxx
+++ b/sc/source/filter/excel/xehelper.cxx
@@ -1087,29 +1087,28 @@ void XclExpCachedMatrix::Save( XclExpStream& rStrm ) const
     {
         for( SCSIZE nCol = 0; nCol < nCols; ++nCol )
         {
-            ScMatValType nMatValType = SC_MATVAL_VALUE;
-            const ScMatrixValue* pMatVal = mrMatrix.Get( nCol, nRow, nMatValType );
+            ScMatrixValue nMatVal = mrMatrix.Get( nCol, nRow );
 
-            if( !pMatVal || SC_MATVAL_EMPTY == nMatValType )
+            if( SC_MATVAL_EMPTY == nMatVal.nType )
             {
                 rStrm.SetSliceSize( 9 );
                 rStrm << EXC_CACHEDVAL_EMPTY;
                 rStrm.WriteZeroBytes( 8 );
             }
-            else if( ScMatrix::IsNonValueType( nMatValType ) )
+            else if( ScMatrix::IsNonValueType( nMatVal.nType ) )
             {
-                XclExpString aStr( pMatVal->GetString(), EXC_STR_DEFAULT );
+                XclExpString aStr( nMatVal.GetString(), EXC_STR_DEFAULT );
                 rStrm.SetSliceSize( 6 );
                 rStrm << EXC_CACHEDVAL_STRING << aStr;
             }
-            else if( SC_MATVAL_BOOLEAN == nMatValType )
+            else if( SC_MATVAL_BOOLEAN == nMatVal.nType )
             {
-                sal_Int8 nBool = pMatVal->GetBoolean();
+                sal_Int8 nBool = nMatVal.GetBoolean();
                 rStrm.SetSliceSize( 9 );
                 rStrm << EXC_CACHEDVAL_BOOL << nBool;
                 rStrm.WriteZeroBytes( 7 );
             }
-            else if( USHORT nScError = pMatVal->GetError() )
+            else if( USHORT nScError = nMatVal.GetError() )
             {
                 sal_Int8 nError ( XclTools::GetXclErrorCode( nScError ) );
                 rStrm.SetSliceSize( 9 );
@@ -1119,7 +1118,7 @@ void XclExpCachedMatrix::Save( XclExpStream& rStrm ) const
             else
             {
                 rStrm.SetSliceSize( 9 );
-                rStrm << EXC_CACHEDVAL_DOUBLE << pMatVal->fVal;
+                rStrm << EXC_CACHEDVAL_DOUBLE << nMatVal.fVal;
             }
         }
     }
diff --git a/sc/source/filter/xml/XMLExportDDELinks.cxx b/sc/source/filter/xml/XMLExportDDELinks.cxx
index 11796ba..8b3b51c 100644
--- a/sc/source/filter/xml/XMLExportDDELinks.cxx
+++ b/sc/source/filter/xml/XMLExportDDELinks.cxx
@@ -57,8 +57,8 @@ ScXMLExportDDELinks::~ScXMLExportDDELinks()
 {
 }
 
-sal_Bool ScXMLExportDDELinks::CellsEqual(const sal_Bool bPrevEmpty, const sal_Bool bPrevString, const String& sPrevValue, const double& fPrevValue,
-                     const sal_Bool bEmpty, const sal_Bool bString, const String& sValue, const double& fValue)
+sal_Bool ScXMLExportDDELinks::CellsEqual(const sal_Bool bPrevEmpty, const sal_Bool bPrevString, const String& sPrevValue, double fPrevValue,
+                    const sal_Bool bEmpty, const sal_Bool bString, const String& sValue, double fValue)
 {
     if (bEmpty == bPrevEmpty)
         if (bEmpty)
@@ -121,8 +121,8 @@ void ScXMLExportDDELinks::WriteTable(const sal_Int32 nPos)
         {
             SvXMLElementExport aElemCol(rExport, XML_NAMESPACE_TABLE, XML_TABLE_COLUMN, sal_True, sal_True);
         }
-        sal_Bool bPrevString(sal_True);
-        sal_Bool bPrevEmpty(sal_True);
+        bool bPrevString = true;
+        bool bPrevEmpty = true;
         double fPrevValue;
         String sPrevValue;
         sal_Int32 nRepeatColsCount(1);
@@ -131,29 +131,28 @@ void ScXMLExportDDELinks::WriteTable(const sal_Int32 nPos)
             SvXMLElementExport aElemRow(rExport, XML_NAMESPACE_TABLE, XML_TABLE_ROW, sal_True, sal_True);
             for(sal_Int32 nColumn = 0; nColumn < nColCount; ++nColumn)
             {
-                ScMatValType nType = SC_MATVAL_VALUE;
-                const ScMatrixValue* pMatVal = pMatrix->Get( static_cast<SCSIZE>(nColumn), static_cast<SCSIZE>(nRow), nType );
-                BOOL bIsString = ScMatrix::IsNonValueType( nType);
+                ScMatrixValue nMatVal = pMatrix->Get( static_cast<SCSIZE>(nColumn), static_cast<SCSIZE>(nRow) );
+                bool bIsString = ScMatrix::IsNonValueType( nMatVal.nType);
 
                 if (nColumn == 0)
                 {
-                    bPrevEmpty = !pMatVal;
+                    bPrevEmpty = nMatVal.nType == SC_MATVAL_EMPTY;
                     bPrevString = bIsString;
                     if( bIsString )
-                        sPrevValue = pMatVal->GetString();
+                        sPrevValue = nMatVal.GetString();
                     else
-                        fPrevValue = pMatVal->fVal;
+                        fPrevValue = nMatVal.fVal;
                 }
                 else
                 {
                     double fValue;
                     String sValue;
-                    sal_Bool bEmpty(!pMatVal);
-                    sal_Bool bString(bIsString);
+                    bool bEmpty = nMatVal.nType == SC_MATVAL_EMPTY;
+                    bool bString = bIsString;
                     if( bIsString )
-                        sValue = pMatVal->GetString();
+                        sValue = nMatVal.GetString();
                     else
-                        fValue = pMatVal->fVal;
+                        fValue = nMatVal.fVal;
 
                     if (CellsEqual(bPrevEmpty, bPrevString, sPrevValue, fPrevValue,
                                 bEmpty, bString, sValue, fValue))
diff --git a/sc/source/filter/xml/XMLExportDDELinks.hxx b/sc/source/filter/xml/XMLExportDDELinks.hxx
index 9f09d62..4ecb6a4 100644
--- a/sc/source/filter/xml/XMLExportDDELinks.hxx
+++ b/sc/source/filter/xml/XMLExportDDELinks.hxx
@@ -36,12 +36,12 @@ class ScXMLExport;
 
 class ScXMLExportDDELinks
 {
-    ScXMLExport&		rExport;
+    ScXMLExport&        rExport;
 
-    sal_Bool			CellsEqual(const sal_Bool bPrevEmpty, const sal_Bool bPrevString, const String& sPrevValue, const double& fPrevValue,
-                                    const sal_Bool bEmpty, const sal_Bool bString, const String& sValue, const double& fValue);
-    void 				WriteCell(const sal_Bool bEmpty, const sal_Bool bString, const String& sValue, const double& fValue, const sal_Int32 nRepeat);
-    void				WriteTable(const sal_Int32 nPos);
+    sal_Bool            CellsEqual(const sal_Bool bPrevEmpty, const sal_Bool bPrevString, const String& sPrevValue, double fPrevValue,
+                                    const sal_Bool bEmpty, const sal_Bool bString, const String& sValue, double fValue);
+    void                WriteCell(const sal_Bool bEmpty, const sal_Bool bString, const String& sValue, const double& fValue, const sal_Int32 nRepeat);
+    void                WriteTable(const sal_Int32 nPos);
 public:
     ScXMLExportDDELinks(ScXMLExport& rExport);
     ~ScXMLExportDDELinks();
commit 8f2d46e3a546e016a5ce6b0ce0acf4cff5e3b3a3
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Sat Nov 6 23:52:13 2010 -0400

    More on fixing build breakage.

diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index e0ecf26..8b0a631 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -2345,47 +2345,51 @@ ScMatValType ScInterpreter::GetDoubleOrStringFromMatrix( double& rDouble,
         String& rString )
 {
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::GetDoubleOrStringFromMatrix" );
+
+    rDouble = 0.0;
+    rString.Erase();
     ScMatValType nMatValType = SC_MATVAL_EMPTY;
+
     switch ( GetStackType() )
     {
         case svMatrix:
             {
-                const ScMatrixValue* pMatVal = 0;
+                ScMatrixValue nMatVal;
                 ScMatrixRef pMat = PopMatrix();
                 if (!pMat)
                     ;   // nothing
                 else if (!pJumpMatrix)
-                    pMatVal = pMat->Get( 0, 0, nMatValType);
+                {
+                    nMatVal = pMat->Get(0, 0);
+                    nMatValType = nMatVal.nType;
+                }
                 else
                 {
                     SCSIZE nCols, nRows, nC, nR;
                     pMat->GetDimensions( nCols, nRows);
                     pJumpMatrix->GetPos( nC, nR);
                     if ( nC < nCols && nR < nRows )
-                        pMatVal = pMat->Get( nC, nR, nMatValType);
+                    {
+                        nMatVal = pMat->Get( nC, nR);
+                        nMatValType = nMatVal.nType;
+                    }
                     else
                         SetError( errNoValue);
                 }
-                if (!pMatVal)
-                {
-                    rDouble = 0.0;
-                    rString.Erase();
-                }
-                else if (nMatValType == SC_MATVAL_VALUE)
-                    rDouble = pMatVal->fVal;
+
+                if (nMatValType == SC_MATVAL_VALUE)
+                    rDouble = nMatVal.fVal;
                 else if (nMatValType == SC_MATVAL_BOOLEAN)
                 {
-                    rDouble = pMatVal->fVal;
+                    rDouble = nMatVal.fVal;
                     nMatValType = SC_MATVAL_VALUE;
                 }
                 else
-                    rString = pMatVal->GetString();
+                    rString = nMatVal.GetString();
             }
             break;
         default:
             PopError();
-            rDouble = 0.0;
-            rString.Erase();
             SetError( errIllegalParameter);
     }
     return nMatValType;
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index c25f684..6098751 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -615,12 +615,12 @@ void ScInterpreter::CalculateMatrixValue(const ScMatrix* pMat,SCSIZE nC,SCSIZE n
         pMat->GetDimensions(nCl, nRw);
         if (nC < nCl && nR < nRw)
         {
-            ScMatValType nMatValType;
-            const ScMatrixValue* pMatVal = pMat->Get( nC, nR,nMatValType);
+            const ScMatrixValue nMatVal = pMat->Get( nC, nR);
+            ScMatValType nMatValType = nMatVal.nType;
             if (ScMatrix::IsNonValueType( nMatValType))
-                PushString( pMatVal->GetString() );
+                PushString( nMatVal.GetString() );
             else
-                PushDouble(pMatVal->fVal);
+                PushDouble(nMatVal.fVal);
                 // also handles DoubleError
         }
         else
@@ -3210,8 +3210,9 @@ void ScInterpreter::ScMatRef()
                 PushNA();
             else
             {
-                ScMatValType nMatValType;
-                const ScMatrixValue* pMatVal = pMat->Get( nC, nR, nMatValType);
+                const ScMatrixValue nMatVal = pMat->Get( nC, nR);
+                ScMatValType nMatValType = nMatVal.nType;
+
                 if (ScMatrix::IsNonValueType( nMatValType))
                 {
                     if (ScMatrix::IsEmptyPathType( nMatValType))
@@ -3225,11 +3226,11 @@ void ScInterpreter::ScMatRef()
                         PushTempToken( new ScEmptyCellToken( false, true));
                     }
                     else
-                        PushString( pMatVal->GetString() );
+                        PushString( nMatVal.GetString() );
                 }
                 else
                 {
-                    PushDouble(pMatVal->fVal);  // handles DoubleError
+                    PushDouble(nMatVal.fVal);  // handles DoubleError
                     pDok->GetNumberFormatInfo( nCurFmtType, nCurFmtIndex, aAdr, pCell );
                     nFuncFmtType = nCurFmtType;
                     nFuncFmtIndex = nCurFmtIndex;
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 9872770..411a9c9 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -42,16 +42,18 @@
 
 #include <math.h>
 
+#define _MDDS_HASH_CONTAINER_COMPAT 1
 #include <mdds/quad_type_matrix.hpp>
 
 using ::std::pair;
-using ::mdds::quad_type_matrix;
 using ::mdds::matrix_element_t;
 
 // ============================================================================
 
 namespace {
 
+typedef ::mdds::quad_type_matrix<String, sal_uInt8> MatrixImplType;
+
 struct ElemEqual : public ::std::unary_function<double, bool>
 {
     bool operator() (double val) const
@@ -101,7 +103,7 @@ struct ElemLessEqual : public ::std::unary_function<double, bool>
 };
 
 template<typename _Comp>
-void compareMatrix(quad_type_matrix<String>& rMat)
+void compareMatrix(MatrixImplType& rMat)
 {
     pair<size_t,size_t> aDim = rMat.size();
     _Comp aComp;
@@ -113,7 +115,7 @@ void compareMatrix(quad_type_matrix<String>& rMat)
             if (eType != mdds::element_numeric && eType == mdds::element_boolean)
                 continue;
 
-            double fVal = maMat.get_numeric(i, j);
+            double fVal = rMat.get_numeric(i, j);
             if (!::rtl::math::isFinite(fVal))
                 continue;
 
@@ -126,8 +128,8 @@ void compareMatrix(quad_type_matrix<String>& rMat)
 
 class ScMatrixImpl
 {
-    quad_type_matrix<String> maMat;
-    ScInterpreter*  pErrorInterpreter;
+    MatrixImplType maMat;
+    ScInterpreter* pErrorInterpreter;
     bool            mbCloneIfConst; // Whether the matrix is cloned with a CloneIfConst() call.
 
 public:
@@ -169,7 +171,7 @@ public:
     const String& GetString( SCSIZE nIndex) const;
     String GetString( SvNumberFormatter& rFormatter, SCSIZE nIndex) const;
     String GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSIZE nR) const;
-    const ScMatrixValue* Get(SCSIZE nC, SCSIZE nR, ScMatValType& nType) const;
+    ScMatrixValue Get(SCSIZE nC, SCSIZE nR) const;
     BOOL IsString( SCSIZE nIndex ) const;
     BOOL IsString( SCSIZE nC, SCSIZE nR ) const;
     BOOL IsEmpty( SCSIZE nIndex ) const;
@@ -196,7 +198,7 @@ public:
     double Or();
 
 private:
-    void CalcPosition(SCSIZE nIndex, SCSIZE& rC, SCSIZE& rR);
+    void CalcPosition(SCSIZE nIndex, SCSIZE& rC, SCSIZE& rR) const;
 };
 
 ScMatrixImpl::ScMatrixImpl(SCSIZE nC, SCSIZE nR) :
@@ -238,20 +240,20 @@ void ScMatrixImpl::SetErrorInterpreter( ScInterpreter* p)
 
 void ScMatrixImpl::GetDimensions( SCSIZE& rC, SCSIZE& rR) const
 {
-    quad_type_matrix<String>::size_pair_type aDims = maMat.size();
+    MatrixImplType::size_pair_type aDims = maMat.size();
     rR = aDims.first;
     rC = aDims.second;
 }
 
 SCSIZE ScMatrixImpl::GetElementCount() const
 {
-    quad_type_matrix<String>::size_pair_type aDims = maMat.size();
+    MatrixImplType::size_pair_type aDims = maMat.size();
     return aDims.first * aDims.second;
 }
 
 bool ScMatrixImpl::ValidColRow( SCSIZE nC, SCSIZE nR) const
 {
-    quad_type_matrix<String>::size_pair_type aDims = maMat.size();
+    MatrixImplType::size_pair_type aDims = maMat.size();
     return nR < aDims.first && nC < aDims.second;
 }
 
@@ -559,10 +561,11 @@ BOOL ScMatrixImpl::IsString( SCSIZE nC, SCSIZE nR ) const
         case mdds::element_empty:
         case mdds::element_string:
             return true;
+        default:
+            ;
     }
     return false;
 }
-
 BOOL ScMatrixImpl::IsEmpty( SCSIZE nIndex ) const
 {
     SCSIZE nC, nR;
@@ -606,6 +609,8 @@ BOOL ScMatrixImpl::IsValue( SCSIZE nC, SCSIZE nR ) const
         case mdds::element_boolean:
         case mdds::element_numeric:
             return true;
+        default:
+            ;
     }
     return false;
 }
@@ -626,10 +631,11 @@ BOOL ScMatrixImpl::IsValueOrEmpty( SCSIZE nC, SCSIZE nR ) const
         case mdds::element_numeric:
         case mdds::element_empty:
             return true;
+        default:
+            ;
     }
     return false;
 }
-
 BOOL ScMatrixImpl::IsBoolean( SCSIZE nIndex ) const
 {
     SCSIZE nC, nR;
@@ -640,18 +646,17 @@ BOOL ScMatrixImpl::IsBoolean( SCSIZE nIndex ) const
 BOOL ScMatrixImpl::IsBoolean( SCSIZE nC, SCSIZE nR ) const
 {
     ValidColRowReplicated( nC, nR );
-    maMat.get_type(nR, nC) == ::mdds::matrix_boolean;
-//  return mnValType && ScMatrix::IsBooleanType( mnValType[ nC * nRowCount + nR ]);
+    return maMat.get_type(nR, nC) == ::mdds::element_boolean;
 }
 
 BOOL ScMatrixImpl::IsNumeric() const
 {
-    maMat.numeric();
+    return maMat.numeric();
 }
 
 void ScMatrixImpl::MatCopy(ScMatrixImpl& mRes) const
 {
-    quad_type_matrix<String>::size_pair_type s1 = maMat.size(), s2 = mRes.maMat.size();

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list