poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ser...@apache.org
Subject svn commit: r1195053 - in /poi/trunk/src: java/org/apache/poi/hpsf/ClipboardData.java testcases/org/apache/poi/hpsf/basic/TestWrite.java
Date Sat, 29 Oct 2011 22:00:43 GMT
Author: sergey
Date: Sat Oct 29 22:00:42 2011
New Revision: 1195053

URL: http://svn.apache.org/viewvc?rev=1195053&view=rev
Log:
replace exception with warning
update test case

Modified:
    poi/trunk/src/java/org/apache/poi/hpsf/ClipboardData.java
    poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java

Modified: poi/trunk/src/java/org/apache/poi/hpsf/ClipboardData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hpsf/ClipboardData.java?rev=1195053&r1=1195052&r2=1195053&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hpsf/ClipboardData.java (original)
+++ poi/trunk/src/java/org/apache/poi/hpsf/ClipboardData.java Sat Oct 29 22:00:42 2011
@@ -21,10 +21,15 @@ import java.io.OutputStream;
 
 import org.apache.poi.util.Internal;
 import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
 
 @Internal
 class ClipboardData
 {
+    private static final POILogger logger = POILogFactory
+            .getLogger( ClipboardData.class );
+
     private int _format;
     private byte[] _value;
 
@@ -33,9 +38,16 @@ class ClipboardData
         int size = LittleEndian.getInt( data, offset );
 
         if ( size < 4 )
-            throw new IllegalPropertySetDataException(
-                    "ClipboardData size less than 4 bytes "
-                            + "(doesn't even have format field!)" );
+        {
+            logger.log( POILogger.WARN, "ClipboardData at offset ",
+                    Integer.valueOf( offset ), " size less than 4 bytes "
+                            + "(doesn't even have format field!). "
+                            + "Setting to format == 0 and hope for the best" );
+            _format = 0;
+            _value = new byte[0];
+            return;
+        }
+
         _format = LittleEndian.getInt( data, offset + LittleEndian.INT_SIZE );
         _value = LittleEndian.getByteArray( data, offset
                 + LittleEndian.INT_SIZE * 2, size - LittleEndian.INT_SIZE );
@@ -57,7 +69,6 @@ class ClipboardData
         LittleEndian.putInt( result, 0 * LittleEndian.INT_SIZE,
                 LittleEndian.INT_SIZE + _value.length );
         LittleEndian.putInt( result, 1 * LittleEndian.INT_SIZE, _format );
-        LittleEndian.putInt( result, 2 * LittleEndian.INT_SIZE, _value.length );
         System.arraycopy( _value, 0, result, LittleEndian.INT_SIZE
                 + LittleEndian.INT_SIZE, _value.length );
         return result;

Modified: poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java?rev=1195053&r1=1195052&r2=1195053&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hpsf/basic/TestWrite.java Sat Oct 29 22:00:42 2011
@@ -36,7 +36,7 @@ import java.util.Map;
 
 import junit.framework.Assert;
 import junit.framework.TestCase;
-
+import org.apache.poi.POIDataSamples;
 import org.apache.poi.hpsf.ClassID;
 import org.apache.poi.hpsf.Constants;
 import org.apache.poi.hpsf.HPSFRuntimeException;
@@ -63,7 +63,6 @@ import org.apache.poi.poifs.eventfilesys
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.TempFile;
-import org.apache.poi.POIDataSamples;
 
 /**
  * <p>Tests HPSF's writing functionality.</p>
@@ -377,14 +376,8 @@ public class TestWrite extends TestCase
             check(Variant.VT_EMPTY, null, codepage);
             check(Variant.VT_BOOL, Boolean.TRUE, codepage);
             check(Variant.VT_BOOL, Boolean.FALSE, codepage);
-            check(Variant.VT_CF, new byte[]{0}, codepage);
-            check(Variant.VT_CF, new byte[]{0, 1}, codepage);
-            check(Variant.VT_CF, new byte[]{0, 1, 2}, codepage);
-            check(Variant.VT_CF, new byte[]{0, 1, 2, 3}, codepage);
-            check(Variant.VT_CF, new byte[]{0, 1, 2, 3, 4}, codepage);
-            check(Variant.VT_CF, new byte[]{0, 1, 2, 3, 4, 5}, codepage);
-            check(Variant.VT_CF, new byte[]{0, 1, 2, 3, 4, 5, 6}, codepage);
-            check(Variant.VT_CF, new byte[]{0, 1, 2, 3, 4, 5, 6, 7}, codepage);
+            check( Variant.VT_CF, new byte[] { 8, 0, 0, 0, 1, 0, 0, 0, 1, 2, 3,
+                    4 }, codepage );
             check(Variant.VT_I4, Integer.valueOf(27), codepage);
             check(Variant.VT_I8, Long.valueOf(28), codepage);
             check(Variant.VT_R8, new Double(29.0), codepage);



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


Mime
View raw message