1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sdrallattribute.cxx,v $
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
49 SdrShadowTextAttribute::SdrShadowTextAttribute(
50 SdrShadowAttribute
* pShadow
,
51 SdrTextAttribute
* pTextAttribute
)
53 mpTextAttribute(pTextAttribute
)
57 SdrShadowTextAttribute::SdrShadowTextAttribute(
58 const SdrShadowTextAttribute
& rCandidate
)
65 SdrShadowTextAttribute::~SdrShadowTextAttribute()
68 delete mpTextAttribute
;
71 SdrShadowTextAttribute
& SdrShadowTextAttribute::operator=(const SdrShadowTextAttribute
& rCandidate
)
75 // delete local mpShadow if necessary
82 // copy mpShadow if necessary
83 if(rCandidate
.mpShadow
)
85 mpShadow
= new SdrShadowAttribute(*rCandidate
.mpShadow
);
89 // handle mpTextAttribute
91 // delete local mpTextAttribute if necessary
94 delete mpTextAttribute
;
98 // copy mpTextAttribute if necessary
99 if(rCandidate
.mpTextAttribute
)
101 mpTextAttribute
= new SdrTextAttribute(*rCandidate
.mpTextAttribute
);
108 bool SdrShadowTextAttribute::operator==(const SdrShadowTextAttribute
& rCandidate
) const
111 if(!pointerOrContentEqual(mpShadow
, rCandidate
.mpShadow
))
114 // handle mpTextAttribute
115 if(!pointerOrContentEqual(mpTextAttribute
, rCandidate
.mpTextAttribute
))
120 } // end of namespace attribute
121 } // end of namespace drawinglayer
123 //////////////////////////////////////////////////////////////////////////////
125 namespace drawinglayer
129 SdrFillTextAttribute::SdrFillTextAttribute(
130 SdrFillAttribute
* pFill
,
131 FillGradientAttribute
* pFillFloatTransGradient
,
132 SdrTextAttribute
* pTextAttribute
)
134 mpFillFloatTransGradient(pFillFloatTransGradient
),
135 mpTextAttribute(pTextAttribute
)
139 SdrFillTextAttribute::SdrFillTextAttribute(
140 const SdrFillTextAttribute
& rCandidate
)
142 mpFillFloatTransGradient(0),
148 SdrFillTextAttribute::~SdrFillTextAttribute()
151 delete mpFillFloatTransGradient
;
152 delete mpTextAttribute
;
155 SdrFillTextAttribute
& SdrFillTextAttribute::operator=(const SdrFillTextAttribute
& rCandidate
)
159 // delete local mpFill if necessary
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
194 delete mpTextAttribute
;
198 // copy mpTextAttribute if necessary
199 if(rCandidate
.mpTextAttribute
)
201 mpTextAttribute
= new SdrTextAttribute(*rCandidate
.mpTextAttribute
);
208 bool SdrFillTextAttribute::operator==(const SdrFillTextAttribute
& rCandidate
) const
211 if(!pointerOrContentEqual(mpFill
, rCandidate
.mpFill
))
214 // handle mpFillFloatTransGradient
215 if(!pointerOrContentEqual(mpFillFloatTransGradient
, rCandidate
.mpFillFloatTransGradient
))
218 // handle mpTextAttribute
219 if(!pointerOrContentEqual(mpTextAttribute
, rCandidate
.mpTextAttribute
))
224 } // end of namespace attribute
225 } // end of namespace drawinglayer
227 //////////////////////////////////////////////////////////////////////////////
229 namespace drawinglayer
233 SdrLineShadowTextAttribute::SdrLineShadowTextAttribute(
234 SdrLineAttribute
* pLine
,
235 SdrLineStartEndAttribute
* pLineStartEnd
,
236 SdrShadowAttribute
* pShadow
,
237 SdrTextAttribute
* pTextAttribute
)
238 : SdrShadowTextAttribute(pShadow
, pTextAttribute
),
240 mpLineStartEnd(pLineStartEnd
)
244 SdrLineShadowTextAttribute::SdrLineShadowTextAttribute(
245 const SdrLineShadowTextAttribute
& rCandidate
)
246 : SdrShadowTextAttribute(0, 0),
253 SdrLineShadowTextAttribute::~SdrLineShadowTextAttribute()
256 delete mpLineStartEnd
;
259 SdrLineShadowTextAttribute
& SdrLineShadowTextAttribute::operator=(const SdrLineShadowTextAttribute
& rCandidate
)
262 SdrShadowTextAttribute::operator=(rCandidate
);
266 // delete local mpLine if necessary
273 // copy mpLine if necessary
274 if(rCandidate
.mpLine
)
276 mpLine
= new SdrLineAttribute(*rCandidate
.mpLine
);
280 // handle mpLineStartEnd
282 // delete local mpLineStartEnd if necessary
285 delete mpLineStartEnd
;
289 // copy mpLineStartEnd if necessary
290 if(rCandidate
.mpLineStartEnd
)
292 mpLineStartEnd
= new SdrLineStartEndAttribute(*rCandidate
.mpLineStartEnd
);
299 bool SdrLineShadowTextAttribute::operator==(const SdrLineShadowTextAttribute
& rCandidate
) const
302 if(!(SdrShadowTextAttribute::operator==(rCandidate
)))
306 if(!pointerOrContentEqual(mpLine
, rCandidate
.mpLine
))
309 // handle mpLineStartEnd
310 if(!pointerOrContentEqual(mpLineStartEnd
, rCandidate
.mpLineStartEnd
))
315 } // end of namespace attribute
316 } // end of namespace drawinglayer
318 //////////////////////////////////////////////////////////////////////////////
320 namespace drawinglayer
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
),
333 mpFillFloatTransGradient(pFillFloatTransGradient
)
337 SdrLineFillShadowTextAttribute::SdrLineFillShadowTextAttribute(
338 const SdrLineFillShadowTextAttribute
& rCandidate
)
339 : SdrLineShadowTextAttribute(0, 0, 0, 0),
341 mpFillFloatTransGradient(0)
346 SdrLineFillShadowTextAttribute::~SdrLineFillShadowTextAttribute()
349 delete mpFillFloatTransGradient
;
352 SdrLineFillShadowTextAttribute
& SdrLineFillShadowTextAttribute::operator=(const SdrLineFillShadowTextAttribute
& rCandidate
)
355 SdrLineShadowTextAttribute::operator=(rCandidate
);
359 // delete local mpFill if necessary
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
);
392 bool SdrLineFillShadowTextAttribute::operator==(const SdrLineFillShadowTextAttribute
& rCandidate
) const
395 if(!(SdrLineShadowTextAttribute::operator==(rCandidate
)))
399 if(!pointerOrContentEqual(mpFill
, rCandidate
.mpFill
))
402 // handle mpFillFloatTransGradient
403 if(!pointerOrContentEqual(mpFillFloatTransGradient
, rCandidate
.mpFillFloatTransGradient
))
408 } // end of namespace attribute
409 } // end of namespace drawinglayer
411 //////////////////////////////////////////////////////////////////////////////