poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r797737 - in /poi/trunk/src: documentation/content/xdocs/status.xml java/org/apache/poi/hssf/record/RecordFactoryInputStream.java testcases/org/apache/poi/hssf/record/TestDrawingRecord.java
Date Sat, 25 Jul 2009 10:22:04 GMT
Author: yegor
Date: Sat Jul 25 10:22:04 2009
New Revision: 797737

URL: http://svn.apache.org/viewvc?rev=797737&view=rev
Log:
Fixed RecordFactoryInputStream to properly read continued DrawingRecords

Added:
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDrawingRecord.java   (with props)
Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/java/org/apache/poi/hssf/record/RecordFactoryInputStream.java

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=797737&r1=797736&r2=797737&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Sat Jul 25 10:22:04 2009
@@ -33,6 +33,7 @@
 
     <changes>
         <release version="3.5-beta7" date="2009-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">47548 - Fixed RecordFactoryInputStream
to properly read continued DrawingRecords</action>
            <action dev="POI-DEVELOPERS" type="fix">46419 - Fixed compatibility issue
with OpenOffice 3.0</action>
            <action dev="POI-DEVELOPERS" type="fix">47559 - Fixed compatibility issue
with Excel 2008 Mac sp2</action>
            <action dev="POI-DEVELOPERS" type="fix">47540 - Fix for saving custom and
extended OOXML properties</action>

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/RecordFactoryInputStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/RecordFactoryInputStream.java?rev=797737&r1=797736&r2=797737&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/RecordFactoryInputStream.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/RecordFactoryInputStream.java Sat Jul 25
10:22:04 2009
@@ -197,6 +197,9 @@
                 } else if (lastRecord instanceof DrawingGroupRecord) {
                     ((DrawingGroupRecord) lastRecord).processContinueRecord(contRec.getData());
                     return null;
+                } else if (lastRecord instanceof DrawingRecord) {
+                    ((DrawingRecord) lastRecord).processContinueRecord(contRec.getData());
+                    return null;
                 } else if (lastRecord instanceof UnknownRecord) {
                     //Gracefully handle records that we don't know about,
                     //that happen to be continued

Added: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDrawingRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDrawingRecord.java?rev=797737&view=auto
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDrawingRecord.java (added)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDrawingRecord.java Sat Jul 25 10:22:04
2009
@@ -0,0 +1,71 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hssf.record;
+
+import junit.framework.TestCase;
+import org.apache.poi.ddf.EscherContainerRecord;
+import org.apache.poi.ddf.EscherSpRecord;
+import org.apache.poi.util.HexDump;
+import org.apache.poi.util.HexRead;
+import org.apache.poi.util.LittleEndianOutput;
+import org.apache.poi.util.LittleEndianOutputStream;
+import org.apache.poi.hssf.HSSFTestDataSamples;
+
+import java.io.*;
+import java.util.List;
+import java.util.Arrays;
+
+public final class TestDrawingRecord extends TestCase {
+
+    /**
+     * Check that RecordFactoryInputStream properly handles continued DrawingRecords
+     * See Bugzilla #47548
+     */
+    public void testReadContinued() throws IOException {
+
+        //simulate a continues drawing record
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        //main part
+        DrawingRecord dg = new DrawingRecord();
+        byte[] data1 = new byte[8224];
+        Arrays.fill(data1, (byte)1);
+        dg.setData(data1);
+        out.write(dg.serialize());
+
+        //continued part
+        byte[] data2 = new byte[4048];
+        Arrays.fill(data2, (byte)2);
+        ContinueRecord cn = new ContinueRecord(data2);
+        out.write(cn.serialize());
+
+        List<Record> rec = RecordFactory.createRecords(new ByteArrayInputStream(out.toByteArray()));
+        assertEquals(1, rec.size());
+        assertTrue(rec.get(0) instanceof DrawingRecord);
+
+        //DrawingRecord.getData() should return concatenated data1 and data2
+        byte[] tmp = new byte[data1.length + data2.length];
+        System.arraycopy(data1, 0, tmp, 0, data1.length);
+        System.arraycopy(data2, 0, tmp, data1.length, data2.length);
+
+        DrawingRecord dg2 = (DrawingRecord)rec.get(0);
+        assertEquals(data1.length + data2.length, dg2.getData().length);
+        assertTrue(Arrays.equals(tmp, dg2.getData()));
+
+    }
+
+}
\ No newline at end of file

Propchange: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestDrawingRecord.java
------------------------------------------------------------------------------
    svn:executable = *



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message