LCOV - code coverage report
Current view: top level - include/svx - xpoly.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 2 2 100.0 %
Date: 2014-11-03 Functions: 1 1 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             : #ifndef INCLUDED_SVX_XPOLY_HXX
      20             : #define INCLUDED_SVX_XPOLY_HXX
      21             : 
      22             : #include <basegfx/polygon/b2dpolypolygon.hxx>
      23             : #include <svx/svxdllapi.h>
      24             : 
      25             : class Point;
      26             : class Rectangle;
      27             : class SvStream;
      28             : class Polygon;
      29             : namespace tools { class PolyPolygon; }
      30             : class OutputDevice;
      31             : 
      32             : #define XPOLYPOLY_APPEND     0xFFFF
      33             : #define XPOLY_APPEND         0xFFFF
      34             : 
      35             : #define XPOLY_MAXPOINTS      0xFFF0 /* Let space for the 32-Bit systems too */
      36             : 
      37             : // point-styles in XPolygon:
      38             : // NORMAL : start-/endpoint of a curve or a line
      39             : // SMOOTH : smooth transition between curves
      40             : // SYMMTR : smooth and symmetrical transition between curves
      41             : // CONTROL: control handles of a  Bezier curve
      42             : 
      43             : enum XPolyFlags { XPOLY_NORMAL, XPOLY_SMOOTH, XPOLY_CONTROL, XPOLY_SYMMTR };
      44             : 
      45             : // Class XPolygon;has a point-array and a flag-array, which contains information about a particular point
      46             : 
      47             : class ImpXPolygon;
      48             : 
      49             : class SVX_DLLPUBLIC XPolygon
      50             : {
      51             : protected:
      52             :     ImpXPolygon*    pImpXPolygon;
      53             : 
      54             :     // check ImpXPolygon-ReferenceCount and decouple if necessary
      55             :     void    CheckReference();
      56             : 
      57             :     // auxiliary functions for Bezier conversion
      58             :     void    SubdivideBezier(sal_uInt16 nPos, bool bCalcFirst, double fT);
      59             :     void    GenBezArc(const Point& rCenter, long nRx, long nRy,
      60             :                       long nXHdl, long nYHdl, sal_uInt16 nStart, sal_uInt16 nEnd,
      61             :                       sal_uInt16 nQuad, sal_uInt16 nFirst);
      62             :     bool    CheckAngles(sal_uInt16& nStart, sal_uInt16 nEnd, sal_uInt16& nA1, sal_uInt16& nA2);
      63             : 
      64             : public:
      65             :     XPolygon( sal_uInt16 nSize=16, sal_uInt16 nResize=16 );
      66             :     XPolygon( const XPolygon& rXPoly );
      67             :     XPolygon( const Polygon& rPoly );
      68             :     XPolygon( const Rectangle& rRect, long nRx = 0, long nRy = 0 );
      69             :     XPolygon( const Point& rCenter, long nRx, long nRy,
      70             :               sal_uInt16 nStartAngle = 0, sal_uInt16 nEndAngle = 3600,
      71             :               bool bClose = true );
      72             : 
      73             :     ~XPolygon();
      74             : 
      75             :     sal_uInt16      GetSize() const;
      76             : 
      77             :     void        SetPointCount( sal_uInt16 nPoints );
      78             :     sal_uInt16      GetPointCount() const;
      79             : 
      80             :     void        Insert( sal_uInt16 nPos, const Point& rPt, XPolyFlags eFlags );
      81             :     void        Insert( sal_uInt16 nPos, const XPolygon& rXPoly );
      82             :     void        Remove( sal_uInt16 nPos, sal_uInt16 nCount );
      83             :     void        Move( long nHorzMove, long nVertMove );
      84             :     Rectangle   GetBoundRect() const;
      85             : 
      86             :     const Point&    operator[]( sal_uInt16 nPos ) const;
      87             :           Point&    operator[]( sal_uInt16 nPos );
      88             :     XPolygon&       operator=( const XPolygon& rXPoly );
      89             :     bool            operator==( const XPolygon& rXPoly ) const;
      90             :     bool            operator!=( const XPolygon& rXPoly ) const;
      91             : 
      92             :     XPolyFlags  GetFlags( sal_uInt16 nPos ) const;
      93             :     void        SetFlags( sal_uInt16 nPos, XPolyFlags eFlags );
      94             :     bool        IsControl(sal_uInt16 nPos) const;
      95             :     bool        IsSmooth(sal_uInt16 nPos) const;
      96             : 
      97             :     // distance between two points
      98             :     double  CalcDistance(sal_uInt16 nP1, sal_uInt16 nP2);
      99             : 
     100             :     // Bezier conversion
     101             :     void CalcSmoothJoin(sal_uInt16 nCenter, sal_uInt16 nDrag, sal_uInt16 nPnt);
     102             :     void CalcTangent(sal_uInt16 nCenter, sal_uInt16 nPrev, sal_uInt16 nNext);
     103             :     void PointsToBezier(sal_uInt16 nFirst);
     104             : 
     105             :     // transformations
     106             :     void Translate(const Point& rTrans);
     107             :     void Scale(double fSx, double fSy);
     108             :     void Distort(const Rectangle& rRefRect, const XPolygon& rDistortedRect);
     109             : 
     110             :     // #116512# convert to basegfx::B2DPolygon and return
     111             :     basegfx::B2DPolygon getB2DPolygon() const;
     112             : 
     113             :     // #116512# constructor to convert from basegfx::B2DPolygon
     114             :      // #i76339# made explicit
     115             :      explicit XPolygon(const basegfx::B2DPolygon& rPolygon);
     116             : };
     117             : 
     118             : // Class XPolyPolygon; like PolyPolygon, composed of XPolygons instead of Polygons
     119             : 
     120             : class ImpXPolyPolygon;
     121             : 
     122             : class SVX_DLLPUBLIC XPolyPolygon
     123             : {
     124             : protected:
     125             :     ImpXPolyPolygon* pImpXPolyPolygon;
     126             : 
     127             :     // check ImpXPolyPolygon-ReferenceCount and decouple if necessary
     128             :     void    CheckReference();
     129             : 
     130             : public:
     131             :                     XPolyPolygon( sal_uInt16 nInitSize = 16, sal_uInt16 nResize = 16 );
     132             :                     XPolyPolygon( const XPolyPolygon& rXPolyPoly );
     133             : 
     134             :                     ~XPolyPolygon();
     135             : 
     136             :     void            Insert( const XPolygon& rXPoly,
     137             :                             sal_uInt16 nPos = XPOLYPOLY_APPEND );
     138             :     void            Insert( const XPolyPolygon& rXPoly,
     139             :                             sal_uInt16 nPos=XPOLYPOLY_APPEND );
     140             :     XPolygon        Remove( sal_uInt16 nPos );
     141             :     const XPolygon& GetObject( sal_uInt16 nPos ) const;
     142             : 
     143             :     void            Clear();
     144             :     sal_uInt16          Count() const;
     145             : 
     146             :     Rectangle       GetBoundRect() const;
     147             : 
     148           6 :     const XPolygon& operator[]( sal_uInt16 nPos ) const
     149           6 :                         { return GetObject( nPos ); }
     150             :     XPolygon&       operator[]( sal_uInt16 nPos );
     151             : 
     152             :     XPolyPolygon&   operator=( const XPolyPolygon& rXPolyPoly );
     153             :     bool            operator==( const XPolyPolygon& rXPolyPoly ) const;
     154             :     bool            operator!=( const XPolyPolygon& rXPolyPoly ) const;
     155             : 
     156             :     // transformations
     157             :     void Distort(const Rectangle& rRefRect, const XPolygon& rDistortedRect);
     158             : 
     159             :     // #116512# convert to basegfx::B2DPolyPolygon and return
     160             :     basegfx::B2DPolyPolygon getB2DPolyPolygon() const;
     161             : 
     162             :     // #116512# constructor to convert from basegfx::B2DPolyPolygon
     163             :      // #i76339# made explicit
     164             :      explicit XPolyPolygon(const basegfx::B2DPolyPolygon& rPolyPolygon);
     165             : };
     166             : 
     167             : #endif // INCLUDED_SVX_XPOLY_HXX
     168             : 
     169             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10