Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Sarke opened this issue May 6, 2022 · 6 comments

Comments

@Sarke
Copy link

Sarke commented May 6, 2022

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...')
@IvanSerevko
Copy link

IvanSerevko commented May 13, 2022

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

@alexfierro
Copy link

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

@s873468834
Copy link

666666666666666

appsol added a commit to appsol/PHPPresentation that referenced this issue Apr 6, 2023
@dmtrbskkv
Copy link

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

@sxaxmz
Copy link

sxaxmz commented Jun 25, 2023

Hi @dmtrbskkv , can you elaborate thanks.

dmtrbskkv added a commit to dmtrbskkv/php-presentation-fix that referenced this issue Jun 28, 2023
@dmtrbskkv
Copy link

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

This was referenced Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

6 participants