1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile: sdrattribute.cxx,v $
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,
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
49 SdrLineAttribute::SdrLineAttribute(
50 basegfx::B2DLineJoin eJoin
, double fWidth
, double fTransparence
, const basegfx::BColor
& rColor
,
51 const ::std::vector
< double >& rDotDashArray
, double fFullDotDashLen
)
54 mfTransparence(fTransparence
),
56 maDotDashArray(rDotDashArray
),
57 mfFullDotDashLen(fFullDotDashLen
)
61 SdrLineAttribute::SdrLineAttribute(const basegfx::BColor
& rColor
)
62 : meJoin(basegfx::B2DLINEJOIN_NONE
),
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
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
130 SdrShadowAttribute::SdrShadowAttribute(const basegfx::B2DVector
& rOffset
, double fTransparence
, const basegfx::BColor
& rColor
)
132 mfTransparence(fTransparence
),
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
156 SdrFillAttribute::SdrFillAttribute(
157 double fTransparence
,
158 const basegfx::BColor
& rColor
,
159 FillGradientAttribute
* pGradient
,
160 FillHatchAttribute
* pHatch
,
161 SdrFillBitmapAttribute
* pBitmap
)
162 : mfTransparence(fTransparence
),
164 mpGradient(pGradient
),
170 SdrFillAttribute::SdrFillAttribute(const SdrFillAttribute
& rCandidate
)
171 : mfTransparence(1.0),
176 if(!(*this == rCandidate
))
182 SdrFillAttribute::~SdrFillAttribute()
189 SdrFillAttribute
& SdrFillAttribute::operator=(const SdrFillAttribute
& rCandidate
)
192 mfTransparence
= rCandidate
.mfTransparence
;
193 maColor
= rCandidate
.maColor
;
197 // delete local mpGradient if necessary
198 if(mpGradient
&& ((!rCandidate
.mpGradient
) || (!(*mpGradient
== *rCandidate
.mpGradient
))))
204 // copy mpGradient if necessary
205 if(!mpGradient
&& rCandidate
.mpGradient
)
207 mpGradient
= new FillGradientAttribute(*rCandidate
.mpGradient
);
213 // delete local mpHatch if necessary
214 if(mpHatch
&& ((!rCandidate
.mpHatch
) || (!(*mpHatch
== *rCandidate
.mpHatch
))))
220 // copy mpHatch if necessary
221 if(!mpHatch
&& rCandidate
.mpHatch
)
223 mpHatch
= new FillHatchAttribute(*rCandidate
.mpHatch
);
229 // delete local mpBitmap if necessary
230 if(mpBitmap
&& ((!rCandidate
.mpBitmap
) || (!(*mpBitmap
== *rCandidate
.mpBitmap
))))
236 // copy mpBitmap if necessary
237 if(!mpBitmap
&& rCandidate
.mpBitmap
)
239 mpBitmap
= new SdrFillBitmapAttribute(*rCandidate
.mpBitmap
);
246 bool SdrFillAttribute::operator==(const SdrFillAttribute
& rCandidate
) const
248 if(mfTransparence
!= rCandidate
.mfTransparence
)
253 if(!rCandidate
.mpGradient
)
256 if(!(*mpGradient
== *rCandidate
.mpGradient
))
261 if(!rCandidate
.mpHatch
)
264 if(!(*mpHatch
== *rCandidate
.mpHatch
))
267 if(mpHatch
->isFillBackground() && !(maColor
== rCandidate
.maColor
))
272 if(!rCandidate
.mpBitmap
)
275 if(!(*mpBitmap
== *rCandidate
.mpBitmap
))
280 if(!rCandidate
.isColor())
283 if(!(maColor
== rCandidate
.maColor
))
289 } // end of namespace attribute
290 } // end of namespace drawinglayer
292 //////////////////////////////////////////////////////////////////////////////