Fix some Sonar issues and some IntelliJ warnings
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1746627 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6b6aa56455
commit
1fdbf14e1e
@ -18,6 +18,7 @@
|
|||||||
package org.apache.poi.xssf.usermodel.examples;
|
package org.apache.poi.xssf.usermodel.examples;
|
||||||
|
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
|
||||||
import org.apache.poi.ss.usermodel.Sheet;
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
import org.apache.poi.ss.usermodel.Workbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
@ -44,10 +45,12 @@ public class Outlining {
|
|||||||
sheet1.groupColumn( (short)9, (short)12 );
|
sheet1.groupColumn( (short)9, (short)12 );
|
||||||
sheet1.groupColumn( (short)10, (short)11 );
|
sheet1.groupColumn( (short)10, (short)11 );
|
||||||
|
|
||||||
FileOutputStream fileOut = new FileOutputStream("outlining.xlsx");
|
OutputStream fileOut = new FileOutputStream("outlining.xlsx");
|
||||||
|
try {
|
||||||
wb.write(fileOut);
|
wb.write(fileOut);
|
||||||
|
} finally {
|
||||||
fileOut.close();
|
fileOut.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void collapseExpandRowColumn() throws Exception {
|
private void collapseExpandRowColumn() throws Exception {
|
||||||
@ -68,8 +71,11 @@ public class Outlining {
|
|||||||
sheet2.setColumnGroupCollapsed( (short)4, true );
|
sheet2.setColumnGroupCollapsed( (short)4, true );
|
||||||
sheet2.setColumnGroupCollapsed( (short)4, false );
|
sheet2.setColumnGroupCollapsed( (short)4, false );
|
||||||
|
|
||||||
FileOutputStream fileOut = new FileOutputStream("outlining_collapsed.xlsx");
|
OutputStream fileOut = new FileOutputStream("outlining_collapsed.xlsx");
|
||||||
|
try {
|
||||||
wb2.write(fileOut);
|
wb2.write(fileOut);
|
||||||
|
} finally {
|
||||||
fileOut.close();
|
fileOut.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package org.apache.poi.xwpf.usermodel;
|
package org.apache.poi.xwpf.usermodel;
|
||||||
|
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -62,6 +63,7 @@ public class SimpleTable {
|
|||||||
public static void createSimpleTable() throws Exception {
|
public static void createSimpleTable() throws Exception {
|
||||||
XWPFDocument doc = new XWPFDocument();
|
XWPFDocument doc = new XWPFDocument();
|
||||||
|
|
||||||
|
try {
|
||||||
XWPFTable table = doc.createTable(3, 3);
|
XWPFTable table = doc.createTable(3, 3);
|
||||||
|
|
||||||
table.getRow(1).getCell(1).setText("EXAMPLE OF TABLE");
|
table.getRow(1).getCell(1).setText("EXAMPLE OF TABLE");
|
||||||
@ -83,12 +85,16 @@ public class SimpleTable {
|
|||||||
|
|
||||||
table.getRow(2).getCell(2).setText("only text");
|
table.getRow(2).getCell(2).setText("only text");
|
||||||
|
|
||||||
FileOutputStream out = new FileOutputStream("simpleTable.docx");
|
OutputStream out = new FileOutputStream("simpleTable.docx");
|
||||||
|
try {
|
||||||
doc.write(out);
|
doc.write(out);
|
||||||
|
} finally {
|
||||||
out.close();
|
out.close();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
doc.close();
|
doc.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a table with some row and column styling. I "manually" add the
|
* Create a table with some row and column styling. I "manually" add the
|
||||||
@ -107,6 +113,8 @@ public class SimpleTable {
|
|||||||
public static void createStyledTable() throws Exception {
|
public static void createStyledTable() throws Exception {
|
||||||
// Create a new document from scratch
|
// Create a new document from scratch
|
||||||
XWPFDocument doc = new XWPFDocument();
|
XWPFDocument doc = new XWPFDocument();
|
||||||
|
|
||||||
|
try {
|
||||||
// -- OR --
|
// -- OR --
|
||||||
// open an existing empty document with styles already defined
|
// open an existing empty document with styles already defined
|
||||||
//XWPFDocument doc = new XWPFDocument(new FileInputStream("base_document.docx"));
|
//XWPFDocument doc = new XWPFDocument(new FileInputStream("base_document.docx"));
|
||||||
@ -150,12 +158,10 @@ public class SimpleTable {
|
|||||||
if (rowCt == 0) {
|
if (rowCt == 0) {
|
||||||
// header row
|
// header row
|
||||||
ctshd.setFill("A7BFDE");
|
ctshd.setFill("A7BFDE");
|
||||||
}
|
} else if (rowCt % 2 == 0) {
|
||||||
else if (rowCt % 2 == 0) {
|
|
||||||
// even row
|
// even row
|
||||||
ctshd.setFill("D3DFEE");
|
ctshd.setFill("D3DFEE");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// odd row
|
// odd row
|
||||||
ctshd.setFill("EDF2F8");
|
ctshd.setFill("EDF2F8");
|
||||||
}
|
}
|
||||||
@ -175,8 +181,7 @@ public class SimpleTable {
|
|||||||
rh.setText("header row, col " + colCt);
|
rh.setText("header row, col " + colCt);
|
||||||
rh.setBold(true);
|
rh.setBold(true);
|
||||||
para.setAlignment(ParagraphAlignment.CENTER);
|
para.setAlignment(ParagraphAlignment.CENTER);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// other rows
|
// other rows
|
||||||
rh.setText("row " + rowCt + ", col " + colCt);
|
rh.setText("row " + rowCt + ", col " + colCt);
|
||||||
para.setAlignment(ParagraphAlignment.LEFT);
|
para.setAlignment(ParagraphAlignment.LEFT);
|
||||||
@ -188,11 +193,14 @@ public class SimpleTable {
|
|||||||
} // for row
|
} // for row
|
||||||
|
|
||||||
// write the file
|
// write the file
|
||||||
FileOutputStream out = new FileOutputStream("styledTable.docx");
|
OutputStream out = new FileOutputStream("styledTable.docx");
|
||||||
|
try {
|
||||||
doc.write(out);
|
doc.write(out);
|
||||||
|
} finally {
|
||||||
out.close();
|
out.close();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
doc.close();
|
doc.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,13 +125,13 @@ public class ExcelAntEvaluateCell extends Task {
|
|||||||
}
|
}
|
||||||
result = wbUtil.evaluateCell(cell, expectedValue, precisionToUse ) ;
|
result = wbUtil.evaluateCell(cell, expectedValue, precisionToUse ) ;
|
||||||
|
|
||||||
StringBuffer sb = new StringBuffer() ;
|
StringBuilder sb = new StringBuilder() ;
|
||||||
sb.append( "evaluation of cell " ) ;
|
sb.append( "evaluation of cell " ) ;
|
||||||
sb.append( cell ) ;
|
sb.append( cell ) ;
|
||||||
sb.append( " resulted in " ) ;
|
sb.append( " resulted in " ) ;
|
||||||
sb.append( result.getReturnValue() ) ;
|
sb.append( result.getReturnValue() ) ;
|
||||||
if( showDelta == true ) {
|
if(showDelta) {
|
||||||
sb.append( " with a delta of " + result.getDelta() ) ;
|
sb.append(" with a delta of ").append(result.getDelta());
|
||||||
}
|
}
|
||||||
|
|
||||||
log( sb.toString(), Project.MSG_DEBUG) ;
|
log( sb.toString(), Project.MSG_DEBUG) ;
|
||||||
@ -141,6 +141,4 @@ public class ExcelAntEvaluateCell extends Task {
|
|||||||
public ExcelAntEvaluationResult getResult() {
|
public ExcelAntEvaluationResult getResult() {
|
||||||
return result ;
|
return result ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,15 +29,13 @@ import org.apache.tools.ant.Project;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ExcelAntSetDoubleCell extends ExcelAntSet {
|
public class ExcelAntSetDoubleCell extends ExcelAntSet {
|
||||||
|
|
||||||
|
|
||||||
private double cellValue;
|
private double cellValue;
|
||||||
|
|
||||||
public ExcelAntSetDoubleCell() {}
|
public ExcelAntSetDoubleCell() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the value of the specified cell as the double passed in.
|
* Set the value of the specified cell as the double passed in.
|
||||||
* @param value
|
* @param value The double-value that should be set when this task is executed.
|
||||||
*/
|
*/
|
||||||
public void setValue( double value ) {
|
public void setValue( double value ) {
|
||||||
cellValue = value ;
|
cellValue = value ;
|
||||||
@ -45,14 +43,14 @@ public class ExcelAntSetDoubleCell extends ExcelAntSet {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the cell value as a double.
|
* Return the cell value as a double.
|
||||||
* @return
|
* @return The double-value of the cell as populated via setValue(), null
|
||||||
|
* if the value was not set yet.
|
||||||
*/
|
*/
|
||||||
public double getCellValue() {
|
public double getCellValue() {
|
||||||
return cellValue;
|
return cellValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void execute() throws BuildException {
|
public void execute() throws BuildException {
|
||||||
|
|
||||||
wbUtil.setDoubleValue(cellStr, cellValue ) ;
|
wbUtil.setDoubleValue(cellStr, cellValue ) ;
|
||||||
|
|
||||||
log( "set cell " + cellStr + " to value " + cellValue + " as double.", Project.MSG_DEBUG ) ;
|
log( "set cell " + cellStr + " to value " + cellValue + " as double.", Project.MSG_DEBUG ) ;
|
||||||
|
@ -29,17 +29,13 @@ import org.apache.tools.ant.Project;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ExcelAntSetStringCell extends ExcelAntSet {
|
public class ExcelAntSetStringCell extends ExcelAntSet {
|
||||||
|
|
||||||
|
|
||||||
private String stringValue ;
|
private String stringValue ;
|
||||||
|
|
||||||
|
|
||||||
public ExcelAntSetStringCell() {}
|
public ExcelAntSetStringCell() {}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the value of the cell to the String passed in.
|
* Set the value of the cell to the String passed in.
|
||||||
* @param value
|
* @param value The string-value that should be set when this task is executed.
|
||||||
*/
|
*/
|
||||||
public void setValue(String value ) {
|
public void setValue(String value ) {
|
||||||
stringValue = value ;
|
stringValue = value ;
|
||||||
@ -47,14 +43,14 @@ public class ExcelAntSetStringCell extends ExcelAntSet {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the value that will be set into the cell.
|
* Return the value that will be set into the cell.
|
||||||
* @return
|
* @return The string-value of the cell as populated via setValue(), null
|
||||||
|
* if the value was not set yet.
|
||||||
*/
|
*/
|
||||||
public String getCellValue() {
|
public String getCellValue() {
|
||||||
return stringValue;
|
return stringValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void execute() throws BuildException {
|
public void execute() throws BuildException {
|
||||||
|
|
||||||
wbUtil.setStringValue(cellStr, stringValue ) ;
|
wbUtil.setStringValue(cellStr, stringValue ) ;
|
||||||
|
|
||||||
log( "set cell " + cellStr + " to value " + stringValue + " as String.", Project.MSG_DEBUG ) ;
|
log( "set cell " + cellStr + " to value " + stringValue + " as String.", Project.MSG_DEBUG ) ;
|
||||||
|
@ -17,14 +17,6 @@
|
|||||||
|
|
||||||
package org.apache.poi.ss.excelant;
|
package org.apache.poi.ss.excelant;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import org.apache.poi.ss.excelant.util.ExcelAntWorkbookUtil;
|
import org.apache.poi.ss.excelant.util.ExcelAntWorkbookUtil;
|
||||||
import org.apache.poi.ss.excelant.util.ExcelAntWorkbookUtilFactory;
|
import org.apache.poi.ss.excelant.util.ExcelAntWorkbookUtilFactory;
|
||||||
import org.apache.poi.ss.usermodel.Workbook;
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
@ -33,6 +25,13 @@ import org.apache.tools.ant.BuildException;
|
|||||||
import org.apache.tools.ant.Project;
|
import org.apache.tools.ant.Project;
|
||||||
import org.apache.tools.ant.Task;
|
import org.apache.tools.ant.Task;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ant task class for testing Excel workbook cells.
|
* Ant task class for testing Excel workbook cells.
|
||||||
*
|
*
|
||||||
@ -85,7 +84,7 @@ public class ExcelAntTask extends Task {
|
|||||||
int totalCount = 0 ;
|
int totalCount = 0 ;
|
||||||
int successCount = 0 ;
|
int successCount = 0 ;
|
||||||
|
|
||||||
StringBuffer versionBffr = new StringBuffer() ;
|
StringBuilder versionBffr = new StringBuilder() ;
|
||||||
versionBffr.append( "ExcelAnt version " ) ;
|
versionBffr.append( "ExcelAnt version " ) ;
|
||||||
versionBffr.append( VERSION ) ;
|
versionBffr.append( VERSION ) ;
|
||||||
versionBffr.append( " Copyright 2011" ) ;
|
versionBffr.append( " Copyright 2011" ) ;
|
||||||
@ -108,17 +107,12 @@ public class ExcelAntTask extends Task {
|
|||||||
}
|
}
|
||||||
if( tests.size() > 0 ) {
|
if( tests.size() > 0 ) {
|
||||||
|
|
||||||
Iterator<ExcelAntTest> testsIt = tests.iterator() ;
|
for (ExcelAntTest test : tests) {
|
||||||
while( testsIt.hasNext() ) {
|
|
||||||
ExcelAntTest test = testsIt.next();
|
|
||||||
|
|
||||||
log("executing test: " + test.getName(), Project.MSG_DEBUG);
|
log("executing test: " + test.getName(), Project.MSG_DEBUG);
|
||||||
|
|
||||||
workbookUtil = ExcelAntWorkbookUtilFactory.getInstance(excelFileName);
|
workbookUtil = ExcelAntWorkbookUtilFactory.getInstance(excelFileName);
|
||||||
|
|
||||||
Iterator<ExcelAntUserDefinedFunction> functionsIt = functions.iterator() ;
|
for (ExcelAntUserDefinedFunction eaUdf : functions) {
|
||||||
while( functionsIt.hasNext() ) {
|
|
||||||
ExcelAntUserDefinedFunction eaUdf = functionsIt.next() ;
|
|
||||||
try {
|
try {
|
||||||
workbookUtil.addFunction(eaUdf.getFunctionAlias(), eaUdf.getClassName());
|
workbookUtil.addFunction(eaUdf.getFunctionAlias(), eaUdf.getClassName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -137,7 +131,7 @@ public class ExcelAntTask extends Task {
|
|||||||
if (test.didTestPass()) {
|
if (test.didTestPass()) {
|
||||||
successCount++;
|
successCount++;
|
||||||
} else {
|
} else {
|
||||||
if( failOnError == true ) {
|
if (failOnError) {
|
||||||
throw new BuildException("Test " + test.getName() + " failed.");
|
throw new BuildException("Test " + test.getName() + " failed.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,8 +163,8 @@ public class ExcelAntTest extends Task{
|
|||||||
eval.execute();
|
eval.execute();
|
||||||
ExcelAntEvaluationResult result = eval.getResult();
|
ExcelAntEvaluationResult result = eval.getResult();
|
||||||
if( result.didTestPass() &&
|
if( result.didTestPass() &&
|
||||||
result.evaluationCompleteWithError() == false ) {
|
!result.evaluationCompleteWithError()) {
|
||||||
if( showSuccessDetails == true ) {
|
if(showSuccessDetails) {
|
||||||
log("Succeeded when evaluating " +
|
log("Succeeded when evaluating " +
|
||||||
result.getCellName() + ". It evaluated to " +
|
result.getCellName() + ". It evaluated to " +
|
||||||
result.getReturnValue() + " when the value of " +
|
result.getReturnValue() + " when the value of " +
|
||||||
@ -172,7 +172,7 @@ public class ExcelAntTest extends Task{
|
|||||||
eval.getPrecision(), Project.MSG_INFO );
|
eval.getPrecision(), Project.MSG_INFO );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if( showFailureDetail == true ) {
|
if(showFailureDetail) {
|
||||||
failureMessages.add( "\tFailed to evaluate cell " +
|
failureMessages.add( "\tFailed to evaluate cell " +
|
||||||
result.getCellName() + ". It evaluated to " +
|
result.getCellName() + ". It evaluated to " +
|
||||||
result.getReturnValue() + " when the value of " +
|
result.getReturnValue() + " when the value of " +
|
||||||
@ -183,7 +183,7 @@ public class ExcelAntTest extends Task{
|
|||||||
passed = false;
|
passed = false;
|
||||||
failureCount++;
|
failureCount++;
|
||||||
|
|
||||||
if( eval.requiredToPass() == true ) {
|
if(eval.requiredToPass()) {
|
||||||
throw new BuildException( "\tFailed to evaluate cell " +
|
throw new BuildException( "\tFailed to evaluate cell " +
|
||||||
result.getCellName() + ". It evaluated to " +
|
result.getCellName() + ". It evaluated to " +
|
||||||
result.getReturnValue() + " when the value of " +
|
result.getReturnValue() + " when the value of " +
|
||||||
@ -200,15 +200,14 @@ public class ExcelAntTest extends Task{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( passed == false ) {
|
if(!passed) {
|
||||||
log( "Test named " + name + " failed because " + failureCount +
|
log( "Test named " + name + " failed because " + failureCount +
|
||||||
" of " + testCount + " evaluations failed to " +
|
" of " + testCount + " evaluations failed to " +
|
||||||
"evaluate correctly.",
|
"evaluate correctly.",
|
||||||
Project.MSG_ERR );
|
Project.MSG_ERR );
|
||||||
if( showFailureDetail == true && failureMessages.size() > 0 ) {
|
if(showFailureDetail && failureMessages.size() > 0 ) {
|
||||||
Iterator<String> failures = failureMessages.iterator();
|
for (String failureMessage : failureMessages) {
|
||||||
while( failures.hasNext() ) {
|
log(failureMessage, Project.MSG_ERR);
|
||||||
log( failures.next(), Project.MSG_ERR );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,11 +36,7 @@ import org.apache.poi.ss.usermodel.Workbook;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface IExcelAntWorkbookHandler {
|
public interface IExcelAntWorkbookHandler {
|
||||||
|
|
||||||
|
|
||||||
public void setWorkbook( Workbook workbook ) ;
|
public void setWorkbook( Workbook workbook ) ;
|
||||||
|
|
||||||
public void execute() ;
|
public void execute() ;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,8 @@ public class ExcelAntWorkbookUtil extends Typedef {
|
|||||||
* path of the Excel file. This constructor initializes a Workbook instance
|
* path of the Excel file. This constructor initializes a Workbook instance
|
||||||
* based on that file name.
|
* based on that file name.
|
||||||
*
|
*
|
||||||
* @param fName
|
* @param fName The fully qualified path of the Excel file.
|
||||||
|
* @throws BuildException If the workbook cannot be loaded.
|
||||||
*/
|
*/
|
||||||
protected ExcelAntWorkbookUtil(String fName) {
|
protected ExcelAntWorkbookUtil(String fName) {
|
||||||
excelFileName = fName;
|
excelFileName = fName;
|
||||||
@ -78,7 +79,7 @@ public class ExcelAntWorkbookUtil extends Typedef {
|
|||||||
/**
|
/**
|
||||||
* Constructs an instance based on a Workbook instance.
|
* Constructs an instance based on a Workbook instance.
|
||||||
*
|
*
|
||||||
* @param wb
|
* @param wb The Workbook to use for this instance.
|
||||||
*/
|
*/
|
||||||
protected ExcelAntWorkbookUtil(Workbook wb) {
|
protected ExcelAntWorkbookUtil(Workbook wb) {
|
||||||
workbook = wb;
|
workbook = wb;
|
||||||
@ -86,7 +87,8 @@ public class ExcelAntWorkbookUtil extends Typedef {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the member variable workbook based on the fileName variable.
|
* Loads the member variable workbook based on the fileName variable.
|
||||||
* @return
|
* @return The opened Workbook-instance
|
||||||
|
* @throws BuildException If the workbook cannot be loaded.
|
||||||
*/
|
*/
|
||||||
private Workbook loadWorkbook() {
|
private Workbook loadWorkbook() {
|
||||||
|
|
||||||
|
@ -40,15 +40,16 @@ public final class ExcelAntWorkbookUtilFactory {
|
|||||||
* Using the fileName, check the internal map to see if an instance
|
* Using the fileName, check the internal map to see if an instance
|
||||||
* of the WorkbookUtil exists. If not, then add an instance to the map.
|
* of the WorkbookUtil exists. If not, then add an instance to the map.
|
||||||
*
|
*
|
||||||
* @param fileName
|
* @param fileName The filename to use as key to look for the ExcelAntWorkbookUtil.
|
||||||
* @return
|
* @return An instance of ExcelAntWorkbookUtil associated with the filename or
|
||||||
|
* a freshly instantiated one if none did exist before.
|
||||||
*/
|
*/
|
||||||
public static ExcelAntWorkbookUtil getInstance(String fileName) {
|
public static ExcelAntWorkbookUtil getInstance(String fileName) {
|
||||||
if(workbookUtilMap == null) {
|
if(workbookUtilMap == null) {
|
||||||
workbookUtilMap = new HashMap<String, ExcelAntWorkbookUtil>();
|
workbookUtilMap = new HashMap<String, ExcelAntWorkbookUtil>();
|
||||||
}
|
}
|
||||||
if(workbookUtilMap != null &&
|
|
||||||
workbookUtilMap.containsKey(fileName)) {
|
if(workbookUtilMap.containsKey(fileName)) {
|
||||||
return workbookUtilMap.get(fileName);
|
return workbookUtilMap.get(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,11 +61,12 @@ public class EscherClientAnchorRecord
|
|||||||
int size = 0;
|
int size = 0;
|
||||||
|
|
||||||
// Always find 4 two byte entries. Sometimes find 9
|
// Always find 4 two byte entries. Sometimes find 9
|
||||||
if (bytesRemaining == 4) // Word format only 4 bytes
|
/*if (bytesRemaining == 4) // Word format only 4 bytes
|
||||||
{
|
{
|
||||||
// Not sure exactly what the format is quite yet, likely a reference to a PLC
|
// Not sure exactly what the format is quite yet, likely a reference to a PLC
|
||||||
}
|
}
|
||||||
else
|
else */
|
||||||
|
if (bytesRemaining != 4) // Word format only 4 bytes
|
||||||
{
|
{
|
||||||
field_1_flag = LittleEndian.getShort( data, pos + size ); size += 2;
|
field_1_flag = LittleEndian.getShort( data, pos + size ); size += 2;
|
||||||
field_2_col1 = LittleEndian.getShort( data, pos + size ); size += 2;
|
field_2_col1 = LittleEndian.getShort( data, pos + size ); size += 2;
|
||||||
@ -157,20 +158,18 @@ public class EscherClientAnchorRecord
|
|||||||
@Override
|
@Override
|
||||||
public String toXml(String tab) {
|
public String toXml(String tab) {
|
||||||
String extraData = HexDump.dump(this.remainingData, 0, 0).trim();
|
String extraData = HexDump.dump(this.remainingData, 0, 0).trim();
|
||||||
StringBuilder builder = new StringBuilder();
|
return tab + formatXmlRecordHeader(getClass().getSimpleName(), HexDump.toHex(getRecordId()), HexDump.toHex(getVersion()), HexDump.toHex(getInstance())) +
|
||||||
builder.append(tab).append(formatXmlRecordHeader(getClass().getSimpleName(), HexDump.toHex(getRecordId()), HexDump.toHex(getVersion()), HexDump.toHex(getInstance())))
|
tab + "\t" + "<Flag>" + field_1_flag + "</Flag>\n" +
|
||||||
.append(tab).append("\t").append("<Flag>").append(field_1_flag).append("</Flag>\n")
|
tab + "\t" + "<Col1>" + field_2_col1 + "</Col1>\n" +
|
||||||
.append(tab).append("\t").append("<Col1>").append(field_2_col1).append("</Col1>\n")
|
tab + "\t" + "<DX1>" + field_3_dx1 + "</DX1>\n" +
|
||||||
.append(tab).append("\t").append("<DX1>").append(field_3_dx1).append("</DX1>\n")
|
tab + "\t" + "<Row1>" + field_4_row1 + "</Row1>\n" +
|
||||||
.append(tab).append("\t").append("<Row1>").append(field_4_row1).append("</Row1>\n")
|
tab + "\t" + "<DY1>" + field_5_dy1 + "</DY1>\n" +
|
||||||
.append(tab).append("\t").append("<DY1>").append(field_5_dy1).append("</DY1>\n")
|
tab + "\t" + "<Col2>" + field_6_col2 + "</Col2>\n" +
|
||||||
.append(tab).append("\t").append("<Col2>").append(field_6_col2).append("</Col2>\n")
|
tab + "\t" + "<DX2>" + field_7_dx2 + "</DX2>\n" +
|
||||||
.append(tab).append("\t").append("<DX2>").append(field_7_dx2).append("</DX2>\n")
|
tab + "\t" + "<Row2>" + field_8_row2 + "</Row2>\n" +
|
||||||
.append(tab).append("\t").append("<Row2>").append(field_8_row2).append("</Row2>\n")
|
tab + "\t" + "<DY2>" + field_9_dy2 + "</DY2>\n" +
|
||||||
.append(tab).append("\t").append("<DY2>").append(field_9_dy2).append("</DY2>\n")
|
tab + "\t" + "<ExtraData>" + extraData + "</ExtraData>\n" +
|
||||||
.append(tab).append("\t").append("<ExtraData>").append(extraData).append("</ExtraData>\n");
|
tab + "</" + getClass().getSimpleName() + ">\n";
|
||||||
builder.append(tab).append("</").append(getClass().getSimpleName()).append(">\n");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -179,9 +179,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
|
|||||||
* used internally to set the properties given a Sheet object
|
* used internally to set the properties given a Sheet object
|
||||||
*/
|
*/
|
||||||
private void setPropertiesFromSheet(InternalSheet sheet) {
|
private void setPropertiesFromSheet(InternalSheet sheet) {
|
||||||
|
|
||||||
RowRecord row = sheet.getNextRow();
|
RowRecord row = sheet.getNextRow();
|
||||||
boolean rowRecordsAlreadyPresent = row != null;
|
|
||||||
|
|
||||||
while (row != null) {
|
while (row != null) {
|
||||||
createRowFromRecord(row);
|
createRowFromRecord(row);
|
||||||
@ -767,7 +765,6 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
|
|||||||
/**
|
/**
|
||||||
* Verify that none of the merged regions intersect a multi-cell array formula in this sheet
|
* Verify that none of the merged regions intersect a multi-cell array formula in this sheet
|
||||||
*
|
*
|
||||||
* @param region
|
|
||||||
* @throws IllegalStateException if candidate region intersects an existing array formula in this sheet
|
* @throws IllegalStateException if candidate region intersects an existing array formula in this sheet
|
||||||
*/
|
*/
|
||||||
private void checkForMergedRegionsIntersectingArrayFormulas() {
|
private void checkForMergedRegionsIntersectingArrayFormulas() {
|
||||||
@ -1451,10 +1448,10 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
|
|||||||
* <p/>
|
* <p/>
|
||||||
* TODO: MODE , this is only row specific
|
* TODO: MODE , this is only row specific
|
||||||
*
|
*
|
||||||
* @param startRow
|
* @param startRow the start-index of the rows to shift, zero-based
|
||||||
* @param endRow
|
* @param endRow the end-index of the rows to shift, zero-based
|
||||||
* @param n
|
* @param n how far to shift, negative to shift up
|
||||||
* @param isRow
|
* @param isRow unused, kept for backwards compatibility
|
||||||
*/
|
*/
|
||||||
protected void shiftMerged(int startRow, int endRow, int n, boolean isRow) {
|
protected void shiftMerged(int startRow, int endRow, int n, boolean isRow) {
|
||||||
List<CellRangeAddress> shiftedRegions = new ArrayList<CellRangeAddress>();
|
List<CellRangeAddress> shiftedRegions = new ArrayList<CellRangeAddress>();
|
||||||
@ -1483,10 +1480,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//read so it doesn't get shifted again
|
//read so it doesn't get shifted again
|
||||||
Iterator<CellRangeAddress> iterator = shiftedRegions.iterator();
|
for (CellRangeAddress region : shiftedRegions) {
|
||||||
while (iterator.hasNext()) {
|
|
||||||
CellRangeAddress region = iterator.next();
|
|
||||||
|
|
||||||
this.addMergedRegion(region);
|
this.addMergedRegion(region);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1942,7 +1936,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
|
|||||||
/**
|
/**
|
||||||
* Removes a page break at the indicated column
|
* Removes a page break at the indicated column
|
||||||
*
|
*
|
||||||
* @param column
|
* @param column The index of the column for which to remove a page-break, zero-based
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void removeColumnBreak(int column) {
|
public void removeColumnBreak(int column) {
|
||||||
@ -1952,7 +1946,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
|
|||||||
/**
|
/**
|
||||||
* Runs a bounds check for row numbers
|
* Runs a bounds check for row numbers
|
||||||
*
|
*
|
||||||
* @param row
|
* @param row the index of the row to validate, zero-based
|
||||||
*/
|
*/
|
||||||
protected void validateRow(int row) {
|
protected void validateRow(int row) {
|
||||||
int maxrow = SpreadsheetVersion.EXCEL97.getLastRowIndex();
|
int maxrow = SpreadsheetVersion.EXCEL97.getLastRowIndex();
|
||||||
@ -1963,7 +1957,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
|
|||||||
/**
|
/**
|
||||||
* Runs a bounds check for column numbers
|
* Runs a bounds check for column numbers
|
||||||
*
|
*
|
||||||
* @param column
|
* @param column the index of the column to validate, zero-based
|
||||||
*/
|
*/
|
||||||
protected void validateColumn(int column) {
|
protected void validateColumn(int column) {
|
||||||
int maxcol = SpreadsheetVersion.EXCEL97.getLastColumnIndex();
|
int maxcol = SpreadsheetVersion.EXCEL97.getLastColumnIndex();
|
||||||
@ -1980,8 +1974,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
|
|||||||
|
|
||||||
EscherAggregate r = (EscherAggregate) getSheet().findFirstRecordBySid(EscherAggregate.sid);
|
EscherAggregate r = (EscherAggregate) getSheet().findFirstRecordBySid(EscherAggregate.sid);
|
||||||
List<EscherRecord> escherRecords = r.getEscherRecords();
|
List<EscherRecord> escherRecords = r.getEscherRecords();
|
||||||
for (Iterator<EscherRecord> iterator = escherRecords.iterator(); iterator.hasNext(); ) {
|
for (EscherRecord escherRecord : escherRecords) {
|
||||||
EscherRecord escherRecord = iterator.next();
|
|
||||||
if (fat) {
|
if (fat) {
|
||||||
pw.println(escherRecord.toString());
|
pw.println(escherRecord.toString());
|
||||||
} else {
|
} else {
|
||||||
@ -2013,8 +2006,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Grab our aggregate record, and wire it up
|
// Grab our aggregate record, and wire it up
|
||||||
EscherAggregate agg = (EscherAggregate) _sheet.findFirstRecordBySid(EscherAggregate.sid);
|
return (EscherAggregate) _sheet.findFirstRecordBySid(EscherAggregate.sid);
|
||||||
return agg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2043,7 +2035,6 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private HSSFPatriarch getPatriarch(boolean createIfMissing) {
|
private HSSFPatriarch getPatriarch(boolean createIfMissing) {
|
||||||
HSSFPatriarch patriarch = null;
|
|
||||||
if (_patriarch != null) {
|
if (_patriarch != null) {
|
||||||
return _patriarch;
|
return _patriarch;
|
||||||
}
|
}
|
||||||
@ -2063,7 +2054,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
|
|||||||
if (createIfMissing) {
|
if (createIfMissing) {
|
||||||
pos = _sheet.aggregateDrawingRecords(dm, true);
|
pos = _sheet.aggregateDrawingRecords(dm, true);
|
||||||
agg = (EscherAggregate) _sheet.getRecords().get(pos);
|
agg = (EscherAggregate) _sheet.getRecords().get(pos);
|
||||||
patriarch = new HSSFPatriarch(this, agg);
|
HSSFPatriarch patriarch = new HSSFPatriarch(this, agg);
|
||||||
patriarch.afterCreate();
|
patriarch.afterCreate();
|
||||||
return patriarch;
|
return patriarch;
|
||||||
} else {
|
} else {
|
||||||
@ -2204,14 +2195,13 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
|
|||||||
/**
|
/**
|
||||||
* Get a Hyperlink in this sheet anchored at row, column
|
* Get a Hyperlink in this sheet anchored at row, column
|
||||||
*
|
*
|
||||||
* @param row
|
* @param row The index of the row of the hyperlink, zero-based
|
||||||
* @param column
|
* @param column the index of the column of the hyperlink, zero-based
|
||||||
* @return hyperlink if there is a hyperlink anchored at row, column; otherwise returns null
|
* @return hyperlink if there is a hyperlink anchored at row, column; otherwise returns null
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public HSSFHyperlink getHyperlink(int row, int column) {
|
public HSSFHyperlink getHyperlink(int row, int column) {
|
||||||
for (Iterator<RecordBase> it = _sheet.getRecords().iterator(); it.hasNext(); ) {
|
for (RecordBase rec : _sheet.getRecords()) {
|
||||||
RecordBase rec = it.next();
|
|
||||||
if (rec instanceof HyperlinkRecord) {
|
if (rec instanceof HyperlinkRecord) {
|
||||||
HyperlinkRecord link = (HyperlinkRecord) rec;
|
HyperlinkRecord link = (HyperlinkRecord) rec;
|
||||||
if (link.getFirstColumn() == column && link.getFirstRow() == row) {
|
if (link.getFirstColumn() == column && link.getFirstRow() == row) {
|
||||||
@ -2230,8 +2220,7 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
|
|||||||
@Override
|
@Override
|
||||||
public List<HSSFHyperlink> getHyperlinkList() {
|
public List<HSSFHyperlink> getHyperlinkList() {
|
||||||
final List<HSSFHyperlink> hyperlinkList = new ArrayList<HSSFHyperlink>();
|
final List<HSSFHyperlink> hyperlinkList = new ArrayList<HSSFHyperlink>();
|
||||||
for (Iterator<RecordBase> it = _sheet.getRecords().iterator(); it.hasNext(); ) {
|
for (RecordBase rec : _sheet.getRecords()) {
|
||||||
RecordBase rec = it.next();
|
|
||||||
if (rec instanceof HyperlinkRecord) {
|
if (rec instanceof HyperlinkRecord) {
|
||||||
HyperlinkRecord link = (HyperlinkRecord) rec;
|
HyperlinkRecord link = (HyperlinkRecord) rec;
|
||||||
hyperlinkList.add(new HSSFHyperlink(link));
|
hyperlinkList.add(new HSSFHyperlink(link));
|
||||||
@ -2586,16 +2575,14 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
|
|||||||
if (areaPtg.getFirstColumn() == 0
|
if (areaPtg.getFirstColumn() == 0
|
||||||
&& areaPtg.getLastColumn() == maxColIndex) {
|
&& areaPtg.getLastColumn() == maxColIndex) {
|
||||||
if (rows) {
|
if (rows) {
|
||||||
CellRangeAddress rowRange = new CellRangeAddress(
|
return new CellRangeAddress(
|
||||||
areaPtg.getFirstRow(), areaPtg.getLastRow(), -1, -1);
|
areaPtg.getFirstRow(), areaPtg.getLastRow(), -1, -1);
|
||||||
return rowRange;
|
|
||||||
}
|
}
|
||||||
} else if (areaPtg.getFirstRow() == 0
|
} else if (areaPtg.getFirstRow() == 0
|
||||||
&& areaPtg.getLastRow() == maxRowIndex) {
|
&& areaPtg.getLastRow() == maxRowIndex) {
|
||||||
if (!rows) {
|
if (!rows) {
|
||||||
CellRangeAddress columnRange = new CellRangeAddress(-1, -1,
|
return new CellRangeAddress(-1, -1,
|
||||||
areaPtg.getFirstColumn(), areaPtg.getLastColumn());
|
areaPtg.getFirstColumn(), areaPtg.getLastColumn());
|
||||||
return columnRange;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ package org.apache.poi.ss.usermodel;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.apache.poi.hssf.util.HSSFColor;
|
import org.apache.poi.hssf.util.HSSFColor;
|
||||||
import org.apache.poi.ss.usermodel.Color;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a XSSF-style color (based on either a
|
* Represents a XSSF-style color (based on either a
|
||||||
@ -82,13 +81,11 @@ public abstract class ExtendedColor implements Color {
|
|||||||
public abstract void setRGB(byte[] rgb);
|
public abstract void setRGB(byte[] rgb);
|
||||||
|
|
||||||
protected byte[] getRGBOrARGB() {
|
protected byte[] getRGBOrARGB() {
|
||||||
byte[] rgb = null;
|
|
||||||
|
|
||||||
if (isIndexed() && getIndex() > 0) {
|
if (isIndexed() && getIndex() > 0) {
|
||||||
int indexNum = getIndex();
|
int indexNum = getIndex();
|
||||||
HSSFColor indexed = HSSFColor.getIndexHash().get(indexNum);
|
HSSFColor indexed = HSSFColor.getIndexHash().get(indexNum);
|
||||||
if (indexed != null) {
|
if (indexed != null) {
|
||||||
rgb = new byte[3];
|
byte[] rgb = new byte[3];
|
||||||
rgb[0] = (byte) indexed.getTriplet()[0];
|
rgb[0] = (byte) indexed.getTriplet()[0];
|
||||||
rgb[1] = (byte) indexed.getTriplet()[1];
|
rgb[1] = (byte) indexed.getTriplet()[1];
|
||||||
rgb[2] = (byte) indexed.getTriplet()[2];
|
rgb[2] = (byte) indexed.getTriplet()[2];
|
||||||
@ -97,8 +94,7 @@ public abstract class ExtendedColor implements Color {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Grab the colour
|
// Grab the colour
|
||||||
rgb = getStoredRBG();
|
return getStoredRBG();
|
||||||
return rgb;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -125,11 +121,12 @@ public abstract class ExtendedColor implements Color {
|
|||||||
* Works for both regular and indexed colours.
|
* Works for both regular and indexed colours.
|
||||||
*/
|
*/
|
||||||
public String getARGBHex() {
|
public String getARGBHex() {
|
||||||
StringBuffer sb = new StringBuffer();
|
|
||||||
byte[] rgb = getARGB();
|
byte[] rgb = getARGB();
|
||||||
if(rgb == null) {
|
if(rgb == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
for(byte c : rgb) {
|
for(byte c : rgb) {
|
||||||
int i = c & 0xff;
|
int i = c & 0xff;
|
||||||
String cs = Integer.toHexString(i);
|
String cs = Integer.toHexString(i);
|
||||||
|
@ -16,30 +16,15 @@
|
|||||||
==================================================================== */
|
==================================================================== */
|
||||||
package org.apache.poi;
|
package org.apache.poi;
|
||||||
|
|
||||||
import java.io.Closeable;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.io.PushbackInputStream;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||||
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
|
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
|
||||||
import org.apache.poi.openxml4j.opc.OPCPackage;
|
import org.apache.poi.openxml4j.opc.*;
|
||||||
import org.apache.poi.openxml4j.opc.PackageAccess;
|
|
||||||
import org.apache.poi.openxml4j.opc.PackagePart;
|
|
||||||
import org.apache.poi.openxml4j.opc.PackageRelationship;
|
|
||||||
import org.apache.poi.openxml4j.opc.PackageRelationshipCollection;
|
|
||||||
import org.apache.poi.poifs.common.POIFSConstants;
|
|
||||||
import org.apache.poi.poifs.filesystem.DocumentFactoryHelper;
|
import org.apache.poi.poifs.filesystem.DocumentFactoryHelper;
|
||||||
import org.apache.poi.util.IOUtils;
|
|
||||||
import org.apache.xmlbeans.impl.common.SystemCache;
|
import org.apache.xmlbeans.impl.common.SystemCache;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
public abstract class POIXMLDocument extends POIXMLDocumentPart implements Closeable {
|
public abstract class POIXMLDocument extends POIXMLDocumentPart implements Closeable {
|
||||||
public static final String DOCUMENT_CREATOR = "Apache POI";
|
public static final String DOCUMENT_CREATOR = "Apache POI";
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ public class POIXMLPropertiesTextExtractor extends POIXMLTextExtractor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (property.isSetArray()) {
|
/*else if (property.isSetArray()) {
|
||||||
// TODO Fetch the array values and output
|
// TODO Fetch the array values and output
|
||||||
}
|
}
|
||||||
else if (property.isSetVector()) {
|
else if (property.isSetVector()) {
|
||||||
@ -245,12 +245,9 @@ public class POIXMLPropertiesTextExtractor extends POIXMLTextExtractor {
|
|||||||
}
|
}
|
||||||
else if (property.isSetStorage() || property.isSetOstorage()) {
|
else if (property.isSetStorage() || property.isSetOstorage()) {
|
||||||
// TODO Decode, if possible
|
// TODO Decode, if possible
|
||||||
}
|
}*/
|
||||||
|
|
||||||
text.append(
|
text.append(property.getName()).append(" = ").append(val).append("\n");
|
||||||
property.getName() +
|
|
||||||
" = " + val + "\n"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return text.toString();
|
return text.toString();
|
||||||
|
@ -355,12 +355,12 @@ public class ExtractorFactory {
|
|||||||
* {@link POITextExtractor} for each embedded file.
|
* {@link POITextExtractor} for each embedded file.
|
||||||
*/
|
*/
|
||||||
public static POITextExtractor[] getEmbededDocsTextExtractors(POIOLE2TextExtractor ext) throws IOException, OpenXML4JException, XmlException {
|
public static POITextExtractor[] getEmbededDocsTextExtractors(POIOLE2TextExtractor ext) throws IOException, OpenXML4JException, XmlException {
|
||||||
// All the embded directories we spotted
|
// All the embedded directories we spotted
|
||||||
ArrayList<Entry> dirs = new ArrayList<Entry>();
|
ArrayList<Entry> dirs = new ArrayList<Entry>();
|
||||||
// For anything else not directly held in as a POIFS directory
|
// For anything else not directly held in as a POIFS directory
|
||||||
ArrayList<InputStream> nonPOIFS = new ArrayList<InputStream>();
|
ArrayList<InputStream> nonPOIFS = new ArrayList<InputStream>();
|
||||||
|
|
||||||
// Find all the embeded directories
|
// Find all the embedded directories
|
||||||
DirectoryEntry root = ext.getRoot();
|
DirectoryEntry root = ext.getRoot();
|
||||||
if(root == null) {
|
if(root == null) {
|
||||||
throw new IllegalStateException("The extractor didn't know which POIFS it came from!");
|
throw new IllegalStateException("The extractor didn't know which POIFS it came from!");
|
||||||
@ -390,7 +390,7 @@ public class ExtractorFactory {
|
|||||||
} catch(FileNotFoundException e) {
|
} catch(FileNotFoundException e) {
|
||||||
// ignored here
|
// ignored here
|
||||||
}
|
}
|
||||||
} else if(ext instanceof PowerPointExtractor) {
|
//} else if(ext instanceof PowerPointExtractor) {
|
||||||
// Tricky, not stored directly in poifs
|
// Tricky, not stored directly in poifs
|
||||||
// TODO
|
// TODO
|
||||||
} else if(ext instanceof OutlookTextExtactor) {
|
} else if(ext instanceof OutlookTextExtactor) {
|
||||||
@ -434,12 +434,12 @@ public class ExtractorFactory {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array of text extractors, one for each of
|
* Returns an array of text extractors, one for each of
|
||||||
* the embeded documents in the file (if there are any).
|
* the embedded documents in the file (if there are any).
|
||||||
* If there are no embeded documents, you'll get back an
|
* If there are no embedded documents, you'll get back an
|
||||||
* empty array. Otherwise, you'll get one open
|
* empty array. Otherwise, you'll get one open
|
||||||
* {@link POITextExtractor} for each embeded file.
|
* {@link POITextExtractor} for each embedded file.
|
||||||
*/
|
*/
|
||||||
public static POITextExtractor[] getEmbededDocsTextExtractors(POIXMLTextExtractor ext) {
|
public static POITextExtractor[] getEmbededDocsTextExtractors(@SuppressWarnings("UnusedParameters") POIXMLTextExtractor ext) {
|
||||||
throw new IllegalStateException("Not yet supported");
|
throw new IllegalStateException("Not yet supported");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,10 +77,6 @@ public final class TestPOIXMLProperties {
|
|||||||
ctProps.setApplication(application);
|
ctProps.setApplication(application);
|
||||||
ctProps.setAppVersion(appVersion);
|
ctProps.setAppVersion(appVersion);
|
||||||
|
|
||||||
ctProps = null;
|
|
||||||
properties = null;
|
|
||||||
props = null;
|
|
||||||
|
|
||||||
XSSFWorkbook newWorkbook =
|
XSSFWorkbook newWorkbook =
|
||||||
XSSFTestDataSamples.writeOutAndReadBack(workbook);
|
XSSFTestDataSamples.writeOutAndReadBack(workbook);
|
||||||
workbook.close();
|
workbook.close();
|
||||||
|
@ -134,7 +134,7 @@ public abstract class BitMaskTextProp extends TextProp implements Cloneable {
|
|||||||
int i=0;
|
int i=0;
|
||||||
for (int mask : subPropMasks) {
|
for (int mask : subPropMasks) {
|
||||||
if (!subPropMatches[i] && (val & mask) != 0) {
|
if (!subPropMatches[i] && (val & mask) != 0) {
|
||||||
sb.append(subPropNames[i]+",");
|
sb.append(subPropNames[i]).append(",");
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -110,12 +110,6 @@ public class HwmfGraphics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected BasicStroke getStroke() {
|
protected BasicStroke getStroke() {
|
||||||
Rectangle2D view = prop.getViewport();
|
|
||||||
Rectangle2D win = prop.getWindow();
|
|
||||||
if (view == null) {
|
|
||||||
view = win;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: fix line width calculation
|
// TODO: fix line width calculation
|
||||||
float width = (float)prop.getPenWidth();
|
float width = (float)prop.getPenWidth();
|
||||||
if (width == 0) {
|
if (width == 0) {
|
||||||
@ -335,10 +329,10 @@ public class HwmfGraphics {
|
|||||||
int len = text.length();
|
int len = text.length();
|
||||||
AttributedString as = new AttributedString(text);
|
AttributedString as = new AttributedString(text);
|
||||||
if (dx == null || dx.length == 0) {
|
if (dx == null || dx.length == 0) {
|
||||||
addAttributes(as, font, 0, len);
|
addAttributes(as, font);
|
||||||
} else {
|
} else {
|
||||||
for (int i=0; i<len; i++) {
|
for (int i=0; i<len; i++) {
|
||||||
addAttributes(as, font, i, i+1);
|
addAttributes(as, font);
|
||||||
// Tracking works as a prefix/advance space on characters whereas
|
// Tracking works as a prefix/advance space on characters whereas
|
||||||
// dx[...] is the complete width of the current char
|
// dx[...] is the complete width of the current char
|
||||||
// therefore we need to add the additional/suffix width to the next char
|
// therefore we need to add the additional/suffix width to the next char
|
||||||
@ -368,7 +362,7 @@ public class HwmfGraphics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addAttributes(AttributedString as, HwmfFont font, int start, int end) {
|
private void addAttributes(AttributedString as, HwmfFont font) {
|
||||||
DrawFontManager fontHandler = (DrawFontManager)graphicsCtx.getRenderingHint(Drawable.FONT_HANDLER);
|
DrawFontManager fontHandler = (DrawFontManager)graphicsCtx.getRenderingHint(Drawable.FONT_HANDLER);
|
||||||
String fontFamily = null;
|
String fontFamily = null;
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -17,26 +17,8 @@
|
|||||||
|
|
||||||
package org.apache.poi.ss.usermodel;
|
package org.apache.poi.ss.usermodel;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.junit.Assert.assertNull;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
|
|
||||||
import java.awt.font.FontRenderContext;
|
|
||||||
import java.awt.font.TextAttribute;
|
|
||||||
import java.awt.font.TextLayout;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.text.AttributedString;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import java.awt.geom.Rectangle2D;
|
|
||||||
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
import org.apache.poi.hssf.util.PaneInformation;
|
import org.apache.poi.hssf.util.PaneInformation;
|
||||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
||||||
import org.apache.poi.ss.ITestDataProvider;
|
import org.apache.poi.ss.ITestDataProvider;
|
||||||
import org.apache.poi.ss.SpreadsheetVersion;
|
import org.apache.poi.ss.SpreadsheetVersion;
|
||||||
import org.apache.poi.ss.util.CellRangeAddress;
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
@ -47,6 +29,17 @@ import org.junit.Assume;
|
|||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.awt.font.FontRenderContext;
|
||||||
|
import java.awt.font.TextAttribute;
|
||||||
|
import java.awt.font.TextLayout;
|
||||||
|
import java.awt.geom.Rectangle2D;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.text.AttributedString;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A base class for bugzilla issues that can be described in terms of common ss interfaces.
|
* A base class for bugzilla issues that can be described in terms of common ss interfaces.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user