Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


On Sat, Jan 12, 2013 at 08:43:53PM +0100, Alexander Thurgood wrote:

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.

It sets it as *un*signed.

This code seems to match the behaviour of Microsoft SQL Server.

It is exactly the opposite of the capabilities of LibreOffice's
internal system with 8-bit integers (most notably the "Any" type; see
http://lists.freedesktop.org/archives/libreoffice/2012-December/043160.html )

In MySQL, any integer type can be signed or unsigned. Most database
engines don't allow that choice (they simply use signed, except
tinyint in Microsoft SQL Server which is always unsigned). See the
first/best answer at
http://stackoverflow.com/questions/2991405/what-is-the-difference-between-tinyint-smallint-mediumint-bigint-and-int-in-s


The central question is: what are the consequences of this code? If it
somewhat restrains user input, we should probably set it to cover
signed and unsigned:

  case DataType::TINYINT  : nMinValue = -127; nMaxValue = 255; break;
  case DataType::SMALLINT : nMinValue = -32768; nMaxValue = 65535; break;
  case DataType::INTEGER  : nMinValue = 0x80000000; nMaxValue = 0x7FFFFFFF; break;

Err... But this will not cover unsigned (32 bit) integer, and neither
will it cover any BIGINT :-(

Pff... This could become a mess to handle.

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

Controls where? In a Form? Isn't it the default font of the underlying
Writer document?

-- 
Lionel

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.