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

Kohei Yoshida kohei at kemper.freedesktop.org
Mon Jan 30 13:19:10 PST 2012


 sc/inc/cell.hxx                |    2 ++
 sc/inc/formularesult.hxx       |   12 ++++++++++++
 sc/source/core/data/cell.cxx   |    5 +++++
 sc/source/core/data/table4.cxx |    1 +
 4 files changed, 20 insertions(+)

New commits:
commit e2b11f4fd79dce4116badb0ecf6477546ca5d0d4
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Mon Jan 30 16:10:48 2012 -0500

    Prevent excessive references to single token instance during fill.
    
    Because if not, we may run out of the 16-bit integer space to store
    reference count.

diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index 52244f6..3bc7aee 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -535,6 +535,8 @@ public:
     bool            IsMultilineResult();
 
     void            MaybeInterpret();
+
+    void            ResetFormulaResult();
 };
 
 //          Iterator for references in a formula cell
diff --git a/sc/inc/formularesult.hxx b/sc/inc/formularesult.hxx
index c1cb906..94c62f8 100644
--- a/sc/inc/formularesult.hxx
+++ b/sc/inc/formularesult.hxx
@@ -117,6 +117,8 @@ public:
                                         mpToken->DecRef();
                                 }
 
+    inline void Reset();
+
     /** Well, guess what ... */
     inline  ScFormulaResult &   operator=( const ScFormulaResult & r );
 
@@ -216,6 +218,16 @@ public:
     inline ScMatrixFormulaCellToken* GetMatrixFormulaCellTokenNonConst();
 };
 
+inline void ScFormulaResult::Reset()
+{
+    ResetToDefaults();
+
+    if (mbToken && mpToken)
+        mpToken->DecRef();
+
+    mbToken = true;
+    mpToken = NULL;
+}
 
 inline void ScFormulaResult::ResetToDefaults()
 {
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index 2f3df26..1f89aed 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -2041,6 +2041,11 @@ void ScFormulaCell::MaybeInterpret()
         Interpret();
 }
 
+void ScFormulaCell::ResetFormulaResult()
+{
+    aResult.Reset();
+}
+
 EditTextObject* ScFormulaCell::CreateURLObject()
 {
     String aCellText;
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index dac4111..6a21a07 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -429,6 +429,7 @@ void ScTable::FillFormula(sal_uLong& /* nFormulaCounter */, bool /* bFirst */, S
     pDocument->SetNoListening( true );  // noch falsche Referenzen
     ScAddress aAddr( nDestCol, nDestRow, nTab );
     ScFormulaCell* pDestCell = new ScFormulaCell( *pSrcCell, *pDocument, aAddr );
+    pDestCell->ResetFormulaResult(); // formula cell is interpreted later during fill.
     aCol[nDestCol].Insert(nDestRow, pDestCell);
 
     if ( bLast && pDestCell->GetMatrixFlag() )


More information about the Libreoffice-commits mailing list