summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/source/ui/sidebar/AlignmentPropertyPanel.cxx33
-rw-r--r--svx/source/sidebar/possize/PosSizePropertyPanel.cxx28
2 files changed, 44 insertions, 17 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(
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);