LCOV - code coverage report
Current view: top level - solver/unxlngi6.pro/inc/vcl - region.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 7 7 100.0 %
Date: 2012-08-25 Functions: 5 5 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef _SV_REGION_HXX
      30                 :            : #define _SV_REGION_HXX
      31                 :            : 
      32                 :            : #include <tools/gen.hxx>
      33                 :            : #include <tools/solar.h>
      34                 :            : #include <vcl/dllapi.h>
      35                 :            : 
      36                 :            : #include <basegfx/polygon/b2dpolypolygon.hxx>
      37                 :            : 
      38                 :            : class ImplRegion;
      39                 :            : class ImplRegionBand;
      40                 :            : class Polygon;
      41                 :            : class PolyPolygon;
      42                 :            : struct ImplRegionInfo;
      43                 :            : 
      44                 :            : // --------------
      45                 :            : // - RegionType -
      46                 :            : // --------------
      47                 :            : 
      48                 :            : enum RegionType { REGION_NULL, REGION_EMPTY, REGION_RECTANGLE, REGION_COMPLEX };
      49                 :            : enum RegionOverlapType { REGION_INSIDE, REGION_OVER, REGION_OUTSIDE };
      50                 :            : 
      51                 :            : typedef long RegionHandle;
      52                 :            : 
      53                 :            : // ----------
      54                 :            : // - Region -
      55                 :            : // ----------
      56                 :            : 
      57                 :            : class VCL_DLLPUBLIC Region
      58                 :            : {
      59                 :            :     friend class OutputDevice;
      60                 :            :     friend class Window;
      61                 :            :     friend class Bitmap;
      62                 :            : 
      63                 :            : private:
      64                 :            :     ImplRegion*         mpImplRegion;
      65                 :            : 
      66                 :            :     SAL_DLLPRIVATE void             ImplCopyData();
      67                 :            :     SAL_DLLPRIVATE void             ImplCreateRectRegion( const Rectangle& rRect );
      68                 :            :     SAL_DLLPRIVATE void             ImplCreatePolyPolyRegion( const PolyPolygon& rPolyPoly );
      69                 :            :     SAL_DLLPRIVATE void             ImplPolyPolyRegionToBandRegionFunc();
      70                 :            :     SAL_DLLPRIVATE inline void      ImplPolyPolyRegionToBandRegion();
      71                 :     137008 :     SAL_DLLPRIVATE const ImplRegion*    ImplGetImplRegion() const { return mpImplRegion; }
      72                 :            :     SAL_DLLPRIVATE ImplRegion*      ImplGetImplRegion() { return mpImplRegion; }
      73                 :            :     SAL_DLLPRIVATE void             ImplBeginAddRect( );
      74                 :            :     SAL_DLLPRIVATE sal_Bool             ImplAddRect( const Rectangle& rRect );
      75                 :            :     SAL_DLLPRIVATE void             ImplEndAddRect( );
      76                 :            :     SAL_DLLPRIVATE void             ImplIntersectWithPolyPolygon( const Region& );
      77                 :            :     SAL_DLLPRIVATE void             ImplExcludePolyPolygon( const Region& );
      78                 :            :     SAL_DLLPRIVATE void             ImplUnionPolyPolygon( const Region& );
      79                 :            :     SAL_DLLPRIVATE void             ImplXOrPolyPolygon( const Region& );
      80                 :            : 
      81                 :            : public: // public within vcl
      82                 :            :     VCL_PLUGIN_PUBLIC bool              ImplGetFirstRect( ImplRegionInfo& rImplRegionInfo,
      83                 :            :                                           long& nX, long& nY, long& nWidth, long& nHeight ) const;
      84                 :            :     VCL_PLUGIN_PUBLIC bool              ImplGetNextRect( ImplRegionInfo& rImplRegionInfo,
      85                 :            :                                          long& nX, long& nY, long& nWidth, long& nHeight ) const;
      86                 :            : #ifdef DBG_UTIL
      87                 :            :     friend const char*  ImplDbgTestRegion( const void* pObj );
      88                 :            : #endif
      89                 :            : 
      90                 :            : public:
      91                 :            :                     Region();
      92                 :            :                     Region( RegionType eType );
      93                 :            :                     Region( const Rectangle& rRect );
      94                 :            :                     Region( const Polygon& rPolygon );
      95                 :            :                     Region( const PolyPolygon& rPolyPoly );
      96                 :            :                     Region( const basegfx::B2DPolyPolygon& );
      97                 :            :                     Region( const Region& rRegion );
      98                 :            :                     ~Region();
      99                 :            : 
     100                 :            :     void            Move( long nHorzMove, long nVertMove );
     101                 :            :     void            Scale( double fScaleX, double fScaleY );
     102                 :            :     void            Union( const Rectangle& rRegion );
     103                 :            :     void            Intersect( const Rectangle& rRegion );
     104                 :            :     void            Exclude( const Rectangle& rRegion );
     105                 :            :     void            XOr( const Rectangle& rRegion );
     106                 :            :     void            Union( const Region& rRegion );
     107                 :            :     void            Intersect( const Region& rRegion );
     108                 :            :     void            Exclude( const Region& rRegion );
     109                 :            :     void            XOr( const Region& rRegion );
     110                 :            : 
     111                 :            :     RegionType      GetType() const;
     112                 :    1470034 :     sal_Bool            IsEmpty() const { return GetType() == REGION_EMPTY; };
     113                 :     120216 :     sal_Bool            IsNull() const { return GetType() == REGION_NULL; };
     114                 :            : 
     115                 :            :     void            SetEmpty();
     116                 :            :     void            SetNull();
     117                 :            : 
     118                 :            :     Rectangle       GetBoundRect() const;
     119                 :            : 
     120                 :            :     sal_Bool            HasPolyPolygon() const;
     121                 :            :     PolyPolygon     GetPolyPolygon() const;
     122                 :            :     // returns an empty polypolygon in case HasPolyPolygon is sal_False
     123                 :            :     const basegfx::B2DPolyPolygon GetB2DPolyPolygon() const;
     124                 :            :     // returns a PolyPolygon either copied from the set PolyPolygon region
     125                 :            :     // or created from the constituent rectangles
     126                 :            :     basegfx::B2DPolyPolygon ConvertToB2DPolyPolygon();
     127                 :            : 
     128                 :            :     sal_uLong           GetRectCount() const;
     129                 :            :     RegionHandle    BeginEnumRects();
     130                 :            :     sal_Bool            GetEnumRects( RegionHandle hRegionHandle, Rectangle& rRect );
     131                 :     340942 :     sal_Bool            GetNextEnumRect( RegionHandle hRegionHandle, Rectangle& rRect )
     132                 :     340942 :                         { return GetEnumRects( hRegionHandle, rRect ); }
     133                 :            :     void            EndEnumRects( RegionHandle hRegionHandle );
     134                 :            : 
     135                 :            :     sal_Bool            IsInside( const Point& rPoint ) const;
     136                 :            :     sal_Bool            IsInside( const Rectangle& rRect ) const;
     137                 :            :     sal_Bool            IsOver( const Rectangle& rRect ) const;
     138                 :            : 
     139                 :            :     Region&         operator=( const Region& rRegion );
     140                 :            :     Region&         operator=( const Rectangle& rRect );
     141                 :            : 
     142                 :            :     sal_Bool            operator==( const Region& rRegion ) const;
     143                 :      33572 :     sal_Bool            operator!=( const Region& rRegion ) const
     144                 :      33572 :                         { return !(Region::operator==( rRegion )); }
     145                 :            : 
     146                 :            :     friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStm, Region& rRegion );
     147                 :            :     friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStm, const Region& rRegion );
     148                 :            : 
     149                 :            :     /* workaround: faster conversion for PolyPolygons
     150                 :            :      * if half of the Polygons contained in rPolyPoly are actually
     151                 :            :      * rectangles, then the returned Region will be constructed by
     152                 :            :      * XOr'ing the contained Polygons together; in the case of
     153                 :            :      * only Rectangles this can be up to eight times faster than
     154                 :            :      * Region( const PolyPolygon& ).
     155                 :            :      * Caution: this is only useful if the Region is known to be
     156                 :            :      * changed to rectangles; e.g. if being set as clip region
     157                 :            :      */
     158                 :            :     static Region GetRegionFromPolyPolygon( const PolyPolygon& rPolyPoly );
     159                 :            : };
     160                 :            : 
     161                 :            : #endif  // _SV_REGION_HXX
     162                 :            : 
     163                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10