LCOV - code coverage report
Current view: top level - libreoffice/svx/source/dialog - paraprev.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 95 0.0 %
Date: 2012-12-27 Functions: 0 3 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             : #include <svx/paraprev.hxx>
      21             : 
      22             : // class SvxParaPrevWindow -----------------------------------------------
      23             : 
      24           0 : SvxParaPrevWindow::SvxParaPrevWindow( Window* pParent, const ResId& rId ) :
      25             : 
      26             :     Window( pParent, rId ),
      27             : 
      28             :     nLeftMargin     ( 0 ),
      29             :     nRightMargin    ( 0 ),
      30             :     nFirstLineOfst  ( 0 ),
      31             :     nUpper          ( 0 ),
      32             :     nLower          ( 0 ),
      33             :     eAdjust         ( SVX_ADJUST_LEFT ),
      34             :     eLastLine       ( SVX_ADJUST_LEFT ),
      35             :     eLine           ( SVX_PREV_LINESPACE_1 ),
      36           0 :     nLineVal        ( 0 )
      37             : 
      38             : {
      39             :     // Count in Twips by default
      40           0 :     SetMapMode( MapMode( MAP_TWIP ) );
      41           0 :     aWinSize = GetOutputSizePixel();
      42           0 :     aWinSize = PixelToLogic( aWinSize );
      43           0 :     Size aTmp(1, 1);
      44           0 :     aTmp = PixelToLogic(aTmp);
      45           0 :     aWinSize.Width() -= aTmp.Width() /2;
      46           0 :     aWinSize.Height() -= aTmp.Height() /2;
      47             : 
      48           0 :     aSize = Size( 11905, 16837 );
      49             : 
      50           0 :     SetBorderStyle( WINDOW_BORDER_MONO );
      51           0 : }
      52             : 
      53             : // -----------------------------------------------------------------------
      54             : 
      55           0 : void SvxParaPrevWindow::Paint( const Rectangle& )
      56             : {
      57           0 :     DrawParagraph( sal_True );
      58           0 : }
      59             : 
      60             : // -----------------------------------------------------------------------
      61             : 
      62             : #define DEF_MARGIN  120
      63             : 
      64           0 : void SvxParaPrevWindow::DrawParagraph( sal_Bool bAll )
      65             : {
      66           0 :     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
      67           0 :     const Color& rWinColor = rStyleSettings.GetWindowColor();
      68           0 :     Color aGrayColor(COL_LIGHTGRAY);
      69             : 
      70           0 :     SetFillColor( Color( rWinColor ) );
      71           0 :     if( bAll )
      72           0 :         DrawRect( Rectangle( Point(), aWinSize ) );
      73             : 
      74           0 :     SetLineColor();
      75             : 
      76           0 :     long nH = aWinSize.Height() / 19;
      77           0 :     Size aLineSiz( aWinSize.Width() - DEF_MARGIN, nH ),
      78           0 :          aSiz = aLineSiz;
      79           0 :     Point aPnt;
      80           0 :     aPnt.X() = DEF_MARGIN / 2;
      81           0 :     SetFillColor( aGrayColor );
      82             : 
      83           0 :     for ( sal_uInt16 i = 0; i < 9; ++i )
      84             :     {
      85           0 :         if ( 3 == i )
      86             :         {
      87           0 :             SetFillColor( Color( COL_GRAY ) );
      88           0 :             long nTop = nUpper * aLineSiz.Height() / aSize.Height();
      89           0 :             aPnt.Y() += nTop * 2;
      90             :         }
      91             : 
      92           0 :         if ( 6 == i )
      93           0 :             SetFillColor( aGrayColor );
      94             : 
      95           0 :         if ( 3 <= i && 6 > i )
      96             :         {
      97           0 :             long nLeft = nLeftMargin * aLineSiz.Width() / aSize.Width();
      98           0 :             long nFirst = nFirstLineOfst * aLineSiz.Width() / aSize.Width();
      99           0 :             long nTmp = nLeft + nFirst;
     100             : 
     101           0 :             if ( 3 == i )
     102             :             {
     103           0 :                 aPnt.X() += nTmp;
     104           0 :                 aSiz.Width() -= nTmp;
     105             :             }
     106             :             else
     107             :             {
     108           0 :                 aPnt.X() += nLeft;
     109           0 :                 aSiz.Width() -= nLeft;
     110             :             }
     111           0 :             long nRight = nRightMargin * aLineSiz.Width() / aSize.Width();
     112           0 :             aSiz.Width() -= nRight;
     113             :         }
     114             : 
     115           0 :         if ( 4 == i || 5 == i || 6 == i )
     116             :         {
     117           0 :             switch ( eLine )
     118             :             {
     119           0 :                 case SVX_PREV_LINESPACE_1:                      break;
     120           0 :                 case SVX_PREV_LINESPACE_15: aPnt.Y() += nH / 2; break;
     121           0 :                 case SVX_PREV_LINESPACE_2:  aPnt.Y() += nH;     break;
     122             : 
     123             :                 case SVX_PREV_LINESPACE_PROP:
     124             :                 case SVX_PREV_LINESPACE_MIN:
     125           0 :                 case SVX_PREV_LINESPACE_DURCH:                  break;
     126             :             }
     127             :         }
     128             : 
     129           0 :         aPnt.Y() += nH;
     130             : 
     131           0 :         if ( (3 <= i) && (5 >= i) )
     132             :         {
     133             :             long nLW;
     134           0 :             switch( i )
     135             :             {
     136             :                 default:
     137           0 :                 case 3: nLW = aLineSiz.Width() * 8 / 10;    break;
     138           0 :                 case 4: nLW = aLineSiz.Width() * 9 / 10;    break;
     139           0 :                 case 5: nLW = aLineSiz.Width() / 2;         break;
     140             :             }
     141             : 
     142           0 :             if ( nLW > aSiz.Width() )
     143           0 :                 nLW = aSiz.Width();
     144             : 
     145           0 :             switch ( eAdjust )
     146             :             {
     147             :                 case SVX_ADJUST_LEFT:
     148           0 :                     break;
     149             :                 case SVX_ADJUST_RIGHT:
     150           0 :                     aPnt.X() += ( aSiz.Width() - nLW );
     151           0 :                     break;
     152             :                 case SVX_ADJUST_CENTER:
     153           0 :                     aPnt.X() += ( aSiz.Width() - nLW ) / 2;
     154           0 :                     break;
     155             :                 default: ; //prevent warning
     156             :             }
     157           0 :             if( SVX_ADJUST_BLOCK == eAdjust )
     158             :             {
     159           0 :                 if( 5 == i )
     160             :                 {
     161           0 :                     switch( eLastLine )
     162             :                     {
     163             :                         case SVX_ADJUST_LEFT:
     164           0 :                             break;
     165             :                         case SVX_ADJUST_RIGHT:
     166           0 :                             aPnt.X() += ( aSiz.Width() - nLW );
     167           0 :                             break;
     168             :                         case SVX_ADJUST_CENTER:
     169           0 :                             aPnt.X() += ( aSiz.Width() - nLW ) / 2;
     170           0 :                             break;
     171             :                         case SVX_ADJUST_BLOCK:
     172           0 :                             nLW = aSiz.Width();
     173           0 :                             break;
     174             :                         default: ; //prevent warning
     175             :                     }
     176             :                 }
     177             :                 else
     178           0 :                     nLW = aSiz.Width();
     179             :             }
     180           0 :             aSiz.Width() = nLW;
     181             :         }
     182             : 
     183           0 :         Rectangle aRect( aPnt, aSiz );
     184             : 
     185           0 :         if ( Lines[i] != aRect || bAll )
     186             :         {
     187           0 :             if ( !bAll )
     188             :             {
     189           0 :                 Color aFillCol = GetFillColor();
     190           0 :                 SetFillColor( rWinColor );
     191           0 :                 DrawRect( Lines[i] );
     192           0 :                 SetFillColor( aFillCol );
     193             :             }
     194           0 :             DrawRect( aRect );
     195           0 :             Lines[i] = aRect;
     196             :         }
     197             : 
     198           0 :         if ( 5 == i )
     199             :         {
     200           0 :             long nBottom = nLower * aLineSiz.Height() / aSize.Height();
     201           0 :             aPnt.Y() += nBottom * 2;
     202             :         }
     203             : 
     204           0 :         aPnt.Y() += nH;
     205             :         // Reset, recalculate for each line
     206           0 :         aPnt.X() = DEF_MARGIN / 2;
     207           0 :         aSiz = aLineSiz;
     208             :     }
     209           0 : }
     210             : 
     211             : #undef DEF_MARGIN
     212             : 
     213             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10