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