diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-10-03 10:55:48 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-10-04 19:15:24 -0400 |
commit | dc1314d96257845139015ee13edc04af470c18f6 (patch) | |
tree | 2f7f3773b245b332e3b9e0350e99c7fcd47eeaf9 /sc | |
parent | bc1c67dc8296cff59759ee4abd5ab0cf0632af85 (diff) |
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
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/document.hxx | 3 | ||||
-rw-r--r-- | sc/source/core/data/column3.cxx | 53 | ||||
-rw-r--r-- | sc/source/core/data/documen2.cxx | 9 | ||||
-rw-r--r-- | sc/source/core/data/documentimport.cxx | 9 |
4 files changed, 35 insertions, 39 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 73d7c1c21582..6828d4d2fa1f 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 90f0f2bf8b81..f5eccae3daea 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 500bc1bfac62..9f640903d7a4 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 9998e83cc97d..4c9157d5a52b 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); } |