1*cde9e8dcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*cde9e8dcSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*cde9e8dcSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*cde9e8dcSAndrew Rist * distributed with this work for additional information
6*cde9e8dcSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*cde9e8dcSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*cde9e8dcSAndrew Rist * "License"); you may not use this file except in compliance
9*cde9e8dcSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*cde9e8dcSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*cde9e8dcSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*cde9e8dcSAndrew Rist * software distributed under the License is distributed on an
15*cde9e8dcSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*cde9e8dcSAndrew Rist * KIND, either express or implied. See the License for the
17*cde9e8dcSAndrew Rist * specific language governing permissions and limitations
18*cde9e8dcSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*cde9e8dcSAndrew Rist *************************************************************/
21*cde9e8dcSAndrew Rist
22*cde9e8dcSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_chart2.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "RelativePositionHelper.hxx"
28cdf0e10cSrcweir #include <rtl/math.hxx>
29cdf0e10cSrcweir
30cdf0e10cSrcweir using namespace ::com::sun::star;
31cdf0e10cSrcweir
32cdf0e10cSrcweir namespace chart
33cdf0e10cSrcweir {
34cdf0e10cSrcweir
getReanchoredPosition(const chart2::RelativePosition & rPosition,const chart2::RelativeSize & rObjectSize,drawing::Alignment aNewAnchor)35cdf0e10cSrcweir chart2::RelativePosition RelativePositionHelper::getReanchoredPosition(
36cdf0e10cSrcweir const chart2::RelativePosition & rPosition,
37cdf0e10cSrcweir const chart2::RelativeSize & rObjectSize,
38cdf0e10cSrcweir drawing::Alignment aNewAnchor )
39cdf0e10cSrcweir {
40cdf0e10cSrcweir chart2::RelativePosition aResult( rPosition );
41cdf0e10cSrcweir if( rPosition.Anchor != aNewAnchor )
42cdf0e10cSrcweir {
43cdf0e10cSrcweir sal_Int32 nShiftHalfWidths = 0;
44cdf0e10cSrcweir sal_Int32 nShiftHalfHeights = 0;
45cdf0e10cSrcweir
46cdf0e10cSrcweir // normalize to top-left
47cdf0e10cSrcweir switch( rPosition.Anchor )
48cdf0e10cSrcweir {
49cdf0e10cSrcweir case drawing::Alignment_TOP_LEFT:
50cdf0e10cSrcweir break;
51cdf0e10cSrcweir case drawing::Alignment_LEFT:
52cdf0e10cSrcweir nShiftHalfHeights -= 1;
53cdf0e10cSrcweir break;
54cdf0e10cSrcweir case drawing::Alignment_BOTTOM_LEFT:
55cdf0e10cSrcweir nShiftHalfHeights -= 2;
56cdf0e10cSrcweir break;
57cdf0e10cSrcweir case drawing::Alignment_TOP:
58cdf0e10cSrcweir nShiftHalfWidths -= 1;
59cdf0e10cSrcweir break;
60cdf0e10cSrcweir case drawing::Alignment_CENTER:
61cdf0e10cSrcweir nShiftHalfWidths -= 1;
62cdf0e10cSrcweir nShiftHalfHeights -= 1;
63cdf0e10cSrcweir break;
64cdf0e10cSrcweir case drawing::Alignment_BOTTOM:
65cdf0e10cSrcweir nShiftHalfWidths -= 1;
66cdf0e10cSrcweir nShiftHalfHeights -= 2;
67cdf0e10cSrcweir break;
68cdf0e10cSrcweir case drawing::Alignment_TOP_RIGHT:
69cdf0e10cSrcweir nShiftHalfWidths -= 2;
70cdf0e10cSrcweir break;
71cdf0e10cSrcweir case drawing::Alignment_RIGHT:
72cdf0e10cSrcweir nShiftHalfWidths -= 2;
73cdf0e10cSrcweir nShiftHalfHeights -= 1;
74cdf0e10cSrcweir break;
75cdf0e10cSrcweir case drawing::Alignment_BOTTOM_RIGHT:
76cdf0e10cSrcweir nShiftHalfWidths -= 2;
77cdf0e10cSrcweir nShiftHalfHeights -= 2;
78cdf0e10cSrcweir break;
79cdf0e10cSrcweir case drawing::Alignment_MAKE_FIXED_SIZE:
80cdf0e10cSrcweir break;
81cdf0e10cSrcweir }
82cdf0e10cSrcweir
83cdf0e10cSrcweir // transform
84cdf0e10cSrcweir switch( aNewAnchor )
85cdf0e10cSrcweir {
86cdf0e10cSrcweir case drawing::Alignment_TOP_LEFT:
87cdf0e10cSrcweir break;
88cdf0e10cSrcweir case drawing::Alignment_LEFT:
89cdf0e10cSrcweir nShiftHalfHeights += 1;
90cdf0e10cSrcweir break;
91cdf0e10cSrcweir case drawing::Alignment_BOTTOM_LEFT:
92cdf0e10cSrcweir nShiftHalfHeights += 2;
93cdf0e10cSrcweir break;
94cdf0e10cSrcweir case drawing::Alignment_TOP:
95cdf0e10cSrcweir nShiftHalfWidths += 1;
96cdf0e10cSrcweir break;
97cdf0e10cSrcweir case drawing::Alignment_CENTER:
98cdf0e10cSrcweir nShiftHalfWidths += 1;
99cdf0e10cSrcweir nShiftHalfHeights += 1;
100cdf0e10cSrcweir break;
101cdf0e10cSrcweir case drawing::Alignment_BOTTOM:
102cdf0e10cSrcweir nShiftHalfWidths += 1;
103cdf0e10cSrcweir nShiftHalfHeights += 2;
104cdf0e10cSrcweir break;
105cdf0e10cSrcweir case drawing::Alignment_TOP_RIGHT:
106cdf0e10cSrcweir nShiftHalfWidths += 2;
107cdf0e10cSrcweir break;
108cdf0e10cSrcweir case drawing::Alignment_RIGHT:
109cdf0e10cSrcweir nShiftHalfWidths += 2;
110cdf0e10cSrcweir nShiftHalfHeights += 1;
111cdf0e10cSrcweir break;
112cdf0e10cSrcweir case drawing::Alignment_BOTTOM_RIGHT:
113cdf0e10cSrcweir nShiftHalfWidths += 2;
114cdf0e10cSrcweir nShiftHalfHeights += 2;
115cdf0e10cSrcweir break;
116cdf0e10cSrcweir case drawing::Alignment_MAKE_FIXED_SIZE:
117cdf0e10cSrcweir break;
118cdf0e10cSrcweir }
119cdf0e10cSrcweir
120cdf0e10cSrcweir if( nShiftHalfWidths != 0 )
121cdf0e10cSrcweir aResult.Primary += (rObjectSize.Primary / 2.0) * nShiftHalfWidths;
122cdf0e10cSrcweir if( nShiftHalfHeights != 0 )
123cdf0e10cSrcweir aResult.Secondary += (rObjectSize.Secondary / 2.0) * nShiftHalfHeights;
124cdf0e10cSrcweir }
125cdf0e10cSrcweir
126cdf0e10cSrcweir return aResult;
127cdf0e10cSrcweir }
128cdf0e10cSrcweir
129cdf0e10cSrcweir
getUpperLeftCornerOfAnchoredObject(awt::Point aPoint,awt::Size aObjectSize,drawing::Alignment aAnchor)130cdf0e10cSrcweir awt::Point RelativePositionHelper::getUpperLeftCornerOfAnchoredObject(
131cdf0e10cSrcweir awt::Point aPoint
132cdf0e10cSrcweir , awt::Size aObjectSize
133cdf0e10cSrcweir , drawing::Alignment aAnchor )
134cdf0e10cSrcweir {
135cdf0e10cSrcweir awt::Point aResult( aPoint );
136cdf0e10cSrcweir
137cdf0e10cSrcweir double fXDelta = 0.0;
138cdf0e10cSrcweir double fYDelta = 0.0;
139cdf0e10cSrcweir
140cdf0e10cSrcweir // adapt x-value
141cdf0e10cSrcweir switch( aAnchor )
142cdf0e10cSrcweir {
143cdf0e10cSrcweir case drawing::Alignment_TOP:
144cdf0e10cSrcweir case drawing::Alignment_CENTER:
145cdf0e10cSrcweir case drawing::Alignment_BOTTOM:
146cdf0e10cSrcweir fXDelta -= static_cast< double >( aObjectSize.Width ) / 2.0;
147cdf0e10cSrcweir break;
148cdf0e10cSrcweir case drawing::Alignment_TOP_RIGHT:
149cdf0e10cSrcweir case drawing::Alignment_RIGHT:
150cdf0e10cSrcweir case drawing::Alignment_BOTTOM_RIGHT:
151cdf0e10cSrcweir fXDelta -= aObjectSize.Width;
152cdf0e10cSrcweir break;
153cdf0e10cSrcweir case drawing::Alignment_TOP_LEFT:
154cdf0e10cSrcweir case drawing::Alignment_LEFT:
155cdf0e10cSrcweir case drawing::Alignment_BOTTOM_LEFT:
156cdf0e10cSrcweir default:
157cdf0e10cSrcweir // nothing to do
158cdf0e10cSrcweir break;
159cdf0e10cSrcweir }
160cdf0e10cSrcweir
161cdf0e10cSrcweir // adapt y-value
162cdf0e10cSrcweir switch( aAnchor )
163cdf0e10cSrcweir {
164cdf0e10cSrcweir case drawing::Alignment_LEFT:
165cdf0e10cSrcweir case drawing::Alignment_CENTER:
166cdf0e10cSrcweir case drawing::Alignment_RIGHT:
167cdf0e10cSrcweir fYDelta -= static_cast< double >( aObjectSize.Height ) / 2.0;
168cdf0e10cSrcweir break;
169cdf0e10cSrcweir case drawing::Alignment_BOTTOM_LEFT:
170cdf0e10cSrcweir case drawing::Alignment_BOTTOM:
171cdf0e10cSrcweir case drawing::Alignment_BOTTOM_RIGHT:
172cdf0e10cSrcweir fYDelta -= aObjectSize.Height;
173cdf0e10cSrcweir break;
174cdf0e10cSrcweir case drawing::Alignment_TOP_LEFT:
175cdf0e10cSrcweir case drawing::Alignment_TOP:
176cdf0e10cSrcweir case drawing::Alignment_TOP_RIGHT:
177cdf0e10cSrcweir default:
178cdf0e10cSrcweir // nothing to do
179cdf0e10cSrcweir break;
180cdf0e10cSrcweir }
181cdf0e10cSrcweir
182cdf0e10cSrcweir aResult.X += static_cast< sal_Int32 >( ::rtl::math::round( fXDelta ));
183cdf0e10cSrcweir aResult.Y += static_cast< sal_Int32 >( ::rtl::math::round( fYDelta ));
184cdf0e10cSrcweir
185cdf0e10cSrcweir return aResult;
186cdf0e10cSrcweir }
187cdf0e10cSrcweir
getCenterOfAnchoredObject(awt::Point aPoint,awt::Size aUnrotatedObjectSize,drawing::Alignment aAnchor,double fAnglePi)188cdf0e10cSrcweir awt::Point RelativePositionHelper::getCenterOfAnchoredObject(
189cdf0e10cSrcweir awt::Point aPoint
190cdf0e10cSrcweir , awt::Size aUnrotatedObjectSize
191cdf0e10cSrcweir , drawing::Alignment aAnchor
192cdf0e10cSrcweir , double fAnglePi )
193cdf0e10cSrcweir {
194cdf0e10cSrcweir awt::Point aResult( aPoint );
195cdf0e10cSrcweir
196cdf0e10cSrcweir double fXDelta = 0.0;
197cdf0e10cSrcweir double fYDelta = 0.0;
198cdf0e10cSrcweir
199cdf0e10cSrcweir // adapt x-value
200cdf0e10cSrcweir switch( aAnchor )
201cdf0e10cSrcweir {
202cdf0e10cSrcweir case drawing::Alignment_TOP:
203cdf0e10cSrcweir case drawing::Alignment_CENTER:
204cdf0e10cSrcweir case drawing::Alignment_BOTTOM:
205cdf0e10cSrcweir // nothing to do
206cdf0e10cSrcweir break;
207cdf0e10cSrcweir case drawing::Alignment_TOP_RIGHT:
208cdf0e10cSrcweir case drawing::Alignment_RIGHT:
209cdf0e10cSrcweir case drawing::Alignment_BOTTOM_RIGHT:
210cdf0e10cSrcweir fXDelta -= aUnrotatedObjectSize.Width/2;
211cdf0e10cSrcweir break;
212cdf0e10cSrcweir case drawing::Alignment_TOP_LEFT:
213cdf0e10cSrcweir case drawing::Alignment_LEFT:
214cdf0e10cSrcweir case drawing::Alignment_BOTTOM_LEFT:
215cdf0e10cSrcweir default:
216cdf0e10cSrcweir fXDelta += aUnrotatedObjectSize.Width/2;
217cdf0e10cSrcweir break;
218cdf0e10cSrcweir }
219cdf0e10cSrcweir
220cdf0e10cSrcweir // adapt y-value
221cdf0e10cSrcweir switch( aAnchor )
222cdf0e10cSrcweir {
223cdf0e10cSrcweir case drawing::Alignment_LEFT:
224cdf0e10cSrcweir case drawing::Alignment_CENTER:
225cdf0e10cSrcweir case drawing::Alignment_RIGHT:
226cdf0e10cSrcweir // nothing to do
227cdf0e10cSrcweir break;
228cdf0e10cSrcweir case drawing::Alignment_BOTTOM_LEFT:
229cdf0e10cSrcweir case drawing::Alignment_BOTTOM:
230cdf0e10cSrcweir case drawing::Alignment_BOTTOM_RIGHT:
231cdf0e10cSrcweir fYDelta -= aUnrotatedObjectSize.Height/2;
232cdf0e10cSrcweir break;
233cdf0e10cSrcweir case drawing::Alignment_TOP_LEFT:
234cdf0e10cSrcweir case drawing::Alignment_TOP:
235cdf0e10cSrcweir case drawing::Alignment_TOP_RIGHT:
236cdf0e10cSrcweir fYDelta += aUnrotatedObjectSize.Height/2;
237cdf0e10cSrcweir default:
238cdf0e10cSrcweir // nothing to do
239cdf0e10cSrcweir break;
240cdf0e10cSrcweir }
241cdf0e10cSrcweir
242cdf0e10cSrcweir //take rotation into account:
243cdf0e10cSrcweir aResult.X += static_cast< sal_Int32 >(
244cdf0e10cSrcweir ::rtl::math::round( fXDelta * rtl::math::cos( fAnglePi ) + fYDelta * rtl::math::sin( fAnglePi ) ) );
245cdf0e10cSrcweir aResult.Y += static_cast< sal_Int32 >(
246cdf0e10cSrcweir ::rtl::math::round( - fXDelta * rtl::math::sin( fAnglePi ) + fYDelta * rtl::math::cos( fAnglePi ) ) );
247cdf0e10cSrcweir
248cdf0e10cSrcweir return aResult;
249cdf0e10cSrcweir }
250cdf0e10cSrcweir
centerGrow(chart2::RelativePosition & rInOutPosition,chart2::RelativeSize & rInOutSize,double fAmountX,double fAmountY,bool bCheck)251cdf0e10cSrcweir bool RelativePositionHelper::centerGrow(
252cdf0e10cSrcweir chart2::RelativePosition & rInOutPosition,
253cdf0e10cSrcweir chart2::RelativeSize & rInOutSize,
254cdf0e10cSrcweir double fAmountX, double fAmountY,
255cdf0e10cSrcweir bool bCheck /* = true */ )
256cdf0e10cSrcweir {
257cdf0e10cSrcweir chart2::RelativePosition aPos( rInOutPosition );
258cdf0e10cSrcweir chart2::RelativeSize aSize( rInOutSize );
259cdf0e10cSrcweir const double fPosCheckThreshold = 0.02;
260cdf0e10cSrcweir const double fSizeCheckThreshold = 0.1;
261cdf0e10cSrcweir
262cdf0e10cSrcweir // grow/shrink, back to relaative
263cdf0e10cSrcweir aSize.Primary += fAmountX;
264cdf0e10cSrcweir aSize.Secondary += fAmountY;
265cdf0e10cSrcweir
266cdf0e10cSrcweir double fShiftAmountX = fAmountX / 2.0;
267cdf0e10cSrcweir double fShiftAmountY = fAmountY / 2.0;
268cdf0e10cSrcweir
269cdf0e10cSrcweir // shift X
270cdf0e10cSrcweir switch( rInOutPosition.Anchor )
271cdf0e10cSrcweir {
272cdf0e10cSrcweir case drawing::Alignment_TOP_LEFT:
273cdf0e10cSrcweir case drawing::Alignment_LEFT:
274cdf0e10cSrcweir case drawing::Alignment_BOTTOM_LEFT:
275cdf0e10cSrcweir aPos.Primary -= fShiftAmountX;
276cdf0e10cSrcweir break;
277cdf0e10cSrcweir case drawing::Alignment_TOP:
278cdf0e10cSrcweir case drawing::Alignment_CENTER:
279cdf0e10cSrcweir case drawing::Alignment_BOTTOM:
280cdf0e10cSrcweir // nothing
281cdf0e10cSrcweir break;
282cdf0e10cSrcweir case drawing::Alignment_TOP_RIGHT:
283cdf0e10cSrcweir case drawing::Alignment_RIGHT:
284cdf0e10cSrcweir case drawing::Alignment_BOTTOM_RIGHT:
285cdf0e10cSrcweir aPos.Primary += fShiftAmountX;
286cdf0e10cSrcweir break;
287cdf0e10cSrcweir case drawing::Alignment_MAKE_FIXED_SIZE:
288cdf0e10cSrcweir break;
289cdf0e10cSrcweir }
290cdf0e10cSrcweir
291cdf0e10cSrcweir // shift Y
292cdf0e10cSrcweir switch( rInOutPosition.Anchor )
293cdf0e10cSrcweir {
294cdf0e10cSrcweir case drawing::Alignment_TOP:
295cdf0e10cSrcweir case drawing::Alignment_TOP_LEFT:
296cdf0e10cSrcweir case drawing::Alignment_TOP_RIGHT:
297cdf0e10cSrcweir aPos.Secondary -= fShiftAmountY;
298cdf0e10cSrcweir break;
299cdf0e10cSrcweir case drawing::Alignment_CENTER:
300cdf0e10cSrcweir case drawing::Alignment_LEFT:
301cdf0e10cSrcweir case drawing::Alignment_RIGHT:
302cdf0e10cSrcweir // nothing
303cdf0e10cSrcweir break;
304cdf0e10cSrcweir case drawing::Alignment_BOTTOM:
305cdf0e10cSrcweir case drawing::Alignment_BOTTOM_LEFT:
306cdf0e10cSrcweir case drawing::Alignment_BOTTOM_RIGHT:
307cdf0e10cSrcweir aPos.Secondary += fShiftAmountY;
308cdf0e10cSrcweir break;
309cdf0e10cSrcweir case drawing::Alignment_MAKE_FIXED_SIZE:
310cdf0e10cSrcweir break;
311cdf0e10cSrcweir }
312cdf0e10cSrcweir
313cdf0e10cSrcweir // anchor must not be changed
314cdf0e10cSrcweir OSL_ASSERT( rInOutPosition.Anchor == aPos.Anchor );
315cdf0e10cSrcweir
316cdf0e10cSrcweir if( rInOutPosition.Primary == aPos.Primary &&
317cdf0e10cSrcweir rInOutPosition.Secondary == aPos.Secondary &&
318cdf0e10cSrcweir rInOutSize.Primary == aSize.Primary &&
319cdf0e10cSrcweir rInOutSize.Secondary == aSize.Secondary )
320cdf0e10cSrcweir return false;
321cdf0e10cSrcweir
322cdf0e10cSrcweir // check
323cdf0e10cSrcweir if( bCheck )
324cdf0e10cSrcweir {
325cdf0e10cSrcweir // Note: this somewhat complicated check allows the output being
326cdf0e10cSrcweir // out-of-bounds if the input was also out-of-bounds, and the change is
327cdf0e10cSrcweir // for "advantage". E.g., you have a chart that laps out on the left
328cdf0e10cSrcweir // side. If you shrink it, this should be possible, also if it still
329cdf0e10cSrcweir // laps out on the left side afterwards. But you shouldn't be able to
330cdf0e10cSrcweir // grow it then.
331cdf0e10cSrcweir
332cdf0e10cSrcweir chart2::RelativePosition aUpperLeft(
333cdf0e10cSrcweir RelativePositionHelper::getReanchoredPosition( aPos, aSize, drawing::Alignment_TOP_LEFT ));
334cdf0e10cSrcweir chart2::RelativePosition aLowerRight(
335cdf0e10cSrcweir RelativePositionHelper::getReanchoredPosition( aPos, aSize, drawing::Alignment_BOTTOM_RIGHT ));
336cdf0e10cSrcweir
337cdf0e10cSrcweir // Do not grow, if this leads to corners being off-screen
338cdf0e10cSrcweir if( fAmountX > 0.0 &&
339cdf0e10cSrcweir ( (aUpperLeft.Primary < fPosCheckThreshold) ||
340cdf0e10cSrcweir (aLowerRight.Primary > (1.0 - fPosCheckThreshold)) ))
341cdf0e10cSrcweir return false;
342cdf0e10cSrcweir if( fAmountY > 0.0 &&
343cdf0e10cSrcweir ( (aUpperLeft.Secondary < fPosCheckThreshold) ||
344cdf0e10cSrcweir (aLowerRight.Secondary > (1.0 - fPosCheckThreshold)) ))
345cdf0e10cSrcweir return false;
346cdf0e10cSrcweir
347cdf0e10cSrcweir // Do not shrink, if this leads to a size too small
348cdf0e10cSrcweir if( fAmountX < 0.0 &&
349cdf0e10cSrcweir ( aSize.Primary < fSizeCheckThreshold ))
350cdf0e10cSrcweir return false;
351cdf0e10cSrcweir if( fAmountY < 0.0 &&
352cdf0e10cSrcweir ( aSize.Secondary < fSizeCheckThreshold ))
353cdf0e10cSrcweir return false;
354cdf0e10cSrcweir }
355cdf0e10cSrcweir
356cdf0e10cSrcweir rInOutPosition = aPos;
357cdf0e10cSrcweir rInOutSize = aSize;
358cdf0e10cSrcweir return true;
359cdf0e10cSrcweir }
360cdf0e10cSrcweir
moveObject(chart2::RelativePosition & rInOutPosition,const chart2::RelativeSize & rObjectSize,double fAmountX,double fAmountY,bool bCheck)361cdf0e10cSrcweir bool RelativePositionHelper::moveObject(
362cdf0e10cSrcweir chart2::RelativePosition & rInOutPosition,
363cdf0e10cSrcweir const chart2::RelativeSize & rObjectSize,
364cdf0e10cSrcweir double fAmountX, double fAmountY,
365cdf0e10cSrcweir bool bCheck /* = true */ )
366cdf0e10cSrcweir {
367cdf0e10cSrcweir chart2::RelativePosition aPos( rInOutPosition );
368cdf0e10cSrcweir aPos.Primary += fAmountX;
369cdf0e10cSrcweir aPos.Secondary += fAmountY;
370cdf0e10cSrcweir const double fPosCheckThreshold = 0.02;
371cdf0e10cSrcweir
372cdf0e10cSrcweir if( bCheck )
373cdf0e10cSrcweir {
374cdf0e10cSrcweir chart2::RelativePosition aUpperLeft(
375cdf0e10cSrcweir RelativePositionHelper::getReanchoredPosition( aPos, rObjectSize, drawing::Alignment_TOP_LEFT ));
376cdf0e10cSrcweir chart2::RelativePosition aLowerRight( aUpperLeft );
377cdf0e10cSrcweir aLowerRight.Primary += rObjectSize.Primary;
378cdf0e10cSrcweir aLowerRight.Secondary += rObjectSize.Secondary;
379cdf0e10cSrcweir
380cdf0e10cSrcweir const double fFarEdgeThreshold = 1.0 - fPosCheckThreshold;
381cdf0e10cSrcweir if( ( fAmountX > 0.0 && (aLowerRight.Primary > fFarEdgeThreshold)) ||
382cdf0e10cSrcweir ( fAmountX < 0.0 && (aUpperLeft.Primary < fPosCheckThreshold)) ||
383cdf0e10cSrcweir ( fAmountY > 0.0 && (aLowerRight.Secondary > fFarEdgeThreshold)) ||
384cdf0e10cSrcweir ( fAmountY < 0.0 && (aUpperLeft.Secondary < fPosCheckThreshold)) )
385cdf0e10cSrcweir return false;
386cdf0e10cSrcweir }
387cdf0e10cSrcweir
388cdf0e10cSrcweir rInOutPosition = aPos;
389cdf0e10cSrcweir return true;
390cdf0e10cSrcweir }
391cdf0e10cSrcweir
392cdf0e10cSrcweir } // namespace chart
393