Update ooo320-m1
[ooovba.git] / sdext / source / presenter / PresenterGeometryHelper.hxx
blob14ec88c29916bc5d48eaece2d6964ef327ea2383
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: PresenterGeometryHelper.hxx,v $
11 * $Revision: 1.4 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 #ifndef SDEXT_PRESENTER_PRESENTER_GEOMETRY_HELPER_HXX
33 #define SDEXT_PRESENTER_PRESENTER_GEOMETRY_HELPER_HXX
35 #include <com/sun/star/awt/Point.hpp>
36 #include <com/sun/star/awt/Rectangle.hpp>
37 #include <com/sun/star/awt/Size.hpp>
38 #include <com/sun/star/rendering/XGraphicDevice.hpp>
39 #include <com/sun/star/rendering/XPolyPolygon2D.hpp>
40 #include <vector>
42 namespace css = ::com::sun::star;
44 namespace sdext { namespace presenter {
46 /** Collection of geometry related convenience functions.
48 class PresenterGeometryHelper
50 public:
51 static sal_Int32 Round (const double nValue);
52 static sal_Int32 Floor (const double nValue);
53 static sal_Int32 Ceil (const double nValue);
55 /** Return the bounding box with integer coordinates of the given
56 rectangle. Note that due to different rounding of the left/top and
57 the right/bottom border the width of the resulting rectangle may
58 differ for different positions but constant width and height.
60 static css::awt::Rectangle ConvertRectangle (
61 const css::geometry::RealRectangle2D& rBox);
63 /** Convert the given rectangle to integer coordinates so that width and
64 height remain constant when only the position changes.
66 static css::awt::Rectangle ConvertRectangleWithConstantSize (
67 const css::geometry::RealRectangle2D& rBox);
69 static css::geometry::RealRectangle2D ConvertRectangle (
70 const css::awt::Rectangle& rBox);
72 // static css::awt::Size ConvertSize (
73 // const css::geometry::RealSize2D& rSize);
75 static css::awt::Rectangle TranslateRectangle (
76 const css::awt::Rectangle& rBox,
77 const sal_Int32 nXOffset,
78 const sal_Int32 nYOffset);
80 static css::awt::Rectangle Intersection (
81 const css::awt::Rectangle& rBox1,
82 const css::awt::Rectangle& rBox2);
84 static css::geometry::RealRectangle2D Intersection (
85 const css::geometry::RealRectangle2D& rBox1,
86 const css::geometry::RealRectangle2D& rBox2);
88 static bool IsInside (
89 const css::geometry::RealRectangle2D& rBox,
90 const css::geometry::RealPoint2D& rPoint);
92 /** Return whether rBox1 is completly inside rBox2.
94 static bool IsInside (
95 const css::awt::Rectangle& rBox1,
96 const css::awt::Rectangle& rBox2);
98 static css::awt::Rectangle Union (
99 const css::awt::Rectangle& rBox1,
100 const css::awt::Rectangle& rBox2);
102 static css::geometry::RealRectangle2D Union (
103 const css::geometry::RealRectangle2D& rBox1,
104 const css::geometry::RealRectangle2D& rBox2);
106 static bool AreRectanglesDisjoint (
107 const css::awt::Rectangle& rBox1,
108 const css::awt::Rectangle& rBox2);
110 static css::uno::Reference<css::rendering::XPolyPolygon2D> CreatePolygon(
111 const css::awt::Rectangle& rBox,
112 const css::uno::Reference<css::rendering::XGraphicDevice>& rxDevice);
114 static css::uno::Reference<css::rendering::XPolyPolygon2D> CreatePolygon(
115 const css::geometry::RealRectangle2D& rBox,
116 const css::uno::Reference<css::rendering::XGraphicDevice>& rxDevice);
118 static css::uno::Reference<css::rendering::XPolyPolygon2D> CreatePolygon(
119 const ::std::vector<css::awt::Rectangle>& rBoxes,
120 const css::uno::Reference<css::rendering::XGraphicDevice>& rxDevice);
122 /** Create a polygon for a rounded rectangle.
124 /* static css::uno::Reference<css::rendering::XPolyPolygon2D> CreatePolygon(
125 const css::awt::Rectangle& rBox,
126 const double nRadius,
127 const css::uno::Reference<css::rendering::XGraphicDevice>&
128 rxDevice);
134 #endif