LCOV - code coverage report
Current view: top level - libreoffice/solver/unxlngi6.pro/inc/vcl - region.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 7 7 100.0 %
Date: 2012-12-27 Functions: 5 5 100.0 %
Legend: Lines: hit not hit

          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             : 
      20             : #ifndef _SV_REGION_HXX
      21             : #define _SV_REGION_HXX
      22             : 
      23             : #include <tools/gen.hxx>
      24             : #include <tools/solar.h>
      25             : #include <vcl/dllapi.h>
      26             : 
      27             : #include <basegfx/polygon/b2dpolypolygon.hxx>
      28             : 
      29             : class ImplRegion;
      30             : class ImplRegionBand;
      31             : class Polygon;
      32             : class PolyPolygon;
      33             : struct ImplRegionInfo;
      34             : 
      35             : // --------------
      36             : // - RegionType -
      37             : // --------------
      38             : 
      39             : enum RegionType { REGION_NULL, REGION_EMPTY, REGION_RECTANGLE, REGION_COMPLEX };
      40             : enum RegionOverlapType { REGION_INSIDE, REGION_OVER, REGION_OUTSIDE };
      41             : 
      42             : typedef long RegionHandle;
      43             : 
      44             : // ----------
      45             : // - Region -
      46             : // ----------
      47             : 
      48             : class VCL_DLLPUBLIC Region
      49             : {
      50             :     friend class OutputDevice;
      51             :     friend class Window;
      52             :     friend class Bitmap;
      53             : 
      54             : private:
      55             :     ImplRegion*         mpImplRegion;
      56             : 
      57             :     SAL_DLLPRIVATE void             ImplCopyData();
      58             :     SAL_DLLPRIVATE void             ImplCreateRectRegion( const Rectangle& rRect );
      59             :     SAL_DLLPRIVATE void             ImplCreatePolyPolyRegion( const PolyPolygon& rPolyPoly );
      60             :     SAL_DLLPRIVATE void             ImplPolyPolyRegionToBandRegionFunc();
      61             :     SAL_DLLPRIVATE inline void      ImplPolyPolyRegionToBandRegion();
      62        4888 :     SAL_DLLPRIVATE const ImplRegion*    ImplGetImplRegion() const { return mpImplRegion; }
      63             :     SAL_DLLPRIVATE ImplRegion*      ImplGetImplRegion() { return mpImplRegion; }
      64             :     SAL_DLLPRIVATE void             ImplBeginAddRect( );
      65             :     SAL_DLLPRIVATE sal_Bool             ImplAddRect( const Rectangle& rRect );
      66             :     SAL_DLLPRIVATE void             ImplEndAddRect( );
      67             :     SAL_DLLPRIVATE void             ImplIntersectWithPolyPolygon( const Region& );
      68             :     SAL_DLLPRIVATE void             ImplExcludePolyPolygon( const Region& );
      69             :     SAL_DLLPRIVATE void             ImplUnionPolyPolygon( const Region& );
      70             :     SAL_DLLPRIVATE void             ImplXOrPolyPolygon( const Region& );
      71             : 
      72             : public: // public within vcl
      73             :     VCL_PLUGIN_PUBLIC bool              ImplGetFirstRect( ImplRegionInfo& rImplRegionInfo,
      74             :                                           long& nX, long& nY, long& nWidth, long& nHeight ) const;
      75             :     VCL_PLUGIN_PUBLIC bool              ImplGetNextRect( ImplRegionInfo& rImplRegionInfo,
      76             :                                          long& nX, long& nY, long& nWidth, long& nHeight ) const;
      77             : #ifdef DBG_UTIL
      78             :     friend const char*  ImplDbgTestRegion( const void* pObj );
      79             : #endif
      80             : 
      81             : public:
      82             :                     Region();
      83             :                     Region( RegionType eType );
      84             :                     Region( const Rectangle& rRect );
      85             :                     Region( const Polygon& rPolygon );
      86             :                     Region( const PolyPolygon& rPolyPoly );
      87             :                     Region( const basegfx::B2DPolyPolygon& );
      88             :                     Region( const Region& rRegion );
      89             :                     ~Region();
      90             : 
      91             :     void            Move( long nHorzMove, long nVertMove );
      92             :     void            Scale( double fScaleX, double fScaleY );
      93             :     void            Union( const Rectangle& rRegion );
      94             :     void            Intersect( const Rectangle& rRegion );
      95             :     void            Exclude( const Rectangle& rRegion );
      96             :     void            XOr( const Rectangle& rRegion );
      97             :     void            Union( const Region& rRegion );
      98             :     void            Intersect( const Region& rRegion );
      99             :     void            Exclude( const Region& rRegion );
     100             :     void            XOr( const Region& rRegion );
     101             : 
     102             :     RegionType      GetType() const;
     103       43438 :     sal_Bool            IsEmpty() const { return GetType() == REGION_EMPTY; };
     104          12 :     sal_Bool            IsNull() const { return GetType() == REGION_NULL; };
     105             : 
     106             :     void            SetEmpty();
     107             :     void            SetNull();
     108             : 
     109             :     Rectangle       GetBoundRect() const;
     110             : 
     111             :     sal_Bool            HasPolyPolygon() const;
     112             :     PolyPolygon     GetPolyPolygon() const;
     113             :     // returns an empty polypolygon in case HasPolyPolygon is sal_False
     114             :     const basegfx::B2DPolyPolygon GetB2DPolyPolygon() const;
     115             :     // returns a PolyPolygon either copied from the set PolyPolygon region
     116             :     // or created from the constituent rectangles
     117             :     basegfx::B2DPolyPolygon ConvertToB2DPolyPolygon();
     118             : 
     119             :     sal_uLong           GetRectCount() const;
     120             :     RegionHandle    BeginEnumRects();
     121             :     sal_Bool            GetEnumRects( RegionHandle hRegionHandle, Rectangle& rRect );
     122          60 :     sal_Bool            GetNextEnumRect( RegionHandle hRegionHandle, Rectangle& rRect )
     123          60 :                         { return GetEnumRects( hRegionHandle, rRect ); }
     124             :     void            EndEnumRects( RegionHandle hRegionHandle );
     125             : 
     126             :     sal_Bool            IsInside( const Point& rPoint ) const;
     127             :     sal_Bool            IsInside( const Rectangle& rRect ) const;
     128             :     sal_Bool            IsOver( const Rectangle& rRect ) const;
     129             : 
     130             :     Region&         operator=( const Region& rRegion );
     131             :     Region&         operator=( const Rectangle& rRect );
     132             : 
     133             :     sal_Bool            operator==( const Region& rRegion ) const;
     134        1584 :     sal_Bool            operator!=( const Region& rRegion ) const
     135        1584 :                         { return !(Region::operator==( rRegion )); }
     136             : 
     137             :     friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStm, Region& rRegion );
     138             :     friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStm, const Region& rRegion );
     139             : 
     140             :     /* workaround: faster conversion for PolyPolygons
     141             :      * if half of the Polygons contained in rPolyPoly are actually
     142             :      * rectangles, then the returned Region will be constructed by
     143             :      * XOr'ing the contained Polygons together; in the case of
     144             :      * only Rectangles this can be up to eight times faster than
     145             :      * Region( const PolyPolygon& ).
     146             :      * Caution: this is only useful if the Region is known to be
     147             :      * changed to rectangles; e.g. if being set as clip region
     148             :      */
     149             :     static Region GetRegionFromPolyPolygon( const PolyPolygon& rPolyPoly );
     150             : };
     151             : 
     152             : #endif  // _SV_REGION_HXX
     153             : 
     154             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10