diff options
author | Armin Le Grand <alg@apache.org> | 2012-10-16 08:44:02 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-06-11 20:00:34 +0100 |
commit | 37aa7d81aacaae12dfe0fd2ade2779235bbf72f1 (patch) | |
tree | baf84cf5f8fcf62221dd75869d507d2396ae690b /drawinglayer/source/attribute | |
parent | e72e1c110ad42b779afbe74b47ca35c1849e06b2 (diff) |
Resolves: #i121194# Better support for graphic fill styles...
which are not bitmaps (svg, metafiles, ..)
(cherry picked from commit 7a652a2b2ab5e0d37e32185c8c5fac3af482bb76)
Conflicts:
drawinglayer/Library_drawinglayer.mk
drawinglayer/Package_inc.mk
drawinglayer/inc/drawinglayer/attribute/fillgraphicattribute.hxx
drawinglayer/inc/drawinglayer/attribute/sdrfillattribute.hxx
drawinglayer/inc/drawinglayer/attribute/sdrfillgraphicattribute.hxx
drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx
drawinglayer/inc/drawinglayer/primitive2d/fillgraphicprimitive2d.hxx
drawinglayer/inc/drawinglayer/primitive2d/polypolygonprimitive2d.hxx
drawinglayer/inc/drawinglayer/primitive3d/textureprimitive3d.hxx
drawinglayer/inc/drawinglayer/processor2d/vclprocessor2d.hxx
drawinglayer/inc/drawinglayer/texture/texture.hxx
drawinglayer/inc/drawinglayer/texture/texture3d.hxx
drawinglayer/source/attribute/fillbitmapattribute.cxx
drawinglayer/source/attribute/sdrfillattribute.cxx
drawinglayer/source/attribute/sdrfillgraphicattribute.cxx
drawinglayer/source/primitive2d/fillbitmapprimitive2d.cxx
drawinglayer/source/primitive2d/graphicprimitive2d.cxx
drawinglayer/source/primitive2d/polypolygonprimitive2d.cxx
drawinglayer/source/processor2d/canvasprocessor.cxx
svx/inc/svx/sdr/primitive2d/sdrattributecreator.hxx
svx/source/sdr/contact/objectcontacttools.cxx
vcl/inc/vcl/graph.hxx
unused file _vclmetafileprocessor2d.cxx deleted, was added by error
(cherry picked from commit ed0d53f8283cd3ce579a90b599118884d0db6119)
Conflicts:
drawinglayer/source/processor2d/_vclmetafileprocessor2d.cxx
Corrected canvasProcessor usage
(cherry picked from commit 7903c33f31c457eb6ff506958c4233f2a5d39bcf)
Conflicts:
svx/source/sdr/contact/objectcontacttools.cxx
Change-Id: I80008050b98dafc92fde043524843c13a75fe22c
d2fa667d7c127b4d735334e56093d1d4553b0a5b
e20c60c7d6472da1295a162d9a629be998861f62
Diffstat (limited to 'drawinglayer/source/attribute')
-rw-r--r-- | drawinglayer/source/attribute/fillbitmapattribute.cxx | 139 | ||||
-rw-r--r-- | drawinglayer/source/attribute/fillgraphicattribute.cxx | 156 | ||||
-rw-r--r-- | drawinglayer/source/attribute/sdrfillattribute.cxx | 22 | ||||
-rwxr-xr-x[-rw-r--r--] | drawinglayer/source/attribute/sdrfillgraphicattribute.cxx (renamed from drawinglayer/source/attribute/sdrfillbitmapattribute.cxx) | 176 |
4 files changed, 231 insertions, 262 deletions
diff --git a/drawinglayer/source/attribute/fillbitmapattribute.cxx b/drawinglayer/source/attribute/fillbitmapattribute.cxx deleted file mode 100644 index e2bedb47d7e3..000000000000 --- a/drawinglayer/source/attribute/fillbitmapattribute.cxx +++ /dev/null @@ -1,139 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <drawinglayer/attribute/fillbitmapattribute.hxx> -#include <vcl/bitmapex.hxx> - -////////////////////////////////////////////////////////////////////////////// - -namespace drawinglayer -{ - namespace attribute - { - class ImpFillBitmapAttribute - { - public: - // data definitions - BitmapEx maBitmapEx; - basegfx::B2DPoint maTopLeft; - basegfx::B2DVector maSize; - - // bitfield - unsigned mbTiling : 1; - - ImpFillBitmapAttribute( - const BitmapEx& rBitmapEx, - const basegfx::B2DPoint& rTopLeft, - const basegfx::B2DVector& rSize, - bool bTiling) - : maBitmapEx(rBitmapEx), - maTopLeft(rTopLeft), - maSize(rSize), - mbTiling(bTiling) - { - } - - ImpFillBitmapAttribute() - : maBitmapEx(BitmapEx()), - maTopLeft(basegfx::B2DPoint()), - maSize(basegfx::B2DVector()), - mbTiling(false) - { - } - - bool operator==(const ImpFillBitmapAttribute& rCandidate) const - { - return (maBitmapEx == rCandidate.maBitmapEx - && maTopLeft == rCandidate.maTopLeft - && maSize == rCandidate.maSize - && mbTiling == rCandidate.mbTiling); - } - - // data read access - const BitmapEx& getBitmapEx() const { return maBitmapEx; } - const basegfx::B2DPoint& getTopLeft() const { return maTopLeft; } - const basegfx::B2DVector& getSize() const { return maSize; } - bool getTiling() const { return mbTiling; } - }; - - namespace - { - struct theGlobalDefault : - public rtl::Static< FillBitmapAttribute::ImplType, theGlobalDefault > {}; - } - - FillBitmapAttribute::FillBitmapAttribute( - const BitmapEx& rBitmapEx, - const basegfx::B2DPoint& rTopLeft, - const basegfx::B2DVector& rSize, - bool bTiling) - : mpFillBitmapAttribute(ImpFillBitmapAttribute( - rBitmapEx, rTopLeft, rSize, bTiling)) - { - } - - FillBitmapAttribute::FillBitmapAttribute(const FillBitmapAttribute& rCandidate) - : mpFillBitmapAttribute(rCandidate.mpFillBitmapAttribute) - { - } - - FillBitmapAttribute::~FillBitmapAttribute() - { - } - - bool FillBitmapAttribute::isDefault() const - { - return mpFillBitmapAttribute.same_object(theGlobalDefault::get()); - } - - FillBitmapAttribute& FillBitmapAttribute::operator=(const FillBitmapAttribute& rCandidate) - { - mpFillBitmapAttribute = rCandidate.mpFillBitmapAttribute; - return *this; - } - - bool FillBitmapAttribute::operator==(const FillBitmapAttribute& rCandidate) const - { - return rCandidate.mpFillBitmapAttribute == mpFillBitmapAttribute; - } - - const BitmapEx& FillBitmapAttribute::getBitmapEx() const - { - return mpFillBitmapAttribute->getBitmapEx(); - } - - const basegfx::B2DPoint& FillBitmapAttribute::getTopLeft() const - { - return mpFillBitmapAttribute->getTopLeft(); - } - - const basegfx::B2DVector& FillBitmapAttribute::getSize() const - { - return mpFillBitmapAttribute->getSize(); - } - - bool FillBitmapAttribute::getTiling() const - { - return mpFillBitmapAttribute->getTiling(); - } - - } // end of namespace attribute -} // end of namespace drawinglayer - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/source/attribute/fillgraphicattribute.cxx b/drawinglayer/source/attribute/fillgraphicattribute.cxx new file mode 100644 index 000000000000..f92b06d5b080 --- /dev/null +++ b/drawinglayer/source/attribute/fillgraphicattribute.cxx @@ -0,0 +1,156 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <drawinglayer/attribute/fillgraphicattribute.hxx> +#include <vcl/graph.hxx> + +////////////////////////////////////////////////////////////////////////////// + +namespace drawinglayer +{ + namespace attribute + { + class ImpFillGraphicAttribute + { + public: + // data definitions + Graphic maGraphic; + basegfx::B2DRange maGraphicRange; + + // bitfield + unsigned mbTiling : 1; + + // tiling definitions, offsets in X/Y in percent for each 2nd row. + // If both are set, Y is ignored (X has precedence) + double mfOffsetX; + double mfOffsetY; + + ImpFillGraphicAttribute( + const Graphic& rGraphic, + const basegfx::B2DRange& rGraphicRange, + bool bTiling, + double fOffsetX, + double fOffsetY) + : maGraphic(rGraphic), + maGraphicRange(rGraphicRange), + mbTiling(bTiling), + mfOffsetX(fOffsetX), + mfOffsetY(fOffsetY) + { + } + + ImpFillGraphicAttribute() + : maGraphic(Graphic()), + maGraphicRange(basegfx::B2DRange()), + mbTiling(false), + mfOffsetX(0.0), + mfOffsetY(0.0) + { + } + + // data read access + const Graphic& getGraphic() const { return maGraphic; } + const basegfx::B2DRange& getGraphicRange() const { return maGraphicRange; } + bool getTiling() const { return mbTiling; } + double getOffsetX() const { return mfOffsetX; } + double getOffsetY() const { return mfOffsetY; } + + bool operator==(const ImpFillGraphicAttribute& rCandidate) const + { + return (getGraphic() == rCandidate.getGraphic() + && getGraphicRange() == rCandidate.getGraphicRange() + && getTiling() == rCandidate.getTiling() + && getOffsetX() == rCandidate.getOffsetX() + && getOffsetY() == rCandidate.getOffsetY()); + } + }; + + namespace + { + struct theGlobalDefault : + public rtl::Static< FillGraphicAttribute::ImplType, theGlobalDefault > {}; + } + + FillGraphicAttribute::FillGraphicAttribute( + const Graphic& rGraphic, + const basegfx::B2DRange& rGraphicRange, + bool bTiling, + double fOffsetX, + double fOffsetY) + : mpFillGraphicAttribute(ImpFillGraphicAttribute( + rGraphic, rGraphicRange, bTiling, + basegfx::clamp(fOffsetX, 0.0, 1.0), + basegfx::clamp(fOffsetY, 0.0, 1.0))) + { + } + + FillGraphicAttribute::FillGraphicAttribute(const FillGraphicAttribute& rCandidate) + : mpFillGraphicAttribute(rCandidate.mpFillGraphicAttribute) + { + } + + FillGraphicAttribute::~FillGraphicAttribute() + { + } + + bool FillGraphicAttribute::isDefault() const + { + return mpFillGraphicAttribute.same_object(theGlobalDefault::get()); + } + + FillGraphicAttribute& FillGraphicAttribute::operator=(const FillGraphicAttribute& rCandidate) + { + mpFillGraphicAttribute = rCandidate.mpFillGraphicAttribute; + return *this; + } + + bool FillGraphicAttribute::operator==(const FillGraphicAttribute& rCandidate) const + { + return rCandidate.mpFillGraphicAttribute == mpFillGraphicAttribute; + } + + const Graphic& FillGraphicAttribute::getGraphic() const + { + return mpFillGraphicAttribute->getGraphic(); + } + + const basegfx::B2DRange& FillGraphicAttribute::getGraphicRange() const + { + return mpFillGraphicAttribute->getGraphicRange(); + } + + bool FillGraphicAttribute::getTiling() const + { + return mpFillGraphicAttribute->getTiling(); + } + + double FillGraphicAttribute::getOffsetX() const + { + return mpFillGraphicAttribute->getOffsetX(); + } + + double FillGraphicAttribute::getOffsetY() const + { + return mpFillGraphicAttribute->getOffsetY(); + } + + } // end of namespace attribute +} // end of namespace drawinglayer + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/source/attribute/sdrfillattribute.cxx b/drawinglayer/source/attribute/sdrfillattribute.cxx index 98c6450a7088..f6e07fb898fc 100644 --- a/drawinglayer/source/attribute/sdrfillattribute.cxx +++ b/drawinglayer/source/attribute/sdrfillattribute.cxx @@ -19,7 +19,7 @@ #include <drawinglayer/attribute/sdrfillattribute.hxx> #include <basegfx/color/bcolor.hxx> -#include <drawinglayer/attribute/sdrfillbitmapattribute.hxx> +#include <drawinglayer/attribute/sdrfillgraphicattribute.hxx> #include <drawinglayer/attribute/fillhatchattribute.hxx> #include <drawinglayer/attribute/fillgradientattribute.hxx> #include <rtl/instance.hxx> @@ -38,7 +38,7 @@ namespace drawinglayer basegfx::BColor maColor; // fill color FillGradientAttribute maGradient; // fill gradient (if used) FillHatchAttribute maHatch; // fill hatch (if used) - SdrFillBitmapAttribute maBitmap; // fill bitmap (if used) + SdrFillGraphicAttribute maFillGraphic; // fill graphic (if used) public: ImpSdrFillAttribute( @@ -46,12 +46,12 @@ namespace drawinglayer const basegfx::BColor& rColor, const FillGradientAttribute& rGradient, const FillHatchAttribute& rHatch, - const SdrFillBitmapAttribute& rBitmap) + const SdrFillGraphicAttribute& rFillGraphic) : mfTransparence(fTransparence), maColor(rColor), maGradient(rGradient), maHatch(rHatch), - maBitmap(rBitmap) + maFillGraphic(rFillGraphic) { } @@ -60,7 +60,7 @@ namespace drawinglayer maColor(basegfx::BColor()), maGradient(FillGradientAttribute()), maHatch(FillHatchAttribute()), - maBitmap(SdrFillBitmapAttribute()) + maFillGraphic(SdrFillGraphicAttribute()) { } @@ -69,7 +69,7 @@ namespace drawinglayer const basegfx::BColor& getColor() const { return maColor; } const FillGradientAttribute& getGradient() const { return maGradient; } const FillHatchAttribute& getHatch() const { return maHatch; } - const SdrFillBitmapAttribute& getBitmap() const { return maBitmap; } + const SdrFillGraphicAttribute& getFillGraphic() const { return maFillGraphic; } // compare operator bool operator==(const ImpSdrFillAttribute& rCandidate) const @@ -78,7 +78,7 @@ namespace drawinglayer && getColor() == rCandidate.getColor() && getGradient() == rCandidate.getGradient() && getHatch() == rCandidate.getHatch() - && getBitmap() == rCandidate.getBitmap()); + && getFillGraphic() == rCandidate.getFillGraphic()); } }; @@ -93,9 +93,9 @@ namespace drawinglayer const basegfx::BColor& rColor, const FillGradientAttribute& rGradient, const FillHatchAttribute& rHatch, - const SdrFillBitmapAttribute& rBitmap) + const SdrFillGraphicAttribute& rFillGraphic) : mpSdrFillAttribute(ImpSdrFillAttribute( - fTransparence, rColor, rGradient, rHatch, rBitmap)) + fTransparence, rColor, rGradient, rHatch, rFillGraphic)) { } @@ -149,9 +149,9 @@ namespace drawinglayer return mpSdrFillAttribute->getHatch(); } - const SdrFillBitmapAttribute& SdrFillAttribute::getBitmap() const + const SdrFillGraphicAttribute& SdrFillAttribute::getFillGraphic() const { - return mpSdrFillAttribute->getBitmap(); + return mpSdrFillAttribute->getFillGraphic(); } } // end of namespace attribute } // end of namespace drawinglayer diff --git a/drawinglayer/source/attribute/sdrfillbitmapattribute.cxx b/drawinglayer/source/attribute/sdrfillgraphicattribute.cxx index b21566f06d81..0b1af9cb07d6 100644..100755 --- a/drawinglayer/source/attribute/sdrfillbitmapattribute.cxx +++ b/drawinglayer/source/attribute/sdrfillgraphicattribute.cxx @@ -17,10 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <drawinglayer/attribute/sdrfillbitmapattribute.hxx> -#include <drawinglayer/attribute/fillbitmapattribute.hxx> +#include <drawinglayer/attribute/sdrfillgraphicattribute.hxx> +#include <drawinglayer/attribute/fillgraphicattribute.hxx> #include <rtl/instance.hxx> -#include <vcl/bitmapex.hxx> +#include <vcl/graph.hxx> ////////////////////////////////////////////////////////////////////////////// @@ -28,11 +28,11 @@ namespace drawinglayer { namespace attribute { - class ImpSdrFillBitmapAttribute + class ImpSdrFillGraphicAttribute { public: // data definitions - BitmapEx maBitmapEx; + Graphic maFillGraphic; basegfx::B2DVector maSize; basegfx::B2DVector maOffset; basegfx::B2DVector maOffsetPosition; @@ -43,8 +43,8 @@ namespace drawinglayer unsigned mbStretch : 1; unsigned mbLogSize : 1; - ImpSdrFillBitmapAttribute( - const BitmapEx& rBitmapEx, + ImpSdrFillGraphicAttribute( + const Graphic& rFillGraphic, const basegfx::B2DVector& rSize, const basegfx::B2DVector& rOffset, const basegfx::B2DVector& rOffsetPosition, @@ -52,7 +52,7 @@ namespace drawinglayer bool bTiling, bool bStretch, bool bLogSize) - : maBitmapEx(rBitmapEx), + : maFillGraphic(rFillGraphic), maSize(rSize), maOffset(rOffset), maOffsetPosition(rOffsetPosition), @@ -63,8 +63,8 @@ namespace drawinglayer { } - ImpSdrFillBitmapAttribute() - : maBitmapEx(BitmapEx()), + ImpSdrFillGraphicAttribute() + : maFillGraphic(Graphic()), maSize(basegfx::B2DVector()), maOffset(basegfx::B2DVector()), maOffsetPosition(basegfx::B2DVector()), @@ -76,7 +76,7 @@ namespace drawinglayer } // data read access - const BitmapEx& getBitmapEx() const { return maBitmapEx; } + const Graphic& getFillGraphic() const { return maFillGraphic; } const basegfx::B2DVector& getSize() const { return maSize; } const basegfx::B2DVector& getOffset() const { return maOffset; } const basegfx::B2DVector& getOffsetPosition() const { return maOffsetPosition; } @@ -85,9 +85,9 @@ namespace drawinglayer bool getStretch() const { return mbStretch; } bool getLogSize() const { return mbLogSize; } - bool operator==(const ImpSdrFillBitmapAttribute& rCandidate) const + bool operator==(const ImpSdrFillGraphicAttribute& rCandidate) const { - return (getBitmapEx() == rCandidate.getBitmapEx() + return (getFillGraphic() == rCandidate.getFillGraphic() && getSize() == rCandidate.getSize() && getOffset() == rCandidate.getOffset() && getOffsetPosition() == rCandidate.getOffsetPosition() @@ -101,11 +101,11 @@ namespace drawinglayer namespace { struct theGlobalDefault : - public rtl::Static< SdrFillBitmapAttribute::ImplType, theGlobalDefault > {}; + public rtl::Static< SdrFillGraphicAttribute::ImplType, theGlobalDefault > {}; } - SdrFillBitmapAttribute::SdrFillBitmapAttribute( - const BitmapEx& rBitmapEx, + SdrFillGraphicAttribute::SdrFillGraphicAttribute( + const Graphic& rFillGraphic, const basegfx::B2DVector& rSize, const basegfx::B2DVector& rOffset, const basegfx::B2DVector& rOffsetPosition, @@ -113,9 +113,9 @@ namespace drawinglayer bool bTiling, bool bStretch, bool bLogSize) - : mpSdrFillBitmapAttribute( - ImpSdrFillBitmapAttribute( - rBitmapEx, + : mpSdrFillGraphicAttribute( + ImpSdrFillGraphicAttribute( + rFillGraphic, rSize, rOffset, rOffsetPosition, @@ -126,134 +126,87 @@ namespace drawinglayer { } - SdrFillBitmapAttribute::SdrFillBitmapAttribute() - : mpSdrFillBitmapAttribute(theGlobalDefault::get()) + SdrFillGraphicAttribute::SdrFillGraphicAttribute() + : mpSdrFillGraphicAttribute(theGlobalDefault::get()) { } - SdrFillBitmapAttribute::SdrFillBitmapAttribute(const SdrFillBitmapAttribute& rCandidate) - : mpSdrFillBitmapAttribute(rCandidate.mpSdrFillBitmapAttribute) + SdrFillGraphicAttribute::SdrFillGraphicAttribute(const SdrFillGraphicAttribute& rCandidate) + : mpSdrFillGraphicAttribute(rCandidate.mpSdrFillGraphicAttribute) { } - SdrFillBitmapAttribute::~SdrFillBitmapAttribute() + SdrFillGraphicAttribute::~SdrFillGraphicAttribute() { } - bool SdrFillBitmapAttribute::isDefault() const + bool SdrFillGraphicAttribute::isDefault() const { - return mpSdrFillBitmapAttribute.same_object(theGlobalDefault::get()); + return mpSdrFillGraphicAttribute.same_object(theGlobalDefault::get()); } - SdrFillBitmapAttribute& SdrFillBitmapAttribute::operator=(const SdrFillBitmapAttribute& rCandidate) + SdrFillGraphicAttribute& SdrFillGraphicAttribute::operator=(const SdrFillGraphicAttribute& rCandidate) { - mpSdrFillBitmapAttribute = rCandidate.mpSdrFillBitmapAttribute; + mpSdrFillGraphicAttribute = rCandidate.mpSdrFillGraphicAttribute; return *this; } - bool SdrFillBitmapAttribute::operator==(const SdrFillBitmapAttribute& rCandidate) const + bool SdrFillGraphicAttribute::operator==(const SdrFillGraphicAttribute& rCandidate) const { - return rCandidate.mpSdrFillBitmapAttribute == mpSdrFillBitmapAttribute; + return rCandidate.mpSdrFillGraphicAttribute == mpSdrFillGraphicAttribute; } - const BitmapEx& SdrFillBitmapAttribute::getBitmapEx() const + const Graphic& SdrFillGraphicAttribute::getFillGraphic() const { - return mpSdrFillBitmapAttribute->getBitmapEx(); + return mpSdrFillGraphicAttribute->getFillGraphic(); } - const basegfx::B2DVector& SdrFillBitmapAttribute::getSize() const + const basegfx::B2DVector& SdrFillGraphicAttribute::getSize() const { - return mpSdrFillBitmapAttribute->getSize(); + return mpSdrFillGraphicAttribute->getSize(); } - const basegfx::B2DVector& SdrFillBitmapAttribute::getOffset() const + const basegfx::B2DVector& SdrFillGraphicAttribute::getOffset() const { - return mpSdrFillBitmapAttribute->getOffset(); + return mpSdrFillGraphicAttribute->getOffset(); } - const basegfx::B2DVector& SdrFillBitmapAttribute::getOffsetPosition() const + const basegfx::B2DVector& SdrFillGraphicAttribute::getOffsetPosition() const { - return mpSdrFillBitmapAttribute->getOffsetPosition(); + return mpSdrFillGraphicAttribute->getOffsetPosition(); } - const basegfx::B2DVector& SdrFillBitmapAttribute::getRectPoint() const + const basegfx::B2DVector& SdrFillGraphicAttribute::getRectPoint() const { - return mpSdrFillBitmapAttribute->getRectPoint(); + return mpSdrFillGraphicAttribute->getRectPoint(); } - bool SdrFillBitmapAttribute::getTiling() const + bool SdrFillGraphicAttribute::getTiling() const { - return mpSdrFillBitmapAttribute->getTiling(); + return mpSdrFillGraphicAttribute->getTiling(); } - bool SdrFillBitmapAttribute::getStretch() const + bool SdrFillGraphicAttribute::getStretch() const { - return mpSdrFillBitmapAttribute->getStretch(); + return mpSdrFillGraphicAttribute->getStretch(); } - FillBitmapAttribute SdrFillBitmapAttribute::getFillBitmapAttribute(const basegfx::B2DRange& rRange) const + bool SdrFillGraphicAttribute::getLogSize() const { - // get logical size of bitmap (before expanding eventually) - BitmapEx aBitmapEx(getBitmapEx()); - const basegfx::B2DVector aLogicalSize(aBitmapEx.GetPrefSize().getWidth(), aBitmapEx.GetPrefSize().getHeight()); - - // get hor/ver shiftings and apply them eventually to the bitmap, but only - // when tiling is on - bool bExpandWidth(false); - bool bExpandHeight(false); - - if(getTiling()) - { - if(0.0 != getOffset().getX() || 0.0 != getOffset().getY()) - { - const sal_uInt32 nWidth(aBitmapEx.GetSizePixel().getWidth()); - const sal_uInt32 nHeight(aBitmapEx.GetSizePixel().getHeight()); + return mpSdrFillGraphicAttribute->getLogSize(); + } - if(0.0 != getOffset().getX()) - { - bExpandHeight = true; - const sal_uInt32 nOffset(basegfx::fround(((double)nWidth * getOffset().getX()) / 100.0)); - aBitmapEx.Expand(0L, nHeight); - - const Size aSizeA(nOffset, nHeight); - const Rectangle aDstA(Point(0L, nHeight), aSizeA); - const Rectangle aSrcA(Point(nWidth - nOffset, 0L), aSizeA); - aBitmapEx.CopyPixel(aDstA, aSrcA); - - const Size aSizeB(nWidth - nOffset, nHeight); - const Rectangle aDstB(Point(nOffset, nHeight), aSizeB); - const Rectangle aSrcB(Point(0L, 0L), aSizeB); - aBitmapEx.CopyPixel(aDstB, aSrcB); - } - else - { - bExpandWidth = true; - const sal_uInt32 nOffset(basegfx::fround(((double)nHeight * getOffset().getY()) / 100.0)); - aBitmapEx.Expand(nWidth, 0L); - - const Size aSize(nWidth, nHeight); - const Rectangle aDst(Point(nWidth, 0L), aSize); - const Rectangle aSrc(Point(0L, 0L), aSize); - aBitmapEx.CopyPixel(aDst, aSrc); - - const Size aSizeA(nWidth, nOffset); - const Rectangle aDstA(Point(0L, 0L), aSizeA); - const Rectangle aSrcA(Point(nWidth, nHeight - nOffset), aSizeA); - aBitmapEx.CopyPixel(aDstA, aSrcA); - - const Size aSizeB(nWidth, nHeight - nOffset); - const Rectangle aDstB(Point(0L, nOffset), aSizeB); - const Rectangle aSrcB(Point(nWidth, 0L), aSizeB); - aBitmapEx.CopyPixel(aDstB, aSrcB); - } - } - } + FillGraphicAttribute SdrFillGraphicAttribute::createFillGraphicAttribute(const basegfx::B2DRange& rRange) const + { + // get logical size of bitmap (before expanding eventually) + Graphic aGraphic(getFillGraphic()); + const basegfx::B2DVector aLogicalSize(aGraphic.GetPrefSize().getWidth(), aGraphic.GetPrefSize().getHeight()); // init values with defaults basegfx::B2DPoint aBitmapSize(1.0, 1.0); basegfx::B2DVector aBitmapTopLeft(0.0, 0.0); - // are canges needed? + // are changes needed? if(getTiling() || !getStretch()) { // init values with range sizes @@ -327,17 +280,6 @@ namespace drawinglayer aBitmapTopLeft.setY(aBitmapTopLeft.getY() + (aBitmapSize.getY() * (getOffsetPosition().getY() * 0.01))); } - // apply expand - if(bExpandWidth) - { - aBitmapSize.setX(aBitmapSize.getX() * 2.0); - } - - if(bExpandHeight) - { - aBitmapSize.setY(aBitmapSize.getY() * 2.0); - } - // apply bitmap size scaling to unit rectangle aBitmapTopLeft.setX(aBitmapTopLeft.getX() / fRangeWidth); aBitmapTopLeft.setY(aBitmapTopLeft.getY() / fRangeHeight); @@ -345,7 +287,17 @@ namespace drawinglayer aBitmapSize.setY(aBitmapSize.getY() / fRangeHeight); } - return FillBitmapAttribute(aBitmapEx, aBitmapTopLeft, aBitmapSize, getTiling()); + // get offset in percent + const double fOffsetX(basegfx::clamp(getOffset().getX() * 0.01, 0.0, 1.0)); + const double fOffsetY(basegfx::clamp(getOffset().getY() * 0.01, 0.0, 1.0)); + + // create FillGraphicAttribute + return FillGraphicAttribute( + aGraphic, + basegfx::B2DRange(aBitmapTopLeft, aBitmapTopLeft + aBitmapSize), + getTiling(), + fOffsetX, + fOffsetY); } } // end of namespace attribute } // end of namespace drawinglayer |