You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ye...@apache.org on 2011/12/16 11:00:11 UTC

svn commit: r1215077 - in /poi/trunk/src: examples/src/org/apache/poi/xslf/usermodel/ ooxml/java/org/apache/poi/xslf/usermodel/

Author: yegor
Date: Fri Dec 16 10:00:11 2011
New Revision: 1215077

URL: http://svn.apache.org/viewvc?rev=1215077&view=rev
Log:
more xlsf docs and samples

Added:
    poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial7.java   (with props)
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/ListAutoNumber.java
Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java
    poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java

Added: poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial7.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial7.java?rev=1215077&view=auto
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial7.java (added)
+++ poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial7.java Fri Dec 16 10:00:11 2011
@@ -0,0 +1,85 @@
+/*
+ *  ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one or more
+ *    contributor license agreements.  See the NOTICE file distributed with
+ *    this work for additional information regarding copyright ownership.
+ *    The ASF licenses this file to You under the Apache License, Version 2.0
+ *    (the "License"); you may not use this file except in compliance with
+ *    the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ * ==================================================================== 
+ */
+
+package org.apache.poi.xslf.usermodel;
+
+import java.awt.*;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+/**
+ * Bullets and numbering
+ *
+ * @author Yegor Kozlov
+ */
+public class Tutorial7 {
+
+    public static void main(String[] args) throws IOException{
+        XMLSlideShow ppt = new XMLSlideShow();
+
+        XSLFSlide slide = ppt.createSlide();
+        XSLFTextBox shape = slide.createTextBox();
+        shape.setAnchor(new Rectangle(50, 50, 400, 200));
+
+        XSLFTextParagraph p1 = shape.addNewTextParagraph();
+        p1.setLevel(0);
+        p1.setBullet(true);
+        XSLFTextRun r1 = p1.addNewTextRun();
+        r1.setText("Bullet1");
+
+        XSLFTextParagraph p2 = shape.addNewTextParagraph();
+        // indentation before text
+        p2.setLeftMargin(60);
+        // the bullet is set 40 pt before the text
+        p2.setIndent(-40);
+        p2.setBullet(true);
+        // customize bullets
+        p2.setBulletFontColor(Color.red);
+        p2.setBulletFont("Wingdings");
+        p2.setBulletCharacter("\u0075");
+        p2.setLevel(1);
+        XSLFTextRun r2 = p2.addNewTextRun();
+        r2.setText("Bullet2");
+
+        // the next three paragraphs form an auto-numbered list
+        XSLFTextParagraph p3 = shape.addNewTextParagraph();
+        p3.setBulletAutoNumber(ListAutoNumber.ALPHA_LC_PARENT_R, 1);
+        p3.setLevel(2);
+        XSLFTextRun r3 = p3.addNewTextRun();
+        r3.setText("Numbered List Item - 1");
+
+        XSLFTextParagraph p4 = shape.addNewTextParagraph();
+        p4.setBulletAutoNumber(ListAutoNumber.ALPHA_LC_PARENT_R, 2);
+        p4.setLevel(2);
+        XSLFTextRun r4 = p4.addNewTextRun();
+        r4.setText("Numbered List Item - 2");
+
+        XSLFTextParagraph p5 = shape.addNewTextParagraph();
+        p5.setBulletAutoNumber(ListAutoNumber.ALPHA_LC_PARENT_R, 3);
+        p5.setLevel(2);
+        XSLFTextRun r5 = p5.addNewTextRun();
+        r5.setText("Numbered List Item - 3");
+
+        shape.resizeToFitText();
+
+        FileOutputStream out = new FileOutputStream("list.pptx");
+        ppt.write(out);
+        out.close();
+    }
+}

Propchange: poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial7.java
------------------------------------------------------------------------------
    svn:executable = *

Added: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/ListAutoNumber.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/ListAutoNumber.java?rev=1215077&view=auto
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/ListAutoNumber.java (added)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/ListAutoNumber.java Fri Dec 16 10:00:11 2011
@@ -0,0 +1,105 @@
+/*
+ *  ====================================================================
+ *    Licensed to the Apache Software Foundation (ASF) under one or more
+ *    contributor license agreements.  See the NOTICE file distributed with
+ *    this work for additional information regarding copyright ownership.
+ *    The ASF licenses this file to You under the Apache License, Version 2.0
+ *    (the "License"); you may not use this file except in compliance with
+ *    the License.  You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ * ====================================================================
+ */
+package org.apache.poi.xslf.usermodel;
+
+/**
+ * Specifies type of automatic numbered bullet points that should be applied to a paragraph.
+ *
+ * @author Yegor Kozlov
+ */
+public enum ListAutoNumber {
+    /**
+     * (a), (b), (c), ...
+     */
+    ALPHA_LC_PARENT_BOTH,
+    /**
+     * (A), (B), (C), ...
+     */
+    ALPHA_UC_PARENT_BOTH,
+    /**
+     * a), b), c), ...
+     */
+    ALPHA_LC_PARENT_R,
+    /**
+     * A), B), C), ...
+     */
+    ALPHA_UC_PARENT_R,
+    /**
+     *  a., b., c., ...
+     */
+    ALPHA_LC_PERIOD,
+    /**
+     * A., B., C., ...
+     */
+    ALPHA_UC_PERIOD,
+    /**
+     * (1), (2), (3), ...
+     */
+    ARABIC_PARENT_BOTH,
+    /**
+     * 1), 2), 3), ...
+     */
+    ARABIC_PARENT_R,
+
+    /**
+     * 1., 2., 3., ...
+     */
+    ARABIC_PERIOD,
+    /**
+     * 1, 2, 3, ...
+     */
+    ARABIC_PLAIN,
+
+    /**
+     * (i), (ii), (iii), ...
+     */
+    ROMAN_LC_PARENT_BOTH,
+    /**
+     * (I), (II), (III), ...
+     */
+    ROMAN_UC_PARENT_BOTH,
+    /**
+     * i), ii), iii), ...
+     */
+    ROMAN_LC_PARENT_R,
+    /**
+     * I), II), III), ...
+     */
+    ROMAN_UC_PARENT_R,
+    /**
+     *  i., ii., iii., ...
+     */
+    ROMAN_LC_PERIOD ,
+    /**
+     * I., II., III., ...
+     */
+    ROMAN_UC_PERIOD,
+    /**
+     * Dbl-byte circle numbers
+     */
+    CIRCLE_NUM_DB_PLAIN,
+    /**
+     * Wingdings black circle numbers
+     */
+    CIRCLE_NUM_WD_BLACK_PLAIN,
+    /**
+     * Wingdings white circle numbers
+     */
+    CIRCLE_NUM_WD_WHITE_PLAIN
+}

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java?rev=1215077&r1=1215076&r2=1215077&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java Fri Dec 16 10:00:11 2011
@@ -21,22 +21,7 @@ import org.apache.poi.util.Internal;
 import org.apache.poi.util.Units;
 import org.apache.poi.xslf.model.ParagraphPropertyFetcher;
 import org.apache.xmlbeans.XmlObject;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTRegularTextRun;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextField;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraph;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextSpacing;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextTabStop;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextTabStopList;
-import org.openxmlformats.schemas.drawingml.x2006.main.STTextAlignType;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextFont;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharBullet;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTColor;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBulletSizePoint;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextLineBreak;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextNormalAutofit;
-import org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties;
+import org.openxmlformats.schemas.drawingml.x2006.main.*;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;
 import org.openxmlformats.schemas.presentationml.x2006.main.STPlaceholderType;
 
@@ -617,6 +602,21 @@ public class XSLFTextParagraph implement
         }
     }
 
+    /**
+     * Specifies that automatic numbered bullet points should be applied to this paragraph
+     *
+     * @param scheme type of auto-numbering
+     * @param startAt the number that will start number for a given sequence of automatically
+    numbered bullets (1-based).
+     */
+    public void setBulletAutoNumber(ListAutoNumber scheme, int startAt) {
+        if(startAt < 1) throw new IllegalArgumentException("Start Number must be greater or equal that 1") ;
+        CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();
+        CTTextAutonumberBullet lst = pr.isSetBuAutoNum() ? pr.getBuAutoNum() : pr.addNewBuAutoNum();
+        lst.setType(STTextAutonumberScheme.Enum.forInt(scheme.ordinal() + 1));
+        lst.setStartAt(startAt);
+    }
+
     @Override
     public String toString(){
         return "[" + getClass() + "]" + getText();

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java?rev=1215077&r1=1215076&r2=1215077&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java Fri Dec 16 10:00:11 2011
@@ -458,7 +458,7 @@ public abstract class XSLFTextShape exte
     /**
      * 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();



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org