diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-12-04 14:35:42 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-12-04 14:39:17 -0500 |
commit | 0fb70733136f2382e7253ef0515a681c7cec724d (patch) | |
tree | c7fae7b5de1f34fc24f95e4bf50c8cf91b7c3f04 /sc | |
parent | 13ce74fd9b5f7b9ea9d3dab34eed27a63aae5468 (diff) |
Assign top cell to the formula group if it's still NULL.
This can happen when Excel's original shared formula range is across
multiple columns, in which case we split that into multiple groups (one
per column), and initialize top cell only for the left most column.
This fixes the crasher on the doc from fdo#31296.
Change-Id: I9e4def9836947fc67523f0d99ca981465709b934
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/filter/excel/excform.cxx | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/sc/source/filter/excel/excform.cxx b/sc/source/filter/excel/excform.cxx index 06e14b2fac39..2b7175b3c754 100644 --- a/sc/source/filter/excel/excform.cxx +++ b/sc/source/filter/excel/excform.cxx @@ -133,15 +133,31 @@ void ImportExcel::Formula( if (pLast && pLast->mpCell && pLast->mnRow == (aScPos.Row()-1)) { ScFormulaCell* pCell = new ScFormulaCell(pD, aScPos, xGroup); - rDoc.getDoc().EnsureTable(aScPos.Tab()); - rDoc.setFormulaCell(aScPos, pCell); - xGroup->mnLength = aScPos.Row() - xGroup->mpTopCell->aPos.Row() + 1; - pCell->SetNeedNumberFormat(false); - if (!rtl::math::isNan(fCurVal)) - pCell->SetResultDouble(fCurVal); - - GetXFRangeBuffer().SetXF(aScPos, nXF); - SetLastFormula(aScPos.Col(), aScPos.Row(), fCurVal, nXF, pCell); + + if (!xGroup->mpTopCell && nSharedRow == aScPos.Row()) + // This formula group object is a duplicate of the + // original one due to Excel's multi-column shared + // range, and doesn't have the top cell assigned yet. + // Assign the current cell as its top cell. + xGroup->mpTopCell = pCell; + + if (xGroup->mpTopCell) + { + rDoc.getDoc().EnsureTable(aScPos.Tab()); + rDoc.setFormulaCell(aScPos, pCell); + xGroup->mnLength = aScPos.Row() - xGroup->mpTopCell->aPos.Row() + 1; + pCell->SetNeedNumberFormat(false); + if (!rtl::math::isNan(fCurVal)) + pCell->SetResultDouble(fCurVal); + + GetXFRangeBuffer().SetXF(aScPos, nXF); + SetLastFormula(aScPos.Col(), aScPos.Row(), fCurVal, nXF, pCell); + } + else + { + // No idea what's going on here... + delete pCell; + } } } else |