summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2015-01-29 22:57:13 +0100
committerAndras Timar <andras.timar@collabora.com>2015-02-06 13:13:37 +0100
commitcdf040bbf2cee33d56b9ec90a6a33bb389d8cf6d (patch)
treefe94bf7cc1086b5001211c1a00ead6dbb563c9c9 /svx
parent204f2e6473ae352eda45fbbab0191dc2bc395b6c (diff)
Resolves: tdf#88740 parse with locale decimal separator
And use a proper string to double conversion and early bail out conditions. (cherry picked from commit 1884c0bbd40f0ded41d7a1656cb64fb1f6368c36) tdf#88740 fix sidebar angle rotation i18n (cherry picked from commit 9a7bf47098fe69b5c6069372708918ef94a9d597) use a less ugly string to double conversion, tdf#88740 follow-up And check string length before accessing characters.. (cherry picked from commit 3ba5ac834780fc2565aff99e42dd8c3b2202fba3) 30355f3aaf77b1952e21050e3593e575571d7aaa ac3c2bf2f67f0cc7fc106515a875512771676e01 f97a25cd2cab0dccf2154465da7c1235ef3ca8c6 Backport: added vcl/settings.hxx Change-Id: I6c89dd850405ad74ebd175800131cdcac19a8c86 Reviewed-on: https://gerrit.libreoffice.org/14245 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/sidebar/possize/PosSizePropertyPanel.cxx28
1 files changed, 17 insertions, 11 deletions
diff --git a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
index b7573a1f7970..d0369dff671c 100644
--- a/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
+++ b/svx/source/sidebar/possize/PosSizePropertyPanel.cxx
@@ -492,12 +492,13 @@ IMPL_LINK( PosSizePropertyPanel, ClickAutoHdl, void *, EMPTYARG )
IMPL_LINK( PosSizePropertyPanel, AngleModifiedHdl, void *, EMPTYARG )
{
OUString sTmp = mpMtrAngle->GetText();
- bool bNegative = false;
+ if (sTmp.isEmpty())
+ return 0;
sal_Unicode nChar = sTmp[0];
-
if( nChar == '-' )
{
- bNegative = true;
+ if (sTmp.getLength() < 2)
+ return 0;
nChar = sTmp[1];
}
@@ -507,15 +508,20 @@ IMPL_LINK( PosSizePropertyPanel, AngleModifiedHdl, void *, EMPTYARG )
const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
const sal_Unicode cSep = rLocaleWrapper.getNumDecimalSep()[0];
- sTmp = sTmp.replace(cSep,'.'); // toDouble() expects decimal point
+ // Do not check that the entire string was parsed up to its end, there may
+ // be a degree symbol following the number. Note that this also means that
+ // the number recognized just stops at any non-matching character.
+ /* TODO: we could check for the degree symbol stop if there are no other
+ * cases with different symbol characters in any language? */
+ rtl_math_ConversionStatus eStatus;
+ double fTmp = rtl::math::stringToDouble( sTmp, cSep, 0, &eStatus);
+ if (eStatus != rtl_math_ConversionStatus_Ok)
+ return 0;
+
+ while (fTmp < 0)
+ fTmp += 360;
- double dTmp = sTmp.toDouble();
- if(bNegative)
- {
- while(dTmp<0)
- dTmp += 360;
- }
- sal_Int64 nTmp = dTmp*100;
+ sal_Int64 nTmp = fTmp*100;
// #i123993# Need to take UIScale into account when executing rotations
const double fUIScale(mpView && mpView->GetModel() ? double(mpView->GetModel()->GetUIScale()) : 1.0);