1464702f4SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3464702f4SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4464702f4SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5464702f4SAndrew Rist  * distributed with this work for additional information
6464702f4SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7464702f4SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8464702f4SAndrew Rist  * "License"); you may not use this file except in compliance
9464702f4SAndrew Rist  * with the License.  You may obtain a copy of the License at
10464702f4SAndrew Rist  *
11464702f4SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12464702f4SAndrew Rist  *
13464702f4SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14464702f4SAndrew Rist  * software distributed under the License is distributed on an
15464702f4SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16464702f4SAndrew Rist  * KIND, either express or implied.  See the License for the
17464702f4SAndrew Rist  * specific language governing permissions and limitations
18464702f4SAndrew Rist  * under the License.
19464702f4SAndrew Rist  *
20464702f4SAndrew Rist  *************************************************************/
21464702f4SAndrew Rist 
22464702f4SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_drawinglayer.hxx"
26cdf0e10cSrcweir 
27035a2f44SArmin Le Grand #include <drawinglayer/attribute/sdrfillgraphicattribute.hxx>
28035a2f44SArmin Le Grand #include <drawinglayer/attribute/fillgraphicattribute.hxx>
29035a2f44SArmin Le Grand #include <vcl/graph.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
32cdf0e10cSrcweir 
33cdf0e10cSrcweir namespace drawinglayer
34cdf0e10cSrcweir {
35cdf0e10cSrcweir 	namespace attribute
36cdf0e10cSrcweir 	{
37035a2f44SArmin Le Grand 		class ImpSdrFillGraphicAttribute
38cdf0e10cSrcweir 		{
39cdf0e10cSrcweir         public:
40cdf0e10cSrcweir 		    // refcounter
41cdf0e10cSrcweir 		    sal_uInt32								mnRefCount;
42cdf0e10cSrcweir 
43cdf0e10cSrcweir             // data definitions
44035a2f44SArmin Le Grand 			Graphic                                 maFillGraphic;
45*e7d68668SArmin Le Grand             basegfx::B2DVector                      maGraphicLogicSize;
46cdf0e10cSrcweir 			basegfx::B2DVector						maSize;
47cdf0e10cSrcweir 			basegfx::B2DVector						maOffset;
48cdf0e10cSrcweir 			basegfx::B2DVector						maOffsetPosition;
49cdf0e10cSrcweir 			basegfx::B2DVector						maRectPoint;
50cdf0e10cSrcweir 
51cdf0e10cSrcweir 			// bitfield
52cdf0e10cSrcweir 			unsigned								mbTiling : 1;
53cdf0e10cSrcweir 			unsigned								mbStretch : 1;
54cdf0e10cSrcweir 			unsigned								mbLogSize : 1;
55cdf0e10cSrcweir 
ImpSdrFillGraphicAttribute(const Graphic & rFillGraphic,const basegfx::B2DVector & rGraphicLogicSize,const basegfx::B2DVector & rSize,const basegfx::B2DVector & rOffset,const basegfx::B2DVector & rOffsetPosition,const basegfx::B2DVector & rRectPoint,bool bTiling,bool bStretch,bool bLogSize)56035a2f44SArmin Le Grand 			ImpSdrFillGraphicAttribute(
57035a2f44SArmin Le Grand 				const Graphic& rFillGraphic,
58*e7d68668SArmin Le Grand                 const basegfx::B2DVector& rGraphicLogicSize,
59cdf0e10cSrcweir                 const basegfx::B2DVector& rSize,
60cdf0e10cSrcweir                 const basegfx::B2DVector& rOffset,
61cdf0e10cSrcweir 				const basegfx::B2DVector& rOffsetPosition,
62cdf0e10cSrcweir                 const basegfx::B2DVector& rRectPoint,
63cdf0e10cSrcweir 				bool bTiling,
64cdf0e10cSrcweir                 bool bStretch,
65cdf0e10cSrcweir                 bool bLogSize)
66cdf0e10cSrcweir 		    :	mnRefCount(0),
67035a2f44SArmin Le Grand 		    	maFillGraphic(rFillGraphic),
68*e7d68668SArmin Le Grand                 maGraphicLogicSize(rGraphicLogicSize),
69cdf0e10cSrcweir 			    maSize(rSize),
70cdf0e10cSrcweir 			    maOffset(rOffset),
71cdf0e10cSrcweir 			    maOffsetPosition(rOffsetPosition),
72cdf0e10cSrcweir 			    maRectPoint(rRectPoint),
73cdf0e10cSrcweir 			    mbTiling(bTiling),
74cdf0e10cSrcweir 			    mbStretch(bStretch),
75cdf0e10cSrcweir 			    mbLogSize(bLogSize)
76cdf0e10cSrcweir 		    {
77cdf0e10cSrcweir 		    }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 			// data read access
getFillGraphic() const80035a2f44SArmin Le Grand             const Graphic& getFillGraphic() const { return maFillGraphic; }
getGraphicLogicSize() const81*e7d68668SArmin Le Grand             const basegfx::B2DVector& getGraphicLogicSize() const { return maGraphicLogicSize; }
getSize() const82cdf0e10cSrcweir             const basegfx::B2DVector& getSize() const { return maSize; }
getOffset() const83cdf0e10cSrcweir             const basegfx::B2DVector& getOffset() const { return maOffset; }
getOffsetPosition() const84cdf0e10cSrcweir             const basegfx::B2DVector& getOffsetPosition() const { return maOffsetPosition; }
getRectPoint() const85cdf0e10cSrcweir             const basegfx::B2DVector& getRectPoint() const { return maRectPoint; }
getTiling() const86cdf0e10cSrcweir             bool getTiling() const { return mbTiling; }
getStretch() const87cdf0e10cSrcweir             bool getStretch() const { return mbStretch; }
getLogSize() const88cdf0e10cSrcweir             bool getLogSize() const { return mbLogSize; }
89cdf0e10cSrcweir 
operator ==(const ImpSdrFillGraphicAttribute & rCandidate) const90035a2f44SArmin Le Grand             bool operator==(const ImpSdrFillGraphicAttribute& rCandidate) const
91cdf0e10cSrcweir             {
92035a2f44SArmin Le Grand 			    return (getFillGraphic() == rCandidate.getFillGraphic()
93*e7d68668SArmin Le Grand                     && getGraphicLogicSize() == rCandidate.getGraphicLogicSize()
94cdf0e10cSrcweir 				    && getSize() == rCandidate.getSize()
95cdf0e10cSrcweir 				    && getOffset() == rCandidate.getOffset()
96cdf0e10cSrcweir 				    && getOffsetPosition() == rCandidate.getOffsetPosition()
97cdf0e10cSrcweir 				    && getRectPoint() == rCandidate.getRectPoint()
98cdf0e10cSrcweir 				    && getTiling() == rCandidate.getTiling()
99cdf0e10cSrcweir 				    && getStretch() == rCandidate.getStretch()
100cdf0e10cSrcweir 				    && getLogSize() == rCandidate.getLogSize());
101cdf0e10cSrcweir             }
102cdf0e10cSrcweir 
get_global_default()103035a2f44SArmin Le Grand             static ImpSdrFillGraphicAttribute* get_global_default()
104cdf0e10cSrcweir             {
105035a2f44SArmin Le Grand                 static ImpSdrFillGraphicAttribute* pDefault = 0;
106cdf0e10cSrcweir 
107cdf0e10cSrcweir                 if(!pDefault)
108cdf0e10cSrcweir                 {
109035a2f44SArmin Le Grand                     pDefault = new ImpSdrFillGraphicAttribute(
110035a2f44SArmin Le Grand 			            Graphic(),
111cdf0e10cSrcweir                         basegfx::B2DVector(),
112*e7d68668SArmin Le Grand                         basegfx::B2DVector(),
113cdf0e10cSrcweir                         basegfx::B2DVector(),
114cdf0e10cSrcweir 			            basegfx::B2DVector(),
115cdf0e10cSrcweir                         basegfx::B2DVector(),
116cdf0e10cSrcweir 			            false,
117cdf0e10cSrcweir                         false,
118cdf0e10cSrcweir                         false);
119cdf0e10cSrcweir 
120cdf0e10cSrcweir                     // never delete; start with RefCount 1, not 0
121cdf0e10cSrcweir     			    pDefault->mnRefCount++;
122cdf0e10cSrcweir                 }
123cdf0e10cSrcweir 
124cdf0e10cSrcweir                 return pDefault;
125cdf0e10cSrcweir             }
126cdf0e10cSrcweir 		};
127cdf0e10cSrcweir 
SdrFillGraphicAttribute(const Graphic & rFillGraphic,const basegfx::B2DVector & rGraphicLogicSize,const basegfx::B2DVector & rSize,const basegfx::B2DVector & rOffset,const basegfx::B2DVector & rOffsetPosition,const basegfx::B2DVector & rRectPoint,bool bTiling,bool bStretch,bool bLogSize)128035a2f44SArmin Le Grand         SdrFillGraphicAttribute::SdrFillGraphicAttribute(
129035a2f44SArmin Le Grand 			const Graphic& rFillGraphic,
130*e7d68668SArmin Le Grand             const basegfx::B2DVector& rGraphicLogicSize,
131cdf0e10cSrcweir             const basegfx::B2DVector& rSize,
132cdf0e10cSrcweir             const basegfx::B2DVector& rOffset,
133cdf0e10cSrcweir 			const basegfx::B2DVector& rOffsetPosition,
134cdf0e10cSrcweir             const basegfx::B2DVector& rRectPoint,
135cdf0e10cSrcweir 			bool bTiling,
136cdf0e10cSrcweir             bool bStretch,
137cdf0e10cSrcweir             bool bLogSize)
138035a2f44SArmin Le Grand 		:	mpSdrFillGraphicAttribute(
139035a2f44SArmin Le Grand                 new ImpSdrFillGraphicAttribute(
140035a2f44SArmin Le Grand                     rFillGraphic,
141*e7d68668SArmin Le Grand                     rGraphicLogicSize,
14270d3707aSArmin Le Grand                     rSize,
14370d3707aSArmin Le Grand                     rOffset,
14470d3707aSArmin Le Grand                     rOffsetPosition,
14570d3707aSArmin Le Grand                     rRectPoint,
14670d3707aSArmin Le Grand                     bTiling,
14770d3707aSArmin Le Grand                     bStretch,
14870d3707aSArmin Le Grand                     bLogSize))
149cdf0e10cSrcweir 		{
150cdf0e10cSrcweir 		}
151cdf0e10cSrcweir 
SdrFillGraphicAttribute()152035a2f44SArmin Le Grand 		SdrFillGraphicAttribute::SdrFillGraphicAttribute()
153035a2f44SArmin Le Grand         :	mpSdrFillGraphicAttribute(ImpSdrFillGraphicAttribute::get_global_default())
154cdf0e10cSrcweir 		{
155035a2f44SArmin Le Grand 			mpSdrFillGraphicAttribute->mnRefCount++;
156cdf0e10cSrcweir 		}
157cdf0e10cSrcweir 
SdrFillGraphicAttribute(const SdrFillGraphicAttribute & rCandidate)158035a2f44SArmin Le Grand         SdrFillGraphicAttribute::SdrFillGraphicAttribute(const SdrFillGraphicAttribute& rCandidate)
159035a2f44SArmin Le Grand 		:	mpSdrFillGraphicAttribute(rCandidate.mpSdrFillGraphicAttribute)
160cdf0e10cSrcweir 		{
161035a2f44SArmin Le Grand 			mpSdrFillGraphicAttribute->mnRefCount++;
162cdf0e10cSrcweir 		}
163cdf0e10cSrcweir 
~SdrFillGraphicAttribute()164035a2f44SArmin Le Grand 		SdrFillGraphicAttribute::~SdrFillGraphicAttribute()
165cdf0e10cSrcweir 		{
166035a2f44SArmin Le Grand 			if(mpSdrFillGraphicAttribute->mnRefCount)
167cdf0e10cSrcweir 			{
168035a2f44SArmin Le Grand 				mpSdrFillGraphicAttribute->mnRefCount--;
169cdf0e10cSrcweir 			}
170cdf0e10cSrcweir 			else
171cdf0e10cSrcweir 			{
172035a2f44SArmin Le Grand 				delete mpSdrFillGraphicAttribute;
173cdf0e10cSrcweir 			}
174cdf0e10cSrcweir 		}
175cdf0e10cSrcweir 
isDefault() const176035a2f44SArmin Le Grand         bool SdrFillGraphicAttribute::isDefault() const
177cdf0e10cSrcweir         {
178035a2f44SArmin Le Grand             return mpSdrFillGraphicAttribute == ImpSdrFillGraphicAttribute::get_global_default();
179cdf0e10cSrcweir         }
180cdf0e10cSrcweir 
operator =(const SdrFillGraphicAttribute & rCandidate)181035a2f44SArmin Le Grand         SdrFillGraphicAttribute& SdrFillGraphicAttribute::operator=(const SdrFillGraphicAttribute& rCandidate)
182cdf0e10cSrcweir 		{
183035a2f44SArmin Le Grand 			if(rCandidate.mpSdrFillGraphicAttribute != mpSdrFillGraphicAttribute)
184cdf0e10cSrcweir 			{
185035a2f44SArmin Le Grand 				if(mpSdrFillGraphicAttribute->mnRefCount)
186cdf0e10cSrcweir 				{
187035a2f44SArmin Le Grand 					mpSdrFillGraphicAttribute->mnRefCount--;
188cdf0e10cSrcweir 				}
189cdf0e10cSrcweir 				else
190cdf0e10cSrcweir 				{
191035a2f44SArmin Le Grand 					delete mpSdrFillGraphicAttribute;
192cdf0e10cSrcweir 				}
193cdf0e10cSrcweir 
194035a2f44SArmin Le Grand 				mpSdrFillGraphicAttribute = rCandidate.mpSdrFillGraphicAttribute;
195035a2f44SArmin Le Grand 				mpSdrFillGraphicAttribute->mnRefCount++;
196cdf0e10cSrcweir 			}
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 			return *this;
199cdf0e10cSrcweir 		}
200cdf0e10cSrcweir 
operator ==(const SdrFillGraphicAttribute & rCandidate) const201035a2f44SArmin Le Grand 		bool SdrFillGraphicAttribute::operator==(const SdrFillGraphicAttribute& rCandidate) const
202cdf0e10cSrcweir 		{
203035a2f44SArmin Le Grand 			if(rCandidate.mpSdrFillGraphicAttribute == mpSdrFillGraphicAttribute)
204cdf0e10cSrcweir 			{
205cdf0e10cSrcweir 				return true;
206cdf0e10cSrcweir 			}
207cdf0e10cSrcweir 
208cdf0e10cSrcweir 			if(rCandidate.isDefault() != isDefault())
209cdf0e10cSrcweir 			{
210cdf0e10cSrcweir 				return false;
211cdf0e10cSrcweir 			}
212cdf0e10cSrcweir 
213035a2f44SArmin Le Grand 			return (*rCandidate.mpSdrFillGraphicAttribute == *mpSdrFillGraphicAttribute);
214cdf0e10cSrcweir 		}
215cdf0e10cSrcweir 
getFillGraphic() const216035a2f44SArmin Le Grand         const Graphic& SdrFillGraphicAttribute::getFillGraphic() const
217cdf0e10cSrcweir         {
218035a2f44SArmin Le Grand             return mpSdrFillGraphicAttribute->getFillGraphic();
219cdf0e10cSrcweir         }
220cdf0e10cSrcweir 
getGraphicLogicSize() const221*e7d68668SArmin Le Grand         const basegfx::B2DVector& SdrFillGraphicAttribute::getGraphicLogicSize() const
222*e7d68668SArmin Le Grand         {
223*e7d68668SArmin Le Grand             return mpSdrFillGraphicAttribute->getGraphicLogicSize();
224*e7d68668SArmin Le Grand         }
225*e7d68668SArmin Le Grand 
getSize() const226035a2f44SArmin Le Grand         const basegfx::B2DVector& SdrFillGraphicAttribute::getSize() const
227cdf0e10cSrcweir         {
228035a2f44SArmin Le Grand             return mpSdrFillGraphicAttribute->getSize();
229cdf0e10cSrcweir         }
230cdf0e10cSrcweir 
getOffset() const231035a2f44SArmin Le Grand         const basegfx::B2DVector& SdrFillGraphicAttribute::getOffset() const
232cdf0e10cSrcweir         {
233035a2f44SArmin Le Grand             return mpSdrFillGraphicAttribute->getOffset();
234cdf0e10cSrcweir         }
235cdf0e10cSrcweir 
getOffsetPosition() const236035a2f44SArmin Le Grand         const basegfx::B2DVector& SdrFillGraphicAttribute::getOffsetPosition() const
237cdf0e10cSrcweir         {
238035a2f44SArmin Le Grand             return mpSdrFillGraphicAttribute->getOffsetPosition();
239cdf0e10cSrcweir         }
240cdf0e10cSrcweir 
getRectPoint() const241035a2f44SArmin Le Grand         const basegfx::B2DVector& SdrFillGraphicAttribute::getRectPoint() const
242cdf0e10cSrcweir         {
243035a2f44SArmin Le Grand             return mpSdrFillGraphicAttribute->getRectPoint();
244cdf0e10cSrcweir         }
245cdf0e10cSrcweir 
getTiling() const246035a2f44SArmin Le Grand         bool SdrFillGraphicAttribute::getTiling() const
247cdf0e10cSrcweir         {
248035a2f44SArmin Le Grand             return mpSdrFillGraphicAttribute->getTiling();
249cdf0e10cSrcweir         }
250cdf0e10cSrcweir 
getStretch() const251035a2f44SArmin Le Grand         bool SdrFillGraphicAttribute::getStretch() const
252cdf0e10cSrcweir         {
253035a2f44SArmin Le Grand             return mpSdrFillGraphicAttribute->getStretch();
254cdf0e10cSrcweir         }
255cdf0e10cSrcweir 
getLogSize() const256035a2f44SArmin Le Grand         bool SdrFillGraphicAttribute::getLogSize() const
257cdf0e10cSrcweir         {
258035a2f44SArmin Le Grand             return mpSdrFillGraphicAttribute->getLogSize();
259cdf0e10cSrcweir         }
260cdf0e10cSrcweir 
createFillGraphicAttribute(const basegfx::B2DRange & rRange) const261035a2f44SArmin Le Grand         FillGraphicAttribute SdrFillGraphicAttribute::createFillGraphicAttribute(const basegfx::B2DRange& rRange) const
262cdf0e10cSrcweir 		{
263cdf0e10cSrcweir 			// get logical size of bitmap (before expanding eventually)
264035a2f44SArmin Le Grand 			Graphic aGraphic(getFillGraphic());
265cdf0e10cSrcweir 
26664b14621SArmin Le Grand 			// init values with defaults for stretched
267cdf0e10cSrcweir 			basegfx::B2DPoint aBitmapSize(1.0, 1.0);
268cdf0e10cSrcweir 			basegfx::B2DVector aBitmapTopLeft(0.0, 0.0);
269cdf0e10cSrcweir 
27064b14621SArmin Le Grand 			//UUUU are changes needed? When streched we are already done, all other values will have no influence
271cdf0e10cSrcweir 			if(getTiling() || !getStretch())
272cdf0e10cSrcweir 			{
273cdf0e10cSrcweir 				// init values with range sizes
274cdf0e10cSrcweir 				const double fRangeWidth(0.0 != rRange.getWidth() ? rRange.getWidth() : 1.0);
275cdf0e10cSrcweir 				const double fRangeHeight(0.0 != rRange.getHeight() ? rRange.getHeight() : 1.0);
276cdf0e10cSrcweir 				aBitmapSize = basegfx::B2DPoint(fRangeWidth, fRangeHeight);
277cdf0e10cSrcweir 
278cdf0e10cSrcweir 				// size changes
279cdf0e10cSrcweir 				if(0.0 != getSize().getX())
280cdf0e10cSrcweir 				{
281cdf0e10cSrcweir 					if(getSize().getX() < 0.0)
282cdf0e10cSrcweir 					{
283cdf0e10cSrcweir 						aBitmapSize.setX(aBitmapSize.getX() * (getSize().getX() * -0.01));
284cdf0e10cSrcweir 					}
285cdf0e10cSrcweir 					else
286cdf0e10cSrcweir 					{
287cdf0e10cSrcweir 						aBitmapSize.setX(getSize().getX());
288cdf0e10cSrcweir 					}
289cdf0e10cSrcweir 				}
290cdf0e10cSrcweir 				else
291cdf0e10cSrcweir 				{
292*e7d68668SArmin Le Grand                     // #124002# use GraphicLogicSize directly, do not try to use GetPrefSize
293*e7d68668SArmin Le Grand                     // of the graphic, that may not be adapted to the MapMode of the target
294*e7d68668SArmin Le Grand                     aBitmapSize.setX(getGraphicLogicSize().getX());
295cdf0e10cSrcweir 				}
296cdf0e10cSrcweir 
297cdf0e10cSrcweir 				if(0.0 != getSize().getY())
298cdf0e10cSrcweir 				{
299cdf0e10cSrcweir 					if(getSize().getY() < 0.0)
300cdf0e10cSrcweir 					{
301cdf0e10cSrcweir 						aBitmapSize.setY(aBitmapSize.getY() * (getSize().getY() * -0.01));
302cdf0e10cSrcweir 					}
303cdf0e10cSrcweir 					else
304cdf0e10cSrcweir 					{
305cdf0e10cSrcweir 						aBitmapSize.setY(getSize().getY());
306cdf0e10cSrcweir 					}
307cdf0e10cSrcweir 				}
308cdf0e10cSrcweir 				else
309cdf0e10cSrcweir 				{
310*e7d68668SArmin Le Grand                     // #124002# use GraphicLogicSize directly, do not try to use GetPrefSize
311*e7d68668SArmin Le Grand                     // of the graphic, that may not be adapted to the MapMode of the target
312*e7d68668SArmin Le Grand                     aBitmapSize.setY(getGraphicLogicSize().getY());
313cdf0e10cSrcweir 				}
314cdf0e10cSrcweir 
315cdf0e10cSrcweir 				// position changes X
31664b14621SArmin Le Grand 				if(0.0 == getRectPoint().getX())
317cdf0e10cSrcweir 				{
318cdf0e10cSrcweir 					aBitmapTopLeft.setX((fRangeWidth - aBitmapSize.getX()) * 0.5);
319cdf0e10cSrcweir 				}
32064b14621SArmin Le Grand 				else if(1.0 == getRectPoint().getX())
321cdf0e10cSrcweir 				{
322cdf0e10cSrcweir 					aBitmapTopLeft.setX(fRangeWidth - aBitmapSize.getX());
323cdf0e10cSrcweir 				}
324cdf0e10cSrcweir 
32564b14621SArmin Le Grand                 // offset positions are only meaningful when tiled
326cdf0e10cSrcweir 				if(getTiling() && 0.0 != getOffsetPosition().getX())
327cdf0e10cSrcweir 				{
328cdf0e10cSrcweir 					aBitmapTopLeft.setX(aBitmapTopLeft.getX() + (aBitmapSize.getX() * (getOffsetPosition().getX() * 0.01)));
329cdf0e10cSrcweir 				}
330cdf0e10cSrcweir 
331cdf0e10cSrcweir 				// position changes Y
33264b14621SArmin Le Grand 				if(0.0 == getRectPoint().getY())
333cdf0e10cSrcweir 				{
334cdf0e10cSrcweir 					aBitmapTopLeft.setY((fRangeHeight - aBitmapSize.getY()) * 0.5);
335cdf0e10cSrcweir 				}
33664b14621SArmin Le Grand 				else if(1.0 == getRectPoint().getY())
337cdf0e10cSrcweir 				{
338cdf0e10cSrcweir 					aBitmapTopLeft.setY(fRangeHeight - aBitmapSize.getY());
339cdf0e10cSrcweir 				}
340cdf0e10cSrcweir 
34164b14621SArmin Le Grand                 // offset positions are only meaningful when tiled
342cdf0e10cSrcweir 				if(getTiling() && 0.0 != getOffsetPosition().getY())
343cdf0e10cSrcweir 				{
344cdf0e10cSrcweir 					aBitmapTopLeft.setY(aBitmapTopLeft.getY() + (aBitmapSize.getY() * (getOffsetPosition().getY() * 0.01)));
345cdf0e10cSrcweir 				}
346cdf0e10cSrcweir 
347cdf0e10cSrcweir 				// apply bitmap size scaling to unit rectangle
348cdf0e10cSrcweir 				aBitmapTopLeft.setX(aBitmapTopLeft.getX() / fRangeWidth);
349cdf0e10cSrcweir 				aBitmapTopLeft.setY(aBitmapTopLeft.getY() / fRangeHeight);
350cdf0e10cSrcweir 				aBitmapSize.setX(aBitmapSize.getX() / fRangeWidth);
351cdf0e10cSrcweir 				aBitmapSize.setY(aBitmapSize.getY() / fRangeHeight);
352cdf0e10cSrcweir 			}
353cdf0e10cSrcweir 
354035a2f44SArmin Le Grand             // get offset in percent
355035a2f44SArmin Le Grand             const double fOffsetX(basegfx::clamp(getOffset().getX() * 0.01, 0.0, 1.0));
356035a2f44SArmin Le Grand             const double fOffsetY(basegfx::clamp(getOffset().getY() * 0.01, 0.0, 1.0));
357035a2f44SArmin Le Grand 
358035a2f44SArmin Le Grand             // create FillGraphicAttribute
359035a2f44SArmin Le Grand             return FillGraphicAttribute(
360035a2f44SArmin Le Grand                 aGraphic,
361035a2f44SArmin Le Grand                 basegfx::B2DRange(aBitmapTopLeft, aBitmapTopLeft + aBitmapSize),
362035a2f44SArmin Le Grand                 getTiling(),
363035a2f44SArmin Le Grand                 fOffsetX,
364035a2f44SArmin Le Grand                 fOffsetY);
365cdf0e10cSrcweir 		}
366cdf0e10cSrcweir 	} // end of namespace attribute
367cdf0e10cSrcweir } // end of namespace drawinglayer
368cdf0e10cSrcweir 
369cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
370cdf0e10cSrcweir // eof
371