SVN commit 1179445 by mkruisselbrink: properly handle a data style with an unspecified precision BUG: 239718 M +1 -1 ValueFormatter.cpp M +5 -1 tests/TestValueFormatter.cpp --- trunk/koffice/kspread/ValueFormatter.cpp #1179444:1179445 @@ -262,7 +262,7 @@ return prefix + postfix; } else if (formatString.contains(QLatin1Char('.'))) { precision = formatString.length() - formatString.indexOf(QLatin1Char('.')) - 1; - } else { + } else if (precision != -1){ precision = 0; } } --- trunk/koffice/kspread/tests/TestValueFormatter.cpp #1179444:1179445 @@ -203,8 +203,12 @@ QTest::newRow("negative sign in format string") << -5.0 << 0 << Format::Number << Style::DefaultFloatFormat << "" << "(-.)" << "(-5)"; -} + QTest::newRow("unspecified precision 1") << + 1.0 << -1 << Format::Number << Style::DefaultFloatFormat << "" << "0" << "1"; + QTest::newRow("unspecified precision 0.5") << + 0.5 << -1 << Format::Number << Style::DefaultFloatFormat << "" << "0" << "0.5";} + void TestValueFormatter::testCreateNumberFormat() { QFETCH(double, value);