Fixed bug with footer preserve text
This commit is contained in:
parent
0b876a3f0b
commit
72fca30e8c
|
|
@ -285,6 +285,9 @@ class PHPWord_Writer_Word2007_Base extends PHPWord_Writer_Word2007_WriterPart
|
||||||
$SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false;
|
$SpIsObject = ($styleParagraph instanceof PHPWord_Style_Paragraph) ? true : false;
|
||||||
|
|
||||||
$arrText = $textrun->getText();
|
$arrText = $textrun->getText();
|
||||||
|
if (!is_array($arrText)) {
|
||||||
|
$arrText = array($arrText);
|
||||||
|
}
|
||||||
|
|
||||||
$objWriter->startElement('w:p');
|
$objWriter->startElement('w:p');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -108,4 +108,19 @@ class BaseTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertEquals($expected, $element->getAttribute('w:val'));
|
$this->assertEquals($expected, $element->getAttribute('w:val'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testWritePreserveText()
|
||||||
|
{
|
||||||
|
$PHPWord = new PHPWord();
|
||||||
|
$section = $PHPWord->createSection();
|
||||||
|
$footer = $section->createFooter();
|
||||||
|
|
||||||
|
$footer->addPreserveText('{PAGE}');
|
||||||
|
|
||||||
|
$doc = TestHelperDOCX::getDocument($PHPWord);
|
||||||
|
$preserve = $doc->getElement("w:p/w:r[2]/w:instrText", 'word/footer1.xml');
|
||||||
|
|
||||||
|
$this->assertEquals('PAGE', $preserve->nodeValue);
|
||||||
|
$this->assertEquals('preserve', $preserve->getAttribute('xml:space'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -15,8 +15,8 @@ class TestHelperDOCX
|
||||||
public static function getDocument(PHPWord $PHPWord)
|
public static function getDocument(PHPWord $PHPWord)
|
||||||
{
|
{
|
||||||
self::$file = tempnam(sys_get_temp_dir(), 'PHPWord');
|
self::$file = tempnam(sys_get_temp_dir(), 'PHPWord');
|
||||||
if(!is_dir(sys_get_temp_dir().'/PHPWord_Unit_Test/')){
|
if (!is_dir(sys_get_temp_dir() . '/PHPWord_Unit_Test/')) {
|
||||||
mkdir(sys_get_temp_dir().'/PHPWord_Unit_Test/');
|
mkdir(sys_get_temp_dir() . '/PHPWord_Unit_Test/');
|
||||||
}
|
}
|
||||||
|
|
||||||
$objWriter = \PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
$objWriter = \PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
|
||||||
|
|
@ -29,16 +29,16 @@ class TestHelperDOCX
|
||||||
$zip->close();
|
$zip->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Xml_Document(sys_get_temp_dir().'/PHPWord_Unit_Test/');
|
return new Xml_Document(sys_get_temp_dir() . '/PHPWord_Unit_Test/');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function clear()
|
public static function clear()
|
||||||
{
|
{
|
||||||
if(file_exists(self::$file)){
|
if (file_exists(self::$file)) {
|
||||||
unlink(self::$file);
|
unlink(self::$file);
|
||||||
}
|
}
|
||||||
if(is_dir(sys_get_temp_dir().'/PHPWord_Unit_Test/')){
|
if (is_dir(sys_get_temp_dir() . '/PHPWord_Unit_Test/')) {
|
||||||
self::deleteDir(sys_get_temp_dir().'/PHPWord_Unit_Test/');
|
self::deleteDir(sys_get_temp_dir() . '/PHPWord_Unit_Test/');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
"ext-xml": "*"
|
"ext-xml": "*"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "3.7.28"
|
"phpunit/phpunit": "3.7.*"
|
||||||
},
|
},
|
||||||
"recommend": {
|
"recommend": {
|
||||||
"ext-zip": "*",
|
"ext-zip": "*",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue