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

Generated by: LCOV version 1.10