[Libreoffice-commits] core.git: Branch 'private/kohei/calc-shared-string' - 249 commits - avmedia/source basctl/source basegfx/Library_basegfx.mk basegfx/source basic/source bridges/source canvas/Library_oglcanvas.mk canvas/Module_canvas.mk canvas/source config_host.mk.in configure.ac connectivity/source cppcanvas/source cppuhelper/source cui/source cui/uiconfig dbaccess/source drawinglayer/source dtrans/source editeng/source embeddedobj/source embeddedobj/test extensions/source extras/source filter/source fpicker/source helpcontent2 hwpfilter/README i18nlangtag/source icu/ExternalProject_icu.mk include/basegfx include/cppcanvas include/drawinglayer include/editeng include/i18nlangtag include/oox include/sal include/sfx2 include/svl include/svtools include/svx include/tools ios/CustomTarget_LibreOffice_app.mk ios/experimental ios/iosremote jvmfwk/source linguistic/source linguistic/workben offapi/com officecfg/registry officecfg/util oox/source postprocess/Rdb_services.mk pyuno/source qad evOOo/tests reportbuilder/java reportdesign/source Repository.mk sal/rtl sc/inc sc/qa sc/source sdext/source sd/Library_sd.mk sd/qa sd/source setup_native/source sfx2/qa sfx2/source slideshow/source solenv/gbuild svgio/source svl/Library_svl.mk svl/qa svl/source svtools/source svx/source svx/uiconfig sw/inc sw/qa sw/source tools/source translations unotools/source unoxml/source ure/Package_install.mk uui/source vbahelper/source vcl/generic vcl/inc vcl/source vcl/unx writerfilter/inc writerfilter/Library_writerfilter.mk writerfilter/source xmloff/source

Kohei Yoshida kohei.yoshida at collabora.com
Tue Oct 8 12:48:39 PDT 2013


Rebased ref, commits from common ancestor:
commit 3786609a153b7fa38393eb646557d241af2d3060
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Oct 8 15:18:16 2013 -0400

    No more getIdentifier*() calls because they are not efficient.
    
    They shall never be used.
    
    Change-Id: I019c88b1511a67175d782777cd41e0ec0434f497

diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index 0ad6d28..06cbbe2 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -154,16 +154,9 @@ void ContentInfo::NormalizeString( svl::SharedStringPool& rPool )
     maText = rPool.intern(OUString(maText.getData()));
 }
 
-sal_uIntPtr ContentInfo::GetStringID( const svl::SharedStringPool& rPool ) const
+const svl::SharedString& ContentInfo::GetSharedString() const
 {
-    rtl_uString* p = const_cast<rtl_uString*>(maText.getData());
-    return rPool.getIdentifier(OUString(p));
-}
-
-sal_uIntPtr ContentInfo::GetStringIDIgnoreCase( const svl::SharedStringPool& rPool ) const
-{
-    rtl_uString* p = const_cast<rtl_uString*>(maText.getData());
-    return rPool.getIdentifierIgnoreCase(OUString(p));
+    return maText;
 }
 
 OUString ContentInfo::GetText() const
@@ -350,14 +343,9 @@ void EditTextObject::NormalizeString( svl::SharedStringPool& rPool )
     mpImpl->NormalizeString(rPool);
 }
 
-bool EditTextObject::GetStringIDs( const svl::SharedStringPool& rPool, std::vector<sal_uIntPtr>& rIDs ) const
-{
-    return mpImpl->GetStringIDs(rPool, rIDs);
-}
-
-bool EditTextObject::GetStringIDsIgnoreCase( const svl::SharedStringPool& rPool, std::vector<sal_uIntPtr>& rIDs ) const
+std::vector<svl::SharedString> EditTextObject::GetSharedStrings() const
 {
-    return mpImpl->GetStringIDsIgnoreCase(rPool, rIDs);
+    return mpImpl->GetSharedStrings();
 }
 
 const SfxItemPool* EditTextObject::GetPool() const
@@ -656,42 +644,17 @@ void EditTextObjectImpl::NormalizeString( svl::SharedStringPool& rPool )
     }
 }
 
-bool EditTextObjectImpl::GetStringIDs( const svl::SharedStringPool& rPool, std::vector<sal_uIntPtr>& rIDs ) const
-{
-    std::vector<sal_uIntPtr> aIDs;
-    aIDs.reserve(aContents.size());
-    ContentInfosType::const_iterator it = aContents.begin(), itEnd = aContents.end();
-    for (; it != itEnd; ++it)
-    {
-        const ContentInfo& rInfo = *it;
-        sal_uIntPtr nID = rInfo.GetStringID(rPool);
-        if (!nID)
-            return false;
-
-        aIDs.push_back(nID);
-    }
-
-    rIDs.swap(aIDs);
-    return true;
-}
-
-bool EditTextObjectImpl::GetStringIDsIgnoreCase( const svl::SharedStringPool& rPool, std::vector<sal_uIntPtr>& rIDs ) const
+std::vector<svl::SharedString> EditTextObjectImpl::GetSharedStrings() const
 {
-    std::vector<sal_uIntPtr> aIDs;
-    aIDs.reserve(aContents.size());
+    std::vector<svl::SharedString> aSSs;
+    aSSs.reserve(aContents.size());
     ContentInfosType::const_iterator it = aContents.begin(), itEnd = aContents.end();
     for (; it != itEnd; ++it)
     {
         const ContentInfo& rInfo = *it;
-        sal_uIntPtr nID = rInfo.GetStringIDIgnoreCase(rPool);
-        if (!nID)
-            return false;
-
-        aIDs.push_back(nID);
+        aSSs.push_back(rInfo.GetSharedString());
     }
-
-    rIDs.swap(aIDs);
-    return true;
+    return aSSs;
 }
 
 bool EditTextObjectImpl::IsVertical() const
diff --git a/editeng/source/editeng/editobj2.hxx b/editeng/source/editeng/editobj2.hxx
index d2ac045..5c1c2a2 100644
--- a/editeng/source/editeng/editobj2.hxx
+++ b/editeng/source/editeng/editobj2.hxx
@@ -144,8 +144,7 @@ public:
                         ~ContentInfo();
 
     void NormalizeString( svl::SharedStringPool& rPool );
-    sal_uIntPtr GetStringID( const svl::SharedStringPool& rPool ) const;
-    sal_uIntPtr GetStringIDIgnoreCase( const svl::SharedStringPool& rPool ) const;
+    const svl::SharedString& GetSharedString() const;
     OUString GetText() const;
     void SetText( const OUString& rStr );
 
@@ -210,8 +209,7 @@ public:
     void SetUserType( sal_uInt16 n );
 
     void NormalizeString( svl::SharedStringPool& rPool );
-    bool GetStringIDs( const svl::SharedStringPool& rPool, std::vector<sal_uIntPtr>& rIDs ) const;
-    bool GetStringIDsIgnoreCase( const svl::SharedStringPool& rPool, std::vector<sal_uIntPtr>& rIDs ) const;
+    std::vector<svl::SharedString> GetSharedStrings() const;
 
     bool                    IsVertical() const;
     void                    SetVertical( bool b );
diff --git a/include/editeng/editobj.hxx b/include/editeng/editobj.hxx
index 3d1ccca..3f78126 100644
--- a/include/editeng/editobj.hxx
+++ b/include/editeng/editobj.hxx
@@ -51,6 +51,7 @@ struct Section;
 
 namespace svl {
 
+class SharedString;
 class SharedStringPool;
 
 }
@@ -85,8 +86,7 @@ public:
      */
     void NormalizeString( svl::SharedStringPool& rPool );
 
-    bool GetStringIDs( const svl::SharedStringPool& rPool, std::vector<sal_uIntPtr>& rIDs ) const;
-    bool GetStringIDsIgnoreCase( const svl::SharedStringPool& rPool, std::vector<sal_uIntPtr>& rIDs ) const;
+    std::vector<svl::SharedString> GetSharedStrings() const;
 
     const SfxItemPool* GetPool() const;
     sal_uInt16 GetUserType() const;    // For OutlinerMode, it can however not save in compatible format
diff --git a/include/svl/sharedstring.hxx b/include/svl/sharedstring.hxx
index b2879a8..1e16c53 100644
--- a/include/svl/sharedstring.hxx
+++ b/include/svl/sharedstring.hxx
@@ -29,6 +29,7 @@ public:
     SharedString& operator= ( const SharedString& r );
 
     bool operator== ( const SharedString& r ) const;
+    bool operator!= ( const SharedString& r ) const;
 
     OUString getString() const;
 
@@ -37,6 +38,8 @@ public:
 
     rtl_uString* getDataIgnoreCase();
     const rtl_uString* getDataIgnoreCase() const;
+
+    bool isValid() const;
 };
 
 }
diff --git a/include/svl/sharedstringpool.hxx b/include/svl/sharedstringpool.hxx
index 35ce28e..c1b7698 100644
--- a/include/svl/sharedstringpool.hxx
+++ b/include/svl/sharedstringpool.hxx
@@ -51,28 +51,6 @@ public:
     SharedString intern( const OUString& rStr );
 
     /**
-     * Get a unique ID of string object that's expected to be in the shared
-     * string pool. If the string is not in the pool, NULL is returned.  The
-     * ID obtained by this method can be used for case sensitive comparison.
-     *
-     * @param rStr string object to get the ID of.
-     *
-     * @return unique ID of the string object.
-     */
-    sal_uIntPtr getIdentifier( const OUString& rStr ) const;
-
-    /**
-     * Get a unique ID of string object for case insensitive comparison. The
-     * string object is expected to be in the pool.
-     *
-     * @param rStr string object to get the ID of.
-     *
-     * @return unique ID of the string object usable for case insensitive
-     *         comparison.
-     */
-    sal_uIntPtr getIdentifierIgnoreCase( const OUString& rStr ) const;
-
-    /**
      * Go through all string objects in the pool, and clear those that are no
      * longer used outside of the pool.
      */
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index ec29627..d623efa 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -280,8 +280,7 @@ public:
     ScFormulaCell* SetFormulaCell( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, ScFormulaCell* pCell );
     bool SetGroupFormulaCell( SCROW nRow, ScFormulaCell* pCell );
 
-    sal_uIntPtr GetCellStringID( SCROW nRow ) const;
-    sal_uIntPtr GetCellStringIDIgnoreCase( SCROW nRow ) const;
+    svl::SharedString GetSharedString( SCROW nRow ) const;
 
     void SetRawString( SCROW nRow, const OUString& rStr, bool bBroadcast = true );
     void SetRawString( SCROW nRow, const svl::SharedString& rStr, bool bBroadcast = true );
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 69c8bdc..076982c 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -855,8 +855,8 @@ public:
 
     SC_DLLPUBLIC svl::SharedStringPool& GetSharedStringPool();
     const svl::SharedStringPool& GetSharedStringPool() const;
-    sal_uIntPtr GetCellStringID( const ScAddress& rPos ) const;
-    sal_uIntPtr GetCellStringIDIgnoreCase( const ScAddress& rPos ) const;
+
+    svl::SharedString GetSharedString( const ScAddress& rPos ) const;
 
     SC_DLLPUBLIC void GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, String& rString );
     SC_DLLPUBLIC void GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, OUString& rString );
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 5a216ae..2ab016a 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -343,8 +343,7 @@ public:
     ScFormulaCell* SetFormulaCell( SCCOL nCol, SCROW nRow, ScFormulaCell* pCell );
     bool SetGroupFormulaCell( SCCOL nCol, SCROW nRow, ScFormulaCell* pCell );
 
-    sal_uIntPtr GetCellStringID( SCCOL nCol, SCROW nRow ) const;
-    sal_uIntPtr GetCellStringIDIgnoreCase( SCCOL nCol, SCROW nRow ) const;
+    svl::SharedString GetSharedString( SCCOL nCol, SCROW nRow ) const;
 
     void        SetValue( SCCOL nCol, SCROW nRow, const double& rVal );
     void        SetError( SCCOL nCol, SCROW nRow, sal_uInt16 nError);
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 3c7bf07..9bba942 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -461,7 +461,7 @@ void Test::testCollator()
     CPPUNIT_ASSERT_MESSAGE("these strings are supposed to be different!", nRes != 0);
 }
 
-void Test::testCellStringPool()
+void Test::testSharedStringPool()
 {
     m_pDoc->InsertTab(0, "foo");
 
@@ -472,34 +472,34 @@ void Test::testCellStringPool()
     m_pDoc->SetString(ScAddress(0,3,0), "andy");  // A4
     m_pDoc->SetString(ScAddress(0,4,0), "BRUCE"); // A5
 
-    sal_uIntPtr nId1 = m_pDoc->GetCellStringID(ScAddress(0,0,0));
-    sal_uIntPtr nId2 = m_pDoc->GetCellStringID(ScAddress(0,1,0));
-    CPPUNIT_ASSERT_MESSAGE("Failed to get a valid string ID.", nId1);
-    CPPUNIT_ASSERT_MESSAGE("Failed to get a valid string ID.", nId2);
-    CPPUNIT_ASSERT_EQUAL(nId1, nId2);
-
-    nId2 = m_pDoc->GetCellStringID(ScAddress(0,2,0));
-    CPPUNIT_ASSERT_MESSAGE("They must differ", nId1 != nId2);
-
-    nId2 = m_pDoc->GetCellStringID(ScAddress(0,3,0));
-    CPPUNIT_ASSERT_MESSAGE("They must differ", nId1 != nId2);
-
-    nId2 = m_pDoc->GetCellStringID(ScAddress(0,4,0));
-    CPPUNIT_ASSERT_MESSAGE("They must differ", nId1 != nId2);
-
-    // A3 and A5 should differ but should be equal case-insensitively.
-    nId1 = m_pDoc->GetCellStringID(ScAddress(0,2,0));
-    nId2 = m_pDoc->GetCellStringID(ScAddress(0,4,0));
-    CPPUNIT_ASSERT_MESSAGE("They must differ", nId1 != nId2);
-
-    nId1 = m_pDoc->GetCellStringIDIgnoreCase(ScAddress(0,2,0));
-    nId2 = m_pDoc->GetCellStringIDIgnoreCase(ScAddress(0,4,0));
-    CPPUNIT_ASSERT_MESSAGE("They must be equal when cases are ignored.", nId1 == nId2);
-
-    // A2 and A4 should be equal when ignoring cases.
-    nId1 = m_pDoc->GetCellStringIDIgnoreCase(ScAddress(0,1,0));
-    nId2 = m_pDoc->GetCellStringIDIgnoreCase(ScAddress(0,3,0));
-    CPPUNIT_ASSERT_MESSAGE("They must be equal when cases are ignored.", nId1 == nId2);
+    {
+        // These two shared string objects must go out of scope before the purge test.
+        svl::SharedString aSS1 = m_pDoc->GetSharedString(ScAddress(0,0,0));
+        svl::SharedString aSS2 = m_pDoc->GetSharedString(ScAddress(0,1,0));
+        CPPUNIT_ASSERT_MESSAGE("Failed to get a valid shared string.", aSS1.isValid());
+        CPPUNIT_ASSERT_MESSAGE("Failed to get a valid shared string.", aSS2.isValid());
+        CPPUNIT_ASSERT_EQUAL(aSS1.getData(), aSS2.getData());
+
+        aSS2 = m_pDoc->GetSharedString(ScAddress(0,2,0));
+        CPPUNIT_ASSERT_MESSAGE("They must differ", aSS1.getData() != aSS2.getData());
+
+        aSS2 = m_pDoc->GetSharedString(ScAddress(0,3,0));
+        CPPUNIT_ASSERT_MESSAGE("They must differ", aSS1.getData() != aSS2.getData());
+
+        aSS2 = m_pDoc->GetSharedString(ScAddress(0,4,0));
+        CPPUNIT_ASSERT_MESSAGE("They must differ", aSS1.getData() != aSS2.getData());
+
+        // A3 and A5 should differ but should be equal case-insensitively.
+        aSS1 = m_pDoc->GetSharedString(ScAddress(0,2,0));
+        aSS2 = m_pDoc->GetSharedString(ScAddress(0,4,0));
+        CPPUNIT_ASSERT_MESSAGE("They must differ", aSS1.getData() != aSS2.getData());
+        CPPUNIT_ASSERT_MESSAGE("They must be equal when cases are ignored.", aSS1.getDataIgnoreCase() == aSS2.getDataIgnoreCase());
+
+        // A2 and A4 should be equal when ignoring cases.
+        aSS1 = m_pDoc->GetSharedString(ScAddress(0,1,0));
+        aSS2 = m_pDoc->GetSharedString(ScAddress(0,3,0));
+        CPPUNIT_ASSERT_MESSAGE("They must be equal when cases are ignored.", aSS1.getDataIgnoreCase() == aSS2.getDataIgnoreCase());
+    }
 
     // Check the string counts after purging. Purging shouldn't remove any strings in this case.
     svl::SharedStringPool& rPool = m_pDoc->GetSharedStringPool();
@@ -568,24 +568,24 @@ void Test::testCellStringPool()
     m_pDoc->SetEditText(ScAddress(1,0,0), rEE.CreateTextObject()); // B1
 
     // These two should be equal.
-    nId1 = m_pDoc->GetCellStringID(ScAddress(0,0,0));
-    nId2 = m_pDoc->GetCellStringID(ScAddress(1,0,0));
-    CPPUNIT_ASSERT_MESSAGE("Failed to get a valid string ID.", nId1);
-    CPPUNIT_ASSERT_MESSAGE("Failed to get a valid string ID.", nId2);
-    CPPUNIT_ASSERT_EQUAL(nId1, nId2);
+    svl::SharedString aSS1 = m_pDoc->GetSharedString(ScAddress(0,0,0));
+    svl::SharedString aSS2 = m_pDoc->GetSharedString(ScAddress(1,0,0));
+    CPPUNIT_ASSERT_MESSAGE("Failed to get a valid string ID.", aSS1.isValid());
+    CPPUNIT_ASSERT_MESSAGE("Failed to get a valid string ID.", aSS2.isValid());
+    CPPUNIT_ASSERT_EQUAL(aSS1.getData(), aSS2.getData());
 
     rEE.SetText("ANDY and BRUCE");
     m_pDoc->SetEditText(ScAddress(2,0,0), rEE.CreateTextObject()); // C1
-    nId2 = m_pDoc->GetCellStringID(ScAddress(2,0,0));
-    CPPUNIT_ASSERT_MESSAGE("Failed to get a valid string ID.", nId2);
-    CPPUNIT_ASSERT_MESSAGE("These two should be different when cases are considered.", nId1 != nId2);
+    aSS2 = m_pDoc->GetSharedString(ScAddress(2,0,0));
+    CPPUNIT_ASSERT_MESSAGE("Failed to get a valid string ID.", aSS2.isValid());
+    CPPUNIT_ASSERT_MESSAGE("These two should be different when cases are considered.", aSS1.getData() != aSS2.getData());
 
     // But they should be considered equal when cases are ignored.
-    nId1 = m_pDoc->GetCellStringIDIgnoreCase(ScAddress(0,0,0));
-    nId2 = m_pDoc->GetCellStringIDIgnoreCase(ScAddress(2,0,0));
-    CPPUNIT_ASSERT_MESSAGE("Failed to get a valid string ID.", nId1);
-    CPPUNIT_ASSERT_MESSAGE("Failed to get a valid string ID.", nId2);
-    CPPUNIT_ASSERT_EQUAL(nId1, nId2);
+    aSS1 = m_pDoc->GetSharedString(ScAddress(0,0,0));
+    aSS2 = m_pDoc->GetSharedString(ScAddress(2,0,0));
+    CPPUNIT_ASSERT_MESSAGE("Failed to get a valid string ID.", aSS1.isValid());
+    CPPUNIT_ASSERT_MESSAGE("Failed to get a valid string ID.", aSS2.isValid());
+    CPPUNIT_ASSERT_EQUAL(aSS1.getDataIgnoreCase(), aSS2.getDataIgnoreCase());
 
     m_pDoc->DeleteTab(0);
 }
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index d1ba668..2c30f43 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -80,7 +80,7 @@ public:
      */
     void testPerf();
     void testCollator();
-    void testCellStringPool();
+    void testSharedStringPool();
     void testRangeList();
     void testInput();
 
@@ -285,7 +285,7 @@ public:
     CPPUNIT_TEST(testPerf);
 #endif
     CPPUNIT_TEST(testCollator);
-    CPPUNIT_TEST(testCellStringPool);
+    CPPUNIT_TEST(testSharedStringPool);
     CPPUNIT_TEST(testRangeList);
     CPPUNIT_TEST(testInput);
     CPPUNIT_TEST(testFormulaHashAndTag);
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index f331d35..ae84c13 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1736,62 +1736,28 @@ bool ScColumn::SetGroupFormulaCell( SCROW nRow, ScFormulaCell* pCell )
     return true;
 }
 
-sal_uIntPtr ScColumn::GetCellStringID( SCROW nRow ) const
+svl::SharedString ScColumn::GetSharedString( SCROW nRow ) const
 {
     sc::CellStoreType::const_position_type aPos = maCells.position(nRow);
     switch (aPos.first->type)
     {
         case sc::element_type_string:
-        {
-            const svl::SharedString& rStr = sc::string_block::at(*aPos.first->data, aPos.second);
-            return reinterpret_cast<sal_uIntPtr>(rStr.getData());
-        }
-        break;
-        case sc::element_type_edittext:
-        {
-            std::vector<sal_uIntPtr> aIDs;
-            const EditTextObject* pObj = sc::edittext_block::at(*aPos.first->data, aPos.second);
-            pObj->GetStringIDs(pDocument->GetSharedStringPool(), aIDs);
-            if (aIDs.size() != 1)
-                // We don't handle multiline content for now.
-                return 0;
-
-            return aIDs[0];
-        }
-        break;
-        default:
-            ;
-    }
-    return 0;
-}
-
-sal_uIntPtr ScColumn::GetCellStringIDIgnoreCase( SCROW nRow ) const
-{
-    sc::CellStoreType::const_position_type aPos = maCells.position(nRow);
-    switch (aPos.first->type)
-    {
-        case sc::element_type_string:
-        {
-            const svl::SharedString& rStr = sc::string_block::at(*aPos.first->data, aPos.second);
-            return reinterpret_cast<sal_uIntPtr>(rStr.getDataIgnoreCase());
-        }
-        break;
+            return sc::string_block::at(*aPos.first->data, aPos.second);
         case sc::element_type_edittext:
         {
-            std::vector<sal_uIntPtr> aIDs;
             const EditTextObject* pObj = sc::edittext_block::at(*aPos.first->data, aPos.second);
-            pObj->GetStringIDsIgnoreCase(pDocument->GetSharedStringPool(), aIDs);
-            if (aIDs.size() != 1)
+            std::vector<svl::SharedString> aSSs = pObj->GetSharedStrings();
+            if (aSSs.size() != 1)
                 // We don't handle multiline content for now.
-                return 0;
+                return svl::SharedString();
 
-            return aIDs[0];
+            return aSSs[0];
         }
         break;
         default:
             ;
     }
-    return 0;
+    return svl::SharedString();
 }
 
 namespace {
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index b5f6b8e..51a5c2e 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3213,20 +3213,12 @@ double* ScDocument::GetValueCell( const ScAddress& rPos )
     return maTabs[rPos.Tab()]->GetValueCell(rPos.Col(), rPos.Row());
 }
 
-sal_uIntPtr ScDocument::GetCellStringID( const ScAddress& rPos ) const
+svl::SharedString ScDocument::GetSharedString( const ScAddress& rPos ) const
 {
     if (!TableExists(rPos.Tab()))
-        return 0;
-
-    return maTabs[rPos.Tab()]->GetCellStringID(rPos.Col(), rPos.Row());
-}
-
-sal_uIntPtr ScDocument::GetCellStringIDIgnoreCase( const ScAddress& rPos ) const
-{
-    if (!TableExists(rPos.Tab()))
-        return 0;
+        return svl::SharedString();
 
-    return maTabs[rPos.Tab()]->GetCellStringIDIgnoreCase(rPos.Col(), rPos.Row());
+    return maTabs[rPos.Tab()]->GetSharedString(rPos.Col(), rPos.Row());
 }
 
 void ScDocument::GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, OUString& rString )
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index a7504cc..be791ca 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1505,20 +1505,12 @@ bool ScTable::SetGroupFormulaCell( SCCOL nCol, SCROW nRow, ScFormulaCell* pCell
     return aCol[nCol].SetGroupFormulaCell(nRow, pCell);
 }
 
-sal_uIntPtr ScTable::GetCellStringID( SCCOL nCol, SCROW nRow ) const
+svl::SharedString ScTable::GetSharedString( SCCOL nCol, SCROW nRow ) const
 {
     if (!ValidColRow(nCol, nRow))
-        return 0;
-
-    return aCol[nCol].GetCellStringID(nRow);
-}
-
-sal_uIntPtr ScTable::GetCellStringIDIgnoreCase( SCCOL nCol, SCROW nRow ) const
-{
-    if (!ValidColRow(nCol, nRow))
-        return 0;
+        return svl::SharedString();
 
-    return aCol[nCol].GetCellStringIDIgnoreCase(nRow);
+    return aCol[nCol].GetSharedString(nRow);
 }
 
 void ScTable::SetValue( SCCOL nCol, SCROW nRow, const double& rVal )
diff --git a/svl/source/misc/sharedstring.cxx b/svl/source/misc/sharedstring.cxx
index e8ad0b7..5eb3af5 100644
--- a/svl/source/misc/sharedstring.cxx
+++ b/svl/source/misc/sharedstring.cxx
@@ -78,6 +78,11 @@ bool SharedString::operator== ( const SharedString& r ) const
     return !r.mpData;
 }
 
+bool SharedString::operator!= ( const SharedString& r ) const
+{
+    return !operator== (r);
+}
+
 OUString SharedString::getString() const
 {
     return mpData ? OUString(mpData) : OUString();
@@ -103,6 +108,11 @@ const rtl_uString* SharedString::getDataIgnoreCase() const
     return mpDataIgnoreCase;
 }
 
+bool SharedString::isValid() const
+{
+    return mpData != NULL;
+}
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svl/source/misc/sharedstringpool.cxx b/svl/source/misc/sharedstringpool.cxx
index 6b8f152..46bf814 100644
--- a/svl/source/misc/sharedstringpool.cxx
+++ b/svl/source/misc/sharedstringpool.cxx
@@ -52,28 +52,6 @@ SharedString SharedStringPool::intern( const OUString& rStr )
     return SharedString(pOrig, aRes.first->pData);
 }
 
-sal_uIntPtr SharedStringPool::getIdentifier( const OUString& rStr ) const
-{
-    StrHashType::const_iterator it = maStrPool.find(rStr);
-    return (it == maStrPool.end()) ? 0 : reinterpret_cast<sal_uIntPtr>(it->pData);
-}
-
-sal_uIntPtr SharedStringPool::getIdentifierIgnoreCase( const OUString& rStr ) const
-{
-    StrHashType::const_iterator itOrig = maStrPool.find(rStr);
-    if (itOrig == maStrPool.end())
-        // Not in the pool.
-        return 0;
-
-    StrStoreType::const_iterator itUpper = maStrStore.find(itOrig->pData);
-    if (itUpper == maStrStore.end())
-        // Passed string is not in the pool.
-        return 0;
-
-    const rtl_uString* pUpper = itUpper->second.pData;
-    return reinterpret_cast<sal_uIntPtr>(pUpper);
-}
-
 namespace {
 
 inline sal_Int32 getRefCount( const rtl_uString* p )
commit a7ff6e0a3fc5fccad33f06ae9d4ec7019f9ae156
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Oct 8 13:47:49 2013 -0400

    Support for passing non-double formula results from group interpreter.
    
    Change-Id: I1cbe6b32d8a9b86a575e9806802f7a2a45eee873

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 3fb39ba..ec29627 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -477,6 +477,7 @@ public:
     void FillMatrix( ScMatrix& rMat, size_t nMatCol, SCROW nRow1, SCROW nRow2 ) const;
     formula::VectorRefArray FetchVectorRefArray( sc::FormulaGroupContext& rCxt, SCROW nRow1, SCROW nRow2 );
     void SetFormulaResults( SCROW nRow, const double* pResults, size_t nLen );
+    void SetFormulaResults( SCROW nRow, const formula::FormulaTokenRef* pResults, size_t nLen );
 
     void SetNumberFormat( SCROW nRow, sal_uInt32 nNumberFormat );
 
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index c1fdacb..69c8bdc 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1748,6 +1748,8 @@ public:
      */
     void SC_DLLPUBLIC SetFormulaResults( const ScAddress& rTopPos, const double* pResults, size_t nLen );
 
+    void SC_DLLPUBLIC SetFormulaResults( const ScAddress& rTopPos, const formula::FormulaTokenRef* pResults, size_t nLen );
+
 private:
     ScDocument(const ScDocument& r); // disabled with no definition
 
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 6e095e2..5a216ae 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -871,6 +871,7 @@ public:
     void InterpretDirtyCells( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
 
     void SetFormulaResults( SCCOL nCol, SCROW nRow, const double* pResults, size_t nLen );
+    void SetFormulaResults( SCCOL nCol, SCROW nRow, const formula::FormulaTokenRef* pResults, size_t nLen );
 
     /**
      * Have formula cells with NeedsListening() == true start listening to the
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index bb8cf5f..ec3d475 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -2466,6 +2466,32 @@ void ScColumn::SetFormulaResults( SCROW nRow, const double* pResults, size_t nLe
     }
 }
 
+void ScColumn::SetFormulaResults( SCROW nRow, const formula::FormulaTokenRef* pResults, size_t nLen )
+{
+    sc::CellStoreType::position_type aPos = maCells.position(nRow);
+    sc::CellStoreType::iterator it = aPos.first;
+    if (it->type != sc::element_type_formula)
+        // This is not a formula block.
+        return;
+
+    size_t nBlockLen = it->size - aPos.second;
+    if (nBlockLen < nLen)
+        // Result array is longer than the length of formula cells. Not good.
+        return;
+
+    sc::formula_block::iterator itCell = sc::formula_block::begin(*it->data);
+    std::advance(itCell, aPos.second);
+
+    const formula::FormulaTokenRef* pResEnd = pResults + nLen;
+    for (; pResults != pResEnd; ++pResults, ++itCell)
+    {
+        ScFormulaCell& rCell = **itCell;
+        rCell.SetResultToken(pResults->get());
+        rCell.ResetDirty();
+        rCell.SetChanged(true);
+    }
+}
+
 void ScColumn::SetNumberFormat( SCROW nRow, sal_uInt32 nNumberFormat )
 {
     short eOldType = pDocument->GetFormatTable()->GetType(
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index d69e25b..c7e6a99 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -454,8 +454,15 @@ void ScDocument::SetFormulaResults( const ScAddress& rTopPos, const double* pRes
     pTab->SetFormulaResults(rTopPos.Col(), rTopPos.Row(), pResults, nLen);
 }
 
+void ScDocument::SetFormulaResults(
+    const ScAddress& rTopPos, const formula::FormulaTokenRef* pResults, size_t nLen )
+{
+    ScTable* pTab = FetchTable(rTopPos.Tab());
+    if (!pTab)
+        return;
 
-//------------------------------------------------------------------------
+    pTab->SetFormulaResults(rTopPos.Col(), rTopPos.Row(), pResults, nLen);
+}
 
 void ScDocument::InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* pAdrTo,
                                       bool bNumFormatChanged )
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 0c985fd..851cf6c 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -2231,6 +2231,15 @@ void ScTable::SetFormulaResults( SCCOL nCol, SCROW nRow, const double* pResults,
     aCol[nCol].SetFormulaResults(nRow, pResults, nLen);
 }
 
+void ScTable::SetFormulaResults(
+    SCCOL nCol, SCROW nRow, const formula::FormulaTokenRef* pResults, size_t nLen )
+{
+    if (!ValidCol(nCol))
+        return;
+
+    aCol[nCol].SetFormulaResults(nRow, pResults, nLen);
+}
+
 #if DEBUG_COLUMN_STORAGE
 void ScTable::DumpFormulaGroups( SCCOL nCol ) const
 {
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index 09076a8..21edd7e 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -141,7 +141,7 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddres
     // the group.
 
     ScAddress aTmpPos = rTopPos;
-    std::vector<double> aResults;
+    std::vector<formula::FormulaTokenRef> aResults;
     aResults.reserve(xGroup->mnLength);
     CachedTokensType aCachedTokens;
 
@@ -256,7 +256,7 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddres
         generateRPNCode(rDoc, aTmpPos, aCode2);
         ScInterpreter aInterpreter(pDest, &rDoc, aTmpPos, aCode2);
         aInterpreter.Interpret();
-        aResults.push_back(aInterpreter.GetResultToken()->GetDouble());
+        aResults.push_back(aInterpreter.GetResultToken());
     } // for loop end (xGroup->mnLength)
 
     if (!aResults.empty())
commit 0b4e68fddc9b259ad89505a5c4ad287b1b31f1e8
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Oct 8 11:24:16 2013 -0400

    Add VLOOKUP to the list of functions we support for group calculation.
    
    Change-Id: I2a440b881af14076928e97918bdc5508804ff0ee

diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 69ba49e..e519455 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1336,6 +1336,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocMatInv:
             case ocCount:
             case ocCount2:
+            case ocVLookup:
                 // Don't change the state.
             break;
             default:
commit 25bb77cd3f4431cdff9ef798976f55b8505c979f
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Oct 8 11:11:48 2013 -0400

    Turns out we are not using OpenCL here in the existing interpreter.
    
    Change-Id: I4d511ef8099b5d7fcff07adf401901c9ee089ad3

diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 3885823..770ee24 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -6449,43 +6449,6 @@ void ScInterpreter::ScHLookup()
     CalculateLookup(true);
 }
 
-namespace {
-
-#if 1
-bool isFilterByEqualString( const ScQueryParam& )
-{
-    return false;
-}
-#else
-bool isFilterByEqualString( const ScQueryParam& rParam )
-{
-    if (rParam.bRegExp)
-        // filter by regular expression.
-        return false;
-
-    if (!rParam.GetEntryCount())
-        // No entries.
-        return false;
-
-    const ScQueryEntry& rEntry = rParam.GetEntry(0);
-    if (rEntry.eOp != SC_EQUAL)
-        return false;
-
-    const ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems();
-    if (rItems.size() != 1)
-        // Multi-item query is not supported.
-        return false;
-
-    if (rItems[0].meType != ScQueryEntry::ByString)
-        // Not by string equality.
-        return false;
-
-    return true;
-}
-#endif
-
-}
-
 void ScInterpreter::CalculateLookup(bool bHLookup)
 {
     sal_uInt8 nParamCount = GetByte();
@@ -6722,18 +6685,9 @@ void ScInterpreter::CalculateLookup(bool bHLookup)
         }
         else
         {
-            if (isFilterByEqualString(aParam))
-            {
-                nRow = nRow1;
-                bFound = true;
-            }
-            else
-            {
-                ScAddress aResultPos( nCol1, nRow1, nTab1);
-                bFound = LookupQueryWithCache( aResultPos, aParam);
-                nRow = aResultPos.Row();
-            }
-
+            ScAddress aResultPos( nCol1, nRow1, nTab1);
+            bFound = LookupQueryWithCache( aResultPos, aParam);
+            nRow = aResultPos.Row();
             nCol = nSpIndex;
         }
 
commit 6cfaf9b3d3194d850b52993d2f0e3dcf8e4e5bce
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Oct 8 10:30:15 2013 -0400

    Let's not do this.
    
    Change-Id: I93fe9f8c5edbfb08b78b6694771db2dd18d8868c

diff --git a/sc/inc/queryentry.hxx b/sc/inc/queryentry.hxx
index 636372e..a3baea6 100644
--- a/sc/inc/queryentry.hxx
+++ b/sc/inc/queryentry.hxx
@@ -42,9 +42,8 @@ struct SC_DLLPUBLIC ScQueryEntry
         QueryType     meType;
         double        mfVal;
         OUString maString;
-        sal_uIntPtr mnStrId;
 
-        Item() : meType(ByValue), mfVal(0.0), mnStrId(0) {}
+        Item() : meType(ByValue), mfVal(0.0) {}
 
         bool operator== (const Item& r) const;
     };
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 87cdc74..3885823 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -6763,7 +6763,6 @@ bool ScInterpreter::FillEntry(ScQueryEntry& rEntry)
             const OUString& sStr = GetString();
             rItem.meType = ScQueryEntry::ByString;
             rItem.maString = sStr;
-            rItem.mnStrId = pDok->GetSharedStringPool().getIdentifierIgnoreCase(rItem.maString);
         }
         break;
         case svDoubleRef :
@@ -6788,7 +6787,6 @@ bool ScInterpreter::FillEntry(ScQueryEntry& rEntry)
                 GetCellString(aStr, aCell);
                 rItem.meType = ScQueryEntry::ByString;
                 rItem.maString = aStr;
-                rItem.mnStrId = pDok->GetSharedStringPool().getIdentifierIgnoreCase(rItem.maString);
             }
         }
         break;
@@ -6797,7 +6795,6 @@ bool ScInterpreter::FillEntry(ScQueryEntry& rEntry)
             OUString aStr;
             const ScMatValType nType = GetDoubleOrStringFromMatrix(rItem.mfVal, aStr);
             rItem.maString = aStr;
-            rItem.mnStrId = pDok->GetSharedStringPool().getIdentifierIgnoreCase(rItem.maString);
             rItem.meType = ScMatrix::IsNonValueType(nType) ?
                 ScQueryEntry::ByString : ScQueryEntry::ByValue;
         }
diff --git a/sc/source/core/tool/queryentry.cxx b/sc/source/core/tool/queryentry.cxx
index e061d0f..1ac1a89 100644
--- a/sc/source/core/tool/queryentry.cxx
+++ b/sc/source/core/tool/queryentry.cxx
@@ -32,7 +32,7 @@
 
 bool ScQueryEntry::Item::operator== (const Item& r) const
 {
-    return meType == r.meType && mfVal == r.mfVal && maString.equals(r.maString) && mnStrId == r.mnStrId;
+    return meType == r.meType && mfVal == r.mfVal && maString.equals(r.maString);
 }
 
 ScQueryEntry::ScQueryEntry() :
commit 165a61190f103d0227f57a3f19afa144604155a9
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Oct 8 10:08:59 2013 -0400

    Handle edit text cells here as well as the string cells.
    
    Change-Id: I46934341dbde93d963764152f663c4d2d310bea0

diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 392a851..bb8cf5f 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -2250,16 +2250,39 @@ bool appendStrings(
     return false;
 }
 
-void copyFirstStringBlock( sc::FormulaGroupContext& rCxt, size_t nLen, const sc::CellStoreType::position_type& rPos )
+void copyFirstStringBlock(
+    ScDocument& rDoc, sc::FormulaGroupContext& rCxt, size_t nLen, const sc::CellStoreType::position_type& rPos )
 {
     rCxt.maStrArrays.push_back(new sc::FormulaGroupContext::StrArrayType);
     sc::FormulaGroupContext::StrArrayType& rArray = rCxt.maStrArrays.back();
     rArray.reserve(nLen);
 
-    svl::SharedString* p = &sc::string_block::at(*rPos.first->data, rPos.second);
-    svl::SharedString* pEnd = p + nLen;
-    for (; p != pEnd; ++p)
-        rArray.push_back(p->getDataIgnoreCase());
+    switch (rPos.first->type)
+    {
+        case sc::element_type_string:
+        {
+            svl::SharedString* p = &sc::string_block::at(*rPos.first->data, rPos.second);
+            svl::SharedString* pEnd = p + nLen;
+            for (; p != pEnd; ++p)
+                rArray.push_back(p->getDataIgnoreCase());
+        }
+        break;
+        case sc::element_type_edittext:
+        {
+            EditTextObject** p = &sc::edittext_block::at(*rPos.first->data, rPos.second);
+            EditTextObject** pEnd = p + nLen;
+            svl::SharedStringPool& rPool = rDoc.GetSharedStringPool();
+            for (; p != pEnd; ++p)
+            {
+                EditTextObject* pText = *p;
+                OUString aStr = ScEditUtil::GetString(*pText, &rDoc);
+                rArray.push_back(rPool.intern(aStr).getDataIgnoreCase());
+            }
+        }
+        break;
+        default:
+            ;
+    }
 }
 
 }
@@ -2366,16 +2389,17 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( sc::FormulaGroupContext&
         }
         break;
         case sc::element_type_string:
+        case sc::element_type_edittext:
         {
             if (nLenRequested <= nLen)
             {
                 // Requested length fits a single block.
-                copyFirstStringBlock(rCxt, nLenRequested, aPos);
+                copyFirstStringBlock(*pDocument, rCxt, nLenRequested, aPos);
                 sc::FormulaGroupContext::StrArrayType& rArray = rCxt.maStrArrays.back();
                 return formula::VectorRefArray(&rArray[0]);
             }
 
-            copyFirstStringBlock(rCxt, nLen, aPos);
+            copyFirstStringBlock(*pDocument, rCxt, nLen, aPos);
             sc::FormulaGroupContext::StrArrayType& rArray = rCxt.maStrArrays.back();
 
             // Fill the remaining array with values from the following blocks.
commit 83998b79f694fc513cb8e6d01f2e40afeb39d17b
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Oct 8 09:33:23 2013 -0400

    Get the string ID's for case insensitive comparisons.
    
    If we ever need to use this for case sensitive comparisons, we'll have to
    find a way to conditionalize it.
    
    Change-Id: Ibb862c4700d2fb660570fc80a80a03eed1d556c3

diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 21ef99f..392a851 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -2183,7 +2183,7 @@ bool appendStrings(
                 getBlockIterators<sc::string_block>(it, nLenRemain, itData, itDataEnd);
 
                 for (; itData != itDataEnd; ++itData)
-                    rArray.push_back(itData->getData());
+                    rArray.push_back(itData->getDataIgnoreCase());
             }
             break;
             case sc::element_type_edittext:
@@ -2194,7 +2194,7 @@ bool appendStrings(
                 for (; itData != itDataEnd; ++itData)
                 {
                     OUString aStr = ScEditUtil::GetString(**itData, pDoc);
-                    rArray.push_back(rPool.intern(aStr).getData());
+                    rArray.push_back(rPool.intern(aStr).getDataIgnoreCase());
                 }
             }
             break;
@@ -2219,7 +2219,7 @@ bool appendStrings(
                         return false;
                     }
 
-                    rArray.push_back(rPool.intern(aStr).getData());
+                    rArray.push_back(rPool.intern(aStr).getDataIgnoreCase());
                 }
             }
             break;
@@ -2250,7 +2250,7 @@ bool appendStrings(
     return false;
 }
 
-void copyFirstBlock( sc::FormulaGroupContext& rCxt, size_t nLen, const sc::CellStoreType::position_type& rPos )
+void copyFirstStringBlock( sc::FormulaGroupContext& rCxt, size_t nLen, const sc::CellStoreType::position_type& rPos )
 {
     rCxt.maStrArrays.push_back(new sc::FormulaGroupContext::StrArrayType);
     sc::FormulaGroupContext::StrArrayType& rArray = rCxt.maStrArrays.back();
@@ -2259,7 +2259,7 @@ void copyFirstBlock( sc::FormulaGroupContext& rCxt, size_t nLen, const sc::CellS
     svl::SharedString* p = &sc::string_block::at(*rPos.first->data, rPos.second);
     svl::SharedString* pEnd = p + nLen;
     for (; p != pEnd; ++p)
-        rArray.push_back(p->getData());
+        rArray.push_back(p->getDataIgnoreCase());
 }
 
 }
@@ -2370,12 +2370,12 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( sc::FormulaGroupContext&
             if (nLenRequested <= nLen)
             {
                 // Requested length fits a single block.
-                copyFirstBlock(rCxt, nLenRequested, aPos);
+                copyFirstStringBlock(rCxt, nLenRequested, aPos);
                 sc::FormulaGroupContext::StrArrayType& rArray = rCxt.maStrArrays.back();
                 return formula::VectorRefArray(&rArray[0]);
             }
 
-            copyFirstBlock(rCxt, nLen, aPos);
+            copyFirstStringBlock(rCxt, nLen, aPos);
             sc::FormulaGroupContext::StrArrayType& rArray = rCxt.maStrArrays.back();
 
             // Fill the remaining array with values from the following blocks.
commit 148ee8f8dfeaf5e84c36017f25e78f59b662bbe6
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Oct 8 09:27:27 2013 -0400

    Rename GetCellStringPool() to GetSharedStringPool().
    
    Change-Id: I99d373f7887424bb103cff60d53f5cd8ce337ef7

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 22d6eed..c1fdacb 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -853,8 +853,8 @@ public:
      */
     double* GetValueCell( const ScAddress& rPos );
 
-    SC_DLLPUBLIC svl::SharedStringPool& GetCellStringPool();
-    const svl::SharedStringPool& GetCellStringPool() const;
+    SC_DLLPUBLIC svl::SharedStringPool& GetSharedStringPool();
+    const svl::SharedStringPool& GetSharedStringPool() const;
     sal_uIntPtr GetCellStringID( const ScAddress& rPos ) const;
     sal_uIntPtr GetCellStringIDIgnoreCase( const ScAddress& rPos ) const;
 
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 8017845..3c7bf07 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -502,7 +502,7 @@ void Test::testCellStringPool()
     CPPUNIT_ASSERT_MESSAGE("They must be equal when cases are ignored.", nId1 == nId2);
 
     // Check the string counts after purging. Purging shouldn't remove any strings in this case.
-    svl::SharedStringPool& rPool = m_pDoc->GetCellStringPool();
+    svl::SharedStringPool& rPool = m_pDoc->GetSharedStringPool();
     rPool.purge();
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), rPool.getCount());
     CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rPool.getCountIgnoreCase());
@@ -1475,7 +1475,7 @@ struct PartiallyFilledEmptyMatrix
 
 void Test::testMatrix()
 {
-    svl::SharedStringPool& rPool = m_pDoc->GetCellStringPool();
+    svl::SharedStringPool& rPool = m_pDoc->GetSharedStringPool();
     ScMatrixRef pMat, pMat2;
 
     // First, test the zero matrix type.
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 4502fe0..bdfb9c5 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1477,7 +1477,7 @@ void ScColumn::CopyStaticToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDestCol
                 for (; itData != itDataEnd; ++itData)
                 {
                     const EditTextObject& rObj = **itData;
-                    svl::SharedString aSS = pDocument->GetCellStringPool().intern(ScEditUtil::GetString(rObj, pDocument));
+                    svl::SharedString aSS = pDocument->GetSharedStringPool().intern(ScEditUtil::GetString(rObj, pDocument));
                     aConverted.push_back(aSS);
                 }
                 aDestPos.miCellPos = rDestCol.maCells.set(aDestPos.miCellPos, nCurRow, aConverted.begin(), aConverted.end());
@@ -1507,7 +1507,7 @@ void ScColumn::CopyStaticToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDestCol
                         aDestPos.miCellPos = rDestCol.maCells.set(aDestPos.miCellPos, nRow, rFC.GetValue());
                     else
                     {
-                        svl::SharedString aSS = pDocument->GetCellStringPool().intern(rFC.GetString());
+                        svl::SharedString aSS = pDocument->GetSharedStringPool().intern(rFC.GetString());
                         if (aSS.getData())
                             aDestPos.miCellPos = rDestCol.maCells.set(aDestPos.miCellPos, nRow, aSS);
                     }
@@ -1800,7 +1800,7 @@ class CopyByCloneHandler
             }
             else
             {
-                svl::SharedString aSS = mrDestCol.GetDoc().GetCellStringPool().intern(aStr);
+                svl::SharedString aSS = mrDestCol.GetDoc().GetSharedStringPool().intern(aStr);
                 if (aSS.getData())
                 {
                     maDestPos.miCellPos =
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 0f13a26..21ef99f 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -1018,7 +1018,7 @@ protected:
 public:
     void commitStrings()
     {
-        svl::SharedStringPool& rPool = mpDoc->GetCellStringPool();
+        svl::SharedStringPool& rPool = mpDoc->GetSharedStringPool();
         sc::CellStoreType::iterator it = mrCells.begin();
         std::vector<StrEntry>::iterator itStr = maStrEntries.begin(), itStrEnd = maStrEntries.end();
         for (; itStr != itStrEnd; ++itStr)
@@ -1957,7 +1957,7 @@ class FillMatrixHandler
 
 public:
     FillMatrixHandler(ScMatrix& rMat, size_t nMatCol, size_t nTopRow, SCCOL nCol, SCTAB nTab, ScDocument* pDoc) :
-        mrMat(rMat), mnMatCol(nMatCol), mnTopRow(nTopRow), mnCol(nCol), mnTab(nTab), mpDoc(pDoc), mrPool(pDoc->GetCellStringPool()) {}
+        mrMat(rMat), mnMatCol(nMatCol), mnTopRow(nTopRow), mnCol(nCol), mnTab(nTab), mpDoc(pDoc), mrPool(pDoc->GetSharedStringPool()) {}
 
     void operator() (const sc::CellStoreType::value_type& node, size_t nOffset, size_t nDataSize)
     {
@@ -2171,7 +2171,7 @@ bool appendStrings(
     size_t nLen, sc::CellStoreType::iterator it, const sc::CellStoreType::iterator& itEnd)
 {
     size_t nLenRemain = nLen;
-    svl::SharedStringPool& rPool = pDoc->GetCellStringPool();
+    svl::SharedStringPool& rPool = pDoc->GetSharedStringPool();
 
     for (; it != itEnd; ++it)
     {
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 16ac30c..f331d35 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1454,7 +1454,7 @@ bool ScColumn::ParseString(
     else
         cFirstChar = 0; // Text
 
-    svl::SharedStringPool& rPool = pDocument->GetCellStringPool();
+    svl::SharedStringPool& rPool = pDocument->GetSharedStringPool();
 
     if ( cFirstChar == '=' )
     {
@@ -1606,7 +1606,7 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const OUString& rString,
 
 void ScColumn::SetEditText( SCROW nRow, EditTextObject* pEditText )
 {
-    pEditText->NormalizeString(pDocument->GetCellStringPool());
+    pEditText->NormalizeString(pDocument->GetSharedStringPool());
     sc::CellStoreType::iterator it = GetPositionToInsert(nRow);
     maCells.set(it, nRow, pEditText);
     maCellTextAttrs.set(nRow, sc::CellTextAttr());
@@ -1617,7 +1617,7 @@ void ScColumn::SetEditText( SCROW nRow, EditTextObject* pEditText )
 
 void ScColumn::SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, EditTextObject* pEditText )
 {
-    pEditText->NormalizeString(pDocument->GetCellStringPool());
+    pEditText->NormalizeString(pDocument->GetSharedStringPool());
     rBlockPos.miCellPos = GetPositionToInsert(rBlockPos.miCellPos, nRow);
     rBlockPos.miCellPos = maCells.set(rBlockPos.miCellPos, nRow, pEditText);
     rBlockPos.miCellTextAttrPos = maCellTextAttrs.set(
@@ -1751,7 +1751,7 @@ sal_uIntPtr ScColumn::GetCellStringID( SCROW nRow ) const
         {
             std::vector<sal_uIntPtr> aIDs;
             const EditTextObject* pObj = sc::edittext_block::at(*aPos.first->data, aPos.second);
-            pObj->GetStringIDs(pDocument->GetCellStringPool(), aIDs);
+            pObj->GetStringIDs(pDocument->GetSharedStringPool(), aIDs);
             if (aIDs.size() != 1)
                 // We don't handle multiline content for now.
                 return 0;
@@ -1780,7 +1780,7 @@ sal_uIntPtr ScColumn::GetCellStringIDIgnoreCase( SCROW nRow ) const
         {
             std::vector<sal_uIntPtr> aIDs;
             const EditTextObject* pObj = sc::edittext_block::at(*aPos.first->data, aPos.second);
-            pObj->GetStringIDsIgnoreCase(pDocument->GetCellStringPool(), aIDs);
+            pObj->GetStringIDsIgnoreCase(pDocument->GetSharedStringPool(), aIDs);
             if (aIDs.size() != 1)
                 // We don't handle multiline content for now.
                 return 0;
@@ -2111,7 +2111,7 @@ class FormulaToValueHandler
 
 public:
 
-    FormulaToValueHandler(ScDocument& rDoc) : mrStrPool(rDoc.GetCellStringPool()) {}
+    FormulaToValueHandler(ScDocument& rDoc) : mrStrPool(rDoc.GetSharedStringPool()) {}
 
     void operator() (size_t nRow, const ScFormulaCell* p)
     {
@@ -2195,7 +2195,7 @@ void ScColumn::SetRawString( SCROW nRow, const OUString& rStr, bool bBroadcast )
     if (!ValidRow(nRow))
         return;
 
-    svl::SharedString aSS = pDocument->GetCellStringPool().intern(rStr);
+    svl::SharedString aSS = pDocument->GetSharedStringPool().intern(rStr);
     if (!aSS.getData())
         return;
 
@@ -2219,7 +2219,7 @@ void ScColumn::SetRawString( SCROW nRow, const svl::SharedString& rStr, bool bBr
 void ScColumn::SetRawString(
     sc::ColumnBlockPosition& rBlockPos, SCROW nRow, const OUString& rStr, bool bBroadcast )
 {
-    svl::SharedString aSS = pDocument->GetCellStringPool().intern(rStr);
+    svl::SharedString aSS = pDocument->GetSharedStringPool().intern(rStr);
     if (!aSS.getData())
         return;
 
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 0fb6755..9a7a0ec 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -600,12 +600,12 @@ ScRefCellValue ScDocument::GetRefCellValue( const ScAddress& rPos )
     return maTabs[rPos.Tab()]->GetRefCellValue(rPos.Col(), rPos.Row());
 }
 
-svl::SharedStringPool& ScDocument::GetCellStringPool()
+svl::SharedStringPool& ScDocument::GetSharedStringPool()
 {
     return *mpCellStringPool;
 }
 
-const svl::SharedStringPool& ScDocument::GetCellStringPool() const
+const svl::SharedStringPool& ScDocument::GetSharedStringPool() const
 {
     return *mpCellStringPool;
 }
diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx
index 334b2f5..03f5842 100644
--- a/sc/source/core/data/documentimport.cxx
+++ b/sc/source/core/data/documentimport.cxx
@@ -150,7 +150,7 @@ void ScDocumentImport::setStringCell(const ScAddress& rPos, const OUString& rStr
     if (!pBlockPos)
         return;
 
-    svl::SharedString aSS = mpImpl->mrDoc.GetCellStringPool().intern(rStr);
+    svl::SharedString aSS = mpImpl->mrDoc.GetSharedStringPool().intern(rStr);
     if (!aSS.getData())
         return;
 
@@ -170,7 +170,7 @@ void ScDocumentImport::setEditCell(const ScAddress& rPos, EditTextObject* pEditT
     if (!pBlockPos)
         return;
 
-    pEditText->NormalizeString(mpImpl->mrDoc.GetCellStringPool());
+    pEditText->NormalizeString(mpImpl->mrDoc.GetSharedStringPool());
     sc::CellStoreType& rCells = pTab->aCol[rPos.Col()].maCells;
     pBlockPos->miCellPos = rCells.set(pBlockPos->miCellPos, rPos.Row(), pEditText);
 }
diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index 07a54f9..c27b25c 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -462,7 +462,7 @@ bool ScValidationData::IsDataValid(
         }
         else
         {
-            svl::SharedString aSS = mpDoc->GetCellStringPool().intern(rTest);
+            svl::SharedString aSS = mpDoc->GetSharedStringPool().intern(rTest);
             ScRefCellValue aTmpCell(&aSS);
             bRet = IsDataValid(aTmpCell, rPos);
         }
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 13fa68b..87cdc74 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -6763,7 +6763,7 @@ bool ScInterpreter::FillEntry(ScQueryEntry& rEntry)
             const OUString& sStr = GetString();
             rItem.meType = ScQueryEntry::ByString;
             rItem.maString = sStr;
-            rItem.mnStrId = pDok->GetCellStringPool().getIdentifierIgnoreCase(rItem.maString);
+            rItem.mnStrId = pDok->GetSharedStringPool().getIdentifierIgnoreCase(rItem.maString);
         }
         break;
         case svDoubleRef :
@@ -6788,7 +6788,7 @@ bool ScInterpreter::FillEntry(ScQueryEntry& rEntry)
                 GetCellString(aStr, aCell);
                 rItem.meType = ScQueryEntry::ByString;
                 rItem.maString = aStr;
-                rItem.mnStrId = pDok->GetCellStringPool().getIdentifierIgnoreCase(rItem.maString);
+                rItem.mnStrId = pDok->GetSharedStringPool().getIdentifierIgnoreCase(rItem.maString);
             }
         }
         break;
@@ -6797,7 +6797,7 @@ bool ScInterpreter::FillEntry(ScQueryEntry& rEntry)
             OUString aStr;
             const ScMatValType nType = GetDoubleOrStringFromMatrix(rItem.mfVal, aStr);
             rItem.maString = aStr;
-            rItem.mnStrId = pDok->GetCellStringPool().getIdentifierIgnoreCase(rItem.maString);
+            rItem.mnStrId = pDok->GetSharedStringPool().getIdentifierIgnoreCase(rItem.maString);
             rItem.meType = ScMatrix::IsNonValueType(nType) ?
                 ScQueryEntry::ByString : ScQueryEntry::ByValue;
         }
diff --git a/sc/source/filter/xcl97/XclImpChangeTrack.cxx b/sc/source/filter/xcl97/XclImpChangeTrack.cxx
index a60b302..a2f1dde 100644
--- a/sc/source/filter/xcl97/XclImpChangeTrack.cxx
+++ b/sc/source/filter/xcl97/XclImpChangeTrack.cxx
@@ -250,7 +250,7 @@ void XclImpChangeTrack::ReadCell(
             if( pStrm->IsValid() )
             {
                 rCell.meType = CELLTYPE_STRING;
-                rCell.mpString = new svl::SharedString(GetDoc().GetCellStringPool().intern(sString));
+                rCell.mpString = new svl::SharedString(GetDoc().GetSharedStringPool().intern(sString));
             }
         }
         break;
diff --git a/sc/source/filter/xml/XMLDDELinksContext.cxx b/sc/source/filter/xml/XMLDDELinksContext.cxx
index ba904b6..dbfe45d 100644
--- a/sc/source/filter/xml/XMLDDELinksContext.cxx
+++ b/sc/source/filter/xml/XMLDDELinksContext.cxx
@@ -166,7 +166,7 @@ void ScXMLDDELinkContext::EndElement()
         ScDDELinkCells::iterator aItr(aDDELinkTable.begin());
         ScDDELinkCells::iterator aEndItr(aDDELinkTable.end());
 
-        svl::SharedStringPool& rPool = pDoc->GetCellStringPool();
+        svl::SharedStringPool& rPool = pDoc->GetSharedStringPool();
         while (aItr != aEndItr)
         {
             if (nIndex % nColumns == 0)
diff --git a/sc/source/filter/xml/XMLTrackedChangesContext.cxx b/sc/source/filter/xml/XMLTrackedChangesContext.cxx
index 590b0e3..fd189ff 100644
--- a/sc/source/filter/xml/XMLTrackedChangesContext.cxx
+++ b/sc/source/filter/xml/XMLTrackedChangesContext.cxx
@@ -1294,7 +1294,7 @@ void ScXMLChangeCellContext::EndElement()
                 if (!sText.isEmpty() && bString)
                 {
                     mrOldCell.meType = CELLTYPE_STRING;
-                    mrOldCell.mpString = new svl::SharedString(pDoc->GetCellStringPool().intern(sText));
+                    mrOldCell.mpString = new svl::SharedString(pDoc->GetSharedStringPool().intern(sText));
                 }
                 else
                 {
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx
index 8078759..24f27a9 100644
--- a/sc/source/ui/undo/undocell.cxx
+++ b/sc/source/ui/undo/undocell.cxx
@@ -670,7 +670,7 @@ ScUndoThesaurus::ScUndoThesaurus( ScDocShell* pNewDocShell,
     else
     {
         aOldCell.meType = CELLTYPE_STRING;
-        aOldCell.mpString = new svl::SharedString(pDocShell->GetDocument()->GetCellStringPool().intern(aUndoStr));
+        aOldCell.mpString = new svl::SharedString(pDocShell->GetDocument()->GetSharedStringPool().intern(aUndoStr));
     }
     SetChangeTrack(aOldCell);
 }
commit 10579fcdbfe7873affaecffb09b13fa97a4c6b23
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Oct 8 09:14:48 2013 -0400

    Use the document's string pool rather than a separate one for the formula.
    
    Change-Id: Id13bca1ed493328fb0b8a664275af8c98e3f46c8

diff --git a/sc/inc/formulagroup.hxx b/sc/inc/formulagroup.hxx
index fc3af2a..ca240f7 100644
--- a/sc/inc/formulagroup.hxx
+++ b/sc/inc/formulagroup.hxx
@@ -33,7 +33,6 @@ struct FormulaGroupContext : boost::noncopyable
     typedef boost::ptr_vector<NumArrayType> NumArrayStoreType;
     typedef boost::ptr_vector<StrArrayType> StrArrayStoreType;
 
-    svl::SharedStringPool maStrPool;
     NumArrayStoreType maNumArrays;
     StrArrayStoreType maStrArrays;
 };
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 35c9153..0f13a26 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -2167,11 +2167,11 @@ bool appendDouble(
 }
 
 bool appendStrings(
-    sc::FormulaGroupContext& rCxt, ScDocument* pDoc,
-    sc::FormulaGroupContext::StrArrayType& rArray, size_t nLen,
-    sc::CellStoreType::iterator it, const sc::CellStoreType::iterator& itEnd )
+    ScDocument* pDoc, sc::FormulaGroupContext::StrArrayType& rArray,
+    size_t nLen, sc::CellStoreType::iterator it, const sc::CellStoreType::iterator& itEnd)
 {
     size_t nLenRemain = nLen;
+    svl::SharedStringPool& rPool = pDoc->GetCellStringPool();
 
     for (; it != itEnd; ++it)
     {
@@ -2194,7 +2194,7 @@ bool appendStrings(
                 for (; itData != itDataEnd; ++itData)
                 {
                     OUString aStr = ScEditUtil::GetString(**itData, pDoc);
-                    rArray.push_back(rCxt.maStrPool.intern(aStr).getData());
+                    rArray.push_back(rPool.intern(aStr).getData());
                 }
             }
             break;
@@ -2219,7 +2219,7 @@ bool appendStrings(
                         return false;
                     }
 
-                    rArray.push_back(rCxt.maStrPool.intern(aStr).getData());
+                    rArray.push_back(rPool.intern(aStr).getData());
                 }
             }
             break;
@@ -2380,7 +2380,7 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( sc::FormulaGroupContext&
 
             // Fill the remaining array with values from the following blocks.
             ++aPos.first;
-            if (!appendStrings(rCxt, pDocument, rArray, nLenRequested - nLen, aPos.first, maCells.end()))
+            if (!appendStrings(pDocument, rArray, nLenRequested - nLen, aPos.first, maCells.end()))
                 return formula::VectorRefArray();
 
             return formula::VectorRefArray(&rArray[0]);
commit 543dfbad46ae0e67636a92af677dd9c3258fac84
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Oct 7 18:03:47 2013 -0400

    Unused methods.
    
    Change-Id: I8e70d2c730f0d8fa43a4270fddeca431bd7a5048

diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index ab14017..3fb39ba 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -292,7 +292,6 @@ public:
     void        SetError( SCROW nRow, const sal_uInt16 nError);
 
     void        GetString( SCROW nRow, OUString& rString ) const;
-    const svl::SharedString* GetStringCell( SCROW nRow ) const;
     double* GetValueCell( SCROW nRow );
     void        GetInputString( SCROW nRow, OUString& rString ) const;
     double      GetValue( SCROW nRow ) const;
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index baae1db..22d6eed 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -844,17 +844,6 @@ public:
     SC_DLLPUBLIC OUString GetString( const ScAddress& rPos ) const;
 
     /**
-     * Return a pointer to the string object stored in string cell.
-     *
-     * @param rPos cell position.
-     *
-     * @return pointer to the string object stored in string cell, or NULL if
-     *         the cell at specified position is not a string cell. Note that
-     *         it returns NULL even for a edit cell.
-     */
-    const svl::SharedString* GetStringCell( const ScAddress& rPos ) const;
-
-    /**
      * Return a pointer to the double value stored in value cell.
      *
      * @param rPos cell position
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 923dafd..6e095e2 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -352,7 +352,6 @@ public:
     void SetRawString( SCCOL nCol, SCROW nRow, const OUString& rStr );
     void SetRawString( SCCOL nCol, SCROW nRow, const svl::SharedString& rStr );
     void        GetString( SCCOL nCol, SCROW nRow, OUString& rString ) const;
-    const svl::SharedString* GetStringCell( SCCOL nCol, SCROW nRow ) const;
     double* GetValueCell( SCCOL nCol, SCROW nRow );
     void        GetInputString( SCCOL nCol, SCROW nRow, OUString& rString ) const;
     double      GetValue( const ScAddress& rPos ) const
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index c854456..16ac30c 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2284,19 +2284,6 @@ void ScColumn::GetString( SCROW nRow, OUString& rString ) const
     ScCellFormat::GetString(aCell, nFormat, rString, &pColor, *(pDocument->GetFormatTable()), pDocument);
 }
 
-const svl::SharedString* ScColumn::GetStringCell( SCROW nRow ) const
-{
-    std::pair<sc::CellStoreType::const_iterator,size_t> aPos = maCells.position(nRow);
-    sc::CellStoreType::const_iterator it = aPos.first;
-    if (it == maCells.end())
-        return NULL;
-
-    if (it->type != sc::element_type_string)
-        return NULL;
-
-    return &sc::string_block::at(*it->data, aPos.second);
-}
-
 double* ScColumn::GetValueCell( SCROW nRow )
 {
     std::pair<sc::CellStoreType::iterator,size_t> aPos = maCells.position(nRow);
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index e3184f0..b5f6b8e 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3205,14 +3205,6 @@ OUString ScDocument::GetString( const ScAddress& rPos ) const
     return aStr;
 }
 
-const svl::SharedString* ScDocument::GetStringCell( const ScAddress& rPos ) const
-{
-    if (!TableExists(rPos.Tab()))
-        return NULL;
-
-    return maTabs[rPos.Tab()]->GetStringCell(rPos.Col(), rPos.Row());
-}
-
 double* ScDocument::GetValueCell( const ScAddress& rPos )
 {
     if (!TableExists(rPos.Tab()))
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index b66be8c..a7504cc 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -1547,14 +1547,6 @@ void ScTable::GetString( SCCOL nCol, SCROW nRow, OUString& rString ) const
         rString = OUString();
 }
 
-const svl::SharedString* ScTable::GetStringCell( SCCOL nCol, SCROW nRow ) const
-{
-    if (!ValidColRow(nCol,nRow))
-        return NULL;
-
-    return aCol[nCol].GetStringCell(nRow);
-}
-
 double* ScTable::GetValueCell( SCCOL nCol, SCROW nRow )
 {
     if (!ValidColRow(nCol,nRow))
commit 658fc68d574bd49b8b233ad5ed886758e290b3aa
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Oct 7 17:27:02 2013 -0400

    Store svl::SharedString in document cell storage instead of OUString.
    
    With this, both ScColumn and ScMatrix store svl::SharedString as their
    string values, instead of OUString.
    
    Change-Id: I3faece94d98f774881fd72b3ed5f6143504cd350

diff --git a/include/svl/sharedstring.hxx b/include/svl/sharedstring.hxx
index 64c024c..b2879a8 100644
--- a/include/svl/sharedstring.hxx
+++ b/include/svl/sharedstring.hxx
@@ -22,6 +22,7 @@ class SVL_DLLPUBLIC SharedString
 public:
     SharedString();
     SharedString( rtl_uString* pData, rtl_uString* pDataIgnoreCase );
+    SharedString( const OUString& rStr );
     SharedString( const SharedString& r );
     ~SharedString();
 
@@ -29,6 +30,8 @@ public:
 
     bool operator== ( const SharedString& r ) const;
 
+    OUString getString() const;
+
     rtl_uString* getData();
     const rtl_uString* getData() const;
 
diff --git a/sc/inc/cellform.hxx b/sc/inc/cellform.hxx
index 7779297..1f6b13a 100644
--- a/sc/inc/cellform.hxx
+++ b/sc/inc/cellform.hxx
@@ -22,6 +22,7 @@
 
 #include <tools/solar.h>
 #include "scdllapi.h"
+#include "rtl/ustring.hxx"
 
 class SvNumberFormatter;
 class Color;
diff --git a/sc/inc/cellvalue.hxx b/sc/inc/cellvalue.hxx
index fd112a6..c2606b5 100644
--- a/sc/inc/cellvalue.hxx
+++ b/sc/inc/cellvalue.hxx
@@ -18,6 +18,12 @@ class EditTextObject;
 class ScColumn;
 struct ScRefCellValue;
 
+namespace svl {
+
+class SharedString;
+
+}
+
 /**
  * Store arbitrary cell value of any kind.  It only stores cell value and
  * nothing else.  It creates a copy of the original cell value, and manages
@@ -28,7 +34,7 @@ struct SC_DLLPUBLIC ScCellValue
     CellType meType;
     union {
         double mfValue;
-        OUString* mpString;
+        svl::SharedString* mpString;
         EditTextObject* mpEditText;
         ScFormulaCell* mpFormula;
     };
@@ -36,7 +42,7 @@ struct SC_DLLPUBLIC ScCellValue
     ScCellValue();
     ScCellValue( const ScRefCellValue& rCell );
     ScCellValue( double fValue );
-    ScCellValue( const OUString& rString );
+    ScCellValue( const svl::SharedString& rString );
     ScCellValue( const EditTextObject& rEditText );
     ScCellValue( const ScFormulaCell& rFormula );
     ScCellValue( const ScCellValue& r );
@@ -45,7 +51,7 @@ struct SC_DLLPUBLIC ScCellValue
     void clear();
 
     void set( double fValue );
-    void set( const OUString& rStr );
+    void set( const svl::SharedString& rStr );
     void set( const EditTextObject& rEditText );
     void set( const ScFormulaCell& rFormula );
     void set( ScFormulaCell* pFormula );
@@ -98,14 +104,14 @@ struct SC_DLLPUBLIC ScRefCellValue
     CellType meType;
     union {
         double mfValue;
-        const OUString* mpString;
+        const svl::SharedString* mpString;
         const EditTextObject* mpEditText;
         ScFormulaCell* mpFormula;
     };
 
     ScRefCellValue();
     ScRefCellValue( double fValue );
-    ScRefCellValue( const OUString* pString );
+    ScRefCellValue( const svl::SharedString* pString );
     ScRefCellValue( const EditTextObject* pEditText );
     ScRefCellValue( ScFormulaCell* pFormula );
     ScRefCellValue( const ScRefCellValue& r );
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index e4fe323..ab14017 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -284,13 +284,15 @@ public:
     sal_uIntPtr GetCellStringIDIgnoreCase( SCROW nRow ) const;
 
     void SetRawString( SCROW nRow, const OUString& rStr, bool bBroadcast = true );
+    void SetRawString( SCROW nRow, const svl::SharedString& rStr, bool bBroadcast = true );
     void SetRawString( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, const OUString& rStr, bool bBroadcast = true );
+    void SetRawString( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, const svl::SharedString& rStr, bool bBroadcast = true );
     void SetValue( SCROW nRow, double fVal );
     void SetValue( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, double fVal, bool bBroadcast = true );
     void        SetError( SCROW nRow, const sal_uInt16 nError);
 
     void        GetString( SCROW nRow, OUString& rString ) const;
-    const OUString* GetStringCell( SCROW nRow ) const;
+    const svl::SharedString* GetStringCell( SCROW nRow ) const;
     double* GetValueCell( SCROW nRow );
     void        GetInputString( SCROW nRow, OUString& rString ) const;
     double      GetValue( SCROW nRow ) const;
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index ad64716..baae1db 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -50,7 +50,12 @@
 
 namespace editeng { class SvxBorderLine; }
 namespace formula { struct VectorRefArray; }
-namespace svl { class SharedStringPool; }
+namespace svl {
+
+class SharedString;
+class SharedStringPool;
+
+}
 
 namespace sc {
     struct FormulaGroupContext;
@@ -847,7 +852,7 @@ public:
      *         the cell at specified position is not a string cell. Note that
      *         it returns NULL even for a edit cell.
      */
-    const OUString* GetStringCell( const ScAddress& rPos ) const;
+    const svl::SharedString* GetStringCell( const ScAddress& rPos ) const;
 
     /**
      * Return a pointer to the double value stored in value cell.
@@ -859,7 +864,7 @@ public:
      */
     double* GetValueCell( const ScAddress& rPos );
 
-    svl::SharedStringPool& GetCellStringPool();
+    SC_DLLPUBLIC svl::SharedStringPool& GetCellStringPool();
     const svl::SharedStringPool& GetCellStringPool() const;
     sal_uIntPtr GetCellStringID( const ScAddress& rPos ) const;
     sal_uIntPtr GetCellStringIDIgnoreCase( const ScAddress& rPos ) const;
diff --git a/sc/inc/mtvelements.hxx b/sc/inc/mtvelements.hxx
index f0e5fff..6279efa 100644
--- a/sc/inc/mtvelements.hxx
+++ b/sc/inc/mtvelements.hxx
@@ -13,6 +13,7 @@
 #include "address.hxx"
 #include "formulacell.hxx"
 #include "svl/broadcast.hxx"
+#include "svl/sharedstring.hxx"
 #include "editeng/editobj.hxx"
 #include "calcmacros.hxx"
 
@@ -62,7 +63,7 @@ const mdds::mtv::element_t element_type_empty = mdds::mtv::element_type_empty;
 
 typedef mdds::mtv::noncopyable_managed_element_block<element_type_broadcaster, SvtBroadcaster> broadcaster_block;
 typedef mdds::mtv::default_element_block<element_type_celltextattr, CellTextAttr> celltextattr_block;
-typedef mdds::mtv::default_element_block<element_type_string, rtl::OUString> string_block;
+typedef mdds::mtv::default_element_block<element_type_string, svl::SharedString> string_block;
 typedef mdds::mtv::noncopyable_managed_element_block<element_type_edittext, EditTextObject> edittext_block;
 typedef mdds::mtv::noncopyable_managed_element_block<element_type_formula, ScFormulaCell> formula_block;
 
@@ -79,9 +80,9 @@ MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(SvtBroadcaster, sc::element_type_broadcast
 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(ScFormulaCell, sc::element_type_formula, NULL, sc::formula_block)
 MDDS_MTV_DEFINE_ELEMENT_CALLBACKS_PTR(EditTextObject, sc::element_type_edittext, NULL, sc::edittext_block)
 
-namespace rtl {
+namespace svl {
 
-MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(OUString, sc::element_type_string, OUString(), sc::string_block)
+MDDS_MTV_DEFINE_ELEMENT_CALLBACKS(SharedString, sc::element_type_string, SharedString(), sc::string_block)
 
 }
 
diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index 2ef596b..6111217 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -34,6 +34,8 @@ class ScInterpreter;
 class SvNumberFormatter;
 class ScMatrixImpl;
 
+namespace svl { class SharedString; }
+
 /**
  * Try NOT to use this struct.  This struct should go away in a hopefully
  * not so distant futture.
@@ -242,9 +244,9 @@ public:
     void PutDouble( double fVal, SCSIZE nIndex);
     void PutDouble(const double* pArray, size_t nLen, SCSIZE nC, SCSIZE nR);
 
-    void PutString( const OUString& rStr, SCSIZE nC, SCSIZE nR);
-    void PutString( const OUString& rStr, SCSIZE nIndex);
-    void PutString(const OUString* pArray, size_t nLen, SCSIZE nC, SCSIZE nR);
+    void PutString( const svl::SharedString& rStr, SCSIZE nC, SCSIZE nR);
+    void PutString( const svl::SharedString& rStr, SCSIZE nIndex);
+    void PutString( const svl::SharedString* pArray, size_t nLen, SCSIZE nC, SCSIZE nR);
 
     void PutEmpty( SCSIZE nC, SCSIZE nR);
 
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 7d5fa1e..923dafd 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -350,8 +350,9 @@ public:
     void        SetError( SCCOL nCol, SCROW nRow, sal_uInt16 nError);
 
     void SetRawString( SCCOL nCol, SCROW nRow, const OUString& rStr );
+    void SetRawString( SCCOL nCol, SCROW nRow, const svl::SharedString& rStr );
     void        GetString( SCCOL nCol, SCROW nRow, OUString& rString ) const;
-    const OUString* GetStringCell( SCCOL nCol, SCROW nRow ) const;
+    const svl::SharedString* GetStringCell( SCCOL nCol, SCROW nRow ) const;
     double* GetValueCell( SCCOL nCol, SCROW nRow );
     void        GetInputString( SCCOL nCol, SCROW nRow, OUString& rString ) const;
     double      GetValue( const ScAddress& rPos ) const
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 1a2bf71..8017845 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1475,6 +1475,7 @@ struct PartiallyFilledEmptyMatrix
 
 void Test::testMatrix()
 {
+    svl::SharedStringPool& rPool = m_pDoc->GetCellStringPool();
     ScMatrixRef pMat, pMat2;
 
     // First, test the zero matrix type.
@@ -1524,7 +1525,7 @@ void Test::testMatrix()
     pMat->PutBoolean(true, 1, 1);
     pMat->PutDouble(-12.5, 4, 5);
     OUString aStr("Test");
-    pMat->PutString(aStr, 8, 2);
+    pMat->PutString(rPool.intern(aStr), 8, 2);
     pMat->PutEmptyPath(8, 11);
     checkMatrixElements<PartiallyFilledEmptyMatrix>(*pMat);
 
@@ -1546,7 +1547,7 @@ void Test::testMatrix()
     pMat->PutDouble(-25, 1, 1);
     CPPUNIT_ASSERT_EQUAL(-25.0, pMat->GetMinValue(false));
     CPPUNIT_ASSERT_EQUAL(-8.0, pMat->GetMaxValue(false));
-    pMat->PutString("Test", 0, 0);
+    pMat->PutString(rPool.intern("Test"), 0, 0);
     CPPUNIT_ASSERT_EQUAL(0.0, pMat->GetMaxValue(true)); // text as zero.
     CPPUNIT_ASSERT_EQUAL(-8.0, pMat->GetMaxValue(false)); // ignore text.
     pMat->PutBoolean(true, 0, 0);
@@ -1562,7 +1563,7 @@ void Test::testMatrix()
     pMat = new ScMatrix(3, 3);
     pMat->PutDouble(2.5, 0, 0);
     pMat->PutDouble(1.2, 0, 1);
-    pMat->PutString("A", 1, 1);
+    pMat->PutString(rPool.intern("A"), 1, 1);
     pMat->PutDouble(2.3, 2, 1);
     pMat->PutDouble(-20, 2, 2);
 
@@ -1585,7 +1586,7 @@ void Test::testMatrix()
     }
 
     pMat2 = new ScMatrix(3, 3, 10.0);
-    pMat2->PutString("B", 1, 0);
+    pMat2->PutString(rPool.intern("B"), 1, 0);
     pMat2->MergeDoubleArray(aDoubles, ScMatrix::Mul);
 
     {
diff --git a/sc/qa/unit/ucalc_sharedformula.cxx b/sc/qa/unit/ucalc_sharedformula.cxx
index 00378dd..b766715 100644
--- a/sc/qa/unit/ucalc_sharedformula.cxx
+++ b/sc/qa/unit/ucalc_sharedformula.cxx
@@ -15,6 +15,7 @@
 #include "clipparam.hxx"
 #include "undoblk.hxx"
 #include "scopetools.hxx"
+#include "svl/sharedstring.hxx"
 
 #include "formula/grammar.hxx"
 
@@ -156,10 +157,10 @@ void Test::testSharedFormulas()
 
     // Set string value to B16 to make B17:B18 shared.
     aPos.SetRow(15);
-    ScCellValue aCell("Test");
+    ScCellValue aCell(svl::SharedString("Test"));
     CPPUNIT_ASSERT_MESSAGE("This should be a string value.", aCell.meType == CELLTYPE_STRING);
     aCell.commit(*m_pDoc, aPos);
-    CPPUNIT_ASSERT_EQUAL(*aCell.mpString, m_pDoc->GetString(aPos));
+    CPPUNIT_ASSERT_EQUAL(aCell.mpString->getString(), m_pDoc->GetString(aPos));
     aPos.SetRow(16);
     pFC = m_pDoc->GetFormulaCell(aPos);
     // B17:B18 should be shared.
diff --git a/sc/source/core/data/cellvalue.cxx b/sc/source/core/data/cellvalue.cxx
index 7a7f941..af12e19 100644
--- a/sc/source/core/data/cellvalue.cxx
+++ b/sc/source/core/data/cellvalue.cxx
@@ -17,6 +17,7 @@
 #include "editutil.hxx"
 #include "tokenarray.hxx"
 #include "formula/token.hxx"
+#include "svl/sharedstring.hxx"
 
 namespace {
 
@@ -36,7 +37,7 @@ template<typename _T>
 OUString getString( const _T& rVal )
 {
     if (rVal.meType == CELLTYPE_STRING)
-        return *rVal.mpString;
+        return rVal.mpString->getString();
 
     if (rVal.meType == CELLTYPE_EDIT)
     {
@@ -163,7 +164,7 @@ ScCellValue::ScCellValue( const ScRefCellValue& rCell ) : meType(rCell.meType),
     switch (rCell.meType)
     {
         case CELLTYPE_STRING:
-            mpString = new OUString(rCell.mpString->pData);
+            mpString = new svl::SharedString(*rCell.mpString);
         break;
         case CELLTYPE_EDIT:
             mpEditText = rCell.mpEditText->Clone();
@@ -177,7 +178,7 @@ ScCellValue::ScCellValue( const ScRefCellValue& rCell ) : meType(rCell.meType),
 }
 
 ScCellValue::ScCellValue( double fValue ) : meType(CELLTYPE_VALUE), mfValue(fValue) {}
-ScCellValue::ScCellValue( const OUString& rString ) : meType(CELLTYPE_STRING), mpString(new OUString(rString)) {}
+ScCellValue::ScCellValue( const svl::SharedString& rString ) : meType(CELLTYPE_STRING), mpString(new svl::SharedString(rString)) {}
 ScCellValue::ScCellValue( const EditTextObject& rEditText ) : meType(CELLTYPE_EDIT), mpEditText(rEditText.Clone()) {}
 ScCellValue::ScCellValue( const ScFormulaCell& rFormula ) : meType(CELLTYPE_FORMULA), mpFormula(rFormula.Clone()) {}
 
@@ -186,7 +187,7 @@ ScCellValue::ScCellValue( const ScCellValue& r ) : meType(r.meType), mfValue(r.m
     switch (r.meType)
     {
         case CELLTYPE_STRING:
-            mpString = new OUString(r.mpString->pData);
+            mpString = new svl::SharedString(*r.mpString);
         break;
         case CELLTYPE_EDIT:
             mpEditText = r.mpEditText->Clone();
@@ -233,11 +234,11 @@ void ScCellValue::set( double fValue )
     mfValue = fValue;
 }
 
-void ScCellValue::set( const OUString& rStr )
+void ScCellValue::set( const svl::SharedString& rStr )
 {
     clear();
     meType = CELLTYPE_STRING;
-    mpString = new OUString(rStr);
+    mpString = new svl::SharedString(rStr);
 }
 
 void ScCellValue::set( const EditTextObject& rEditText )
@@ -272,7 +273,7 @@ void ScCellValue::assign( const ScDocument& rDoc, const ScAddress& rPos )
     switch (meType)
     {
         case CELLTYPE_STRING:
-            mpString = new OUString(aRefVal.mpString->pData);
+            mpString = new svl::SharedString(*aRefVal.mpString);
         break;
         case CELLTYPE_EDIT:
             if (aRefVal.mpEditText)
@@ -297,7 +298,7 @@ void ScCellValue::assign( const ScCellValue& rOther, ScDocument& rDestDoc, int n
     switch (meType)
     {
         case CELLTYPE_STRING:
-            mpString = new OUString(rOther.mpString->pData);
+            mpString = new svl::SharedString(*rOther.mpString);
         break;
         case CELLTYPE_EDIT:
         {
@@ -342,7 +343,7 @@ void ScCellValue::commit( ScDocument& rDoc, const ScAddress& rPos ) const
         {
             ScSetStringParam aParam;
             aParam.setTextInput();
-            rDoc.SetString(rPos, *mpString, &aParam);
+            rDoc.SetString(rPos, mpString->getString(), &aParam);
         }
         break;
         case CELLTYPE_EDIT:
@@ -373,7 +374,7 @@ void ScCellValue::release( ScDocument& rDoc, const ScAddress& rPos )
             // Currently, string cannot be placed without copying.
             ScSetStringParam aParam;
             aParam.setTextInput();
-            rDoc.SetString(rPos, *mpString, &aParam);
+            rDoc.SetString(rPos, mpString->getString(), &aParam);
             delete mpString;
         }
         break;
@@ -471,7 +472,7 @@ void ScCellValue::swap( ScCellValue& r )
 
 ScRefCellValue::ScRefCellValue() : meType(CELLTYPE_NONE), mfValue(0.0) {}
 ScRefCellValue::ScRefCellValue( double fValue ) : meType(CELLTYPE_VALUE), mfValue(fValue) {}
-ScRefCellValue::ScRefCellValue( const OUString* pString ) : meType(CELLTYPE_STRING), mpString(pString) {}
+ScRefCellValue::ScRefCellValue( const svl::SharedString* pString ) : meType(CELLTYPE_STRING), mpString(pString) {}
 ScRefCellValue::ScRefCellValue( const EditTextObject* pEditText ) : meType(CELLTYPE_EDIT), mpEditText(pEditText) {}
 ScRefCellValue::ScRefCellValue( ScFormulaCell* pFormula ) : meType(CELLTYPE_FORMULA), mpFormula(pFormula) {}
 
@@ -504,7 +505,7 @@ void ScRefCellValue::commit( ScDocument& rDoc, const ScAddress& rPos ) const
         {
             ScSetStringParam aParam;
             aParam.setTextInput();
-            rDoc.SetString(rPos, *mpString, &aParam);
+            rDoc.SetString(rPos, mpString->getString(), &aParam);
         }
         break;
         case CELLTYPE_EDIT:
@@ -557,7 +558,7 @@ OUString ScRefCellValue::getString( const ScDocument* pDoc )
         case CELLTYPE_VALUE:
             return OUString::number(mfValue);
         case CELLTYPE_STRING:
-            return *mpString;
+            return mpString->getString();
         case CELLTYPE_EDIT:
             if (mpEditText)
                 return ScEditUtil::GetString(*mpEditText, pDoc);
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index d8c3e60..4502fe0 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -44,6 +44,7 @@
 
 #include <svl/poolcach.hxx>
 #include <svl/zforlist.hxx>
+#include "svl/sharedstringpool.hxx"
 #include <editeng/scripttypeitem.hxx>
 #include "editeng/fieldupdater.hxx"
 
@@ -950,7 +951,7 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2)
             break;
             case CELLTYPE_STRING:
             {
-                OUString aStr = *aCell1.mpString; // make a copy.
+                svl::SharedString aStr = *aCell1.mpString; // make a copy.
                 it1 = maCells.set_empty(it1, nRow1, nRow1); // original string is gone.
                 maCells.set(it1, nRow2, aStr);
             }
@@ -1018,7 +1019,7 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2)
         break;
         case CELLTYPE_STRING:
         {
-            OUString aStr = *aCell1.mpString; // make a copy.
+            svl::SharedString aStr = *aCell1.mpString; // make a copy.
             switch (aCell2.meType)
             {
                 case CELLTYPE_VALUE:
@@ -1471,12 +1472,13 @@ void ScColumn::CopyStaticToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDestCol
                 std::advance(itDataEnd, nDataSize);
 
                 // Convert to simple strings.
-                std::vector<OUString> aConverted;
+                std::vector<svl::SharedString> aConverted;
                 aConverted.reserve(nDataSize);
                 for (; itData != itDataEnd; ++itData)
                 {
                     const EditTextObject& rObj = **itData;
-                    aConverted.push_back(ScEditUtil::GetString(rObj, pDocument));
+                    svl::SharedString aSS = pDocument->GetCellStringPool().intern(ScEditUtil::GetString(rObj, pDocument));
+                    aConverted.push_back(aSS);
                 }
                 aDestPos.miCellPos = rDestCol.maCells.set(aDestPos.miCellPos, nCurRow, aConverted.begin(), aConverted.end());
             }
@@ -1504,7 +1506,11 @@ void ScColumn::CopyStaticToDocument(SCROW nRow1, SCROW nRow2, ScColumn& rDestCol
                     if (rFC.IsValue())
                         aDestPos.miCellPos = rDestCol.maCells.set(aDestPos.miCellPos, nRow, rFC.GetValue());
                     else
-                        aDestPos.miCellPos = rDestCol.maCells.set(aDestPos.miCellPos, nRow, rFC.GetString());
+                    {
+                        svl::SharedString aSS = pDocument->GetCellStringPool().intern(rFC.GetString());
+                        if (aSS.getData())
+                            aDestPos.miCellPos = rDestCol.maCells.set(aDestPos.miCellPos, nRow, aSS);
+                    }
                 }
             }
             break;
@@ -1794,8 +1800,12 @@ class CopyByCloneHandler
             }
             else
             {
-                maDestPos.miCellPos =
-                    mrDestCol.GetCellStore().set(maDestPos.miCellPos, nRow, aStr);
+                svl::SharedString aSS = mrDestCol.GetDoc().GetCellStringPool().intern(aStr);
+                if (aSS.getData())
+                {
+                    maDestPos.miCellPos =
+                        mrDestCol.GetCellStore().set(maDestPos.miCellPos, nRow, aSS);
+                }
             }
 
             setDefaultAttrToDest(nRow);
@@ -1855,8 +1865,8 @@ public:
 
                 for (; it != itEnd; ++it, ++nRow)
                 {
-                    const OUString& rStr = *it;
-                    if (rStr.isEmpty())
+                    const svl::SharedString& rStr = *it;
+                    if (rStr.getString().isEmpty())
                     {
                         // String cell with empty value is used to special-case cell value removal.
                         maDestPos.miCellPos = mrDestCol.GetCellStore().set_empty(
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 2b7d522..35c9153 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -576,10 +576,14 @@ public:
         checkLength(aCell);
     }
 
-    void operator() (size_t /*nRow*/, const OUString& rStr)
+    void operator() (size_t /*nRow*/, const svl::SharedString& rSS)
     {
-        ScRefCellValue aCell(&rStr);
-        checkLength(aCell);
+        OUString aStr = rSS.getString();
+        if (aStr.getLength() > mnMaxLen)
+        {
+            mnMaxLen = aStr.getLength();
+            maMaxLenStr = aStr;
+        }
     }
 
     void operator() (size_t /*nRow*/, const EditTextObject* p)
@@ -1007,26 +1011,27 @@ protected:
     };
 
     std::vector<StrEntry> maStrEntries;
+    ScDocument* mpDoc;
 
-    StrEntries(sc::CellStoreType& rCells) : mrCells(rCells) {}
+    StrEntries(sc::CellStoreType& rCells, ScDocument* pDoc) : mrCells(rCells), mpDoc(pDoc) {}
 
 public:
     void commitStrings()
     {
+        svl::SharedStringPool& rPool = mpDoc->GetCellStringPool();
         sc::CellStoreType::iterator it = mrCells.begin();
         std::vector<StrEntry>::iterator itStr = maStrEntries.begin(), itStrEnd = maStrEntries.end();
         for (; itStr != itStrEnd; ++itStr)
-            it = mrCells.set(it, itStr->mnRow, itStr->maStr);
+            it = mrCells.set(it, itStr->mnRow, rPool.intern(itStr->maStr));
     }
 };
 
 class RemoveEditAttribsHandler : public StrEntries
 {
-    ScDocument* mpDoc;
     boost::scoped_ptr<ScFieldEditEngine> mpEngine;
 
 public:
-    RemoveEditAttribsHandler(sc::CellStoreType& rCells, ScDocument* pDoc) : StrEntries(rCells), mpDoc(pDoc) {}
+    RemoveEditAttribsHandler(sc::CellStoreType& rCells, ScDocument* pDoc) : StrEntries(rCells, pDoc) {}
 
     void operator() (size_t nRow, EditTextObject*& pObj)
     {
@@ -1838,8 +1843,8 @@ formula::FormulaTokenRef ScColumn::ResolveStaticReference( SCROW nRow )
         }
         case sc::element_type_string:
         {
-            OUString aStr = sc::string_block::at(*it->data, aPos.second);
-            return formula::FormulaTokenRef(new formula::FormulaStringToken(aStr));
+            const svl::SharedString& rSS = sc::string_block::at(*it->data, aPos.second);
+            return formula::FormulaTokenRef(new formula::FormulaStringToken(rSS.getString()));
         }
         case sc::element_type_edittext:
         {
@@ -1881,9 +1886,9 @@ public:
             mrMat.PutString(rCell.GetString(), mnMatCol, nRow - mnTopRow);
     }
 
-    void operator() (size_t nRow, const OUString& rStr)
+    void operator() (size_t nRow, const svl::SharedString& rSS)
     {
-        mrMat.PutString(rStr, mnMatCol, nRow - mnTopRow);
+        mrMat.PutString(rSS.getString(), mnMatCol, nRow - mnTopRow);
     }
 
     void operator() (size_t nRow, const EditTextObject* pStr)
@@ -1911,7 +1916,7 @@ struct CellBucket
     SCSIZE mnNumValStart;
     SCSIZE mnStrValStart;
     std::vector<double> maNumVals;
-    std::vector<OUString> maStrVals;
+    std::vector<svl::SharedString> maStrVals;
 
     CellBucket() : mnNumValStart(0), mnStrValStart(0) {}
 
@@ -1925,7 +1930,7 @@ struct CellBucket
         }
         else if (!maStrVals.empty())
         {
-            const OUString* p = &maStrVals[0];
+            const svl::SharedString* p = &maStrVals[0];
             rMat.PutString(p, maStrVals.size(), nCol, mnStrValStart);
             reset();
         }
@@ -1947,11 +1952,12 @@ class FillMatrixHandler
 
     SCCOL mnCol;
     SCTAB mnTab;
-    const ScDocument* mpDoc;
+    ScDocument* mpDoc;
+    svl::SharedStringPool& mrPool;
 
 public:
-    FillMatrixHandler(ScMatrix& rMat, size_t nMatCol, size_t nTopRow, SCCOL nCol, SCTAB nTab, const ScDocument* pDoc) :
-        mrMat(rMat), mnMatCol(nMatCol), mnTopRow(nTopRow), mnCol(nCol), mnTab(nTab), mpDoc(pDoc) {}
+    FillMatrixHandler(ScMatrix& rMat, size_t nMatCol, size_t nTopRow, SCCOL nCol, SCTAB nTab, ScDocument* pDoc) :
+        mrMat(rMat), mnMatCol(nMatCol), mnTopRow(nTopRow), mnCol(nCol), mnTab(nTab), mpDoc(pDoc), mrPool(pDoc->GetCellStringPool()) {}
 
     void operator() (const sc::CellStoreType::value_type& node, size_t nOffset, size_t nDataSize)
     {
@@ -1967,22 +1973,25 @@ public:
             break;
             case sc::element_type_string:
             {
-                const OUString* p = &sc::string_block::at(*node.data, nOffset);
+                const svl::SharedString* p = &sc::string_block::at(*node.data, nOffset);
                 mrMat.PutString(p, nDataSize, mnMatCol, nMatRow);
             }
             break;
             case sc::element_type_edittext:
             {
-                std::vector<OUString> aStrs;
-                aStrs.reserve(nDataSize);
+                std::vector<svl::SharedString> aSSs;
+                aSSs.reserve(nDataSize);
                 sc::edittext_block::const_iterator it = sc::edittext_block::begin(*node.data);
                 std::advance(it, nOffset);
                 sc::edittext_block::const_iterator itEnd = it;
                 std::advance(itEnd, nDataSize);
                 for (; it != itEnd; ++it)
-                    aStrs.push_back(ScEditUtil::GetString(**it, mpDoc));
+                {
+                    OUString aStr = ScEditUtil::GetString(**it, mpDoc);
+                    aSSs.push_back(mrPool.intern(aStr));
+                }
 
-                const OUString* p = &aStrs[0];
+                const svl::SharedString* p = &aSSs[0];
                 mrMat.PutString(p, nDataSize, mnMatCol, nMatRow);
             }
             break;
@@ -2029,7 +2038,7 @@ public:
                         continue;
                     }
 
-                    OUString aStr = rCell.GetString();
+                    svl::SharedString aStr = mrPool.intern(rCell.GetString());
                     if (!aBucket.maStrVals.empty() && nThisRow == nPrevRow + 1)
                     {
                         // Secondary strings.
@@ -2174,7 +2183,7 @@ bool appendStrings(
                 getBlockIterators<sc::string_block>(it, nLenRemain, itData, itDataEnd);
 
                 for (; itData != itDataEnd; ++itData)
-                    rArray.push_back(rCxt.maStrPool.intern(*itData).getData());
+                    rArray.push_back(itData->getData());
             }
             break;
             case sc::element_type_edittext:
@@ -2247,10 +2256,10 @@ void copyFirstBlock( sc::FormulaGroupContext& rCxt, size_t nLen, const sc::CellS
     sc::FormulaGroupContext::StrArrayType& rArray = rCxt.maStrArrays.back();
     rArray.reserve(nLen);
 
-    const OUString* p = &sc::string_block::at(*rPos.first->data, rPos.second);
-    const OUString* pEnd = p + nLen;
+    svl::SharedString* p = &sc::string_block::at(*rPos.first->data, rPos.second);
+    svl::SharedString* pEnd = p + nLen;
     for (; p != pEnd; ++p)
-        rArray.push_back(rCxt.maStrPool.intern(*p).getData());
+        rArray.push_back(p->getData());
 }
 
 }
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index f9f21d52..c854456 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1087,7 +1087,7 @@ public:
         }
     }
 
-    void operator() (size_t nRow, const OUString& rStr)
+    void operator() (size_t nRow, const svl::SharedString& rStr)
     {
         miNewCellsPos = maNewCells.set(miNewCellsPos, nRow-mnRowOffset, rStr);
     }
@@ -1200,7 +1200,7 @@ public:
                 break;
                 case sc::element_type_string:
                 {
-                    OUString aVal = sc::string_block::at(*aPos.first->data, aPos.second);
+                    const svl::SharedString& aVal = sc::string_block::at(*aPos.first->data, aPos.second);
                     miNewCellsPos = maNewCells.set(
                             miNewCellsPos, nDestRow-mnRowOffset, aVal);
                 }
@@ -1454,10 +1454,14 @@ bool ScColumn::ParseString(
     else
         cFirstChar = 0; // Text
 
+    svl::SharedStringPool& rPool = pDocument->GetCellStringPool();
+
     if ( cFirstChar == '=' )
     {
         if ( rString.getLength() == 1 ) // = Text
-            rCell.set(rString);
+        {
+            rCell.set(rPool.intern(rString));
+        }
         else // = Formula
             rCell.set(
                 new ScFormulaCell(
@@ -1477,11 +1481,11 @@ bool ScColumn::ParseString(
             bNumeric = aParam.mpNumFormatter->IsNumberFormat(aTest, nIndex, fTest);
             if (bNumeric)
                 // This is a number. Strip out the first char.
-                rCell.set(aTest);
+                rCell.set(rPool.intern(aTest));
         }
         if (!bNumeric)
             // This is normal text. Take it as-is.
-            rCell.set(rString);
+            rCell.set(rPool.intern(rString));
     }
     else
     {
@@ -1573,7 +1577,7 @@ bool ScColumn::ParseString(
                 ApplyPattern(nRow, aNewAttrs);
             }
 
-            rCell.set(rString);
+            rCell.set(rPool.intern(rString));
         }
     }
 
@@ -1739,8 +1743,8 @@ sal_uIntPtr ScColumn::GetCellStringID( SCROW nRow ) const
     {
         case sc::element_type_string:
         {
-            const OUString& rStr = sc::string_block::at(*aPos.first->data, aPos.second);
-            return pDocument->GetCellStringPool().getIdentifier(rStr);
+            const svl::SharedString& rStr = sc::string_block::at(*aPos.first->data, aPos.second);
+            return reinterpret_cast<sal_uIntPtr>(rStr.getData());
         }
         break;
         case sc::element_type_edittext:
@@ -1768,8 +1772,8 @@ sal_uIntPtr ScColumn::GetCellStringIDIgnoreCase( SCROW nRow ) const
     {
         case sc::element_type_string:
         {
-            const OUString& rStr = sc::string_block::at(*aPos.first->data, aPos.second);
-            return pDocument->GetCellStringPool().getIdentifierIgnoreCase(rStr);
+            const svl::SharedString& rStr = sc::string_block::at(*aPos.first->data, aPos.second);
+            return reinterpret_cast<sal_uIntPtr>(rStr.getDataIgnoreCase());
         }
         break;
         case sc::element_type_edittext:
@@ -1865,7 +1869,7 @@ public:
         processCell(nRow, aCell);
     }
 
-    void operator() (size_t nRow, const OUString& rStr)
+    void operator() (size_t nRow, const svl::SharedString& rStr)
     {
         ScRefCellValue aCell(&rStr);
         processCell(nRow, aCell);
@@ -1998,7 +2002,7 @@ public:
         switch (maPos.first->type)
         {
             case sc::element_type_string:
-                return sc::string_block::at(*maPos.first->data, maPos.second);
+                return sc::string_block::at(*maPos.first->data, maPos.second).getString();
             case sc::element_type_edittext:
             {
                 const EditTextObject* p = sc::edittext_block::at(*maPos.first->data, maPos.second);
@@ -2098,21 +2102,24 @@ class FormulaToValueHandler
         ScCellValue maValue;
 
         Entry(SCROW nRow, double f) : mnRow(nRow), maValue(f) {}
-        Entry(SCROW nRow, const OUString& rStr) : mnRow(nRow), maValue(rStr) {}
+        Entry(SCROW nRow, const svl::SharedString& rStr) : mnRow(nRow), maValue(rStr) {}
     };
 
     typedef std::vector<Entry> EntriesType;
     EntriesType maEntries;
+    svl::SharedStringPool& mrStrPool;
 
 public:
 
+    FormulaToValueHandler(ScDocument& rDoc) : mrStrPool(rDoc.GetCellStringPool()) {}
+
     void operator() (size_t nRow, const ScFormulaCell* p)
     {
         ScFormulaCell* p2 = const_cast<ScFormulaCell*>(p);
         if (p2->IsValue())
             maEntries.push_back(Entry(nRow, p2->GetValue()));
         else
-            maEntries.push_back(Entry(nRow, p2->GetString()));
+            maEntries.push_back(Entry(nRow, mrStrPool.intern(p2->GetString())));
     }
 
     void commitCells(ScColumn& rColumn)
@@ -2142,7 +2149,7 @@ public:
 
 void ScColumn::RemoveProtected( SCROW nStartRow, SCROW nEndRow )
 {
-    FormulaToValueHandler aFunc;
+    FormulaToValueHandler aFunc(*pDocument);
     sc::CellStoreType::const_iterator itPos = maCells.begin();
 
     ScAttrIterator aAttrIter( pAttrArray, nStartRow, nEndRow );
@@ -2188,12 +2195,20 @@ void ScColumn::SetRawString( SCROW nRow, const OUString& rStr, bool bBroadcast )
     if (!ValidRow(nRow))
         return;
 
-    rtl_uString* pStr = pDocument->GetCellStringPool().intern(rStr).getData();
-    if (!pStr)
+    svl::SharedString aSS = pDocument->GetCellStringPool().intern(rStr);
+    if (!aSS.getData())
+        return;
+
+    SetRawString(nRow, aSS, bBroadcast);
+}
+
+void ScColumn::SetRawString( SCROW nRow, const svl::SharedString& rStr, bool bBroadcast )
+{
+    if (!ValidRow(nRow))
         return;
 
     sc::CellStoreType::iterator it = GetPositionToInsert(nRow);
-    maCells.set(it, nRow, OUString(pStr));
+    maCells.set(it, nRow, rStr);
     maCellTextAttrs.set(nRow, sc::CellTextAttr());
     CellStorageModified();
 
@@ -2204,15 +2219,21 @@ void ScColumn::SetRawString( SCROW nRow, const OUString& rStr, bool bBroadcast )
 void ScColumn::SetRawString(
     sc::ColumnBlockPosition& rBlockPos, SCROW nRow, const OUString& rStr, bool bBroadcast )
 {
-    if (!ValidRow(nRow))
+    svl::SharedString aSS = pDocument->GetCellStringPool().intern(rStr);
+    if (!aSS.getData())
         return;
 
-    rtl_uString* pStr = pDocument->GetCellStringPool().intern(rStr).getData();
-    if (!pStr)
+    SetRawString(rBlockPos, nRow, aSS, bBroadcast);
+}
+
+void ScColumn::SetRawString(
+    sc::ColumnBlockPosition& rBlockPos, SCROW nRow, const svl::SharedString& rStr, bool bBroadcast )
+{
+    if (!ValidRow(nRow))
         return;
 
     rBlockPos.miCellPos = GetPositionToInsert(rBlockPos.miCellPos, nRow);
-    rBlockPos.miCellPos = maCells.set(rBlockPos.miCellPos, nRow, OUString(pStr));
+    rBlockPos.miCellPos = maCells.set(rBlockPos.miCellPos, nRow, rStr);
     rBlockPos.miCellTextAttrPos = maCellTextAttrs.set(
         rBlockPos.miCellTextAttrPos, nRow, sc::CellTextAttr());
     CellStorageModified();
@@ -2263,7 +2284,7 @@ void ScColumn::GetString( SCROW nRow, OUString& rString ) const
     ScCellFormat::GetString(aCell, nFormat, rString, &pColor, *(pDocument->GetFormatTable()), pDocument);
 }
 
-const OUString* ScColumn::GetStringCell( SCROW nRow ) const
+const svl::SharedString* ScColumn::GetStringCell( SCROW nRow ) const
 {
     std::pair<sc::CellStoreType::const_iterator,size_t> aPos = maCells.position(nRow);
     sc::CellStoreType::const_iterator it = aPos.first;
@@ -2551,7 +2572,7 @@ public:
         processCell(nRow, aCell);
     }
 
-    void operator() (size_t nRow, const OUString& rStr)
+    void operator() (size_t nRow, const svl::SharedString& rStr)
     {
         ScRefCellValue aCell(&rStr);
         processCell(nRow, aCell);
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 6cc4f1b..418b303 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -40,6 +40,7 @@
 #include "editutil.hxx"
 #include "tokenarray.hxx"
 #include "refupdatecontext.hxx"
+#include "svl/sharedstring.hxx"
 
 using namespace formula;
 //------------------------------------------------------------------------
@@ -723,7 +724,7 @@ static bool lcl_GetCellContent( ScRefCellValue& rCell, bool bIsStr1, double& rAr
         case CELLTYPE_EDIT:
             bVal = false;
             if (rCell.meType == CELLTYPE_STRING)
-                rArgStr = *rCell.mpString;
+                rArgStr = rCell.mpString->getString();
             else if (rCell.mpEditText)
                 rArgStr = ScEditUtil::GetString(*rCell.mpEditText, pDoc);
         break;
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 6f4d4a7..189c822 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -41,6 +41,7 @@
 
 #include "tools/fract.hxx"
 #include "editeng/editobj.hxx"
+#include "svl/sharedstring.hxx"
 
 #include <vector>
 
@@ -963,7 +964,7 @@ ScCellValue ScCellIterator::getCellValue() const
     switch (maCurCell.meType)
     {
         case CELLTYPE_STRING:
-            aRet.mpString = new OUString(*maCurCell.mpString);
+            aRet.mpString = new svl::SharedString(*maCurCell.mpString);
         break;
         case CELLTYPE_EDIT:
             aRet.mpEditText = maCurCell.mpEditText->Clone();
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index db94928..d69e25b 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -1407,7 +1407,7 @@ void ScDocument::TransliterateText( const ScMarkData& rMultiMark, sal_Int32 nTyp
                     }
                     pEngine->SetDefaults( pDefaults,  true );
                     if (aCell.meType == CELLTYPE_STRING)
-                        pEngine->SetText(*aCell.mpString);

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list