mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-12 19:16:45 +00:00
support justifyLastLine
This commit is contained in:
@@ -241,6 +241,8 @@ class Styles extends BaseParserClass
|
||||
if ($horizontal !== '') {
|
||||
$alignment->setHorizontal($horizontal);
|
||||
}
|
||||
$justifyLastLine = (string) $this->getAttribute($alignmentXml, 'justifyLastLine');
|
||||
$alignment->setJustifyLastLine(self::boolean($justifyLastLine));
|
||||
$vertical = (string) $this->getAttribute($alignmentXml, 'vertical');
|
||||
if ($vertical !== '') {
|
||||
$alignment->setVertical($vertical);
|
||||
|
||||
@@ -97,6 +97,11 @@ class Alignment extends Supervisor
|
||||
*/
|
||||
protected ?string $horizontal = self::HORIZONTAL_GENERAL;
|
||||
|
||||
/**
|
||||
* Justify Last Line alignment.
|
||||
*/
|
||||
protected ?string $justifyLastLine = null;
|
||||
|
||||
/**
|
||||
* Vertical alignment.
|
||||
*/
|
||||
@@ -196,6 +201,9 @@ class Alignment extends Supervisor
|
||||
if (isset($styleArray['horizontal'])) {
|
||||
$this->setHorizontal($styleArray['horizontal']);
|
||||
}
|
||||
if (isset($styleArray['justifyLastLine'])) {
|
||||
$this->setJustifyLastLine($styleArray['justifyLastLine']);
|
||||
}
|
||||
if (isset($styleArray['vertical'])) {
|
||||
$this->setVertical($styleArray['vertical']);
|
||||
}
|
||||
@@ -255,6 +263,37 @@ class Alignment extends Supervisor
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Justify Last Line.
|
||||
*/
|
||||
public function getJustifyLastLine(): null|string
|
||||
{
|
||||
if ($this->isSupervisor) {
|
||||
return $this->getSharedComponent()->getJustifyLastLine();
|
||||
}
|
||||
|
||||
return $this->justifyLastLine;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Justify Last Line.
|
||||
*
|
||||
* @param string $justifyLastLine see self::HORIZONTAL_*
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setJustifyLastLine(string $justifyLastLine): static
|
||||
{
|
||||
if ($this->isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(['justifyLastLine' => $justifyLastLine]);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->justifyLastLine = $justifyLastLine;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Vertical.
|
||||
*/
|
||||
@@ -489,6 +528,7 @@ class Alignment extends Supervisor
|
||||
{
|
||||
$exportedArray = [];
|
||||
$this->exportArray2($exportedArray, 'horizontal', $this->getHorizontal());
|
||||
$this->exportArray2($exportedArray, 'justifyLastLine', $this->getJustifyLastLine());
|
||||
$this->exportArray2($exportedArray, 'indent', $this->getIndent());
|
||||
$this->exportArray2($exportedArray, 'readOrder', $this->getReadOrder());
|
||||
$this->exportArray2($exportedArray, 'shrinkToFit', $this->getShrinkToFit());
|
||||
|
||||
@@ -454,6 +454,9 @@ class Style extends WriterPart
|
||||
if ($vertical !== '') {
|
||||
$objWriter->writeAttribute('vertical', $vertical);
|
||||
}
|
||||
if ($style->getAlignment()->getJustifyLastLine()) {
|
||||
$objWriter->writeAttribute('justifyLastLine', '1');
|
||||
}
|
||||
|
||||
if ($style->getAlignment()->getTextRotation() >= 0) {
|
||||
$textRotation = $style->getAlignment()->getTextRotation();
|
||||
|
||||
Reference in New Issue
Block a user