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

Source for file OLE_File.php

Documentation is available at OLE_File.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2002 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.02 of the PHP license,      |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Author: Xavier Noguer <xnoguer@php.net>                              |
  17. // | Based on OLE::Storage_Lite by Kawai, Takanori                        |
  18. // +----------------------------------------------------------------------+
  19. //
  20. // $Id: File.php,v 1.11 2007/02/13 21:00:42 schmidt Exp $
  21.  
  22.  
  23. /** PHPExcel root directory */
  24. if (!defined('PHPEXCEL_ROOT')) {
  25.     /**
  26.      * @ignore
  27.      */
  28.     define('PHPEXCEL_ROOT'dirname(__FILE__'/../../../');
  29. }
  30.  
  31. require_once PHPEXCEL_ROOT 'PHPExcel/Shared/OLE/OLE_PPS.php';
  32.  
  33. /**
  34. * Class for creating File PPS's for OLE containers
  35. *
  36. @author   Xavier Noguer <xnoguer@php.net>
  37. @category PHPExcel
  38. @package  PHPExcel_Shared_OLE
  39. */
  40.     {
  41.     /**
  42.     * The temporary dir for storing the OLE file
  43.     * @var string 
  44.     */
  45.     public $_tmp_dir;
  46.  
  47.     /**
  48.     * The constructor
  49.     *
  50.     * @access public
  51.     * @param string $name The name of the file (in Unicode)
  52.     * @see OLE::Asc2Ucs()
  53.     */
  54.     public function __construct($name)
  55.     {
  56.         $this->_tmp_dir = '';
  57.         parent::__construct(
  58.             null
  59.             $name,
  60.             PHPExcel_Shared_OLE::OLE_PPS_TYPE_FILE,
  61.             null,
  62.             null,
  63.             null,
  64.             null,
  65.             null,
  66.             '',
  67.             array());
  68.     }
  69.  
  70.     /**
  71.     * Sets the temp dir used for storing the OLE file
  72.     *
  73.     * @access public
  74.     * @param string $dir The dir to be used as temp dir
  75.     * @return true if given dir is valid, false otherwise
  76.     */
  77.     public function setTempDir($dir)
  78.     {
  79.         if (is_dir($dir)) {
  80.             $this->_tmp_dir = $dir;
  81.             return true;
  82.         }
  83.         return false;
  84.     }
  85.  
  86.     /**
  87.     * Initialization method. Has to be called right after OLE_PPS_File().
  88.     *
  89.     * @access public
  90.     * @return mixed true on success
  91.     */
  92.     public function init()
  93.     {
  94.         $this->_tmp_filename tempnam($this->_tmp_dir"OLE_PPS_File");
  95.         $fh fopen($this->_tmp_filename"w+b");
  96.         if ($fh === false{
  97.             throw new Exception("Can't create temporary file");
  98.         }
  99.         $this->_PPS_FILE $fh;
  100.         if ($this->_PPS_FILE{
  101.             fseek($this->_PPS_FILE0);
  102.         }
  103.         return true;
  104.     }
  105.  
  106.     /**
  107.     * Append data to PPS
  108.     *
  109.     * @access public
  110.     * @param string $data The data to append
  111.     */
  112.     public function append($data)
  113.     {
  114.         if ($this->_PPS_FILE{
  115.             fwrite($this->_PPS_FILE$data);
  116.         else {
  117.             $this->_data .= $data;
  118.         }
  119.     }
  120.  
  121.     /**
  122.      * Returns a stream for reading this file using fread() etc.
  123.      * @return  resource  a read-only stream
  124.      */
  125.     public function getStream()
  126.     {
  127.         $this->ole->getStream($this);
  128.     }
  129. }

Documentation generated on Mon, 10 Aug 2009 08:06:54 +0200 by phpDocumentor 1.4.1