Пример #1
0
 /**
  * Write Legend
  *
  * @param  \PhpOffice\Common\XMLWriter   $objWriter XML Writer
  * @param  \PhpOffice\PhpPresentation\Shape\Chart\Legend $subject
  * @throws \Exception
  */
 protected function writeLegend(XMLWriter $objWriter, Legend $subject)
 {
     // c:legend
     $objWriter->startElement('c:legend');
     // c:legendPos
     $objWriter->startElement('c:legendPos');
     $objWriter->writeAttribute('val', $subject->getPosition());
     $objWriter->endElement();
     // Write layout
     $this->writeLayout($objWriter, $subject);
     // c:overlay
     $objWriter->startElement('c:overlay');
     $objWriter->writeAttribute('val', '0');
     $objWriter->endElement();
     // c:spPr
     $objWriter->startElement('c:spPr');
     // Fill
     $this->writeFill($objWriter, $subject->getFill());
     // Border
     if ($subject->getBorder()->getLineStyle() != Border::LINE_NONE) {
         $this->writeBorder($objWriter, $subject->getBorder(), '');
     }
     $objWriter->endElement();
     // c:txPr
     $objWriter->startElement('c:txPr');
     // 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->startElement('a:defRPr');
     $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();
     $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();
 }
Пример #2
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__);
 }
Пример #3
0
 public function testWidth()
 {
     $object = new Legend();
     $value = rand(0, 100);
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setWidth());
     $this->assertEquals(0, $object->getWidth());
     $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Shape\\Chart\\Legend', $object->setWidth($value));
     $this->assertEquals($value, $object->getWidth());
 }