You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2015/10/29 02:05:28 UTC
svn commit: r1711171 [1/5] - in /poi: site/src/documentation/content/xdocs/
trunk/src/examples/src/org/apache/poi/hslf/examples/
trunk/src/examples/src/org/apache/poi/xslf/usermodel/
trunk/src/java/org/apache/poi/sl/draw/ trunk/src/java/org/apache/poi/...
Author: kiwiwings
Date: Thu Oct 29 01:05:27 2015
New Revision: 1711171
URL: http://svn.apache.org/viewvc?rev=1711171&view=rev
Log:
Common sl unification - copy first paragraph / textrun properties on XSLFTextShape.setText()
Common sl unification - converted ApacheconEU08 example to common sl - added missing functionality
Common sl unification - return null instead of default values for missing borders X/HSLFTable
Common sl unification - use points in HSLFTable.setColumnWidth()
Fix appending text to empty HSLFTextParagraph
Added:
poi/trunk/src/java/org/apache/poi/sl/draw/SLGraphics.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFPlaceholder.java
- copied, changed from r1707403, poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Placeholder.java
Removed:
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/Placeholder.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/Placeholder.java
Modified:
poi/site/src/documentation/content/xdocs/status.xml
poi/trunk/src/examples/src/org/apache/poi/hslf/examples/ApacheconEU08.java
poi/trunk/src/examples/src/org/apache/poi/hslf/examples/TableDemo.java
poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial3.java
poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial4.java
poi/trunk/src/java/org/apache/poi/sl/draw/DrawTableShape.java
poi/trunk/src/java/org/apache/poi/sl/usermodel/SimpleShape.java
poi/trunk/src/java/org/apache/poi/sl/usermodel/SlideShow.java
poi/trunk/src/java/org/apache/poi/sl/usermodel/StrokeStyle.java
poi/trunk/src/java/org/apache/poi/sl/usermodel/TableCell.java
poi/trunk/src/java/org/apache/poi/sl/usermodel/TableShape.java
poi/trunk/src/java/org/apache/poi/sl/usermodel/TextBox.java
poi/trunk/src/java/org/apache/poi/sl/usermodel/TextParagraph.java
poi/trunk/src/java/org/apache/poi/sl/usermodel/TextRun.java
poi/trunk/src/java/org/apache/poi/sl/usermodel/TextShape.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFAutoShape.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFShape.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSheet.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSimpleShape.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideLayout.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTable.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTableCell.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextBox.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextParagraph.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java
poi/trunk/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextShape.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFAutoShape.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFNotes.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSimpleShape.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTable.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextBox.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFAutoShape.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFGroupShape.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShapeFactory.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSheet.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSimpleShape.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlide.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShow.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTable.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTableCell.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextRun.java
poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFTextShape.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestLine.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/model/TestTable.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTable.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTextRun.java
Modified: poi/site/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/site/src/documentation/content/xdocs/status.xml?rev=1711171&r1=1711170&r2=1711171&view=diff
==============================================================================
--- poi/site/src/documentation/content/xdocs/status.xml (original)
+++ poi/site/src/documentation/content/xdocs/status.xml Thu Oct 29 01:05:27 2015
@@ -39,6 +39,11 @@
</devs>
<release version="3.14-beta1" date="2015-11-??">
+ <action dev="PD" type="fix">Common sl unification - copy first paragraph / textrun properties on XSLFTextShape.setText()</action>
+ <action dev="PD" type="fix">Common sl unification - converted ApacheconEU08 example to common sl - added missing functionality</action>
+ <action dev="PD" type="fix">Common sl unification - return null instead of default values for missing borders X/HSLFTable</action>
+ <action dev="PD" type="fix">Common sl unification - use points in HSLFTable.setColumnWidth()</action>
+ <action dev="PD" type="fix">Fix appending text to empty HSLFTextParagraph</action>
<action dev="PD" type="fix" fixes-bug="58558">SXSSFCell.setCellValue((RichTextString)null) fixed to work like XSSF and HSSF</action>
<action dev="PD" type="fix" fixes-bug="58536">DataFormatter and CellFormat non-localised support for localised currency formats like [$$-408]</action>
<action dev="PD" type="fix" fixes-bug="58532">DataFormatter cell formatting for things like [>999999]#,,"M";[>999]#,"K";#</action>
Modified: poi/trunk/src/examples/src/org/apache/poi/hslf/examples/ApacheconEU08.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/hslf/examples/ApacheconEU08.java?rev=1711171&r1=1711170&r2=1711171&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/hslf/examples/ApacheconEU08.java (original)
+++ poi/trunk/src/examples/src/org/apache/poi/hslf/examples/ApacheconEU08.java Thu Oct 29 01:05:27 2015
@@ -26,19 +26,20 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
-import org.apache.poi.hslf.model.PPGraphics2D;
-import org.apache.poi.hslf.record.TextHeaderAtom;
-import org.apache.poi.hslf.usermodel.HSLFAutoShape;
-import org.apache.poi.hslf.usermodel.HSLFGroupShape;
-import org.apache.poi.hslf.usermodel.HSLFSlide;
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
-import org.apache.poi.hslf.usermodel.HSLFTable;
-import org.apache.poi.hslf.usermodel.HSLFTableCell;
-import org.apache.poi.hslf.usermodel.HSLFTextBox;
-import org.apache.poi.hslf.usermodel.HSLFTextParagraph;
-import org.apache.poi.hslf.usermodel.HSLFTextRun;
-import org.apache.poi.hslf.usermodel.HSLFLine;
+import org.apache.poi.sl.draw.DrawTableShape;
+import org.apache.poi.sl.draw.SLGraphics;
+import org.apache.poi.sl.usermodel.AutoShape;
+import org.apache.poi.sl.usermodel.GroupShape;
import org.apache.poi.sl.usermodel.ShapeType;
+import org.apache.poi.sl.usermodel.Slide;
+import org.apache.poi.sl.usermodel.SlideShow;
+import org.apache.poi.sl.usermodel.TableCell;
+import org.apache.poi.sl.usermodel.TableShape;
+import org.apache.poi.sl.usermodel.TextBox;
+import org.apache.poi.sl.usermodel.TextParagraph;
+import org.apache.poi.sl.usermodel.TextRun;
+import org.apache.poi.sl.usermodel.TextShape.TextPlaceholder;
import org.apache.poi.sl.usermodel.VerticalAlignment;
/**
@@ -49,7 +50,8 @@ import org.apache.poi.sl.usermodel.Verti
public final class ApacheconEU08 {
public static void main(String[] args) throws IOException {
- HSLFSlideShow ppt = new HSLFSlideShow();
+ SlideShow<?,?> ppt = new HSLFSlideShow();
+ // SlideShow<?,?> ppt = new XMLSlideShow();
ppt.setPageSize(new Dimension(720, 540));
slide1(ppt);
@@ -65,69 +67,62 @@ public final class ApacheconEU08 {
slide11(ppt);
slide12(ppt);
- FileOutputStream out = new FileOutputStream("apachecon_eu_08.ppt");
+ String ext = ppt.getClass().getName().contains("HSLF") ? "ppt" : "pptx";
+ FileOutputStream out = new FileOutputStream("apachecon_eu_08."+ext);
ppt.write(out);
out.close();
}
- public static void slide1(HSLFSlideShow ppt) throws IOException {
- HSLFSlide slide = ppt.createSlide();
+ public static void slide1(SlideShow<?,?> ppt) throws IOException {
+ Slide<?,?> slide = ppt.createSlide();
- HSLFTextBox box1 = new HSLFTextBox();
- box1.setRunType(TextHeaderAtom.CENTER_TITLE_TYPE);
+ TextBox<?,?> box1 = slide.createTextBox();
+ box1.setTextPlaceholder(TextPlaceholder.CENTER_TITLE);
box1.setText("POI-HSLF");
box1.setAnchor(new Rectangle(54, 78, 612, 115));
- slide.addShape(box1);
- HSLFTextBox box2 = new HSLFTextBox();
- box2.setRunType(TextHeaderAtom.CENTRE_BODY_TYPE);
+ TextBox<?,?> box2 = slide.createTextBox();
+ box2.setTextPlaceholder(TextPlaceholder.CENTER_BODY);
box2.setText("Java API To Access Microsoft PowerPoint Format Files");
box2.setAnchor(new Rectangle(108, 204, 504, 138));
- slide.addShape(box2);
- HSLFTextBox box3 = new HSLFTextBox();
+ TextBox<?,?> box3 = slide.createTextBox();
box3.getTextParagraphs().get(0).getTextRuns().get(0).setFontSize(32d);
box3.setText(
"Yegor Kozlov\r" +
"yegor - apache - org");
box3.setHorizontalCentered(true);
box3.setAnchor(new Rectangle(206, 348, 310, 84));
- slide.addShape(box3);
}
- public static void slide2(HSLFSlideShow ppt) throws IOException {
- HSLFSlide slide = ppt.createSlide();
+ public static void slide2(SlideShow<?,?> ppt) throws IOException {
+ Slide<?,?> slide = ppt.createSlide();
- HSLFTextBox box1 = new HSLFTextBox();
- box1.setRunType(TextHeaderAtom.TITLE_TYPE);
+ TextBox<?,?> box1 = slide.createTextBox();
+ box1.setTextPlaceholder(TextPlaceholder.TITLE);
box1.setText("What is HSLF?");
box1.setAnchor(new Rectangle(36, 21, 648, 90));
- slide.addShape(box1);
- HSLFTextBox box2 = new HSLFTextBox();
- box2.setRunType(TextHeaderAtom.BODY_TYPE);
+ TextBox<?,?> box2 = slide.createTextBox();
+ box2.setTextPlaceholder(TextPlaceholder.BODY);
box2.setText("HorribleSLideshowFormat is the POI Project's pure Java implementation " +
"of the Powerpoint binary file format. \r" +
"POI sub-project since 2005\r" +
- "Started by Nick Birch, Yegor Kozlov joined soon after");
+ "Started by Nick Burch, Yegor Kozlov joined soon after");
box2.setAnchor(new Rectangle(36, 126, 648, 356));
- slide.addShape(box2);
-
-
}
- public static void slide3(HSLFSlideShow ppt) throws IOException {
- HSLFSlide slide = ppt.createSlide();
+ public static void slide3(SlideShow<?,?> ppt) throws IOException {
+ Slide<?,?> slide = ppt.createSlide();
- HSLFTextBox box1 = new HSLFTextBox();
- box1.setRunType(TextHeaderAtom.TITLE_TYPE);
+ TextBox<?,?> box1 = slide.createTextBox();
+ box1.setTextPlaceholder(TextPlaceholder.TITLE);
box1.setText("HSLF in a Nutshell");
box1.setAnchor(new Rectangle(36, 15, 648, 65));
- slide.addShape(box1);
- HSLFTextBox box2 = new HSLFTextBox();
- box2.setRunType(TextHeaderAtom.BODY_TYPE);
+ TextBox<?,?> box2 = slide.createTextBox();
+ box2.setTextPlaceholder(TextPlaceholder.BODY);
box2.setText(
"HSLF provides a way to read, create and modify MS PowerPoint presentations\r" +
"Pure Java API - you don't need PowerPoint to read and write *.ppt files\r" +
@@ -140,7 +135,7 @@ public final class ApacheconEU08 {
"Access to low level data structures"
);
- List<HSLFTextParagraph> tp = box2.getTextParagraphs();
+ List<? extends TextParagraph<?,?,?>> tp = box2.getTextParagraphs();
for (int i : new byte[]{0,1,2,8}) {
tp.get(i).getTextRuns().get(0).setFontSize(28d);
}
@@ -149,102 +144,88 @@ public final class ApacheconEU08 {
tp.get(i).setIndentLevel(1);
}
box2.setAnchor(new Rectangle(36, 80, 648, 400));
- slide.addShape(box2);
}
- public static void slide4(HSLFSlideShow ppt) throws IOException {
- HSLFSlide slide = ppt.createSlide();
+ public static void slide4(SlideShow<?,?> ppt) throws IOException {
+ Slide<?,?> slide = ppt.createSlide();
String[][] txt1 = {
{"Note"},
{"This presentation was created programmatically using POI HSLF"}
};
- HSLFTable table1 = new HSLFTable(2, 1);
+ TableShape<?,?> table1 = slide.createTable(2, 1);
for (int i = 0; i < txt1.length; i++) {
for (int j = 0; j < txt1[i].length; j++) {
- HSLFTableCell cell = table1.getCell(i, j);
+ TableCell<?,?> cell = table1.getCell(i, j);
cell.setText(txt1[i][j]);
- HSLFTextRun rt = cell.getTextParagraphs().get(0).getTextRuns().get(0);
+ TextRun rt = cell.getTextParagraphs().get(0).getTextRuns().get(0);
rt.setFontSize(10d);
rt.setFontFamily("Arial");
rt.setBold(true);
if(i == 0){
rt.setFontSize(32d);
rt.setFontColor(Color.white);
- cell.getFill().setForegroundColor(new Color(0, 153, 204));
+ cell.setFillColor(new Color(0, 153, 204));
} else {
rt.setFontSize(28d);
- cell.getFill().setForegroundColor(new Color(235, 239, 241));
+ cell.setFillColor(new Color(235, 239, 241));
}
cell.setVerticalAlignment(VerticalAlignment.MIDDLE);
}
}
- HSLFLine border1 = table1.createBorder();
- border1.setLineColor(Color.black);
- border1.setLineWidth(1.0);
- table1.setAllBorders(border1);
-
- HSLFLine border2 = table1.createBorder();
- border2.setLineColor(Color.black);
- border2.setLineWidth(2.0);
- table1.setOutsideBorders(border2);
-
- table1.setColumnWidth(0, 510);
- table1.setRowHeight(0, 60);
- table1.setRowHeight(1, 100);
- slide.addShape(table1);
-
- table1.moveTo(100, 100);
+ DrawTableShape dts = new DrawTableShape(table1);
+ dts.setAllBorders(1.0, Color.black);
+ dts.setOutsideBorders(4.0);
+
+ table1.setColumnWidth(0, 450);
+ table1.setRowHeight(0, 50);
+ table1.setRowHeight(1, 80);
+
+ Dimension dim = ppt.getPageSize();
+ Rectangle oldAnchor = table1.getAnchor();
+ table1.setAnchor(new Rectangle((dim.width-450)/2, 100, oldAnchor.width, oldAnchor.height));
- HSLFTextBox box1 = new HSLFTextBox();
+ TextBox<?,?> box1 = slide.createTextBox();
box1.setHorizontalCentered(true);
box1.getTextParagraphs().get(0).getTextRuns().get(0).setFontSize(24d);
box1.setText("The source code is available at\r" +
"http://people.apache.org/~yegor/apachecon_eu08/");
box1.setAnchor(new Rectangle(80, 356, 553, 65));
- slide.addShape(box1);
-
}
- public static void slide5(HSLFSlideShow ppt) throws IOException {
- HSLFSlide slide = ppt.createSlide();
+ public static void slide5(SlideShow<?,?> ppt) throws IOException {
+ Slide<?,?> slide = ppt.createSlide();
- HSLFTextBox box1 = new HSLFTextBox();
- box1.setRunType(TextHeaderAtom.TITLE_TYPE);
+ TextBox<?,?> box1 = slide.createTextBox();
+ box1.setTextPlaceholder(TextPlaceholder.TITLE);
box1.setText("HSLF in Action - 1\rData Extraction");
box1.setAnchor(new Rectangle(36, 21, 648, 100));
- slide.addShape(box1);
- HSLFTextBox box2 = new HSLFTextBox();
- box2.setRunType(TextHeaderAtom.BODY_TYPE);
+ TextBox<?,?> box2 = slide.createTextBox();
+ box2.setTextPlaceholder(TextPlaceholder.BODY);
box2.setText(
"Text from slides and notes\r" +
"Images\r" +
"Shapes and their properties (type, position in the slide, color, font, etc.)");
box2.setAnchor(new Rectangle(36, 150, 648, 300));
- slide.addShape(box2);
-
-
}
- public static void slide6(HSLFSlideShow ppt) throws IOException {
- HSLFSlide slide = ppt.createSlide();
+ public static void slide6(SlideShow<?,?> ppt) throws IOException {
+ Slide<?,?> slide = ppt.createSlide();
- HSLFTextBox box1 = new HSLFTextBox();
- box1.setRunType(TextHeaderAtom.TITLE_TYPE);
+ TextBox<?,?> box1 = slide.createTextBox();
+ box1.setTextPlaceholder(TextPlaceholder.TITLE);
box1.setText("HSLF in Action - 2");
box1.setAnchor(new Rectangle(36, 20, 648, 90));
- slide.addShape(box1);
- HSLFTextBox box2 = new HSLFTextBox();
+ TextBox<?,?> box2 = slide.createTextBox();
box2.getTextParagraphs().get(0).getTextRuns().get(0).setFontSize(18d);
box2.setText("Creating a simple presentation from scratch");
box2.setAnchor(new Rectangle(170, 100, 364, 30));
- slide.addShape(box2);
- HSLFTextBox box3 = new HSLFTextBox();
- HSLFTextRun rt3 = box3.getTextParagraphs().get(0).getTextRuns().get(0);
+ TextBox<?,?> box3 = slide.createTextBox();
+ TextRun rt3 = box3.getTextParagraphs().get(0).getTextRuns().get(0);
rt3.setFontFamily("Courier New");
rt3.setFontSize(8d);
box3.setText(
@@ -283,77 +264,67 @@ public final class ApacheconEU08 {
"out.close();");
box3.setAnchor(new Rectangle(30, 150, 618, 411));
box3.setHorizontalCentered(true);
- slide.addShape(box3);
}
- public static void slide7(HSLFSlideShow ppt) throws IOException {
- HSLFSlide slide = ppt.createSlide();
+ public static void slide7(SlideShow<?,?> ppt) throws IOException {
+ Slide<?,?> slide = ppt.createSlide();
- HSLFTextBox box2 = new HSLFTextBox();
+ TextBox<?,?> box2 = slide.createTextBox();
box2.setHorizontalCentered(true);
box2.setVerticalAlignment(VerticalAlignment.MIDDLE);
box2.setText("Java Code");
- box2.getFill().setForegroundColor(new Color(187, 224, 227));
- box2.setLineColor(Color.black);
- box2.setLineWidth(0.75);
+ box2.setFillColor(new Color(187, 224, 227));
+ box2.setStrokeStyle(0.75, Color.black);
box2.setAnchor(new Rectangle(66, 243, 170, 170));
- slide.addShape(box2);
- HSLFTextBox box3 = new HSLFTextBox();
+ TextBox<?,?> box3 = slide.createTextBox();
box3.setHorizontalCentered(true);
box3.setVerticalAlignment(VerticalAlignment.MIDDLE);
box3.setText("*.ppt file");
- box3.setLineWidth(0.75);
- box3.setLineColor(Color.black);
- box3.getFill().setForegroundColor(new Color(187, 224, 227));
+ box3.setFillColor(new Color(187, 224, 227));
+ box3.setStrokeStyle(0.75, Color.black);
box3.setAnchor(new Rectangle(473, 243, 170, 170));
- slide.addShape(box3);
- HSLFAutoShape box4 = new HSLFAutoShape(ShapeType.RIGHT_ARROW);
- box4.getFill().setForegroundColor(new Color(187, 224, 227));
- box4.setLineWidth(0.75);
- box4.setLineColor(Color.black);
+ AutoShape<?,?> box4 = slide.createAutoShape();
+ box4.setShapeType(ShapeType.RIGHT_ARROW);
+ box4.setFillColor(new Color(187, 224, 227));
+ box4.setStrokeStyle(0.75, Color.black);
box4.setAnchor(new Rectangle(253, 288, 198, 85));
- slide.addShape(box4);
}
- public static void slide8(HSLFSlideShow ppt) throws IOException {
- HSLFSlide slide = ppt.createSlide();
+ public static void slide8(SlideShow<?,?> ppt) throws IOException {
+ Slide<?,?> slide = ppt.createSlide();
- HSLFTextBox box1 = new HSLFTextBox();
- box1.setRunType(TextHeaderAtom.TITLE_TYPE);
+ TextBox<?,?> box1 = slide.createTextBox();
+ box1.setTextPlaceholder(TextPlaceholder.TITLE);
box1.setText("Wait, there is more!");
box1.setAnchor(new Rectangle(36, 21, 648, 90));
- slide.addShape(box1);
- HSLFTextBox box2 = new HSLFTextBox();
- box2.setRunType(TextHeaderAtom.BODY_TYPE);
+ TextBox<?,?> box2 = slide.createTextBox();
+ box2.setTextPlaceholder(TextPlaceholder.BODY);
box2.setText(
"Rich text\r" +
"Tables\r" +
"Pictures (JPEG, PNG, BMP, WMF, PICT)\r" +
"Comprehensive formatting features");
box2.setAnchor(new Rectangle(36, 126, 648, 356));
- slide.addShape(box2);
}
- public static void slide9(HSLFSlideShow ppt) throws IOException {
- HSLFSlide slide = ppt.createSlide();
+ public static void slide9(SlideShow<?,?> ppt) throws IOException {
+ Slide<?,?> slide = ppt.createSlide();
- HSLFTextBox box1 = new HSLFTextBox();
- box1.setRunType(TextHeaderAtom.TITLE_TYPE);
+ TextBox<?,?> box1 = slide.createTextBox();
+ box1.setTextPlaceholder(TextPlaceholder.TITLE);
box1.setText("HSLF in Action - 3");
box1.setAnchor(new Rectangle(36, 20, 648, 50));
- slide.addShape(box1);
- HSLFTextBox box2 = new HSLFTextBox();
+ TextBox<?,?> box2 = slide.createTextBox();
box2.getTextParagraphs().get(0).getTextRuns().get(0).setFontSize(18d);
box2.setText("PPGraphics2D: PowerPoint Graphics2D driver");
box2.setAnchor(new Rectangle(178, 70, 387, 30));
- slide.addShape(box2);
- HSLFTextBox box3 = new HSLFTextBox();
- HSLFTextRun rt3 = box3.getTextParagraphs().get(0).getTextRuns().get(0);
+ TextBox<?,?> box3 = slide.createTextBox();
+ TextRun rt3 = box3.getTextParagraphs().get(0).getTextRuns().get(0);
rt3.setFontFamily("Courier New");
rt3.setFontSize(8d);
box3.setText(
@@ -397,10 +368,9 @@ public final class ApacheconEU08 {
"out.close();");
box3.setAnchor(new Rectangle(96, 110, 499, 378));
box3.setHorizontalCentered(true);
- slide.addShape(box3);
}
- public static void slide10(HSLFSlideShow ppt) throws IOException {
+ public static void slide10(SlideShow<?,?> ppt) throws IOException {
//bar chart data. The first value is the bar color, the second is the width
Object[] def = new Object[]{
Color.yellow, new Integer(100),
@@ -409,14 +379,13 @@ public final class ApacheconEU08 {
Color.red, new Integer(200),
};
- HSLFSlide slide = ppt.createSlide();
+ Slide<?,?> slide = ppt.createSlide();
- HSLFGroupShape group = new HSLFGroupShape();
+ GroupShape<?,?> group = slide.createGroup();
//define position of the drawing in the slide
Rectangle bounds = new java.awt.Rectangle(200, 100, 350, 300);
group.setAnchor(bounds);
- slide.addShape(group);
- Graphics2D graphics = new PPGraphics2D(group);
+ Graphics2D graphics = new SLGraphics(group);
//draw a simple bar graph
int x = bounds.x + 50, y = bounds.y + 50;
@@ -437,17 +406,16 @@ public final class ApacheconEU08 {
}
- public static void slide11(HSLFSlideShow ppt) throws IOException {
- HSLFSlide slide = ppt.createSlide();
+ public static void slide11(SlideShow<?,?> ppt) throws IOException {
+ Slide<?,?> slide = ppt.createSlide();
- HSLFTextBox box1 = new HSLFTextBox();
- box1.setRunType(TextHeaderAtom.TITLE_TYPE);
+ TextBox<?,?> box1 = slide.createTextBox();
+ box1.setTextPlaceholder(TextPlaceholder.TITLE);
box1.setText("HSLF Development Plans");
box1.setAnchor(new Rectangle(36, 21, 648, 90));
- slide.addShape(box1);
- HSLFTextBox box2 = new HSLFTextBox();
- box2.setRunType(TextHeaderAtom.BODY_TYPE);
+ TextBox<?,?> box2 = slide.createTextBox();
+ box2.setTextPlaceholder(TextPlaceholder.BODY);
box2.setText(
"Support for more PowerPoint functionality\r" +
"Rendering slides into java.awt.Graphics2D\r" +
@@ -457,7 +425,7 @@ public final class ApacheconEU08 {
"PPT2PDF transcoder"
);
- List<HSLFTextParagraph> tp = box2.getTextParagraphs();
+ List<? extends TextParagraph<?,?,?>> tp = box2.getTextParagraphs();
for (int i : new byte[]{0,1,3}) {
tp.get(i).getTextRuns().get(0).setFontSize(28d);
}
@@ -467,24 +435,21 @@ public final class ApacheconEU08 {
}
box2.setAnchor(new Rectangle(36, 126, 648, 400));
- slide.addShape(box2);
}
- public static void slide12(HSLFSlideShow ppt) throws IOException {
- HSLFSlide slide = ppt.createSlide();
+ public static void slide12(SlideShow<?,?> ppt) throws IOException {
+ Slide<?,?> slide = ppt.createSlide();
- HSLFTextBox box1 = new HSLFTextBox();
- box1.setRunType(TextHeaderAtom.CENTER_TITLE_TYPE);
+ TextBox<?,?> box1 = slide.createTextBox();
+ box1.setTextPlaceholder(TextPlaceholder.CENTER_TITLE);
box1.setText("Questions?");
box1.setAnchor(new Rectangle(54, 167, 612, 115));
- slide.addShape(box1);
- HSLFTextBox box2 = new HSLFTextBox();
- box2.setRunType(TextHeaderAtom.CENTRE_BODY_TYPE);
+ TextBox<?,?> box2 = slide.createTextBox();
+ box2.setTextPlaceholder(TextPlaceholder.CENTER_BODY);
box2.setText(
"http://poi.apache.org/hslf/\r" +
"http://people.apache.org/~yegor");
box2.setAnchor(new Rectangle(108, 306, 504, 138));
- slide.addShape(box2);
}
}
Modified: poi/trunk/src/examples/src/org/apache/poi/hslf/examples/TableDemo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/hslf/examples/TableDemo.java?rev=1711171&r1=1711170&r2=1711171&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/hslf/examples/TableDemo.java (original)
+++ poi/trunk/src/examples/src/org/apache/poi/hslf/examples/TableDemo.java Thu Oct 29 01:05:27 2015
@@ -25,7 +25,7 @@ import org.apache.poi.hslf.usermodel.HSL
import org.apache.poi.hslf.usermodel.HSLFTable;
import org.apache.poi.hslf.usermodel.HSLFTableCell;
import org.apache.poi.hslf.usermodel.HSLFTextRun;
-import org.apache.poi.hslf.usermodel.HSLFLine;
+import org.apache.poi.sl.draw.DrawTableShape;
import org.apache.poi.sl.usermodel.TextParagraph.TextAlign;
import org.apache.poi.sl.usermodel.VerticalAlignment;
@@ -53,7 +53,7 @@ public final class TableDemo {
HSLFSlide slide = ppt.createSlide();
//six rows, two columns
- HSLFTable table1 = new HSLFTable(6, 2);
+ HSLFTable table1 = slide.createTable(6, 2);
for (int i = 0; i < txt1.length; i++) {
for (int j = 0; j < txt1[i].length; j++) {
HSLFTableCell cell = table1.getCell(i, j);
@@ -71,15 +71,12 @@ public final class TableDemo {
}
}
- HSLFLine border1 = table1.createBorder();
- border1.setLineColor(Color.black);
- border1.setLineWidth(1.0);
- table1.setAllBorders(border1);
+ DrawTableShape dts1 = new DrawTableShape(table1);
+ dts1.setAllBorders(1.0, Color.black);
table1.setColumnWidth(0, 300);
table1.setColumnWidth(1, 150);
- slide.addShape(table1);
int pgWidth = ppt.getPageSize().width;
table1.moveTo((pgWidth - table1.getAnchor().width)/2, 100);
@@ -92,7 +89,7 @@ public final class TableDemo {
};
//two rows, one column
- HSLFTable table2 = new HSLFTable(2, 1);
+ HSLFTable table2 = slide.createTable(2, 1);
for (int i = 0; i < txt2.length; i++) {
for (int j = 0; j < txt2[i].length; j++) {
HSLFTableCell cell = table2.getCell(i, j);
@@ -119,10 +116,9 @@ public final class TableDemo {
table2.setRowHeight(0, 30);
table2.setRowHeight(1, 70);
- HSLFLine border2 = table2.createBorder();
- table2.setOutsideBorders(border2);
+ DrawTableShape dts2 = new DrawTableShape(table2);
+ dts2.setOutsideBorders(Color.black, 1.0);
- slide.addShape(table2);
table2.moveTo(200, 400);
FileOutputStream out = new FileOutputStream("hslf-table.ppt");
Modified: poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial3.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial3.java?rev=1711171&r1=1711170&r2=1711171&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial3.java (original)
+++ poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial3.java Thu Oct 29 01:05:27 2015
@@ -23,6 +23,8 @@ import java.awt.Rectangle;
import java.io.FileOutputStream;
import java.io.IOException;
+import org.apache.poi.sl.usermodel.SimpleShape.Placeholder;
+
/**
* How to set slide title
*
Modified: poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial4.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial4.java?rev=1711171&r1=1711170&r2=1711171&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial4.java (original)
+++ poi/trunk/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial4.java Thu Oct 29 01:05:27 2015
@@ -24,6 +24,7 @@ import java.awt.Rectangle;
import java.io.FileOutputStream;
import java.io.IOException;
+import org.apache.poi.sl.usermodel.TableCell.BorderEdge;
import org.apache.poi.sl.usermodel.TextParagraph.TextAlign;
/**
@@ -56,8 +57,8 @@ public class Tutorial4 {
r.setBold(true);
r.setFontColor(Color.white);
th.setFillColor(new Color(79, 129, 189));
- th.setBorderBottom(2);
- th.setBorderBottomColor(Color.white);
+ th.setBorderWidth(BorderEdge.bottom, 2.0);
+ th.setBorderColor(BorderEdge.bottom, Color.white);
tbl.setColumnWidth(i, 150); // all columns are equally sized
}
Modified: poi/trunk/src/java/org/apache/poi/sl/draw/DrawTableShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/draw/DrawTableShape.java?rev=1711171&r1=1711170&r2=1711171&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/draw/DrawTableShape.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/draw/DrawTableShape.java Thu Oct 29 01:05:27 2015
@@ -17,9 +17,15 @@
package org.apache.poi.sl.draw;
+import java.awt.Color;
import java.awt.Graphics2D;
import org.apache.poi.sl.usermodel.GroupShape;
+import org.apache.poi.sl.usermodel.StrokeStyle;
+import org.apache.poi.sl.usermodel.StrokeStyle.LineCompound;
+import org.apache.poi.sl.usermodel.StrokeStyle.LineDash;
+import org.apache.poi.sl.usermodel.TableCell;
+import org.apache.poi.sl.usermodel.TableCell.BorderEdge;
import org.apache.poi.sl.usermodel.TableShape;
public class DrawTableShape extends DrawShape {
@@ -57,5 +63,111 @@ public class DrawTableShape extends Draw
}
}
+ @Override
+ protected TableShape<?,?> getShape() {
+ return (TableShape<?,?>)shape;
+ }
+
+ /**
+ * Format the table and apply the specified Line to all cell boundaries,
+ * both outside and inside.
+ * An empty args parameter removes the affected border.
+ *
+ * @param args a varargs array possible containing {@link Double} (width),
+ * {@link StrokeStyle.LineCompound}, {@link Color}, {@link StrokeStyle.LineDash}
+ */
+ public void setAllBorders(Object... args) {
+ TableShape<?,?> table = getShape();
+ final int rows = table.getNumberOfRows();
+ final int cols = table.getNumberOfColumns();
+
+ BorderEdge edges[] = { BorderEdge.top, BorderEdge.left, null, null };
+ for (int row = 0; row < rows; row++) {
+ for (int col = 0; col < cols; col++) {
+ edges[2] = (col == cols - 1) ? BorderEdge.right : null;
+ edges[3] = (row == rows - 1) ? BorderEdge.bottom : null;
+ setEdges(table.getCell(row, col), edges, args);
+ }
+ }
+ }
+
+ /**
+ * Format the outside border using the specified Line object
+ * An empty args parameter removes the affected border.
+ *
+ * @param args a varargs array possible containing {@link Double} (width),
+ * {@link StrokeStyle.LineCompound}, {@link Color}, {@link StrokeStyle.LineDash}
+ */
+ public void setOutsideBorders(Object... args){
+ if (args.length == 0) return;
+
+ TableShape<?,?> table = getShape();
+ final int rows = table.getNumberOfRows();
+ final int cols = table.getNumberOfColumns();
+
+ BorderEdge edges[] = new BorderEdge[4];
+ for (int row = 0; row < rows; row++) {
+ for (int col = 0; col < cols; col++) {
+ edges[0] = (col == 0) ? BorderEdge.left : null;
+ edges[1] = (col == cols - 1) ? BorderEdge.right : null;
+ edges[2] = (row == 0) ? BorderEdge.top : null;
+ edges[3] = (row == rows - 1) ? BorderEdge.bottom : null;
+ setEdges(table.getCell(row, col), edges, args);
+ }
+ }
+ }
+
+ /**
+ * Format the inside border using the specified Line object
+ * An empty args parameter removes the affected border.
+ *
+ * @param args a varargs array possible containing {@link Double} (width),
+ * {@link StrokeStyle.LineCompound}, {@link Color}, {@link StrokeStyle.LineDash}
+ */
+ public void setInsideBorders(Object... args) {
+ if (args.length == 0) return;
+
+ TableShape<?,?> table = getShape();
+ final int rows = table.getNumberOfRows();
+ final int cols = table.getNumberOfColumns();
+
+ BorderEdge edges[] = new BorderEdge[2];
+ for (int row = 0; row < rows; row++) {
+ for (int col = 0; col < cols; col++) {
+ edges[0] = (col > 0 && col < cols - 1) ? BorderEdge.right : null;
+ edges[1] = (row > 0 && row < rows - 1) ? BorderEdge.bottom : null;
+ setEdges(table.getCell(row, col), edges, args);
+ }
+ }
+ }
+
+ /**
+ * Apply the border attributes (args) to the given cell and edges
+ *
+ * @param cell the cell
+ * @param edges the border edges
+ * @param args the border attributes
+ */
+ private static void setEdges(TableCell<?,?> cell, BorderEdge edges[], Object... args) {
+ for (BorderEdge be : edges) {
+ if (be != null) {
+ if (args.length == 0) {
+ cell.removeBorder(be);
+ } else {
+ for (Object o : args) {
+ if (o instanceof Double) {
+ cell.setBorderWidth(be, (Double)o);
+ } else if (o instanceof Color) {
+ cell.setBorderColor(be, (Color)o);
+ } else if (o instanceof LineDash) {
+ cell.setBorderDash(be, (LineDash)o);
+ } else if (o instanceof LineCompound) {
+ cell.setBorderCompound(be, (LineCompound)o);
+ }
+ }
+ }
+ }
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org