소스 검색

* Applied patch from Ondrej Pokorny, bug ID #30090

git-svn-id: trunk@33632 -
michael 9 년 전
부모
커밋
3d479ed732
2개의 변경된 파일15개의 추가작업 그리고 16개의 파일을 삭제
  1. 10 11
      packages/fcl-pdf/src/fppdf.pp
  2. 5 5
      packages/fcl-pdf/tests/fppdf_test.pas

+ 10 - 11
packages/fcl-pdf/src/fppdf.pp

@@ -382,12 +382,11 @@ type
   private
     FNumber: integer;
     FPos: TPDFCoord;
-    FWidth: integer;
-    FHeight: integer;
+    FSize: TPDFCoord;
   protected
     procedure Write(const AStream: TStream); override;
   public
-    constructor Create(Const ADocument : TPDFDocument; const ALeft, ABottom: TPDFFloat; AWidth, AHeight, ANumber: integer); overload;
+    constructor Create(Const ADocument : TPDFDocument; const ALeft, ABottom, AWidth, AHeight: TPDFFloat; ANumber: integer); overload;
   end;
 
 
@@ -853,7 +852,7 @@ type
     Function CreateDictionary : TPDFDictionary;
     Function CreateXRef : TPDFXRef;
     Function CreateArray : TPDFArray;
-    Function CreateImage(const ALeft, ABottom: TPDFFloat; AWidth, AHeight, ANumber: integer) : TPDFImage;
+    Function CreateImage(const ALeft, ABottom, AWidth, AHeight: TPDFFloat; ANumber: integer) : TPDFImage;
     Function AddFont(AName : String; AColor : TARGBColor = clBlack) : Integer; overload;
     Function AddFont(AFontFile: String; AName : String; AColor : TARGBColor = clBlack) : Integer; overload;
     Function AddLineStyleDef(ALineWidth : TPDFFloat; AColor : TARGBColor = clBlack; APenStyle : TPDFPenStyle = ppsSolid) : Integer;
@@ -1811,7 +1810,7 @@ begin
   p2.X := AWidth;
   p2.Y := AHeight;
   DoUnitConversion(p2);
-  AddObject(Document.CreateImage(p1.X, p1.Y, round(p2.X), round(p2.Y), ANumber));
+  AddObject(Document.CreateImage(p1.X, p1.Y, p2.X, p2.Y, ANumber));
 end;
 
 procedure TPDFPage.DrawImage(const APos: TPDFCoord; const AWidth, AHeight: TPDFFloat; const ANumber: integer);
@@ -2695,19 +2694,19 @@ end;
 procedure TPDFImage.Write(const AStream: TStream);
 begin
   WriteString('q'+CRLF, AStream);   // save graphics state
-  WriteString(IntToStr(FWidth)+' 0 0 '+IntToStr(FHeight)+' '+FloatStr( FPos.X)+' '+FloatStr( FPos.Y)+' cm'+CRLF, AStream);
+  WriteString(FloatStr(FSize.X)+' 0 0 '+FloatStr(FSize.Y)+' '+FloatStr( FPos.X)+' '+FloatStr( FPos.Y)+' cm'+CRLF, AStream);
   WriteString('/I'+IntToStr(FNumber)+' Do'+CRLF, AStream);
   WriteString('Q'+CRLF, AStream);   // restore graphics state
 end;
 
-constructor TPDFImage.Create(Const ADocument : TPDFDocument; const ALeft, ABottom: TPDFFloat; AWidth, AHeight, ANumber: integer);
+constructor TPDFImage.Create(const ADocument: TPDFDocument; const ALeft, ABottom, AWidth, AHeight: TPDFFloat; ANumber: integer);
 begin
   inherited Create(ADocument);
   FNumber:=ANumber;
   FPos.X:=ALeft;
   FPos.Y:=ABottom;
-  FWidth:=AWidth;
-  FHeight:=AHeight;
+  FSize.X:=AWidth;
+  FSize.Y:=AHeight;
 end;
 
 procedure TPDFLineStyle.Write(const AStream: TStream);
@@ -3934,8 +3933,8 @@ begin
   Result:=TPDFArray.Create(Self);
 end;
 
-function TPDFDocument.CreateImage(const ALeft, ABottom: TPDFFloat; AWidth,
-  AHeight, ANumber: integer): TPDFImage;
+function TPDFDocument.CreateImage(const ALeft, ABottom, AWidth,
+  AHeight: TPDFFloat; ANumber: integer): TPDFImage;
 begin
   Result:=TPDFImage.Create(Self,ALeft,ABottom,AWidth,AHeight,ANumber);
 end;

+ 5 - 5
packages/fcl-pdf/tests/fppdf_test.pas

@@ -1364,7 +1364,7 @@ begin
     AssertEquals('Failed on 2',
       // save graphics state
       'q'+CRLF+
-      '150 0 0 75  100  200 cm'+CRLF+
+      ' 150 0 0   75  100  200 cm'+CRLF+
       '/I1 Do'+CRLF+
       // restore graphics state
       'Q'+CRLF,
@@ -1391,7 +1391,7 @@ begin
   AssertEquals('Failed on 5',
     // save graphics state
     'q'+CRLF+
-    '200 0 0 100 28.35 785.31 cm'+CRLF+
+    ' 200 0 0  100 28.35 785.31 cm'+CRLF+
     '/I1 Do'+CRLF+
     // restore graphics state
     'Q'+CRLF,
@@ -1411,7 +1411,7 @@ begin
   AssertEquals('Failed on 10',
     // save graphics state
     'q'+CRLF+
-    '200 0 0 100 283.46 275.07 cm'+CRLF+
+    ' 200 0 0  100 283.46 275.07 cm'+CRLF+
     '/I1 Do'+CRLF+
     // restore graphics state
     'Q'+CRLF,
@@ -1435,7 +1435,7 @@ begin
   AssertEquals('Failed on 5',
     // save graphics state
     'q'+CRLF+
-    '57 0 0 28 28.35 785.31 cm'+CRLF+
+    '56.69 0 0 28.35 28.35 785.31 cm'+CRLF+
     '/I1 Do'+CRLF+
     // restore graphics state
     'Q'+CRLF,
@@ -1455,7 +1455,7 @@ begin
   AssertEquals('Failed on 10',
     // save graphics state
     'q'+CRLF+
-    '567 0 0 283 283.46 275.07 cm'+CRLF+
+    '566.93 0 0 283.46 283.46 275.07 cm'+CRLF+
     '/I1 Do'+CRLF+
     // restore graphics state
     'Q'+CRLF,