From a431972f98d98114dc9a5a65a3fbaf68967a8161 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 13 Feb 2016 18:18:33 +0000 Subject: Add result objects --- src/main/java/org/zwobble/mammoth/Mammoth.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/main/java/org/zwobble/mammoth/Mammoth.java') diff --git a/src/main/java/org/zwobble/mammoth/Mammoth.java b/src/main/java/org/zwobble/mammoth/Mammoth.java index 05080cf..7282082 100644 --- a/src/main/java/org/zwobble/mammoth/Mammoth.java +++ b/src/main/java/org/zwobble/mammoth/Mammoth.java @@ -13,15 +13,16 @@ import java.util.zip.ZipFile; import static com.google.common.collect.Iterables.transform; public class Mammoth { - public static String convertToHtml(File file) { + public static Result convertToHtml(File file) { try (ZipFile zipFile = new ZipFile(file)) { ZipEntry entry = zipFile.getEntry("word/document.xml"); XmlElement documentXml = OfficeXml.parseXml(zipFile.getInputStream(entry)); Styles styles = Styles.EMPTY; Numbering numbering = Numbering.EMPTY; - Document document = new DocumentXmlReader(new BodyXmlReader(styles, numbering)).readElement(documentXml); - return convertToHtml(document); + DocumentXmlReader reader = new DocumentXmlReader(new BodyXmlReader(styles, numbering)); + return reader.readElement(documentXml) + .map(Mammoth::convertToHtml); } catch (IOException e) { throw new UnsupportedOperationException("Should return a result of failure"); } -- cgit v1.2.3