[Libreoffice-commits] core.git: Branch 'feature/perfwork' - 2 commits - sc/inc sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Wed Oct 1 17:41:03 PDT 2014
sc/inc/formulacell.hxx | 3 ++
sc/source/core/data/column.cxx | 36 +++++++++++++++++++++++++++-
sc/source/core/data/column3.cxx | 41 +++++++++++++++++++++++++++++++--
sc/source/core/data/documentimport.cxx | 41 ++++++++++++++++++++++++++++-----
sc/source/core/data/formulacell.cxx | 25 ++++++++++++++++----
5 files changed, 133 insertions(+), 13 deletions(-)
New commits:
commit 3f96f44be8048c112766819f990c3bb18366c874
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Wed Oct 1 20:34:36 2014 -0400
Be sure to copy the cell text attributes values to and from clip.
Otherwise we'd have to unnecessarily re-calculate the script types again
which is not cheap...
Change-Id: Ie589fb4a7e5ec9b5ef646dabea4e6bd0c0aca560
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 939069b..656d53c 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -983,6 +983,31 @@ public:
}
};
+class CopyTextAttrToClipHandler
+{
+ sc::CellTextAttrStoreType& mrDestAttrs;
+ sc::CellTextAttrStoreType::iterator miPos;
+
+public:
+ CopyTextAttrToClipHandler( sc::CellTextAttrStoreType& rAttrs ) :
+ mrDestAttrs(rAttrs), miPos(mrDestAttrs.begin()) {}
+
+ void operator() ( const sc::CellTextAttrStoreType::value_type& aNode, size_t nOffset, size_t nDataSize )
+ {
+ if (aNode.type != sc::element_type_celltextattr)
+ return;
+
+ sc::celltextattr_block::const_iterator it = sc::celltextattr_block::begin(*aNode.data);
+ std::advance(it, nOffset);
+ sc::celltextattr_block::const_iterator itEnd = it;
+ std::advance(itEnd, nDataSize);
+
+ size_t nPos = aNode.position + nOffset;
+ miPos = mrDestAttrs.set(miPos, nPos, it, itEnd);
+ }
+};
+
+
}
void ScColumn::CopyToClip(
@@ -991,8 +1016,15 @@ void ScColumn::CopyToClip(
pAttrArray->CopyArea( nRow1, nRow2, 0, *rColumn.pAttrArray,
rCxt.isKeepScenarioFlags() ? (SC_MF_ALL & ~SC_MF_SCENARIO) : SC_MF_ALL );
- CopyToClipHandler aFunc(*this, rColumn, rCxt.getBlockPosition(rColumn.nTab, rColumn.nCol), rCxt.isCloneNotes());
- sc::ParseBlock(maCells.begin(), maCells, aFunc, nRow1, nRow2);
+ {
+ CopyToClipHandler aFunc(*this, rColumn, rCxt.getBlockPosition(rColumn.nTab, rColumn.nCol), rCxt.isCloneNotes());
+ sc::ParseBlock(maCells.begin(), maCells, aFunc, nRow1, nRow2);
+ }
+
+ {
+ CopyTextAttrToClipHandler aFunc(rColumn.maCellTextAttrs);
+ sc::ParseBlock(maCellTextAttrs.begin(), maCellTextAttrs, aFunc, nRow1, nRow2);
+ }
rColumn.CellStorageModified();
}
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 5723b73..225276a 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -950,6 +950,31 @@ public:
}
};
+class CopyTextAttrsFromClipHandler
+{
+ sc::CellTextAttrStoreType& mrAttrs;
+ sc::CellTextAttrStoreType::iterator miPos;
+ size_t mnDelta;
+
+public:
+ CopyTextAttrsFromClipHandler( sc::CellTextAttrStoreType& rAttrs, size_t nDelta ) :
+ mrAttrs(rAttrs), miPos(mrAttrs.begin()), mnDelta(nDelta) {}
+
+ void operator() ( const sc::CellTextAttrStoreType::value_type& aNode, size_t nOffset, size_t nDataSize )
+ {
+ if (aNode.type != sc::element_type_celltextattr)
+ return;
+
+ sc::celltextattr_block::const_iterator it = sc::celltextattr_block::begin(*aNode.data);
+ std::advance(it, nOffset);
+ sc::celltextattr_block::const_iterator itEnd = it;
+ std::advance(itEnd, nDataSize);
+
+ size_t nPos = aNode.position + nOffset + mnDelta;
+ miPos = mrAttrs.set(miPos, nPos, it, itEnd);
+ }
+};
+
}
// rColumn = source
@@ -1001,6 +1026,10 @@ void ScColumn::CopyFromClip(
SetFormulaCell(nDestRow, new ScFormulaCell(pDocument, aDestPos, aArr));
}
+ // Don't forget to copy the cell text attributes.
+ CopyTextAttrsFromClipHandler aFunc(maCellTextAttrs, nDy);
+ sc::ParseBlock(rColumn.maCellTextAttrs.begin(), rColumn.maCellTextAttrs, aFunc, nRow1-nDy, nRow2-nDy);
+
return;
}
@@ -1011,8 +1040,16 @@ void ScColumn::CopyFromClip(
// nRow1 to nRow2 is for destination (this) column. Subtract nDy to get the source range.
// Copy all cells in the source column (rColumn) from nRow1-nDy to nRow2-nDy to this column.
- CopyCellsFromClipHandler aFunc(rCxt, rColumn, *this, nTab, nCol, nDy, pSharedStringPool);
- sc::ParseBlock(rColumn.maCells.begin(), rColumn.maCells, aFunc, nRow1-nDy, nRow2-nDy);
+ {
+ CopyCellsFromClipHandler aFunc(rCxt, rColumn, *this, nTab, nCol, nDy, pSharedStringPool);
+ sc::ParseBlock(rColumn.maCells.begin(), rColumn.maCells, aFunc, nRow1-nDy, nRow2-nDy);
+ }
+
+ {
+ // Don't forget to copy the cell text attributes.
+ CopyTextAttrsFromClipHandler aFunc(maCellTextAttrs, nDy);
+ sc::ParseBlock(rColumn.maCellTextAttrs.begin(), rColumn.maCellTextAttrs, aFunc, nRow1-nDy, nRow2-nDy);
+ }
}
void ScColumn::MixMarked(
commit 673534adcbd32bde262875d0af29a9f42e5949ed
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Wed Oct 1 15:18:17 2014 -0400
Set script type to latin for formula cells with numeric results.
But only when the column contains only standard number format types.
Change-Id: I83982d2e87f9776cf03754beaf183e35675be992
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx
index b765ff0..502fbb8 100644
--- a/sc/inc/formulacell.hxx
+++ b/sc/inc/formulacell.hxx
@@ -289,6 +289,7 @@ public:
bool IsEmptyDisplayedAsString();
bool IsValue(); // also true if formula::svEmptyCell
bool IsValueNoError();
+ bool IsValueNoError() const;
bool IsHybridValueCell(); // for cells after import to deal with inherited number formats
double GetValue();
svl::SharedString GetString();
@@ -370,6 +371,8 @@ public:
/** Determines whether or not the result string contains more than one paragraph */
bool IsMultilineResult();
+ bool NeedsInterpret() const;
+
void MaybeInterpret();
/**
diff --git a/sc/source/core/data/documentimport.cxx b/sc/source/core/data/documentimport.cxx
index 29f912f..625b92f 100644
--- a/sc/source/core/data/documentimport.cxx
+++ b/sc/source/core/data/documentimport.cxx
@@ -513,12 +513,43 @@ public:
// Fill with default values for non-empty cell segments.
sc::CellTextAttr aDefault;
- if (node.type == sc::element_type_numeric)
+ switch (node.type)
{
- aDefault.mnScriptType = mpImpl->mnScriptNumeric;
- const ColAttr* p = mrDocImpl.getColAttr(mnTab, mnCol);
- if (p && p->mbLatinNumFmtOnly)
- aDefault.mnScriptType = SCRIPTTYPE_LATIN;
+ case sc::element_type_numeric:
+ {
+ aDefault.mnScriptType = mpImpl->mnScriptNumeric;
+ const ColAttr* p = mrDocImpl.getColAttr(mnTab, mnCol);
+ if (p && p->mbLatinNumFmtOnly)
+ aDefault.mnScriptType = SCRIPTTYPE_LATIN;
+ }
+ break;
+ case sc::element_type_formula:
+ {
+ const ColAttr* p = mrDocImpl.getColAttr(mnTab, mnCol);
+ if (p && p->mbLatinNumFmtOnly)
+ {
+ // We can assume latin script type if the block only
+ // contains formula cells with numeric results.
+ ScFormulaCell** pp = &sc::formula_block::at(*node.data, 0);
+ ScFormulaCell** ppEnd = pp + node.size;
+ bool bNumResOnly = true;
+ for (; pp != ppEnd; ++pp)
+ {
+ const ScFormulaCell& rCell = **pp;
+ if (!rCell.IsValueNoError())
+ {
+ bNumResOnly = false;
+ break;
+ }
+ }
+
+ if (bNumResOnly)
+ aDefault.mnScriptType = SCRIPTTYPE_LATIN;
+ }
+ }
+ break;
+ default:
+ ;
}
std::vector<sc::CellTextAttr> aDefaults(node.size, aDefault);
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index d10b9d4..f809cc2 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -2218,15 +2218,20 @@ bool ScFormulaCell::IsMultilineResult()
return false;
}
-void ScFormulaCell::MaybeInterpret()
+bool ScFormulaCell::NeedsInterpret() const
{
if (mxGroup && mxGroup->meKernelState == sc::OpenCLKernelCompilationScheduled)
- return;
+ return false;
if (!IsDirtyOrInTableOpDirty())
- return;
+ return false;
- if (pDocument->GetAutoCalc() || (cMatrixFlag != MM_NONE))
+ return (pDocument->GetAutoCalc() || (cMatrixFlag != MM_NONE));
+}
+
+void ScFormulaCell::MaybeInterpret()
+{
+ if (NeedsInterpret())
Interpret();
}
@@ -2271,6 +2276,18 @@ bool ScFormulaCell::IsValueNoError()
return aResult.IsValueNoError();
}
+bool ScFormulaCell::IsValueNoError() const
+{
+ if (NeedsInterpret())
+ // false if the cell is dirty & needs to be interpreted.
+ return false;
+
+ if (pCode->GetCodeError())
+ return false;
+
+ return aResult.IsValueNoError();
+}
+
bool ScFormulaCell::IsHybridValueCell()
{
return aResult.GetType() == formula::svHybridValueCell;
More information about the Libreoffice-commits
mailing list