diff options
Diffstat (limited to 'drawinglayer/source/primitive2d/fillgraphicprimitive2d.cxx')
-rw-r--r-- | drawinglayer/source/primitive2d/fillgraphicprimitive2d.cxx | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/drawinglayer/source/primitive2d/fillgraphicprimitive2d.cxx b/drawinglayer/source/primitive2d/fillgraphicprimitive2d.cxx index 708b3f2ce48d..5ef71c97aa33 100644 --- a/drawinglayer/source/primitive2d/fillgraphicprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/fillgraphicprimitive2d.cxx @@ -24,7 +24,9 @@ #include <basegfx/matrix/b2dhommatrixtools.hxx> #include <drawinglayer/primitive2d/transformprimitive2d.hxx> #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> -#include <primitive2d/graphicprimitivehelper2d.hxx> +#include <drawinglayer/primitive2d/graphicprimitivehelper2d.hxx> +#include <utility> +#include <vcl/graph.hxx> using namespace com::sun::star; @@ -32,24 +34,25 @@ using namespace com::sun::star; namespace drawinglayer::primitive2d { - void FillGraphicPrimitive2D::create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& /*rViewInformation*/) const + Primitive2DReference FillGraphicPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const { const attribute::FillGraphicAttribute& rAttribute = getFillGraphic(); if(rAttribute.isDefault()) - return; + return nullptr; const Graphic& rGraphic = rAttribute.getGraphic(); if(GraphicType::Bitmap != rGraphic.GetType() && GraphicType::GdiMetafile != rGraphic.GetType()) - return; + return nullptr; const Size aSize(rGraphic.GetPrefSize()); if(!(aSize.Width() && aSize.Height())) - return; + return nullptr; // we have a graphic (bitmap or metafile) with some size + Primitive2DContainer aContainer; if(rAttribute.getTiling()) { // get object range and create tiling matrices @@ -66,13 +69,15 @@ namespace drawinglayer::primitive2d Primitive2DContainer xSeq; create2DDecompositionOfGraphic(xSeq, rGraphic, - basegfx::B2DHomMatrix()); + basegfx::B2DHomMatrix(), + getTransparency()); - for(size_t a(0); a < aMatrices.size(); a++) + rtl::Reference<GroupPrimitive2D> xGroup = new GroupPrimitive2D(std::move(xSeq)); + for(const auto &a : aMatrices) { - rContainer.push_back(new TransformPrimitive2D( - getTransformation() * aMatrices[a], - xSeq)); + aContainer.push_back(new TransformPrimitive2D( + getTransformation() * a, + *xGroup)); } } else @@ -83,18 +88,23 @@ namespace drawinglayer::primitive2d rAttribute.getGraphicRange().getRange(), rAttribute.getGraphicRange().getMinimum())); - create2DDecompositionOfGraphic(rContainer, + create2DDecompositionOfGraphic(aContainer, rGraphic, - aObjectTransform); + aObjectTransform, + getTransparency()); } + + return new GroupPrimitive2D(std::move(aContainer)); } FillGraphicPrimitive2D::FillGraphicPrimitive2D( - const basegfx::B2DHomMatrix& rTransformation, - const attribute::FillGraphicAttribute& rFillGraphic) - : BufferedDecompositionPrimitive2D(), - maTransformation(rTransformation), - maFillGraphic(rFillGraphic) + basegfx::B2DHomMatrix aTransformation, + const attribute::FillGraphicAttribute& rFillGraphic, + double fTransparency) + : maTransformation(std::move(aTransformation)) + , maFillGraphic(rFillGraphic) + , maOffsetXYCreatedBitmap() + , mfTransparency(std::max(0.0, std::min(1.0, fTransparency))) { } @@ -105,7 +115,8 @@ namespace drawinglayer::primitive2d const FillGraphicPrimitive2D& rCompare = static_cast< const FillGraphicPrimitive2D& >(rPrimitive); return (getTransformation() == rCompare.getTransformation() - && getFillGraphic() == rCompare.getFillGraphic()); + && getFillGraphic() == rCompare.getFillGraphic() + && basegfx::fTools::equal(getTransparency(), rCompare.getTransparency())); } return false; @@ -121,7 +132,10 @@ namespace drawinglayer::primitive2d } // provide unique ID - ImplPrimitive2DIDBlock(FillGraphicPrimitive2D, PRIMITIVE2D_ID_FILLGRAPHICPRIMITIVE2D) + sal_uInt32 FillGraphicPrimitive2D::getPrimitive2DID() const + { + return PRIMITIVE2D_ID_FILLGRAPHICPRIMITIVE2D; + } } // end of namespace |