* Support rendering transparent bitmaps in presentations.
Add PictureShape.getAlpha() method and implementations for HSLF and
XSLF. Then make use of it in DrawPictureShape to apply the right alpha
value to the picture being drawn.
Fixed a bug in BitmapImageRenderer that considered alpha value 0 as
"fully opaque", when it means "fully transparent" instead.
Finally, added a test for this feature in TestDrawPictureShape for XSLF.
A test for HSLF could not be created because it was not possible to
generate a test file with today's tools; MS Office removes the
bitmap transparency effect when saving as .ppt, and LibreOffice blends
it into the bitmap.
* Address reviewer comments.
* Add comment about default alpha value.
* Prevent NPE in XSLFPictureShape.getAlpha().
* Change wording in comments to avoid the word "percentage".
* Use static vars for extreme alpha values.
When retrieving picture data
When retrieving text in slides
When handling XSLFTableStyles
In EmbeddedExtractor if ShapeName is not set
In HSSF with invalid EscherSpRecord
In HSSF with invalid RecordStreams
When drawing arcs for shapes in slides
In HSSFPicture.getPictureIndex
Adjust "opens" for tests in poi-ooxml
Either handle it gracefully or throw
IllegalStateException instead for broken files
The current implementation calls updateHeaders() very often
causing cloning a sheet to take very long with high CPU.
We can optimize a number of things here:
* Use getTableColumnArray() as the List-based methods
have very costly implementations of hasNext()/next()
* Avoid some duplicated calls to updateHeaders()
There are likely more aggressive optimizations like
only calling updateHeaders() once after cloning,
but this would require more invasive changes in this
rarely used code-area.
* Add getter for body elements in XWPFSDTContent.
This getter allows to navigate the POI objects stored inside a
XWPFSDTContent object without resorting to navigating XML.
* Address comments in review.
* Allow to load a word document with chartex chart
ChartEx (new charts introduced in Office 2016) will raise exceptions in underlying XML parsing, we catch them here in order to still be able to load the document
* spacing
some extra spaces were unbearable and could have prevented the pull request
* add test
* Update POIXMLDocumentPart.java
* Update POIXMLDocumentPart.java
* Update POIXMLDocumentPart.java
* reduce risk of swallowing zip bomb exceptions
* Update POIXMLDocumentPart.java
---------
Co-authored-by: PJ Fanning <pjfanning@users.noreply.github.com>
Only signing-handling in poi-ooxml is still remaining, but
this deprecation seems to have been moved to Gradle 10 anyway.
Gradle 9 will require JDK 17, though, so we can only upgrade
when the min. supported JDK is bumped once more.
* Fix rules for table style application in XSLFTables.
Table styles contain rules for first and last rows/columns, even and
odd rows/columns... When one of these rules is empty, we are supposed
to fall back to the "whole table" rules. The fallback must also be
applied for the format that's not explicitly specified in the specific
rules.
when the corresponding specific rule is missing some info.
Fallback must also be applied when the corresponding specific rule is
missing some info. A couple of examples from the reproducer/test file
included:
The included reproducer/test file contained a few problems related to
table style application:
* The second style for horizontal/vertical banding (band2H, band2V) was
never applied.
* In the table with horizontal banding enabled, the style band1H did
not set a font color, POI returned a null font color instead of the
color from wholeTable.
* In the table with horizontal banding enabled, the style band2H did
not set a background color, POI returned null instead of the color
specified in wholeTable.
This patches fixes the behaviors mentioned above, making POI behavior
match the one from MS Office and LibreOffice.
* Replace uses of java.util.list.getFirst().
* Add methods to manage first slide number(firstSlideNum)
Adds methods to manage the custom starting slide number in XSLF (PowerPoint) presentations. This property is stored as the 'firstSlideNum' attribute in ppt/presentation.xml.
The following methods are added to XMLSlideShow:
- getFirstSlideNumber(): Retrieves the current starting slide number (default is 1).
- setFirstSlideNumber(int num): Sets the custom starting slide number.
- unsetFirstSlideNumber(): Removes the 'firstSlideNum' attribute, reverting to the default (1).
Constraints:
The 'set' method enforces the bounds [0, 9999] as defined by Microsoft's implementation specifications (MS-OI29500, Part 1, Section 19.2.1.26) to ensure the creation of valid PowerPoint files.
Also includes TestXSLFSlideShow updates to cover the new functionality, persistence, and validation checks.
* Review: Apply review feedback to firstSlideNumber feature
- Add @since 6.0.0 Javadoc tag to getFirstSlideNumber(), setFirstSlideNumber(), and unsetFirstSlideNumber() methods in XMLSlideShow.
- Refactor TestXSLFSlideShow to use explicit static JUnit imports (e.g., assertEquals, assertThrows) instead of wildcard imports, adhering to project coding style guidelines.
* whitespace
---------
Co-authored-by: PJ Fanning <pjfanning@users.noreply.github.com>
* Add XSSFOptimiser - XSSF equivalent of HSSFOptimiser
Adds optimization methods for XSSF workbooks to address style explosion
issues. HSSFOptimiser exists for HSSF but no equivalent existed for XSSF.
Methods added:
- optimiseCellStyles(XSSFWorkbook): Remaps cells using duplicate styles
to canonical (first) occurrence
- optimiseFonts(XSSFWorkbook): Updates style font references to canonical
fonts
Implementation uses a safe remapping approach rather than removing entries
from XML, which avoids XmlValueDisconnectedException issues caused by
StylesTable's internal list becoming disconnected from CTStylesheet.
Includes comprehensive test coverage in TestXSSFOptimiser.
Closes#951
* Address PR review comments
- Add "since 6.0.0" javadoc tag to XSSFOptimiser class
- Use Locale.ROOT in String.format() to comply with forbidden-apis check
We recently changed the getters so they don't create the PPr object if
it doesn't exist, but we missed adding one null check for the new
situation.
Add a test to exercise all the getters in a case where there isn't a PPr
object.
We announced their removal for 6.0.0, so
we can remove them now as we plan a 6.0.0 release
next.
Some were not yet removed as they have still internal
usage or seem to need more work to finally remove.
We announced their removal already for 5.0.0 or 5.3.0, so
we can safely remove them now as we plan a 6.0.0 release
next.
Cell.setCellType() needs a closer look later as
it is not a simple deletion of code.