poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rainer Schwarze <...@admadic.de>
Subject HWPF: Writing/Copying Word files - Word crashes when saving such files
Date Fri, 15 Sep 2006 22:24:38 GMT

When I load files generated by HWPF into Word 2000 and save them,
Word locks up and takes 100%-cpu resources.

My first question is: 
Should this work with the current HWPF code and if not, does someone
know a version of HWPF where saving the generated files in Word worked?

My second question is: 
HWPF creates a Document Property record (DOP) of length 504 bytes
whereas 500 would be the "documented" size. Does someone know whether
that's intended or not? (I would guess it is a typo, but ... - See below)


I created a simple Word file (one paragraph with several characters)
and did the following:

  HWPFDocument inDoc = new HWPFDocument(new FileInputStream(srcFile));
  OutputStream out = new FileOutputStream(dstFile);

As mentioned, loading the output file into Word and saving it locks up Word.

I used the latest code from the SVN repository.

While digging through Word file format documentation, Word
import/export sources from other projects and the HWPF sources, I get
the impression that the DOP for a Word97 should have a size of 500.
(In Word 2000 it has a size of 544, but it still works when the DOP
in the DOC file is patched to a size of 500.) 

When I look at the file DOPAbstractType.java in package
org.apache.poi.hwpf.model.types and in the function getSize, the
following code shows up:

    public int getSize()
        return 4 +  + 1 + 1 + 2 ... (rest of line removed)

In which the "4 + + " part looks a little bit strange. The file which
I believe generates the DOPAbstractType.java is (among others)
hdftype.xsl in src/types/styles/ and contains:

     * Size of record (exluding 4 byte header)
    public int getSize()
<xsl:variable name="fieldIterator" select="field:new()"/>
<xsl:text>        return 4 + </xsl:text>
<xsl:for-each select="//fields/field">

The calcSize returns something like " + 1" which explains "4 + + 1...".

That looks to me as if this simply could be the reason for the DOP
being 504 instead of 500 and that it could simply be a typo. This "4
+ + " exists in most of the files in the package
org.apache.poi.hwpf.model.types .

Removing those "4 + + " parts does not prevent Word from crashing
when saving the files. So it is probably not only the size of the
records in the doc file which causes the problems. (Given that it is
not only me who has those problems.)

Thanks in advance for any hints.

To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/

View raw message