[Libreoffice-commits] core.git: Branch 'libreoffice-4-2' - sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Wed Dec 4 11:38:35 PST 2013
sc/source/filter/excel/excform.cxx | 34 +++++++++++++++++++++++++---------
1 file changed, 25 insertions(+), 9 deletions(-)
New commits:
commit fdf5b7b0f9e01735d5721b8080a29bfcb893d12c
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Wed Dec 4 14:35:42 2013 -0500
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
(cherry picked from commit 0fb70733136f2382e7253ef0515a681c7cec724d)
diff --git a/sc/source/filter/excel/excform.cxx b/sc/source/filter/excel/excform.cxx
index 06e14b2..2b7175b 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
More information about the Libreoffice-commits
mailing list