From 49effd635f60be8032ce6e8933adf46ae119b4f5 Mon Sep 17 00:00:00 2001 From: jesus Date: Wed, 8 May 2013 06:57:43 +0000 Subject: [PATCH] LazReport, fix reading barcode zoom values when decimal separator=',', issue #24393 git-svn-id: trunk@41070 - --- components/lazreport/source/lr_class.pas | 12 +++++++----- components/lazreport/source/lr_utils.pas | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/components/lazreport/source/lr_class.pas b/components/lazreport/source/lr_class.pas index be2a4a4fab..57af198525 100644 --- a/components/lazreport/source/lr_class.pas +++ b/components/lazreport/source/lr_class.pas @@ -11634,7 +11634,6 @@ end; function TfrObject.GetSaveProperty(const Prop: String; aObj : TPersistent=nil): string; Var PropInfo : PPropInfo; Obj : TObject; - OldSep : char; begin Result:=''; @@ -11657,10 +11656,9 @@ begin end; tkSet : Result:=GetSetProp(aObj,Prop); tkFloat : begin - OldSep := DecimalSeparator; - DecimalSeparator := '.'; + lrNormalizeLocaleFloats(True); Result := FloatToStr(GetFloatProp(aObj,Prop)); - DecimalSeparator := OldSep; + lrNormalizeLocaleFloats(false); end; tkEnumeration : Result:=GetEnumProp(aObj,Prop); tkClass : Begin @@ -11700,7 +11698,11 @@ begin SetOrdProp(aObj,PropInfo,StrToInt(aValue)) end; tkSet : SetSetProp(aObj,Prop,aValue); - tkFloat : SetFloatProp(aObj,Prop,StrToFloat(aValue)); + tkFloat : begin + lrNormalizeLocaleFloats(true); + SetFloatProp(aObj,Prop,StrToFloat(aValue)); + lrNormalizeLocaleFloats(false); + end; tkEnumeration : SetEnumProp(aObj,Prop,aValue); tkClass : Begin Obj:=GetObjectProp(aObj,Prop); diff --git a/components/lazreport/source/lr_utils.pas b/components/lazreport/source/lr_utils.pas index f52ba7d8fa..15b16ad118 100644 --- a/components/lazreport/source/lr_utils.pas +++ b/components/lazreport/source/lr_utils.pas @@ -67,6 +67,7 @@ function lrValidFieldReference(s: string):boolean; function lrDateTimeToStr(ADate:TDateTime):string; function lrStrToDateTime(AValue: string): TDateTime; function lrExpandVariables(const S:string):string; +procedure lrNormalizeLocaleFloats(DisableLocale: boolean); // utf8 tools function UTF8Desc(S:string; var Desc: string): Integer; @@ -82,6 +83,9 @@ implementation uses LR_Class, LR_Const, LR_Pars; +var + PreviousFormatSettings: TFormatSettings; + procedure frInitFont(aFont : TFont; aColor : TColor; aSize : Integer; aStyle : TFontStyles); begin with aFont do @@ -727,6 +731,16 @@ begin Result:=Result + Copy(S, K, I-K); end; +procedure lrNormalizeLocaleFloats(DisableLocale: boolean); +begin + if DisableLocale then + begin + PreviousFormatSettings := DefaultFormatSettings; + DefaultFormatSettings.DecimalSeparator := '.'; + end else + DefaultFormatSettings := PreviousFormatSettings; +end; + function UTF8Desc(S: string; var Desc: string): Integer; var i,b: Integer;