PHPPresentation icon indicating copy to clipboard operation
PHPPresentation copied to clipboard

PowerPoint2007::loadShapeRichText() must be an instance of AbstractSlide, instance of Note given

Open Sarke opened this issue 2 years ago • 7 comments

TypeError: Argument 3 passed to PhpOffice\PhpPresentation\Reader\PowerPoint2007::loadShapeRichText() must be an instance of PhpOffice\PhpPresentation\Slide\AbstractSlide, instance of PhpOffice\PhpPresentation\Slide\Note given, called in /app/vendor/phpoffice/phppresentation/src/PhpPresentation/Reader/PowerPoint2007.php on line 1387 and defined in /app/vendor/phpoffice/phppresentation/src/PhpPresentation/Reader/PowerPoint2007.php:886

Stack trace:
#0 /app/vendor/phpoffice/phppresentation/src/PhpPresentation/Reader/PowerPoint2007.php(1387): PhpOffice\PhpPresentation\Reader\PowerPoint2007->loadShapeRichText(Object(PhpOffice\Common\XMLReader), Object(DOMElement), Object(PhpOffice\PhpPresentation\Slide\Note))
#1 /app/vendor/phpoffice/phppresentation/src/PhpPresentation/Reader/PowerPoint2007.php(756): PhpOffice\PhpPresentation\Reader\PowerPoint2007->loadSlideShapes(Object(PhpOffice\PhpPresentation\Slide\Note), Object(DOMNodeList), Object(PhpOffice\Common\XMLReader))
#2 /app/vendor/phpoffice/phppresentation/src/PhpPresentation/Reader/PowerPoint2007.php(370): PhpOffice\PhpPresentation\Reader\PowerPoint2007->loadSlideNote('notesSlide1.xml', Object(PhpOffice\PhpPresentation\Slide))
#3 /app/vendor/phpoffice/phppresentation/src/PhpPresentation/Reader/PowerPoint2007.php(170): PhpOffice\PhpPresentation\Reader\PowerPoint2007->loadSlides('<?xml version="...')
#4 /app/vendor/phpoffice/phppresentation/src/PhpPresentation/Reader/PowerPoint2007.php(137): PhpOffice\PhpPresentation\Reader\PowerPoint2007->loadFile('/app/data/templ...')
#5 /app/vendor/phpoffice/phppresentation/src/PhpPresentation/IOFactory.php(73): PhpOffice\PhpPresentation\Reader\PowerPoint2007->load('/app/data/templ...')

Sarke avatar May 06 '22 09:05 Sarke

vendor/phpoffice/phppresentation/src/PhpPresentation/Reader/PowerPoint2007.php

 protected function loadShapeRichText(XMLReader $document, DOMElement $node, AbstractSlide $oSlide): void
 {
        if (!$document->elementExists('p:txBody/a:p/a:r', $node)) {
            return;
        }

replace to

    protected function loadShapeRichText(XMLReader $document, DOMElement $node, $oSlide): void
    {
        if (!$document->elementExists('p:txBody/a:p/a:r', $node) || !$oSlide instanceof AbstractSlide) {
            return;
        }

and in vendor/phpoffice/phppresentation/src/PhpPresentation/Style/Border.php

 public function setLineWidth(int $pValue = 1): self
    {
        $this->lineWidth =  $pValue;

replace to

 public function setLineWidth($pValue = 1): self
    {
        $this->lineWidth = (int) $pValue;

but it is required from the developer

IvanSerevko avatar May 13 '22 12:05 IvanSerevko

I can confirm that @IvanSerevko 's revision fixes this issue quite effectively. Any chance to get this pulled?

alexfierro avatar Dec 22 '22 15:12 alexfierro

666666666666666

s873468834 avatar Mar 22 '23 13:03 s873468834

I fork and do this. Mb it's can help: https://github.com/dmtrbskkv/php-presentation-fix

dmtrbskkv avatar Jun 21 '23 17:06 dmtrbskkv

Hi @dmtrbskkv , can you elaborate thanks.

sxaxmz avatar Jun 25 '23 09:06 sxaxmz

Hi @dmtrbskkv , can you elaborate thanks.

I make fork of the main repository and fix this bug. Fix like in this answer. How to install, u can find on repository page

dmtrbskkv avatar Jun 28 '23 13:06 dmtrbskkv