Merge remote-tracking branch
'github_troosan/fix_for_different_even_odd_headers' into develop Conflicts: tests/PhpWord/SettingsTest.php tests/PhpWord/Writer/Word2007/Part/SettingsTest.php
This commit is contained in:
commit
d8c5703e06
@ -145,7 +145,14 @@ class Settings
|
||||
* @var bool
|
||||
*/
|
||||
private static $outputEscapingEnabled = false;
|
||||
|
||||
|
||||
/**
|
||||
* Enables different header for odd and even pages.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private static $evenAndOddHeaders = false;
|
||||
|
||||
/**
|
||||
* Return the compatibility option used by the XMLWriter
|
||||
*
|
||||
@ -352,6 +359,22 @@ class Settings
|
||||
self::$outputEscapingEnabled = $outputEscapingEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isEvenAndOddHeaders()
|
||||
{
|
||||
return self::$evenAndOddHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $evenAndOddHeaders
|
||||
*/
|
||||
public static function setEvenAndOddHeaders($evenAndOddHeaders)
|
||||
{
|
||||
self::$evenAndOddHeaders = $evenAndOddHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default font name
|
||||
*
|
||||
|
||||
@ -105,6 +105,7 @@ class Settings extends AbstractPart
|
||||
'w:defaultTabStop' => array('@attributes' => array('w:val' => '708')),
|
||||
'w:hyphenationZone' => array('@attributes' => array('w:val' => '425')),
|
||||
'w:characterSpacingControl' => array('@attributes' => array('w:val' => 'doNotCompress')),
|
||||
'w:evenAndOddHeaders' => array('@attributes' => array('w:val' => DocumentSettings::isEvenAndOddHeaders() ? 'true': 'false')),
|
||||
'w:themeFontLang' => array('@attributes' => array('w:val' => 'en-US')),
|
||||
'w:hideSpellingErrors' => array('@attributes' => array('w:val' => DocumentSettings::isSpellingErrorsHidden() ? 'true' : 'false')),
|
||||
'w:hideGrammaticalErrors' => array('@attributes' => array('w:val' => DocumentSettings::isGrammaticalErrorsHidden() ? 'true' : 'false')),
|
||||
|
||||
@ -128,6 +128,16 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertTrue(Settings::isGrammaticalErrorsHidden());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test set/get even and odd headers
|
||||
*/
|
||||
public function testSetGetEvenAndOddHeaders()
|
||||
{
|
||||
$this->assertFalse(Settings::isEvenAndOddHeaders());
|
||||
Settings::setEvenAndOddHeaders(true);
|
||||
$this->assertTrue(Settings::isEvenAndOddHeaders());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test load config
|
||||
*/
|
||||
|
||||
@ -104,4 +104,23 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->assertEquals('true', $element->getAttribute('w:val'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test even and odd headers
|
||||
*/
|
||||
public function testEvenAndOddHeaders()
|
||||
{
|
||||
$phpWord = new PhpWord();
|
||||
Settings::setEvenAndOddHeaders(true);
|
||||
|
||||
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||
|
||||
$file = 'word/settings.xml';
|
||||
|
||||
$path = '/w:settings/w:evenAndOddHeaders';
|
||||
$this->assertTrue($doc->elementExists($path, $file));
|
||||
|
||||
$element = $doc->getElement($path, $file);
|
||||
$this->assertEquals('true', $element->getAttribute('w:val'));
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user