pjfanning opened a new pull request, #1535:
URL: https://github.com/apache/poi/pull/1535

   `DrawSimpleShape.drawShadow` drew shadows of flipped shapes on the wrong 
side. It added 180 degrees for a vertical flip, which dates from 2011 with no 
bug reference, and ignored horizontal flips, parent group flips and 
`rotWithShape`.
   
   ## PowerPoint's behaviour
   
   I rendered a test deck of flipped and rotated shapes in PowerPoint for the 
web and measured the shadow offsets from a screenshot. All shapes used `dir` = 
45 degrees (down-right on the page).
   
   | Case | no flip | flipH | flipV | flipH + flipV |
   |---|---|---|---|---|
   | `rotWithShape=0`, any rotation | 45° | 45° | 45° | 45° |
   | `rotWithShape=1`, no rotation | 45° | 135° | -45° | 225° |
   | `rotWithShape=1`, rotated 30° | 75° | 165° | -15° | 255° |
   
   - With `rotWithShape=0`, the shadow keeps its direction on the page.
   - With `rotWithShape=1`, the offset goes through the shape's rotation and 
flips. The schema default is `true`, so an unset value behaves the same way.
   - A flip on a parent group gave the same results as a flip on the shape.
   
   ## Changes
   
   - Add `Shadow.isRotateWithShape()`, a default method returning `false`. 
`XSLFShadow` overrides it from `rotWithShape`.
   - Add `DrawSimpleShape.getShadowOffset`. It keeps the offset as-is when the 
shadow rotates with the shape, and otherwise reverts the rotation and flips of 
the shape and its parent groups.
   
   This also changes rotated XSLF shapes that have no flip: with 
`rotWithShape=1` or unset, their shadow now rotates with the shape. Before, it 
always kept its page direction.
   
   ## Not verified against PowerPoint
   
   - **HSLF:** the `.ppt` test deck wouldn't open in PowerPoint for the web, so 
that file gave no results. HSLF has no `rotWithShape`, so it uses the page 
direction it already used for rotation, now also for flips.
   - **Rotated parent groups:** the deck only covered flipped groups. Reverting 
parent rotation follows from the same rule but wasn't observed.
   
   ## Relationship to #1534
   
   This PR doesn't depend on #1534 and can merge first, but flipped shapes 
won't render correctly until #1534 is in, because trunk's `DrawShape` flips 
every shape. With #1534's main code applied temporarily, rendering the deck 
through POI gave the same shadow directions as PowerPoint on all three XSLF 
slides.
   
   ## Tests
   
   `TestXSLFShadow` asserts the table above, including flipped groups, and 
`TestHSLFShadow` asserts the page direction. Both passed locally; I ran only 
these two classes.
   
   I found no related issue on GitHub. ASF Bugzilla's search needs a login, so 
I couldn't search it directly.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to