summaryrefslogtreecommitdiff
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:50:22 -0500
commit808fd5fbd8868dfd95c8a38676815798fa2b79c4 (patch)
tree5bec9519ec53ec0a0f68688a3e156b4bf8eb71a2
parent6e91763769a562b88882a4c2a94b1367c6ed4866 (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
-rw-r--r--sc/Library_sc.mk1
-rw-r--r--sc/inc/celltextattr.hxx30
-rw-r--r--sc/inc/clipcontext.hxx5
-rw-r--r--sc/inc/column.hxx4
-rw-r--r--sc/inc/mtvelements.hxx10
-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
12 files changed, 98 insertions, 24 deletions
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index bddec8e04ba6..d8cf1bc62cad 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -102,6 +102,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/core/data/autonamecache \
sc/source/core/data/bcaslot \
sc/source/core/data/bigrange \
+ sc/source/core/data/celltextattr \
sc/source/core/data/cellvalue \
sc/source/core/data/cellvalues \
sc/source/core/data/clipcontext \
diff --git a/sc/inc/celltextattr.hxx b/sc/inc/celltextattr.hxx
new file mode 100644
index 000000000000..9e4675d0e3c3
--- /dev/null
+++ b/sc/inc/celltextattr.hxx
@@ -0,0 +1,30 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_SC_CELLTEXTATTR_HXX
+#define INCLUDED_SC_CELLTEXTATTR_HXX
+
+#include <sal/types.h>
+
+namespace sc {
+
+struct CellTextAttr
+{
+ sal_uInt16 mnTextWidth;
+ sal_uInt8 mnScriptType;
+
+ CellTextAttr();
+ CellTextAttr(const CellTextAttr& r);
+};
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/clipcontext.hxx b/sc/inc/clipcontext.hxx
index aa783e4aa203..78481992dc40 100644
--- a/sc/inc/clipcontext.hxx
+++ b/sc/inc/clipcontext.hxx
@@ -12,6 +12,7 @@
#include "address.hxx"
#include "cellvalue.hxx"
+#include <celltextattr.hxx>
#include <vector>
#include <boost/unordered_map.hpp>
@@ -57,6 +58,7 @@ class CopyFromClipContext : public ClipContextBase
InsertDeleteFlags mnDeleteFlag;
std::vector<ScCellValue> maSingleCells;
+ std::vector<sc::CellTextAttr> maSingleCellAttrs;
std::vector<const ScPatternAttr*> maSinglePatterns;
std::vector<const ScPostIt*> maSingleNotes;
@@ -107,8 +109,11 @@ public:
void setSingleCellColumnSize( size_t nSize );
ScCellValue& getSingleCell( size_t nColOffset );
+ sc::CellTextAttr& getSingleCellAttr( size_t nColOffset );
+
void setSingleCell( const ScAddress& rSrcPos, const ScColumn& rSrcCol );
+
const ScPatternAttr* getSingleCellPattern( size_t nColOffset ) const;
void setSingleCellPattern( size_t nColOffset, const ScPatternAttr* pAttr );
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 1d7078f526a4..7eaf60c9e24c 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -195,6 +195,7 @@ public:
ScRefCellValue GetCellValue( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow ) const;
ScRefCellValue GetCellValue( const sc::CellStoreType::const_iterator& itPos, size_t nOffset ) const;
+ const sc::CellTextAttr* GetCellTextAttr( SCROW nRow ) const;
const sc::CellTextAttr* GetCellTextAttr( sc::ColumnBlockConstPosition& rBlockPos, SCROW nRow ) const;
void Delete( SCROW nRow );
@@ -337,7 +338,8 @@ public:
bool HasFormulaCell( SCROW nRow1, SCROW nRow2 ) const;
void 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 );
svl::SharedString GetSharedString( SCROW nRow ) const;
diff --git a/sc/inc/mtvelements.hxx b/sc/inc/mtvelements.hxx
index 0e4093ed4008..1d303ceea72d 100644
--- a/sc/inc/mtvelements.hxx
+++ b/sc/inc/mtvelements.hxx
@@ -17,6 +17,7 @@
#include <editeng/editobj.hxx>
#include "calcmacros.hxx"
#include "postit.hxx"
+#include <celltextattr.hxx>
#include <osl/mutex.hxx>
#if DEBUG_COLUMN_STORAGE
@@ -38,15 +39,6 @@ struct ScRefCellValue;
namespace sc {
-struct CellTextAttr
-{
- sal_uInt16 mnTextWidth;
- sal_uInt8 mnScriptType;
-
- CellTextAttr();
- CellTextAttr(const CellTextAttr& r);
-};
-
/// Custom element type IDs for multi_type_vector.
const mdds::mtv::element_t element_type_broadcaster = mdds::mtv::element_type_user_start;
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 e5b67f82ebfc..549a433f6438 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 6b0412bfe8c0..c4ca9add700d 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 bdf1a6aa2b09..f3789c7b3262 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);