1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_CHART2_SOURCE_INC_RELATIVEPOSITIONHELPER_HXX
21 #define INCLUDED_CHART2_SOURCE_INC_RELATIVEPOSITIONHELPER_HXX
23 #include <com/sun/star/chart2/RelativePosition.hpp>
24 #include <com/sun/star/chart2/RelativeSize.hpp>
25 #include <com/sun/star/drawing/Alignment.hpp>
26 #include <com/sun/star/awt/Point.hpp>
27 #include <com/sun/star/awt/Size.hpp>
28 #include "charttoolsdllapi.hxx"
36 class OOO_DLLPUBLIC_CHARTTOOLS RelativePositionHelper
39 /** returns the upper left corner of an object that has size aObjectSize and
40 where the point indicated by aAnchor has coordinates indicated by aPoint
41 ( e.g. if aAnchor equals BOTTOM_LEFT, aPoint describes the
42 coordinates of the bottom left corner of an object with size aObjectSize )
44 static ::com::sun::star::awt::Point
45 getUpperLeftCornerOfAnchoredObject(
46 ::com::sun::star::awt::Point aPoint
,
47 ::com::sun::star::awt::Size aObjectSize
,
48 ::com::sun::star::drawing::Alignment aAnchor
);
50 /** returns the center 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 )
55 static ::com::sun::star::awt::Point
56 getCenterOfAnchoredObject(
57 ::com::sun::star::awt::Point aPoint
,
58 ::com::sun::star::awt::Size aUnrotatedObjectSize
,
59 ::com::sun::star::drawing::Alignment aAnchor
,
62 /** Returns a relative position that is the same point after the anchor has
63 been changed to the given one. The passed object size is taken into
64 account for shifting the position.
66 SAL_DLLPRIVATE
static ::com::sun::star::chart2::RelativePosition
67 getReanchoredPosition(
68 const ::com::sun::star::chart2::RelativePosition
& rPosition
,
69 const ::com::sun::star::chart2::RelativeSize
& rObjectSize
,
70 ::com::sun::star::drawing::Alignment aNewAnchor
);
72 /** grows a relative size about the given amount and shifts the given
73 position such that the resize is relative to the former rectangle's
76 @param bCheck If </sal_True>, the resize is only done, if after
77 transformation, the position and size are within the bounds [0,1].
79 @return </sal_True>, if changes were applied.
81 <p>That means, if the position's alignment is center, the position will
82 not change at all.</p>
84 static bool centerGrow(
85 ::com::sun::star::chart2::RelativePosition
& rInOutPosition
,
86 ::com::sun::star::chart2::RelativeSize
& rInOutSize
,
87 double fAmountX
, double fAmountY
,
90 /** shifts a relative position about the given amount
92 @param bCheck If </sal_True>, the shift is only done, if after
93 transformation, the object represented by the position
94 rInOutPosition and its size rObjectSize the position and size are
95 within the bounds [0,1].
97 @return </sal_True>, if changes were applied.
99 static bool moveObject(
100 ::com::sun::star::chart2::RelativePosition
& rInOutPosition
,
101 const ::com::sun::star::chart2::RelativeSize
& rObjectSize
,
102 double fAmountX
, double fAmountY
,
103 bool bCheck
= true );
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */