TINYINT set as signed in formcontrolfactory.cxx

Alexander Thurgood alex.thurgood at gmail.com
Sat Jan 12 11:43:53 PST 2013


Hi,

While trying to find out where the default font for form controls was
set, I came across this in the file formcontrolfactory.cxx, which has
left me a bit puzzled :


sal_Int32 nDataType = DataType::OTHER;
            OSL_VERIFY( _rxDatabaseField->getPropertyValue(
FM_PROP_FIELDTYPE ) >>= nDataType );

            if  (   xModelPSI->hasPropertyByName( FM_PROP_VALUEMIN )
                &&  xModelPSI->hasPropertyByName( FM_PROP_VALUEMAX )
                )
            {
                sal_Int32 nMinValue = -1000000000, nMaxValue = 1000000000;
                switch ( nDataType )
                {
                    case DataType::TINYINT  : nMinValue = 0; nMaxValue =
255; break;
                    case DataType::SMALLINT : nMinValue = -32768;
nMaxValue = 32767; break;
                    case DataType::INTEGER  : nMinValue = 0x80000000;
nMaxValue = 0x7FFFFFFF; break;
                        // double and singles are ignored
                }

In particular, the line :

case DataType::TINYINT  : nMinValue = 0; nMaxValue = 255; break

sets TINYINT as signed. This surely must lead to strange results for
TINYINT fields where the default is often -127 to +128, e.g. mysql.

Am I barking up the wrong tree here, and if so, can someone please
enlighten me ?

Oh, and if anyone happens to know where the Default font for form
controls is defined, I would be most obliged ;-)


Alex




More information about the LibreOffice mailing list