git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1723899 13f79535-47bb-0310-9956-ffa450edef68tags/REL_3_14_FINAL
@@ -390,15 +390,9 @@ public final class BiffViewer { | |||
* </table> | |||
* | |||
*/ | |||
public static void main(String[] args) throws IOException { | |||
public static void main(String[] args) throws IOException, CommandParseException { | |||
// args = new String[] { "--out", "", }; | |||
CommandArgs cmdArgs; | |||
try { | |||
cmdArgs = CommandArgs.parse(args); | |||
} catch (CommandParseException e) { | |||
e.printStackTrace(); | |||
return; | |||
} | |||
CommandArgs cmdArgs = CommandArgs.parse(args); | |||
PrintWriter pw; | |||
if (cmdArgs.shouldOutputToFile()) { |
@@ -72,21 +72,14 @@ public class EFBiffViewer | |||
this.file = file; | |||
} | |||
public static void main(String [] args) | |||
public static void main(String [] args) throws IOException | |||
{ | |||
if ((args.length == 1) && !args[ 0 ].equals("--help")) | |||
{ | |||
try | |||
{ | |||
EFBiffViewer viewer = new EFBiffViewer(); | |||
EFBiffViewer viewer = new EFBiffViewer(); | |||
viewer.setFile(args[ 0 ]); | |||
viewer.run(); | |||
} | |||
catch (IOException e) | |||
{ | |||
e.printStackTrace(); | |||
} | |||
viewer.setFile(args[ 0 ]); | |||
viewer.run(); | |||
} | |||
else | |||
{ |
@@ -18,6 +18,7 @@ | |||
package org.apache.poi.hssf.dev; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.io.InputStream; | |||
import java.util.List; | |||
@@ -52,13 +53,14 @@ public class FormulaViewer | |||
/** | |||
* Method run | |||
* @throws IOException | |||
* | |||
* | |||
* @exception Exception | |||
* | |||
*/ | |||
public void run() throws Exception { | |||
public void run() throws IOException { | |||
NPOIFSFileSystem fs = new NPOIFSFileSystem(new File(file), true); | |||
InputStream is = BiffViewer.getPOIFSInputStream(fs); | |||
List<Record> records = RecordFactory.createRecords(is); | |||
@@ -206,10 +208,12 @@ public class FormulaViewer | |||
* pass me a filename and I'll try and parse the formulas from it | |||
* | |||
* @param args pass one argument with the filename or --help | |||
* @throws IOException | |||
* @throws Exception | |||
* | |||
*/ | |||
public static void main(String args[]) | |||
public static void main(String args[]) throws IOException | |||
{ | |||
if ((args == null) || (args.length >2 ) | |||
|| args[ 0 ].equals("--help")) | |||
@@ -218,31 +222,17 @@ public class FormulaViewer | |||
"FormulaViewer .8 proof that the devil lies in the details (or just in BIFF8 files in general)"); | |||
System.out.println("usage: Give me a big fat file name"); | |||
} else if (args[0].equals("--listFunctions")) { // undocumented attribute to research functions!~ | |||
try { | |||
FormulaViewer viewer = new FormulaViewer(); | |||
viewer.setFile(args[1]); | |||
viewer.setList(true); | |||
viewer.run(); | |||
} | |||
catch (Exception e) { | |||
System.out.println("Whoops!"); | |||
e.printStackTrace(); | |||
} | |||
FormulaViewer viewer = new FormulaViewer(); | |||
viewer.setFile(args[1]); | |||
viewer.setList(true); | |||
viewer.run(); | |||
} | |||
else | |||
{ | |||
try | |||
{ | |||
FormulaViewer viewer = new FormulaViewer(); | |||
FormulaViewer viewer = new FormulaViewer(); | |||
viewer.setFile(args[ 0 ]); | |||
viewer.run(); | |||
} | |||
catch (Exception e) | |||
{ | |||
System.out.println("Whoops!"); | |||
e.printStackTrace(); | |||
} | |||
viewer.setFile(args[ 0 ]); | |||
viewer.run(); | |||
} | |||
} | |||
} |
@@ -180,21 +180,14 @@ public class RecordLister | |||
this.file = file; | |||
} | |||
public static void main(String [] args) | |||
public static void main(String [] args) throws IOException | |||
{ | |||
if ((args.length == 1) && !args[ 0 ].equals("--help")) | |||
{ | |||
try | |||
{ | |||
RecordLister viewer = new RecordLister(); | |||
RecordLister viewer = new RecordLister(); | |||
viewer.setFile(args[ 0 ]); | |||
viewer.run(); | |||
} | |||
catch (IOException e) | |||
{ | |||
e.printStackTrace(); | |||
} | |||
viewer.setFile(args[ 0 ]); | |||
viewer.run(); | |||
} | |||
else | |||
{ |
@@ -207,8 +207,9 @@ public class ExcelExtractor extends POIOLE2TextExtractor implements org.apache.p | |||
/** | |||
* Command line extractor. | |||
* @throws IOException | |||
*/ | |||
public static void main(String[] args) { | |||
public static void main(String[] args) throws IOException { | |||
CommandArgs cmdArgs; | |||
try { | |||
@@ -225,27 +226,23 @@ public class ExcelExtractor extends POIOLE2TextExtractor implements org.apache.p | |||
return; | |||
} | |||
try { | |||
InputStream is; | |||
if(cmdArgs.getInputFile() == null) { | |||
is = System.in; | |||
} else { | |||
is = new FileInputStream(cmdArgs.getInputFile()); | |||
} | |||
HSSFWorkbook wb = new HSSFWorkbook(is); | |||
ExcelExtractor extractor = new ExcelExtractor(wb); | |||
extractor.setIncludeSheetNames(cmdArgs.shouldShowSheetNames()); | |||
extractor.setFormulasNotResults(!cmdArgs.shouldEvaluateFormulas()); | |||
extractor.setIncludeCellComments(cmdArgs.shouldShowCellComments()); | |||
extractor.setIncludeBlankCells(cmdArgs.shouldShowBlankCells()); | |||
extractor.setIncludeHeadersFooters(cmdArgs.shouldIncludeHeadersFooters()); | |||
System.out.println(extractor.getText()); | |||
extractor.close(); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
System.exit(1); | |||
InputStream is; | |||
if(cmdArgs.getInputFile() == null) { | |||
is = System.in; | |||
} else { | |||
is = new FileInputStream(cmdArgs.getInputFile()); | |||
} | |||
HSSFWorkbook wb = new HSSFWorkbook(is); | |||
is.close(); | |||
ExcelExtractor extractor = new ExcelExtractor(wb); | |||
extractor.setIncludeSheetNames(cmdArgs.shouldShowSheetNames()); | |||
extractor.setFormulasNotResults(!cmdArgs.shouldEvaluateFormulas()); | |||
extractor.setIncludeCellComments(cmdArgs.shouldShowCellComments()); | |||
extractor.setIncludeBlankCells(cmdArgs.shouldShowBlankCells()); | |||
extractor.setIncludeHeadersFooters(cmdArgs.shouldIncludeHeadersFooters()); | |||
System.out.println(extractor.getText()); | |||
extractor.close(); | |||
} | |||
/** | |||
* Should sheet names be included? Default is true |
@@ -17,13 +17,24 @@ | |||
package org.apache.poi.hssf.usermodel; | |||
import org.apache.poi.ddf.*; | |||
import java.io.ByteArrayOutputStream; | |||
import java.io.IOException; | |||
import org.apache.poi.ddf.EscherBoolProperty; | |||
import org.apache.poi.ddf.EscherChildAnchorRecord; | |||
import org.apache.poi.ddf.EscherClientAnchorRecord; | |||
import org.apache.poi.ddf.EscherContainerRecord; | |||
import org.apache.poi.ddf.EscherOptRecord; | |||
import org.apache.poi.ddf.EscherProperties; | |||
import org.apache.poi.ddf.EscherProperty; | |||
import org.apache.poi.ddf.EscherRGBProperty; | |||
import org.apache.poi.ddf.EscherSimpleProperty; | |||
import org.apache.poi.ddf.EscherSpRecord; | |||
import org.apache.poi.hssf.record.CommonObjectDataSubRecord; | |||
import org.apache.poi.hssf.record.ObjRecord; | |||
import org.apache.poi.util.LittleEndian; | |||
import java.io.ByteArrayOutputStream; | |||
import java.io.IOException; | |||
import org.apache.poi.util.POILogFactory; | |||
import org.apache.poi.util.POILogger; | |||
/** | |||
* An abstract shape. | |||
@@ -34,6 +45,8 @@ import java.io.IOException; | |||
* setFlipVertical() or setFlipHorizontally(). | |||
*/ | |||
public abstract class HSSFShape { | |||
private static final POILogger LOG = POILogFactory.getLogger(HSSFShape.class); | |||
public static final int LINEWIDTH_ONE_PT = 12700; | |||
public static final int LINEWIDTH_DEFAULT = 9525; | |||
public static final int LINESTYLE__COLOR_DEFAULT = 0x08000040; | |||
@@ -362,7 +375,7 @@ public abstract class HSSFShape { | |||
LittleEndian.putInt(property.getPropertyValue(), bos); | |||
return LittleEndian.getShort(bos.toByteArray(), 2); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
LOG.log(POILogger.ERROR, "can't determine rotation degree", e); | |||
return 0; | |||
} | |||
} |
@@ -57,6 +57,8 @@ import org.apache.poi.util.CloseIgnoringInputStream; | |||
import org.apache.poi.util.IOUtils; | |||
import org.apache.poi.util.Internal; | |||
import org.apache.poi.util.LongField; | |||
import org.apache.poi.util.POILogFactory; | |||
import org.apache.poi.util.POILogger; | |||
/** | |||
* <p>This is the main class of the POIFS system; it manages the entire | |||
@@ -67,8 +69,7 @@ import org.apache.poi.util.LongField; | |||
public class NPOIFSFileSystem extends BlockStore | |||
implements POIFSViewable, Closeable | |||
{ | |||
// private static final POILogger _logger = | |||
// POILogFactory.getLogger(NPOIFSFileSystem.class); | |||
private static final POILogger LOG = POILogFactory.getLogger(NPOIFSFileSystem.class); | |||
/** | |||
* Convenience method for clients that want to avoid the auto-close behaviour of the constructor. | |||
@@ -346,7 +347,7 @@ public class NPOIFSFileSystem extends BlockStore | |||
} | |||
// else not success? Try block did not complete normally | |||
// just print stack trace and leave original ex to be thrown | |||
e.printStackTrace(); | |||
LOG.log(POILogger.ERROR, "can't close input stream", e); | |||
} | |||
} | |||
@@ -194,7 +194,7 @@ public class OPOIFSFileSystem | |||
} | |||
// else not success? Try block did not complete normally | |||
// just print stack trace and leave original ex to be thrown | |||
e.printStackTrace(); | |||
_logger.log(POILogger.ERROR, "can't close input stream", e); | |||
} | |||
} | |||
@@ -32,6 +32,8 @@ import java.util.regex.Matcher; | |||
import org.apache.poi.ss.format.CellFormatPart.PartHandler; | |||
import org.apache.poi.util.LocaleUtil; | |||
import org.apache.poi.util.POILogFactory; | |||
import org.apache.poi.util.POILogger; | |||
/** | |||
* This class implements printing out a value using a number format. | |||
@@ -39,6 +41,8 @@ import org.apache.poi.util.LocaleUtil; | |||
* @author Ken Arnold, Industrious Media LLC | |||
*/ | |||
public class CellNumberFormatter extends CellFormatter { | |||
private static final POILogger LOG = POILogFactory.getLogger(CellNumberFormatter.class); | |||
private final String desc; | |||
private String printfFmt; | |||
private double scale; | |||
@@ -843,7 +847,7 @@ public class CellNumberFormatter extends CellFormatter { | |||
writeSingleInteger(denominatorFmt, d, output, denominatorSpecials, | |||
mods); | |||
} catch (RuntimeException ignored) { | |||
ignored.printStackTrace(); | |||
LOG.log(POILogger.ERROR, "error while fraction evaluation", ignored); | |||
} | |||
} | |||
@@ -332,7 +332,7 @@ public final class WorkbookEvaluator { | |||
return new NotImplementedException(msg, inner); | |||
} catch (Exception e) { | |||
// avoid bombing out during exception handling | |||
e.printStackTrace(); | |||
LOG.log(POILogger.ERROR, "Can't add exception info", e); | |||
return inner; // preserve original exception | |||
} | |||
} |
@@ -22,11 +22,15 @@ import org.apache.poi.ss.formula.eval.EvaluationException; | |||
import org.apache.poi.ss.formula.eval.NumberEval; | |||
import org.apache.poi.ss.formula.eval.OperandResolver; | |||
import org.apache.poi.ss.formula.eval.ValueEval; | |||
import org.apache.poi.util.POILogFactory; | |||
import org.apache.poi.util.POILogger; | |||
/** | |||
* Implements the Excel Rate function | |||
*/ | |||
public class Rate implements Function { | |||
private static final POILogger LOG = POILogFactory.getLogger(Rate.class); | |||
public ValueEval evaluate(ValueEval[] args, int srcRowIndex, int srcColumnIndex) { | |||
if (args.length < 3) { //First 3 parameters are mandatory | |||
return ErrorEval.VALUE_INVALID; | |||
@@ -61,7 +65,7 @@ public class Rate implements Function { | |||
checkValue(rate); | |||
} catch (EvaluationException e) { | |||
e.printStackTrace() ; | |||
LOG.log(POILogger.ERROR, "Can't evaluate rate function", e); | |||
return e.getErrorEval(); | |||
} | |||
@@ -46,6 +46,8 @@ import org.apache.poi.ss.usermodel.Cell; | |||
import org.apache.poi.ss.usermodel.DateUtil; | |||
import org.apache.poi.util.DocumentHelper; | |||
import org.apache.poi.util.LocaleUtil; | |||
import org.apache.poi.util.POILogFactory; | |||
import org.apache.poi.util.POILogger; | |||
import org.apache.poi.xssf.usermodel.XSSFCell; | |||
import org.apache.poi.xssf.usermodel.XSSFMap; | |||
import org.apache.poi.xssf.usermodel.XSSFRow; | |||
@@ -80,6 +82,7 @@ import org.xml.sax.SAXException; | |||
* </ul> | |||
*/ | |||
public class XSSFExportToXml implements Comparator<String>{ | |||
private static final POILogger LOG = POILogFactory.getLogger(XSSFExportToXml.class); | |||
private XSSFMap map; | |||
@@ -265,7 +268,7 @@ public class XSSFExportToXml implements Comparator<String>{ | |||
//if no exceptions where raised, the document is valid | |||
return true; | |||
} catch(IOException e) { | |||
e.printStackTrace(); | |||
LOG.log(POILogger.ERROR, "document is not valid", e); | |||
} | |||
return false; |
@@ -24,6 +24,8 @@ import java.util.Iterator; | |||
import java.util.List; | |||
import org.apache.poi.POIXMLDocumentPart; | |||
import org.apache.poi.util.POILogFactory; | |||
import org.apache.poi.util.POILogger; | |||
import org.apache.poi.xwpf.usermodel.XWPFDocument; | |||
import org.apache.poi.xwpf.usermodel.XWPFFactory; | |||
import org.apache.poi.xwpf.usermodel.XWPFFooter; | |||
@@ -66,6 +68,8 @@ import com.microsoft.schemas.vml.STTrueFalse; | |||
* the right headers and footers for the document. | |||
*/ | |||
public class XWPFHeaderFooterPolicy { | |||
private static final POILogger LOG = POILogFactory.getLogger(XWPFHeaderFooterPolicy.class); | |||
public static final Enum DEFAULT = STHdrFtr.DEFAULT; | |||
public static final Enum EVEN = STHdrFtr.EVEN; | |||
public static final Enum FIRST = STHdrFtr.FIRST; | |||
@@ -376,8 +380,7 @@ public class XWPFHeaderFooterPolicy { | |||
pars[0] = getWatermarkParagraph(text, 3); | |||
createHeader(EVEN, pars); | |||
} catch (IOException e) { | |||
// TODO Auto-generated catch block | |||
e.printStackTrace(); | |||
LOG.log(POILogger.ERROR, "error while creating watermark", e); | |||
} | |||
} | |||
@@ -52,6 +52,8 @@ import org.apache.poi.poifs.crypt.HashAlgorithm; | |||
import org.apache.poi.util.IOUtils; | |||
import org.apache.poi.util.IdentifierManager; | |||
import org.apache.poi.util.Internal; | |||
import org.apache.poi.util.POILogFactory; | |||
import org.apache.poi.util.POILogger; | |||
import org.apache.poi.util.PackageHelper; | |||
import org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy; | |||
import org.apache.xmlbeans.XmlCursor; | |||
@@ -88,6 +90,8 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.StylesDocument; | |||
* at some point in your use.</p> | |||
*/ | |||
public class XWPFDocument extends POIXMLDocument implements Document, IBody { | |||
private static final POILogger LOG = POILogFactory.getLogger(XWPFDocument.class); | |||
protected List<XWPFFooter> footers = new ArrayList<XWPFFooter>(); | |||
protected List<XWPFHeader> headers = new ArrayList<XWPFHeader>(); | |||
protected List<XWPFComment> comments = new ArrayList<XWPFComment>(); | |||
@@ -899,7 +903,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody { | |||
int level = Integer.parseInt(parStyle.substring("Heading".length())); | |||
toc.addRow(level, par.getText(), 1, "112723803"); | |||
} catch (NumberFormatException e) { | |||
e.printStackTrace(); | |||
LOG.log(POILogger.ERROR, "can't format number in TOC heading", e); | |||
} | |||
} | |||
} |
@@ -25,5 +25,6 @@ | |||
#java.lang.Runtime#exit(int) | |||
#java.lang.Runtime#halt(int) | |||
@defaultMessage Please do not try to stop the world | |||
java.lang.System#gc() | |||
java.lang.System#gc() @ Please do not try to stop the world | |||
java.lang.Throwable#printStackTrace() @ Please use POILogger for exceptions |
@@ -29,6 +29,8 @@ import org.apache.poi.hslf.exceptions.HSLFException; | |||
import org.apache.poi.hslf.record.StyleTextPropAtom; | |||
import org.apache.poi.util.HexDump; | |||
import org.apache.poi.util.LittleEndian; | |||
import org.apache.poi.util.POILogFactory; | |||
import org.apache.poi.util.POILogger; | |||
/** | |||
* For a given run of characters, holds the properties (which could | |||
@@ -37,6 +39,8 @@ import org.apache.poi.util.LittleEndian; | |||
* properties, and the indent level if required. | |||
*/ | |||
public class TextPropCollection { | |||
private static final POILogger LOG = POILogFactory.getLogger(TextPropCollection.class); | |||
/** All the different kinds of paragraph properties we might handle */ | |||
private static final TextProp[] paragraphTextPropTypes = { | |||
// TextProp order is according to 2.9.20 TextPFException, | |||
@@ -376,8 +380,8 @@ public class TextPropCollection { | |||
writeOut(baos); | |||
byte[] b = baos.toByteArray(); | |||
out.append(HexDump.dump(b, 0, 0)); | |||
} catch (Exception e ) { | |||
e.printStackTrace(); | |||
} catch (IOException e ) { | |||
LOG.log(POILogger.ERROR, "can't dump TextPropCollection", e); | |||
} | |||
return out.toString(); |
@@ -77,8 +77,7 @@ public final class MasterTextPropAtom extends RecordAtom { | |||
try { | |||
read(); | |||
} catch (Exception e){ | |||
logger.log(POILogger.ERROR, "Failed to parse MasterTextPropAtom: " + e.getMessage()); | |||
e.printStackTrace(); | |||
logger.log(POILogger.ERROR, "Failed to parse MasterTextPropAtom", e); | |||
} | |||
} | |||
@@ -25,11 +25,8 @@ import org.apache.poi.util.POILogger; | |||
/** | |||
* Ruler of a text as it differs from the style's ruler settings. | |||
* | |||
* @author Yegor Kozlov | |||
*/ | |||
public final class TextRulerAtom extends RecordAtom { | |||
/** | |||
* Record header. | |||
*/ | |||
@@ -79,7 +76,6 @@ public final class TextRulerAtom extends RecordAtom { | |||
read(); | |||
} catch (Exception e){ | |||
logger.log(POILogger.ERROR, "Failed to parse TextRulerAtom: " + e.getMessage()); | |||
e.printStackTrace(); | |||
} | |||
} | |||
@@ -48,6 +48,8 @@ import org.apache.poi.util.POILogger; | |||
* @author Yegor Kozlov | |||
*/ | |||
public final class TxMasterStyleAtom extends RecordAtom { | |||
private static final POILogger LOG = POILogFactory.getLogger(TxMasterStyleAtom.class); | |||
/** | |||
* Maximum number of indentation levels allowed in PowerPoint documents | |||
*/ | |||
@@ -71,7 +73,7 @@ public final class TxMasterStyleAtom extends RecordAtom { | |||
try { | |||
init(); | |||
} catch (Exception e){ | |||
POILogFactory.getLogger(TxMasterStyleAtom.class).log(POILogger.WARN, "Exception when reading available styles", e); | |||
LOG.log(POILogger.WARN, "Exception when reading available styles", e); | |||
} | |||
} | |||
@@ -17,13 +17,16 @@ | |||
package org.apache.poi.hssf.converter; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.util.ArrayList; | |||
import java.util.LinkedHashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import javax.xml.parsers.ParserConfigurationException; | |||
import javax.xml.transform.OutputKeys; | |||
import javax.xml.transform.Transformer; | |||
import javax.xml.transform.TransformerException; | |||
import javax.xml.transform.TransformerFactory; | |||
import javax.xml.transform.dom.DOMSource; | |||
import javax.xml.transform.stream.StreamResult; | |||
@@ -68,8 +71,11 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter | |||
* </p> | |||
* Where infile is an input .xls file ( Word 97-2007) which will be rendered | |||
* as HTML into outfile | |||
* @throws TransformerException | |||
* @throws Exception | |||
*/ | |||
public static void main( String[] args ) | |||
throws IOException, ParserConfigurationException, TransformerException | |||
{ | |||
if ( args.length < 2 ) | |||
{ | |||
@@ -80,25 +86,19 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter | |||
System.out.println( "Converting " + args[0] ); | |||
System.out.println( "Saving output to " + args[1] ); | |||
try | |||
{ | |||
Document doc = ExcelToHtmlConverter.process( new File( args[0] ) ); | |||
DOMSource domSource = new DOMSource( doc ); | |||
StreamResult streamResult = new StreamResult( new File(args[1]) ); | |||
TransformerFactory tf = TransformerFactory.newInstance(); | |||
Transformer serializer = tf.newTransformer(); | |||
// TODO set encoding from a command argument | |||
serializer.setOutputProperty( OutputKeys.ENCODING, "UTF-8" ); | |||
serializer.setOutputProperty( OutputKeys.INDENT, "no" ); | |||
serializer.setOutputProperty( OutputKeys.METHOD, "html" ); | |||
serializer.transform( domSource, streamResult ); | |||
} | |||
catch ( Exception e ) | |||
{ | |||
e.printStackTrace(); | |||
} | |||
Document doc = ExcelToHtmlConverter.process( new File( args[0] ) ); | |||
DOMSource domSource = new DOMSource( doc ); | |||
StreamResult streamResult = new StreamResult( new File(args[1]) ); | |||
TransformerFactory tf = TransformerFactory.newInstance(); | |||
Transformer serializer = tf.newTransformer(); | |||
// TODO set encoding from a command argument | |||
serializer.setOutputProperty( OutputKeys.ENCODING, "UTF-8" ); | |||
serializer.setOutputProperty( OutputKeys.INDENT, "no" ); | |||
serializer.setOutputProperty( OutputKeys.METHOD, "html" ); | |||
serializer.transform( domSource, streamResult ); | |||
} | |||
/** | |||
@@ -107,8 +107,10 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter | |||
* @param xlsFile | |||
* file to process | |||
* @return DOM representation of result HTML | |||
* @throws IOException | |||
* @throws ParserConfigurationException | |||
*/ | |||
public static Document process( File xlsFile ) throws Exception | |||
public static Document process( File xlsFile ) throws IOException, ParserConfigurationException | |||
{ | |||
final HSSFWorkbook workbook = ExcelToHtmlUtils.loadXls( xlsFile ); | |||
ExcelToHtmlConverter excelToHtmlConverter = new ExcelToHtmlConverter( |
@@ -18,6 +18,8 @@ | |||
package org.apache.poi.hwpf; | |||
import java.io.FileInputStream; | |||
import java.io.FileNotFoundException; | |||
import java.io.IOException; | |||
import org.apache.poi.hwpf.usermodel.CharacterRun; | |||
import org.apache.poi.hwpf.usermodel.Paragraph; | |||
@@ -30,10 +32,8 @@ public final class QuickTest | |||
{ | |||
} | |||
public static void main(String[] args) | |||
public static void main(String[] args) throws IOException | |||
{ | |||
try | |||
{ | |||
HWPFDocument doc = new HWPFDocument (new FileInputStream (args[0])); | |||
Range r = doc.getRange(); | |||
@@ -81,12 +81,6 @@ public final class QuickTest | |||
// System.out.println(); | |||
// } | |||
// } | |||
} | |||
catch (Exception t) | |||
{ | |||
t.printStackTrace(); | |||
} | |||
} | |||
} |
@@ -156,16 +156,7 @@ public class CHPBinTable | |||
if ( hasChp ) | |||
{ | |||
SprmBuffer newSprmBuffer; | |||
try | |||
{ | |||
newSprmBuffer = (SprmBuffer) sprmBuffer.clone(); | |||
} | |||
catch ( CloneNotSupportedException e ) | |||
{ | |||
// shall not happen | |||
throw new Error( e ); | |||
} | |||
SprmBuffer newSprmBuffer = sprmBuffer.clone(); | |||
CHPX chpx = new CHPX( textPiece.getStart(), | |||
textPiece.getEnd(), newSprmBuffer ); |
@@ -277,18 +277,9 @@ public class PAPBinTable | |||
if ( papx.getGrpprl() == null || papx.getGrpprl().length == 0 ) | |||
continue; | |||
if ( sprmBuffer == null ) | |||
try | |||
{ | |||
sprmBuffer = (SprmBuffer) papx.getSprmBuf().clone(); | |||
} | |||
catch ( CloneNotSupportedException e ) | |||
{ | |||
// can't happen | |||
throw new Error( e ); | |||
} | |||
else | |||
{ | |||
if ( sprmBuffer == null ) { | |||
sprmBuffer = papx.getSprmBuf().clone(); | |||
} else { | |||
sprmBuffer.append( papx.getGrpprl(), 2 ); | |||
} | |||
} | |||
@@ -325,15 +316,7 @@ public class PAPBinTable | |||
PAPX currentPap = _paragraphs.get(listIndex); | |||
if (currentPap != null && currentPap.getStart() < cpStart) | |||
{ | |||
SprmBuffer clonedBuf = null; | |||
try | |||
{ | |||
clonedBuf = (SprmBuffer)currentPap.getSprmBuf().clone(); | |||
} | |||
catch (CloneNotSupportedException exc) | |||
{ | |||
exc.printStackTrace(); | |||
} | |||
SprmBuffer clonedBuf = currentPap.getSprmBuf().clone(); | |||
// Copy the properties of the one before to afterwards | |||
// Will go: |
@@ -128,13 +128,16 @@ public final class SprmBuffer implements Cloneable | |||
System.arraycopy( grpprl, offset, _buf, _offset, grpprl.length - offset ); | |||
_offset += grpprl.length - offset; | |||
} | |||
public Object clone() | |||
throws CloneNotSupportedException | |||
public SprmBuffer clone() | |||
{ | |||
SprmBuffer retVal = (SprmBuffer)super.clone(); | |||
retVal._buf = new byte[_buf.length]; | |||
System.arraycopy(_buf, 0, retVal._buf, 0, _buf.length); | |||
return retVal; | |||
try { | |||
SprmBuffer retVal = (SprmBuffer)super.clone(); | |||
retVal._buf = new byte[_buf.length]; | |||
System.arraycopy(_buf, 0, retVal._buf, 0, _buf.length); | |||
return retVal; | |||
} catch (CloneNotSupportedException e) { | |||
throw new RuntimeException(e); | |||
} | |||
} | |||
private void ensureCapacity( int addition ) | |||
{ |