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

Kohei Yoshida kohei at kemper.freedesktop.org
Fri Nov 5 14:54:52 PDT 2010


 sc/inc/scmatrix.hxx              |    3 +--
 sc/source/core/tool/scmatrix.cxx |   23 +++++++++++++++++++++--
 2 files changed, 22 insertions(+), 4 deletions(-)

New commits:
commit a07946e4cbad6105fcab2af7157f4995ad4354ac
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Fri Nov 5 17:54:21 2010 -0400

    Moved mbCloneIfCount into ScMatrixImpl.

diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index e42cb4b..b540fb9 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -112,7 +112,6 @@ class SC_DLLPUBLIC ScMatrix
 {
     ScMatrixImpl*   pImpl;
     mutable ULONG   nRefCnt;    // reference count
-    bool            mbCloneIfConst;     // Whether the matrix is cloned with a CloneIfConst() call.
 
     // only delete via Delete()
     ~ScMatrix();
@@ -186,7 +185,7 @@ public:
 
     /** Set the matrix to (im)mutable for CloneIfConst(), only the interpreter 
         should do this and know the consequences. */
-    inline void SetImmutable( bool bVal ) { mbCloneIfConst = bVal; }
+    void SetImmutable( bool bVal );
 
     /** 
      * Resize the matrix to specified new dimension.  Note that this operation
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 0815dcc..9872770 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -128,12 +128,15 @@ class ScMatrixImpl
 {
     quad_type_matrix<String> maMat;
     ScInterpreter*  pErrorInterpreter;
+    bool            mbCloneIfConst; // Whether the matrix is cloned with a CloneIfConst() call.
 
 public:
     ScMatrixImpl(SCSIZE nC, SCSIZE nR);
     ~ScMatrixImpl();
 
     void Clear();
+    void SetImmutable(bool bVal);
+    bool IsImmutable() const;
     void Resize(SCSIZE nC, SCSIZE nR);
     void SetErrorInterpreter( ScInterpreter* p);
     ScInterpreter* GetErrorInterpreter() const { return pErrorInterpreter; }
@@ -197,7 +200,8 @@ private:
 };
 
 ScMatrixImpl::ScMatrixImpl(SCSIZE nC, SCSIZE nR) :
-    maMat(nC, nR, ::mdds::matrix_density_filled_zero)
+    maMat(nC, nR, ::mdds::matrix_density_filled_zero),
+    mbCloneIfConst(true)
 {
 }
 
@@ -211,6 +215,16 @@ void ScMatrixImpl::Clear()
     maMat.clear();
 }
 
+void ScMatrixImpl::SetImmutable(bool bVal)
+{
+    mbCloneIfConst = bVal;
+}
+
+bool ScMatrixImpl::IsImmutable() const
+{
+    return mbCloneIfConst;
+}
+
 void ScMatrixImpl::Resize(SCSIZE nC, SCSIZE nR)
 {
     maMat.resize(nC, nR);
@@ -784,7 +798,12 @@ ScMatrix* ScMatrix::Clone() const
 
 ScMatrix* ScMatrix::CloneIfConst()
 {
-    return (mbCloneIfConst || IsEternalRef()) ? Clone() : this;
+    return (pImpl->IsImmutable() || IsEternalRef()) ? Clone() : this;
+}
+
+void ScMatrix::SetImmutable( bool bVal )
+{
+    pImpl->SetImmutable(bVal);
 }
 
 void ScMatrix::Resize( SCSIZE nC, SCSIZE nR)


More information about the Libreoffice-commits mailing list