add indentation support to paragraphs
This commit is contained in:
parent
ad47f3997c
commit
30a7a178e2
|
|
@ -64,6 +64,14 @@ class PHPWord_Style_Paragraph {
|
|||
private $_spacing;
|
||||
|
||||
|
||||
/**
|
||||
* Indent by how much
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_indent;
|
||||
|
||||
|
||||
/**
|
||||
* New Paragraph Style
|
||||
*/
|
||||
|
|
@ -72,6 +80,7 @@ class PHPWord_Style_Paragraph {
|
|||
$this->_spaceBefore = null;
|
||||
$this->_spaceAfter = null;
|
||||
$this->_spacing = null;
|
||||
$this->_indent = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -84,6 +93,9 @@ class PHPWord_Style_Paragraph {
|
|||
if($key == '_spacing') {
|
||||
$value += 240; // because line height of 1 matches 240 twips
|
||||
}
|
||||
if($key == '_indent') {
|
||||
$value = (int)$value * 720; // 720 twips per indent
|
||||
}
|
||||
$this->$key = $value;
|
||||
}
|
||||
|
||||
|
|
@ -170,5 +182,25 @@ class PHPWord_Style_Paragraph {
|
|||
$this->_spacing = $pValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get indentation
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getIndent() {
|
||||
return $this->_indent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set indentation
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return PHPWord_Style_Paragraph
|
||||
*/
|
||||
public function setIndent($pValue = null) {
|
||||
$this->_indent = $pValue;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -113,9 +113,10 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
$spaceBefore = $style->getSpaceBefore();
|
||||
$spaceAfter = $style->getSpaceAfter();
|
||||
$spacing = $style->getSpacing();
|
||||
$indent = $style->getIndent();
|
||||
|
||||
|
||||
if(!is_null($align) || !is_null($spacing) || !is_null($spaceBefore) || !is_null($spaceAfter)) {
|
||||
if(!is_null($align) || !is_null($spacing) || !is_null($spaceBefore) || !is_null($spaceAfter) || !is_null($indent)) {
|
||||
|
||||
if(!$withoutPPR) {
|
||||
$objWriter->startElement('w:pPr');
|
||||
|
|
@ -127,6 +128,13 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart {
|
|||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
if(!is_null($indent)) {
|
||||
$objWriter->startElement('w:ind');
|
||||
$objWriter->writeAttribute('w:firstLine', 0);
|
||||
$objWriter->writeAttribute('w:left', $indent);
|
||||
$objWriter->endElement();
|
||||
}
|
||||
|
||||
if(!is_null($spaceBefore) || !is_null($spaceAfter) || !is_null($spacing)) {
|
||||
|
||||
$objWriter->startElement('w:spacing');
|
||||
|
|
|
|||
Loading…
Reference in New Issue