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 .
22 #include <com/sun/star/chart2/RelativePosition.hpp>
23 #include <com/sun/star/drawing/Alignment.hpp>
24 #include <com/sun/star/awt/Point.hpp>
25 #include "charttoolsdllapi.hxx"
27 namespace com::sun::star::awt
{ struct Size
; }
28 namespace com::sun::star::chart2
{ struct RelativeSize
; }
33 class OOO_DLLPUBLIC_CHARTTOOLS RelativePositionHelper
36 /** returns the upper left corner of an object that has size aObjectSize and
37 where the point indicated by aAnchor has coordinates indicated by aPoint
38 ( e.g. if aAnchor equals BOTTOM_LEFT, aPoint describes the
39 coordinates of the bottom left corner of an object with size aObjectSize )
41 static css::awt::Point
42 getUpperLeftCornerOfAnchoredObject(
43 css::awt::Point aPoint
,
44 css::awt::Size aObjectSize
,
45 css::drawing::Alignment aAnchor
);
47 /** returns the center of an object that has size aObjectSize and
48 where the point indicated by aAnchor has coordinates indicated by aPoint
49 ( e.g. if aAnchor equals BOTTOM_LEFT, aPoint describes the
50 coordinates of the bottom left corner of an object with size aObjectSize )
52 static css::awt::Point
53 getCenterOfAnchoredObject(
54 css::awt::Point aPoint
,
55 css::awt::Size aUnrotatedObjectSize
,
56 css::drawing::Alignment aAnchor
,
59 /** Returns a relative position that is the same point after the anchor has
60 been changed to the given one. The passed object size is taken into
61 account for shifting the position.
63 SAL_DLLPRIVATE
static css::chart2::RelativePosition
64 getReanchoredPosition(
65 const css::chart2::RelativePosition
& rPosition
,
66 const css::chart2::RelativeSize
& rObjectSize
,
67 css::drawing::Alignment aNewAnchor
);
69 /** grows a relative size about the given amount and shifts the given
70 position such that the resize is relative to the former rectangle's
73 The resize is only done, if after
74 transformation, the position and size are within the bounds [0,1].
76 @return </sal_True>, if changes were applied.
78 <p>That means, if the position's alignment is center, the position will
79 not change at all.</p>
81 static bool centerGrow(
82 css::chart2::RelativePosition
& rInOutPosition
,
83 css::chart2::RelativeSize
& rInOutSize
,
84 double fAmountX
, double fAmountY
);
86 /** shifts a relative position about the given amount
88 The shift is only done, if after
89 transformation, the object represented by the position
90 rInOutPosition and its size rObjectSize the position and size are
91 within the bounds [0,1].
93 @return </sal_True>, if changes were applied.
95 static bool moveObject(
96 css::chart2::RelativePosition
& rInOutPosition
,
97 const css::chart2::RelativeSize
& rObjectSize
,
98 double fAmountX
, double fAmountY
);
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */