summaryrefslogtreecommitdiff
path: root/include/tools/fract.hxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-09-14 08:49:52 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-09-15 09:53:57 +0200
commit331e2e5ed3bf4e0b2c1fab3b7bca836170317827 (patch)
tree09fb12876006112c5bf5f8f33ec72641b828885c /include/tools/fract.hxx
parent54e608c6605ca2bcfd8dfdbe674d5110a18d2c5c (diff)
long->sal_Int32 in Fraction
because long is 32bits on Windows and 64bits on Linux. Reasoning: (a) all the users of Fraction used to be 32bit in the past (b) this makes the Linux code behave the same as the Windows code (c) changing it to 64bits would be dangerous because then call sites could see silent truncation. Change-Id: I2a36200623a3cf2e7d62ccad030a20614e1798fb Reviewed-on: https://gerrit.libreoffice.org/42200 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/tools/fract.hxx')
-rw-r--r--include/tools/fract.hxx13
1 files changed, 7 insertions, 6 deletions
diff --git a/include/tools/fract.hxx b/include/tools/fract.hxx
index 4cde7db061db..68c0984a19a5 100644
--- a/include/tools/fract.hxx
+++ b/include/tools/fract.hxx
@@ -25,8 +25,6 @@
class SvStream;
-// This class uses the platform defined type 'long' as valid values but do all
-// calculations using sal_Int64 with checks for 'long' overflows.
class SAL_WARN_UNUSED TOOLS_DLLPUBLIC Fraction final
{
struct Impl;
@@ -39,16 +37,19 @@ public:
Fraction();
Fraction( const Fraction & rFrac );
Fraction( Fraction && rFrac );
- Fraction( long nNum, long nDen );
+ Fraction( sal_Int64 nNum, sal_Int64 nDen );
explicit Fraction( double dVal );
~Fraction();
bool IsValid() const;
- long GetNumerator() const;
- long GetDenominator() const;
+ sal_Int32 GetNumerator() const;
+ sal_Int32 GetDenominator() const;
- explicit operator long() const;
+ explicit operator sal_Int32() const;
+#if SAL_TYPES_SIZEOFLONG == 8
+ explicit operator long() const { return sal_Int32(*this); }
+#endif
explicit operator double() const;
Fraction& operator=( const Fraction& rfrFrac );