LCOV - code coverage report
Current view: top level - tools/inc/tools - gen.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 77 93 82.8 %
Date: 2012-08-25 Functions: 35 43 81.4 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 31 44 70.5 %

           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                 :            :     long                A() const { return nA; }
      41                 :            :     long                B() const { return nB; }
      42                 :            : 
      43                 :            :     long&               A() { return nA; }
      44                 :            :     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                 :      10216 : inline Pair::Pair()
      54                 :            : {
      55                 :      10216 :     nA = nB = 0;
      56                 :      10216 : }
      57                 :            : 
      58                 :    2211956 : inline Pair::Pair( long _nA, long _nB )
      59                 :            : {
      60                 :    2211956 :     Pair::nA = _nA;
      61                 :    2211956 :     Pair::nB = _nB;
      62                 :    2211956 : }
      63                 :            : 
      64                 :       1321 : inline sal_Bool Pair::operator == ( const Pair& rPair ) const
      65                 :            : {
      66 [ +  - ][ +  + ]:       1321 :     return ((nA == rPair.nA) && (nB == rPair.nB));
      67                 :            : }
      68                 :            : 
      69                 :       1848 : inline sal_Bool Pair::operator != ( const Pair& rPair ) const
      70                 :            : {
      71 [ +  + ][ +  - ]:       1848 :     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                 :    2493661 :     long                X() const { return nA; }
      83                 :    2493683 :     long                Y() const { return nB; }
      84                 :            : 
      85                 :    5256395 :     long&               X() { return nA; }
      86                 :    5256395 :     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                 :            :     long                getX() const { return X(); }
     105                 :            :     long                getY() const { return Y(); }
     106                 :            :     void                setX(long nX)  { X() = nX; }
     107                 :            :     void                setY(long nY)  { Y() = nY; }
     108                 :            : };
     109                 :            : 
     110                 :      10216 : inline Point::Point()
     111                 :            : {
     112                 :      10216 : }
     113                 :            : 
     114                 :    2211866 : inline Point::Point( long nX, long nY ) : Pair( nX, nY )
     115                 :            : {
     116                 :    2211866 : }
     117                 :            : 
     118                 :            : inline void Point::Move( long nHorzMove, long nVertMove )
     119                 :            : {
     120                 :            :     nA += nHorzMove;
     121                 :            :     nB += nVertMove;
     122                 :            : }
     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                 :     133888 : inline Point& Point::operator += ( const Point& rPoint )
     145                 :            : {
     146                 :     133888 :     nA += rPoint.nA;
     147                 :     133888 :     nB += rPoint.nB;
     148                 :     133888 :     return *this;
     149                 :            : }
     150                 :            : 
     151                 :            : inline Point& Point::operator -= ( const Point& rPoint )
     152                 :            : {
     153                 :            :     nA -= rPoint.nA;
     154                 :            :     nB -= rPoint.nB;
     155                 :            :     return *this;
     156                 :            : }
     157                 :            : 
     158                 :            : inline Point& Point::operator *= ( const long nVal )
     159                 :            : {
     160                 :            :     nA *= nVal;
     161                 :            :     nB *= nVal;
     162                 :            :     return *this;
     163                 :            : }
     164                 :            : 
     165                 :            : inline Point& Point::operator /= ( const long nVal )
     166                 :            : {
     167                 :            :     nA /= nVal;
     168                 :            :     nB /= nVal;
     169                 :            :     return *this;
     170                 :            : }
     171                 :            : 
     172                 :            : inline Point operator+( const Point &rVal1, const Point &rVal2 )
     173                 :            : {
     174                 :            :     return Point( rVal1.nA+rVal2.nA, rVal1.nB+rVal2.nB );
     175                 :            : }
     176                 :            : 
     177                 :            : inline Point operator-( const Point &rVal1, const Point &rVal2 )
     178                 :            : {
     179                 :            :     return Point( rVal1.nA-rVal2.nA, rVal1.nB-rVal2.nB );
     180                 :            : }
     181                 :            : 
     182                 :            : inline Point operator*( const Point &rVal1, const long nVal2 )
     183                 :            : {
     184                 :            :     return Point( rVal1.nA*nVal2, rVal1.nB*nVal2 );
     185                 :            : }
     186                 :            : 
     187                 :            : inline Point operator/( const Point &rVal1, const long nVal2 )
     188                 :            : {
     189                 :            :     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                 :     720048 :     long            Width() const  { return nA; }
     201                 :     723401 :     long            Height() const { return nB; }
     202                 :            : 
     203                 :          0 :     long&           Width()  { return nA; }
     204                 :          0 :     long&           Height() { return nB; }
     205                 :            : 
     206                 :            :     long                getWidth() const { return Width(); }
     207                 :            :     long                getHeight() const { return Height(); }
     208                 :            :     void                setWidth(long nWidth)  { Width() = nWidth; }
     209                 :            :     void                setHeight(long nHeight)  { Height() = nHeight; }
     210                 :            : };
     211                 :            : 
     212                 :            : inline Size::Size()
     213                 :            : {
     214                 :            : }
     215                 :            : 
     216                 :          0 : inline Size::Size( long nWidth, long nHeight ) :
     217                 :          0 :                 Pair( nWidth, nHeight )
     218                 :            : {
     219                 :          0 : }
     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                 :        654 :     long            Min() const { return nA; }
     232                 :        654 :     long            Max() const { return nB; }
     233                 :        692 :     long            Len() const { return nB - nA + 1; }
     234                 :            : 
     235                 :        364 :     long&           Min() { return nA; }
     236                 :       1434 :     long&           Max() { return nB; }
     237                 :            : 
     238                 :            :     sal_Bool            IsInside( long nIs ) const;
     239                 :            : 
     240                 :            :     void            Justify();
     241                 :            : };
     242                 :            : 
     243                 :            : inline Range::Range()
     244                 :            : {
     245                 :            : }
     246                 :            : 
     247                 :         90 : inline Range::Range( long nMin, long nMax ) : Pair( nMin, nMax )
     248                 :            : {
     249                 :         90 : }
     250                 :            : 
     251                 :        214 : inline sal_Bool Range::IsInside( long nIs ) const
     252                 :            : {
     253 [ +  + ][ +  - ]:        214 :     return ((nA <= nIs) && (nIs <= nB ));
     254                 :            : }
     255                 :            : 
     256                 :            : inline void Range::Justify()
     257                 :            : {
     258                 :            :     if ( nA > nB )
     259                 :            :     {
     260                 :            :         long nHelp = nA;
     261                 :            :         nA = nB;
     262                 :            :         nB = nHelp;
     263                 :            :     }
     264                 :            : }
     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                 :            :     long            Min() const { return nA; }
     279                 :            :     long            Max() const { return nB; }
     280                 :            :     long            Len() const { return nB - nA; }
     281                 :            : 
     282                 :            :     long&           Min() { return nA; }
     283                 :            :     long&           Max() { return nB; }
     284                 :            : 
     285                 :            :     sal_Bool            IsInside( long nIs ) const;
     286                 :            : 
     287                 :            :     void            Justify();
     288                 :            : 
     289                 :            :     sal_Bool            operator !() const { return !Len(); }
     290                 :            : 
     291                 :            :     long                getMin() const { return Min(); }
     292                 :            :     long                getMax() const { return Max(); }
     293                 :            :     void                setMin(long nMin)  { Min() = nMin; }
     294                 :            :     void                setMax(long nMax)  { Max() = nMax; }
     295                 :            : };
     296                 :            : 
     297                 :            : inline Selection::Selection()
     298                 :            : {
     299                 :            : }
     300                 :            : 
     301                 :            : inline Selection::Selection( long nPos ) : Pair( nPos, nPos )
     302                 :            : {
     303                 :            : }
     304                 :            : 
     305                 :            : inline Selection::Selection( long nMin, long nMax ) :
     306                 :            :            Pair( nMin, nMax )
     307                 :            : {
     308                 :            : }
     309                 :            : 
     310                 :            : inline sal_Bool Selection::IsInside( long nIs ) const
     311                 :            : {
     312                 :            :     return ((nA <= nIs) && (nIs < nB ));
     313                 :            : }
     314                 :            : 
     315                 :            : inline void Selection::Justify()
     316                 :            : {
     317                 :            :     if ( nA > nB )
     318                 :            :     {
     319                 :            :         long nHelp = nA;
     320                 :            :         nA = nB;
     321                 :            :         nB = nHelp;
     322                 :            :     }
     323                 :            : }
     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                 :          0 :     long                Left() const    { return nLeft;   }
     344                 :          0 :     long                Right() const   { return nRight;  }
     345                 :          0 :     long                Top() const     { return nTop;    }
     346                 :            :     long                Bottom() const  { return nBottom; }
     347                 :            : 
     348                 :       9104 :     long&               Left()          { return nLeft;   }
     349                 :       8368 :     long&               Right()         { return nRight;  }
     350                 :       9104 :     long&               Top()           { return nTop;    }
     351                 :       8368 :     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                 :            :     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                 :            :     long                getX() const { return nLeft; }
     400                 :            :     long                getY() const { return nTop; }
     401                 :            :     long                getWidth() const { return nRight - nLeft; }
     402                 :            :     long                getHeight() const { return nBottom - nTop; }
     403                 :            :     void                setX( long n ) { nRight += n-nLeft; nLeft = n; }
     404                 :            :     void                setY( long n ) { nBottom += n-nTop; nTop = n; }
     405                 :            :     void                setWidth( long n ) { nRight = nLeft + n; }
     406                 :            :     void                setHeight( long n ) { nBottom = nTop + n; }
     407                 :            : };
     408                 :            : 
     409                 :     399910 : inline Rectangle::Rectangle()
     410                 :            : {
     411                 :     399910 :     nLeft = nTop = 0;
     412                 :     399910 :     nRight = nBottom = RECT_EMPTY;
     413                 :     399910 : }
     414                 :            : 
     415                 :            : inline Rectangle::Rectangle( const Point& rLT, const Point& rRB )
     416                 :            : {
     417                 :            :     nLeft   = rLT.X();
     418                 :            :     nTop    = rLT.Y();
     419                 :            :     nRight  = rRB.X();
     420                 :            :     nBottom = rRB.Y();
     421                 :            : }
     422                 :            : 
     423                 :      13167 : inline Rectangle::Rectangle( long _nLeft,  long _nTop,
     424                 :            :                              long _nRight, long _nBottom )
     425                 :            : {
     426                 :      13167 :     nLeft   = _nLeft;
     427                 :      13167 :     nTop    = _nTop;
     428                 :      13167 :     nRight  = _nRight;
     429                 :      13167 :     nBottom = _nBottom;
     430                 :      13167 : }
     431                 :            : 
     432                 :            : inline Rectangle::Rectangle( const Point& rLT, const Size& rSize )
     433                 :            : {
     434                 :            :     nLeft   = rLT.X();
     435                 :            :     nTop    = rLT.Y();
     436                 :            :     nRight  = rSize.Width()  ? nLeft+rSize.Width()-1 : RECT_EMPTY;
     437                 :            :     nBottom = rSize.Height() ? nTop+rSize.Height()-1 : RECT_EMPTY;
     438                 :            : }
     439                 :            : 
     440                 :    4292378 : inline sal_Bool Rectangle::IsEmpty() const
     441                 :            : {
     442 [ +  + ][ +  + ]:    4292378 :     return ((nRight == RECT_EMPTY) || (nBottom == RECT_EMPTY));
     443                 :            : }
     444                 :            : 
     445                 :      81842 : inline Point Rectangle::TopLeft() const
     446                 :            : {
     447                 :      81842 :     return Point( nLeft, nTop );
     448                 :            : }
     449                 :            : 
     450                 :      16189 : inline Point Rectangle::TopRight() const
     451                 :            : {
     452         [ -  + ]:      16189 :     return Point( (nRight == RECT_EMPTY) ? nLeft : nRight, nTop );
     453                 :            : }
     454                 :            : 
     455                 :      16189 : inline Point Rectangle::BottomLeft() const
     456                 :            : {
     457         [ -  + ]:      16189 :     return Point( nLeft, (nBottom == RECT_EMPTY) ? nTop : nBottom );
     458                 :            : }
     459                 :            : 
     460                 :      64437 : inline Point Rectangle::BottomRight() const
     461                 :            : {
     462                 :            :     return Point( (nRight  == RECT_EMPTY) ? nLeft : nRight,
     463 [ -  + ][ -  + ]:      64437 :                   (nBottom == RECT_EMPTY) ? nTop  : nBottom );
     464                 :            : }
     465                 :            : 
     466                 :            : inline Point Rectangle::TopCenter() const
     467                 :            : {
     468                 :            :     if ( IsEmpty() )
     469                 :            :         return Point( nLeft, nTop );
     470                 :            :     else
     471                 :            :         return Point( Min( nLeft, nRight ) + Abs( (nRight - nLeft)/2 ),
     472                 :            :                       Min( nTop,  nBottom) );
     473                 :            : }
     474                 :            : 
     475                 :            : inline Point Rectangle::BottomCenter() const
     476                 :            : {
     477                 :            :     if ( IsEmpty() )
     478                 :            :         return Point( nLeft, nTop );
     479                 :            :     else
     480                 :            :         return Point( Min( nLeft, nRight ) + Abs( (nRight - nLeft)/2 ),
     481                 :            :                       Max( nTop,  nBottom) );
     482                 :            : }
     483                 :            : 
     484                 :            : inline Point Rectangle::LeftCenter() const
     485                 :            : {
     486                 :            :     if ( IsEmpty() )
     487                 :            :         return Point( nLeft, nTop );
     488                 :            :     else
     489                 :            :         return Point( Min( nLeft, nRight ), nTop + (nBottom - nTop)/2 );
     490                 :            : }
     491                 :            : 
     492                 :            : inline Point Rectangle::RightCenter() const
     493                 :            : {
     494                 :            :     if ( IsEmpty() )
     495                 :            :         return Point( nLeft, nTop );
     496                 :            :     else
     497                 :            :         return Point( Max( nLeft, nRight ), nTop + (nBottom - nTop)/2 );
     498                 :            : }
     499                 :            : 
     500                 :          0 : inline Point Rectangle::Center() const
     501                 :            : {
     502         [ #  # ]:          0 :     if ( IsEmpty() )
     503                 :          0 :         return Point( nLeft, nTop );
     504                 :            :     else
     505                 :          0 :         return Point( nLeft+(nRight-nLeft)/2 , nTop+(nBottom-nTop)/2 );
     506                 :            : }
     507                 :            : 
     508                 :            : inline void Rectangle::Move( long nHorzMove, long nVertMove )
     509                 :            : {
     510                 :            :     nLeft += nHorzMove;
     511                 :            :     nTop  += nVertMove;
     512                 :            :     if ( nRight != RECT_EMPTY )
     513                 :            :         nRight += nHorzMove;
     514                 :            :     if ( nBottom != RECT_EMPTY )
     515                 :            :         nBottom += nVertMove;
     516                 :            : }
     517                 :            : 
     518                 :            : void Rectangle::Transpose()
     519                 :            : {
     520                 :            :     if ( !IsEmpty() )
     521                 :            :     {
     522                 :            :         long swap( nLeft );
     523                 :            :         nLeft = nTop;
     524                 :            :         nTop = swap;
     525                 :            : 
     526                 :            :         swap = nRight;
     527                 :            :         nRight = nBottom;
     528                 :            :         nBottom = swap;
     529                 :            :     }
     530                 :            : }
     531                 :            : 
     532                 :            : inline void Rectangle::SetPos( const Point& rPoint )
     533                 :            : {
     534                 :            :     if ( nRight != RECT_EMPTY )
     535                 :            :         nRight += rPoint.X() - nLeft;
     536                 :            :     if ( nBottom != RECT_EMPTY )
     537                 :            :         nBottom += rPoint.Y() - nTop;
     538                 :            :     nLeft = rPoint.X();
     539                 :            :     nTop  = rPoint.Y();
     540                 :            : }
     541                 :            : 
     542                 :       5831 : inline long Rectangle::GetWidth() const
     543                 :            : {
     544                 :            :     long n;
     545         [ +  + ]:       5831 :     if ( nRight == RECT_EMPTY )
     546                 :        175 :         n = 0;
     547                 :            :     else
     548                 :            :     {
     549                 :       5656 :         n = nRight - nLeft;
     550         [ -  + ]:       5656 :         if( n < 0 )
     551                 :          0 :             n--;
     552                 :            :         else
     553                 :       5656 :             n++;
     554                 :            :     }
     555                 :            : 
     556                 :       5831 :     return n;
     557                 :            : }
     558                 :            : 
     559                 :       5831 : inline long Rectangle::GetHeight() const
     560                 :            : {
     561                 :            :     long n;
     562         [ +  + ]:       5831 :     if ( nBottom == RECT_EMPTY )
     563                 :        175 :         n = 0;
     564                 :            :     else
     565                 :            :     {
     566                 :       5656 :         n = nBottom - nTop;
     567         [ -  + ]:       5656 :         if ( n < 0 )
     568                 :          0 :             n--;
     569                 :            :         else
     570                 :       5656 :             n++;
     571                 :            :     }
     572                 :            : 
     573                 :       5831 :     return n;
     574                 :            : }
     575                 :            : 
     576                 :          0 : inline Size Rectangle::GetSize() const
     577                 :            : {
     578                 :          0 :     return Size( GetWidth(), GetHeight() );
     579                 :            : }
     580                 :            : 
     581                 :            : inline Rectangle Rectangle::GetUnion( const Rectangle& rRect ) const
     582                 :            : {
     583                 :            :     Rectangle aTmpRect( *this );
     584                 :            :     return aTmpRect.Union( rRect );
     585                 :            : }
     586                 :            : 
     587                 :     640754 : inline Rectangle Rectangle::GetIntersection( const Rectangle& rRect ) const
     588                 :            : {
     589                 :     640754 :     Rectangle aTmpRect( *this );
     590         [ +  - ]:     640754 :     return aTmpRect.Intersection( rRect );
     591                 :            : }
     592                 :            : 
     593                 :            : inline sal_Bool Rectangle::operator == ( const Rectangle& rRect ) const
     594                 :            : {
     595                 :            :     return ((nLeft   == rRect.nLeft   ) &&
     596                 :            :             (nTop    == rRect.nTop    ) &&
     597                 :            :             (nRight  == rRect.nRight  ) &&
     598                 :            :             (nBottom == rRect.nBottom ));
     599                 :            : }
     600                 :            : 
     601                 :       4625 : inline sal_Bool Rectangle::operator != ( const Rectangle& rRect ) const
     602                 :            : {
     603                 :            :     return ((nLeft   != rRect.nLeft   ) ||
     604                 :            :             (nTop    != rRect.nTop    ) ||
     605                 :            :             (nRight  != rRect.nRight  ) ||
     606 [ +  + ][ +  + ]:       4625 :             (nBottom != rRect.nBottom ));
         [ +  + ][ -  + ]
     607                 :            : }
     608                 :            : 
     609                 :            : inline Rectangle& Rectangle::operator +=( const Point& rPt )
     610                 :            : {
     611                 :            :     nLeft += rPt.X();
     612                 :            :     nTop  += rPt.Y();
     613                 :            :     if ( nRight != RECT_EMPTY )
     614                 :            :         nRight += rPt.X();
     615                 :            :     if ( nBottom != RECT_EMPTY )
     616                 :            :         nBottom += rPt.Y();
     617                 :            :     return *this;
     618                 :            : }
     619                 :            : 
     620                 :            : inline Rectangle& Rectangle::operator -= ( const Point& rPt )
     621                 :            : {
     622                 :            :     nLeft -= rPt.X();
     623                 :            :     nTop  -= rPt.Y();
     624                 :            :     if ( nRight != RECT_EMPTY )
     625                 :            :         nRight -= rPt.X();
     626                 :            :     if ( nBottom != RECT_EMPTY )
     627                 :            :         nBottom -= rPt.Y();
     628                 :            :     return *this;
     629                 :            : }
     630                 :            : 
     631                 :            : inline Rectangle operator + ( const Rectangle& rRect, const Point& rPt )
     632                 :            : {
     633                 :            :     Rectangle aRect( rRect.nLeft  + rPt.X(), rRect.nTop    + rPt.Y(),
     634                 :            :                      (rRect.nRight  == RECT_EMPTY) ? RECT_EMPTY : rRect.nRight + rPt.X(),
     635                 :            :                      (rRect.nBottom == RECT_EMPTY) ? RECT_EMPTY : rRect.nBottom + rPt.Y() );
     636                 :            :     return aRect;
     637                 :            : }
     638                 :            : 
     639                 :            : inline Rectangle operator - ( const Rectangle& rRect, const Point& rPt )
     640                 :            : {
     641                 :            :     Rectangle aRect( rRect.nLeft - rPt.X(),
     642                 :            :                      rRect.nTop - rPt.Y(),
     643                 :            :                      (rRect.nRight  == RECT_EMPTY) ? RECT_EMPTY : rRect.nRight - rPt.X(),
     644                 :            :                      (rRect.nBottom == RECT_EMPTY) ? RECT_EMPTY : rRect.nBottom - rPt.Y() );
     645                 :            :     return aRect;
     646                 :            : }
     647                 :            : 
     648                 :            : #endif
     649                 :            : 
     650                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10