Bugfix setBulletStyle in XSLFTextParagraph (#770)

* Bugfix setBulletStyle in XSLFTextParagraph

Having a 0 here throws IllegalArgumentException, the method setBulletAutoNumber requires 1 as minimun as argument

* tests added for setBulletStyle fix
This commit is contained in:
Vengador 2025-07-08 17:42:19 +02:00 committed by GitHub
parent 0c3cc9a5e1
commit bbd404f343
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 33 additions and 1 deletions

View File

@ -952,7 +952,7 @@ public class XSLFTextParagraph implements TextParagraph<XSLFShape,XSLFTextParagr
} else if (ostyle instanceof String) {
setBulletFont((String)ostyle);
} else if (ostyle instanceof AutoNumberingScheme) {
setBulletAutoNumber((AutoNumberingScheme)ostyle, 0);
setBulletAutoNumber((AutoNumberingScheme)ostyle, 1);
}
}
}

View File

@ -18,6 +18,7 @@ package org.apache.poi.xslf;
import java.awt.Color;
import java.awt.geom.Rectangle2D;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.POIDataSamples;
@ -25,6 +26,7 @@ import org.apache.poi.ooxml.POIXMLProperties.CoreProperties;
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.sl.usermodel.AutoNumberingScheme;
import org.apache.poi.sl.usermodel.ShapeType;
import org.apache.poi.xslf.usermodel.*;
import org.apache.xmlbeans.XmlException;
@ -167,4 +169,34 @@ class TestXSLFSlideShow {
assertNotEquals(templateTextRunXmlObject, copyTextRunXmlObject);
}
}
@Test
void testBulletStyle_DoesNotThrowException() throws IOException {
XMLSlideShow ppt = new XMLSlideShow();
XSLFSlide slide = ppt.createSlide();
XSLFAutoShape shape = slide.createAutoShape();
shape.setAnchor(new Rectangle2D.Double(50., 50., 300., 50.));
XSLFTextParagraph p = shape.addNewTextParagraph();
p.addNewTextRun().setText("Text bullet style bug");
assertDoesNotThrow(() -> p.setBulletStyle(20., Color.RED, "Calibri", AutoNumberingScheme.arabicParenRight));
ppt.close();
}
@Test
void testBulletStyle_setsCorrectValue() throws IOException {
XMLSlideShow ppt = new XMLSlideShow();
XSLFSlide slide = ppt.createSlide();
XSLFAutoShape shape = slide.createAutoShape();
shape.setAnchor(new Rectangle2D.Double(50., 50., 300., 50.));
XSLFTextParagraph p = shape.addNewTextParagraph();
p.addNewTextRun().setText("Text bullet style bug");
double fontSize = 20.;
AutoNumberingScheme scheme = AutoNumberingScheme.arabicParenRight;
p.setBulletStyle(fontSize, scheme);
assertEquals(fontSize, p.getBulletFontSize());
assertEquals(scheme, p.getAutoNumberingScheme());
ppt.close();
}
}