private function buildSlide(PHPPowerPoint_Slide $currentSlide, WallPost $post) { // Graph image $shape = $currentSlide->createDrawingShape(); $shape->setName($post->title); $shape->setDescription($post->title); $shape->setPath($post->getFile()); $shape->setHeight(405); $shape->setWidth(792); $shape->setOffsetX(70); $shape->setOffsetY(135); // Title $shape = $currentSlide->createRichTextShape(); $shape->setHeight(30); $shape->setWidth(600); $shape->setOffsetX(180); $shape->setOffsetY(50); $shape->createText($post->title); $shape->getAlignment()->setHorizontal(PHPPowerPoint_Style_Alignment::HORIZONTAL_CENTER); // Comment $shape = $currentSlide->createRichTextShape(); $shape->setHeight(100); $shape->setWidth(600); $shape->setOffsetX(180); $shape->setOffsetY(550); $shape->createText($post->comment); $shape->getAlignment()->setHorizontal(PHPPowerPoint_Style_Alignment::HORIZONTAL_CENTER); }
/** * Get hash code * * @return string Hash code */ public function getHashCode() { return md5($this->_slide->getHashCode() . $this->_offsetX . $this->_offsetY . $this->_width . $this->_height . $this->_rotation . $this->getFill()->getHashCode() . $this->_shadow->getHashCode() . (is_null($this->_hyperlink) ? '' : $this->_hyperlink->getHashCode()) . __CLASS__); }
/** * Write slide relationships to XML format * * Numbering is as follows: * rId1 - Drawings * * @param PHPPowerPoint_Slide $pSlide * @param int $pSlideId * @return string XML Output * @throws Exception */ public function writeSlideRelationships(PHPPowerPoint_Slide $pSlide = null, $pSlideId = 1) { // Create XML writer $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY); } // XML header $objWriter->startDocument('1.0', 'UTF-8', 'yes'); // Relationships $objWriter->startElement('Relationships'); $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); // Starting relation id $relId = 1; // Write slideLayout relationship $layoutPack = $this->getParentWriter()->getLayoutPack(); $layoutIndex = $layoutPack->findlayoutIndex($pSlide->getSlideLayout()); $this->_writeRelationship($objWriter, $relId++, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout', '../slideLayouts/slideLayout' . ($layoutIndex + 1) . '.xml'); // Write drawing relationships? if ($pSlide->getShapeCollection()->count() > 0) { // Loop trough images and write relationships $iterator = $pSlide->getShapeCollection()->getIterator(); while ($iterator->valid()) { if ($iterator->current() instanceof PHPPowerPoint_Shape_Drawing || $iterator->current() instanceof PHPPowerPoint_Shape_MemoryDrawing) { // Write relationship for image drawing $this->_writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', '../media/' . str_replace(' ', '', $iterator->current()->getIndexedFilename())); } $iterator->next(); ++$relId; } } $objWriter->endElement(); // Return return $objWriter->getData(); }
/** * Add external slide * * @param PHPPowerPoint_Slide $slide External slide to add * @throws Exception * @return PHPPowerPoint_Slide */ public function addExternalSheet(PHPPowerPoint_Slide $slide) { $slide->rebindParent($this); return $this->addSheet($slide); }
/** * Write slide relationships to XML format * * @param PHPPowerPoint_Slide $pSlide * @return string XML Output * @throws Exception */ public function writeSlideRelationships(PHPPowerPoint_Slide $pSlide = null) { // Create XML writer $objWriter = null; if ($this->getParentWriter()->getUseDiskCaching()) { $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory()); } else { $objWriter = new PHPPowerPoint_Shared_XMLWriter(PHPPowerPoint_Shared_XMLWriter::STORAGE_MEMORY); } // XML header $objWriter->startDocument('1.0', 'UTF-8', 'yes'); // Relationships $objWriter->startElement('Relationships'); $objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships'); // Starting relation id $relId = 1; // Write slideLayout relationship $layoutPack = $this->getParentWriter()->getLayoutPack(); $layoutIndex = $layoutPack->findlayoutIndex($pSlide->getSlideLayout(), $pSlide->getSlideMasterId()); $this->_writeRelationship($objWriter, $relId++, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout', '../slideLayouts/slideLayout' . ($layoutIndex + 1) . '.xml'); // Write drawing relationships? if ($pSlide->getShapeCollection()->count() > 0) { // Loop trough images and write relationships $iterator = $pSlide->getShapeCollection()->getIterator(); while ($iterator->valid()) { if ($iterator->current() instanceof PHPPowerPoint_Shape_Drawing || $iterator->current() instanceof PHPPowerPoint_Shape_MemoryDrawing) { // Write relationship for image drawing $this->_writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', '../media/' . str_replace(' ', '_', $iterator->current()->getIndexedFilename())); $iterator->current()->__relationId = 'rId' . $relId; ++$relId; } elseif ($iterator->current() instanceof PHPPowerPoint_Shape_Chart) { // Write relationship for chart drawing $this->_writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart', '../charts/' . $iterator->current()->getIndexedFilename()); $iterator->current()->__relationId = 'rId' . $relId; ++$relId; } $iterator->next(); } } // Write hyperlink relationships? if ($pSlide->getShapeCollection()->count() > 0) { // Loop trough hyperlinks and write relationships $iterator = $pSlide->getShapeCollection()->getIterator(); while ($iterator->valid()) { // Hyperlink on shape if ($iterator->current()->hasHyperlink()) { // Write relationship for hyperlink $hyperlink = $iterator->current()->getHyperlink(); $hyperlink->__relationId = 'rId' . $relId; if (!$hyperlink->isInternal()) { $this->_writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink', $hyperlink->getUrl(), 'External'); } else { $this->_writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide', 'slide' . $hyperlink->getSlideNumber() . '.xml'); } ++$relId; } // Hyperlink on rich text run if ($iterator->current() instanceof PHPPowerPoint_Shape_RichText) { foreach ($iterator->current()->getParagraphs() as $paragraph) { foreach ($paragraph->getRichTextElements() as $element) { if ($element instanceof PHPPowerPoint_Shape_RichText_Run || $element instanceof PHPPowerPoint_Shape_RichText_TextElement) { if ($element->hasHyperlink()) { // Write relationship for hyperlink $hyperlink = $element->getHyperlink(); $hyperlink->__relationId = 'rId' . $relId; if (!$hyperlink->isInternal()) { $this->_writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink', $hyperlink->getUrl(), 'External'); } else { $this->_writeRelationship($objWriter, $relId, 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide', 'slide' . $hyperlink->getSlideNumber() . '.xml'); } ++$relId; } } } } } $iterator->next(); } } $objWriter->endElement(); // Return return $objWriter->getData(); }
/** * @param PHPPowerPoint_Slide $currentSlide * @param Decision $decision */ private function buildSlide(PHPPowerPoint_Slide $currentSlide, Decision $decision) { // Title $shape = $currentSlide->createRichTextShape(); $shape->setHeight(30); $shape->setWidth(600); $shape->setOffsetX(180); $shape->setOffsetY(50); $shape->createText($decision->getName()); $shape->getAlignment()->setHorizontal(PHPPowerPoint_Style_Alignment::HORIZONTAL_CENTER); // Other info $shape = $currentSlide->createRichTextShape(); $shape->setHeight(500); $shape->setWidth(920); $shape->setOffsetX(20); $shape->setOffsetY(80); $shape->getAlignment()->setHorizontal(PHPPowerPoint_Style_Alignment::HORIZONTAL_LEFT); $textRun = $shape->createTextRun('Start/End date'); $textRun->getFont()->setBold(true); $shape->createTextRun(': '); if ($decision->getStartDate()) { $shape->createTextRun(DateTime::createFromFormat('Y-m-d H:i:s', $decision->getStartDate())->format('j M Y')); } else { $textRun = $shape->createTextRun('not set'); $textRun->getFont()->setItalic(true); } $shape->createTextRun(' - '); if ($decision->getEndDate()) { $shape->createTextRun(DateTime::createFromFormat('Y-m-d H:i:s', $decision->getEndDate())->format('j M Y')); } else { $textRun = $shape->createTextRun('not set'); $textRun->getFont()->setItalic(true); } $shape->createBreak(); $textRun = $shape->createTextRun('Status'); $textRun->getFont()->setBold(true); $shape->createTextRun(': ' . $decision->getStatus()); $shape->createBreak(); $tags = array(); foreach ($decision->getTagDecision() as $tag_decision) { $tags[] = $tag_decision->getTag()->getName(); } $textRun = $shape->createTextRun('Tags'); $textRun->getFont()->setBold(true); $shape->createTextRun(': ' . implode(', ', $tags)); $shape->createBreak(); $shape->createBreak(); $shape->createTextRun(strip_tags($decision->getObjective())); if ($this->roadmap->getShowReleases() && count($decision->getProjectRelease())) { $shape->createBreak(); $shape->createBreak(); $textRun = $shape->createTextRun('Releases'); $textRun->getFont()->setSize(14); $shape->createBreak(); foreach ($decision->getProjectRelease() as $project_release) { /** @var ProjectRelease $project_release */ $textRun = $shape->createTextRun(' ' . $project_release->getName()); $textRun->getFont()->setSize(12); $shape->createBreak(); if ($this->roadmap->getShowItems()) { foreach ($project_release->getProjectReleaseAlternative() as $project_release_alternative) { /** @var ProjectReleaseAlternative $project_release_alternative */ $shape->createTextRun(' ' . $project_release_alternative->getAlternative()->getName()); $shape->createBreak(); } } } } if ($this->roadmap->getShowDependencies()) { $alternative_relations_text = ''; $alternative_relations = array(); $related_decisions = array(); foreach ($decision->getAlternative() as $alternative) { /** @var $alternative Alternative */ if (count($alternative->getAlternativeRelation())) { $alternative_relations[$alternative->getId()]['alternative'] = $alternative; foreach ($alternative->getAlternativeRelation() as $relation) { /** @var $relation AlternativeRelation */ $related_decisions[$relation->getAlternativeTo()->getDecisionId()] = $relation->getAlternativeTo()->getDecision()->getName(); $alternative_relations[$alternative->getId()]['relations'][$relation->getAlternativeTo()->getDecisionId()]['decision'] = $relation->getAlternativeTo()->getDecision(); $alternative_relations[$alternative->getId()]['relations'][$relation->getAlternativeTo()->getDecisionId()]['linked_alternatives'][] = $relation->getAlternativeTo(); } } } if (count($alternative_relations)) { $shape->createBreak(); $shape->createTextRun('This project has dependency to project(s) ' . implode(', ', $related_decisions))->getFont()->setBold(true); foreach ($alternative_relations as $alternative_relation) { foreach ($alternative_relation['relations'] as $relation) { $temp_linked_alternatives = array(); foreach ($relation['linked_alternatives'] as $linked_alternative) { $temp_linked_alternatives[] .= $linked_alternative->getName(); } $shape->createBreak(); $shape->createTextRun(' - ' . $alternative_relation['alternative']->getName() . " has dependency to " . implode(', ', $temp_linked_alternatives) . " in project " . $relation['decision']->getName()); } } } } }