1*b1cdbd2cSJim Jagielski /**************************************************************
2*b1cdbd2cSJim Jagielski *
3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file
5*b1cdbd2cSJim Jagielski * distributed with this work for additional information
6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file
7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski *
11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski *
13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the
17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski * under the License.
19*b1cdbd2cSJim Jagielski *
20*b1cdbd2cSJim Jagielski *************************************************************/
21*b1cdbd2cSJim Jagielski
22*b1cdbd2cSJim Jagielski
23*b1cdbd2cSJim Jagielski
24*b1cdbd2cSJim Jagielski // MARKER(update_precomp.py): autogen include statement, do not remove
25*b1cdbd2cSJim Jagielski #include "precompiled_sdext.hxx"
26*b1cdbd2cSJim Jagielski
27*b1cdbd2cSJim Jagielski #include "PresenterGeometryHelper.hxx"
28*b1cdbd2cSJim Jagielski
29*b1cdbd2cSJim Jagielski #include <math.h>
30*b1cdbd2cSJim Jagielski #include <algorithm>
31*b1cdbd2cSJim Jagielski
32*b1cdbd2cSJim Jagielski using namespace ::com::sun::star;
33*b1cdbd2cSJim Jagielski using namespace ::com::sun::star::uno;
34*b1cdbd2cSJim Jagielski
35*b1cdbd2cSJim Jagielski namespace {
36*b1cdbd2cSJim Jagielski
Right(const awt::Rectangle & rBox)37*b1cdbd2cSJim Jagielski sal_Int32 Right (const awt::Rectangle& rBox)
38*b1cdbd2cSJim Jagielski {
39*b1cdbd2cSJim Jagielski return rBox.X + rBox.Width - 1;
40*b1cdbd2cSJim Jagielski }
41*b1cdbd2cSJim Jagielski
Bottom(const awt::Rectangle & rBox)42*b1cdbd2cSJim Jagielski sal_Int32 Bottom (const awt::Rectangle& rBox)
43*b1cdbd2cSJim Jagielski {
44*b1cdbd2cSJim Jagielski return rBox.Y + rBox.Height - 1;
45*b1cdbd2cSJim Jagielski }
46*b1cdbd2cSJim Jagielski
Width(const sal_Int32 nLeft,const sal_Int32 nRight)47*b1cdbd2cSJim Jagielski sal_Int32 Width (const sal_Int32 nLeft, const sal_Int32 nRight)
48*b1cdbd2cSJim Jagielski {
49*b1cdbd2cSJim Jagielski return nRight - nLeft + 1;
50*b1cdbd2cSJim Jagielski }
51*b1cdbd2cSJim Jagielski
Height(const sal_Int32 nTop,const sal_Int32 nBottom)52*b1cdbd2cSJim Jagielski sal_Int32 Height (const sal_Int32 nTop, const sal_Int32 nBottom)
53*b1cdbd2cSJim Jagielski {
54*b1cdbd2cSJim Jagielski return nBottom - nTop + 1;
55*b1cdbd2cSJim Jagielski }
56*b1cdbd2cSJim Jagielski
57*b1cdbd2cSJim Jagielski
58*b1cdbd2cSJim Jagielski } // end of anonymous namespace
59*b1cdbd2cSJim Jagielski
60*b1cdbd2cSJim Jagielski
61*b1cdbd2cSJim Jagielski
62*b1cdbd2cSJim Jagielski namespace sdext { namespace presenter {
63*b1cdbd2cSJim Jagielski
Floor(const double nValue)64*b1cdbd2cSJim Jagielski sal_Int32 PresenterGeometryHelper::Floor (const double nValue)
65*b1cdbd2cSJim Jagielski {
66*b1cdbd2cSJim Jagielski return sal::static_int_cast<sal_Int32>(floor(nValue));
67*b1cdbd2cSJim Jagielski }
68*b1cdbd2cSJim Jagielski
69*b1cdbd2cSJim Jagielski
70*b1cdbd2cSJim Jagielski
71*b1cdbd2cSJim Jagielski
Ceil(const double nValue)72*b1cdbd2cSJim Jagielski sal_Int32 PresenterGeometryHelper::Ceil (const double nValue)
73*b1cdbd2cSJim Jagielski {
74*b1cdbd2cSJim Jagielski return sal::static_int_cast<sal_Int32>(ceil(nValue));
75*b1cdbd2cSJim Jagielski }
76*b1cdbd2cSJim Jagielski
77*b1cdbd2cSJim Jagielski
78*b1cdbd2cSJim Jagielski
79*b1cdbd2cSJim Jagielski
Round(const double nValue)80*b1cdbd2cSJim Jagielski sal_Int32 PresenterGeometryHelper::Round (const double nValue)
81*b1cdbd2cSJim Jagielski {
82*b1cdbd2cSJim Jagielski return sal::static_int_cast<sal_Int32>(floor(0.5 + nValue));
83*b1cdbd2cSJim Jagielski }
84*b1cdbd2cSJim Jagielski
85*b1cdbd2cSJim Jagielski
86*b1cdbd2cSJim Jagielski
87*b1cdbd2cSJim Jagielski
ConvertRectangle(const geometry::RealRectangle2D & rBox)88*b1cdbd2cSJim Jagielski awt::Rectangle PresenterGeometryHelper::ConvertRectangle (
89*b1cdbd2cSJim Jagielski const geometry::RealRectangle2D& rBox)
90*b1cdbd2cSJim Jagielski {
91*b1cdbd2cSJim Jagielski const sal_Int32 nLeft (Floor(rBox.X1));
92*b1cdbd2cSJim Jagielski const sal_Int32 nTop (Floor(rBox.Y1));
93*b1cdbd2cSJim Jagielski const sal_Int32 nRight (Ceil(rBox.X2));
94*b1cdbd2cSJim Jagielski const sal_Int32 nBottom (Ceil(rBox.Y2));
95*b1cdbd2cSJim Jagielski return awt::Rectangle (nLeft,nTop,nRight-nLeft,nBottom-nTop);
96*b1cdbd2cSJim Jagielski }
97*b1cdbd2cSJim Jagielski
98*b1cdbd2cSJim Jagielski
99*b1cdbd2cSJim Jagielski
100*b1cdbd2cSJim Jagielski
ConvertRectangleWithConstantSize(const geometry::RealRectangle2D & rBox)101*b1cdbd2cSJim Jagielski awt::Rectangle PresenterGeometryHelper::ConvertRectangleWithConstantSize (
102*b1cdbd2cSJim Jagielski const geometry::RealRectangle2D& rBox)
103*b1cdbd2cSJim Jagielski {
104*b1cdbd2cSJim Jagielski return awt::Rectangle (
105*b1cdbd2cSJim Jagielski Round(rBox.X1),
106*b1cdbd2cSJim Jagielski Round(rBox.Y1),
107*b1cdbd2cSJim Jagielski Round(rBox.X2 - rBox.X1),
108*b1cdbd2cSJim Jagielski Round(rBox.Y2 - rBox.Y1));
109*b1cdbd2cSJim Jagielski }
110*b1cdbd2cSJim Jagielski
111*b1cdbd2cSJim Jagielski
112*b1cdbd2cSJim Jagielski
113*b1cdbd2cSJim Jagielski
ConvertRectangle(const css::awt::Rectangle & rBox)114*b1cdbd2cSJim Jagielski geometry::RealRectangle2D PresenterGeometryHelper::ConvertRectangle (
115*b1cdbd2cSJim Jagielski const css::awt::Rectangle& rBox)
116*b1cdbd2cSJim Jagielski {
117*b1cdbd2cSJim Jagielski return geometry::RealRectangle2D(
118*b1cdbd2cSJim Jagielski rBox.X,
119*b1cdbd2cSJim Jagielski rBox.Y,
120*b1cdbd2cSJim Jagielski rBox.X + rBox.Width,
121*b1cdbd2cSJim Jagielski rBox.Y + rBox.Height);
122*b1cdbd2cSJim Jagielski }
123*b1cdbd2cSJim Jagielski
124*b1cdbd2cSJim Jagielski
125*b1cdbd2cSJim Jagielski
126*b1cdbd2cSJim Jagielski
TranslateRectangle(const css::awt::Rectangle & rBox,const sal_Int32 nXOffset,const sal_Int32 nYOffset)127*b1cdbd2cSJim Jagielski awt::Rectangle PresenterGeometryHelper::TranslateRectangle (
128*b1cdbd2cSJim Jagielski const css::awt::Rectangle& rBox,
129*b1cdbd2cSJim Jagielski const sal_Int32 nXOffset,
130*b1cdbd2cSJim Jagielski const sal_Int32 nYOffset)
131*b1cdbd2cSJim Jagielski {
132*b1cdbd2cSJim Jagielski return awt::Rectangle(rBox.X + nXOffset, rBox.Y + nYOffset, rBox.Width, rBox.Height);
133*b1cdbd2cSJim Jagielski }
134*b1cdbd2cSJim Jagielski
135*b1cdbd2cSJim Jagielski
136*b1cdbd2cSJim Jagielski
137*b1cdbd2cSJim Jagielski
Intersection(const css::awt::Rectangle & rBox1,const css::awt::Rectangle & rBox2)138*b1cdbd2cSJim Jagielski awt::Rectangle PresenterGeometryHelper::Intersection (
139*b1cdbd2cSJim Jagielski const css::awt::Rectangle& rBox1,
140*b1cdbd2cSJim Jagielski const css::awt::Rectangle& rBox2)
141*b1cdbd2cSJim Jagielski {
142*b1cdbd2cSJim Jagielski const sal_Int32 nLeft (::std::max(rBox1.X, rBox2.X));
143*b1cdbd2cSJim Jagielski const sal_Int32 nTop (::std::max(rBox1.Y, rBox2.Y));
144*b1cdbd2cSJim Jagielski const sal_Int32 nRight (::std::min(Right(rBox1), Right(rBox2)));
145*b1cdbd2cSJim Jagielski const sal_Int32 nBottom (::std::min(Bottom(rBox1), Bottom(rBox2)));
146*b1cdbd2cSJim Jagielski if (nLeft >= nRight || nTop >= nBottom)
147*b1cdbd2cSJim Jagielski return awt::Rectangle();
148*b1cdbd2cSJim Jagielski else
149*b1cdbd2cSJim Jagielski return awt::Rectangle(nLeft,nTop, Width(nLeft,nRight), Height(nTop,nBottom));
150*b1cdbd2cSJim Jagielski }
151*b1cdbd2cSJim Jagielski
152*b1cdbd2cSJim Jagielski
153*b1cdbd2cSJim Jagielski
154*b1cdbd2cSJim Jagielski
Intersection(const geometry::RealRectangle2D & rBox1,const geometry::RealRectangle2D & rBox2)155*b1cdbd2cSJim Jagielski geometry::RealRectangle2D PresenterGeometryHelper::Intersection (
156*b1cdbd2cSJim Jagielski const geometry::RealRectangle2D& rBox1,
157*b1cdbd2cSJim Jagielski const geometry::RealRectangle2D& rBox2)
158*b1cdbd2cSJim Jagielski {
159*b1cdbd2cSJim Jagielski const double nLeft (::std::max(rBox1.X1, rBox2.X1));
160*b1cdbd2cSJim Jagielski const double nTop (::std::max(rBox1.Y1, rBox2.Y1));
161*b1cdbd2cSJim Jagielski const double nRight (::std::min(rBox1.X2, rBox2.X2));
162*b1cdbd2cSJim Jagielski const double nBottom (::std::min(rBox1.Y2, rBox2.Y2));
163*b1cdbd2cSJim Jagielski if (nLeft >= nRight || nTop >= nBottom)
164*b1cdbd2cSJim Jagielski return geometry::RealRectangle2D(0,0,0,0);
165*b1cdbd2cSJim Jagielski else
166*b1cdbd2cSJim Jagielski return geometry::RealRectangle2D(nLeft,nTop, nRight, nBottom);
167*b1cdbd2cSJim Jagielski }
168*b1cdbd2cSJim Jagielski
169*b1cdbd2cSJim Jagielski
170*b1cdbd2cSJim Jagielski
171*b1cdbd2cSJim Jagielski
IsInside(const css::geometry::RealRectangle2D & rBox,const css::geometry::RealPoint2D & rPoint)172*b1cdbd2cSJim Jagielski bool PresenterGeometryHelper::IsInside (
173*b1cdbd2cSJim Jagielski const css::geometry::RealRectangle2D& rBox,
174*b1cdbd2cSJim Jagielski const css::geometry::RealPoint2D& rPoint)
175*b1cdbd2cSJim Jagielski {
176*b1cdbd2cSJim Jagielski return rBox.X1 <= rPoint.X
177*b1cdbd2cSJim Jagielski && rBox.Y1 <= rPoint.Y
178*b1cdbd2cSJim Jagielski && rBox.X2 >= rPoint.X
179*b1cdbd2cSJim Jagielski && rBox.Y2 >= rPoint.Y;
180*b1cdbd2cSJim Jagielski }
181*b1cdbd2cSJim Jagielski
182*b1cdbd2cSJim Jagielski
183*b1cdbd2cSJim Jagielski
184*b1cdbd2cSJim Jagielski
IsInside(const css::awt::Rectangle & rBox1,const css::awt::Rectangle & rBox2)185*b1cdbd2cSJim Jagielski bool PresenterGeometryHelper::IsInside (
186*b1cdbd2cSJim Jagielski const css::awt::Rectangle& rBox1,
187*b1cdbd2cSJim Jagielski const css::awt::Rectangle& rBox2)
188*b1cdbd2cSJim Jagielski {
189*b1cdbd2cSJim Jagielski return rBox1.X >= rBox2.X
190*b1cdbd2cSJim Jagielski && rBox1.Y >= rBox2.Y
191*b1cdbd2cSJim Jagielski && rBox1.X+rBox1.Width <= rBox2.X+rBox2.Width
192*b1cdbd2cSJim Jagielski && rBox1.Y+rBox1.Height <= rBox2.Y+rBox2.Height;
193*b1cdbd2cSJim Jagielski }
194*b1cdbd2cSJim Jagielski
195*b1cdbd2cSJim Jagielski
196*b1cdbd2cSJim Jagielski
197*b1cdbd2cSJim Jagielski
Union(const css::awt::Rectangle & rBox1,const css::awt::Rectangle & rBox2)198*b1cdbd2cSJim Jagielski awt::Rectangle PresenterGeometryHelper::Union (
199*b1cdbd2cSJim Jagielski const css::awt::Rectangle& rBox1,
200*b1cdbd2cSJim Jagielski const css::awt::Rectangle& rBox2)
201*b1cdbd2cSJim Jagielski {
202*b1cdbd2cSJim Jagielski if (rBox1.Width<=0 || rBox1.Height<=0)
203*b1cdbd2cSJim Jagielski return rBox2;
204*b1cdbd2cSJim Jagielski else if (rBox2.Width<=0 || rBox2.Height<=0)
205*b1cdbd2cSJim Jagielski return rBox1;
206*b1cdbd2cSJim Jagielski
207*b1cdbd2cSJim Jagielski const sal_Int32 nLeft (::std::min(rBox1.X, rBox2.X));
208*b1cdbd2cSJim Jagielski const sal_Int32 nTop (::std::min(rBox1.Y, rBox2.Y));
209*b1cdbd2cSJim Jagielski const sal_Int32 nRight (::std::max(Right(rBox1), Right(rBox2)));
210*b1cdbd2cSJim Jagielski const sal_Int32 nBottom (::std::max(Bottom(rBox1), Bottom(rBox2)));
211*b1cdbd2cSJim Jagielski if (nLeft >= nRight || nTop >= nBottom)
212*b1cdbd2cSJim Jagielski return awt::Rectangle();
213*b1cdbd2cSJim Jagielski else
214*b1cdbd2cSJim Jagielski return awt::Rectangle(nLeft,nTop, Width(nLeft,nRight), Height(nTop,nBottom));
215*b1cdbd2cSJim Jagielski }
216*b1cdbd2cSJim Jagielski
217*b1cdbd2cSJim Jagielski
218*b1cdbd2cSJim Jagielski
219*b1cdbd2cSJim Jagielski
Union(const geometry::RealRectangle2D & rBox1,const geometry::RealRectangle2D & rBox2)220*b1cdbd2cSJim Jagielski geometry::RealRectangle2D PresenterGeometryHelper::Union (
221*b1cdbd2cSJim Jagielski const geometry::RealRectangle2D& rBox1,
222*b1cdbd2cSJim Jagielski const geometry::RealRectangle2D& rBox2)
223*b1cdbd2cSJim Jagielski {
224*b1cdbd2cSJim Jagielski const double nLeft (::std::min(rBox1.X1, rBox2.X1));
225*b1cdbd2cSJim Jagielski const double nTop (::std::min(rBox1.Y1, rBox2.Y1));
226*b1cdbd2cSJim Jagielski const double nRight (::std::max(rBox1.X2, rBox2.X2));
227*b1cdbd2cSJim Jagielski const double nBottom (::std::max(rBox1.Y2, rBox2.Y2));
228*b1cdbd2cSJim Jagielski if (nLeft >= nRight || nTop >= nBottom)
229*b1cdbd2cSJim Jagielski return geometry::RealRectangle2D(0,0,0,0);
230*b1cdbd2cSJim Jagielski else
231*b1cdbd2cSJim Jagielski return geometry::RealRectangle2D(nLeft,nTop, nRight, nBottom);
232*b1cdbd2cSJim Jagielski }
233*b1cdbd2cSJim Jagielski
234*b1cdbd2cSJim Jagielski
235*b1cdbd2cSJim Jagielski
236*b1cdbd2cSJim Jagielski
AreRectanglesDisjoint(const css::awt::Rectangle & rBox1,const css::awt::Rectangle & rBox2)237*b1cdbd2cSJim Jagielski bool PresenterGeometryHelper::AreRectanglesDisjoint (
238*b1cdbd2cSJim Jagielski const css::awt::Rectangle& rBox1,
239*b1cdbd2cSJim Jagielski const css::awt::Rectangle& rBox2)
240*b1cdbd2cSJim Jagielski {
241*b1cdbd2cSJim Jagielski return rBox1.X+rBox1.Width <= rBox2.X
242*b1cdbd2cSJim Jagielski || rBox1.Y+rBox1.Height <= rBox2.Y
243*b1cdbd2cSJim Jagielski || rBox1.X >= rBox2.X+rBox2.Width
244*b1cdbd2cSJim Jagielski || rBox1.Y >= rBox2.Y+rBox2.Height;
245*b1cdbd2cSJim Jagielski }
246*b1cdbd2cSJim Jagielski
247*b1cdbd2cSJim Jagielski
248*b1cdbd2cSJim Jagielski
249*b1cdbd2cSJim Jagielski
CreatePolygon(const awt::Rectangle & rBox,const Reference<rendering::XGraphicDevice> & rxDevice)250*b1cdbd2cSJim Jagielski Reference<rendering::XPolyPolygon2D> PresenterGeometryHelper::CreatePolygon(
251*b1cdbd2cSJim Jagielski const awt::Rectangle& rBox,
252*b1cdbd2cSJim Jagielski const Reference<rendering::XGraphicDevice>& rxDevice)
253*b1cdbd2cSJim Jagielski {
254*b1cdbd2cSJim Jagielski if ( ! rxDevice.is())
255*b1cdbd2cSJim Jagielski return NULL;
256*b1cdbd2cSJim Jagielski
257*b1cdbd2cSJim Jagielski Sequence<Sequence<geometry::RealPoint2D> > aPoints(1);
258*b1cdbd2cSJim Jagielski aPoints[0] = Sequence<geometry::RealPoint2D>(4);
259*b1cdbd2cSJim Jagielski aPoints[0][0] = geometry::RealPoint2D(rBox.X, rBox.Y);
260*b1cdbd2cSJim Jagielski aPoints[0][1] = geometry::RealPoint2D(rBox.X, rBox.Y+rBox.Height);
261*b1cdbd2cSJim Jagielski aPoints[0][2] = geometry::RealPoint2D(rBox.X+rBox.Width, rBox.Y+rBox.Height);
262*b1cdbd2cSJim Jagielski aPoints[0][3] = geometry::RealPoint2D(rBox.X+rBox.Width, rBox.Y);
263*b1cdbd2cSJim Jagielski Reference<rendering::XLinePolyPolygon2D> xPolygon (
264*b1cdbd2cSJim Jagielski rxDevice->createCompatibleLinePolyPolygon(aPoints));
265*b1cdbd2cSJim Jagielski Reference<rendering::XPolyPolygon2D> xRectangle (xPolygon, UNO_QUERY);
266*b1cdbd2cSJim Jagielski if (xRectangle.is())
267*b1cdbd2cSJim Jagielski xRectangle->setClosed(0, sal_True);
268*b1cdbd2cSJim Jagielski
269*b1cdbd2cSJim Jagielski return xRectangle;
270*b1cdbd2cSJim Jagielski }
271*b1cdbd2cSJim Jagielski
272*b1cdbd2cSJim Jagielski
273*b1cdbd2cSJim Jagielski
274*b1cdbd2cSJim Jagielski
CreatePolygon(const geometry::RealRectangle2D & rBox,const Reference<rendering::XGraphicDevice> & rxDevice)275*b1cdbd2cSJim Jagielski Reference<rendering::XPolyPolygon2D> PresenterGeometryHelper::CreatePolygon(
276*b1cdbd2cSJim Jagielski const geometry::RealRectangle2D& rBox,
277*b1cdbd2cSJim Jagielski const Reference<rendering::XGraphicDevice>& rxDevice)
278*b1cdbd2cSJim Jagielski {
279*b1cdbd2cSJim Jagielski if ( ! rxDevice.is())
280*b1cdbd2cSJim Jagielski return NULL;
281*b1cdbd2cSJim Jagielski
282*b1cdbd2cSJim Jagielski Sequence<Sequence<geometry::RealPoint2D> > aPoints(1);
283*b1cdbd2cSJim Jagielski aPoints[0] = Sequence<geometry::RealPoint2D>(4);
284*b1cdbd2cSJim Jagielski aPoints[0][0] = geometry::RealPoint2D(rBox.X1, rBox.Y1);
285*b1cdbd2cSJim Jagielski aPoints[0][1] = geometry::RealPoint2D(rBox.X1, rBox.Y2);
286*b1cdbd2cSJim Jagielski aPoints[0][2] = geometry::RealPoint2D(rBox.X2, rBox.Y2);
287*b1cdbd2cSJim Jagielski aPoints[0][3] = geometry::RealPoint2D(rBox.X2, rBox.Y1);
288*b1cdbd2cSJim Jagielski Reference<rendering::XLinePolyPolygon2D> xPolygon (
289*b1cdbd2cSJim Jagielski rxDevice->createCompatibleLinePolyPolygon(aPoints));
290*b1cdbd2cSJim Jagielski Reference<rendering::XPolyPolygon2D> xRectangle (xPolygon, UNO_QUERY);
291*b1cdbd2cSJim Jagielski if (xRectangle.is())
292*b1cdbd2cSJim Jagielski xRectangle->setClosed(0, sal_True);
293*b1cdbd2cSJim Jagielski
294*b1cdbd2cSJim Jagielski return xRectangle;
295*b1cdbd2cSJim Jagielski }
296*b1cdbd2cSJim Jagielski
297*b1cdbd2cSJim Jagielski
298*b1cdbd2cSJim Jagielski
299*b1cdbd2cSJim Jagielski
CreatePolygon(const::std::vector<css::awt::Rectangle> & rBoxes,const Reference<rendering::XGraphicDevice> & rxDevice)300*b1cdbd2cSJim Jagielski Reference<rendering::XPolyPolygon2D> PresenterGeometryHelper::CreatePolygon(
301*b1cdbd2cSJim Jagielski const ::std::vector<css::awt::Rectangle>& rBoxes,
302*b1cdbd2cSJim Jagielski const Reference<rendering::XGraphicDevice>& rxDevice)
303*b1cdbd2cSJim Jagielski {
304*b1cdbd2cSJim Jagielski if ( ! rxDevice.is())
305*b1cdbd2cSJim Jagielski return NULL;
306*b1cdbd2cSJim Jagielski
307*b1cdbd2cSJim Jagielski const sal_Int32 nCount (rBoxes.size());
308*b1cdbd2cSJim Jagielski Sequence<Sequence<geometry::RealPoint2D> > aPoints(nCount);
309*b1cdbd2cSJim Jagielski for (sal_Int32 nIndex=0; nIndex<nCount; ++nIndex)
310*b1cdbd2cSJim Jagielski {
311*b1cdbd2cSJim Jagielski const awt::Rectangle& rBox (rBoxes[nIndex]);
312*b1cdbd2cSJim Jagielski aPoints[nIndex] = Sequence<geometry::RealPoint2D>(4);
313*b1cdbd2cSJim Jagielski aPoints[nIndex][0] = geometry::RealPoint2D(rBox.X, rBox.Y);
314*b1cdbd2cSJim Jagielski aPoints[nIndex][1] = geometry::RealPoint2D(rBox.X, rBox.Y+rBox.Height);
315*b1cdbd2cSJim Jagielski aPoints[nIndex][2] = geometry::RealPoint2D(rBox.X+rBox.Width, rBox.Y+rBox.Height);
316*b1cdbd2cSJim Jagielski aPoints[nIndex][3] = geometry::RealPoint2D(rBox.X+rBox.Width, rBox.Y);
317*b1cdbd2cSJim Jagielski }
318*b1cdbd2cSJim Jagielski
319*b1cdbd2cSJim Jagielski Reference<rendering::XLinePolyPolygon2D> xPolygon (
320*b1cdbd2cSJim Jagielski rxDevice->createCompatibleLinePolyPolygon(aPoints));
321*b1cdbd2cSJim Jagielski Reference<rendering::XPolyPolygon2D> xRectangle (xPolygon, UNO_QUERY);
322*b1cdbd2cSJim Jagielski if (xRectangle.is())
323*b1cdbd2cSJim Jagielski for (sal_Int32 nIndex=0; nIndex<nCount; ++nIndex)
324*b1cdbd2cSJim Jagielski xRectangle->setClosed(nIndex, sal_True);
325*b1cdbd2cSJim Jagielski
326*b1cdbd2cSJim Jagielski return xRectangle;
327*b1cdbd2cSJim Jagielski }
328*b1cdbd2cSJim Jagielski
329*b1cdbd2cSJim Jagielski
330*b1cdbd2cSJim Jagielski } }
331