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

Generated by: LCOV version 1.10