[Libreoffice-commits] core.git: 2 commits - sc/inc sc/qa sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Mon Feb 24 10:13:11 PST 2014


 sc/inc/document.hxx              |    4 +++-
 sc/qa/unit/ucalc.cxx             |   32 ++++++++++++++++++++++++++++++++
 sc/qa/unit/ucalc.hxx             |    2 ++
 sc/source/core/data/document.cxx |    3 +++
 4 files changed, 40 insertions(+), 1 deletion(-)

New commits:
commit e752620bf593af8839831f693ec21bb02a8b23d6
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Feb 24 13:10:17 2014 -0500

    fdo#75259: Let undo document share its string pool with the source doc.
    
    We already do that for the pool helper.  It would only make sense to do
    it for shared strings as well.
    
    Change-Id: I813d262799af6f0c1d3fa12246ad973f852ac199

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 0ab8400..6bb74e2 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -46,6 +46,8 @@
 #include <vector>
 #include <boost/ptr_container/ptr_vector.hpp>
 #include <boost/scoped_ptr.hpp>
+#include <boost/shared_ptr.hpp>
+
 #include "markdata.hxx"
 
 namespace editeng { class SvxBorderLine; }
@@ -260,7 +262,7 @@ private:
 
     rtl::Reference<ScPoolHelper> xPoolHelper;
 
-    boost::scoped_ptr<svl::SharedStringPool> mpCellStringPool;
+    boost::shared_ptr<svl::SharedStringPool> mpCellStringPool;
     boost::scoped_ptr<sc::FormulaGroupContext> mpFormulaGroupCxt;
     mutable boost::scoped_ptr<sc::DocumentLinkManager> mpDocLinkMgr;
 
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 92d1f7e..963ffe6 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1852,7 +1852,10 @@ 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;
+
         if (pSrcDoc->pShell->GetMedium())
             maFileURL = pSrcDoc->pShell->GetMedium()->GetURLObject().GetMainURL(INetURLObject::DECODE_TO_IURI);
 
commit d7e5c54451acc9959fd38f0db7eb7e5ac6b38858
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Feb 24 13:06:07 2014 -0500

    fdo#75259: Add unit test for sharing of string pools with undo docs.
    
    Change-Id: I785345144f7dd733b2ce8970412f79b384b8c94d

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 58c2128..a4c09ab 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -599,6 +599,38 @@ void Test::testSharedStringPool()
     m_pDoc->DeleteTab(0);
 }
 
+void Test::testSharedStringPoolUndoDoc()
+{
+    m_pDoc->InsertTab(0, "Test");
+
+    m_pDoc->SetString(ScAddress(0,0,0), "Header");
+    m_pDoc->SetString(ScAddress(0,1,0), "A1");
+    m_pDoc->SetString(ScAddress(0,2,0), "A2");
+    m_pDoc->SetString(ScAddress(0,3,0), "A3");
+
+    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));
+    }
+
+
+    // 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());
+    }
+
+    m_pDoc->DeleteTab(0);
+}
+
 void Test::testRangeList()
 {
     m_pDoc->InsertTab(0, "foo");
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 29b4c53..28e0156 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -89,6 +89,7 @@ public:
     void testPerf();
     void testCollator();
     void testSharedStringPool();
+    void testSharedStringPoolUndoDoc();
     void testRangeList();
     void testMarkData();
     void testInput();
@@ -341,6 +342,7 @@ public:
 #endif
     CPPUNIT_TEST(testCollator);
     CPPUNIT_TEST(testSharedStringPool);
+    CPPUNIT_TEST(testSharedStringPoolUndoDoc);
     CPPUNIT_TEST(testRangeList);
     CPPUNIT_TEST(testMarkData);
     CPPUNIT_TEST(testInput);


More information about the Libreoffice-commits mailing list