You've already forked lazarus-ccr
fpspreadsheet: Remove reduncant code when comparing fonts
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4311 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -1332,23 +1332,14 @@ end;
|
||||
{******************************************************************************}
|
||||
function FindFontInList(AFontList: TFPList; AFontName: String; ASize: Single;
|
||||
AStyle: TsFontStyles; AColor: TsColor; APos: TsFontPosition): Integer;
|
||||
const
|
||||
EPS = 1e-3;
|
||||
var
|
||||
fnt: TsFont;
|
||||
begin
|
||||
for Result := 0 to AFontList.Count-1 do
|
||||
begin
|
||||
fnt := TsFont(AFontList.Items[Result]);
|
||||
if (fnt <> nil) and
|
||||
SameText(AFontName, fnt.FontName) and
|
||||
SameValue(ASize, fnt.Size, EPS) and // careful when comparing floating point numbers
|
||||
(AStyle = fnt.Style) and
|
||||
(AColor = fnt.Color) and
|
||||
(APos = fnt.Position)
|
||||
if SameFont(
|
||||
TsFont(AFontList.Items[Result]),
|
||||
AFontName, ASize, AStyle, AColor, APos
|
||||
)
|
||||
then
|
||||
exit;
|
||||
end;
|
||||
Result := -1;
|
||||
end;
|
||||
|
||||
|
@ -148,7 +148,9 @@ procedure InitPageLayout(out APageLayout: TsPageLayout);
|
||||
procedure CopyCellValue(AFromCell, AToCell: PCell);
|
||||
function HasFormula(ACell: PCell): Boolean;
|
||||
function SameCellBorders(AFormat1, AFormat2: PsCellFormat): Boolean;
|
||||
function SameFont(AFont1, AFont2: TsFont): Boolean;
|
||||
function SameFont(AFont1, AFont2: TsFont): Boolean; overload;
|
||||
function SameFont(AFont: TsFont; AFontName: String; AFontSize: Single;
|
||||
AStyle: TsFontStyles; AColor: TsColor; APos: TsFontPosition): Boolean; overload;
|
||||
|
||||
function GetUniqueTempDir(Global: Boolean): String;
|
||||
|
||||
@ -1919,21 +1921,39 @@ end;
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Checks whether two fonts are equal
|
||||
|
||||
@param AFormat1 Pointer to the first font to be compared
|
||||
@param AFormat2 Pointer to the second font to be compared
|
||||
@param AFont1 Pointer to the first font to be compared
|
||||
@param AFont2 Pointer to the second font to be compared
|
||||
-------------------------------------------------------------------------------}
|
||||
function SameFont(AFont1, AFont2: TsFont): Boolean;
|
||||
const
|
||||
EPS = 1E-3;
|
||||
begin
|
||||
Result := (AFont1 <> nil) and (AFont2 <> nil) and
|
||||
SameText(AFont1.FontName, AFont2.FontName) and
|
||||
SameValue(AFont1.Size, AFont2.Size, EPS) and
|
||||
(AFont1.Color = AFont2.Color) and
|
||||
(AFont1.Style = AFont2.Style) and
|
||||
(AFont1.Position = AFont2.Position);
|
||||
if (AFont1 = nil) and (AFont2 = nil) then
|
||||
Result := true;
|
||||
Result := true
|
||||
else
|
||||
if (AFont2 <> nil) then
|
||||
Result := SameFont(AFont1, AFont2.FontName, AFont2.Size, AFont2.Style, AFont2.Color, AFont2.Position)
|
||||
else
|
||||
Result := false;
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Checks whether two fonts are equal
|
||||
|
||||
@param AFont1 Pointer to the first font to be compared
|
||||
@param AFont2 Pointer to the second font to be compared
|
||||
-------------------------------------------------------------------------------}
|
||||
function SameFont(AFont: TsFont; AFontName: String; AFontSize: Single;
|
||||
AStyle: TsFontStyles; AColor: TsColor; APos: TsFontPosition): Boolean;
|
||||
const
|
||||
EPS = 1E-3;
|
||||
begin
|
||||
Result := (AFont <> nil) and
|
||||
SameText(AFont.FontName, AFontName) and
|
||||
SameValue(AFont.Size, AFontSize, EPS) and
|
||||
(AFont.Style = AStyle) and
|
||||
(AFont.Color = AColor) and
|
||||
(AFont.Position = APos);
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user