diff options
author | Michael Stahl <mstahl@redhat.com> | 2015-05-19 11:42:04 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2015-05-19 11:54:05 +0200 |
commit | d6c80f239ee7487e38ce17afdb02c160fca7d313 (patch) | |
tree | 97101b5c74a7204a3949fa9348bd5b0848c19e34 /tools/source | |
parent | 7cc23494dbadcd1ae0b94f6163ffe293857eb266 (diff) |
tools: check for data loss in WriteFraction
Currently it's only used in VCL's MapMode.
Change-Id: Ib8ce09fadc704bc4d592d333d4cf3bddc9185036
Diffstat (limited to 'tools/source')
-rw-r--r-- | tools/source/generic/fract.cxx | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tools/source/generic/fract.cxx b/tools/source/generic/fract.cxx index b5db1e02607a..72ce43d954f8 100644 --- a/tools/source/generic/fract.cxx +++ b/tools/source/generic/fract.cxx @@ -384,6 +384,12 @@ SvStream& WriteFraction( SvStream& rOStream, const Fraction& rFract ) rOStream.WriteInt32( 0 ); rOStream.WriteInt32( -1 ); } else { +#if OSL_DEBUG_LEVEL > 0 + // can only write 32 bits - check that no data is lost! + boost::rational<sal_Int64> copy(rFract.mpImpl->value); + rational_ReduceInaccurate(copy, 32); + assert(copy == rFract.mpImpl->value && "data loss in WriteFraction!"); +#endif rOStream.WriteInt32( rFract.mpImpl->value.numerator() ); rOStream.WriteInt32( rFract.mpImpl->value.denominator() ); } |