removed thread safety stuff. We still need to revisit how this is being
done. I dislike "currentBook" and would prefer some kind of context mechanism or directly passing the book to the PTGs etc. Perhaps a "PTGWorkbookContextInterface" that defines set/getWorkbook etc etc. PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352760 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d01b6e7db0
commit
8e92c6e9d1
@ -88,7 +88,7 @@ import org.apache.poi.util.POILogFactory;
|
|||||||
public class Workbook {
|
public class Workbook {
|
||||||
private static final int DEBUG = POILogger.DEBUG;
|
private static final int DEBUG = POILogger.DEBUG;
|
||||||
|
|
||||||
public static ThreadLocal currentBook = new ThreadLocal();
|
public static Workbook currentBook = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* constant used to set the "codepage" wherever "codepage" is set in records
|
* constant used to set the "codepage" wherever "codepage" is set in records
|
||||||
|
@ -289,7 +289,7 @@ public class Area3DPtg extends Ptg
|
|||||||
public String toFormulaString()
|
public String toFormulaString()
|
||||||
{
|
{
|
||||||
StringBuffer retval = new StringBuffer();
|
StringBuffer retval = new StringBuffer();
|
||||||
Object book = Workbook.currentBook.get();
|
Object book = Workbook.currentBook;
|
||||||
if (book != null) {
|
if (book != null) {
|
||||||
retval.append(((Workbook) book).findSheetNameFromExternSheet(this.field_1_index_extern_sheet));
|
retval.append(((Workbook) book).findSheetNameFromExternSheet(this.field_1_index_extern_sheet));
|
||||||
retval.append('!');
|
retval.append('!');
|
||||||
|
@ -107,8 +107,6 @@ public class FormulaParser {
|
|||||||
* later call the parse() method to return ptg list in rpn order
|
* later call the parse() method to return ptg list in rpn order
|
||||||
* then call the getRPNPtg() to retrive the parse results
|
* then call the getRPNPtg() to retrive the parse results
|
||||||
* This class is recommended only for single threaded use
|
* This class is recommended only for single threaded use
|
||||||
* The parse and getPRNPtg are internally synchronized for safety, thus
|
|
||||||
* while it is safe to use in a multithreaded environment, you will get long lock waits.
|
|
||||||
*/
|
*/
|
||||||
public FormulaParser(String formula, Workbook book){
|
public FormulaParser(String formula, Workbook book){
|
||||||
formulaString = formula;
|
formulaString = formula;
|
||||||
|
@ -192,7 +192,7 @@ public class Ref3DPtg extends Ptg {
|
|||||||
|
|
||||||
public String toFormulaString() {
|
public String toFormulaString() {
|
||||||
StringBuffer retval = new StringBuffer();
|
StringBuffer retval = new StringBuffer();
|
||||||
Object book = Workbook.currentBook.get();
|
Object book = Workbook.currentBook;
|
||||||
if (book != null) {
|
if (book != null) {
|
||||||
retval.append(((Workbook) book).findSheetNameFromExternSheet(this.field_1_index_extern_sheet));
|
retval.append(((Workbook) book).findSheetNameFromExternSheet(this.field_1_index_extern_sheet));
|
||||||
retval.append('!');
|
retval.append('!');
|
||||||
|
@ -693,7 +693,7 @@ public class HSSFCell
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setCellFormula(String formula) {
|
public void setCellFormula(String formula) {
|
||||||
Workbook.currentBook.set(book);
|
Workbook.currentBook=book;
|
||||||
if (formula==null) {
|
if (formula==null) {
|
||||||
setCellType(CELL_TYPE_BLANK,false);
|
setCellType(CELL_TYPE_BLANK,false);
|
||||||
} else {
|
} else {
|
||||||
@ -712,14 +712,14 @@ public class HSSFCell
|
|||||||
rec.pushExpressionToken(ptg[ k ]);
|
rec.pushExpressionToken(ptg[ k ]);
|
||||||
}
|
}
|
||||||
rec.setExpressionLength(( short ) size);
|
rec.setExpressionLength(( short ) size);
|
||||||
Workbook.currentBook.set(null);
|
Workbook.currentBook = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCellFormula() {
|
public String getCellFormula() {
|
||||||
Workbook.currentBook.set(book);
|
Workbook.currentBook=book;
|
||||||
String retval = FormulaParser.toFormulaString(((FormulaRecord)record).getParsedExpression());
|
String retval = FormulaParser.toFormulaString(((FormulaRecord)record).getParsedExpression());
|
||||||
Workbook.currentBook.set(null);
|
Workbook.currentBook=null;
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,14 +257,14 @@ public class HSSFName {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public String getReference() {
|
public String getReference() {
|
||||||
Workbook.currentBook.set(book);
|
Workbook.currentBook=book;
|
||||||
String result;
|
String result;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
result = name.getAreaReference();
|
result = name.getAreaReference();
|
||||||
|
|
||||||
Workbook.currentBook.set(null);
|
Workbook.currentBook=null;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user