merge the formfield patch from ooo-build
[ooovba.git] / svx / source / sdr / attribute / sdrallattribute.cxx
blob1150f5a684625060ee74fb6dacb1ae9e31f42586
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sdrallattribute.cxx,v $
11 * $Revision: 1.2 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 #include "precompiled_svx.hxx"
34 #include <svx/sdr/attribute/sdrallattribute.hxx>
35 #include <drawinglayer/attribute/sdrattribute.hxx>
36 #include <drawinglayer/attribute/fillattribute.hxx>
37 #include <svx/sdr/attribute/sdrtextattribute.hxx>
39 //////////////////////////////////////////////////////////////////////////////
40 // pointer compare define
41 #define pointerOrContentEqual(p, q) ((p == q) || (p && q && *p == *q))
43 //////////////////////////////////////////////////////////////////////////////
45 namespace drawinglayer
47 namespace attribute
49 SdrShadowTextAttribute::SdrShadowTextAttribute(
50 SdrShadowAttribute* pShadow,
51 SdrTextAttribute* pTextAttribute)
52 : mpShadow(pShadow),
53 mpTextAttribute(pTextAttribute)
57 SdrShadowTextAttribute::SdrShadowTextAttribute(
58 const SdrShadowTextAttribute& rCandidate)
59 : mpShadow(0),
60 mpTextAttribute(0)
62 *this = rCandidate;
65 SdrShadowTextAttribute::~SdrShadowTextAttribute()
67 delete mpShadow;
68 delete mpTextAttribute;
71 SdrShadowTextAttribute& SdrShadowTextAttribute::operator=(const SdrShadowTextAttribute& rCandidate)
73 // handle mpShadow
75 // delete local mpShadow if necessary
76 if(mpShadow)
78 delete mpShadow;
79 mpShadow = 0;
82 // copy mpShadow if necessary
83 if(rCandidate.mpShadow)
85 mpShadow = new SdrShadowAttribute(*rCandidate.mpShadow);
89 // handle mpTextAttribute
91 // delete local mpTextAttribute if necessary
92 if(mpTextAttribute)
94 delete mpTextAttribute;
95 mpTextAttribute = 0;
98 // copy mpTextAttribute if necessary
99 if(rCandidate.mpTextAttribute)
101 mpTextAttribute = new SdrTextAttribute(*rCandidate.mpTextAttribute);
105 return *this;
108 bool SdrShadowTextAttribute::operator==(const SdrShadowTextAttribute& rCandidate) const
110 // handle mpShadow
111 if(!pointerOrContentEqual(mpShadow, rCandidate.mpShadow))
112 return false;
114 // handle mpTextAttribute
115 if(!pointerOrContentEqual(mpTextAttribute, rCandidate.mpTextAttribute))
116 return false;
118 return true;
120 } // end of namespace attribute
121 } // end of namespace drawinglayer
123 //////////////////////////////////////////////////////////////////////////////
125 namespace drawinglayer
127 namespace attribute
129 SdrFillTextAttribute::SdrFillTextAttribute(
130 SdrFillAttribute* pFill,
131 FillGradientAttribute* pFillFloatTransGradient,
132 SdrTextAttribute* pTextAttribute)
133 : mpFill(pFill),
134 mpFillFloatTransGradient(pFillFloatTransGradient),
135 mpTextAttribute(pTextAttribute)
139 SdrFillTextAttribute::SdrFillTextAttribute(
140 const SdrFillTextAttribute& rCandidate)
141 : mpFill(0),
142 mpFillFloatTransGradient(0),
143 mpTextAttribute(0)
145 *this = rCandidate;
148 SdrFillTextAttribute::~SdrFillTextAttribute()
150 delete mpFill;
151 delete mpFillFloatTransGradient;
152 delete mpTextAttribute;
155 SdrFillTextAttribute& SdrFillTextAttribute::operator=(const SdrFillTextAttribute& rCandidate)
157 // handle mpFill
159 // delete local mpFill if necessary
160 if(mpFill)
162 delete mpFill;
163 mpFill = 0;
166 // copy mpFill if necessary
167 if(rCandidate.mpFill)
169 mpFill = new attribute::SdrFillAttribute(*rCandidate.mpFill);
173 // handle mpFillFloatTransGradient
175 // delete local mpFillFloatTransGradient if necessary
176 if(mpFillFloatTransGradient)
178 delete mpFillFloatTransGradient;
179 mpFillFloatTransGradient = 0;
182 // copy mpFillFloatTransGradient if necessary
183 if(rCandidate.mpFillFloatTransGradient)
185 mpFillFloatTransGradient = new FillGradientAttribute(*rCandidate.mpFillFloatTransGradient);
189 // handle mpTextAttribute
191 // delete local mpTextAttribute if necessary
192 if(mpTextAttribute)
194 delete mpTextAttribute;
195 mpTextAttribute = 0;
198 // copy mpTextAttribute if necessary
199 if(rCandidate.mpTextAttribute)
201 mpTextAttribute = new SdrTextAttribute(*rCandidate.mpTextAttribute);
205 return *this;
208 bool SdrFillTextAttribute::operator==(const SdrFillTextAttribute& rCandidate) const
210 // handle mpFill
211 if(!pointerOrContentEqual(mpFill, rCandidate.mpFill))
212 return false;
214 // handle mpFillFloatTransGradient
215 if(!pointerOrContentEqual(mpFillFloatTransGradient, rCandidate.mpFillFloatTransGradient))
216 return false;
218 // handle mpTextAttribute
219 if(!pointerOrContentEqual(mpTextAttribute, rCandidate.mpTextAttribute))
220 return false;
222 return true;
224 } // end of namespace attribute
225 } // end of namespace drawinglayer
227 //////////////////////////////////////////////////////////////////////////////
229 namespace drawinglayer
231 namespace attribute
233 SdrLineShadowTextAttribute::SdrLineShadowTextAttribute(
234 SdrLineAttribute* pLine,
235 SdrLineStartEndAttribute* pLineStartEnd,
236 SdrShadowAttribute* pShadow,
237 SdrTextAttribute* pTextAttribute)
238 : SdrShadowTextAttribute(pShadow, pTextAttribute),
239 mpLine(pLine),
240 mpLineStartEnd(pLineStartEnd)
244 SdrLineShadowTextAttribute::SdrLineShadowTextAttribute(
245 const SdrLineShadowTextAttribute& rCandidate)
246 : SdrShadowTextAttribute(0, 0),
247 mpLine(0),
248 mpLineStartEnd(0)
250 *this = rCandidate;
253 SdrLineShadowTextAttribute::~SdrLineShadowTextAttribute()
255 delete mpLine;
256 delete mpLineStartEnd;
259 SdrLineShadowTextAttribute& SdrLineShadowTextAttribute::operator=(const SdrLineShadowTextAttribute& rCandidate)
261 // call parent
262 SdrShadowTextAttribute::operator=(rCandidate);
264 // handle mpLine
266 // delete local mpLine if necessary
267 if(mpLine)
269 delete mpLine;
270 mpLine = 0;
273 // copy mpLine if necessary
274 if(rCandidate.mpLine)
276 mpLine = new SdrLineAttribute(*rCandidate.mpLine);
280 // handle mpLineStartEnd
282 // delete local mpLineStartEnd if necessary
283 if(mpLineStartEnd)
285 delete mpLineStartEnd;
286 mpLineStartEnd = 0;
289 // copy mpLineStartEnd if necessary
290 if(rCandidate.mpLineStartEnd)
292 mpLineStartEnd = new SdrLineStartEndAttribute(*rCandidate.mpLineStartEnd);
296 return *this;
299 bool SdrLineShadowTextAttribute::operator==(const SdrLineShadowTextAttribute& rCandidate) const
301 // call parent
302 if(!(SdrShadowTextAttribute::operator==(rCandidate)))
303 return false;
305 // handle mpLine
306 if(!pointerOrContentEqual(mpLine, rCandidate.mpLine))
307 return false;
309 // handle mpLineStartEnd
310 if(!pointerOrContentEqual(mpLineStartEnd, rCandidate.mpLineStartEnd))
311 return false;
313 return true;
315 } // end of namespace attribute
316 } // end of namespace drawinglayer
318 //////////////////////////////////////////////////////////////////////////////
320 namespace drawinglayer
322 namespace attribute
324 SdrLineFillShadowTextAttribute::SdrLineFillShadowTextAttribute(
325 SdrLineAttribute* pLine,
326 attribute::SdrFillAttribute* pFill,
327 SdrLineStartEndAttribute* pLineStartEnd,
328 SdrShadowAttribute* pShadow,
329 FillGradientAttribute* pFillFloatTransGradient,
330 SdrTextAttribute* pTextAttribute)
331 : SdrLineShadowTextAttribute(pLine, pLineStartEnd, pShadow, pTextAttribute),
332 mpFill(pFill),
333 mpFillFloatTransGradient(pFillFloatTransGradient)
337 SdrLineFillShadowTextAttribute::SdrLineFillShadowTextAttribute(
338 const SdrLineFillShadowTextAttribute& rCandidate)
339 : SdrLineShadowTextAttribute(0, 0, 0, 0),
340 mpFill(0),
341 mpFillFloatTransGradient(0)
343 *this = rCandidate;
346 SdrLineFillShadowTextAttribute::~SdrLineFillShadowTextAttribute()
348 delete mpFill;
349 delete mpFillFloatTransGradient;
352 SdrLineFillShadowTextAttribute& SdrLineFillShadowTextAttribute::operator=(const SdrLineFillShadowTextAttribute& rCandidate)
354 // call parent
355 SdrLineShadowTextAttribute::operator=(rCandidate);
357 // handle mpFill
359 // delete local mpFill if necessary
360 if(mpFill)
362 delete mpFill;
363 mpFill = 0;
366 // copy mpFill if necessary
367 if(rCandidate.mpFill)
369 mpFill = new attribute::SdrFillAttribute(*rCandidate.mpFill);
373 // handle mpFillFloatTransGradient
375 // delete local mpFillFloatTransGradient if necessary
376 if(mpFillFloatTransGradient)
378 delete mpFillFloatTransGradient;
379 mpFillFloatTransGradient = 0;
382 // copy mpFillFloatTransGradient if necessary
383 if(rCandidate.mpFillFloatTransGradient)
385 mpFillFloatTransGradient = new FillGradientAttribute(*rCandidate.mpFillFloatTransGradient);
389 return *this;
392 bool SdrLineFillShadowTextAttribute::operator==(const SdrLineFillShadowTextAttribute& rCandidate) const
394 // call parent
395 if(!(SdrLineShadowTextAttribute::operator==(rCandidate)))
396 return false;
398 // handle mpFill
399 if(!pointerOrContentEqual(mpFill, rCandidate.mpFill))
400 return false;
402 // handle mpFillFloatTransGradient
403 if(!pointerOrContentEqual(mpFillFloatTransGradient, rCandidate.mpFillFloatTransGradient))
404 return false;
406 return true;
408 } // end of namespace attribute
409 } // end of namespace drawinglayer
411 //////////////////////////////////////////////////////////////////////////////
412 // eof