LCOV - code coverage report
Current view: top level - basegfx/source/tools - canvastools.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 23 210 11.0 %
Date: 2012-08-25 Functions: 4 30 13.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 252 0.8 %

           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/RealSize2D.hpp>
      30                 :            : #include <com/sun/star/geometry/RealPoint2D.hpp>
      31                 :            : #include <com/sun/star/geometry/RealRectangle2D.hpp>
      32                 :            : #include <com/sun/star/geometry/RealRectangle3D.hpp>
      33                 :            : #include <com/sun/star/geometry/RealBezierSegment2D.hpp>
      34                 :            : #include <com/sun/star/geometry/AffineMatrix2D.hpp>
      35                 :            : #include <com/sun/star/geometry/AffineMatrix3D.hpp>
      36                 :            : #include <com/sun/star/geometry/Matrix2D.hpp>
      37                 :            : #include <com/sun/star/geometry/IntegerSize2D.hpp>
      38                 :            : #include <com/sun/star/geometry/IntegerPoint2D.hpp>
      39                 :            : #include <com/sun/star/geometry/IntegerRectangle2D.hpp>
      40                 :            : #include <com/sun/star/rendering/XPolyPolygon2D.hpp>
      41                 :            : #include <com/sun/star/rendering/XGraphicDevice.hpp>
      42                 :            : #include <com/sun/star/awt/Size.hpp>
      43                 :            : #include <com/sun/star/awt/Point.hpp>
      44                 :            : #include <com/sun/star/awt/Rectangle.hpp>
      45                 :            : #include <basegfx/tools/unopolypolygon.hxx>
      46                 :            : #include <basegfx/matrix/b2dhommatrix.hxx>
      47                 :            : #include <basegfx/matrix/b3dhommatrix.hxx>
      48                 :            : #include <basegfx/vector/b2dsize.hxx>
      49                 :            : #include <basegfx/point/b2dpoint.hxx>
      50                 :            : #include <basegfx/range/b2drectangle.hxx>
      51                 :            : #include <basegfx/range/b3drange.hxx>
      52                 :            : #include <basegfx/vector/b2isize.hxx>
      53                 :            : #include <basegfx/point/b2ipoint.hxx>
      54                 :            : #include <basegfx/range/b2irectangle.hxx>
      55                 :            : #include <basegfx/range/b2ibox.hxx>
      56                 :            : #include <basegfx/polygon/b2dpolygon.hxx>
      57                 :            : #include <basegfx/polygon/b2dpolypolygon.hxx>
      58                 :            : #include <basegfx/tools/canvastools.hxx>
      59                 :            : #include <limits>
      60                 :            : 
      61                 :            : using namespace ::com::sun::star;
      62                 :            : 
      63                 :            : namespace basegfx
      64                 :            : {
      65                 :            : 
      66                 :            :     namespace unotools
      67                 :            :     {
      68                 :            :         namespace
      69                 :            :         {
      70                 :          0 :             uno::Sequence< geometry::RealBezierSegment2D > bezierSequenceFromB2DPolygon(const ::basegfx::B2DPolygon& rPoly)
      71                 :            :             {
      72                 :          0 :                 const sal_uInt32 nPointCount(rPoly.count());
      73                 :          0 :                 uno::Sequence< geometry::RealBezierSegment2D > outputSequence(nPointCount);
      74         [ #  # ]:          0 :                 geometry::RealBezierSegment2D* pOutput = outputSequence.getArray();
      75                 :            : 
      76                 :            :                 // fill sequences and imply clodes polygon on this implementation layer
      77         [ #  # ]:          0 :                 for(sal_uInt32 a(0); a < nPointCount; a++)
      78                 :            :                 {
      79         [ #  # ]:          0 :                     const basegfx::B2DPoint aStart(rPoly.getB2DPoint(a));
      80         [ #  # ]:          0 :                     const basegfx::B2DPoint aControlA(rPoly.getNextControlPoint(a));
      81         [ #  # ]:          0 :                     const basegfx::B2DPoint aControlB(rPoly.getPrevControlPoint((a + 1) % nPointCount));
      82                 :            : 
      83                 :            :                     pOutput[a] = geometry::RealBezierSegment2D(
      84                 :          0 :                         aStart.getX(), aStart.getY(),
      85                 :          0 :                         aControlA.getX(), aControlA.getY(),
      86                 :          0 :                         aControlB.getX(), aControlB.getY());
      87                 :          0 :                 }
      88                 :            : 
      89                 :          0 :                 return outputSequence;
      90                 :            :             }
      91                 :            : 
      92                 :          0 :             uno::Sequence< geometry::RealPoint2D > pointSequenceFromB2DPolygon( const ::basegfx::B2DPolygon& rPoly )
      93                 :            :             {
      94                 :          0 :                 const sal_uInt32 nNumPoints( rPoly.count() );
      95                 :            : 
      96                 :          0 :                 uno::Sequence< geometry::RealPoint2D > outputSequence( nNumPoints );
      97         [ #  # ]:          0 :                 geometry::RealPoint2D* pOutput = outputSequence.getArray();
      98                 :            : 
      99                 :            :                 // fill sequence from polygon
     100                 :            :                 sal_uInt32 i;
     101         [ #  # ]:          0 :                 for( i=0; i<nNumPoints; ++i )
     102                 :            :                 {
     103         [ #  # ]:          0 :                     const ::basegfx::B2DPoint   aPoint( rPoly.getB2DPoint(i) );
     104                 :            : 
     105                 :          0 :                     pOutput[i] = geometry::RealPoint2D( aPoint.getX(),
     106                 :          0 :                                                         aPoint.getY() );
     107                 :          0 :                 }
     108                 :            : 
     109                 :          0 :                 return outputSequence;
     110                 :            :             }
     111                 :            :         }
     112                 :            : 
     113                 :            :         //---------------------------------------------------------------------------------------
     114                 :            : 
     115                 :          0 :         uno::Sequence< uno::Sequence< geometry::RealBezierSegment2D > > bezierSequenceSequenceFromB2DPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly )
     116                 :            :         {
     117                 :          0 :             const sal_uInt32 nNumPolies( rPolyPoly.count() );
     118                 :            :             sal_uInt32 i;
     119                 :            : 
     120                 :          0 :             uno::Sequence< uno::Sequence< geometry::RealBezierSegment2D > > outputSequence( nNumPolies );
     121         [ #  # ]:          0 :             uno::Sequence< geometry::RealBezierSegment2D >* pOutput = outputSequence.getArray();
     122                 :            : 
     123         [ #  # ]:          0 :             for( i=0; i<nNumPolies; ++i )
     124                 :            :             {
     125 [ #  # ][ #  # ]:          0 :                 pOutput[i] = bezierSequenceFromB2DPolygon( rPolyPoly.getB2DPolygon(i) );
         [ #  # ][ #  # ]
                 [ #  # ]
     126                 :            :             }
     127                 :            : 
     128                 :          0 :             return outputSequence;
     129                 :            :         }
     130                 :            : 
     131                 :            :         //---------------------------------------------------------------------------------------
     132                 :            : 
     133                 :          0 :         uno::Sequence< uno::Sequence< geometry::RealPoint2D > > pointSequenceSequenceFromB2DPolyPolygon( const ::basegfx::B2DPolyPolygon& rPolyPoly  )
     134                 :            :         {
     135                 :          0 :             const sal_uInt32 nNumPolies( rPolyPoly.count() );
     136                 :            :             sal_uInt32 i;
     137                 :            : 
     138                 :          0 :             uno::Sequence< uno::Sequence< geometry::RealPoint2D > > outputSequence( nNumPolies );
     139         [ #  # ]:          0 :             uno::Sequence< geometry::RealPoint2D >* pOutput = outputSequence.getArray();
     140                 :            : 
     141         [ #  # ]:          0 :             for( i=0; i<nNumPolies; ++i )
     142                 :            :             {
     143 [ #  # ][ #  # ]:          0 :                 pOutput[i] = pointSequenceFromB2DPolygon( rPolyPoly.getB2DPolygon(i) );
         [ #  # ][ #  # ]
                 [ #  # ]
     144                 :            :             }
     145                 :            : 
     146                 :          0 :             return outputSequence;
     147                 :            :         }
     148                 :            : 
     149                 :            :         //---------------------------------------------------------------------------------------
     150                 :            : 
     151                 :          0 :         uno::Reference< rendering::XPolyPolygon2D > xPolyPolygonFromB2DPolygon( const uno::Reference< rendering::XGraphicDevice >&  xGraphicDevice,
     152                 :            :                                                                                 const ::basegfx::B2DPolygon&                        rPoly    )
     153                 :            :         {
     154                 :          0 :             uno::Reference< rendering::XPolyPolygon2D > xRes;
     155                 :            : 
     156         [ #  # ]:          0 :             if( !xGraphicDevice.is() )
     157                 :          0 :                 return xRes;
     158                 :            : 
     159 [ #  # ][ #  # ]:          0 :             if( rPoly.areControlPointsUsed() )
     160                 :            :             {
     161         [ #  # ]:          0 :                 uno::Sequence< uno::Sequence< geometry::RealBezierSegment2D > > outputSequence( 1 );
     162 [ #  # ][ #  # ]:          0 :                 outputSequence[0] = bezierSequenceFromB2DPolygon( rPoly );
         [ #  # ][ #  # ]
     163                 :            : 
     164         [ #  # ]:          0 :                 xRes.set( xGraphicDevice->createCompatibleBezierPolyPolygon( outputSequence ),
     165 [ #  # ][ #  # ]:          0 :                           uno::UNO_QUERY );
                 [ #  # ]
     166                 :            :             }
     167                 :            :             else
     168                 :            :             {
     169         [ #  # ]:          0 :                 uno::Sequence< uno::Sequence< geometry::RealPoint2D > > outputSequence( 1 );
     170 [ #  # ][ #  # ]:          0 :                 outputSequence[0] = pointSequenceFromB2DPolygon( rPoly );
         [ #  # ][ #  # ]
     171                 :            : 
     172         [ #  # ]:          0 :                 xRes.set( xGraphicDevice->createCompatibleLinePolyPolygon( outputSequence ),
     173 [ #  # ][ #  # ]:          0 :                           uno::UNO_QUERY );
                 [ #  # ]
     174                 :            :             }
     175                 :            : 
     176 [ #  # ][ #  # ]:          0 :             if( xRes.is() && rPoly.isClosed() )
         [ #  # ][ #  # ]
     177 [ #  # ][ #  # ]:          0 :                 xRes->setClosed( 0, sal_True );
     178                 :            : 
     179                 :          0 :             return xRes;
     180                 :            :         }
     181                 :            : 
     182                 :            :         //---------------------------------------------------------------------------------------
     183                 :            : 
     184                 :          0 :         uno::Reference< rendering::XPolyPolygon2D > xPolyPolygonFromB2DPolyPolygon( const uno::Reference< rendering::XGraphicDevice >&  xGraphicDevice,
     185                 :            :                                                                                     const ::basegfx::B2DPolyPolygon&                    rPolyPoly    )
     186                 :            :         {
     187                 :          0 :             uno::Reference< rendering::XPolyPolygon2D > xRes;
     188                 :            : 
     189         [ #  # ]:          0 :             if( !xGraphicDevice.is() )
     190                 :          0 :                 return xRes;
     191                 :            : 
     192         [ #  # ]:          0 :             const sal_uInt32 nNumPolies( rPolyPoly.count() );
     193                 :            :             sal_uInt32 i;
     194                 :            : 
     195 [ #  # ][ #  # ]:          0 :             if( rPolyPoly.areControlPointsUsed() )
     196                 :            :             {
     197         [ #  # ]:          0 :                 xRes.set( xGraphicDevice->createCompatibleBezierPolyPolygon(
     198                 :          0 :                               bezierSequenceSequenceFromB2DPolyPolygon( rPolyPoly ) ),
     199 [ #  # ][ #  # ]:          0 :                           uno::UNO_QUERY );
         [ #  # ][ #  # ]
     200                 :            :             }
     201                 :            :             else
     202                 :            :             {
     203         [ #  # ]:          0 :                 xRes.set( xGraphicDevice->createCompatibleLinePolyPolygon(
     204                 :          0 :                               pointSequenceSequenceFromB2DPolyPolygon( rPolyPoly ) ),
     205 [ #  # ][ #  # ]:          0 :                           uno::UNO_QUERY );
         [ #  # ][ #  # ]
     206                 :            :             }
     207                 :            : 
     208         [ #  # ]:          0 :             for( i=0; i<nNumPolies; ++i )
     209                 :            :             {
     210 [ #  # ][ #  # ]:          0 :                 xRes->setClosed( i, rPolyPoly.getB2DPolygon(i).isClosed() );
         [ #  # ][ #  # ]
                 [ #  # ]
     211                 :            :             }
     212                 :            : 
     213                 :          0 :             return xRes;
     214                 :            :         }
     215                 :            : 
     216                 :            :         //---------------------------------------------------------------------------------------
     217                 :            : 
     218                 :          0 :         ::basegfx::B2DPolygon polygonFromPoint2DSequence( const uno::Sequence< geometry::RealPoint2D >& points )
     219                 :            :         {
     220                 :          0 :             const sal_Int32 nCurrSize( points.getLength() );
     221                 :            : 
     222                 :          0 :             ::basegfx::B2DPolygon aPoly;
     223                 :            : 
     224         [ #  # ]:          0 :             for( sal_Int32 nCurrPoint=0; nCurrPoint<nCurrSize; ++nCurrPoint )
     225 [ #  # ][ #  # ]:          0 :                 aPoly.append( b2DPointFromRealPoint2D( points[nCurrPoint] ) );
     226                 :            : 
     227                 :          0 :             return aPoly;
     228                 :            :         }
     229                 :            : 
     230                 :            :         //---------------------------------------------------------------------------------------
     231                 :            : 
     232                 :          0 :         ::basegfx::B2DPolyPolygon polyPolygonFromPoint2DSequenceSequence( const uno::Sequence< uno::Sequence< geometry::RealPoint2D > >& points )
     233                 :            :         {
     234                 :          0 :             ::basegfx::B2DPolyPolygon aRes;
     235                 :            : 
     236         [ #  # ]:          0 :             for( sal_Int32 nCurrPoly=0; nCurrPoly<points.getLength(); ++nCurrPoly )
     237                 :            :             {
     238 [ #  # ][ #  # ]:          0 :                 aRes.append( polygonFromPoint2DSequence( points[nCurrPoly] ) );
                 [ #  # ]
     239                 :            :             }
     240                 :            : 
     241                 :          0 :             return aRes;
     242                 :            :         }
     243                 :            : 
     244                 :            :         //---------------------------------------------------------------------------------------
     245                 :            : 
     246                 :          0 :         ::basegfx::B2DPolygon polygonFromBezier2DSequence( const uno::Sequence< geometry::RealBezierSegment2D >& curves )
     247                 :            :         {
     248                 :          0 :             const sal_Int32 nSize(curves.getLength());
     249                 :          0 :             basegfx::B2DPolygon aRetval;
     250                 :            : 
     251         [ #  # ]:          0 :             if(nSize)
     252                 :            :             {
     253                 :            :                 // prepare start with providing a start point. Use the first point from
     254                 :            :                 // the sequence for this
     255                 :          0 :                 const geometry::RealBezierSegment2D& rFirstSegment(curves[0]); // #i79917# first segment, not last
     256         [ #  # ]:          0 :                 aRetval.append(basegfx::B2DPoint(rFirstSegment.Px, rFirstSegment.Py));
     257                 :            : 
     258         [ #  # ]:          0 :                 for(sal_Int32 a(0); a < nSize; a++)
     259                 :            :                 {
     260                 :          0 :                     const geometry::RealBezierSegment2D& rCurrSegment(curves[a]);
     261                 :          0 :                     const geometry::RealBezierSegment2D& rNextSegment(curves[(a + 1) % nSize]);
     262                 :            : 
     263                 :            :                     // append curved edge with the control points and the next point
     264                 :            :                     aRetval.appendBezierSegment(
     265                 :            :                         basegfx::B2DPoint(rCurrSegment.C1x, rCurrSegment.C1y),
     266                 :            :                         basegfx::B2DPoint(rCurrSegment.C2x, rCurrSegment.C2y), // #i79917# Argh! An x for an y!!
     267         [ #  # ]:          0 :                         basegfx::B2DPoint(rNextSegment.Px, rNextSegment.Py));
     268                 :            :                 }
     269                 :            : 
     270                 :            :                 // rescue the control point and remove the now double-added point
     271 [ #  # ][ #  # ]:          0 :                 aRetval.setPrevControlPoint(0, aRetval.getPrevControlPoint(aRetval.count() - 1));
                 [ #  # ]
     272 [ #  # ][ #  # ]:          0 :                 aRetval.remove(aRetval.count() - 1);
     273                 :            :             }
     274                 :            : 
     275                 :          0 :             return aRetval;
     276                 :            :         }
     277                 :            : 
     278                 :            :         //---------------------------------------------------------------------------------------
     279                 :            : 
     280                 :          0 :         ::basegfx::B2DPolyPolygon polyPolygonFromBezier2DSequenceSequence( const uno::Sequence< uno::Sequence< geometry::RealBezierSegment2D > >& curves )
     281                 :            :         {
     282                 :          0 :             ::basegfx::B2DPolyPolygon aRes;
     283                 :            : 
     284         [ #  # ]:          0 :             for( sal_Int32 nCurrPoly=0; nCurrPoly<curves.getLength(); ++nCurrPoly )
     285                 :            :             {
     286 [ #  # ][ #  # ]:          0 :                 aRes.append( polygonFromBezier2DSequence( curves[nCurrPoly] ) );
                 [ #  # ]
     287                 :            :             }
     288                 :            : 
     289                 :          0 :             return aRes;
     290                 :            :         }
     291                 :            : 
     292                 :            :         //---------------------------------------------------------------------------------------
     293                 :            : 
     294                 :         45 :         ::basegfx::B2DPolyPolygon b2DPolyPolygonFromXPolyPolygon2D( const uno::Reference< rendering::XPolyPolygon2D >& xPoly )
     295                 :            :         {
     296                 :            :             ::basegfx::unotools::UnoPolyPolygon* pPolyImpl =
     297         [ -  + ]:         45 :                 dynamic_cast< ::basegfx::unotools::UnoPolyPolygon* >( xPoly.get() );
     298                 :            : 
     299         [ +  - ]:         45 :             if( pPolyImpl )
     300                 :            :             {
     301                 :         45 :                 return pPolyImpl->getPolyPolygon();
     302                 :            :             }
     303                 :            :             else
     304                 :            :             {
     305                 :            :                 // not a known implementation object - try data source
     306                 :            :                 // interfaces
     307 [ #  # ][ #  # ]:          0 :                 const sal_Int32 nPolys( xPoly->getNumberOfPolygons() );
     308                 :            : 
     309                 :            :                 uno::Reference< rendering::XBezierPolyPolygon2D > xBezierPoly(
     310                 :            :                     xPoly,
     311         [ #  # ]:          0 :                     uno::UNO_QUERY );
     312                 :            : 
     313         [ #  # ]:          0 :                 if( xBezierPoly.is() )
     314                 :            :                 {
     315                 :            :                     return ::basegfx::unotools::polyPolygonFromBezier2DSequenceSequence(
     316         [ #  # ]:          0 :                         xBezierPoly->getBezierSegments( 0,
     317                 :            :                                                         nPolys,
     318                 :            :                                                         0,
     319 [ #  # ][ #  # ]:          0 :                                                         -1 ) );
                 [ #  # ]
     320                 :            :                 }
     321                 :            :                 else
     322                 :            :                 {
     323                 :            :                     uno::Reference< rendering::XLinePolyPolygon2D > xLinePoly(
     324                 :            :                         xPoly,
     325         [ #  # ]:          0 :                         uno::UNO_QUERY );
     326                 :            : 
     327                 :            :                     // no implementation class and no data provider
     328                 :            :                     // found - contract violation.
     329         [ #  # ]:          0 :                     if( !xLinePoly.is() )
     330                 :            :                     {
     331                 :            :                         throw lang::IllegalArgumentException(
     332                 :            :                             ::rtl::OUString(
     333                 :            :                                     "basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(): Invalid input"
     334                 :            :                                     "poly-polygon, cannot retrieve vertex data"),
     335                 :            :                             uno::Reference< uno::XInterface >(),
     336         [ #  # ]:          0 :                             0 );
     337                 :            :                     }
     338                 :            : 
     339                 :            :                     return ::basegfx::unotools::polyPolygonFromPoint2DSequenceSequence(
     340         [ #  # ]:          0 :                         xLinePoly->getPoints( 0,
     341                 :            :                                               nPolys,
     342                 :            :                                               0,
     343 [ #  # ][ #  # ]:          0 :                                               -1 ));
                 [ #  # ]
     344                 :         45 :                 }
     345                 :            :             }
     346                 :            :         }
     347                 :            : 
     348                 :            :         //---------------------------------------------------------------------------------------
     349                 :            : 
     350                 :         18 :         ::basegfx::B2DHomMatrix& homMatrixFromAffineMatrix( ::basegfx::B2DHomMatrix&        output,
     351                 :            :                                                             const geometry::AffineMatrix2D& input )
     352                 :            :         {
     353                 :            :             // ensure last row is [0,0,1] (and optimized away)
     354                 :         18 :             output.identity();
     355                 :            : 
     356                 :         18 :             output.set(0,0, input.m00);
     357                 :         18 :             output.set(0,1, input.m01);
     358                 :         18 :             output.set(0,2, input.m02);
     359                 :         18 :             output.set(1,0, input.m10);
     360                 :         18 :             output.set(1,1, input.m11);
     361                 :         18 :             output.set(1,2, input.m12);
     362                 :            : 
     363                 :         18 :             return output;
     364                 :            :         }
     365                 :            : 
     366                 :          0 :         ::basegfx::B3DHomMatrix homMatrixFromAffineMatrix3D( const ::com::sun::star::geometry::AffineMatrix3D& input )
     367                 :            :         {
     368                 :          0 :             ::basegfx::B3DHomMatrix output;
     369                 :            : 
     370         [ #  # ]:          0 :             output.set(0,0, input.m00);
     371         [ #  # ]:          0 :             output.set(0,1, input.m01);
     372         [ #  # ]:          0 :             output.set(0,2, input.m02);
     373         [ #  # ]:          0 :             output.set(0,3, input.m03);
     374                 :            : 
     375         [ #  # ]:          0 :             output.set(1,0, input.m10);
     376         [ #  # ]:          0 :             output.set(1,1, input.m11);
     377         [ #  # ]:          0 :             output.set(1,2, input.m12);
     378         [ #  # ]:          0 :             output.set(1,3, input.m13);
     379                 :            : 
     380         [ #  # ]:          0 :             output.set(2,0, input.m20);
     381         [ #  # ]:          0 :             output.set(2,1, input.m21);
     382         [ #  # ]:          0 :             output.set(2,2, input.m22);
     383         [ #  # ]:          0 :             output.set(2,3, input.m23);
     384                 :            : 
     385                 :          0 :             return output;
     386                 :            :         }
     387                 :            : 
     388                 :          0 :         geometry::AffineMatrix2D& affineMatrixFromHomMatrix( geometry::AffineMatrix2D&      output,
     389                 :            :                                                              const ::basegfx::B2DHomMatrix& input)
     390                 :            :         {
     391                 :          0 :             output.m00 = input.get(0,0);
     392                 :          0 :             output.m01 = input.get(0,1);
     393                 :          0 :             output.m02 = input.get(0,2);
     394                 :          0 :             output.m10 = input.get(1,0);
     395                 :          0 :             output.m11 = input.get(1,1);
     396                 :          0 :             output.m12 = input.get(1,2);
     397                 :            : 
     398                 :          0 :             return output;
     399                 :            :         }
     400                 :            : 
     401                 :          0 :         geometry::AffineMatrix3D& affineMatrixFromHomMatrix3D(
     402                 :            :             geometry::AffineMatrix3D& output,
     403                 :            :             const ::basegfx::B3DHomMatrix&  input)
     404                 :            :         {
     405                 :          0 :             output.m00 = input.get(0,0);
     406                 :          0 :             output.m01 = input.get(0,1);
     407                 :          0 :             output.m02 = input.get(0,2);
     408                 :          0 :             output.m03 = input.get(0,3);
     409                 :            : 
     410                 :          0 :             output.m10 = input.get(1,0);
     411                 :          0 :             output.m11 = input.get(1,1);
     412                 :          0 :             output.m12 = input.get(1,2);
     413                 :          0 :             output.m13 = input.get(1,3);
     414                 :            : 
     415                 :          0 :             output.m20 = input.get(2,0);
     416                 :          0 :             output.m21 = input.get(2,1);
     417                 :          0 :             output.m22 = input.get(2,2);
     418                 :          0 :             output.m23 = input.get(2,3);
     419                 :            : 
     420                 :          0 :             return output;
     421                 :            :         }
     422                 :            : 
     423                 :            :         //---------------------------------------------------------------------------------------
     424                 :            : 
     425                 :         66 :         ::basegfx::B2DHomMatrix& homMatrixFromMatrix( ::basegfx::B2DHomMatrix&  output,
     426                 :            :                                                       const geometry::Matrix2D& input )
     427                 :            :         {
     428                 :            :             // ensure last row is [0,0,1] (and optimized away)
     429                 :         66 :             output.identity();
     430                 :            : 
     431                 :         66 :             output.set(0,0, input.m00);
     432                 :         66 :             output.set(0,1, input.m01);
     433                 :         66 :             output.set(1,0, input.m10);
     434                 :         66 :             output.set(1,1, input.m11);
     435                 :            : 
     436                 :         66 :             return output;
     437                 :            :         }
     438                 :            : 
     439                 :            :         //---------------------------------------------------------------------------------------
     440                 :            : 
     441                 :          0 :         geometry::RealSize2D size2DFromB2DSize( const ::basegfx::B2DVector& rVec )
     442                 :            :         {
     443                 :          0 :             return geometry::RealSize2D( rVec.getX(),
     444                 :          0 :                                          rVec.getY() );
     445                 :            :         }
     446                 :            : 
     447                 :          0 :         geometry::RealPoint2D point2DFromB2DPoint( const ::basegfx::B2DPoint& rPoint )
     448                 :            :         {
     449                 :          0 :             return geometry::RealPoint2D( rPoint.getX(),
     450                 :          0 :                                           rPoint.getY() );
     451                 :            :         }
     452                 :            : 
     453                 :          0 :         geometry::RealRectangle2D rectangle2DFromB2DRectangle( const ::basegfx::B2DRange& rRect )
     454                 :            :         {
     455         [ #  # ]:          0 :             return geometry::RealRectangle2D( rRect.getMinX(),
     456         [ #  # ]:          0 :                                               rRect.getMinY(),
     457         [ #  # ]:          0 :                                               rRect.getMaxX(),
     458                 :          0 :                                               rRect.getMaxY() );
     459                 :            :         }
     460                 :            : 
     461                 :          0 :         geometry::RealRectangle3D rectangle3DFromB3DRectangle( const ::basegfx::B3DRange& rRect )
     462                 :            :         {
     463         [ #  # ]:          0 :             return geometry::RealRectangle3D( rRect.getMinX(),
     464         [ #  # ]:          0 :                                               rRect.getMinY(),
     465         [ #  # ]:          0 :                                               rRect.getMinZ(),
     466         [ #  # ]:          0 :                                               rRect.getMaxX(),
     467         [ #  # ]:          0 :                                               rRect.getMaxY(),
     468                 :          0 :                                               rRect.getMaxZ());
     469                 :            :         }
     470                 :            : 
     471                 :          0 :         ::basegfx::B2DPoint b2DPointFromRealPoint2D( const geometry::RealPoint2D& rPoint )
     472                 :            :         {
     473                 :            :             return ::basegfx::B2DPoint( rPoint.X,
     474                 :          0 :                                         rPoint.Y );
     475                 :            :         }
     476                 :            : 
     477                 :        624 :         ::basegfx::B2DRange b2DRectangleFromRealRectangle2D( const geometry::RealRectangle2D& rRect )
     478                 :            :         {
     479                 :            :             return ::basegfx::B2DRange( rRect.X1,
     480                 :            :                                         rRect.Y1,
     481                 :            :                                         rRect.X2,
     482                 :        624 :                                         rRect.Y2 );
     483                 :            :         }
     484                 :            : 
     485                 :          0 :         ::basegfx::B3DRange b3DRectangleFromRealRectangle3D( const geometry::RealRectangle3D& rRect )
     486                 :            :         {
     487                 :            :             return ::basegfx::B3DRange( rRect.X1,
     488                 :            :                                         rRect.Y1,
     489                 :            :                                         rRect.Z1,
     490                 :            :                                         rRect.X2,
     491                 :            :                                         rRect.Y2,
     492                 :          0 :                                         rRect.Z2);
     493                 :            :         }
     494                 :            : 
     495                 :          0 :         geometry::IntegerSize2D integerSize2DFromB2ISize( const ::basegfx::B2IVector& rSize )
     496                 :            :         {
     497                 :          0 :             return geometry::IntegerSize2D( rSize.getX(),
     498                 :          0 :                                             rSize.getY() );
     499                 :            :         }
     500                 :            : 
     501                 :          0 :         ::basegfx::B2IVector b2ISizeFromIntegerSize2D( const geometry::IntegerSize2D& rSize )
     502                 :            :         {
     503                 :            :             return ::basegfx::B2IVector( rSize.Width,
     504                 :          0 :                                          rSize.Height );
     505                 :            :         }
     506                 :            : 
     507                 :          0 :         ::basegfx::B2IRange b2IRectangleFromIntegerRectangle2D( const geometry::IntegerRectangle2D& rRectangle )
     508                 :            :         {
     509                 :            :             return ::basegfx::B2IRange( rRectangle.X1, rRectangle.Y1,
     510                 :          0 :                                         rRectangle.X2, rRectangle.Y2 );
     511                 :            :         }
     512                 :            : 
     513                 :          0 :         ::basegfx::B2IRange b2IRectangleFromAwtRectangle( const awt::Rectangle& rRect )
     514                 :            :         {
     515                 :            :             return ::basegfx::B2IRange( rRect.X,
     516                 :            :                                         rRect.Y,
     517                 :            :                                         rRect.X + rRect.Width,
     518                 :          0 :                                         rRect.Y + rRect.Height );
     519                 :            :         }
     520                 :            : 
     521                 :          0 :         ::basegfx::B2IBox b2ISurroundingBoxFromB2DRange( const ::basegfx::B2DRange& rRange )
     522                 :            :         {
     523                 :          0 :             return ::basegfx::B2IBox( static_cast<sal_Int32>( floor(rRange.getMinX()) ),
     524                 :          0 :                                       static_cast<sal_Int32>( floor(rRange.getMinY()) ),
     525                 :          0 :                                       static_cast<sal_Int32>( ceil(rRange.getMaxX()) ),
     526                 :          0 :                                       static_cast<sal_Int32>( ceil(rRange.getMaxY()) ) );
     527                 :            :         }
     528                 :            : 
     529                 :          0 :         ::basegfx::B2IRange b2ISurroundingRangeFromB2DRange( const ::basegfx::B2DRange& rRange )
     530                 :            :         {
     531                 :          0 :             return ::basegfx::B2IRange( static_cast<sal_Int32>( floor(rRange.getMinX()) ),
     532                 :          0 :                                         static_cast<sal_Int32>( floor(rRange.getMinY()) ),
     533                 :          0 :                                         static_cast<sal_Int32>( ceil(rRange.getMaxX()) ),
     534                 :          0 :                                         static_cast<sal_Int32>( ceil(rRange.getMaxY()) ) );
     535                 :            :         }
     536                 :            : 
     537                 :          0 :         ::basegfx::B2DRange b2DSurroundingIntegerRangeFromB2DRange( const ::basegfx::B2DRange& rRange )
     538                 :            :         {
     539                 :            :             return ::basegfx::B2DRange( floor(rRange.getMinX()),
     540                 :            :                                         floor(rRange.getMinY()),
     541                 :            :                                         ceil(rRange.getMaxX()),
     542                 :          0 :                                         ceil(rRange.getMaxY()) );
     543                 :            :         }
     544                 :            : 
     545                 :            :     } // namespace bgfxtools
     546                 :            : 
     547                 :            : } // namespace canvas
     548                 :            : 
     549                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10