pjfanning commented on code in PR #1033:
URL: https://github.com/apache/poi/pull/1033#discussion_r2964463235
##########
poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFTextParagraph.java:
##########
@@ -224,4 +230,37 @@ void testXSSFTextParagraph2() throws IOException {
assertArrayEquals(run.getFontColorAsBytes(),
run2.getFontColorAsBytes());
}
}
+
+ @Test
+ public void testBulletAutoNumberSchemeOutOfBounds() {
+ try (XSSFWorkbook wb = new XSSFWorkbook()) {
+ XSSFSheet sheet = wb.createSheet();
+ XSSFDrawing drawing = sheet.createDrawingPatriarch();
+ XSSFTextBox shape = drawing.createTextbox(new XSSFClientAnchor(0,
0, 0, 0, 0, 0, 1, 1));
+
+ // Ensure the paragraph is created correctly
+ XSSFTextParagraph para = shape.addNewTextParagraph();
+
+ // 1. Obtain or create the underlying XML structure
+ CTTextParagraph ctPara = para.getXmlObject();
+ CTTextParagraphProperties pr = ctPara.isSetPPr() ? ctPara.getPPr()
: ctPara.addNewPPr();
+
+ // 2. Force a level to avoid ParagraphPropertyFetcher errors
+ pr.setLvl(0);
+
+ // 3. Set an out-of-range autonumber type (e.g. 24)
+ CTTextAutonumberBullet bullet = pr.isSetBuAutoNum() ?
pr.getBuAutoNum() : pr.addNewBuAutoNum();
+ bullet.setType(STTextAutonumberScheme.Enum.forInt(24));
+
+ // 4. Execute the test
+ // If you haven't applied the fix, this line will throw AIOOBE
+ // If the fix is applied, this should return ARABIC_PLAIN
+ ListAutoNumber result = para.getBulletAutoNumberScheme();
+
+ assertNotNull(result, "Result should not be null");
+ assertEquals(ListAutoNumber.ARABIC_PLAIN, result, "Should fallback
to ARABIC_PLAIN for unknown index");
+ } catch (Exception e) {
Review Comment:
please remove the catch - it is much better to have the full exception stack
trace if an exception is thrown
--
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]