poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew C. Oliver" <acoli...@apache.org>
Subject Re: Bug 17208 - WordDocument Problem: createListTables - Negative Array Size
Date Mon, 03 Mar 2003 17:06:41 GMT
Robert Paris wrote:

> Thanks for the reply Andy! Actually, it would be nice to have a bit of 
> help in reading those german comments! I guess maybe someone needs to 
> create a comment-translating IDE. JK.
>
> Right now I'm actually going through the POI HDF code to make sure 
> that everything is done to spec and that there isn't something that's 
> obviously missing. I don't know if you guys want it or not, but I'm 
> also adding comments to all of the code (A LOT of comments). I figure, 
> this is open source and the more comments the better so that in the 
> future someone can come in and follow exactly what the code is doing 
> right away. (I have posted a small example below so you can judge if 
> you want comments like these)

Definitely.  Comments are awesome. 

>
> If it's not too much trouble, could you send me the translations of 
> those german comments? I'm almost done going through the POI code so 
> I'll then move on to that code. Unfortunately, I don't know any german 
> and the code is similar to microsoft code (i.e. variable names are no 
> help at all) it's not always the easiest to follow.

Umm...  Lets do this the other way around.  You see code with comments, 
you email it to me, I'll explain what it means.  (Me searching through 
the megabytes of code and finding comments to translate and sending them 
well...won't happen real soon ;-) )

Why do you think we call this Horrible Document Format.  

Note that you cannot contribute if you have ever recieved any 
information /sourcecode under NDA from microsoft or if you have 
illegally received such information from a third party which was bound 
by that type of agreement.  (Basically don't do illegal stuff).  

Contribute comments and patches and you'll be a committer in no time! :-)

-Andy

>
> Thanks!
>
> - Robert Paris
>
> EXAMPLE CODE COMMENTS FOR METHOD: processComplexFile
> (I made it fit in the email so the lines wouldn't wrap)
>
> private void processComplexFile( boolean useTable1,
>                                 int charTable,
>                                 int charPlcSize,
>                                 int parTable,
>                                 int parPlcSize) throws IOException
> {
>
>     /*
>      * Offset in file stream of info for complex word files
>      * (i.e. word 97 and later). Consists of an encoding of
>      * all of the prms (Property Modifiers) quoted by the document
>      * followed by the PLex of Cps (explained above) containing
>      * Piece Descriptors (plcfpcd) for the document. plcfpcd is the
>      * table that holds the mapping between the position of a
>      * character within the word "document" and its position within
>      * the actual file. As well, it holds any recent format changes.
>      *
>      * 0x1a2 is the "well-known" position for this offset. MS
>      * documents this in the spec as the offset for this info. It
>      * is position 418.
>      */
>     int complexOffset = LittleEndian.getInt( _header, 0x1a2 );
>
>     String tablename = null;
>     DocumentEntry tableEntry = null;
>
>     /*
>      * As noted earlier, the table to use (which houses the actual
>      * document data). As noted earlier, there is normally one
>      * table, but in event of a crash without a save, there will
>      * be a second table with "lost" data. The "useTable1" boolean
>      * is set in "readFIB()."
>      */
>     if(useTable1)
>     {
>         tablename = "1Table";
>     }
>     else
>     {
>         tablename = "0Table";
>     }
>
>     //Get the actual table data - Not sure how this is stored as
>     //DocumentEntry as I haven't gone through all the POI code,
>     //anyone who knows, feel free to write that here
>     tableEntry = ( DocumentEntry ) filesystem.getRoot()
>                        .getEntry(tablename); //WRAPPED
>
>     /*
>      * Load the table stream into a buffer. The term "stream" is
>      * misleading. Microsoft calls byte arrays streams in their
>      * spec document, so I'm assuming someone's staying consistent
>      * with that. It is NOT a stream in the Java io sense, but
>      * simply a byte array.
>      */
>     int size = tableEntry.getSize();
>     byte[] tableStream = new byte[ size ];
>     filesystem.createDocumentInputStream( tablename )
>                     .read( tableStream ); //WRAPPED
>
>     /*
>      * Init the Document Properties (DOP) for this document. The
>      * DOP is the data structure describing properties that apply
>      * to the document as a whole.
>      */
>     initDocProperties(tableStream);
>
>     /*
>      * I didn't want to go changing methods on people, but this
>      * is supposed to be plc NOT pcl. Maybe someone will change the
>      * implementation to delegate to method: initPlcfHdd?
>      * And to be honest, I'd prefer that all variables and methods
>      * be given "good" Java names that are more descriptive and then
>      * use the comments to connect these to the less descriptive
>      * Microsoft names like plcfhdd.
>      *
>      * Loads the header/footer (of the word doc not of the file)
>      * raw data for this document. This data is written (within the
>      * file) immediately after the previously recorded table if the
>      * document contains headers or footers.
>      */
>     initPclfHdd(tableStream);
>
>     /*
>      * Find the point in the whole table byte array (called stream)
>      * where the array of the actual text in the word document
>      * begins.
>      */
>     findText( tableStream, complexOffset );
>
>     /*
>      * Find the formatting info in the table stream. This is also
>      * a sub-array of the whole byte array
>      */
>     findFormatting( tableStream, charTable, charPlcSize, parTable,
>             parPlcSize);
>
> }
>
> _________________________________________________________________
> Add photos to your messages with MSN 8. Get 2 months FREE*.  
> http://join.msn.com/?page=features/featuredemail
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: poi-dev-help@jakarta.apache.org
>
>




Mime
View raw message