Additional work on bugfix GH-161: Hyperlinks break when removing rows

This commit is contained in:
Mark Baker 2013-04-20 23:53:25 +01:00
parent e76673bcc0
commit ab01a6c6dc
2 changed files with 25 additions and 3 deletions

View File

@ -68,6 +68,26 @@ class PHPExcel_ReferenceHelper
protected function __construct() { protected function __construct() {
} }
private function cellSort($a, $b) {
list($ac,$ar) = sscanf($a,'%[A-Z]%d');
list($bc,$br) = sscanf($b,'%[A-Z]%d');
if ($ar == $br) {
return strcasecmp(sprintf('%03s',$ac), sprintf('%03s',$bc));
}
return ($ar < $br) ? -1 : 1;
}
private function cellReverseSort($a, $b) {
list($ac,$ar) = sscanf($a,'%[A-Z]%d');
list($bc,$br) = sscanf($b,'%[A-Z]%d');
if ($ar == $br) {
return 1 - strcasecmp(sprintf('%03s',$ac), sprintf('%03s',$bc));
}
return ($ar < $br) ? 1 : -1;
}
/** /**
* Insert a new column, updating all possible related data * Insert a new column, updating all possible related data
* *
@ -274,9 +294,10 @@ class PHPExcel_ReferenceHelper
$pSheet->setComments($aNewComments); // replace the comments array $pSheet->setComments($aNewComments); // replace the comments array
// Update worksheet: hyperlinks // Update worksheet: hyperlinks
$aHyperlinkCollection = $pNumCols > 0 || $pNumRows > 0 ? $aHyperlinkCollection = $pSheet->getHyperlinkCollection();
array_reverse($pSheet->getHyperlinkCollection(), true) : ($pNumCols > 0 || $pNumRows > 0) ?
$pSheet->getHyperlinkCollection(); uksort($aHyperlinkCollection, array('PHPExcel_ReferenceHelper','cellReverseSort')) :
uksort($aHyperlinkCollection, array('PHPExcel_ReferenceHelper','cellSort'));
foreach ($aHyperlinkCollection as $key => $value) { foreach ($aHyperlinkCollection as $key => $value) {
$newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows); $newReference = $this->updateCellReference($key, $pBefore, $pNumCols, $pNumRows);
if ($key != $newReference) { if ($key != $newReference) {

View File

@ -58,6 +58,7 @@ Fixed in develop branch for release v1.7.9:
- Bugfix: (MBaker) - Add DROP TABLE in destructor for SQLite and SQLite3 cache controllers - Bugfix: (MBaker) - Add DROP TABLE in destructor for SQLite and SQLite3 cache controllers
- Bugfix: (alexgann) Work item GH-154 - Fix merged-cell borders on HTML/PDF output - Bugfix: (alexgann) Work item GH-154 - Fix merged-cell borders on HTML/PDF output
- Bugfix: (Shanto) Work item GH-161 - Fix: Hyperlinks break when removing rows - Bugfix: (Shanto) Work item GH-161 - Fix: Hyperlinks break when removing rows
- Bugfix: (neclimdul) Work item GH-166 - Fix Extra Table Row From Images and Charts
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------