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 _CHART2_RELATIVEPOSITIONHELPER_HXX 29 #define _CHART2_RELATIVEPOSITIONHELPER_HXX 30 31 #include <com/sun/star/chart2/RelativePosition.hpp> 32 #include <com/sun/star/chart2/RelativeSize.hpp> 33 #include <com/sun/star/drawing/Alignment.hpp> 34 #include <com/sun/star/awt/Point.hpp> 35 #include <com/sun/star/awt/Size.hpp> 36 #include "charttoolsdllapi.hxx" 37 38 //............................................................................. 39 namespace chart 40 { 41 //............................................................................. 42 43 //----------------------------------------------------------------------------- 44 /** 45 */ 46 47 class OOO_DLLPUBLIC_CHARTTOOLS RelativePositionHelper 48 { 49 public: 50 /** returns the upper left corner of an object that has size aObjectSize and 51 where the point indicated by aAnchor has coordinates indicated by aPoint 52 ( e.g. if aAnchor equals BOTTOM_LEFT, aPoint describes the 53 coordinates of the bottom left corner of an object with size aObjectSize ) 54 */ 55 static ::com::sun::star::awt::Point 56 getUpperLeftCornerOfAnchoredObject( 57 ::com::sun::star::awt::Point aPoint, 58 ::com::sun::star::awt::Size aObjectSize, 59 ::com::sun::star::drawing::Alignment aAnchor ); 60 61 /** returns the center of an object that has size aObjectSize and 62 where the point indicated by aAnchor has coordinates indicated by aPoint 63 ( e.g. if aAnchor equals BOTTOM_LEFT, aPoint describes the 64 coordinates of the bottom left corner of an object with size aObjectSize ) 65 */ 66 static ::com::sun::star::awt::Point 67 getCenterOfAnchoredObject( 68 ::com::sun::star::awt::Point aPoint, 69 ::com::sun::star::awt::Size aUnrotatedObjectSize, 70 ::com::sun::star::drawing::Alignment aAnchor, 71 double fAnglePi ); 72 73 /** Returns a relative position that is the same point after the anchor has 74 been changed to the given one. The passed object size is taken into 75 account for shifting the position. 76 */ 77 SAL_DLLPRIVATE static ::com::sun::star::chart2::RelativePosition 78 getReanchoredPosition( 79 const ::com::sun::star::chart2::RelativePosition & rPosition, 80 const ::com::sun::star::chart2::RelativeSize & rObjectSize, 81 ::com::sun::star::drawing::Alignment aNewAnchor ); 82 83 /** grows a relative size about the given amount and shifts the given 84 position such that the resize is relative to the former rectangle's 85 center. 86 87 @param bCheck If </sal_True>, the resize is only done, if after 88 transformation, the position and size are within the bounds [0,1]. 89 90 @return </sal_True>, if changes were applied. 91 92 <p>That means, if the position's alignment is center, the position will 93 not change at all.</p> 94 */ 95 static bool centerGrow( 96 ::com::sun::star::chart2::RelativePosition & rInOutPosition, 97 ::com::sun::star::chart2::RelativeSize & rInOutSize, 98 double fAmountX, double fAmountY, 99 bool bCheck = true ); 100 101 /** shifts a relative position about the given amount 102 103 @param bCheck If </sal_True>, the shift is only done, if after 104 transformation, the object represented by the position 105 rInOutPosition and its size rObjectSize the position and size are 106 within the bounds [0,1]. 107 108 @return </sal_True>, if changes were applied. 109 */ 110 static bool moveObject( 111 ::com::sun::star::chart2::RelativePosition & rInOutPosition, 112 const ::com::sun::star::chart2::RelativeSize & rObjectSize, 113 double fAmountX, double fAmountY, 114 bool bCheck = true ); 115 }; 116 117 //............................................................................. 118 } //namespace chart 119 //............................................................................. 120 #endif 121