1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _CHART2_RELATIVEPOSITIONHELPER_HXX 25 #define _CHART2_RELATIVEPOSITIONHELPER_HXX 26 27 #include <com/sun/star/chart2/RelativePosition.hpp> 28 #include <com/sun/star/chart2/RelativeSize.hpp> 29 #include <com/sun/star/drawing/Alignment.hpp> 30 #include <com/sun/star/awt/Point.hpp> 31 #include <com/sun/star/awt/Size.hpp> 32 #include "charttoolsdllapi.hxx" 33 34 //............................................................................. 35 namespace chart 36 { 37 //............................................................................. 38 39 //----------------------------------------------------------------------------- 40 /** 41 */ 42 43 class OOO_DLLPUBLIC_CHARTTOOLS RelativePositionHelper 44 { 45 public: 46 /** returns the upper left corner of an object that has size aObjectSize and 47 where the point indicated by aAnchor has coordinates indicated by aPoint 48 ( e.g. if aAnchor equals BOTTOM_LEFT, aPoint describes the 49 coordinates of the bottom left corner of an object with size aObjectSize ) 50 */ 51 static ::com::sun::star::awt::Point 52 getUpperLeftCornerOfAnchoredObject( 53 ::com::sun::star::awt::Point aPoint, 54 ::com::sun::star::awt::Size aObjectSize, 55 ::com::sun::star::drawing::Alignment aAnchor ); 56 57 /** returns the center of an object that has size aObjectSize and 58 where the point indicated by aAnchor has coordinates indicated by aPoint 59 ( e.g. if aAnchor equals BOTTOM_LEFT, aPoint describes the 60 coordinates of the bottom left corner of an object with size aObjectSize ) 61 */ 62 static ::com::sun::star::awt::Point 63 getCenterOfAnchoredObject( 64 ::com::sun::star::awt::Point aPoint, 65 ::com::sun::star::awt::Size aUnrotatedObjectSize, 66 ::com::sun::star::drawing::Alignment aAnchor, 67 double fAnglePi ); 68 69 /** Returns a relative position that is the same point after the anchor has 70 been changed to the given one. The passed object size is taken into 71 account for shifting the position. 72 */ 73 SAL_DLLPRIVATE static ::com::sun::star::chart2::RelativePosition 74 getReanchoredPosition( 75 const ::com::sun::star::chart2::RelativePosition & rPosition, 76 const ::com::sun::star::chart2::RelativeSize & rObjectSize, 77 ::com::sun::star::drawing::Alignment aNewAnchor ); 78 79 /** grows a relative size about the given amount and shifts the given 80 position such that the resize is relative to the former rectangle's 81 center. 82 83 @param bCheck If </sal_True>, the resize is only done, if after 84 transformation, the position and size are within the bounds [0,1]. 85 86 @return </sal_True>, if changes were applied. 87 88 <p>That means, if the position's alignment is center, the position will 89 not change at all.</p> 90 */ 91 static bool centerGrow( 92 ::com::sun::star::chart2::RelativePosition & rInOutPosition, 93 ::com::sun::star::chart2::RelativeSize & rInOutSize, 94 double fAmountX, double fAmountY, 95 bool bCheck = true ); 96 97 /** shifts a relative position about the given amount 98 99 @param bCheck If </sal_True>, the shift is only done, if after 100 transformation, the object represented by the position 101 rInOutPosition and its size rObjectSize the position and size are 102 within the bounds [0,1]. 103 104 @return </sal_True>, if changes were applied. 105 */ 106 static bool moveObject( 107 ::com::sun::star::chart2::RelativePosition & rInOutPosition, 108 const ::com::sun::star::chart2::RelativeSize & rObjectSize, 109 double fAmountX, double fAmountY, 110 bool bCheck = true ); 111 }; 112 113 //............................................................................. 114 } //namespace chart 115 //............................................................................. 116 #endif 117