mirror of https://github.com/apache/poi.git
more xlsf docs and samples
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1215077 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
799ab1ff5d
commit
40e7917560
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -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
|
||||||
|
}
|
|
@ -21,22 +21,7 @@ import org.apache.poi.util.Internal;
|
||||||
import org.apache.poi.util.Units;
|
import org.apache.poi.util.Units;
|
||||||
import org.apache.poi.xslf.model.ParagraphPropertyFetcher;
|
import org.apache.poi.xslf.model.ParagraphPropertyFetcher;
|
||||||
import org.apache.xmlbeans.XmlObject;
|
import org.apache.xmlbeans.XmlObject;
|
||||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTRegularTextRun;
|
import org.openxmlformats.schemas.drawingml.x2006.main.*;
|
||||||
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.presentationml.x2006.main.CTPlaceholder;
|
import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;
|
||||||
import org.openxmlformats.schemas.presentationml.x2006.main.STPlaceholderType;
|
import org.openxmlformats.schemas.presentationml.x2006.main.STPlaceholderType;
|
||||||
|
|
||||||
|
@ -617,6 +602,21 @@ public class XSLFTextParagraph implements Iterable<XSLFTextRun>{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
@Override
|
||||||
public String toString(){
|
public String toString(){
|
||||||
return "[" + getClass() + "]" + getText();
|
return "[" + getClass() + "]" + getText();
|
||||||
|
|
|
@ -458,7 +458,7 @@ public abstract class XSLFTextShape extends XSLFSimpleShape implements Iterable<
|
||||||
/**
|
/**
|
||||||
* Adjust the size of the shape so it encompasses the text inside it.
|
* 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(){
|
public Rectangle2D resizeToFitText(){
|
||||||
Rectangle2D anchor = getAnchor();
|
Rectangle2D anchor = getAnchor();
|
||||||
|
|
Loading…
Reference in New Issue