[Libreoffice-commits] core.git: sc/inc sc/Library_sc.mk sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Wed Dec 10 19:51:36 PST 2014
sc/Library_sc.mk | 1 +
sc/inc/celltextattr.hxx | 30 ++++++++++++++++++++++++++++++
sc/inc/clipcontext.hxx | 5 +++++
sc/inc/column.hxx | 4 +++-
sc/inc/mtvelements.hxx | 10 +---------
sc/source/core/data/celltextattr.cxx | 25 +++++++++++++++++++++++++
sc/source/core/data/clipcontext.cxx | 15 +++++++++++++++
sc/source/core/data/column.cxx | 7 +++++++
sc/source/core/data/column4.cxx | 10 ++++++----
sc/source/core/data/document10.cxx | 5 ++++-
sc/source/core/data/mtvelements.cxx | 8 --------
sc/source/core/data/table4.cxx | 2 +-
12 files changed, 98 insertions(+), 24 deletions(-)
New commits:
commit 808fd5fbd8868dfd95c8a38676815798fa2b79c4
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Wed Dec 10 22:47:05 2014 -0500
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
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index bddec8e..d8cf1bc 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 0000000..9e4675d
--- /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 aa783e4..7848199 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 1d7078f..7eaf60c 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 0e4093e..1d303ce 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 0000000..5542813
--- /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 8300327..654bad7 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 e5b67f8..549a433 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 6b0412b..c4ca9ad 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 0ddfbd1..06ab0b9 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 3a74b8a..3e0a17f 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 bdf1a6a..f3789c7 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);
More information about the Libreoffice-commits
mailing list