xref: /AOO41X/main/drawinglayer/source/primitive2d/sdrdecompositiontools2d.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  *  OpenOffice.org - a multi-platform office productivity suite
4  *
5  *  $RCSfile: sdrdecompositiontools3d.cxx,v $
6  *
7  *  $Revision: 1.7 $
8  *
9  *  last change: $Author: aw $ $Date: 2008-05-27 14:11:21 $
10  *
11  *  The Contents of this file are made available subject to
12  *  the terms of GNU Lesser General Public License Version 2.1.
13  *
14  *
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
19  *
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.
23  *
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.
28  *
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
33  *
34  ************************************************************************/
35 
36 // MARKER(update_precomp.py): autogen include statement, do not remove
37 #include "precompiled_drawinglayer.hxx"
38 
39 #include <drawinglayer/primitive2d/sdrdecompositiontools2d.hxx>
40 #include <basegfx/polygon/b2dpolygon.hxx>
41 #include <basegfx/polygon/b2dpolygontools.hxx>
42 #include <basegfx/matrix/b2dhommatrix.hxx>
43 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
44 #include <drawinglayer/primitive2d/hiddengeometryprimitive2d.hxx>
45 
46 //////////////////////////////////////////////////////////////////////////////
47 
48 namespace drawinglayer
49 {
50 	namespace primitive2d
51 	{
52         Primitive2DReference createHiddenGeometryPrimitives2D(
53             bool bFilled,
54             const basegfx::B2DHomMatrix& rMatrix)
55         {
56 			const basegfx::B2DPolygon aUnitOutline(basegfx::tools::createUnitPolygon());
57 
58             return createHiddenGeometryPrimitives2D(
59                 bFilled,
60                 basegfx::B2DPolyPolygon(aUnitOutline),
61                 rMatrix);
62         }
63 
64         Primitive2DReference createHiddenGeometryPrimitives2D(
65             bool bFilled,
66             const basegfx::B2DPolyPolygon& rPolyPolygon)
67         {
68             return createHiddenGeometryPrimitives2D(
69                 bFilled,
70                 rPolyPolygon,
71                 basegfx::B2DHomMatrix());
72         }
73 
74         Primitive2DReference createHiddenGeometryPrimitives2D(
75             bool bFilled,
76             const basegfx::B2DRange& rRange)
77 		{
78 			return createHiddenGeometryPrimitives2D(
79                 bFilled,
80                 rRange,
81                 basegfx::B2DHomMatrix());
82 		}
83 
84         Primitive2DReference createHiddenGeometryPrimitives2D(
85             bool bFilled,
86             const basegfx::B2DRange& rRange,
87             const basegfx::B2DHomMatrix& rMatrix)
88 		{
89 			const basegfx::B2DPolyPolygon aOutline(basegfx::tools::createPolygonFromRect(rRange));
90 
91 			return createHiddenGeometryPrimitives2D(
92                 bFilled,
93                 aOutline,
94                 rMatrix);
95 		}
96 
97         Primitive2DReference createHiddenGeometryPrimitives2D(
98             bool bFilled,
99             const basegfx::B2DPolyPolygon& rPolyPolygon,
100             const basegfx::B2DHomMatrix& rMatrix)
101         {
102             // create fill or line primitive
103             Primitive2DReference xReference;
104 			basegfx::B2DPolyPolygon aScaledOutline(rPolyPolygon);
105             aScaledOutline.transform(rMatrix);
106 
107             if(bFilled)
108             {
109                 xReference = new PolyPolygonColorPrimitive2D(
110                     basegfx::B2DPolyPolygon(aScaledOutline),
111                     basegfx::BColor(0.0, 0.0, 0.0));
112             }
113             else
114             {
115 				const basegfx::BColor aGrayTone(0xc0 / 255.0, 0xc0 / 255.0, 0xc0 / 255.0);
116 
117                 xReference = new PolyPolygonHairlinePrimitive2D(
118                     aScaledOutline,
119                     aGrayTone);
120             }
121 
122             // create HiddenGeometryPrimitive2D
123             return Primitive2DReference(
124                 new HiddenGeometryPrimitive2D(Primitive2DSequence(&xReference, 1)));
125         }
126 	} // end of namespace primitive2d
127 } // end of namespace drawinglayer
128 
129 //////////////////////////////////////////////////////////////////////////////
130 // eof
131