Question unoType for getXmlToken (dbaccess/reportdesign module)

Lionel Elie Mamane lionel at mamane.lu
Fri May 16 21:29:32 PDT 2014


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




--
View this message in context: http://nabble.documentfoundation.org/Question-unoType-for-getXmlToken-dbaccess-reportdesign-module-tp4109071p4109116.html
Sent from the Dev mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20140516/3152f1db/attachment.html>


More information about the LibreOffice mailing list