From 64185cd51cb621632b825cf8a2aa89afa63e34ae Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Fri, 25 Mar 2011 16:21:09 +0000 Subject: [PATCH] More NPOIFS Constructor updates git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1085447 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/org/apache/poi/hdgf/HDGFDiagram.java | 17 +++++++++--- .../hdgf/extractor/VisioTextExtractor.java | 15 ++++++++--- .../org/apache/poi/hslf/HSLFSlideShow.java | 15 +++++++++++ .../hslf/extractor/PowerPointExtractor.java | 26 ++++++++++++++++++- .../src/org/apache/poi/hsmf/MAPIMessage.java | 20 ++++++++++++-- .../hsmf/extractor/OutlookTextExtactor.java | 11 ++++++++ 6 files changed, 95 insertions(+), 9 deletions(-) diff --git a/src/scratchpad/src/org/apache/poi/hdgf/HDGFDiagram.java b/src/scratchpad/src/org/apache/poi/hdgf/HDGFDiagram.java index aa15ce1b1..b8c918ed7 100644 --- a/src/scratchpad/src/org/apache/poi/hdgf/HDGFDiagram.java +++ b/src/scratchpad/src/org/apache/poi/hdgf/HDGFDiagram.java @@ -31,6 +31,7 @@ import org.apache.poi.hdgf.streams.StringsStream; import org.apache.poi.hdgf.streams.TrailerStream; import org.apache.poi.poifs.filesystem.DirectoryNode; import org.apache.poi.poifs.filesystem.DocumentEntry; +import org.apache.poi.poifs.filesystem.NPOIFSFileSystem; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.util.LittleEndian; @@ -56,10 +57,20 @@ public final class HDGFDiagram extends POIDocument { private PointerFactory ptrFactory; public HDGFDiagram(POIFSFileSystem fs) throws IOException { - this(fs.getRoot(), fs); + this(fs.getRoot()); } - public HDGFDiagram(DirectoryNode dir, POIFSFileSystem fs) throws IOException { - super(dir, fs); + public HDGFDiagram(NPOIFSFileSystem fs) throws IOException { + this(fs.getRoot()); + } + /** + * @deprecated Use {@link #HDGFDiagram(DirectoryNode)} instead + */ + @Deprecated + public HDGFDiagram(DirectoryNode dir, POIFSFileSystem fs) throws IOException { + this(dir); + } + public HDGFDiagram(DirectoryNode dir) throws IOException { + super(dir); DocumentEntry docProps = (DocumentEntry)dir.getEntry("VisioDocument"); diff --git a/src/scratchpad/src/org/apache/poi/hdgf/extractor/VisioTextExtractor.java b/src/scratchpad/src/org/apache/poi/hdgf/extractor/VisioTextExtractor.java index 74488f4be..0290d5913 100644 --- a/src/scratchpad/src/org/apache/poi/hdgf/extractor/VisioTextExtractor.java +++ b/src/scratchpad/src/org/apache/poi/hdgf/extractor/VisioTextExtractor.java @@ -30,6 +30,7 @@ import org.apache.poi.hdgf.streams.ChunkStream; import org.apache.poi.hdgf.streams.PointerContainingStream; import org.apache.poi.hdgf.streams.Stream; import org.apache.poi.poifs.filesystem.DirectoryNode; +import org.apache.poi.poifs.filesystem.NPOIFSFileSystem; import org.apache.poi.poifs.filesystem.POIFSFileSystem; /** @@ -39,18 +40,26 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem; */ public final class VisioTextExtractor extends POIOLE2TextExtractor { private HDGFDiagram hdgf; - private POIFSFileSystem fs; public VisioTextExtractor(HDGFDiagram hdgf) { super(hdgf); this.hdgf = hdgf; } public VisioTextExtractor(POIFSFileSystem fs) throws IOException { - this(fs.getRoot(), fs); + this(fs.getRoot()); } + public VisioTextExtractor(NPOIFSFileSystem fs) throws IOException { + this(fs.getRoot()); + } + public VisioTextExtractor(DirectoryNode dir) throws IOException { + this(new HDGFDiagram(dir)); + } + /** + * @deprecated Use {@link #VisioTextExtractor(DirectoryNode)} instead + */ + @Deprecated public VisioTextExtractor(DirectoryNode dir, POIFSFileSystem fs) throws IOException { this(new HDGFDiagram(dir, fs)); - this.fs = fs; } public VisioTextExtractor(InputStream inp) throws IOException { this(new POIFSFileSystem(inp)); diff --git a/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java b/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java index 65954a775..6fb390218 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java +++ b/src/scratchpad/src/org/apache/poi/hslf/HSLFSlideShow.java @@ -46,6 +46,7 @@ import org.apache.poi.hslf.usermodel.PictureData; import org.apache.poi.poifs.filesystem.DirectoryNode; import org.apache.poi.poifs.filesystem.DocumentEntry; import org.apache.poi.poifs.filesystem.DocumentInputStream; +import org.apache.poi.poifs.filesystem.NPOIFSFileSystem; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.util.LittleEndian; import org.apache.poi.util.POILogFactory; @@ -128,15 +129,29 @@ public final class HSLFSlideShow extends POIDocument { this(filesystem.getRoot()); } + /** + * Constructs a Powerpoint document from a POIFS Filesystem. Parses the + * document and places all the important stuff into data structures. + * + * @param filesystem the POIFS FileSystem to read from + * @throws IOException if there is a problem while parsing the document. + */ + public HSLFSlideShow(NPOIFSFileSystem filesystem) throws IOException + { + this(filesystem.getRoot()); + } + /** * Constructs a Powerpoint document from a specific point in a * POIFS Filesystem. Parses the document and places all the * important stuff into data structures. * + * @deprecated Use {@link #HSLFSlideShow(DirectoryNode)} instead * @param dir the POIFS directory to read from * @param filesystem the POIFS FileSystem to read from * @throws IOException if there is a problem while parsing the document. */ + @Deprecated public HSLFSlideShow(DirectoryNode dir, POIFSFileSystem filesystem) throws IOException { this(dir); diff --git a/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java b/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java index ca815c7c9..239df9a69 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java +++ b/src/scratchpad/src/org/apache/poi/hslf/extractor/PowerPointExtractor.java @@ -29,6 +29,7 @@ import org.apache.poi.hslf.HSLFSlideShow; import org.apache.poi.hslf.model.*; import org.apache.poi.hslf.usermodel.SlideShow; import org.apache.poi.poifs.filesystem.DirectoryNode; +import org.apache.poi.poifs.filesystem.NPOIFSFileSystem; import org.apache.poi.poifs.filesystem.POIFSFileSystem; /** @@ -100,9 +101,32 @@ public final class PowerPointExtractor extends POIOLE2TextExtractor { * @param fs the POIFSFileSystem containing the PowerPoint document */ public PowerPointExtractor(POIFSFileSystem fs) throws IOException { - this(new HSLFSlideShow(fs)); + this(fs.getRoot()); } + /** + * Creates a PowerPointExtractor, from an open NPOIFSFileSystem + * + * @param fs the NPOIFSFileSystem containing the PowerPoint document + */ + public PowerPointExtractor(NPOIFSFileSystem fs) throws IOException { + this(fs.getRoot()); + } + + /** + * Creates a PowerPointExtractor, from a specific place + * inside an open NPOIFSFileSystem + * + * @param dir the POIFS Directory containing the PowerPoint document + */ + public PowerPointExtractor(DirectoryNode dir) throws IOException { + this(new HSLFSlideShow(dir)); + } + + /** + * @deprecated Use {@link #PowerPointExtractor(DirectoryNode)} instead + */ + @Deprecated public PowerPointExtractor(DirectoryNode dir, POIFSFileSystem fs) throws IOException { this(new HSLFSlideShow(dir, fs)); } diff --git a/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java b/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java index f9bfa4477..f220ebfe5 100644 --- a/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java +++ b/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java @@ -41,6 +41,7 @@ import org.apache.poi.hsmf.datatypes.StringChunk; import org.apache.poi.hsmf.exceptions.ChunkNotFoundException; import org.apache.poi.hsmf.parsers.POIFSChunkParser; import org.apache.poi.poifs.filesystem.DirectoryNode; +import org.apache.poi.poifs.filesystem.NPOIFSFileSystem; import org.apache.poi.poifs.filesystem.POIFSFileSystem; /** @@ -92,7 +93,22 @@ public class MAPIMessage extends POIDocument { * @throws IOException */ public MAPIMessage(POIFSFileSystem fs) throws IOException { - this(fs.getRoot(), fs); + this(fs.getRoot()); + } + /** + * Constructor for reading MSG Files from a POIFS filesystem + * @param fs + * @throws IOException + */ + public MAPIMessage(NPOIFSFileSystem fs) throws IOException { + this(fs.getRoot()); + } + /** + * @deprecated Use {@link #MAPIMessage(DirectoryNode)} instead + */ + @Deprecated + public MAPIMessage(DirectoryNode poifsDir, POIFSFileSystem fs) throws IOException { + this(poifsDir); } /** * Constructor for reading MSG Files from a certain @@ -101,7 +117,7 @@ public class MAPIMessage extends POIDocument { * @param fs * @throws IOException */ - public MAPIMessage(DirectoryNode poifsDir, POIFSFileSystem fs) throws IOException { + public MAPIMessage(DirectoryNode poifsDir) throws IOException { super(poifsDir); // Grab all the chunks diff --git a/src/scratchpad/src/org/apache/poi/hsmf/extractor/OutlookTextExtactor.java b/src/scratchpad/src/org/apache/poi/hsmf/extractor/OutlookTextExtactor.java index dcbb03712..34e473797 100644 --- a/src/scratchpad/src/org/apache/poi/hsmf/extractor/OutlookTextExtactor.java +++ b/src/scratchpad/src/org/apache/poi/hsmf/extractor/OutlookTextExtactor.java @@ -25,6 +25,7 @@ import org.apache.poi.hsmf.MAPIMessage; import org.apache.poi.hsmf.datatypes.AttachmentChunks; import org.apache.poi.hsmf.exceptions.ChunkNotFoundException; import org.apache.poi.poifs.filesystem.DirectoryNode; +import org.apache.poi.poifs.filesystem.NPOIFSFileSystem; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.util.StringUtil.StringsIterator; @@ -36,12 +37,22 @@ public class OutlookTextExtactor extends POIOLE2TextExtractor { public OutlookTextExtactor(MAPIMessage msg) { super(msg); } + /** + * Use {@link #OutlookTextExtactor(DirectoryNode)} instead + */ + @Deprecated public OutlookTextExtactor(DirectoryNode poifsDir, POIFSFileSystem fs) throws IOException { this(new MAPIMessage(poifsDir, fs)); } + public OutlookTextExtactor(DirectoryNode poifsDir) throws IOException { + this(new MAPIMessage(poifsDir)); + } public OutlookTextExtactor(POIFSFileSystem fs) throws IOException { this(new MAPIMessage(fs)); } + public OutlookTextExtactor(NPOIFSFileSystem fs) throws IOException { + this(new MAPIMessage(fs)); + } public OutlookTextExtactor(InputStream inp) throws IOException { this(new MAPIMessage(inp)); }