diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2018-06-29 20:08:50 +1000 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2018-06-29 17:10:56 +0200 |
commit | e6c43ed9e6bb41b64bcc8105ad006c999deebcd7 (patch) | |
tree | 8cdf948c53f2ba064995372fef7bf0a25e2bc90c | |
parent | f7f75d92604cb591c5a974d433651dff98708511 (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/56675
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r-- | sc/source/filter/oox/formulabuffer.cxx | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx index 9f7977b5ddb2..0b6bd75ce236 100644 --- a/sc/source/filter/oox/formulabuffer.cxx +++ b/sc/source/filter/oox/formulabuffer.cxx @@ -110,7 +110,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; { @@ -133,6 +134,7 @@ void applySharedFormulas( } { + svl::SharedStringPool& rStrPool = rDoc.getDoc().GetSharedStringPool(); // Process formulas that use shared formulas. for (const FormulaBuffer::SharedFormulaDesc& rDesc : rCells) { @@ -150,7 +152,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 (rDesc.mnValueType) { @@ -158,6 +160,19 @@ void applySharedFormulas( // numeric value. pCell->SetResultDouble(rDesc.maCellValue.toDouble()); break; + case XML_str: + if (bGeneratorKnownGood) + { + // See applyCellFormulaValues + svl::SharedString aSS = rStrPool.intern(rDesc.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(); @@ -292,7 +307,8 @@ void processSheetFormulaCells( const Sequence<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) { |