LCOV - code coverage report
Current view: top level - svx/source/dialog - paraprev.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 104 0.0 %
Date: 2015-06-13 12:38:46 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/builderfactory.hxx>
      23             : #include <vcl/settings.hxx>
      24             : 
      25           0 : SvxParaPrevWindow::SvxParaPrevWindow( vcl::Window* pParent,  WinBits nBits) :
      26             :     Window( pParent, nBits),
      27             :     nLeftMargin     ( 0 ),
      28             :     nRightMargin    ( 0 ),
      29             :     nFirstLineOfst  ( 0 ),
      30             :     nUpper          ( 0 ),
      31             :     nLower          ( 0 ),
      32             :     eAdjust         ( SVX_ADJUST_LEFT ),
      33             :     eLastLine       ( SVX_ADJUST_LEFT ),
      34             :     eLine           ( SVX_PREV_LINESPACE_1 ),
      35           0 :     nLineVal        ( 0 )
      36             : 
      37             : {
      38             :     // Count in Twips by default
      39           0 :     SetMapMode(MapMode(MAP_TWIP));
      40             : 
      41           0 :     aSize = Size(11905, 16837);
      42             : 
      43           0 :     SetBorderStyle(WindowBorderStyle::MONO);
      44           0 : }
      45             : 
      46           0 : VCL_BUILDER_FACTORY_ARGS(SvxParaPrevWindow, WB_BORDER)
      47             : 
      48           0 : Size SvxParaPrevWindow::GetOptimalSize() const
      49             : {
      50           0 :     return getParagraphPreviewOptimalSize(this);
      51             : }
      52             : 
      53           0 : void SvxParaPrevWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
      54             : {
      55           0 :     DrawParagraph(rRenderContext, true);
      56           0 : }
      57             : 
      58             : #define DEF_MARGIN  120
      59             : 
      60           0 : void SvxParaPrevWindow::DrawParagraph(vcl::RenderContext& rRenderContext, bool bAll)
      61             : {
      62           0 :     Size aWinSize = rRenderContext.GetOutputSizePixel();
      63           0 :     aWinSize = rRenderContext.PixelToLogic(aWinSize);
      64           0 :     Size aTmp(1, 1);
      65           0 :     aTmp = PixelToLogic(aTmp);
      66           0 :     aWinSize.Width() -= aTmp.Width() /2;
      67           0 :     aWinSize.Height() -= aTmp.Height() /2;
      68             : 
      69           0 :     const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
      70           0 :     const Color& rWinColor = rStyleSettings.GetWindowColor();
      71           0 :     Color aGrayColor(COL_LIGHTGRAY);
      72             : 
      73           0 :     rRenderContext.SetFillColor(Color(rWinColor));
      74           0 :     if (bAll)
      75           0 :         rRenderContext.DrawRect(Rectangle(Point(), aWinSize));
      76             : 
      77           0 :     rRenderContext.SetLineColor();
      78             : 
      79           0 :     long nH = aWinSize.Height() / 19;
      80           0 :     Size aLineSiz(aWinSize.Width() - DEF_MARGIN, nH);
      81           0 :     Size aSiz = aLineSiz;
      82           0 :     Point aPnt;
      83           0 :     aPnt.X() = DEF_MARGIN / 2;
      84           0 :     rRenderContext.SetFillColor(aGrayColor);
      85             : 
      86           0 :     for (sal_uInt16 i = 0; i < 9; ++i)
      87             :     {
      88           0 :         if (i == 3)
      89             :         {
      90           0 :             rRenderContext.SetFillColor(Color(COL_GRAY));
      91           0 :             long nTop = nUpper * aLineSiz.Height() / aSize.Height();
      92           0 :             aPnt.Y() += nTop * 2;
      93             :         }
      94             : 
      95           0 :         if (i == 6 )
      96           0 :             rRenderContext.SetFillColor(aGrayColor);
      97             : 
      98           0 :         if (3 <= i && 6 > i)
      99             :         {
     100           0 :             long nLeft = nLeftMargin * aLineSiz.Width() / aSize.Width();
     101           0 :             long nFirst = nFirstLineOfst * aLineSiz.Width() / aSize.Width();
     102           0 :             long nTmp = nLeft + nFirst;
     103             : 
     104           0 :             if (i == 3)
     105             :             {
     106           0 :                 aPnt.X() += nTmp;
     107           0 :                 aSiz.Width() -= nTmp;
     108             :             }
     109             :             else
     110             :             {
     111           0 :                 aPnt.X() += nLeft;
     112           0 :                 aSiz.Width() -= nLeft;
     113             :             }
     114           0 :             long nRight = nRightMargin * aLineSiz.Width() / aSize.Width();
     115           0 :             aSiz.Width() -= nRight;
     116             :         }
     117             : 
     118           0 :         if (4 == i || 5 == i || 6 == i)
     119             :         {
     120           0 :             switch (eLine)
     121             :             {
     122             :                 case SVX_PREV_LINESPACE_1:
     123           0 :                     break;
     124             :                 case SVX_PREV_LINESPACE_15:
     125           0 :                     aPnt.Y() += nH / 2;
     126           0 :                     break;
     127             :                 case SVX_PREV_LINESPACE_2:
     128           0 :                     aPnt.Y() += nH;
     129           0 :                     break;
     130             :                 case SVX_PREV_LINESPACE_PROP:
     131             :                 case SVX_PREV_LINESPACE_MIN:
     132             :                 case SVX_PREV_LINESPACE_DURCH:
     133           0 :                     break;
     134             :             }
     135             :         }
     136             : 
     137           0 :         aPnt.Y() += nH;
     138             : 
     139           0 :         if (3 <= i && 5 >= i)
     140             :         {
     141           0 :             long nLW = long();
     142           0 :             switch (i)
     143             :             {
     144             :                 case 3:
     145           0 :                     nLW = aLineSiz.Width() * 8 / 10;
     146           0 :                     break;
     147             :                 case 4:
     148           0 :                     nLW = aLineSiz.Width() * 9 / 10;
     149           0 :                     break;
     150             :                 case 5:
     151           0 :                     nLW = aLineSiz.Width() / 2;
     152           0 :                     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 = rRenderContext.GetFillColor();
     203           0 :                 rRenderContext.SetFillColor(rWinColor);
     204           0 :                 rRenderContext.DrawRect(Lines[i]);
     205           0 :                 rRenderContext.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.11