drawinglayer/source/primitive2d/borderlineprimitive2d.cxx | 10 include/svtools/borderhelper.hxx | 17 - svtools/source/control/ctrlbox.cxx | 173 +++++--------- 3 files changed, 81 insertions(+), 119 deletions(-)
New commits: commit 600fa753ecaba0244d41ea82cc046664d26687de Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Wed Jan 15 16:37:03 2014 -0500 Distance value has been already scaled; no need to apply scaling twice. Change-Id: Id3ffc253dbd50fd23e924b4e1a349ab5c2c8518b diff --git a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx index 049e390..853ab7c 100644 --- a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx @@ -153,6 +153,9 @@ namespace drawinglayer nWidth = lcl_GetCorrectedWidth(nWidth, getStart(), getEnd(), rViewInformation); + // distance is already scaled. + double fGap = mfDistance*12.0; + if (bIsHairline) { // create hairline primitive @@ -160,7 +163,6 @@ namespace drawinglayer aPolygon.append( getEnd() ); basegfx::B2DPolygon aPolygon2 = aPolygon; - double fGap = (mfDistance/mfLeftWidth) * mfPatternScale * 10.0; moveLine(aPolygon2, fGap, aVector); xRetval.realloc(2); @@ -190,7 +192,6 @@ namespace drawinglayer aPolygon = aClipped.getB2DPolygon(0); basegfx::B2DPolygon aPolygon2 = aPolygon; - double fGap = (mfDistance/mfLeftWidth + aVector.getLength()) * mfPatternScale * 10.0; moveLine(aPolygon2, fGap, aVector); xRetval.realloc(2); commit 405eb064c10eb5df7da625f1ccd0544d9e4f240e Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Wed Jan 15 16:24:12 2014 -0500 Apply dashing without consulting current map unit. Using scaling is sufficient. Change-Id: If976bec3940772432d814a77681170d7c99306d2 diff --git a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx index fc99399..049e390 100644 --- a/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/borderlineprimitive2d.cxx @@ -241,8 +241,9 @@ namespace drawinglayer aPolygon.append( aTmpStart ); aPolygon.append( aTmpEnd ); - basegfx::B2DPolyPolygon aDashed = svtools::ApplyLineDashing( - aPolygon, getStyle(), MAP_PIXEL, mfPatternScale*10.0); + basegfx::B2DPolyPolygon aDashed = + svtools::ApplyLineDashing(aPolygon, getStyle(), mfPatternScale*10.0); + for (sal_uInt32 i = 0; i < aDashed.count(); i++ ) { basegfx::B2DPolygon aDash = aDashed.getB2DPolygon( i ); diff --git a/include/svtools/borderhelper.hxx b/include/svtools/borderhelper.hxx index ea89ca8..a1eb77b 100644 --- a/include/svtools/borderhelper.hxx +++ b/include/svtools/borderhelper.hxx @@ -27,19 +27,16 @@ #include <basegfx/point/b2dpoint.hxx> #include <vcl/outdev.hxx> -namespace svtools -{ - SVT_DLLPUBLIC basegfx::B2DPolyPolygon ApplyLineDashing( const basegfx::B2DPolygon& rPolygon, - sal_uInt16 nDashing, MapUnit eUnit ); +namespace svtools { - SVT_DLLPUBLIC basegfx::B2DPolyPolygon ApplyLineDashing( const basegfx::B2DPolygon& rPolygon, - sal_uInt16 nDashing, MapUnit eUnit, double fScale ); +SVT_DLLPUBLIC basegfx::B2DPolyPolygon ApplyLineDashing( + const basegfx::B2DPolygon& rPolygon, sal_uInt16 nDashing, double fScale ); - SVT_DLLPUBLIC void DrawLine( OutputDevice& rDev, const basegfx::B2DPoint& rBeg, - const basegfx::B2DPoint& rEnd, sal_uInt32 nWidth, sal_uInt16 nDashing ); +SVT_DLLPUBLIC void DrawLine( OutputDevice& rDev, const basegfx::B2DPoint& rBeg, + const basegfx::B2DPoint& rEnd, sal_uInt32 nWidth, sal_uInt16 nDashing ); - SVT_DLLPUBLIC void DrawLine( OutputDevice& rDev, const Point& rBeg, - const Point& rEnd, sal_uInt32 nWidth, sal_uInt16 nDashing ); +SVT_DLLPUBLIC void DrawLine( OutputDevice& rDev, const Point& rBeg, + const Point& rEnd, sal_uInt32 nWidth, sal_uInt16 nDashing ); } #endif diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx index 0ba3bc6..a6e545d 100644 --- a/svtools/source/control/ctrlbox.cxx +++ b/svtools/source/control/ctrlbox.cxx @@ -553,7 +553,13 @@ void lclDrawPolygon( OutputDevice& rDev, const basegfx::B2DPolygon& rPolygon, lo sal_uInt16 nOldAA = rDev.GetAntialiasing(); rDev.SetAntialiasing( nOldAA & ~ANTIALIASING_ENABLE_B2DDRAW ); - basegfx::B2DPolyPolygon aPolygons = svtools::ApplyLineDashing( rPolygon, nDashing, rDev.GetMapMode().GetMapUnit() ); + long nPix = rDev.PixelToLogic(Size(1, 1)).Width(); + basegfx::B2DPolyPolygon aPolygons = svtools::ApplyLineDashing(rPolygon, nDashing, nPix); + + // Handle problems of width 1px in Pixel mode: 0.5px gives a 1px line + if (rDev.GetMapMode().GetMapUnit() == MAP_PIXEL && nWidth == nPix) + nWidth = 0; + for ( sal_uInt32 i = 0; i < aPolygons.count( ); i++ ) { basegfx::B2DPolygon aDash = aPolygons.getB2DPolygon( i ); @@ -564,11 +570,6 @@ void lclDrawPolygon( OutputDevice& rDev, const basegfx::B2DPolygon& rPolygon, lo aVector.normalize( ); const basegfx::B2DVector aPerpendicular(basegfx::getPerpendicular(aVector)); - // Handle problems of width 1px in Pixel mode: 0.5px gives a 1px line - long nPix = rDev.PixelToLogic( Size( 0, 1 ) ).Height(); - if ( rDev.GetMapMode().GetMapUnit() == MAP_PIXEL && nWidth == nPix ) - nWidth = 0; - const basegfx::B2DVector aWidthOffset( double( nWidth ) / 2 * aPerpendicular); basegfx::B2DPolygon aDashPolygon; aDashPolygon.append( aStart + aWidthOffset ); @@ -583,116 +584,78 @@ void lclDrawPolygon( OutputDevice& rDev, const basegfx::B2DPolygon& rPolygon, lo rDev.SetAntialiasing( nOldAA ); } -namespace svtools +namespace svtools { + +std::vector<double> GetDashing( sal_uInt16 nDashing ) { - std::vector < double > GetDashing( sal_uInt16 nDashing, MapUnit eUnit ) + std::vector<double> aPattern; + switch (nDashing) { - ::std::vector < double >aPattern; - switch ( nDashing ) - { - case table::BorderLineStyle::DOTTED: - if ( eUnit == MAP_TWIP ) - { - aPattern.push_back( 30.0 ); - aPattern.push_back( 60.0 ); - } - else if ( eUnit == MAP_100TH_MM ) - { - aPattern.push_back( 50.0 ); - aPattern.push_back( 100.0 ); - } - else if ( eUnit == MAP_PIXEL ) - { - aPattern.push_back( 1.0 ); // line - aPattern.push_back( 2.0 ); // blank - } - break; - case table::BorderLineStyle::DASHED: - if ( eUnit == MAP_TWIP ) - { - aPattern.push_back( 120.0 ); - aPattern.push_back( 40.0 ); - } - else if ( eUnit == MAP_100TH_MM ) - { - aPattern.push_back( 150.0 ); - aPattern.push_back( 50.0 ); - } - else if ( eUnit == MAP_PIXEL ) - { - aPattern.push_back( 9.0 ); - aPattern.push_back( 3.0 ); - } - break; - case table::BorderLineStyle::FINE_DASHED: - if ( eUnit == MAP_TWIP ) - { - aPattern.push_back( 60.0 ); - aPattern.push_back( 40.0 ); - } - else if ( eUnit == MAP_100TH_MM ) - { - aPattern.push_back( 75.0 ); - aPattern.push_back( 50.0 ); - } - else if ( eUnit == MAP_PIXEL ) - { - aPattern.push_back( 3.0 ); - aPattern.push_back( 2.0 ); - } - break; - default: - break; - } - - return aPattern; + case table::BorderLineStyle::DOTTED: + aPattern.push_back( 1.0 ); // line + aPattern.push_back( 2.0 ); // blank + break; + case table::BorderLineStyle::DASHED: + aPattern.push_back( 9.0 ); + aPattern.push_back( 3.0 ); + break; + case table::BorderLineStyle::FINE_DASHED: + aPattern.push_back( 3.0 ); + aPattern.push_back( 2.0 ); + break; + default: + ; } - basegfx::B2DPolyPolygon ApplyLineDashing( const basegfx::B2DPolygon& rPolygon, sal_uInt16 nDashing, MapUnit eUnit ) - { - std::vector< double > aPattern = GetDashing( nDashing, eUnit ); - basegfx::B2DPolyPolygon aPolygons; - if ( ! aPattern.empty() ) - basegfx::tools::applyLineDashing( rPolygon, aPattern, &aPolygons ); - else - aPolygons.append( rPolygon ); + return aPattern; +} - return aPolygons; - } +namespace { - basegfx::B2DPolyPolygon ApplyLineDashing( const basegfx::B2DPolygon& rPolygon, sal_uInt16 nDashing, MapUnit eUnit, double fScale ) +class ApplyScale : std::unary_function<double, void> +{ + double mfScale; +public: + ApplyScale( double fScale ) : mfScale(fScale) {} + void operator() ( double& rVal ) { - std::vector< double > aPattern = GetDashing( nDashing, eUnit ); - std::vector< double >::iterator i = aPattern.begin(); - while( i != aPattern.end() ) { - (*i) *= fScale; - ++i; - } + rVal *= mfScale; + } +}; - basegfx::B2DPolyPolygon aPolygons; - if ( ! aPattern.empty() ) - basegfx::tools::applyLineDashing( rPolygon, aPattern, &aPolygons ); - else - aPolygons.append( rPolygon ); +} - return aPolygons; - } +basegfx::B2DPolyPolygon ApplyLineDashing( const basegfx::B2DPolygon& rPolygon, sal_uInt16 nDashing, double fScale ) +{ + std::vector<double> aPattern = GetDashing(nDashing); + std::for_each(aPattern.begin(), aPattern.end(), ApplyScale(fScale)); - void DrawLine( OutputDevice& rDev, const Point& rP1, const Point& rP2, - sal_uInt32 nWidth, sal_uInt16 nDashing ) - { - DrawLine( rDev, basegfx::B2DPoint( rP1.X(), rP1.Y() ), - basegfx::B2DPoint( rP2.X(), rP2.Y( ) ), nWidth, nDashing ); - } + basegfx::B2DPolyPolygon aPolygons; + + if (aPattern.empty()) + aPolygons.append(rPolygon); + else + basegfx::tools::applyLineDashing(rPolygon, aPattern, &aPolygons); + + return aPolygons; +} + +void DrawLine( OutputDevice& rDev, const Point& rP1, const Point& rP2, + sal_uInt32 nWidth, sal_uInt16 nDashing ) +{ + DrawLine( rDev, basegfx::B2DPoint( rP1.X(), rP1.Y() ), + basegfx::B2DPoint( rP2.X(), rP2.Y( ) ), nWidth, nDashing ); +} + +void DrawLine( OutputDevice& rDev, const basegfx::B2DPoint& rP1, const basegfx::B2DPoint& rP2, + sal_uInt32 nWidth, sal_uInt16 nDashing ) +{ + basegfx::B2DPolygon aPolygon; + aPolygon.append( rP1 ); + aPolygon.append( rP2 ); + lclDrawPolygon( rDev, aPolygon, nWidth, nDashing ); +} - void DrawLine( OutputDevice& rDev, const basegfx::B2DPoint& rP1, const basegfx::B2DPoint& rP2, - sal_uInt32 nWidth, sal_uInt16 nDashing ) - { - basegfx::B2DPolygon aPolygon; - aPolygon.append( rP1 ); - aPolygon.append( rP2 ); - lclDrawPolygon( rDev, aPolygon, nWidth, nDashing ); - } } void LineListBox::ImpGetLine( long nLine1, long nLine2, long nDistance, _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits