LCOV - code coverage report
Current view: top level - slideshow/source/engine - slidebitmap.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 33 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 6 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             : // must be first
      22             : #include <canvas/debug.hxx>
      23             : #include <tools/diagnose_ex.h>
      24             : #include <slidebitmap.hxx>
      25             : 
      26             : #include <com/sun/star/rendering/XCanvas.hpp>
      27             : #include <com/sun/star/rendering/XBitmap.hpp>
      28             : #include <comphelper/anytostring.hxx>
      29             : #include <cppuhelper/exc_hlp.hxx>
      30             : 
      31             : #include <basegfx/matrix/b2dhommatrix.hxx>
      32             : #include <basegfx/matrix/b2dhommatrixtools.hxx>
      33             : 
      34             : #include <canvas/canvastools.hxx>
      35             : #include <basegfx/tools/canvastools.hxx>
      36             : 
      37             : 
      38             : using namespace ::com::sun::star;
      39             : 
      40             : namespace slideshow
      41             : {
      42             :     namespace internal
      43             :     {
      44             : 
      45           0 :         SlideBitmap::SlideBitmap( const ::cppcanvas::BitmapSharedPtr& rBitmap ) :
      46             :             maOutputPos(),
      47             :             maClipPoly(),
      48           0 :             mxBitmap()
      49             :         {
      50           0 :             if( rBitmap )
      51           0 :                 mxBitmap = rBitmap->getUNOBitmap();
      52             : 
      53           0 :             ENSURE_OR_THROW( mxBitmap.is(), "SlideBitmap::SlideBitmap(): Invalid bitmap" );
      54           0 :         }
      55             : 
      56           0 :         bool SlideBitmap::draw( const ::cppcanvas::CanvasSharedPtr& rCanvas ) const
      57             :         {
      58           0 :             ENSURE_OR_RETURN_FALSE( rCanvas && rCanvas->getUNOCanvas().is(),
      59             :                                "SlideBitmap::draw(): Invalid canvas" );
      60             : 
      61             :             // selectively only copy the transformation from current viewstate,
      62             :             // don't want no clipping here.
      63           0 :             rendering::ViewState aViewState;
      64           0 :             aViewState.AffineTransform = rCanvas->getViewState().AffineTransform;
      65             : 
      66           0 :             rendering::RenderState aRenderState;
      67           0 :             ::canvas::tools::initRenderState( aRenderState );
      68             : 
      69           0 :             const basegfx::B2DHomMatrix aTranslation(basegfx::tools::createTranslateB2DHomMatrix(maOutputPos));
      70           0 :             ::canvas::tools::setRenderStateTransform( aRenderState, aTranslation );
      71             : 
      72             :             try
      73             :             {
      74           0 :                 if( maClipPoly.count() )
      75             :                 {
      76             :                     // TODO(P1): Buffer the clip polygon
      77           0 :                     aRenderState.Clip =
      78             :                         ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
      79           0 :                             rCanvas->getUNOCanvas()->getDevice(),
      80           0 :                             maClipPoly );
      81             :                 }
      82             : 
      83           0 :                 rCanvas->getUNOCanvas()->drawBitmap( mxBitmap,
      84             :                                                      aViewState,
      85           0 :                                                      aRenderState );
      86             :             }
      87           0 :             catch( uno::Exception& )
      88             :             {
      89             :                 OSL_FAIL( OUStringToOString(
      90             :                                 comphelper::anyToString( cppu::getCaughtException() ),
      91             :                                 RTL_TEXTENCODING_UTF8 ).getStr() );
      92             : 
      93           0 :                 return false;
      94             :             }
      95             : 
      96           0 :             return true;
      97             :         }
      98             : 
      99           0 :         ::basegfx::B2ISize SlideBitmap::getSize() const
     100             :         {
     101           0 :             return ::basegfx::unotools::b2ISizeFromIntegerSize2D( mxBitmap->getSize() );
     102             :         }
     103             : 
     104           0 :         void SlideBitmap::move( const ::basegfx::B2DPoint& rNewPos )
     105             :         {
     106           0 :             maOutputPos = rNewPos;
     107           0 :         }
     108             : 
     109           0 :         void SlideBitmap::clip( const ::basegfx::B2DPolyPolygon& rClipPoly )
     110             :         {
     111           0 :             maClipPoly = rClipPoly;
     112           0 :         }
     113             : 
     114             :         ::com::sun::star::uno::Reference<
     115           0 :                 ::com::sun::star::rendering::XBitmap >    SlideBitmap::getXBitmap()
     116             :         {
     117           0 :         return mxBitmap;
     118             :         }
     119             : 
     120             :     }
     121             : }
     122             : 
     123             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11