<changes>
<release version="3.8-beta5" date="2011-??-??">
+ <action dev="poi-developers" type="fix">51834 - Opening and Writing .doc file results in corrupt document</action>
<action dev="poi-developers" type="fix">51902 - Picture.fillRawImageContent - ArrayIndexOutOfBoundsException (duplicate)</action>
<action dev="poi-developers" type="fix">51890 - ArrayIndexOutOfBounds ExceptionPicture.fillRawImageContent</action>
<action dev="poi-developers" type="add">Allow the passing of a File object to WorkbookFactory.create, which permits lower memory processing than the InputStream version</action>
else
trueOrFalse = (short) 0x0000;
TypeWriter.writeUShortToStream( out, trueOrFalse );
- TypeWriter.writeUShortToStream( out, (short) 0x0000 );
- length += 4;
+ length += 2;
break;
}
case Variant.VT_LPSTR:
out.write(highb);
length += 2;
}
- out.write(0x00);
- out.write(0x00);
- length += 2;
break;
}
case Variant.VT_CF:
case Variant.VT_I2:
{
TypeWriter.writeToStream(out, ((Integer) value).shortValue());
- // length = LittleEndianConsts.SHORT_SIZE;
- TypeWriter.writeToStream( out, (short) 0x0000 );
- /*
- * MUST be a 16-bit signed integer, followed by zero padding to 4
- * bytes -- http://msdn.microsoft.com/en-us/library/dd942532(v=PROT.13).aspx
- */
- length = LittleEndianConsts.INT_SIZE;
+ length = LittleEndianConsts.SHORT_SIZE;
break;
}
case Variant.VT_I4:
}
}
+ /* pad values to 4-bytes */
+ while ( ( length & 0x3 ) != 0 )
+ {
+ out.write( 0x00 );
+ length++;
+ }
+
return length;
}
}
package org.apache.poi.hwpf.usermodel;
import java.io.ByteArrayOutputStream;
+import java.io.File;
import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
import junit.framework.TestCase;
+
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.poi.POIDataSamples;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.model.SubdocumentType;
import org.apache.poi.hwpf.model.io.HWPFOutputStream;
import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.util.IOUtils;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
+ " has type " + pictureType );
}
}
+
+ /**
+ * [RESOLVED FIXED] Bug 51834 - Opening and Writing .doc file results in
+ * corrupt document
+ */
+ public void testBug51834() throws Exception
+ {
+ /*
+ * we don't have Java test for this file - it should be checked using
+ * Microsoft BFF Validator. But check read-write-read anyway. -- sergey
+ */
+ HWPFTestDataSamples.openSampleFile( "Bug51834.doc" );
+ HWPFTestDataSamples.writeOutAndReadBack( HWPFTestDataSamples
+ .openSampleFile( "Bug51834.doc" ) );
+ }
}