Skip to content

Commit

Permalink
Merge pull request #134 from PHPOffice/develop
Browse files Browse the repository at this point in the history
Version 0.8.0
  • Loading branch information
Progi1984 committed Mar 15, 2014
2 parents 5a6cb08 + 542451d commit 6837b11
Show file tree
Hide file tree
Showing 174 changed files with 9,540 additions and 1,329 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ phpunit.xml
composer.lock
composer.phar
vendor
/report
/.settings
/.buildpath
/.project
Expand Down
68 changes: 51 additions & 17 deletions Classes/PHPWord.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,42 @@
*/

/** PHPWORD_BASE_PATH */
// @codeCoverageIgnoreStart
if (!defined('PHPWORD_BASE_PATH')) {
define('PHPWORD_BASE_PATH', dirname(__FILE__) . '/');
require PHPWORD_BASE_PATH . 'PHPWord/Autoloader.php';
PHPWord_Autoloader::Register();
}

// @codeCoverageIgnoreEnd

/**
* PHPWord
*/
class PHPWord
{

/**
* Default font name (Arial)
*/
const DEFAULT_FONT_NAME = 'Arial';
/**
* Default Font Content Type(default)
* default|eastAsia|cs
*/
const DEFAULT_FONT_CONTENT_TYPE='default';
/**
* Default font size in points (10pt)
*
* OOXML defined font size values in halfpoints, i.e. twice of what PHPWord
* use, and the conversion will be conducted during XML writing.
*/
const DEFAULT_FONT_SIZE = 10;

/**
* Default font color (black)
*/
const DEFAULT_FONT_COLOR = '000000';

/**
* Document properties
*
Expand Down Expand Up @@ -74,8 +97,8 @@ class PHPWord
public function __construct()
{
$this->_properties = new PHPWord_DocumentProperties();
$this->_defaultFontName = 'Arial';
$this->_defaultFontSize = 20;
$this->_defaultFontName = PHPWord::DEFAULT_FONT_NAME;
$this->_defaultFontSize = PHPWord::DEFAULT_FONT_SIZE;
}

/**
Expand Down Expand Up @@ -133,7 +156,7 @@ public function setDefaultFontName($pValue)
}

/**
* Get default Font size
* Get default Font size (in points)
* @return string
*/
public function getDefaultFontSize()
Expand All @@ -142,15 +165,24 @@ public function getDefaultFontSize()
}

/**
* Set default Font size
* Set default Font size (in points)
* @param int $pValue
*/
public function setDefaultFontSize($pValue)
{
$pValue = $pValue * 2;
$this->_defaultFontSize = $pValue;
}

/**
* Set default paragraph style definition to styles.xml
*
* @param array $styles Paragraph style definition
*/
public function setDefaultParagraphStyle($styles)
{
PHPWord_Style::setDefaultParagraphStyle($styles);
}

/**
* Adds a paragraph style definition to styles.xml
*
Expand Down Expand Up @@ -215,15 +247,6 @@ public function getSections()
return $this->_sectionCollection;
}

/**
* Get section count
* @return int
*/
private function _countSections()
{
return count($this->_sectionCollection);
}

/**
* Load a Template File
*
Expand All @@ -236,7 +259,18 @@ public function loadTemplate($strFilename)
$template = new PHPWord_Template($strFilename);
return $template;
} else {
trigger_error('Template file ' . $strFilename . ' not found.', E_USER_ERROR);
throw new PHPWord_Exception(
"Template file {$strFilename} not found."
);
}
}
}

/**
* Get section count
* @return int
*/
private function _countSections()
{
return count($this->_sectionCollection);
}
}
4 changes: 2 additions & 2 deletions Classes/PHPWord/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
*/
class PHPWord_Autoloader
{
const PREFIX = 'PHPWord';
const PREFIX = 'PhpOffice\PhpWord';

/**
* Register the autoloader
Expand Down Expand Up @@ -82,4 +82,4 @@ public static function autoload($class)
}
}
}
}
}
Loading

0 comments on commit 6837b11

Please sign in to comment.