diff --git a/components/fpvectorial/fpvectorial.pas b/components/fpvectorial/fpvectorial.pas index 8a00b2bd3c..c12b3fae5d 100644 --- a/components/fpvectorial/fpvectorial.pas +++ b/components/fpvectorial/fpvectorial.pas @@ -1399,7 +1399,7 @@ type function GenerateDebugTree(ADestRoutine: TvDebugAddItemProc; APageItem: Pointer): Pointer; override; end; - TvVectorialReaderFlag = (vrfSVG_UseTopLeftCoords); + TvVectorialReaderFlag = (vrfSVG_UseTopLeftCoords, vrfWMF_UseTopLeftCoords); TvVectorialReaderFlags = set of TvVectorialReaderFlag; TvVectorialReaderSettings = record @@ -5853,6 +5853,8 @@ begin curDimY := IfThen(AMulY < 0, curDimY - (lFontSizePx * (1 + LINE_SPACING) * AMulY), curDimY + (lFontSizePx * (1 + LINE_SPACING) * AMulY)); + // wp: isn't this the same as + // curDimY := curDimY + (lFontSizePx * (1 + LINE_SPACING) * abs(AMulY); end; end; diff --git a/components/fpvectorial/svgvectorialwriter.pas b/components/fpvectorial/svgvectorialwriter.pas index bf1d78b051..0f148cfd39 100644 --- a/components/fpvectorial/svgvectorialwriter.pas +++ b/components/fpvectorial/svgvectorialwriter.pas @@ -98,7 +98,7 @@ procedure TvSVGVectorialWriter.ConvertFPVCoordinatesToSVGCoordinates( const ASrcX, ASrcY: Double; var ADestX, ADestY: double); begin ADestX := ASrcX * FLOAT_PIXELS_PER_MILLIMETER; - if APage.HasNaturalRenderPos then + if APage.UseTopLeftCoordinates then ADestY := ASrcY * FLOAT_PIXELS_PER_MILLIMETER else ADestY := (APage.Height - ASrcY) * FLOAT_PIXELS_PER_MILLIMETER; end; diff --git a/components/fpvectorial/wmfvectorialreader.pas b/components/fpvectorial/wmfvectorialreader.pas index 23eda2095b..6580148b34 100644 --- a/components/fpvectorial/wmfvectorialreader.pas +++ b/components/fpvectorial/wmfvectorialreader.pas @@ -124,9 +124,6 @@ type procedure ReadFromStream(AStream: TStream; AData: TvVectorialDocument); override; end; -var - // Settings - gWMFVecReader_UseTopLeftCoords: Boolean = True; implementation @@ -801,7 +798,7 @@ var page: TvVectorialPage; prevX, prevY: Word; begin - page := AData.AddPage(gWMFVecReader_UseTopLeftCoords); + page := AData.AddPage(vrfWMF_UseTopLeftCoords in Settings.VecReaderFlags); while AStream.Position < AStream.Size do begin // Store the stream position where the current record begins @@ -999,31 +996,7 @@ begin SetLength(params, 0); end; -(* -procedure TvWMFVectorialReader.ReadRectangle(APage: TvVectorialPage; - const AParams: TParamArray); -// To do: not tested, having not test file -var - rectRec: PWMFRectRecord; // coordinates are SmallInt - poly: TvPolygon; - pts: array of T3DPoint; -begin - rectRec := PWMFRectRecord(@AParams[0]); - SetLength(pts, 5); - pts[0] := Make3DPoint(ScaleX(rectRec^.Left), ScaleY(rectRec^.Top)); - pts[1] := Make3DPoint(ScaleX(rectRec^.Right), ScaleY(rectRec^.Top)); - pts[2] := Make3DPoint(ScaleX(rectRec^.Right), ScaleY(rectRec^.Bottom)); - pts[3] := Make3DPoint(ScaleX(rectRec^.Left), ScaleY(rectRec^.Bottom)); - pts[4] := pts[0]; - - poly := TvPolygon.Create(APage); - poly.Points := pts; - poly.Pen := FCurrPen; - poly.Brush := FCurrBrush; - APage.AddEntity(poly); -end; - *) procedure TvWMFVectorialReader.ReadRectangle(APage: TvVectorialPage; const AParams: TParamArray; IsRounded: Boolean); var @@ -1043,9 +1016,9 @@ begin rect := TvRectangle.Create(APage); rect.X := ScaleX(rectRec^.Left); - rect.Y := ScaleY(rectRec^.Bottom); // since the axis goes down bottom and top are interchanged! - rect.CX := ScaleSizeX(rectRec^.Right - rectRec^.Left); - rect.CY := ScaleSizeY(rectRec^.Bottom - rectRec^.Top); // wmf: Top < Bottom! + rect.Y := ScaleY(rectRec^.Top); + rect.CX := ScaleSizeX(abs(rectRec^.Right - rectRec^.Left)); + rect.CY := ScaleSizeY(abs(rectRec^.Bottom - rectRec^.Top)); rect.RX := ScaleSizeX(rx); rect.RY := ScaleSizeY(ry); rect.Pen := FCurrPen; @@ -1358,7 +1331,13 @@ end; Coordinates will be increasing downwards, like in SVG } function TvWMFVectorialReader.ScaleY(y: Integer): Double; begin - Result := ScaleSizeY(y - FWindowOrigin.Y); // there is probably an issue with y direction +// Result := ScaleSizeY(y - FWindowOrigin.Y); // there is probably an issue with y direction + + if (vrfWMF_UseTopLeftCoords in Settings.VecReaderFlags) then + Result := ScaleSizeY(y - FWindowOrigin.Y) + else + Result := FPageHeight - ScaleSizeY(y); + // Result := FPageHeight - ScaleSizeY(y); end; diff --git a/components/fpvectorial/wmfvectorialwriter.pas b/components/fpvectorial/wmfvectorialwriter.pas index d7674e41a7..f503992c92 100644 --- a/components/fpvectorial/wmfvectorialwriter.pas +++ b/components/fpvectorial/wmfvectorialwriter.pas @@ -81,6 +81,7 @@ type procedure WriteBkColor(AStream: TStream; APage: TvVectorialPage); procedure WriteBkMode(AStream: TStream; AMode: Word); procedure WriteBrush(AStream: TStream; ABrush: TvBrush); + procedure WriteCircle(AStream: TStream; ACircle: TvCircle); procedure WriteEllipse(AStream: TStream; AEllipse: TvEllipse); procedure WriteEOF(AStream: TStream); procedure WriteExtText(AStream: TStream; AText: TvText); @@ -441,6 +442,35 @@ begin FCurrBrush := ABrush; end; +procedure TvWMFVectorialWriter.WriteCircle(AStream: TStream; + ACircle: TvCircle); +var + rec: TWMFRectRecord; + c, r: TPoint; +begin + WritePen(AStream, ACircle.Pen); + WriteBrush(AStream, ACircle.Brush); + c.x := ScaleX(ACircle.X); + c.y := ScaleY(ACircle.Y); + r.x := ScaleSizeX(ACircle.Radius); + r.y := ScaleSizeY(ACircle.Radius); + rec.Left := c.x - r.x; + rec.Right := c.x + r.x; + if FUseTopLeftCoordinates then begin + rec.Top := c.y - r.y; + rec.Bottom := c.y + r.y; + end else + begin + rec.Top := c.y + r.y; + reC.Bottom := c.y - r.y; + end; + UpdateBounds(rec.Left, rec.Top); + UpdateBounds(rec.Right, rec.Bottom); + + // WMF record header + parameters + WriteWMFRecord(AStream, META_ELLIPSE, rec, SizeOf(TWMFRectRecord)); +end; + procedure TvWMFVectorialWriter.WriteEllipse(AStream: TStream; AEllipse: TvEllipse); var @@ -466,6 +496,8 @@ begin WritePolygon(AStream, TvPolygon(AEntity)) else if AEntity is TvRectangle then WriteRectangle(AStream, TvRectangle(AEntity)) + else if AEntity is TvCircle then + WriteCircle(AStream, TvCircle(AEntity)) else if AEntity is TvEllipse then WriteEllipse(AStream, TvEllipse(AEntity)) else if AEntity is TvText then @@ -904,7 +936,7 @@ begin FWMFHeader.MaxRecordSize := 0; FBBox := Rect(0, 0, 0, 0); page := AData.GetPageAsVectorial(PAGE_INDEX); - FUseTopLeftCoordinates := page.HasNaturalRenderPos; + FUseTopLeftCoordinates := page.UseTopLeftCoordinates; // Prepare scaling PrepareScaling(page);