|
22 | 22 | use PhpOffice\Common\XMLWriter;
|
23 | 23 | use PhpOffice\PhpPowerpoint\PhpPowerpoint;
|
24 | 24 | use PhpOffice\PhpPowerpoint\Shape\Chart;
|
| 25 | +use PhpOffice\PhpPowerpoint\Shape\Chart\Title; |
25 | 26 | use PhpOffice\PhpPowerpoint\Shape\Chart\Type\AbstractTypeBar;
|
26 | 27 | use PhpOffice\PhpPowerpoint\Shape\Chart\Type\AbstractTypePie;
|
27 | 28 | use PhpOffice\PhpPowerpoint\Shape\Chart\Type\Area;
|
@@ -184,7 +185,7 @@ private function writeContentPart(Chart $chart)
|
184 | 185 | $this->writePlotAreaStyle($chart);
|
185 | 186 |
|
186 | 187 | // Title
|
187 |
| - $this->writeTitleStyle($chart); |
| 188 | + $this->writeTitleStyle($chart->getTitle()); |
188 | 189 |
|
189 | 190 | // Wall
|
190 | 191 | $this->writeWallStyle($chart);
|
@@ -216,7 +217,7 @@ private function writeContentPart(Chart $chart)
|
216 | 217 | }
|
217 | 218 |
|
218 | 219 | //**** Title ****
|
219 |
| - $this->writeTitle($chart); |
| 220 | + $this->writeTitle($chart->getTitle()); |
220 | 221 |
|
221 | 222 | //**** Legend ****
|
222 | 223 | $this->writeLegend($chart);
|
@@ -756,43 +757,47 @@ private function writeTable()
|
756 | 757 | }
|
757 | 758 |
|
758 | 759 | /**
|
759 |
| - * @param Chart $chart |
| 760 | + * @param Title $oTitle |
760 | 761 | */
|
761 |
| - private function writeTitle(Chart $chart) |
| 762 | + private function writeTitle(Title $oTitle) |
762 | 763 | {
|
763 |
| - // chart:title |
764 |
| - $this->xmlContent->startElement('chart:title'); |
765 |
| - $this->xmlContent->writeAttribute('svg:x', String::numberFormat(CommonDrawing::pixelsToCentimeters($chart->getTitle()->getOffsetX()), 3) . 'cm'); |
766 |
| - $this->xmlContent->writeAttribute('svg:y', String::numberFormat(CommonDrawing::pixelsToCentimeters($chart->getTitle()->getOffsetY()), 3) . 'cm'); |
767 |
| - $this->xmlContent->writeAttribute('chart:style-name', 'styleTitle'); |
768 |
| - // > text:p |
769 |
| - $this->xmlContent->startElement('text:p'); |
770 |
| - $this->xmlContent->text($chart->getTitle()->getText()); |
771 |
| - // > text:p |
772 |
| - $this->xmlContent->endElement(); |
773 |
| - // > chart:title |
774 |
| - $this->xmlContent->endElement(); |
| 764 | + if ($oTitle->isVisible()) { |
| 765 | + // chart:title |
| 766 | + $this->xmlContent->startElement('chart:title'); |
| 767 | + $this->xmlContent->writeAttribute('svg:x', String::numberFormat(CommonDrawing::pixelsToCentimeters($oTitle->getOffsetX()), 3) . 'cm'); |
| 768 | + $this->xmlContent->writeAttribute('svg:y', String::numberFormat(CommonDrawing::pixelsToCentimeters($oTitle->getOffsetY()), 3) . 'cm'); |
| 769 | + $this->xmlContent->writeAttribute('chart:style-name', 'styleTitle'); |
| 770 | + // > text:p |
| 771 | + $this->xmlContent->startElement('text:p'); |
| 772 | + $this->xmlContent->text($oTitle->getText()); |
| 773 | + // > text:p |
| 774 | + $this->xmlContent->endElement(); |
| 775 | + // > chart:title |
| 776 | + $this->xmlContent->endElement(); |
| 777 | + } |
775 | 778 | }
|
776 | 779 |
|
777 | 780 | /**
|
778 |
| - * @param Chart $chart |
| 781 | + * @param Title $oTitle |
779 | 782 | */
|
780 |
| - private function writeTitleStyle(Chart $chart) |
| 783 | + private function writeTitleStyle(Title $oTitle) |
781 | 784 | {
|
782 |
| - // style:style |
783 |
| - $this->xmlContent->startElement('style:style'); |
784 |
| - $this->xmlContent->writeAttribute('style:name', 'styleTitle'); |
785 |
| - $this->xmlContent->writeAttribute('style:family', 'chart'); |
786 |
| - // style:text-properties |
787 |
| - $this->xmlContent->startElement('style:text-properties'); |
788 |
| - $this->xmlContent->writeAttribute('fo:color', '#'.$chart->getTitle()->getFont()->getColor()->getRGB()); |
789 |
| - $this->xmlContent->writeAttribute('fo:font-family', $chart->getTitle()->getFont()->getName()); |
790 |
| - $this->xmlContent->writeAttribute('fo:font-size', $chart->getTitle()->getFont()->getSize().'pt'); |
791 |
| - $this->xmlContent->writeAttribute('fo:font-style', $chart->getTitle()->getFont()->isItalic() ? 'italic' : 'normal'); |
792 |
| - // > style:text-properties |
793 |
| - $this->xmlContent->endElement(); |
794 |
| - // > style:style |
795 |
| - $this->xmlContent->endElement(); |
| 785 | + if ($oTitle->isVisible()) { |
| 786 | + // style:style |
| 787 | + $this->xmlContent->startElement('style:style'); |
| 788 | + $this->xmlContent->writeAttribute('style:name', 'styleTitle'); |
| 789 | + $this->xmlContent->writeAttribute('style:family', 'chart'); |
| 790 | + // style:text-properties |
| 791 | + $this->xmlContent->startElement('style:text-properties'); |
| 792 | + $this->xmlContent->writeAttribute('fo:color', '#'.$oTitle->getFont()->getColor()->getRGB()); |
| 793 | + $this->xmlContent->writeAttribute('fo:font-family', $oTitle->getFont()->getName()); |
| 794 | + $this->xmlContent->writeAttribute('fo:font-size', $oTitle->getFont()->getSize().'pt'); |
| 795 | + $this->xmlContent->writeAttribute('fo:font-style', $oTitle->getFont()->isItalic() ? 'italic' : 'normal'); |
| 796 | + // > style:text-properties |
| 797 | + $this->xmlContent->endElement(); |
| 798 | + // > style:style |
| 799 | + $this->xmlContent->endElement(); |
| 800 | + } |
796 | 801 | }
|
797 | 802 |
|
798 | 803 | private function writeWall()
|
|
0 commit comments