summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2019-02-20 12:04:24 +0100
committerMike Kaganski <mike.kaganski@collabora.com>2019-02-20 22:01:41 +0100
commit4458109430f837fc3141067aaddf490b10364ff2 (patch)
tree2c1215dc599d640ea32ed566f1f00418e7ce333d /sw
parent8193e697d286595aa62859011761adeb002244e3 (diff)
Avoid meaningless string<->integer conversions
Change-Id: I4b86636cc4e4884459d59d1df9949505274bde9e Reviewed-on: https://gerrit.libreoffice.org/68069 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/filter/ww8/docxsdrexport.cxx45
1 files changed, 4 insertions, 41 deletions
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index 114cbce5ac10..425f9bd5fa0a 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -710,47 +710,10 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons
* 2147483647( MAX_INTEGER_VALUE ).
* Therefore changing the following accordingly so that LO sync's up with MSO.
**/
- sal_uInt64 cx = 0;
- sal_uInt64 cy = 0;
- const sal_Int64 MAX_INTEGER_VALUE = SAL_MAX_INT32;
-
- // the 'Size' type uses 'long' for width and height, so on
- // platforms where 'long' is 32 bits they can obviously never be
- // larger than the max signed 32-bit integer.
-#if SAL_TYPES_SIZEOFLONG > 4
- if (rSize.Width() > MAX_INTEGER_VALUE)
- cx = MAX_INTEGER_VALUE;
- else
-#endif
- {
- if (0 > rSize.Width())
- cx = 0;
- else
- cx = rSize.Width();
- }
-
-#if SAL_TYPES_SIZEOFLONG > 4
- if (rSize.Height() > MAX_INTEGER_VALUE)
- cy = MAX_INTEGER_VALUE;
- else
-#endif
- {
- if (0 > rSize.Height())
- cy = 0;
- else
- cy = rSize.Height();
- }
-
- OString aWidth(OString::number(TwipsToEMU(cx)));
- //we explicitly check the converted EMU value for the range as mentioned in above comment.
- aWidth = (aWidth.toInt64() > 0 ? (aWidth.toInt64() > MAX_INTEGER_VALUE ? I64S(MAX_INTEGER_VALUE)
- : aWidth.getStr())
- : "0");
- OString aHeight(OString::number(TwipsToEMU(cy)));
- aHeight
- = (aHeight.toInt64() > 0 ? (aHeight.toInt64() > MAX_INTEGER_VALUE ? I64S(MAX_INTEGER_VALUE)
- : aHeight.getStr())
- : "0");
+ sal_uInt64 cx = TwipsToEMU(std::clamp(rSize.Width(), 0L, long(SAL_MAX_INT32)));
+ OString aWidth(OString::number(std::min(cx, sal_uInt64(SAL_MAX_INT32))));
+ sal_uInt64 cy = TwipsToEMU(std::clamp(rSize.Height(), 0L, long(SAL_MAX_INT32)));
+ OString aHeight(OString::number(std::min(cy, sal_uInt64(SAL_MAX_INT32))));
m_pImpl->getSerializer()->singleElementNS(XML_wp, XML_extent, XML_cx, aWidth, XML_cy, aHeight,
FSEND);