LCOV - code coverage report
Current view: top level - cppcanvas/source/wrapper - implpolypolygon.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 64 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 15 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/math.hxx>
      22             : #include <osl/diagnose.h>
      23             : 
      24             : #include <com/sun/star/rendering/XCanvas.hpp>
      25             : #include <com/sun/star/rendering/PathJoinType.hpp>
      26             : #include <com/sun/star/rendering/PathCapType.hpp>
      27             : 
      28             : #include <basegfx/matrix/b2dhommatrix.hxx>
      29             : #include <basegfx/tools/canvastools.hxx>
      30             : 
      31             : #include "implpolypolygon.hxx"
      32             : #include "tools.hxx"
      33             : 
      34             : 
      35             : using namespace ::com::sun::star;
      36             : 
      37             : 
      38             : namespace cppcanvas
      39             : {
      40             :     namespace internal
      41             :     {
      42           0 :         ImplPolyPolygon::ImplPolyPolygon( const CanvasSharedPtr& rParentCanvas,
      43             :                                           const uno::Reference< rendering::XPolyPolygon2D >& rPolyPoly ) :
      44             :             CanvasGraphicHelper( rParentCanvas ),
      45             :             mxPolyPoly( rPolyPoly ),
      46             :             maStrokeAttributes(1.0,
      47             :                                10.0,
      48             :                                uno::Sequence< double >(),
      49             :                                uno::Sequence< double >(),
      50             :                                rendering::PathCapType::ROUND,
      51             :                                rendering::PathCapType::ROUND,
      52             :                                rendering::PathJoinType::ROUND ),
      53             :             maFillColor(),
      54             :             maStrokeColor(),
      55             :             mbFillColorSet( false ),
      56           0 :             mbStrokeColorSet( false )
      57             :         {
      58             :             OSL_ENSURE( mxPolyPoly.is(), "PolyPolygonImpl::PolyPolygonImpl: no valid polygon" );
      59           0 :         }
      60             : 
      61           0 :         ImplPolyPolygon::~ImplPolyPolygon()
      62             :         {
      63           0 :         }
      64             : 
      65           0 :         void ImplPolyPolygon::addPolygon( const ::basegfx::B2DPolygon& rPoly )
      66             :         {
      67             :             OSL_ENSURE( mxPolyPoly.is(),
      68             :                         "ImplPolyPolygon::addPolygon(): Invalid polygon" );
      69             : 
      70           0 :             if( !mxPolyPoly.is() )
      71           0 :                 return;
      72             : 
      73           0 :             uno::Reference< rendering::XGraphicDevice > xDevice( getGraphicDevice() );
      74             : 
      75             :             OSL_ENSURE( xDevice.is(),
      76             :                         "ImplPolyPolygon::addPolygon(): Invalid graphic device" );
      77             : 
      78           0 :             if( !xDevice.is() )
      79           0 :                 return;
      80             : 
      81           0 :             mxPolyPoly->addPolyPolygon( geometry::RealPoint2D(0.0, 0.0),
      82             :                                         ::basegfx::unotools::xPolyPolygonFromB2DPolygon(
      83             :                                             xDevice,
      84           0 :                                             rPoly) );
      85             :         }
      86             : 
      87           0 :         void ImplPolyPolygon::addPolyPolygon( const ::basegfx::B2DPolyPolygon& rPoly )
      88             :         {
      89             :             OSL_ENSURE( mxPolyPoly.is(),
      90             :                         "ImplPolyPolygon::addPolyPolygon(): Invalid polygon" );
      91             : 
      92           0 :             if( !mxPolyPoly.is() )
      93           0 :                 return;
      94             : 
      95           0 :             uno::Reference< rendering::XGraphicDevice > xDevice( getGraphicDevice() );
      96             : 
      97             :             OSL_ENSURE( xDevice.is(),
      98             :                         "ImplPolyPolygon::addPolyPolygon(): Invalid graphic device" );
      99             : 
     100           0 :             if( !xDevice.is() )
     101           0 :                 return;
     102             : 
     103           0 :             mxPolyPoly->addPolyPolygon( geometry::RealPoint2D(0.0, 0.0),
     104             :                                         ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
     105             :                                             xDevice,
     106           0 :                                             rPoly) );
     107             :         }
     108             : 
     109           0 :         void ImplPolyPolygon::setRGBAFillColor( Color::IntSRGBA aColor )
     110             :         {
     111           0 :             maFillColor = tools::intSRGBAToDoubleSequence( getGraphicDevice(),
     112           0 :                                                            aColor );
     113           0 :             mbFillColorSet = true;
     114           0 :         }
     115             : 
     116           0 :         void ImplPolyPolygon::setRGBALineColor( Color::IntSRGBA aColor )
     117             :         {
     118           0 :             maStrokeColor = tools::intSRGBAToDoubleSequence( getGraphicDevice(),
     119           0 :                                                              aColor );
     120           0 :             mbStrokeColorSet = true;
     121           0 :         }
     122             : 
     123           0 :         Color::IntSRGBA ImplPolyPolygon::getRGBAFillColor() const
     124             :         {
     125             :             return tools::doubleSequenceToIntSRGBA( getGraphicDevice(),
     126           0 :                                                     maFillColor );
     127             :         }
     128             : 
     129           0 :         Color::IntSRGBA ImplPolyPolygon::getRGBALineColor() const
     130             :         {
     131             :             return tools::doubleSequenceToIntSRGBA( getGraphicDevice(),
     132           0 :                                                     maStrokeColor );
     133             :         }
     134             : 
     135           0 :         void ImplPolyPolygon::setStrokeWidth( const double& rStrokeWidth )
     136             :         {
     137           0 :             maStrokeAttributes.StrokeWidth = rStrokeWidth;
     138           0 :         }
     139             : 
     140           0 :         double ImplPolyPolygon::getStrokeWidth() const
     141             :         {
     142           0 :             return maStrokeAttributes.StrokeWidth;
     143             :         }
     144             : 
     145           0 :         bool ImplPolyPolygon::draw() const
     146             :         {
     147           0 :             CanvasSharedPtr pCanvas( getCanvas() );
     148             : 
     149             :             OSL_ENSURE( pCanvas.get() != NULL &&
     150             :                         pCanvas->getUNOCanvas().is(),
     151             :                         "ImplBitmap::draw: invalid canvas" );
     152             : 
     153           0 :             if( pCanvas.get() == NULL ||
     154           0 :                 !pCanvas->getUNOCanvas().is() )
     155           0 :                 return false;
     156             : 
     157           0 :             if( mbFillColorSet )
     158             :             {
     159           0 :                 rendering::RenderState aLocalState( getRenderState() );
     160           0 :                 aLocalState.DeviceColor = maFillColor;
     161             : 
     162           0 :                 pCanvas->getUNOCanvas()->fillPolyPolygon( mxPolyPoly,
     163           0 :                                                           pCanvas->getViewState(),
     164           0 :                                                           aLocalState );
     165             :             }
     166             : 
     167           0 :             if( mbStrokeColorSet )
     168             :             {
     169           0 :                 rendering::RenderState aLocalState( getRenderState() );
     170           0 :                 aLocalState.DeviceColor = maStrokeColor;
     171             : 
     172           0 :                 if( ::rtl::math::approxEqual(maStrokeAttributes.StrokeWidth, 1.0) )
     173           0 :                     pCanvas->getUNOCanvas()->drawPolyPolygon( mxPolyPoly,
     174           0 :                                                               pCanvas->getViewState(),
     175           0 :                                                               aLocalState );
     176             :                 else
     177           0 :                     pCanvas->getUNOCanvas()->strokePolyPolygon( mxPolyPoly,
     178           0 :                                                                 pCanvas->getViewState(),
     179             :                                                                 aLocalState,
     180           0 :                                                                 maStrokeAttributes );
     181             :             }
     182             : 
     183           0 :             return true;
     184             :         }
     185             : 
     186           0 :         uno::Reference< rendering::XPolyPolygon2D > ImplPolyPolygon::getUNOPolyPolygon() const
     187             :         {
     188           0 :             return mxPolyPoly;
     189             :         }
     190             : 
     191             :     }
     192             : }
     193             : 
     194             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11