Example #1
0
 /**
  * Get hash code
  *
  * @return string Hash code
  */
 public function getHashCode()
 {
     return md5(parent::getHashCode() . $this->title->getHashCode() . $this->legend->getHashCode() . $this->plotArea->getHashCode() . $this->view3D->getHashCode() . ($this->includeSpreadsheet ? 1 : 0) . __CLASS__);
 }
Example #2
0
 /**
  * Write Title
  *
  * @param  \PhpOffice\Common\XMLWriter  $objWriter XML Writer
  * @param  \PhpOffice\PhpPresentation\Shape\Chart\Title $subject
  * @throws \Exception
  */
 protected function writeTitle(XMLWriter $objWriter, Title $subject)
 {
     // c:title
     $objWriter->startElement('c:title');
     // c:tx
     $objWriter->startElement('c:tx');
     // c:rich
     $objWriter->startElement('c:rich');
     // a:bodyPr
     $objWriter->writeElement('a:bodyPr', null);
     // a:lstStyle
     $objWriter->writeElement('a:lstStyle', null);
     // a:p
     $objWriter->startElement('a:p');
     // a:pPr
     $objWriter->startElement('a:pPr');
     $objWriter->writeAttribute('algn', $subject->getAlignment()->getHorizontal());
     $objWriter->writeAttribute('fontAlgn', $subject->getAlignment()->getVertical());
     $objWriter->writeAttribute('marL', CommonDrawing::pixelsToEmu($subject->getAlignment()->getMarginLeft()));
     $objWriter->writeAttribute('marR', CommonDrawing::pixelsToEmu($subject->getAlignment()->getMarginRight()));
     $objWriter->writeAttribute('indent', CommonDrawing::pixelsToEmu($subject->getAlignment()->getIndent()));
     $objWriter->writeAttribute('lvl', $subject->getAlignment()->getLevel());
     // a:defRPr
     $objWriter->writeElement('a:defRPr', null);
     $objWriter->endElement();
     // a:r
     $objWriter->startElement('a:r');
     // a:rPr
     $objWriter->startElement('a:rPr');
     $objWriter->writeAttribute('lang', 'en-US');
     $objWriter->writeAttribute('dirty', '0');
     $objWriter->writeAttribute('b', $subject->getFont()->isBold() ? 'true' : 'false');
     $objWriter->writeAttribute('i', $subject->getFont()->isItalic() ? 'true' : 'false');
     $objWriter->writeAttribute('strike', $subject->getFont()->isStrikethrough() ? 'sngStrike' : 'noStrike');
     $objWriter->writeAttribute('sz', $subject->getFont()->getSize() * 100);
     $objWriter->writeAttribute('u', $subject->getFont()->getUnderline());
     if ($subject->getFont()->isSuperScript() || $subject->getFont()->isSubScript()) {
         if ($subject->getFont()->isSuperScript()) {
             $objWriter->writeAttribute('baseline', '30000');
         } elseif ($subject->getFont()->isSubScript()) {
             $objWriter->writeAttribute('baseline', '-25000');
         }
     }
     // Font - a:solidFill
     $objWriter->startElement('a:solidFill');
     // a:srgbClr
     $objWriter->startElement('a:srgbClr');
     $objWriter->writeAttribute('val', $subject->getFont()->getColor()->getRGB());
     $objWriter->endElement();
     $objWriter->endElement();
     // Font - a:latin
     $objWriter->startElement('a:latin');
     $objWriter->writeAttribute('typeface', $subject->getFont()->getName());
     $objWriter->endElement();
     $objWriter->endElement();
     // a:t
     $objWriter->writeElement('a:t', $subject->getText());
     $objWriter->endElement();
     // a:endParaRPr
     $objWriter->startElement('a:endParaRPr');
     $objWriter->writeAttribute('lang', 'en-US');
     $objWriter->writeAttribute('dirty', '0');
     $objWriter->endElement();
     $objWriter->endElement();
     $objWriter->endElement();
     $objWriter->endElement();
     // Write layout
     $this->writeLayout($objWriter, $subject);
     // c:overlay
     $objWriter->startElement('c:overlay');
     $objWriter->writeAttribute('val', '0');
     $objWriter->endElement();
     $objWriter->endElement();
 }
Example #3
0
 /**
  * @param Title $oTitle
  */
 private function writeTitleStyle(Title $oTitle)
 {
     if ($oTitle->isVisible()) {
         // style:style
         $this->xmlContent->startElement('style:style');
         $this->xmlContent->writeAttribute('style:name', 'styleTitle');
         $this->xmlContent->writeAttribute('style:family', 'chart');
         // style:text-properties
         $this->xmlContent->startElement('style:text-properties');
         $this->xmlContent->writeAttribute('fo:color', '#' . $oTitle->getFont()->getColor()->getRGB());
         $this->xmlContent->writeAttribute('fo:font-family', $oTitle->getFont()->getName());
         $this->xmlContent->writeAttribute('fo:font-size', $oTitle->getFont()->getSize() . 'pt');
         $this->xmlContent->writeAttribute('fo:font-style', $oTitle->getFont()->isItalic() ? 'italic' : 'normal');
         // > style:text-properties
         $this->xmlContent->endElement();
         // > style:style
         $this->xmlContent->endElement();
     }
 }
Example #4
0
 public function testWidth()
 {
     $object = new Title();
     $value = rand(0, 100);
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setWidth());
     $this->assertEquals(0, $object->getWidth());
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Title', $object->setWidth($value));
     $this->assertEquals($value, $object->getWidth());
 }