Skip to content

Commit 911739a

Browse files
authored
Merge branch 'develop' into odt_page_break
2 parents 01008a5 + 6faddc6 commit 911739a

File tree

10 files changed

+88
-2
lines changed

10 files changed

+88
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ This is the last version to support PHP 5.3
1818
- Support for Comments - @troosan #1067
1919
- Support for paragraph textAlignment - @troosan #1165
2020
- 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
2222
- Allow to change the line height rule @troosan
2323
- Implement PageBreak for odt writer @cookiekiller #863 #824
24+
- Allow to force an update of all fields on opening a document - @troosan #951
2425

2526
### Fixed
2627
- Loosen dependency to Zend

docs/ISSUE_TEMPLATE.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Issue tracker is **ONLY** used for reporting bugs. NO NEW FEATURE ACCEPTED! Use [stackoverflow](https://stackoverflow.com/questions/tagged/phpword) for supporting issues.
2+
3+
# Expected Behavior
4+
5+
Please describe the behavior you are expecting.
6+
7+
# Current Behavior
8+
9+
What is the current behavior?
10+
11+
# Failure Information
12+
13+
Please help provide information about the failure.
14+
15+
## How to Reproduce
16+
17+
Please provide a code sample that reproduces the issue.
18+
19+
```php
20+
$phpWord = new \PhpOffice\PhpWord\PhpWord();
21+
$section = $phpWord->addSection();
22+
$section->...
23+
```
24+
25+
## Context
26+
27+
* PHP version:
28+
* PHPWord version: 0.14

docs/PULL_REQUEST_TEMPLATE.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Description
2+
3+
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.
4+
5+
Fixes # (issue)
6+
7+
# Checklist:
8+
9+
- [ ] I have commented my code, particularly in hard-to-understand areas
10+
- [ ] I have run phpunit, phpcs, php-cs-fixer, phpmd
11+
- [ ] The new code is covered by unit tests
12+
- [ ] I have update the documentation to describe the changes

docs/elements.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ Your TOC can only be generated if you have add at least one title (See "Titles")
297297

298298
Options for ``$tocStyle``:
299299

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``.
301301
- ``tabPos``. The position of the tab where the page number appears in twips.
302302
- ``indent``. The indent factor of the titles in twips.
303303

docs/general.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,3 +271,12 @@ points to twips.
271271
$sectionStyle->setMarginLeft(\PhpOffice\PhpWord\Shared\Converter::inchToTwip(.5));
272272
// 2 cm right margin
273273
$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);

samples/Sample_17_TitleTOC.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// New Word document
55
echo date('H:i:s'), ' Create new PhpWord object', EOL;
66
$phpWord = new \PhpOffice\PhpWord\PhpWord();
7+
$phpWord->getSettings()->setUpdateFields(true);
78

89
// New section
910
$section = $phpWord->addSection();

src/PhpWord/Metadata/Settings.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ class Settings
116116
*/
117117
private $themeFontLang;
118118

119+
/**
120+
* Automatically Recalculate Fields on Open
121+
*
122+
* @var bool
123+
*/
124+
private $updateFields = false;
125+
119126
/**
120127
* Radix Point for Field Code Evaluation
121128
*
@@ -345,6 +352,22 @@ public function setThemeFontLang($themeFontLang)
345352
$this->themeFontLang = $themeFontLang;
346353
}
347354

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+
348371
/**
349372
* Returns the Radix Point for Field Code Evaluation
350373
*

src/PhpWord/Writer/Word2007/Part/Settings.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ private function getSettings()
147147
$this->setOnOffValue('w:doNotTrackMoves', $documentSettings->hasDoNotTrackMoves());
148148
$this->setOnOffValue('w:doNotTrackFormatting', $documentSettings->hasDoNotTrackFormatting());
149149
$this->setOnOffValue('w:evenAndOddHeaders', $documentSettings->hasEvenAndOddHeaders());
150+
$this->setOnOffValue('w:updateFields', $documentSettings->hasUpdateFields());
150151

151152
$this->setThemeFontLang($documentSettings->getThemeFontLang());
152153
$this->setRevisionView($documentSettings->getRevisionView());

src/PhpWord/Writer/Word2007/Style/Font.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ private function writeStyle()
104104

105105
// Bold, italic
106106
$xmlWriter->writeElementIf($style->isBold(), 'w:b');
107+
$xmlWriter->writeElementIf($style->isBold(), 'w:bCs');
107108
$xmlWriter->writeElementIf($style->isItalic(), 'w:i');
108109
$xmlWriter->writeElementIf($style->isItalic(), 'w:iCs');
109110

tests/PhpWord/Metadata/SettingsTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,14 @@ public function testZoomEnum()
153153
$oSettings->setZoom(Zoom::FULL_PAGE);
154154
$this->assertEquals('fullPage', $oSettings->getZoom());
155155
}
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+
}
156166
}

0 commit comments

Comments
 (0)