summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2015-01-29 22:57:13 +0100
committerCaolán McNamara <caolanm@redhat.com>2015-01-30 11:34:36 +0000
commitc0001928ceff2e50b7884e352a57f4dba7dca891 (patch)
tree5538007d9dd2dd0c83dfd8d9c54293fa36cc2771 /sc
parentd9a587c91d2cc5864c00c9f04fa4942aebb2481e (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 'sc')
-rw-r--r--sc/source/ui/sidebar/AlignmentPropertyPanel.cxx33
1 files changed, 27 insertions, 6 deletions
diff --git a/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx b/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx
index bdc61d7d7371..9326d6e0b5ed 100644
--- a/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx
+++ b/sc/source/ui/sidebar/AlignmentPropertyPanel.cxx
@@ -26,6 +26,8 @@
#include <svx/algitem.hxx>
#include <svx/dlgutil.hxx>
#include <vcl/toolbox.hxx>
+#include <vcl/settings.hxx>
+#include <vcl/svapp.hxx>
#include <svx/sidebar/SidebarDialControl.hxx>
using namespace css;
@@ -113,16 +115,35 @@ void AlignmentPropertyPanel::Initialize()
IMPL_LINK( AlignmentPropertyPanel, AngleModifiedHdl, void *, EMPTYARG )
{
OUString sTmp = mpMtrAngle->GetText();
+ if (sTmp.isEmpty())
+ return 0;
+ sal_Unicode nChar = sTmp[0];
+ if( nChar == '-' )
+ {
+ if (sTmp.getLength() < 2)
+ return 0;
+ nChar = sTmp[1];
+ }
+
+ if( (nChar < '0') || (nChar > '9') )
+ return 0;
- sal_Unicode nChar = sTmp.isEmpty() ? 0 : sTmp[0];
- if((sTmp.getLength()== 1 && nChar == '-') ||
- (nChar != '-' && ((nChar < '0') || (nChar > '9') ) )) ////modify
+ const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
+ const sal_Unicode cSep = rLocaleWrapper.getNumDecimalSep()[0];
+
+ // 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;
- double dTmp = sTmp.toDouble();
- FormatDegrees(dTmp);
+ FormatDegrees(fTmp);
- sal_Int64 nTmp = (sal_Int64)dTmp*100;
+ sal_Int64 nTmp = (sal_Int64)fTmp*100;
SfxInt32Item aAngleItem( SID_ATTR_ALIGN_DEGREES,(sal_uInt32) nTmp);
GetBindings()->GetDispatcher()->Execute(