Skip to content

Commit

Permalink
Work item 2541 - Table Cell Borders Not Displaying Correctly
Browse files Browse the repository at this point in the history
git-svn-id: https://phppowerpoint.svn.codeplex.com/svn/trunk@51982 ffd33b8c-2492-42e0-bdc5-587b920b7d6d
  • Loading branch information
maartenba committed Oct 7, 2010
1 parent 7ff04ff commit a5013ed
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Classes/PHPPowerPoint/Style/Border.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class PHPPowerPoint_Style_Border implements PHPPowerPoint_IComparable
const DASH_SYSDASHDOT = 'sysDashDot';
const DASH_SYSDASHDOTDOT = 'sysDashDotDot';
const DASH_SYSDOT = 'sysDot';

/**
* Line width
*
Expand Down Expand Up @@ -191,6 +191,7 @@ public function setColor(PHPPowerPoint_Style_Color $color = null) {
public function getHashCode() {
return md5(
$this->_lineStyle
. $this->_lineWidth
. $this->_dashStyle
. $this->_color->getHashCode()
. __CLASS__
Expand Down
48 changes: 46 additions & 2 deletions Classes/PHPPowerPoint/Writer/PowerPoint2007/Slide.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,9 @@ private function _writeTable(PHPPowerPoint_Shared_XMLWriter $objWriter = null, P
// Colspan / rowspan containers
$colSpan = array();
$rowSpan = array();

// Default border style
$defaultBorder = new PHPPowerPoint_Style_Border();

// Write rows
for ($row = 0; $row < count($shape->getRows()); $row++)
Expand All @@ -518,7 +521,21 @@ private function _writeTable(PHPPowerPoint_Shared_XMLWriter $objWriter = null, P
{
// Current cell
$currentCell = $shape->getRow($row)->getCell($cell);


// Next cell right
$nextCellRight = null;
try {
$nextCellRight = $shape->getRow($row)->getCell($cell + 1);
} catch (Exception $ex) {
}

// Next cell below
$nextCellBelow = null;
try {
$nextCellBelow = $shape->getRow($row + 1)->getCell($cell);
} catch (Exception $ex) {
}

// a:tc
$objWriter->startElement('a:tc');
// Colspan
Expand Down Expand Up @@ -577,8 +594,35 @@ private function _writeTable(PHPPowerPoint_Shared_XMLWriter $objWriter = null, P
$objWriter->writeAttribute('anchor', $horizontalAlign);
}




// Borders
$this->_writeBorders($objWriter, $currentCell->getBorders());
// - Left
$this->_writeBorder($objWriter, $currentCell->getBorders()->getLeft(), 'L');

// - Right
$tempCell = $currentCell;
if (!is_null($nextCellRight) && $nextCellRight->getBorders()->getRight()->getHashCode() != $defaultBorder->getHashCode())
{
$tempCell = $nextCellRight;
}
$this->_writeBorder($objWriter, $tempCell->getBorders()->getRight(), 'R');

// - Top
$this->_writeBorder($objWriter, $currentCell->getBorders()->getTop(), 'T');

// - Bottom
$tempCell = $currentCell;
if (!is_null($nextCellBelow) && $nextCellBelow->getBorders()->getBottom()->getHashCode() != $defaultBorder->getHashCode())
{
$tempCell = $nextCellBelow;
}
$this->_writeBorder($objWriter, $tempCell->getBorders()->getBottom(), 'B');

// - Diagonals
$this->_writeBorder($objWriter, $currentCell->getBorders()->getDiagonalDown(), 'TlToBr');
$this->_writeBorder($objWriter, $currentCell->getBorders()->getDiagonalUp(), 'BlToTr');

// Fill
$this->_writeFill($objWriter, $currentCell->getFill());
Expand Down
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ To be planned:
- Bugfix: (MB) Work item 3910 - Table width setting Office 2007
- Bugfix: (MB) Work item 4598 - Bullet characters in Master Slide Layouts of template file become corrupted
- Bugfix: (MB) Work item 3424 - Generated files cannot be opened in Office 08 for Mac OSX
- Bugfix: (MB) Work item 2541 - Table Cell Borders Not Displaying Correctly


Initial version:
Expand Down

0 comments on commit a5013ed

Please sign in to comment.