Kaydet (Commit) 96d3c756 authored tarafından Mike Kaganski's avatar Mike Kaganski Kaydeden (comit) Andras Timar

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: 's avatarMike Kaganski <mike.kaganski@collabora.com>
(cherry picked from commit e6c43ed9)
Reviewed-on: https://gerrit.libreoffice.org/56732Reviewed-by: 's avatarAndras Timar <andras.timar@collabora.com>
Tested-by: 's avatarAndras Timar <andras.timar@collabora.com>
üst 3bba368c
...@@ -109,7 +109,8 @@ void applySharedFormulas( ...@@ -109,7 +109,8 @@ void applySharedFormulas(
ScDocumentImport& rDoc, ScDocumentImport& rDoc,
SvNumberFormatter& rFormatter, SvNumberFormatter& rFormatter,
std::vector<FormulaBuffer::SharedFormulaEntry>& rSharedFormulas, std::vector<FormulaBuffer::SharedFormulaEntry>& rSharedFormulas,
std::vector<FormulaBuffer::SharedFormulaDesc>& rCells ) std::vector<FormulaBuffer::SharedFormulaDesc>& rCells,
bool bGeneratorKnownGood)
{ {
sc::SharedFormulaGroups aGroups; sc::SharedFormulaGroups aGroups;
{ {
...@@ -132,6 +133,7 @@ void applySharedFormulas( ...@@ -132,6 +133,7 @@ void applySharedFormulas(
} }
{ {
svl::SharedStringPool& rStrPool = rDoc.getDoc().GetSharedStringPool();
// Process formulas that use shared formulas. // Process formulas that use shared formulas.
for (const FormulaBuffer::SharedFormulaDesc& rDesc : rCells) for (const FormulaBuffer::SharedFormulaDesc& rDesc : rCells)
{ {
...@@ -149,7 +151,7 @@ void applySharedFormulas( ...@@ -149,7 +151,7 @@ void applySharedFormulas(
continue; 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. // results. Find out how to utilize cached results of other types.
switch (rDesc.mnValueType) switch (rDesc.mnValueType)
{ {
...@@ -157,6 +159,19 @@ void applySharedFormulas( ...@@ -157,6 +159,19 @@ void applySharedFormulas(
// numeric value. // numeric value.
pCell->SetResultDouble(rDesc.maCellValue.toDouble()); pCell->SetResultDouble(rDesc.maCellValue.toDouble());
break; 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: default:
// Mark it for re-calculation. // Mark it for re-calculation.
pCell->SetDirty(); pCell->SetDirty();
...@@ -291,7 +306,8 @@ void processSheetFormulaCells( ...@@ -291,7 +306,8 @@ void processSheetFormulaCells(
const Sequence<ExternalLinkInfo>& rExternalLinks, bool bGeneratorKnownGood ) const Sequence<ExternalLinkInfo>& rExternalLinks, bool bGeneratorKnownGood )
{ {
if (rItem.mpSharedFormulaEntries && rItem.mpSharedFormulaIDs) if (rItem.mpSharedFormulaEntries && rItem.mpSharedFormulaIDs)
applySharedFormulas(rDoc, rFormatter, *rItem.mpSharedFormulaEntries, *rItem.mpSharedFormulaIDs); applySharedFormulas(rDoc, rFormatter, *rItem.mpSharedFormulaEntries,
*rItem.mpSharedFormulaIDs, bGeneratorKnownGood);
if (rItem.mpCellFormulas) if (rItem.mpCellFormulas)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment