[Libreoffice-commits] core.git: sc/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Tue Jan 26 13:19:54 PST 2016
sc/source/filter/oox/condformatbuffer.cxx | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)
New commits:
commit b1ba84efc38821d5d272448cb34af7519306b8ce
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue Jan 26 19:10:35 2016 +0100
handle entries with num type and formula during OOXML import, tdf#94626
Change-Id: I0d48120f2b128fb898c7cc55cc41ce52378851dc
Reviewed-on: https://gerrit.libreoffice.org/21820
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard at googlemail.com>
diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx
index 4ab87ed..4aeeaa9 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -104,18 +104,30 @@ const sal_uInt16 BIFF12_CFRULE_ABOVEAVERAGE = 0x0004;
const sal_uInt16 BIFF12_CFRULE_BOTTOM = 0x0008;
const sal_uInt16 BIFF12_CFRULE_PERCENT = 0x0010;
+bool isValue(const OUString& rStr, double& rVal)
+{
+ sal_Int32 nEnd = -1;
+ rVal = rtl::math::stringToDouble(rStr.trim(), '.', ',', nullptr, &nEnd);
+
+ if (nEnd < rStr.getLength())
+ return false;
+
+ return true;
+}
+
void SetCfvoData( ColorScaleRuleModelEntry* pEntry, const AttributeList& rAttribs )
{
OUString aType = rAttribs.getString( XML_type, OUString() );
+ OUString aVal = rAttribs.getString(XML_val, OUString());
- if( aType == "formula" )
+ double nVal = 0.0;
+ bool bVal = isValue(aVal, nVal);
+ if( !bVal || aType == "formula" )
{
- OUString aFormula = rAttribs.getString( XML_val, OUString() );
- pEntry->maFormula = aFormula;
+ pEntry->maFormula = aVal;
}
else
{
- double nVal = rAttribs.getDouble( XML_val, 0.0 );
pEntry->mnVal = nVal;
}
@@ -357,11 +369,9 @@ void IconSetRule::importAttribs( const AttributeList& rAttribs )
void IconSetRule::importFormula(const OUString& rFormula)
{
ColorScaleRuleModelEntry& rEntry = maEntries.back();
- if (rEntry.mbNum ||
- rEntry.mbPercent ||
- rEntry.mbPercentile)
+ double nVal = 0.0;
+ if ((rEntry.mbNum || rEntry.mbPercent || rEntry.mbPercentile) && isValue(rFormula, nVal))
{
- double nVal = rFormula.toDouble();
rEntry.mnVal = nVal;
}
else if (!rFormula.isEmpty())
More information about the Libreoffice-commits
mailing list