Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
30 : : #include <basegfx/polygon/b2dpolypolygontools.hxx>
31 : : #include <basegfx/tools/canvastools.hxx>
32 : : #include <drawinglayer/primitive2d/fillgradientprimitive2d.hxx>
33 : : #include <drawinglayer/primitive2d/maskprimitive2d.hxx>
34 : : #include <drawinglayer/primitive2d/fillhatchprimitive2d.hxx>
35 : : #include <basegfx/matrix/b2dhommatrix.hxx>
36 : : #include <drawinglayer/primitive2d/fillbitmapprimitive2d.hxx>
37 : : #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
38 : : #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
39 : :
40 : : //////////////////////////////////////////////////////////////////////////////
41 : :
42 : : using namespace com::sun::star;
43 : :
44 : : //////////////////////////////////////////////////////////////////////////////
45 : :
46 : : namespace drawinglayer
47 : : {
48 : : namespace primitive2d
49 : : {
50 : 18766 : Primitive2DSequence PolyPolygonHairlinePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
51 : : {
52 [ + - ]: 18766 : const basegfx::B2DPolyPolygon aPolyPolygon(getB2DPolyPolygon());
53 [ + - ]: 18766 : const sal_uInt32 nCount(aPolyPolygon.count());
54 : :
55 [ + - ]: 18766 : if(nCount)
56 : : {
57 [ + - ]: 18766 : Primitive2DSequence aRetval(nCount);
58 : :
59 [ + + ]: 59591 : for(sal_uInt32 a(0L); a < nCount; a++)
60 : : {
61 [ + - ][ + - ]: 40825 : aRetval[a] = Primitive2DReference(new PolygonHairlinePrimitive2D(aPolyPolygon.getB2DPolygon(a), getBColor()));
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
62 : : }
63 : :
64 [ + - ][ + - ]: 18766 : return aRetval;
65 : : }
66 : : else
67 : : {
68 [ # # ]: 0 : return Primitive2DSequence();
69 [ + - ]: 18766 : }
70 : : }
71 : :
72 : 38912 : PolyPolygonHairlinePrimitive2D::PolyPolygonHairlinePrimitive2D(const basegfx::B2DPolyPolygon& rPolyPolygon, const basegfx::BColor& rBColor)
73 : : : BufferedDecompositionPrimitive2D(),
74 : : maPolyPolygon(rPolyPolygon),
75 [ + - ]: 38912 : maBColor(rBColor)
76 : : {
77 : 38912 : }
78 : :
79 : 98 : bool PolyPolygonHairlinePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
80 : : {
81 [ + - ]: 98 : if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
82 : : {
83 : 98 : const PolyPolygonHairlinePrimitive2D& rCompare = (PolyPolygonHairlinePrimitive2D&)rPrimitive;
84 : :
85 : 98 : return (getB2DPolyPolygon() == rCompare.getB2DPolyPolygon()
86 [ + - ][ + + ]: 98 : && getBColor() == rCompare.getBColor());
87 : : }
88 : :
89 : 98 : return false;
90 : : }
91 : :
92 : 179257 : basegfx::B2DRange PolyPolygonHairlinePrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const
93 : : {
94 : : // return range
95 : 179257 : return basegfx::tools::getRange(getB2DPolyPolygon());
96 : : }
97 : :
98 : : // provide unique ID
99 : 23781 : ImplPrimitrive2DIDBlock(PolyPolygonHairlinePrimitive2D, PRIMITIVE2D_ID_POLYPOLYGONHAIRLINEPRIMITIVE2D)
100 : :
101 : : } // end of namespace primitive2d
102 : : } // end of namespace drawinglayer
103 : :
104 : : //////////////////////////////////////////////////////////////////////////////
105 : :
106 : : namespace drawinglayer
107 : : {
108 : : namespace primitive2d
109 : : {
110 : 0 : Primitive2DSequence PolyPolygonMarkerPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
111 : : {
112 [ # # ]: 0 : const basegfx::B2DPolyPolygon aPolyPolygon(getB2DPolyPolygon());
113 [ # # ]: 0 : const sal_uInt32 nCount(aPolyPolygon.count());
114 : :
115 [ # # ]: 0 : if(nCount)
116 : : {
117 [ # # ]: 0 : Primitive2DSequence aRetval(nCount);
118 : :
119 [ # # ]: 0 : for(sal_uInt32 a(0L); a < nCount; a++)
120 : : {
121 [ # # ][ # # ]: 0 : aRetval[a] = Primitive2DReference(new PolygonMarkerPrimitive2D(aPolyPolygon.getB2DPolygon(a), getRGBColorA(), getRGBColorB(), getDiscreteDashLength()));
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
122 : : }
123 : :
124 [ # # ][ # # ]: 0 : return aRetval;
125 : : }
126 : : else
127 : : {
128 [ # # ]: 0 : return Primitive2DSequence();
129 [ # # ]: 0 : }
130 : : }
131 : :
132 : 0 : PolyPolygonMarkerPrimitive2D::PolyPolygonMarkerPrimitive2D(
133 : : const basegfx::B2DPolyPolygon& rPolyPolygon,
134 : : const basegfx::BColor& rRGBColorA,
135 : : const basegfx::BColor& rRGBColorB,
136 : : double fDiscreteDashLength)
137 : : : BufferedDecompositionPrimitive2D(),
138 : : maPolyPolygon(rPolyPolygon),
139 : : maRGBColorA(rRGBColorA),
140 : : maRGBColorB(rRGBColorB),
141 [ # # ]: 0 : mfDiscreteDashLength(fDiscreteDashLength)
142 : : {
143 : 0 : }
144 : :
145 : 0 : bool PolyPolygonMarkerPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
146 : : {
147 [ # # ]: 0 : if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
148 : : {
149 : 0 : const PolyPolygonMarkerPrimitive2D& rCompare = (PolyPolygonMarkerPrimitive2D&)rPrimitive;
150 : :
151 : 0 : return (getB2DPolyPolygon() == rCompare.getB2DPolyPolygon()
152 : 0 : && getRGBColorA() == rCompare.getRGBColorA()
153 : 0 : && getRGBColorB() == rCompare.getRGBColorB()
154 [ # # ][ # # : 0 : && getDiscreteDashLength() == rCompare.getDiscreteDashLength());
# # # # ]
155 : : }
156 : :
157 : 0 : return false;
158 : : }
159 : :
160 : 0 : basegfx::B2DRange PolyPolygonMarkerPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const
161 : : {
162 : : // return range
163 : 0 : return basegfx::tools::getRange(getB2DPolyPolygon());
164 : : }
165 : :
166 : : // provide unique ID
167 : 0 : ImplPrimitrive2DIDBlock(PolyPolygonMarkerPrimitive2D, PRIMITIVE2D_ID_POLYPOLYGONMARKERPRIMITIVE2D)
168 : :
169 : : } // end of namespace primitive2d
170 : : } // end of namespace drawinglayer
171 : :
172 : : //////////////////////////////////////////////////////////////////////////////
173 : :
174 : : namespace drawinglayer
175 : : {
176 : : namespace primitive2d
177 : : {
178 : 18 : Primitive2DSequence PolyPolygonStrokePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
179 : : {
180 [ + - ]: 18 : const basegfx::B2DPolyPolygon aPolyPolygon(getB2DPolyPolygon());
181 [ + - ]: 18 : const sal_uInt32 nCount(aPolyPolygon.count());
182 : :
183 [ + - ]: 18 : if(nCount)
184 : : {
185 [ + - ]: 18 : Primitive2DSequence aRetval(nCount);
186 : :
187 [ + + ]: 36 : for(sal_uInt32 a(0L); a < nCount; a++)
188 : : {
189 [ + - ]: 18 : aRetval[a] = Primitive2DReference(
190 : : new PolygonStrokePrimitive2D(
191 [ + - ][ + - ]: 36 : aPolyPolygon.getB2DPolygon(a), getLineAttribute(), getStrokeAttribute()));
[ + - ][ + - ]
[ + - ][ + - ]
192 : : }
193 : :
194 [ + - ][ + - ]: 18 : return aRetval;
195 : : }
196 : : else
197 : : {
198 [ # # ]: 0 : return Primitive2DSequence();
199 [ + - ]: 18 : }
200 : : }
201 : :
202 : 18 : PolyPolygonStrokePrimitive2D::PolyPolygonStrokePrimitive2D(
203 : : const basegfx::B2DPolyPolygon& rPolyPolygon,
204 : : const attribute::LineAttribute& rLineAttribute,
205 : : const attribute::StrokeAttribute& rStrokeAttribute)
206 : : : BufferedDecompositionPrimitive2D(),
207 : : maPolyPolygon(rPolyPolygon),
208 : : maLineAttribute(rLineAttribute),
209 [ + - ][ + - ]: 18 : maStrokeAttribute(rStrokeAttribute)
[ + - ]
210 : : {
211 : 18 : }
212 : :
213 : 0 : bool PolyPolygonStrokePrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
214 : : {
215 [ # # ]: 0 : if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
216 : : {
217 : 0 : const PolyPolygonStrokePrimitive2D& rCompare = (PolyPolygonStrokePrimitive2D&)rPrimitive;
218 : :
219 : 0 : return (getB2DPolyPolygon() == rCompare.getB2DPolyPolygon()
220 : 0 : && getLineAttribute() == rCompare.getLineAttribute()
221 [ # # ]: 0 : && getStrokeAttribute() == rCompare.getStrokeAttribute());
[ # # # # ]
222 : : }
223 : :
224 : 0 : return false;
225 : : }
226 : :
227 : 0 : basegfx::B2DRange PolyPolygonStrokePrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const
228 : : {
229 : : // get range of it (subdivided)
230 : 0 : basegfx::B2DRange aRetval(basegfx::tools::getRange(getB2DPolyPolygon()));
231 : :
232 : : // if width, grow by line width
233 [ # # ]: 0 : if(getLineAttribute().getWidth())
234 : : {
235 : 0 : aRetval.grow(getLineAttribute().getWidth() / 2.0);
236 : : }
237 : :
238 : 0 : return aRetval;
239 : : }
240 : :
241 : : // provide unique ID
242 : 18 : ImplPrimitrive2DIDBlock(PolyPolygonStrokePrimitive2D, PRIMITIVE2D_ID_POLYPOLYGONSTROKEPRIMITIVE2D)
243 : :
244 : : } // end of namespace primitive2d
245 : : } // end of namespace drawinglayer
246 : :
247 : : //////////////////////////////////////////////////////////////////////////////
248 : :
249 : : namespace drawinglayer
250 : : {
251 : : namespace primitive2d
252 : : {
253 : 218446 : PolyPolygonColorPrimitive2D::PolyPolygonColorPrimitive2D(
254 : : const basegfx::B2DPolyPolygon& rPolyPolygon,
255 : : const basegfx::BColor& rBColor)
256 : : : BasePrimitive2D(),
257 : : maPolyPolygon(rPolyPolygon),
258 [ + - ]: 218446 : maBColor(rBColor)
259 : : {
260 : 218446 : }
261 : :
262 : 1979 : bool PolyPolygonColorPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
263 : : {
264 [ + - ]: 1979 : if(BasePrimitive2D::operator==(rPrimitive))
265 : : {
266 : 1979 : const PolyPolygonColorPrimitive2D& rCompare = (PolyPolygonColorPrimitive2D&)rPrimitive;
267 : :
268 : 1979 : return (getB2DPolyPolygon() == rCompare.getB2DPolyPolygon()
269 [ + - ][ + + ]: 1979 : && getBColor() == rCompare.getBColor());
270 : : }
271 : :
272 : 1979 : return false;
273 : : }
274 : :
275 : 252070 : basegfx::B2DRange PolyPolygonColorPrimitive2D::getB2DRange(const geometry::ViewInformation2D& /*rViewInformation*/) const
276 : : {
277 : : // return range
278 : 252070 : return basegfx::tools::getRange(getB2DPolyPolygon());
279 : : }
280 : :
281 : : // provide unique ID
282 : 278142 : ImplPrimitrive2DIDBlock(PolyPolygonColorPrimitive2D, PRIMITIVE2D_ID_POLYPOLYGONCOLORPRIMITIVE2D)
283 : :
284 : : } // end of namespace primitive2d
285 : : } // end of namespace drawinglayer
286 : :
287 : : //////////////////////////////////////////////////////////////////////////////
288 : :
289 : : namespace drawinglayer
290 : : {
291 : : namespace primitive2d
292 : : {
293 : 209 : Primitive2DSequence PolyPolygonGradientPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
294 : : {
295 [ + - ]: 209 : if(!getFillGradient().isDefault())
296 : : {
297 : : // create SubSequence with FillGradientPrimitive2D
298 [ + - ]: 209 : const basegfx::B2DRange aPolyPolygonRange(getB2DPolyPolygon().getB2DRange());
299 [ + - ]: 209 : FillGradientPrimitive2D* pNewGradient = new FillGradientPrimitive2D(aPolyPolygonRange, getFillGradient());
300 [ + - ][ + - ]: 209 : const Primitive2DReference xSubRef(pNewGradient);
301 [ + - ]: 209 : const Primitive2DSequence aSubSequence(&xSubRef, 1L);
302 : :
303 : : // create mask primitive
304 [ + - ]: 209 : MaskPrimitive2D* pNewMask = new MaskPrimitive2D(getB2DPolyPolygon(), aSubSequence);
305 [ + - ][ + - ]: 209 : const Primitive2DReference xRef(pNewMask);
306 : :
307 [ + - ][ + - ]: 209 : return Primitive2DSequence(&xRef, 1);
308 : : }
309 : : else
310 : : {
311 : 209 : return Primitive2DSequence();
312 : : }
313 : : }
314 : :
315 : 209 : PolyPolygonGradientPrimitive2D::PolyPolygonGradientPrimitive2D(
316 : : const basegfx::B2DPolyPolygon& rPolyPolygon,
317 : : const attribute::FillGradientAttribute& rFillGradient)
318 : : : BufferedDecompositionPrimitive2D(),
319 : : maPolyPolygon(rPolyPolygon),
320 [ + - ][ + - ]: 209 : maFillGradient(rFillGradient)
321 : : {
322 : 209 : }
323 : :
324 : 0 : bool PolyPolygonGradientPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
325 : : {
326 [ # # ]: 0 : if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
327 : : {
328 : 0 : const PolyPolygonGradientPrimitive2D& rCompare = (PolyPolygonGradientPrimitive2D&)rPrimitive;
329 : :
330 : 0 : return (getFillGradient() == rCompare.getFillGradient());
331 : : }
332 : :
333 : 0 : return false;
334 : : }
335 : :
336 : : // provide unique ID
337 : 467 : ImplPrimitrive2DIDBlock(PolyPolygonGradientPrimitive2D, PRIMITIVE2D_ID_POLYPOLYGONGRADIENTPRIMITIVE2D)
338 : :
339 : : } // end of namespace primitive2d
340 : : } // end of namespace drawinglayer
341 : :
342 : : //////////////////////////////////////////////////////////////////////////////
343 : :
344 : : namespace drawinglayer
345 : : {
346 : : namespace primitive2d
347 : : {
348 : 1266 : Primitive2DSequence PolyPolygonHatchPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
349 : : {
350 [ + - ]: 1266 : if(!getFillHatch().isDefault())
351 : : {
352 : : // create SubSequence with FillHatchPrimitive2D
353 [ + - ]: 1266 : const basegfx::B2DRange aPolyPolygonRange(getB2DPolyPolygon().getB2DRange());
354 [ + - ]: 1266 : FillHatchPrimitive2D* pNewHatch = new FillHatchPrimitive2D(aPolyPolygonRange, getBackgroundColor(), getFillHatch());
355 [ + - ][ + - ]: 1266 : const Primitive2DReference xSubRef(pNewHatch);
356 [ + - ]: 1266 : const Primitive2DSequence aSubSequence(&xSubRef, 1L);
357 : :
358 : : // create mask primitive
359 [ + - ]: 1266 : MaskPrimitive2D* pNewMask = new MaskPrimitive2D(getB2DPolyPolygon(), aSubSequence);
360 [ + - ][ + - ]: 1266 : const Primitive2DReference xRef(pNewMask);
361 : :
362 [ + - ][ + - ]: 1266 : return Primitive2DSequence(&xRef, 1);
363 : : }
364 : : else
365 : : {
366 : 1266 : return Primitive2DSequence();
367 : : }
368 : : }
369 : :
370 : 1266 : PolyPolygonHatchPrimitive2D::PolyPolygonHatchPrimitive2D(
371 : : const basegfx::B2DPolyPolygon& rPolyPolygon,
372 : : const basegfx::BColor& rBackgroundColor,
373 : : const attribute::FillHatchAttribute& rFillHatch)
374 : : : BufferedDecompositionPrimitive2D(),
375 : : maPolyPolygon(rPolyPolygon),
376 : : maBackgroundColor(rBackgroundColor),
377 [ + - ][ + - ]: 1266 : maFillHatch(rFillHatch)
378 : : {
379 : 1266 : }
380 : :
381 : 0 : bool PolyPolygonHatchPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
382 : : {
383 [ # # ]: 0 : if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
384 : : {
385 : 0 : const PolyPolygonHatchPrimitive2D& rCompare = (PolyPolygonHatchPrimitive2D&)rPrimitive;
386 : :
387 : 0 : return (getBackgroundColor() == rCompare.getBackgroundColor()
388 [ # # ][ # # ]: 0 : && getFillHatch() == rCompare.getFillHatch());
389 : : }
390 : :
391 : 0 : return false;
392 : : }
393 : :
394 : : // provide unique ID
395 : 1852 : ImplPrimitrive2DIDBlock(PolyPolygonHatchPrimitive2D, PRIMITIVE2D_ID_POLYPOLYGONHATCHPRIMITIVE2D)
396 : :
397 : : } // end of namespace primitive2d
398 : : } // end of namespace drawinglayer
399 : :
400 : : //////////////////////////////////////////////////////////////////////////////
401 : :
402 : : namespace drawinglayer
403 : : {
404 : : namespace primitive2d
405 : : {
406 : 262 : Primitive2DSequence PolyPolygonBitmapPrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& /*rViewInformation*/) const
407 : : {
408 [ + - ]: 262 : if(!getFillBitmap().isDefault())
409 : : {
410 : : // create SubSequence with FillBitmapPrimitive2D
411 [ + - ]: 262 : const basegfx::B2DRange aPolyPolygonRange(getB2DPolyPolygon().getB2DRange());
412 [ + - ]: 262 : basegfx::B2DHomMatrix aNewObjectTransform;
413 [ + - ][ + - ]: 262 : aNewObjectTransform.set(0, 0, aPolyPolygonRange.getWidth());
414 [ + - ][ + - ]: 262 : aNewObjectTransform.set(1, 1, aPolyPolygonRange.getHeight());
415 [ + - ][ + - ]: 262 : aNewObjectTransform.set(0, 2, aPolyPolygonRange.getMinX());
416 [ + - ][ + - ]: 262 : aNewObjectTransform.set(1, 2, aPolyPolygonRange.getMinY());
417 [ + - ]: 262 : FillBitmapPrimitive2D* pNewBitmap = new FillBitmapPrimitive2D(aNewObjectTransform, getFillBitmap());
418 [ + - ][ + - ]: 262 : const Primitive2DReference xSubRef(pNewBitmap);
419 [ + - ]: 262 : const Primitive2DSequence aSubSequence(&xSubRef, 1L);
420 : :
421 : : // create mask primitive
422 [ + - ]: 262 : MaskPrimitive2D* pNewMask = new MaskPrimitive2D(getB2DPolyPolygon(), aSubSequence);
423 [ + - ][ + - ]: 262 : const Primitive2DReference xRef(pNewMask);
424 : :
425 [ + - ][ + - ]: 262 : return Primitive2DSequence(&xRef, 1);
[ + - ]
426 : : }
427 : : else
428 : : {
429 : 262 : return Primitive2DSequence();
430 : : }
431 : : }
432 : :
433 : 262 : PolyPolygonBitmapPrimitive2D::PolyPolygonBitmapPrimitive2D(
434 : : const basegfx::B2DPolyPolygon& rPolyPolygon,
435 : : const attribute::FillBitmapAttribute& rFillBitmap)
436 : : : BufferedDecompositionPrimitive2D(),
437 : : maPolyPolygon(rPolyPolygon),
438 [ + - ][ + - ]: 262 : maFillBitmap(rFillBitmap)
439 : : {
440 : 262 : }
441 : :
442 : 0 : bool PolyPolygonBitmapPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
443 : : {
444 [ # # ]: 0 : if(BufferedDecompositionPrimitive2D::operator==(rPrimitive))
445 : : {
446 : 0 : const PolyPolygonBitmapPrimitive2D& rCompare = (PolyPolygonBitmapPrimitive2D&)rPrimitive;
447 : :
448 : 0 : return (getFillBitmap() == rCompare.getFillBitmap());
449 : : }
450 : :
451 : 0 : return false;
452 : : }
453 : :
454 : : // provide unique ID
455 : 569 : ImplPrimitrive2DIDBlock(PolyPolygonBitmapPrimitive2D, PRIMITIVE2D_ID_POLYPOLYGONBITMAPPRIMITIVE2D)
456 : :
457 : : } // end of namespace primitive2d
458 : : } // end of namespace drawinglayer
459 : :
460 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|