From 156e67bc52a8899c8cbb5a3ec494da7de1cc6a84 Mon Sep 17 00:00:00 2001 From: Benjamin Gamard Date: Tue, 3 Apr 2018 20:40:24 +0200 Subject: [PATCH] upgrade opensagres.xdocreport --- docs-core/pom.xml | 4 ++-- .../sismics/docs/core/util/format/DocxFormatHandler.java | 6 ++++-- .../sismics/docs/core/util/format/OdtFormatHandler.java | 4 ++-- .../sismics/docs/core/util/format/PptxFormatHandler.java | 9 +++++---- pom.xml | 6 +++--- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/docs-core/pom.xml b/docs-core/pom.xml index 280e8d1d..64fbea77 100644 --- a/docs-core/pom.xml +++ b/docs-core/pom.xml @@ -140,12 +140,12 @@ fr.opensagres.xdocreport - org.odftoolkit.odfdom.converter.pdf + fr.opensagres.odfdom.converter.pdf fr.opensagres.xdocreport - org.apache.poi.xwpf.converter.pdf + fr.opensagres.poi.xwpf.converter.pdf diff --git a/docs-core/src/main/java/com/sismics/docs/core/util/format/DocxFormatHandler.java b/docs-core/src/main/java/com/sismics/docs/core/util/format/DocxFormatHandler.java index 10e4f7f9..3ba41fbb 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/util/format/DocxFormatHandler.java +++ b/docs-core/src/main/java/com/sismics/docs/core/util/format/DocxFormatHandler.java @@ -3,6 +3,8 @@ package com.sismics.docs.core.util.format; import com.google.common.io.Closer; import com.sismics.util.context.ThreadLocalContext; import com.sismics.util.mime.MimeType; +import fr.opensagres.poi.xwpf.converter.pdf.PdfConverter; +import fr.opensagres.poi.xwpf.converter.pdf.PdfOptions; import org.apache.pdfbox.io.MemoryUsageSetting; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.poi.xwpf.usermodel.XWPFDocument; @@ -60,8 +62,8 @@ public class DocxFormatHandler implements FormatHandler { try (InputStream inputStream = Files.newInputStream(file); OutputStream outputStream = Files.newOutputStream(temporaryPdfFile)) { XWPFDocument document = new XWPFDocument(inputStream); - org.apache.poi.xwpf.converter.pdf.PdfOptions options = org.apache.poi.xwpf.converter.pdf.PdfOptions.create(); - org.apache.poi.xwpf.converter.pdf.PdfConverter.getInstance().convert(document, outputStream, options); + PdfOptions options = PdfOptions.create(); + PdfConverter.getInstance().convert(document, outputStream, options); } } diff --git a/docs-core/src/main/java/com/sismics/docs/core/util/format/OdtFormatHandler.java b/docs-core/src/main/java/com/sismics/docs/core/util/format/OdtFormatHandler.java index 1e9802f3..1db8415f 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/util/format/OdtFormatHandler.java +++ b/docs-core/src/main/java/com/sismics/docs/core/util/format/OdtFormatHandler.java @@ -3,10 +3,10 @@ package com.sismics.docs.core.util.format; import com.google.common.io.Closer; import com.sismics.util.context.ThreadLocalContext; import com.sismics.util.mime.MimeType; +import fr.opensagres.odfdom.converter.pdf.PdfConverter; +import fr.opensagres.odfdom.converter.pdf.PdfOptions; import org.apache.pdfbox.io.MemoryUsageSetting; import org.apache.pdfbox.pdmodel.PDDocument; -import org.odftoolkit.odfdom.converter.pdf.PdfConverter; -import org.odftoolkit.odfdom.converter.pdf.PdfOptions; import org.odftoolkit.odfdom.doc.OdfTextDocument; import java.awt.image.BufferedImage; diff --git a/docs-core/src/main/java/com/sismics/docs/core/util/format/PptxFormatHandler.java b/docs-core/src/main/java/com/sismics/docs/core/util/format/PptxFormatHandler.java index 24468d82..db3074bd 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/util/format/PptxFormatHandler.java +++ b/docs-core/src/main/java/com/sismics/docs/core/util/format/PptxFormatHandler.java @@ -19,6 +19,7 @@ import java.awt.image.BufferedImage; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; +import java.util.List; /** * PPTX format handler. @@ -39,7 +40,7 @@ public class PptxFormatHandler implements FormatHandler { @Override public BufferedImage generateThumbnail(Path file) throws Exception { XMLSlideShow pptx = loadPPtxFile(file); - if (pptx.getSlides().length > 0) { + if (pptx.getSlides().size() > 0) { return generateImageFromSlide(pptx, 0); } @@ -55,9 +56,9 @@ public class PptxFormatHandler implements FormatHandler { @Override public void appendToPdf(Path file, PDDocument doc, boolean fitImageToPage, int margin, MemoryUsageSetting memUsageSettings, Closer closer) throws Exception { XMLSlideShow pptx = loadPPtxFile(file); - XSLFSlide[] slides = pptx.getSlides(); + List slides = pptx.getSlides(); Dimension pgsize = pptx.getPageSize(); - for (int slideIndex = 0; slideIndex < slides.length; slideIndex++) { + for (int slideIndex = 0; slideIndex < slides.size(); slideIndex++) { // One PDF page per slide PDPage page = new PDPage(new PDRectangle(pgsize.width, pgsize.height)); try (PDPageContentStream contentStream = new PDPageContentStream(doc, page)) { @@ -91,7 +92,7 @@ public class PptxFormatHandler implements FormatHandler { Graphics2D graphics = img.createGraphics(); graphics.setPaint(Color.white); graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height)); - pptx.getSlides()[slideIndex].draw(graphics); + pptx.getSlides().get(slideIndex).draw(graphics); return img; } } diff --git a/pom.xml b/pom.xml index 199d15ca..b346cfee 100644 --- a/pom.xml +++ b/pom.xml @@ -38,7 +38,7 @@ 2.9.2 5.1.0.Final 3.1.0 - 1.0.5 + 2.0.1 4.2.1 3.3.2 1.6.5 @@ -401,13 +401,13 @@ fr.opensagres.xdocreport - org.odftoolkit.odfdom.converter.pdf + fr.opensagres.odfdom.converter.pdf ${fr.opensagres.xdocreport.version} fr.opensagres.xdocreport - org.apache.poi.xwpf.converter.pdf + fr.opensagres.poi.xwpf.converter.pdf ${fr.opensagres.xdocreport.version}