Question unoType for getXmlToken (dbaccess/reportdesign module)

classic Classic list List threaded Threaded
4 messages Options
julien2412 julien2412
Reply | Threaded
Open this post in threaded view
|

Question unoType for getXmlToken (dbaccess/reportdesign module)

Hello,

I noticed this:
s_aTypeNameMap[GetXMLToken( XML_FLOAT)] = ::cppu::UnoType<double>::get();
present at 2 locations:
See http://opengrok.libreoffice.org/search?q=%22GetXMLToken%28+XML_FLOAT%29%22&project=core&defs=&refs=&path=&hist=

Why shouldn't be this:
s_aTypeNameMap[GetXMLToken( XML_FLOAT)] = ::cppu::UnoType<float>::get();
?

(If "double" is ok, I'll comment the code accordingly).

Julien
Lionel Elie Mamane Lionel Elie Mamane
Reply | Threaded
Open this post in threaded view
|

Re: Question unoType for getXmlToken (dbaccess/reportdesign module)

On Fri, May 16, 2014 at 10:30:27AM -0700, julien2412 [via Document Foundation Mail Archive] wrote:

> I noticed this:
> s_aTypeNameMap[GetXMLToken( XML_FLOAT)] = ::cppu::UnoType<double>::get();
> present at 2 locations:
> See
> http://opengrok.libreoffice.org/search?q=%22GetXMLToken%28+XML_FLOAT%29%22&project=core&defs=&refs=&path=&hist=

> Why shouldn't be this:
> s_aTypeNameMap[GetXMLToken( XML_FLOAT)] = ::cppu::UnoType<float>::get();
> ?

Also in xmloff/source/forms/propertyimport.cxx (which is not found by
the above search).

In that file I also see:

    token::XMLTokenEnum OPropertyExport::implGetPropertyXMLType(const ::com::sun::star::uno::Type& _rType)
    {
        // handle the type description
        switch (_rType.getTypeClass())
        {
            case TypeClass_DOUBLE:
            case TypeClass_BYTE:
            case TypeClass_SHORT:
            case TypeClass_LONG:
            case TypeClass_HYPER:
            case TypeClass_ENUM:
                return token::XML_FLOAT;


So there, clearly, all numeric types (including the UNO double)
consistently map to XML_FLOAT, so taking the extra precision from the
C++ type "float" to "double" makes absolute sense. What is called
"float" in XML seems to be the general notion of number, not
specifically the IEE754 single precision 32-bit floating point.


Looking into an .odb file's reports, I don't see "double" used at
all. Again, "float" seems to be used in the general sense of
"number". This is confirmed by
http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1417680_253892949
which shows that the ODF format uses the XML token "float" to mean
"number", and does not have a difference between the notion of
"integer" and "floating point", much less between different precision
levels of floating point data types.

So again, it makes sense to use the C++ type "double" for that (extra
precision, matches the type used by our numeric formatters, ...).

--
Lionel
julien2412 julien2412
Reply | Threaded
Open this post in threaded view
|

[SOLVED] Re: Question unoType for getXmlToken (dbaccess/reportdesign module)

Thank you Lionel for your detailed feedback!

I quoted you for the comment, see http://cgit.freedesktop.org/libreoffice/core/commit/?id=f62de9113a4866f7152acbe0e8221c594b7a7b68

Julien
sberg sberg
Reply | Threaded
Open this post in threaded view
|

Re: Question unoType for getXmlToken (dbaccess/reportdesign module)

In reply to this post by julien2412
On 05/16/2014 07:30 PM, julien2412 [via Document Foundation Mail
Archive] wrote:
> I noticed this:
> s_aTypeNameMap[GetXMLToken( XML_FLOAT)] = ::cppu::UnoType<double>::get();
> present at 2 locations:
> See
> http://opengrok.libreoffice.org/search?q=%22GetXMLToken%28+XML_FLOAT%29%22&project=core&defs=&refs=&path=&hist=
>
> Why shouldn't be this:
> s_aTypeNameMap[GetXMLToken( XML_FLOAT)] = ::cppu::UnoType<float>::get();
> ?

Why should it, because of the "FLOAT" in XML_FLOAT?  I don't know
anything about that dbaccess/reportbuilder code.  You might want to ask
on the ML instead (maybe Lionel knows), but I'd assume the code is fine
as is.

Stephan