1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: RelativePositionHelper.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _CHART2_RELATIVEPOSITIONHELPER_HXX
32 #define _CHART2_RELATIVEPOSITIONHELPER_HXX
34 #include <com/sun/star/chart2/RelativePosition.hpp>
35 #include <com/sun/star/chart2/RelativeSize.hpp>
36 #include <com/sun/star/drawing/Alignment.hpp>
37 #include <com/sun/star/awt/Point.hpp>
38 #include <com/sun/star/awt/Size.hpp>
39 #include "charttoolsdllapi.hxx"
41 //.............................................................................
44 //.............................................................................
46 //-----------------------------------------------------------------------------
50 class OOO_DLLPUBLIC_CHARTTOOLS RelativePositionHelper
53 /** returns the upper left corner of an object that has size aObjectSize and
54 where the point indicated by aAnchor has coordinates indicated by aPoint
55 ( e.g. if aAnchor equals BOTTOM_LEFT, aPoint describes the
56 coordinates of the bottom left corner of an object with size aObjectSize )
58 static ::com::sun::star::awt::Point
59 getUpperLeftCornerOfAnchoredObject(
60 ::com::sun::star::awt::Point aPoint
,
61 ::com::sun::star::awt::Size aObjectSize
,
62 ::com::sun::star::drawing::Alignment aAnchor
);
64 /** returns the center of an object that has size aObjectSize and
65 where the point indicated by aAnchor has coordinates indicated by aPoint
66 ( e.g. if aAnchor equals BOTTOM_LEFT, aPoint describes the
67 coordinates of the bottom left corner of an object with size aObjectSize )
69 static ::com::sun::star::awt::Point
70 getCenterOfAnchoredObject(
71 ::com::sun::star::awt::Point aPoint
,
72 ::com::sun::star::awt::Size aUnrotatedObjectSize
,
73 ::com::sun::star::drawing::Alignment aAnchor
,
76 /** Returns a relative position that is the same point after the anchor has
77 been changed to the given one. The passed object size is taken into
78 account for shifting the position.
80 SAL_DLLPRIVATE
static ::com::sun::star::chart2::RelativePosition
81 getReanchoredPosition(
82 const ::com::sun::star::chart2::RelativePosition
& rPosition
,
83 const ::com::sun::star::chart2::RelativeSize
& rObjectSize
,
84 ::com::sun::star::drawing::Alignment aNewAnchor
);
86 /** grows a relative size about the given amount and shifts the given
87 position such that the resize is relative to the former rectangle's
90 @param bCheck If </TRUE>, the resize is only done, if after
91 transformation, the position and size are within the bounds [0,1].
93 @return </TRUE>, if changes were applied.
95 <p>That means, if the position's alignment is center, the position will
96 not change at all.</p>
98 static bool centerGrow(
99 ::com::sun::star::chart2::RelativePosition
& rInOutPosition
,
100 ::com::sun::star::chart2::RelativeSize
& rInOutSize
,
101 double fAmountX
, double fAmountY
,
102 bool bCheck
= true );
104 /** shifts a relative position about the given amount
106 @param bCheck If </TRUE>, the shift is only done, if after
107 transformation, the object represented by the position
108 rInOutPosition and its size rObjectSize the position and size are
109 within the bounds [0,1].
111 @return </TRUE>, if changes were applied.
113 static bool moveObject(
114 ::com::sun::star::chart2::RelativePosition
& rInOutPosition
,
115 const ::com::sun::star::chart2::RelativeSize
& rObjectSize
,
116 double fAmountX
, double fAmountY
,
117 bool bCheck
= true );
120 //.............................................................................
122 //.............................................................................