32sal_Int32
Right (
const awt::Rectangle& rBox)
34 return rBox.X + rBox.Width - 1;
37sal_Int32
Bottom (
const awt::Rectangle& rBox)
39 return rBox.Y + rBox.Height - 1;
42sal_Int32
Width (
const sal_Int32 nLeft,
const sal_Int32 nRight)
44 return nRight - nLeft + 1;
47sal_Int32
Height (
const sal_Int32 nTop,
const sal_Int32 nBottom)
49 return nBottom - nTop + 1;
58 return sal::static_int_cast<sal_Int32>(floor(
nValue));
63 return sal::static_int_cast<sal_Int32>(ceil(
nValue));
68 return sal::static_int_cast<sal_Int32>(floor(0.5 +
nValue));
72 const geometry::RealRectangle2D& rBox)
74 const sal_Int32 nLeft (
Floor(rBox.X1));
75 const sal_Int32 nTop (
Floor(rBox.Y1));
76 const sal_Int32 nRight (
Ceil(rBox.X2));
77 const sal_Int32 nBottom (
Ceil(rBox.Y2));
78 return awt::Rectangle (nLeft,nTop,nRight-nLeft,nBottom-nTop);
82 const geometry::RealRectangle2D& rBox)
84 return awt::Rectangle (
87 Round(rBox.X2 - rBox.X1),
88 Round(rBox.Y2 - rBox.Y1));
92 const css::awt::Rectangle& rBox)
94 return geometry::RealRectangle2D(
98 rBox.Y + rBox.Height);
102 const css::awt::Rectangle& rBox,
103 const sal_Int32 nXOffset,
104 const sal_Int32 nYOffset)
106 return awt::Rectangle(rBox.X + nXOffset, rBox.Y + nYOffset, rBox.Width, rBox.Height);
110 const css::awt::Rectangle& rBox1,
111 const css::awt::Rectangle& rBox2)
113 const sal_Int32 nLeft (::std::max(rBox1.X, rBox2.X));
114 const sal_Int32 nTop (::std::max(rBox1.Y, rBox2.Y));
115 const sal_Int32 nRight (::std::min(
Right(rBox1),
Right(rBox2)));
116 const sal_Int32 nBottom (::std::min(
Bottom(rBox1),
Bottom(rBox2)));
117 if (nLeft >= nRight || nTop >= nBottom)
118 return awt::Rectangle();
120 return awt::Rectangle(nLeft,nTop,
Width(nLeft,nRight),
Height(nTop,nBottom));
124 const geometry::RealRectangle2D& rBox1,
125 const geometry::RealRectangle2D& rBox2)
127 const double nLeft (::std::max(rBox1.X1, rBox2.X1));
128 const double nTop (::std::max(rBox1.Y1, rBox2.Y1));
129 const double nRight (::std::min(rBox1.X2, rBox2.X2));
130 const double nBottom (::std::min(rBox1.Y2, rBox2.Y2));
131 if (nLeft >= nRight || nTop >= nBottom)
132 return geometry::RealRectangle2D(0,0,0,0);
134 return geometry::RealRectangle2D(nLeft,nTop, nRight, nBottom);
138 const css::geometry::RealRectangle2D& rBox,
139 const css::geometry::RealPoint2D& rPoint)
141 return rBox.X1 <= rPoint.X
142 && rBox.Y1 <= rPoint.Y
143 && rBox.X2 >= rPoint.X
144 && rBox.Y2 >= rPoint.Y;
148 const css::awt::Rectangle& rBox1,
149 const css::awt::Rectangle& rBox2)
151 return rBox1.X >= rBox2.X
152 && rBox1.Y >= rBox2.Y
153 && rBox1.X+rBox1.Width <= rBox2.X+rBox2.Width
154 && rBox1.Y+rBox1.Height <= rBox2.Y+rBox2.Height;
158 const geometry::RealRectangle2D& rBox1,
159 const geometry::RealRectangle2D& rBox2)
161 const double nLeft (::std::min(rBox1.X1, rBox2.X1));
162 const double nTop (::std::min(rBox1.Y1, rBox2.Y1));
163 const double nRight (::std::max(rBox1.X2, rBox2.X2));
164 const double nBottom (::std::max(rBox1.Y2, rBox2.Y2));
165 if (nLeft >= nRight || nTop >= nBottom)
166 return geometry::RealRectangle2D(0,0,0,0);
168 return geometry::RealRectangle2D(nLeft,nTop, nRight, nBottom);
172 const css::awt::Rectangle& rBox1,
173 const css::awt::Rectangle& rBox2)
175 return rBox1.X+rBox1.Width <= rBox2.X
176 || rBox1.Y+rBox1.Height <= rBox2.Y
177 || rBox1.X >= rBox2.X+rBox2.Width
178 || rBox1.Y >= rBox2.Y+rBox2.Height;
182 const awt::Rectangle& rBox,
183 const Reference<rendering::XGraphicDevice>& rxDevice)
185 if ( ! rxDevice.is())
188 Sequence<Sequence<geometry::RealPoint2D> > aPoints
191 { o3tl::narrowing<double>(rBox.X), o3tl::narrowing<double>(rBox.Y) },
192 { o3tl::narrowing<double>(rBox.X), o3tl::narrowing<double>(rBox.Y+rBox.Height) },
193 { o3tl::narrowing<double>(rBox.X+rBox.Width), o3tl::narrowing<double>(rBox.Y+rBox.Height) },
194 { o3tl::narrowing<double>(rBox.X+rBox.Width), o3tl::narrowing<double>(rBox.Y) }
197 Reference<rendering::XLinePolyPolygon2D> xPolygon (
198 rxDevice->createCompatibleLinePolyPolygon(aPoints));
200 xPolygon->setClosed(0,
true);
206 const geometry::RealRectangle2D& rBox,
207 const Reference<rendering::XGraphicDevice>& rxDevice)
209 if ( ! rxDevice.is())
212 Sequence<Sequence<geometry::RealPoint2D> > aPoints
215 { rBox.X1, rBox.Y1 },
216 { rBox.X1, rBox.Y2 },
217 { rBox.X2, rBox.Y2 },
221 Reference<rendering::XLinePolyPolygon2D> xPolygon (
222 rxDevice->createCompatibleLinePolyPolygon(aPoints));
224 xPolygon->setClosed(0,
true);
230 const ::std::vector<css::awt::Rectangle>& rBoxes,
231 const Reference<rendering::XGraphicDevice>& rxDevice)
233 if ( ! rxDevice.is())
236 const sal_Int32
nCount (rBoxes.size());
237 Sequence<Sequence<geometry::RealPoint2D> > aPoints(nCount);
238 auto aPointsRange = asNonConstRange(aPoints);
241 const awt::Rectangle& rBox (rBoxes[nIndex]);
242 aPointsRange[
nIndex] = Sequence<geometry::RealPoint2D>
244 { o3tl::narrowing<double>(rBox.X), o3tl::narrowing<double>(rBox.Y) },
245 { o3tl::narrowing<double>(rBox.X), o3tl::narrowing<double>(rBox.Y+rBox.Height) },
246 { o3tl::narrowing<double>(rBox.X+rBox.Width), o3tl::narrowing<double>(rBox.Y+rBox.Height) },
247 { o3tl::narrowing<double>(rBox.X+rBox.Width), o3tl::narrowing<double>(rBox.Y) }
251 Reference<rendering::XLinePolyPolygon2D> xPolygon (
252 rxDevice->createCompatibleLinePolyPolygon(aPoints));
255 xPolygon->setClosed(nIndex,
true);
static css::awt::Rectangle TranslateRectangle(const css::awt::Rectangle &rBox, const sal_Int32 nXOffset, const sal_Int32 nYOffset)
static sal_Int32 Floor(const double nValue)
static css::geometry::RealRectangle2D Union(const css::geometry::RealRectangle2D &rBox1, const css::geometry::RealRectangle2D &rBox2)
static sal_Int32 Round(const double nValue)
static bool AreRectanglesDisjoint(const css::awt::Rectangle &rBox1, const css::awt::Rectangle &rBox2)
static bool IsInside(const css::geometry::RealRectangle2D &rBox, const css::geometry::RealPoint2D &rPoint)
static css::awt::Rectangle Intersection(const css::awt::Rectangle &rBox1, const css::awt::Rectangle &rBox2)
static sal_Int32 Ceil(const double nValue)
static css::awt::Rectangle ConvertRectangleWithConstantSize(const css::geometry::RealRectangle2D &rBox)
Convert the given rectangle to integer coordinates so that width and height remain constant when only...
static css::uno::Reference< css::rendering::XPolyPolygon2D > CreatePolygon(const css::awt::Rectangle &rBox, const css::uno::Reference< css::rendering::XGraphicDevice > &rxDevice)
static css::awt::Rectangle ConvertRectangle(const css::geometry::RealRectangle2D &rBox)
Return the bounding box with integer coordinates of the given rectangle.