NumericBox unsafe double conversion

Zolnai Tamás zolnaitamas2000 at gmail.com
Mon Mar 18 09:56:17 PDT 2013


Hi Kendy,

Can you please point exactly to the code in question, like
> filename:line_number, or ClassName::MethodName, or something similar?
> It helps a lot to understand what you have in mind, and saves the
> guessing if it was (in this case) MetricField::ConvertValue() from
> vcl/source/control/field.cxx, or something different :-)


Well, I was indeed not too concrete. Sorry. I was debugging a bit and found
this.

The sourcefile was found yet: /core<http://opengrok.libreoffice.org/xref/core>
/vcl <http://opengrok.libreoffice.org/xref/core/vcl>/source<http://opengrok.libreoffice.org/xref/core/vcl/source>
/control <http://opengrok.libreoffice.org/xref/core/vcl/source/control>/
field.cxx<http://opengrok.libreoffice.org/xref/core/vcl/source/control/field.cxx>

First point is: void NumericFormatter::Reformat():
This function run, when the NumericBox loose focus.

It calls NumericFormatter::ImplNumericReformat(), which calls
ImplNumericGetValue().

And the problem was found in this function, in line 199:
double nValue = rtl::OUString(aStr).toDouble();

In general the NumericBox store its data in an sal_Int64 variable, but here
this OUString->double conversion cause changes in big numbers. The "aStr"
variable comes from GetText() function, which gives the NumericBox's
content, so it is a string representation of an sal_Int64 value. I don't
know this behaviour is the expected from the OUString::toDouble() function,
or it is a bug.

Regards,
Tamás
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20130318/a554e396/attachment.html>


More information about the LibreOffice mailing list