Author: hdu Date: Thu Feb 28 13:16:29 2013 New Revision: 1451191 URL: http://svn.apache.org/r1451191 Log: Fix build aborts in the customshape code caused by integer-narrowing-down problems
0x80000000 is used as magic constant all over the customshape code where it is squeezed into signed int32 types that cannot preserve this value. Good compilers notice the problem and have every right to complain or error-out. Using the magic constant already casted down consolidates the problem and is the least invasive way to fix it until the code gets its well deserved makeover. Modified: openoffice/trunk/main/svx/inc/svx/EnhancedCustomShapeGeometry.hxx openoffice/trunk/main/svx/source/customshapes/EnhancedCustomShape2d.cxx openoffice/trunk/main/svx/source/customshapes/EnhancedCustomShapeGeometry.cxx Modified: openoffice/trunk/main/svx/inc/svx/EnhancedCustomShapeGeometry.hxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/inc/svx/EnhancedCustomShapeGeometry.hxx?rev=1451191&r1=1451190&r2=1451191&view=diff ============================================================================== --- openoffice/trunk/main/svx/inc/svx/EnhancedCustomShapeGeometry.hxx (original) +++ openoffice/trunk/main/svx/inc/svx/EnhancedCustomShapeGeometry.hxx Thu Feb 28 13:16:29 2013 @@ -83,7 +83,13 @@ struct mso_CustomShape sal_uInt32 nHandles; }; -#define MSO_I | (sal_Int32)0x80000000 +// 0x80000000 is used as magic constant all over the customshape code where +// it is squeezed into signed int32 type that cannot preserve this value. Good +// compilers notice the problem and have every right to complain or error-out. +// Using the magic constant already casted down consolidates the problem and is +// the least invasive way to fix it until the code gets its well deserved makeover. +#define Mx80000000 static_cast<sal_Int32>(0x80000000) +#define MSO_I | Mx80000000 sal_Bool SortFilledObjectsToBackByDefault( MSO_SPT eSpType ); SVX_DLLPUBLIC sal_Bool IsCustomShapeFilledByDefault( MSO_SPT eSpType ); Modified: openoffice/trunk/main/svx/source/customshapes/EnhancedCustomShape2d.cxx URL: http://svn.apache.org/viewvc/openoffice/trunk/main/svx/source/customshapes/EnhancedCustomShape2d.cxx?rev=1451191&r1=1451190&r2=1451191&view=diff ============================================================================== --- openoffice/trunk/main/svx/source/customshapes/EnhancedCustomShape2d.cxx (original) +++ openoffice/trunk/main/svx/source/customshapes/EnhancedCustomShape2d.cxx Thu Feb 28 13:16:29 2013 @@ -697,8 +697,8 @@ EnhancedCustomShape2d::EnhancedCustomSha nCoordTop ( 0 ), nCoordWidth ( 21600 ), nCoordHeight ( 21600 ), - nXRef ( 0x80000000 ), - nYRef ( 0x80000000 ), + nXRef ( Mx80000000 ), + nYRef ( Mx80000000 ), nFlags ( 0 ), nColorData ( 0 ), bTextFlow ( sal_False ), @@ -798,7 +798,7 @@ EnhancedCustomShape2d::EnhancedCustomSha } fXScale = nCoordWidth == 0 ? 0.0 : (double)aLogicRect.GetWidth() / (double)nCoordWidth; fYScale = nCoordHeight == 0 ? 0.0 : (double)aLogicRect.GetHeight() / (double)nCoordHeight; - if ( (sal_uInt32)nXRef != 0x80000000 && aLogicRect.GetHeight() ) + if( (nXRef != Mx80000000) && aLogicRect.GetHeight() ) { fXRatio = (double)aLogicRect.GetWidth() / (double)aLogicRect.GetHeight(); if ( fXRatio > 1 ) @@ -808,7 +808,7 @@ EnhancedCustomShape2d::EnhancedCustomSha } else fXRatio = 1.0; - if ( (sal_uInt32)nYRef != 0x80000000 && aLogicRect.GetWidth() ) + if( (nYRef != Mx80000000) && aLogicRect.GetWidth() ) { fYRatio = (double)aLogicRect.GetHeight() / (double)aLogicRect.GetWidth(); if ( fYRatio > 1 )