1*06bcd5d2SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*06bcd5d2SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*06bcd5d2SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*06bcd5d2SAndrew Rist  * distributed with this work for additional information
6*06bcd5d2SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*06bcd5d2SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*06bcd5d2SAndrew Rist  * "License"); you may not use this file except in compliance
9*06bcd5d2SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*06bcd5d2SAndrew Rist  *
11*06bcd5d2SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*06bcd5d2SAndrew Rist  *
13*06bcd5d2SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*06bcd5d2SAndrew Rist  * software distributed under the License is distributed on an
15*06bcd5d2SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*06bcd5d2SAndrew Rist  * KIND, either express or implied.  See the License for the
17*06bcd5d2SAndrew Rist  * specific language governing permissions and limitations
18*06bcd5d2SAndrew Rist  * under the License.
19*06bcd5d2SAndrew Rist  *
20*06bcd5d2SAndrew Rist  *************************************************************/
21*06bcd5d2SAndrew Rist 
22*06bcd5d2SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef SDEXT_PRESENTER_PRESENTER_GEOMETRY_HELPER_HXX
25cdf0e10cSrcweir #define SDEXT_PRESENTER_PRESENTER_GEOMETRY_HELPER_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/awt/Point.hpp>
28cdf0e10cSrcweir #include <com/sun/star/awt/Rectangle.hpp>
29cdf0e10cSrcweir #include <com/sun/star/awt/Size.hpp>
30cdf0e10cSrcweir #include <com/sun/star/rendering/XGraphicDevice.hpp>
31cdf0e10cSrcweir #include <com/sun/star/rendering/XPolyPolygon2D.hpp>
32cdf0e10cSrcweir #include <com/sun/star/geometry/RealRectangle2D.hpp>
33cdf0e10cSrcweir #include <vector>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir namespace css = ::com::sun::star;
36cdf0e10cSrcweir 
37cdf0e10cSrcweir namespace sdext { namespace presenter {
38cdf0e10cSrcweir 
39cdf0e10cSrcweir /** Collection of geometry related convenience functions.
40cdf0e10cSrcweir */
41cdf0e10cSrcweir class PresenterGeometryHelper
42cdf0e10cSrcweir {
43cdf0e10cSrcweir public:
44cdf0e10cSrcweir     static sal_Int32 Round (const double nValue);
45cdf0e10cSrcweir     static sal_Int32 Floor (const double nValue);
46cdf0e10cSrcweir     static sal_Int32 Ceil (const double nValue);
47cdf0e10cSrcweir 
48cdf0e10cSrcweir     /** Return the bounding box with integer coordinates of the given
49cdf0e10cSrcweir         rectangle.  Note that due to different rounding of the left/top and
50cdf0e10cSrcweir         the right/bottom border the width of the resulting rectangle may
51cdf0e10cSrcweir         differ for different positions but constant width and height.
52cdf0e10cSrcweir     */
53cdf0e10cSrcweir     static css::awt::Rectangle ConvertRectangle (
54cdf0e10cSrcweir         const css::geometry::RealRectangle2D& rBox);
55cdf0e10cSrcweir 
56cdf0e10cSrcweir     /** Convert the given rectangle to integer coordinates so that width and
57cdf0e10cSrcweir         height remain constant when only the position changes.
58cdf0e10cSrcweir     */
59cdf0e10cSrcweir     static css::awt::Rectangle ConvertRectangleWithConstantSize (
60cdf0e10cSrcweir         const css::geometry::RealRectangle2D& rBox);
61cdf0e10cSrcweir 
62cdf0e10cSrcweir     static css::geometry::RealRectangle2D ConvertRectangle (
63cdf0e10cSrcweir         const css::awt::Rectangle& rBox);
64cdf0e10cSrcweir 
65cdf0e10cSrcweir     //    static css::awt::Size ConvertSize (
66cdf0e10cSrcweir     //        const css::geometry::RealSize2D& rSize);
67cdf0e10cSrcweir 
68cdf0e10cSrcweir     static css::awt::Rectangle TranslateRectangle (
69cdf0e10cSrcweir         const css::awt::Rectangle& rBox,
70cdf0e10cSrcweir         const sal_Int32 nXOffset,
71cdf0e10cSrcweir         const sal_Int32 nYOffset);
72cdf0e10cSrcweir 
73cdf0e10cSrcweir     static css::awt::Rectangle Intersection (
74cdf0e10cSrcweir         const css::awt::Rectangle& rBox1,
75cdf0e10cSrcweir         const css::awt::Rectangle& rBox2);
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     static css::geometry::RealRectangle2D Intersection (
78cdf0e10cSrcweir         const css::geometry::RealRectangle2D& rBox1,
79cdf0e10cSrcweir         const css::geometry::RealRectangle2D& rBox2);
80cdf0e10cSrcweir 
81cdf0e10cSrcweir     static bool IsInside (
82cdf0e10cSrcweir         const css::geometry::RealRectangle2D& rBox,
83cdf0e10cSrcweir         const css::geometry::RealPoint2D& rPoint);
84cdf0e10cSrcweir 
85cdf0e10cSrcweir     /** Return whether rBox1 is completly inside rBox2.
86cdf0e10cSrcweir     */
87cdf0e10cSrcweir     static bool IsInside (
88cdf0e10cSrcweir         const css::awt::Rectangle& rBox1,
89cdf0e10cSrcweir         const css::awt::Rectangle& rBox2);
90cdf0e10cSrcweir 
91cdf0e10cSrcweir     static css::awt::Rectangle Union (
92cdf0e10cSrcweir         const css::awt::Rectangle& rBox1,
93cdf0e10cSrcweir         const css::awt::Rectangle& rBox2);
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     static css::geometry::RealRectangle2D Union (
96cdf0e10cSrcweir         const css::geometry::RealRectangle2D& rBox1,
97cdf0e10cSrcweir         const css::geometry::RealRectangle2D& rBox2);
98cdf0e10cSrcweir 
99cdf0e10cSrcweir     static bool AreRectanglesDisjoint (
100cdf0e10cSrcweir         const css::awt::Rectangle& rBox1,
101cdf0e10cSrcweir         const css::awt::Rectangle& rBox2);
102cdf0e10cSrcweir 
103cdf0e10cSrcweir     static css::uno::Reference<css::rendering::XPolyPolygon2D> CreatePolygon(
104cdf0e10cSrcweir         const css::awt::Rectangle& rBox,
105cdf0e10cSrcweir         const css::uno::Reference<css::rendering::XGraphicDevice>& rxDevice);
106cdf0e10cSrcweir 
107cdf0e10cSrcweir     static css::uno::Reference<css::rendering::XPolyPolygon2D> CreatePolygon(
108cdf0e10cSrcweir         const css::geometry::RealRectangle2D& rBox,
109cdf0e10cSrcweir         const css::uno::Reference<css::rendering::XGraphicDevice>& rxDevice);
110cdf0e10cSrcweir 
111cdf0e10cSrcweir     static css::uno::Reference<css::rendering::XPolyPolygon2D> CreatePolygon(
112cdf0e10cSrcweir         const ::std::vector<css::awt::Rectangle>& rBoxes,
113cdf0e10cSrcweir         const css::uno::Reference<css::rendering::XGraphicDevice>& rxDevice);
114cdf0e10cSrcweir 
115cdf0e10cSrcweir     /** Create a polygon for a rounded rectangle.
116cdf0e10cSrcweir     */
117cdf0e10cSrcweir     /*    static css::uno::Reference<css::rendering::XPolyPolygon2D> CreatePolygon(
118cdf0e10cSrcweir         const css::awt::Rectangle& rBox,
119cdf0e10cSrcweir         const double nRadius,
120cdf0e10cSrcweir         const css::uno::Reference<css::rendering::XGraphicDevice>&
121cdf0e10cSrcweir         rxDevice);
122cdf0e10cSrcweir     */
123cdf0e10cSrcweir };
124cdf0e10cSrcweir 
125cdf0e10cSrcweir } }
126cdf0e10cSrcweir 
127cdf0e10cSrcweir #endif
128