summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-06-29 20:08:50 +1000
committerAron Budea <aron.budea@collabora.com>2018-06-30 02:44:52 +0200
commite745bf67b7bd2701ae1334de42ffdf78c67e7177 (patch)
tree44908388888b51fa0188cd74779598a61b0739a6
parent2d1547b1b970498b3d7abb3bf2f08be01cc45ee4 (diff)
tdf#118441: also keep string-formula results for shared formulas
... like it is done for normal cells. So, the cells that have markup like <row r="2" ...> <c r="A2" t="str"> <f t="shared" ref="A2:A65" si="0">Test(B2:Z2)</f> <v>0</v> </c> </row> <row r="3" ...> <c r="A3" t="str"> <f t="shared" si="0"/> <v>0</v> </c> </row> now are handled (wrt restoring the stored result value) just like cells with this markup without sharing have long been handled: <row r="1" ...> <c r="A1" t="str"> <f>Test(B1:Z1)</f> <v>0</v> </c> </row> Change-Id: Ifcf62cf6d073faff310aa8553c6f57f42ae588cc Reviewed-on: https://gerrit.libreoffice.org/56697 Reviewed-by: Aron Budea <aron.budea@collabora.com> Tested-by: Aron Budea <aron.budea@collabora.com>
-rw-r--r--sc/source/filter/oox/formulabuffer.cxx22
1 files changed, 19 insertions, 3 deletions
diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx
index bfa229292775..c54ae121543d 100644
--- a/sc/source/filter/oox/formulabuffer.cxx
+++ b/sc/source/filter/oox/formulabuffer.cxx
@@ -114,7 +114,8 @@ void applySharedFormulas(
ScDocumentImport& rDoc,
SvNumberFormatter& rFormatter,
std::vector<FormulaBuffer::SharedFormulaEntry>& rSharedFormulas,
- std::vector<FormulaBuffer::SharedFormulaDesc>& rCells )
+ std::vector<FormulaBuffer::SharedFormulaDesc>& rCells,
+ bool bGeneratorKnownGood)
{
sc::SharedFormulaGroups aGroups;
{
@@ -139,6 +140,7 @@ void applySharedFormulas(
}
{
+ svl::SharedStringPool& rStrPool = rDoc.getDoc().GetSharedStringPool();
// Process formulas that use shared formulas.
std::vector<FormulaBuffer::SharedFormulaDesc>::const_iterator it = rCells.begin(), itEnd = rCells.end();
for (; it != itEnd; ++it)
@@ -157,7 +159,7 @@ void applySharedFormulas(
continue;
}
- // Set cached formula results. For now, we only use numeric
+ // Set cached formula results. For now, we only use numeric and string-formula
// results. Find out how to utilize cached results of other types.
switch (it->mnValueType)
{
@@ -165,6 +167,19 @@ void applySharedFormulas(
// numeric value.
pCell->SetResultDouble(it->maCellValue.toDouble());
break;
+ case XML_str:
+ if (bGeneratorKnownGood)
+ {
+ // See applyCellFormulaValues
+ svl::SharedString aSS = rStrPool.intern(it->maCellValue);
+ pCell->SetResultToken(new formula::FormulaStringToken(aSS));
+ // If we don't reset dirty, then e.g. disabling macros makes all cells
+ // that use macro functions to show #VALUE!
+ pCell->ResetDirty();
+ pCell->SetChanged(false);
+ break;
+ }
+ SAL_FALLTHROUGH;
default:
// Mark it for re-calculation.
pCell->SetDirty();
@@ -306,7 +321,8 @@ void processSheetFormulaCells(
const uno::Sequence<sheet::ExternalLinkInfo>& rExternalLinks, bool bGeneratorKnownGood )
{
if (rItem.mpSharedFormulaEntries && rItem.mpSharedFormulaIDs)
- applySharedFormulas(rDoc, rFormatter, *rItem.mpSharedFormulaEntries, *rItem.mpSharedFormulaIDs);
+ applySharedFormulas(rDoc, rFormatter, *rItem.mpSharedFormulaEntries,
+ *rItem.mpSharedFormulaIDs, bGeneratorKnownGood);
if (rItem.mpCellFormulas)
{