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

Generated by: LCOV version 1.10