From: Nick Burch Date: Wed, 27 Jun 2007 19:00:35 +0000 (+0000) Subject: Include a test for the text extraction code. Update code to use POILogger instead... X-Git-Tag: REL_3_0_2_BETA1~88 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=211c9e157ae2ebf09fbd45c8a2f7cd60d14d2739;p=poi.git Include a test for the text extraction code. Update code to use POILogger instead of System.err. Update the NOTICE file for the TLP change, and add entries for JUnit and the small GPL v3 bits of HDGF git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@551273 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/legal/NOTICE b/legal/NOTICE index d417a360a7..190d974632 100644 --- a/legal/NOTICE +++ b/legal/NOTICE @@ -1,5 +1,16 @@ -Apache Jakarta POI +Apache POI Copyright 2001-2007 The Apache Software Foundation This product includes software developed by The Apache Software Foundation (http://www.apache.org/). + + +Unit testing support is provided by JUnit, under the +Common Public License Version 1.0: + http://www.opensource.org/licenses/cpl.php +See http://www.junit.org/ + +Small parts of the POI component HDGF are based on VSDump, +and are under the GNU General Public Licence version 3 (GPL v3): + http://gplv3.fsf.org/ +See http://www.gnome.ru/projects/vsdump_en.html diff --git a/src/scratchpad/src/org/apache/poi/hdgf/chunks/Chunk.java b/src/scratchpad/src/org/apache/poi/hdgf/chunks/Chunk.java index 673d56edf3..5928927c4d 100644 --- a/src/scratchpad/src/org/apache/poi/hdgf/chunks/Chunk.java +++ b/src/scratchpad/src/org/apache/poi/hdgf/chunks/Chunk.java @@ -20,6 +20,8 @@ import java.util.ArrayList; import org.apache.poi.hdgf.chunks.ChunkFactory.CommandDefinition; import org.apache.poi.util.LittleEndian; +import org.apache.poi.util.POILogFactory; +import org.apache.poi.util.POILogger; import org.apache.poi.util.StringUtil; /** @@ -45,6 +47,9 @@ public class Chunk { /** The name of the chunk, as found from the commandDefinitions */ private String name; + /** For logging warnings about the structure of the file */ + private POILogger logger = POILogFactory.getLogger(Chunk.class); + public Chunk(ChunkHeader header, ChunkTrailer trailer, ChunkSeparator separator, byte[] contents) { this.header = header; this.trailer = trailer; @@ -149,7 +154,9 @@ public class Chunk { // Check we seem to have enough data if(offset >= contents.length) { - System.err.println("Command offset " + offset + " past end of data at " + contents.length); + logger.log(POILogger.WARN, + "Command offset " + offset + " past end of data at " + contents.length + ); continue; } @@ -207,7 +214,8 @@ public class Chunk { break; default: - //System.err.println("Warning - Command of type " + type + " not processed!"); + logger.log(POILogger.INFO, + "Command of type " + type + " not processed!"); } // Add to the array diff --git a/src/scratchpad/src/org/apache/poi/hdgf/chunks/ChunkFactory.java b/src/scratchpad/src/org/apache/poi/hdgf/chunks/ChunkFactory.java index efac0d3574..fe0fc91a4d 100644 --- a/src/scratchpad/src/org/apache/poi/hdgf/chunks/ChunkFactory.java +++ b/src/scratchpad/src/org/apache/poi/hdgf/chunks/ChunkFactory.java @@ -24,6 +24,9 @@ import java.util.ArrayList; import java.util.Hashtable; import java.util.StringTokenizer; +import org.apache.poi.util.POILogFactory; +import org.apache.poi.util.POILogger; + /** * Factor class to create the appropriate chunks, which * needs the version of the file to process the chunk header @@ -42,6 +45,9 @@ public class ChunkFactory { private static String chunkTableName = "/org/apache/poi/hdgf/chunks/chunks_parse_cmds.tbl"; + /** For logging problems we spot with the file */ + private POILogger logger = POILogFactory.getLogger(ChunkFactory.class); + public ChunkFactory(int version) throws IOException { this.version = version; @@ -107,7 +113,8 @@ public class ChunkFactory { // Check we have enough data, and tweak the header size // as required if(endOfDataPos > data.length) { - System.err.println("Header called for " + header.getLength() +" bytes, but that would take us passed the end of the data!"); + logger.log(POILogger.WARN, + "Header called for " + header.getLength() +" bytes, but that would take us passed the end of the data!"); endOfDataPos = data.length; header.length = data.length - offset - header.getSizeInBytes(); diff --git a/src/scratchpad/src/org/apache/poi/hdgf/extractor/VisioTextExtractor.java b/src/scratchpad/src/org/apache/poi/hdgf/extractor/VisioTextExtractor.java index f7ef6df086..b2c4ee37f9 100644 --- a/src/scratchpad/src/org/apache/poi/hdgf/extractor/VisioTextExtractor.java +++ b/src/scratchpad/src/org/apache/poi/hdgf/extractor/VisioTextExtractor.java @@ -57,7 +57,6 @@ public class VisioTextExtractor { for(int i=0; i