File tree Expand file tree Collapse file tree 8 files changed +48
-2
lines changed Expand file tree Collapse file tree 8 files changed +48
-2
lines changed Original file line number Diff line number Diff line change @@ -18,8 +18,9 @@ This is the last version to support PHP 5.3
18
18
- Support for Comments - @troosan #1067
19
19
- Support for paragraph textAlignment - @troosan #1165
20
20
- Add support for HTML underline tag <u > in addHtml - @zNightFalLz #1186
21
- - Allow to change cell width unit - guillaume-ro-fr #986
21
+ - Allow to change cell width unit - @ guillaume-ro-fr #986
22
22
- Allow to change the line height rule @troosan
23
+ - Allow to force an update of all fields on opening a document - @troosan #951
23
24
24
25
### Fixed
25
26
- Loosen dependency to Zend
Original file line number Diff line number Diff line change @@ -297,7 +297,7 @@ Your TOC can only be generated if you have add at least one title (See "Titles")
297
297
298
298
Options for ``$tocStyle ``:
299
299
300
- - ``tabLeader ``. Fill type between the title text and the page number. Use the defined constants in PHPWord \\ Style\\ TOC.
300
+ - ``tabLeader ``. Fill type between the title text and the page number. Use the defined constants in `` \PhpOffice\PhpWord\ Style\TOC`` .
301
301
- ``tabPos ``. The position of the tab where the page number appears in twips.
302
302
- ``indent ``. The indent factor of the titles in twips.
303
303
Original file line number Diff line number Diff line change @@ -271,3 +271,12 @@ points to twips.
271
271
$sectionStyle->setMarginLeft(\PhpOffice\PhpWord\Shared\Converter::inchToTwip(.5));
272
272
// 2 cm right margin
273
273
$sectionStyle->setMarginRight(\PhpOffice\PhpWord\Shared\Converter::cmToTwip(2));
274
+
275
+ Automatically Recalculate Fields on Open
276
+ ----------------------------------------
277
+
278
+ To force an update of the fields present in the document, set updateFields to true
279
+
280
+ .. code-block :: php
281
+
282
+ $phpWord->getSettings()->setUpdateFields(true);
Original file line number Diff line number Diff line change 4
4
// New Word document
5
5
echo date ('H:i:s ' ), ' Create new PhpWord object ' , EOL ;
6
6
$ phpWord = new \PhpOffice \PhpWord \PhpWord ();
7
+ $ phpWord ->getSettings ()->setUpdateFields (true );
7
8
8
9
// New section
9
10
$ section = $ phpWord ->addSection ();
Original file line number Diff line number Diff line change @@ -116,6 +116,13 @@ class Settings
116
116
*/
117
117
private $ themeFontLang ;
118
118
119
+ /**
120
+ * Automatically Recalculate Fields on Open
121
+ *
122
+ * @var bool
123
+ */
124
+ private $ updateFields = false ;
125
+
119
126
/**
120
127
* Radix Point for Field Code Evaluation
121
128
*
@@ -345,6 +352,22 @@ public function setThemeFontLang($themeFontLang)
345
352
$ this ->themeFontLang = $ themeFontLang ;
346
353
}
347
354
355
+ /**
356
+ * @return bool
357
+ */
358
+ public function hasUpdateFields ()
359
+ {
360
+ return $ this ->updateFields ;
361
+ }
362
+
363
+ /**
364
+ * @param bool $updateFields
365
+ */
366
+ public function setUpdateFields ($ updateFields )
367
+ {
368
+ $ this ->updateFields = $ updateFields === null ? false : $ updateFields ;
369
+ }
370
+
348
371
/**
349
372
* Returns the Radix Point for Field Code Evaluation
350
373
*
Original file line number Diff line number Diff line change @@ -147,6 +147,7 @@ private function getSettings()
147
147
$ this ->setOnOffValue ('w:doNotTrackMoves ' , $ documentSettings ->hasDoNotTrackMoves ());
148
148
$ this ->setOnOffValue ('w:doNotTrackFormatting ' , $ documentSettings ->hasDoNotTrackFormatting ());
149
149
$ this ->setOnOffValue ('w:evenAndOddHeaders ' , $ documentSettings ->hasEvenAndOddHeaders ());
150
+ $ this ->setOnOffValue ('w:updateFields ' , $ documentSettings ->hasUpdateFields ());
150
151
151
152
$ this ->setThemeFontLang ($ documentSettings ->getThemeFontLang ());
152
153
$ this ->setRevisionView ($ documentSettings ->getRevisionView ());
Original file line number Diff line number Diff line change @@ -104,6 +104,7 @@ private function writeStyle()
104
104
105
105
// Bold, italic
106
106
$ xmlWriter ->writeElementIf ($ style ->isBold (), 'w:b ' );
107
+ $ xmlWriter ->writeElementIf ($ style ->isBold (), 'w:bCs ' );
107
108
$ xmlWriter ->writeElementIf ($ style ->isItalic (), 'w:i ' );
108
109
$ xmlWriter ->writeElementIf ($ style ->isItalic (), 'w:iCs ' );
109
110
Original file line number Diff line number Diff line change @@ -153,4 +153,14 @@ public function testZoomEnum()
153
153
$ oSettings ->setZoom (Zoom::FULL_PAGE );
154
154
$ this ->assertEquals ('fullPage ' , $ oSettings ->getZoom ());
155
155
}
156
+
157
+ /**
158
+ * Test Update Fields on update
159
+ */
160
+ public function testUpdateFields ()
161
+ {
162
+ $ oSettings = new Settings ();
163
+ $ oSettings ->setUpdateFields (true );
164
+ $ this ->assertTrue ($ oSettings ->hasUpdateFields ());
165
+ }
156
166
}
You can’t perform that action at this time.
0 commit comments