diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-09-11 01:04:18 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-09-11 01:06:10 -0400 |
commit | 6ebb9a3bf4c00df694df844345748a1b736791b0 (patch) | |
tree | ebd8be4223620627927b2a3d5f75935799a5bdb8 | |
parent | d66ae92ade617b390c879ac99d9bbca8a7b6617f (diff) |
Handle import of shared formula from xls more gracefully.
Many xls documents contain shared formula entries that don't follow
the spec. We still need to be able to handle them.
Change-Id: Ia7d01101a6759967d9ebb27b6540dcb67607d13f
-rw-r--r-- | sc/source/filter/excel/excform.cxx | 37 | ||||
-rw-r--r-- | sc/source/filter/excel/namebuff.cxx | 3 |
2 files changed, 20 insertions, 20 deletions
diff --git a/sc/source/filter/excel/excform.cxx b/sc/source/filter/excel/excform.cxx index 56a18f8f81d4..82a3ae59a8db 100644 --- a/sc/source/filter/excel/excform.cxx +++ b/sc/source/filter/excel/excform.cxx @@ -115,27 +115,28 @@ void ImportExcel::Formula( { // This is a shared formula. Get the token array from the shared formula pool. ScFormulaCellGroupRef xGroup = pFormConv->GetSharedFormula(maStrm, aScPos.Col(), nFormLen); - if (!xGroup) - return; - - if (xGroup->mnStart == aScPos.Row()) - // Generate code for the top cell only. - xGroup->compileCode(*pD, aScPos, formula::FormulaGrammar::GRAM_DEFAULT); - - ScFormulaCell* pCell = new ScFormulaCell(pD, aScPos, xGroup); - pD->EnsureTable(aScPos.Tab()); - bool bInserted = pD->SetGroupFormulaCell(aScPos, pCell); - if (!bInserted) + if (xGroup) { - delete pCell; + if (xGroup->mnStart == aScPos.Row()) + // Generate code for the top cell only. + xGroup->compileCode(*pD, aScPos, formula::FormulaGrammar::GRAM_DEFAULT); + + ScFormulaCell* pCell = new ScFormulaCell(pD, aScPos, xGroup); + pD->EnsureTable(aScPos.Tab()); + bool bInserted = pD->SetGroupFormulaCell(aScPos, pCell); + if (!bInserted) + { + delete pCell; + return; + } + xGroup->mnLength = aScPos.Row() - xGroup->mnStart + 1; + pCell->SetNeedNumberFormat(false); + if (!rtl::math::isNan(fCurVal)) + pCell->SetResultDouble(fCurVal); + + GetXFRangeBuffer().SetXF(aScPos, nXF); return; } - pCell->SetNeedNumberFormat(false); - if (!rtl::math::isNan(fCurVal)) - pCell->SetResultDouble(fCurVal); - - GetXFRangeBuffer().SetXF(aScPos, nXF); - return; } ConvErr eErr = pFormConv->Convert( pResult, maStrm, nFormLen, true, FT_CellFormula); diff --git a/sc/source/filter/excel/namebuff.cxx b/sc/source/filter/excel/namebuff.cxx index 4e47c09f7346..4c75d64216d9 100644 --- a/sc/source/filter/excel/namebuff.cxx +++ b/sc/source/filter/excel/namebuff.cxx @@ -79,7 +79,6 @@ void SharedFormulaBuffer::Clear() void SharedFormulaBuffer::Store( const ScRange& rRange, const ScTokenArray& rArray ) { - SCROW nGroupLen = rRange.aEnd.Row() - rRange.aStart.Row() + 1; for (SCCOL i = rRange.aStart.Col(); i <= rRange.aEnd.Col(); ++i) { // Create one group per column. @@ -88,7 +87,7 @@ void SharedFormulaBuffer::Store( const ScRange& rRange, const ScTokenArray& rArr ScFormulaCellGroupRef xNewGroup(new ScFormulaCellGroup); xNewGroup->mnStart = rRange.aStart.Row(); - xNewGroup->mnLength = nGroupLen; + xNewGroup->mnLength = 1; xNewGroup->setCode(rArray); maFormulaGroups.insert(FormulaGroupsType::value_type(aPos, xNewGroup)); } |