diff options
-rw-r--r-- | vcl/source/gdi/FileDefinitionWidgetDraw.cxx | 64 |
1 files changed, 28 insertions, 36 deletions
diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx index ae303d966897..a15010014aa4 100644 --- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx +++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx @@ -168,24 +168,18 @@ void drawFromDrawCommands(gfx::DrawRoot const& rDrawRoot, SalGraphics& rGraphics basegfx::B2DRange aInputRectangle(rRectangle.maRectangle); + double fDeltaX = aTargetSurface.getWidth() - aSVGRect.getWidth(); + double fDeltaY = aTargetSurface.getHeight() - aSVGRect.getHeight(); + basegfx::B2DRange aFinalRectangle( - aTargetSurface.getMinX() + aInputRectangle.getMinX(), - aTargetSurface.getMinY() + aInputRectangle.getMinY(), - aTargetSurface.getMaxX() - (aSVGRect.getMaxX() - aInputRectangle.getMaxX()), - aTargetSurface.getMaxY() - (aSVGRect.getMaxY() - aInputRectangle.getMaxY())); - - aInputRectangle.transform(basegfx::utils::createTranslateB2DHomMatrix( - -aInputRectangle.getMinX(), -aInputRectangle.getMinY())); - aInputRectangle.transform(basegfx::utils::createScaleB2DHomMatrix( - aFinalRectangle.getWidth() / aInputRectangle.getWidth(), - aFinalRectangle.getHeight() / aInputRectangle.getHeight())); - aInputRectangle.transform(basegfx::utils::createTranslateB2DHomMatrix( - aFinalRectangle.getMinX() - 0.5, - aFinalRectangle.getMinY() - - 0.5)); // compensate 0.5 for different interpretation of where the center of a pixel is + aInputRectangle.getMinX(), aInputRectangle.getMinY(), + aInputRectangle.getMaxX() + fDeltaX, aInputRectangle.getMaxY() + fDeltaY); + + aFinalRectangle.transform(basegfx::utils::createTranslateB2DHomMatrix( + aTargetSurface.getMinX() - 0.5, aTargetSurface.getMinY() - 0.5)); basegfx::B2DPolygon aB2DPolygon = basegfx::utils::createPolygonFromRect( - aInputRectangle, rRectangle.mnRx / aFinalRectangle.getWidth() * 2.0, + aFinalRectangle, rRectangle.mnRx / aFinalRectangle.getWidth() * 2.0, rRectangle.mnRy / aFinalRectangle.getHeight() * 2.0); if (rRectangle.mpFillColor) @@ -209,29 +203,27 @@ void drawFromDrawCommands(gfx::DrawRoot const& rDrawRoot, SalGraphics& rGraphics { auto const& rPath = static_cast<gfx::DrawPath const&>(*pDrawBase); - basegfx::B2DRange aPolyPolygonRange(rPath.maPolyPolygon.getB2DRange()); - basegfx::B2DPolyPolygon aPolyPolygon(rPath.maPolyPolygon); - - basegfx::B2DRange aFinalRectangle( - aTargetSurface.getMinX() + aPolyPolygonRange.getMinX(), - aTargetSurface.getMinY() + aPolyPolygonRange.getMinY(), - aTargetSurface.getMaxX() - (aSVGRect.getMaxX() - aPolyPolygonRange.getMaxX()), - aTargetSurface.getMaxY() - (aSVGRect.getMaxY() - aPolyPolygonRange.getMaxY())); - - aPolyPolygon.transform(basegfx::utils::createTranslateB2DHomMatrix( - -aPolyPolygonRange.getMinX(), -aPolyPolygonRange.getMinY())); - - double fScaleX = 1.0; - double fScaleY = 1.0; - if (aPolyPolygonRange.getWidth() > 0.0) - fScaleX = aFinalRectangle.getWidth() / aPolyPolygonRange.getWidth(); - if (aPolyPolygonRange.getHeight() > 0.0) - fScaleY = aFinalRectangle.getHeight() / aPolyPolygonRange.getHeight(); - - aPolyPolygon.transform(basegfx::utils::createScaleB2DHomMatrix(fScaleX, fScaleY)); + double fDeltaX = aTargetSurface.getWidth() - aSVGRect.getWidth(); + double fDeltaY = aTargetSurface.getHeight() - aSVGRect.getHeight(); + basegfx::B2DPolyPolygon aPolyPolygon(rPath.maPolyPolygon); + for (auto& rPolygon : aPolyPolygon) + { + for (size_t i = 0; i < rPolygon.count(); ++i) + { + auto& rPoint = rPolygon.getB2DPoint(i); + double x = rPoint.getX(); + double y = rPoint.getY(); + + if (x > aSVGRect.getCenterX()) + x = x + fDeltaX; + if (y > aSVGRect.getCenterY()) + y = y + fDeltaY; + rPolygon.setB2DPoint(i, basegfx::B2DPoint(x, y)); + } + } aPolyPolygon.transform(basegfx::utils::createTranslateB2DHomMatrix( - aFinalRectangle.getMinX() - 0.5, aFinalRectangle.getMinY() - 0.5)); + aTargetSurface.getMinX() - 0.5, aTargetSurface.getMinY() - 0.5)); if (rPath.mpFillColor) { |