LCOV - code coverage report
Current view: top level - cppcanvas/source/mtfrenderer - polypolyaction.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 124 0.0 %
Date: 2012-08-25 Functions: 0 30 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 282 0.0 %

           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                 :            : 
      30                 :            : #include <rtl/logfile.hxx>
      31                 :            : 
      32                 :            : #include <com/sun/star/rendering/XCanvas.hpp>
      33                 :            : #include <com/sun/star/rendering/TexturingMode.hpp>
      34                 :            : 
      35                 :            : #include <tools/gen.hxx>
      36                 :            : #include <vcl/canvastools.hxx>
      37                 :            : 
      38                 :            : #include <basegfx/range/b2drectangle.hxx>
      39                 :            : #include <basegfx/tools/canvastools.hxx>
      40                 :            : #include <basegfx/polygon/b2dpolypolygon.hxx>
      41                 :            : #include <basegfx/polygon/b2dpolypolygontools.hxx>
      42                 :            : #include <basegfx/matrix/b2dhommatrix.hxx>
      43                 :            : #include <canvas/canvastools.hxx>
      44                 :            : 
      45                 :            : #include <boost/utility.hpp>
      46                 :            : 
      47                 :            : #include "cachedprimitivebase.hxx"
      48                 :            : #include "polypolyaction.hxx"
      49                 :            : #include "outdevstate.hxx"
      50                 :            : #include "mtftools.hxx"
      51                 :            : 
      52                 :            : 
      53                 :            : using namespace ::com::sun::star;
      54                 :            : 
      55                 :            : namespace cppcanvas
      56                 :            : {
      57                 :            :     namespace internal
      58                 :            :     {
      59                 :            :         namespace
      60                 :            :         {
      61 [ #  # ][ #  # ]:          0 :             class PolyPolyAction : public CachedPrimitiveBase
         [ #  # ][ #  # ]
      62                 :            :             {
      63                 :            :             public:
      64                 :            :                 PolyPolyAction( const ::basegfx::B2DPolyPolygon&,
      65                 :            :                                 const CanvasSharedPtr&,
      66                 :            :                                 const OutDevState&,
      67                 :            :                                 bool bFill,
      68                 :            :                                 bool bStroke );
      69                 :            :                 PolyPolyAction( const ::basegfx::B2DPolyPolygon&,
      70                 :            :                                 const CanvasSharedPtr&,
      71                 :            :                                 const OutDevState&,
      72                 :            :                                 bool bFill,
      73                 :            :                                 bool bStroke,
      74                 :            :                                 int nTransparency );
      75                 :            : 
      76                 :            :                 virtual bool renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
      77                 :            :                                            const Subset&                  rSubset ) const;
      78                 :            : 
      79                 :            :                 virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const;
      80                 :            :                 virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix&   rTransformation,
      81                 :            :                                                        const Subset&                    rSubset ) const;
      82                 :            : 
      83                 :            :                 virtual sal_Int32 getActionCount() const;
      84                 :            : 
      85                 :            :             private:
      86                 :            :                 using Action::render;
      87                 :            :                 virtual bool renderPrimitive( uno::Reference< rendering::XCachedPrimitive >& rCachedPrimitive,
      88                 :            :                                               const ::basegfx::B2DHomMatrix&                 rTransformation ) const;
      89                 :            : 
      90                 :            :                 const uno::Reference< rendering::XPolyPolygon2D >   mxPolyPoly;
      91                 :            :                 const ::basegfx::B2DRange                           maBounds;
      92                 :            :                 const CanvasSharedPtr                               mpCanvas;
      93                 :            : 
      94                 :            :                 // stroke color is now implicit: the maState.DeviceColor member
      95                 :            :                 rendering::RenderState                              maState;
      96                 :            : 
      97                 :            :                 uno::Sequence< double >                             maFillColor;
      98                 :            :             };
      99                 :            : 
     100                 :          0 :             PolyPolyAction::PolyPolyAction( const ::basegfx::B2DPolyPolygon&    rPolyPoly,
     101                 :            :                                             const CanvasSharedPtr&              rCanvas,
     102                 :            :                                             const OutDevState&                  rState,
     103                 :            :                                             bool                                bFill,
     104                 :            :                                             bool                                bStroke ) :
     105                 :            :                 CachedPrimitiveBase( rCanvas, false ),
     106 [ #  # ][ #  # ]:          0 :                 mxPolyPoly( ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon( rCanvas->getUNOCanvas()->getDevice(), rPolyPoly) ),
     107                 :            :                 maBounds( ::basegfx::tools::getRange(rPolyPoly) ),
     108                 :            :                 mpCanvas( rCanvas ),
     109                 :            :                 maState(),
     110 [ #  # ][ #  # ]:          0 :                 maFillColor()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     111                 :            :             {
     112         [ #  # ]:          0 :                 tools::initRenderState(maState,rState);
     113                 :            : 
     114         [ #  # ]:          0 :                 if( bFill )
     115         [ #  # ]:          0 :                     maFillColor = rState.fillColor;
     116                 :            : 
     117         [ #  # ]:          0 :                 if( bStroke )
     118         [ #  # ]:          0 :                     maState.DeviceColor = rState.lineColor;
     119                 :          0 :             }
     120                 :            : 
     121                 :          0 :             PolyPolyAction::PolyPolyAction( const ::basegfx::B2DPolyPolygon&    rPolyPoly,
     122                 :            :                                             const CanvasSharedPtr&              rCanvas,
     123                 :            :                                             const OutDevState&                  rState,
     124                 :            :                                             bool                                bFill,
     125                 :            :                                             bool                                bStroke,
     126                 :            :                                             int                                 nTransparency ) :
     127                 :            :                 CachedPrimitiveBase( rCanvas, false ),
     128 [ #  # ][ #  # ]:          0 :                 mxPolyPoly( ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon( rCanvas->getUNOCanvas()->getDevice(), rPolyPoly) ),
     129                 :            :                 maBounds( ::basegfx::tools::getRange(rPolyPoly) ),
     130                 :            :                 mpCanvas( rCanvas ),
     131                 :            :                 maState(),
     132 [ #  # ][ #  # ]:          0 :                 maFillColor()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     133                 :            :             {
     134         [ #  # ]:          0 :                 tools::initRenderState(maState,rState);
     135                 :            : 
     136         [ #  # ]:          0 :                 if( bFill )
     137                 :            :                 {
     138         [ #  # ]:          0 :                     maFillColor = rState.fillColor;
     139                 :            : 
     140         [ #  # ]:          0 :                     if( maFillColor.getLength() < 4 )
     141         [ #  # ]:          0 :                         maFillColor.realloc( 4 );
     142                 :            : 
     143                 :            :                     // TODO(F1): Color management
     144                 :            :                     // adapt fill color transparency
     145         [ #  # ]:          0 :                     maFillColor[3] = 1.0 - nTransparency / 100.0;
     146                 :            :                 }
     147                 :            : 
     148         [ #  # ]:          0 :                 if( bStroke )
     149                 :            :                 {
     150         [ #  # ]:          0 :                     maState.DeviceColor = rState.lineColor;
     151                 :            : 
     152         [ #  # ]:          0 :                     if( maState.DeviceColor.getLength() < 4 )
     153         [ #  # ]:          0 :                         maState.DeviceColor.realloc( 4 );
     154                 :            : 
     155                 :            :                     // TODO(F1): Color management
     156                 :            :                     // adapt fill color transparency
     157         [ #  # ]:          0 :                     maState.DeviceColor[3] = 1.0 - nTransparency / 100.0;
     158                 :            :                 }
     159                 :          0 :             }
     160                 :            : 
     161                 :          0 :             bool PolyPolyAction::renderPrimitive( uno::Reference< rendering::XCachedPrimitive >& rCachedPrimitive,
     162                 :            :                                                   const ::basegfx::B2DHomMatrix&                 rTransformation ) const
     163                 :            :             {
     164                 :            :                 RTL_LOGFILE_CONTEXT( aLog, "::cppcanvas::internal::PolyPolyAction::renderPrimitive()" );
     165                 :            :                 RTL_LOGFILE_CONTEXT_TRACE1( aLog, "::cppcanvas::internal::PolyPolyAction: 0x%X", this );
     166                 :            : 
     167         [ #  # ]:          0 :                 rendering::RenderState aLocalState( maState );
     168         [ #  # ]:          0 :                 ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
     169                 :            : 
     170         [ #  # ]:          0 :                 if( maFillColor.getLength() )
     171                 :            :                 {
     172                 :            :                     // TODO(E3): Use DBO's finalizer here,
     173                 :            :                     // fillPolyPolygon() might throw
     174         [ #  # ]:          0 :                     const uno::Sequence< double > aTmpColor( aLocalState.DeviceColor );
     175         [ #  # ]:          0 :                     aLocalState.DeviceColor = maFillColor;
     176                 :            : 
     177 [ #  # ][ #  # ]:          0 :                     rCachedPrimitive = mpCanvas->getUNOCanvas()->fillPolyPolygon( mxPolyPoly,
     178                 :          0 :                                                                                   mpCanvas->getViewState(),
     179 [ #  # ][ #  # ]:          0 :                                                                                   aLocalState );
         [ #  # ][ #  # ]
     180                 :            : 
     181 [ #  # ][ #  # ]:          0 :                     aLocalState.DeviceColor = aTmpColor;
     182                 :            :                 }
     183                 :            : 
     184         [ #  # ]:          0 :                 if( aLocalState.DeviceColor.getLength() )
     185                 :            :                 {
     186 [ #  # ][ #  # ]:          0 :                     rCachedPrimitive = mpCanvas->getUNOCanvas()->drawPolyPolygon( mxPolyPoly,
     187                 :          0 :                                                                                   mpCanvas->getViewState(),
     188 [ #  # ][ #  # ]:          0 :                                                                                   aLocalState );
         [ #  # ][ #  # ]
     189                 :            :                 }
     190                 :            : 
     191         [ #  # ]:          0 :                 return true;
     192                 :            :             }
     193                 :            : 
     194                 :          0 :             bool PolyPolyAction::renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
     195                 :            :                                                const Subset&                  rSubset ) const
     196                 :            :             {
     197                 :            :                 // TODO(F1): Split up poly-polygon into polygons, or even
     198                 :            :                 // line segments, when subsets are requested.
     199                 :            : 
     200                 :            :                 // polygon only contains a single action, fail if subset
     201                 :            :                 // requests different range
     202 [ #  # ][ #  # ]:          0 :                 if( rSubset.mnSubsetBegin != 0 ||
     203                 :            :                     rSubset.mnSubsetEnd != 1 )
     204                 :          0 :                     return false;
     205                 :            : 
     206                 :          0 :                 return CachedPrimitiveBase::render( rTransformation );
     207                 :            :             }
     208                 :            : 
     209                 :          0 :             ::basegfx::B2DRange PolyPolyAction::getBounds( const ::basegfx::B2DHomMatrix&   rTransformation ) const
     210                 :            :             {
     211         [ #  # ]:          0 :                 rendering::RenderState aLocalState( maState );
     212         [ #  # ]:          0 :                 ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
     213                 :            : 
     214                 :            :                 return tools::calcDevicePixelBounds(
     215                 :            :                     maBounds,
     216                 :          0 :                     mpCanvas->getViewState(),
     217 [ #  # ][ #  # ]:          0 :                     aLocalState );
         [ #  # ][ #  # ]
     218                 :            :             }
     219                 :            : 
     220                 :          0 :             ::basegfx::B2DRange PolyPolyAction::getBounds( const ::basegfx::B2DHomMatrix&   rTransformation,
     221                 :            :                                                            const Subset&                    rSubset ) const
     222                 :            :             {
     223                 :            :                 // TODO(F1): Split up poly-polygon into polygons, or even
     224                 :            :                 // line segments, when subsets are requested.
     225                 :            : 
     226                 :            :                 // polygon only contains a single action, empty bounds
     227                 :            :                 // if subset requests different range
     228 [ #  # ][ #  # ]:          0 :                 if( rSubset.mnSubsetBegin != 0 ||
     229                 :            :                     rSubset.mnSubsetEnd != 1 )
     230                 :          0 :                     return ::basegfx::B2DRange();
     231                 :            : 
     232                 :          0 :                 return getBounds( rTransformation );
     233                 :            :             }
     234                 :            : 
     235                 :          0 :             sal_Int32 PolyPolyAction::getActionCount() const
     236                 :            :             {
     237                 :            :                 // TODO(F1): Split up poly-polygon into polygons, or even
     238                 :            :                 // line segments, when subsets are requested.
     239                 :          0 :                 return 1;
     240                 :            :             }
     241                 :            : 
     242                 :            : 
     243                 :            :             // -------------------------------------------------------------------------------
     244                 :            : 
     245 [ #  # ][ #  # ]:          0 :             class TexturedPolyPolyAction : public CachedPrimitiveBase
         [ #  # ][ #  # ]
     246                 :            :             {
     247                 :            :             public:
     248                 :            :                 TexturedPolyPolyAction( const ::basegfx::B2DPolyPolygon& rPoly,
     249                 :            :                                         const CanvasSharedPtr&           rCanvas,
     250                 :            :                                         const OutDevState&               rState,
     251                 :            :                                         const rendering::Texture&        rTexture );
     252                 :            : 
     253                 :            :                 virtual bool renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
     254                 :            :                                            const Subset&                  rSubset ) const;
     255                 :            : 
     256                 :            :                 virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const;
     257                 :            :                 virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix&   rTransformation,
     258                 :            :                                                        const Subset&                    rSubset ) const;
     259                 :            : 
     260                 :            :                 virtual sal_Int32 getActionCount() const;
     261                 :            : 
     262                 :            :             private:
     263                 :            :                 using Action::render;
     264                 :            :                 virtual bool renderPrimitive( uno::Reference< rendering::XCachedPrimitive >& rCachedPrimitive,
     265                 :            :                                               const ::basegfx::B2DHomMatrix&                 rTransformation ) const;
     266                 :            : 
     267                 :            :                 const uno::Reference< rendering::XPolyPolygon2D >   mxPolyPoly;
     268                 :            :                 const ::basegfx::B2DRectangle                       maBounds;
     269                 :            :                 const CanvasSharedPtr                               mpCanvas;
     270                 :            : 
     271                 :            :                 // stroke color is now implicit: the maState.DeviceColor member
     272                 :            :                 rendering::RenderState                              maState;
     273                 :            :                 const rendering::Texture                            maTexture;
     274                 :            :             };
     275                 :            : 
     276                 :          0 :             TexturedPolyPolyAction::TexturedPolyPolyAction( const ::basegfx::B2DPolyPolygon& rPolyPoly,
     277                 :            :                                                             const CanvasSharedPtr&           rCanvas,
     278                 :            :                                                             const OutDevState&               rState,
     279                 :            :                                                             const rendering::Texture&        rTexture ) :
     280                 :            :                 CachedPrimitiveBase( rCanvas, true ),
     281 [ #  # ][ #  # ]:          0 :                 mxPolyPoly( ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon( rCanvas->getUNOCanvas()->getDevice(), rPolyPoly) ),
     282                 :            :                 maBounds( ::basegfx::tools::getRange(rPolyPoly) ),
     283                 :            :                 mpCanvas( rCanvas ),
     284                 :            :                 maState(),
     285 [ #  # ][ #  # ]:          0 :                 maTexture( rTexture )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     286                 :            :             {
     287         [ #  # ]:          0 :                 tools::initRenderState(maState,rState);
     288                 :          0 :             }
     289                 :            : 
     290                 :          0 :             bool TexturedPolyPolyAction::renderPrimitive( uno::Reference< rendering::XCachedPrimitive >& rCachedPrimitive,
     291                 :            :                                                           const ::basegfx::B2DHomMatrix&                 rTransformation ) const
     292                 :            :             {
     293                 :            :                 RTL_LOGFILE_CONTEXT( aLog, "::cppcanvas::internal::PolyPolyAction::renderPrimitive()" );
     294                 :            :                 RTL_LOGFILE_CONTEXT_TRACE1( aLog, "::cppcanvas::internal::PolyPolyAction: 0x%X", this );
     295                 :            : 
     296         [ #  # ]:          0 :                 rendering::RenderState aLocalState( maState );
     297         [ #  # ]:          0 :                 ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
     298                 :            : 
     299         [ #  # ]:          0 :                 uno::Sequence< rendering::Texture > aSeq(1);
     300 [ #  # ][ #  # ]:          0 :                 aSeq[0] = maTexture;
     301                 :            : 
     302 [ #  # ][ #  # ]:          0 :                 rCachedPrimitive = mpCanvas->getUNOCanvas()->fillTexturedPolyPolygon( mxPolyPoly,
     303                 :          0 :                                                                                       mpCanvas->getViewState(),
     304                 :            :                                                                                       aLocalState,
     305 [ #  # ][ #  # ]:          0 :                                                                                       aSeq );
         [ #  # ][ #  # ]
     306 [ #  # ][ #  # ]:          0 :                 return true;
     307                 :            :             }
     308                 :            : 
     309                 :          0 :             bool TexturedPolyPolyAction::renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
     310                 :            :                                                        const Subset&                  rSubset ) const
     311                 :            :             {
     312                 :            :                 // TODO(F1): Split up poly-polygon into polygons, or even
     313                 :            :                 // line segments, when subsets are requested.
     314                 :            : 
     315                 :            :                 // polygon only contains a single action, fail if subset
     316                 :            :                 // requests different range
     317 [ #  # ][ #  # ]:          0 :                 if( rSubset.mnSubsetBegin != 0 ||
     318                 :            :                     rSubset.mnSubsetEnd != 1 )
     319                 :          0 :                     return false;
     320                 :            : 
     321                 :          0 :                 return CachedPrimitiveBase::render( rTransformation );
     322                 :            :             }
     323                 :            : 
     324                 :          0 :             ::basegfx::B2DRange TexturedPolyPolyAction::getBounds( const ::basegfx::B2DHomMatrix&   rTransformation ) const
     325                 :            :             {
     326         [ #  # ]:          0 :                 rendering::RenderState aLocalState( maState );
     327         [ #  # ]:          0 :                 ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
     328                 :            : 
     329                 :            :                 return tools::calcDevicePixelBounds(
     330                 :            :                     maBounds,
     331                 :          0 :                     mpCanvas->getViewState(),
     332 [ #  # ][ #  # ]:          0 :                     aLocalState );
         [ #  # ][ #  # ]
     333                 :            :             }
     334                 :            : 
     335                 :          0 :             ::basegfx::B2DRange TexturedPolyPolyAction::getBounds( const ::basegfx::B2DHomMatrix&   rTransformation,
     336                 :            :                                                                    const Subset&                    rSubset ) const
     337                 :            :             {
     338                 :            :                 // TODO(F1): Split up poly-polygon into polygons, or even
     339                 :            :                 // line segments, when subsets are requested.
     340                 :            : 
     341                 :            :                 // polygon only contains a single action, empty bounds
     342                 :            :                 // if subset requests different range
     343 [ #  # ][ #  # ]:          0 :                 if( rSubset.mnSubsetBegin != 0 ||
     344                 :            :                     rSubset.mnSubsetEnd != 1 )
     345                 :          0 :                     return ::basegfx::B2DRange();
     346                 :            : 
     347                 :          0 :                 return getBounds( rTransformation );
     348                 :            :             }
     349                 :            : 
     350                 :          0 :             sal_Int32 TexturedPolyPolyAction::getActionCount() const
     351                 :            :             {
     352                 :            :                 // TODO(F1): Split up poly-polygon into polygons, or even
     353                 :            :                 // line segments, when subsets are requested.
     354                 :          0 :                 return 1;
     355                 :            :             }
     356                 :            : 
     357                 :            :             // -------------------------------------------------------------------------------
     358                 :            : 
     359 [ #  # ][ #  # ]:          0 :             class StrokedPolyPolyAction : public CachedPrimitiveBase
         [ #  # ][ #  # ]
     360                 :            :             {
     361                 :            :             public:
     362                 :            :                 StrokedPolyPolyAction( const ::basegfx::B2DPolyPolygon&     rPoly,
     363                 :            :                                        const CanvasSharedPtr&               rCanvas,
     364                 :            :                                        const OutDevState&                   rState,
     365                 :            :                                        const rendering::StrokeAttributes&   rStrokeAttributes );
     366                 :            : 
     367                 :            :                 virtual bool renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
     368                 :            :                                            const Subset&                  rSubset ) const;
     369                 :            : 
     370                 :            :                 virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const;
     371                 :            :                 virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix&   rTransformation,
     372                 :            :                                                        const Subset&                    rSubset ) const;
     373                 :            : 
     374                 :            :                 virtual sal_Int32 getActionCount() const;
     375                 :            : 
     376                 :            :             private:
     377                 :            :                 using Action::render;
     378                 :            :                 virtual bool renderPrimitive( uno::Reference< rendering::XCachedPrimitive >& rCachedPrimitive,
     379                 :            :                                               const ::basegfx::B2DHomMatrix&                 rTransformation ) const;
     380                 :            : 
     381                 :            :                 const uno::Reference< rendering::XPolyPolygon2D >   mxPolyPoly;
     382                 :            :                 const ::basegfx::B2DRectangle                       maBounds;
     383                 :            :                 const CanvasSharedPtr                               mpCanvas;
     384                 :            :                 rendering::RenderState                              maState;
     385                 :            :                 const rendering::StrokeAttributes                   maStrokeAttributes;
     386                 :            :             };
     387                 :            : 
     388                 :          0 :             StrokedPolyPolyAction::StrokedPolyPolyAction( const ::basegfx::B2DPolyPolygon&      rPolyPoly,
     389                 :            :                                                           const CanvasSharedPtr&                rCanvas,
     390                 :            :                                                           const OutDevState&                    rState,
     391                 :            :                                                           const rendering::StrokeAttributes&    rStrokeAttributes ) :
     392                 :            :                 CachedPrimitiveBase( rCanvas, false ),
     393 [ #  # ][ #  # ]:          0 :                 mxPolyPoly( ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon( rCanvas->getUNOCanvas()->getDevice(), rPolyPoly) ),
     394                 :            :                 maBounds( ::basegfx::tools::getRange(rPolyPoly) ),
     395                 :            :                 mpCanvas( rCanvas ),
     396                 :            :                 maState(),
     397 [ #  # ][ #  # ]:          0 :                 maStrokeAttributes( rStrokeAttributes )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     398                 :            :             {
     399         [ #  # ]:          0 :                 tools::initRenderState(maState,rState);
     400         [ #  # ]:          0 :                 maState.DeviceColor = rState.lineColor;
     401                 :          0 :             }
     402                 :            : 
     403                 :          0 :             bool StrokedPolyPolyAction::renderPrimitive( uno::Reference< rendering::XCachedPrimitive >& rCachedPrimitive,
     404                 :            :                                                          const ::basegfx::B2DHomMatrix&                 rTransformation ) const
     405                 :            :             {
     406                 :            :                 RTL_LOGFILE_CONTEXT( aLog, "::cppcanvas::internal::PolyPolyAction::renderPrimitive()" );
     407                 :            :                 RTL_LOGFILE_CONTEXT_TRACE1( aLog, "::cppcanvas::internal::PolyPolyAction: 0x%X", this );
     408                 :            : 
     409         [ #  # ]:          0 :                 rendering::RenderState aLocalState( maState );
     410         [ #  # ]:          0 :                 ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
     411                 :            : 
     412 [ #  # ][ #  # ]:          0 :                 rCachedPrimitive = mpCanvas->getUNOCanvas()->strokePolyPolygon( mxPolyPoly,
     413                 :          0 :                                                                                 mpCanvas->getViewState(),
     414                 :            :                                                                                 aLocalState,
     415 [ #  # ][ #  # ]:          0 :                                                                                 maStrokeAttributes );
         [ #  # ][ #  # ]
     416         [ #  # ]:          0 :                 return true;
     417                 :            :             }
     418                 :            : 
     419                 :          0 :             bool StrokedPolyPolyAction::renderSubset( const ::basegfx::B2DHomMatrix&  rTransformation,
     420                 :            :                                                       const Subset&                   rSubset ) const
     421                 :            :             {
     422                 :            :                 // TODO(F1): Split up poly-polygon into polygons, or even
     423                 :            :                 // line segments, when subsets are requested.
     424                 :            : 
     425                 :            :                 // polygon only contains a single action, fail if subset
     426                 :            :                 // requests different range
     427 [ #  # ][ #  # ]:          0 :                 if( rSubset.mnSubsetBegin != 0 ||
     428                 :            :                     rSubset.mnSubsetEnd != 1 )
     429                 :          0 :                     return false;
     430                 :            : 
     431                 :          0 :                 return CachedPrimitiveBase::render( rTransformation );
     432                 :            :             }
     433                 :            : 
     434                 :          0 :             ::basegfx::B2DRange StrokedPolyPolyAction::getBounds( const ::basegfx::B2DHomMatrix&    rTransformation ) const
     435                 :            :             {
     436         [ #  # ]:          0 :                 rendering::RenderState aLocalState( maState );
     437         [ #  # ]:          0 :                 ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
     438                 :            : 
     439                 :            :                 return tools::calcDevicePixelBounds(
     440                 :            :                     maBounds,
     441                 :          0 :                     mpCanvas->getViewState(),
     442 [ #  # ][ #  # ]:          0 :                     aLocalState );
         [ #  # ][ #  # ]
     443                 :            :             }
     444                 :            : 
     445                 :          0 :             ::basegfx::B2DRange StrokedPolyPolyAction::getBounds( const ::basegfx::B2DHomMatrix&    rTransformation,
     446                 :            :                                                                   const Subset&                 rSubset ) const
     447                 :            :             {
     448                 :            :                 // TODO(F1): Split up poly-polygon into polygons, or even
     449                 :            :                 // line segments, when subsets are requested.
     450                 :            : 
     451                 :            :                 // polygon only contains a single action, empty bounds
     452                 :            :                 // if subset requests different range
     453 [ #  # ][ #  # ]:          0 :                 if( rSubset.mnSubsetBegin != 0 ||
     454                 :            :                     rSubset.mnSubsetEnd != 1 )
     455                 :          0 :                     return ::basegfx::B2DRange();
     456                 :            : 
     457                 :          0 :                 return getBounds( rTransformation );
     458                 :            :             }
     459                 :            : 
     460                 :          0 :             sal_Int32 StrokedPolyPolyAction::getActionCount() const
     461                 :            :             {
     462                 :            :                 // TODO(F1): Split up poly-polygon into polygons, or even
     463                 :            :                 // line segments, when subsets are requested.
     464                 :          0 :                 return 1;
     465                 :            :             }
     466                 :            :         }
     467                 :            : 
     468                 :          0 :         ActionSharedPtr PolyPolyActionFactory::createPolyPolyAction( const ::basegfx::B2DPolyPolygon& rPoly,
     469                 :            :                                                                      const CanvasSharedPtr&           rCanvas,
     470                 :            :                                                                      const OutDevState&               rState    )
     471                 :            :         {
     472                 :            :             OSL_ENSURE( rState.isLineColorSet || rState.isFillColorSet,
     473                 :            :                         "PolyPolyActionFactory::createPolyPolyAction() with empty line and fill color" );
     474                 :            :             return ActionSharedPtr( new PolyPolyAction( rPoly, rCanvas, rState,
     475                 :            :                                                         rState.isFillColorSet,
     476         [ #  # ]:          0 :                                                         rState.isLineColorSet ) );
     477                 :            :         }
     478                 :            : 
     479                 :          0 :         ActionSharedPtr PolyPolyActionFactory::createPolyPolyAction( const ::basegfx::B2DPolyPolygon&   rPoly,
     480                 :            :                                                                      const CanvasSharedPtr&             rCanvas,
     481                 :            :                                                                      const OutDevState&                 rState,
     482                 :            :                                                                      const rendering::Texture&          rTexture )
     483                 :            :         {
     484         [ #  # ]:          0 :             return ActionSharedPtr( new TexturedPolyPolyAction( rPoly, rCanvas, rState, rTexture ) );
     485                 :            :         }
     486                 :            : 
     487                 :          0 :         ActionSharedPtr PolyPolyActionFactory::createLinePolyPolyAction( const ::basegfx::B2DPolyPolygon& rPoly,
     488                 :            :                                                                          const CanvasSharedPtr&           rCanvas,
     489                 :            :                                                                          const OutDevState&               rState )
     490                 :            :         {
     491                 :            :             OSL_ENSURE( rState.isLineColorSet,
     492                 :            :                         "PolyPolyActionFactory::createLinePolyPolyAction() called with empty line color" );
     493                 :            : 
     494                 :            :             return ActionSharedPtr( new PolyPolyAction( rPoly, rCanvas, rState,
     495                 :            :                                                         false,
     496         [ #  # ]:          0 :                                                         rState.isLineColorSet ) );
     497                 :            :         }
     498                 :            : 
     499                 :          0 :         ActionSharedPtr PolyPolyActionFactory::createPolyPolyAction( const ::basegfx::B2DPolyPolygon&   rPoly,
     500                 :            :                                                                      const CanvasSharedPtr&             rCanvas,
     501                 :            :                                                                      const OutDevState&                 rState,
     502                 :            :                                                                      const rendering::StrokeAttributes& rStrokeAttributes )
     503                 :            :         {
     504                 :            :             OSL_ENSURE( rState.isLineColorSet,
     505                 :            :                         "PolyPolyActionFactory::createPolyPolyAction() for strokes called with empty line color" );
     506         [ #  # ]:          0 :             return ActionSharedPtr( new StrokedPolyPolyAction( rPoly, rCanvas, rState, rStrokeAttributes ) );
     507                 :            :         }
     508                 :            : 
     509                 :          0 :         ActionSharedPtr PolyPolyActionFactory::createPolyPolyAction( const ::basegfx::B2DPolyPolygon& rPoly,
     510                 :            :                                                                      const CanvasSharedPtr&           rCanvas,
     511                 :            :                                                                      const OutDevState&               rState,
     512                 :            :                                                                      int                              nTransparency     )
     513                 :            :         {
     514                 :            :             OSL_ENSURE( rState.isLineColorSet || rState.isFillColorSet,
     515                 :            :                         "PolyPolyActionFactory::createPolyPolyAction() with empty line and fill color" );
     516                 :            :             return ActionSharedPtr( new PolyPolyAction( rPoly, rCanvas, rState,
     517                 :            :                                                         rState.isFillColorSet,
     518                 :            :                                                         rState.isLineColorSet,
     519         [ #  # ]:          0 :                                                         nTransparency ) );
     520                 :            :         }
     521                 :            : 
     522                 :            :     }
     523                 :            : }
     524                 :            : 
     525                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10