diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-06-22 16:05:11 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-06-23 08:59:30 +0200 |
commit | 58ae5fb5ff69a5581cffa583a57ad9381140fa9a (patch) | |
tree | e4776c71b6038e983579facd2ef0c1f8f926d54b /drawinglayer | |
parent | cb37c5f0f3de7b545231a53d46a5271058af76ad (diff) |
loplugin:oncevar in cppcanvas..drawinglayer
Change-Id: I5456aad61fb0dfe6830eae62b91d1a6399d6343f
Reviewed-on: https://gerrit.libreoffice.org/39128
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'drawinglayer')
-rw-r--r-- | drawinglayer/qa/unit/border.cxx | 32 | ||||
-rw-r--r-- | drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx | 144 |
2 files changed, 79 insertions, 97 deletions
diff --git a/drawinglayer/qa/unit/border.cxx b/drawinglayer/qa/unit/border.cxx index 9df6f23d57df..25264c46ee51 100644 --- a/drawinglayer/qa/unit/border.cxx +++ b/drawinglayer/qa/unit/border.cxx @@ -49,17 +49,17 @@ void DrawinglayerBorderTest::testDoubleDecompositionSolid() basegfx::B2DPoint aStart(0, 20); basegfx::B2DPoint aEnd(100, 20); double fLeftWidth = 1.47; - double fDistance = 1.47; - double fRightWidth = 1.47; - double fExtendLeftStart = 0; - double fExtendLeftEnd = 0; - double fExtendRightStart = 0; - double fExtendRightEnd = 0; + double const fDistance = 1.47; + double const fRightWidth = 1.47; + double const fExtendLeftStart = 0; + double const fExtendLeftEnd = 0; + double const fExtendRightStart = 0; + double const fExtendRightEnd = 0; basegfx::BColor aColorRight; basegfx::BColor aColorLeft; basegfx::BColor aColorGap; - bool bHasGapColor = false; - SvxBorderLineStyle nStyle = SvxBorderLineStyle::DOUBLE; + bool const bHasGapColor = false; + SvxBorderLineStyle const nStyle = SvxBorderLineStyle::DOUBLE; rtl::Reference<drawinglayer::primitive2d::BorderLinePrimitive2D> aBorder(new drawinglayer::primitive2d::BorderLinePrimitive2D(aStart, aEnd, fLeftWidth, fDistance, fRightWidth, fExtendLeftStart, fExtendLeftEnd, fExtendRightStart, fExtendRightEnd, aColorRight, aColorLeft, aColorGap, bHasGapColor, nStyle)); // Decompose it into polygons. @@ -98,18 +98,18 @@ void DrawinglayerBorderTest::testDoublePixelProcessing() // 1.47 pixels is 0.03cm at 130% zoom and 96 DPI. basegfx::B2DPoint aStart(0, 20); basegfx::B2DPoint aEnd(100, 20); - double fLeftWidth = 1.47; - double fDistance = 1.47; + double const fLeftWidth = 1.47; + double const fDistance = 1.47; double fRightWidth = 1.47; - double fExtendLeftStart = 0; - double fExtendLeftEnd = 0; - double fExtendRightStart = 0; - double fExtendRightEnd = 0; + double const fExtendLeftStart = 0; + double const fExtendLeftEnd = 0; + double const fExtendRightStart = 0; + double const fExtendRightEnd = 0; basegfx::BColor aColorRight; basegfx::BColor aColorLeft; basegfx::BColor aColorGap; - bool bHasGapColor = false; - SvxBorderLineStyle nStyle = SvxBorderLineStyle::DOUBLE; + bool const bHasGapColor = false; + SvxBorderLineStyle const nStyle = SvxBorderLineStyle::DOUBLE; rtl::Reference<drawinglayer::primitive2d::BorderLinePrimitive2D> xBorder(new drawinglayer::primitive2d::BorderLinePrimitive2D(aStart, aEnd, fLeftWidth, fDistance, fRightWidth, fExtendLeftStart, fExtendLeftEnd, fExtendRightStart, fExtendRightEnd, aColorRight, aColorLeft, aColorGap, bHasGapColor, nStyle)); drawinglayer::primitive2d::Primitive2DContainer aPrimitives; aPrimitives.push_back(drawinglayer::primitive2d::Primitive2DReference(xBorder.get())); diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx index 99d9e700e390..38c196f53b8f 100644 --- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx @@ -118,9 +118,8 @@ namespace } // #112245# helper to evtl. split filled polygons to maximum metafile point count - bool fillPolyPolygonNeededToBeSplit(basegfx::B2DPolyPolygon& rPolyPolygon) + void fillPolyPolygonNeededToBeSplit(basegfx::B2DPolyPolygon& rPolyPolygon) { - bool bRetval(false); const sal_uInt32 nPolyCount(rPolyPolygon.count()); if(nPolyCount) @@ -204,8 +203,6 @@ namespace rPolyPolygon = aSplitted; } } - - return bRetval; } /** Filter input polypolygon for effectively empty sub-fills @@ -1365,81 +1362,70 @@ namespace drawinglayer const primitive2d::PolyPolygonGraphicPrimitive2D& rBitmapCandidate = static_cast< const primitive2d::PolyPolygonGraphicPrimitive2D& >(rCandidate); basegfx::B2DPolyPolygon aLocalPolyPolygon(rBitmapCandidate.getB2DPolyPolygon()); - if(fillPolyPolygonNeededToBeSplit(aLocalPolyPolygon)) - { - // #i112245# Metafiles use tools Polygon and are not able to have more than 65535 points - // per polygon. If there are more use the splitted polygon and call recursively - rtl::Reference< primitive2d::PolyPolygonGraphicPrimitive2D > xSplitted(new primitive2d::PolyPolygonGraphicPrimitive2D( - aLocalPolyPolygon, - rBitmapCandidate.getFillGraphic())); + fillPolyPolygonNeededToBeSplit(aLocalPolyPolygon); - processBasePrimitive2D(*xSplitted.get()); - } - else + SvtGraphicFill* pSvtGraphicFill = nullptr; + + if(!mnSvtGraphicFillCount && aLocalPolyPolygon.count()) { - SvtGraphicFill* pSvtGraphicFill = nullptr; + // #121194# Changed implementation and checked usages fo convert to metafile, + // presentation start (uses SvtGraphicFill) and printing. - if(!mnSvtGraphicFillCount && aLocalPolyPolygon.count()) - { - // #121194# Changed implementation and checked usages fo convert to metafile, - // presentation start (uses SvtGraphicFill) and printing. - - // calculate transformation. Get real object size, all values in FillGraphicAttribute - // are relative to the unified object - aLocalPolyPolygon.transform(maCurrentTransformation); - const basegfx::B2DVector aOutlineSize(aLocalPolyPolygon.getB2DRange().getRange()); - - // the scaling needs scale from pixel to logic coordinate system - const attribute::FillGraphicAttribute& rFillGraphicAttribute = rBitmapCandidate.getFillGraphic(); - const Size aBmpSizePixel(rFillGraphicAttribute.getGraphic().GetSizePixel()); - - // setup transformation like in impgrfll. Multiply with aOutlineSize - // to get from unit coordinates in rFillGraphicAttribute.getGraphicRange() - // to object coordinates with object's top left being at (0,0). Divide - // by pixel size so that scale from pixel to logic will work in SvtGraphicFill. - const basegfx::B2DVector aTransformScale( - rFillGraphicAttribute.getGraphicRange().getRange() / - basegfx::B2DVector( - std::max(1.0, double(aBmpSizePixel.Width())), - std::max(1.0, double(aBmpSizePixel.Height()))) * - aOutlineSize); - const basegfx::B2DPoint aTransformPosition( - rFillGraphicAttribute.getGraphicRange().getMinimum() * aOutlineSize); - - // setup transformation like in impgrfll - SvtGraphicFill::Transform aTransform; - - // scale values are divided by bitmap pixel sizes - aTransform.matrix[0] = aTransformScale.getX(); - aTransform.matrix[4] = aTransformScale.getY(); - - // translates are absolute - aTransform.matrix[2] = aTransformPosition.getX(); - aTransform.matrix[5] = aTransformPosition.getY(); - - pSvtGraphicFill = new SvtGraphicFill( - getFillPolyPolygon(aLocalPolyPolygon), - Color(), - 0.0, - SvtGraphicFill::fillEvenOdd, - SvtGraphicFill::fillTexture, - aTransform, - rFillGraphicAttribute.getTiling(), - SvtGraphicFill::hatchSingle, - Color(), - SvtGraphicFill::GradientType::Linear, - Color(), - Color(), - 0, - rFillGraphicAttribute.getGraphic()); - } + // calculate transformation. Get real object size, all values in FillGraphicAttribute + // are relative to the unified object + aLocalPolyPolygon.transform(maCurrentTransformation); + const basegfx::B2DVector aOutlineSize(aLocalPolyPolygon.getB2DRange().getRange()); + + // the scaling needs scale from pixel to logic coordinate system + const attribute::FillGraphicAttribute& rFillGraphicAttribute = rBitmapCandidate.getFillGraphic(); + const Size aBmpSizePixel(rFillGraphicAttribute.getGraphic().GetSizePixel()); + + // setup transformation like in impgrfll. Multiply with aOutlineSize + // to get from unit coordinates in rFillGraphicAttribute.getGraphicRange() + // to object coordinates with object's top left being at (0,0). Divide + // by pixel size so that scale from pixel to logic will work in SvtGraphicFill. + const basegfx::B2DVector aTransformScale( + rFillGraphicAttribute.getGraphicRange().getRange() / + basegfx::B2DVector( + std::max(1.0, double(aBmpSizePixel.Width())), + std::max(1.0, double(aBmpSizePixel.Height()))) * + aOutlineSize); + const basegfx::B2DPoint aTransformPosition( + rFillGraphicAttribute.getGraphicRange().getMinimum() * aOutlineSize); + + // setup transformation like in impgrfll + SvtGraphicFill::Transform aTransform; - // Do use decomposition; encapsulate with SvtGraphicFill - impStartSvtGraphicFill(pSvtGraphicFill); - process(rCandidate); - impEndSvtGraphicFill(pSvtGraphicFill); + // scale values are divided by bitmap pixel sizes + aTransform.matrix[0] = aTransformScale.getX(); + aTransform.matrix[4] = aTransformScale.getY(); + + // translates are absolute + aTransform.matrix[2] = aTransformPosition.getX(); + aTransform.matrix[5] = aTransformPosition.getY(); + + pSvtGraphicFill = new SvtGraphicFill( + getFillPolyPolygon(aLocalPolyPolygon), + Color(), + 0.0, + SvtGraphicFill::fillEvenOdd, + SvtGraphicFill::fillTexture, + aTransform, + rFillGraphicAttribute.getTiling(), + SvtGraphicFill::hatchSingle, + Color(), + SvtGraphicFill::GradientType::Linear, + Color(), + Color(), + 0, + rFillGraphicAttribute.getGraphic()); } + // Do use decomposition; encapsulate with SvtGraphicFill + impStartSvtGraphicFill(pSvtGraphicFill); + process(rCandidate); + impEndSvtGraphicFill(pSvtGraphicFill); + break; } case PRIMITIVE2D_ID_POLYPOLYGONHATCHPRIMITIVE2D : @@ -1460,8 +1446,7 @@ namespace drawinglayer // #i112245# Metafiles use tools Polygon and are not able to have more than 65535 points // per polygon. Split polygon until there are less than that - while(fillPolyPolygonNeededToBeSplit(aLocalPolyPolygon)) - ; + fillPolyPolygonNeededToBeSplit(aLocalPolyPolygon); if(rFillHatchAttribute.isFillBackground()) { @@ -1597,8 +1582,7 @@ namespace drawinglayer // #i112245# Metafiles use tools Polygon and are not able to have more than 65535 points // per polygon. Split polygon until there are less than that - while(fillPolyPolygonNeededToBeSplit(aLocalPolyPolygon)) - ; + fillPolyPolygonNeededToBeSplit(aLocalPolyPolygon); // for support of MetaCommentActions of the form XGRAD_SEQ_BEGIN, XGRAD_SEQ_END // it is safest to use the VCL OutputDevice::DrawGradient method which creates those. @@ -1672,8 +1656,7 @@ namespace drawinglayer // #i112245# Metafiles use tools Polygon and are not able to have more than 65535 points // per polygon. Split polygon until there are less than that - while(fillPolyPolygonNeededToBeSplit(aLocalPolyPolygon)) - ; + fillPolyPolygonNeededToBeSplit(aLocalPolyPolygon); const basegfx::BColor aPolygonColor(maBColorModifierStack.getModifiedColor(rPolygonCandidate.getBColor())); aLocalPolyPolygon.transform(maCurrentTransformation); @@ -1850,8 +1833,7 @@ namespace drawinglayer // #i112245# Metafiles use tools Polygon and are not able to have more than 65535 points // per polygon. Split polygon until there are less than that - while(fillPolyPolygonNeededToBeSplit(aLocalPolyPolygon)) - ; + fillPolyPolygonNeededToBeSplit(aLocalPolyPolygon); // now transform aLocalPolyPolygon.transform(maCurrentTransformation); |