Skip to content

implement underlineColor in Word2007, ODText, and HTML#2862

Open
ger82 wants to merge 3 commits intoPHPOffice:masterfrom
ger82:master
Open

implement underlineColor in Word2007, ODText, and HTML#2862
ger82 wants to merge 3 commits intoPHPOffice:masterfrom
ger82:master

Conversation

@ger82
Copy link

@ger82 ger82 commented Mar 4, 2026

Description

implement underlineColor in Word2007, ODText, and HTML

Checklist:

  • My CI is 🟢 , I think so
  • I have covered by unit tests my new code (check build/coverage for coverage report)
  • I have updated the documentation to describe the changes
  • I have updated the changelog

*
* @return string
*/
public function getUnderlineColor()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public function getUnderlineColor()
public function getUnderlineColor(): string

*
* @return self
*/
public function setUnderlineColor(?string $value = null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public function setUnderlineColor(?string $value = null)
public function setUnderlineColor(string $value = ''): self

Comment on lines +536 to +539
*
* @param string|null $value
*
* @return self
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
*
* @param string|null $value
*
* @return self

Comment on lines +526 to +527
*
* @return string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
*
* @return string

*/
private $underline = self::UNDERLINE_NONE;

private $underlineColor;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private $underlineColor;
/**
* Underline color.
*
* @var string
*/
private $underlineColor = '';

$css['vertical-align'] .= $this->getValueIf($style->isSubScript(), 'sub');
$css['text-decoration'] = '';
$css['text-decoration'] .= $this->getValueIf($underline, 'underline ');
$css['text-decoration-color'] .= $this->getValueIf($underlineColor !== null, "#{$underlineColor}");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$css['text-decoration-color'] .= $this->getValueIf($underlineColor !== null, "#{$underlineColor}");
$css['text-decoration-color'] .= $this->getValueIf($underlineColor !== '', '#' .$underlineColor);

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

// UnderlineColor
$xmlWriter->writeElementIf($style->getUnderlineColor() !== null, 'w:u', 'w:color', $style->getUnderlineColor());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$xmlWriter->writeElementIf($style->getUnderlineColor() !== null, 'w:u', 'w:color', $style->getUnderlineColor());
$xmlWriter->writeElementIf($style->getUnderlineColor() !== '', 'w:u', 'w:color', $style->getUnderlineColor());

'bold' => false,
'italic' => false,
'underline' => Font::UNDERLINE_NONE,
'underlineColor' => null,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'underlineColor' => null,
'underlineColor' => '',

Copy link
Member

@Progi1984 Progi1984 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ger82 Great contribution. Could you add unit tests for each writer and check all my feedbacks, please ?

@ger82
Copy link
Author

ger82 commented Mar 4, 2026

@Progi1984 Hi, to check you feedback, should I use the Button "resolve conversation" if it's ok?

I think your code changes are OK. I based my changes on the existing code, especially color and underline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants