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 
27cdf0e10cSrcweir #include <drawinglayer/texture/texture.hxx>
28cdf0e10cSrcweir #include <basegfx/numeric/ftools.hxx>
29cdf0e10cSrcweir #include <basegfx/tools/gradienttools.hxx>
30cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrixtools.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
33cdf0e10cSrcweir 
34cdf0e10cSrcweir namespace drawinglayer
35cdf0e10cSrcweir {
36cdf0e10cSrcweir 	namespace texture
37cdf0e10cSrcweir 	{
GeoTexSvx()38cdf0e10cSrcweir 		GeoTexSvx::GeoTexSvx()
39cdf0e10cSrcweir 		{
40cdf0e10cSrcweir 		}
41cdf0e10cSrcweir 
~GeoTexSvx()42cdf0e10cSrcweir 		GeoTexSvx::~GeoTexSvx()
43cdf0e10cSrcweir 		{
44cdf0e10cSrcweir 		}
45cdf0e10cSrcweir 
operator ==(const GeoTexSvx &) const46cdf0e10cSrcweir 		bool GeoTexSvx::operator==(const GeoTexSvx& /*rGeoTexSvx*/) const
47cdf0e10cSrcweir 		{
48cdf0e10cSrcweir 			// default implementation says yes (no data -> no difference)
49cdf0e10cSrcweir 			return true;
50cdf0e10cSrcweir 		}
51cdf0e10cSrcweir 
modifyBColor(const basegfx::B2DPoint &,basegfx::BColor & rBColor,double &) const52cdf0e10cSrcweir 		void GeoTexSvx::modifyBColor(const basegfx::B2DPoint& /*rUV*/, basegfx::BColor& rBColor, double& /*rfOpacity*/) const
53cdf0e10cSrcweir 		{
54cdf0e10cSrcweir 			// base implementation creates random color (for testing only, may also be pure virtual)
55cdf0e10cSrcweir 			rBColor.setRed((rand() & 0x7fff) / 32767.0);
56cdf0e10cSrcweir 			rBColor.setGreen((rand() & 0x7fff) / 32767.0);
57cdf0e10cSrcweir 			rBColor.setBlue((rand() & 0x7fff) / 32767.0);
58cdf0e10cSrcweir 		}
59cdf0e10cSrcweir 
modifyOpacity(const basegfx::B2DPoint & rUV,double & rfOpacity) const60cdf0e10cSrcweir 		void GeoTexSvx::modifyOpacity(const basegfx::B2DPoint& rUV, double& rfOpacity) const
61cdf0e10cSrcweir 		{
62cdf0e10cSrcweir 			// base implementation uses inverse of luminance of solved color (for testing only, may also be pure virtual)
63cdf0e10cSrcweir 			basegfx::BColor aBaseColor;
64cdf0e10cSrcweir 			modifyBColor(rUV, aBaseColor, rfOpacity);
65cdf0e10cSrcweir 			rfOpacity = 1.0 - aBaseColor.luminance();
66cdf0e10cSrcweir 		}
67cdf0e10cSrcweir 	} // end of namespace texture
68cdf0e10cSrcweir } // end of namespace drawinglayer
69cdf0e10cSrcweir 
70cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
71cdf0e10cSrcweir 
72cdf0e10cSrcweir namespace drawinglayer
73cdf0e10cSrcweir {
7496fc4b33SArmin Le Grand     namespace texture
7596fc4b33SArmin Le Grand     {
GeoTexSvxGradient(const basegfx::B2DRange & rTargetRange,const basegfx::BColor & rStart,const basegfx::BColor & rEnd,sal_uInt32,double fBorder)7696fc4b33SArmin Le Grand 		GeoTexSvxGradient::GeoTexSvxGradient(
7796fc4b33SArmin Le Grand             const basegfx::B2DRange& rTargetRange,
7896fc4b33SArmin Le Grand             const basegfx::BColor& rStart,
7996fc4b33SArmin Le Grand             const basegfx::BColor& rEnd,
80d931502cSPavel Janík             sal_uInt32 /* nSteps */,
8196fc4b33SArmin Le Grand             double fBorder)
8296fc4b33SArmin Le Grand 		:	GeoTexSvx(),
8396fc4b33SArmin Le Grand             maGradientInfo(),
8496fc4b33SArmin Le Grand             maTargetRange(rTargetRange),
85cdf0e10cSrcweir 			maStart(rStart),
86cdf0e10cSrcweir 			maEnd(rEnd),
87cdf0e10cSrcweir 			mfBorder(fBorder)
88cdf0e10cSrcweir 		{
89cdf0e10cSrcweir 		}
90cdf0e10cSrcweir 
~GeoTexSvxGradient()91cdf0e10cSrcweir 		GeoTexSvxGradient::~GeoTexSvxGradient()
92cdf0e10cSrcweir 		{
93cdf0e10cSrcweir 		}
94cdf0e10cSrcweir 
operator ==(const GeoTexSvx & rGeoTexSvx) const95cdf0e10cSrcweir 		bool GeoTexSvxGradient::operator==(const GeoTexSvx& rGeoTexSvx) const
96cdf0e10cSrcweir 		{
97cdf0e10cSrcweir 			const GeoTexSvxGradient* pCompare = dynamic_cast< const GeoTexSvxGradient* >(&rGeoTexSvx);
9896fc4b33SArmin Le Grand 
9996fc4b33SArmin Le Grand             return (pCompare
10096fc4b33SArmin Le Grand 				&& maGradientInfo == pCompare->maGradientInfo
101cdf0e10cSrcweir 				&& maTargetRange == pCompare->maTargetRange
102cdf0e10cSrcweir 				&& mfBorder == pCompare->mfBorder);
103cdf0e10cSrcweir 		}
104cdf0e10cSrcweir 	} // end of namespace texture
105cdf0e10cSrcweir } // end of namespace drawinglayer
106cdf0e10cSrcweir 
107cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
108cdf0e10cSrcweir 
109cdf0e10cSrcweir namespace drawinglayer
110cdf0e10cSrcweir {
111cdf0e10cSrcweir 	namespace texture
112cdf0e10cSrcweir 	{
GeoTexSvxGradientLinear(const basegfx::B2DRange & rTargetRange,const basegfx::BColor & rStart,const basegfx::BColor & rEnd,sal_uInt32 nSteps,double fBorder,double fAngle)11396fc4b33SArmin Le Grand 		GeoTexSvxGradientLinear::GeoTexSvxGradientLinear(
11496fc4b33SArmin Le Grand             const basegfx::B2DRange& rTargetRange,
11596fc4b33SArmin Le Grand             const basegfx::BColor& rStart,
11696fc4b33SArmin Le Grand             const basegfx::BColor& rEnd,
11796fc4b33SArmin Le Grand             sal_uInt32 nSteps,
11896fc4b33SArmin Le Grand             double fBorder,
11996fc4b33SArmin Le Grand             double fAngle)
120cdf0e10cSrcweir 		:	GeoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder)
121cdf0e10cSrcweir 		{
12296fc4b33SArmin Le Grand             maGradientInfo = basegfx::tools::createLinearODFGradientInfo(
12396fc4b33SArmin Le Grand                 rTargetRange,
12496fc4b33SArmin Le Grand                 nSteps,
12596fc4b33SArmin Le Grand                 fBorder,
12696fc4b33SArmin Le Grand                 fAngle);
127cdf0e10cSrcweir 		}
128cdf0e10cSrcweir 
~GeoTexSvxGradientLinear()129cdf0e10cSrcweir 		GeoTexSvxGradientLinear::~GeoTexSvxGradientLinear()
130cdf0e10cSrcweir 		{
131cdf0e10cSrcweir 		}
132cdf0e10cSrcweir 
appendTransformationsAndColors(std::vector<B2DHomMatrixAndBColor> & rEntries,basegfx::BColor & rOutmostColor)13396fc4b33SArmin Le Grand         void GeoTexSvxGradientLinear::appendTransformationsAndColors(
13496fc4b33SArmin Le Grand             std::vector< B2DHomMatrixAndBColor >& rEntries,
13596fc4b33SArmin Le Grand             basegfx::BColor& rOutmostColor)
13696fc4b33SArmin Le Grand         {
13796fc4b33SArmin Le Grand             rOutmostColor = maStart;
13896fc4b33SArmin Le Grand 
13996fc4b33SArmin Le Grand             if(maGradientInfo.getSteps())
14096fc4b33SArmin Le Grand             {
14196fc4b33SArmin Le Grand                 const double fStripeWidth(1.0 / maGradientInfo.getSteps());
14296fc4b33SArmin Le Grand                 B2DHomMatrixAndBColor aB2DHomMatrixAndBColor;
14396fc4b33SArmin Le Grand 
14496fc4b33SArmin Le Grand                 for(sal_uInt32 a(1); a < maGradientInfo.getSteps(); a++)
14596fc4b33SArmin Le Grand                 {
14696fc4b33SArmin Le Grand                     const double fPos(fStripeWidth * a);
14796fc4b33SArmin Le Grand                     // optimized below...
14896fc4b33SArmin Le Grand                     //
14996fc4b33SArmin Le Grand                     // basegfx::B2DHomMatrix aNew;
15096fc4b33SArmin Le Grand                     // aNew.scale(0.5, 0.5);
15196fc4b33SArmin Le Grand                     // aNew.translate(0.5, 0.5);
15296fc4b33SArmin Le Grand                     // aNew.scale(1.0, (1.0 - fPos));
15396fc4b33SArmin Le Grand                     // aNew.translate(0.0, fPos);
15496fc4b33SArmin Le Grand                     // aNew = maGradientInfo.getTextureTransform() * aNew;
15596fc4b33SArmin Le Grand                     aB2DHomMatrixAndBColor.maB2DHomMatrix = maGradientInfo.getTextureTransform() *
15696fc4b33SArmin Le Grand                         basegfx::tools::createScaleTranslateB2DHomMatrix(0.5, 0.5 * (1.0 - fPos), 0.5, 0.5 * (1.0 + fPos));
15796fc4b33SArmin Le Grand                     aB2DHomMatrixAndBColor.maBColor = interpolate(maStart, maEnd, double(a) / double(maGradientInfo.getSteps() - 1));
15896fc4b33SArmin Le Grand                     rEntries.push_back(aB2DHomMatrixAndBColor);
15996fc4b33SArmin Le Grand                 }
16096fc4b33SArmin Le Grand             }
16196fc4b33SArmin Le Grand         }
162cdf0e10cSrcweir 
modifyBColor(const basegfx::B2DPoint & rUV,basegfx::BColor & rBColor,double &) const163cdf0e10cSrcweir 		void GeoTexSvxGradientLinear::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& /*rfOpacity*/) const
164cdf0e10cSrcweir 		{
165cdf0e10cSrcweir             const double fScaler(basegfx::tools::getLinearGradientAlpha(rUV, maGradientInfo));
166cdf0e10cSrcweir 
1677024eca9SArmin Le Grand             rBColor = basegfx::interpolate(maStart, maEnd, fScaler);
168cdf0e10cSrcweir 		}
169cdf0e10cSrcweir 	} // end of namespace texture
170cdf0e10cSrcweir } // end of namespace drawinglayer
171cdf0e10cSrcweir 
172cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
173cdf0e10cSrcweir 
174cdf0e10cSrcweir namespace drawinglayer
175cdf0e10cSrcweir {
176cdf0e10cSrcweir 	namespace texture
177cdf0e10cSrcweir 	{
GeoTexSvxGradientAxial(const basegfx::B2DRange & rTargetRange,const basegfx::BColor & rStart,const basegfx::BColor & rEnd,sal_uInt32 nSteps,double fBorder,double fAngle)17896fc4b33SArmin Le Grand 		GeoTexSvxGradientAxial::GeoTexSvxGradientAxial(
17996fc4b33SArmin Le Grand             const basegfx::B2DRange& rTargetRange,
18096fc4b33SArmin Le Grand             const basegfx::BColor& rStart,
18196fc4b33SArmin Le Grand             const basegfx::BColor& rEnd,
18296fc4b33SArmin Le Grand             sal_uInt32 nSteps,
18396fc4b33SArmin Le Grand             double fBorder,
18496fc4b33SArmin Le Grand             double fAngle)
185cdf0e10cSrcweir 		:	GeoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder)
186cdf0e10cSrcweir 		{
18796fc4b33SArmin Le Grand             maGradientInfo = basegfx::tools::createAxialODFGradientInfo(
18896fc4b33SArmin Le Grand                 rTargetRange,
18996fc4b33SArmin Le Grand                 nSteps,
19096fc4b33SArmin Le Grand                 fBorder,
19196fc4b33SArmin Le Grand                 fAngle);
192cdf0e10cSrcweir 		}
193cdf0e10cSrcweir 
~GeoTexSvxGradientAxial()194cdf0e10cSrcweir 		GeoTexSvxGradientAxial::~GeoTexSvxGradientAxial()
195cdf0e10cSrcweir 		{
196cdf0e10cSrcweir 		}
197cdf0e10cSrcweir 
appendTransformationsAndColors(std::vector<B2DHomMatrixAndBColor> & rEntries,basegfx::BColor & rOutmostColor)19896fc4b33SArmin Le Grand         void GeoTexSvxGradientAxial::appendTransformationsAndColors(
19996fc4b33SArmin Le Grand             std::vector< B2DHomMatrixAndBColor >& rEntries,
20096fc4b33SArmin Le Grand             basegfx::BColor& rOutmostColor)
20196fc4b33SArmin Le Grand         {
20296fc4b33SArmin Le Grand             rOutmostColor = maEnd;
203cdf0e10cSrcweir 
20496fc4b33SArmin Le Grand             if(maGradientInfo.getSteps())
20596fc4b33SArmin Le Grand             {
20696fc4b33SArmin Le Grand                 const double fStripeWidth(1.0 / maGradientInfo.getSteps());
20796fc4b33SArmin Le Grand                 B2DHomMatrixAndBColor aB2DHomMatrixAndBColor;
208cdf0e10cSrcweir 
20996fc4b33SArmin Le Grand                 for(sal_uInt32 a(1); a < maGradientInfo.getSteps(); a++)
21096fc4b33SArmin Le Grand                 {
21196fc4b33SArmin Le Grand                     // const double fPos(fStripeWidth * a);
21296fc4b33SArmin Le Grand                     // optimized below...
21396fc4b33SArmin Le Grand                     //
21496fc4b33SArmin Le Grand                     // basegfx::B2DHomMatrix aNew;
21596fc4b33SArmin Le Grand                     // aNew.scale(0.50, (1.0 - fPos));
21696fc4b33SArmin Le Grand                     // aNew.translate(0.5, 0.0);
21796fc4b33SArmin Le Grand                     // aNew = maGradientInfo.getTextureTransform() * aNew;
21896fc4b33SArmin Le Grand                     aB2DHomMatrixAndBColor.maB2DHomMatrix = maGradientInfo.getTextureTransform() *
21996fc4b33SArmin Le Grand                         basegfx::tools::createScaleTranslateB2DHomMatrix(0.5, 1.0 - (fStripeWidth * a), 0.5, 0.0);
22096fc4b33SArmin Le Grand                     aB2DHomMatrixAndBColor.maBColor = interpolate(maEnd, maStart, double(a) / double(maGradientInfo.getSteps() - 1));
22196fc4b33SArmin Le Grand                     rEntries.push_back(aB2DHomMatrixAndBColor);
22296fc4b33SArmin Le Grand                 }
22396fc4b33SArmin Le Grand             }
224cdf0e10cSrcweir 		}
225cdf0e10cSrcweir 
modifyBColor(const basegfx::B2DPoint & rUV,basegfx::BColor & rBColor,double &) const226cdf0e10cSrcweir 		void GeoTexSvxGradientAxial::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& /*rfOpacity*/) const
227cdf0e10cSrcweir 		{
228cdf0e10cSrcweir             const double fScaler(basegfx::tools::getAxialGradientAlpha(rUV, maGradientInfo));
229cdf0e10cSrcweir 
2307024eca9SArmin Le Grand             rBColor = basegfx::interpolate(maStart, maEnd, fScaler);
231cdf0e10cSrcweir 		}
232cdf0e10cSrcweir 	} // end of namespace texture
233cdf0e10cSrcweir } // end of namespace drawinglayer
234cdf0e10cSrcweir 
235cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
236cdf0e10cSrcweir 
237cdf0e10cSrcweir namespace drawinglayer
238cdf0e10cSrcweir {
239cdf0e10cSrcweir 	namespace texture
240cdf0e10cSrcweir 	{
GeoTexSvxGradientRadial(const basegfx::B2DRange & rTargetRange,const basegfx::BColor & rStart,const basegfx::BColor & rEnd,sal_uInt32 nSteps,double fBorder,double fOffsetX,double fOffsetY)24196fc4b33SArmin Le Grand 		GeoTexSvxGradientRadial::GeoTexSvxGradientRadial(
24296fc4b33SArmin Le Grand             const basegfx::B2DRange& rTargetRange,
24396fc4b33SArmin Le Grand             const basegfx::BColor& rStart,
24496fc4b33SArmin Le Grand             const basegfx::BColor& rEnd,
24596fc4b33SArmin Le Grand             sal_uInt32 nSteps,
24696fc4b33SArmin Le Grand             double fBorder,
24796fc4b33SArmin Le Grand             double fOffsetX,
24896fc4b33SArmin Le Grand             double fOffsetY)
249cdf0e10cSrcweir 		:	GeoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder)
250cdf0e10cSrcweir 		{
25196fc4b33SArmin Le Grand             maGradientInfo = basegfx::tools::createRadialODFGradientInfo(
25296fc4b33SArmin Le Grand                 rTargetRange,
25396fc4b33SArmin Le Grand                 basegfx::B2DVector(fOffsetX,fOffsetY),
25496fc4b33SArmin Le Grand                 nSteps,
25596fc4b33SArmin Le Grand                 fBorder);
256cdf0e10cSrcweir 		}
257cdf0e10cSrcweir 
~GeoTexSvxGradientRadial()258cdf0e10cSrcweir 		GeoTexSvxGradientRadial::~GeoTexSvxGradientRadial()
259cdf0e10cSrcweir 		{
260cdf0e10cSrcweir 		}
261cdf0e10cSrcweir 
appendTransformationsAndColors(std::vector<B2DHomMatrixAndBColor> & rEntries,basegfx::BColor & rOutmostColor)26296fc4b33SArmin Le Grand 		void GeoTexSvxGradientRadial::appendTransformationsAndColors(
26396fc4b33SArmin Le Grand             std::vector< B2DHomMatrixAndBColor >& rEntries,
26496fc4b33SArmin Le Grand             basegfx::BColor& rOutmostColor)
265cdf0e10cSrcweir 		{
26696fc4b33SArmin Le Grand             rOutmostColor = maStart;
267cdf0e10cSrcweir 
26896fc4b33SArmin Le Grand             if(maGradientInfo.getSteps())
26996fc4b33SArmin Le Grand             {
27096fc4b33SArmin Le Grand                 const double fStepSize(1.0 / maGradientInfo.getSteps());
27196fc4b33SArmin Le Grand                 B2DHomMatrixAndBColor aB2DHomMatrixAndBColor;
27296fc4b33SArmin Le Grand 
27396fc4b33SArmin Le Grand                 for(sal_uInt32 a(1); a < maGradientInfo.getSteps(); a++)
27496fc4b33SArmin Le Grand                 {
27596fc4b33SArmin Le Grand                     const double fSize(1.0 - (fStepSize * a));
27696fc4b33SArmin Le Grand                     aB2DHomMatrixAndBColor.maB2DHomMatrix = maGradientInfo.getTextureTransform() * basegfx::tools::createScaleB2DHomMatrix(fSize, fSize);
27796fc4b33SArmin Le Grand                     aB2DHomMatrixAndBColor.maBColor = interpolate(maStart, maEnd, double(a) / double(maGradientInfo.getSteps() - 1));
27896fc4b33SArmin Le Grand                     rEntries.push_back(aB2DHomMatrixAndBColor);
27996fc4b33SArmin Le Grand                 }
28096fc4b33SArmin Le Grand             }
28196fc4b33SArmin Le Grand         }
282cdf0e10cSrcweir 
modifyBColor(const basegfx::B2DPoint & rUV,basegfx::BColor & rBColor,double &) const283cdf0e10cSrcweir 		void GeoTexSvxGradientRadial::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& /*rfOpacity*/) const
284cdf0e10cSrcweir 		{
285cdf0e10cSrcweir             const double fScaler(basegfx::tools::getRadialGradientAlpha(rUV, maGradientInfo));
286cdf0e10cSrcweir 
2877024eca9SArmin Le Grand             rBColor = basegfx::interpolate(maStart, maEnd, fScaler);
288cdf0e10cSrcweir 		}
289cdf0e10cSrcweir 	} // end of namespace texture
290cdf0e10cSrcweir } // end of namespace drawinglayer
291cdf0e10cSrcweir 
292cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
293cdf0e10cSrcweir 
294cdf0e10cSrcweir namespace drawinglayer
295cdf0e10cSrcweir {
296cdf0e10cSrcweir 	namespace texture
297cdf0e10cSrcweir 	{
GeoTexSvxGradientElliptical(const basegfx::B2DRange & rTargetRange,const basegfx::BColor & rStart,const basegfx::BColor & rEnd,sal_uInt32 nSteps,double fBorder,double fOffsetX,double fOffsetY,double fAngle)29896fc4b33SArmin Le Grand 		GeoTexSvxGradientElliptical::GeoTexSvxGradientElliptical(
29996fc4b33SArmin Le Grand             const basegfx::B2DRange& rTargetRange,
30096fc4b33SArmin Le Grand             const basegfx::BColor& rStart,
30196fc4b33SArmin Le Grand             const basegfx::BColor& rEnd,
30296fc4b33SArmin Le Grand             sal_uInt32 nSteps,
30396fc4b33SArmin Le Grand             double fBorder,
30496fc4b33SArmin Le Grand             double fOffsetX,
30596fc4b33SArmin Le Grand             double fOffsetY,
30696fc4b33SArmin Le Grand             double fAngle)
307cdf0e10cSrcweir 		:	GeoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder)
308cdf0e10cSrcweir 		{
30996fc4b33SArmin Le Grand             maGradientInfo = basegfx::tools::createEllipticalODFGradientInfo(
31096fc4b33SArmin Le Grand                 rTargetRange,
31196fc4b33SArmin Le Grand                 basegfx::B2DVector(fOffsetX,fOffsetY),
31296fc4b33SArmin Le Grand                 nSteps,
31396fc4b33SArmin Le Grand                 fBorder,
31496fc4b33SArmin Le Grand                 fAngle);
315cdf0e10cSrcweir 		}
316cdf0e10cSrcweir 
~GeoTexSvxGradientElliptical()317cdf0e10cSrcweir 		GeoTexSvxGradientElliptical::~GeoTexSvxGradientElliptical()
318cdf0e10cSrcweir 		{
319cdf0e10cSrcweir 		}
320cdf0e10cSrcweir 
appendTransformationsAndColors(std::vector<B2DHomMatrixAndBColor> & rEntries,basegfx::BColor & rOutmostColor)32196fc4b33SArmin Le Grand 		void GeoTexSvxGradientElliptical::appendTransformationsAndColors(
32296fc4b33SArmin Le Grand             std::vector< B2DHomMatrixAndBColor >& rEntries,
32396fc4b33SArmin Le Grand             basegfx::BColor& rOutmostColor)
324cdf0e10cSrcweir 		{
32596fc4b33SArmin Le Grand             rOutmostColor = maStart;
326cdf0e10cSrcweir 
32796fc4b33SArmin Le Grand             if(maGradientInfo.getSteps())
32896fc4b33SArmin Le Grand             {
32996fc4b33SArmin Le Grand                 double fWidth(1.0);
33096fc4b33SArmin Le Grand                 double fHeight(1.0);
33196fc4b33SArmin Le Grand                 double fIncrementX(0.0);
33296fc4b33SArmin Le Grand                 double fIncrementY(0.0);
33396fc4b33SArmin Le Grand 
33496fc4b33SArmin Le Grand                 if(maGradientInfo.getAspectRatio() > 1.0)
33596fc4b33SArmin Le Grand                 {
33696fc4b33SArmin Le Grand                     fIncrementY = fHeight / maGradientInfo.getSteps();
33796fc4b33SArmin Le Grand                     fIncrementX = fIncrementY / maGradientInfo.getAspectRatio();
33896fc4b33SArmin Le Grand                 }
33996fc4b33SArmin Le Grand                 else
34096fc4b33SArmin Le Grand                 {
34196fc4b33SArmin Le Grand                     fIncrementX = fWidth / maGradientInfo.getSteps();
34296fc4b33SArmin Le Grand                     fIncrementY = fIncrementX * maGradientInfo.getAspectRatio();
34396fc4b33SArmin Le Grand                 }
34496fc4b33SArmin Le Grand 
34596fc4b33SArmin Le Grand                 B2DHomMatrixAndBColor aB2DHomMatrixAndBColor;
34696fc4b33SArmin Le Grand 
34796fc4b33SArmin Le Grand                 for(sal_uInt32 a(1); a < maGradientInfo.getSteps(); a++)
34896fc4b33SArmin Le Grand                 {
34996fc4b33SArmin Le Grand                     // next step
35096fc4b33SArmin Le Grand                     fWidth -= fIncrementX;
35196fc4b33SArmin Le Grand                     fHeight -= fIncrementY;
35296fc4b33SArmin Le Grand 
35396fc4b33SArmin Le Grand                     aB2DHomMatrixAndBColor.maB2DHomMatrix = maGradientInfo.getTextureTransform() * basegfx::tools::createScaleB2DHomMatrix(fWidth, fHeight);
35496fc4b33SArmin Le Grand                     aB2DHomMatrixAndBColor.maBColor = interpolate(maStart, maEnd, double(a) / double(maGradientInfo.getSteps() - 1));
35596fc4b33SArmin Le Grand                     rEntries.push_back(aB2DHomMatrixAndBColor);
35696fc4b33SArmin Le Grand                 }
35796fc4b33SArmin Le Grand             }
358cdf0e10cSrcweir 		}
359cdf0e10cSrcweir 
modifyBColor(const basegfx::B2DPoint & rUV,basegfx::BColor & rBColor,double &) const360cdf0e10cSrcweir 		void GeoTexSvxGradientElliptical::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& /*rfOpacity*/) const
361cdf0e10cSrcweir 		{
362cdf0e10cSrcweir             const double fScaler(basegfx::tools::getEllipticalGradientAlpha(rUV, maGradientInfo));
363cdf0e10cSrcweir 
3647024eca9SArmin Le Grand             rBColor = basegfx::interpolate(maStart, maEnd, fScaler);
365cdf0e10cSrcweir 		}
366cdf0e10cSrcweir 	} // end of namespace texture
367cdf0e10cSrcweir } // end of namespace drawinglayer
368cdf0e10cSrcweir 
369cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
370cdf0e10cSrcweir 
371cdf0e10cSrcweir namespace drawinglayer
372cdf0e10cSrcweir {
373cdf0e10cSrcweir 	namespace texture
374cdf0e10cSrcweir 	{
GeoTexSvxGradientSquare(const basegfx::B2DRange & rTargetRange,const basegfx::BColor & rStart,const basegfx::BColor & rEnd,sal_uInt32 nSteps,double fBorder,double fOffsetX,double fOffsetY,double fAngle)37596fc4b33SArmin Le Grand 		GeoTexSvxGradientSquare::GeoTexSvxGradientSquare(
37696fc4b33SArmin Le Grand             const basegfx::B2DRange& rTargetRange,
37796fc4b33SArmin Le Grand             const basegfx::BColor& rStart,
37896fc4b33SArmin Le Grand             const basegfx::BColor& rEnd,
37996fc4b33SArmin Le Grand             sal_uInt32 nSteps,
38096fc4b33SArmin Le Grand             double fBorder,
38196fc4b33SArmin Le Grand             double fOffsetX,
38296fc4b33SArmin Le Grand             double fOffsetY,
38396fc4b33SArmin Le Grand             double fAngle)
384cdf0e10cSrcweir 		:	GeoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder)
385cdf0e10cSrcweir 		{
38696fc4b33SArmin Le Grand             maGradientInfo = basegfx::tools::createSquareODFGradientInfo(
38796fc4b33SArmin Le Grand                 rTargetRange,
38896fc4b33SArmin Le Grand                 basegfx::B2DVector(fOffsetX,fOffsetY),
38996fc4b33SArmin Le Grand                 nSteps,
39096fc4b33SArmin Le Grand                 fBorder,
39196fc4b33SArmin Le Grand                 fAngle);
392cdf0e10cSrcweir 		}
393cdf0e10cSrcweir 
~GeoTexSvxGradientSquare()394cdf0e10cSrcweir 		GeoTexSvxGradientSquare::~GeoTexSvxGradientSquare()
395cdf0e10cSrcweir 		{
396cdf0e10cSrcweir 		}
397cdf0e10cSrcweir 
appendTransformationsAndColors(std::vector<B2DHomMatrixAndBColor> & rEntries,basegfx::BColor & rOutmostColor)39896fc4b33SArmin Le Grand 		void GeoTexSvxGradientSquare::appendTransformationsAndColors(
39996fc4b33SArmin Le Grand             std::vector< B2DHomMatrixAndBColor >& rEntries,
40096fc4b33SArmin Le Grand             basegfx::BColor& rOutmostColor)
401cdf0e10cSrcweir 		{
40296fc4b33SArmin Le Grand             rOutmostColor = maStart;
403cdf0e10cSrcweir 
40496fc4b33SArmin Le Grand             if(maGradientInfo.getSteps())
40596fc4b33SArmin Le Grand             {
40696fc4b33SArmin Le Grand                 const double fStepSize(1.0 / maGradientInfo.getSteps());
40796fc4b33SArmin Le Grand                 B2DHomMatrixAndBColor aB2DHomMatrixAndBColor;
40896fc4b33SArmin Le Grand 
40996fc4b33SArmin Le Grand                 for(sal_uInt32 a(1); a < maGradientInfo.getSteps(); a++)
41096fc4b33SArmin Le Grand                 {
41196fc4b33SArmin Le Grand                     const double fSize(1.0 - (fStepSize * a));
41296fc4b33SArmin Le Grand                     aB2DHomMatrixAndBColor.maB2DHomMatrix = maGradientInfo.getTextureTransform() * basegfx::tools::createScaleB2DHomMatrix(fSize, fSize);
41396fc4b33SArmin Le Grand                     aB2DHomMatrixAndBColor.maBColor = interpolate(maStart, maEnd, double(a) / double(maGradientInfo.getSteps() - 1));
41496fc4b33SArmin Le Grand                     rEntries.push_back(aB2DHomMatrixAndBColor);
41596fc4b33SArmin Le Grand                 }
41696fc4b33SArmin Le Grand             }
417cdf0e10cSrcweir 		}
418cdf0e10cSrcweir 
modifyBColor(const basegfx::B2DPoint & rUV,basegfx::BColor & rBColor,double &) const419cdf0e10cSrcweir 		void GeoTexSvxGradientSquare::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& /*rfOpacity*/) const
420cdf0e10cSrcweir 		{
421cdf0e10cSrcweir             const double fScaler(basegfx::tools::getSquareGradientAlpha(rUV, maGradientInfo));
422cdf0e10cSrcweir 
4237024eca9SArmin Le Grand             rBColor = basegfx::interpolate(maStart, maEnd, fScaler);
424cdf0e10cSrcweir 		}
425cdf0e10cSrcweir 	} // end of namespace texture
426cdf0e10cSrcweir } // end of namespace drawinglayer
427cdf0e10cSrcweir 
428cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
429cdf0e10cSrcweir 
430cdf0e10cSrcweir namespace drawinglayer
431cdf0e10cSrcweir {
432cdf0e10cSrcweir 	namespace texture
433cdf0e10cSrcweir 	{
GeoTexSvxGradientRect(const basegfx::B2DRange & rTargetRange,const basegfx::BColor & rStart,const basegfx::BColor & rEnd,sal_uInt32 nSteps,double fBorder,double fOffsetX,double fOffsetY,double fAngle)43496fc4b33SArmin Le Grand 		GeoTexSvxGradientRect::GeoTexSvxGradientRect(
43596fc4b33SArmin Le Grand             const basegfx::B2DRange& rTargetRange,
43696fc4b33SArmin Le Grand             const basegfx::BColor& rStart,
43796fc4b33SArmin Le Grand             const basegfx::BColor& rEnd,
43896fc4b33SArmin Le Grand             sal_uInt32 nSteps,
43996fc4b33SArmin Le Grand             double fBorder,
44096fc4b33SArmin Le Grand             double fOffsetX,
44196fc4b33SArmin Le Grand             double fOffsetY,
44296fc4b33SArmin Le Grand             double fAngle)
443cdf0e10cSrcweir 		:	GeoTexSvxGradient(rTargetRange, rStart, rEnd, nSteps, fBorder)
444cdf0e10cSrcweir 		{
44596fc4b33SArmin Le Grand             maGradientInfo = basegfx::tools::createRectangularODFGradientInfo(
44696fc4b33SArmin Le Grand                 rTargetRange,
44796fc4b33SArmin Le Grand                 basegfx::B2DVector(fOffsetX,fOffsetY),
44896fc4b33SArmin Le Grand                 nSteps,
44996fc4b33SArmin Le Grand                 fBorder,
45096fc4b33SArmin Le Grand                 fAngle);
451cdf0e10cSrcweir 		}
452cdf0e10cSrcweir 
~GeoTexSvxGradientRect()453cdf0e10cSrcweir 		GeoTexSvxGradientRect::~GeoTexSvxGradientRect()
454cdf0e10cSrcweir 		{
455cdf0e10cSrcweir 		}
456cdf0e10cSrcweir 
appendTransformationsAndColors(std::vector<B2DHomMatrixAndBColor> & rEntries,basegfx::BColor & rOutmostColor)45796fc4b33SArmin Le Grand 		void GeoTexSvxGradientRect::appendTransformationsAndColors(
45896fc4b33SArmin Le Grand             std::vector< B2DHomMatrixAndBColor >& rEntries,
45996fc4b33SArmin Le Grand             basegfx::BColor& rOutmostColor)
460cdf0e10cSrcweir 		{
46196fc4b33SArmin Le Grand             rOutmostColor = maStart;
462cdf0e10cSrcweir 
46396fc4b33SArmin Le Grand             if(maGradientInfo.getSteps())
46496fc4b33SArmin Le Grand             {
46596fc4b33SArmin Le Grand                 double fWidth(1.0);
46696fc4b33SArmin Le Grand                 double fHeight(1.0);
46796fc4b33SArmin Le Grand                 double fIncrementX(0.0);
46896fc4b33SArmin Le Grand                 double fIncrementY(0.0);
46996fc4b33SArmin Le Grand 
47096fc4b33SArmin Le Grand                 if(maGradientInfo.getAspectRatio() > 1.0)
47196fc4b33SArmin Le Grand                 {
47296fc4b33SArmin Le Grand                     fIncrementY = fHeight / maGradientInfo.getSteps();
47396fc4b33SArmin Le Grand                     fIncrementX = fIncrementY / maGradientInfo.getAspectRatio();
47496fc4b33SArmin Le Grand                 }
47596fc4b33SArmin Le Grand                 else
47696fc4b33SArmin Le Grand                 {
47796fc4b33SArmin Le Grand                     fIncrementX = fWidth / maGradientInfo.getSteps();
47896fc4b33SArmin Le Grand                     fIncrementY = fIncrementX * maGradientInfo.getAspectRatio();
47996fc4b33SArmin Le Grand                 }
48096fc4b33SArmin Le Grand 
48196fc4b33SArmin Le Grand                 B2DHomMatrixAndBColor aB2DHomMatrixAndBColor;
48296fc4b33SArmin Le Grand 
48396fc4b33SArmin Le Grand                 for(sal_uInt32 a(1); a < maGradientInfo.getSteps(); a++)
48496fc4b33SArmin Le Grand                 {
48596fc4b33SArmin Le Grand                     // next step
48696fc4b33SArmin Le Grand                     fWidth -= fIncrementX;
48796fc4b33SArmin Le Grand                     fHeight -= fIncrementY;
48896fc4b33SArmin Le Grand 
48996fc4b33SArmin Le Grand                     aB2DHomMatrixAndBColor.maB2DHomMatrix = maGradientInfo.getTextureTransform() * basegfx::tools::createScaleB2DHomMatrix(fWidth, fHeight);
49096fc4b33SArmin Le Grand                     aB2DHomMatrixAndBColor.maBColor = interpolate(maStart, maEnd, double(a) / double(maGradientInfo.getSteps() - 1));
49196fc4b33SArmin Le Grand                     rEntries.push_back(aB2DHomMatrixAndBColor);
49296fc4b33SArmin Le Grand                 }
49396fc4b33SArmin Le Grand             }
494cdf0e10cSrcweir 		}
495cdf0e10cSrcweir 
modifyBColor(const basegfx::B2DPoint & rUV,basegfx::BColor & rBColor,double &) const496cdf0e10cSrcweir 		void GeoTexSvxGradientRect::modifyBColor(const basegfx::B2DPoint& rUV, basegfx::BColor& rBColor, double& /*rfOpacity*/) const
497cdf0e10cSrcweir 		{
498cdf0e10cSrcweir             const double fScaler(basegfx::tools::getRectangularGradientAlpha(rUV, maGradientInfo));
499cdf0e10cSrcweir 
5007024eca9SArmin Le Grand             rBColor = basegfx::interpolate(maStart, maEnd, fScaler);
501cdf0e10cSrcweir 		}
502cdf0e10cSrcweir 	} // end of namespace texture
503cdf0e10cSrcweir } // end of namespace drawinglayer
504cdf0e10cSrcweir 
505cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
506cdf0e10cSrcweir 
507cdf0e10cSrcweir namespace drawinglayer
508cdf0e10cSrcweir {
509cdf0e10cSrcweir 	namespace texture
510cdf0e10cSrcweir 	{
GeoTexSvxHatch(const basegfx::B2DRange & rTargetRange,double fDistance,double fAngle)51196fc4b33SArmin Le Grand 		GeoTexSvxHatch::GeoTexSvxHatch(
51296fc4b33SArmin Le Grand             const basegfx::B2DRange& rTargetRange,
51396fc4b33SArmin Le Grand             double fDistance,
51496fc4b33SArmin Le Grand             double fAngle)
515cdf0e10cSrcweir 		:	mfDistance(0.1),
516cdf0e10cSrcweir 			mfAngle(fAngle),
517cdf0e10cSrcweir 			mnSteps(10L)
518cdf0e10cSrcweir 		{
519cdf0e10cSrcweir 			double fTargetSizeX(rTargetRange.getWidth());
520cdf0e10cSrcweir 			double fTargetSizeY(rTargetRange.getHeight());
521cdf0e10cSrcweir 			double fTargetOffsetX(rTargetRange.getMinX());
522cdf0e10cSrcweir 			double fTargetOffsetY(rTargetRange.getMinY());
523cdf0e10cSrcweir 
524cdf0e10cSrcweir             fAngle = -fAngle;
525cdf0e10cSrcweir 
526cdf0e10cSrcweir 			// add object expansion
527cdf0e10cSrcweir 			if(0.0 != fAngle)
528cdf0e10cSrcweir 			{
529cdf0e10cSrcweir 				const double fAbsCos(fabs(cos(fAngle)));
530cdf0e10cSrcweir 				const double fAbsSin(fabs(sin(fAngle)));
531cdf0e10cSrcweir 				const double fNewX(fTargetSizeX * fAbsCos + fTargetSizeY * fAbsSin);
532cdf0e10cSrcweir 				const double fNewY(fTargetSizeY * fAbsCos + fTargetSizeX * fAbsSin);
533cdf0e10cSrcweir 				fTargetOffsetX -= (fNewX - fTargetSizeX) / 2.0;
534cdf0e10cSrcweir 				fTargetOffsetY -= (fNewY - fTargetSizeY) / 2.0;
535cdf0e10cSrcweir 				fTargetSizeX = fNewX;
536cdf0e10cSrcweir 				fTargetSizeY = fNewY;
537cdf0e10cSrcweir 			}
538cdf0e10cSrcweir 
539cdf0e10cSrcweir 			// add object scale before rotate
540cdf0e10cSrcweir 			maTextureTransform.scale(fTargetSizeX, fTargetSizeY);
541cdf0e10cSrcweir 
542cdf0e10cSrcweir 			// add texture rotate after scale to keep perpendicular angles
543cdf0e10cSrcweir 			if(0.0 != fAngle)
544cdf0e10cSrcweir 			{
545cdf0e10cSrcweir 				basegfx::B2DPoint aCenter(0.5, 0.5);
546cdf0e10cSrcweir 				aCenter *= maTextureTransform;
547cdf0e10cSrcweir 
548cdf0e10cSrcweir                 maTextureTransform = basegfx::tools::createRotateAroundPoint(aCenter, fAngle)
549cdf0e10cSrcweir                     * maTextureTransform;
550cdf0e10cSrcweir 			}
551cdf0e10cSrcweir 
552cdf0e10cSrcweir 			// add object translate
553cdf0e10cSrcweir 			maTextureTransform.translate(fTargetOffsetX, fTargetOffsetY);
554cdf0e10cSrcweir 
555cdf0e10cSrcweir 			// prepare height for texture
556cdf0e10cSrcweir 			const double fSteps((0.0 != fDistance) ? fTargetSizeY / fDistance : 10.0);
557cdf0e10cSrcweir 			mnSteps = basegfx::fround(fSteps + 0.5);
558cdf0e10cSrcweir 			mfDistance = 1.0 / fSteps;
559cdf0e10cSrcweir 		}
560cdf0e10cSrcweir 
~GeoTexSvxHatch()561cdf0e10cSrcweir 		GeoTexSvxHatch::~GeoTexSvxHatch()
562cdf0e10cSrcweir 		{
563cdf0e10cSrcweir 		}
564cdf0e10cSrcweir 
operator ==(const GeoTexSvx & rGeoTexSvx) const565cdf0e10cSrcweir 		bool GeoTexSvxHatch::operator==(const GeoTexSvx& rGeoTexSvx) const
566cdf0e10cSrcweir 		{
567cdf0e10cSrcweir 			const GeoTexSvxHatch* pCompare = dynamic_cast< const GeoTexSvxHatch* >(&rGeoTexSvx);
568cdf0e10cSrcweir 			return (pCompare
569cdf0e10cSrcweir 				&& maTextureTransform == pCompare->maTextureTransform
570cdf0e10cSrcweir 				&& mfDistance == pCompare->mfDistance
571cdf0e10cSrcweir 				&& mfAngle == pCompare->mfAngle
572cdf0e10cSrcweir 				&& mnSteps == pCompare->mnSteps);
573cdf0e10cSrcweir 		}
574cdf0e10cSrcweir 
appendTransformations(::std::vector<basegfx::B2DHomMatrix> & rMatrices)575cdf0e10cSrcweir 		void GeoTexSvxHatch::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices)
576cdf0e10cSrcweir 		{
577cdf0e10cSrcweir 			for(sal_uInt32 a(1L); a < mnSteps; a++)
578cdf0e10cSrcweir 			{
579cdf0e10cSrcweir 				// create matrix
580cdf0e10cSrcweir 				const double fOffset(mfDistance * (double)a);
581cdf0e10cSrcweir 				basegfx::B2DHomMatrix aNew;
582cdf0e10cSrcweir 				aNew.set(1, 2, fOffset);
583cdf0e10cSrcweir 				rMatrices.push_back(maTextureTransform * aNew);
584cdf0e10cSrcweir 			}
585cdf0e10cSrcweir 		}
586cdf0e10cSrcweir 
getDistanceToHatch(const basegfx::B2DPoint & rUV) const587cdf0e10cSrcweir 		double GeoTexSvxHatch::getDistanceToHatch(const basegfx::B2DPoint& rUV) const
588cdf0e10cSrcweir 		{
58996fc4b33SArmin Le Grand 			const basegfx::B2DPoint aCoor(getBackTextureTransform() * rUV);
590cdf0e10cSrcweir 			return fmod(aCoor.getY(), mfDistance);
591cdf0e10cSrcweir 		}
59296fc4b33SArmin Le Grand 
getBackTextureTransform() const59396fc4b33SArmin Le Grand         const basegfx::B2DHomMatrix& GeoTexSvxHatch::getBackTextureTransform() const
59496fc4b33SArmin Le Grand         {
59596fc4b33SArmin Le Grand             if(maBackTextureTransform.isIdentity())
59696fc4b33SArmin Le Grand             {
59796fc4b33SArmin Le Grand                 const_cast< GeoTexSvxHatch* >(this)->maBackTextureTransform = maTextureTransform;
59896fc4b33SArmin Le Grand                 const_cast< GeoTexSvxHatch* >(this)->maBackTextureTransform.invert();
59996fc4b33SArmin Le Grand             }
60096fc4b33SArmin Le Grand 
60196fc4b33SArmin Le Grand             return maBackTextureTransform;
60296fc4b33SArmin Le Grand         }
603cdf0e10cSrcweir 	} // end of namespace texture
604cdf0e10cSrcweir } // end of namespace drawinglayer
605cdf0e10cSrcweir 
606cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
607cdf0e10cSrcweir 
608cdf0e10cSrcweir namespace drawinglayer
609cdf0e10cSrcweir {
610cdf0e10cSrcweir 	namespace texture
611cdf0e10cSrcweir 	{
GeoTexSvxTiled(const basegfx::B2DRange & rRange,double fOffsetX,double fOffsetY)61296fc4b33SArmin Le Grand 		GeoTexSvxTiled::GeoTexSvxTiled(
613*035a2f44SArmin Le Grand             const basegfx::B2DRange& rRange,
614*035a2f44SArmin Le Grand             double fOffsetX,
615*035a2f44SArmin Le Grand             double fOffsetY)
616*035a2f44SArmin Le Grand 		:	maRange(rRange),
617*035a2f44SArmin Le Grand             mfOffsetX(basegfx::clamp(fOffsetX, 0.0, 1.0)),
618*035a2f44SArmin Le Grand             mfOffsetY(basegfx::clamp(fOffsetY, 0.0, 1.0))
619cdf0e10cSrcweir 		{
620*035a2f44SArmin Le Grand             if(!basegfx::fTools::equalZero(mfOffsetX))
621*035a2f44SArmin Le Grand             {
622*035a2f44SArmin Le Grand                 mfOffsetY = 0.0;
623*035a2f44SArmin Le Grand             }
624cdf0e10cSrcweir 		}
625cdf0e10cSrcweir 
~GeoTexSvxTiled()626cdf0e10cSrcweir 		GeoTexSvxTiled::~GeoTexSvxTiled()
627cdf0e10cSrcweir 		{
628cdf0e10cSrcweir 		}
629cdf0e10cSrcweir 
operator ==(const GeoTexSvx & rGeoTexSvx) const630cdf0e10cSrcweir 		bool GeoTexSvxTiled::operator==(const GeoTexSvx& rGeoTexSvx) const
631cdf0e10cSrcweir 		{
632cdf0e10cSrcweir 			const GeoTexSvxTiled* pCompare = dynamic_cast< const GeoTexSvxTiled* >(&rGeoTexSvx);
633*035a2f44SArmin Le Grand 
634*035a2f44SArmin Le Grand             return (pCompare
635*035a2f44SArmin Le Grand 				&& maRange == pCompare->maRange
636*035a2f44SArmin Le Grand 				&& mfOffsetX == pCompare->mfOffsetX
637*035a2f44SArmin Le Grand                 && mfOffsetY == pCompare->mfOffsetY);
638cdf0e10cSrcweir 		}
639cdf0e10cSrcweir 
appendTransformations(::std::vector<basegfx::B2DHomMatrix> & rMatrices)640cdf0e10cSrcweir 		void GeoTexSvxTiled::appendTransformations(::std::vector< basegfx::B2DHomMatrix >& rMatrices)
641cdf0e10cSrcweir 		{
642*035a2f44SArmin Le Grand             const double fWidth(maRange.getWidth());
643cdf0e10cSrcweir 
644*035a2f44SArmin Le Grand             if(!basegfx::fTools::equalZero(fWidth))
645*035a2f44SArmin Le Grand             {
646*035a2f44SArmin Le Grand                 const double fHeight(maRange.getHeight());
647cdf0e10cSrcweir 
648*035a2f44SArmin Le Grand                 if(!basegfx::fTools::equalZero(fHeight))
649*035a2f44SArmin Le Grand                 {
650*035a2f44SArmin Le Grand 			        double fStartX(maRange.getMinX());
651*035a2f44SArmin Le Grand 			        double fStartY(maRange.getMinY());
652*035a2f44SArmin Le Grand                     sal_Int32 nPosX(0);
653*035a2f44SArmin Le Grand                     sal_Int32 nPosY(0);
654*035a2f44SArmin Le Grand 
655*035a2f44SArmin Le Grand 			        if(basegfx::fTools::more(fStartX, 0.0))
656*035a2f44SArmin Le Grand 			        {
657*035a2f44SArmin Le Grand                         const sal_Int32 nDiff(static_cast<sal_Int32>(floor(fStartX / fWidth)) + 1);
658*035a2f44SArmin Le Grand 
659*035a2f44SArmin Le Grand                         nPosX -= nDiff;
660*035a2f44SArmin Le Grand 				        fStartX -= nDiff * fWidth;
661*035a2f44SArmin Le Grand 			        }
662*035a2f44SArmin Le Grand 
663*035a2f44SArmin Le Grand 			        if(basegfx::fTools::less(fStartX + fWidth, 0.0))
664*035a2f44SArmin Le Grand 			        {
665*035a2f44SArmin Le Grand                         const sal_Int32 nDiff(static_cast<sal_Int32>(floor(-fStartX / fWidth)));
666*035a2f44SArmin Le Grand 
667*035a2f44SArmin Le Grand                         nPosX += nDiff;
668*035a2f44SArmin Le Grand 				        fStartX += nDiff * fWidth;
669*035a2f44SArmin Le Grand 			        }
670*035a2f44SArmin Le Grand 
671*035a2f44SArmin Le Grand 			        if(basegfx::fTools::more(fStartY, 0.0))
672*035a2f44SArmin Le Grand 			        {
673*035a2f44SArmin Le Grand                         const sal_Int32 nDiff(static_cast<sal_Int32>(floor(fStartY / fHeight)) + 1);
674*035a2f44SArmin Le Grand 
675*035a2f44SArmin Le Grand                         nPosY -= nDiff;
676*035a2f44SArmin Le Grand 				        fStartY -= nDiff * fHeight;
677*035a2f44SArmin Le Grand 			        }
678*035a2f44SArmin Le Grand 
679*035a2f44SArmin Le Grand 			        if(basegfx::fTools::less(fStartY + fHeight, 0.0))
680*035a2f44SArmin Le Grand 			        {
681*035a2f44SArmin Le Grand                         const sal_Int32 nDiff(static_cast<sal_Int32>(floor(-fStartY / fHeight)));
682*035a2f44SArmin Le Grand 
683*035a2f44SArmin Le Grand                         nPosY += nDiff;
684*035a2f44SArmin Le Grand 				        fStartY += nDiff * fHeight;
685*035a2f44SArmin Le Grand 			        }
686*035a2f44SArmin Le Grand 
687*035a2f44SArmin Le Grand                     if(!basegfx::fTools::equalZero(mfOffsetY))
688*035a2f44SArmin Le Grand                     {
689*035a2f44SArmin Le Grand                         for(double fPosX(fStartX); basegfx::fTools::less(fPosX, 1.0); fPosX += fWidth, nPosX++)
690*035a2f44SArmin Le Grand                         {
691*035a2f44SArmin Le Grand                             for(double fPosY(nPosX % 2 ? fStartY - fHeight + (mfOffsetY * fHeight) : fStartY);
692*035a2f44SArmin Le Grand                                 basegfx::fTools::less(fPosY, 1.0); fPosY += fHeight)
693*035a2f44SArmin Le Grand                             {
694*035a2f44SArmin Le Grand                                 rMatrices.push_back(
695*035a2f44SArmin Le Grand                                     basegfx::tools::createScaleTranslateB2DHomMatrix(
696*035a2f44SArmin Le Grand                                         fWidth,
697*035a2f44SArmin Le Grand                                         fHeight,
698*035a2f44SArmin Le Grand                                         fPosX,
699*035a2f44SArmin Le Grand                                         fPosY));
700*035a2f44SArmin Le Grand                             }
701*035a2f44SArmin Le Grand                         }
702*035a2f44SArmin Le Grand                     }
703*035a2f44SArmin Le Grand                     else
704*035a2f44SArmin Le Grand                     {
705*035a2f44SArmin Le Grand                         for(double fPosY(fStartY); basegfx::fTools::less(fPosY, 1.0); fPosY += fHeight, nPosY++)
706*035a2f44SArmin Le Grand                         {
707*035a2f44SArmin Le Grand                             for(double fPosX(nPosY % 2 ? fStartX - fWidth + (mfOffsetX * fWidth) : fStartX);
708*035a2f44SArmin Le Grand                                 basegfx::fTools::less(fPosX, 1.0); fPosX += fWidth)
709*035a2f44SArmin Le Grand                             {
710*035a2f44SArmin Le Grand                                 rMatrices.push_back(
711*035a2f44SArmin Le Grand                                     basegfx::tools::createScaleTranslateB2DHomMatrix(
712*035a2f44SArmin Le Grand                                         fWidth,
713*035a2f44SArmin Le Grand                                         fHeight,
714*035a2f44SArmin Le Grand                                         fPosX,
715*035a2f44SArmin Le Grand                                         fPosY));
716*035a2f44SArmin Le Grand                             }
717*035a2f44SArmin Le Grand                         }
718*035a2f44SArmin Le Grand                     }
719*035a2f44SArmin Le Grand                 }
720*035a2f44SArmin Le Grand             }
721cdf0e10cSrcweir 		}
722cdf0e10cSrcweir 	} // end of namespace texture
723cdf0e10cSrcweir } // end of namespace drawinglayer
724cdf0e10cSrcweir 
725cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////////////
726cdf0e10cSrcweir // eof
727