LCOV - code coverage report
Current view: top level - cppcanvas/source/tools - canvasgraphichelper.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 41 0.0 %
Date: 2014-04-14 Functions: 0 12 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include <canvasgraphichelper.hxx>
      22             : 
      23             : #include <com/sun/star/rendering/XGraphicDevice.hpp>
      24             : #include <com/sun/star/rendering/XCanvas.hpp>
      25             : #include <com/sun/star/rendering/XPolyPolygon2D.hpp>
      26             : 
      27             : #include <canvas/canvastools.hxx>
      28             : #include <basegfx/tools/canvastools.hxx>
      29             : #include <basegfx/matrix/b2dhommatrix.hxx>
      30             : 
      31             : #include <cppcanvas/polypolygon.hxx>
      32             : #include "tools.hxx"
      33             : 
      34             : 
      35             : using namespace ::com::sun::star;
      36             : 
      37             : /* Implementation of CanvasGraphicHelper class */
      38             : 
      39             : namespace cppcanvas
      40             : {
      41             : 
      42             :     namespace internal
      43             :     {
      44           0 :         CanvasGraphicHelper::CanvasGraphicHelper( const CanvasSharedPtr& rParentCanvas ) :
      45             :             maClipPolyPolygon(),
      46             :             mpCanvas( rParentCanvas ),
      47           0 :             mxGraphicDevice()
      48             :         {
      49             :             OSL_ENSURE( mpCanvas.get() != NULL &&
      50             :                         mpCanvas->getUNOCanvas().is(),
      51             :                         "CanvasGraphicHelper::CanvasGraphicHelper: no valid canvas" );
      52             : 
      53           0 :             if( mpCanvas.get() != NULL &&
      54           0 :                 mpCanvas->getUNOCanvas().is() )
      55             :             {
      56           0 :                 mxGraphicDevice = mpCanvas->getUNOCanvas()->getDevice();
      57             :             }
      58             : 
      59           0 :             ::canvas::tools::initRenderState( maRenderState );
      60           0 :         }
      61             : 
      62           0 :         void CanvasGraphicHelper::setTransformation( const ::basegfx::B2DHomMatrix& rMatrix )
      63             :         {
      64           0 :             ::canvas::tools::setRenderStateTransform( maRenderState, rMatrix );
      65           0 :         }
      66             : 
      67           0 :         ::basegfx::B2DHomMatrix CanvasGraphicHelper::getTransformation() const
      68             :         {
      69           0 :             ::basegfx::B2DHomMatrix aMatrix;
      70             :             return ::canvas::tools::getRenderStateTransform( aMatrix,
      71           0 :                                                              maRenderState );
      72             :         }
      73             : 
      74           0 :         void CanvasGraphicHelper::setClip( const ::basegfx::B2DPolyPolygon& rClipPoly )
      75             :         {
      76             :             // TODO(T3): not thread-safe. B2DPolyPolygon employs copy-on-write
      77           0 :             maClipPolyPolygon.reset( rClipPoly );
      78           0 :             maRenderState.Clip.clear();
      79           0 :         }
      80             : 
      81           0 :         void CanvasGraphicHelper::setClip()
      82             :         {
      83           0 :             maClipPolyPolygon.reset();
      84           0 :             maRenderState.Clip.clear();
      85           0 :         }
      86             : 
      87           0 :         ::basegfx::B2DPolyPolygon const* CanvasGraphicHelper::getClip() const
      88             :         {
      89           0 :             return !maClipPolyPolygon ? NULL : &(*maClipPolyPolygon);
      90             :         }
      91             : 
      92           0 :         const rendering::RenderState& CanvasGraphicHelper::getRenderState() const
      93             :         {
      94           0 :             if( maClipPolyPolygon && !maRenderState.Clip.is() )
      95             :             {
      96           0 :                 uno::Reference< rendering::XCanvas > xCanvas( mpCanvas->getUNOCanvas() );
      97           0 :                 if( !xCanvas.is() )
      98           0 :                     return maRenderState;
      99             : 
     100           0 :                 maRenderState.Clip = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
     101           0 :                     xCanvas->getDevice(),
     102           0 :                     *maClipPolyPolygon );
     103             :             }
     104             : 
     105           0 :             return maRenderState;
     106             :         }
     107             : 
     108           0 :         void CanvasGraphicHelper::setCompositeOp( CompositeOp aOp )
     109             :         {
     110           0 :             maRenderState.CompositeOperation = (sal_Int8)aOp;
     111           0 :         }
     112             : 
     113           0 :         CanvasGraphic::CompositeOp CanvasGraphicHelper::getCompositeOp() const
     114             :         {
     115           0 :             return static_cast<CompositeOp>(maRenderState.CompositeOperation);
     116             :         }
     117             : 
     118           0 :         CanvasSharedPtr CanvasGraphicHelper::getCanvas() const
     119             :         {
     120           0 :             return mpCanvas;
     121             :         }
     122             : 
     123           0 :         uno::Reference< rendering::XGraphicDevice > CanvasGraphicHelper::getGraphicDevice() const
     124             :         {
     125           0 :             return mxGraphicDevice;
     126             :         }
     127             : 
     128             :     }
     129             : }
     130             : 
     131             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10