mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-25 23:06:03 +03:00
Support for cell readorder Context/LTR/RTL
This commit is contained in:
parent
125f39c745
commit
d777d0283d
@ -1893,6 +1893,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
|
||||
$docStyle->getAlignment()->setWrapText(self::boolean((string) $style->alignment["wrapText"]));
|
||||
$docStyle->getAlignment()->setShrinkToFit(self::boolean((string) $style->alignment["shrinkToFit"]));
|
||||
$docStyle->getAlignment()->setIndent( intval((string)$style->alignment["indent"]) > 0 ? intval((string)$style->alignment["indent"]) : 0 );
|
||||
$docStyle->getAlignment()->setReadorder( intval((string)$style->alignment["readingOrder"]) > 0 ? intval((string)$style->alignment["readingOrder"]) : 0 );
|
||||
}
|
||||
|
||||
// protection
|
||||
|
@ -36,49 +36,54 @@
|
||||
class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPExcel_IComparable
|
||||
{
|
||||
/* Horizontal alignment styles */
|
||||
const HORIZONTAL_GENERAL = 'general';
|
||||
const HORIZONTAL_LEFT = 'left';
|
||||
const HORIZONTAL_RIGHT = 'right';
|
||||
const HORIZONTAL_CENTER = 'center';
|
||||
const HORIZONTAL_CENTER_CONTINUOUS = 'centerContinuous';
|
||||
const HORIZONTAL_JUSTIFY = 'justify';
|
||||
const HORIZONTAL_FILL = 'fill';
|
||||
const HORIZONTAL_DISTRIBUTED = 'distributed'; // Excel2007 only
|
||||
const HORIZONTAL_GENERAL = 'general';
|
||||
const HORIZONTAL_LEFT = 'left';
|
||||
const HORIZONTAL_RIGHT = 'right';
|
||||
const HORIZONTAL_CENTER = 'center';
|
||||
const HORIZONTAL_CENTER_CONTINUOUS = 'centerContinuous';
|
||||
const HORIZONTAL_JUSTIFY = 'justify';
|
||||
const HORIZONTAL_FILL = 'fill';
|
||||
const HORIZONTAL_DISTRIBUTED = 'distributed'; // Excel2007 only
|
||||
|
||||
/* Vertical alignment styles */
|
||||
const VERTICAL_BOTTOM = 'bottom';
|
||||
const VERTICAL_TOP = 'top';
|
||||
const VERTICAL_CENTER = 'center';
|
||||
const VERTICAL_JUSTIFY = 'justify';
|
||||
const VERTICAL_DISTRIBUTED = 'distributed'; // Excel2007 only
|
||||
const VERTICAL_BOTTOM = 'bottom';
|
||||
const VERTICAL_TOP = 'top';
|
||||
const VERTICAL_CENTER = 'center';
|
||||
const VERTICAL_JUSTIFY = 'justify';
|
||||
const VERTICAL_DISTRIBUTED = 'distributed'; // Excel2007 only
|
||||
|
||||
/* Read order */
|
||||
const READORDER_CONTEXT = 0;
|
||||
const READORDER_LTR = 1;
|
||||
const READORDER_RTL = 2;
|
||||
|
||||
/**
|
||||
* Horizontal
|
||||
* Horizontal alignment
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_horizontal = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
|
||||
protected $_horizontal = PHPExcel_Style_Alignment::HORIZONTAL_GENERAL;
|
||||
|
||||
/**
|
||||
* Vertical
|
||||
* Vertical alignment
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_vertical = PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
|
||||
protected $_vertical = PHPExcel_Style_Alignment::VERTICAL_BOTTOM;
|
||||
|
||||
/**
|
||||
* Text rotation
|
||||
*
|
||||
* @var int
|
||||
* @var integer
|
||||
*/
|
||||
protected $_textRotation = 0;
|
||||
protected $_textRotation = 0;
|
||||
|
||||
/**
|
||||
* Wrap text
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $_wrapText = FALSE;
|
||||
protected $_wrapText = FALSE;
|
||||
|
||||
/**
|
||||
* Shrink to fit
|
||||
@ -90,9 +95,16 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE
|
||||
/**
|
||||
* Indent - only possible with horizontal alignment left and right
|
||||
*
|
||||
* @var int
|
||||
* @var integer
|
||||
*/
|
||||
protected $_indent = 0;
|
||||
protected $_indent = 0;
|
||||
|
||||
/**
|
||||
* Read order
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $_readorder = 0;
|
||||
|
||||
/**
|
||||
* Create a new PHPExcel_Style_Alignment
|
||||
@ -180,6 +192,9 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE
|
||||
if (isset($pStyles['indent'])) {
|
||||
$this->setIndent($pStyles['indent']);
|
||||
}
|
||||
if (isset($pStyles['readorder'])) {
|
||||
$this->setReadorder($pStyles['readorder']);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new PHPExcel_Exception("Invalid style array passed.");
|
||||
@ -389,6 +404,37 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get read order
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getReadorder() {
|
||||
if ($this->_isSupervisor) {
|
||||
return $this->getSharedComponent()->getReadorder();
|
||||
}
|
||||
return $this->_readorder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set read order
|
||||
*
|
||||
* @param int $pValue
|
||||
* @return PHPExcel_Style_Alignment
|
||||
*/
|
||||
public function setReadorder($pValue = 0) {
|
||||
if ($pValue < 0 || $pValue > 2) {
|
||||
$pValue = 0;
|
||||
}
|
||||
if ($this->_isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(array('readorder' => $pValue));
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->_readorder = $pValue;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hash code
|
||||
*
|
||||
@ -405,6 +451,7 @@ class PHPExcel_Style_Alignment extends PHPExcel_Style_Supervisor implements PHPE
|
||||
. ($this->_wrapText ? 't' : 'f')
|
||||
. ($this->_shrinkToFit ? 't' : 'f')
|
||||
. $this->_indent
|
||||
. $this->_readorder
|
||||
. __CLASS__
|
||||
);
|
||||
}
|
||||
|
@ -439,6 +439,9 @@ class PHPExcel_Writer_Excel2007_Style extends PHPExcel_Writer_Excel2007_WriterPa
|
||||
if ($pStyle->getAlignment()->getIndent() > 0) {
|
||||
$objWriter->writeAttribute('indent', $pStyle->getAlignment()->getIndent());
|
||||
}
|
||||
if ($pStyle->getAlignment()->getReadorder() > 0) {
|
||||
$objWriter->writeAttribute('readingOrder', $pStyle->getAlignment()->getReadorder());
|
||||
}
|
||||
$objWriter->endElement();
|
||||
|
||||
// protection
|
||||
|
Loading…
Reference in New Issue
Block a user