diff options
-rw-r--r-- | include/vcl/outdev.hxx | 8 | ||||
-rw-r--r-- | vcl/source/outdev/map.cxx | 41 | ||||
-rw-r--r-- | vcl/source/outdev/polyline.cxx | 9 |
3 files changed, 54 insertions, 4 deletions
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index f5f398a1e0b9..a80b49c2239b 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -1787,6 +1787,14 @@ public: */ SAL_DLLPRIVATE tools::Polygon ImplLogicToDevicePixel( const tools::Polygon& rLogicPoly ) const; + /** Convert a logical B2DPolygon to a B2DPolygon in physical device pixel units. + + @param rLogicSize Const reference to a B2DPolygon in logical units + + @returns B2DPolyPolygon based on physical device pixel coordinates and units. + */ + SAL_DLLPRIVATE ::basegfx::B2DPolygon ImplLogicToDevicePixel( const ::basegfx::B2DPolygon& rLogicPoly ) const; + /** Convert a logical polypolygon to a polypolygon in physical device pixel units. @param rLogicPolyPoly Const reference to a polypolygon in logical units diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx index 4761062c820c..3410157d2d15 100644 --- a/vcl/source/outdev/map.cxx +++ b/vcl/source/outdev/map.cxx @@ -268,6 +268,14 @@ static tools::Long ImplLogicToPixel(tools::Long n, tools::Long nDPI, tools::Long return n; } +static double ImplLogicToPixel(double n, tools::Long nDPI, tools::Long nMapNum, + tools::Long nMapDenom) +{ + assert(nDPI > 0); + assert(nMapDenom != 0); + return n * nMapNum * nDPI / nMapDenom; +} + static tools::Long ImplPixelToLogic(tools::Long n, tools::Long nDPI, tools::Long nMapNum, tools::Long nMapDenom) { @@ -457,6 +465,39 @@ tools::Polygon OutputDevice::ImplLogicToDevicePixel( const tools::Polygon& rLogi return aPoly; } +basegfx::B2DPolygon OutputDevice::ImplLogicToDevicePixel(const basegfx::B2DPolygon& rLogicPoly) const +{ + if (!mbMap && !mnOutOffX && !mnOutOffY) + return rLogicPoly; + + sal_uInt32 nPoints = rLogicPoly.count(); + basegfx::B2DPolygon aPoly(rLogicPoly); + + if (mbMap) + { + for (sal_uInt32 i = 0; i < nPoints; ++i) + { + const basegfx::B2DPoint& rPt = aPoly.getB2DPoint(i); + basegfx::B2DPoint aPt(ImplLogicToPixel( rPt.getX()+maMapRes.mnMapOfsX, mnDPIX, + maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX )+mnOutOffX+mnOutOffOrigX, + ImplLogicToPixel( rPt.getY()+maMapRes.mnMapOfsY, mnDPIY, + maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY )+mnOutOffY+mnOutOffOrigY); + aPoly.setB2DPoint(i, aPt); + } + } + else + { + for (sal_uInt32 i = 0; i < nPoints; ++i) + { + const basegfx::B2DPoint& rPt = aPoly.getB2DPoint(i); + basegfx::B2DPoint aPt(rPt.getX() + mnOutOffX, rPt.getY() + mnOutOffY); + aPoly.setB2DPoint(i, aPt); + } + } + + return aPoly; +} + tools::PolyPolygon OutputDevice::ImplLogicToDevicePixel( const tools::PolyPolygon& rLogicPolyPoly ) const { if ( !mbMap && !mnOutOffX && !mnOutOffY ) diff --git a/vcl/source/outdev/polyline.cxx b/vcl/source/outdev/polyline.cxx index e3ec909c733b..aeeb90845bd1 100644 --- a/vcl/source/outdev/polyline.cxx +++ b/vcl/source/outdev/polyline.cxx @@ -248,8 +248,6 @@ void OutputDevice::drawPolyLine(const tools::Polygon& rPoly, const LineInfo& rLi if ( !IsDeviceOutputNecessary() || !mbLineColor || ( nPoints < 2 ) || ( LineStyle::NONE == rLineInfo.GetStyle() ) || ImplIsRecordLayout() ) return; - tools::Polygon aPoly = ImplLogicToDevicePixel( rPoly ); - // we need a graphics if ( !mpGraphics && !AcquireGraphics() ) return; @@ -268,12 +266,15 @@ void OutputDevice::drawPolyLine(const tools::Polygon& rPoly, const LineInfo& rLi const bool bDashUsed(LineStyle::Dash == aInfo.GetStyle()); const bool bLineWidthUsed(aInfo.GetWidth() > 1); - if(bDashUsed || bLineWidthUsed) + if (bDashUsed || bLineWidthUsed) { - drawLine ( basegfx::B2DPolyPolygon(aPoly.getB2DPolygon()), aInfo ); + basegfx::B2DPolygon aPoly = ImplLogicToDevicePixel(rPoly.getB2DPolygon()); + drawLine(basegfx::B2DPolyPolygon(aPoly), aInfo); } else { + tools::Polygon aPoly = ImplLogicToDevicePixel(rPoly); + // #100127# the subdivision HAS to be done here since only a pointer // to an array of points is given to the DrawPolyLine method, there is // NO way to find out there that it's a curve. |