From 6c1e024d511496fd5dba031d9d4360275edbb4db Mon Sep 17 00:00:00 2001 From: chenxudong Date: Tue, 18 Feb 2025 10:08:44 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E9=80=9A=E4=BA=86ppt=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../industry/software/common/parse/PptParse.java | 5 +---- .../industry/software/common/util/OfficeFileUtil.java | 4 +++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/electromagnetic-common/src/main/java/com/electromagnetic/industry/software/common/parse/PptParse.java b/electromagnetic-common/src/main/java/com/electromagnetic/industry/software/common/parse/PptParse.java index dfbf7c3..47f8ea8 100644 --- a/electromagnetic-common/src/main/java/com/electromagnetic/industry/software/common/parse/PptParse.java +++ b/electromagnetic-common/src/main/java/com/electromagnetic/industry/software/common/parse/PptParse.java @@ -15,10 +15,7 @@ public class PptParse extends FileParse { String res = ""; try { FileUtil.writeFromStream(stream, fileTmpPath); - if (fileType.endsWith("pptx")) { - res = OfficeFileUtil.parsePptxAllText(fileTmpPath); - } - res = OfficeFileUtil.parsePptAllText(fileTmpPath); + res = fileType.endsWith("pptx") ? OfficeFileUtil.parsePptxAllText(fileTmpPath) : OfficeFileUtil.parsePptAllText(fileTmpPath); } catch (Exception e) { log.error("解析{}格式的ppt错误,具体为{}",fileType, e.getMessage(), e); } diff --git a/electromagnetic-common/src/main/java/com/electromagnetic/industry/software/common/util/OfficeFileUtil.java b/electromagnetic-common/src/main/java/com/electromagnetic/industry/software/common/util/OfficeFileUtil.java index 083d992..ee000f6 100644 --- a/electromagnetic-common/src/main/java/com/electromagnetic/industry/software/common/util/OfficeFileUtil.java +++ b/electromagnetic-common/src/main/java/com/electromagnetic/industry/software/common/util/OfficeFileUtil.java @@ -175,17 +175,19 @@ public class OfficeFileUtil { } public static String parsePptAllText(String filePath) throws IOException { + log.info("Start parse ppt file, path is {}", filePath); return handlePptFile(filePath, false); } public static String parsePptxAllText(String filePath) throws IOException { + log.info("Start parse pptx file, path is {}", filePath); return handlePptFile(filePath, true); } private static String handlePptFile(String path, boolean isPptx) throws IOException { StringBuilder stringBuilder = new StringBuilder(); InputStream input = Files.newInputStream(Paths.get(path)); - String pptText = isPptx ? new SlideShowExtractor(new HSLFSlideShow(input)).getText() : new SlideShowExtractor(new XMLSlideShow(input)).getText(); + String pptText = isPptx ? new SlideShowExtractor(new XMLSlideShow(input)).getText() : new SlideShowExtractor(new HSLFSlideShow(input)).getText(); stringBuilder.append(pptText); return EleCommonUtil.formateString(stringBuilder.toString()); }