LCOV - code coverage report
Current view: top level - basegfx/source/tools - unopolypolygon.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 9 177 5.1 %
Date: 2012-08-25 Functions: 2 21 9.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 6 404 1.5 %

           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                 :            : #include <com/sun/star/geometry/AffineMatrix2D.hpp>
      30                 :            : #include <com/sun/star/rendering/RenderState.hpp>
      31                 :            : #include <com/sun/star/rendering/ViewState.hpp>
      32                 :            : #include <com/sun/star/rendering/XCanvas.hpp>
      33                 :            : #include <com/sun/star/rendering/CompositeOperation.hpp>
      34                 :            : 
      35                 :            : #include <basegfx/matrix/b2dhommatrix.hxx>
      36                 :            : #include <basegfx/range/b2drange.hxx>
      37                 :            : #include <basegfx/range/b2drectangle.hxx>
      38                 :            : #include <basegfx/point/b2dpoint.hxx>
      39                 :            : #include <basegfx/tools/canvastools.hxx>
      40                 :            : #include <basegfx/polygon/b2dpolygon.hxx>
      41                 :            : #include <basegfx/polygon/b2dpolypolygontools.hxx>
      42                 :            : #include <basegfx/tools/unopolypolygon.hxx>
      43                 :            : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      44                 :            : 
      45                 :            : 
      46                 :            : using namespace ::com::sun::star;
      47                 :            : 
      48                 :            : namespace basegfx
      49                 :            : {
      50                 :            : namespace unotools
      51                 :            : {
      52                 :         45 :     UnoPolyPolygon::UnoPolyPolygon( const B2DPolyPolygon& rPolyPoly ) :
      53                 :            :         UnoPolyPolygonBase( m_aMutex ),
      54                 :            :         maPolyPoly( rPolyPoly ),
      55         [ +  - ]:         45 :         meFillRule( rendering::FillRule_EVEN_ODD )
      56                 :            :     {
      57                 :            :         // or else races will haunt us.
      58         [ +  - ]:         45 :         maPolyPoly.makeUnique();
      59                 :         45 :     }
      60                 :            : 
      61                 :          0 :     void SAL_CALL UnoPolyPolygon::addPolyPolygon(
      62                 :            :         const geometry::RealPoint2D&                        position,
      63                 :            :         const uno::Reference< rendering::XPolyPolygon2D >&  polyPolygon ) throw (lang::IllegalArgumentException,uno::RuntimeException)
      64                 :            :     {
      65         [ #  # ]:          0 :         osl::MutexGuard const guard( m_aMutex );
      66         [ #  # ]:          0 :         modifying();
      67                 :            : 
      68                 :            :         // TODO(F1): Correctly fulfill the UNO API
      69                 :            :         // specification. This will probably result in a vector of
      70                 :            :         // poly-polygons to be stored in this object.
      71                 :            : 
      72 [ #  # ][ #  # ]:          0 :         const sal_Int32 nPolys( polyPolygon->getNumberOfPolygons() );
      73                 :            : 
      74 [ #  # ][ #  # ]:          0 :         if( !polyPolygon.is() || !nPolys )
                 [ #  # ]
      75                 :            :         {
      76                 :            :             // invalid or empty polygon - nothing to do.
      77                 :          0 :             return;
      78                 :            :         }
      79                 :            : 
      80         [ #  # ]:          0 :         B2DPolyPolygon        aSrcPoly;
      81 [ #  # ][ #  # ]:          0 :         const UnoPolyPolygon* pSrc( dynamic_cast< UnoPolyPolygon* >(polyPolygon.get()) );
      82                 :            : 
      83                 :            :         // try to extract polygon data from interface. First,
      84                 :            :         // check whether it's the same implementation object,
      85                 :            :         // which we can tunnel then.
      86         [ #  # ]:          0 :         if( pSrc )
      87                 :            :         {
      88 [ #  # ][ #  # ]:          0 :             aSrcPoly = pSrc->getPolyPolygon();
                 [ #  # ]
      89                 :            :         }
      90                 :            :         else
      91                 :            :         {
      92                 :            :             // not a known implementation object - try data source
      93                 :            :             // interfaces
      94                 :            :             uno::Reference< rendering::XBezierPolyPolygon2D > xBezierPoly(
      95                 :            :                 polyPolygon,
      96         [ #  # ]:          0 :                 uno::UNO_QUERY );
      97                 :            : 
      98         [ #  # ]:          0 :             if( xBezierPoly.is() )
      99                 :            :             {
     100                 :            :                 aSrcPoly = unotools::polyPolygonFromBezier2DSequenceSequence(
     101         [ #  # ]:          0 :                     xBezierPoly->getBezierSegments( 0,
     102                 :            :                                                     nPolys,
     103                 :            :                                                     0,
     104 [ #  # ][ #  # ]:          0 :                                                     -1 ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     105                 :            :             }
     106                 :            :             else
     107                 :            :             {
     108                 :            :                 uno::Reference< rendering::XLinePolyPolygon2D > xLinePoly(
     109                 :            :                     polyPolygon,
     110         [ #  # ]:          0 :                     uno::UNO_QUERY );
     111                 :            : 
     112                 :            :                 // no implementation class and no data provider
     113                 :            :                 // found - contract violation.
     114         [ #  # ]:          0 :                 if( !xLinePoly.is() )
     115                 :            :                     throw lang::IllegalArgumentException(
     116                 :            :                         ::rtl::OUString(
     117                 :            :                             RTL_CONSTASCII_USTRINGPARAM(
     118                 :            :                                 "UnoPolyPolygon::addPolyPolygon(): Invalid input "
     119                 :            :                                 "poly-polygon, cannot retrieve vertex data")),
     120 [ #  # ][ #  # ]:          0 :                         static_cast<cppu::OWeakObject*>(this), 1);
                 [ #  # ]
     121                 :            : 
     122                 :            :                 aSrcPoly = unotools::polyPolygonFromPoint2DSequenceSequence(
     123         [ #  # ]:          0 :                     xLinePoly->getPoints( 0,
     124                 :            :                                           nPolys,
     125                 :            :                                           0,
     126 [ #  # ][ #  # ]:          0 :                                           -1 ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     127                 :          0 :             }
     128                 :            :         }
     129                 :            : 
     130         [ #  # ]:          0 :         const B2DRange  aBounds( tools::getRange( aSrcPoly ) );
     131                 :            :         const B2DVector     aOffset( unotools::b2DPointFromRealPoint2D( position ) -
     132 [ #  # ][ #  # ]:          0 :                                              aBounds.getMinimum() );
     133                 :            : 
     134 [ #  # ][ #  # ]:          0 :         if( !aOffset.equalZero() )
     135                 :            :         {
     136         [ #  # ]:          0 :             const B2DHomMatrix aTranslate(tools::createTranslateB2DHomMatrix(aOffset));
     137 [ #  # ][ #  # ]:          0 :             aSrcPoly.transform( aTranslate );
     138                 :            :         }
     139                 :            : 
     140 [ #  # ][ #  # ]:          0 :         maPolyPoly.append( aSrcPoly );
         [ #  # ][ #  # ]
     141                 :            :     }
     142                 :            : 
     143                 :          0 :     sal_Int32 SAL_CALL UnoPolyPolygon::getNumberOfPolygons() throw (uno::RuntimeException)
     144                 :            :     {
     145         [ #  # ]:          0 :         osl::MutexGuard const guard( m_aMutex );
     146 [ #  # ][ #  # ]:          0 :         return maPolyPoly.count();
     147                 :            :     }
     148                 :            : 
     149                 :          0 :     sal_Int32 SAL_CALL UnoPolyPolygon::getNumberOfPolygonPoints(
     150                 :            :         sal_Int32 polygon ) throw (lang::IndexOutOfBoundsException,uno::RuntimeException)
     151                 :            :     {
     152         [ #  # ]:          0 :         osl::MutexGuard const guard( m_aMutex );
     153         [ #  # ]:          0 :         checkIndex( polygon );
     154                 :            : 
     155 [ #  # ][ #  # ]:          0 :         return maPolyPoly.getB2DPolygon(polygon).count();
         [ #  # ][ #  # ]
     156                 :            :     }
     157                 :            : 
     158                 :          0 :     rendering::FillRule SAL_CALL UnoPolyPolygon::getFillRule() throw (uno::RuntimeException)
     159                 :            :     {
     160         [ #  # ]:          0 :         osl::MutexGuard const guard( m_aMutex );
     161         [ #  # ]:          0 :         return meFillRule;
     162                 :            :     }
     163                 :            : 
     164                 :          0 :     void SAL_CALL UnoPolyPolygon::setFillRule(
     165                 :            :         rendering::FillRule fillRule ) throw (uno::RuntimeException)
     166                 :            :     {
     167         [ #  # ]:          0 :         osl::MutexGuard const guard( m_aMutex );
     168         [ #  # ]:          0 :         modifying();
     169                 :            : 
     170         [ #  # ]:          0 :         meFillRule = fillRule;
     171                 :          0 :     }
     172                 :            : 
     173                 :          0 :     sal_Bool SAL_CALL UnoPolyPolygon::isClosed(
     174                 :            :         sal_Int32 index ) throw (lang::IndexOutOfBoundsException,uno::RuntimeException)
     175                 :            :     {
     176         [ #  # ]:          0 :         osl::MutexGuard const guard( m_aMutex );
     177         [ #  # ]:          0 :         checkIndex( index );
     178                 :            : 
     179 [ #  # ][ #  # ]:          0 :         return maPolyPoly.getB2DPolygon(index).isClosed();
         [ #  # ][ #  # ]
     180                 :            :     }
     181                 :            : 
     182                 :          0 :     void SAL_CALL UnoPolyPolygon::setClosed(
     183                 :            :         sal_Int32 index,
     184                 :            :         sal_Bool closedState ) throw (lang::IndexOutOfBoundsException,uno::RuntimeException)
     185                 :            :     {
     186         [ #  # ]:          0 :         osl::MutexGuard const guard( m_aMutex );
     187         [ #  # ]:          0 :         modifying();
     188                 :            : 
     189         [ #  # ]:          0 :         if( index == -1L )
     190                 :            :         {
     191                 :            :             // set all
     192         [ #  # ]:          0 :             maPolyPoly.setClosed( closedState );
     193                 :            :         }
     194                 :            :         else
     195                 :            :         {
     196         [ #  # ]:          0 :             checkIndex( index );
     197                 :            : 
     198                 :            :             // fetch referenced polygon, change state
     199         [ #  # ]:          0 :             B2DPolygon aTmp( maPolyPoly.getB2DPolygon(index) );
     200         [ #  # ]:          0 :             aTmp.setClosed( closedState );
     201                 :            : 
     202                 :            :             // set back to container
     203 [ #  # ][ #  # ]:          0 :             maPolyPoly.setB2DPolygon( index, aTmp );
     204         [ #  # ]:          0 :         }
     205                 :          0 :     }
     206                 :            : 
     207                 :          0 :     uno::Sequence< uno::Sequence< geometry::RealPoint2D > > SAL_CALL UnoPolyPolygon::getPoints(
     208                 :            :         sal_Int32 nPolygonIndex,
     209                 :            :         sal_Int32 nNumberOfPolygons,
     210                 :            :         sal_Int32 nPointIndex,
     211                 :            :         sal_Int32 nNumberOfPoints ) throw (lang::IndexOutOfBoundsException,uno::RuntimeException)
     212                 :            :     {
     213         [ #  # ]:          0 :         osl::MutexGuard const guard( m_aMutex );
     214                 :            : 
     215                 :            :         return unotools::pointSequenceSequenceFromB2DPolyPolygon(
     216                 :            :             getSubsetPolyPolygon( nPolygonIndex,
     217                 :            :                                   nNumberOfPolygons,
     218                 :            :                                   nPointIndex,
     219 [ #  # ][ #  # ]:          0 :                                   nNumberOfPoints ) );
         [ #  # ][ #  # ]
     220                 :            :     }
     221                 :            : 
     222                 :          0 :     void SAL_CALL UnoPolyPolygon::setPoints(
     223                 :            :         const uno::Sequence< uno::Sequence< geometry::RealPoint2D > >& points,
     224                 :            :         sal_Int32 nPolygonIndex ) throw (lang::IndexOutOfBoundsException,uno::RuntimeException)
     225                 :            :     {
     226         [ #  # ]:          0 :         osl::MutexGuard const guard( m_aMutex );
     227         [ #  # ]:          0 :         modifying();
     228                 :            : 
     229                 :            :         const B2DPolyPolygon& rNewPolyPoly(
     230         [ #  # ]:          0 :             unotools::polyPolygonFromPoint2DSequenceSequence( points ) );
     231                 :            : 
     232         [ #  # ]:          0 :         if( nPolygonIndex == -1 )
     233                 :            :         {
     234         [ #  # ]:          0 :             maPolyPoly = rNewPolyPoly;
     235                 :            :         }
     236                 :            :         else
     237                 :            :         {
     238         [ #  # ]:          0 :             checkIndex( nPolygonIndex );
     239                 :            : 
     240         [ #  # ]:          0 :             maPolyPoly.insert( nPolygonIndex, rNewPolyPoly );
     241 [ #  # ][ #  # ]:          0 :         }
     242                 :          0 :     }
     243                 :            : 
     244                 :          0 :     geometry::RealPoint2D SAL_CALL UnoPolyPolygon::getPoint(
     245                 :            :         sal_Int32 nPolygonIndex,
     246                 :            :         sal_Int32 nPointIndex ) throw (lang::IndexOutOfBoundsException,uno::RuntimeException)
     247                 :            :     {
     248         [ #  # ]:          0 :         osl::MutexGuard const guard( m_aMutex );
     249         [ #  # ]:          0 :         checkIndex( nPolygonIndex );
     250                 :            : 
     251         [ #  # ]:          0 :         const B2DPolygon& rPoly( maPolyPoly.getB2DPolygon( nPolygonIndex ) );
     252                 :            : 
     253 [ #  # ][ #  # ]:          0 :         if( nPointIndex < 0 || nPointIndex >= static_cast<sal_Int32>(rPoly.count()) )
         [ #  # ][ #  # ]
     254         [ #  # ]:          0 :             throw lang::IndexOutOfBoundsException();
     255                 :            : 
     256 [ #  # ][ #  # ]:          0 :         return unotools::point2DFromB2DPoint( rPoly.getB2DPoint( nPointIndex ) );
         [ #  # ][ #  # ]
     257                 :            :     }
     258                 :            : 
     259                 :          0 :     void SAL_CALL UnoPolyPolygon::setPoint(
     260                 :            :         const geometry::RealPoint2D& point,
     261                 :            :         sal_Int32 nPolygonIndex,
     262                 :            :         sal_Int32 nPointIndex ) throw (lang::IndexOutOfBoundsException,uno::RuntimeException)
     263                 :            :     {
     264         [ #  # ]:          0 :         osl::MutexGuard const guard( m_aMutex );
     265         [ #  # ]:          0 :         checkIndex( nPolygonIndex );
     266         [ #  # ]:          0 :         modifying();
     267                 :            : 
     268         [ #  # ]:          0 :         B2DPolygon aPoly( maPolyPoly.getB2DPolygon( nPolygonIndex ) );
     269                 :            : 
     270 [ #  # ][ #  # ]:          0 :         if( nPointIndex < 0 || nPointIndex >= static_cast<sal_Int32>(aPoly.count()) )
         [ #  # ][ #  # ]
     271         [ #  # ]:          0 :             throw lang::IndexOutOfBoundsException();
     272                 :            : 
     273                 :            :         aPoly.setB2DPoint( nPointIndex,
     274 [ #  # ][ #  # ]:          0 :                            unotools::b2DPointFromRealPoint2D( point ) );
     275 [ #  # ][ #  # ]:          0 :         maPolyPoly.setB2DPolygon( nPolygonIndex, aPoly );
                 [ #  # ]
     276                 :          0 :     }
     277                 :            : 
     278                 :          0 :     uno::Sequence< uno::Sequence< geometry::RealBezierSegment2D > > SAL_CALL UnoPolyPolygon::getBezierSegments(
     279                 :            :         sal_Int32 nPolygonIndex,
     280                 :            :         sal_Int32 nNumberOfPolygons,
     281                 :            :         sal_Int32 nPointIndex,
     282                 :            :         sal_Int32 nNumberOfPoints ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
     283                 :            :     {
     284         [ #  # ]:          0 :         osl::MutexGuard const guard( m_aMutex );
     285                 :            :         return unotools::bezierSequenceSequenceFromB2DPolyPolygon(
     286                 :            :             getSubsetPolyPolygon( nPolygonIndex,
     287                 :            :                                   nNumberOfPolygons,
     288                 :            :                                   nPointIndex,
     289 [ #  # ][ #  # ]:          0 :                                   nNumberOfPoints ) );
         [ #  # ][ #  # ]
     290                 :            :     }
     291                 :            : 
     292                 :          0 :     void SAL_CALL UnoPolyPolygon::setBezierSegments(
     293                 :            :         const uno::Sequence< uno::Sequence< geometry::RealBezierSegment2D > >&  points,
     294                 :            :         sal_Int32                                                               nPolygonIndex ) throw (lang::IndexOutOfBoundsException,
     295                 :            :                                                                                                        uno::RuntimeException)
     296                 :            :     {
     297         [ #  # ]:          0 :         osl::MutexGuard const guard( m_aMutex );
     298         [ #  # ]:          0 :         modifying();
     299                 :            :         const B2DPolyPolygon& rNewPolyPoly(
     300         [ #  # ]:          0 :             unotools::polyPolygonFromBezier2DSequenceSequence( points ) );
     301                 :            : 
     302         [ #  # ]:          0 :         if( nPolygonIndex == -1 )
     303                 :            :         {
     304         [ #  # ]:          0 :             maPolyPoly = rNewPolyPoly;
     305                 :            :         }
     306                 :            :         else
     307                 :            :         {
     308         [ #  # ]:          0 :             checkIndex( nPolygonIndex );
     309                 :            : 
     310         [ #  # ]:          0 :             maPolyPoly.insert( nPolygonIndex, rNewPolyPoly );
     311 [ #  # ][ #  # ]:          0 :         }
     312                 :          0 :     }
     313                 :            : 
     314                 :          0 :     geometry::RealBezierSegment2D SAL_CALL UnoPolyPolygon::getBezierSegment( sal_Int32 nPolygonIndex,
     315                 :            :                                                                              sal_Int32 nPointIndex ) throw (lang::IndexOutOfBoundsException,
     316                 :            :                                                                                                             uno::RuntimeException)
     317                 :            :     {
     318         [ #  # ]:          0 :         osl::MutexGuard const guard( m_aMutex );
     319         [ #  # ]:          0 :         checkIndex( nPolygonIndex );
     320                 :            : 
     321         [ #  # ]:          0 :         const B2DPolygon& rPoly( maPolyPoly.getB2DPolygon( nPolygonIndex ) );
     322         [ #  # ]:          0 :         const sal_uInt32  nPointCount(rPoly.count());
     323                 :            : 
     324 [ #  # ][ #  # ]:          0 :         if( nPointIndex < 0 || nPointIndex >= static_cast<sal_Int32>(nPointCount) )
     325         [ #  # ]:          0 :             throw lang::IndexOutOfBoundsException();
     326                 :            : 
     327         [ #  # ]:          0 :         const B2DPoint& rPt( rPoly.getB2DPoint( nPointIndex ) );
     328         [ #  # ]:          0 :         const B2DPoint& rCtrl0( rPoly.getNextControlPoint(nPointIndex) );
     329         [ #  # ]:          0 :         const B2DPoint& rCtrl1( rPoly.getPrevControlPoint((nPointIndex + 1) % nPointCount) );
     330                 :            : 
     331                 :          0 :         return geometry::RealBezierSegment2D( rPt.getX(),
     332                 :          0 :                                               rPt.getY(),
     333                 :          0 :                                               rCtrl0.getX(),
     334                 :          0 :                                               rCtrl0.getY(),
     335                 :          0 :                                               rCtrl1.getX(),
     336 [ #  # ][ #  # ]:          0 :                                               rCtrl1.getY() );
     337                 :            :     }
     338                 :            : 
     339                 :          0 :     void SAL_CALL UnoPolyPolygon::setBezierSegment( const geometry::RealBezierSegment2D& segment,
     340                 :            :                                                          sal_Int32                       nPolygonIndex,
     341                 :            :                                                          sal_Int32                       nPointIndex ) throw (lang::IndexOutOfBoundsException,
     342                 :            :                                                                                                               uno::RuntimeException)
     343                 :            :     {
     344         [ #  # ]:          0 :         osl::MutexGuard const guard( m_aMutex );
     345         [ #  # ]:          0 :         checkIndex( nPolygonIndex );
     346         [ #  # ]:          0 :         modifying();
     347                 :            : 
     348         [ #  # ]:          0 :         B2DPolygon aPoly( maPolyPoly.getB2DPolygon( nPolygonIndex ) );
     349         [ #  # ]:          0 :         const sal_uInt32 nPointCount(aPoly.count());
     350                 :            : 
     351 [ #  # ][ #  # ]:          0 :         if( nPointIndex < 0 || nPointIndex >= static_cast<sal_Int32>(nPointCount) )
     352         [ #  # ]:          0 :             throw lang::IndexOutOfBoundsException();
     353                 :            : 
     354                 :            :         aPoly.setB2DPoint( nPointIndex,
     355                 :            :                            B2DPoint( segment.Px,
     356         [ #  # ]:          0 :                                      segment.Py ) );
     357                 :            :         aPoly.setNextControlPoint(nPointIndex,
     358         [ #  # ]:          0 :                                   B2DPoint(segment.C1x, segment.C1y));
     359                 :            :         aPoly.setPrevControlPoint((nPointIndex + 1) % nPointCount,
     360         [ #  # ]:          0 :                                   B2DPoint(segment.C2x, segment.C2y));
     361                 :            : 
     362 [ #  # ][ #  # ]:          0 :         maPolyPoly.setB2DPolygon( nPolygonIndex, aPoly );
                 [ #  # ]
     363                 :          0 :     }
     364                 :            : 
     365                 :          0 :     B2DPolyPolygon UnoPolyPolygon::getSubsetPolyPolygon(
     366                 :            :         sal_Int32 nPolygonIndex,
     367                 :            :         sal_Int32 nNumberOfPolygons,
     368                 :            :         sal_Int32 nPointIndex,
     369                 :            :         sal_Int32 nNumberOfPoints ) const
     370                 :            :     {
     371         [ #  # ]:          0 :         osl::MutexGuard const guard( m_aMutex );
     372         [ #  # ]:          0 :         checkIndex( nPolygonIndex );
     373                 :            : 
     374         [ #  # ]:          0 :         const sal_Int32 nPolyCount( maPolyPoly.count() );
     375                 :            : 
     376                 :            :         // check for "full polygon" case
     377 [ #  # ][ #  # ]:          0 :         if( !nPolygonIndex &&
         [ #  # ][ #  # ]
     378                 :            :             !nPointIndex &&
     379                 :            :             nNumberOfPolygons == nPolyCount &&
     380                 :            :             nNumberOfPoints == -1 )
     381                 :            :         {
     382         [ #  # ]:          0 :             return maPolyPoly;
     383                 :            :         }
     384                 :            : 
     385         [ #  # ]:          0 :         B2DPolyPolygon aSubsetPoly;
     386                 :            : 
     387                 :            :         // create temporary polygon (as an extract from maPoly,
     388                 :            :         // which contains the requested subset)
     389         [ #  # ]:          0 :         for( sal_Int32 i=nPolygonIndex; i<nNumberOfPolygons; ++i )
     390                 :            :         {
     391         [ #  # ]:          0 :             checkIndex(i);
     392                 :            : 
     393         [ #  # ]:          0 :             const B2DPolygon& rCurrPoly( maPolyPoly.getB2DPolygon(i) );
     394                 :            : 
     395                 :          0 :             sal_Int32 nFirstPoint(0);
     396                 :          0 :             sal_Int32 nLastPoint(nPolyCount-1);
     397                 :            : 
     398 [ #  # ][ #  # ]:          0 :             if( nPointIndex && i==nPolygonIndex )
     399                 :            :             {
     400                 :            :                 // very first polygon - respect nPointIndex, if
     401                 :            :                 // not zero
     402                 :            : 
     403                 :            :                 // empty polygon - impossible to specify _any_
     404                 :            :                 // legal value except 0 here!
     405 [ #  # ][ #  # ]:          0 :                 if( !nPolyCount && nPointIndex )
     406         [ #  # ]:          0 :                     throw lang::IndexOutOfBoundsException();
     407                 :            : 
     408                 :          0 :                 nFirstPoint = nPointIndex;
     409                 :            :             }
     410                 :            : 
     411 [ #  # ][ #  # ]:          0 :             if( i==nNumberOfPolygons-1 && nNumberOfPoints != -1 )
     412                 :            :             {
     413                 :            :                 // very last polygon - respect nNumberOfPoints
     414                 :            : 
     415                 :            :                 // empty polygon - impossible to specify _any_
     416                 :            :                 // legal value except -1 here!
     417         [ #  # ]:          0 :                 if( !nPolyCount )
     418         [ #  # ]:          0 :                     throw lang::IndexOutOfBoundsException();
     419                 :            : 
     420                 :          0 :                 nLastPoint = nFirstPoint+nNumberOfPoints;
     421                 :            :             }
     422                 :            : 
     423         [ #  # ]:          0 :             if( !nPolyCount )
     424                 :            :             {
     425                 :            :                 // empty polygon - index checks already performed
     426                 :            :                 // above, now simply append empty polygon
     427         [ #  # ]:          0 :                 aSubsetPoly.append( rCurrPoly );
     428                 :            :             }
     429                 :            :             else
     430                 :            :             {
     431 [ #  # ][ #  # ]:          0 :                 if( nFirstPoint < 0 || nFirstPoint >= nPolyCount )
     432         [ #  # ]:          0 :                     throw lang::IndexOutOfBoundsException();
     433                 :            : 
     434 [ #  # ][ #  # ]:          0 :                 if( nLastPoint < 0 || nLastPoint >= nPolyCount )
     435         [ #  # ]:          0 :                     throw lang::IndexOutOfBoundsException();
     436                 :            : 
     437         [ #  # ]:          0 :                 B2DPolygon aTmp;
     438         [ #  # ]:          0 :                 for( sal_Int32 j=nFirstPoint; j<nLastPoint; ++j )
     439 [ #  # ][ #  # ]:          0 :                     aTmp.append( rCurrPoly.getB2DPoint(j) );
     440                 :            : 
     441 [ #  # ][ #  # ]:          0 :                 aSubsetPoly.append( aTmp );
     442                 :            :             }
     443         [ #  # ]:          0 :         }
     444                 :            : 
     445 [ #  # ][ #  # ]:          0 :         return aSubsetPoly;
                 [ #  # ]
     446                 :            :     }
     447                 :            : 
     448                 :            : #define IMPLEMENTATION_NAME "gfx::internal::UnoPolyPolygon"
     449                 :            : #define SERVICE_NAME "com.sun.star.rendering.PolyPolygon2D"
     450                 :          0 :     ::rtl::OUString SAL_CALL UnoPolyPolygon::getImplementationName() throw( uno::RuntimeException )
     451                 :            :     {
     452                 :          0 :         return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) );
     453                 :            :     }
     454                 :            : 
     455                 :          0 :     sal_Bool SAL_CALL UnoPolyPolygon::supportsService( const ::rtl::OUString& ServiceName ) throw( uno::RuntimeException )
     456                 :            :     {
     457                 :          0 :         return ServiceName == SERVICE_NAME;
     458                 :            :     }
     459                 :            : 
     460                 :          0 :     uno::Sequence< ::rtl::OUString > SAL_CALL UnoPolyPolygon::getSupportedServiceNames()  throw( uno::RuntimeException )
     461                 :            :     {
     462                 :          0 :         uno::Sequence< ::rtl::OUString > aRet(1);
     463 [ #  # ][ #  # ]:          0 :         aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
     464                 :            : 
     465                 :          0 :         return aRet;
     466                 :            :     }
     467                 :            : 
     468                 :         45 :     B2DPolyPolygon UnoPolyPolygon::getPolyPolygon() const
     469                 :            :     {
     470         [ +  - ]:         45 :         osl::MutexGuard const guard( m_aMutex );
     471                 :            : 
     472                 :            :         // detach result from us
     473         [ +  - ]:         45 :         B2DPolyPolygon aRet( maPolyPoly );
     474         [ +  - ]:         45 :         aRet.makeUnique();
     475         [ +  - ]:         45 :         return aRet;
     476                 :            :     }
     477                 :            : 
     478                 :            : }
     479                 :            : }
     480                 :            : 
     481                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10