1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERGEOMETRYHELPER_HXX
21 #define INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERGEOMETRYHELPER_HXX
23 #include <com/sun/star/awt/Point.hpp>
24 #include <com/sun/star/awt/Rectangle.hpp>
25 #include <com/sun/star/awt/Size.hpp>
26 #include <com/sun/star/rendering/XGraphicDevice.hpp>
27 #include <com/sun/star/rendering/XPolyPolygon2D.hpp>
28 #include <com/sun/star/geometry/RealRectangle2D.hpp>
31 namespace sdext
{ namespace presenter
{
33 /** Collection of geometry related convenience functions.
35 class PresenterGeometryHelper
38 static sal_Int32
Round (const double nValue
);
39 static sal_Int32
Floor (const double nValue
);
40 static sal_Int32
Ceil (const double nValue
);
42 /** Return the bounding box with integer coordinates of the given
43 rectangle. Note that due to different rounding of the left/top and
44 the right/bottom border the width of the resulting rectangle may
45 differ for different positions but constant width and height.
47 static css::awt::Rectangle
ConvertRectangle (
48 const css::geometry::RealRectangle2D
& rBox
);
50 /** Convert the given rectangle to integer coordinates so that width and
51 height remain constant when only the position changes.
53 static css::awt::Rectangle
ConvertRectangleWithConstantSize (
54 const css::geometry::RealRectangle2D
& rBox
);
56 static css::geometry::RealRectangle2D
ConvertRectangle (
57 const css::awt::Rectangle
& rBox
);
59 // static css::awt::Size ConvertSize (
60 // const css::geometry::RealSize2D& rSize);
62 static css::awt::Rectangle
TranslateRectangle (
63 const css::awt::Rectangle
& rBox
,
64 const sal_Int32 nXOffset
,
65 const sal_Int32 nYOffset
);
67 static css::awt::Rectangle
Intersection (
68 const css::awt::Rectangle
& rBox1
,
69 const css::awt::Rectangle
& rBox2
);
71 static css::geometry::RealRectangle2D
Intersection (
72 const css::geometry::RealRectangle2D
& rBox1
,
73 const css::geometry::RealRectangle2D
& rBox2
);
75 static bool IsInside (
76 const css::geometry::RealRectangle2D
& rBox
,
77 const css::geometry::RealPoint2D
& rPoint
);
79 /** Return whether rBox1 is completely inside rBox2.
81 static bool IsInside (
82 const css::awt::Rectangle
& rBox1
,
83 const css::awt::Rectangle
& rBox2
);
85 static css::geometry::RealRectangle2D
Union (
86 const css::geometry::RealRectangle2D
& rBox1
,
87 const css::geometry::RealRectangle2D
& rBox2
);
89 static bool AreRectanglesDisjoint (
90 const css::awt::Rectangle
& rBox1
,
91 const css::awt::Rectangle
& rBox2
);
93 static css::uno::Reference
<css::rendering::XPolyPolygon2D
> CreatePolygon(
94 const css::awt::Rectangle
& rBox
,
95 const css::uno::Reference
<css::rendering::XGraphicDevice
>& rxDevice
);
97 static css::uno::Reference
<css::rendering::XPolyPolygon2D
> CreatePolygon(
98 const css::geometry::RealRectangle2D
& rBox
,
99 const css::uno::Reference
<css::rendering::XGraphicDevice
>& rxDevice
);
101 static css::uno::Reference
<css::rendering::XPolyPolygon2D
> CreatePolygon(
102 const ::std::vector
<css::awt::Rectangle
>& rBoxes
,
103 const css::uno::Reference
<css::rendering::XGraphicDevice
>& rxDevice
);
105 /** Create a polygon for a rounded rectangle.
107 /* static css::uno::Reference<css::rendering::XPolyPolygon2D> CreatePolygon(
108 const css::awt::Rectangle& rBox,
109 const double nRadius,
110 const css::uno::Reference<css::rendering::XGraphicDevice>&
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */