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 _______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice