summaryrefslogtreecommitdiff
path: root/sc/source/core/data
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-12-10 22:47:05 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-12-10 22:51:17 -0500
commita597f75d1452cc89f5ce31ea82f38b19cd71f7e7 (patch)
treeb6d886bc28594355eca7e9d15f29430bb628c655 /sc/source/core/data
parent3d541065fe235de6f1dc3e673082e9a8cda9b328 (diff)
Deteremine the script type of source cell during paste replication.
Doing this ahead of time eliminates the need to update script types of all replicated cells after the paste. This makes significant performance impact. Change-Id: Ic4f7d7b2fe152bd5640ddb1dae01cc2ed757657e (cherry picked from commit 808fd5fbd8868dfd95c8a38676815798fa2b79c4)
Diffstat (limited to 'sc/source/core/data')
-rw-r--r--sc/source/core/data/celltextattr.cxx25
-rw-r--r--sc/source/core/data/clipcontext.cxx15
-rw-r--r--sc/source/core/data/column.cxx7
-rw-r--r--sc/source/core/data/column4.cxx10
-rw-r--r--sc/source/core/data/document10.cxx5
-rw-r--r--sc/source/core/data/mtvelements.cxx8
-rw-r--r--sc/source/core/data/table4.cxx2
7 files changed, 58 insertions, 14 deletions
diff --git a/sc/source/core/data/celltextattr.cxx b/sc/source/core/data/celltextattr.cxx
new file mode 100644
index 000000000000..5542813c7dca
--- /dev/null
+++ b/sc/source/core/data/celltextattr.cxx
@@ -0,0 +1,25 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <celltextattr.hxx>
+#include <globalnames.hxx>
+
+namespace sc {
+
+CellTextAttr::CellTextAttr() :
+ mnTextWidth(TEXTWIDTH_DIRTY),
+ mnScriptType(SC_SCRIPTTYPE_UNKNOWN) {}
+
+CellTextAttr::CellTextAttr(const CellTextAttr& r) :
+ mnTextWidth(r.mnTextWidth),
+ mnScriptType(r.mnScriptType) {}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/clipcontext.cxx b/sc/source/core/data/clipcontext.cxx
index 83003273b62b..654bad7e1e9d 100644
--- a/sc/source/core/data/clipcontext.cxx
+++ b/sc/source/core/data/clipcontext.cxx
@@ -113,6 +113,7 @@ InsertDeleteFlags CopyFromClipContext::getDeleteFlag() const
void CopyFromClipContext::setSingleCellColumnSize( size_t nSize )
{
maSingleCells.resize(nSize);
+ maSingleCellAttrs.resize(nSize);
maSinglePatterns.resize(nSize, NULL);
maSingleNotes.resize(nSize, NULL);
}
@@ -123,11 +124,25 @@ ScCellValue& CopyFromClipContext::getSingleCell( size_t nColOffset )
return maSingleCells[nColOffset];
}
+sc::CellTextAttr& CopyFromClipContext::getSingleCellAttr( size_t nColOffset )
+{
+ assert(nColOffset < maSingleCellAttrs.size());
+ return maSingleCellAttrs[nColOffset];
+}
+
void CopyFromClipContext::setSingleCell( const ScAddress& rSrcPos, const ScColumn& rSrcCol )
{
SCCOL nColOffset = rSrcPos.Col() - mpClipDoc->GetClipParam().getWholeRange().aStart.Col();
ScCellValue& rSrcCell = getSingleCell(nColOffset);
+ const sc::CellTextAttr* pAttr = rSrcCol.GetCellTextAttr(rSrcPos.Row());
+
+ if (pAttr)
+ {
+ sc::CellTextAttr& rAttr = getSingleCellAttr(nColOffset);
+ rAttr = *pAttr;
+ }
+
if (mbAsLink)
{
ScSingleRefData aRef;
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 5185c3aa450f..b60fcc228114 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -763,6 +763,13 @@ ScRefCellValue ScColumn::GetCellValue( const sc::CellStoreType::const_iterator&
return aVal;
}
+const sc::CellTextAttr* ScColumn::GetCellTextAttr( SCROW nRow ) const
+{
+ sc::ColumnBlockConstPosition aBlockPos;
+ aBlockPos.miCellTextAttrPos = maCellTextAttrs.begin();
+ return GetCellTextAttr(aBlockPos, nRow);
+}
+
const sc::CellTextAttr* ScColumn::GetCellTextAttr( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow ) const
{
sc::CellTextAttrStoreType::const_position_type aPos = maCellTextAttrs.position(rBlockPos.miCellTextAttrPos, nRow);
diff --git a/sc/source/core/data/column4.cxx b/sc/source/core/data/column4.cxx
index c4be8c8339ef..23862965ad59 100644
--- a/sc/source/core/data/column4.cxx
+++ b/sc/source/core/data/column4.cxx
@@ -152,6 +152,7 @@ void ScColumn::CopyOneCellFromClip( sc::CopyFromClipContext& rCxt, SCROW nRow1,
bool bSameDocPool = (rCxt.getClipDoc()->GetPool() == pDocument->GetPool());
ScCellValue& rSrcCell = rCxt.getSingleCell(nColOffset);
+ sc::CellTextAttr& rSrcAttr = rCxt.getSingleCellAttr(nColOffset);
InsertDeleteFlags nFlags = rCxt.getInsertFlag();
@@ -167,7 +168,7 @@ void ScColumn::CopyOneCellFromClip( sc::CopyFromClipContext& rCxt, SCROW nRow1,
if ((nFlags & IDF_CONTENTS) != IDF_NONE)
{
- std::vector<sc::CellTextAttr> aTextAttrs(nDestSize);
+ std::vector<sc::CellTextAttr> aTextAttrs(nDestSize, rSrcAttr);
switch (rSrcCell.meType)
{
@@ -217,7 +218,7 @@ void ScColumn::CopyOneCellFromClip( sc::CopyFromClipContext& rCxt, SCROW nRow1,
std::vector<sc::RowSpan> aRanges;
aRanges.reserve(1);
aRanges.push_back(sc::RowSpan(nRow1, nRow2));
- CloneFormulaCell(*rSrcCell.mpFormula, aRanges, NULL);
+ CloneFormulaCell(*rSrcCell.mpFormula, rSrcAttr, aRanges, NULL);
}
break;
default:
@@ -478,7 +479,8 @@ void ScColumn::DeleteRanges( const std::vector<sc::RowSpan>& rRanges, InsertDele
}
void ScColumn::CloneFormulaCell(
- const ScFormulaCell& rSrc, const std::vector<sc::RowSpan>& rRanges, sc::StartListeningContext* pCxt )
+ const ScFormulaCell& rSrc, const sc::CellTextAttr& rAttr,
+ const std::vector<sc::RowSpan>& rRanges, sc::StartListeningContext* pCxt )
{
sc::CellStoreType::iterator itPos = maCells.begin();
sc::CellTextAttrStoreType::iterator itAttrPos = maCellTextAttrs.begin();
@@ -543,7 +545,7 @@ void ScColumn::CloneFormulaCell(
pCell = sc::formula_block::at(*aPosObj.first->data, aPosObj.second);
JoinNewFormulaCell(aPosObj, *pCell);
- std::vector<sc::CellTextAttr> aTextAttrs(nLen);
+ std::vector<sc::CellTextAttr> aTextAttrs(nLen, rAttr);
itAttrPos = maCellTextAttrs.set(itAttrPos, nRow1, aTextAttrs.begin(), aTextAttrs.end());
}
diff --git a/sc/source/core/data/document10.cxx b/sc/source/core/data/document10.cxx
index 0ddfbd192ef9..06ab0b98bf28 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -105,7 +105,10 @@ bool ScDocument::CopyOneCellFromClip(
if ((rCxt.getInsertFlag() & (IDF_NOTE | IDF_ADDNOTES)) != IDF_NONE)
rCxt.setSingleCellNote(nColOffset, pClipDoc->GetNote(aSrcPos));
- rCxt.setSingleCell(aSrcPos, pSrcTab->aCol[aSrcPos.Col()]);
+ ScColumn& rSrcCol = pSrcTab->aCol[aSrcPos.Col()];
+ // Determine the script type of the copied single cell.
+ rSrcCol.UpdateScriptTypes(aSrcPos.Row(), aSrcPos.Row());
+ rCxt.setSingleCell(aSrcPos, rSrcCol);
}
// All good. Proceed with the pasting.
diff --git a/sc/source/core/data/mtvelements.cxx b/sc/source/core/data/mtvelements.cxx
index 3a74b8ab4e37..3e0a17f89cdb 100644
--- a/sc/source/core/data/mtvelements.cxx
+++ b/sc/source/core/data/mtvelements.cxx
@@ -14,14 +14,6 @@
namespace sc {
-CellTextAttr::CellTextAttr() :
- mnTextWidth(TEXTWIDTH_DIRTY),
- mnScriptType(SC_SCRIPTTYPE_UNKNOWN) {}
-
-CellTextAttr::CellTextAttr(const CellTextAttr& r) :
- mnTextWidth(r.mnTextWidth),
- mnScriptType(r.mnScriptType) {}
-
ColumnBlockPositionSet::ColumnBlockPositionSet(ScDocument& rDoc) : mrDoc(rDoc) {}
ColumnBlockPosition* ColumnBlockPositionSet::getBlockPosition(SCTAB nTab, SCCOL nCol)
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index e1881ba0da37..5ceb75850035 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -1171,7 +1171,7 @@ void ScTable::FillFormulaVertical(
return;
aCol[nCol].DeleteRanges(aSpans, IDF_CONTENTS, false);
- aCol[nCol].CloneFormulaCell(rSrcCell, aSpans, NULL);
+ aCol[nCol].CloneFormulaCell(rSrcCell, sc::CellTextAttr(), aSpans, NULL);
boost::shared_ptr<sc::ColumnBlockPositionSet> pSet(new sc::ColumnBlockPositionSet(*pDocument));
sc::StartListeningContext aStartCxt(*pDocument, pSet);