PHPExcel_Shared
[ class tree: PHPExcel_Shared ] [ index: PHPExcel_Shared ] [ all elements ]

Source for file Drawing.php

Documentation is available at Drawing.php

  1. <?php
  2. /**
  3.  * PHPExcel
  4.  *
  5.  * Copyright (c) 2006 - 2009 PHPExcel
  6.  *
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU Lesser General Public
  9.  * License as published by the Free Software Foundation; either
  10.  * version 2.1 of the License, or (at your option) any later version.
  11.  * 
  12.  * This library is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  * Lesser General Public License for more details.
  16.  * 
  17.  * You should have received a copy of the GNU Lesser General Public
  18.  * License along with this library; if not, write to the Free Software
  19.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  20.  *
  21.  * @category   PHPExcel
  22.  * @package    PHPExcel_Shared
  23.  * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
  24.  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  25.  * @version    1.7.0, 2009-08-10
  26.  */
  27.  
  28.  
  29. /**
  30.  * PHPExcel_Shared_Drawing
  31.  *
  32.  * @category   PHPExcel
  33.  * @package    PHPExcel_Shared
  34.  * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
  35.  */
  36. {
  37.     /**
  38.      * Convert pixels to EMU
  39.      *
  40.      * @param     int $pValue    Value in pixels
  41.      * @return     int            Value in EMU
  42.      */
  43.     public static function pixelsToEMU($pValue 0{
  44.         return round($pValue 9525);
  45.     }
  46.     
  47.     /**
  48.      * Convert EMU to pixels
  49.      *
  50.      * @param     int $pValue    Value in EMU
  51.      * @return     int            Value in pixels
  52.      */
  53.     public static function EMUToPixels($pValue 0{
  54.         if ($pValue != 0{
  55.             return round($pValue 9525);
  56.         else {
  57.             return 0;
  58.         }
  59.     }
  60.     
  61.     /**
  62.      * Convert pixels to cell dimension. Exact algorithm not known.
  63.      * By inspection of a real Excel file using Calibri 11, one finds 1000px ~ 142.85546875
  64.      * This gives a conversion factor of 7. Also, we assume that pixels and font size are proportional.
  65.      *
  66.      * @param     int $pValue    Value in pixels
  67.      * @param     int $pFontSize    Default font size of workbook
  68.      * @return     int            Value in cell dimension
  69.      */
  70.     public static function pixelsToCellDimension($pValue 0$pFontSize 11{
  71.         return $pValue $pFontSize 11 7;
  72.     }
  73.     
  74.     /**
  75.      * Convert cell width to pixels
  76.      *
  77.      * @param     int $pValue    Value in cell dimension
  78.      * @param     int $pFontSize    Default font size of workbook
  79.      * @return     int            Value in pixels
  80.      */
  81.     public static function cellDimensionToPixels($pValue 0$pFontSize 11{
  82.         if ($pValue != 0{
  83.             return $pValue $pFontSize 11;
  84.         else {
  85.             return 0;
  86.         }
  87.     }
  88.     
  89.     /**
  90.      * Convert pixels to points
  91.      *
  92.      * @param     int $pValue    Value in pixels
  93.      * @return     int            Value in points
  94.      */
  95.     public static function pixelsToPoints($pValue 0{
  96.         return $pValue 0.67777777;
  97.     }
  98.     
  99.     /**
  100.      * Convert points to pixels
  101.      *
  102.      * @param     int $pValue    Value in points
  103.      * @return     int            Value in pixels
  104.      */
  105.     public static function pointsToPixels($pValue 0{
  106.         if ($pValue != 0{
  107.             return (int) ceil($pValue 1.333333333);
  108.         else {
  109.             return 0;
  110.         }
  111.     }
  112.  
  113.     /**
  114.      * Convert degrees to angle
  115.      *
  116.      * @param     int $pValue    Degrees
  117.      * @return     int            Angle
  118.      */
  119.     public static function degreesToAngle($pValue 0{
  120.         return (int)round($pValue 60000);
  121.     }
  122.     
  123.     /**
  124.      * Convert angle to degrees
  125.      *
  126.      * @param     int $pValue    Angle
  127.      * @return     int            Degrees
  128.      */
  129.     public static function angleToDegrees($pValue 0{
  130.         if ($pValue != 0{
  131.             return round($pValue 60000);
  132.         else {
  133.             return 0;
  134.         }
  135.     }
  136. }

Documentation generated on Mon, 10 Aug 2009 08:03:19 +0200 by phpDocumentor 1.4.1