Skip to content

Commit 353f77b

Browse files
author
ArthurHub
committed
* remove undeeded casts after float to double change
1 parent 23cb30f commit 353f77b

7 files changed

Lines changed: 28 additions & 28 deletions

File tree

Source/HtmlRenderer.PdfSharp/Utilities/Utils.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ internal static class Utils
2525
/// </summary>
2626
public static RPoint Convert(XPoint p)
2727
{
28-
return new RPoint((float)p.X, (float)p.Y);
28+
return new RPoint(p.X, p.Y);
2929
}
3030

3131
/// <summary>
@@ -52,7 +52,7 @@ public static XPoint Convert(RPoint p)
5252
/// </summary>
5353
public static RSize Convert(XSize s)
5454
{
55-
return new RSize((float)s.Width, (float)s.Height);
55+
return new RSize(s.Width, s.Height);
5656
}
5757

5858
/// <summary>
@@ -68,7 +68,7 @@ public static XSize Convert(RSize s)
6868
/// </summary>
6969
public static RRect Convert(XRect r)
7070
{
71-
return new RRect((float)r.X, (float)r.Y, (float)r.Width, (float)r.Height);
71+
return new RRect(r.X, r.Y, r.Width, r.Height);
7272
}
7373

7474
/// <summary>

Source/HtmlRenderer/Core/Dom/CssBoxFrame.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,8 @@ protected override void PaintImp(IGraphics g)
413413
tmpRect.Offset(offset);
414414
tmpRect.Height -= ActualBorderTopWidth + ActualBorderBottomWidth + ActualPaddingTop + ActualPaddingBottom;
415415
tmpRect.Y += ActualBorderTopWidth + ActualPaddingTop;
416-
tmpRect.X = (double)Math.Floor(tmpRect.X);
417-
tmpRect.Y = (double)Math.Floor(tmpRect.Y);
416+
tmpRect.X = Math.Floor(tmpRect.X);
417+
tmpRect.Y = Math.Floor(tmpRect.Y);
418418
var rect = tmpRect;
419419

420420
DrawImage(g, offset, rect);

Source/HtmlRenderer/Core/Dom/CssBoxImage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ protected override void PaintImp(IGraphics g)
9090
r.Offset(offset);
9191
r.Height -= ActualBorderTopWidth + ActualBorderBottomWidth + ActualPaddingTop + ActualPaddingBottom;
9292
r.Y += ActualBorderTopWidth + ActualPaddingTop;
93-
r.X = (double) Math.Floor(r.X);
94-
r.Y = (double)Math.Floor(r.Y);
93+
r.X = Math.Floor(r.X);
94+
r.Y = Math.Floor(r.Y);
9595

9696
if (_imageWord.Image != null)
9797
{

Source/HtmlRenderer/Core/Handlers/BordersDrawHandler.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,16 @@ private static void DrawBorder(Border border, CssBox box, IGraphics g, RRect rec
126126
switch (border)
127127
{
128128
case Border.Top:
129-
g.DrawLine(pen, (double)Math.Ceiling(rect.Left), rect.Top + box.ActualBorderTopWidth / 2, rect.Right - 1, rect.Top + box.ActualBorderTopWidth / 2);
129+
g.DrawLine(pen, Math.Ceiling(rect.Left), rect.Top + box.ActualBorderTopWidth / 2, rect.Right - 1, rect.Top + box.ActualBorderTopWidth / 2);
130130
break;
131131
case Border.Left:
132-
g.DrawLine(pen, rect.Left + box.ActualBorderLeftWidth / 2, (double)Math.Ceiling(rect.Top), rect.Left + box.ActualBorderLeftWidth / 2, (double)Math.Floor(rect.Bottom));
132+
g.DrawLine(pen, rect.Left + box.ActualBorderLeftWidth / 2, Math.Ceiling(rect.Top), rect.Left + box.ActualBorderLeftWidth / 2, Math.Floor(rect.Bottom));
133133
break;
134134
case Border.Bottom:
135-
g.DrawLine(pen, (double)Math.Ceiling(rect.Left), rect.Bottom - box.ActualBorderBottomWidth / 2, rect.Right - 1, rect.Bottom - box.ActualBorderBottomWidth / 2);
135+
g.DrawLine(pen, Math.Ceiling(rect.Left), rect.Bottom - box.ActualBorderBottomWidth / 2, rect.Right - 1, rect.Bottom - box.ActualBorderBottomWidth / 2);
136136
break;
137137
case Border.Right:
138-
g.DrawLine(pen, rect.Right - box.ActualBorderRightWidth / 2, (double)Math.Ceiling(rect.Top), rect.Right - box.ActualBorderRightWidth / 2, (double)Math.Floor(rect.Bottom));
138+
g.DrawLine(pen, rect.Right - box.ActualBorderRightWidth / 2, Math.Ceiling(rect.Top), rect.Right - box.ActualBorderRightWidth / 2, Math.Floor(rect.Bottom));
139139
break;
140140
}
141141
}

Source/HtmlRenderer/Entities/RPoint.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ public double Y
162162
/// <filterpriority>3</filterpriority>
163163
public static bool operator ==(RPoint left, RPoint right)
164164
{
165-
if( left.X == (double)right.X )
166-
return left.Y == (double)right.Y;
165+
if( left.X == right.X )
166+
return left.Y == right.Y;
167167
else
168168
return false;
169169
}
@@ -256,7 +256,7 @@ public override bool Equals(object obj)
256256
if( !( obj is RPoint ) )
257257
return false;
258258
var pointF = (RPoint)obj;
259-
if( pointF.X == (double)X && pointF.Y == (double)Y )
259+
if( pointF.X == X && pointF.Y == Y )
260260
return pointF.GetType().Equals(GetType());
261261
else
262262
return false;

Source/HtmlRenderer/Entities/RRect.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ public bool IsEmpty
233233
/// </param>
234234
public static bool operator ==(RRect left, RRect right)
235235
{
236-
if( Math.Abs(left.X - (double)right.X) < 0.001 && Math.Abs(left.Y - (double)right.Y) < 0.001 && Math.Abs(left.Width - (double)right.Width) < 0.001 )
237-
return Math.Abs(left.Height - (double)right.Height) < 0.001;
236+
if( Math.Abs(left.X - right.X) < 0.001 && Math.Abs(left.Y - right.Y) < 0.001 && Math.Abs(left.Width - right.Width) < 0.001 )
237+
return Math.Abs(left.Height - right.Height) < 0.001;
238238
else
239239
return false;
240240
}
@@ -289,8 +289,8 @@ public override bool Equals(object obj)
289289
if( !( obj is RRect ) )
290290
return false;
291291
var rectangleF = (RRect)obj;
292-
if( Math.Abs(rectangleF.X - (double)X) < 0.001 && Math.Abs(rectangleF.Y - (double)Y) < 0.001 && Math.Abs(rectangleF.Width - (double)Width) < 0.001 )
293-
return Math.Abs(rectangleF.Height - (double)Height) < 0.001;
292+
if( Math.Abs(rectangleF.X - X) < 0.001 && Math.Abs(rectangleF.Y - Y) < 0.001 && Math.Abs(rectangleF.Width - Width) < 0.001 )
293+
return Math.Abs(rectangleF.Height - Height) < 0.001;
294294
else
295295
return false;
296296
}
@@ -307,8 +307,8 @@ public override bool Equals(object obj)
307307
/// <param name="y">The y-coordinate of the point to test. </param>
308308
public bool Contains(double x, double y)
309309
{
310-
if( X <= (double)x && x < X + (double)Width && Y <= (double)y )
311-
return y < Y + (double)Height;
310+
if( X <= x && x < X + Width && Y <= y )
311+
return y < Y + Height;
312312
else
313313
return false;
314314
}
@@ -342,8 +342,8 @@ public bool Contains(RPoint pt)
342342
/// </param>
343343
public bool Contains(RRect rect)
344344
{
345-
if( X <= (double)rect.X && rect.X + (double)rect.Width <= X + (double)Width && Y <= (double)rect.Y )
346-
return rect.Y + (double)rect.Height <= Y + (double)Height;
345+
if( X <= rect.X && rect.X + rect.Width <= X + Width && Y <= rect.Y )
346+
return rect.Y + rect.Height <= Y + Height;
347347
else
348348
return false;
349349
}
@@ -425,7 +425,7 @@ public static RRect Intersect(RRect a, RRect b)
425425
double num1 = Math.Min(a.X + a.Width, b.X + b.Width);
426426
double y = Math.Max(a.Y, b.Y);
427427
double num2 = Math.Min(a.Y + a.Height, b.Y + b.Height);
428-
if( num1 >= (double)x && num2 >= (double)y )
428+
if( num1 >= x && num2 >= y )
429429
return new RRect(x, y, num1 - x, num2 - y);
430430
else
431431
return Empty;
@@ -440,8 +440,8 @@ public static RRect Intersect(RRect a, RRect b)
440440
/// <param name="rect">The rectangle to test. </param>
441441
public bool IntersectsWith(RRect rect)
442442
{
443-
if( rect.X < X + (double)Width && X < rect.X + (double)rect.Width && rect.Y < Y + (double)Height )
444-
return Y < rect.Y + (double)rect.Height;
443+
if( rect.X < X + Width && X < rect.X + rect.Width && rect.Y < Y + Height )
444+
return Y < rect.Y + rect.Height;
445445
else
446446
return false;
447447
}

Source/HtmlRenderer/Entities/RSize.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ public static explicit operator RPoint(RSize size)
204204
/// <filterpriority>3</filterpriority>
205205
public static bool operator ==(RSize sz1, RSize sz2)
206206
{
207-
if( Math.Abs(sz1.Width - (double)sz2.Width) < 0.001 )
208-
return Math.Abs(sz1.Height - (double)sz2.Height) < 0.001;
207+
if( Math.Abs(sz1.Width - sz2.Width) < 0.001 )
208+
return Math.Abs(sz1.Height - sz2.Height) < 0.001;
209209
else
210210
return false;
211211
}
@@ -292,7 +292,7 @@ public override bool Equals(object obj)
292292
if( !( obj is RSize ) )
293293
return false;
294294
var sizeF = (RSize)obj;
295-
if( Math.Abs(sizeF.Width - (double)Width) < 0.001 && Math.Abs(sizeF.Height - (double)Height) < 0.001 )
295+
if( Math.Abs(sizeF.Width - Width) < 0.001 && Math.Abs(sizeF.Height - Height) < 0.001 )
296296
return sizeF.GetType() == GetType();
297297
else
298298
return false;

0 commit comments

Comments
 (0)