Snapshot commit - still lots of errors, xslf rendering works, started work on hslf
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/common_sl@1667902 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a0070048fe
commit
652211b8d2
@ -34,7 +34,7 @@ import java.awt.*;
|
||||
public final class ApacheconEU08 {
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
SlideShow ppt = new SlideShow();
|
||||
HSLFSlideShow ppt = new HSLFSlideShow();
|
||||
ppt.setPageSize(new Dimension(720, 540));
|
||||
|
||||
slide1(ppt);
|
||||
@ -56,27 +56,27 @@ public final class ApacheconEU08 {
|
||||
|
||||
}
|
||||
|
||||
public static void slide1(SlideShow ppt) throws IOException {
|
||||
Slide slide = ppt.createSlide();
|
||||
public static void slide1(HSLFSlideShow ppt) throws IOException {
|
||||
HSLFSlide slide = ppt.createSlide();
|
||||
|
||||
TextBox box1 = new TextBox();
|
||||
TextRun tr1 = box1.getTextRun();
|
||||
HSLFTextBox box1 = new HSLFTextBox();
|
||||
HSLFTextParagraph tr1 = box1.getTextParagraph();
|
||||
tr1.setRunType(TextHeaderAtom.CENTER_TITLE_TYPE);
|
||||
tr1.setText("POI-HSLF");
|
||||
box1.setAnchor(new Rectangle(54, 78, 612, 115));
|
||||
slide.addShape(box1);
|
||||
|
||||
TextBox box2 = new TextBox();
|
||||
TextRun tr2 = box2.getTextRun();
|
||||
HSLFTextBox box2 = new HSLFTextBox();
|
||||
HSLFTextParagraph tr2 = box2.getTextParagraph();
|
||||
tr2.setRunType(TextHeaderAtom.CENTRE_BODY_TYPE);
|
||||
tr2.setText("Java API To Access Microsoft PowerPoint Format Files");
|
||||
box2.setAnchor(new Rectangle(108, 204, 504, 138));
|
||||
slide.addShape(box2);
|
||||
|
||||
TextBox box3 = new TextBox();
|
||||
TextRun tr3 = box3.getTextRun();
|
||||
HSLFTextBox box3 = new HSLFTextBox();
|
||||
HSLFTextParagraph tr3 = box3.getTextParagraph();
|
||||
tr3.getRichTextRuns()[0].setFontSize(32);
|
||||
box3.setHorizontalAlignment(TextBox.AlignCenter);
|
||||
box3.setHorizontalAlignment(HSLFTextBox.AlignCenter);
|
||||
tr3.setText(
|
||||
"Yegor Kozlov\r" +
|
||||
"yegor - apache - org");
|
||||
@ -84,18 +84,18 @@ public final class ApacheconEU08 {
|
||||
slide.addShape(box3);
|
||||
}
|
||||
|
||||
public static void slide2(SlideShow ppt) throws IOException {
|
||||
Slide slide = ppt.createSlide();
|
||||
public static void slide2(HSLFSlideShow ppt) throws IOException {
|
||||
HSLFSlide slide = ppt.createSlide();
|
||||
|
||||
TextBox box1 = new TextBox();
|
||||
TextRun tr1 = box1.getTextRun();
|
||||
HSLFTextBox box1 = new HSLFTextBox();
|
||||
HSLFTextParagraph tr1 = box1.getTextParagraph();
|
||||
tr1.setRunType(TextHeaderAtom.TITLE_TYPE);
|
||||
tr1.setText("What is HSLF?");
|
||||
box1.setAnchor(new Rectangle(36, 21, 648, 90));
|
||||
slide.addShape(box1);
|
||||
|
||||
TextBox box2 = new TextBox();
|
||||
TextRun tr2 = box2.getTextRun();
|
||||
HSLFTextBox box2 = new HSLFTextBox();
|
||||
HSLFTextParagraph tr2 = box2.getTextParagraph();
|
||||
tr2.setRunType(TextHeaderAtom.BODY_TYPE);
|
||||
tr2.setText("HorribleSLideshowFormat is the POI Project's pure Java implementation " +
|
||||
"of the Powerpoint binary file format. \r" +
|
||||
@ -107,18 +107,18 @@ public final class ApacheconEU08 {
|
||||
|
||||
}
|
||||
|
||||
public static void slide3(SlideShow ppt) throws IOException {
|
||||
Slide slide = ppt.createSlide();
|
||||
public static void slide3(HSLFSlideShow ppt) throws IOException {
|
||||
HSLFSlide slide = ppt.createSlide();
|
||||
|
||||
TextBox box1 = new TextBox();
|
||||
TextRun tr1 = box1.getTextRun();
|
||||
HSLFTextBox box1 = new HSLFTextBox();
|
||||
HSLFTextParagraph tr1 = box1.getTextParagraph();
|
||||
tr1.setRunType(TextHeaderAtom.TITLE_TYPE);
|
||||
tr1.setText("HSLF in a Nutshell");
|
||||
box1.setAnchor(new Rectangle(36, 15, 648, 65));
|
||||
slide.addShape(box1);
|
||||
|
||||
TextBox box2 = new TextBox();
|
||||
TextRun tr2 = box2.getTextRun();
|
||||
HSLFTextBox box2 = new HSLFTextBox();
|
||||
HSLFTextParagraph tr2 = box2.getTextParagraph();
|
||||
tr2.setRunType(TextHeaderAtom.BODY_TYPE);
|
||||
tr2.setText(
|
||||
"HSLF provides a way to read, create and modify MS PowerPoint presentations\r" +
|
||||
@ -128,8 +128,8 @@ public final class ApacheconEU08 {
|
||||
box2.setAnchor(new Rectangle(36, 80, 648, 200));
|
||||
slide.addShape(box2);
|
||||
|
||||
TextBox box3 = new TextBox();
|
||||
TextRun tr3 = box3.getTextRun();
|
||||
HSLFTextBox box3 = new HSLFTextBox();
|
||||
HSLFTextParagraph tr3 = box3.getTextParagraph();
|
||||
tr3.setRunType(TextHeaderAtom.BODY_TYPE);
|
||||
tr3.setText(
|
||||
"Rich text\r" +
|
||||
@ -142,16 +142,16 @@ public final class ApacheconEU08 {
|
||||
box3.setAnchor(new Rectangle(36, 265, 648, 150));
|
||||
slide.addShape(box3);
|
||||
|
||||
TextBox box4 = new TextBox();
|
||||
TextRun tr4 = box4.getTextRun();
|
||||
HSLFTextBox box4 = new HSLFTextBox();
|
||||
HSLFTextParagraph tr4 = box4.getTextParagraph();
|
||||
tr4.setRunType(TextHeaderAtom.BODY_TYPE);
|
||||
tr4.setText("Access to low level data structures");
|
||||
box4.setAnchor(new Rectangle(36, 430, 648, 50));
|
||||
slide.addShape(box4);
|
||||
}
|
||||
|
||||
public static void slide4(SlideShow ppt) throws IOException {
|
||||
Slide slide = ppt.createSlide();
|
||||
public static void slide4(HSLFSlideShow ppt) throws IOException {
|
||||
HSLFSlide slide = ppt.createSlide();
|
||||
|
||||
String[][] txt1 = {
|
||||
{"Note"},
|
||||
@ -162,8 +162,8 @@ public final class ApacheconEU08 {
|
||||
for (int j = 0; j < txt1[i].length; j++) {
|
||||
TableCell cell = table1.getCell(i, j);
|
||||
cell.setText(txt1[i][j]);
|
||||
cell.getTextRun().getRichTextRuns()[0].setFontSize(10);
|
||||
RichTextRun rt = cell.getTextRun().getRichTextRuns()[0];
|
||||
cell.getTextParagraph().getRichTextRuns()[0].setFontSize(10);
|
||||
HSLFTextRun rt = cell.getTextParagraph().getRichTextRuns()[0];
|
||||
rt.setFontName("Arial");
|
||||
rt.setBold(true);
|
||||
if(i == 0){
|
||||
@ -174,7 +174,7 @@ public final class ApacheconEU08 {
|
||||
rt.setFontSize(28);
|
||||
cell.getFill().setForegroundColor(new Color(235, 239, 241));
|
||||
}
|
||||
cell.setVerticalAlignment(TextBox.AnchorMiddle);
|
||||
cell.setVerticalAlignment(HSLFTextBox.AnchorMiddle);
|
||||
}
|
||||
}
|
||||
|
||||
@ -195,30 +195,30 @@ public final class ApacheconEU08 {
|
||||
|
||||
table1.moveTo(100, 100);
|
||||
|
||||
TextBox box1 = new TextBox();
|
||||
box1.setHorizontalAlignment(TextBox.AlignCenter);
|
||||
TextRun tr1 = box1.getTextRun();
|
||||
HSLFTextBox box1 = new HSLFTextBox();
|
||||
box1.setHorizontalAlignment(HSLFTextBox.AlignCenter);
|
||||
HSLFTextParagraph tr1 = box1.getTextParagraph();
|
||||
tr1.setText("The source code is available at\r" +
|
||||
"http://people.apache.org/~yegor/apachecon_eu08/");
|
||||
RichTextRun rt = tr1.getRichTextRuns()[0];
|
||||
HSLFTextRun rt = tr1.getRichTextRuns()[0];
|
||||
rt.setFontSize(24);
|
||||
box1.setAnchor(new Rectangle(80, 356, 553, 65));
|
||||
slide.addShape(box1);
|
||||
|
||||
}
|
||||
|
||||
public static void slide5(SlideShow ppt) throws IOException {
|
||||
Slide slide = ppt.createSlide();
|
||||
public static void slide5(HSLFSlideShow ppt) throws IOException {
|
||||
HSLFSlide slide = ppt.createSlide();
|
||||
|
||||
TextBox box1 = new TextBox();
|
||||
TextRun tr1 = box1.getTextRun();
|
||||
HSLFTextBox box1 = new HSLFTextBox();
|
||||
HSLFTextParagraph tr1 = box1.getTextParagraph();
|
||||
tr1.setRunType(TextHeaderAtom.TITLE_TYPE);
|
||||
tr1.setText("HSLF in Action - 1\rData Extraction");
|
||||
box1.setAnchor(new Rectangle(36, 21, 648, 100));
|
||||
slide.addShape(box1);
|
||||
|
||||
TextBox box2 = new TextBox();
|
||||
TextRun tr2 = box2.getTextRun();
|
||||
HSLFTextBox box2 = new HSLFTextBox();
|
||||
HSLFTextParagraph tr2 = box2.getTextParagraph();
|
||||
tr2.setRunType(TextHeaderAtom.BODY_TYPE);
|
||||
tr2.setText(
|
||||
"Text from slides and notes\r" +
|
||||
@ -230,26 +230,26 @@ public final class ApacheconEU08 {
|
||||
|
||||
}
|
||||
|
||||
public static void slide6(SlideShow ppt) throws IOException {
|
||||
Slide slide = ppt.createSlide();
|
||||
public static void slide6(HSLFSlideShow ppt) throws IOException {
|
||||
HSLFSlide slide = ppt.createSlide();
|
||||
|
||||
TextBox box1 = new TextBox();
|
||||
TextRun tr1 = box1.getTextRun();
|
||||
HSLFTextBox box1 = new HSLFTextBox();
|
||||
HSLFTextParagraph tr1 = box1.getTextParagraph();
|
||||
tr1.setRunType(TextHeaderAtom.TITLE_TYPE);
|
||||
tr1.setText("HSLF in Action - 2");
|
||||
box1.setAnchor(new Rectangle(36, 20, 648, 90));
|
||||
slide.addShape(box1);
|
||||
|
||||
TextBox box2 = new TextBox();
|
||||
TextRun tr2 = box2.getTextRun();
|
||||
HSLFTextBox box2 = new HSLFTextBox();
|
||||
HSLFTextParagraph tr2 = box2.getTextParagraph();
|
||||
tr2.getRichTextRuns()[0].setFontSize(18);
|
||||
tr2.setText("Creating a simple presentation from scratch");
|
||||
box2.setAnchor(new Rectangle(170, 100, 364, 30));
|
||||
slide.addShape(box2);
|
||||
|
||||
TextBox box3 = new TextBox();
|
||||
TextRun tr3 = box3.getTextRun();
|
||||
RichTextRun rt3 = tr3.getRichTextRuns()[0];
|
||||
HSLFTextBox box3 = new HSLFTextBox();
|
||||
HSLFTextParagraph tr3 = box3.getTextParagraph();
|
||||
HSLFTextRun rt3 = tr3.getRichTextRuns()[0];
|
||||
rt3.setFontName("Courier New");
|
||||
rt3.setFontSize(8);
|
||||
tr3.setText(
|
||||
@ -290,30 +290,30 @@ public final class ApacheconEU08 {
|
||||
slide.addShape(box3);
|
||||
}
|
||||
|
||||
public static void slide7(SlideShow ppt) throws IOException {
|
||||
Slide slide = ppt.createSlide();
|
||||
public static void slide7(HSLFSlideShow ppt) throws IOException {
|
||||
HSLFSlide slide = ppt.createSlide();
|
||||
|
||||
TextBox box2 = new TextBox();
|
||||
box2.setHorizontalAlignment(TextBox.AlignCenter);
|
||||
box2.setVerticalAlignment(TextBox.AnchorMiddle);
|
||||
box2.getTextRun().setText("Java Code");
|
||||
HSLFTextBox box2 = new HSLFTextBox();
|
||||
box2.setHorizontalAlignment(HSLFTextBox.AlignCenter);
|
||||
box2.setVerticalAlignment(HSLFTextBox.AnchorMiddle);
|
||||
box2.getTextParagraph().setText("Java Code");
|
||||
box2.getFill().setForegroundColor(new Color(187, 224, 227));
|
||||
box2.setLineColor(Color.black);
|
||||
box2.setLineWidth(0.75);
|
||||
box2.setAnchor(new Rectangle(66, 243, 170, 170));
|
||||
slide.addShape(box2);
|
||||
|
||||
TextBox box3 = new TextBox();
|
||||
box3.setHorizontalAlignment(TextBox.AlignCenter);
|
||||
box3.setVerticalAlignment(TextBox.AnchorMiddle);
|
||||
box3.getTextRun().setText("*.ppt file");
|
||||
HSLFTextBox box3 = new HSLFTextBox();
|
||||
box3.setHorizontalAlignment(HSLFTextBox.AlignCenter);
|
||||
box3.setVerticalAlignment(HSLFTextBox.AnchorMiddle);
|
||||
box3.getTextParagraph().setText("*.ppt file");
|
||||
box3.setLineWidth(0.75);
|
||||
box3.setLineColor(Color.black);
|
||||
box3.getFill().setForegroundColor(new Color(187, 224, 227));
|
||||
box3.setAnchor(new Rectangle(473, 243, 170, 170));
|
||||
slide.addShape(box3);
|
||||
|
||||
AutoShape box4 = new AutoShape(ShapeType.RIGHT_ARROW);
|
||||
HSLFAutoShape box4 = new HSLFAutoShape(ShapeType.RIGHT_ARROW);
|
||||
box4.getFill().setForegroundColor(new Color(187, 224, 227));
|
||||
box4.setLineWidth(0.75);
|
||||
box4.setLineColor(Color.black);
|
||||
@ -321,18 +321,18 @@ public final class ApacheconEU08 {
|
||||
slide.addShape(box4);
|
||||
}
|
||||
|
||||
public static void slide8(SlideShow ppt) throws IOException {
|
||||
Slide slide = ppt.createSlide();
|
||||
public static void slide8(HSLFSlideShow ppt) throws IOException {
|
||||
HSLFSlide slide = ppt.createSlide();
|
||||
|
||||
TextBox box1 = new TextBox();
|
||||
TextRun tr1 = box1.getTextRun();
|
||||
HSLFTextBox box1 = new HSLFTextBox();
|
||||
HSLFTextParagraph tr1 = box1.getTextParagraph();
|
||||
tr1.setRunType(TextHeaderAtom.TITLE_TYPE);
|
||||
tr1.setText("Wait, there is more!");
|
||||
box1.setAnchor(new Rectangle(36, 21, 648, 90));
|
||||
slide.addShape(box1);
|
||||
|
||||
TextBox box2 = new TextBox();
|
||||
TextRun tr2 = box2.getTextRun();
|
||||
HSLFTextBox box2 = new HSLFTextBox();
|
||||
HSLFTextParagraph tr2 = box2.getTextParagraph();
|
||||
tr2.setRunType(TextHeaderAtom.BODY_TYPE);
|
||||
tr2.setText(
|
||||
"Rich text\r" +
|
||||
@ -343,26 +343,26 @@ public final class ApacheconEU08 {
|
||||
slide.addShape(box2);
|
||||
}
|
||||
|
||||
public static void slide9(SlideShow ppt) throws IOException {
|
||||
Slide slide = ppt.createSlide();
|
||||
public static void slide9(HSLFSlideShow ppt) throws IOException {
|
||||
HSLFSlide slide = ppt.createSlide();
|
||||
|
||||
TextBox box1 = new TextBox();
|
||||
TextRun tr1 = box1.getTextRun();
|
||||
HSLFTextBox box1 = new HSLFTextBox();
|
||||
HSLFTextParagraph tr1 = box1.getTextParagraph();
|
||||
tr1.setRunType(TextHeaderAtom.TITLE_TYPE);
|
||||
tr1.setText("HSLF in Action - 3");
|
||||
box1.setAnchor(new Rectangle(36, 20, 648, 50));
|
||||
slide.addShape(box1);
|
||||
|
||||
TextBox box2 = new TextBox();
|
||||
TextRun tr2 = box2.getTextRun();
|
||||
HSLFTextBox box2 = new HSLFTextBox();
|
||||
HSLFTextParagraph tr2 = box2.getTextParagraph();
|
||||
tr2.getRichTextRuns()[0].setFontSize(18);
|
||||
tr2.setText("PPGraphics2D: PowerPoint Graphics2D driver");
|
||||
box2.setAnchor(new Rectangle(178, 70, 387, 30));
|
||||
slide.addShape(box2);
|
||||
|
||||
TextBox box3 = new TextBox();
|
||||
TextRun tr3 = box3.getTextRun();
|
||||
RichTextRun rt3 = tr3.getRichTextRuns()[0];
|
||||
HSLFTextBox box3 = new HSLFTextBox();
|
||||
HSLFTextParagraph tr3 = box3.getTextParagraph();
|
||||
HSLFTextRun rt3 = tr3.getRichTextRuns()[0];
|
||||
rt3.setFontName("Courier New");
|
||||
rt3.setFontSize(8);
|
||||
tr3.setText(
|
||||
@ -408,7 +408,7 @@ public final class ApacheconEU08 {
|
||||
slide.addShape(box3);
|
||||
}
|
||||
|
||||
public static void slide10(SlideShow ppt) throws IOException {
|
||||
public static void slide10(HSLFSlideShow 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),
|
||||
@ -417,7 +417,7 @@ public final class ApacheconEU08 {
|
||||
Color.red, new Integer(200),
|
||||
};
|
||||
|
||||
Slide slide = ppt.createSlide();
|
||||
HSLFSlide slide = ppt.createSlide();
|
||||
|
||||
HSLFGroupShape group = new HSLFGroupShape();
|
||||
//define position of the drawing in the slide
|
||||
@ -445,18 +445,18 @@ public final class ApacheconEU08 {
|
||||
|
||||
}
|
||||
|
||||
public static void slide11(SlideShow ppt) throws IOException {
|
||||
Slide slide = ppt.createSlide();
|
||||
public static void slide11(HSLFSlideShow ppt) throws IOException {
|
||||
HSLFSlide slide = ppt.createSlide();
|
||||
|
||||
TextBox box1 = new TextBox();
|
||||
TextRun tr1 = box1.getTextRun();
|
||||
HSLFTextBox box1 = new HSLFTextBox();
|
||||
HSLFTextParagraph tr1 = box1.getTextParagraph();
|
||||
tr1.setRunType(TextHeaderAtom.TITLE_TYPE);
|
||||
tr1.setText("HSLF Development Plans");
|
||||
box1.setAnchor(new Rectangle(36, 21, 648, 90));
|
||||
slide.addShape(box1);
|
||||
|
||||
TextBox box2 = new TextBox();
|
||||
TextRun tr2 = box2.getTextRun();
|
||||
HSLFTextBox box2 = new HSLFTextBox();
|
||||
HSLFTextParagraph tr2 = box2.getTextParagraph();
|
||||
tr2.setRunType(TextHeaderAtom.BODY_TYPE);
|
||||
tr2.getRichTextRuns()[0].setFontSize(32);
|
||||
tr2.setText(
|
||||
@ -465,8 +465,8 @@ public final class ApacheconEU08 {
|
||||
box2.setAnchor(new Rectangle(36, 126, 648, 100));
|
||||
slide.addShape(box2);
|
||||
|
||||
TextBox box3 = new TextBox();
|
||||
TextRun tr3 = box3.getTextRun();
|
||||
HSLFTextBox box3 = new HSLFTextBox();
|
||||
HSLFTextParagraph tr3 = box3.getTextParagraph();
|
||||
tr3.setRunType(TextHeaderAtom.BODY_TYPE);
|
||||
tr3.getRichTextRuns()[0].setIndentLevel(1);
|
||||
tr3.setText(
|
||||
@ -474,8 +474,8 @@ public final class ApacheconEU08 {
|
||||
box3.setAnchor(new Rectangle(36, 220, 648, 70));
|
||||
slide.addShape(box3);
|
||||
|
||||
TextBox box4 = new TextBox();
|
||||
TextRun tr4 = box4.getTextRun();
|
||||
HSLFTextBox box4 = new HSLFTextBox();
|
||||
HSLFTextParagraph tr4 = box4.getTextParagraph();
|
||||
tr4.setRunType(TextHeaderAtom.BODY_TYPE);
|
||||
tr4.getRichTextRuns()[0].setFontSize(32);
|
||||
tr4.setText(
|
||||
@ -483,8 +483,8 @@ public final class ApacheconEU08 {
|
||||
box4.setAnchor(new Rectangle(36, 290, 648, 90));
|
||||
slide.addShape(box4);
|
||||
|
||||
TextBox box5 = new TextBox();
|
||||
TextRun tr5 = box5.getTextRun();
|
||||
HSLFTextBox box5 = new HSLFTextBox();
|
||||
HSLFTextParagraph tr5 = box5.getTextParagraph();
|
||||
tr5.setRunType(TextHeaderAtom.BODY_TYPE);
|
||||
tr5.getRichTextRuns()[0].setIndentLevel(1);
|
||||
tr5.setText(
|
||||
@ -494,18 +494,18 @@ public final class ApacheconEU08 {
|
||||
slide.addShape(box5);
|
||||
}
|
||||
|
||||
public static void slide12(SlideShow ppt) throws IOException {
|
||||
Slide slide = ppt.createSlide();
|
||||
public static void slide12(HSLFSlideShow ppt) throws IOException {
|
||||
HSLFSlide slide = ppt.createSlide();
|
||||
|
||||
TextBox box1 = new TextBox();
|
||||
TextRun tr1 = box1.getTextRun();
|
||||
HSLFTextBox box1 = new HSLFTextBox();
|
||||
HSLFTextParagraph tr1 = box1.getTextParagraph();
|
||||
tr1.setRunType(TextHeaderAtom.CENTER_TITLE_TYPE);
|
||||
tr1.setText("Questions?");
|
||||
box1.setAnchor(new Rectangle(54, 167, 612, 115));
|
||||
slide.addShape(box1);
|
||||
|
||||
TextBox box2 = new TextBox();
|
||||
TextRun tr2 = box2.getTextRun();
|
||||
HSLFTextBox box2 = new HSLFTextBox();
|
||||
HSLFTextParagraph tr2 = box2.getTextParagraph();
|
||||
tr2.setRunType(TextHeaderAtom.CENTRE_BODY_TYPE);
|
||||
tr2.setText(
|
||||
"http://poi.apache.org/hslf/\r" +
|
||||
|
@ -17,10 +17,10 @@
|
||||
|
||||
package org.apache.poi.hslf.examples;
|
||||
|
||||
import org.apache.poi.hslf.usermodel.SlideShow;
|
||||
import org.apache.poi.hslf.usermodel.RichTextRun;
|
||||
import org.apache.poi.hslf.model.Slide;
|
||||
import org.apache.poi.hslf.model.TextBox;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.hslf.usermodel.HSLFTextRun;
|
||||
import org.apache.poi.hslf.model.HSLFSlide;
|
||||
import org.apache.poi.hslf.model.HSLFTextBox;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
@ -34,12 +34,12 @@ public final class BulletsDemo {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
SlideShow ppt = new SlideShow();
|
||||
HSLFSlideShow ppt = new HSLFSlideShow();
|
||||
|
||||
Slide slide = ppt.createSlide();
|
||||
HSLFSlide slide = ppt.createSlide();
|
||||
|
||||
TextBox shape = new TextBox();
|
||||
RichTextRun rt = shape.getTextRun().getRichTextRuns()[0];
|
||||
HSLFTextBox shape = new HSLFTextBox();
|
||||
HSLFTextRun rt = shape.getTextParagraph().getRichTextRuns()[0];
|
||||
shape.setText(
|
||||
"January\r" +
|
||||
"February\r" +
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
package org.apache.poi.hslf.examples;
|
||||
|
||||
import org.apache.poi.hslf.usermodel.SlideShow;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.hslf.model.*;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
@ -31,14 +31,14 @@ import java.awt.*;
|
||||
public final class CreateHyperlink {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SlideShow ppt = new SlideShow();
|
||||
HSLFSlideShow ppt = new HSLFSlideShow();
|
||||
|
||||
Slide slideA = ppt.createSlide();
|
||||
Slide slideB = ppt.createSlide();
|
||||
Slide slideC = ppt.createSlide();
|
||||
HSLFSlide slideA = ppt.createSlide();
|
||||
HSLFSlide slideB = ppt.createSlide();
|
||||
HSLFSlide slideC = ppt.createSlide();
|
||||
|
||||
// link to a URL
|
||||
TextBox textBox1 = new TextBox();
|
||||
HSLFTextBox textBox1 = new HSLFTextBox();
|
||||
textBox1.setText("Apache POI");
|
||||
textBox1.setAnchor(new Rectangle(100, 100, 200, 50));
|
||||
|
||||
@ -54,7 +54,7 @@ public final class CreateHyperlink {
|
||||
slideA.addShape(textBox1);
|
||||
|
||||
// link to another slide
|
||||
TextBox textBox2 = new TextBox();
|
||||
HSLFTextBox textBox2 = new HSLFTextBox();
|
||||
textBox2.setText("Go to slide #3");
|
||||
textBox2.setAnchor(new Rectangle(100, 300, 200, 50));
|
||||
|
||||
|
@ -41,11 +41,11 @@ public final class DataExtraction {
|
||||
}
|
||||
|
||||
FileInputStream is = new FileInputStream(args[0]);
|
||||
SlideShow ppt = new SlideShow(is);
|
||||
HSLFSlideShow ppt = new HSLFSlideShow(is);
|
||||
is.close();
|
||||
|
||||
//extract all sound files embedded in this presentation
|
||||
SoundData[] sound = ppt.getSoundData();
|
||||
HSLFSoundData[] sound = ppt.getSoundData();
|
||||
for (int i = 0; i < sound.length; i++) {
|
||||
String type = sound[i].getSoundType(); //*.wav
|
||||
String name = sound[i].getSoundName(); //typically file name
|
||||
@ -58,13 +58,13 @@ public final class DataExtraction {
|
||||
}
|
||||
|
||||
//extract embedded OLE documents
|
||||
Slide[] slide = ppt.getSlides();
|
||||
HSLFSlide[] slide = ppt.getSlides();
|
||||
for (int i = 0; i < slide.length; i++) {
|
||||
HSLFShape[] shape = slide[i].getShapes();
|
||||
for (int j = 0; j < shape.length; j++) {
|
||||
if (shape[j] instanceof OLEShape) {
|
||||
OLEShape ole = (OLEShape) shape[j];
|
||||
ObjectData data = ole.getObjectData();
|
||||
HSLFObjectData data = ole.getObjectData();
|
||||
String name = ole.getInstanceName();
|
||||
if ("Worksheet".equals(name)) {
|
||||
|
||||
@ -104,29 +104,29 @@ public final class DataExtraction {
|
||||
for (int i = 0; i < slide.length; i++) {
|
||||
HSLFShape[] shape = slide[i].getShapes();
|
||||
for (int j = 0; j < shape.length; j++) {
|
||||
if (shape[j] instanceof Picture) {
|
||||
Picture p = (Picture) shape[j];
|
||||
PictureData data = p.getPictureData();
|
||||
if (shape[j] instanceof HSLFPictureShape) {
|
||||
HSLFPictureShape p = (HSLFPictureShape) shape[j];
|
||||
HSLFPictureData data = p.getPictureData();
|
||||
String name = p.getPictureName();
|
||||
int type = data.getType();
|
||||
String ext;
|
||||
switch (type) {
|
||||
case Picture.JPEG:
|
||||
case HSLFPictureShape.JPEG:
|
||||
ext = ".jpg";
|
||||
break;
|
||||
case Picture.PNG:
|
||||
case HSLFPictureShape.PNG:
|
||||
ext = ".png";
|
||||
break;
|
||||
case Picture.WMF:
|
||||
case HSLFPictureShape.WMF:
|
||||
ext = ".wmf";
|
||||
break;
|
||||
case Picture.EMF:
|
||||
case HSLFPictureShape.EMF:
|
||||
ext = ".emf";
|
||||
break;
|
||||
case Picture.PICT:
|
||||
case HSLFPictureShape.PICT:
|
||||
ext = ".pict";
|
||||
break;
|
||||
case Picture.DIB:
|
||||
case HSLFPictureShape.DIB:
|
||||
ext = ".dib";
|
||||
break;
|
||||
default:
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
package org.apache.poi.hslf.examples;
|
||||
|
||||
import org.apache.poi.hslf.usermodel.SlideShow;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.hslf.model.*;
|
||||
|
||||
import java.awt.*;
|
||||
@ -34,7 +34,7 @@ public final class Graphics2DDemo {
|
||||
* A simple bar chart demo
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
SlideShow ppt = new SlideShow();
|
||||
HSLFSlideShow ppt = new HSLFSlideShow();
|
||||
|
||||
//bar chart data. The first value is the bar color, the second is the width
|
||||
Object[] def = new Object[]{
|
||||
@ -44,7 +44,7 @@ public final class Graphics2DDemo {
|
||||
Color.red, new Integer(80),
|
||||
};
|
||||
|
||||
Slide slide = ppt.createSlide();
|
||||
HSLFSlide slide = ppt.createSlide();
|
||||
|
||||
HSLFGroupShape group = new HSLFGroupShape();
|
||||
//define position of the drawing in the slide
|
||||
|
@ -16,9 +16,9 @@
|
||||
==================================================================== */
|
||||
package org.apache.poi.hslf.examples;
|
||||
|
||||
import org.apache.poi.hslf.usermodel.SlideShow;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.hslf.model.HeadersFooters;
|
||||
import org.apache.poi.hslf.model.Slide;
|
||||
import org.apache.poi.hslf.model.HSLFSlide;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
@ -29,7 +29,7 @@ import java.io.FileOutputStream;
|
||||
*/
|
||||
public class HeadersFootersDemo {
|
||||
public static void main(String[] args) throws Exception {
|
||||
SlideShow ppt = new SlideShow();
|
||||
HSLFSlideShow ppt = new HSLFSlideShow();
|
||||
|
||||
HeadersFooters slideHeaders = ppt.getSlideHeadersFooters();
|
||||
slideHeaders.setFootersText("Created by POI-HSLF");
|
||||
@ -40,7 +40,7 @@ public class HeadersFootersDemo {
|
||||
notesHeaders.setFootersText("My notes footers");
|
||||
notesHeaders.setHeaderText("My notes header");
|
||||
|
||||
Slide slide = ppt.createSlide();
|
||||
HSLFSlide slide = ppt.createSlide();
|
||||
|
||||
FileOutputStream out = new FileOutputStream("headers_footers.ppt");
|
||||
ppt.write(out);
|
||||
|
@ -17,9 +17,9 @@
|
||||
|
||||
package org.apache.poi.hslf.examples;
|
||||
|
||||
import org.apache.poi.hslf.usermodel.SlideShow;
|
||||
import org.apache.poi.hslf.model.Slide;
|
||||
import org.apache.poi.hslf.model.TextRun;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.hslf.model.HSLFSlide;
|
||||
import org.apache.poi.hslf.model.HSLFTextParagraph;
|
||||
import org.apache.poi.hslf.model.Hyperlink;
|
||||
import org.apache.poi.hslf.model.HSLFShape;
|
||||
|
||||
@ -35,16 +35,16 @@ public final class Hyperlinks {
|
||||
public static void main(String[] args) throws Exception {
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
FileInputStream is = new FileInputStream(args[i]);
|
||||
SlideShow ppt = new SlideShow(is);
|
||||
HSLFSlideShow ppt = new HSLFSlideShow(is);
|
||||
is.close();
|
||||
|
||||
Slide[] slide = ppt.getSlides();
|
||||
HSLFSlide[] slide = ppt.getSlides();
|
||||
for (int j = 0; j < slide.length; j++) {
|
||||
System.out.println("slide " + slide[j].getSlideNumber());
|
||||
|
||||
//read hyperlinks from the slide's text runs
|
||||
System.out.println("reading hyperlinks from the text runs");
|
||||
TextRun[] txt = slide[j].getTextRuns();
|
||||
HSLFTextParagraph[] txt = slide[j].getTextRuns();
|
||||
for (int k = 0; k < txt.length; k++) {
|
||||
String text = txt[k].getText();
|
||||
Hyperlink[] links = txt[k].getHyperlinks();
|
||||
|
@ -62,14 +62,14 @@ public final class PPT2PNG {
|
||||
}
|
||||
|
||||
FileInputStream is = new FileInputStream(file);
|
||||
SlideShow ppt = new SlideShow(is);
|
||||
HSLFSlideShow ppt = new HSLFSlideShow(is);
|
||||
is.close();
|
||||
|
||||
Dimension pgsize = ppt.getPageSize();
|
||||
int width = (int)(pgsize.width*scale);
|
||||
int height = (int)(pgsize.height*scale);
|
||||
|
||||
Slide[] slide = ppt.getSlides();
|
||||
HSLFSlide[] slide = ppt.getSlides();
|
||||
for (int i = 0; i < slide.length; i++) {
|
||||
if (slidenum != -1 && slidenum != (i+1)) continue;
|
||||
|
||||
|
@ -32,10 +32,10 @@ import java.util.List;
|
||||
*/
|
||||
public class SoundFinder {
|
||||
public static void main(String[] args) throws Exception {
|
||||
SlideShow ppt = new SlideShow(new FileInputStream(args[0]));
|
||||
SoundData[] sounds = ppt.getSoundData();
|
||||
HSLFSlideShow ppt = new HSLFSlideShow(new FileInputStream(args[0]));
|
||||
HSLFSoundData[] sounds = ppt.getSoundData();
|
||||
|
||||
Slide[] slide = ppt.getSlides();
|
||||
HSLFSlide[] slide = ppt.getSlides();
|
||||
for (int i = 0; i < slide.length; i++) {
|
||||
HSLFShape[] shape = slide[i].getShapes();
|
||||
for (int j = 0; j < shape.length; j++) {
|
||||
|
@ -17,8 +17,8 @@
|
||||
|
||||
package org.apache.poi.hslf.examples;
|
||||
|
||||
import org.apache.poi.hslf.usermodel.SlideShow;
|
||||
import org.apache.poi.hslf.usermodel.RichTextRun;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.hslf.usermodel.HSLFTextRun;
|
||||
import org.apache.poi.hslf.model.*;
|
||||
|
||||
import java.awt.*;
|
||||
@ -43,9 +43,9 @@ public final class TableDemo {
|
||||
{"Total PO History Spend", "$10,172,038"}
|
||||
};
|
||||
|
||||
SlideShow ppt = new SlideShow();
|
||||
HSLFSlideShow ppt = new HSLFSlideShow();
|
||||
|
||||
Slide slide = ppt.createSlide();
|
||||
HSLFSlide slide = ppt.createSlide();
|
||||
|
||||
//six rows, two columns
|
||||
Table table1 = new Table(6, 2);
|
||||
@ -53,7 +53,7 @@ public final class TableDemo {
|
||||
for (int j = 0; j < txt1[i].length; j++) {
|
||||
TableCell cell = table1.getCell(i, j);
|
||||
cell.setText(txt1[i][j]);
|
||||
RichTextRun rt = cell.getTextRun().getRichTextRuns()[0];
|
||||
HSLFTextRun rt = cell.getTextParagraph().getRichTextRuns()[0];
|
||||
rt.setFontName("Arial");
|
||||
rt.setFontSize(10);
|
||||
if(i == 0){
|
||||
@ -61,8 +61,8 @@ public final class TableDemo {
|
||||
} else {
|
||||
rt.setBold(true);
|
||||
}
|
||||
cell.setVerticalAlignment(TextBox.AnchorMiddle);
|
||||
cell.setHorizontalAlignment(TextBox.AlignCenter);
|
||||
cell.setVerticalAlignment(HSLFTextBox.AnchorMiddle);
|
||||
cell.setHorizontalAlignment(HSLFTextBox.AlignCenter);
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ public final class TableDemo {
|
||||
for (int j = 0; j < txt2[i].length; j++) {
|
||||
TableCell cell = table2.getCell(i, j);
|
||||
cell.setText(txt2[i][j]);
|
||||
RichTextRun rt = cell.getTextRun().getRichTextRuns()[0];
|
||||
HSLFTextRun rt = cell.getTextParagraph().getRichTextRuns()[0];
|
||||
rt.setFontSize(10);
|
||||
rt.setFontName("Arial");
|
||||
if(i == 0){
|
||||
@ -100,13 +100,13 @@ public final class TableDemo {
|
||||
rt.setFontColor(Color.white);
|
||||
rt.setBold(true);
|
||||
rt.setFontSize(14);
|
||||
cell.setHorizontalAlignment(TextBox.AlignCenter);
|
||||
cell.setHorizontalAlignment(HSLFTextBox.AlignCenter);
|
||||
} else {
|
||||
rt.setBullet(true);
|
||||
rt.setFontSize(12);
|
||||
cell.setHorizontalAlignment(TextBox.AlignLeft);
|
||||
cell.setHorizontalAlignment(HSLFTextBox.AlignLeft);
|
||||
}
|
||||
cell.setVerticalAlignment(TextBox.AnchorMiddle);
|
||||
cell.setVerticalAlignment(HSLFTextBox.AnchorMiddle);
|
||||
}
|
||||
}
|
||||
table2.setColumnWidth(0, 300);
|
||||
|
@ -21,8 +21,8 @@ import org.apache.poi.poifs.filesystem.DirectoryNode;
|
||||
import org.apache.poi.poifs.filesystem.Entry;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
import org.apache.poi.hwpf.HWPFDocument;
|
||||
import org.apache.poi.hslf.HSLFSlideShow;
|
||||
import org.apache.poi.hslf.usermodel.SlideShow;
|
||||
import org.apache.poi.hslf.model.HSLFSlideShowImpl;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.util.Iterator;
|
||||
@ -47,7 +47,7 @@ public class EmeddedObjects {
|
||||
//System.out.println(entry.getName() + ": " + embeddedWordDocument.getRange().text());
|
||||
} else if (oleName.equals("Presentation")) {
|
||||
DirectoryNode dn = (DirectoryNode) obj.getDirectory();
|
||||
SlideShow embeddedPowerPointDocument = new SlideShow(new HSLFSlideShow(dn));
|
||||
HSLFSlideShow embeddedPowerPointDocument = new HSLFSlideShow(new HSLFSlideShowImpl(dn));
|
||||
//System.out.println(entry.getName() + ": " + embeddedPowerPointDocument.getSlides().length);
|
||||
} else {
|
||||
if(obj.hasDirectoryEntry()){
|
||||
|
@ -76,7 +76,6 @@ public final class DataExtraction {
|
||||
Dimension pageSize = ppt.getPageSize(); // size of the canvas in points
|
||||
for(XSLFSlide slide : ppt.getSlides()) {
|
||||
for(XSLFShape shape : slide){
|
||||
Rectangle2D anchor = shape.getAnchor(); // position on the canvas
|
||||
if(shape instanceof XSLFTextShape) {
|
||||
XSLFTextShape txShape = (XSLFTextShape)shape;
|
||||
System.out.println(txShape.getText());
|
||||
|
@ -19,12 +19,12 @@
|
||||
|
||||
package org.apache.poi.xslf.usermodel;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Color;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.poi.sl.usermodel.TextAlign;
|
||||
import org.apache.poi.sl.usermodel.TextParagraph.TextAlign;
|
||||
|
||||
/**
|
||||
* PPTX Tables
|
||||
|
@ -20,7 +20,7 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.apache.poi.openxml4j.opc.OPCPackage;
|
||||
import org.apache.poi.openxml4j.opc.PackagePart;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
import org.apache.poi.hslf.HSLFSlideShow;
|
||||
import org.apache.poi.hslf.model.HSLFSlideShowImpl;
|
||||
import org.apache.poi.hwpf.HWPFDocument;
|
||||
import org.apache.poi.xslf.XSLFSlideShow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
@ -54,7 +54,7 @@ public class EmbeddedObjects {
|
||||
}
|
||||
// PowerPoint Document - binary file format
|
||||
else if (contentType.equals("application/vnd.ms-powerpoint")) {
|
||||
HSLFSlideShow slideShow = new HSLFSlideShow(pPart.getInputStream());
|
||||
HSLFSlideShowImpl slideShow = new HSLFSlideShowImpl(pPart.getInputStream());
|
||||
}
|
||||
// PowerPoint Document - OpenXML file format
|
||||
else if (contentType.equals("application/vnd.openxmlformats-officedocument.presentationml.presentation")) {
|
||||
|
@ -22,14 +22,14 @@ import static org.junit.Assert.assertTrue;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.apache.poi.hslf.HSLFSlideShow;
|
||||
import org.apache.poi.hslf.model.HSLFSlideShowImpl;
|
||||
import org.apache.poi.hslf.record.Record;
|
||||
import org.junit.Test;
|
||||
|
||||
public class HSLFFileHandler extends POIFSFileHandler {
|
||||
@Override
|
||||
public void handleFile(InputStream stream) throws Exception {
|
||||
HSLFSlideShow slide = new HSLFSlideShow(stream);
|
||||
HSLFSlideShowImpl slide = new HSLFSlideShowImpl(stream);
|
||||
assertNotNull(slide.getCurrentUserAtom());
|
||||
assertNotNull(slide.getEmbeddedObjects());
|
||||
assertNotNull(slide.getUnderlyingBytes());
|
||||
|
@ -19,25 +19,19 @@
|
||||
|
||||
package org.apache.poi.xslf.usermodel;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.poi.openxml4j.opc.PackagePart;
|
||||
import org.apache.poi.openxml4j.opc.PackageRelationship;
|
||||
import org.apache.poi.openxml4j.opc.TargetMode;
|
||||
import org.apache.poi.sl.usermodel.*;
|
||||
import org.apache.poi.openxml4j.opc.*;
|
||||
import org.apache.poi.sl.usermodel.PlaceableShape;
|
||||
import org.apache.poi.sl.usermodel.ShapeGroup;
|
||||
import org.apache.poi.util.Beta;
|
||||
import org.apache.poi.util.Units;
|
||||
import org.apache.xmlbeans.XmlObject;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.*;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTConnector;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShapeNonVisual;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.*;
|
||||
|
||||
/**
|
||||
* Represents a group shape that consists of many shapes grouped together.
|
||||
@ -45,7 +39,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTShape;
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
@Beta
|
||||
public class XSLFGroupShape extends XSLFShape implements XSLFShapeContainer, PlaceableShape {
|
||||
public class XSLFGroupShape extends XSLFShape implements XSLFShapeContainer, ShapeGroup<XSLFShape> {
|
||||
private final List<XSLFShape> _shapes;
|
||||
private final CTGroupShapeProperties _grpSpPr;
|
||||
private XSLFDrawing _drawing;
|
||||
|
@ -17,20 +17,19 @@
|
||||
package org.apache.poi.xslf.usermodel;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.POIXMLDocumentPart;
|
||||
import org.apache.poi.openxml4j.opc.PackagePart;
|
||||
import org.apache.poi.openxml4j.opc.PackageRelationship;
|
||||
import org.apache.poi.sl.usermodel.Notes;
|
||||
import org.apache.poi.sl.usermodel.TextRun;
|
||||
import org.apache.poi.util.Beta;
|
||||
import org.apache.xmlbeans.XmlException;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTCommonSlideData;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTNotesSlide;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.NotesDocument;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.*;
|
||||
|
||||
@Beta
|
||||
public final class XSLFNotes extends XSLFSheet implements Notes<XSLFShape> {
|
||||
public final class XSLFNotes extends XSLFSheet implements Notes<XSLFShape,XMLSlideShow> {
|
||||
private CTNotesSlide _notes;
|
||||
|
||||
/**
|
||||
@ -91,19 +90,15 @@ public final class XSLFNotes extends XSLFSheet implements Notes<XSLFShape> {
|
||||
return null;
|
||||
}
|
||||
|
||||
public TextRun getTextRun() {
|
||||
@Override
|
||||
public List<XSLFTextParagraph> getTextParagraphs() {
|
||||
List<XSLFTextParagraph> tp = new ArrayList<XSLFTextParagraph>();
|
||||
for (XSLFShape sh : super.getShapes()) {
|
||||
if (sh instanceof XSLFTextShape) {
|
||||
XSLFTextShape txt = (XSLFTextShape)sh;
|
||||
for (XSLFTextParagraph p : txt.getTextParagraphs()) {
|
||||
for (XSLFTextRun r : p.getTextRuns()) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
tp.addAll(txt.getTextParagraphs());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return tp;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.NotesMasterDocument;
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
@Beta
|
||||
public class XSLFNotesMaster extends XSLFSheet implements MasterSheet<XSLFShape> {
|
||||
public class XSLFNotesMaster extends XSLFSheet implements MasterSheet<XSLFShape,XMLSlideShow> {
|
||||
private CTNotesMaster _slide;
|
||||
private XSLFTheme _theme;
|
||||
|
||||
@ -94,7 +94,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.NotesMasterDocument;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MasterSheet getMasterSheet() {
|
||||
public MasterSheet<XSLFShape,XMLSlideShow> getMasterSheet() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package org.apache.poi.xslf.usermodel;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Insets;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
@ -32,27 +31,18 @@ import javax.xml.namespace.QName;
|
||||
import org.apache.poi.POIXMLException;
|
||||
import org.apache.poi.openxml4j.opc.PackagePart;
|
||||
import org.apache.poi.openxml4j.opc.PackageRelationship;
|
||||
import org.apache.poi.sl.usermodel.PictureShape;
|
||||
import org.apache.poi.util.Beta;
|
||||
import org.apache.xmlbeans.XmlCursor;
|
||||
import org.apache.xmlbeans.XmlObject;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTBlip;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeArtExtension;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeArtExtensionList;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTRelativeRect;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.STShapeType;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTApplicationNonVisualDrawingProps;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTPicture;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTPictureNonVisual;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.*;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.*;
|
||||
|
||||
/**
|
||||
* Represents a picture shape
|
||||
*/
|
||||
@Beta
|
||||
public class XSLFPictureShape extends XSLFSimpleShape {
|
||||
public class XSLFPictureShape extends XSLFSimpleShape implements PictureShape {
|
||||
private XSLFPictureData _data;
|
||||
|
||||
/*package*/ XSLFPictureShape(CTPicture shape, XSLFSheet sheet) {
|
||||
|
@ -88,7 +88,7 @@ public class XSLFShadow extends XSLFShape implements Shadow {
|
||||
*/
|
||||
public Color getFillColor() {
|
||||
SolidPaint ps = getFillStyle();
|
||||
if (ps == TRANSPARENT_PAINT) return null;
|
||||
if (ps == PaintStyle.TRANSPARENT_PAINT) return null;
|
||||
Color col = DrawPaint.applyColorTransform(ps.getSolidColor());
|
||||
return col;
|
||||
}
|
||||
@ -97,7 +97,7 @@ public class XSLFShadow extends XSLFShape implements Shadow {
|
||||
public SolidPaint getFillStyle() {
|
||||
XSLFTheme theme = getSheet().getTheme();
|
||||
CTOuterShadowEffect ct = (CTOuterShadowEffect)getXmlObject();
|
||||
if(ct == null) return TRANSPARENT_PAINT;
|
||||
if(ct == null) return PaintStyle.TRANSPARENT_PAINT;
|
||||
|
||||
CTSchemeColor phClr = ct.getSchemeClr();
|
||||
final XSLFColor xc = new XSLFColor(ct, theme, phClr);
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package org.apache.poi.xslf.usermodel;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
@ -28,7 +27,6 @@ import java.util.Comparator;
|
||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||
import org.apache.poi.openxml4j.opc.PackagePart;
|
||||
import org.apache.poi.openxml4j.opc.PackageRelationship;
|
||||
import org.apache.poi.sl.draw.DrawPaint;
|
||||
import org.apache.poi.sl.usermodel.*;
|
||||
import org.apache.poi.sl.usermodel.PaintStyle.GradientPaint;
|
||||
import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;
|
||||
@ -56,19 +54,6 @@ public abstract class XSLFShape implements Shape {
|
||||
private CTNonVisualDrawingProps _nvPr;
|
||||
private CTPlaceholder _ph;
|
||||
|
||||
protected static final SolidPaint TRANSPARENT_PAINT = new SolidPaint() {
|
||||
public ColorStyle getSolidColor() {
|
||||
return new ColorStyle(){
|
||||
public Color getColor() { return DrawPaint.NO_PAINT; }
|
||||
public int getAlpha() { return -1; }
|
||||
public int getLumOff() { return -1; }
|
||||
public int getLumMod() { return -1; }
|
||||
public int getShade() { return -1; }
|
||||
public int getTint() { return -1; }
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
protected XSLFShape(XmlObject shape, XSLFSheet sheet) {
|
||||
_shape = shape;
|
||||
_sheet = sheet;
|
||||
@ -146,7 +131,7 @@ public abstract class XSLFShape implements Shape {
|
||||
try {
|
||||
pr = shape.getSpPr();
|
||||
if (((CTShapeProperties)pr).isSetNoFill()) {
|
||||
setValue(TRANSPARENT_PAINT);
|
||||
setValue(PaintStyle.TRANSPARENT_PAINT);
|
||||
return true;
|
||||
}
|
||||
} catch (IllegalStateException e) {}
|
||||
@ -158,7 +143,7 @@ public abstract class XSLFShape implements Shape {
|
||||
pr = shape.getGrpSpPr();
|
||||
}
|
||||
if (pr == null) {
|
||||
setValue(TRANSPARENT_PAINT);
|
||||
setValue(PaintStyle.TRANSPARENT_PAINT);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -190,7 +175,7 @@ public abstract class XSLFShape implements Shape {
|
||||
fillRef = getBgRef();
|
||||
}
|
||||
if (fillRef == null) {
|
||||
return TRANSPARENT_PAINT;
|
||||
return PaintStyle.TRANSPARENT_PAINT;
|
||||
}
|
||||
|
||||
// The idx attribute refers to the index of a fill style or
|
||||
@ -213,21 +198,21 @@ public abstract class XSLFShape implements Shape {
|
||||
paint = selectPaint(fillProps, phClr, sheet.getPackagePart());
|
||||
}
|
||||
|
||||
return paint == null ? TRANSPARENT_PAINT : paint;
|
||||
return paint == null ? PaintStyle.TRANSPARENT_PAINT : paint;
|
||||
}
|
||||
|
||||
protected CTBackgroundProperties getBgPr() {
|
||||
String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' .//*/p:bgPr";
|
||||
String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' p:bgPr";
|
||||
return selectProperty(CTBackgroundProperties.class, xquery);
|
||||
}
|
||||
|
||||
protected CTStyleMatrixReference getBgRef() {
|
||||
String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' .//*/p:bgRef";
|
||||
String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' p:bgRef";
|
||||
return selectProperty(CTStyleMatrixReference.class, xquery);
|
||||
}
|
||||
|
||||
protected CTGroupShapeProperties getGrpSpPr() {
|
||||
String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' .//*/p:grpSpPr";
|
||||
String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' p:grpSpPr";
|
||||
return selectProperty(CTGroupShapeProperties.class, xquery);
|
||||
}
|
||||
|
||||
@ -241,7 +226,7 @@ public abstract class XSLFShape implements Shape {
|
||||
|
||||
protected CTShapeProperties getSpPr() {
|
||||
if (_spPr == null) {
|
||||
String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' .//*/p:spPr";
|
||||
String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' p:spPr";
|
||||
_spPr = selectProperty(CTShapeProperties.class, xquery);
|
||||
}
|
||||
if (_spPr == null) {
|
||||
@ -252,7 +237,7 @@ public abstract class XSLFShape implements Shape {
|
||||
|
||||
protected CTShapeStyle getSpStyle() {
|
||||
if (_spStyle == null) {
|
||||
String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' .//*/p:style";
|
||||
String xquery = "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' p:style";
|
||||
_spStyle = selectProperty(CTShapeStyle.class, xquery);
|
||||
}
|
||||
return _spStyle;
|
||||
@ -348,7 +333,7 @@ public abstract class XSLFShape implements Shape {
|
||||
paint = selectPaint(obj, phClr, pp);
|
||||
if(paint != null) break;
|
||||
}
|
||||
return paint == null ? TRANSPARENT_PAINT : paint;
|
||||
return paint == null ? PaintStyle.TRANSPARENT_PAINT : paint;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -373,7 +358,7 @@ public abstract class XSLFShape implements Shape {
|
||||
*/
|
||||
protected PaintStyle selectPaint(XmlObject obj, final CTSchemeColor phClr, final PackagePart parentPart) {
|
||||
if (obj instanceof CTNoFillProperties) {
|
||||
return TRANSPARENT_PAINT;
|
||||
return PaintStyle.TRANSPARENT_PAINT;
|
||||
} else if (obj instanceof CTSolidColorFillProperties) {
|
||||
return selectPaint((CTSolidColorFillProperties)obj, phClr, parentPart);
|
||||
} else if (obj instanceof CTBlipFillProperties) {
|
||||
|
@ -37,7 +37,7 @@ import org.openxmlformats.schemas.officeDocument.x2006.relationships.STRelations
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.*;
|
||||
|
||||
@Beta
|
||||
public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeContainer, Sheet<XSLFShape> {
|
||||
public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeContainer, Sheet<XSLFShape, XMLSlideShow> {
|
||||
private XSLFCommonSlideData _commonSlideData;
|
||||
private XSLFDrawing _drawing;
|
||||
private List<XSLFShape> _shapes;
|
||||
@ -516,25 +516,26 @@ public abstract class XSLFSheet extends POIXMLDocumentPart implements XSLFShapeC
|
||||
* Import a package part into this sheet.
|
||||
*/
|
||||
PackagePart importPart(PackageRelationship srcRel, PackagePart srcPafrt) {
|
||||
|
||||
OPCPackage pkg = getPackagePart().getPackage();
|
||||
if(!pkg.containPart(srcPafrt.getPartName())){
|
||||
PackageRelationship rel = getPackagePart().addRelationship(
|
||||
srcPafrt.getPartName(), TargetMode.INTERNAL, srcRel.getRelationshipType());
|
||||
|
||||
PackagePart part = pkg.createPart(srcPafrt.getPartName(), srcPafrt.getContentType());
|
||||
OutputStream out = part.getOutputStream();
|
||||
try {
|
||||
InputStream is = srcPafrt.getInputStream();
|
||||
IOUtils.copy(is, out);
|
||||
out.close();
|
||||
} catch (IOException e){
|
||||
throw new POIXMLException(e);
|
||||
}
|
||||
return part;
|
||||
} else {
|
||||
PackagePart destPP = getPackagePart();
|
||||
PackagePartName srcPPName = srcPafrt.getPartName();
|
||||
|
||||
OPCPackage pkg = destPP.getPackage();
|
||||
if(pkg.containPart(srcPPName)){
|
||||
// already exists
|
||||
return pkg.getPart(srcPafrt.getPartName());
|
||||
return pkg.getPart(srcPPName);
|
||||
}
|
||||
|
||||
destPP.addRelationship(srcPPName, TargetMode.INTERNAL, srcRel.getRelationshipType());
|
||||
|
||||
PackagePart part = pkg.createPart(srcPPName, srcPafrt.getContentType());
|
||||
OutputStream out = part.getOutputStream();
|
||||
try {
|
||||
InputStream is = srcPafrt.getInputStream();
|
||||
IOUtils.copy(is, out);
|
||||
out.close();
|
||||
} catch (IOException e){
|
||||
throw new POIXMLException(e);
|
||||
}
|
||||
return part;
|
||||
}
|
||||
}
|
@ -19,19 +19,21 @@
|
||||
|
||||
package org.apache.poi.xslf.usermodel;
|
||||
|
||||
import static org.apache.poi.sl.usermodel.PaintStyle.TRANSPARENT_PAINT;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
|
||||
import org.apache.poi.sl.draw.DrawPaint;
|
||||
import org.apache.poi.sl.draw.geom.*;
|
||||
import org.apache.poi.sl.usermodel.*;
|
||||
import org.apache.poi.sl.usermodel.LineDecoration.DecorationShape;
|
||||
import org.apache.poi.sl.usermodel.LineDecoration.DecorationSize;
|
||||
import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;
|
||||
import org.apache.poi.sl.usermodel.StrokeStyle.LineCap;
|
||||
import org.apache.poi.sl.usermodel.StrokeStyle.LineCompound;
|
||||
import org.apache.poi.sl.usermodel.StrokeStyle.LineDash;
|
||||
import org.apache.poi.util.Beta;
|
||||
import org.apache.poi.util.Units;
|
||||
@ -208,8 +210,7 @@ public abstract class XSLFSimpleShape extends XSLFShape implements SimpleShape {
|
||||
PaintStyle ps = getLinePaint();
|
||||
if (ps == null || ps == TRANSPARENT_PAINT) return null;
|
||||
if (ps instanceof SolidPaint) {
|
||||
Color col = ((SolidPaint)ps).getSolidColor().getColor();
|
||||
return (col == DrawPaint.NO_PAINT) ? null : col;
|
||||
return ((SolidPaint)ps).getSolidColor().getColor();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -273,7 +274,6 @@ public abstract class XSLFSimpleShape extends XSLFShape implements SimpleShape {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return line width in points. <code>0</code> means no line.
|
||||
*/
|
||||
public double getLineWidth() {
|
||||
@ -310,6 +310,54 @@ public abstract class XSLFSimpleShape extends XSLFShape implements SimpleShape {
|
||||
return lineWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the line compound
|
||||
*/
|
||||
public LineCompound getLineCompound() {
|
||||
PropertyFetcher<Integer> fetcher = new PropertyFetcher<Integer>() {
|
||||
public boolean fetch(XSLFShape shape) {
|
||||
CTShapeProperties spPr = shape.getSpPr();
|
||||
CTLineProperties ln = spPr.getLn();
|
||||
if (ln != null) {
|
||||
STCompoundLine.Enum stCmpd = ln.getCmpd();
|
||||
if (stCmpd != null) {
|
||||
setValue(stCmpd.intValue());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
fetchShapeProperty(fetcher);
|
||||
|
||||
Integer cmpd = fetcher.getValue();
|
||||
if (cmpd == null) {
|
||||
CTLineProperties defaultLn = getDefaultLineProperties();
|
||||
if (defaultLn != null) {
|
||||
STCompoundLine.Enum stCmpd = defaultLn.getCmpd();
|
||||
if (stCmpd != null) {
|
||||
cmpd = stCmpd.intValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cmpd == null) return null;
|
||||
|
||||
switch (cmpd) {
|
||||
default:
|
||||
case STCompoundLine.INT_SNG:
|
||||
return LineCompound.SINGLE;
|
||||
case STCompoundLine.INT_DBL:
|
||||
return LineCompound.DOUBLE;
|
||||
case STCompoundLine.INT_THICK_THIN:
|
||||
return LineCompound.THICK_THIN;
|
||||
case STCompoundLine.INT_THIN_THICK:
|
||||
return LineCompound.THIN_THICK;
|
||||
case STCompoundLine.INT_TRI:
|
||||
return LineCompound.TRIPLE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dash a preset line dashing scheme to stroke thr shape outline
|
||||
@ -453,8 +501,7 @@ public abstract class XSLFSimpleShape extends XSLFShape implements SimpleShape {
|
||||
PaintStyle ps = getFillPaint();
|
||||
if (ps == null || ps == TRANSPARENT_PAINT) return null;
|
||||
if (ps instanceof SolidPaint) {
|
||||
Color col = ((SolidPaint)ps).getSolidColor().getColor();
|
||||
return (col == DrawPaint.NO_PAINT) ? null : col;
|
||||
return ((SolidPaint)ps).getSolidColor().getColor();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -769,6 +816,10 @@ public abstract class XSLFSimpleShape extends XSLFShape implements SimpleShape {
|
||||
public double getLineWidth() {
|
||||
return XSLFSimpleShape.this.getLineWidth();
|
||||
}
|
||||
|
||||
public LineCompound getLineCompound() {
|
||||
return XSLFSimpleShape.this.getLineCompound();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ import org.openxmlformats.schemas.drawingml.x2006.main.*;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.*;
|
||||
|
||||
@Beta
|
||||
public final class XSLFSlide extends XSLFSheet implements Slide<XSLFShape> {
|
||||
public final class XSLFSlide extends XSLFSheet implements Slide<XSLFShape, XMLSlideShow> {
|
||||
private final CTSlide _slide;
|
||||
private XSLFSlideLayout _layout;
|
||||
private XSLFComments _comments;
|
||||
@ -245,7 +245,7 @@ public final class XSLFSlide extends XSLFSheet implements Slide<XSLFShape> {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void setNotes(Notes<XSLFShape> notes) {
|
||||
public void setNotes(Notes<XSLFShape,XMLSlideShow> notes) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.SldLayoutDocument;
|
||||
import java.io.IOException;
|
||||
|
||||
@Beta
|
||||
public class XSLFSlideLayout extends XSLFSheet implements MasterSheet<XSLFShape> {
|
||||
public class XSLFSlideLayout extends XSLFSheet implements MasterSheet<XSLFShape, XMLSlideShow> {
|
||||
private CTSlideLayout _layout;
|
||||
private XSLFSlideMaster _master;
|
||||
|
||||
|
@ -54,7 +54,7 @@ import java.util.Map;
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
@Beta
|
||||
public class XSLFSlideMaster extends XSLFSheet implements MasterSheet<XSLFShape> {
|
||||
public class XSLFSlideMaster extends XSLFSheet implements MasterSheet<XSLFShape, XMLSlideShow> {
|
||||
private CTSlideMaster _slide;
|
||||
private Map<String, XSLFSlideLayout> _layouts;
|
||||
private XSLFTheme _theme;
|
||||
@ -83,7 +83,7 @@ import java.util.Map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MasterSheet getMasterSheet() {
|
||||
public MasterSheet<XSLFShape, XMLSlideShow> getMasterSheet() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -18,9 +18,10 @@ package org.apache.poi.xslf.usermodel;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.poi.sl.usermodel.ShapeType;
|
||||
import org.apache.poi.sl.usermodel.TextAlign;
|
||||
import org.apache.poi.sl.usermodel.VerticalAlignment;
|
||||
import org.apache.poi.sl.usermodel.*;
|
||||
import org.apache.poi.sl.usermodel.TextParagraph.TextAlign;
|
||||
import org.apache.poi.sl.usermodel.TextShape.TextAutofit;
|
||||
import org.apache.poi.sl.usermodel.TextShape.TextDirection;
|
||||
import org.apache.poi.util.Units;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.STTextStrikeType;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.STTextUnderlineType;
|
||||
|
@ -16,14 +16,17 @@
|
||||
==================================================================== */
|
||||
package org.apache.poi.xslf.usermodel;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.poi.sl.usermodel.ShapeType;
|
||||
import org.apache.poi.sl.usermodel.LineDecoration.DecorationShape;
|
||||
import org.apache.poi.sl.usermodel.LineDecoration.DecorationSize;
|
||||
import org.apache.poi.sl.usermodel.*;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.*;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTConnector;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
@ -40,70 +43,70 @@ public class TestXSLFConnectorShape extends TestCase {
|
||||
assertFalse(shape.getSpPr().getLn().isSetTailEnd());
|
||||
|
||||
// line decorations
|
||||
assertEquals(LineDecoration.NONE, shape.getLineHeadDecoration());
|
||||
assertEquals(LineDecoration.NONE, shape.getLineTailDecoration());
|
||||
assertEquals(DecorationShape.NONE, shape.getLineHeadDecoration());
|
||||
assertEquals(DecorationShape.NONE, shape.getLineTailDecoration());
|
||||
shape.setLineHeadDecoration(null);
|
||||
shape.setLineTailDecoration(null);
|
||||
assertEquals(LineDecoration.NONE, shape.getLineHeadDecoration());
|
||||
assertEquals(LineDecoration.NONE, shape.getLineTailDecoration());
|
||||
assertEquals(DecorationShape.NONE, shape.getLineHeadDecoration());
|
||||
assertEquals(DecorationShape.NONE, shape.getLineTailDecoration());
|
||||
assertFalse(shape.getSpPr().getLn().getHeadEnd().isSetType());
|
||||
assertFalse(shape.getSpPr().getLn().getTailEnd().isSetType());
|
||||
|
||||
shape.setLineHeadDecoration(LineDecoration.ARROW);
|
||||
shape.setLineTailDecoration(LineDecoration.DIAMOND);
|
||||
assertEquals(LineDecoration.ARROW, shape.getLineHeadDecoration());
|
||||
assertEquals(LineDecoration.DIAMOND, shape.getLineTailDecoration());
|
||||
shape.setLineHeadDecoration(DecorationShape.ARROW);
|
||||
shape.setLineTailDecoration(DecorationShape.DIAMOND);
|
||||
assertEquals(DecorationShape.ARROW, shape.getLineHeadDecoration());
|
||||
assertEquals(DecorationShape.DIAMOND, shape.getLineTailDecoration());
|
||||
assertEquals(STLineEndType.ARROW, shape.getSpPr().getLn().getHeadEnd().getType());
|
||||
assertEquals(STLineEndType.DIAMOND, shape.getSpPr().getLn().getTailEnd().getType());
|
||||
|
||||
shape.setLineHeadDecoration(LineDecoration.DIAMOND);
|
||||
shape.setLineTailDecoration(LineDecoration.ARROW);
|
||||
assertEquals(LineDecoration.DIAMOND, shape.getLineHeadDecoration());
|
||||
assertEquals(LineDecoration.ARROW, shape.getLineTailDecoration());
|
||||
shape.setLineHeadDecoration(DecorationShape.DIAMOND);
|
||||
shape.setLineTailDecoration(DecorationShape.ARROW);
|
||||
assertEquals(DecorationShape.DIAMOND, shape.getLineHeadDecoration());
|
||||
assertEquals(DecorationShape.ARROW, shape.getLineTailDecoration());
|
||||
assertEquals(STLineEndType.DIAMOND, shape.getSpPr().getLn().getHeadEnd().getType());
|
||||
assertEquals(STLineEndType.ARROW, shape.getSpPr().getLn().getTailEnd().getType());
|
||||
|
||||
// line end width
|
||||
assertEquals(LineEndWidth.MEDIUM, shape.getLineHeadWidth());
|
||||
assertEquals(LineEndWidth.MEDIUM, shape.getLineTailWidth());
|
||||
assertEquals(DecorationSize.MEDIUM, shape.getLineHeadWidth());
|
||||
assertEquals(DecorationSize.MEDIUM, shape.getLineTailWidth());
|
||||
shape.setLineHeadWidth(null);
|
||||
shape.setLineHeadWidth(null);
|
||||
assertEquals(LineEndWidth.MEDIUM, shape.getLineHeadWidth());
|
||||
assertEquals(LineEndWidth.MEDIUM, shape.getLineTailWidth());
|
||||
assertEquals(DecorationSize.MEDIUM, shape.getLineHeadWidth());
|
||||
assertEquals(DecorationSize.MEDIUM, shape.getLineTailWidth());
|
||||
assertFalse(shape.getSpPr().getLn().getHeadEnd().isSetW());
|
||||
assertFalse(shape.getSpPr().getLn().getTailEnd().isSetW());
|
||||
shape.setLineHeadWidth(LineEndWidth.LARGE);
|
||||
shape.setLineTailWidth(LineEndWidth.MEDIUM);
|
||||
assertEquals(LineEndWidth.LARGE, shape.getLineHeadWidth());
|
||||
assertEquals(LineEndWidth.MEDIUM, shape.getLineTailWidth());
|
||||
shape.setLineHeadWidth(DecorationSize.LARGE);
|
||||
shape.setLineTailWidth(DecorationSize.MEDIUM);
|
||||
assertEquals(DecorationSize.LARGE, shape.getLineHeadWidth());
|
||||
assertEquals(DecorationSize.MEDIUM, shape.getLineTailWidth());
|
||||
assertEquals(STLineEndWidth.LG, shape.getSpPr().getLn().getHeadEnd().getW());
|
||||
assertEquals(STLineEndWidth.MED, shape.getSpPr().getLn().getTailEnd().getW());
|
||||
shape.setLineHeadWidth(LineEndWidth.MEDIUM);
|
||||
shape.setLineTailWidth(LineEndWidth.LARGE);
|
||||
assertEquals(LineEndWidth.MEDIUM, shape.getLineHeadWidth());
|
||||
assertEquals(LineEndWidth.LARGE, shape.getLineTailWidth());
|
||||
shape.setLineHeadWidth(DecorationSize.MEDIUM);
|
||||
shape.setLineTailWidth(DecorationSize.LARGE);
|
||||
assertEquals(DecorationSize.MEDIUM, shape.getLineHeadWidth());
|
||||
assertEquals(DecorationSize.LARGE, shape.getLineTailWidth());
|
||||
assertEquals(STLineEndWidth.MED, shape.getSpPr().getLn().getHeadEnd().getW());
|
||||
assertEquals(STLineEndWidth.LG, shape.getSpPr().getLn().getTailEnd().getW());
|
||||
|
||||
// line end length
|
||||
assertEquals(LineEndLength.MEDIUM, shape.getLineHeadLength());
|
||||
assertEquals(LineEndLength.MEDIUM, shape.getLineTailLength());
|
||||
assertEquals(DecorationSize.MEDIUM, shape.getLineHeadLength());
|
||||
assertEquals(DecorationSize.MEDIUM, shape.getLineTailLength());
|
||||
shape.setLineHeadLength(null);
|
||||
shape.setLineTailLength(null);
|
||||
assertEquals(LineEndLength.MEDIUM, shape.getLineHeadLength());
|
||||
assertEquals(LineEndLength.MEDIUM, shape.getLineTailLength());
|
||||
assertEquals(DecorationSize.MEDIUM, shape.getLineHeadLength());
|
||||
assertEquals(DecorationSize.MEDIUM, shape.getLineTailLength());
|
||||
assertFalse(shape.getSpPr().getLn().getHeadEnd().isSetLen());
|
||||
assertFalse(shape.getSpPr().getLn().getTailEnd().isSetLen());
|
||||
shape.setLineHeadLength(LineEndLength.LARGE);
|
||||
shape.setLineTailLength(LineEndLength.MEDIUM);
|
||||
assertEquals(LineEndLength.LARGE, shape.getLineHeadLength());
|
||||
assertEquals(LineEndLength.MEDIUM, shape.getLineTailLength());
|
||||
shape.setLineHeadLength(DecorationSize.LARGE);
|
||||
shape.setLineTailLength(DecorationSize.MEDIUM);
|
||||
assertEquals(DecorationSize.LARGE, shape.getLineHeadLength());
|
||||
assertEquals(DecorationSize.MEDIUM, shape.getLineTailLength());
|
||||
assertEquals(STLineEndLength.LG, shape.getSpPr().getLn().getHeadEnd().getLen());
|
||||
assertEquals(STLineEndLength.MED, shape.getSpPr().getLn().getTailEnd().getLen());
|
||||
shape.setLineHeadLength(LineEndLength.MEDIUM);
|
||||
shape.setLineTailLength(LineEndLength.LARGE);
|
||||
assertEquals(LineEndLength.MEDIUM, shape.getLineHeadLength());
|
||||
assertEquals(LineEndLength.LARGE, shape.getLineTailLength());
|
||||
shape.setLineHeadLength(DecorationSize.MEDIUM);
|
||||
shape.setLineTailLength(DecorationSize.LARGE);
|
||||
assertEquals(DecorationSize.MEDIUM, shape.getLineHeadLength());
|
||||
assertEquals(DecorationSize.LARGE, shape.getLineTailLength());
|
||||
assertEquals(STLineEndLength.MED, shape.getSpPr().getLn().getHeadEnd().getLen());
|
||||
assertEquals(STLineEndLength.LG, shape.getSpPr().getLn().getTailEnd().getLen());
|
||||
|
||||
|
@ -20,17 +20,11 @@ import java.awt.Color;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.poi.sl.usermodel.LineCap;
|
||||
import org.apache.poi.sl.usermodel.LineDash;
|
||||
import org.apache.poi.sl.usermodel.StrokeStyle.LineCap;
|
||||
import org.apache.poi.sl.usermodel.StrokeStyle.LineDash;
|
||||
import org.apache.poi.util.Units;
|
||||
import org.apache.poi.xslf.XSLFTestDataSamples;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTEffectStyleItem;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTEffectStyleList;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTOuterShadowEffect;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTStyleMatrix;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.STLineCap;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.STPresetLineDashVal;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.*;
|
||||
|
||||
/**
|
||||
* @author Yegor Kozlov
|
||||
|
@ -20,6 +20,7 @@ import junit.framework.TestCase;
|
||||
|
||||
import org.apache.poi.sl.usermodel.VerticalAlignment;
|
||||
import org.apache.poi.xslf.XSLFTestDataSamples;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTTableCell;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrame;
|
||||
|
||||
import java.awt.Color;
|
||||
@ -99,10 +100,11 @@ public class TestXSLFTable extends TestCase {
|
||||
XSLFTableCell cell0 = row0.addCell();
|
||||
assertNotNull(cell0.getXmlObject());
|
||||
// by default table cell has no borders
|
||||
assertTrue(cell0.getXmlObject().getTcPr().getLnB().isSetNoFill());
|
||||
assertTrue(cell0.getXmlObject().getTcPr().getLnT().isSetNoFill());
|
||||
assertTrue(cell0.getXmlObject().getTcPr().getLnL().isSetNoFill());
|
||||
assertTrue(cell0.getXmlObject().getTcPr().getLnR().isSetNoFill());
|
||||
CTTableCell tc = (CTTableCell)cell0.getXmlObject();
|
||||
assertTrue(tc.getTcPr().getLnB().isSetNoFill());
|
||||
assertTrue(tc.getTcPr().getLnT().isSetNoFill());
|
||||
assertTrue(tc.getTcPr().getLnL().isSetNoFill());
|
||||
assertTrue(tc.getTcPr().getLnR().isSetNoFill());
|
||||
|
||||
assertSame(cell0, row0.getCells().get(0));
|
||||
assertEquals(1, tbl.getNumberOfColumns());
|
||||
|
@ -16,25 +16,46 @@
|
||||
==================================================================== */
|
||||
package org.apache.poi.xslf.usermodel;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.poi.sl.draw.TextFragment;
|
||||
import org.apache.poi.sl.usermodel.TextAlign;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
import org.apache.poi.xslf.XSLFTestDataSamples;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.sl.draw.DrawTextFragment;
|
||||
import org.apache.poi.sl.draw.DrawTextParagraph;
|
||||
import org.apache.poi.sl.usermodel.TextParagraph.TextAlign;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
import org.apache.poi.xslf.XSLFTestDataSamples;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public class TestXSLFTextParagraph extends TestCase {
|
||||
public class TestXSLFTextParagraph {
|
||||
private static POILogger _logger = POILogFactory.getLogger(XSLFTextParagraph.class);
|
||||
|
||||
static class DrawTextParagraphProxy extends DrawTextParagraph<XSLFTextRun> {
|
||||
DrawTextParagraphProxy(XSLFTextParagraph p) {
|
||||
super(p);
|
||||
}
|
||||
|
||||
public void breakText(Graphics2D graphics) {
|
||||
super.breakText(graphics);
|
||||
}
|
||||
|
||||
public double getWrappingWidth(boolean firstLine, Graphics2D graphics) {
|
||||
return super.getWrappingWidth(firstLine, graphics);
|
||||
}
|
||||
|
||||
public List<DrawTextFragment> getLines() {
|
||||
return lines;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWrappingWidth() throws Exception {
|
||||
XMLSlideShow ppt = new XMLSlideShow();
|
||||
XSLFSlide slide = ppt.createSlide();
|
||||
@ -49,45 +70,47 @@ public class TestXSLFTextParagraph extends TestCase {
|
||||
|
||||
Rectangle2D anchor = new Rectangle(50, 50, 300, 200);
|
||||
sh.setAnchor(anchor);
|
||||
|
||||
DrawTextParagraphProxy dtp = new DrawTextParagraphProxy(p);
|
||||
|
||||
double leftInset = sh.getLeftInset();
|
||||
double rightInset = sh.getRightInset();
|
||||
assertEquals(7.2, leftInset);
|
||||
assertEquals(7.2, rightInset);
|
||||
assertEquals(7.2, leftInset, 0);
|
||||
assertEquals(7.2, rightInset, 0);
|
||||
|
||||
double leftMargin = p.getLeftMargin();
|
||||
assertEquals(0.0, leftMargin);
|
||||
assertEquals(0.0, leftMargin, 0);
|
||||
|
||||
double indent = p.getIndent();
|
||||
assertEquals(0.0, indent); // default
|
||||
assertEquals(0.0, indent, 0); // default
|
||||
|
||||
double expectedWidth;
|
||||
|
||||
// Case 1: bullet=false, leftMargin=0, indent=0.
|
||||
expectedWidth = anchor.getWidth() - leftInset - rightInset - leftMargin;
|
||||
assertEquals(285.6, expectedWidth); // 300 - 7.2 - 7.2 - 0
|
||||
assertEquals(expectedWidth, p.getWrappingWidth(true, null));
|
||||
assertEquals(expectedWidth, p.getWrappingWidth(false, null));
|
||||
assertEquals(285.6, expectedWidth, 0); // 300 - 7.2 - 7.2 - 0
|
||||
assertEquals(expectedWidth, dtp.getWrappingWidth(true, null), 0);
|
||||
assertEquals(expectedWidth, dtp.getWrappingWidth(false, null), 0);
|
||||
|
||||
p.setLeftMargin(36); // 0.5"
|
||||
leftMargin = p.getLeftMargin();
|
||||
assertEquals(36.0, leftMargin);
|
||||
assertEquals(36.0, leftMargin, 0);
|
||||
expectedWidth = anchor.getWidth() - leftInset - rightInset - leftMargin;
|
||||
assertEquals(249.6, expectedWidth, 1E-5); // 300 - 7.2 - 7.2 - 36
|
||||
assertEquals(expectedWidth, p.getWrappingWidth(true, null));
|
||||
assertEquals(expectedWidth, p.getWrappingWidth(false, null));
|
||||
assertEquals(expectedWidth, dtp.getWrappingWidth(true, null), 0);
|
||||
assertEquals(expectedWidth, dtp.getWrappingWidth(false, null), 0);
|
||||
|
||||
// increase insets, the wrapping width should get smaller
|
||||
sh.setLeftInset(10);
|
||||
sh.setRightInset(10);
|
||||
leftInset = sh.getLeftInset();
|
||||
rightInset = sh.getRightInset();
|
||||
assertEquals(10.0, leftInset);
|
||||
assertEquals(10.0, rightInset);
|
||||
assertEquals(10.0, leftInset, 0);
|
||||
assertEquals(10.0, rightInset, 0);
|
||||
expectedWidth = anchor.getWidth() - leftInset - rightInset - leftMargin;
|
||||
assertEquals(244.0, expectedWidth); // 300 - 10 - 10 - 36
|
||||
assertEquals(expectedWidth, p.getWrappingWidth(true, null));
|
||||
assertEquals(expectedWidth, p.getWrappingWidth(false, null));
|
||||
assertEquals(244.0, expectedWidth, 0); // 300 - 10 - 10 - 36
|
||||
assertEquals(expectedWidth, dtp.getWrappingWidth(true, null), 0);
|
||||
assertEquals(expectedWidth, dtp.getWrappingWidth(false, null), 0);
|
||||
|
||||
// set a positive indent of a 0.5 inch. This means "First Line" indentation:
|
||||
// |<--- indent -->|Here goes first line of the text
|
||||
@ -95,34 +118,35 @@ public class TestXSLFTextParagraph extends TestCase {
|
||||
|
||||
p.setIndent(36.0); // 0.5"
|
||||
indent = p.getIndent();
|
||||
assertEquals(36.0, indent);
|
||||
assertEquals(36.0, indent, 0);
|
||||
expectedWidth = anchor.getWidth() - leftInset - rightInset - leftMargin - indent;
|
||||
assertEquals(208.0, expectedWidth); // 300 - 10 - 10 - 36 - 6.4
|
||||
assertEquals(expectedWidth, p.getWrappingWidth(true, null)); // first line is indented
|
||||
assertEquals(208.0, expectedWidth, 0); // 300 - 10 - 10 - 36 - 6.4
|
||||
assertEquals(expectedWidth, dtp.getWrappingWidth(true, null), 0); // first line is indented
|
||||
// other lines are not indented
|
||||
expectedWidth = anchor.getWidth() - leftInset - rightInset - leftMargin;
|
||||
assertEquals(244.0, expectedWidth); // 300 - 10 - 10 - 36
|
||||
assertEquals(expectedWidth, p.getWrappingWidth(false, null));
|
||||
assertEquals(244.0, expectedWidth, 0); // 300 - 10 - 10 - 36
|
||||
assertEquals(expectedWidth, dtp.getWrappingWidth(false, null), 0);
|
||||
|
||||
// set a negative indent of a 1 inch. This means "Hanging" indentation:
|
||||
// Here goes first line of the text
|
||||
// |<--- indent -->|Here go other lines (second and subsequent)
|
||||
p.setIndent(-72.0); // 1"
|
||||
indent = p.getIndent();
|
||||
assertEquals(-72.0, indent);
|
||||
assertEquals(-72.0, indent, 0);
|
||||
expectedWidth = anchor.getWidth() - leftInset - rightInset;
|
||||
assertEquals(280.0, expectedWidth); // 300 - 10 - 10
|
||||
assertEquals(expectedWidth, p.getWrappingWidth(true, null)); // first line is NOT indented
|
||||
assertEquals(280.0, expectedWidth, 0); // 300 - 10 - 10
|
||||
assertEquals(expectedWidth, dtp.getWrappingWidth(true, null), 0); // first line is NOT indented
|
||||
// other lines are indented by leftMargin (the value of indent is not used)
|
||||
expectedWidth = anchor.getWidth() - leftInset - rightInset - leftMargin;
|
||||
assertEquals(244.0, expectedWidth); // 300 - 10 - 10 - 36
|
||||
assertEquals(expectedWidth, p.getWrappingWidth(false, null));
|
||||
assertEquals(244.0, expectedWidth, 0); // 300 - 10 - 10 - 36
|
||||
assertEquals(expectedWidth, dtp.getWrappingWidth(false, null), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* test breaking test into lines.
|
||||
* This test requires that the Arial font is available and will run only on windows
|
||||
*/
|
||||
@Test
|
||||
public void testBreakLines(){
|
||||
String os = System.getProperty("os.name");
|
||||
if(os == null || !os.contains("Windows")) {
|
||||
@ -144,44 +168,52 @@ public class TestXSLFTextParagraph extends TestCase {
|
||||
"residing within the corresponding paragraph.");
|
||||
|
||||
sh.setAnchor(new Rectangle(50, 50, 300, 200));
|
||||
DrawTextParagraphProxy dtp = new DrawTextParagraphProxy(p);
|
||||
|
||||
BufferedImage img = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
|
||||
Graphics2D graphics = img.createGraphics();
|
||||
|
||||
List<TextFragment> lines;
|
||||
lines = p.breakText(graphics);
|
||||
List<DrawTextFragment> lines;
|
||||
dtp.breakText(graphics);
|
||||
lines = dtp.getLines();
|
||||
assertEquals(4, lines.size());
|
||||
|
||||
// descrease the shape width from 300 pt to 100 pt
|
||||
sh.setAnchor(new Rectangle(50, 50, 100, 200));
|
||||
lines = p.breakText(graphics);
|
||||
dtp.breakText(graphics);
|
||||
lines = dtp.getLines();
|
||||
assertEquals(12, lines.size());
|
||||
|
||||
// descrease the shape width from 300 pt to 100 pt
|
||||
sh.setAnchor(new Rectangle(50, 50, 600, 200));
|
||||
lines = p.breakText(graphics);
|
||||
dtp.breakText(graphics);
|
||||
lines = dtp.getLines();
|
||||
assertEquals(2, lines.size());
|
||||
|
||||
// set left and right margins to 200pt. This leaves 200pt for wrapping text
|
||||
sh.setLeftInset(200);
|
||||
sh.setRightInset(200);
|
||||
lines = p.breakText(graphics);
|
||||
dtp.breakText(graphics);
|
||||
lines = dtp.getLines();
|
||||
assertEquals(5, lines.size());
|
||||
|
||||
r.setText("Apache POI");
|
||||
lines = p.breakText(graphics);
|
||||
dtp.breakText(graphics);
|
||||
lines = dtp.getLines();
|
||||
assertEquals(1, lines.size());
|
||||
assertEquals("Apache POI", lines.get(0).getString());
|
||||
|
||||
r.setText("Apache\nPOI");
|
||||
lines = p.breakText(graphics);
|
||||
dtp.breakText(graphics);
|
||||
lines = dtp.getLines();
|
||||
assertEquals(2, lines.size());
|
||||
assertEquals("Apache", lines.get(0).getString());
|
||||
assertEquals("POI", lines.get(1).getString());
|
||||
|
||||
// trailing newlines are ignored
|
||||
r.setText("Apache\nPOI\n");
|
||||
lines = p.breakText(graphics);
|
||||
dtp.breakText(graphics);
|
||||
lines = dtp.getLines();
|
||||
assertEquals(2, lines.size());
|
||||
assertEquals("Apache", lines.get(0).getString());
|
||||
assertEquals("POI", lines.get(1).getString());
|
||||
@ -197,7 +229,8 @@ public class TestXSLFTextParagraph extends TestCase {
|
||||
r3.setFontFamily("serif"); // this should always be available
|
||||
r3.setFontSize(10);
|
||||
r3.setText("POI");
|
||||
lines = p2.breakText(graphics);
|
||||
dtp.breakText(graphics);
|
||||
lines = dtp.getLines();
|
||||
assertEquals(2, lines.size());
|
||||
assertEquals("Apache", lines.get(0).getString());
|
||||
assertEquals("POI", lines.get(1).getString());
|
||||
@ -206,6 +239,7 @@ public class TestXSLFTextParagraph extends TestCase {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testThemeInheritance(){
|
||||
XMLSlideShow ppt = XSLFTestDataSamples.openSampleDocument("prProps.pptx");
|
||||
XSLFShape[] shapes = ppt.getSlides()[0].getShapes();
|
||||
@ -220,6 +254,7 @@ public class TestXSLFTextParagraph extends TestCase {
|
||||
assertEquals(TextAlign.CENTER, sh3.getTextParagraphs().get(0).getTextAlign());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParagraphProperties(){
|
||||
XMLSlideShow ppt = new XMLSlideShow();
|
||||
XSLFSlide slide = ppt.createSlide();
|
||||
@ -242,25 +277,25 @@ public class TestXSLFTextParagraph extends TestCase {
|
||||
p.setBulletFontColor(Color.red);
|
||||
assertEquals(Color.red, p.getBulletFontColor());
|
||||
|
||||
assertEquals(100.0, p.getBulletFontSize());
|
||||
assertEquals(100.0, p.getBulletFontSize(), 0);
|
||||
p.setBulletFontSize(200.);
|
||||
assertEquals(200., p.getBulletFontSize());
|
||||
assertEquals(200., p.getBulletFontSize(), 0);
|
||||
p.setBulletFontSize(-20.);
|
||||
assertEquals(-20.0, p.getBulletFontSize());
|
||||
assertEquals(-20.0, p.getBulletFontSize(), 0);
|
||||
|
||||
assertEquals(72.0, p.getDefaultTabSize());
|
||||
assertEquals(72.0, p.getDefaultTabSize(), 0);
|
||||
|
||||
assertEquals(0.0, p.getIndent());
|
||||
assertEquals(0.0, p.getIndent(), 0);
|
||||
p.setIndent(72.0);
|
||||
assertEquals(72.0, p.getIndent());
|
||||
assertEquals(72.0, p.getIndent(), 0);
|
||||
p.setIndent(-1.0); // the value of -1.0 resets to the defaults
|
||||
assertEquals(0.0, p.getIndent());
|
||||
assertEquals(0.0, p.getIndent(), 0);
|
||||
|
||||
assertEquals(0.0, p.getLeftMargin());
|
||||
assertEquals(0.0, p.getLeftMargin(), 0);
|
||||
p.setLeftMargin(72.0);
|
||||
assertEquals(72.0, p.getLeftMargin());
|
||||
assertEquals(72.0, p.getLeftMargin(), 0);
|
||||
p.setLeftMargin(-1.0); // the value of -1.0 resets to the defaults
|
||||
assertEquals(0.0, p.getLeftMargin());
|
||||
assertEquals(0.0, p.getLeftMargin(), 0);
|
||||
|
||||
assertEquals(0, p.getLevel());
|
||||
p.setLevel(1);
|
||||
@ -268,23 +303,23 @@ public class TestXSLFTextParagraph extends TestCase {
|
||||
p.setLevel(2);
|
||||
assertEquals(2, p.getLevel());
|
||||
|
||||
assertEquals(100., p.getLineSpacing());
|
||||
assertEquals(100., p.getLineSpacing(), 0);
|
||||
p.setLineSpacing(200.);
|
||||
assertEquals(200.0, p.getLineSpacing());
|
||||
assertEquals(200.0, p.getLineSpacing(), 0);
|
||||
p.setLineSpacing(-15.);
|
||||
assertEquals(-15.0, p.getLineSpacing());
|
||||
assertEquals(-15.0, p.getLineSpacing(), 0);
|
||||
|
||||
assertEquals(0., p.getSpaceAfter());
|
||||
assertEquals(0., p.getSpaceAfter(), 0);
|
||||
p.setSpaceAfter(200.);
|
||||
assertEquals(200.0, p.getSpaceAfter());
|
||||
assertEquals(200.0, p.getSpaceAfter(), 0);
|
||||
p.setSpaceAfter(-15.);
|
||||
assertEquals(-15.0, p.getSpaceAfter());
|
||||
assertEquals(-15.0, p.getSpaceAfter(), 0);
|
||||
|
||||
assertEquals(0., p.getSpaceBefore());
|
||||
assertEquals(0., p.getSpaceBefore(), 0);
|
||||
p.setSpaceBefore(200.);
|
||||
assertEquals(200.0, p.getSpaceBefore());
|
||||
assertEquals(200.0, p.getSpaceBefore(), 0);
|
||||
p.setSpaceBefore(-15.);
|
||||
assertEquals(-15.0, p.getSpaceBefore());
|
||||
assertEquals(-15.0, p.getSpaceBefore(), 0);
|
||||
|
||||
assertEquals(TextAlign.LEFT, p.getTextAlign());
|
||||
p.setTextAlign(TextAlign.RIGHT);
|
||||
@ -296,15 +331,16 @@ public class TestXSLFTextParagraph extends TestCase {
|
||||
p.setBulletAutoNumber(ListAutoNumber.ALPHA_LC_PARENT_BOTH, 1);
|
||||
|
||||
double tabStop = p.getTabStop(0);
|
||||
assertEquals(0.0, tabStop);
|
||||
assertEquals(0.0, tabStop, 0);
|
||||
|
||||
p.addTabStop(100.);
|
||||
assertEquals(100., p.getTabStop(0));
|
||||
assertEquals(100., p.getTabStop(0), 0);
|
||||
|
||||
assertEquals(72.0, p.getDefaultTabSize());
|
||||
assertEquals(72.0, p.getDefaultTabSize(), 0);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLineBreak(){
|
||||
XMLSlideShow ppt = new XMLSlideShow();
|
||||
XSLFSlide slide = ppt.createSlide();
|
||||
@ -316,12 +352,12 @@ public class TestXSLFTextParagraph extends TestCase {
|
||||
XSLFTextRun r2 = p.addLineBreak();
|
||||
assertEquals("\n", r2.getText());
|
||||
r2.setFontSize(10.0);
|
||||
assertEquals(10.0, r2.getFontSize());
|
||||
assertEquals(10.0, r2.getFontSize(), 0);
|
||||
XSLFTextRun r3 = p.addNewTextRun();
|
||||
r3.setText("World!");
|
||||
r3.setFontSize(20.0);
|
||||
XSLFTextRun r4 = p.addLineBreak();
|
||||
assertEquals(20.0, r4.getFontSize());
|
||||
assertEquals(20.0, r4.getFontSize(), 0);
|
||||
|
||||
assertEquals("Hello,\nWorld!\n",sh.getText());
|
||||
|
||||
|
@ -16,20 +16,17 @@
|
||||
==================================================================== */
|
||||
package org.apache.poi.xslf.usermodel;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.poi.sl.usermodel.TextAlign;
|
||||
import org.apache.poi.sl.usermodel.TextParagraph.TextAlign;
|
||||
import org.apache.poi.sl.usermodel.VerticalAlignment;
|
||||
import org.apache.poi.xslf.XSLFTestDataSamples;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBodyProperties;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.STTextAlignType;
|
||||
import org.openxmlformats.schemas.drawingml.x2006.main.*;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.CTPlaceholder;
|
||||
import org.openxmlformats.schemas.presentationml.x2006.main.STPlaceholderType;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
/**
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
package org.apache.poi.hslf.blip;
|
||||
|
||||
import org.apache.poi.hslf.usermodel.PictureData;
|
||||
import org.apache.poi.hslf.usermodel.HSLFPictureData;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@ -28,7 +28,7 @@ import java.io.ByteArrayOutputStream;
|
||||
*
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public abstract class Bitmap extends PictureData {
|
||||
public abstract class Bitmap extends HSLFPictureData {
|
||||
|
||||
public byte[] getData(){
|
||||
byte[] rawdata = getRawData();
|
||||
|
@ -17,8 +17,8 @@
|
||||
|
||||
package org.apache.poi.hslf.blip;
|
||||
|
||||
import org.apache.poi.hslf.usermodel.PictureData;
|
||||
import org.apache.poi.hslf.model.Picture;
|
||||
import org.apache.poi.hslf.usermodel.HSLFPictureData;
|
||||
import org.apache.poi.hslf.model.HSLFPictureShape;
|
||||
import org.apache.poi.util.POILogger;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
|
||||
@ -56,7 +56,7 @@ import java.io.ByteArrayInputStream;
|
||||
public final class BitmapPainter implements ImagePainter {
|
||||
protected POILogger logger = POILogFactory.getLogger(this.getClass());
|
||||
|
||||
public void paint(Graphics2D graphics, PictureData pict, Picture parent) {
|
||||
public void paint(Graphics2D graphics, HSLFPictureData pict, HSLFPictureShape parent) {
|
||||
BufferedImage img;
|
||||
try {
|
||||
img = ImageIO.read(new ByteArrayInputStream(pict.getData()));
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
package org.apache.poi.hslf.blip;
|
||||
|
||||
import org.apache.poi.hslf.model.Picture;
|
||||
import org.apache.poi.hslf.model.HSLFPictureShape;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -35,10 +35,10 @@ public final class DIB extends Bitmap {
|
||||
|
||||
/**
|
||||
* @return type of this picture
|
||||
* @see org.apache.poi.hslf.model.Picture#DIB
|
||||
* @see org.apache.poi.hslf.model.HSLFPictureShape#DIB
|
||||
*/
|
||||
public int getType(){
|
||||
return Picture.DIB;
|
||||
return HSLFPictureShape.DIB;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -89,4 +89,8 @@ public final class DIB extends Bitmap {
|
||||
System.arraycopy(data, HEADER_SIZE, dib, 0, dib.length);
|
||||
super.setData(dib);
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
return "image/bmp";
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
package org.apache.poi.hslf.blip;
|
||||
|
||||
import org.apache.poi.hslf.model.Picture;
|
||||
import org.apache.poi.hslf.model.HSLFPictureShape;
|
||||
import org.apache.poi.hslf.model.HSLFShape;
|
||||
import org.apache.poi.hslf.exceptions.HSLFException;
|
||||
|
||||
@ -80,7 +80,7 @@ public final class EMF extends Metafile {
|
||||
}
|
||||
|
||||
public int getType(){
|
||||
return Picture.EMF;
|
||||
return HSLFPictureShape.EMF;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -91,4 +91,8 @@ public final class EMF extends Metafile {
|
||||
public int getSignature(){
|
||||
return 0x3D40;
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
return "image/x-emf";
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,8 @@
|
||||
|
||||
package org.apache.poi.hslf.blip;
|
||||
|
||||
import org.apache.poi.hslf.model.Picture;
|
||||
import org.apache.poi.hslf.usermodel.PictureData;
|
||||
import org.apache.poi.hslf.model.HSLFPictureShape;
|
||||
import org.apache.poi.hslf.usermodel.HSLFPictureData;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
@ -68,5 +68,5 @@ public interface ImagePainter {
|
||||
* @param pict the data to paint
|
||||
* @param parent the shapes that owns the picture data
|
||||
*/
|
||||
public void paint(Graphics2D graphics, PictureData pict, Picture parent);
|
||||
public void paint(Graphics2D graphics, HSLFPictureData pict, HSLFPictureShape parent);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
package org.apache.poi.hslf.blip;
|
||||
|
||||
import org.apache.poi.hslf.model.Picture;
|
||||
import org.apache.poi.hslf.model.HSLFPictureShape;
|
||||
|
||||
/**
|
||||
* Represents a JPEG picture data in a PPT file
|
||||
@ -28,10 +28,10 @@ public final class JPEG extends Bitmap {
|
||||
|
||||
/**
|
||||
* @return type of this picture
|
||||
* @see org.apache.poi.hslf.model.Picture#JPEG
|
||||
* @see org.apache.poi.hslf.model.HSLFPictureShape#JPEG
|
||||
*/
|
||||
public int getType(){
|
||||
return Picture.JPEG;
|
||||
return HSLFPictureShape.JPEG;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -42,4 +42,8 @@ public final class JPEG extends Bitmap {
|
||||
public int getSignature(){
|
||||
return 0x46A0;
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
return "image/jpeg";
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
package org.apache.poi.hslf.blip;
|
||||
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.hslf.usermodel.PictureData;
|
||||
import org.apache.poi.hslf.usermodel.HSLFPictureData;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
@ -30,7 +30,7 @@ import java.util.zip.DeflaterOutputStream;
|
||||
*
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public abstract class Metafile extends PictureData {
|
||||
public abstract class Metafile extends HSLFPictureData {
|
||||
|
||||
/**
|
||||
* A structure which represents a 34-byte header preceeding the compressed metafile data
|
||||
|
@ -23,7 +23,7 @@ import java.io.IOException;
|
||||
import java.util.zip.InflaterInputStream;
|
||||
|
||||
import org.apache.poi.hslf.exceptions.HSLFException;
|
||||
import org.apache.poi.hslf.model.Picture;
|
||||
import org.apache.poi.hslf.model.HSLFPictureShape;
|
||||
import org.apache.poi.hslf.model.HSLFShape;
|
||||
|
||||
/**
|
||||
@ -102,10 +102,10 @@ public final class PICT extends Metafile {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.poi.hslf.model.Picture#PICT
|
||||
* @see org.apache.poi.hslf.model.HSLFPictureShape#PICT
|
||||
*/
|
||||
public int getType(){
|
||||
return Picture.PICT;
|
||||
return HSLFPictureShape.PICT;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -117,4 +117,8 @@ public final class PICT extends Metafile {
|
||||
return 0x5430;
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
return "image/x-pict";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,14 +17,8 @@
|
||||
|
||||
package org.apache.poi.hslf.blip;
|
||||
|
||||
import org.apache.poi.hslf.model.HSLFPictureShape;
|
||||
import org.apache.poi.util.PngUtils;
|
||||
import org.apache.poi.hslf.model.Picture;
|
||||
import org.apache.poi.hslf.exceptions.HSLFException;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Represents a PNG picture data in a PPT file
|
||||
@ -52,10 +46,10 @@ public final class PNG extends Bitmap {
|
||||
|
||||
/**
|
||||
* @return type of this picture
|
||||
* @see org.apache.poi.hslf.model.Picture#PNG
|
||||
* @see org.apache.poi.hslf.model.HSLFPictureShape#PNG
|
||||
*/
|
||||
public int getType(){
|
||||
return Picture.PNG;
|
||||
return HSLFPictureShape.PNG;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,4 +60,8 @@ public final class PNG extends Bitmap {
|
||||
public int getSignature(){
|
||||
return 0x6E00;
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
return "image/png";
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ package org.apache.poi.hslf.blip;
|
||||
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.util.POILogger;
|
||||
import org.apache.poi.hslf.model.Picture;
|
||||
import org.apache.poi.hslf.model.HSLFPictureShape;
|
||||
import org.apache.poi.hslf.model.HSLFShape;
|
||||
import org.apache.poi.hslf.exceptions.HSLFException;
|
||||
|
||||
@ -95,7 +95,7 @@ public final class WMF extends Metafile {
|
||||
* We are of type <code>Picture.WMF</code>
|
||||
*/
|
||||
public int getType(){
|
||||
return Picture.WMF;
|
||||
return HSLFPictureShape.WMF;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -188,4 +188,9 @@ public final class WMF extends Metafile {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getContentType() {
|
||||
return "image/x-wmf";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
package org.apache.poi.hslf.dev;
|
||||
|
||||
import org.apache.poi.hslf.*;
|
||||
import org.apache.poi.hslf.model.HSLFSlideShowImpl;
|
||||
import org.apache.poi.hslf.record.*;
|
||||
|
||||
|
||||
@ -33,7 +34,7 @@ public final class PPDrawingTextListing {
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
HSLFSlideShow ss = new HSLFSlideShow(args[0]);
|
||||
HSLFSlideShowImpl ss = new HSLFSlideShowImpl(args[0]);
|
||||
|
||||
// Find PPDrawings at any second level position
|
||||
Record[] records = ss.getRecords();
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
package org.apache.poi.hslf.dev;
|
||||
|
||||
import org.apache.poi.hslf.HSLFSlideShow;
|
||||
import org.apache.poi.hslf.model.HSLFSlideShowImpl;
|
||||
import org.apache.poi.hslf.record.Document;
|
||||
import org.apache.poi.hslf.record.Record;
|
||||
import org.apache.poi.hslf.record.RecordTypes;
|
||||
@ -35,7 +35,7 @@ public final class SLWTListing {
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
HSLFSlideShow ss = new HSLFSlideShow(args[0]);
|
||||
HSLFSlideShowImpl ss = new HSLFSlideShowImpl(args[0]);
|
||||
|
||||
// Find the documents, and then their SLWT
|
||||
Record[] records = ss.getRecords();
|
||||
|
@ -18,6 +18,7 @@
|
||||
package org.apache.poi.hslf.dev;
|
||||
|
||||
import org.apache.poi.hslf.*;
|
||||
import org.apache.poi.hslf.model.HSLFSlideShowImpl;
|
||||
import org.apache.poi.hslf.record.*;
|
||||
|
||||
/**
|
||||
@ -32,7 +33,7 @@ public final class SLWTTextListing {
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
HSLFSlideShow ss = new HSLFSlideShow(args[0]);
|
||||
HSLFSlideShowImpl ss = new HSLFSlideShowImpl(args[0]);
|
||||
|
||||
// Find the documents, and then their SLWT
|
||||
Record[] records = ss.getRecords();
|
||||
|
@ -18,6 +18,7 @@
|
||||
package org.apache.poi.hslf.dev;
|
||||
|
||||
import org.apache.poi.hslf.*;
|
||||
import org.apache.poi.hslf.model.HSLFSlideShowImpl;
|
||||
import org.apache.poi.hslf.record.*;
|
||||
|
||||
|
||||
@ -34,7 +35,7 @@ public final class SlideAndNotesAtomListing {
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
HSLFSlideShow ss = new HSLFSlideShow(args[0]);
|
||||
HSLFSlideShowImpl ss = new HSLFSlideShowImpl(args[0]);
|
||||
System.out.println("");
|
||||
|
||||
// Find either Slides or Notes
|
||||
|
@ -20,7 +20,7 @@ package org.apache.poi.hslf.dev;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.poi.hslf.HSLFSlideShow;
|
||||
import org.apache.poi.hslf.model.HSLFSlideShowImpl;
|
||||
import org.apache.poi.hslf.record.Document;
|
||||
import org.apache.poi.hslf.record.Notes;
|
||||
import org.apache.poi.hslf.record.NotesAtom;
|
||||
@ -31,7 +31,7 @@ import org.apache.poi.hslf.record.Slide;
|
||||
import org.apache.poi.hslf.record.SlideAtom;
|
||||
import org.apache.poi.hslf.record.SlideListWithText;
|
||||
import org.apache.poi.hslf.record.SlidePersistAtom;
|
||||
import org.apache.poi.hslf.usermodel.SlideShow;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
||||
/**
|
||||
@ -50,8 +50,8 @@ public final class SlideIdListing {
|
||||
|
||||
|
||||
// Create the slideshow object, for normal working with
|
||||
HSLFSlideShow hss = new HSLFSlideShow(args[0]);
|
||||
SlideShow ss = new SlideShow(hss);
|
||||
HSLFSlideShowImpl hss = new HSLFSlideShowImpl(args[0]);
|
||||
HSLFSlideShow ss = new HSLFSlideShow(hss);
|
||||
|
||||
// Grab the base contents
|
||||
fileContents = hss.getUnderlyingBytes();
|
||||
|
@ -19,10 +19,9 @@ package org.apache.poi.hslf.dev;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.poi.hslf.HSLFSlideShow;
|
||||
import org.apache.poi.hslf.model.HSLFSlideShowImpl;
|
||||
import org.apache.poi.hslf.record.Record;
|
||||
import org.apache.poi.util.HexDump;
|
||||
import org.apache.poi.ddf.DefaultEscherRecordFactory;
|
||||
@ -44,7 +43,7 @@ import org.apache.poi.hslf.record.StyleTextPropAtom;
|
||||
public final class SlideShowRecordDumper {
|
||||
private boolean optVerbose;
|
||||
private boolean optEscher;
|
||||
private HSLFSlideShow doc;
|
||||
private HSLFSlideShowImpl doc;
|
||||
|
||||
/**
|
||||
* right now this function takes one parameter: a ppt file, and outputs
|
||||
@ -103,7 +102,7 @@ public final class SlideShowRecordDumper {
|
||||
{
|
||||
optVerbose = verbose;
|
||||
optEscher = escher;
|
||||
doc = new HSLFSlideShow(fileName);
|
||||
doc = new HSLFSlideShowImpl(fileName);
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
package org.apache.poi.hslf.dev;
|
||||
|
||||
import org.apache.poi.hslf.*;
|
||||
import org.apache.poi.hslf.model.HSLFSlideShowImpl;
|
||||
import org.apache.poi.hslf.model.textproperties.BitMaskTextProp;
|
||||
import org.apache.poi.hslf.model.textproperties.TextProp;
|
||||
import org.apache.poi.hslf.model.textproperties.TextPropCollection;
|
||||
@ -36,7 +37,7 @@ public final class TextStyleListing {
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
HSLFSlideShow ss = new HSLFSlideShow(args[0]);
|
||||
HSLFSlideShowImpl ss = new HSLFSlideShowImpl(args[0]);
|
||||
|
||||
// Find the documents, and then their SLWT
|
||||
Record[] records = ss.getRecords();
|
||||
|
@ -20,7 +20,7 @@ package org.apache.poi.hslf.dev;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.poi.hslf.HSLFSlideShow;
|
||||
import org.apache.poi.hslf.model.HSLFSlideShowImpl;
|
||||
import org.apache.poi.hslf.record.CurrentUserAtom;
|
||||
import org.apache.poi.hslf.record.PersistPtrHolder;
|
||||
import org.apache.poi.hslf.record.PositionDependentRecord;
|
||||
@ -44,7 +44,7 @@ public final class UserEditAndPersistListing {
|
||||
|
||||
|
||||
// Create the slideshow object, for normal working with
|
||||
HSLFSlideShow ss = new HSLFSlideShow(args[0]);
|
||||
HSLFSlideShowImpl ss = new HSLFSlideShowImpl(args[0]);
|
||||
fileContents = ss.getUnderlyingBytes();
|
||||
System.out.println("");
|
||||
|
||||
|
@ -17,10 +17,10 @@
|
||||
|
||||
package org.apache.poi.hslf.extractor;
|
||||
|
||||
import org.apache.poi.hslf.usermodel.SlideShow;
|
||||
import org.apache.poi.hslf.usermodel.PictureData;
|
||||
import org.apache.poi.hslf.HSLFSlideShow;
|
||||
import org.apache.poi.hslf.model.Picture;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.hslf.usermodel.HSLFPictureData;
|
||||
import org.apache.poi.hslf.model.HSLFPictureShape;
|
||||
import org.apache.poi.hslf.model.HSLFSlideShowImpl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.FileOutputStream;
|
||||
@ -37,12 +37,12 @@ public final class ImageExtractor {
|
||||
System.err.println("\tImageExtractor <file>");
|
||||
return;
|
||||
}
|
||||
SlideShow ppt = new SlideShow(new HSLFSlideShow(args[0]));
|
||||
HSLFSlideShow ppt = new HSLFSlideShow(new HSLFSlideShowImpl(args[0]));
|
||||
|
||||
//extract all pictures contained in the presentation
|
||||
PictureData[] pdata = ppt.getPictureData();
|
||||
HSLFPictureData[] pdata = ppt.getPictureData();
|
||||
for (int i = 0; i < pdata.length; i++) {
|
||||
PictureData pict = pdata[i];
|
||||
HSLFPictureData pict = pdata[i];
|
||||
|
||||
// picture data
|
||||
byte[] data = pict.getData();
|
||||
@ -50,22 +50,22 @@ public final class ImageExtractor {
|
||||
int type = pict.getType();
|
||||
String ext;
|
||||
switch (type) {
|
||||
case Picture.JPEG:
|
||||
case HSLFPictureShape.JPEG:
|
||||
ext = ".jpg";
|
||||
break;
|
||||
case Picture.PNG:
|
||||
case HSLFPictureShape.PNG:
|
||||
ext = ".png";
|
||||
break;
|
||||
case Picture.WMF:
|
||||
case HSLFPictureShape.WMF:
|
||||
ext = ".wmf";
|
||||
break;
|
||||
case Picture.EMF:
|
||||
case HSLFPictureShape.EMF:
|
||||
ext = ".emf";
|
||||
break;
|
||||
case Picture.PICT:
|
||||
case HSLFPictureShape.PICT:
|
||||
ext = ".pict";
|
||||
break;
|
||||
case Picture.DIB:
|
||||
case HSLFPictureShape.DIB:
|
||||
ext = ".dib";
|
||||
break;
|
||||
default:
|
||||
|
@ -25,9 +25,8 @@ import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.apache.poi.POIOLE2TextExtractor;
|
||||
import org.apache.poi.hslf.HSLFSlideShow;
|
||||
import org.apache.poi.hslf.model.*;
|
||||
import org.apache.poi.hslf.usermodel.SlideShow;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.poifs.filesystem.DirectoryNode;
|
||||
import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
@ -39,9 +38,9 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
* @author Nick Burch
|
||||
*/
|
||||
public final class PowerPointExtractor extends POIOLE2TextExtractor {
|
||||
private HSLFSlideShow _hslfshow;
|
||||
private SlideShow _show;
|
||||
private Slide[] _slides;
|
||||
private HSLFSlideShowImpl _hslfshow;
|
||||
private HSLFSlideShow _show;
|
||||
private HSLFSlide[] _slides;
|
||||
|
||||
private boolean _slidesByDefault = true;
|
||||
private boolean _notesByDefault = false;
|
||||
@ -120,7 +119,7 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor {
|
||||
* @param dir the POIFS Directory containing the PowerPoint document
|
||||
*/
|
||||
public PowerPointExtractor(DirectoryNode dir) throws IOException {
|
||||
this(new HSLFSlideShow(dir));
|
||||
this(new HSLFSlideShowImpl(dir));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -128,7 +127,7 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor {
|
||||
*/
|
||||
@Deprecated
|
||||
public PowerPointExtractor(DirectoryNode dir, POIFSFileSystem fs) throws IOException {
|
||||
this(new HSLFSlideShow(dir, fs));
|
||||
this(new HSLFSlideShowImpl(dir, fs));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -136,10 +135,10 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor {
|
||||
*
|
||||
* @param ss the HSLFSlideShow to extract text from
|
||||
*/
|
||||
public PowerPointExtractor(HSLFSlideShow ss) {
|
||||
public PowerPointExtractor(HSLFSlideShowImpl ss) {
|
||||
super(ss);
|
||||
_hslfshow = ss;
|
||||
_show = new SlideShow(_hslfshow);
|
||||
_show = new HSLFSlideShow(_hslfshow);
|
||||
_slides = _show.getSlides();
|
||||
}
|
||||
|
||||
@ -190,7 +189,7 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor {
|
||||
List<OLEShape> list = new ArrayList<OLEShape>();
|
||||
|
||||
for (int i = 0; i < _slides.length; i++) {
|
||||
Slide slide = _slides[i];
|
||||
HSLFSlide slide = _slides[i];
|
||||
|
||||
HSLFShape[] shapes = slide.getShapes();
|
||||
for (int j = 0; j < shapes.length; j++) {
|
||||
@ -222,14 +221,14 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor {
|
||||
if (getMasterText) {
|
||||
for (SlideMaster master : _show.getSlidesMasters()) {
|
||||
for(HSLFShape sh : master.getShapes()){
|
||||
if(sh instanceof TextShape){
|
||||
if(MasterSheet.isPlaceholder(sh)) {
|
||||
if(sh instanceof HSLFTextShape){
|
||||
if(HSLFMasterSheet.isPlaceholder(sh)) {
|
||||
// don't bother about boiler
|
||||
// plate text on master
|
||||
// sheets
|
||||
continue;
|
||||
}
|
||||
TextShape tsh = (TextShape)sh;
|
||||
HSLFTextShape tsh = (HSLFTextShape)sh;
|
||||
String text = tsh.getText();
|
||||
if (text != null){
|
||||
ret.append(text);
|
||||
@ -243,7 +242,7 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor {
|
||||
}
|
||||
|
||||
for (int i = 0; i < _slides.length; i++) {
|
||||
Slide slide = _slides[i];
|
||||
HSLFSlide slide = _slides[i];
|
||||
|
||||
// Slide header, if set
|
||||
HeadersFooters hf = slide.getHeadersFooters();
|
||||
@ -286,7 +285,7 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor {
|
||||
HeadersFooters hf = _show.getNotesHeadersFooters();
|
||||
|
||||
for (int i = 0; i < _slides.length; i++) {
|
||||
Notes notes = _slides[i].getNotesSheet();
|
||||
HSLFNotes notes = _slides[i].getNotesSheet();
|
||||
if (notes == null) {
|
||||
continue;
|
||||
}
|
||||
@ -331,13 +330,13 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor {
|
||||
ret.append('\n');
|
||||
}
|
||||
}
|
||||
private void textRunsToText(StringBuffer ret, TextRun[] runs) {
|
||||
private void textRunsToText(StringBuffer ret, HSLFTextParagraph[] runs) {
|
||||
if (runs==null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int j = 0; j < runs.length; j++) {
|
||||
TextRun run = runs[j];
|
||||
HSLFTextParagraph run = runs[j];
|
||||
if (run != null) {
|
||||
String text = run.getText();
|
||||
ret.append(text);
|
||||
|
@ -23,7 +23,7 @@ import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.hslf.model.TextRun;
|
||||
import org.apache.poi.hslf.model.HSLFTextParagraph;
|
||||
import org.apache.poi.hslf.record.CString;
|
||||
import org.apache.poi.hslf.record.Record;
|
||||
import org.apache.poi.hslf.record.RecordTypes;
|
||||
@ -175,17 +175,17 @@ public final class QuickButCruddyTextExtractor {
|
||||
|
||||
// Otherwise, check the type to see if it's text
|
||||
long type = LittleEndian.getUShort(pptContents,startPos+2);
|
||||
TextRun trun = null;
|
||||
HSLFTextParagraph trun = null;
|
||||
|
||||
// TextBytesAtom
|
||||
if(type == RecordTypes.TextBytesAtom.typeID) {
|
||||
TextBytesAtom tba = (TextBytesAtom)Record.createRecordForType(type, pptContents, startPos, len+8);
|
||||
trun = new TextRun((TextHeaderAtom)null,tba,(StyleTextPropAtom)null);
|
||||
trun = new HSLFTextParagraph((TextHeaderAtom)null,tba,(StyleTextPropAtom)null);
|
||||
}
|
||||
// TextCharsAtom
|
||||
if(type == RecordTypes.TextCharsAtom.typeID) {
|
||||
TextCharsAtom tca = (TextCharsAtom)Record.createRecordForType(type, pptContents, startPos, len+8);
|
||||
trun = new TextRun((TextHeaderAtom)null,tca,(StyleTextPropAtom)null);
|
||||
trun = new HSLFTextParagraph((TextHeaderAtom)null,tca,(StyleTextPropAtom)null);
|
||||
}
|
||||
|
||||
// CString (doesn't go via a TextRun)
|
||||
|
@ -45,7 +45,7 @@ import org.apache.poi.util.StringUtil;
|
||||
* TODO: finish
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public final class ActiveXShape extends Picture {
|
||||
public final class ActiveXShape extends HSLFPictureShape {
|
||||
public static final int DEFAULT_ACTIVEX_THUMBNAIL = -1;
|
||||
|
||||
/**
|
||||
@ -108,7 +108,7 @@ public final class ActiveXShape extends Picture {
|
||||
/**
|
||||
* Assign a control to this shape
|
||||
*
|
||||
* @see org.apache.poi.hslf.usermodel.SlideShow#addMovie(String, int)
|
||||
* @see org.apache.poi.hslf.usermodel.HSLFSlideShow#addMovie(String, int)
|
||||
* @param idx the index of the movie
|
||||
*/
|
||||
public void setActiveXIndex(int idx){
|
||||
@ -164,7 +164,7 @@ public final class ActiveXShape extends Picture {
|
||||
return ctrl;
|
||||
}
|
||||
|
||||
protected void afterInsert(Sheet sheet){
|
||||
protected void afterInsert(HSLFSheet sheet){
|
||||
ExControl ctrl = getExControl();
|
||||
ctrl.getExControlAtom().setSlideId(sheet._getSheetNumber());
|
||||
|
||||
|
@ -1,81 +0,0 @@
|
||||
/* ====================================================================
|
||||
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.hslf.model;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.apache.poi.ddf.EscherContainerRecord;
|
||||
import org.apache.poi.hslf.blip.Bitmap;
|
||||
import org.apache.poi.hslf.usermodel.PictureData;
|
||||
import org.apache.poi.sl.usermodel.ShapeContainer;
|
||||
import org.apache.poi.util.POILogger;
|
||||
|
||||
/**
|
||||
* Background shape
|
||||
*
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public final class Background extends HSLFShape {
|
||||
|
||||
protected Background(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent) {
|
||||
super(escherRecord, parent);
|
||||
}
|
||||
|
||||
protected EscherContainerRecord createSpContainer(boolean isChild) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void draw(Graphics2D graphics) {
|
||||
Fill f = getFill();
|
||||
Dimension pg = getSheet().getSlideShow().getPageSize();
|
||||
Rectangle anchor = new Rectangle(0, 0, pg.width, pg.height);
|
||||
switch (f.getFillType()) {
|
||||
case Fill.FILL_SOLID:
|
||||
Color color = f.getForegroundColor();
|
||||
graphics.setPaint(color);
|
||||
graphics.fill(anchor);
|
||||
break;
|
||||
case Fill.FILL_PICTURE:
|
||||
PictureData data = f.getPictureData();
|
||||
if (data instanceof Bitmap) {
|
||||
BufferedImage img = null;
|
||||
try {
|
||||
img = ImageIO.read(new ByteArrayInputStream(data.getData()));
|
||||
} catch (Exception e) {
|
||||
logger.log(POILogger.WARN, "ImageIO failed to create image. image.type: " + data.getType());
|
||||
return;
|
||||
}
|
||||
Image scaledImg = img.getScaledInstance(anchor.width, anchor.height, Image.SCALE_SMOOTH);
|
||||
graphics.drawImage(scaledImg, anchor.x, anchor.y, null);
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
logger.log(POILogger.WARN, "unsuported fill type: " + f.getFillType());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -18,11 +18,13 @@
|
||||
package org.apache.poi.hslf.model;
|
||||
|
||||
import org.apache.poi.ddf.*;
|
||||
import org.apache.poi.sl.usermodel.ShapeContainer;
|
||||
import org.apache.poi.sl.usermodel.ShapeType;
|
||||
import org.apache.poi.sl.draw.geom.CustomGeometry;
|
||||
import org.apache.poi.sl.draw.geom.Guide;
|
||||
import org.apache.poi.sl.usermodel.*;
|
||||
import org.apache.poi.util.POILogger;
|
||||
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Represents an AutoShape.
|
||||
@ -33,18 +35,18 @@ import java.awt.geom.Rectangle2D;
|
||||
*
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public class AutoShape extends TextShape {
|
||||
public class HSLFAutoShape extends HSLFTextShape implements AutoShape<HSLFTextParagraph> {
|
||||
|
||||
protected AutoShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
|
||||
protected HSLFAutoShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
|
||||
super(escherRecord, parent);
|
||||
}
|
||||
|
||||
public AutoShape(ShapeType type, ShapeContainer<HSLFShape> parent){
|
||||
public HSLFAutoShape(ShapeType type, ShapeContainer<HSLFShape> parent){
|
||||
super(null, parent);
|
||||
_escherContainer = createSpContainer(type, parent instanceof HSLFGroupShape);
|
||||
}
|
||||
|
||||
public AutoShape(ShapeType type){
|
||||
public HSLFAutoShape(ShapeType type){
|
||||
this(type, null);
|
||||
}
|
||||
|
||||
@ -66,10 +68,10 @@ public class AutoShape extends TextShape {
|
||||
return _escherContainer;
|
||||
}
|
||||
|
||||
protected void setDefaultTextProperties(TextRun _txtrun){
|
||||
setVerticalAlignment(TextBox.AnchorMiddle);
|
||||
setHorizontalAlignment(TextBox.AlignCenter);
|
||||
setWordWrap(TextBox.WrapNone);
|
||||
protected void setDefaultTextProperties(HSLFTextParagraph _txtrun){
|
||||
setVerticalAlignment(HSLFTextBox.AnchorMiddle);
|
||||
setHorizontalAlignment(HSLFTextBox.AlignCenter);
|
||||
setWordWrap(HSLFTextBox.WrapNone);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -118,5 +120,4 @@ public class AutoShape extends TextShape {
|
||||
java.awt.Shape shape = outline.getOutline(this);
|
||||
return AutoShapes.transform(shape, anchor);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/* ====================================================================
|
||||
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.hslf.model;
|
||||
|
||||
import org.apache.poi.ddf.EscherContainerRecord;
|
||||
import org.apache.poi.sl.usermodel.Background;
|
||||
import org.apache.poi.sl.usermodel.ShapeContainer;
|
||||
|
||||
/**
|
||||
* Background shape
|
||||
*
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public final class HSLFBackground extends HSLFShape implements Background {
|
||||
|
||||
protected HSLFBackground(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent) {
|
||||
super(escherRecord, parent);
|
||||
}
|
||||
|
||||
protected EscherContainerRecord createSpContainer(boolean isChild) {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -18,17 +18,17 @@
|
||||
package org.apache.poi.hslf.model;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.ddf.EscherBSERecord;
|
||||
import org.apache.poi.ddf.EscherContainerRecord;
|
||||
import org.apache.poi.ddf.EscherOptRecord;
|
||||
import org.apache.poi.ddf.EscherProperties;
|
||||
import org.apache.poi.ddf.EscherRecord;
|
||||
import org.apache.poi.ddf.EscherSimpleProperty;
|
||||
import org.apache.poi.ddf.*;
|
||||
import org.apache.poi.hslf.record.Document;
|
||||
import org.apache.poi.hslf.usermodel.PictureData;
|
||||
import org.apache.poi.hslf.usermodel.SlideShow;
|
||||
import org.apache.poi.hslf.usermodel.HSLFPictureData;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.sl.usermodel.*;
|
||||
import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;
|
||||
import org.apache.poi.sl.usermodel.PaintStyle.TexturePaint;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
|
||||
@ -37,7 +37,7 @@ import org.apache.poi.util.POILogger;
|
||||
*
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public final class Fill {
|
||||
public final class HSLFFill {
|
||||
// For logging
|
||||
protected POILogger logger = POILogFactory.getLogger(this.getClass());
|
||||
|
||||
@ -106,10 +106,55 @@ public final class Fill {
|
||||
*
|
||||
* @param shape the shape this background applies to
|
||||
*/
|
||||
public Fill(HSLFShape shape){
|
||||
public HSLFFill(HSLFShape shape){
|
||||
this.shape = shape;
|
||||
}
|
||||
|
||||
|
||||
public FillStyle getFillStyle() {
|
||||
return new FillStyle() {
|
||||
public PaintStyle getPaint() {
|
||||
switch (getFillType()) {
|
||||
case FILL_SOLID: {
|
||||
return new SolidPaint() {
|
||||
public ColorStyle getSolidColor() {
|
||||
return new ColorStyle() {
|
||||
public Color getColor() { return getForegroundColor(); }
|
||||
public int getAlpha() { return -1; }
|
||||
public int getLumOff() { return -1; }
|
||||
public int getLumMod() { return -1; }
|
||||
public int getShade() { return -1; }
|
||||
public int getTint() { return -1; }
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
case FILL_PICTURE: {
|
||||
return new TexturePaint() {
|
||||
final HSLFPictureData pd = getPictureData();
|
||||
|
||||
public InputStream getImageData() {
|
||||
return new ByteArrayInputStream(pd.getData());
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
return pd.getContentType();
|
||||
}
|
||||
|
||||
public int getAlpha() {
|
||||
return (int)(shape.getAlpha(EscherProperties.FILL__FILLOPACITY)*100000.0);
|
||||
}
|
||||
};
|
||||
}
|
||||
default:
|
||||
logger.log(POILogger.WARN, "unsuported fill type: " + getFillType());
|
||||
break;
|
||||
}
|
||||
return PaintStyle.TRANSPARENT_PAINT;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns fill type.
|
||||
* Must be one of the <code>FILL_*</code> constants defined in this class.
|
||||
@ -124,7 +169,7 @@ public final class Fill {
|
||||
|
||||
/**
|
||||
*/
|
||||
protected void afterInsert(Sheet sh){
|
||||
protected void afterInsert(HSLFSheet sh){
|
||||
EscherOptRecord opt = shape.getEscherOptRecord();
|
||||
EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE);
|
||||
if(p != null) {
|
||||
@ -135,12 +180,12 @@ public final class Fill {
|
||||
}
|
||||
|
||||
protected EscherBSERecord getEscherBSERecord(int idx){
|
||||
Sheet sheet = shape.getSheet();
|
||||
HSLFSheet sheet = shape.getSheet();
|
||||
if(sheet == null) {
|
||||
logger.log(POILogger.DEBUG, "Fill has not yet been assigned to a sheet");
|
||||
return null;
|
||||
}
|
||||
SlideShow ppt = sheet.getSlideShow();
|
||||
HSLFSlideShow ppt = sheet.getSlideShow();
|
||||
Document doc = ppt.getDocumentRecord();
|
||||
EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
|
||||
EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
|
||||
@ -220,13 +265,13 @@ public final class Fill {
|
||||
/**
|
||||
* <code>PictureData</code> object used in a texture, pattern of picture fill.
|
||||
*/
|
||||
public PictureData getPictureData(){
|
||||
public HSLFPictureData getPictureData(){
|
||||
EscherOptRecord opt = shape.getEscherOptRecord();
|
||||
EscherSimpleProperty p = HSLFShape.getEscherProperty(opt, EscherProperties.FILL__PATTERNTEXTURE);
|
||||
if (p == null) return null;
|
||||
|
||||
SlideShow ppt = shape.getSheet().getSlideShow();
|
||||
PictureData[] pict = ppt.getPictureData();
|
||||
HSLFSlideShow ppt = shape.getSheet().getSlideShow();
|
||||
HSLFPictureData[] pict = ppt.getPictureData();
|
||||
Document doc = ppt.getDocumentRecord();
|
||||
|
||||
EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
|
@ -45,7 +45,7 @@ import org.apache.poi.util.POILogger;
|
||||
* </p>
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public final class Freeform extends AutoShape {
|
||||
public final class HSLFFreeformShape extends HSLFAutoShape {
|
||||
|
||||
public static final byte[] SEGMENTINFO_MOVETO = new byte[]{0x00, 0x40};
|
||||
public static final byte[] SEGMENTINFO_LINETO = new byte[]{0x00, (byte)0xAC};
|
||||
@ -62,7 +62,7 @@ public final class Freeform extends AutoShape {
|
||||
* @param escherRecord <code>EscherSpContainer</code> container which holds information about this shape
|
||||
* @param parent the parent of the shape
|
||||
*/
|
||||
protected Freeform(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
|
||||
protected HSLFFreeformShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
|
||||
super(escherRecord, parent);
|
||||
|
||||
}
|
||||
@ -73,7 +73,7 @@ public final class Freeform extends AutoShape {
|
||||
* @param parent the parent of this Shape. For example, if this text box is a cell
|
||||
* in a table then the parent is Table.
|
||||
*/
|
||||
public Freeform(ShapeContainer<HSLFShape> parent){
|
||||
public HSLFFreeformShape(ShapeContainer<HSLFShape> parent){
|
||||
super((EscherContainerRecord)null, parent);
|
||||
_escherContainer = createSpContainer(ShapeType.NOT_PRIMITIVE, parent instanceof HSLFGroupShape);
|
||||
}
|
||||
@ -82,7 +82,7 @@ public final class Freeform extends AutoShape {
|
||||
* Create a new Freeform. This constructor is used when a new shape is created.
|
||||
*
|
||||
*/
|
||||
public Freeform(){
|
||||
public HSLFFreeformShape(){
|
||||
this(null);
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ public class HSLFGroupShape extends HSLFShape implements ShapeContainer<HSLFShap
|
||||
public void addShape(HSLFShape shape){
|
||||
_escherContainer.addChildRecord(shape.getSpContainer());
|
||||
|
||||
Sheet sheet = getSheet();
|
||||
HSLFSheet sheet = getSheet();
|
||||
shape.setSheet(sheet);
|
||||
shape.setShapeId(sheet.allocateShapeId());
|
||||
shape.afterInsert(sheet);
|
||||
|
@ -18,7 +18,9 @@
|
||||
package org.apache.poi.hslf.model;
|
||||
|
||||
import org.apache.poi.hslf.record.SheetContainer;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.hslf.model.textproperties.TextProp;
|
||||
import org.apache.poi.sl.usermodel.MasterSheet;
|
||||
|
||||
/**
|
||||
* The superclass of all master sheets - Slide masters, Notes masters, etc.
|
||||
@ -27,8 +29,8 @@ import org.apache.poi.hslf.model.textproperties.TextProp;
|
||||
*
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public abstract class MasterSheet extends Sheet {
|
||||
public MasterSheet(SheetContainer container, int sheetNo){
|
||||
public abstract class HSLFMasterSheet extends HSLFSheet implements MasterSheet<HSLFShape,HSLFSlideShow> {
|
||||
public HSLFMasterSheet(SheetContainer container, int sheetNo){
|
||||
super(container, sheetNo);
|
||||
}
|
||||
|
||||
@ -47,9 +49,9 @@ public abstract class MasterSheet extends Sheet {
|
||||
* @return true if the shape is a placeholder
|
||||
*/
|
||||
public static boolean isPlaceholder(HSLFShape shape){
|
||||
if(!(shape instanceof TextShape)) return false;
|
||||
if(!(shape instanceof HSLFTextShape)) return false;
|
||||
|
||||
TextShape tx = (TextShape)shape;
|
||||
HSLFTextShape tx = (HSLFTextShape)shape;
|
||||
return tx.getPlaceholderAtom() != null;
|
||||
}
|
||||
}
|
@ -17,6 +17,12 @@
|
||||
|
||||
package org.apache.poi.hslf.model;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.sl.usermodel.Notes;
|
||||
|
||||
/**
|
||||
* This class represents a slide's notes in a PowerPoint Document. It
|
||||
* allows access to the text within, and the layout. For now, it only
|
||||
@ -25,42 +31,45 @@ package org.apache.poi.hslf.model;
|
||||
* @author Nick Burch
|
||||
*/
|
||||
|
||||
public final class Notes extends Sheet
|
||||
{
|
||||
private TextRun[] _runs;
|
||||
public final class HSLFNotes extends HSLFSheet implements Notes<HSLFShape, HSLFSlideShow> {
|
||||
private HSLFTextParagraph[] _runs;
|
||||
|
||||
/**
|
||||
* Constructs a Notes Sheet from the given Notes record.
|
||||
* Initialises TextRuns, to provide easier access to the text
|
||||
*
|
||||
* @param notes the Notes record to read from
|
||||
*/
|
||||
public Notes (org.apache.poi.hslf.record.Notes notes) {
|
||||
super(notes, notes.getNotesAtom().getSlideID());
|
||||
/**
|
||||
* Constructs a Notes Sheet from the given Notes record.
|
||||
* Initialises TextRuns, to provide easier access to the text
|
||||
*
|
||||
* @param notes the Notes record to read from
|
||||
*/
|
||||
public HSLFNotes(org.apache.poi.hslf.record.Notes notes) {
|
||||
super(notes, notes.getNotesAtom().getSlideID());
|
||||
|
||||
// Now, build up TextRuns from pairs of TextHeaderAtom and
|
||||
// one of TextBytesAtom or TextCharsAtom, found inside
|
||||
// EscherTextboxWrapper's in the PPDrawing
|
||||
_runs = findTextRuns(getPPDrawing());
|
||||
// Now, build up TextRuns from pairs of TextHeaderAtom and
|
||||
// one of TextBytesAtom or TextCharsAtom, found inside
|
||||
// EscherTextboxWrapper's in the PPDrawing
|
||||
_runs = findTextRuns(getPPDrawing());
|
||||
|
||||
// Set the sheet on each TextRun
|
||||
for (int i = 0; i < _runs.length; i++)
|
||||
_runs[i].setSheet(this);
|
||||
}
|
||||
// Set the sheet on each TextRun
|
||||
for (HSLFTextParagraph tp : _runs) {
|
||||
tp.supplySheet(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of all the TextRuns found
|
||||
*/
|
||||
public HSLFTextParagraph[] getTextRuns() {
|
||||
return _runs;
|
||||
}
|
||||
|
||||
// Accesser methods follow
|
||||
|
||||
/**
|
||||
* Returns an array of all the TextRuns found
|
||||
*/
|
||||
public TextRun[] getTextRuns() { return _runs; }
|
||||
|
||||
@Override
|
||||
public List<HSLFTextParagraph> getTextParagraphs() {
|
||||
return Arrays.asList(_runs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return <code>null</code> - Notes Masters are not yet supported
|
||||
*/
|
||||
public MasterSheet getMasterSheet() {
|
||||
public HSLFMasterSheet getMasterSheet() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -37,8 +37,8 @@ import org.apache.poi.ddf.EscherSimpleProperty;
|
||||
import org.apache.poi.ddf.EscherSpRecord;
|
||||
import org.apache.poi.hslf.blip.Bitmap;
|
||||
import org.apache.poi.hslf.record.Document;
|
||||
import org.apache.poi.hslf.usermodel.PictureData;
|
||||
import org.apache.poi.hslf.usermodel.SlideShow;
|
||||
import org.apache.poi.hslf.usermodel.HSLFPictureData;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.sl.usermodel.ShapeContainer;
|
||||
import org.apache.poi.sl.usermodel.ShapeType;
|
||||
import org.apache.poi.util.POILogger;
|
||||
@ -51,7 +51,7 @@ import org.apache.poi.util.Units;
|
||||
*
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public class Picture extends SimpleShape {
|
||||
public class HSLFPictureShape extends HSLFSimpleShape {
|
||||
|
||||
/**
|
||||
* Windows Enhanced Metafile (EMF)
|
||||
@ -88,7 +88,7 @@ public class Picture extends SimpleShape {
|
||||
*
|
||||
* @param idx the index of the picture
|
||||
*/
|
||||
public Picture(int idx){
|
||||
public HSLFPictureShape(int idx){
|
||||
this(idx, null);
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ public class Picture extends SimpleShape {
|
||||
* @param idx the index of the picture
|
||||
* @param parent the parent shape
|
||||
*/
|
||||
public Picture(int idx, ShapeContainer<HSLFShape> parent) {
|
||||
public HSLFPictureShape(int idx, ShapeContainer<HSLFShape> parent) {
|
||||
super(null, parent);
|
||||
_escherContainer = createSpContainer(idx, parent instanceof HSLFGroupShape);
|
||||
}
|
||||
@ -110,7 +110,7 @@ public class Picture extends SimpleShape {
|
||||
* this picture in the <code>Slide</code>
|
||||
* @param parent the parent shape of this picture
|
||||
*/
|
||||
protected Picture(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
|
||||
protected HSLFPictureShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
|
||||
super(escherRecord, parent);
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ public class Picture extends SimpleShape {
|
||||
* for other types sets the default size of 200x200 pixels.
|
||||
*/
|
||||
public void setDefaultSize(){
|
||||
PictureData pict = getPictureData();
|
||||
HSLFPictureData pict = getPictureData();
|
||||
if (pict instanceof Bitmap){
|
||||
BufferedImage img = null;
|
||||
try {
|
||||
@ -183,9 +183,9 @@ public class Picture extends SimpleShape {
|
||||
*
|
||||
* @return the picture data for this picture.
|
||||
*/
|
||||
public PictureData getPictureData(){
|
||||
SlideShow ppt = getSheet().getSlideShow();
|
||||
PictureData[] pict = ppt.getPictureData();
|
||||
public HSLFPictureData getPictureData(){
|
||||
HSLFSlideShow ppt = getSheet().getSlideShow();
|
||||
HSLFPictureData[] pict = ppt.getPictureData();
|
||||
|
||||
EscherBSERecord bse = getEscherBSERecord();
|
||||
if (bse == null){
|
||||
@ -202,7 +202,7 @@ public class Picture extends SimpleShape {
|
||||
}
|
||||
|
||||
protected EscherBSERecord getEscherBSERecord(){
|
||||
SlideShow ppt = getSheet().getSlideShow();
|
||||
HSLFSlideShow ppt = getSheet().getSlideShow();
|
||||
Document doc = ppt.getDocumentRecord();
|
||||
EscherContainerRecord dggContainer = doc.getPPDrawingGroup().getDggContainer();
|
||||
EscherContainerRecord bstore = HSLFShape.getEscherChild(dggContainer, EscherContainerRecord.BSTORE_CONTAINER);
|
||||
@ -247,7 +247,7 @@ public class Picture extends SimpleShape {
|
||||
/**
|
||||
* By default set the orininal image size
|
||||
*/
|
||||
protected void afterInsert(Sheet sh){
|
||||
protected void afterInsert(HSLFSheet sh){
|
||||
super.afterInsert(sh);
|
||||
|
||||
EscherBSERecord bse = getEscherBSERecord();
|
||||
@ -263,7 +263,7 @@ public class Picture extends SimpleShape {
|
||||
AffineTransform at = graphics.getTransform();
|
||||
ShapePainter.paint(this, graphics);
|
||||
|
||||
PictureData data = getPictureData();
|
||||
HSLFPictureData data = getPictureData();
|
||||
if(data != null) data.draw(graphics, this);
|
||||
|
||||
graphics.setTransform(at);
|
@ -17,17 +17,15 @@
|
||||
|
||||
package org.apache.poi.hslf.model;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.poi.ddf.*;
|
||||
import org.apache.poi.hslf.record.ColorSchemeAtom;
|
||||
import org.apache.poi.sl.usermodel.ShapeContainer;
|
||||
import org.apache.poi.sl.usermodel.ShapeType;
|
||||
import org.apache.poi.util.POILogger;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.Units;
|
||||
|
||||
import java.util.*;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import org.apache.poi.sl.usermodel.*;
|
||||
import org.apache.poi.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -45,7 +43,7 @@ import java.awt.geom.Rectangle2D;
|
||||
*
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public abstract class HSLFShape implements org.apache.poi.sl.usermodel.Shape<HSLFShape> {
|
||||
public abstract class HSLFShape implements Shape {
|
||||
|
||||
// For logging
|
||||
protected POILogger logger = POILogFactory.getLogger(this.getClass());
|
||||
@ -90,12 +88,12 @@ public abstract class HSLFShape implements org.apache.poi.sl.usermodel.Shape<HSL
|
||||
/**
|
||||
* The <code>Sheet</code> this shape belongs to
|
||||
*/
|
||||
protected Sheet _sheet;
|
||||
protected HSLFSheet _sheet;
|
||||
|
||||
/**
|
||||
* Fill
|
||||
*/
|
||||
protected Fill _fill;
|
||||
protected HSLFFill _fill;
|
||||
|
||||
/**
|
||||
* Create a Shape object. This constructor is used when an existing Shape is read from from a PowerPoint document.
|
||||
@ -336,7 +334,7 @@ public abstract class HSLFShape implements org.apache.poi.sl.usermodel.Shape<HSL
|
||||
*
|
||||
* @param sh - owning shape
|
||||
*/
|
||||
protected void afterInsert(Sheet sh){
|
||||
protected void afterInsert(HSLFSheet sh){
|
||||
if(_fill != null) {
|
||||
_fill.afterInsert(sh);
|
||||
}
|
||||
@ -345,7 +343,7 @@ public abstract class HSLFShape implements org.apache.poi.sl.usermodel.Shape<HSL
|
||||
/**
|
||||
* @return the <code>SlideShow</code> this shape belongs to
|
||||
*/
|
||||
public Sheet getSheet(){
|
||||
public HSLFSheet getSheet(){
|
||||
return _sheet;
|
||||
}
|
||||
|
||||
@ -354,7 +352,7 @@ public abstract class HSLFShape implements org.apache.poi.sl.usermodel.Shape<HSL
|
||||
*
|
||||
* @param sheet owner of this shape
|
||||
*/
|
||||
public void setSheet(Sheet sheet){
|
||||
public void setSheet(HSLFSheet sheet){
|
||||
_sheet = sheet;
|
||||
}
|
||||
|
||||
@ -375,7 +373,7 @@ public abstract class HSLFShape implements org.apache.poi.sl.usermodel.Shape<HSL
|
||||
|
||||
int rgb[] = ecr.getRGB();
|
||||
|
||||
Sheet sheet = getSheet();
|
||||
HSLFSheet sheet = getSheet();
|
||||
if (fSchemeIndex && sheet != null) {
|
||||
//red is the index to the color scheme
|
||||
ColorSchemeAtom ca = sheet.getColorScheme();
|
||||
@ -394,13 +392,18 @@ public abstract class HSLFShape implements org.apache.poi.sl.usermodel.Shape<HSL
|
||||
//TODO
|
||||
}
|
||||
|
||||
double alpha = getAlpha(opacityProperty);
|
||||
return new Color(rgb[0], rgb[1], rgb[2], (int)(alpha*255.0));
|
||||
}
|
||||
|
||||
double getAlpha(short opacityProperty) {
|
||||
EscherOptRecord opt = getEscherOptRecord();
|
||||
EscherSimpleProperty op = getEscherProperty(opt, opacityProperty);
|
||||
int defaultOpacity = 0x00010000;
|
||||
int opacity = (op == null) ? defaultOpacity : op.getPropertyValue();
|
||||
double alpha = Units.fixedPointToDouble(opacity)*255.0;
|
||||
return new Color(rgb[0], rgb[1], rgb[2], (int)alpha);
|
||||
return Units.fixedPointToDouble(opacity);
|
||||
}
|
||||
|
||||
|
||||
Color toRGB(int val){
|
||||
int a = (val >> 24) & 0xFF;
|
||||
int b = (val >> 16) & 0xFF;
|
||||
@ -446,11 +449,16 @@ public abstract class HSLFShape implements org.apache.poi.sl.usermodel.Shape<HSL
|
||||
*
|
||||
* @return fill properties of this shape
|
||||
*/
|
||||
public Fill getFill(){
|
||||
if(_fill == null) _fill = new Fill(this);
|
||||
public HSLFFill getFill(){
|
||||
if(_fill == null) {
|
||||
_fill = new HSLFFill(this);
|
||||
}
|
||||
return _fill;
|
||||
}
|
||||
|
||||
public FillStyle getFillStyle() {
|
||||
return getFill().getFillStyle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hyperlink assigned to this shape
|
||||
@ -479,46 +487,39 @@ public abstract class HSLFShape implements org.apache.poi.sl.usermodel.Shape<HSL
|
||||
return getEscherChild(EscherOptRecord.RECORD_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFlipHorizontal(){
|
||||
EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
|
||||
return (spRecord.getFlags()& EscherSpRecord.FLAG_FLIPHORIZ) != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlipHorizontal(boolean flip) {
|
||||
EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
|
||||
int flag = spRecord.getFlags() | EscherSpRecord.FLAG_FLIPHORIZ;
|
||||
spRecord.setFlags(flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFlipVertical(){
|
||||
EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
|
||||
return (spRecord.getFlags()& EscherSpRecord.FLAG_FLIPVERT) != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlipVertical(boolean flip) {
|
||||
EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
|
||||
int flag = spRecord.getFlags() | EscherSpRecord.FLAG_FLIPVERT;
|
||||
spRecord.setFlags(flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getRotation(){
|
||||
int rot = getEscherProperty(EscherProperties.TRANSFORM__ROTATION);
|
||||
double angle = Units.fixedPointToDouble(rot) % 360.0;
|
||||
return angle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRotation(double theta){
|
||||
int rot = Units.doubleToFixedPoint(theta % 360.0);
|
||||
setEscherProperty(EscherProperties.TRANSFORM__ROTATION, rot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlaceholder() {
|
||||
return false;
|
||||
}
|
||||
|
@ -18,34 +18,12 @@
|
||||
package org.apache.poi.hslf.model;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.poi.ddf.EscherContainerRecord;
|
||||
import org.apache.poi.ddf.EscherDgRecord;
|
||||
import org.apache.poi.ddf.EscherDggRecord;
|
||||
import org.apache.poi.ddf.EscherRecord;
|
||||
import org.apache.poi.hslf.record.CString;
|
||||
import org.apache.poi.hslf.record.ColorSchemeAtom;
|
||||
import org.apache.poi.hslf.record.EscherTextboxWrapper;
|
||||
import org.apache.poi.hslf.record.MasterTextPropAtom;
|
||||
import org.apache.poi.hslf.record.OEPlaceholderAtom;
|
||||
import org.apache.poi.hslf.record.PPDrawing;
|
||||
import org.apache.poi.hslf.record.Record;
|
||||
import org.apache.poi.hslf.record.RecordContainer;
|
||||
import org.apache.poi.hslf.record.RecordTypes;
|
||||
import org.apache.poi.hslf.record.RoundTripHFPlaceholder12;
|
||||
import org.apache.poi.hslf.record.SheetContainer;
|
||||
import org.apache.poi.hslf.record.StyleTextProp9Atom;
|
||||
import org.apache.poi.hslf.record.StyleTextPropAtom;
|
||||
import org.apache.poi.hslf.record.TextBytesAtom;
|
||||
import org.apache.poi.hslf.record.TextCharsAtom;
|
||||
import org.apache.poi.hslf.record.TextHeaderAtom;
|
||||
import org.apache.poi.hslf.record.TextRulerAtom;
|
||||
import org.apache.poi.hslf.record.TextSpecInfoAtom;
|
||||
import org.apache.poi.hslf.usermodel.SlideShow;
|
||||
import org.apache.poi.sl.usermodel.ShapeContainer;
|
||||
import org.apache.poi.ddf.*;
|
||||
import org.apache.poi.hslf.record.*;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.sl.usermodel.Sheet;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
|
||||
@ -57,18 +35,18 @@ import org.apache.poi.util.POILogger;
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
|
||||
public abstract class Sheet implements ShapeContainer<HSLFShape> {
|
||||
private static POILogger logger = POILogFactory.getLogger(Sheet.class);
|
||||
public abstract class HSLFSheet implements Sheet<HSLFShape,HSLFSlideShow> {
|
||||
private static POILogger logger = POILogFactory.getLogger(HSLFSheet.class);
|
||||
|
||||
/**
|
||||
* The <code>SlideShow</code> we belong to
|
||||
*/
|
||||
private SlideShow _slideShow;
|
||||
private HSLFSlideShow _slideShow;
|
||||
|
||||
/**
|
||||
* Sheet background
|
||||
*/
|
||||
private Background _background;
|
||||
private HSLFBackground _background;
|
||||
|
||||
/**
|
||||
* Record container that holds sheet data.
|
||||
@ -80,7 +58,7 @@ public abstract class Sheet implements ShapeContainer<HSLFShape> {
|
||||
|
||||
private int _sheetNo;
|
||||
|
||||
public Sheet(SheetContainer container, int sheetNo) {
|
||||
public HSLFSheet(SheetContainer container, int sheetNo) {
|
||||
_container = container;
|
||||
_sheetNo = sheetNo;
|
||||
}
|
||||
@ -88,7 +66,7 @@ public abstract class Sheet implements ShapeContainer<HSLFShape> {
|
||||
/**
|
||||
* Returns an array of all the TextRuns in the sheet.
|
||||
*/
|
||||
public abstract TextRun[] getTextRuns();
|
||||
public abstract HSLFTextParagraph[] getTextRuns();
|
||||
|
||||
/**
|
||||
* Returns the (internal, RefID based) sheet number, as used
|
||||
@ -116,7 +94,7 @@ public abstract class Sheet implements ShapeContainer<HSLFShape> {
|
||||
/**
|
||||
* Fetch the SlideShow we're attached to
|
||||
*/
|
||||
public SlideShow getSlideShow() {
|
||||
public HSLFSlideShow getSlideShow() {
|
||||
return _slideShow;
|
||||
}
|
||||
|
||||
@ -131,13 +109,12 @@ public abstract class Sheet implements ShapeContainer<HSLFShape> {
|
||||
* Set the SlideShow we're attached to.
|
||||
* Also passes it on to our child RichTextRuns
|
||||
*/
|
||||
public void setSlideShow(SlideShow ss) {
|
||||
public void setSlideShow(HSLFSlideShow ss) {
|
||||
_slideShow = ss;
|
||||
TextRun[] trs = getTextRuns();
|
||||
if (trs != null) {
|
||||
for (int i = 0; i < trs.length; i++) {
|
||||
trs[i].supplySlideShow(_slideShow);
|
||||
}
|
||||
HSLFTextParagraph[] trs = getTextRuns();
|
||||
if (trs == null) return;
|
||||
for (HSLFTextParagraph tp : trs) {
|
||||
tp.supplySheet(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,8 +122,8 @@ public abstract class Sheet implements ShapeContainer<HSLFShape> {
|
||||
/**
|
||||
* For a given PPDrawing, grab all the TextRuns
|
||||
*/
|
||||
public static TextRun[] findTextRuns(PPDrawing ppdrawing) {
|
||||
final List<TextRun> runsV = new ArrayList<TextRun>();
|
||||
public static HSLFTextParagraph[] findTextRuns(PPDrawing ppdrawing) {
|
||||
final List<HSLFTextParagraph> runsV = new ArrayList<HSLFTextParagraph>();
|
||||
final EscherTextboxWrapper[] wrappers = ppdrawing.getTextboxWrappers();
|
||||
for (int i = 0; i < wrappers.length; i++) {
|
||||
int s1 = runsV.size();
|
||||
@ -156,11 +133,11 @@ public abstract class Sheet implements ShapeContainer<HSLFShape> {
|
||||
findTextRuns(wrappers[i], runsV);
|
||||
int s2 = runsV.size();
|
||||
if (s2 != s1){
|
||||
TextRun t = runsV.get(runsV.size()-1);
|
||||
HSLFTextParagraph t = runsV.get(runsV.size()-1);
|
||||
t.setShapeId(wrappers[i].getShapeId());
|
||||
}
|
||||
}
|
||||
return runsV.toArray(new TextRun[runsV.size()]);
|
||||
return runsV.toArray(new HSLFTextParagraph[runsV.size()]);
|
||||
}
|
||||
/**
|
||||
* Scans through the supplied record array, looking for
|
||||
@ -170,7 +147,7 @@ public abstract class Sheet implements ShapeContainer<HSLFShape> {
|
||||
* @param records the records to build from
|
||||
* @param found vector to add any found to
|
||||
*/
|
||||
protected static void findTextRuns(final Record[] records, final List<TextRun> found) {
|
||||
protected static void findTextParagraphs(final Record[] records, final List<HSLFTextParagraph> found) {
|
||||
findTextRuns(records, found, null);
|
||||
}
|
||||
/**
|
||||
@ -181,7 +158,7 @@ public abstract class Sheet implements ShapeContainer<HSLFShape> {
|
||||
* @param wrapper an EscherTextboxWrapper
|
||||
* @param found vector to add any found to
|
||||
*/
|
||||
protected static void findTextRuns(final EscherTextboxWrapper wrapper, final List<TextRun> found) {
|
||||
protected static void findTextRuns(final EscherTextboxWrapper wrapper, final List<HSLFTextParagraph> found) {
|
||||
findTextRuns(wrapper.getChildRecords(), found, wrapper.getStyleTextProp9Atom());
|
||||
}
|
||||
/**
|
||||
@ -193,12 +170,12 @@ public abstract class Sheet implements ShapeContainer<HSLFShape> {
|
||||
* @param found vector to add any found to
|
||||
* @param styleTextProp9Atom a StyleTextProp9Atom with numbered lists info
|
||||
*/
|
||||
protected static void findTextRuns(final Record[] records, final List<TextRun> found, final StyleTextProp9Atom styleTextProp9Atom) {
|
||||
protected static void findTextRuns(final Record[] records, final List<HSLFTextParagraph> found, final StyleTextProp9Atom styleTextProp9Atom) {
|
||||
for (int i = 0, slwtIndex=0; i < (records.length - 1); i++) {
|
||||
if (records[i] instanceof TextHeaderAtom) {
|
||||
TextHeaderAtom tha = (TextHeaderAtom) records[i];
|
||||
StyleTextPropAtom stpa = null;
|
||||
TextRun trun = null;
|
||||
HSLFTextParagraph trun = null;
|
||||
Record next = null;
|
||||
Record subs = null;
|
||||
|
||||
@ -231,10 +208,10 @@ public abstract class Sheet implements ShapeContainer<HSLFShape> {
|
||||
// Now, check if the next record is one to record
|
||||
if (next instanceof TextCharsAtom) {
|
||||
TextCharsAtom tca = (TextCharsAtom)next;
|
||||
trun = new TextRun(tha, tca, stpa);
|
||||
trun = new HSLFTextParagraph(tha, tca, stpa);
|
||||
} else if (next instanceof TextBytesAtom) {
|
||||
TextBytesAtom tba = (TextBytesAtom)next;
|
||||
trun = new TextRun(tha, tba, stpa);
|
||||
trun = new HSLFTextParagraph(tha, tba, stpa);
|
||||
} else if (next instanceof StyleTextPropAtom) {
|
||||
stpa = (StyleTextPropAtom)next;
|
||||
} else if (next instanceof TextHeaderAtom) {
|
||||
@ -372,7 +349,7 @@ public abstract class Sheet implements ShapeContainer<HSLFShape> {
|
||||
/**
|
||||
* Return the master sheet .
|
||||
*/
|
||||
public abstract MasterSheet getMasterSheet();
|
||||
public abstract HSLFMasterSheet getMasterSheet();
|
||||
|
||||
/**
|
||||
* Color scheme for this sheet.
|
||||
@ -386,7 +363,7 @@ public abstract class Sheet implements ShapeContainer<HSLFShape> {
|
||||
*
|
||||
* @return the background shape for this sheet.
|
||||
*/
|
||||
public Background getBackground() {
|
||||
public HSLFBackground getBackground() {
|
||||
if (_background == null) {
|
||||
PPDrawing ppdrawing = getPPDrawing();
|
||||
|
||||
@ -400,7 +377,7 @@ public abstract class Sheet implements ShapeContainer<HSLFShape> {
|
||||
break;
|
||||
}
|
||||
}
|
||||
_background = new Background(spContainer, null);
|
||||
_background = new HSLFBackground(spContainer, null);
|
||||
_background.setSheet(this);
|
||||
}
|
||||
return _background;
|
||||
@ -416,7 +393,7 @@ public abstract class Sheet implements ShapeContainer<HSLFShape> {
|
||||
*
|
||||
* @param shape
|
||||
*/
|
||||
protected void onAddTextShape(TextShape shape) {
|
||||
protected void onAddTextShape(HSLFTextShape shape) {
|
||||
|
||||
}
|
||||
|
||||
@ -426,12 +403,12 @@ public abstract class Sheet implements ShapeContainer<HSLFShape> {
|
||||
* @param type type of text, See {@link org.apache.poi.hslf.record.TextHeaderAtom}
|
||||
* @return <code>TextShape</code> or <code>null</code>
|
||||
*/
|
||||
public TextShape getPlaceholderByTextType(int type){
|
||||
public HSLFTextShape getPlaceholderByTextType(int type){
|
||||
HSLFShape[] shape = getShapes();
|
||||
for (int i = 0; i < shape.length; i++) {
|
||||
if(shape[i] instanceof TextShape){
|
||||
TextShape tx = (TextShape)shape[i];
|
||||
TextRun run = tx.getTextRun();
|
||||
if(shape[i] instanceof HSLFTextShape){
|
||||
HSLFTextShape tx = (HSLFTextShape)shape[i];
|
||||
HSLFTextParagraph run = tx.getTextParagraph();
|
||||
if(run != null && run.getRunType() == type){
|
||||
return tx;
|
||||
}
|
||||
@ -446,11 +423,11 @@ public abstract class Sheet implements ShapeContainer<HSLFShape> {
|
||||
* @param type type of placeholder to search. See {@link org.apache.poi.hslf.record.OEPlaceholderAtom}
|
||||
* @return <code>TextShape</code> or <code>null</code>
|
||||
*/
|
||||
public TextShape getPlaceholder(int type){
|
||||
public HSLFTextShape getPlaceholder(int type){
|
||||
HSLFShape[] shape = getShapes();
|
||||
for (int i = 0; i < shape.length; i++) {
|
||||
if(shape[i] instanceof TextShape){
|
||||
TextShape tx = (TextShape)shape[i];
|
||||
if(shape[i] instanceof HSLFTextShape){
|
||||
HSLFTextShape tx = (HSLFTextShape)shape[i];
|
||||
int placeholderId = 0;
|
||||
OEPlaceholderAtom oep = tx.getPlaceholderAtom();
|
||||
if(oep != null) {
|
||||
@ -540,4 +517,14 @@ public abstract class Sheet implements ShapeContainer<HSLFShape> {
|
||||
return shapeList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether shapes on the master sheet should be shown. By default master graphics is turned off.
|
||||
* Sheets that support the notion of master (slide, slideLayout) should override it and
|
||||
* check this setting
|
||||
*/
|
||||
public boolean getFollowMasterGraphics() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -38,8 +38,10 @@ import org.apache.poi.hslf.exceptions.HSLFException;
|
||||
import org.apache.poi.hslf.record.InteractiveInfo;
|
||||
import org.apache.poi.hslf.record.InteractiveInfoAtom;
|
||||
import org.apache.poi.hslf.record.Record;
|
||||
import org.apache.poi.sl.usermodel.ShapeContainer;
|
||||
import org.apache.poi.sl.usermodel.*;
|
||||
import org.apache.poi.sl.usermodel.StrokeStyle.*;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
import org.apache.poi.util.Units;
|
||||
|
||||
/**
|
||||
* An abstract simple (non-group) shape.
|
||||
@ -47,7 +49,7 @@ import org.apache.poi.util.LittleEndian;
|
||||
*
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public abstract class SimpleShape extends HSLFShape {
|
||||
public abstract class HSLFSimpleShape extends HSLFShape implements SimpleShape {
|
||||
|
||||
public final static double DEFAULT_LINE_WIDTH = 0.75;
|
||||
|
||||
@ -63,7 +65,7 @@ public abstract class SimpleShape extends HSLFShape {
|
||||
* @param escherRecord <code>EscherSpContainer</code> container which holds information about this shape
|
||||
* @param parent the parent of the shape
|
||||
*/
|
||||
protected SimpleShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
|
||||
protected HSLFSimpleShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
|
||||
super(escherRecord, parent);
|
||||
}
|
||||
|
||||
@ -112,7 +114,7 @@ public abstract class SimpleShape extends HSLFShape {
|
||||
public double getLineWidth(){
|
||||
EscherOptRecord opt = getEscherOptRecord();
|
||||
EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH);
|
||||
double width = prop == null ? DEFAULT_LINE_WIDTH : (double)prop.getPropertyValue()/EMU_PER_POINT;
|
||||
double width = (prop == null) ? DEFAULT_LINE_WIDTH : Units.toPoints(prop.getPropertyValue());
|
||||
return width;
|
||||
}
|
||||
|
||||
@ -122,7 +124,7 @@ public abstract class SimpleShape extends HSLFShape {
|
||||
*/
|
||||
public void setLineWidth(double width){
|
||||
EscherOptRecord opt = getEscherOptRecord();
|
||||
setEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH, (int)(width*EMU_PER_POINT));
|
||||
setEscherProperty(opt, EscherProperties.LINESTYLE__LINEWIDTH, Units.toEMU(width));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -155,36 +157,45 @@ public abstract class SimpleShape extends HSLFShape {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets line dashing. One of the PEN_* constants defined in this class.
|
||||
* Gets line dashing.
|
||||
*
|
||||
* @return dashing of the line.
|
||||
*/
|
||||
public int getLineDashing(){
|
||||
public LineDash getLineDashing(){
|
||||
EscherOptRecord opt = getEscherOptRecord();
|
||||
|
||||
EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.LINESTYLE__LINEDASHING);
|
||||
return prop == null ? Line.PEN_SOLID : prop.getPropertyValue();
|
||||
return (prop == null) ? LineDash.SOLID : LineDash.fromNativeId(prop.getPropertyValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets line dashing. One of the PEN_* constants defined in this class.
|
||||
* Sets line dashing.
|
||||
*
|
||||
* @param pen new style of the line.
|
||||
*/
|
||||
public void setLineDashing(int pen){
|
||||
public void setLineDashing(LineDash pen){
|
||||
EscherOptRecord opt = getEscherOptRecord();
|
||||
|
||||
setEscherProperty(opt, EscherProperties.LINESTYLE__LINEDASHING, pen == Line.PEN_SOLID ? -1 : pen);
|
||||
setEscherProperty(opt, EscherProperties.LINESTYLE__LINEDASHING, pen == LineDash.SOLID ? -1 : pen.nativeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets line style. One of the constants defined in this class.
|
||||
* Gets the line compound style
|
||||
*
|
||||
* @param style new style of the line.
|
||||
* @return the compound style of the line.
|
||||
*/
|
||||
public void setLineStyle(int style){
|
||||
public LineCompound getLineCompound() {
|
||||
EscherOptRecord opt = getEscherOptRecord();
|
||||
setEscherProperty(opt, EscherProperties.LINESTYLE__LINESTYLE, style == Line.LINE_SIMPLE ? -1 : style);
|
||||
EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.LINESTYLE__LINESTYLE);
|
||||
return (prop == null) ? LineCompound.SINGLE : LineCompound.fromNativeId(prop.getPropertyValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the line compound style
|
||||
*
|
||||
* @param style new compound style of the line.
|
||||
*/
|
||||
public void setLineCompound(LineCompound style){
|
||||
EscherOptRecord opt = getEscherOptRecord();
|
||||
setEscherProperty(opt, EscherProperties.LINESTYLE__LINESTYLE, style == LineCompound.SINGLE ? -1 : style.nativeId);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -192,10 +203,29 @@ public abstract class SimpleShape extends HSLFShape {
|
||||
*
|
||||
* @return style of the line.
|
||||
*/
|
||||
public int getStrokeStyle(){
|
||||
EscherOptRecord opt = getEscherOptRecord();
|
||||
EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.LINESTYLE__LINESTYLE);
|
||||
return prop == null ? Line.LINE_SIMPLE : prop.getPropertyValue();
|
||||
public StrokeStyle getStrokeStyle(){
|
||||
return new StrokeStyle() {
|
||||
public PaintStyle getPaint() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public LineCap getLineCap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public LineDash getLineDash() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public LineCompound getLineCompound() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public double getLineWidth() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
@ -37,7 +37,9 @@ import org.apache.poi.hslf.record.SlideAtom;
|
||||
import org.apache.poi.hslf.record.SlideListWithText.SlideAtomsSet;
|
||||
import org.apache.poi.hslf.record.StyleTextProp9Atom;
|
||||
import org.apache.poi.hslf.record.TextHeaderAtom;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.sl.usermodel.ShapeType;
|
||||
import org.apache.poi.sl.usermodel.Slide;
|
||||
|
||||
/**
|
||||
* This class represents a slide in a PowerPoint Document. It allows
|
||||
@ -48,11 +50,11 @@ import org.apache.poi.sl.usermodel.ShapeType;
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
|
||||
public final class Slide extends Sheet {
|
||||
public final class HSLFSlide extends HSLFSheet implements Slide<HSLFShape,HSLFSlideShow> {
|
||||
private int _slideNo;
|
||||
private SlideAtomsSet _atomSet;
|
||||
private TextRun[] _runs;
|
||||
private Notes _notes; // usermodel needs to set this
|
||||
private HSLFTextParagraph[] _runs;
|
||||
private HSLFNotes _notes; // usermodel needs to set this
|
||||
|
||||
/**
|
||||
* Constructs a Slide from the Slide record, and the SlideAtomsSet
|
||||
@ -63,7 +65,7 @@ public final class Slide extends Sheet {
|
||||
* @param notes the Notes sheet attached to us
|
||||
* @param atomSet the SlideAtomsSet to get the text from
|
||||
*/
|
||||
public Slide(org.apache.poi.hslf.record.Slide slide, Notes notes, SlideAtomsSet atomSet, int slideIdentifier, int slideNumber) {
|
||||
public HSLFSlide(org.apache.poi.hslf.record.Slide slide, HSLFNotes notes, SlideAtomsSet atomSet, int slideIdentifier, int slideNumber) {
|
||||
super(slide, slideIdentifier);
|
||||
|
||||
_notes = notes;
|
||||
@ -71,31 +73,31 @@ public final class Slide extends Sheet {
|
||||
_slideNo = slideNumber;
|
||||
|
||||
// Grab the TextRuns from the PPDrawing
|
||||
TextRun[] _otherRuns = findTextRuns(getPPDrawing());
|
||||
HSLFTextParagraph[] _otherRuns = findTextRuns(getPPDrawing());
|
||||
|
||||
// For the text coming in from the SlideAtomsSet:
|
||||
// Build up TextRuns from pairs of TextHeaderAtom and
|
||||
// one of TextBytesAtom or TextCharsAtom
|
||||
final List<TextRun> textRuns = new LinkedList<TextRun>();
|
||||
final List<HSLFTextParagraph> textParagraphs = new LinkedList<HSLFTextParagraph>();
|
||||
if(_atomSet != null) {
|
||||
findTextRuns(_atomSet.getSlideRecords(),textRuns);
|
||||
findTextParagraphs(_atomSet.getSlideRecords(),textParagraphs);
|
||||
} else {
|
||||
// No text on the slide, must just be pictures
|
||||
}
|
||||
|
||||
// Build an array, more useful than a vector
|
||||
_runs = new TextRun[textRuns.size()+_otherRuns.length];
|
||||
_runs = new HSLFTextParagraph[textParagraphs.size()+_otherRuns.length];
|
||||
// Grab text from SlideListWithTexts entries
|
||||
int i=0;
|
||||
for(i=0; i<textRuns.size(); i++) {
|
||||
_runs[i] = textRuns.get(i);
|
||||
_runs[i].setSheet(this);
|
||||
for(HSLFTextParagraph tp : textParagraphs) {
|
||||
_runs[i++] = tp;
|
||||
tp.supplySheet(this);
|
||||
}
|
||||
// Grab text from slide's PPDrawing
|
||||
for(int k=0; k<_otherRuns.length; i++, k++) {
|
||||
_runs[i] = _otherRuns[k];
|
||||
_runs[i].setSheet(this);
|
||||
_runs[i].setIndex(-1); // runs found in PPDrawing are not linked with SlideListWithTexts
|
||||
for(HSLFTextParagraph tp : _otherRuns) {
|
||||
_runs[i++] = tp;
|
||||
tp.supplySheet(this);
|
||||
tp.setIndex(-1); // runs found in PPDrawing are not linked with SlideListWithTexts
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,7 +106,7 @@ public final class Slide extends Sheet {
|
||||
* @param sheetNumber The internal number of the sheet, as used by PersistPtrHolder
|
||||
* @param slideNumber The user facing number of the sheet
|
||||
*/
|
||||
public Slide(int sheetNumber, int sheetRefId, int slideNumber){
|
||||
public HSLFSlide(int sheetNumber, int sheetRefId, int slideNumber){
|
||||
super(new org.apache.poi.hslf.record.Slide(), sheetNumber);
|
||||
_slideNo = slideNumber;
|
||||
getSheetContainer().setSheetId(sheetRefId);
|
||||
@ -114,7 +116,7 @@ public final class Slide extends Sheet {
|
||||
* Sets the Notes that are associated with this. Updates the
|
||||
* references in the records to point to the new ID
|
||||
*/
|
||||
public void setNotes(Notes notes) {
|
||||
public void setNotes(HSLFNotes notes) {
|
||||
_notes = notes;
|
||||
|
||||
// Update the Slide Atom's ID of where to point to
|
||||
@ -131,7 +133,7 @@ public final class Slide extends Sheet {
|
||||
|
||||
/**
|
||||
* Changes the Slide's (external facing) page number.
|
||||
* @see org.apache.poi.hslf.usermodel.SlideShow#reorderSlide(int, int)
|
||||
* @see org.apache.poi.hslf.usermodel.HSLFSlideShow#reorderSlide(int, int)
|
||||
*/
|
||||
public void setSlideNumber(int newSlideNumber) {
|
||||
_slideNo = newSlideNumber;
|
||||
@ -178,10 +180,10 @@ public final class Slide extends Sheet {
|
||||
*
|
||||
* @return <code>TextBox</code> object that represents the slide's title.
|
||||
*/
|
||||
public TextBox addTitle() {
|
||||
public HSLFTextBox addTitle() {
|
||||
Placeholder pl = new Placeholder();
|
||||
pl.setShapeType(ShapeType.RECT);
|
||||
pl.getTextRun().setRunType(TextHeaderAtom.TITLE_TYPE);
|
||||
pl.getTextParagraph().setRunType(TextHeaderAtom.TITLE_TYPE);
|
||||
pl.setText("Click to edit title");
|
||||
pl.setAnchor(new java.awt.Rectangle(54, 48, 612, 90));
|
||||
addShape(pl);
|
||||
@ -203,7 +205,7 @@ public final class Slide extends Sheet {
|
||||
* @return title of this slide
|
||||
*/
|
||||
public String getTitle(){
|
||||
TextRun[] txt = getTextRuns();
|
||||
HSLFTextParagraph[] txt = getTextRuns();
|
||||
for (int i = 0; i < txt.length; i++) {
|
||||
int type = txt[i].getRunType();
|
||||
if (type == TextHeaderAtom.CENTER_TITLE_TYPE ||
|
||||
@ -220,7 +222,7 @@ public final class Slide extends Sheet {
|
||||
/**
|
||||
* Returns an array of all the TextRuns found
|
||||
*/
|
||||
public TextRun[] getTextRuns() { return _runs; }
|
||||
public HSLFTextParagraph[] getTextRuns() { return _runs; }
|
||||
|
||||
/**
|
||||
* Returns the (public facing) page number of this slide
|
||||
@ -237,7 +239,7 @@ public final class Slide extends Sheet {
|
||||
/**
|
||||
* Returns the Notes Sheet for this slide, or null if there isn't one
|
||||
*/
|
||||
public Notes getNotesSheet() { return _notes; }
|
||||
public HSLFNotes getNotesSheet() { return _notes; }
|
||||
|
||||
/**
|
||||
* @return set of records inside <code>SlideListWithtext</code> container
|
||||
@ -251,11 +253,11 @@ public final class Slide extends Sheet {
|
||||
*
|
||||
* @return the master sheet associated with this slide.
|
||||
*/
|
||||
public MasterSheet getMasterSheet(){
|
||||
public HSLFMasterSheet getMasterSheet(){
|
||||
SlideMaster[] master = getSlideShow().getSlidesMasters();
|
||||
SlideAtom sa = getSlideRecord().getSlideAtom();
|
||||
int masterId = sa.getMasterID();
|
||||
MasterSheet sheet = null;
|
||||
HSLFMasterSheet sheet = null;
|
||||
for (int i = 0; i < master.length; i++) {
|
||||
if (masterId == master[i]._getSheetNumber()) {
|
||||
sheet = master[i];
|
||||
@ -277,7 +279,7 @@ public final class Slide extends Sheet {
|
||||
/**
|
||||
* Change Master of this slide.
|
||||
*/
|
||||
public void setMasterSheet(MasterSheet master){
|
||||
public void setMasterSheet(HSLFMasterSheet master){
|
||||
SlideAtom sa = getSlideRecord().getSlideAtom();
|
||||
int sheetNo = master._getSheetNumber();
|
||||
sa.setMasterID(sheetNo);
|
||||
@ -352,7 +354,7 @@ public final class Slide extends Sheet {
|
||||
/**
|
||||
* Background for this slide.
|
||||
*/
|
||||
public Background getBackground() {
|
||||
public HSLFBackground getBackground() {
|
||||
if(getFollowMasterBackground()) {
|
||||
return getMasterSheet().getBackground();
|
||||
}
|
||||
@ -423,14 +425,14 @@ public final class Slide extends Sheet {
|
||||
}
|
||||
|
||||
public void draw(Graphics2D graphics){
|
||||
MasterSheet master = getMasterSheet();
|
||||
Background bg = getBackground();
|
||||
HSLFMasterSheet master = getMasterSheet();
|
||||
HSLFBackground bg = getBackground();
|
||||
if(bg != null)bg.draw(graphics);
|
||||
|
||||
if(getFollowMasterObjects()){
|
||||
HSLFShape[] sh = master.getShapes();
|
||||
for (int i = 0; i < sh.length; i++) {
|
||||
if(MasterSheet.isPlaceholder(sh[i])) continue;
|
||||
if(HSLFMasterSheet.isPlaceholder(sh[i])) continue;
|
||||
|
||||
sh[i].draw(graphics);
|
||||
}
|
||||
@ -469,12 +471,12 @@ public final class Slide extends Sheet {
|
||||
return new HeadersFooters(hdd, this, newRecord, ppt2007);
|
||||
}
|
||||
|
||||
protected void onAddTextShape(TextShape shape) {
|
||||
TextRun run = shape.getTextRun();
|
||||
protected void onAddTextShape(HSLFTextShape shape) {
|
||||
HSLFTextParagraph run = shape.getTextParagraph();
|
||||
|
||||
if(_runs == null) _runs = new TextRun[]{run};
|
||||
if(_runs == null) _runs = new HSLFTextParagraph[]{run};
|
||||
else {
|
||||
TextRun[] tmp = new TextRun[_runs.length + 1];
|
||||
HSLFTextParagraph[] tmp = new HSLFTextParagraph[_runs.length + 1];
|
||||
System.arraycopy(_runs, 0, tmp, 0, _runs.length);
|
||||
tmp[tmp.length-1] = run;
|
||||
_runs = tmp;
|
@ -15,7 +15,7 @@
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.hslf;
|
||||
package org.apache.poi.hslf.model;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.security.GeneralSecurityException;
|
||||
@ -49,7 +49,7 @@ import org.apache.poi.util.LittleEndian;
|
||||
* This class provides helper functions for encrypted PowerPoint documents.
|
||||
*/
|
||||
@Internal
|
||||
public class EncryptedSlideShow {
|
||||
public class HSLFSlideShowEncrypted {
|
||||
DocumentEncryptionAtom dea;
|
||||
CryptoAPIEncryptor enc = null;
|
||||
CryptoAPIDecryptor dec = null;
|
||||
@ -58,11 +58,11 @@ public class EncryptedSlideShow {
|
||||
|
||||
private static final BitField fieldRecInst = new BitField(0xFFF0);
|
||||
|
||||
protected EncryptedSlideShow(DocumentEncryptionAtom dea) {
|
||||
protected HSLFSlideShowEncrypted(DocumentEncryptionAtom dea) {
|
||||
this.dea = dea;
|
||||
}
|
||||
|
||||
protected EncryptedSlideShow(byte[] docstream, NavigableMap<Integer,Record> recordMap) {
|
||||
protected HSLFSlideShowEncrypted(byte[] docstream, NavigableMap<Integer,Record> recordMap) {
|
||||
// check for DocumentEncryptionAtom, which would be at the last offset
|
||||
// need to ignore already set UserEdit and PersistAtoms
|
||||
UserEditAtom userEditAtomWithEncryption = null;
|
||||
@ -362,7 +362,7 @@ public class EncryptedSlideShow {
|
||||
/**
|
||||
* remove duplicated UserEditAtoms and merge PersistPtrHolder.
|
||||
* Before this method is called, make sure that the offsets are correct,
|
||||
* i.e. call {@link HSLFSlideShow#updateAndWriteDependantRecords(OutputStream, Map)}
|
||||
* i.e. call {@link HSLFSlideShowImpl#updateAndWriteDependantRecords(OutputStream, Map)}
|
||||
*/
|
||||
protected static Record[] normalizeRecords(Record records[]) {
|
||||
// http://msdn.microsoft.com/en-us/library/office/gg615594(v=office.14).aspx
|
@ -15,7 +15,7 @@
|
||||
limitations under the License.
|
||||
==================================================================== */
|
||||
|
||||
package org.apache.poi.hslf;
|
||||
package org.apache.poi.hslf.model;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@ -45,8 +45,8 @@ import org.apache.poi.hslf.record.PositionDependentRecord;
|
||||
import org.apache.poi.hslf.record.Record;
|
||||
import org.apache.poi.hslf.record.RecordTypes;
|
||||
import org.apache.poi.hslf.record.UserEditAtom;
|
||||
import org.apache.poi.hslf.usermodel.ObjectData;
|
||||
import org.apache.poi.hslf.usermodel.PictureData;
|
||||
import org.apache.poi.hslf.usermodel.HSLFObjectData;
|
||||
import org.apache.poi.hslf.usermodel.HSLFPictureData;
|
||||
import org.apache.poi.poifs.crypt.cryptoapi.CryptoAPIEncryptor;
|
||||
import org.apache.poi.poifs.filesystem.DirectoryNode;
|
||||
import org.apache.poi.poifs.filesystem.DocumentEntry;
|
||||
@ -64,7 +64,7 @@ import org.apache.poi.util.POILogger;
|
||||
*
|
||||
* @author Nick Burch
|
||||
*/
|
||||
public final class HSLFSlideShow extends POIDocument {
|
||||
public final class HSLFSlideShowImpl extends POIDocument {
|
||||
public static final int UNSET_OFFSET = -1;
|
||||
|
||||
// For logging
|
||||
@ -80,10 +80,10 @@ public final class HSLFSlideShow extends POIDocument {
|
||||
private Record[] _records;
|
||||
|
||||
// Raw Pictures contained in the pictures stream
|
||||
private List<PictureData> _pictures;
|
||||
private List<HSLFPictureData> _pictures;
|
||||
|
||||
// Embedded objects stored in storage records in the document stream, lazily populated.
|
||||
private ObjectData[] _objects;
|
||||
private HSLFObjectData[] _objects;
|
||||
|
||||
/**
|
||||
* Returns the underlying POIFSFileSystem for the document
|
||||
@ -108,7 +108,7 @@ public final class HSLFSlideShow extends POIDocument {
|
||||
* @param fileName The name of the file to read.
|
||||
* @throws IOException if there is a problem while parsing the document.
|
||||
*/
|
||||
public HSLFSlideShow(String fileName) throws IOException
|
||||
public HSLFSlideShowImpl(String fileName) throws IOException
|
||||
{
|
||||
this(new FileInputStream(fileName));
|
||||
}
|
||||
@ -120,7 +120,7 @@ public final class HSLFSlideShow extends POIDocument {
|
||||
* @param inputStream the source of the data
|
||||
* @throws IOException if there is a problem while parsing the document.
|
||||
*/
|
||||
public HSLFSlideShow(InputStream inputStream) throws IOException {
|
||||
public HSLFSlideShowImpl(InputStream inputStream) throws IOException {
|
||||
//do Ole stuff
|
||||
this(new POIFSFileSystem(inputStream));
|
||||
}
|
||||
@ -132,7 +132,7 @@ public final class HSLFSlideShow extends POIDocument {
|
||||
* @param filesystem the POIFS FileSystem to read from
|
||||
* @throws IOException if there is a problem while parsing the document.
|
||||
*/
|
||||
public HSLFSlideShow(POIFSFileSystem filesystem) throws IOException
|
||||
public HSLFSlideShowImpl(POIFSFileSystem filesystem) throws IOException
|
||||
{
|
||||
this(filesystem.getRoot());
|
||||
}
|
||||
@ -144,7 +144,7 @@ public final class HSLFSlideShow extends POIDocument {
|
||||
* @param filesystem the POIFS FileSystem to read from
|
||||
* @throws IOException if there is a problem while parsing the document.
|
||||
*/
|
||||
public HSLFSlideShow(NPOIFSFileSystem filesystem) throws IOException
|
||||
public HSLFSlideShowImpl(NPOIFSFileSystem filesystem) throws IOException
|
||||
{
|
||||
this(filesystem.getRoot());
|
||||
}
|
||||
@ -160,7 +160,7 @@ public final class HSLFSlideShow extends POIDocument {
|
||||
* @throws IOException if there is a problem while parsing the document.
|
||||
*/
|
||||
@Deprecated
|
||||
public HSLFSlideShow(DirectoryNode dir, POIFSFileSystem filesystem) throws IOException
|
||||
public HSLFSlideShowImpl(DirectoryNode dir, POIFSFileSystem filesystem) throws IOException
|
||||
{
|
||||
this(dir);
|
||||
}
|
||||
@ -173,7 +173,7 @@ public final class HSLFSlideShow extends POIDocument {
|
||||
* @param dir the POIFS directory to read from
|
||||
* @throws IOException if there is a problem while parsing the document.
|
||||
*/
|
||||
public HSLFSlideShow(DirectoryNode dir) throws IOException {
|
||||
public HSLFSlideShowImpl(DirectoryNode dir) throws IOException {
|
||||
super(handleDualStorage(dir));
|
||||
|
||||
// First up, grab the "Current User" stream
|
||||
@ -202,13 +202,13 @@ public final class HSLFSlideShow extends POIDocument {
|
||||
/**
|
||||
* Constructs a new, empty, Powerpoint document.
|
||||
*/
|
||||
public static final HSLFSlideShow create() {
|
||||
InputStream is = HSLFSlideShow.class.getResourceAsStream("data/empty.ppt");
|
||||
public static final HSLFSlideShowImpl create() {
|
||||
InputStream is = HSLFSlideShowImpl.class.getResourceAsStream("data/empty.ppt");
|
||||
if (is == null) {
|
||||
throw new RuntimeException("Missing resource 'empty.ppt'");
|
||||
}
|
||||
try {
|
||||
return new HSLFSlideShow(is);
|
||||
return new HSLFSlideShowImpl(is);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@ -279,7 +279,7 @@ public final class HSLFSlideShow extends POIDocument {
|
||||
NavigableMap<Integer,Record> records = new TreeMap<Integer,Record>(); // offset -> record
|
||||
Map<Integer,Integer> persistIds = new HashMap<Integer,Integer>(); // offset -> persistId
|
||||
initRecordOffsets(docstream, usrOffset, records, persistIds);
|
||||
EncryptedSlideShow decryptData = new EncryptedSlideShow(docstream, records);
|
||||
HSLFSlideShowEncrypted decryptData = new HSLFSlideShowEncrypted(docstream, records);
|
||||
|
||||
for (Map.Entry<Integer,Record> entry : records.entrySet()) {
|
||||
Integer offset = entry.getKey();
|
||||
@ -373,12 +373,12 @@ public final class HSLFSlideShow extends POIDocument {
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private void readPictures() throws IOException {
|
||||
_pictures = new ArrayList<PictureData>();
|
||||
_pictures = new ArrayList<HSLFPictureData>();
|
||||
|
||||
// if the presentation doesn't contain pictures - will use a null set instead
|
||||
if (!directory.hasEntry("Pictures")) return;
|
||||
|
||||
EncryptedSlideShow decryptData = new EncryptedSlideShow(getDocumentEncryptionAtom());
|
||||
HSLFSlideShowEncrypted decryptData = new HSLFSlideShowEncrypted(getDocumentEncryptionAtom());
|
||||
|
||||
DocumentEntry entry = (DocumentEntry)directory.getEntry("Pictures");
|
||||
byte[] pictstream = new byte[entry.getSize()];
|
||||
@ -423,7 +423,7 @@ public final class HSLFSlideShow extends POIDocument {
|
||||
} else {
|
||||
// Build the PictureData object from the data
|
||||
try {
|
||||
PictureData pict = PictureData.create(type - 0xF018);
|
||||
HSLFPictureData pict = HSLFPictureData.create(type - 0xF018);
|
||||
|
||||
// Copy the data, ready to pass to PictureData
|
||||
byte[] imgdata = new byte[imgsize];
|
||||
@ -451,7 +451,7 @@ public final class HSLFSlideShow extends POIDocument {
|
||||
} catch (IOException e) {
|
||||
throw new CorruptPowerPointFileException(e);
|
||||
}
|
||||
_records = EncryptedSlideShow.normalizeRecords(_records);
|
||||
_records = HSLFSlideShowEncrypted.normalizeRecords(_records);
|
||||
}
|
||||
|
||||
|
||||
@ -517,7 +517,7 @@ public final class HSLFSlideShow extends POIDocument {
|
||||
persistIds.put(oldToNewPositions.get(entry.getValue()), entry.getKey());
|
||||
}
|
||||
|
||||
EncryptedSlideShow encData = new EncryptedSlideShow(getDocumentEncryptionAtom());
|
||||
HSLFSlideShowEncrypted encData = new HSLFSlideShowEncrypted(getDocumentEncryptionAtom());
|
||||
|
||||
for (Record record : _records) {
|
||||
assert(record instanceof PositionDependentRecord);
|
||||
@ -580,7 +580,7 @@ public final class HSLFSlideShow extends POIDocument {
|
||||
getDocumentSummaryInformation();
|
||||
|
||||
// set new encryption settings
|
||||
EncryptedSlideShow encryptedSS = new EncryptedSlideShow(getDocumentEncryptionAtom());
|
||||
HSLFSlideShowEncrypted encryptedSS = new HSLFSlideShowEncrypted(getDocumentEncryptionAtom());
|
||||
_records = encryptedSS.updateEncryptionRecord(_records);
|
||||
|
||||
// Get a new Filesystem to write into
|
||||
@ -615,7 +615,7 @@ public final class HSLFSlideShow extends POIDocument {
|
||||
|
||||
if (_pictures.size() > 0) {
|
||||
BufAccessBAOS pict = new BufAccessBAOS();
|
||||
for (PictureData p : _pictures) {
|
||||
for (HSLFPictureData p : _pictures) {
|
||||
int offset = pict.size();
|
||||
p.write(pict);
|
||||
encryptedSS.encryptPicture(pict.getBuf(), offset);
|
||||
@ -704,7 +704,7 @@ public final class HSLFSlideShow extends POIDocument {
|
||||
*
|
||||
* @return offset of this picture in the Pictures stream
|
||||
*/
|
||||
public int addPicture(PictureData img) {
|
||||
public int addPicture(HSLFPictureData img) {
|
||||
// Process any existing pictures if we haven't yet
|
||||
if(_pictures == null) {
|
||||
try {
|
||||
@ -717,7 +717,7 @@ public final class HSLFSlideShow extends POIDocument {
|
||||
// Add the new picture in
|
||||
int offset = 0;
|
||||
if(_pictures.size() > 0) {
|
||||
PictureData prev = _pictures.get(_pictures.size() - 1);
|
||||
HSLFPictureData prev = _pictures.get(_pictures.size() - 1);
|
||||
offset = prev.getOffset() + prev.getRawData().length + 8;
|
||||
}
|
||||
img.setOffset(offset);
|
||||
@ -750,7 +750,7 @@ public final class HSLFSlideShow extends POIDocument {
|
||||
* @return array with the read pictures or <code>null</code> if the
|
||||
* presentation doesn't contain pictures.
|
||||
*/
|
||||
public PictureData[] getPictures() {
|
||||
public HSLFPictureData[] getPictures() {
|
||||
if(_pictures == null) {
|
||||
try {
|
||||
readPictures();
|
||||
@ -759,7 +759,7 @@ public final class HSLFSlideShow extends POIDocument {
|
||||
}
|
||||
}
|
||||
|
||||
return _pictures.toArray(new PictureData[_pictures.size()]);
|
||||
return _pictures.toArray(new HSLFPictureData[_pictures.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -767,15 +767,15 @@ public final class HSLFSlideShow extends POIDocument {
|
||||
*
|
||||
* @return the embedded objects.
|
||||
*/
|
||||
public ObjectData[] getEmbeddedObjects() {
|
||||
public HSLFObjectData[] getEmbeddedObjects() {
|
||||
if (_objects == null) {
|
||||
List<ObjectData> objects = new ArrayList<ObjectData>();
|
||||
List<HSLFObjectData> objects = new ArrayList<HSLFObjectData>();
|
||||
for (Record r : _records) {
|
||||
if (r instanceof ExOleObjStg) {
|
||||
objects.add(new ObjectData((ExOleObjStg)r));
|
||||
objects.add(new HSLFObjectData((ExOleObjStg)r));
|
||||
}
|
||||
}
|
||||
_objects = objects.toArray(new ObjectData[objects.size()]);
|
||||
_objects = objects.toArray(new HSLFObjectData[objects.size()]);
|
||||
}
|
||||
return _objects;
|
||||
}
|
@ -30,7 +30,7 @@ import org.apache.poi.sl.usermodel.ShapeType;
|
||||
*
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public class TextBox extends TextShape {
|
||||
public class HSLFTextBox extends HSLFTextShape {
|
||||
|
||||
/**
|
||||
* Create a TextBox object and initialize it from the supplied Record container.
|
||||
@ -38,7 +38,7 @@ public class TextBox extends TextShape {
|
||||
* @param escherRecord <code>EscherSpContainer</code> container which holds information about this shape
|
||||
* @param parent the parent of the shape
|
||||
*/
|
||||
protected TextBox(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
|
||||
protected HSLFTextBox(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
|
||||
super(escherRecord, parent);
|
||||
|
||||
}
|
||||
@ -49,7 +49,7 @@ public class TextBox extends TextShape {
|
||||
* @param parent the parent of this Shape. For example, if this text box is a cell
|
||||
* in a table then the parent is Table.
|
||||
*/
|
||||
public TextBox(ShapeContainer<HSLFShape> parent){
|
||||
public HSLFTextBox(ShapeContainer<HSLFShape> parent){
|
||||
super(parent);
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ public class TextBox extends TextShape {
|
||||
* Create a new TextBox. This constructor is used when a new shape is created.
|
||||
*
|
||||
*/
|
||||
public TextBox(){
|
||||
public HSLFTextBox(){
|
||||
this(null);
|
||||
}
|
||||
|
||||
@ -84,8 +84,8 @@ public class TextBox extends TextShape {
|
||||
return _escherContainer;
|
||||
}
|
||||
|
||||
protected void setDefaultTextProperties(TextRun _txtrun){
|
||||
setVerticalAlignment(TextBox.AnchorTop);
|
||||
protected void setDefaultTextProperties(HSLFTextParagraph _txtrun){
|
||||
setVerticalAlignment(HSLFTextBox.AnchorTop);
|
||||
setEscherProperty(EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x20002);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -47,7 +47,7 @@ import org.apache.poi.hslf.record.TextBytesAtom;
|
||||
import org.apache.poi.hslf.record.TextCharsAtom;
|
||||
import org.apache.poi.hslf.record.TextHeaderAtom;
|
||||
import org.apache.poi.hslf.record.TxInteractiveInfoAtom;
|
||||
import org.apache.poi.hslf.usermodel.RichTextRun;
|
||||
import org.apache.poi.hslf.usermodel.HSLFTextRun;
|
||||
import org.apache.poi.sl.usermodel.ShapeContainer;
|
||||
import org.apache.poi.util.POILogger;
|
||||
|
||||
@ -56,7 +56,7 @@ import org.apache.poi.util.POILogger;
|
||||
*
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public abstract class TextShape extends SimpleShape {
|
||||
public abstract class HSLFTextShape extends HSLFSimpleShape {
|
||||
|
||||
/**
|
||||
* How to anchor the text
|
||||
@ -92,7 +92,7 @@ public abstract class TextShape extends SimpleShape {
|
||||
/**
|
||||
* TextRun object which holds actual text and format data
|
||||
*/
|
||||
protected TextRun _txtrun;
|
||||
protected HSLFTextParagraph _txtrun;
|
||||
|
||||
/**
|
||||
* Escher container which holds text attributes such as
|
||||
@ -111,7 +111,7 @@ public abstract class TextShape extends SimpleShape {
|
||||
* @param escherRecord <code>EscherSpContainer</code> container which holds information about this shape
|
||||
* @param parent the parent of the shape
|
||||
*/
|
||||
protected TextShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
|
||||
protected HSLFTextShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
|
||||
super(escherRecord, parent);
|
||||
|
||||
}
|
||||
@ -122,7 +122,7 @@ public abstract class TextShape extends SimpleShape {
|
||||
* @param parent the parent of this Shape. For example, if this text box is a cell
|
||||
* in a table then the parent is Table.
|
||||
*/
|
||||
public TextShape(ShapeContainer<HSLFShape> parent){
|
||||
public HSLFTextShape(ShapeContainer<HSLFShape> parent){
|
||||
super(null, parent);
|
||||
_escherContainer = createSpContainer(parent instanceof HSLFGroupShape);
|
||||
}
|
||||
@ -131,15 +131,15 @@ public abstract class TextShape extends SimpleShape {
|
||||
* Create a new TextBox. This constructor is used when a new shape is created.
|
||||
*
|
||||
*/
|
||||
public TextShape(){
|
||||
public HSLFTextShape(){
|
||||
this(null);
|
||||
}
|
||||
|
||||
public TextRun createTextRun(){
|
||||
public HSLFTextParagraph createTextRun(){
|
||||
_txtbox = getEscherTextboxWrapper();
|
||||
if(_txtbox == null) _txtbox = new EscherTextboxWrapper();
|
||||
|
||||
_txtrun = getTextRun();
|
||||
_txtrun = getTextParagraph();
|
||||
if(_txtrun == null){
|
||||
TextHeaderAtom tha = new TextHeaderAtom();
|
||||
tha.setParentRecord(_txtbox);
|
||||
@ -151,7 +151,7 @@ public abstract class TextShape extends SimpleShape {
|
||||
StyleTextPropAtom sta = new StyleTextPropAtom(0);
|
||||
_txtbox.appendChildRecord(sta);
|
||||
|
||||
_txtrun = new TextRun(tha,tca,sta);
|
||||
_txtrun = new HSLFTextParagraph(tha,tca,sta);
|
||||
_txtrun._records = new Record[]{tha, tca, sta};
|
||||
_txtrun.setText("");
|
||||
|
||||
@ -170,7 +170,7 @@ public abstract class TextShape extends SimpleShape {
|
||||
* AutoShape: align=center, valign=middle
|
||||
*
|
||||
*/
|
||||
protected void setDefaultTextProperties(TextRun _txtrun){
|
||||
protected void setDefaultTextProperties(HSLFTextParagraph _txtrun){
|
||||
|
||||
}
|
||||
|
||||
@ -180,7 +180,7 @@ public abstract class TextShape extends SimpleShape {
|
||||
* @return the text string for this textbox.
|
||||
*/
|
||||
public String getText(){
|
||||
TextRun tx = getTextRun();
|
||||
HSLFTextParagraph tx = getTextParagraph();
|
||||
return tx == null ? null : tx.getText();
|
||||
}
|
||||
|
||||
@ -190,7 +190,7 @@ public abstract class TextShape extends SimpleShape {
|
||||
* @param text the text string used by this object.
|
||||
*/
|
||||
public void setText(String text){
|
||||
TextRun tx = getTextRun();
|
||||
HSLFTextParagraph tx = getTextParagraph();
|
||||
if(tx == null){
|
||||
tx = createTextRun();
|
||||
}
|
||||
@ -204,7 +204,7 @@ public abstract class TextShape extends SimpleShape {
|
||||
*
|
||||
* @param sh the sheet we are adding to
|
||||
*/
|
||||
protected void afterInsert(Sheet sh){
|
||||
protected void afterInsert(HSLFSheet sh){
|
||||
super.afterInsert(sh);
|
||||
|
||||
EscherTextboxWrapper _txtbox = getEscherTextboxWrapper();
|
||||
@ -241,7 +241,7 @@ public abstract class TextShape extends SimpleShape {
|
||||
String txt = getText();
|
||||
if(txt == null || txt.length() == 0) return new Rectangle2D.Float();
|
||||
|
||||
RichTextRun rt = getTextRun().getRichTextRuns()[0];
|
||||
HSLFTextRun rt = getTextParagraph().getRichTextRuns()[0];
|
||||
int size = rt.getFontSize();
|
||||
int style = 0;
|
||||
if (rt.isBold()) style |= Font.BOLD;
|
||||
@ -284,26 +284,26 @@ public abstract class TextShape extends SimpleShape {
|
||||
public int getVerticalAlignment(){
|
||||
EscherOptRecord opt = getEscherOptRecord();
|
||||
EscherSimpleProperty prop = getEscherProperty(opt, EscherProperties.TEXT__ANCHORTEXT);
|
||||
int valign = TextShape.AnchorTop;
|
||||
int valign = HSLFTextShape.AnchorTop;
|
||||
if (prop == null){
|
||||
/**
|
||||
* If vertical alignment was not found in the shape properties then try to
|
||||
* fetch the master shape and search for the align property there.
|
||||
*/
|
||||
int type = getTextRun().getRunType();
|
||||
MasterSheet master = getSheet().getMasterSheet();
|
||||
int type = getTextParagraph().getRunType();
|
||||
HSLFMasterSheet master = getSheet().getMasterSheet();
|
||||
if(master != null){
|
||||
TextShape masterShape = master.getPlaceholderByTextType(type);
|
||||
HSLFTextShape masterShape = master.getPlaceholderByTextType(type);
|
||||
if(masterShape != null) valign = masterShape.getVerticalAlignment();
|
||||
} else {
|
||||
//not found in the master sheet. Use the hardcoded defaults.
|
||||
switch (type){
|
||||
case TextHeaderAtom.TITLE_TYPE:
|
||||
case TextHeaderAtom.CENTER_TITLE_TYPE:
|
||||
valign = TextShape.AnchorMiddle;
|
||||
valign = HSLFTextShape.AnchorMiddle;
|
||||
break;
|
||||
default:
|
||||
valign = TextShape.AnchorTop;
|
||||
valign = HSLFTextShape.AnchorTop;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -330,7 +330,7 @@ public abstract class TextShape extends SimpleShape {
|
||||
* @param align - the type of horizontal alignment
|
||||
*/
|
||||
public void setHorizontalAlignment(int align){
|
||||
TextRun tx = getTextRun();
|
||||
HSLFTextParagraph tx = getTextParagraph();
|
||||
if(tx != null) tx.getRichTextRuns()[0].setAlignment(align);
|
||||
}
|
||||
|
||||
@ -341,7 +341,7 @@ public abstract class TextShape extends SimpleShape {
|
||||
* @return align - the type of horizontal alignment
|
||||
*/
|
||||
public int getHorizontalAlignment(){
|
||||
TextRun tx = getTextRun();
|
||||
HSLFTextParagraph tx = getTextParagraph();
|
||||
return tx == null ? -1 : tx.getRichTextRuns()[0].getAlignment();
|
||||
}
|
||||
|
||||
@ -487,7 +487,7 @@ public abstract class TextShape extends SimpleShape {
|
||||
/**
|
||||
* @return the TextRun object for this text box
|
||||
*/
|
||||
public TextRun getTextRun(){
|
||||
public HSLFTextParagraph getTextParagraph(){
|
||||
if (null == this._txtrun) initTextRun();
|
||||
if (null == this._txtrun && null != this._txtbox) {
|
||||
TextHeaderAtom tha = null;
|
||||
@ -507,36 +507,31 @@ public abstract class TextShape extends SimpleShape {
|
||||
}
|
||||
}
|
||||
if (tba != null) {
|
||||
this._txtrun = new TextRun(tha, tba, sta);
|
||||
this._txtrun = new HSLFTextParagraph(tha, tba, sta);
|
||||
} else if (tca != null) {
|
||||
this._txtrun = new TextRun(tha, tca, sta);
|
||||
this._txtrun = new HSLFTextParagraph(tha, tca, sta);
|
||||
}
|
||||
}
|
||||
return _txtrun;
|
||||
}
|
||||
|
||||
public void setSheet(Sheet sheet) {
|
||||
public void setSheet(HSLFSheet sheet) {
|
||||
_sheet = sheet;
|
||||
|
||||
// Initialize _txtrun object.
|
||||
// (We can't do it in the constructor because the sheet
|
||||
// is not assigned then, it's only built once we have
|
||||
// all the records)
|
||||
TextRun tx = getTextRun();
|
||||
HSLFTextParagraph tx = getTextParagraph();
|
||||
if (tx != null) {
|
||||
// Supply the sheet to our child RichTextRuns
|
||||
tx.setSheet(_sheet);
|
||||
RichTextRun[] rt = tx.getRichTextRuns();
|
||||
for (int i = 0; i < rt.length; i++) {
|
||||
rt[i].supplySlideShow(_sheet.getSlideShow());
|
||||
}
|
||||
tx.supplySheet(_sheet);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void initTextRun(){
|
||||
EscherTextboxWrapper txtbox = getEscherTextboxWrapper();
|
||||
Sheet sheet = getSheet();
|
||||
HSLFSheet sheet = getSheet();
|
||||
|
||||
if(sheet == null || txtbox == null) return;
|
||||
|
||||
@ -550,7 +545,7 @@ public abstract class TextShape extends SimpleShape {
|
||||
}
|
||||
}
|
||||
|
||||
TextRun[] runs = _sheet.getTextRuns();
|
||||
HSLFTextParagraph[] runs = _sheet.getTextRuns();
|
||||
if (ota != null) {
|
||||
int idx = ota.getTextIndex();
|
||||
for (int i = 0; i < runs.length; i++) {
|
||||
@ -572,11 +567,14 @@ public abstract class TextShape extends SimpleShape {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ensure the same references child records of TextRun
|
||||
if(_txtrun != null) for (int i = 0; i < child.length; i++) {
|
||||
for (Record r : _txtrun.getRecords()) {
|
||||
if (child[i].getRecordType() == r.getRecordType()) {
|
||||
child[i] = r;
|
||||
if(_txtrun != null) {
|
||||
for (int i = 0; i < child.length; i++) {
|
||||
for (Record r : _txtrun.getRecords()) {
|
||||
if (child[i].getRecordType() == r.getRecordType()) {
|
||||
child[i] = r;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -605,7 +603,7 @@ public abstract class TextShape extends SimpleShape {
|
||||
* @param linkId id of the hyperlink, @see org.apache.poi.hslf.usermodel.SlideShow#addHyperlink(Hyperlink)
|
||||
* @param beginIndex the beginning index, inclusive.
|
||||
* @param endIndex the ending index, exclusive.
|
||||
* @see org.apache.poi.hslf.usermodel.SlideShow#addHyperlink(Hyperlink)
|
||||
* @see org.apache.poi.hslf.usermodel.HSLFSlideShow#addHyperlink(Hyperlink)
|
||||
*/
|
||||
public void setHyperlink(int linkId, int beginIndex, int endIndex){
|
||||
//TODO validate beginIndex and endIndex and throw IllegalArgumentException
|
@ -18,7 +18,7 @@
|
||||
package org.apache.poi.hslf.model;
|
||||
|
||||
import org.apache.poi.hslf.record.*;
|
||||
import org.apache.poi.hslf.usermodel.SlideShow;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
|
||||
/**
|
||||
* Header / Footer settings.
|
||||
@ -31,19 +31,19 @@ public final class HeadersFooters {
|
||||
|
||||
private HeadersFootersContainer _container;
|
||||
private boolean _newRecord;
|
||||
private SlideShow _ppt;
|
||||
private Sheet _sheet;
|
||||
private HSLFSlideShow _ppt;
|
||||
private HSLFSheet _sheet;
|
||||
private boolean _ppt2007;
|
||||
|
||||
|
||||
public HeadersFooters(HeadersFootersContainer rec, SlideShow ppt, boolean newRecord, boolean isPpt2007){
|
||||
public HeadersFooters(HeadersFootersContainer rec, HSLFSlideShow ppt, boolean newRecord, boolean isPpt2007){
|
||||
_container = rec;
|
||||
_newRecord = newRecord;
|
||||
_ppt = ppt;
|
||||
_ppt2007 = isPpt2007;
|
||||
}
|
||||
|
||||
public HeadersFooters(HeadersFootersContainer rec, Sheet sheet, boolean newRecord, boolean isPpt2007){
|
||||
public HeadersFooters(HeadersFootersContainer rec, HSLFSheet sheet, boolean newRecord, boolean isPpt2007){
|
||||
_container = rec;
|
||||
_newRecord = newRecord;
|
||||
_sheet = sheet;
|
||||
@ -240,8 +240,8 @@ public final class HeadersFooters {
|
||||
private boolean isVisible(int flag, int placeholderId){
|
||||
boolean visible;
|
||||
if(_ppt2007){
|
||||
Sheet master = _sheet != null ? _sheet : _ppt.getSlidesMasters()[0];
|
||||
TextShape placeholder = master.getPlaceholder(placeholderId);
|
||||
HSLFSheet master = _sheet != null ? _sheet : _ppt.getSlidesMasters()[0];
|
||||
HSLFTextShape placeholder = master.getPlaceholder(placeholderId);
|
||||
visible = placeholder != null && placeholder.getText() != null;
|
||||
} else {
|
||||
visible = _container.getHeadersFootersAtom().getFlag(flag);
|
||||
@ -252,8 +252,8 @@ public final class HeadersFooters {
|
||||
private String getPlaceholderText(int placeholderId, CString cs){
|
||||
String text = null;
|
||||
if(_ppt2007){
|
||||
Sheet master = _sheet != null ? _sheet : _ppt.getSlidesMasters()[0];
|
||||
TextShape placeholder = master.getPlaceholder(placeholderId);
|
||||
HSLFSheet master = _sheet != null ? _sheet : _ppt.getSlidesMasters()[0];
|
||||
HSLFTextShape placeholder = master.getPlaceholder(placeholderId);
|
||||
if(placeholder != null) text = placeholder.getText();
|
||||
|
||||
//default text in master placeholders is not visible
|
||||
|
@ -18,7 +18,7 @@
|
||||
package org.apache.poi.hslf.model;
|
||||
|
||||
import org.apache.poi.hslf.record.*;
|
||||
import org.apache.poi.hslf.usermodel.SlideShow;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.ddf.EscherContainerRecord;
|
||||
import org.apache.poi.ddf.EscherRecord;
|
||||
import org.apache.poi.ddf.EscherClientDataRecord;
|
||||
@ -95,7 +95,7 @@ public final class Hyperlink {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(Slide slide) {
|
||||
public void setAddress(HSLFSlide slide) {
|
||||
String href = slide._getSheetNumber() + ","+slide.getSlideNumber()+",Slide " + slide.getSlideNumber();
|
||||
setAddress(href);;
|
||||
setTitle("Slide " + slide.getSlideNumber());
|
||||
@ -151,9 +151,9 @@ public final class Hyperlink {
|
||||
* @param run <code>TextRun</code> to lookup hyperlinks in
|
||||
* @return found hyperlinks or <code>null</code> if not found
|
||||
*/
|
||||
protected static Hyperlink[] find(TextRun run){
|
||||
protected static Hyperlink[] find(HSLFTextParagraph run){
|
||||
List<Hyperlink> lst = new ArrayList<Hyperlink>();
|
||||
SlideShow ppt = run.getSheet().getSlideShow();
|
||||
HSLFSlideShow ppt = run.getSheet().getSlideShow();
|
||||
//document-level container which stores info about all links in a presentation
|
||||
ExObjList exobj = ppt.getDocumentRecord().getExObjList();
|
||||
if (exobj == null) {
|
||||
@ -178,7 +178,7 @@ public final class Hyperlink {
|
||||
*/
|
||||
protected static Hyperlink find(HSLFShape shape){
|
||||
List<Hyperlink> lst = new ArrayList<Hyperlink>();
|
||||
SlideShow ppt = shape.getSheet().getSlideShow();
|
||||
HSLFSlideShow ppt = shape.getSheet().getSlideShow();
|
||||
//document-level container which stores info about all links in a presentation
|
||||
ExObjList exobj = ppt.getDocumentRecord().getExObjList();
|
||||
if (exobj == null) {
|
||||
|
@ -29,74 +29,7 @@ import java.awt.geom.Line2D;
|
||||
*
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public final class Line extends SimpleShape {
|
||||
/**
|
||||
* Solid (continuous) pen
|
||||
*/
|
||||
public static final int PEN_SOLID = 1;
|
||||
/**
|
||||
* PS_DASH system dash style
|
||||
*/
|
||||
public static final int PEN_PS_DASH = 2;
|
||||
/**
|
||||
* PS_DOT system dash style
|
||||
*/
|
||||
public static final int PEN_DOT = 3;
|
||||
/**
|
||||
* PS_DASHDOT system dash style
|
||||
*/
|
||||
public static final int PEN_DASHDOT = 4;
|
||||
/**
|
||||
* PS_DASHDOTDOT system dash style
|
||||
*/
|
||||
public static final int PEN_DASHDOTDOT = 5;
|
||||
/**
|
||||
* square dot style
|
||||
*/
|
||||
public static final int PEN_DOTGEL = 6;
|
||||
/**
|
||||
* dash style
|
||||
*/
|
||||
public static final int PEN_DASH = 7;
|
||||
/**
|
||||
* long dash style
|
||||
*/
|
||||
public static final int PEN_LONGDASHGEL = 8;
|
||||
/**
|
||||
* dash short dash
|
||||
*/
|
||||
public static final int PEN_DASHDOTGEL = 9;
|
||||
/**
|
||||
* long dash short dash
|
||||
*/
|
||||
public static final int PEN_LONGDASHDOTGEL = 10;
|
||||
/**
|
||||
* long dash short dash short dash
|
||||
*/
|
||||
public static final int PEN_LONGDASHDOTDOTGEL = 11;
|
||||
|
||||
/**
|
||||
* Single line (of width lineWidth)
|
||||
*/
|
||||
public static final int LINE_SIMPLE = 0;
|
||||
/**
|
||||
* Double lines of equal width
|
||||
*/
|
||||
public static final int LINE_DOUBLE = 1;
|
||||
/**
|
||||
* Double lines, one thick, one thin
|
||||
*/
|
||||
public static final int LINE_THICKTHIN = 2;
|
||||
/**
|
||||
* Double lines, reverse order
|
||||
*/
|
||||
public static final int LINE_THINTHICK = 3;
|
||||
/**
|
||||
* Three lines, thin, thick, thin
|
||||
*/
|
||||
public static final int LINE_TRIPLE = 4;
|
||||
|
||||
|
||||
public final class Line extends HSLFSimpleShape {
|
||||
protected Line(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
|
||||
super(escherRecord, parent);
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ import org.apache.poi.ddf.EscherContainerRecord;
|
||||
import org.apache.poi.ddf.EscherProperties;
|
||||
import org.apache.poi.hslf.exceptions.HSLFException;
|
||||
import org.apache.poi.hslf.record.*;
|
||||
import org.apache.poi.hslf.usermodel.SlideShow;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.sl.usermodel.ShapeContainer;
|
||||
|
||||
/**
|
||||
@ -32,7 +32,7 @@ import org.apache.poi.sl.usermodel.ShapeContainer;
|
||||
*
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public final class MovieShape extends Picture {
|
||||
public final class MovieShape extends HSLFPictureShape {
|
||||
public static final int DEFAULT_MOVIE_THUMBNAIL = -1;
|
||||
|
||||
public static final int MOVIE_MPEG = 1;
|
||||
@ -113,7 +113,7 @@ public final class MovieShape extends Picture {
|
||||
/**
|
||||
* Assign a movie to this shape
|
||||
*
|
||||
* @see org.apache.poi.hslf.usermodel.SlideShow#addMovie(String, int)
|
||||
* @see org.apache.poi.hslf.usermodel.HSLFSlideShow#addMovie(String, int)
|
||||
* @param idx the index of the movie
|
||||
*/
|
||||
public void setMovieIndex(int idx){
|
||||
@ -154,7 +154,7 @@ public final class MovieShape extends Picture {
|
||||
OEShapeAtom oe = getClientDataRecord(RecordTypes.OEShapeAtom.typeID);
|
||||
int idx = oe.getOptions();
|
||||
|
||||
SlideShow ppt = getSheet().getSlideShow();
|
||||
HSLFSlideShow ppt = getSheet().getSlideShow();
|
||||
ExObjList lst = (ExObjList)ppt.getDocumentRecord().findFirstOfType(RecordTypes.ExObjList.typeID);
|
||||
if(lst == null) return null;
|
||||
|
||||
|
@ -18,8 +18,8 @@
|
||||
package org.apache.poi.hslf.model;
|
||||
|
||||
import org.apache.poi.ddf.*;
|
||||
import org.apache.poi.hslf.usermodel.SlideShow;
|
||||
import org.apache.poi.hslf.usermodel.ObjectData;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
import org.apache.poi.hslf.usermodel.HSLFObjectData;
|
||||
import org.apache.poi.hslf.record.ExObjList;
|
||||
import org.apache.poi.hslf.record.Record;
|
||||
import org.apache.poi.hslf.record.ExEmbed;
|
||||
@ -34,7 +34,7 @@ import org.apache.poi.util.POILogger;
|
||||
*
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public final class OLEShape extends Picture {
|
||||
public final class OLEShape extends HSLFPictureShape {
|
||||
protected ExEmbed _exEmbed;
|
||||
|
||||
/**
|
||||
@ -117,13 +117,13 @@ public final class OLEShape extends Picture {
|
||||
*
|
||||
* @return the unique identifier for the OLE object
|
||||
*/
|
||||
public ObjectData getObjectData(){
|
||||
SlideShow ppt = getSheet().getSlideShow();
|
||||
ObjectData[] ole = ppt.getEmbeddedObjects();
|
||||
public HSLFObjectData getObjectData(){
|
||||
HSLFSlideShow ppt = getSheet().getSlideShow();
|
||||
HSLFObjectData[] ole = ppt.getEmbeddedObjects();
|
||||
|
||||
//persist reference
|
||||
ExEmbed exEmbed = getExEmbed();
|
||||
ObjectData data = null;
|
||||
HSLFObjectData data = null;
|
||||
if(exEmbed != null) {
|
||||
int ref = exEmbed.getExOleObjAtom().getObjStgDataRef();
|
||||
|
||||
@ -156,7 +156,7 @@ public final class OLEShape extends Picture {
|
||||
*/
|
||||
public ExEmbed getExEmbed(){
|
||||
if(_exEmbed == null){
|
||||
SlideShow ppt = getSheet().getSlideShow();
|
||||
HSLFSlideShow ppt = getSheet().getSlideShow();
|
||||
|
||||
ExObjList lst = ppt.getDocumentRecord().getExObjList();
|
||||
if(lst == null){
|
||||
|
@ -28,7 +28,7 @@ import java.awt.image.renderable.RenderableImage;
|
||||
import java.awt.geom.*;
|
||||
import java.text.AttributedCharacterIterator;
|
||||
import java.util.Map;
|
||||
import org.apache.poi.hslf.usermodel.RichTextRun;
|
||||
import org.apache.poi.hslf.usermodel.HSLFTextRun;
|
||||
import org.apache.poi.hslf.exceptions.HSLFException;
|
||||
import org.apache.poi.util.POILogger;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
@ -214,7 +214,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
|
||||
*/
|
||||
public void draw(Shape shape){
|
||||
GeneralPath path = new GeneralPath(_transform.createTransformedShape(shape));
|
||||
Freeform p = new Freeform(_group);
|
||||
HSLFFreeformShape p = new HSLFFreeformShape(_group);
|
||||
p.setPath(path);
|
||||
p.getFill().setForegroundColor(null);
|
||||
applyStroke(p);
|
||||
@ -250,12 +250,11 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
|
||||
* @see #setClip
|
||||
*/
|
||||
public void drawString(String s, float x, float y) {
|
||||
TextBox txt = new TextBox(_group);
|
||||
txt.getTextRun().supplySlideShow(_group.getSheet().getSlideShow());
|
||||
txt.getTextRun().setSheet(_group.getSheet());
|
||||
HSLFTextBox txt = new HSLFTextBox(_group);
|
||||
txt.getTextParagraph().supplySheet(_group.getSheet());
|
||||
txt.setText(s);
|
||||
|
||||
RichTextRun rt = txt.getTextRun().getRichTextRuns()[0];
|
||||
HSLFTextRun rt = txt.getTextParagraph().getRichTextRuns()[0];
|
||||
rt.setFontSize(_font.getSize());
|
||||
rt.setFontName(_font.getFamily());
|
||||
|
||||
@ -267,9 +266,9 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
|
||||
txt.setMarginTop(0);
|
||||
txt.setMarginLeft(0);
|
||||
txt.setMarginRight(0);
|
||||
txt.setWordWrap(TextBox.WrapNone);
|
||||
txt.setHorizontalAlignment(TextBox.AlignLeft);
|
||||
txt.setVerticalAlignment(TextBox.AnchorMiddle);
|
||||
txt.setWordWrap(HSLFTextBox.WrapNone);
|
||||
txt.setHorizontalAlignment(HSLFTextBox.AlignLeft);
|
||||
txt.setVerticalAlignment(HSLFTextBox.AnchorMiddle);
|
||||
|
||||
|
||||
TextLayout layout = new TextLayout(s, _font, getFontRenderContext());
|
||||
@ -317,7 +316,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
|
||||
*/
|
||||
public void fill(Shape shape){
|
||||
GeneralPath path = new GeneralPath(_transform.createTransformedShape(shape));
|
||||
Freeform p = new Freeform(_group);
|
||||
HSLFFreeformShape p = new HSLFFreeformShape(_group);
|
||||
p.setPath(path);
|
||||
applyPaint(p);
|
||||
p.setLineColor(null); //Fills must be "No Line"
|
||||
@ -1788,7 +1787,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
protected void applyStroke(SimpleShape shape) {
|
||||
protected void applyStroke(HSLFSimpleShape shape) {
|
||||
if (_stroke instanceof BasicStroke){
|
||||
BasicStroke bs = (BasicStroke)_stroke;
|
||||
shape.setLineWidth(bs.getLineWidth());
|
||||
@ -1800,7 +1799,7 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
protected void applyPaint(SimpleShape shape) {
|
||||
protected void applyPaint(HSLFSimpleShape shape) {
|
||||
if (_paint instanceof Color) {
|
||||
shape.getFill().setForegroundColor((Color)_paint);
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ import java.io.ByteArrayOutputStream;
|
||||
*
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public final class Placeholder extends TextBox {
|
||||
public final class Placeholder extends HSLFTextBox {
|
||||
|
||||
protected Placeholder(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape> parent){
|
||||
super(escherRecord, parent);
|
||||
|
@ -29,7 +29,7 @@ import java.awt.geom.Point2D;
|
||||
*
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public final class Polygon extends AutoShape {
|
||||
public final class Polygon extends HSLFAutoShape {
|
||||
/**
|
||||
* Create a Polygon object and initialize it from the supplied Record container.
|
||||
*
|
||||
|
@ -89,7 +89,7 @@ public final class ShapeFactory {
|
||||
ShapeType type = ShapeType.forId(spRecord.getShapeType(), false);
|
||||
switch (type){
|
||||
case TEXT_BOX:
|
||||
shape = new TextBox(spContainer, parent);
|
||||
shape = new HSLFTextBox(spContainer, parent);
|
||||
break;
|
||||
case HOST_CONTROL:
|
||||
case FRAME: {
|
||||
@ -110,7 +110,7 @@ public final class ShapeFactory {
|
||||
shape = new OLEShape(spContainer, parent);
|
||||
}
|
||||
|
||||
if(shape == null) shape = new Picture(spContainer, parent);
|
||||
if(shape == null) shape = new HSLFPictureShape(spContainer, parent);
|
||||
break;
|
||||
}
|
||||
case LINE:
|
||||
@ -120,16 +120,16 @@ public final class ShapeFactory {
|
||||
EscherOptRecord opt = HSLFShape.getEscherChild(spContainer, EscherOptRecord.RECORD_ID);
|
||||
EscherProperty prop = HSLFShape.getEscherProperty(opt, EscherProperties.GEOMETRY__VERTICES);
|
||||
if(prop != null)
|
||||
shape = new Freeform(spContainer, parent);
|
||||
shape = new HSLFFreeformShape(spContainer, parent);
|
||||
else {
|
||||
|
||||
logger.log(POILogger.WARN, "Creating AutoShape for a NotPrimitive shape");
|
||||
shape = new AutoShape(spContainer, parent);
|
||||
shape = new HSLFAutoShape(spContainer, parent);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
shape = new AutoShape(spContainer, parent);
|
||||
shape = new HSLFAutoShape(spContainer, parent);
|
||||
break;
|
||||
}
|
||||
return shape;
|
||||
|
@ -35,7 +35,7 @@ import org.apache.poi.util.POILogger;
|
||||
public final class ShapePainter {
|
||||
protected static final POILogger logger = POILogFactory.getLogger(ShapePainter.class);
|
||||
|
||||
public static void paint(SimpleShape shape, Graphics2D graphics){
|
||||
public static void paint(HSLFSimpleShape shape, Graphics2D graphics){
|
||||
Rectangle2D anchor = shape.getLogicalAnchor2D();
|
||||
java.awt.Shape outline = shape.getOutline();
|
||||
|
||||
|
@ -20,7 +20,7 @@ package org.apache.poi.hslf.model;
|
||||
import org.apache.poi.hslf.model.textproperties.TextProp;
|
||||
import org.apache.poi.hslf.model.textproperties.TextPropCollection;
|
||||
import org.apache.poi.hslf.record.*;
|
||||
import org.apache.poi.hslf.usermodel.SlideShow;
|
||||
import org.apache.poi.hslf.usermodel.HSLFSlideShow;
|
||||
|
||||
/**
|
||||
* SlideMaster determines the graphics, layout, and formatting for all the slides in a given presentation.
|
||||
@ -29,8 +29,8 @@ import org.apache.poi.hslf.usermodel.SlideShow;
|
||||
*
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public final class SlideMaster extends MasterSheet {
|
||||
private TextRun[] _runs;
|
||||
public final class SlideMaster extends HSLFMasterSheet {
|
||||
private HSLFTextParagraph[] _runs;
|
||||
|
||||
/**
|
||||
* all TxMasterStyleAtoms available in this master
|
||||
@ -51,14 +51,14 @@ public final class SlideMaster extends MasterSheet {
|
||||
/**
|
||||
* Returns an array of all the TextRuns found
|
||||
*/
|
||||
public TextRun[] getTextRuns() {
|
||||
public HSLFTextParagraph[] getTextRuns() {
|
||||
return _runs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>null</code> since SlideMasters doen't have master sheet.
|
||||
*/
|
||||
public MasterSheet getMasterSheet() {
|
||||
public HSLFMasterSheet getMasterSheet() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ public final class SlideMaster extends MasterSheet {
|
||||
* Assign SlideShow for this slide master.
|
||||
* (Used interanlly)
|
||||
*/
|
||||
public void setSlideShow(SlideShow ss) {
|
||||
public void setSlideShow(HSLFSlideShow ss) {
|
||||
super.setSlideShow(ss);
|
||||
|
||||
//after the slide show is assigned collect all available style records
|
||||
@ -130,12 +130,12 @@ public final class SlideMaster extends MasterSheet {
|
||||
}
|
||||
}
|
||||
|
||||
protected void onAddTextShape(TextShape shape) {
|
||||
TextRun run = shape.getTextRun();
|
||||
protected void onAddTextShape(HSLFTextShape shape) {
|
||||
HSLFTextParagraph run = shape.getTextParagraph();
|
||||
|
||||
if(_runs == null) _runs = new TextRun[]{run};
|
||||
if(_runs == null) _runs = new HSLFTextParagraph[]{run};
|
||||
else {
|
||||
TextRun[] tmp = new TextRun[_runs.length + 1];
|
||||
HSLFTextParagraph[] tmp = new HSLFTextParagraph[_runs.length + 1];
|
||||
System.arraycopy(_runs, 0, tmp, 0, _runs.length);
|
||||
tmp[tmp.length-1] = run;
|
||||
_runs = tmp;
|
||||
|
@ -115,7 +115,7 @@ public final class Table extends HSLFGroupShape {
|
||||
return cells.length;
|
||||
}
|
||||
|
||||
protected void afterInsert(Sheet sh){
|
||||
protected void afterInsert(HSLFSheet sh){
|
||||
super.afterInsert(sh);
|
||||
|
||||
EscherContainerRecord spCont = (EscherContainerRecord) getSpContainer().getChild(0);
|
||||
@ -165,7 +165,7 @@ public final class Table extends HSLFGroupShape {
|
||||
List<List<HSLFShape>> lst = new ArrayList<List<HSLFShape>>();
|
||||
List<HSLFShape> row = null;
|
||||
for (HSLFShape sh : shapeList) {
|
||||
if(sh instanceof TextShape){
|
||||
if(sh instanceof HSLFTextShape){
|
||||
Rectangle anchor = sh.getAnchor();
|
||||
if(anchor.y != y0){
|
||||
y0 = anchor.y;
|
||||
@ -180,7 +180,7 @@ public final class Table extends HSLFGroupShape {
|
||||
for (int i = 0; i < lst.size(); i++) {
|
||||
row = lst.get(i);
|
||||
for (int j = 0; j < row.size(); j++) {
|
||||
TextShape tx = (TextShape)row.get(j);
|
||||
HSLFTextShape tx = (HSLFTextShape)row.get(j);
|
||||
cells[i][j] = new TableCell(tx.getSpContainer(), getParent());
|
||||
cells[i][j].setSheet(tx.getSheet());
|
||||
}
|
||||
@ -192,7 +192,7 @@ public final class Table extends HSLFGroupShape {
|
||||
*
|
||||
* @param sheet owner of this shape
|
||||
*/
|
||||
public void setSheet(Sheet sheet){
|
||||
public void setSheet(HSLFSheet sheet){
|
||||
super.setSheet(sheet);
|
||||
if(cells == null) initTable();
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ import org.apache.poi.sl.usermodel.ShapeType;
|
||||
*
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public final class TableCell extends TextBox {
|
||||
public final class TableCell extends HSLFTextBox {
|
||||
protected static final int DEFAULT_WIDTH = 100;
|
||||
protected static final int DEFAULT_HEIGHT = 40;
|
||||
|
||||
|
@ -35,7 +35,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.poi.hslf.record.TextRulerAtom;
|
||||
import org.apache.poi.hslf.usermodel.RichTextRun;
|
||||
import org.apache.poi.hslf.usermodel.HSLFTextRun;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
|
||||
@ -57,27 +57,27 @@ public final class TextPainter {
|
||||
*/
|
||||
protected static final char DEFAULT_BULLET_CHAR = '\u25a0';
|
||||
|
||||
protected TextShape _shape;
|
||||
protected HSLFTextShape _shape;
|
||||
|
||||
public TextPainter(TextShape shape){
|
||||
public TextPainter(HSLFTextShape shape){
|
||||
_shape = shape;
|
||||
}
|
||||
|
||||
public AttributedString getAttributedString(TextRun txrun) {
|
||||
public AttributedString getAttributedString(HSLFTextParagraph txrun) {
|
||||
return getAttributedString(txrun, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the underlying set of rich text runs into java.text.AttributedString
|
||||
*/
|
||||
public AttributedString getAttributedString(TextRun txrun, Graphics2D graphics){
|
||||
public AttributedString getAttributedString(HSLFTextParagraph txrun, Graphics2D graphics){
|
||||
String text = txrun.getText();
|
||||
//TODO: properly process tabs
|
||||
text = text.replace('\t', ' ');
|
||||
text = text.replace((char)160, ' ');
|
||||
|
||||
AttributedString at = new AttributedString(text);
|
||||
RichTextRun[] rt = txrun.getRichTextRuns();
|
||||
HSLFTextRun[] rt = txrun.getRichTextRuns();
|
||||
for (int i = 0; i < rt.length; i++) {
|
||||
int start = rt[i].getStartIndex();
|
||||
int end = rt[i].getEndIndex();
|
||||
@ -157,15 +157,15 @@ public final class TextPainter {
|
||||
int valign = _shape.getVerticalAlignment();
|
||||
double y0 = anchor.getY();
|
||||
switch (valign){
|
||||
case TextShape.AnchorTopBaseline:
|
||||
case TextShape.AnchorTop:
|
||||
case HSLFTextShape.AnchorTopBaseline:
|
||||
case HSLFTextShape.AnchorTop:
|
||||
y0 += _shape.getMarginTop();
|
||||
break;
|
||||
case TextShape.AnchorBottom:
|
||||
case HSLFTextShape.AnchorBottom:
|
||||
y0 += anchor.getHeight() - textHeight - _shape.getMarginBottom();
|
||||
break;
|
||||
default:
|
||||
case TextShape.AnchorMiddle:
|
||||
case HSLFTextShape.AnchorMiddle:
|
||||
float delta = (float)anchor.getHeight() - textHeight - _shape.getMarginTop() - _shape.getMarginBottom();
|
||||
y0 += _shape.getMarginTop() + delta/2;
|
||||
break;
|
||||
@ -205,14 +205,14 @@ public final class TextPainter {
|
||||
pen.y = y0;
|
||||
switch (elem[i]._align) {
|
||||
default:
|
||||
case TextShape.AlignLeft:
|
||||
case HSLFTextShape.AlignLeft:
|
||||
pen.x = anchor.getX() + _shape.getMarginLeft();
|
||||
break;
|
||||
case TextShape.AlignCenter:
|
||||
case HSLFTextShape.AlignCenter:
|
||||
pen.x = anchor.getX() + _shape.getMarginLeft() +
|
||||
(anchor.getWidth() - elem[i].advance - _shape.getMarginLeft() - _shape.getMarginRight()) / 2;
|
||||
break;
|
||||
case TextShape.AlignRight:
|
||||
case HSLFTextShape.AlignRight:
|
||||
pen.x = anchor.getX() + _shape.getMarginLeft() +
|
||||
(anchor.getWidth() - elem[i].advance - _shape.getMarginLeft() - _shape.getMarginRight());
|
||||
break;
|
||||
@ -235,7 +235,7 @@ public final class TextPainter {
|
||||
}
|
||||
|
||||
public TextElement[] getTextElements(float textWidth, FontRenderContext frc, Graphics2D graphics){
|
||||
TextRun run = _shape.getTextRun();
|
||||
HSLFTextParagraph run = _shape.getTextParagraph();
|
||||
if (run == null) return null;
|
||||
|
||||
String text = run.getText();
|
||||
@ -257,7 +257,7 @@ public final class TextPainter {
|
||||
boolean prStart = text.charAt(startIndex) == '\n';
|
||||
if(prStart) measurer.setPosition(startIndex++);
|
||||
|
||||
RichTextRun rt = run.getRichTextRunAt(startIndex == text.length() ? (startIndex-1) : startIndex);
|
||||
HSLFTextRun rt = run.getRichTextRunAt(startIndex == text.length() ? (startIndex-1) : startIndex);
|
||||
if(rt == null) {
|
||||
logger.log(POILogger.WARN, "RichTextRun not found at pos" + startIndex + "; text.length: " + text.length());
|
||||
break;
|
||||
@ -283,7 +283,7 @@ public final class TextPainter {
|
||||
|
||||
if(bulletOffset > 0 || prStart || startIndex == 0) wrappingWidth -= textOffset;
|
||||
|
||||
if (_shape.getWordWrap() == TextShape.WrapNone) {
|
||||
if (_shape.getWordWrap() == HSLFTextShape.WrapNone) {
|
||||
wrappingWidth = _shape.getSheet().getSlideShow().getPageSize().width;
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,8 @@ import org.apache.poi.hslf.record.*;
|
||||
*
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public final class TitleMaster extends MasterSheet {
|
||||
private TextRun[] _runs;
|
||||
public final class TitleMaster extends HSLFMasterSheet {
|
||||
private HSLFTextParagraph[] _runs;
|
||||
|
||||
/**
|
||||
* Constructs a TitleMaster
|
||||
@ -42,7 +42,7 @@ public final class TitleMaster extends MasterSheet {
|
||||
/**
|
||||
* Returns an array of all the TextRuns found
|
||||
*/
|
||||
public TextRun[] getTextRuns() {
|
||||
public HSLFTextParagraph[] getTextRuns() {
|
||||
return _runs;
|
||||
}
|
||||
|
||||
@ -50,14 +50,14 @@ public final class TitleMaster extends MasterSheet {
|
||||
* Delegate the call to the underlying slide master.
|
||||
*/
|
||||
public TextProp getStyleAttribute(int txtype, int level, String name, boolean isCharacter) {
|
||||
MasterSheet master = getMasterSheet();
|
||||
HSLFMasterSheet master = getMasterSheet();
|
||||
return master == null ? null : master.getStyleAttribute(txtype, level, name, isCharacter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the slide master for this title master.
|
||||
*/
|
||||
public MasterSheet getMasterSheet(){
|
||||
public HSLFMasterSheet getMasterSheet(){
|
||||
SlideMaster[] master = getSlideShow().getSlidesMasters();
|
||||
SlideAtom sa = ((org.apache.poi.hslf.record.Slide)getSheetContainer()).getSlideAtom();
|
||||
int masterId = sa.getMasterID();
|
||||
|
@ -26,7 +26,7 @@ import org.apache.poi.hslf.record.ExOleObjStg;
|
||||
*
|
||||
* @author Daniel Noll
|
||||
*/
|
||||
public class ObjectData {
|
||||
public class HSLFObjectData {
|
||||
/**
|
||||
* The record that contains the object data.
|
||||
*/
|
||||
@ -37,7 +37,7 @@ public class ObjectData {
|
||||
*
|
||||
* @param storage the record that contains the object data.
|
||||
*/
|
||||
public ObjectData(ExOleObjStg storage) {
|
||||
public HSLFObjectData(ExOleObjStg storage) {
|
||||
this.storage = storage;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ import org.apache.poi.hslf.blip.JPEG;
|
||||
import org.apache.poi.hslf.blip.PICT;
|
||||
import org.apache.poi.hslf.blip.PNG;
|
||||
import org.apache.poi.hslf.blip.WMF;
|
||||
import org.apache.poi.hslf.model.Picture;
|
||||
import org.apache.poi.hslf.model.HSLFPictureShape;
|
||||
import org.apache.poi.poifs.crypt.CryptoFunctions;
|
||||
import org.apache.poi.poifs.crypt.HashAlgorithm;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
@ -42,7 +42,7 @@ import org.apache.poi.util.POILogger;
|
||||
*
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public abstract class PictureData {
|
||||
public abstract class HSLFPictureData {
|
||||
|
||||
protected POILogger logger = POILogFactory.getLogger(this.getClass());
|
||||
|
||||
@ -68,6 +68,14 @@ public abstract class PictureData {
|
||||
*/
|
||||
public abstract int getType();
|
||||
|
||||
|
||||
/**
|
||||
* Returns content type (mime type) of this picture.
|
||||
*
|
||||
* @return content type of this picture.
|
||||
*/
|
||||
public abstract String getContentType();
|
||||
|
||||
/**
|
||||
* Returns the binary data of this Picture
|
||||
* @return picture data
|
||||
@ -86,9 +94,9 @@ public abstract class PictureData {
|
||||
|
||||
protected static final ImagePainter[] painters = new ImagePainter[8];
|
||||
static {
|
||||
PictureData.setImagePainter(Picture.PNG, new BitmapPainter());
|
||||
PictureData.setImagePainter(Picture.JPEG, new BitmapPainter());
|
||||
PictureData.setImagePainter(Picture.DIB, new BitmapPainter());
|
||||
HSLFPictureData.setImagePainter(HSLFPictureShape.PNG, new BitmapPainter());
|
||||
HSLFPictureData.setImagePainter(HSLFPictureShape.JPEG, new BitmapPainter());
|
||||
HSLFPictureData.setImagePainter(HSLFPictureShape.DIB, new BitmapPainter());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -173,25 +181,25 @@ public abstract class PictureData {
|
||||
* Must be one of the static constants defined in the <code>Picture<code> class.
|
||||
* @return concrete instance of <code>PictureData</code>
|
||||
*/
|
||||
public static PictureData create(int type){
|
||||
PictureData pict;
|
||||
public static HSLFPictureData create(int type){
|
||||
HSLFPictureData pict;
|
||||
switch (type){
|
||||
case Picture.EMF:
|
||||
case HSLFPictureShape.EMF:
|
||||
pict = new EMF();
|
||||
break;
|
||||
case Picture.WMF:
|
||||
case HSLFPictureShape.WMF:
|
||||
pict = new WMF();
|
||||
break;
|
||||
case Picture.PICT:
|
||||
case HSLFPictureShape.PICT:
|
||||
pict = new PICT();
|
||||
break;
|
||||
case Picture.JPEG:
|
||||
case HSLFPictureShape.JPEG:
|
||||
pict = new JPEG();
|
||||
break;
|
||||
case Picture.PNG:
|
||||
case HSLFPictureShape.PNG:
|
||||
pict = new PNG();
|
||||
break;
|
||||
case Picture.DIB:
|
||||
case HSLFPictureShape.DIB:
|
||||
pict = new DIB();
|
||||
break;
|
||||
default:
|
||||
@ -227,7 +235,7 @@ public abstract class PictureData {
|
||||
return getData().length;
|
||||
}
|
||||
|
||||
public void draw(Graphics2D graphics, Picture parent){
|
||||
public void draw(Graphics2D graphics, HSLFPictureShape parent){
|
||||
ImagePainter painter = painters[getType()];
|
||||
if(painter != null) painter.paint(graphics, this, parent);
|
||||
else logger.log(POILogger.WARN, "Rendering is not supported: " + getClass().getName());
|
@ -37,19 +37,9 @@ import org.apache.poi.ddf.EscherContainerRecord;
|
||||
import org.apache.poi.ddf.EscherOptRecord;
|
||||
import org.apache.poi.ddf.EscherRecord;
|
||||
import org.apache.poi.hpsf.ClassID;
|
||||
import org.apache.poi.hslf.HSLFSlideShow;
|
||||
import org.apache.poi.hslf.exceptions.CorruptPowerPointFileException;
|
||||
import org.apache.poi.hslf.exceptions.HSLFException;
|
||||
import org.apache.poi.hslf.model.HeadersFooters;
|
||||
import org.apache.poi.hslf.model.Hyperlink;
|
||||
import org.apache.poi.hslf.model.MovieShape;
|
||||
import org.apache.poi.hslf.model.Notes;
|
||||
import org.apache.poi.hslf.model.PPFont;
|
||||
import org.apache.poi.hslf.model.Picture;
|
||||
import org.apache.poi.hslf.model.HSLFShape;
|
||||
import org.apache.poi.hslf.model.Slide;
|
||||
import org.apache.poi.hslf.model.SlideMaster;
|
||||
import org.apache.poi.hslf.model.TitleMaster;
|
||||
import org.apache.poi.hslf.model.*;
|
||||
import org.apache.poi.hslf.record.Document;
|
||||
import org.apache.poi.hslf.record.DocumentAtom;
|
||||
import org.apache.poi.hslf.record.ExAviMovie;
|
||||
@ -79,6 +69,7 @@ import org.apache.poi.hslf.record.SlidePersistAtom;
|
||||
import org.apache.poi.hslf.record.UserEditAtom;
|
||||
import org.apache.poi.poifs.filesystem.DirectoryNode;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
import org.apache.poi.sl.usermodel.SlideShow;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
|
||||
@ -91,9 +82,9 @@ import org.apache.poi.util.POILogger;
|
||||
* @author Nick Burch
|
||||
* @author Yegor kozlov
|
||||
*/
|
||||
public final class SlideShow {
|
||||
public final class HSLFSlideShow implements SlideShow {
|
||||
// What we're based on
|
||||
private HSLFSlideShow _hslfSlideShow;
|
||||
private HSLFSlideShowImpl _hslfSlideShow;
|
||||
|
||||
// Pointers to the most recent versions of the core records
|
||||
// (Document, Notes, Slide etc)
|
||||
@ -108,8 +99,8 @@ public final class SlideShow {
|
||||
// Friendly objects for people to deal with
|
||||
private SlideMaster[] _masters;
|
||||
private TitleMaster[] _titleMasters;
|
||||
private Slide[] _slides;
|
||||
private Notes[] _notes;
|
||||
private HSLFSlide[] _slides;
|
||||
private HSLFNotes[] _notes;
|
||||
private FontCollection _fonts;
|
||||
|
||||
// For logging
|
||||
@ -128,7 +119,7 @@ public final class SlideShow {
|
||||
*
|
||||
* @param hslfSlideShow the HSLFSlideShow to base on
|
||||
*/
|
||||
public SlideShow(HSLFSlideShow hslfSlideShow) {
|
||||
public HSLFSlideShow(HSLFSlideShowImpl hslfSlideShow) {
|
||||
// Get useful things from our base slideshow
|
||||
_hslfSlideShow = hslfSlideShow;
|
||||
|
||||
@ -149,15 +140,15 @@ public final class SlideShow {
|
||||
/**
|
||||
* Constructs a new, empty, Powerpoint document.
|
||||
*/
|
||||
public SlideShow() {
|
||||
this(HSLFSlideShow.create());
|
||||
public HSLFSlideShow() {
|
||||
this(HSLFSlideShowImpl.create());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a Powerpoint document from an input stream.
|
||||
*/
|
||||
public SlideShow(InputStream inputStream) throws IOException {
|
||||
this(new HSLFSlideShow(inputStream));
|
||||
public HSLFSlideShow(InputStream inputStream) throws IOException {
|
||||
this(new HSLFSlideShowImpl(inputStream));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -417,21 +408,21 @@ public final class SlideShow {
|
||||
|
||||
// Finally, generate model objects for everything
|
||||
// Notes first
|
||||
_notes = new Notes[notesRecords.length];
|
||||
_notes = new HSLFNotes[notesRecords.length];
|
||||
for (int i = 0; i < _notes.length; i++) {
|
||||
if (notesRecords[i] != null) {
|
||||
_notes[i] = new Notes(notesRecords[i]);
|
||||
_notes[i] = new HSLFNotes(notesRecords[i]);
|
||||
_notes[i].setSlideShow(this);
|
||||
}
|
||||
}
|
||||
// Then slides
|
||||
_slides = new Slide[slidesRecords.length];
|
||||
_slides = new HSLFSlide[slidesRecords.length];
|
||||
for (int i = 0; i < _slides.length; i++) {
|
||||
SlideAtomsSet sas = slidesSets[i];
|
||||
int slideIdentifier = sas.getSlidePersistAtom().getSlideIdentifier();
|
||||
|
||||
// Do we have a notes for this?
|
||||
Notes notes = null;
|
||||
HSLFNotes notes = null;
|
||||
// Slide.SlideAtom.notesId references the corresponding notes slide.
|
||||
// 0 if slide has no notes.
|
||||
int noteId = slidesRecords[i].getSlideAtom().getNotesID();
|
||||
@ -445,7 +436,7 @@ public final class SlideShow {
|
||||
}
|
||||
|
||||
// Now, build our slide
|
||||
_slides[i] = new Slide(slidesRecords[i], notes, sas, slideIdentifier, (i + 1));
|
||||
_slides[i] = new HSLFSlide(slidesRecords[i], notes, sas, slideIdentifier, (i + 1));
|
||||
_slides[i].setSlideShow(this);
|
||||
}
|
||||
}
|
||||
@ -481,14 +472,14 @@ public final class SlideShow {
|
||||
/**
|
||||
* Returns an array of all the normal Slides found in the slideshow
|
||||
*/
|
||||
public Slide[] getSlides() {
|
||||
public HSLFSlide[] getSlides() {
|
||||
return _slides;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of all the normal Notes found in the slideshow
|
||||
*/
|
||||
public Notes[] getNotes() {
|
||||
public HSLFNotes[] getNotes() {
|
||||
return _notes;
|
||||
}
|
||||
|
||||
@ -509,22 +500,22 @@ public final class SlideShow {
|
||||
/**
|
||||
* Returns the data of all the pictures attached to the SlideShow
|
||||
*/
|
||||
public PictureData[] getPictureData() {
|
||||
public HSLFPictureData[] getPictureData() {
|
||||
return _hslfSlideShow.getPictures();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data of all the embedded OLE object in the SlideShow
|
||||
*/
|
||||
public ObjectData[] getEmbeddedObjects() {
|
||||
public HSLFObjectData[] getEmbeddedObjects() {
|
||||
return _hslfSlideShow.getEmbeddedObjects();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data of all the embedded sounds in the SlideShow
|
||||
*/
|
||||
public SoundData[] getSoundData() {
|
||||
return SoundData.find(_documentRecord);
|
||||
public HSLFSoundData[] getSoundData() {
|
||||
return HSLFSoundData.find(_documentRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -621,7 +612,7 @@ public final class SlideShow {
|
||||
* the index of the slide to remove (0-based)
|
||||
* @return the slide that was removed from the slide show.
|
||||
*/
|
||||
public Slide removeSlide(int index) {
|
||||
public HSLFSlide removeSlide(int index) {
|
||||
int lastSlideIdx = _slides.length - 1;
|
||||
if (index < 0 || index > lastSlideIdx) {
|
||||
throw new IllegalArgumentException("Slide index (" + index + ") is out of range (0.."
|
||||
@ -631,13 +622,13 @@ public final class SlideShow {
|
||||
SlideListWithText slwt = _documentRecord.getSlideSlideListWithText();
|
||||
SlideAtomsSet[] sas = slwt.getSlideAtomsSets();
|
||||
|
||||
Slide removedSlide = null;
|
||||
HSLFSlide removedSlide = null;
|
||||
ArrayList<Record> records = new ArrayList<Record>();
|
||||
ArrayList<SlideAtomsSet> sa = new ArrayList<SlideAtomsSet>();
|
||||
ArrayList<Slide> sl = new ArrayList<Slide>();
|
||||
ArrayList<HSLFSlide> sl = new ArrayList<HSLFSlide>();
|
||||
|
||||
ArrayList<Notes> nt = new ArrayList<Notes>();
|
||||
for (Notes notes : getNotes())
|
||||
ArrayList<HSLFNotes> nt = new ArrayList<HSLFNotes>();
|
||||
for (HSLFNotes notes : getNotes())
|
||||
nt.add(notes);
|
||||
|
||||
for (int i = 0, num = 0; i < _slides.length; i++) {
|
||||
@ -658,7 +649,7 @@ public final class SlideShow {
|
||||
slwt.setSlideAtomsSets(sa.toArray(new SlideAtomsSet[sa.size()]));
|
||||
slwt.setChildRecord(records.toArray(new Record[records.size()]));
|
||||
}
|
||||
_slides = sl.toArray(new Slide[sl.size()]);
|
||||
_slides = sl.toArray(new HSLFSlide[sl.size()]);
|
||||
|
||||
// if the removed slide had notes - remove references to them too
|
||||
|
||||
@ -685,7 +676,7 @@ public final class SlideShow {
|
||||
|
||||
}
|
||||
}
|
||||
_notes = nt.toArray(new Notes[nt.size()]);
|
||||
_notes = nt.toArray(new HSLFNotes[nt.size()]);
|
||||
|
||||
return removedSlide;
|
||||
}
|
||||
@ -701,7 +692,7 @@ public final class SlideShow {
|
||||
*
|
||||
* @return the created <code>Slide</code>
|
||||
*/
|
||||
public Slide createSlide() {
|
||||
public HSLFSlide createSlide() {
|
||||
SlideListWithText slist = null;
|
||||
|
||||
// We need to add the records to the SLWT that deals
|
||||
@ -745,12 +736,12 @@ public final class SlideShow {
|
||||
slist.addSlidePersistAtom(sp);
|
||||
|
||||
// Create a new Slide
|
||||
Slide slide = new Slide(sp.getSlideIdentifier(), sp.getRefID(), _slides.length + 1);
|
||||
HSLFSlide slide = new HSLFSlide(sp.getSlideIdentifier(), sp.getRefID(), _slides.length + 1);
|
||||
slide.setSlideShow(this);
|
||||
slide.onCreate();
|
||||
|
||||
// Add in to the list of Slides
|
||||
Slide[] s = new Slide[_slides.length + 1];
|
||||
HSLFSlide[] s = new HSLFSlide[_slides.length + 1];
|
||||
System.arraycopy(_slides, 0, s, 0, _slides.length);
|
||||
s[_slides.length] = slide;
|
||||
_slides = s;
|
||||
@ -779,7 +770,7 @@ public final class SlideShow {
|
||||
* @return the index to this picture (1 based).
|
||||
*/
|
||||
public int addPicture(byte[] data, int format) throws IOException {
|
||||
byte[] uid = PictureData.getChecksum(data);
|
||||
byte[] uid = HSLFPictureData.getChecksum(data);
|
||||
|
||||
EscherContainerRecord bstore;
|
||||
|
||||
@ -801,7 +792,7 @@ public final class SlideShow {
|
||||
}
|
||||
}
|
||||
|
||||
PictureData pict = PictureData.create(format);
|
||||
HSLFPictureData pict = HSLFPictureData.create(format);
|
||||
pict.setData(data);
|
||||
|
||||
int offset = _hslfSlideShow.addPicture(pict);
|
||||
@ -815,12 +806,12 @@ public final class SlideShow {
|
||||
bse.setBlipTypeMacOS((byte) format);
|
||||
bse.setBlipTypeWin32((byte) format);
|
||||
|
||||
if (format == Picture.EMF)
|
||||
bse.setBlipTypeMacOS((byte) Picture.PICT);
|
||||
else if (format == Picture.WMF)
|
||||
bse.setBlipTypeMacOS((byte) Picture.PICT);
|
||||
else if (format == Picture.PICT)
|
||||
bse.setBlipTypeWin32((byte) Picture.WMF);
|
||||
if (format == HSLFPictureShape.EMF)
|
||||
bse.setBlipTypeMacOS((byte) HSLFPictureShape.PICT);
|
||||
else if (format == HSLFPictureShape.WMF)
|
||||
bse.setBlipTypeMacOS((byte) HSLFPictureShape.PICT);
|
||||
else if (format == HSLFPictureShape.PICT)
|
||||
bse.setBlipTypeWin32((byte) HSLFPictureShape.WMF);
|
||||
|
||||
bse.setRef(0);
|
||||
bse.setOffset(offset);
|
||||
@ -1134,7 +1125,7 @@ public final class SlideShow {
|
||||
}
|
||||
|
||||
protected int addPersistentObject(PositionDependentRecord slideRecord) {
|
||||
slideRecord.setLastOnDiskOffset(HSLFSlideShow.UNSET_OFFSET);
|
||||
slideRecord.setLastOnDiskOffset(HSLFSlideShowImpl.UNSET_OFFSET);
|
||||
_hslfSlideShow.appendRootLevelRecord((Record)slideRecord);
|
||||
|
||||
// For position dependent records, hold where they were and now are
|
@ -26,7 +26,7 @@ import java.util.ArrayList;
|
||||
*
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public final class SoundData {
|
||||
public final class HSLFSoundData {
|
||||
/**
|
||||
* The record that contains the object data.
|
||||
*/
|
||||
@ -37,7 +37,7 @@ public final class SoundData {
|
||||
*
|
||||
* @param container the record that contains the sound data.
|
||||
*/
|
||||
public SoundData(Sound container) {
|
||||
public HSLFSoundData(Sound container) {
|
||||
this._container = container;
|
||||
}
|
||||
|
||||
@ -74,8 +74,8 @@ public final class SoundData {
|
||||
* @param document the document to find in
|
||||
* @return the array with the sound data
|
||||
*/
|
||||
public static SoundData[] find(Document document){
|
||||
ArrayList<SoundData> lst = new ArrayList<SoundData>();
|
||||
public static HSLFSoundData[] find(Document document){
|
||||
ArrayList<HSLFSoundData> lst = new ArrayList<HSLFSoundData>();
|
||||
Record[] ch = document.getChildRecords();
|
||||
for (int i = 0; i < ch.length; i++) {
|
||||
if(ch[i].getRecordType() == RecordTypes.SoundCollection.typeID){
|
||||
@ -83,12 +83,12 @@ public final class SoundData {
|
||||
Record[] sr = col.getChildRecords();
|
||||
for (int j = 0; j < sr.length; j++) {
|
||||
if(sr[j] instanceof Sound){
|
||||
lst.add(new SoundData((Sound)sr[j]));
|
||||
lst.add(new HSLFSoundData((Sound)sr[j]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return lst.toArray(new SoundData[lst.size()]);
|
||||
return lst.toArray(new HSLFSoundData[lst.size()]);
|
||||
}
|
||||
}
|
@ -19,16 +19,14 @@ package org.apache.poi.hslf.usermodel;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import org.apache.poi.hslf.model.MasterSheet;
|
||||
import org.apache.poi.hslf.model.HSLFShape;
|
||||
import org.apache.poi.hslf.model.Sheet;
|
||||
import org.apache.poi.hslf.model.TextRun;
|
||||
import org.apache.poi.hslf.model.*;
|
||||
import org.apache.poi.hslf.model.textproperties.BitMaskTextProp;
|
||||
import org.apache.poi.hslf.model.textproperties.CharFlagsTextProp;
|
||||
import org.apache.poi.hslf.model.textproperties.ParagraphFlagsTextProp;
|
||||
import org.apache.poi.hslf.model.textproperties.TextProp;
|
||||
import org.apache.poi.hslf.model.textproperties.TextPropCollection;
|
||||
import org.apache.poi.hslf.record.ColorSchemeAtom;
|
||||
import org.apache.poi.sl.usermodel.TextRun;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
|
||||
@ -37,13 +35,13 @@ import org.apache.poi.util.POILogger;
|
||||
* Represents a run of text, all with the same style
|
||||
*
|
||||
*/
|
||||
public final class RichTextRun {
|
||||
public final class HSLFTextRun implements TextRun {
|
||||
protected POILogger logger = POILogFactory.getLogger(this.getClass());
|
||||
|
||||
/** The TextRun we belong to */
|
||||
private TextRun parentRun;
|
||||
private HSLFTextParagraph parentParagraph;
|
||||
/** The SlideShow we belong to */
|
||||
private SlideShow slideShow;
|
||||
// private SlideShow slideShow;
|
||||
|
||||
/** Where in the parent TextRun we start from */
|
||||
private int startPos;
|
||||
@ -68,7 +66,7 @@ public final class RichTextRun {
|
||||
* @param startAt
|
||||
* @param len
|
||||
*/
|
||||
public RichTextRun(TextRun parent, int startAt, int len) {
|
||||
public HSLFTextRun(HSLFTextParagraph parent, int startAt, int len) {
|
||||
this(parent, startAt, len, null, null, false, false);
|
||||
}
|
||||
/**
|
||||
@ -81,10 +79,10 @@ public final class RichTextRun {
|
||||
* @param pShared The paragraph styles are shared with other runs
|
||||
* @param cShared The character styles are shared with other runs
|
||||
*/
|
||||
public RichTextRun(TextRun parent, int startAt, int len,
|
||||
public HSLFTextRun(HSLFTextParagraph parent, int startAt, int len,
|
||||
TextPropCollection pStyle, TextPropCollection cStyle,
|
||||
boolean pShared, boolean cShared) {
|
||||
parentRun = parent;
|
||||
parentParagraph = parent;
|
||||
startPos = startAt;
|
||||
length = len;
|
||||
paragraphStyle = pStyle;
|
||||
@ -109,8 +107,7 @@ public final class RichTextRun {
|
||||
/**
|
||||
* Supply the SlideShow we belong to
|
||||
*/
|
||||
public void supplySlideShow(SlideShow ss) {
|
||||
slideShow = ss;
|
||||
public void updateSheet() {
|
||||
if (_fontname != null) {
|
||||
setFontName(_fontname);
|
||||
_fontname = null;
|
||||
@ -146,20 +143,20 @@ public final class RichTextRun {
|
||||
* Fetch the text, in output suitable form
|
||||
*/
|
||||
public String getText() {
|
||||
return parentRun.getText().substring(startPos, startPos+length);
|
||||
return parentParagraph.getText().substring(startPos, startPos+length);
|
||||
}
|
||||
/**
|
||||
* Fetch the text, in raw storage form
|
||||
*/
|
||||
public String getRawText() {
|
||||
return parentRun.getRawText().substring(startPos, startPos+length);
|
||||
return parentParagraph.getRawText().substring(startPos, startPos+length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the text
|
||||
*/
|
||||
public void setText(String text) {
|
||||
String s = parentRun.normalize(text);
|
||||
String s = parentParagraph.normalize(text);
|
||||
setRawText(s);
|
||||
}
|
||||
|
||||
@ -168,7 +165,7 @@ public final class RichTextRun {
|
||||
*/
|
||||
public void setRawText(String text) {
|
||||
length = text.length();
|
||||
parentRun.changeTextInRichTextRun(this,text);
|
||||
parentParagraph.changeTextInRichTextRun(this,text);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -207,10 +204,10 @@ public final class RichTextRun {
|
||||
prop = (BitMaskTextProp)props.findByName(propname);
|
||||
}
|
||||
if (prop == null){
|
||||
Sheet sheet = parentRun.getSheet();
|
||||
HSLFSheet sheet = parentParagraph.getSheet();
|
||||
if(sheet != null){
|
||||
int txtype = parentRun.getRunType();
|
||||
MasterSheet master = sheet.getMasterSheet();
|
||||
int txtype = parentParagraph.getRunType();
|
||||
HSLFMasterSheet master = sheet.getMasterSheet();
|
||||
if (master != null){
|
||||
prop = (BitMaskTextProp)master.getStyleAttribute(txtype, getIndentLevel(), propname, isCharacter);
|
||||
}
|
||||
@ -243,7 +240,7 @@ public final class RichTextRun {
|
||||
|
||||
// Ensure we have the StyleTextProp atom we're going to need
|
||||
if(props == null) {
|
||||
parentRun.ensureStyleAtomPresent();
|
||||
parentParagraph.ensureStyleAtomPresent();
|
||||
props = isCharacter ? characterStyle : paragraphStyle;
|
||||
}
|
||||
|
||||
@ -279,9 +276,9 @@ public final class RichTextRun {
|
||||
}
|
||||
|
||||
if (prop == null){
|
||||
Sheet sheet = parentRun.getSheet();
|
||||
int txtype = parentRun.getRunType();
|
||||
MasterSheet master = sheet.getMasterSheet();
|
||||
HSLFSheet sheet = parentParagraph.getSheet();
|
||||
int txtype = parentParagraph.getRunType();
|
||||
HSLFMasterSheet master = sheet.getMasterSheet();
|
||||
if (master != null)
|
||||
prop = master.getStyleAttribute(txtype, getIndentLevel(), propName, true);
|
||||
}
|
||||
@ -303,9 +300,9 @@ public final class RichTextRun {
|
||||
hardAttribute = maskProp != null && maskProp.getValue() == 0;
|
||||
}
|
||||
if (prop == null && !hardAttribute){
|
||||
Sheet sheet = parentRun.getSheet();
|
||||
int txtype = parentRun.getRunType();
|
||||
MasterSheet master = sheet.getMasterSheet();
|
||||
HSLFSheet sheet = parentParagraph.getSheet();
|
||||
int txtype = parentParagraph.getRunType();
|
||||
HSLFMasterSheet master = sheet.getMasterSheet();
|
||||
if (master != null)
|
||||
prop = master.getStyleAttribute(txtype, getIndentLevel(), propName, false);
|
||||
}
|
||||
@ -321,7 +318,7 @@ public final class RichTextRun {
|
||||
public void setParaTextPropVal(String propName, int val) {
|
||||
// Ensure we have the StyleTextProp atom we're going to need
|
||||
if(paragraphStyle == null) {
|
||||
parentRun.ensureStyleAtomPresent();
|
||||
parentParagraph.ensureStyleAtomPresent();
|
||||
// paragraphStyle will now be defined
|
||||
}
|
||||
|
||||
@ -337,7 +334,7 @@ public final class RichTextRun {
|
||||
public void setCharTextPropVal(String propName, int val) {
|
||||
// Ensure we have the StyleTextProp atom we're going to need
|
||||
if(characterStyle == null) {
|
||||
parentRun.ensureStyleAtomPresent();
|
||||
parentParagraph.ensureStyleAtomPresent();
|
||||
// characterStyle will now be defined
|
||||
}
|
||||
|
||||
@ -380,14 +377,14 @@ public final class RichTextRun {
|
||||
/**
|
||||
* Is the text underlined?
|
||||
*/
|
||||
public boolean isUnderlined() {
|
||||
public boolean isUnderline() {
|
||||
return isCharFlagsTextPropVal(CharFlagsTextProp.UNDERLINE_IDX);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the text underlined?
|
||||
*/
|
||||
public void setUnderlined(boolean underlined) {
|
||||
public void setUnderline(boolean underlined) {
|
||||
setCharFlagsTextPropVal(CharFlagsTextProp.UNDERLINE_IDX, underlined);
|
||||
}
|
||||
|
||||
@ -486,21 +483,25 @@ public final class RichTextRun {
|
||||
* Sets the font name to use
|
||||
*/
|
||||
public void setFontName(String fontName) {
|
||||
if (slideShow == null) {
|
||||
HSLFSheet sheet = parentParagraph.getSheet();
|
||||
HSLFSlideShowImpl slideShow = (sheet == null) ? null : sheet.getSlideShow();
|
||||
if (sheet == null || slideShow == null) {
|
||||
//we can't set font since slideshow is not assigned yet
|
||||
_fontname = fontName;
|
||||
} else {
|
||||
// Get the index for this font (adding if needed)
|
||||
int fontIdx = slideShow.getFontCollection().addFont(fontName);
|
||||
setCharTextPropVal("font.index", fontIdx);
|
||||
return;
|
||||
}
|
||||
// Get the index for this font (adding if needed)
|
||||
int fontIdx = slideShow.getFontCollection().addFont(fontName);
|
||||
setCharTextPropVal("font.index", fontIdx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the font name
|
||||
*/
|
||||
public String getFontName() {
|
||||
if (slideShow == null) {
|
||||
HSLFSheet sheet = parentParagraph.getSheet();
|
||||
HSLFSlideShowImpl slideShow = (sheet == null) ? null : sheet.getSlideShow();
|
||||
if (sheet == null || slideShow == null) {
|
||||
return _fontname;
|
||||
}
|
||||
int fontIdx = getCharTextPropVal("font.index");
|
||||
@ -517,7 +518,7 @@ public final class RichTextRun {
|
||||
|
||||
int cidx = rgb >> 24;
|
||||
if (rgb % 0x1000000 == 0){
|
||||
ColorSchemeAtom ca = parentRun.getSheet().getColorScheme();
|
||||
ColorSchemeAtom ca = parentParagraph.getSheet().getColorScheme();
|
||||
if(cidx >= 0 && cidx <= 7) rgb = ca.getColor(cidx);
|
||||
}
|
||||
Color tmp = new Color(rgb, true);
|
||||
@ -673,7 +674,7 @@ public final class RichTextRun {
|
||||
|
||||
int cidx = rgb >> 24;
|
||||
if (rgb % 0x1000000 == 0){
|
||||
ColorSchemeAtom ca = parentRun.getSheet().getColorScheme();
|
||||
ColorSchemeAtom ca = parentParagraph.getSheet().getColorScheme();
|
||||
if(cidx >= 0 && cidx <= 7) rgb = ca.getColor(cidx);
|
||||
}
|
||||
Color tmp = new Color(rgb, true);
|
@ -3,7 +3,7 @@ package org.apache.poi.sl.draw;
|
||||
import org.apache.poi.sl.usermodel.*;
|
||||
|
||||
|
||||
public class DrawAutoShape<T extends AutoShape<? extends TextParagraph>> extends DrawTextShape<T> {
|
||||
public class DrawAutoShape<T extends AutoShape<? extends TextParagraph<? extends TextRun>>> extends DrawTextShape<T> {
|
||||
public DrawAutoShape(T shape) {
|
||||
super(shape);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class DrawFactory {
|
||||
boolean isHint = false;
|
||||
if (graphics != null) {
|
||||
factory = (DrawFactory)graphics.getRenderingHint(DRAW_FACTORY);
|
||||
isHint = true;
|
||||
isHint = (factory != null);
|
||||
}
|
||||
// secondly try the thread local default
|
||||
if (factory == null) {
|
||||
@ -76,25 +76,25 @@ public class DrawFactory {
|
||||
} else if (shape instanceof Background) {
|
||||
return getDrawable((Background)shape);
|
||||
} else if (shape instanceof Slide) {
|
||||
return getDrawable((Slide<? extends Shape>)shape);
|
||||
return getDrawable((Slide<? extends Shape, ? extends SlideShow>)shape);
|
||||
} else if (shape instanceof MasterSheet) {
|
||||
return getDrawable((MasterSheet<? extends Shape>)shape);
|
||||
return getDrawable((MasterSheet<? extends Shape, ? extends SlideShow>)shape);
|
||||
} else if (shape instanceof Sheet) {
|
||||
return getDrawable((Sheet<? extends Shape>)shape);
|
||||
return getDrawable((Sheet<? extends Shape, ? extends SlideShow>)shape);
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Unsupported shape type: "+shape.getClass());
|
||||
}
|
||||
|
||||
public <T extends Slide<? extends Shape>> DrawSlide<T> getDrawable(T sheet) {
|
||||
public <T extends Slide<? extends Shape, ? extends SlideShow>> DrawSlide<T> getDrawable(T sheet) {
|
||||
return new DrawSlide<T>(sheet);
|
||||
}
|
||||
|
||||
public <T extends Sheet<? extends Shape>> DrawSheet<T> getDrawable(T sheet) {
|
||||
public <T extends Sheet<? extends Shape, ? extends SlideShow>> DrawSheet<T> getDrawable(T sheet) {
|
||||
return new DrawSheet<T>(sheet);
|
||||
}
|
||||
|
||||
public <T extends MasterSheet<? extends Shape>> DrawMasterSheet<T> getDrawable(T sheet) {
|
||||
public <T extends MasterSheet<? extends Shape, ? extends SlideShow>> DrawMasterSheet<T> getDrawable(T sheet) {
|
||||
return new DrawMasterSheet<T>(sheet);
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ package org.apache.poi.sl.draw;
|
||||
import org.apache.poi.sl.usermodel.*;
|
||||
|
||||
|
||||
public class DrawMasterSheet<T extends MasterSheet<? extends Shape>> extends DrawSheet<T> {
|
||||
public class DrawMasterSheet<T extends MasterSheet<? extends Shape, ? extends SlideShow>> extends DrawSheet<T> {
|
||||
|
||||
public DrawMasterSheet(T sheet) {
|
||||
super(sheet);
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
package org.apache.poi.sl.draw;
|
||||
|
||||
import static org.apache.poi.sl.usermodel.PaintStyle.TRANSPARENT_PAINT;
|
||||
import java.awt.*;
|
||||
import java.awt.MultipleGradientPaint.ColorSpaceType;
|
||||
import java.awt.MultipleGradientPaint.CycleMethod;
|
||||
@ -35,7 +36,7 @@ import org.apache.poi.util.POILogger;
|
||||
|
||||
|
||||
public class DrawPaint {
|
||||
public final static Color NO_PAINT = new Color(0xFF, 0xFF, 0xFF, 0);
|
||||
|
||||
private final static POILogger LOG = POILogFactory.getLogger(DrawPaint.class);
|
||||
|
||||
protected PlaceableShape shape;
|
||||
@ -43,6 +44,21 @@ public class DrawPaint {
|
||||
public DrawPaint(PlaceableShape shape) {
|
||||
this.shape = shape;
|
||||
}
|
||||
|
||||
public static SolidPaint createSolidPaint(final Color color) {
|
||||
return new SolidPaint() {
|
||||
public ColorStyle getSolidColor() {
|
||||
return new ColorStyle(){
|
||||
public Color getColor() { return color; }
|
||||
public int getAlpha() { return -1; }
|
||||
public int getLumOff() { return -1; }
|
||||
public int getLumMod() { return -1; }
|
||||
public int getShade() { return -1; }
|
||||
public int getTint() { return -1; }
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public Paint getPaint(Graphics2D graphics, PaintStyle paint) {
|
||||
if (paint instanceof SolidPaint) {
|
||||
@ -74,7 +90,7 @@ public class DrawPaint {
|
||||
|
||||
protected Paint getTexturePaint(TexturePaint fill, Graphics2D graphics) {
|
||||
InputStream is = fill.getImageData();
|
||||
if (is == null) return NO_PAINT;
|
||||
if (is == null) return TRANSPARENT_PAINT.getSolidColor().getColor();
|
||||
assert(graphics != null);
|
||||
|
||||
ImageRenderer renderer = (ImageRenderer)graphics.getRenderingHint(Drawable.IMAGE_RENDERER);
|
||||
@ -84,7 +100,7 @@ public class DrawPaint {
|
||||
renderer.loadImage(fill.getImageData(), fill.getContentType());
|
||||
} catch (IOException e) {
|
||||
LOG.log(POILogger.ERROR, "Can't load image data - using transparent color", e);
|
||||
return NO_PAINT;
|
||||
return TRANSPARENT_PAINT.getSolidColor().getColor();
|
||||
}
|
||||
|
||||
int alpha = fill.getAlpha();
|
||||
@ -105,7 +121,9 @@ public class DrawPaint {
|
||||
public static Color applyColorTransform(ColorStyle color){
|
||||
Color result = color.getColor();
|
||||
|
||||
if (result == null || color.getAlpha() == 100) return NO_PAINT;
|
||||
if (result == null || color.getAlpha() == 100) {
|
||||
return TRANSPARENT_PAINT.getSolidColor().getColor();
|
||||
}
|
||||
|
||||
result = applyAlpha(result, color);
|
||||
result = applyLuminanace(result, color);
|
||||
|
@ -7,17 +7,12 @@ import java.awt.geom.Rectangle2D;
|
||||
import org.apache.poi.sl.usermodel.*;
|
||||
|
||||
|
||||
public class DrawShapeGroup<T extends ShapeGroup<? extends Shape>> implements Drawable {
|
||||
public class DrawShapeGroup<T extends ShapeGroup<? extends Shape>> extends DrawShape<T> implements Drawable {
|
||||
|
||||
protected final T shape;
|
||||
|
||||
public DrawShapeGroup(T shape) {
|
||||
this.shape = shape;
|
||||
super(shape);
|
||||
}
|
||||
|
||||
public void applyTransform(Graphics2D context) {
|
||||
}
|
||||
|
||||
public void draw(Graphics2D graphics) {
|
||||
|
||||
// the coordinate system of this group of shape
|
||||
@ -54,7 +49,4 @@ public class DrawShapeGroup<T extends ShapeGroup<? extends Shape>> implements Dr
|
||||
graphics.setRenderingHint(Drawable.GROUP_TRANSFORM, tx0);
|
||||
|
||||
}
|
||||
|
||||
public void drawContent(Graphics2D context) {
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import java.awt.geom.AffineTransform;
|
||||
import org.apache.poi.sl.usermodel.*;
|
||||
|
||||
|
||||
public class DrawSheet<T extends Sheet<? extends Shape>> implements Drawable {
|
||||
public class DrawSheet<T extends Sheet<? extends Shape, ? extends SlideShow>> implements Drawable {
|
||||
|
||||
protected final T sheet;
|
||||
|
||||
@ -14,14 +14,9 @@ public class DrawSheet<T extends Sheet<? extends Shape>> implements Drawable {
|
||||
this.sheet = sheet;
|
||||
}
|
||||
|
||||
public void applyTransform(Graphics2D context) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void draw(Graphics2D graphics) {
|
||||
DrawFactory drawFact = DrawFactory.getInstance(graphics);
|
||||
MasterSheet<? extends Shape> master = sheet.getMasterSheet();
|
||||
MasterSheet<? extends Shape, ? extends SlideShow> master = sheet.getMasterSheet();
|
||||
|
||||
if(sheet.getFollowMasterGraphics() && master != null) {
|
||||
Drawable drawer = drawFact.getDrawable(master);
|
||||
@ -53,9 +48,10 @@ public class DrawSheet<T extends Sheet<? extends Shape>> implements Drawable {
|
||||
}
|
||||
}
|
||||
|
||||
public void applyTransform(Graphics2D context) {
|
||||
}
|
||||
|
||||
public void drawContent(Graphics2D context) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -18,7 +18,7 @@ import org.apache.poi.sl.draw.geom.*;
|
||||
import org.apache.poi.sl.usermodel.*;
|
||||
import org.apache.poi.sl.usermodel.LineDecoration.DecorationSize;
|
||||
import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;
|
||||
import org.apache.poi.sl.usermodel.StrokeStyle.LineDash;
|
||||
import org.apache.poi.sl.usermodel.StrokeStyle.*;
|
||||
import org.apache.poi.util.Units;
|
||||
|
||||
|
||||
@ -223,15 +223,22 @@ public class DrawSimpleShape<T extends SimpleShape> extends DrawShape<T> {
|
||||
if (lineWidth == 0.0f) lineWidth = 0.25f; // Both PowerPoint and OOo draw zero-length lines as 0.25pt
|
||||
|
||||
LineDash lineDash = strokeStyle.getLineDash();
|
||||
if (lineDash == null) {
|
||||
lineDash = LineDash.SOLID;
|
||||
lineWidth = 0.0f;
|
||||
}
|
||||
|
||||
int dashPatI[] = lineDash.pattern;
|
||||
float[] dashPatF = new float[dashPatI.length];
|
||||
final float dash_phase = 0;
|
||||
for (int i=0; i<dashPatI.length; i++) {
|
||||
dashPatF[i] = dashPatI[i]*lineWidth;
|
||||
dashPatF[i] = dashPatI[i]*Math.max(1, lineWidth);
|
||||
}
|
||||
|
||||
LineCap lineCapE = strokeStyle.getLineCap();
|
||||
if (lineCapE == null) lineCapE = LineCap.FLAT;
|
||||
int lineCap;
|
||||
switch (strokeStyle.getLineCap()) {
|
||||
switch (lineCapE) {
|
||||
case ROUND:
|
||||
lineCap = BasicStroke.CAP_ROUND;
|
||||
break;
|
||||
@ -246,7 +253,7 @@ public class DrawSimpleShape<T extends SimpleShape> extends DrawShape<T> {
|
||||
|
||||
int lineJoin = BasicStroke.JOIN_ROUND;
|
||||
|
||||
return new BasicStroke(lineWidth, lineCap, lineJoin, Math.max(1, lineWidth), dashPatF, dash_phase);
|
||||
return new BasicStroke(lineWidth, lineCap, lineJoin, lineWidth, dashPatF, dash_phase);
|
||||
}
|
||||
|
||||
protected void drawShadow(
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user