Skip to content

Commit

Permalink
#31 : Fix PHPCS
Browse files Browse the repository at this point in the history
  • Loading branch information
Progi1984 committed Jul 3, 2014
1 parent 627da39 commit 569df5a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
58 changes: 29 additions & 29 deletions src/PhpPowerpoint/Writer/ODPresentation/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function writeContent(PHPPowerPoint $pPHPPowerPoint = null)
$objWriter->startElement('office:automatic-styles');

$shapeId = 0;
foreach ($pPHPPowerPoint->getAllSlides() as $pSlide){
foreach ($pPHPPowerPoint->getAllSlides() as $pSlide) {
// Images
$shapes = $pSlide->getShapeCollection();
foreach ($shapes as $shape) {
Expand Down Expand Up @@ -250,80 +250,80 @@ public function writeContent(PHPPowerPoint $pPHPPowerPoint = null)

// style:graphic-properties
$objWriter->startElement('style:graphic-properties');
if($shapeCell->getFill()->getFillType() == Fill::FILL_SOLID){
if ($shapeCell->getFill()->getFillType() == Fill::FILL_SOLID) {
$objWriter->writeAttribute('draw:fill', 'solid');
$objWriter->writeAttribute('draw:fill-color', '#'.$shapeCell->getFill()->getStartColor()->getRGB());;
$objWriter->writeAttribute('draw:fill-color', '#'.$shapeCell->getFill()->getStartColor()->getRGB());
}
if($shapeCell->getFill()->getFillType() == Fill::FILL_GRADIENT_LINEAR){
if ($shapeCell->getFill()->getFillType() == Fill::FILL_GRADIENT_LINEAR) {
$objWriter->writeAttribute('draw:fill', 'gradient');
$objWriter->writeAttribute('draw:fill-gradient-name', 'gradient_'.$shapeCell->getFill()->getHashCode());
}
$objWriter->endElement();
// <style:graphic-properties
// <style:graphic-properties

// style:paragraph-properties
$objWriter->startElement('style:paragraph-properties');
if($shapeCell->getBorders()->getBottom()->getHashCode() == $shapeCell->getBorders()->getTop()->getHashCode()
if ($shapeCell->getBorders()->getBottom()->getHashCode() == $shapeCell->getBorders()->getTop()->getHashCode()
&& $shapeCell->getBorders()->getBottom()->getHashCode() == $shapeCell->getBorders()->getLeft()->getHashCode()
&& $shapeCell->getBorders()->getBottom()->getHashCode() == $shapeCell->getBorders()->getRight()->getHashCode()){
&& $shapeCell->getBorders()->getBottom()->getHashCode() == $shapeCell->getBorders()->getRight()->getHashCode()) {
$lineStyle = 'none';
$lineWidth = number_format($shapeCell->getBorders()->getBottom()->getLineWidth() / 1.75, 2);
$lineColor = $shapeCell->getBorders()->getBottom()->getColor()->getRGB();
switch ($shapeCell->getBorders()->getBottom()->getLineStyle()){
case Border::LINE_SINGLE:
$lineStyle = 'solid';
case Border::LINE_SINGLE:
$lineStyle = 'solid';
}
$objWriter->writeAttribute('fo:border', $lineWidth.'pt '.$lineStyle.' #'.$lineColor);
} else {
$lineStyle = 'none';
$lineWidth = number_format($shapeCell->getBorders()->getBottom()->getLineWidth() / 1.75, 2);
$lineColor = $shapeCell->getBorders()->getBottom()->getColor()->getRGB();
switch ($shapeCell->getBorders()->getBottom()->getLineStyle()){
case Border::LINE_SINGLE:
$lineStyle = 'solid';
case Border::LINE_SINGLE:
$lineStyle = 'solid';
}
$objWriter->writeAttribute('fo:border-bottom', $lineWidth.'pt '.$lineStyle.' #'.$lineColor);
// TOP
$lineStyle = 'none';
$lineWidth = number_format($shapeCell->getBorders()->getTop()->getLineWidth() / 1.75, 2);
$lineColor = $shapeCell->getBorders()->getTop()->getColor()->getRGB();
switch ($shapeCell->getBorders()->getTop()->getLineStyle()){
case Border::LINE_SINGLE:
$lineStyle = 'solid';
case Border::LINE_SINGLE:
$lineStyle = 'solid';
}
$objWriter->writeAttribute('fo:border-top', $lineWidth.'pt '.$lineStyle.' #'.$lineColor);
// RIGHT
$lineStyle = 'none';
$lineWidth = number_format($shapeCell->getBorders()->getRight()->getLineWidth() / 1.75, 2);
$lineColor = $shapeCell->getBorders()->getRight()->getColor()->getRGB();
switch ($shapeCell->getBorders()->getRight()->getLineStyle()){
case Border::LINE_SINGLE:
$lineStyle = 'solid';
case Border::LINE_SINGLE:
$lineStyle = 'solid';
}
$objWriter->writeAttribute('fo:border-right', $lineWidth.'pt '.$lineStyle.' #'.$lineColor);
// LEFT
$lineStyle = 'none';
$lineWidth = number_format($shapeCell->getBorders()->getLeft()->getLineWidth() / 1.75, 2);
$lineColor = $shapeCell->getBorders()->getLeft()->getColor()->getRGB();
switch ($shapeCell->getBorders()->getLeft()->getLineStyle()){
case Border::LINE_SINGLE:
$lineStyle = 'solid';
case Border::LINE_SINGLE:
$lineStyle = 'solid';
}
$objWriter->writeAttribute('fo:border-left', $lineWidth.'pt '.$lineStyle.' #'.$lineColor);
}
$objWriter->endElement();

$objWriter->endElement();

foreach ($shapeCell->getParagraphs() as $shapeParagraph){
foreach ($shapeParagraph->getRichTextElements() as $shapeRichText){
if ($shapeRichText instanceof Run) {
// Style des font text
if (!isset($arrStyleTextFont[$shapeRichText->getFont()->getHashCode()])) {
$arrStyleTextFont[$shapeRichText->getFont()->getHashCode()] = $shapeRichText->getFont();
}
}
}
foreach ($shapeCell->getParagraphs() as $shapeParagraph) {
foreach ($shapeParagraph->getRichTextElements() as $shapeRichText) {
if ($shapeRichText instanceof Run) {
// Style des font text
if (!isset($arrStyleTextFont[$shapeRichText->getFont()->getHashCode()])) {
$arrStyleTextFont[$shapeRichText->getFont()->getHashCode()] = $shapeRichText->getFont();
}
}
}
}
}
}
Expand Down Expand Up @@ -709,7 +709,7 @@ public function writeShapeTable(XMLWriter $objWriter, Table $shape, $shapeId)
//@todo getFill

$numColspan = 0;
foreach ($shapeRow->getCells() as $keyCell => $shapeCell){
foreach ($shapeRow->getCells() as $keyCell => $shapeCell) {
if ($numColspan == 0) {
// table:table-cell
$objWriter->startElement('table:table-cell');
Expand All @@ -723,8 +723,8 @@ public function writeShapeTable(XMLWriter $objWriter, Table $shape, $shapeId)
$objWriter->startElement('text:p');

// text:span
foreach ($shapeCell->getParagraphs() as $shapeParagraph){
foreach ($shapeParagraph->getRichTextElements() as $shapeRichText){
foreach ($shapeCell->getParagraphs() as $shapeParagraph) {
foreach ($shapeParagraph->getRichTextElements() as $shapeRichText) {
$objWriter->startElement('text:span');
$objWriter->writeAttribute('text:style-name', 'T_' . $shapeRichText->getFont()->getHashCode());
$objWriter->text($shapeRichText->getText());
Expand Down
14 changes: 7 additions & 7 deletions src/PhpPowerpoint/Writer/ODPresentation/Styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ public function writeStyles(PHPPowerPoint $pPHPPowerPoint = null)
$objWriter->endElement();
// draw:gradient
$arrayGradient = array();
foreach ($pPHPPowerPoint->getAllSlides() as $slide){
foreach ($slide->getShapeCollection() as $shape){
if($shape instanceof Table){
foreach ($shape->getRows() as $row){
foreach ($row->getCells() as $cell){
if($cell->getFill()->getFillType() == Fill::FILL_GRADIENT_LINEAR){
if(!in_array($cell->getFill()->getHashCode(), $arrayGradient)){
foreach ($pPHPPowerPoint->getAllSlides() as $slide) {
foreach ($slide->getShapeCollection() as $shape) {
if ($shape instanceof Table) {
foreach ($shape->getRows() as $row) {
foreach ($row->getCells() as $cell) {
if ($cell->getFill()->getFillType() == Fill::FILL_GRADIENT_LINEAR) {
if (!in_array($cell->getFill()->getHashCode(), $arrayGradient)) {
$objWriter->startElement('draw:gradient');
$objWriter->writeAttribute('draw:name', 'gradient_'.$cell->getFill()->getHashCode());
$objWriter->writeAttribute('draw:display-name', 'gradient_'.$cell->getFill()->getHashCode());
Expand Down

0 comments on commit 569df5a

Please sign in to comment.