File tree Expand file tree Collapse file tree 4 files changed +54
-1
lines changed Expand file tree Collapse file tree 4 files changed +54
-1
lines changed Original file line number Diff line number Diff line change @@ -145,7 +145,14 @@ class Settings
145
145
* @var bool
146
146
*/
147
147
private static $ outputEscapingEnabled = false ;
148
-
148
+
149
+ /**
150
+ * Enables different header for odd and even pages.
151
+ *
152
+ * @var bool
153
+ */
154
+ private static $ evenAndOddHeaders = false ;
155
+
149
156
/**
150
157
* Return the compatibility option used by the XMLWriter
151
158
*
@@ -352,6 +359,22 @@ public static function setOutputEscapingEnabled($outputEscapingEnabled)
352
359
self ::$ outputEscapingEnabled = $ outputEscapingEnabled ;
353
360
}
354
361
362
+ /**
363
+ * @return boolean
364
+ */
365
+ public static function isEvenAndOddHeaders ()
366
+ {
367
+ return self ::$ evenAndOddHeaders ;
368
+ }
369
+
370
+ /**
371
+ * @param boolean $evenAndOddHeaders
372
+ */
373
+ public static function setEvenAndOddHeaders ($ evenAndOddHeaders )
374
+ {
375
+ self ::$ evenAndOddHeaders = $ evenAndOddHeaders ;
376
+ }
377
+
355
378
/**
356
379
* Get default font name
357
380
*
Original file line number Diff line number Diff line change @@ -105,6 +105,7 @@ private function getSettings()
105
105
'w:defaultTabStop ' => array ('@attributes ' => array ('w:val ' => '708 ' )),
106
106
'w:hyphenationZone ' => array ('@attributes ' => array ('w:val ' => '425 ' )),
107
107
'w:characterSpacingControl ' => array ('@attributes ' => array ('w:val ' => 'doNotCompress ' )),
108
+ 'w:evenAndOddHeaders ' => array ('@attributes ' => array ('w:val ' => DocumentSettings::isEvenAndOddHeaders () ? 'true ' : 'false ' )),
108
109
'w:themeFontLang ' => array ('@attributes ' => array ('w:val ' => 'en-US ' )),
109
110
'w:hideSpellingErrors ' => array ('@attributes ' => array ('w:val ' => DocumentSettings::isSpellingErrorsHidden () ? 'true ' : 'false ' )),
110
111
'w:hideGrammaticalErrors ' => array ('@attributes ' => array ('w:val ' => DocumentSettings::isGrammaticalErrorsHidden () ? 'true ' : 'false ' )),
Original file line number Diff line number Diff line change @@ -128,6 +128,16 @@ public function testSetGetSpellingGrammar()
128
128
$ this ->assertTrue (Settings::isGrammaticalErrorsHidden ());
129
129
}
130
130
131
+ /**
132
+ * Test set/get even and odd headers
133
+ */
134
+ public function testSetGetEvenAndOddHeaders ()
135
+ {
136
+ $ this ->assertFalse (Settings::isEvenAndOddHeaders ());
137
+ Settings::setEvenAndOddHeaders (true );
138
+ $ this ->assertTrue (Settings::isEvenAndOddHeaders ());
139
+ }
140
+
131
141
/**
132
142
* Test load config
133
143
*/
Original file line number Diff line number Diff line change @@ -104,4 +104,23 @@ public function testSpelling()
104
104
105
105
$ this ->assertEquals ('true ' , $ element ->getAttribute ('w:val ' ));
106
106
}
107
+
108
+ /**
109
+ * Test even and odd headers
110
+ */
111
+ public function testEvenAndOddHeaders ()
112
+ {
113
+ $ phpWord = new PhpWord ();
114
+ Settings::setEvenAndOddHeaders (true );
115
+
116
+ $ doc = TestHelperDOCX::getDocument ($ phpWord );
117
+
118
+ $ file = 'word/settings.xml ' ;
119
+
120
+ $ path = '/w:settings/w:evenAndOddHeaders ' ;
121
+ $ this ->assertTrue ($ doc ->elementExists ($ path , $ file ));
122
+
123
+ $ element = $ doc ->getElement ($ path , $ file );
124
+ $ this ->assertEquals ('true ' , $ element ->getAttribute ('w:val ' ));
125
+ }
107
126
}
You can’t perform that action at this time.
0 commit comments