[Libreoffice-commits] core.git: sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Tue Sep 10 22:06:19 PDT 2013
sc/source/filter/excel/excform.cxx | 37 ++++++++++++++++++------------------
sc/source/filter/excel/namebuff.cxx | 3 --
2 files changed, 20 insertions(+), 20 deletions(-)
New commits:
commit 6ebb9a3bf4c00df694df844345748a1b736791b0
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Wed Sep 11 01:04:18 2013 -0400
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
diff --git a/sc/source/filter/excel/excform.cxx b/sc/source/filter/excel/excform.cxx
index 56a18f8..82a3ae5 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 4e47c09..4c75d64 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));
}
More information about the Libreoffice-commits
mailing list