diff --git a/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java b/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java index fe22c03eff..0d65389176 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java @@ -572,12 +572,27 @@ public final class HWPFDocument extends HWPFDocumentCore { } /** - * Warning - not currently implemented for HWPF! + * Write out the word file that is represented by this class, to the + * currently open {@link File}, via the writeable {@link POIFSFileSystem} + * it was opened as. + * + *
This will fail (with an {@link IllegalStateException} if the
+ * Document was opened read-only, opened from an {@link InputStream}
+ * instead of a File, or if this is not the root document. For those cases,
+ * you must use {@link #write(OutputStream)} or {@link #write(File)} to
+ * write to a brand new document.
+ *
+ * @since 3.15
*/
@Override
public void write() throws IOException {
- // TODO Implement
- throw new IllegalStateException("Coming soon!");
+ validateInPlaceWritePossible();
+
+ // Update the Document+Properties streams in the file
+ write(directory.getFileSystem(), false);
+
+ // Sync with the File on disk
+ directory.getFileSystem().writeFilesystem();
}
/**
@@ -912,22 +927,18 @@ public final class HWPFDocument extends HWPFDocumentCore {
dataBuf = tempBuf;
}
- // create new document preserving order of entries
- // TODO Check "copyOtherEntries" and tweak behaviour based on that
- // TODO That's needed for in-place write
+ // Create a new document preserving order of entries / Update existing
boolean docWritten = false;
boolean dataWritten = false;
boolean objectPoolWritten = false;
boolean tableWritten = false;
boolean propertiesWritten = false;
- for ( Iterator