https://bz.apache.org/bugzilla/show_bug.cgi?id=66509

            Bug ID: 66509
           Summary: NullPointerException when invoking getAnchor() on
                    groups/shapes that are missing the off attribute
           Product: POI
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSLF
          Assignee: dev@poi.apache.org
          Reporter: he...@canva.com
  Target Milestone: ---

Created attachment 38518
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=38518&action=edit
Zip file containing a Maven project that reproduces the issue

Issue:
When parsing PowerPoint files, some files may be missing the `<a:off>` tag from
the `<a:xfrm>` section. While PowerPoint and other applications can open these
files without issue, POI throws a `NullPointerException` when trying to
retrieve the `anchor` of a shape that is missing this tag.

Steps to reproduce:

1. Download the attached zip file containing a Maven project, unzip the folder
and `cd` into its directory.
2. Run `maven install` and then `mvn exec:java`.
3. Observe the `NullPointerException` that is thrown.

```
java.lang.NullPointerException: Cannot invoke
"org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D.xgetX()" because
"off" is null
    at org.apache.poi.xslf.usermodel.XSLFGroupShape.getAnchor
(XSLFGroupShape.java:87)
    at com.example.Main.main (Main.java:17)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke
(DirectMethodHandleAccessor.java:104)
    at java.lang.reflect.Method.invoke (Method.java:578)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:282)
    at java.lang.Thread.run (Thread.java:1589)
```

Expected behavior:
POI could gracefully handle missing `<a:off>` tags and not throw a
`NullPointerException` when trying to retrieve the anchor of a shape that is
missing this tag.

Proposed solution:
We are going to submit a pull request that makes the library return `null` in
cases where the `<a:off>` tag is missing for both `XSLFGroupShape` and
`XSLFSimpleShape`, instead of allowing the `NullPointerException` to occur.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org

Reply via email to