Package org.apache.poi.hwpf
Class HWPFOldDocument
- java.lang.Object
-
- org.apache.poi.POIDocument
-
- org.apache.poi.hwpf.HWPFDocumentCore
-
- org.apache.poi.hwpf.HWPFOldDocument
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class HWPFOldDocument extends HWPFDocumentCore
Provides very simple support for old (Word 6 / Word 95) files.
-
-
Constructor Summary
Constructors Constructor Description HWPFOldDocument(DirectoryNode directory)HWPFOldDocument(POIFSFileSystem fs)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FontTablegetFontTable()UsegetOldFontTable()instead!!! This always throws an IllegalArgumentException.java.nio.charset.CharsetgetGuessedCharset()As a rough heuristic (total hack), read through the HPSF, then read through the font table, and take the first non-default, non-ansi, non-symbol font's charset and return that.OldFontTablegetOldFontTable()RangegetOverallRange()Returns the range that covers all text in the file, including main text, footnotes, headers and commentsRangegetRange()Returns the range which covers the whole of the document, but excludes any headers and footers.java.lang.StringBuildergetText()Internal method to access document textTextPieceTablegetTextTable()voidwrite()Writes the document out to the currently openFile, via the writeablePOIFSFileSystemit was opened from.voidwrite(java.io.File out)Writes the document out to the specified newFile.voidwrite(java.io.OutputStream out)Writes the document out to the specified output stream.-
Methods inherited from class org.apache.poi.hwpf.HWPFDocumentCore
getCharacterTable, getDocumentText, getEncryptionInfo, getFileInformationBlock, getListTables, getMainStream, getObjectsPool, getParagraphTable, getSectionTable, getStyleSheet, verifyAndBuildPOIFS
-
Methods inherited from class org.apache.poi.POIDocument
close, createInformationProperties, getDirectory, getDocumentSummaryInformation, getSummaryInformation
-
-
-
-
Constructor Detail
-
HWPFOldDocument
public HWPFOldDocument(POIFSFileSystem fs) throws java.io.IOException
- Throws:
java.io.IOException
-
HWPFOldDocument
public HWPFOldDocument(DirectoryNode directory) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
getOverallRange
public Range getOverallRange()
Description copied from class:HWPFDocumentCoreReturns the range that covers all text in the file, including main text, footnotes, headers and comments- Specified by:
getOverallRangein classHWPFDocumentCore
-
getFontTable
@NotImplemented public FontTable getFontTable()
UsegetOldFontTable()instead!!! This always throws an IllegalArgumentException.- Overrides:
getFontTablein classHWPFDocumentCore- Returns:
- nothing
- Throws:
java.lang.UnsupportedOperationException
-
getOldFontTable
public OldFontTable getOldFontTable()
-
getRange
public Range getRange()
Description copied from class:HWPFDocumentCoreReturns the range which covers the whole of the document, but excludes any headers and footers.- Specified by:
getRangein classHWPFDocumentCore
-
getTextTable
public TextPieceTable getTextTable()
- Specified by:
getTextTablein classHWPFDocumentCore
-
getText
public java.lang.StringBuilder getText()
Description copied from class:HWPFDocumentCoreInternal method to access document text- Specified by:
getTextin classHWPFDocumentCore
-
write
public void write() throws java.io.IOExceptionDescription copied from class:POIDocumentWrites the document out to the currently openFile, via the writeablePOIFSFileSystemit was opened from.This will fail (with an
IllegalStateExceptionif the document was opened read-only, opened from anInputStreaminstead of a File, or if this is not the root document. For those cases, you must usePOIDocument.write(OutputStream)orPOIDocument.write(File)to write to a brand new document.- Specified by:
writein classPOIDocument- Throws:
java.io.IOException- thrown on errors writing to the file
-
write
public void write(java.io.File out) throws java.io.IOExceptionDescription copied from class:POIDocumentWrites the document out to the specified newFile. If the file exists, it will be replaced, otherwise a new one will be created- Specified by:
writein classPOIDocument- Parameters:
out- The new File to write to.- Throws:
java.io.IOException- thrown on errors writing to the file
-
write
public void write(java.io.OutputStream out) throws java.io.IOExceptionDescription copied from class:POIDocumentWrites the document out to the specified output stream. The stream is not closed as part of this operation. Note - if the Document was opened from aFilerather than anInputStream, you must write out usingPOIDocument.write()or to a different File. Overwriting the currently open file via an OutputStream isn't possible. Ifstreamis aFileOutputStreamon a networked drive or has a high cost/latency associated with each written byte, consider wrapping the OutputStream in aBufferedOutputStreamto improve write performance, or usePOIDocument.write()/POIDocument.write(File)if possible.- Specified by:
writein classPOIDocument- Parameters:
out- The stream to write to.- Throws:
java.io.IOException- thrown on errors writing to the stream
-
getGuessedCharset
public java.nio.charset.Charset getGuessedCharset()
As a rough heuristic (total hack), read through the HPSF, then read through the font table, and take the first non-default, non-ansi, non-symbol font's charset and return that. Once we figure out how to link a font to a text piece, we should use the font information per text piece.- Returns:
- charset
-
-