本文整理汇总了Java中org.apache.poi.hslf.usermodel.HSLFSlide类的典型用法代码示例。如果您正苦于以下问题:Java HSLFSlide类的具体用法?Java HSLFSlide怎么用?Java HSLFSlide使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HSLFSlide类属于org.apache.poi.hslf.usermodel包,在下文中一共展示了HSLFSlide类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: backgroundImage
import org.apache.poi.hslf.usermodel.HSLFSlide; //导入依赖的package包/类
/**
* PPT Slide에 backgroundFile 이미지를 그려 넣는다. <br/>
*
* @작성자 : KYJ
* @작성일 : 2017. 10. 19.
* @param ppt
* ppt File
* @param slide
* ppt Slide File
* @param backgroundFile
* Background Image File.
*/
public static void backgroundImage(HSLFSlideShow ppt, HSLFSlide slide, File backgroundFile) {
try {
// 이부분 반드시 호출
// This slide has its own background.
// Without this line it will use master's background.
slide.setFollowMasterBackground(false);
HSLFFill fill = slide.getBackground().getFill();
HSLFPictureData pd;
pd = ppt.addPicture(backgroundFile, PictureData.PictureType.PNG);
fill.setFillType(HSLFFill.FILL_PICTURE);
fill.setPictureData(pd);
} catch (IOException e) {
e.printStackTrace();
}
}
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:33,代码来源:PPTUtil.java
示例2: main
import org.apache.poi.hslf.usermodel.HSLFSlide; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
FileInputStream is = new FileInputStream("/Users/brandl/Dropbox/private/oc2/testdata/experimental design.ppt");
// FileInputStream is = new FileInputStream("/Users/brandl/Dropbox/private/oc2/testdata/Presentation5.ppt");
HSLFSlideShow ppt = new HSLFSlideShow(is);
is.close();
Dimension pgsize = ppt.getPageSize();
java.util.List<HSLFSlide> slides = ppt.getSlides();
for (int i = 0; i < slides.size(); i++) {
BufferedImage img = new BufferedImage(pgsize.width, pgsize.height,
BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = img.createGraphics();
//clear the drawing area
graphics.setPaint(Color.white);
graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height));
//render
HSLFSlide slide1 = slides.get(i);
slide1.draw(graphics);
//save the output
FileOutputStream out = new FileOutputStream("slide-" + (i + 1) + slide1.getTitle() + ".png");
javax.imageio.ImageIO.write(img, "png", out);
out.close();
}
}
开发者ID:holgerbrandl,项目名称:opencards,代码行数:34,代码来源:ConvertPPT2PNG.java
示例3: calculateSubtitle
import org.apache.poi.hslf.usermodel.HSLFSlide; //导入依赖的package包/类
private String calculateSubtitle(XSLFSlide slideX, HSLFSlide slide) {
if (isContentSlide(slide.getSlideNumber())) {
return null;
}
for (XSLFShape shape : slideX.getShapes()) {
if (shape instanceof XSLFTextShape) {
XSLFTextShape tsh = (XSLFTextShape) shape;
Rectangle2D figure = getRelativeFigure(tsh);
if (figure.getY() < 0.1) {
continue;
}
for (XSLFTextParagraph p : tsh) {
for (XSLFTextRun r : p) {
return r.getRawText();
}
}
return null;
}
}
return null;
}
开发者ID:codeurjc,项目名称:slides-converter,代码行数:31,代码来源:PowerPointToHTML.java
示例4: createHSLFSlideShowFileSimpleImages
import org.apache.poi.hslf.usermodel.HSLFSlide; //导入依赖的package包/类
/**
* @작성자 : KYJ
* @작성일 : 2017. 10. 19.
* @param pptFile
* @param images
* @throws IOException
*/
public static void createHSLFSlideShowFileSimpleImages(File pptFile, File... images) throws IOException {
HSLFSlideShow ppt = new HSLFSlideShow();
File backgroundFile = new File("C:\\Users\\KYJ\\Pictures\\10.png");
// [START] PPT Title
HSLFSlide titleSlide = ppt.createSlide();
HSLFTextBox addTitle = titleSlide.addTitle();
addTitle.setText(pptFile.getName());
// Font Color
List<HSLFTextParagraph> textParagraphs = addTitle.getTextParagraphs();
HSLFTextParagraph hslfTextParagraph = textParagraphs.get(0);
hslfTextParagraph.setTextAlign(TextAlign.CENTER);
HSLFTextRun run = hslfTextParagraph.getTextRuns().get(0);
run.setFontColor(Color.WHITE);
backgroundImage(ppt, titleSlide, backgroundFile);
// [END]
// [START] PPT Content
for (File image : images) {
DefaultHslfSlideCreateImageHandler handler = new DefaultHslfSlideCreateImageHandler(ppt);
HSLFSlide slide = handler.getSlide();
handler.setPptFile(pptFile);
// handler.setBackgroundFile(backgroundFile);
backgroundImage(ppt, slide, backgroundFile);
handler.createImage(image);
}
// [END]
try (FileOutputStream stream = new FileOutputStream(pptFile)) {
ppt.write(stream);
}
}
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:42,代码来源:PPTUtil.java
示例5: background
import org.apache.poi.hslf.usermodel.HSLFSlide; //导入依赖的package包/类
public void background(Color color) {
try {
HSLFSlide slide = getSlide();
HSLFFill fill = slide.getBackground().getFill();
fill.setFillType(HSLFFill.FILL_SHADE);
fill.setBackgroundColor(color);
fill.setForegroundColor(color);
} catch (Exception e) {
e.printStackTrace();
}
}
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:14,代码来源:DefaultHslfSlideCreateImageHandler.java
示例6: drawSlidesPartially
import org.apache.poi.hslf.usermodel.HSLFSlide; //导入依赖的package包/类
private void drawSlidesPartially(Graphics2D graphics, HSLFSlide slide) {
HSLFSlideMaster master = (HSLFSlideMaster) slide.getMasterSheet();
if (slide.getFollowMasterBackground() && master.getBackground() != null) {
// master.getBackground().draw(graphics, null);
factoryDraw(graphics, master.getBackground());
}
if (slide.getFollowMasterObjects()) {
java.util.List<HSLFShape> sh = master.getShapes();
for (HSLFShape aSh : sh) {
if (aSh.isPlaceholder()) continue;
aSh.draw(graphics, null);
}
}
HSLFShape titleShape = getTitleShape(slide);
for (HSLFShape shape : slide.getShapes()) {
boolean isTitleShape = shape.getShapeId() == titleShape.getShapeId();
if (isTitleShape && showTitleShape) {
// shape.draw(graphics);
factoryDraw(graphics, shape);
}
if (!isTitleShape && showContent) {
// shape.draw(graphics);
factoryDraw(graphics, shape);
}
}
}
开发者ID:holgerbrandl,项目名称:opencards,代码行数:36,代码来源:PPTSlideRenderPanel.java
示例7: getTitleShape
import org.apache.poi.hslf.usermodel.HSLFSlide; //导入依赖的package包/类
private HSLFShape getTitleShape(HSLFSlide slide) {
String slideTitle = slide.getTitle();
for (HSLFShape shape : slide.getShapes()) {
if (shape instanceof AutoShape) {
HSLFAutoShape autoShape = (HSLFAutoShape) shape;
if (autoShape.getText() != null && autoShape.getText().equals(slideTitle)) {
int type = autoShape.getRunType();
if (type == TextHeaderAtom.CENTER_TITLE_TYPE || type == TextHeaderAtom.TITLE_TYPE) {
return shape;
}
}
}
}
// When you have a XSLFSlide object you can use .getShapes() to get all shapes in the slide. If the shape is a
// XSLFTextShape you can use .getTextType() to check if it's a title, .getTextParagraphs() to get the paragraphs and
// .getTextRuns() on the paragraphs to get the text runs with the text. That should give you
return null;
// can not work as we don't have a slide title for slides without a title element
// // if we don't find a title shape than use the most topwards element as question
// if(slide.getShapes().length ==0)
// return null;
//
// return Collections.max(Arrays.asList(slide.getShapes()), new Comparator<Shape>() {
// @Override
// public int compare(Shape o1, Shape o2) {
// return o1.getAnchor().getCenterY() - o2.getAnchor().getCenterY() < 0 ? -1 : 1;
// }
// });
}
开发者ID:holgerbrandl,项目名称:opencards,代码行数:35,代码来源:PPTSlideRenderPanel.java
示例8: configure
import org.apache.poi.hslf.usermodel.HSLFSlide; //导入依赖的package包/类
public void configure(Slide slide, boolean showTitle, boolean showContent) {
this.slide = (HSLFSlide) slide;
this.showTitleShape = showTitle;
this.showContent = showContent;
repaint();
}
开发者ID:holgerbrandl,项目名称:opencards,代码行数:9,代码来源:PPTSlideRenderPanel.java
示例9: main
import org.apache.poi.hslf.usermodel.HSLFSlide; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
// XMLSlideShow ppt = new XMLSlideShow();
FileInputStream is = new FileInputStream("/Users/brandl/Dropbox/private/oc2/testdata/experimental design.ppt");
HSLFSlideShow ppt = new HSLFSlideShow(is);
for (HSLFSlide xslfSlide : ppt.getSlides()) {
System.out.println(xslfSlide.getTitle());
}
// XSLFSlide slide getTitle= ppt.getSlides()[0];0
// new org.apache.poi.hslf.extractor.PowerPointExtractor("xslf-demo.pptx").getSlides
}
开发者ID:holgerbrandl,项目名称:opencards,代码行数:14,代码来源:ExtractSlidesFromPPTX.java
示例10: main
import org.apache.poi.hslf.usermodel.HSLFSlide; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
// XMLSlideShow ppt = new XMLSlideShow();
// FileInputStream is = new FileInputStream("/Users/brandl/Dropbox/private/oc2/testdata/experimental design.ppt");
FileInputStream is = new FileInputStream("testdata/testdata 1 reordered slides.ppt");
HSLFSlideShow ppt = new HSLFSlideShow(is);
for (HSLFSlide slide : ppt.getSlides()) {
String slideTitle = slide.getTitle();
System.err.println("-----------");
System.err.println(slideTitle);
// System.err.println("sheetid : "+slide.getSlideRecord().getSheetId());
// // does just reflect the slide number
//
// System.err.println("refsheetid: "+ slide._getSheetRefId());
//
// System.err.println("atomhah: "+ slide.getSlideRecord().getSlideAtom().toString());
//
// System.err.println("ppdrawing: "+ slide.getSlideRecord().toString());
System.err.println(slide.getSlideRecord().getPPDrawing());
slide.getSlideRecord().getPPDrawing().toString();
slide.getSlideRecord().getSlideAtom().hashCode();
// XSLFSlide slide getTitle= ppt.getSlides()[0];0
// new org.apache.poi.hslf.extractor.PowerPointExtractor("xslf-demo.pptx").getSlides
}
}
开发者ID:holgerbrandl,项目名称:opencards,代码行数:34,代码来源:ExtractSlidesFromPPT.java
示例11: main
import org.apache.poi.hslf.usermodel.HSLFSlide; //导入依赖的package包/类
public static void main(String[] args) throws IOException, InvalidFormatException {
FileInputStream is = new FileInputStream("/Users/brandl/Dropbox/private/oc2/testdata/experimental design.pptx");
XMLSlideShow ppt2 = new XMLSlideShow(OPCPackage.open("/Users/brandl/Dropbox/private/oc2/testdata/experimental design.pptx"));
XSLFSlide slide1 = ppt2.getSlides().get(0);
// slide1.get
HSLFSlideShow ppt = new HSLFSlideShow(is);
//
HSLFSlide slide2 = ppt.getSlides().get(1);
is.close();
Dimension pgsize = ppt.getPageSize();
java.util.List<HSLFSlide> slides = ppt.getSlides();
for (int i = 0; i < slides.size(); i++) {
BufferedImage img = new BufferedImage(pgsize.width, pgsize.height,
BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = img.createGraphics();
//clear the drawing area
graphics.setPaint(Color.white);
graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height));
//render
slides.get(i).draw(graphics);
//save the output
FileOutputStream out = new FileOutputStream("slide-" + (i + 1) + ".png");
javax.imageio.ImageIO.write(img, "png", out);
out.close();
}
}
开发者ID:holgerbrandl,项目名称:opencards,代码行数:37,代码来源:ConvertPPTX2PNG.java
示例12: createSlide
import org.apache.poi.hslf.usermodel.HSLFSlide; //导入依赖的package包/类
@Override
public HSLFSlide createSlide(HSLFSlideShow ppt) {
// HSLFSlideMaster defaultMaster = ppt.getSlideMasters().get(0);
return ppt.createSlide();
}
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:6,代码来源:DefaultHslfSlideCreateImageHandler.java
示例13: createImage
import org.apache.poi.hslf.usermodel.HSLFSlide; //导入依赖的package包/类
@Override
public HSLFPictureShape createImage(File imageFile, PictureType format) {
HSLFSlideShow ppt = getPpt();
HSLFSlide slide = getSlide();
// Set Title
HSLFTextBox addTitle = slide.addTitle();
addTitle.setText(imageFile.getName());
// Font Color
List<HSLFTextParagraph> textParagraphs = addTitle.getTextParagraphs();
HSLFTextParagraph hslfTextParagraph = textParagraphs.get(0);
hslfTextParagraph.setTextAlign(TextAlign.CENTER);
HSLFTextRun run = hslfTextParagraph.getTextRuns().get(0);
run.setFontColor(Color.WHITE);
// Image Processing.
if (format != null) {
Dimension pageSize = ppt.getPageSize();
try {
// load image file.
HSLFPictureData picData = ppt.addPicture(imageFile, format);
// get shape
HSLFPictureShape picShape = new HSLFPictureShape(picData);
int y = (int) pageSize.getHeight() / 4;
int width = (int) (pageSize.getWidth() - 30.0);
int height = (int) (pageSize.getHeight() - y - 10.0);
int x = 15;
// location 위치를 잡아줌.
picShape.setAnchor(new Rectangle(x, y, width, height));
// finally add image 그림 추가
slide.addShape(picShape);
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:49,代码来源:DefaultHslfSlideCreateImageHandler.java
示例14: getSlide
import org.apache.poi.hslf.usermodel.HSLFSlide; //导入依赖的package包/类
public final HSLFSlide getSlide() {
return slide;
}
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:4,代码来源:CreateHslfSlideImageHandler.java
示例15: readFlashcardsFromFile
import org.apache.poi.hslf.usermodel.HSLFSlide; //导入依赖的package包/类
public FlashCardCollection readFlashcardsFromFile(CardFile cardFile) {
Utils.log("extracting flashcards from file '" + cardFile + "'...");
FlashCardCollection fc = new FlashCardCollection();
try {
if (cardFile.getFileLocation().getName().endsWith(".ppt")) {
FileInputStream is = new FileInputStream(cardFile.getFileLocation());
HSLFSlideShow ppt = new HSLFSlideShow(is);
for (HSLFSlide xslfSlide : ppt.getSlides()) {
String slideTitle = xslfSlide.getTitle();
if (slideTitle == null)
continue;
// old OC1.x approach to create a unique card-id
// int cardID = Utils.getRandGen().nextInt(Integer.MAX_VALUE);
fc.add(new FlashCard(slideTitle.hashCode(), slideTitle, xslfSlide.getSlideNumber()));
}
} else if (cardFile.getFileLocation().getName().endsWith(".md")) {
boolean useSelector = cardFile.getProperties().useMarkdownSelector();
List<MarkdownFlashcard> flashcards = MarkdownParserKt.parseMD(cardFile.getFileLocation(), useSelector);
for (int i = 0; i < flashcards.size(); i++) {
MarkdownFlashcard card = flashcards.get(i);
String question = card.getQuestion();
if (question.trim().isEmpty()) {
continue;
}
fc.add(new FlashCard(question.hashCode(), question, i + 1));
}
} else {
throw new InvalidCardFileFormatException();
}
} catch (IOException e) {
// rephrase IO problem into something more specific
throw new InvalidCardFileFormatException();
}
return fc;
}
开发者ID:holgerbrandl,项目名称:opencards,代码行数:48,代码来源:PPTSerializer.java
示例16: parseContent
import org.apache.poi.hslf.usermodel.HSLFSlide; //导入依赖的package包/类
@Override
protected void parseContent(StreamLimiter streamLimiter, LanguageEnum lang) throws IOException {
HSLFSlideShow ppt = new HSLFSlideShow(streamLimiter.getNewInputStream());
List<HSLFSlide> slides = ppt.getSlides();
ParserResultItem result = getNewParserResultItem();
for (HSLFSlide slide : slides) {
List<List<HSLFTextParagraph>> textLevel0 = slide.getTextParagraphs();
for (List<HSLFTextParagraph> textLevel1 : textLevel0) {
for (HSLFTextParagraph textPara : textLevel1) {
ParserFieldEnum field;
switch (textPara.getRunType()) {
case TextHeaderAtom.TITLE_TYPE:
case TextHeaderAtom.CENTER_TITLE_TYPE:
field = ParserFieldEnum.title;
break;
case TextHeaderAtom.NOTES_TYPE:
field = ParserFieldEnum.note;
break;
case TextHeaderAtom.BODY_TYPE:
case TextHeaderAtom.CENTRE_BODY_TYPE:
case TextHeaderAtom.HALF_BODY_TYPE:
case TextHeaderAtom.QUARTER_BODY_TYPE:
field = ParserFieldEnum.body;
break;
case TextHeaderAtom.OTHER_TYPE:
default:
field = ParserFieldEnum.other;
break;
}
StringBuilder sb = new StringBuilder();
for (HSLFTextRun textRun : textPara.getTextRuns()) {
sb.append(textRun.getRawText());
sb.append(' ');
}
result.addField(field, StringUtils.replaceConsecutiveSpaces(sb.toString(), " "));
}
}
}
result.langDetection(10000, ParserFieldEnum.body);
}
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:42,代码来源:PptParser.java
示例17: calculateTitle
import org.apache.poi.hslf.usermodel.HSLFSlide; //导入依赖的package包/类
private String calculateTitle(XSLFSlide slideX, HSLFSlide slide) {
String title = slide.getTitle();
if (title != null) {
return title;
}
title = slideX.getTitle();
if (title != null) {
return title;
}
boolean titleSlide = ArrayUtils.contains(titleSlides,
slideX.getSlideNumber());
for (XSLFShape shape : slideX.getShapes()) {
if (shape instanceof XSLFTextShape) {
XSLFTextShape tsh = (XSLFTextShape) shape;
Rectangle2D figure = getRelativeFigure(tsh);
if (titleSlide || figure.getY() < 0.1) {
StringBuilder titleSB = new StringBuilder();
for (XSLFTextParagraph p : tsh) {
for (XSLFTextRun r : p) {
titleSB.append(r.getRawText());
}
}
title = titleSB.toString();
if (!title.trim().isEmpty()) {
return title;
}
}
}
}
return null;
}
开发者ID:codeurjc,项目名称:slides-converter,代码行数:47,代码来源:PowerPointToHTML.java
示例18: createSlide
import org.apache.poi.hslf.usermodel.HSLFSlide; //导入依赖的package包/类
protected abstract HSLFSlide createSlide(HSLFSlideShow ppt);
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:2,代码来源:CreateHslfSlideImageHandler.java
注:本文中的org.apache.poi.hslf.usermodel.HSLFSlide类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论