Introduce Int32ToSVBT32 for cases that apparently want to write a signed value

...and clean up some other (legitimate) uses of UInt32ToSVBT32 to not use a
(somewhat misleading) static_cast<long>(...)

Change-Id: Ifd0c3f771c3f6e20eef3413b9c27fd2514dc0c13
Reviewed-on: https://gerrit.libreoffice.org/68767
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
Stephan Bergmann
2019-03-05 17:38:52 +01:00
parent efcf8149b5
commit 936308d3ef
4 changed files with 58 additions and 53 deletions

View File

@@ -94,6 +94,7 @@ inline void UInt32ToSVBT32 ( sal_uInt32 n, SVBT32 p )
p[2] = static_cast<sal_uInt8>(n >> 16);
p[3] = static_cast<sal_uInt8>(n >> 24);
}
inline void Int32ToSVBT32 ( sal_Int32 n, SVBT32 p ) { UInt32ToSVBT32(sal_uInt32(n), p); }
#if defined OSL_LITENDIAN
inline void DoubleToSVBT64( double n, SVBT64 p ) { p[0] = reinterpret_cast<sal_uInt8*>(&n)[0];
p[1] = reinterpret_cast<sal_uInt8*>(&n)[1];

View File

@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/config.h>
#include <o3tl/underlyingenumvalue.hxx>
#include <tools/stream.hxx>
#include <rtl/crc.h>
#include <sal/log.hxx>
@@ -38,25 +41,25 @@ BitmapChecksum AnimationBitmap::GetChecksum() const
BitmapChecksum nCrc = aBmpEx.GetChecksum();
SVBT32 aBT32;
UInt32ToSVBT32( aPosPix.X(), aBT32 );
Int32ToSVBT32( aPosPix.X(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( aPosPix.Y(), aBT32 );
Int32ToSVBT32( aPosPix.Y(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( aSizePix.Width(), aBT32 );
Int32ToSVBT32( aSizePix.Width(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( aSizePix.Height(), aBT32 );
Int32ToSVBT32( aSizePix.Height(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( nWait, aBT32 );
Int32ToSVBT32( nWait, aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( static_cast<long>(eDisposal), aBT32 );
UInt32ToSVBT32( o3tl::underlyingEnumValue(eDisposal), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( static_cast<long>(bUserInput), aBT32 );
UInt32ToSVBT32( sal_uInt32(bUserInput), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
return nCrc;
@@ -195,10 +198,10 @@ BitmapChecksum Animation::GetChecksum() const
UInt32ToSVBT32( maList.size(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( maGlobalSize.Width(), aBT32 );
Int32ToSVBT32( maGlobalSize.Width(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( maGlobalSize.Height(), aBT32 );
Int32ToSVBT32( maGlobalSize.Height(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
for(auto const & i : maList)

View File

@@ -20,6 +20,7 @@
#include <rtl/crc.h>
#include <rtl/strbuf.hxx>
#include <sal/log.hxx>
#include <o3tl/underlyingenumvalue.hxx>
#include <osl/diagnose.h>
#include <tools/debug.hxx>
#include <tools/stream.hxx>
@@ -291,10 +292,10 @@ BitmapChecksum BitmapEx::GetChecksum() const
SVBT32 aBT32;
BitmapChecksumOctetArray aBCOA;
UInt32ToSVBT32( static_cast<long>(meTransparent), aBT32 );
UInt32ToSVBT32( o3tl::underlyingEnumValue(meTransparent), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( static_cast<long>(mbAlpha), aBT32 );
UInt32ToSVBT32( sal_uInt32(mbAlpha), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
if( ( TransparentType::Bitmap == meTransparent ) && !maMask.IsEmpty() )

View File

@@ -2229,10 +2229,10 @@ BitmapChecksum GDIMetaFile::GetChecksum() const
BCToBCOA( pAct->GetBitmap().GetChecksum(), aBCOA );
nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE );
UInt32ToSVBT32( pAct->GetPoint().X(), aBT32 );
Int32ToSVBT32( pAct->GetPoint().X(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetPoint().Y(), aBT32 );
Int32ToSVBT32( pAct->GetPoint().Y(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
}
break;
@@ -2247,16 +2247,16 @@ BitmapChecksum GDIMetaFile::GetChecksum() const
BCToBCOA( pAct->GetBitmap().GetChecksum(), aBCOA );
nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE );
UInt32ToSVBT32( pAct->GetPoint().X(), aBT32 );
Int32ToSVBT32( pAct->GetPoint().X(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetPoint().Y(), aBT32 );
Int32ToSVBT32( pAct->GetPoint().Y(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSize().Width(), aBT32 );
Int32ToSVBT32( pAct->GetSize().Width(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSize().Height(), aBT32 );
Int32ToSVBT32( pAct->GetSize().Height(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
}
break;
@@ -2271,28 +2271,28 @@ BitmapChecksum GDIMetaFile::GetChecksum() const
BCToBCOA( pAct->GetBitmap().GetChecksum(), aBCOA );
nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE );
UInt32ToSVBT32( pAct->GetDestPoint().X(), aBT32 );
Int32ToSVBT32( pAct->GetDestPoint().X(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetDestPoint().Y(), aBT32 );
Int32ToSVBT32( pAct->GetDestPoint().Y(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetDestSize().Width(), aBT32 );
Int32ToSVBT32( pAct->GetDestSize().Width(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetDestSize().Height(), aBT32 );
Int32ToSVBT32( pAct->GetDestSize().Height(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSrcPoint().X(), aBT32 );
Int32ToSVBT32( pAct->GetSrcPoint().X(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSrcPoint().Y(), aBT32 );
Int32ToSVBT32( pAct->GetSrcPoint().Y(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSrcSize().Width(), aBT32 );
Int32ToSVBT32( pAct->GetSrcSize().Width(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSrcSize().Height(), aBT32 );
Int32ToSVBT32( pAct->GetSrcSize().Height(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
}
break;
@@ -2307,10 +2307,10 @@ BitmapChecksum GDIMetaFile::GetChecksum() const
BCToBCOA( pAct->GetBitmapEx().GetChecksum(), aBCOA );
nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE );
UInt32ToSVBT32( pAct->GetPoint().X(), aBT32 );
Int32ToSVBT32( pAct->GetPoint().X(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetPoint().Y(), aBT32 );
Int32ToSVBT32( pAct->GetPoint().Y(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
}
break;
@@ -2325,16 +2325,16 @@ BitmapChecksum GDIMetaFile::GetChecksum() const
BCToBCOA( pAct->GetBitmapEx().GetChecksum(), aBCOA );
nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE );
UInt32ToSVBT32( pAct->GetPoint().X(), aBT32 );
Int32ToSVBT32( pAct->GetPoint().X(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetPoint().Y(), aBT32 );
Int32ToSVBT32( pAct->GetPoint().Y(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSize().Width(), aBT32 );
Int32ToSVBT32( pAct->GetSize().Width(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSize().Height(), aBT32 );
Int32ToSVBT32( pAct->GetSize().Height(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
}
break;
@@ -2349,28 +2349,28 @@ BitmapChecksum GDIMetaFile::GetChecksum() const
BCToBCOA( pAct->GetBitmapEx().GetChecksum(), aBCOA );
nCrc = vcl_get_checksum( nCrc, aBCOA, BITMAP_CHECKSUM_SIZE );
UInt32ToSVBT32( pAct->GetDestPoint().X(), aBT32 );
Int32ToSVBT32( pAct->GetDestPoint().X(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetDestPoint().Y(), aBT32 );
Int32ToSVBT32( pAct->GetDestPoint().Y(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetDestSize().Width(), aBT32 );
Int32ToSVBT32( pAct->GetDestSize().Width(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetDestSize().Height(), aBT32 );
Int32ToSVBT32( pAct->GetDestSize().Height(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSrcPoint().X(), aBT32 );
Int32ToSVBT32( pAct->GetSrcPoint().X(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSrcPoint().Y(), aBT32 );
Int32ToSVBT32( pAct->GetSrcPoint().Y(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSrcSize().Width(), aBT32 );
Int32ToSVBT32( pAct->GetSrcSize().Width(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSrcSize().Height(), aBT32 );
Int32ToSVBT32( pAct->GetSrcSize().Height(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
}
break;
@@ -2388,10 +2388,10 @@ BitmapChecksum GDIMetaFile::GetChecksum() const
UInt32ToSVBT32( sal_uInt32(pAct->GetColor()), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetPoint().X(), aBT32 );
Int32ToSVBT32( pAct->GetPoint().X(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetPoint().Y(), aBT32 );
Int32ToSVBT32( pAct->GetPoint().Y(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
}
break;
@@ -2409,16 +2409,16 @@ BitmapChecksum GDIMetaFile::GetChecksum() const
UInt32ToSVBT32( sal_uInt32(pAct->GetColor()), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetPoint().X(), aBT32 );
Int32ToSVBT32( pAct->GetPoint().X(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetPoint().Y(), aBT32 );
Int32ToSVBT32( pAct->GetPoint().Y(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSize().Width(), aBT32 );
Int32ToSVBT32( pAct->GetSize().Width(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSize().Height(), aBT32 );
Int32ToSVBT32( pAct->GetSize().Height(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
}
break;
@@ -2436,28 +2436,28 @@ BitmapChecksum GDIMetaFile::GetChecksum() const
UInt32ToSVBT32( sal_uInt32(pAct->GetColor()), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetDestPoint().X(), aBT32 );
Int32ToSVBT32( pAct->GetDestPoint().X(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetDestPoint().Y(), aBT32 );
Int32ToSVBT32( pAct->GetDestPoint().Y(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetDestSize().Width(), aBT32 );
Int32ToSVBT32( pAct->GetDestSize().Width(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetDestSize().Height(), aBT32 );
Int32ToSVBT32( pAct->GetDestSize().Height(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSrcPoint().X(), aBT32 );
Int32ToSVBT32( pAct->GetSrcPoint().X(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSrcPoint().Y(), aBT32 );
Int32ToSVBT32( pAct->GetSrcPoint().Y(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSrcSize().Width(), aBT32 );
Int32ToSVBT32( pAct->GetSrcSize().Width(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
UInt32ToSVBT32( pAct->GetSrcSize().Height(), aBT32 );
Int32ToSVBT32( pAct->GetSrcSize().Height(), aBT32 );
nCrc = vcl_get_checksum( nCrc, aBT32, 4 );
}
break;