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

Generated by: LCOV version 1.11