LCOV - code coverage report
Current view: top level - sfx2/source/sidebar - DrawHelper.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 48 63 76.2 %
Date: 2014-11-03 Functions: 6 6 100.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             : #include "DrawHelper.hxx"
      21             : #include "Paint.hxx"
      22             : 
      23             : #include <vcl/lineinfo.hxx>
      24             : 
      25             : namespace sfx2 { namespace sidebar {
      26             : 
      27       19772 : void DrawHelper::DrawBorder (
      28             :     OutputDevice& rDevice,
      29             :     const Rectangle rBox,
      30             :     const SvBorder aBorderSize,
      31             :     const Paint& rHorizontalPaint,
      32             :     const Paint& rVerticalPaint)
      33             : {
      34             :     // Draw top line.
      35             :     DrawHorizontalLine(
      36             :         rDevice,
      37       19772 :         rBox.Left(),
      38       19772 :         rBox.Right(),
      39       19772 :         rBox.Top(),
      40       19772 :         aBorderSize.Top(),
      41       79088 :         rHorizontalPaint);
      42             :     // Draw bottom line.
      43             :     DrawHorizontalLine(
      44             :         rDevice,
      45       39544 :         rBox.Left()+aBorderSize.Left(),
      46       19772 :         rBox.Right(),
      47       39544 :         rBox.Bottom()-aBorderSize.Bottom()+1,
      48       19772 :         aBorderSize.Bottom(),
      49      118632 :         rHorizontalPaint);
      50             :     // Draw left line.
      51             :     DrawVerticalLine(
      52             :         rDevice,
      53       39544 :         rBox.Top()+aBorderSize.Top(),
      54       19772 :         rBox.Bottom(),
      55       19772 :         rBox.Left(),
      56       19772 :         aBorderSize.Left(),
      57       98860 :         rVerticalPaint);
      58             :     // Draw right line.
      59             :     DrawVerticalLine(
      60             :         rDevice,
      61       39544 :         rBox.Top()+aBorderSize.Top(),
      62       39544 :         rBox.Bottom()-aBorderSize.Bottom(),
      63       39544 :         rBox.Right()-aBorderSize.Right()+1,
      64       19772 :         aBorderSize.Right(),
      65      138404 :         rVerticalPaint);
      66       19772 : }
      67             : 
      68       51113 : void DrawHelper::DrawHorizontalLine(
      69             :     OutputDevice& rDevice,
      70             :     const sal_Int32 nLeft,
      71             :     const sal_Int32 nRight,
      72             :     const sal_Int32 nY,
      73             :     const sal_Int32 nHeight,
      74             :     const Paint& rPaint)
      75             : {
      76       51113 :     switch (rPaint.GetType())
      77             :     {
      78             :         case Paint::NoPaint:
      79             :         default:
      80           0 :             break;
      81             : 
      82             :         case Paint::ColorPaint:
      83             :         {
      84       51113 :             const Color aColor (rPaint.GetColor());
      85       51113 :             rDevice.SetLineColor(aColor);
      86      121998 :             for (sal_Int32 nYOffset=0; nYOffset<nHeight; ++nYOffset)
      87             :                 rDevice.DrawLine(
      88       70885 :                     Point(nLeft,nY+nYOffset),
      89      141770 :                     Point(nRight,nY+nYOffset));
      90       51113 :             break;
      91             :         }
      92             :         case Paint::GradientPaint:
      93             :             rDevice.DrawGradient(
      94             :                 Rectangle(
      95             :                     nLeft,
      96             :                     nY,
      97             :                     nRight,
      98           0 :                     nY+nHeight-1),
      99           0 :                 rPaint.GetGradient());
     100           0 :             break;
     101             :     }
     102       51113 : }
     103             : 
     104       39544 : void DrawHelper::DrawVerticalLine(
     105             :     OutputDevice& rDevice,
     106             :     const sal_Int32 nTop,
     107             :     const sal_Int32 nBottom,
     108             :     const sal_Int32 nX,
     109             :     const sal_Int32 nWidth,
     110             :     const Paint& rPaint)
     111             : {
     112       39544 :     switch (rPaint.GetType())
     113             :     {
     114             :         case Paint::NoPaint:
     115             :         default:
     116           0 :             break;
     117             : 
     118             :         case Paint::ColorPaint:
     119             :         {
     120       39544 :             const Color aColor (rPaint.GetColor());
     121       39544 :             rDevice.SetLineColor(aColor);
     122       98860 :             for (sal_Int32 nXOffset=0; nXOffset<nWidth; ++nXOffset)
     123             :                 rDevice.DrawLine(
     124       59316 :                     Point(nX+nXOffset, nTop),
     125      118632 :                     Point(nX+nXOffset, nBottom));
     126       39544 :             break;
     127             :         }
     128             :         case Paint::GradientPaint:
     129             :             rDevice.DrawGradient(
     130             :                 Rectangle(
     131             :                     nX,
     132             :                     nTop,
     133           0 :                     nX+nWidth-1,
     134             :                     nBottom),
     135           0 :                 rPaint.GetGradient());
     136           0 :             break;
     137             :     }
     138       39544 : }
     139             : 
     140       15387 : void DrawHelper::DrawRoundedRectangle (
     141             :     OutputDevice& rDevice,
     142             :     const Rectangle& rBox,
     143             :     const sal_Int32 nCornerRadius,
     144             :     const Color& rBorderColor,
     145             :     const Paint& rFillPaint)
     146             : {
     147       15387 :     rDevice.SetLineColor(rBorderColor);
     148       15387 :     switch(rFillPaint.GetType())
     149             :     {
     150             :         case Paint::NoPaint:
     151             :         default:
     152       15387 :             rDevice.SetFillColor();
     153       15387 :             rDevice.DrawRect(rBox, nCornerRadius, nCornerRadius);
     154       15387 :             break;
     155             : 
     156             :         case Paint::ColorPaint:
     157           0 :             rDevice.SetFillColor(rFillPaint.GetColor());
     158           0 :             rDevice.DrawRect(rBox, nCornerRadius, nCornerRadius);
     159           0 :             break;
     160             : 
     161             :         case Paint::GradientPaint:
     162             :             rDevice.DrawGradient(
     163             :                 rBox,
     164           0 :                 rFillPaint.GetGradient());
     165           0 :             rDevice.SetFillColor();
     166           0 :             rDevice.DrawRect(rBox, nCornerRadius, nCornerRadius);
     167           0 :             break;
     168             :     }
     169       15387 : }
     170             : 
     171         951 : } } // end of namespace sfx2::sidebar
     172             : 
     173             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10