当前位置: 首页>>代码示例>>Java>>正文


Java HSLFTextParagraph类代码示例

本文整理汇总了Java中org.apache.poi.hslf.usermodel.HSLFTextParagraph的典型用法代码示例。如果您正苦于以下问题:Java HSLFTextParagraph类的具体用法?Java HSLFTextParagraph怎么用?Java HSLFTextParagraph使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HSLFTextParagraph类属于org.apache.poi.hslf.usermodel包,在下文中一共展示了HSLFTextParagraph类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createHSLFSlideShowFileSimpleImages

import org.apache.poi.hslf.usermodel.HSLFTextParagraph; //导入依赖的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

示例2: createImage

import org.apache.poi.hslf.usermodel.HSLFTextParagraph; //导入依赖的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

示例3: parseContent

import org.apache.poi.hslf.usermodel.HSLFTextParagraph; //导入依赖的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


注:本文中的org.apache.poi.hslf.usermodel.HSLFTextParagraph类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。