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/Rectangle.hpp>
24 #include <com/sun/star/rendering/XGraphicDevice.hpp>
25 #include <com/sun/star/rendering/XPolyPolygon2D.hpp>
26 #include <com/sun/star/geometry/RealRectangle2D.hpp>
29 namespace sdext
{ namespace presenter
{
31 /** Collection of geometry related convenience functions.
33 class PresenterGeometryHelper
36 static sal_Int32
Round (const double nValue
);
37 static sal_Int32
Floor (const double nValue
);
38 static sal_Int32
Ceil (const double nValue
);
40 /** Return the bounding box with integer coordinates of the given
41 rectangle. Note that due to different rounding of the left/top and
42 the right/bottom border the width of the resulting rectangle may
43 differ for different positions but constant width and height.
45 static css::awt::Rectangle
ConvertRectangle (
46 const css::geometry::RealRectangle2D
& rBox
);
48 /** Convert the given rectangle to integer coordinates so that width and
49 height remain constant when only the position changes.
51 static css::awt::Rectangle
ConvertRectangleWithConstantSize (
52 const css::geometry::RealRectangle2D
& rBox
);
54 static css::geometry::RealRectangle2D
ConvertRectangle (
55 const css::awt::Rectangle
& rBox
);
57 // static css::awt::Size ConvertSize (
58 // const css::geometry::RealSize2D& rSize);
60 static css::awt::Rectangle
TranslateRectangle (
61 const css::awt::Rectangle
& rBox
,
62 const sal_Int32 nXOffset
,
63 const sal_Int32 nYOffset
);
65 static css::awt::Rectangle
Intersection (
66 const css::awt::Rectangle
& rBox1
,
67 const css::awt::Rectangle
& rBox2
);
69 static css::geometry::RealRectangle2D
Intersection (
70 const css::geometry::RealRectangle2D
& rBox1
,
71 const css::geometry::RealRectangle2D
& rBox2
);
73 static bool IsInside (
74 const css::geometry::RealRectangle2D
& rBox
,
75 const css::geometry::RealPoint2D
& rPoint
);
77 /** Return whether rBox1 is completely inside rBox2.
79 static bool IsInside (
80 const css::awt::Rectangle
& rBox1
,
81 const css::awt::Rectangle
& rBox2
);
83 static css::geometry::RealRectangle2D
Union (
84 const css::geometry::RealRectangle2D
& rBox1
,
85 const css::geometry::RealRectangle2D
& rBox2
);
87 static bool AreRectanglesDisjoint (
88 const css::awt::Rectangle
& rBox1
,
89 const css::awt::Rectangle
& rBox2
);
91 static css::uno::Reference
<css::rendering::XPolyPolygon2D
> CreatePolygon(
92 const css::awt::Rectangle
& rBox
,
93 const css::uno::Reference
<css::rendering::XGraphicDevice
>& rxDevice
);
95 static css::uno::Reference
<css::rendering::XPolyPolygon2D
> CreatePolygon(
96 const css::geometry::RealRectangle2D
& rBox
,
97 const css::uno::Reference
<css::rendering::XGraphicDevice
>& rxDevice
);
99 static css::uno::Reference
<css::rendering::XPolyPolygon2D
> CreatePolygon(
100 const ::std::vector
<css::awt::Rectangle
>& rBoxes
,
101 const css::uno::Reference
<css::rendering::XGraphicDevice
>& rxDevice
);
103 /** Create a polygon for a rounded rectangle.
105 /* static css::uno::Reference<css::rendering::XPolyPolygon2D> CreatePolygon(
106 const css::awt::Rectangle& rBox,
107 const double nRadius,
108 const css::uno::Reference<css::rendering::XGraphicDevice>&
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */