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

Generated by: LCOV version 1.10