merge the formfield patch from ooo-build
[ooovba.git] / drawinglayer / source / attribute / sdrattribute.cxx
blob4955ceddc95c42c77c8fa71663f6676489332ab4
1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile: sdrattribute.cxx,v $
7 * $Revision: 1.5 $
9 * last change: $Author: aw $ $Date: 2008-05-27 14:11:19 $
11 * The Contents of this file are made available subject to
12 * the terms of GNU Lesser General Public License Version 2.1.
15 * GNU Lesser General Public License Version 2.1
16 * =============================================
17 * Copyright 2005 by Sun Microsystems, Inc.
18 * 901 San Antonio Road, Palo Alto, CA 94303, USA
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License version 2.1, as published by the Free Software Foundation.
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * Lesser General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this library; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
32 * MA 02111-1307 USA
34 ************************************************************************/
36 // MARKER(update_precomp.py): autogen include statement, do not remove
37 #include "precompiled_drawinglayer.hxx"
39 #include <drawinglayer/attribute/sdrattribute.hxx>
40 #include <drawinglayer/attribute/fillattribute.hxx>
41 #include <drawinglayer/attribute/sdrfillbitmapattribute.hxx>
43 //////////////////////////////////////////////////////////////////////////////
45 namespace drawinglayer
47 namespace attribute
49 SdrLineAttribute::SdrLineAttribute(
50 basegfx::B2DLineJoin eJoin, double fWidth, double fTransparence, const basegfx::BColor& rColor,
51 const ::std::vector< double >& rDotDashArray, double fFullDotDashLen)
52 : meJoin(eJoin),
53 mfWidth(fWidth),
54 mfTransparence(fTransparence),
55 maColor(rColor),
56 maDotDashArray(rDotDashArray),
57 mfFullDotDashLen(fFullDotDashLen)
61 SdrLineAttribute::SdrLineAttribute(const basegfx::BColor& rColor)
62 : meJoin(basegfx::B2DLINEJOIN_NONE),
63 mfWidth(0.0),
64 mfTransparence(0.0),
65 maColor(rColor),
66 maDotDashArray(),
67 mfFullDotDashLen(0.0)
71 SdrLineAttribute::~SdrLineAttribute()
75 bool SdrLineAttribute::operator==(const SdrLineAttribute& rCandidate) const
77 return (meJoin == rCandidate.meJoin
78 && mfWidth == rCandidate.mfWidth
79 && mfTransparence == rCandidate.mfTransparence
80 && maColor == rCandidate.maColor
81 && maDotDashArray == rCandidate.maDotDashArray);
83 } // end of namespace attribute
84 } // end of namespace drawinglayer
86 //////////////////////////////////////////////////////////////////////////////
88 namespace drawinglayer
90 namespace attribute
92 SdrLineStartEndAttribute::SdrLineStartEndAttribute(
93 const basegfx::B2DPolyPolygon& rStartPolyPolygon, const basegfx::B2DPolyPolygon& rEndPolyPolygon,
94 double fStartWidth, double fEndWidth, bool bStartActive, bool bEndActive, bool bStartCentered, bool bEndCentered)
95 : maStartPolyPolygon(rStartPolyPolygon),
96 maEndPolyPolygon(rEndPolyPolygon),
97 mfStartWidth(fStartWidth),
98 mfEndWidth(fEndWidth),
99 mbStartActive(bStartActive),
100 mbEndActive(bEndActive),
101 mbStartCentered(bStartCentered),
102 mbEndCentered(bEndCentered)
106 SdrLineStartEndAttribute::~SdrLineStartEndAttribute()
110 bool SdrLineStartEndAttribute::operator==(const SdrLineStartEndAttribute& rCandidate) const
112 return (mbStartActive == rCandidate.mbStartActive
113 && mbEndActive == rCandidate.mbEndActive
114 && mbStartCentered == rCandidate.mbStartCentered
115 && mbEndCentered == rCandidate.mbEndCentered
116 && mfStartWidth == rCandidate.mfStartWidth
117 && mfEndWidth == rCandidate.mfEndWidth
118 && maStartPolyPolygon == rCandidate.maStartPolyPolygon
119 && maEndPolyPolygon == rCandidate.maEndPolyPolygon);
121 } // end of namespace attribute
122 } // end of namespace drawinglayer
124 //////////////////////////////////////////////////////////////////////////////
126 namespace drawinglayer
128 namespace attribute
130 SdrShadowAttribute::SdrShadowAttribute(const basegfx::B2DVector& rOffset, double fTransparence, const basegfx::BColor& rColor)
131 : maOffset(rOffset),
132 mfTransparence(fTransparence),
133 maColor(rColor)
137 SdrShadowAttribute::~SdrShadowAttribute()
141 bool SdrShadowAttribute::operator==(const SdrShadowAttribute& rCandidate) const
143 return (mfTransparence == rCandidate.mfTransparence
144 && maColor == rCandidate.maColor
145 && maOffset == rCandidate.maOffset);
147 } // end of namespace attribute
148 } // end of namespace drawinglayer
150 //////////////////////////////////////////////////////////////////////////////
152 namespace drawinglayer
154 namespace attribute
156 SdrFillAttribute::SdrFillAttribute(
157 double fTransparence,
158 const basegfx::BColor& rColor,
159 FillGradientAttribute* pGradient,
160 FillHatchAttribute* pHatch,
161 SdrFillBitmapAttribute* pBitmap)
162 : mfTransparence(fTransparence),
163 maColor(rColor),
164 mpGradient(pGradient),
165 mpHatch(pHatch),
166 mpBitmap(pBitmap)
170 SdrFillAttribute::SdrFillAttribute(const SdrFillAttribute& rCandidate)
171 : mfTransparence(1.0),
172 mpGradient(0L),
173 mpHatch(0L),
174 mpBitmap(0L)
176 if(!(*this == rCandidate))
178 *this = rCandidate;
182 SdrFillAttribute::~SdrFillAttribute()
184 delete mpGradient;
185 delete mpHatch;
186 delete mpBitmap;
189 SdrFillAttribute& SdrFillAttribute::operator=(const SdrFillAttribute& rCandidate)
191 // copy data
192 mfTransparence = rCandidate.mfTransparence;
193 maColor = rCandidate.maColor;
195 // handle mpGradient
197 // delete local mpGradient if necessary
198 if(mpGradient && ((!rCandidate.mpGradient) || (!(*mpGradient == *rCandidate.mpGradient))))
200 delete mpGradient;
201 mpGradient = 0L;
204 // copy mpGradient if necessary
205 if(!mpGradient && rCandidate.mpGradient)
207 mpGradient = new FillGradientAttribute(*rCandidate.mpGradient);
211 // handle mpHatch
213 // delete local mpHatch if necessary
214 if(mpHatch && ((!rCandidate.mpHatch) || (!(*mpHatch == *rCandidate.mpHatch))))
216 delete mpHatch;
217 mpHatch = 0L;
220 // copy mpHatch if necessary
221 if(!mpHatch && rCandidate.mpHatch)
223 mpHatch = new FillHatchAttribute(*rCandidate.mpHatch);
227 // handle mpBitmap
229 // delete local mpBitmap if necessary
230 if(mpBitmap && ((!rCandidate.mpBitmap) || (!(*mpBitmap == *rCandidate.mpBitmap))))
232 delete mpBitmap;
233 mpBitmap = 0L;
236 // copy mpBitmap if necessary
237 if(!mpBitmap && rCandidate.mpBitmap)
239 mpBitmap = new SdrFillBitmapAttribute(*rCandidate.mpBitmap);
243 return *this;
246 bool SdrFillAttribute::operator==(const SdrFillAttribute& rCandidate) const
248 if(mfTransparence != rCandidate.mfTransparence)
249 return false;
251 if(mpGradient)
253 if(!rCandidate.mpGradient)
254 return false;
256 if(!(*mpGradient == *rCandidate.mpGradient))
257 return false;
259 else if(mpHatch)
261 if(!rCandidate.mpHatch)
262 return false;
264 if(!(*mpHatch == *rCandidate.mpHatch))
265 return false;
267 if(mpHatch->isFillBackground() && !(maColor == rCandidate.maColor))
268 return false;
270 else if(mpBitmap)
272 if(!rCandidate.mpBitmap)
273 return false;
275 if(!(*mpBitmap == *rCandidate.mpBitmap))
276 return false;
278 else
280 if(!rCandidate.isColor())
281 return false;
283 if(!(maColor == rCandidate.maColor))
284 return false;
287 return true;
289 } // end of namespace attribute
290 } // end of namespace drawinglayer
292 //////////////////////////////////////////////////////////////////////////////
293 // eof