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

Kohei Yoshida kohei.yoshida at collabora.com
Thu Oct 3 08:09:25 PDT 2013


 sc/inc/document.hxx                    |    3 +
 sc/source/core/data/column3.cxx        |   53 ++++++++++-----------------------
 sc/source/core/data/documen2.cxx       |    9 ++++-
 sc/source/core/data/documentimport.cxx |    9 ++++-
 4 files changed, 35 insertions(+), 39 deletions(-)

New commits:
commit 196afba99063ef477e6a4aadfd105041b9c8803f
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Thu Oct 3 10:55:48 2013 -0400

    Normalize all string objects that are cell contents before they get stored.
    
    Hopefully I've covered all entry points. There may be more lurking in some
    dark corneres...
    
    Change-Id: I62e655cc579aad08fa64b5d58e739c55425cd216

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 73d7c1c..6828d4d 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -234,6 +234,7 @@ friend class ScDocRowHeightUpdater;
 friend class ScColumnTextWidthIterator;
 friend class ScFormulaCell;
 friend class ScTable;
+friend class ScColumn;
 friend struct ScRefCellValue;
 friend class ScDocumentImport;
 friend class sc::ColumnSpanSet;
@@ -2065,6 +2066,8 @@ private: // CLOOK-Impl-methods
 
     ScRefCellValue GetRefCellValue( const ScAddress& rPos );
 
+    svl::StringPool& GetCellStringPool();
+
     std::map< SCTAB, ScSortParam > mSheetSortParams;
 
 };
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 90f0f2b..f5eccae 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -57,6 +57,7 @@
 #include <svl/zforlist.hxx>
 #include <svl/zformat.hxx>
 #include <svl/broadcast.hxx>
+#include "svl/stringpool.hxx"
 #include "editeng/editstat.hxx"
 
 #include <cstdio>
@@ -1601,6 +1602,7 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString,
 
 void ScColumn::SetEditText( SCROW nRow, EditTextObject* pEditText )
 {
+    pEditText->NormalizeString(pDocument->GetCellStringPool());
     sc::CellStoreType::iterator it = GetPositionToInsert(nRow);
     maCells.set(it, nRow, pEditText);
     maCellTextAttrs.set(nRow, sc::CellTextAttr());
@@ -1611,6 +1613,7 @@ void ScColumn::SetEditText( SCROW nRow, EditTextObject* pEditText )
 
 void ScColumn::SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, EditTextObject* pEditText )
 {
+    pEditText->NormalizeString(pDocument->GetCellStringPool());
     rBlockPos.miCellPos = GetPositionToInsert(rBlockPos.miCellPos, nRow);
     rBlockPos.miCellPos = maCells.set(rBlockPos.miCellPos, nRow, pEditText);
     rBlockPos.miCellTextAttrPos = maCellTextAttrs.set(
@@ -1632,24 +1635,9 @@ void ScColumn::SetEditText( sc::ColumnBlockPosition& rBlockPos, SCROW nRow, cons
     // Sadly there is no other way to change the Pool than to
     // "spool" the Object through a corresponding Engine
     EditEngine& rEngine = pDocument->GetEditEngine();
-    if (!rEditText.HasOnlineSpellErrors())
-    {
-        rEngine.SetText(rEditText);
-        SetEditText(rBlockPos, nRow, rEngine.CreateTextObject());
-        return;
-    }
-
-    sal_uLong nControl = rEngine.GetControlWord();
-    const sal_uLong nSpellControl = EE_CNTRL_ONLINESPELLING | EE_CNTRL_ALLOWBIGOBJS;
-    bool bNewControl = (nControl & nSpellControl) != nSpellControl;
-    if (bNewControl)
-        rEngine.SetControlWord(nControl | nSpellControl);
     rEngine.SetText(rEditText);
-    EditTextObject* pData = rEngine.CreateTextObject();
-    if (bNewControl)
-        rEngine.SetControlWord(nControl);
-
-    SetEditText(rBlockPos, nRow, pData);
+    SetEditText(rBlockPos, nRow, rEngine.CreateTextObject());
+    return;
 }
 
 void ScColumn::SetEditText( SCROW nRow, const EditTextObject& rEditText, const SfxItemPool* pEditPool )
@@ -1664,24 +1652,9 @@ void ScColumn::SetEditText( SCROW nRow, const EditTextObject& rEditText, const S
     // Sadly there is no other way to change the Pool than to
     // "spool" the Object through a corresponding Engine
     EditEngine& rEngine = pDocument->GetEditEngine();
-    if (!rEditText.HasOnlineSpellErrors())
-    {
-        rEngine.SetText(rEditText);
-        SetEditText(nRow, rEngine.CreateTextObject());
-        return;
-    }
-
-    sal_uLong nControl = rEngine.GetControlWord();
-    const sal_uLong nSpellControl = EE_CNTRL_ONLINESPELLING | EE_CNTRL_ALLOWBIGOBJS;
-    bool bNewControl = (nControl & nSpellControl) != nSpellControl;
-    if (bNewControl)
-        rEngine.SetControlWord(nControl | nSpellControl);
     rEngine.SetText(rEditText);
-    EditTextObject* pData = rEngine.CreateTextObject();
-    if (bNewControl)
-        rEngine.SetControlWord(nControl);
-
-    SetEditText(nRow, pData);
+    SetEditText(nRow, rEngine.CreateTextObject());
+    return;
 }
 
 void ScColumn::SetFormula( SCROW nRow, const ScTokenArray& rArray, formula::FormulaGrammar::Grammar eGram )
@@ -2157,8 +2130,12 @@ void ScColumn::SetRawString( SCROW nRow, const OUString& rStr, bool bBroadcast )
     if (!ValidRow(nRow))
         return;
 
+    rtl_uString* pStr = pDocument->GetCellStringPool().intern(rStr);
+    if (!pStr)
+        return;
+
     sc::CellStoreType::iterator it = GetPositionToInsert(nRow);
-    maCells.set(it, nRow, rStr);
+    maCells.set(it, nRow, OUString(pStr));
     maCellTextAttrs.set(nRow, sc::CellTextAttr());
     CellStorageModified();
 
@@ -2172,8 +2149,12 @@ void ScColumn::SetRawString(
     if (!ValidRow(nRow))
         return;
 
+    rtl_uString* pStr = pDocument->GetCellStringPool().intern(rStr);
+    if (!pStr)
+        return;
+
     rBlockPos.miCellPos = GetPositionToInsert(rBlockPos.miCellPos, nRow);
-    rBlockPos.miCellPos = maCells.set(rBlockPos.miCellPos, nRow, rStr);
+    rBlockPos.miCellPos = maCells.set(rBlockPos.miCellPos, nRow, OUString(pStr));
     rBlockPos.miCellTextAttrPos = maCellTextAttrs.set(
         rBlockPos.miCellTextAttrPos, nRow, sc::CellTextAttr());
     CellStorageModified();
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 54c3577..deec664 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -118,8 +118,8 @@ private:
 
 // STATIC DATA -----------------------------------------------------------
 
-ScDocument::ScDocument( ScDocumentMode  eMode,
-                        SfxObjectShell* pDocShell ) :
+ScDocument::ScDocument( ScDocumentMode eMode, SfxObjectShell* pDocShell ) :
+        mpCellStringPool(new svl::StringPool(ScGlobal::pCharClass)),
         mpUndoManager( NULL ),
         pEditEngine( NULL ),
         pNoteEngine( NULL ),
@@ -600,6 +600,11 @@ ScRefCellValue ScDocument::GetRefCellValue( const ScAddress& rPos )
     return maTabs[rPos.Tab()]->GetRefCellValue(rPos.Col(), rPos.Row());
 }
 
+svl::StringPool& ScDocument::GetCellStringPool()
+{
+    return *mpCellStringPool;
+}
+
 bool ScDocument::GetPrintArea( SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow,
                                 bool bNotes ) const
 {
diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx
index 9998e83..4c9157d 100644
--- a/sc/source/core/data/documentimport.cxx
+++ b/sc/source/core/data/documentimport.cxx
@@ -17,6 +17,8 @@
 #include "mtvelements.hxx"
 #include "tokenarray.hxx"
 
+#include "svl/stringpool.hxx"
+
 struct ScDocumentImportImpl
 {
     ScDocument& mrDoc;
@@ -148,8 +150,12 @@ void ScDocumentImport::setStringCell(const ScAddress& rPos, const OUString& rStr
     if (!pBlockPos)
         return;
 
+    rtl_uString* pStr = mpImpl->mrDoc.GetCellStringPool().intern(rStr);
+    if (!pStr)
+        return;
+
     sc::CellStoreType& rCells = pTab->aCol[rPos.Col()].maCells;
-    pBlockPos->miCellPos = rCells.set(pBlockPos->miCellPos, rPos.Row(), rStr);
+    pBlockPos->miCellPos = rCells.set(pBlockPos->miCellPos, rPos.Row(), OUString(pStr));
 }
 
 void ScDocumentImport::setEditCell(const ScAddress& rPos, EditTextObject* pEditText)
@@ -164,6 +170,7 @@ void ScDocumentImport::setEditCell(const ScAddress& rPos, EditTextObject* pEditT
     if (!pBlockPos)
         return;
 
+    pEditText->NormalizeString(mpImpl->mrDoc.GetCellStringPool());
     sc::CellStoreType& rCells = pTab->aCol[rPos.Col()].maCells;
     pBlockPos->miCellPos = rCells.set(pBlockPos->miCellPos, rPos.Row(), pEditText);
 }


More information about the Libreoffice-commits mailing list