LCOV - code coverage report
Current view: top level - sw/source/core/uibase/docvw - DashedLine.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 39 0.0 %
Date: 2014-04-14 Functions: 0 4 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             : 
      10             : #include <DashedLine.hxx>
      11             : 
      12             : #include <basegfx/color/bcolortools.hxx>
      13             : #include <basegfx/polygon/b2dpolygon.hxx>
      14             : #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
      15             : #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
      16             : #include <drawinglayer/processor2d/baseprocessor2d.hxx>
      17             : #include <drawinglayer/processor2d/processorfromoutputdevice.hxx>
      18             : #include <vcl/svapp.hxx>
      19             : #include <vcl/settings.hxx>
      20             : 
      21           0 : SwDashedLine::SwDashedLine( Window* pParent, Color& ( *pColorFn )() ) :
      22             :     FixedLine( pParent, WB_DIALOGCONTROL | WB_HORZ ),
      23           0 :     m_pColorFn( pColorFn )
      24             : {
      25           0 : }
      26             : 
      27           0 : SwDashedLine::~SwDashedLine( )
      28             : {
      29           0 : }
      30             : 
      31           0 : void SwDashedLine::Paint( const Rectangle& )
      32             : {
      33           0 :     const drawinglayer::geometry::ViewInformation2D aNewViewInfos;
      34             :     drawinglayer::processor2d::BaseProcessor2D * pProcessor =
      35             :         drawinglayer::processor2d::createBaseProcessor2DFromOutputDevice(
      36           0 :                     *this, aNewViewInfos );
      37             : 
      38             :     // Compute the start and end points
      39           0 :     const Rectangle aRect( Rectangle( Point( 0, 0 ), PixelToLogic( GetSizePixel() ) ) );
      40           0 :     double nHalfWidth = double( aRect.Top() + aRect.Bottom() ) / 2.0;
      41             : 
      42           0 :     basegfx::B2DPoint aStart( double( aRect.Left() ), nHalfWidth );
      43           0 :     basegfx::B2DPoint aEnd( double( aRect.Right() ), nHalfWidth );
      44             : 
      45           0 :     basegfx::B2DPolygon aPolygon;
      46           0 :     aPolygon.append( aStart );
      47           0 :     aPolygon.append( aEnd );
      48             : 
      49           0 :     drawinglayer::primitive2d::Primitive2DSequence aSeq( 1 );
      50             : 
      51           0 :     const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings();
      52             : 
      53           0 :     std::vector< double > aStrokePattern;
      54           0 :     basegfx::BColor aColor = m_pColorFn().getBColor();
      55           0 :     if ( rSettings.GetHighContrastMode( ) )
      56             :     {
      57             :         // Only a solid line in high contrast mode
      58           0 :         aColor = rSettings.GetDialogTextColor().getBColor();
      59             :     }
      60             :     else
      61             :     {
      62             :         // Get a color for the contrast
      63           0 :         basegfx::BColor aHslLine = basegfx::tools::rgb2hsl( aColor );
      64           0 :         double nLuminance = aHslLine.getZ();
      65           0 :         nLuminance += ( 1.0 - nLuminance ) * 0.75;
      66           0 :         if ( aHslLine.getZ() > 0.7 )
      67           0 :             nLuminance = aHslLine.getZ() * 0.7;
      68           0 :         aHslLine.setZ( nLuminance );
      69           0 :         const basegfx::BColor aOtherColor = basegfx::tools::hsl2rgb( aHslLine );
      70             : 
      71             :         // Compute the plain line
      72             :         drawinglayer::primitive2d::PolygonHairlinePrimitive2D * pPlainLine =
      73             :             new drawinglayer::primitive2d::PolygonHairlinePrimitive2D(
      74           0 :                     aPolygon, aOtherColor );
      75             : 
      76           0 :         aSeq[0] = drawinglayer::primitive2d::Primitive2DReference( pPlainLine );
      77             :         // Dashed line in twips
      78           0 :         aStrokePattern.push_back( 3 );
      79           0 :         aStrokePattern.push_back( 3 );
      80             : 
      81           0 :         aSeq.realloc( 2 );
      82             :     }
      83             : 
      84             :     // Compute the dashed line primitive
      85             :     drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D * pLine =
      86             :             new drawinglayer::primitive2d::PolyPolygonStrokePrimitive2D (
      87             :                 basegfx::B2DPolyPolygon( aPolygon ),
      88           0 :                 drawinglayer::attribute::LineAttribute( m_pColorFn().getBColor() ),
      89           0 :                 drawinglayer::attribute::StrokeAttribute( aStrokePattern ) );
      90             : 
      91           0 :     aSeq[ aSeq.getLength() - 1 ] = drawinglayer::primitive2d::Primitive2DReference( pLine );
      92             : 
      93           0 :     pProcessor->process( aSeq );
      94           0 :     delete pProcessor;
      95           0 : }
      96             : 
      97             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10