sc/inc/document.hxx                |    2 +
 sc/qa/unit/ucalc.cxx               |   52 +++++++++++++++++++++++++++----------
 sc/source/core/data/documen2.cxx   |    2 -
 sc/source/core/data/document.cxx   |    6 +---
 sc/source/core/data/document10.cxx |    7 ++++
 5 files changed, 50 insertions(+), 19 deletions(-)

New commits:
commit 8f403051968298fbabd61de82fbb6a77762c83cc
Author: Kohei Yoshida <kohei.yosh...@collabora.com>
Date:   Mon Apr 14 11:23:23 2014 -0400

    fdo#77209: Share string pool with clip documents.
    
    We do the same with undo documents, and it will only make sense to do
    the same with clip documents as well.  Also, put the sharing part into
    a common method (for ease of tracking).
    
    Change-Id: I342b22d95374ee06d16318a66ffea0ac5b42621c

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 6fe5f9f..582d086 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -2147,6 +2147,8 @@ private: // CLOOK-Impl-methods
     SCSIZE GetPatternCount( SCTAB nTab, SCCOL nCol ) const;
     SCSIZE GetPatternCount( SCTAB nTab, SCCOL nCol, SCROW nRow1, SCROW nRow2 ) 
const;
     bool   ReservePatternCount( SCTAB nTab, SCCOL nCol, SCSIZE nReserve );
+
+    void SharePooledResources( ScDocument* pSrcDoc );
 };
 inline void ScDocument::GetSortParam( ScSortParam& rParam, SCTAB nTab )
 {
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 3390f8a..1ea05ca 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -464,7 +464,7 @@ void ScDocument::InitClipPtrs( ScDocument* pSourceDoc )
 
     Clear();
 
-    xPoolHelper = pSourceDoc->xPoolHelper;
+    SharePooledResources(pSourceDoc);
 
     //  bedingte Formate / Gueltigkeiten
     //! Vorlagen kopieren?
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index b5f412b..4f90b2f 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1831,8 +1831,7 @@ void ScDocument::InitUndoSelected( ScDocument* pSrcDoc, 
const ScMarkData& rTabSe
     {
         Clear();
 
-        xPoolHelper = pSrcDoc->xPoolHelper;
-
+        SharePooledResources(pSrcDoc);
 
         OUString aString;
         for (SCTAB nTab = 0; nTab <= rTabSelection.GetLastSelected(); nTab++)
@@ -1867,8 +1866,7 @@ void ScDocument::InitUndo( ScDocument* pSrcDoc, SCTAB 
nTab1, SCTAB nTab2,
         Clear();
 
         // Undo document shares its pooled resources with the source document.
-        xPoolHelper = pSrcDoc->xPoolHelper;
-        mpCellStringPool = pSrcDoc->mpCellStringPool;
+        SharePooledResources(pSrcDoc);
 
         if (pSrcDoc->pShell->GetMedium())
             maFileURL = 
pSrcDoc->pShell->GetMedium()->GetURLObject().GetMainURL(INetURLObject::DECODE_TO_IURI);
diff --git a/sc/source/core/data/document10.cxx 
b/sc/source/core/data/document10.cxx
index e4a2ff1..a04e8f9 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -16,6 +16,7 @@
 #include <editutil.hxx>
 #include <listenercontext.hxx>
 #include <tokenstringcontext.hxx>
+#include <poolhelp.hxx>
 
 // Add totally brand-new methods to this source file.
 
@@ -263,4 +264,10 @@ void ScDocument::PostprocessRangeNameUpdate()
     }
 }
 
+void ScDocument::SharePooledResources( ScDocument* pSrcDoc )
+{
+    xPoolHelper = pSrcDoc->xPoolHelper;
+    mpCellStringPool = pSrcDoc->mpCellStringPool;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 85a070f93f4dc02a1c0142e4e8f03bde55227e76
Author: Kohei Yoshida <kohei.yosh...@collabora.com>
Date:   Mon Apr 14 11:22:23 2014 -0400

    fdo#77209: Adjust this test to cover clip document use case as well.
    
    Turns out that we do need to share pooled resources with clip documents
    in addition to undo documents.
    
    Change-Id: If220c2d4bfc2bece9e884e034525e72dff8e3d66

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 06ef566..7563012 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -599,6 +599,36 @@ void Test::testSharedStringPool()
 
 void Test::testSharedStringPoolUndoDoc()
 {
+    struct
+    {
+        bool check( ScDocument& rSrcDoc, ScDocument& rCopyDoc )
+        {
+            // Copy A1:A4 to the undo document.
+            for (SCROW i = 0; i <= 4; ++i)
+            {
+                ScAddress aPos(0,i,0);
+                rCopyDoc.SetString(aPos, rSrcDoc.GetString(aPos));
+            }
+
+            // String values in A1:A4 should have identical hash.
+            for (SCROW i = 0; i <= 4; ++i)
+            {
+                ScAddress aPos(0,i,0);
+                svl::SharedString aSS1 = rSrcDoc.GetSharedString(aPos);
+                svl::SharedString aSS2 = rCopyDoc.GetSharedString(aPos);
+                if (aSS1.getDataIgnoreCase() != aSS2.getDataIgnoreCase())
+                {
+                    cerr << "String hash values are not equal at row " << (i+1)
+                        << " for string '" << aSS1.getString() << "'" << endl;
+                    return false;
+                }
+            }
+
+            return true;
+        }
+
+    } aTest;
+
     m_pDoc->InsertTab(0, "Test");
 
     m_pDoc->SetString(ScAddress(0,0,0), "Header");
@@ -609,21 +639,15 @@ void Test::testSharedStringPoolUndoDoc()
     ScDocument aUndoDoc(SCDOCMODE_UNDO);
     aUndoDoc.InitUndo(m_pDoc, 0, 0);
 
-    // Copy A1:A4 to the undo document.
-    for (SCROW i = 0; i <= 4; ++i)
-    {
-        ScAddress aPos(0,i,0);
-        aUndoDoc.SetString(aPos, m_pDoc->GetString(aPos));
-    }
+    bool bSuccess = aTest.check(*m_pDoc, aUndoDoc);
+    CPPUNIT_ASSERT_MESSAGE("Check failed with undo document.", bSuccess);
 
-    // String values in A1:A4 should have identical hash.
-    for (SCROW i = 0; i <= 4; ++i)
-    {
-        ScAddress aPos(0,i,0);
-        svl::SharedString aSS1 = m_pDoc->GetSharedString(aPos);
-        svl::SharedString aSS2 = aUndoDoc.GetSharedString(aPos);
-        CPPUNIT_ASSERT_MESSAGE("String hash values are not equal.", 
aSS1.getDataIgnoreCase() == aSS2.getDataIgnoreCase());
-    }
+    // Test the clip document as well.
+    ScDocument aClipDoc(SCDOCMODE_CLIP);
+    aClipDoc.ResetClip(m_pDoc, static_cast<SCTAB>(0));
+
+    bSuccess = aTest.check(*m_pDoc, aClipDoc);
+    CPPUNIT_ASSERT_MESSAGE("Check failed with clip document.", bSuccess);
 
     m_pDoc->DeleteTab(0);
 }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to