LCOV - code coverage report
Current view: top level - cppcanvas/source/mtfrenderer - lineaction.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 33 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 9 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 <lineaction.hxx>
      22             : #include <outdevstate.hxx>
      23             : 
      24             : #include <com/sun/star/rendering/XCanvas.hpp>
      25             : 
      26             : #include <tools/gen.hxx>
      27             : #include <vcl/canvastools.hxx>
      28             : 
      29             : #include <basegfx/range/b2drange.hxx>
      30             : #include <basegfx/point/b2dpoint.hxx>
      31             : #include <basegfx/tools/canvastools.hxx>
      32             : #include <canvas/canvastools.hxx>
      33             : 
      34             : #include <boost/utility.hpp>
      35             : 
      36             : #include <cppcanvas/canvas.hxx>
      37             : 
      38             : #include <mtftools.hxx>
      39             : 
      40             : 
      41             : using namespace ::com::sun::star;
      42             : 
      43             : namespace cppcanvas
      44             : {
      45             :     namespace internal
      46             :     {
      47             :         namespace
      48             :         {
      49           0 :             class LineAction : public Action, private ::boost::noncopyable
      50             :             {
      51             :             public:
      52             :                 LineAction( const ::basegfx::B2DPoint&,
      53             :                             const ::basegfx::B2DPoint&,
      54             :                             const CanvasSharedPtr&,
      55             :                             const OutDevState& );
      56             : 
      57             :                 virtual bool render( const ::basegfx::B2DHomMatrix& rTransformation ) const SAL_OVERRIDE;
      58             :                 virtual bool renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
      59             :                                            const Subset&                  rSubset ) const SAL_OVERRIDE;
      60             : 
      61             :                 virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const SAL_OVERRIDE;
      62             :                 virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix&   rTransformation,
      63             :                                                        const Subset&                    rSubset ) const SAL_OVERRIDE;
      64             : 
      65             :                 virtual sal_Int32 getActionCount() const SAL_OVERRIDE;
      66             : 
      67             :             private:
      68             :                 ::basegfx::B2DPoint     maStartPoint;
      69             :                 ::basegfx::B2DPoint     maEndPoint;
      70             :                 CanvasSharedPtr         mpCanvas;
      71             :                 rendering::RenderState  maState;
      72             :             };
      73             : 
      74           0 :             LineAction::LineAction( const ::basegfx::B2DPoint& rStartPoint,
      75             :                                     const ::basegfx::B2DPoint& rEndPoint,
      76             :                                     const CanvasSharedPtr&     rCanvas,
      77             :                                     const OutDevState&         rState ) :
      78             :                 maStartPoint( rStartPoint ),
      79             :                 maEndPoint( rEndPoint ),
      80             :                 mpCanvas( rCanvas ),
      81           0 :                 maState()
      82             :             {
      83           0 :                 tools::initRenderState(maState,rState);
      84           0 :                 maState.DeviceColor = rState.lineColor;
      85           0 :             }
      86             : 
      87           0 :             bool LineAction::render( const ::basegfx::B2DHomMatrix& rTransformation ) const
      88             :             {
      89             :                 SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::LineAction::render()" );
      90             :                 SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::LineAction: 0x" << std::hex << this );
      91             : 
      92           0 :                 rendering::RenderState aLocalState( maState );
      93           0 :                 ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
      94             : 
      95           0 :                 mpCanvas->getUNOCanvas()->drawLine( ::basegfx::unotools::point2DFromB2DPoint(maStartPoint),
      96           0 :                                                     ::basegfx::unotools::point2DFromB2DPoint(maEndPoint),
      97           0 :                                                     mpCanvas->getViewState(),
      98           0 :                                                     aLocalState );
      99             : 
     100           0 :                 return true;
     101             :             }
     102             : 
     103           0 :             bool LineAction::renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
     104             :                                            const Subset&                  rSubset ) const
     105             :             {
     106             :                 // line only contains a single action, fail if subset
     107             :                 // requests different range
     108           0 :                 if( rSubset.mnSubsetBegin != 0 ||
     109           0 :                     rSubset.mnSubsetEnd != 1 )
     110           0 :                     return false;
     111             : 
     112           0 :                 return render( rTransformation );
     113             :             }
     114             : 
     115           0 :             ::basegfx::B2DRange LineAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const
     116             :             {
     117           0 :                 rendering::RenderState aLocalState( maState );
     118           0 :                 ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
     119             : 
     120             :                 return tools::calcDevicePixelBounds( ::basegfx::B2DRange( maStartPoint,
     121             :                                                                           maEndPoint ),
     122           0 :                                                      mpCanvas->getViewState(),
     123           0 :                                                      aLocalState );
     124             :             }
     125             : 
     126           0 :             ::basegfx::B2DRange LineAction::getBounds( const ::basegfx::B2DHomMatrix&   rTransformation,
     127             :                                                        const Subset&                    rSubset ) const
     128             :             {
     129             :                 // line only contains a single action, empty bounds
     130             :                 // if subset requests different range
     131           0 :                 if( rSubset.mnSubsetBegin != 0 ||
     132           0 :                     rSubset.mnSubsetEnd != 1 )
     133           0 :                     return ::basegfx::B2DRange();
     134             : 
     135           0 :                 return getBounds( rTransformation );
     136             :             }
     137             : 
     138           0 :             sal_Int32 LineAction::getActionCount() const
     139             :             {
     140           0 :                 return 1;
     141             :             }
     142             :         }
     143             : 
     144           0 :         ActionSharedPtr LineActionFactory::createLineAction( const ::basegfx::B2DPoint& rStartPoint,
     145             :                                                              const ::basegfx::B2DPoint& rEndPoint,
     146             :                                                              const CanvasSharedPtr&     rCanvas,
     147             :                                                              const OutDevState&         rState  )
     148             :         {
     149             :             return ActionSharedPtr( new LineAction( rStartPoint,
     150             :                                                     rEndPoint,
     151             :                                                     rCanvas,
     152           0 :                                                     rState) );
     153             :         }
     154             : 
     155             :     }
     156             : }
     157             : 
     158             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11