--- /dev/null
+/*\r
+ * ====================================================================\r
+ * Licensed to the Apache Software Foundation (ASF) under one or more\r
+ * contributor license agreements. See the NOTICE file distributed with\r
+ * this work for additional information regarding copyright ownership.\r
+ * The ASF licenses this file to You under the Apache License, Version 2.0\r
+ * (the "License"); you may not use this file except in compliance with\r
+ * the License. You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ==================================================================== \r
+ */\r
+\r
+package org.apache.poi.xslf.usermodel;\r
+\r
+import java.awt.*;\r
+import java.io.FileOutputStream;\r
+import java.io.IOException;\r
+\r
+/**\r
+ * Bullets and numbering\r
+ *\r
+ * @author Yegor Kozlov\r
+ */\r
+public class Tutorial7 {\r
+\r
+ public static void main(String[] args) throws IOException{\r
+ XMLSlideShow ppt = new XMLSlideShow();\r
+\r
+ XSLFSlide slide = ppt.createSlide();\r
+ XSLFTextBox shape = slide.createTextBox();\r
+ shape.setAnchor(new Rectangle(50, 50, 400, 200));\r
+\r
+ XSLFTextParagraph p1 = shape.addNewTextParagraph();\r
+ p1.setLevel(0);\r
+ p1.setBullet(true);\r
+ XSLFTextRun r1 = p1.addNewTextRun();\r
+ r1.setText("Bullet1");\r
+\r
+ XSLFTextParagraph p2 = shape.addNewTextParagraph();\r
+ // indentation before text\r
+ p2.setLeftMargin(60);\r
+ // the bullet is set 40 pt before the text\r
+ p2.setIndent(-40);\r
+ p2.setBullet(true);\r
+ // customize bullets\r
+ p2.setBulletFontColor(Color.red);\r
+ p2.setBulletFont("Wingdings");\r
+ p2.setBulletCharacter("\u0075");\r
+ p2.setLevel(1);\r
+ XSLFTextRun r2 = p2.addNewTextRun();\r
+ r2.setText("Bullet2");\r
+\r
+ // the next three paragraphs form an auto-numbered list\r
+ XSLFTextParagraph p3 = shape.addNewTextParagraph();\r
+ p3.setBulletAutoNumber(ListAutoNumber.ALPHA_LC_PARENT_R, 1);\r
+ p3.setLevel(2);\r
+ XSLFTextRun r3 = p3.addNewTextRun();\r
+ r3.setText("Numbered List Item - 1");\r
+\r
+ XSLFTextParagraph p4 = shape.addNewTextParagraph();\r
+ p4.setBulletAutoNumber(ListAutoNumber.ALPHA_LC_PARENT_R, 2);\r
+ p4.setLevel(2);\r
+ XSLFTextRun r4 = p4.addNewTextRun();\r
+ r4.setText("Numbered List Item - 2");\r
+\r
+ XSLFTextParagraph p5 = shape.addNewTextParagraph();\r
+ p5.setBulletAutoNumber(ListAutoNumber.ALPHA_LC_PARENT_R, 3);\r
+ p5.setLevel(2);\r
+ XSLFTextRun r5 = p5.addNewTextRun();\r
+ r5.setText("Numbered List Item - 3");\r
+\r
+ shape.resizeToFitText();\r
+\r
+ FileOutputStream out = new FileOutputStream("list.pptx");\r
+ ppt.write(out);\r
+ out.close();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * ====================================================================\r
+ * Licensed to the Apache Software Foundation (ASF) under one or more\r
+ * contributor license agreements. See the NOTICE file distributed with\r
+ * this work for additional information regarding copyright ownership.\r
+ * The ASF licenses this file to You under the Apache License, Version 2.0\r
+ * (the "License"); you may not use this file except in compliance with\r
+ * the License. You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ====================================================================\r
+ */\r
+package org.apache.poi.xslf.usermodel;\r
+\r
+/**\r
+ * Specifies type of automatic numbered bullet points that should be applied to a paragraph.\r
+ *\r
+ * @author Yegor Kozlov\r
+ */\r
+public enum ListAutoNumber {\r
+ /**\r
+ * (a), (b), (c), ...\r
+ */\r
+ ALPHA_LC_PARENT_BOTH,\r
+ /**\r
+ * (A), (B), (C), ...\r
+ */\r
+ ALPHA_UC_PARENT_BOTH,\r
+ /**\r
+ * a), b), c), ...\r
+ */\r
+ ALPHA_LC_PARENT_R,\r
+ /**\r
+ * A), B), C), ...\r
+ */\r
+ ALPHA_UC_PARENT_R,\r
+ /**\r
+ * a., b., c., ...\r
+ */\r
+ ALPHA_LC_PERIOD,\r
+ /**\r
+ * A., B., C., ...\r
+ */\r
+ ALPHA_UC_PERIOD,\r
+ /**\r
+ * (1), (2), (3), ...\r
+ */\r
+ ARABIC_PARENT_BOTH,\r
+ /**\r
+ * 1), 2), 3), ...\r
+ */\r
+ ARABIC_PARENT_R,\r
+\r
+ /**\r
+ * 1., 2., 3., ...\r
+ */\r
+ ARABIC_PERIOD,\r
+ /**\r
+ * 1, 2, 3, ...\r
+ */\r
+ ARABIC_PLAIN,\r
+\r
+ /**\r
+ * (i), (ii), (iii), ...\r
+ */\r
+ ROMAN_LC_PARENT_BOTH,\r
+ /**\r
+ * (I), (II), (III), ...\r
+ */\r
+ ROMAN_UC_PARENT_BOTH,\r
+ /**\r
+ * i), ii), iii), ...\r
+ */\r
+ ROMAN_LC_PARENT_R,\r
+ /**\r
+ * I), II), III), ...\r
+ */\r
+ ROMAN_UC_PARENT_R,\r
+ /**\r
+ * i., ii., iii., ...\r
+ */\r
+ ROMAN_LC_PERIOD ,\r
+ /**\r
+ * I., II., III., ...\r
+ */\r
+ ROMAN_UC_PERIOD,\r
+ /**\r
+ * Dbl-byte circle numbers\r
+ */\r
+ CIRCLE_NUM_DB_PLAIN,\r
+ /**\r
+ * Wingdings black circle numbers\r
+ */\r
+ CIRCLE_NUM_WD_BLACK_PLAIN,\r
+ /**\r
+ * Wingdings white circle numbers\r
+ */\r
+ CIRCLE_NUM_WD_WHITE_PLAIN\r
+}\r
import org.apache.poi.util.Units;\r
import org.apache.poi.xslf.model.ParagraphPropertyFetcher;\r
import org.apache.xmlbeans.XmlObject;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.CTRegularTextRun;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextField;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraph;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextSpacing;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextTabStop;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextTabStopList;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.STTextAlignType;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextFont;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharBullet;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.CTColor;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBulletSizePoint;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextLineBreak;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextNormalAutofit;\r
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties;\r
+import org.openxmlformats.schemas.drawingml.x2006.main.*;\r
import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;\r
import org.openxmlformats.schemas.presentationml.x2006.main.STPlaceholderType;\r
\r
}\r
}\r
\r
+ /**\r
+ * Specifies that automatic numbered bullet points should be applied to this paragraph\r
+ *\r
+ * @param scheme type of auto-numbering\r
+ * @param startAt the number that will start number for a given sequence of automatically\r
+ numbered bullets (1-based).\r
+ */\r
+ public void setBulletAutoNumber(ListAutoNumber scheme, int startAt) {\r
+ if(startAt < 1) throw new IllegalArgumentException("Start Number must be greater or equal that 1") ;\r
+ CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();\r
+ CTTextAutonumberBullet lst = pr.isSetBuAutoNum() ? pr.getBuAutoNum() : pr.addNewBuAutoNum();\r
+ lst.setType(STTextAutonumberScheme.Enum.forInt(scheme.ordinal() + 1));\r
+ lst.setStartAt(startAt);\r
+ }\r
+\r
@Override\r
public String toString(){\r
return "[" + getClass() + "]" + getText();\r
/**
* Adjust the size of the shape so it encompasses the text inside it.
*
- * @return a <code>Rectangle2D</code> that is the bounds of this <code>TextShape</code>.
+ * @return a <code>Rectangle2D</code> that is the bounds of this shape.
*/
public Rectangle2D resizeToFitText(){
Rectangle2D anchor = getAnchor();