[Libreoffice-commits] core.git: Branch 'private/kohei/calc-shared-string' - 4 commits - editeng/source include/svl sc/inc sc/qa sc/source svl/source

Kohei Yoshida kohei.yoshida at collabora.com
Mon Oct 7 15:02:28 PDT 2013


 editeng/source/editeng/editobj.cxx                     |   39 +++++---
 editeng/source/editeng/editobj2.hxx                    |    7 -
 editeng/source/editeng/impedit4.cxx                    |    2 
 include/svl/sharedstring.hxx                           |    5 +
 sc/inc/cellform.hxx                                    |    1 
 sc/inc/cellvalue.hxx                                   |   16 ++-
 sc/inc/column.hxx                                      |    3 
 sc/inc/document.hxx                                    |   20 +---
 sc/inc/mtvelements.hxx                                 |    7 -
 sc/inc/scmatrix.hxx                                    |    8 +
 sc/inc/table.hxx                                       |    2 
 sc/qa/unit/ucalc.cxx                                   |    9 +
 sc/qa/unit/ucalc_sharedformula.cxx                     |    5 -
 sc/source/core/data/cellvalue.cxx                      |   27 ++---
 sc/source/core/data/column.cxx                         |   28 ++++-
 sc/source/core/data/column2.cxx                        |   61 +++++++-----
 sc/source/core/data/column3.cxx                        |   80 +++++++++--------
 sc/source/core/data/conditio.cxx                       |    3 
 sc/source/core/data/dociter.cxx                        |    3 
 sc/source/core/data/documen8.cxx                       |    4 
 sc/source/core/data/document.cxx                       |    8 -
 sc/source/core/data/documentimport.cxx                 |    6 -
 sc/source/core/data/fillinfo.cxx                       |    2 
 sc/source/core/data/table2.cxx                         |   16 +--
 sc/source/core/data/table3.cxx                         |    4 
 sc/source/core/data/table4.cxx                         |    4 
 sc/source/core/data/validat.cxx                        |    6 -
 sc/source/core/tool/addincol.cxx                       |   17 ++-
 sc/source/core/tool/cellform.cxx                       |    6 -
 sc/source/core/tool/chgtrack.cxx                       |    4 
 sc/source/core/tool/ddelink.cxx                        |    7 -
 sc/source/core/tool/formulagroup.cxx                   |    4 
 sc/source/core/tool/interpr1.cxx                       |    4 
 sc/source/core/tool/interpr2.cxx                       |    6 -
 sc/source/core/tool/interpr5.cxx                       |   16 +--
 sc/source/core/tool/rangeseq.cxx                       |    7 -
 sc/source/core/tool/scmatrix.cxx                       |   31 +++---
 sc/source/core/tool/token.cxx                          |    3 
 sc/source/filter/excel/excform.cxx                     |    3 
 sc/source/filter/excel/xetable.cxx                     |    2 
 sc/source/filter/excel/xihelper.cxx                    |    3 
 sc/source/filter/excel/xilink.cxx                      |    3 
 sc/source/filter/xcl97/XclExpChangeTrack.cxx           |    5 -
 sc/source/filter/xcl97/XclImpChangeTrack.cxx           |    3 
 sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx |    6 -
 sc/source/filter/xml/XMLDDELinksContext.cxx            |    8 +
 sc/source/filter/xml/XMLTrackedChangesContext.cxx      |   14 +-
 sc/source/ui/docshell/docsh.cxx                        |    2 
 sc/source/ui/docshell/externalrefmgr.cxx               |   21 ++--
 sc/source/ui/undo/undocell.cxx                         |    8 +
 sc/source/ui/view/gridwin.cxx                          |    2 
 sc/source/ui/view/tabvwsh5.cxx                         |    3 
 svl/source/misc/sharedstring.cxx                       |   27 +++++
 53 files changed, 346 insertions(+), 245 deletions(-)

New commits:
commit 388c46aa61f2503b7039b6ab788e986516199646
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 f0c7757..f81ad71 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 31f1cec..fc0058d 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 2e3d484..2597217 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 e97e7c2..c6bb3a2 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 77421ec..a82b5a9 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 c44d7393793f9a9251eeaa0a9b8148ea18cc81d1
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 2f4d697..f0c7757 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 550f7b7..31f1cec 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 eb61b90..91afa61 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 43486b1..2e3d484 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.Len() == 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);
+                        pEngine->SetText(aCell.mpString->getString());
                     else if (aCell.mpEditText)
                         pEngine->SetText(*aCell.mpEditText);
 
@@ -1444,7 +1444,7 @@ void ScDocument::TransliterateText( const ScMarkData& rMultiMark, sal_Int32 nTyp
 
                 else if (aCell.meType == CELLTYPE_STRING)
                 {
-                    OUString aOldStr = *aCell.mpString;
+                    OUString aOldStr = aCell.mpString->getString();
                     sal_Int32 nOldLen = aOldStr.getLength();
 
                     if ( bConsiderLanguage )
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 9b91290..e97e7c2 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3205,7 +3205,7 @@ OUString ScDocument::GetString( const ScAddress& rPos ) const
     return aStr;
 }
 
-const OUString* ScDocument::GetStringCell( const ScAddress& rPos ) const
+const svl::SharedString* ScDocument::GetStringCell( const ScAddress& rPos ) const
 {
     if (!TableExists(rPos.Tab()))
         return NULL;
diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx
index 95ae3cf..334b2f5 100644
--- a/sc/source/core/data/documentimport.cxx
+++ b/sc/source/core/data/documentimport.cxx
@@ -150,12 +150,12 @@ void ScDocumentImport::setStringCell(const ScAddress& rPos, const OUString& rStr
     if (!pBlockPos)
         return;
 
-    rtl_uString* pStr = mpImpl->mrDoc.GetCellStringPool().intern(rStr).getData();
-    if (!pStr)
+    svl::SharedString aSS = mpImpl->mrDoc.GetCellStringPool().intern(rStr);
+    if (!aSS.getData())
         return;
 
     sc::CellStoreType& rCells = pTab->aCol[rPos.Col()].maCells;
-    pBlockPos->miCellPos = rCells.set(pBlockPos->miCellPos, rPos.Row(), OUString(pStr));
+    pBlockPos->miCellPos = rCells.set(pBlockPos->miCellPos, rPos.Row(), aSS);
 }
 
 void ScDocumentImport::setEditCell(const ScAddress& rPos, EditTextObject* pEditText)
diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index 5646527..4ce3ee5 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -174,7 +174,7 @@ public:
             setInfo(nRow, ScRefCellValue(fVal));
     }
 
-    void operator() (size_t nRow, const OUString& rStr)
+    void operator() (size_t nRow, const svl::SharedString& rStr)
     {
         if (!isHidden(nRow))
             setInfo(nRow, ScRefCellValue(&rStr));
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 9ec6977..77421ec 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -938,7 +938,7 @@ public:
         mrClipTab.SetValue(nTransCol, mnTransRow, fVal);
     }
 
-    void operator() (size_t nRow, const OUString& rStr)
+    void operator() (size_t nRow, const svl::SharedString& rStr)
     {
         if (mbAsLink)
         {
@@ -1533,6 +1533,12 @@ void ScTable::SetRawString( SCCOL nCol, SCROW nRow, const OUString& rStr )
         aCol[nCol].SetRawString(nRow, rStr);
 }
 
+void ScTable::SetRawString( SCCOL nCol, SCROW nRow, const svl::SharedString& rStr )
+{
+    if (ValidColRow(nCol, nRow))
+        aCol[nCol].SetRawString(nRow, rStr);
+}
+
 void ScTable::GetString( SCCOL nCol, SCROW nRow, OUString& rString ) const
 {
     if (ValidColRow(nCol,nRow))
@@ -1541,7 +1547,7 @@ void ScTable::GetString( SCCOL nCol, SCROW nRow, OUString& rString ) const
         rString = OUString();
 }
 
-const OUString* ScTable::GetStringCell( SCCOL nCol, SCROW nRow ) const
+const svl::SharedString* ScTable::GetStringCell( SCCOL nCol, SCROW nRow ) const
 {
     if (!ValidColRow(nCol,nRow))
         return NULL;
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index d5649ee..b8b5c9e 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -396,11 +396,11 @@ short ScTable::CompareCell(
                 OUString aStr1;
                 OUString aStr2;
                 if (eType1 == CELLTYPE_STRING)
-                    aStr1 = *rCell1.mpString;
+                    aStr1 = rCell1.mpString->getString();
                 else
                     GetString(nCell1Col, nCell1Row, aStr1);
                 if (eType2 == CELLTYPE_STRING)
-                    aStr2 = *rCell2.mpString;
+                    aStr2 = rCell2.mpString->getString();
                 else
                     GetString(nCell2Col, nCell2Row, aStr2);
 
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index 0e5d7cd..0fcd1bb 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -787,7 +787,7 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
                                 case CELLTYPE_STRING:
                                 case CELLTYPE_EDIT:
                                     if ( eCellType == CELLTYPE_STRING )
-                                        aValue = *aSrcCell.mpString;
+                                        aValue = aSrcCell.mpString->getString();
                                     else
                                         aValue = ScEditUtil::GetString(*aSrcCell.mpEditText, pDocument);
                                     if ( !(nScFillModeMouseModifier & KEY_MOD1) && !bHasFiltered )
@@ -1578,7 +1578,7 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
                 }
                 OUString aValue;
                 if (eCellType == CELLTYPE_STRING)
-                    aValue = *aSrcCell.mpString;
+                    aValue = aSrcCell.mpString->getString();
                 else
                     aValue = ScEditUtil::GetString(*aSrcCell.mpEditText, pDocument);
                 sal_Int32 nStringValue;
diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index 2c66dd5..07a54f9 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -29,6 +29,7 @@
 
 #include <basic/sbx.hxx>
 #include <svl/zforlist.hxx>
+#include "svl/sharedstringpool.hxx"
 #include <vcl/msgbox.hxx>
 #include <rtl/math.hxx>
 
@@ -461,7 +462,8 @@ bool ScValidationData::IsDataValid(
         }
         else
         {
-            ScRefCellValue aTmpCell(&rTest);
+            svl::SharedString aSS = mpDoc->GetCellStringPool().intern(rTest);
+            ScRefCellValue aTmpCell(&aSS);
             bRet = IsDataValid(aTmpCell, rPos);
         }
     }
@@ -484,7 +486,7 @@ bool ScValidationData::IsDataValid( ScRefCellValue& rCell, const ScAddress& rPos
             nVal = rCell.mfValue;
         break;
         case CELLTYPE_STRING:
-            aString = *rCell.mpString;
+            aString = rCell.mpString->getString();
             bIsVal = false;
         break;
         case CELLTYPE_EDIT:
diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx
index 894d42f..807bba2 100644
--- a/sc/source/core/tool/addincol.cxx
+++ b/sc/source/core/tool/addincol.cxx
@@ -49,6 +49,7 @@
 #include "scmod.hxx"
 #include "rangeseq.hxx"
 #include "funcdesc.hxx"
+#include "svl/sharedstring.hxx"
 
 using namespace com::sun::star;
 
@@ -1663,13 +1664,17 @@ void ScUnoAddInCall::SetResult( const uno::Any& rNewRes )
                             long nColCount = pRowArr[nRow].getLength();
                             const OUString* pColArr = pRowArr[nRow].getConstArray();
                             for (nCol=0; nCol<nColCount; nCol++)
-                                xMatrix->PutString( pColArr[nCol],
-                                    static_cast<SCSIZE>(nCol),
-                                    static_cast<SCSIZE>(nRow) );
+                            {
+                                xMatrix->PutString(
+                                    svl::SharedString(pColArr[nCol]),
+                                    static_cast<SCSIZE>(nCol), static_cast<SCSIZE>(nRow));
+                            }
                             for (nCol=nColCount; nCol<nMaxColCount; nCol++)
-                                xMatrix->PutString( EMPTY_OUSTRING,
-                                        static_cast<SCSIZE>(nCol),
-                                        static_cast<SCSIZE>(nRow) );
+                            {
+                                xMatrix->PutString(
+                                    svl::SharedString(EMPTY_OUSTRING),
+                                    static_cast<SCSIZE>(nCol), static_cast<SCSIZE>(nRow));
+                            }
                         }
                     }
                 }
diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx
index 57ada4a..1f394f7 100644
--- a/sc/source/core/tool/cellform.cxx
+++ b/sc/source/core/tool/cellform.cxx
@@ -17,11 +17,13 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include "cellform.hxx"
+
 #include <sfx2/objsh.hxx>
 #include <svl/smplhint.hxx>
 #include <svl/zforlist.hxx>
+#include "svl/sharedstring.hxx"
 
-#include "cellform.hxx"
 #include "formulacell.hxx"
 #include "document.hxx"
 #include "cellvalue.hxx"
@@ -47,7 +49,7 @@ void ScCellFormat::GetString( ScRefCellValue& rCell, sal_uLong nFormat, OUString
     switch (rCell.meType)
     {
         case CELLTYPE_STRING:
-            rFormatter.GetOutputString(*rCell.mpString, nFormat, rString, ppColor, bUseStarFormat);
+            rFormatter.GetOutputString(rCell.mpString->getString(), nFormat, rString, ppColor, bUseStarFormat);
         break;
         case CELLTYPE_EDIT:
             rFormatter.GetOutputString(rCell.getString(pDoc), nFormat, rString, ppColor );
diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx
index 5ba0e35..ab07a63 100644
--- a/sc/source/core/tool/chgtrack.cxx
+++ b/sc/source/core/tool/chgtrack.cxx
@@ -1643,7 +1643,7 @@ void ScChangeActionContent::GetStringOfCell(
             pDoc->GetFormatTable()->GetInputLineString(rCell.mfValue, nFormat, rStr);
         break;
         case CELLTYPE_STRING:
-            rStr = *rCell.mpString;
+            rStr = rCell.mpString->getString();
         break;
         case CELLTYPE_EDIT:
             if (rCell.mpEditText)
@@ -1791,7 +1791,7 @@ void ScChangeActionContent::GetValueString(
     switch (rCell.meType)
     {
         case CELLTYPE_STRING :
-            rStr = *rCell.mpString;
+            rStr = rCell.mpString->getString();
         break;
         case CELLTYPE_EDIT :
             if (rCell.mpEditText)
diff --git a/sc/source/core/tool/ddelink.cxx b/sc/source/core/tool/ddelink.cxx
index 96a9a25..0d19a51 100644
--- a/sc/source/core/tool/ddelink.cxx
+++ b/sc/source/core/tool/ddelink.cxx
@@ -21,6 +21,7 @@
 #include <sfx2/linkmgr.hxx>
 #include <sfx2/bindings.hxx>
 #include <svl/zforlist.hxx>
+#include "svl/sharedstring.hxx"
 
 #include "ddelink.hxx"
 #include "brdcst.hxx"
@@ -172,7 +173,7 @@ sfx2::SvBaseLink::UpdateResult ScDdeLink::DataChanged(
         else if ( nMode == SC_DDE_ENGLISH )
             nStdFormat = pFormatter->GetStandardIndex(LANGUAGE_ENGLISH_US);
 
-        String aEntry;
+        OUString aEntry;
         for (SCSIZE nR=0; nR<nRows; nR++)
         {
             aLine = aLinkStr.getToken( (sal_Int32) nR, '\n' );
@@ -183,11 +184,11 @@ sfx2::SvBaseLink::UpdateResult ScDdeLink::DataChanged(
                 double fVal = double();
                 if ( nMode != SC_DDE_TEXT && pFormatter->IsNumberFormat( aEntry, nIndex, fVal ) )
                     pResult->PutDouble( fVal, nC, nR );
-                else if (aEntry.Len() == 0)
+                else if (aEntry.isEmpty())
                     // empty cell
                     pResult->PutEmpty(nC, nR);
                 else
-                    pResult->PutString( aEntry, nC, nR );
+                    pResult->PutString(svl::SharedString(aEntry), nC, nR);
             }
         }
     }
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index 98ae0b4..09076a8 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -79,10 +79,10 @@ void flushSegment(
     ScMatrix& rMat, size_t nCol, rtl_uString** pHead, rtl_uString** pCur, rtl_uString** pTop )
 {
     size_t nOffset = pHead - pTop;
-    std::vector<OUString> aStrs;
+    std::vector<svl::SharedString> aStrs;
     aStrs.reserve(pCur - pHead);
     for (; pHead != pCur; ++pHead)
-        aStrs.push_back(OUString(*pHead));
+        aStrs.push_back(svl::SharedString(*pHead, NULL));
 
     rMat.PutString(&aStrs[0], aStrs.size(), nCol, nOffset);
 }
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 6bf0093..f4c2d4f 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -261,8 +261,8 @@ static void lcl_storeJumpMatResult( const ScMatrix* pMat, ScMatrix* pResMat, SCS
     }
     else
     {
-        const String& rStr = pMat->GetString( nC, nR );
-        pResMat->PutString( rStr, nC, nR );
+        const OUString& rStr = pMat->GetString(nC, nR);
+        pResMat->PutString(svl::SharedString(rStr), nC, nR);
     }
 }
 
diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index 6f08958..d49949d 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -2503,7 +2503,7 @@ void ScInterpreter::ScHyperLink()
                     SetError( errIllegalArgument);
             }
         }
-        String aUrl = GetString();
+        OUString aUrl = GetString();
         ScMatrixRef pResMat = GetNewMat( 1, 2);
         if (nGlobalError)
         {
@@ -2520,8 +2520,8 @@ void ScInterpreter::ScHyperLink()
                 pResMat->PutDouble( 0.0, 0 );
         }
         else
-            pResMat->PutString( aUrl, 0 );
-        pResMat->PutString( aUrl, 1 );
+            pResMat->PutString(svl::SharedString(aUrl), 0);
+        pResMat->PutString(svl::SharedString(aUrl), 1);
         bMatrixFormula = true;
         PushMatrix(pResMat);
     }
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index 0f52e43..24319fa 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -439,7 +439,7 @@ ScMatrixRef ScInterpreter::GetMatrix()
         break;
         case svString :
         {
-            String aStr = GetString();
+            OUString aStr = GetString();
             pMat = GetNewMat( 1, 1);
             if ( pMat )
             {
@@ -450,7 +450,7 @@ ScMatrixRef ScInterpreter::GetMatrix()
                     nGlobalError = 0;
                 }
                 else
-                    pMat->PutString( aStr, 0);
+                    pMat->PutString(svl::SharedString(aStr), 0);
             }
         }
         break;
@@ -1083,9 +1083,9 @@ ScMatrixRef ScInterpreter::MatConcat(const ScMatrixRef& pMat1, const ScMatrixRef
                     xResMat->PutError( nErr, i, j);
                 else
                 {
-                    String aTmp( pMat1->GetString( *pFormatter, i, j));
+                    OUString aTmp = pMat1->GetString(*pFormatter, i, j);
                     aTmp += pMat2->GetString( *pFormatter, i, j);
-                    xResMat->PutString( aTmp, i, j);
+                    xResMat->PutString(svl::SharedString(aTmp), i, j);
                 }
             }
         }
@@ -1314,9 +1314,9 @@ void ScInterpreter::ScAmpersand()
                             pResMat->PutError( nErr, i, j);
                         else
                         {
-                            String aTmp( sStr);
+                            OUString aTmp = sStr;
                             aTmp += pMat->GetString( *pFormatter, i, j);
-                            pResMat->PutString( aTmp, i, j);
+                            pResMat->PutString(svl::SharedString(aTmp), i, j);
                         }
                     }
             }
@@ -1330,9 +1330,9 @@ void ScInterpreter::ScAmpersand()
                             pResMat->PutError( nErr, i, j);
                         else
                         {
-                            String aTmp( pMat->GetString( *pFormatter, i, j));
+                            OUString aTmp = pMat->GetString(*pFormatter, i, j);
                             aTmp += sStr;
-                            pResMat->PutString( aTmp, i, j);
+                            pResMat->PutString(svl::SharedString(aTmp), i, j);
                         }
                     }
             }
diff --git a/sc/source/core/tool/rangeseq.cxx b/sc/source/core/tool/rangeseq.cxx
index 39ef812..0547a84 100644
--- a/sc/source/core/tool/rangeseq.cxx
+++ b/sc/source/core/tool/rangeseq.cxx
@@ -406,9 +406,10 @@ ScMatrixRef ScSequenceToMatrix::CreateMixedMatrix( const com::sun::star::uno::An
                         // Try string, else use empty as last resort.
 
                         if ( pColArr[nCol] >>= aUStr )
-                            xMatrix->PutString( String( aUStr ),
-                                    static_cast<SCSIZE>(nCol),
-                                    static_cast<SCSIZE>(nRow) );
+                        {
+                            xMatrix->PutString(
+                                svl::SharedString(aUStr), static_cast<SCSIZE>(nCol), static_cast<SCSIZE>(nRow));
+                        }
                         else
                             xMatrix->PutEmpty(
                                     static_cast<SCSIZE>(nCol),
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 286b425..ad1712d 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -25,6 +25,7 @@
 #include "mtvelements.hxx"
 
 #include <svl/zforlist.hxx>
+#include "svl/sharedstring.hxx"
 #include <tools/stream.hxx>
 #include <rtl/math.hxx>
 
@@ -55,7 +56,7 @@ using ::std::unary_function;
  */
 struct custom_string_trait
 {
-    typedef OUString string_type;
+    typedef svl::SharedString string_type;
     typedef sc::string_block string_element_block;
 
     static const mdds::mtv::element_t string_type_identifier = sc::element_type_string;
@@ -179,9 +180,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);
     void PutEmptyPath(SCSIZE nC, SCSIZE nR);
@@ -361,7 +362,7 @@ void ScMatrixImpl::PutDouble( double fVal, SCSIZE nIndex)
     PutDouble(fVal, nC, nR);
 }
 
-void ScMatrixImpl::PutString(const OUString& rStr, SCSIZE nC, SCSIZE nR)
+void ScMatrixImpl::PutString(const svl::SharedString& rStr, SCSIZE nC, SCSIZE nR)
 {
     if (ValidColRow( nC, nR))
         maMat.set(nR, nC, rStr);
@@ -371,7 +372,7 @@ void ScMatrixImpl::PutString(const OUString& rStr, SCSIZE nC, SCSIZE nR)
     }
 }
 
-void ScMatrixImpl::PutString(const OUString* pArray, size_t nLen, SCSIZE nC, SCSIZE nR)
+void ScMatrixImpl::PutString(const svl::SharedString* pArray, size_t nLen, SCSIZE nC, SCSIZE nR)
 {
     if (ValidColRow( nC, nR))
         maMat.set(nR, nC, pArray, pArray + nLen);
@@ -381,7 +382,7 @@ void ScMatrixImpl::PutString(const OUString* pArray, size_t nLen, SCSIZE nC, SCS
     }
 }
 
-void ScMatrixImpl::PutString(const OUString& rStr, SCSIZE nIndex)
+void ScMatrixImpl::PutString(const svl::SharedString& rStr, SCSIZE nIndex)
 {
     SCSIZE nC, nR;
     CalcPosition(nIndex, nC, nR);
@@ -479,7 +480,7 @@ OUString ScMatrixImpl::GetString(SCSIZE nC, SCSIZE nR) const
         switch (maMat.get_type(aPos))
         {
             case mdds::mtm::element_string:
-                return maMat.get_string(aPos);
+                return maMat.get_string(aPos).getString();
             case mdds::mtm::element_empty:
                 return EMPTY_OUSTRING;
             case mdds::mtm::element_numeric:
@@ -518,7 +519,7 @@ OUString ScMatrixImpl::GetString( SvNumberFormatter& rFormatter, SCSIZE nC, SCSI
     switch (maMat.get_type(aPos))
     {
         case mdds::mtm::element_string:
-            return maMat.get_string(aPos);
+            return maMat.get_string(aPos).getString();
         case mdds::mtm::element_empty:
         {
             if (!maMatFlag.get<bool>(nR, nC))
@@ -574,7 +575,7 @@ ScMatrixValue ScMatrixImpl::Get(SCSIZE nC, SCSIZE nR) const
             break;
             case mdds::mtm::element_string:
                 aVal.nType = SC_MATVAL_STRING;
-                aVal.aStr = maMat.get_string(aPos);
+                aVal.aStr = maMat.get_string(aPos).getString();
             break;
             case mdds::mtm::element_empty:
                 // Empty path equals empty plus flag.
@@ -1034,7 +1035,7 @@ size_t WalkAndMatchElements<OUString>::compare(const MatrixImplType::element_blo
             MatrixImplType::string_block_type::const_iterator itEnd = MatrixImplType::string_block_type::end(*node.data);
             for (; it != itEnd; ++it, ++nCount)
             {
-                if (ScGlobal::GetpTransliteration()->isEqual(*it, maMatchValue))
+                if (ScGlobal::GetpTransliteration()->isEqual(it->getString(), maMatchValue))
                 {
                     return mnIndex + nCount;
                 }
@@ -1354,7 +1355,7 @@ void ScMatrixImpl::Dump() const
             switch (maMat.get_type(nRow, nCol))
             {
                 case mdds::mtm::element_string:
-                    cout << "string (" << maMat.get_string(nRow, nCol) << ")";
+                    cout << "string (" << maMat.get_string(nRow, nCol).getString() << ")";
                 break;
                 case mdds::mtm::element_numeric:
                     cout << "numeric (" << maMat.get_numeric(nRow, nCol) << ")";
@@ -1497,17 +1498,17 @@ void ScMatrix::PutDouble(const double* pArray, size_t nLen, SCSIZE nC, SCSIZE nR
     pImpl->PutDouble(pArray, nLen, nC, nR);
 }
 
-void ScMatrix::PutString(const OUString& rStr, SCSIZE nC, SCSIZE nR)
+void ScMatrix::PutString(const svl::SharedString& rStr, SCSIZE nC, SCSIZE nR)
 {
     pImpl->PutString(rStr, nC, nR);
 }
 
-void ScMatrix::PutString(const OUString& rStr, SCSIZE nIndex)
+void ScMatrix::PutString(const svl::SharedString& rStr, SCSIZE nIndex)
 {
     pImpl->PutString(rStr, nIndex);
 }
 
-void ScMatrix::PutString(const OUString* pArray, size_t nLen, SCSIZE nC, SCSIZE nR)
+void ScMatrix::PutString(const svl::SharedString* pArray, size_t nLen, SCSIZE nC, SCSIZE nR)
 {
     pImpl->PutString(pArray, nLen, nC, nR);
 }
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 201bd43..69ba49e 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -39,6 +39,7 @@
 #include "document.hxx"
 #include "refupdatecontext.hxx"
 #include "types.hxx"
+#include "svl/sharedstring.hxx"
 
 using ::std::vector;
 
@@ -1788,7 +1789,7 @@ FormulaToken* ScTokenArray::MergeArray( )
                 }
                 else if ( t->GetType() == svString )
                 {
-                    pArray->PutString( t->GetString(), nCol, nRow );
+                    pArray->PutString(svl::SharedString(t->GetString()), nCol, nRow);
                 }
             break;
 
diff --git a/sc/source/filter/excel/excform.cxx b/sc/source/filter/excel/excform.cxx
index a2df17e..54f3c3a 100644
--- a/sc/source/filter/excel/excform.cxx
+++ b/sc/source/filter/excel/excform.cxx
@@ -27,6 +27,7 @@
 #include "scmatrix.hxx"
 
 #include "formula/errorcodes.hxx"
+#include "svl/sharedstring.hxx"
 
 #include "imp_op.hxx"
 #include "root.hxx"
@@ -1850,7 +1851,7 @@ void ExcelToSc::ReadExtensionArray( unsigned int n, XclImpStream& aIn )
                     }
                     if( NULL != pMatrix )
                     {
-                        pMatrix->PutString( aString, nC, nR );
+                        pMatrix->PutString(svl::SharedString(aString), nC, nR);
                     }
                     break;
 
diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx
index 5df2e81..a86410fb 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -2360,7 +2360,7 @@ XclExpCellTable::XclExpCellTable( const XclExpRoot& rRoot ) :
             case CELLTYPE_STRING:
             {
                 xCell.reset(new XclExpLabelCell(
-                    GetRoot(), aXclPos, pPattern, nMergeBaseXFId, *rScCell.mpString));
+                    GetRoot(), aXclPos, pPattern, nMergeBaseXFId, rScCell.mpString->getString()));
             }
             break;
 
diff --git a/sc/source/filter/excel/xihelper.cxx b/sc/source/filter/excel/xihelper.cxx
index 73b4003..d426332 100644
--- a/sc/source/filter/excel/xihelper.cxx
+++ b/sc/source/filter/excel/xihelper.cxx
@@ -19,6 +19,7 @@
 
 #include "xihelper.hxx"
 #include <svl/itemset.hxx>
+#include "svl/sharedstring.hxx"
 #include <editeng/editobj.hxx>
 #include <tools/urlobj.hxx>
 #include "scitems.hxx"
@@ -877,7 +878,7 @@ ScMatrixRef XclImpCachedMatrix::CreateScMatrix() const
                         xScMatrix->PutDouble( itValue->GetValue(), nScCol, nScRow );
                     break;
                     case EXC_CACHEDVAL_STRING:
-                        xScMatrix->PutString( itValue->GetString(), nScCol, nScRow );
+                        xScMatrix->PutString(svl::SharedString(itValue->GetString()), nScCol, nScRow);
                     break;
                     case EXC_CACHEDVAL_BOOL:
                         xScMatrix->PutBoolean( itValue->GetBool(), nScCol, nScRow );
diff --git a/sc/source/filter/excel/xilink.cxx b/sc/source/filter/excel/xilink.cxx
index f7119dc..4303889 100644
--- a/sc/source/filter/excel/xilink.cxx
+++ b/sc/source/filter/excel/xilink.cxx
@@ -29,6 +29,7 @@
 #include "tokenarray.hxx"
 #include "externalrefmgr.hxx"
 #include "scmatrix.hxx"
+#include "svl/sharedstring.hxx"
 
 #include <vector>
 #include <boost/ptr_container/ptr_vector.hpp>
@@ -296,7 +297,7 @@ XclImpExtName::MOper::MOper(XclImpStream& rStrm) :
                 case 0x02:
                 {
                     OUString aStr = rStrm.ReadUniString();
-                    mxCached->PutString(aStr, nCol, nRow);
+                    mxCached->PutString(svl::SharedString(aStr), nCol, nRow);
                 }
                 break;
                 case 0x04:
diff --git a/sc/source/filter/xcl97/XclExpChangeTrack.cxx b/sc/source/filter/xcl97/XclExpChangeTrack.cxx
index dbaf1bea..5a81874 100644
--- a/sc/source/filter/xcl97/XclExpChangeTrack.cxx
+++ b/sc/source/filter/xcl97/XclExpChangeTrack.cxx
@@ -32,6 +32,7 @@
 
 #include <oox/token/tokens.hxx>
 #include <rtl/strbuf.hxx>
+#include "svl/sharedstring.hxx"
 
 using namespace oox;
 
@@ -845,9 +846,9 @@ void XclExpChTrCellContent::GetCellData(
             OUString sCellStr;
             if (rScCell.meType == CELLTYPE_STRING)
             {
-                sCellStr = *rScCell.mpString;
+                sCellStr = rScCell.mpString->getString();
                 rpData->mpFormattedString = XclExpStringHelper::CreateCellString(
-                    rRoot, *rScCell.mpString, NULL);
+                    rRoot, sCellStr, NULL);
             }
             else
             {
diff --git a/sc/source/filter/xcl97/XclImpChangeTrack.cxx b/sc/source/filter/xcl97/XclImpChangeTrack.cxx
index 948543a..a93b911 100644
--- a/sc/source/filter/xcl97/XclImpChangeTrack.cxx
+++ b/sc/source/filter/xcl97/XclImpChangeTrack.cxx
@@ -21,6 +21,7 @@
 #include "XclImpChangeTrack.hxx"
 #include <sot/storage.hxx>
 #include <svl/zforlist.hxx>
+#include "svl/sharedstringpool.hxx"
 #include "chgviset.hxx"
 #include "formulacell.hxx"
 #include "chgtrack.hxx"
@@ -249,7 +250,7 @@ void XclImpChangeTrack::ReadCell(
             if( pStrm->IsValid() )
             {
                 rCell.meType = CELLTYPE_STRING;
-                rCell.mpString = new OUString(sString);
+                rCell.mpString = new svl::SharedString(GetDoc().GetCellStringPool().intern(sString));
             }
         }
         break;
diff --git a/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx b/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx
index 72993ac..1fd98cd 100644
--- a/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx
+++ b/sc/source/filter/xml/XMLChangeTrackingExportHelper.cxx
@@ -36,6 +36,7 @@
 #include <com/sun/star/util/DateTime.hpp>
 #include <tools/datetime.hxx>
 #include <svl/zforlist.hxx>
+#include "svl/sharedstring.hxx"
 
 #define SC_CHANGE_ID_PREFIX "ct"
 
@@ -293,11 +294,12 @@ void ScChangeTrackingExportHelper::WriteStringCell(const ScCellValue& rCell)
 
     rExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_VALUE_TYPE, XML_STRING);
     SvXMLElementExport aElemC(rExport, XML_NAMESPACE_TABLE, XML_CHANGE_TRACK_TABLE_CELL, true, true);
-    if (!rCell.mpString->isEmpty())
+    OUString aStr = rCell.mpString->getString();
+    if (!aStr.isEmpty())
     {
         SvXMLElementExport aElemP(rExport, XML_NAMESPACE_TEXT, XML_P, true, false);
         bool bPrevCharWasSpace(true);
-        rExport.GetTextParagraphExport()->exportText(*rCell.mpString, bPrevCharWasSpace);
+        rExport.GetTextParagraphExport()->exportText(aStr, bPrevCharWasSpace);
     }
 }
 
diff --git a/sc/source/filter/xml/XMLDDELinksContext.cxx b/sc/source/filter/xml/XMLDDELinksContext.cxx
index 4f6d51f..ba904b6 100644
--- a/sc/source/filter/xml/XMLDDELinksContext.cxx
+++ b/sc/source/filter/xml/XMLDDELinksContext.cxx
@@ -25,6 +25,7 @@
 #include <xmloff/xmlnmspe.hxx>
 #include <xmloff/nmspmap.hxx>
 #include <sax/tools/converter.hxx>
+#include "svl/sharedstringpool.hxx"
 
 using namespace com::sun::star;
 using namespace xmloff::token;
@@ -142,7 +143,8 @@ void ScXMLDDELinkContext::AddRowsToTable(const sal_Int32 nRowsP)
 
 void ScXMLDDELinkContext::EndElement()
 {
-    if (nPosition > -1 && nColumns && nRows && GetScImport().GetDocument())
+    ScDocument* pDoc = GetScImport().GetDocument();
+    if (nPosition > -1 && nColumns && nRows)
     {
         bool bSizeMatch = (static_cast<size_t>(nColumns * nRows) == aDDELinkTable.size());
         OSL_ENSURE( bSizeMatch, "ScXMLDDELinkContext::EndElement: matrix dimension doesn't match cells count");
@@ -163,6 +165,8 @@ void ScXMLDDELinkContext::EndElement()
         sal_Int32 nIndex(0);
         ScDDELinkCells::iterator aItr(aDDELinkTable.begin());
         ScDDELinkCells::iterator aEndItr(aDDELinkTable.end());
+
+        svl::SharedStringPool& rPool = pDoc->GetCellStringPool();
         while (aItr != aEndItr)
         {
             if (nIndex % nColumns == 0)
@@ -178,7 +182,7 @@ void ScXMLDDELinkContext::EndElement()
             if( aItr->bEmpty )
                 pMatrix->PutEmpty( nScCol, nScRow );
             else if( aItr->bString )
-                pMatrix->PutString( aItr->sValue, nScCol, nScRow );
+                pMatrix->PutString(rPool.intern(aItr->sValue), nScCol, nScRow);
             else
                 pMatrix->PutDouble( aItr->fValue, nScCol, nScRow );
 
diff --git a/sc/source/filter/xml/XMLTrackedChangesContext.cxx b/sc/source/filter/xml/XMLTrackedChangesContext.cxx
index b66b081..590b0e3 100644
--- a/sc/source/filter/xml/XMLTrackedChangesContext.cxx
+++ b/sc/source/filter/xml/XMLTrackedChangesContext.cxx
@@ -32,6 +32,7 @@
 #include <xmloff/xmluconv.hxx>
 #include <sax/tools/converter.hxx>
 #include <svl/zforlist.hxx>
+#include "svl/sharedstringpool.hxx"
 #include <com/sun/star/text/XTextCursor.hpp>
 #include <com/sun/star/text/ControlCharacter.hpp>
 
@@ -1265,6 +1266,7 @@ void ScXMLChangeCellContext::EndElement()
 {
     if (!bEmpty)
     {
+        ScDocument* pDoc = GetScImport().GetDocument();
         if (pEditTextObj)
         {
             if (GetImport().GetTextImport()->GetCursor().is())
@@ -1278,12 +1280,10 @@ void ScXMLChangeCellContext::EndElement()
                         sal_True );
                 }
             }
-            if (GetScImport().GetDocument())
-            {
-                // The cell will own the text object instance.
-                mrOldCell.meType = CELLTYPE_EDIT;
-                mrOldCell.mpEditText = pEditTextObj->CreateTextObject();
-            }
+
+            // The cell will own the text object instance.
+            mrOldCell.meType = CELLTYPE_EDIT;
+            mrOldCell.mpEditText = pEditTextObj->CreateTextObject();
             GetScImport().GetTextImport()->ResetCursor();
             pEditTextObj->release();
         }
@@ -1294,7 +1294,7 @@ void ScXMLChangeCellContext::EndElement()
                 if (!sText.isEmpty() && bString)
                 {
                     mrOldCell.meType = CELLTYPE_STRING;
-                    mrOldCell.mpString = new OUString(sText);
+                    mrOldCell.mpString = new svl::SharedString(pDoc->GetCellStringPool().intern(sText));
                 }
                 else
                 {
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 12596466..f6a8a3f 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -1961,7 +1961,7 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt
                     aString = ScCellFormat::GetString(aDocument, aPos, nFormat, &pDummy, rFormatter);
                 }
                 else
-                    aString = *pCell->mpString;
+                    aString = pCell->mpString->getString();
                 bString = true;
                 break;
             case CELLTYPE_EDIT :
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index 8548f06..29994a8 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -45,6 +45,7 @@
 #include "svl/stritem.hxx"
 #include "svl/urihelper.hxx"
 #include "svl/zformat.hxx"
+#include "svl/sharedstring.hxx"
 #include "sfx2/linkmgr.hxx"
 #include "tools/urlobj.hxx"
 #include "unotools/ucbhelper.hxx"
@@ -644,7 +645,7 @@ ScExternalRefCache::TokenArrayRef ScExternalRefCache::getCellRangeData(
                         xMat->PutDouble(pToken->GetDouble(), nC, nR);
                     break;
                     case svString:
-                        xMat->PutString(pToken->GetString(), nC, nR);
+                        xMat->PutString(svl::SharedString(pToken->GetString()), nC, nR);
                     break;
                     default:
                         ;
@@ -1349,9 +1350,9 @@ struct ColumnBatch
 };
 
 template<>
-inline OUString ColumnBatch<OUString>::getValue(ScRefCellValue& raCell) const
+inline svl::SharedString ColumnBatch<svl::SharedString>::getValue(ScRefCellValue& rCell) const
 {
-    return raCell.getString(NULL);
+    return svl::SharedString(rCell.getString(NULL));
 }
 
 template<class T>
@@ -1361,7 +1362,7 @@ inline T ColumnBatch<T>::getValue(ScRefCellValue& raCell) const
 }
 
 template<>
-inline void ColumnBatch<OUString>::putValues(ScMatrixRef& xMat, const SCCOL nCol) const
+inline void ColumnBatch<svl::SharedString>::putValues(ScMatrixRef& xMat, const SCCOL nCol) const
 {
     xMat->PutString(maStorage.data(), maStorage.size(), nCol, mnRowStart);
 }
@@ -1419,8 +1420,8 @@ static ScTokenArray* convertToTokenArray(
             static_cast<SCSIZE>(nCol2-nCol1+1), static_cast<SCSIZE>(nRow2-nRow1+1));
 
         ScRefCellValue aCell;
-        ColumnBatch<OUString> stringBatch(CELLTYPE_STRING, CELLTYPE_EDIT);
-        ColumnBatch<double> doubleBatch(CELLTYPE_VALUE, CELLTYPE_VALUE);
+        ColumnBatch<svl::SharedString> aStringBatch(CELLTYPE_STRING, CELLTYPE_EDIT);
+        ColumnBatch<double> aDoubleBatch(CELLTYPE_VALUE, CELLTYPE_VALUE);
 
         for (SCCOL nCol = nDataCol1; nCol <= nDataCol2; ++nCol)
         {
@@ -1431,8 +1432,8 @@ static ScTokenArray* convertToTokenArray(
 
                 aCell.assign(*pSrcDoc, ScAddress(nCol, nRow, nTab));
 
-                stringBatch.update(aCell, nC, nR, xMat);
-                doubleBatch.update(aCell, nC, nR, xMat);
+                aStringBatch.update(aCell, nC, nR, xMat);
+                aDoubleBatch.update(aCell, nC, nR, xMat);
 
                 if (aCell.hasEmptyValue())
                     // Skip empty cells.  Matrix's default values are empty elements.
@@ -1463,8 +1464,8 @@ static ScTokenArray* convertToTokenArray(
                 }
             }
 
-            stringBatch.flush(nC, xMat);
-            doubleBatch.flush(nC, xMat);
+            aStringBatch.flush(nC, xMat);
+            aDoubleBatch.flush(nC, xMat);
         }
         if (!bFirstTab)
             pArray->AddOpCode(ocSep);
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx
index 8151d3f..cff0e7f 100644
--- a/sc/source/ui/undo/undocell.cxx
+++ b/sc/source/ui/undo/undocell.cxx
@@ -17,13 +17,15 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include "undocell.hxx"
+
 #include "scitems.hxx"
 #include <editeng/eeitem.hxx>
 #include <editeng/editobj.hxx>
 #include <svl/zforlist.hxx>
+#include "svl/sharedstringpool.hxx"
 #include <sfx2/app.hxx>
 
-#include "undocell.hxx"
 #include "document.hxx"
 #include "docpool.hxx"
 #include "patattr.hxx"
@@ -481,7 +483,7 @@ void ScUndoSetCell::SetValue( const ScCellValue& rVal )
         {
             ScSetStringParam aParam;
             aParam.setTextInput();
-            pDoc->SetString(maPos, *rVal.mpString);
+            pDoc->SetString(maPos, rVal.mpString->getString());
         }
         break;
         case CELLTYPE_EDIT:
@@ -668,7 +670,7 @@ ScUndoThesaurus::ScUndoThesaurus( ScDocShell* pNewDocShell,
     else
     {
         aOldCell.meType = CELLTYPE_STRING;
-        aOldCell.mpString = new OUString(aUndoStr);
+        aOldCell.mpString = new svl::SharedString(pDocShell->GetDocument()->GetCellStringPool().intern(aUndoStr));
     }
     SetChangeTrack(aOldCell);
 }
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index d437bee..23b62e3 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -5465,7 +5465,7 @@ bool ScGridWindow::ContinueOnlineSpelling()
             pEngine->SetDefaultLanguage(nCellLang);
 
             if (eType == CELLTYPE_STRING)
-                pEngine->SetText(*pCell->mpString);
+                pEngine->SetText(pCell->mpString->getString());
             else
                 pEngine->SetText(*pCell->mpEditText);
 
diff --git a/sc/source/ui/view/tabvwsh5.cxx b/sc/source/ui/view/tabvwsh5.cxx
index 79e5064..c6fcace 100644
--- a/sc/source/ui/view/tabvwsh5.cxx
+++ b/sc/source/ui/view/tabvwsh5.cxx
@@ -38,6 +38,7 @@
 #include "editsh.hxx"
 #include "hints.hxx"
 #include "cellvalue.hxx"
+#include "svl/sharedstring.hxx"
 
 //==================================================================
 
@@ -332,7 +333,7 @@ void ScTabViewShell::MakeNumberInfoItem( ScDocument*         pDoc,
 
         case CELLTYPE_STRING:
         {
-            aCellString = *aCell.mpString;
+            aCellString = aCell.mpString->getString();
             eValType = SVX_VALUE_TYPE_STRING;
         }
         break;
diff --git a/svl/source/misc/sharedstring.cxx b/svl/source/misc/sharedstring.cxx
index 7286cba..e8ad0b7 100644
--- a/svl/source/misc/sharedstring.cxx
+++ b/svl/source/misc/sharedstring.cxx
@@ -22,6 +22,11 @@ SharedString::SharedString( rtl_uString* pData, rtl_uString* pDataIgnoreCase ) :
         rtl_uString_acquire(mpDataIgnoreCase);
 }
 
+SharedString::SharedString( const OUString& rStr ) : mpData(rStr.pData), mpDataIgnoreCase(NULL)
+{
+    rtl_uString_acquire(mpData);
+}
+
 SharedString::SharedString( const SharedString& r ) : mpData(r.mpData), mpDataIgnoreCase(r.mpDataIgnoreCase)
 {
     if (mpData)
@@ -73,6 +78,11 @@ bool SharedString::operator== ( const SharedString& r ) const
     return !r.mpData;
 }
 
+OUString SharedString::getString() const
+{
+    return mpData ? OUString(mpData) : OUString();
+}
+
 rtl_uString* SharedString::getData()
 {
     return mpData;
commit 75ff6d7a657e36f2f6c5772a0a16a4ec21627ecf
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Oct 7 13:07:28 2013 -0400

    ContentInfo to store svl::SharedString instead of OUString.
    
    Change-Id: I633e3bb633317eeb61cd804faf20e79312f569f7

diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index c7d9974..0ad6d28 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -121,7 +121,7 @@ ContentInfo::ContentInfo( SfxItemPool& rPool ) :
 
 // the real Copy constructor is nonsens, since I have to work with another Pool!
 ContentInfo::ContentInfo( const ContentInfo& rCopyFrom, SfxItemPool& rPoolToUse ) :
-    aText(rCopyFrom.aText),
+    maText(rCopyFrom.maText),
     aStyle(rCopyFrom.aStyle),
     eFamily(rCopyFrom.eFamily),
     aParaAttribs(rPoolToUse, EE_PARA_START, EE_CHAR_END)
@@ -151,27 +151,30 @@ ContentInfo::~ContentInfo()
 
 void ContentInfo::NormalizeString( svl::SharedStringPool& rPool )
 {
-    aText = OUString(rPool.intern(aText).getData());
+    maText = rPool.intern(OUString(maText.getData()));
 }
 
 sal_uIntPtr ContentInfo::GetStringID( const svl::SharedStringPool& rPool ) const
 {
-    return rPool.getIdentifier(aText);
+    rtl_uString* p = const_cast<rtl_uString*>(maText.getData());
+    return rPool.getIdentifier(OUString(p));
 }
 
 sal_uIntPtr ContentInfo::GetStringIDIgnoreCase( const svl::SharedStringPool& rPool ) const
 {
-    return rPool.getIdentifierIgnoreCase(aText);
+    rtl_uString* p = const_cast<rtl_uString*>(maText.getData());
+    return rPool.getIdentifierIgnoreCase(OUString(p));
 }
 
 OUString ContentInfo::GetText() const
 {
-    return aText;
+    rtl_uString* p = const_cast<rtl_uString*>(maText.getData());
+    return OUString(p);
 }
 
 void ContentInfo::SetText( const OUString& rStr )
 {
-    aText = rStr;
+    maText = svl::SharedString(rStr.pData, NULL);
 }
 
 const WrongList* ContentInfo::GetWrongList() const
@@ -200,7 +203,7 @@ bool ContentInfo::isWrongListEqual(const ContentInfo& rCompare) const
 void ContentInfo::Dump() const
 {
     cout << "--" << endl;
-    cout << "text: '" << aText << "'" << endl;
+    cout << "text: '" << OUString(maText.getData()) << "'" << endl;
     cout << "style: '" << aStyle << "'" << endl;
 
     XEditAttributesType::const_iterator it = aAttribs.begin(), itEnd = aAttribs.end();
@@ -216,7 +219,7 @@ void ContentInfo::Dump() const
 
 bool ContentInfo::operator==( const ContentInfo& rCompare ) const
 {
-    if( (aText == rCompare.aText) &&
+    if( (maText == rCompare.maText) &&
             (aStyle == rCompare.aStyle ) &&
             (aAttribs.size() == rCompare.aAttribs.size()) &&
             (eFamily == rCompare.eFamily ) &&
diff --git a/editeng/source/editeng/editobj2.hxx b/editeng/source/editeng/editobj2.hxx
index 964c978..d2ac045 100644
--- a/editeng/source/editeng/editobj2.hxx
+++ b/editeng/source/editeng/editobj2.hxx
@@ -24,6 +24,7 @@
 #include <editdoc.hxx>
 
 #include <unotools/fontcvt.hxx>
+#include "svl/sharedstring.hxx"
 
 #include <boost/ptr_container/ptr_vector.hpp>
 #include <boost/noncopyable.hpp>
@@ -128,7 +129,7 @@ public:
     typedef boost::ptr_vector<XEditAttribute> XEditAttributesType;
 
 private:
-    OUString            aText;
+    svl::SharedString maText;
     OUString            aStyle;
 
     XEditAttributesType aAttribs;
diff --git a/include/svl/sharedstring.hxx b/include/svl/sharedstring.hxx
index 062d064..64c024c 100644
--- a/include/svl/sharedstring.hxx
+++ b/include/svl/sharedstring.hxx
@@ -27,6 +27,8 @@ public:
 
     SharedString& operator= ( const SharedString& r );
 
+    bool operator== ( const SharedString& r ) const;
+
     rtl_uString* getData();
     const rtl_uString* getData() const;
 
diff --git a/svl/source/misc/sharedstring.cxx b/svl/source/misc/sharedstring.cxx
index d5b27bd..7286cba 100644
--- a/svl/source/misc/sharedstring.cxx
+++ b/svl/source/misc/sharedstring.cxx
@@ -56,6 +56,23 @@ SharedString& SharedString::operator= ( const SharedString& r )
     return *this;
 }
 
+bool SharedString::operator== ( const SharedString& r ) const
+{
+    // Only compare case sensitive strings.
+    if (mpData)
+    {
+        if (!r.mpData)
+            return false;
+
+        if (mpData->length != r.mpData->length)
+            return false;
+
+        return rtl_ustr_compare_WithLength(mpData->buffer, mpData->length, r.mpData->buffer, r.mpData->length);
+    }
+
+    return !r.mpData;
+}
+
 rtl_uString* SharedString::getData()
 {
     return mpData;
commit c2ba2aeb328dff80ab876c1f66057be6acd19594
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Oct 7 12:31:42 2013 -0400

    Avoid exposing aText; encapsulate it.
    
    Change-Id: I7f6ba0735830b55e35b7e352a5e31fdda47a8dfb

diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index d1e1a6e..c7d9974 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -164,6 +164,16 @@ sal_uIntPtr ContentInfo::GetStringIDIgnoreCase( const svl::SharedStringPool& rPo
     return rPool.getIdentifierIgnoreCase(aText);
 }
 
+OUString ContentInfo::GetText() const
+{
+    return aText;
+}
+
+void ContentInfo::SetText( const OUString& rStr )
+{
+    aText = rStr;
+}
+
 const WrongList* ContentInfo::GetWrongList() const
 {
     return mpWrongs.get();
@@ -1341,7 +1351,7 @@ void EditTextObjectImpl::CreateData( SvStream& rIStream )
 
         // The Text...
         OString aByteString = read_lenPrefixed_uInt8s_ToOString<sal_uInt16>(rIStream);
-        pC->GetText() = OStringToOUString(aByteString, eSrcEncoding);
+        pC->SetText(OStringToOUString(aByteString, eSrcEncoding));
 
         // StyleName and Family...
         pC->GetStyle() = rIStream.ReadUniOrByteString(eSrcEncoding);
@@ -1378,7 +1388,7 @@ void EditTextObjectImpl::CreateData( SvStream& rIStream )
                     sal_Char cEncodedChar = aByteString[nStart];
                     sal_Unicode cChar = OUString(&cEncodedChar, 1,
                         ((SvxCharSetColorItem*)pItem)->GetCharSet()).toChar();
-                    pC->GetText() = pC->GetText().replaceAt(nStart, 1, OUString(cChar));
+                    pC->SetText(pC->GetText().replaceAt(nStart, 1, OUString(cChar)));
                 }
                 else
                 {
@@ -1390,7 +1400,7 @@ void EditTextObjectImpl::CreateData( SvStream& rIStream )
                         // Convert CH_FEATURE to CH_FEATURE_OLD
                         DBG_ASSERT( (sal_uInt8) aByteString[nStart] == CH_FEATURE_OLD, "CreateData: CH_FEATURE expected!" );
                         if ( (sal_uInt8) aByteString[nStart] == CH_FEATURE_OLD )
-                            pC->GetText() = pC->GetText().replaceAt( nStart, 1, OUString(CH_FEATURE) );
+                            pC->SetText(pC->GetText().replaceAt(nStart, 1, OUString(CH_FEATURE)));
                     }
                 }
             }
@@ -1405,7 +1415,7 @@ void EditTextObjectImpl::CreateData( SvStream& rIStream )
             const SvxFontItem& rFontItem = (const SvxFontItem&)pC->GetParaAttribs().Get( EE_CHAR_FONTINFO );
             if ( rFontItem.GetCharSet() == RTL_TEXTENCODING_SYMBOL )
             {
-                pC->GetText() = OStringToOUString(aByteString, RTL_TEXTENCODING_SYMBOL);
+                pC->SetText(OStringToOUString(aByteString, RTL_TEXTENCODING_SYMBOL));
                 bSymbolPara = true;
             }
         }
@@ -1422,7 +1432,7 @@ void EditTextObjectImpl::CreateData( SvStream& rIStream )
                     // Not correctly converted
                     OString aPart(aByteString.copy(rAttr.GetStart(), rAttr.GetEnd()-rAttr.GetStart()));
                     OUString aNew(OStringToOUString(aPart, rFontItem.GetCharSet()));
-                    pC->GetText() = pC->GetText().replaceAt( rAttr.GetStart(), rAttr.GetEnd()-rAttr.GetStart(), aNew );
+                    pC->SetText(pC->GetText().replaceAt(rAttr.GetStart(), rAttr.GetEnd()-rAttr.GetStart(), aNew));
                 }
 
                 // Convert StarMath and StarBats to StarSymbol
@@ -1445,7 +1455,7 @@ void EditTextObjectImpl::CreateData( SvStream& rIStream )
                         DBG_ASSERT( cOld >= 0xF000, "cOld not converted?!" );
                         sal_Unicode cConv = ConvertFontToSubsFontChar( hConv, cOld );
                         if ( cConv )
-                            pC->GetText() = pC->GetText().replaceAt( nChar, 1, OUString(cConv) );
+                            pC->SetText(pC->GetText().replaceAt(nChar, 1, OUString(cConv)));
                     }
 
                     DestroyFontToSubsFontConverter( hConv );
@@ -1479,7 +1489,7 @@ void EditTextObjectImpl::CreateData( SvStream& rIStream )
                         DBG_ASSERT( cOld >= 0xF000, "cOld not converted?!" );
                         sal_Unicode cConv = ConvertFontToSubsFontChar( hConv, cOld );
                         if ( cConv )
-                            pC->GetText() = pC->GetText().replaceAt( nChar, 1, OUString(cConv) );
+                            pC->SetText(pC->GetText().replaceAt(nChar, 1, OUString(cConv)));
                     }
                 }
 
diff --git a/editeng/source/editeng/editobj2.hxx b/editeng/source/editeng/editobj2.hxx
index 20dafe9..964c978 100644
--- a/editeng/source/editeng/editobj2.hxx
+++ b/editeng/source/editeng/editobj2.hxx
@@ -145,16 +145,16 @@ public:
     void NormalizeString( svl::SharedStringPool& rPool );
     sal_uIntPtr GetStringID( const svl::SharedStringPool& rPool ) const;
     sal_uIntPtr GetStringIDIgnoreCase( const svl::SharedStringPool& rPool ) const;
+    OUString GetText() const;
+    void SetText( const OUString& rStr );
 
     const XEditAttributesType& GetAttribs() const { return aAttribs; }
     XEditAttributesType& GetAttribs() { return aAttribs; }
 
-    const OUString&     GetText()           const   { return aText; }
     const OUString&     GetStyle()          const   { return aStyle; }
     const SfxItemSet&   GetParaAttribs()    const   { return aParaAttribs; }
     SfxStyleFamily      GetFamily()         const   { return eFamily; }
 
-    OUString&           GetText()           { return aText; }
     OUString&           GetStyle()          { return aStyle; }
     SfxItemSet&         GetParaAttribs()    { return aParaAttribs; }
     SfxStyleFamily&     GetFamily()         { return eFamily; }
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index ada5a54..fa8110b 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -1084,7 +1084,7 @@ EditTextObject* ImpEditEngine::CreateTextObject( EditSelection aSel, SfxItemPool
         }
 
         // The Text...
-        pC->GetText() = pNode->Copy( nStartPos, nEndPos-nStartPos );
+        pC->SetText(pNode->Copy(nStartPos, nEndPos-nStartPos));
 
         // and the Attribute...
         sal_uInt16 nAttr = 0;


More information about the Libreoffice-commits mailing list