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

Generated by: LCOV version 1.10