summaryrefslogtreecommitdiff
path: root/sc/source/filter/oox/formulabuffer.cxx
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2016-10-15 16:42:42 +0200
committerEike Rathke <erack@redhat.com>2016-10-15 16:49:57 +0200
commit2a45b26c619d1125419819d501a7653cf8d6e5ca (patch)
tree364c94f0b2f01be9ef71a8d6dd36970a77f4ef39 /sc/source/filter/oox/formulabuffer.cxx
parent7125de1cdb4d29cc3763147571808033ee207777 (diff)
Resolves: tdf#98481 Google Sheets uses OOXML t="str" differently
Set string results only for known good generators, otherwise recalculate. See source code comment. Change-Id: Ib89ba70fd7c3c515439498882fef90ca7c6e278d
Diffstat (limited to 'sc/source/filter/oox/formulabuffer.cxx')
-rw-r--r--sc/source/filter/oox/formulabuffer.cxx32
1 files changed, 22 insertions, 10 deletions
diff --git a/sc/source/filter/oox/formulabuffer.cxx b/sc/source/filter/oox/formulabuffer.cxx
index 73d01e748cd7..bed3f5ff2600 100644
--- a/sc/source/filter/oox/formulabuffer.cxx
+++ b/sc/source/filter/oox/formulabuffer.cxx
@@ -255,7 +255,7 @@ void applyArrayFormulas(
}
void applyCellFormulaValues(
- ScDocumentImport& rDoc, const std::vector<FormulaBuffer::FormulaValue>& rVector )
+ ScDocumentImport& rDoc, const std::vector<FormulaBuffer::FormulaValue>& rVector, bool bGeneratorKnownGood )
{
svl::SharedStringPool& rStrPool = rDoc.getDoc().GetSharedStringPool();
@@ -278,12 +278,23 @@ void applyCellFormulaValues(
}
break;
case XML_str:
- {
- svl::SharedString aSS = rStrPool.intern(rValueStr);
- pCell->SetResultToken(new formula::FormulaStringToken(aSS));
- pCell->ResetDirty();
- pCell->SetChanged(false);
- }
+ // Excel uses t="str" for string results (per definition
+ // ECMA-376 18.18.11 ST_CellType (Cell Type) "Cell containing a
+ // formula string.", but that 't' Cell Data Type attribute, "an
+ // enumeration representing the cell's data type", is meant for
+ // the content of the <v> element). We follow that. Other
+ // applications might not and instead use t="str" for the cell
+ // content if formula. Setting an otherwise numeric result as
+ // string result fouls things up, set result strings only for
+ // documents claiming to be generated by a known good
+ // generator. See tdf#98481
+ if (bGeneratorKnownGood)
+ {
+ svl::SharedString aSS = rStrPool.intern(rValueStr);
+ pCell->SetResultToken(new formula::FormulaStringToken(aSS));
+ pCell->ResetDirty();
+ pCell->SetChanged(false);
+ }
break;
default:
;
@@ -293,7 +304,7 @@ void applyCellFormulaValues(
void processSheetFormulaCells(
ScDocumentImport& rDoc, FormulaBuffer::SheetItem& rItem, SvNumberFormatter& rFormatter,
- const uno::Sequence<sheet::ExternalLinkInfo>& rExternalLinks )
+ const uno::Sequence<sheet::ExternalLinkInfo>& rExternalLinks, bool bGeneratorKnownGood )
{
if (rItem.mpSharedFormulaEntries && rItem.mpSharedFormulaIDs)
applySharedFormulas(rDoc, rFormatter, *rItem.mpSharedFormulaEntries, *rItem.mpSharedFormulaIDs);
@@ -308,7 +319,7 @@ void processSheetFormulaCells(
applyArrayFormulas(rDoc, rFormatter, *rItem.mpArrayFormulas);
if (rItem.mpCellFormulaValues)
- applyCellFormulaValues(rDoc, *rItem.mpCellFormulaValues);
+ applyCellFormulaValues(rDoc, *rItem.mpCellFormulaValues, bGeneratorKnownGood);
}
}
@@ -362,7 +373,8 @@ void FormulaBuffer::finalizeImport()
std::vector<SheetItem>::iterator it = aSheetItems.begin(), itEnd = aSheetItems.end();
for (; it != itEnd; ++it)
- processSheetFormulaCells(rDoc, *it, *rDoc.getDoc().GetFormatTable(), getExternalLinks().getLinkInfos());
+ processSheetFormulaCells(rDoc, *it, *rDoc.getDoc().GetFormatTable(), getExternalLinks().getLinkInfos(),
+ isGeneratorKnownGood());
rDoc.getDoc().SetAutoNameCache(nullptr);