mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-22 21:36:05 +03:00
Validate additional booleans attributes in LibreOffice saved xlsx files for 'true'/'false' instead of '1'/'0'
This commit is contained in:
parent
9c213cc1cb
commit
a33926431d
@ -566,8 +566,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
|
|||||||
if ($xmlWorkbook->workbookPr) {
|
if ($xmlWorkbook->workbookPr) {
|
||||||
PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900);
|
PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_WINDOWS_1900);
|
||||||
if (isset($xmlWorkbook->workbookPr['date1904'])) {
|
if (isset($xmlWorkbook->workbookPr['date1904'])) {
|
||||||
$date1904 = (string)$xmlWorkbook->workbookPr['date1904'];
|
if (self::boolean((string) $xmlWorkbook->workbookPr['date1904'])) {
|
||||||
if ($date1904 == "true" || $date1904 == "1") {
|
|
||||||
PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_MAC_1904);
|
PHPExcel_Shared_Date::setExcelCalendar(PHPExcel_Shared_Date::CALENDAR_MAC_1904);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -674,29 +673,34 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->outlinePr)) {
|
if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->outlinePr)) {
|
||||||
if (isset($xmlSheet->sheetPr->outlinePr['summaryRight']) && $xmlSheet->sheetPr->outlinePr['summaryRight'] == false) {
|
if (isset($xmlSheet->sheetPr->outlinePr['summaryRight']) &&
|
||||||
$docSheet->setShowSummaryRight(false);
|
!self::boolean((string) $xmlSheet->sheetPr->outlinePr['summaryRight'])) {
|
||||||
|
$docSheet->setShowSummaryRight(FALSE);
|
||||||
} else {
|
} else {
|
||||||
$docSheet->setShowSummaryRight(true);
|
$docSheet->setShowSummaryRight(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($xmlSheet->sheetPr->outlinePr['summaryBelow']) && $xmlSheet->sheetPr->outlinePr['summaryBelow'] == false) {
|
if (isset($xmlSheet->sheetPr->outlinePr['summaryBelow']) &&
|
||||||
$docSheet->setShowSummaryBelow(false);
|
!self::boolean((string) $xmlSheet->sheetPr->outlinePr['summaryBelow'])) {
|
||||||
|
$docSheet->setShowSummaryBelow(FALSE);
|
||||||
} else {
|
} else {
|
||||||
$docSheet->setShowSummaryBelow(true);
|
$docSheet->setShowSummaryBelow(TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->pageSetUpPr)) {
|
if (isset($xmlSheet->sheetPr) && isset($xmlSheet->sheetPr->pageSetUpPr)) {
|
||||||
if (isset($xmlSheet->sheetPr->pageSetUpPr['fitToPage']) && !self::boolean((string) $xmlSheet->sheetPr->pageSetUpPr['fitToPage'])) {
|
if (isset($xmlSheet->sheetPr->pageSetUpPr['fitToPage']) &&
|
||||||
$docSheet->getPageSetup()->setFitToPage(false);
|
!self::boolean((string) $xmlSheet->sheetPr->pageSetUpPr['fitToPage'])) {
|
||||||
|
$docSheet->getPageSetup()->setFitToPage(FALSE);
|
||||||
} else {
|
} else {
|
||||||
$docSheet->getPageSetup()->setFitToPage(true);
|
$docSheet->getPageSetup()->setFitToPage(TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($xmlSheet->sheetFormatPr)) {
|
if (isset($xmlSheet->sheetFormatPr)) {
|
||||||
if (isset($xmlSheet->sheetFormatPr['customHeight']) && ((string)$xmlSheet->sheetFormatPr['customHeight'] == '1' || strtolower((string)$xmlSheet->sheetFormatPr['customHeight']) == 'true') && isset($xmlSheet->sheetFormatPr['defaultRowHeight'])) {
|
if (isset($xmlSheet->sheetFormatPr['customHeight']) &&
|
||||||
|
self::boolean((string) $xmlSheet->sheetFormatPr['customHeight']) &&
|
||||||
|
isset($xmlSheet->sheetFormatPr['defaultRowHeight'])) {
|
||||||
$docSheet->getDefaultRowDimension()->setRowHeight( (float)$xmlSheet->sheetFormatPr['defaultRowHeight'] );
|
$docSheet->getDefaultRowDimension()->setRowHeight( (float)$xmlSheet->sheetFormatPr['defaultRowHeight'] );
|
||||||
}
|
}
|
||||||
if (isset($xmlSheet->sheetFormatPr['defaultColWidth'])) {
|
if (isset($xmlSheet->sheetFormatPr['defaultColWidth'])) {
|
||||||
@ -715,13 +719,13 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
|
|||||||
$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setXfIndex(intval($col["style"]));
|
$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setXfIndex(intval($col["style"]));
|
||||||
}
|
}
|
||||||
if (self::boolean($col["bestFit"])) {
|
if (self::boolean($col["bestFit"])) {
|
||||||
//$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setAutoSize(true);
|
//$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setAutoSize(TRUE);
|
||||||
}
|
}
|
||||||
if (self::boolean($col["hidden"])) {
|
if (self::boolean($col["hidden"])) {
|
||||||
$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setVisible(false);
|
$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setVisible(FALSE);
|
||||||
}
|
}
|
||||||
if (self::boolean($col["collapsed"])) {
|
if (self::boolean($col["collapsed"])) {
|
||||||
$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setCollapsed(true);
|
$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setCollapsed(TRUE);
|
||||||
}
|
}
|
||||||
if ($col["outlineLevel"] > 0) {
|
if ($col["outlineLevel"] > 0) {
|
||||||
$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setOutlineLevel(intval($col["outlineLevel"]));
|
$docSheet->getColumnDimension(PHPExcel_Cell::stringFromColumnIndex($i))->setOutlineLevel(intval($col["outlineLevel"]));
|
||||||
@ -736,19 +740,19 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($xmlSheet->printOptions) && !$this->_readDataOnly) {
|
if (isset($xmlSheet->printOptions) && !$this->_readDataOnly) {
|
||||||
if ($xmlSheet->printOptions['gridLinesSet'] == 'true' && $xmlSheet->printOptions['gridLinesSet'] == '1') {
|
if (self::boolean((string) $xmlSheet->printOptions['gridLinesSet'])) {
|
||||||
$docSheet->setShowGridlines(true);
|
$docSheet->setShowGridlines(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($xmlSheet->printOptions['gridLines'] == 'true' || $xmlSheet->printOptions['gridLines'] == '1') {
|
if (self::boolean((string) $xmlSheet->printOptions['gridLines'])) {
|
||||||
$docSheet->setPrintGridlines(true);
|
$docSheet->setPrintGridlines(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($xmlSheet->printOptions['horizontalCentered']) {
|
if (self::boolean((string) $xmlSheet->printOptions['horizontalCentered'])) {
|
||||||
$docSheet->getPageSetup()->setHorizontalCentered(true);
|
$docSheet->getPageSetup()->setHorizontalCentered(TRUE);
|
||||||
}
|
}
|
||||||
if ($xmlSheet->printOptions['verticalCentered']) {
|
if (self::boolean((string) $xmlSheet->printOptions['verticalCentered'])) {
|
||||||
$docSheet->getPageSetup()->setVerticalCentered(true);
|
$docSheet->getPageSetup()->setVerticalCentered(TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -758,10 +762,10 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
|
|||||||
$docSheet->getRowDimension(intval($row["r"]))->setRowHeight(floatval($row["ht"]));
|
$docSheet->getRowDimension(intval($row["r"]))->setRowHeight(floatval($row["ht"]));
|
||||||
}
|
}
|
||||||
if (self::boolean($row["hidden"]) && !$this->_readDataOnly) {
|
if (self::boolean($row["hidden"]) && !$this->_readDataOnly) {
|
||||||
$docSheet->getRowDimension(intval($row["r"]))->setVisible(false);
|
$docSheet->getRowDimension(intval($row["r"]))->setVisible(FALSE);
|
||||||
}
|
}
|
||||||
if (self::boolean($row["collapsed"])) {
|
if (self::boolean($row["collapsed"])) {
|
||||||
$docSheet->getRowDimension(intval($row["r"]))->setCollapsed(true);
|
$docSheet->getRowDimension(intval($row["r"]))->setCollapsed(TRUE);
|
||||||
}
|
}
|
||||||
if ($row["outlineLevel"] > 0) {
|
if ($row["outlineLevel"] > 0) {
|
||||||
$docSheet->getRowDimension(intval($row["r"]))->setOutlineLevel(intval($row["outlineLevel"]));
|
$docSheet->getRowDimension(intval($row["r"]))->setOutlineLevel(intval($row["outlineLevel"]));
|
||||||
@ -938,12 +942,12 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
|
|||||||
if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->sheetProtection) {
|
if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->sheetProtection) {
|
||||||
foreach ($aKeys as $key) {
|
foreach ($aKeys as $key) {
|
||||||
$method = "set" . ucfirst($key);
|
$method = "set" . ucfirst($key);
|
||||||
$docSheet->getProtection()->$method($xmlSheet->sheetProtection[$key] == "true");
|
$docSheet->getProtection()->$method(self::boolean((string) $xmlSheet->sheetProtection[$key]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->sheetProtection) {
|
if (!$this->_readDataOnly && $xmlSheet && $xmlSheet->sheetProtection) {
|
||||||
$docSheet->getProtection()->setPassword((string) $xmlSheet->sheetProtection["password"], true);
|
$docSheet->getProtection()->setPassword((string) $xmlSheet->sheetProtection["password"], TRUE);
|
||||||
if ($xmlSheet->protectedRanges->protectedRange) {
|
if ($xmlSheet->protectedRanges->protectedRange) {
|
||||||
foreach ($xmlSheet->protectedRanges->protectedRange as $protectedRange) {
|
foreach ($xmlSheet->protectedRanges->protectedRange as $protectedRange) {
|
||||||
$docSheet->protectCells((string) $protectedRange["sqref"], (string) $protectedRange["password"], true);
|
$docSheet->protectCells((string) $protectedRange["sqref"], (string) $protectedRange["password"], true);
|
||||||
@ -1080,16 +1084,16 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
|
|||||||
$docPageSetup->setPaperSize(intval($xmlSheet->pageSetup["paperSize"]));
|
$docPageSetup->setPaperSize(intval($xmlSheet->pageSetup["paperSize"]));
|
||||||
}
|
}
|
||||||
if (isset($xmlSheet->pageSetup["scale"])) {
|
if (isset($xmlSheet->pageSetup["scale"])) {
|
||||||
$docPageSetup->setScale(intval($xmlSheet->pageSetup["scale"]), false);
|
$docPageSetup->setScale(intval($xmlSheet->pageSetup["scale"]), FALSE);
|
||||||
}
|
}
|
||||||
if (isset($xmlSheet->pageSetup["fitToHeight"]) && intval($xmlSheet->pageSetup["fitToHeight"]) >= 0) {
|
if (isset($xmlSheet->pageSetup["fitToHeight"]) && intval($xmlSheet->pageSetup["fitToHeight"]) >= 0) {
|
||||||
$docPageSetup->setFitToHeight(intval($xmlSheet->pageSetup["fitToHeight"]), false);
|
$docPageSetup->setFitToHeight(intval($xmlSheet->pageSetup["fitToHeight"]), FALSE);
|
||||||
}
|
}
|
||||||
if (isset($xmlSheet->pageSetup["fitToWidth"]) && intval($xmlSheet->pageSetup["fitToWidth"]) >= 0) {
|
if (isset($xmlSheet->pageSetup["fitToWidth"]) && intval($xmlSheet->pageSetup["fitToWidth"]) >= 0) {
|
||||||
$docPageSetup->setFitToWidth(intval($xmlSheet->pageSetup["fitToWidth"]), false);
|
$docPageSetup->setFitToWidth(intval($xmlSheet->pageSetup["fitToWidth"]), FALSE);
|
||||||
}
|
}
|
||||||
if (isset($xmlSheet->pageSetup["firstPageNumber"]) && isset($xmlSheet->pageSetup["useFirstPageNumber"]) &&
|
if (isset($xmlSheet->pageSetup["firstPageNumber"]) && isset($xmlSheet->pageSetup["useFirstPageNumber"]) &&
|
||||||
((string)$xmlSheet->pageSetup["useFirstPageNumber"] == 'true' || (string)$xmlSheet->pageSetup["useFirstPageNumber"] == '1')) {
|
self::boolean((string) $xmlSheet->pageSetup["useFirstPageNumber"])) {
|
||||||
$docPageSetup->setFirstPageNumber(intval($xmlSheet->pageSetup["firstPageNumber"]));
|
$docPageSetup->setFirstPageNumber(intval($xmlSheet->pageSetup["firstPageNumber"]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1098,28 +1102,28 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
|
|||||||
$docHeaderFooter = $docSheet->getHeaderFooter();
|
$docHeaderFooter = $docSheet->getHeaderFooter();
|
||||||
|
|
||||||
if (isset($xmlSheet->headerFooter["differentOddEven"]) &&
|
if (isset($xmlSheet->headerFooter["differentOddEven"]) &&
|
||||||
((string)$xmlSheet->headerFooter["differentOddEven"] == 'true' || (string)$xmlSheet->headerFooter["differentOddEven"] == '1')) {
|
self::boolean((string)$xmlSheet->headerFooter["differentOddEven"])) {
|
||||||
$docHeaderFooter->setDifferentOddEven(true);
|
$docHeaderFooter->setDifferentOddEven(TRUE);
|
||||||
} else {
|
} else {
|
||||||
$docHeaderFooter->setDifferentOddEven(false);
|
$docHeaderFooter->setDifferentOddEven(FALSE);
|
||||||
}
|
}
|
||||||
if (isset($xmlSheet->headerFooter["differentFirst"]) &&
|
if (isset($xmlSheet->headerFooter["differentFirst"]) &&
|
||||||
((string)$xmlSheet->headerFooter["differentFirst"] == 'true' || (string)$xmlSheet->headerFooter["differentFirst"] == '1')) {
|
self::boolean((string)$xmlSheet->headerFooter["differentFirst"])) {
|
||||||
$docHeaderFooter->setDifferentFirst(true);
|
$docHeaderFooter->setDifferentFirst(TRUE);
|
||||||
} else {
|
} else {
|
||||||
$docHeaderFooter->setDifferentFirst(false);
|
$docHeaderFooter->setDifferentFirst(FALSE);
|
||||||
}
|
}
|
||||||
if (isset($xmlSheet->headerFooter["scaleWithDoc"]) &&
|
if (isset($xmlSheet->headerFooter["scaleWithDoc"]) &&
|
||||||
((string)$xmlSheet->headerFooter["scaleWithDoc"] == 'false' || (string)$xmlSheet->headerFooter["scaleWithDoc"] == '0')) {
|
!self::boolean((string)$xmlSheet->headerFooter["scaleWithDoc"])) {
|
||||||
$docHeaderFooter->setScaleWithDocument(false);
|
$docHeaderFooter->setScaleWithDocument(FALSE);
|
||||||
} else {
|
} else {
|
||||||
$docHeaderFooter->setScaleWithDocument(true);
|
$docHeaderFooter->setScaleWithDocument(TRUE);
|
||||||
}
|
}
|
||||||
if (isset($xmlSheet->headerFooter["alignWithMargins"]) &&
|
if (isset($xmlSheet->headerFooter["alignWithMargins"]) &&
|
||||||
((string)$xmlSheet->headerFooter["alignWithMargins"] == 'false' || (string)$xmlSheet->headerFooter["alignWithMargins"] == '0')) {
|
!self::boolean((string)$xmlSheet->headerFooter["alignWithMargins"])) {
|
||||||
$docHeaderFooter->setAlignWithMargins(false);
|
$docHeaderFooter->setAlignWithMargins(FALSE);
|
||||||
} else {
|
} else {
|
||||||
$docHeaderFooter->setAlignWithMargins(true);
|
$docHeaderFooter->setAlignWithMargins(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
$docHeaderFooter->setOddHeader((string) $xmlSheet->headerFooter->oddHeader);
|
$docHeaderFooter->setOddHeader((string) $xmlSheet->headerFooter->oddHeader);
|
||||||
@ -1727,13 +1731,13 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
|
|||||||
$docStyle->getFont()->setName((string) $style->font->name["val"]);
|
$docStyle->getFont()->setName((string) $style->font->name["val"]);
|
||||||
$docStyle->getFont()->setSize((string) $style->font->sz["val"]);
|
$docStyle->getFont()->setSize((string) $style->font->sz["val"]);
|
||||||
if (isset($style->font->b)) {
|
if (isset($style->font->b)) {
|
||||||
$docStyle->getFont()->setBold(!isset($style->font->b["val"]) || $style->font->b["val"] == 'true' || $style->font->b["val"] == '1');
|
$docStyle->getFont()->setBold(!isset($style->font->b["val"]) || self::boolean((string) $style->font->b["val"]));
|
||||||
}
|
}
|
||||||
if (isset($style->font->i)) {
|
if (isset($style->font->i)) {
|
||||||
$docStyle->getFont()->setItalic(!isset($style->font->i["val"]) || $style->font->i["val"] == 'true' || $style->font->i["val"] == '1');
|
$docStyle->getFont()->setItalic(!isset($style->font->i["val"]) || self::boolean((string) $style->font->i["val"]));
|
||||||
}
|
}
|
||||||
if (isset($style->font->strike)) {
|
if (isset($style->font->strike)) {
|
||||||
$docStyle->getFont()->setStrikethrough(!isset($style->font->strike["val"]) || $style->font->strike["val"] == 'true' || $style->font->strike["val"] == '1');
|
$docStyle->getFont()->setStrikethrough(!isset($style->font->strike["val"]) || self::boolean((string) $style->font->strike["val"]));
|
||||||
}
|
}
|
||||||
$docStyle->getFont()->getColor()->setARGB(self::_readColor($style->font->color));
|
$docStyle->getFont()->getColor()->setARGB(self::_readColor($style->font->color));
|
||||||
|
|
||||||
@ -1781,21 +1785,15 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
|
|||||||
|
|
||||||
// border
|
// border
|
||||||
if (isset($style->border)) {
|
if (isset($style->border)) {
|
||||||
$diagonalUp = false;
|
$diagonalUp = self::boolean((string) $style->border["diagonalUp"]);
|
||||||
$diagonalDown = false;
|
$diagonalDown = self::boolean((string) $style->border["diagonalDown"]);
|
||||||
if ($style->border["diagonalUp"] == 'true' || $style->border["diagonalUp"] == 1) {
|
if (!$diagonalUp && !$diagonalDown) {
|
||||||
$diagonalUp = true;
|
|
||||||
}
|
|
||||||
if ($style->border["diagonalDown"] == 'true' || $style->border["diagonalDown"] == 1) {
|
|
||||||
$diagonalDown = true;
|
|
||||||
}
|
|
||||||
if ($diagonalUp == false && $diagonalDown == false) {
|
|
||||||
$docStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_NONE);
|
$docStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_NONE);
|
||||||
} elseif ($diagonalUp == true && $diagonalDown == false) {
|
} elseif ($diagonalUp && !$diagonalDown) {
|
||||||
$docStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_UP);
|
$docStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_UP);
|
||||||
} elseif ($diagonalUp == false && $diagonalDown == true) {
|
} elseif (!$diagonalUp && $diagonalDown) {
|
||||||
$docStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_DOWN);
|
$docStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_DOWN);
|
||||||
} elseif ($diagonalUp == true && $diagonalDown == true) {
|
} else {
|
||||||
$docStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_BOTH);
|
$docStyle->getBorders()->setDiagonalDirection(PHPExcel_Style_Borders::DIAGONAL_BOTH);
|
||||||
}
|
}
|
||||||
self::_readBorder($docStyle->getBorders()->getLeft(), $style->border->left);
|
self::_readBorder($docStyle->getBorders()->getLeft(), $style->border->left);
|
||||||
@ -1818,15 +1816,15 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
|
|||||||
}
|
}
|
||||||
|
|
||||||
$docStyle->getAlignment()->setTextRotation(intval($textRotation));
|
$docStyle->getAlignment()->setTextRotation(intval($textRotation));
|
||||||
$docStyle->getAlignment()->setWrapText( (string)$style->alignment["wrapText"] == "true" || (string)$style->alignment["wrapText"] == "1" );
|
$docStyle->getAlignment()->setWrapText(self::boolean((string) $style->alignment["wrapText"]));
|
||||||
$docStyle->getAlignment()->setShrinkToFit( (string)$style->alignment["shrinkToFit"] == "true" || (string)$style->alignment["shrinkToFit"] == "1" );
|
$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()->setIndent( intval((string)$style->alignment["indent"]) > 0 ? intval((string)$style->alignment["indent"]) : 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// protection
|
// protection
|
||||||
if (isset($style->protection)) {
|
if (isset($style->protection)) {
|
||||||
if (isset($style->protection['locked'])) {
|
if (isset($style->protection['locked'])) {
|
||||||
if ((string)$style->protection['locked'] == 'true') {
|
if (self::boolean((string) $style->protection['locked'])) {
|
||||||
$docStyle->getProtection()->setLocked(PHPExcel_Style_Protection::PROTECTION_PROTECTED);
|
$docStyle->getProtection()->setLocked(PHPExcel_Style_Protection::PROTECTION_PROTECTED);
|
||||||
} else {
|
} else {
|
||||||
$docStyle->getProtection()->setLocked(PHPExcel_Style_Protection::PROTECTION_UNPROTECTED);
|
$docStyle->getProtection()->setLocked(PHPExcel_Style_Protection::PROTECTION_UNPROTECTED);
|
||||||
@ -1834,7 +1832,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($style->protection['hidden'])) {
|
if (isset($style->protection['hidden'])) {
|
||||||
if ((string)$style->protection['hidden'] == 'true') {
|
if (self::boolean((string) $style->protection['hidden'])) {
|
||||||
$docStyle->getProtection()->setHidden(PHPExcel_Style_Protection::PROTECTION_PROTECTED);
|
$docStyle->getProtection()->setHidden(PHPExcel_Style_Protection::PROTECTION_PROTECTED);
|
||||||
} else {
|
} else {
|
||||||
$docStyle->getProtection()->setHidden(PHPExcel_Style_Protection::PROTECTION_UNPROTECTED);
|
$docStyle->getProtection()->setHidden(PHPExcel_Style_Protection::PROTECTION_UNPROTECTED);
|
||||||
@ -1879,23 +1877,23 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
|
|||||||
$objText->getFont()->setColor( new PHPExcel_Style_Color( self::_readColor($run->rPr->color) ) );
|
$objText->getFont()->setColor( new PHPExcel_Style_Color( self::_readColor($run->rPr->color) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (isset($run->rPr->b["val"]) && ((string) $run->rPr->b["val"] == 'true' || (string) $run->rPr->b["val"] == '1'))
|
if ((isset($run->rPr->b["val"]) && self::boolean((string) $run->rPr->b["val"])) ||
|
||||||
|| (isset($run->rPr->b) && !isset($run->rPr->b["val"])) ) {
|
(isset($run->rPr->b) && !isset($run->rPr->b["val"]))) {
|
||||||
$objText->getFont()->setBold(true);
|
$objText->getFont()->setBold(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (isset($run->rPr->i["val"]) && ((string) $run->rPr->i["val"] == 'true' || (string) $run->rPr->i["val"] == '1'))
|
if ((isset($run->rPr->i["val"]) && self::boolean((string) $run->rPr->i["val"])) ||
|
||||||
|| (isset($run->rPr->i) && !isset($run->rPr->i["val"])) ) {
|
(isset($run->rPr->i) && !isset($run->rPr->i["val"]))) {
|
||||||
$objText->getFont()->setItalic(true);
|
$objText->getFont()->setItalic(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($run->rPr->vertAlign) && isset($run->rPr->vertAlign["val"])) {
|
if (isset($run->rPr->vertAlign) && isset($run->rPr->vertAlign["val"])) {
|
||||||
$vertAlign = strtolower((string)$run->rPr->vertAlign["val"]);
|
$vertAlign = strtolower((string)$run->rPr->vertAlign["val"]);
|
||||||
if ($vertAlign == 'superscript') {
|
if ($vertAlign == 'superscript') {
|
||||||
$objText->getFont()->setSuperScript(true);
|
$objText->getFont()->setSuperScript(TRUE);
|
||||||
}
|
}
|
||||||
if ($vertAlign == 'subscript') {
|
if ($vertAlign == 'subscript') {
|
||||||
$objText->getFont()->setSubScript(true);
|
$objText->getFont()->setSubScript(TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1905,9 +1903,9 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
|
|||||||
$objText->getFont()->setUnderline((string)$run->rPr->u["val"]);
|
$objText->getFont()->setUnderline((string)$run->rPr->u["val"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (isset($run->rPr->strike["val"]) && ((string) $run->rPr->strike["val"] == 'true' || (string) $run->rPr->strike["val"] == '1'))
|
if ((isset($run->rPr->strike["val"]) && self::boolean((string) $run->rPr->strike["val"])) ||
|
||||||
|| (isset($run->rPr->strike) && !isset($run->rPr->strike["val"])) ) {
|
(isset($run->rPr->strike) && !isset($run->rPr->strike["val"]))) {
|
||||||
$objText->getFont()->setStrikethrough(true);
|
$objText->getFont()->setStrikethrough(TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1957,11 +1955,11 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
|
|||||||
return $style;
|
return $style;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function boolean($value)
|
private static function boolean($value = NULL)
|
||||||
{
|
{
|
||||||
if (is_numeric($value)) {
|
if (is_numeric($value)) {
|
||||||
return (boolean) $value;
|
return (bool) $value;
|
||||||
}
|
}
|
||||||
return ($value === 'true') ? TRUE : FALSE;
|
return ($value === 'true' || $value === 'TRUE') ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user