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