Skip to content

Commit 32dd241

Browse files
committed
Rename property to 'hidden'
added unit test docx reader html reader/writer odt writer updated samples
1 parent 2b51c5c commit 32dd241

File tree

12 files changed

+49
-8
lines changed

12 files changed

+49
-8
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"php-cs-fixer fix --ansi --dry-run --diff",
4646
"phpcs --report-width=200 --report-summary --report-full samples/ src/ tests/ --ignore=src/PhpWord/Shared/PCLZip --standard=PSR2 -n",
4747
"phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php",
48-
"@test"
48+
"@test-no-coverage"
4949
],
5050
"fix": [
5151
"php-cs-fixer fix --ansi"

samples/Sample_04_Textrun.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
$textrun->addObject('resources/_sheet.xls');
4040
$textrun->addText(' Here is some more text. ');
4141

42+
$textrun = $section->addTextRun();
43+
$textrun->addText('This text is not visible.', array('hidden' => true));
44+
4245
// Save file
4346
echo write($phpWord, basename(__FILE__, '.php'), $writers);
4447
if (!CLI) {

samples/Sample_26_Html.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@
8989
<tr><td style="text-align: center;">Cell in parent table</td></tr>
9090
</table>';
9191

92+
$html .= '<p style="margin-top: 240pt;">The text below is not visible, click on show/hide to reveil it:</p>';
93+
$html .= '<p style="display: none">This is hidden text</p>';
94+
9295
\PhpOffice\PhpWord\Shared\Html::addHtml($section, $html, false, false);
9396

9497
// Save file

src/PhpWord/Reader/Word2007/AbstractPart.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ protected function readFontStyle(XMLReader $xmlReader, \DOMElement $domNode)
444444
'rtl' => array(self::READ_TRUE, 'w:rtl'),
445445
'lang' => array(self::READ_VALUE, 'w:lang'),
446446
'position' => array(self::READ_VALUE, 'w:position'),
447+
'hidden' => array(self::READ_TRUE, 'w:vanish'),
447448
);
448449

449450
return $this->readStyleDefs($xmlReader, $styleNode, $styleDefs);

src/PhpWord/Reader/Word2007/Styles.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public function read(PhpWord $phpWord)
6868
if (is_null($name)) {
6969
$name = $xmlReader->getAttribute('w:val', $node, 'w:name');
7070
}
71+
$headingMatches = array();
7172
preg_match('/Heading(\d)/', $name, $headingMatches);
7273
// $default = ($xmlReader->getAttribute('w:default', $node) == 1);
7374
switch ($type) {

src/PhpWord/Shared/Html.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,9 @@ private static function parseStyle($attribute, $styles)
515515
case 'text-align':
516516
$styles['alignment'] = self::mapAlign($cValue);
517517
break;
518+
case 'display':
519+
$styles['hidden'] = $cValue === 'none';
520+
break;
518521
case 'direction':
519522
$styles['rtl'] = $cValue === 'rtl';
520523
break;

src/PhpWord/Style/Font.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ class Font extends AbstractStyle
258258
* @var bool
259259
* @see http://www.datypic.com/sc/ooxml/e-w_vanish-1.html
260260
*/
261-
private $hiddenText = false;
261+
private $hidden = false;
262262

263263
/**
264264
* Vertically Raised or Lowered Text
@@ -307,7 +307,7 @@ public function getStyleValues()
307307
'smallCaps' => $this->isSmallCaps(),
308308
'allCaps' => $this->isAllCaps(),
309309
'fgColor' => $this->getFgColor(),
310-
'hiddenText'=> $this->isHiddenText(),
310+
'hidden' => $this->isHidden(),
311311
),
312312
'spacing' => array(
313313
'scale' => $this->getScale(),
@@ -952,9 +952,9 @@ public function getParagraphStyle()
952952
*
953953
* @return bool
954954
*/
955-
public function isHiddenText()
955+
public function isHidden()
956956
{
957-
return $this->hiddenText;
957+
return $this->hidden;
958958
}
959959

960960
/**
@@ -963,9 +963,9 @@ public function isHiddenText()
963963
* @param bool $value
964964
* @return self
965965
*/
966-
public function setHiddenText($value = true)
966+
public function setHidden($value = true)
967967
{
968-
$this->hiddenText = $this->setBoolVal($value, $this->hiddenText);
968+
$this->hidden = $this->setBoolVal($value, $this->hidden);
969969

970970
return $this;
971971
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public function write()
6060
$css['text-decoration'] .= $this->getValueIf($lineThrough, 'line-through ');
6161
$css['text-transform'] = $this->getValueIf($style->isAllCaps(), 'uppercase');
6262
$css['font-variant'] = $this->getValueIf($style->isSmallCaps(), 'small-caps');
63+
$css['display'] = $this->getValueIf($style->isHidden(), 'none');
6364

6465
$spacing = $style->getSpacing();
6566
$css['letter-spacing'] = $this->getValueIf(!is_null($spacing), ($spacing / 20) . 'pt');

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ public function write()
7575
$xmlWriter->writeAttributeIf($style->isSmallCaps(), 'fo:font-variant', 'small-caps');
7676
$xmlWriter->writeAttributeIf($style->isAllCaps(), 'fo:text-transform', 'uppercase');
7777

78+
//Hidden text
79+
$xmlWriter->writeAttributeIf($style->isHidden(), 'text:display', 'none');
80+
7881
// Superscript/subscript
7982
$xmlWriter->writeAttributeIf($style->isSuperScript(), 'style:text-position', 'super');
8083
$xmlWriter->writeAttributeIf($style->isSubScript(), 'style:text-position', 'sub');

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ private function writeStyle()
121121
$xmlWriter->writeElementIf($style->isAllCaps(), 'w:caps');
122122

123123
//Hidden text
124-
$xmlWriter->writeElementIf($style->isHiddenText(), 'w:vanish');
124+
$xmlWriter->writeElementIf($style->isHidden(), 'w:vanish');
125125

126126
// Underline
127127
$xmlWriter->writeElementIf($style->getUnderline() != 'none', 'w:u', 'w:val', $style->getUnderline());

0 commit comments

Comments
 (0)