Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : : #ifndef _SV_GEN_HXX
20 : : #define _SV_GEN_HXX
21 : :
22 : : #include "tools/toolsdllapi.h"
23 : : #include <tools/solar.h>
24 : :
25 : : #include <limits.h>
26 : :
27 : : class SvStream;
28 : :
29 : : // Pair
30 : :
31 : : class Pair
32 : : {
33 : : public:
34 : : long nA;
35 : : long nB;
36 : :
37 : : Pair();
38 : : Pair( long nA, long nB );
39 : :
40 : 0 : long A() const { return nA; }
41 : 0 : long B() const { return nB; }
42 : :
43 : 34397 : long& A() { return nA; }
44 : 34397 : long& B() { return nB; }
45 : :
46 : : sal_Bool operator == ( const Pair& rPair ) const;
47 : : sal_Bool operator != ( const Pair& rPair ) const;
48 : :
49 : : TOOLS_DLLPUBLIC friend SvStream& operator>>( SvStream& rIStream, Pair& rPair );
50 : : TOOLS_DLLPUBLIC friend SvStream& operator<<( SvStream& rOStream, const Pair& rPair );
51 : : };
52 : :
53 : 20805004 : inline Pair::Pair()
54 : : {
55 : 20805004 : nA = nB = 0;
56 : 20805004 : }
57 : :
58 : 70999968 : inline Pair::Pair( long _nA, long _nB )
59 : : {
60 : 70999968 : Pair::nA = _nA;
61 : 70999968 : Pair::nB = _nB;
62 : 70999968 : }
63 : :
64 : 487276 : inline sal_Bool Pair::operator == ( const Pair& rPair ) const
65 : : {
66 [ + + ][ + + ]: 487276 : return ((nA == rPair.nA) && (nB == rPair.nB));
67 : : }
68 : :
69 : 2686903 : inline sal_Bool Pair::operator != ( const Pair& rPair ) const
70 : : {
71 [ + + ][ + + ]: 2686903 : return ((nA != rPair.nA) || (nB != rPair.nB));
72 : : }
73 : :
74 : : // Point
75 : :
76 : : class Point : public Pair
77 : : {
78 : : public:
79 : : Point();
80 : : Point( long nX, long nY );
81 : :
82 : 53365588 : long X() const { return nA; }
83 : 28532202 : long Y() const { return nB; }
84 : :
85 : 15976522 : long& X() { return nA; }
86 : 12228976 : long& Y() { return nB; }
87 : :
88 : : void Move( long nHorzMove, long nVertMove );
89 : : sal_Bool IsAbove( const Point& rPoint ) const;
90 : : sal_Bool IsBelow( const Point& rPoint ) const;
91 : : sal_Bool IsLeft( const Point& rPoint ) const;
92 : : sal_Bool IsRight( const Point& rPoint ) const;
93 : :
94 : : Point& operator += ( const Point& rPoint );
95 : : Point& operator -= ( const Point& rPoint );
96 : : Point& operator *= ( const long nVal );
97 : : Point& operator /= ( const long nVal );
98 : :
99 : : friend inline Point operator+( const Point &rVal1, const Point &rVal2 );
100 : : friend inline Point operator-( const Point &rVal1, const Point &rVal2 );
101 : : friend inline Point operator*( const Point &rVal1, const long nVal2 );
102 : : friend inline Point operator/( const Point &rVal1, const long nVal2 );
103 : :
104 : 6322124 : long getX() const { return X(); }
105 : 5140828 : long getY() const { return Y(); }
106 : 463644 : void setX(long nX) { X() = nX; }
107 : 359542 : void setY(long nY) { Y() = nY; }
108 : : };
109 : :
110 : 8521298 : inline Point::Point()
111 : : {
112 : 8521298 : }
113 : :
114 : 54792597 : inline Point::Point( long nX, long nY ) : Pair( nX, nY )
115 : : {
116 : 54792597 : }
117 : :
118 : 734 : inline void Point::Move( long nHorzMove, long nVertMove )
119 : : {
120 : 734 : nA += nHorzMove;
121 : 734 : nB += nVertMove;
122 : 734 : }
123 : :
124 : : inline sal_Bool Point::IsAbove( const Point& rPoint ) const
125 : : {
126 : : return (nB > rPoint.nB);
127 : : }
128 : :
129 : : inline sal_Bool Point::IsBelow( const Point& rPoint ) const
130 : : {
131 : : return (nB < rPoint.nB);
132 : : }
133 : :
134 : : inline sal_Bool Point::IsLeft( const Point& rPoint ) const
135 : : {
136 : : return (nA < rPoint.nA);
137 : : }
138 : :
139 : : inline sal_Bool Point::IsRight( const Point& rPoint ) const
140 : : {
141 : : return (nA > rPoint.nA);
142 : : }
143 : :
144 : 2873458 : inline Point& Point::operator += ( const Point& rPoint )
145 : : {
146 : 2873458 : nA += rPoint.nA;
147 : 2873458 : nB += rPoint.nB;
148 : 2873458 : return *this;
149 : : }
150 : :
151 : 211221 : inline Point& Point::operator -= ( const Point& rPoint )
152 : : {
153 : 211221 : nA -= rPoint.nA;
154 : 211221 : nB -= rPoint.nB;
155 : 211221 : return *this;
156 : : }
157 : :
158 : 0 : inline Point& Point::operator *= ( const long nVal )
159 : : {
160 : 0 : nA *= nVal;
161 : 0 : nB *= nVal;
162 : 0 : return *this;
163 : : }
164 : :
165 : 0 : inline Point& Point::operator /= ( const long nVal )
166 : : {
167 : 0 : nA /= nVal;
168 : 0 : nB /= nVal;
169 : 0 : return *this;
170 : : }
171 : :
172 : 7255707 : inline Point operator+( const Point &rVal1, const Point &rVal2 )
173 : : {
174 : 7255707 : return Point( rVal1.nA+rVal2.nA, rVal1.nB+rVal2.nB );
175 : : }
176 : :
177 : 2726875 : inline Point operator-( const Point &rVal1, const Point &rVal2 )
178 : : {
179 : 2726875 : return Point( rVal1.nA-rVal2.nA, rVal1.nB-rVal2.nB );
180 : : }
181 : :
182 : 0 : inline Point operator*( const Point &rVal1, const long nVal2 )
183 : : {
184 : 0 : return Point( rVal1.nA*nVal2, rVal1.nB*nVal2 );
185 : : }
186 : :
187 : 0 : inline Point operator/( const Point &rVal1, const long nVal2 )
188 : : {
189 : 0 : return Point( rVal1.nA/nVal2, rVal1.nB/nVal2 );
190 : : }
191 : :
192 : : // Size
193 : :
194 : : class Size : public Pair
195 : : {
196 : : public:
197 : : Size();
198 : : Size( long nWidth, long nHeight );
199 : :
200 : 25432235 : long Width() const { return nA; }
201 : 23923838 : long Height() const { return nB; }
202 : :
203 : 21937070 : long& Width() { return nA; }
204 : 12791045 : long& Height() { return nB; }
205 : :
206 : 7412336 : long getWidth() const { return Width(); }
207 : 7037238 : long getHeight() const { return Height(); }
208 : 1377552 : void setWidth(long nWidth) { Width() = nWidth; }
209 : 1079554 : void setHeight(long nHeight) { Height() = nHeight; }
210 : : };
211 : :
212 : 12275978 : inline Size::Size()
213 : : {
214 : 12275978 : }
215 : :
216 : 15816706 : inline Size::Size( long nWidth, long nHeight ) :
217 : 15816706 : Pair( nWidth, nHeight )
218 : : {
219 : 15816706 : }
220 : :
221 : : // Range
222 : :
223 : : #define RANGE_MAX LONG_MAX
224 : :
225 : : class Range : public Pair
226 : : {
227 : : public:
228 : : Range();
229 : : Range( long nMin, long nMax );
230 : :
231 : 2412 : long Min() const { return nA; }
232 : 3164 : long Max() const { return nB; }
233 : 325641 : long Len() const { return nB - nA + 1; }
234 : :
235 : 652015 : long& Min() { return nA; }
236 : 1464712 : long& Max() { return nB; }
237 : :
238 : : sal_Bool IsInside( long nIs ) const;
239 : :
240 : : void Justify();
241 : : };
242 : :
243 : 138 : inline Range::Range()
244 : : {
245 : 138 : }
246 : :
247 : 384617 : inline Range::Range( long nMin, long nMax ) : Pair( nMin, nMax )
248 : : {
249 : 384617 : }
250 : :
251 : 933 : inline sal_Bool Range::IsInside( long nIs ) const
252 : : {
253 [ + - ][ + + ]: 933 : return ((nA <= nIs) && (nIs <= nB ));
254 : : }
255 : :
256 : 21099 : inline void Range::Justify()
257 : : {
258 [ + + ]: 21099 : if ( nA > nB )
259 : : {
260 : 54 : long nHelp = nA;
261 : 54 : nA = nB;
262 : 54 : nB = nHelp;
263 : : }
264 : 21099 : }
265 : :
266 : : // Selection
267 : :
268 : : #define SELECTION_MIN LONG_MIN
269 : : #define SELECTION_MAX LONG_MAX
270 : :
271 : : class Selection : public Pair
272 : : {
273 : : public:
274 : : Selection();
275 : : Selection( long nPos );
276 : : Selection( long nMin, long nMax );
277 : :
278 : 0 : long Min() const { return nA; }
279 : 0 : long Max() const { return nB; }
280 : 23173 : long Len() const { return nB - nA; }
281 : :
282 : 33256 : long& Min() { return nA; }
283 : 28405 : long& Max() { return nB; }
284 : :
285 : : sal_Bool IsInside( long nIs ) const;
286 : :
287 : : void Justify();
288 : :
289 : 214 : sal_Bool operator !() const { return !Len(); }
290 : :
291 : 0 : long getMin() const { return Min(); }
292 : : long getMax() const { return Max(); }
293 : 0 : void setMin(long nMin) { Min() = nMin; }
294 : 0 : void setMax(long nMax) { Max() = nMax; }
295 : : };
296 : :
297 : 7590 : inline Selection::Selection()
298 : : {
299 : 7590 : }
300 : :
301 : 0 : inline Selection::Selection( long nPos ) : Pair( nPos, nPos )
302 : : {
303 : 0 : }
304 : :
305 : 6042 : inline Selection::Selection( long nMin, long nMax ) :
306 : 6042 : Pair( nMin, nMax )
307 : : {
308 : 6042 : }
309 : :
310 : 0 : inline sal_Bool Selection::IsInside( long nIs ) const
311 : : {
312 [ # # ][ # # ]: 0 : return ((nA <= nIs) && (nIs < nB ));
313 : : }
314 : :
315 : 5951 : inline void Selection::Justify()
316 : : {
317 [ - + ]: 5951 : if ( nA > nB )
318 : : {
319 : 0 : long nHelp = nA;
320 : 0 : nA = nB;
321 : 0 : nB = nHelp;
322 : : }
323 : 5951 : }
324 : :
325 : : // Rectangle
326 : :
327 : : #define RECT_EMPTY ((short)-32767)
328 : :
329 : : class TOOLS_DLLPUBLIC Rectangle
330 : : {
331 : : public:
332 : : long nLeft;
333 : : long nTop;
334 : : long nRight;
335 : : long nBottom;
336 : :
337 : : Rectangle();
338 : : Rectangle( const Point& rLT, const Point& rRB );
339 : : Rectangle( long nLeft, long nTop,
340 : : long nRight, long nBottom );
341 : : Rectangle( const Point& rLT, const Size& rSize );
342 : :
343 : 6251478 : long Left() const { return nLeft; }
344 : 5841190 : long Right() const { return nRight; }
345 : 6247447 : long Top() const { return nTop; }
346 : 5809534 : long Bottom() const { return nBottom; }
347 : :
348 : 9350985 : long& Left() { return nLeft; }
349 : 3276016 : long& Right() { return nRight; }
350 : 11460403 : long& Top() { return nTop; }
351 : 3146894 : long& Bottom() { return nBottom; }
352 : :
353 : : inline Point TopLeft() const;
354 : : Point TopRight() const;
355 : : Point TopCenter() const;
356 : : Point BottomLeft() const;
357 : : Point BottomRight() const;
358 : : Point BottomCenter() const;
359 : : Point LeftCenter() const;
360 : : Point RightCenter() const;
361 : : Point Center() const;
362 : :
363 : : void Move( long nHorzMove, long nVertMove );
364 : : inline void Transpose();
365 : : inline void SetPos( const Point& rPoint );
366 : : void SetSize( const Size& rSize );
367 : : inline Size GetSize() const;
368 : :
369 : : long GetWidth() const;
370 : : long GetHeight() const;
371 : :
372 : : Rectangle& Union( const Rectangle& rRect );
373 : : Rectangle& Intersection( const Rectangle& rRect );
374 : : Rectangle GetUnion( const Rectangle& rRect ) const;
375 : : Rectangle GetIntersection( const Rectangle& rRect ) const;
376 : :
377 : : void Justify();
378 : :
379 : : sal_Bool IsInside( const Point& rPOINT ) const;
380 : : sal_Bool IsInside( const Rectangle& rRect ) const;
381 : : sal_Bool IsOver( const Rectangle& rRect ) const;
382 : :
383 : 275602 : void SetEmpty() { nRight = nBottom = RECT_EMPTY; }
384 : : sal_Bool IsEmpty() const;
385 : :
386 : : sal_Bool operator == ( const Rectangle& rRect ) const;
387 : : sal_Bool operator != ( const Rectangle& rRect ) const;
388 : :
389 : : Rectangle& operator += ( const Point& rPt );
390 : : Rectangle& operator -= ( const Point& rPt );
391 : :
392 : : friend inline Rectangle operator + ( const Rectangle& rRect, const Point& rPt );
393 : : friend inline Rectangle operator - ( const Rectangle& rRect, const Point& rPt );
394 : :
395 : : TOOLS_DLLPUBLIC friend SvStream& operator>>( SvStream& rIStream, Rectangle& rRect );
396 : : TOOLS_DLLPUBLIC friend SvStream& operator<<( SvStream& rOStream, const Rectangle& rRect );
397 : :
398 : : // ONE
399 : 966 : long getX() const { return nLeft; }
400 : 1858 : long getY() const { return nTop; }
401 : 104413 : long getWidth() const { return nRight - nLeft; }
402 : 100800 : long getHeight() const { return nBottom - nTop; }
403 : 10007 : void setX( long n ) { nRight += n-nLeft; nLeft = n; }
404 : 9747 : void setY( long n ) { nBottom += n-nTop; nTop = n; }
405 : 116769 : void setWidth( long n ) { nRight = nLeft + n; }
406 : 122116 : void setHeight( long n ) { nBottom = nTop + n; }
407 : : };
408 : :
409 : 6314653 : inline Rectangle::Rectangle()
410 : : {
411 : 6314653 : nLeft = nTop = 0;
412 : 6314653 : nRight = nBottom = RECT_EMPTY;
413 : 6314653 : }
414 : :
415 : 601741 : inline Rectangle::Rectangle( const Point& rLT, const Point& rRB )
416 : : {
417 : 601741 : nLeft = rLT.X();
418 : 601741 : nTop = rLT.Y();
419 : 601741 : nRight = rRB.X();
420 : 601741 : nBottom = rRB.Y();
421 : 601741 : }
422 : :
423 : 3931536 : inline Rectangle::Rectangle( long _nLeft, long _nTop,
424 : : long _nRight, long _nBottom )
425 : : {
426 : 3931536 : nLeft = _nLeft;
427 : 3931536 : nTop = _nTop;
428 : 3931536 : nRight = _nRight;
429 : 3931536 : nBottom = _nBottom;
430 : 3931536 : }
431 : :
432 : 3829968 : inline Rectangle::Rectangle( const Point& rLT, const Size& rSize )
433 : : {
434 : 3829968 : nLeft = rLT.X();
435 : 3829968 : nTop = rLT.Y();
436 [ + + ]: 3829968 : nRight = rSize.Width() ? nLeft+rSize.Width()-1 : RECT_EMPTY;
437 [ + + ]: 3829968 : nBottom = rSize.Height() ? nTop+rSize.Height()-1 : RECT_EMPTY;
438 : 3829968 : }
439 : :
440 : 7797391 : inline sal_Bool Rectangle::IsEmpty() const
441 : : {
442 [ + + ][ + + ]: 7797391 : return ((nRight == RECT_EMPTY) || (nBottom == RECT_EMPTY));
443 : : }
444 : :
445 : 3480222 : inline Point Rectangle::TopLeft() const
446 : : {
447 : 3480222 : return Point( nLeft, nTop );
448 : : }
449 : :
450 : 2596094 : inline Point Rectangle::TopRight() const
451 : : {
452 [ + + ]: 2596094 : return Point( (nRight == RECT_EMPTY) ? nLeft : nRight, nTop );
453 : : }
454 : :
455 : 309871 : inline Point Rectangle::BottomLeft() const
456 : : {
457 [ + + ]: 309871 : return Point( nLeft, (nBottom == RECT_EMPTY) ? nTop : nBottom );
458 : : }
459 : :
460 : 293333 : inline Point Rectangle::BottomRight() const
461 : : {
462 : : return Point( (nRight == RECT_EMPTY) ? nLeft : nRight,
463 [ + + ][ + + ]: 293333 : (nBottom == RECT_EMPTY) ? nTop : nBottom );
464 : : }
465 : :
466 : 888 : inline Point Rectangle::TopCenter() const
467 : : {
468 [ - + ]: 888 : if ( IsEmpty() )
469 : 0 : return Point( nLeft, nTop );
470 : : else
471 : 888 : return Point( Min( nLeft, nRight ) + Abs( (nRight - nLeft)/2 ),
472 : 1776 : Min( nTop, nBottom) );
473 : : }
474 : :
475 : 896 : inline Point Rectangle::BottomCenter() const
476 : : {
477 [ - + ]: 896 : if ( IsEmpty() )
478 : 0 : return Point( nLeft, nTop );
479 : : else
480 : 896 : return Point( Min( nLeft, nRight ) + Abs( (nRight - nLeft)/2 ),
481 : 1792 : Max( nTop, nBottom) );
482 : : }
483 : :
484 : 888 : inline Point Rectangle::LeftCenter() const
485 : : {
486 [ - + ]: 888 : if ( IsEmpty() )
487 : 0 : return Point( nLeft, nTop );
488 : : else
489 : 888 : return Point( Min( nLeft, nRight ), nTop + (nBottom - nTop)/2 );
490 : : }
491 : :
492 : 888 : inline Point Rectangle::RightCenter() const
493 : : {
494 [ - + ]: 888 : if ( IsEmpty() )
495 : 0 : return Point( nLeft, nTop );
496 : : else
497 : 888 : return Point( Max( nLeft, nRight ), nTop + (nBottom - nTop)/2 );
498 : : }
499 : :
500 : 272903 : inline Point Rectangle::Center() const
501 : : {
502 [ + + ]: 272903 : if ( IsEmpty() )
503 : 69338 : return Point( nLeft, nTop );
504 : : else
505 : 272903 : return Point( nLeft+(nRight-nLeft)/2 , nTop+(nBottom-nTop)/2 );
506 : : }
507 : :
508 : 360099 : inline void Rectangle::Move( long nHorzMove, long nVertMove )
509 : : {
510 : 360099 : nLeft += nHorzMove;
511 : 360099 : nTop += nVertMove;
512 [ + + ]: 360099 : if ( nRight != RECT_EMPTY )
513 : 207080 : nRight += nHorzMove;
514 [ + + ]: 360099 : if ( nBottom != RECT_EMPTY )
515 : 206676 : nBottom += nVertMove;
516 : 360099 : }
517 : :
518 : 0 : void Rectangle::Transpose()
519 : : {
520 [ # # ]: 0 : if ( !IsEmpty() )
521 : : {
522 : 0 : long swap( nLeft );
523 : 0 : nLeft = nTop;
524 : 0 : nTop = swap;
525 : :
526 : 0 : swap = nRight;
527 : 0 : nRight = nBottom;
528 : 0 : nBottom = swap;
529 : : }
530 : 0 : }
531 : :
532 : 14180 : inline void Rectangle::SetPos( const Point& rPoint )
533 : : {
534 [ + + ]: 14180 : if ( nRight != RECT_EMPTY )
535 : 6608 : nRight += rPoint.X() - nLeft;
536 [ + + ]: 14180 : if ( nBottom != RECT_EMPTY )
537 : 9935 : nBottom += rPoint.Y() - nTop;
538 : 14180 : nLeft = rPoint.X();
539 : 14180 : nTop = rPoint.Y();
540 : 14180 : }
541 : :
542 : 2900851 : inline long Rectangle::GetWidth() const
543 : : {
544 : : long n;
545 [ + + ]: 2900851 : if ( nRight == RECT_EMPTY )
546 : 77201 : n = 0;
547 : : else
548 : : {
549 : 2823650 : n = nRight - nLeft;
550 [ + + ]: 2823650 : if( n < 0 )
551 : 2820 : n--;
552 : : else
553 : 2820830 : n++;
554 : : }
555 : :
556 : 2900851 : return n;
557 : : }
558 : :
559 : 3375953 : inline long Rectangle::GetHeight() const
560 : : {
561 : : long n;
562 [ + + ]: 3375953 : if ( nBottom == RECT_EMPTY )
563 : 73018 : n = 0;
564 : : else
565 : : {
566 : 3302935 : n = nBottom - nTop;
567 [ + + ]: 3302935 : if ( n < 0 )
568 : 2934 : n--;
569 : : else
570 : 3300001 : n++;
571 : : }
572 : :
573 : 3375953 : return n;
574 : : }
575 : :
576 : 646719 : inline Size Rectangle::GetSize() const
577 : : {
578 : 646719 : return Size( GetWidth(), GetHeight() );
579 : : }
580 : :
581 : 0 : inline Rectangle Rectangle::GetUnion( const Rectangle& rRect ) const
582 : : {
583 : 0 : Rectangle aTmpRect( *this );
584 [ # # ]: 0 : return aTmpRect.Union( rRect );
585 : : }
586 : :
587 : 2381 : inline Rectangle Rectangle::GetIntersection( const Rectangle& rRect ) const
588 : : {
589 : 2381 : Rectangle aTmpRect( *this );
590 [ + - ]: 2381 : return aTmpRect.Intersection( rRect );
591 : : }
592 : :
593 : 17040 : inline sal_Bool Rectangle::operator == ( const Rectangle& rRect ) const
594 : : {
595 : : return ((nLeft == rRect.nLeft ) &&
596 : : (nTop == rRect.nTop ) &&
597 : : (nRight == rRect.nRight ) &&
598 [ + + ][ + + ]: 17040 : (nBottom == rRect.nBottom ));
[ + + ][ + + ]
599 : : }
600 : :
601 : 140341 : inline sal_Bool Rectangle::operator != ( const Rectangle& rRect ) const
602 : : {
603 : : return ((nLeft != rRect.nLeft ) ||
604 : : (nTop != rRect.nTop ) ||
605 : : (nRight != rRect.nRight ) ||
606 [ + + ][ + + ]: 140341 : (nBottom != rRect.nBottom ));
[ + + ][ + + ]
607 : : }
608 : :
609 : 425898 : inline Rectangle& Rectangle::operator +=( const Point& rPt )
610 : : {
611 : 425898 : nLeft += rPt.X();
612 : 425898 : nTop += rPt.Y();
613 [ + + ]: 425898 : if ( nRight != RECT_EMPTY )
614 : 418578 : nRight += rPt.X();
615 [ + + ]: 425898 : if ( nBottom != RECT_EMPTY )
616 : 400845 : nBottom += rPt.Y();
617 : 425898 : return *this;
618 : : }
619 : :
620 : 6 : inline Rectangle& Rectangle::operator -= ( const Point& rPt )
621 : : {
622 : 6 : nLeft -= rPt.X();
623 : 6 : nTop -= rPt.Y();
624 [ + - ]: 6 : if ( nRight != RECT_EMPTY )
625 : 6 : nRight -= rPt.X();
626 [ + - ]: 6 : if ( nBottom != RECT_EMPTY )
627 : 6 : nBottom -= rPt.Y();
628 : 6 : return *this;
629 : : }
630 : :
631 : 10020 : inline Rectangle operator + ( const Rectangle& rRect, const Point& rPt )
632 : : {
633 : 10020 : Rectangle aRect( rRect.nLeft + rPt.X(), rRect.nTop + rPt.Y(),
634 : 10020 : (rRect.nRight == RECT_EMPTY) ? RECT_EMPTY : rRect.nRight + rPt.X(),
635 [ + - ][ + - ]: 30060 : (rRect.nBottom == RECT_EMPTY) ? RECT_EMPTY : rRect.nBottom + rPt.Y() );
636 : 10020 : return aRect;
637 : : }
638 : :
639 : 3072 : inline Rectangle operator - ( const Rectangle& rRect, const Point& rPt )
640 : : {
641 : 3072 : Rectangle aRect( rRect.nLeft - rPt.X(),
642 : 3072 : rRect.nTop - rPt.Y(),
643 : 3072 : (rRect.nRight == RECT_EMPTY) ? RECT_EMPTY : rRect.nRight - rPt.X(),
644 [ + - ][ + - ]: 9216 : (rRect.nBottom == RECT_EMPTY) ? RECT_EMPTY : rRect.nBottom - rPt.Y() );
645 : 3072 : return aRect;
646 : : }
647 : :
648 : : #endif
649 : :
650 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|