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

Powerpoint 2007 & ODPresentation Readers: Added support for loading embedded media #849

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Wilkolicious
Copy link

@Wilkolicious Wilkolicious commented Jan 28, 2025

Description

Motivation

I work on behalf of an e-Learning authoring tool. We are adding powerpoint import as an option for client learning designers to quickly import proprietary information into their course designs.

We wanted to add support for importing the following data from a powerpoint:

  • text
  • images
  • video
  • audio

I noticed that, although text and images were being loaded, there were no signs of embedded files. This PR aims to ameliorate that.

Changes

  • The Powerpoint 2007 loader now reads in embedded media files
    • Refactored out loading of images into PowerPoint2007::loadShapeDrawingImage
  • The OpenDocument Presentation loader now reads in embedded media files

I tried not to deviate too far from existing code norms, and didn't over-optimise by refactoring common bits between loading shapes.

Limitations

Not sure where to start for Powerpoint 97 (PPT) formats. 🤔

Observations

The (untouched) parent classes of Media and File look very biased to images.

Checklist:

  • My CI is 🟢
  • I have covered by unit tests my new code (check build/coverage for coverage report)
  • I have updated the documentation to describe the changes
  • I have updated the changelog

@@ -791,7 +793,11 @@ protected function loadShapeDrawing(XMLReader $document, DOMElement $node, Abstr
{
// Core
$document->registerNamespace('asvg', 'http://schemas.microsoft.com/office/drawing/2016/SVG/main');
if ($document->getElement('p:blipFill/a:blip/a:extLst/a:ext/asvg:svgBlip', $node)) {
$embedNode = $document->getElements("p:nvPicPr/p:nvPr//*[local-name()='media']", $node);
$embedNode = $embedNode ? $embedNode->item(0) : false;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PHP Static Analysis (7.1) error doesn't look correct.

Ternary operator condition is always true.

$document->getElements() likely invokes and returns the result of DOMXPath::query, thus $embedNode may have a value of false:

If the expression is malformed or the contextNode is invalid, DOMXPath::query() returns false.

https://www.php.net/manual/en/domxpath.query.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant