ASF Bugzilla – Attachment 9541 Details for
Bug 25457
[PATCH] Formula Parser doesn't allow ' around worksheet names and others
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
UPDATED: patch for single-ticks around worksheet names against REL_2_BRANCH
poi.patch (text/plain), 4.87 KB, created by
Peter M. Murray
on 2003-12-12 16:07:31 UTC
(
hide
)
Description:
UPDATED: patch for single-ticks around worksheet names against REL_2_BRANCH
Filename:
MIME Type:
Creator:
Peter M. Murray
Created:
2003-12-12 16:07:31 UTC
Size:
4.87 KB
patch
obsolete
>Index: src/java/org/apache/poi/hssf/model/FormulaParser.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/java/org/apache/poi/hssf/model/FormulaParser.java,v >retrieving revision 1.13.2.1 >diff -u -r1.13.2.1 FormulaParser.java >--- src/java/org/apache/poi/hssf/model/FormulaParser.java 23 Aug 2003 19:40:04 -0000 1.13.2.1 >+++ src/java/org/apache/poi/hssf/model/FormulaParser.java 12 Dec 2003 16:05:22 -0000 >@@ -80,6 +80,7 @@ > * @author Andrew C. oliver (acoliver at apache dot org) > * @author Eric Ladner (eladner at goldinc dot com) > * @author Cameron Riley (criley at ekmail.com) >+ * @author Peter M. Murray (pete at quantrix dot com) - added ' handling to worksheet references > */ > public class FormulaParser { > >@@ -228,13 +229,31 @@ > /** Get an Identifier */ > private String GetName() { > StringBuffer Token = new StringBuffer(); >- if (!IsAlpha(look)) { >+ if (!IsAlpha(look) && look != '\'') { > Expected("Name"); > } >- while (IsAlNum(look)) { >- Token = Token.append(Character.toUpperCase(look)); >- GetChar(); >- } >+ if(look == '\'') >+ { >+ Match('\''); >+ boolean done = look == '\''; >+ while(!done) >+ { >+ Token.append(Character.toUpperCase(look)); >+ GetChar(); >+ if(look == '\'') >+ { >+ Match('\''); >+ done = look != '\''; >+ } >+ } >+ } >+ else >+ { >+ while (IsAlNum(look)) { >+ Token.append(Character.toUpperCase(look)); >+ GetChar(); >+ } >+ } > SkipWhite(); > return Token.toString(); > } >@@ -483,7 +502,7 @@ > Expression(); > Match(')'); > tokens.add(new ParenthesisPtg()); >- } else if (IsAlpha(look)){ >+ } else if (IsAlpha(look) || look == '\''){ > Ident(); > } else if(look == '"') { > StringLiteral(); >@@ -725,7 +744,7 @@ > private void setRootLevelRVA(Node n, int formulaType) { > //Pg 16, excelfileformat.pdf @ openoffice.org > Ptg p = (Ptg) n.getValue(); >- if (formulaType == this.FORMULA_TYPE_NAMEDRANGE) { >+ if (formulaType == FormulaParser.FORMULA_TYPE_NAMEDRANGE) { > if (p.getDefaultOperandClass() == Ptg.CLASS_REF) { > setClass(n,Ptg.CLASS_REF); > } else { >Index: src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java >=================================================================== >RCS file: /home/cvspublic/jakarta-poi/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java,v >retrieving revision 1.7.2.3 >diff -u -r1.7.2.3 TestFormulaParser.java >--- src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java 13 Oct 2003 16:42:17 -0000 1.7.2.3 >+++ src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java 12 Dec 2003 16:05:23 -0000 >@@ -55,7 +55,23 @@ > > import junit.framework.TestCase; > >-import org.apache.poi.hssf.record.formula.*; >+import org.apache.poi.hssf.record.formula.AbstractFunctionPtg; >+import org.apache.poi.hssf.record.formula.AddPtg; >+import org.apache.poi.hssf.record.formula.AttrPtg; >+import org.apache.poi.hssf.record.formula.BoolPtg; >+import org.apache.poi.hssf.record.formula.EqualPtg; >+import org.apache.poi.hssf.record.formula.FuncVarPtg; >+import org.apache.poi.hssf.record.formula.IntPtg; >+import org.apache.poi.hssf.record.formula.LessEqualPtg; >+import org.apache.poi.hssf.record.formula.LessThanPtg; >+import org.apache.poi.hssf.record.formula.NamePtg; >+import org.apache.poi.hssf.record.formula.NotEqualPtg; >+import org.apache.poi.hssf.record.formula.Ptg; >+import org.apache.poi.hssf.record.formula.StringPtg; >+import org.apache.poi.hssf.usermodel.HSSFCell; >+import org.apache.poi.hssf.usermodel.HSSFRow; >+import org.apache.poi.hssf.usermodel.HSSFSheet; >+import org.apache.poi.hssf.usermodel.HSSFWorkbook; > > /** > * Test the low level formula parser functionality. High level tests are to >@@ -312,6 +328,24 @@ > Ptg[] ptg = fp.getRPNPtg(); > assertTrue("first ptg is string",ptg[0] instanceof StringPtg); > assertTrue("second ptg is string",ptg[1] instanceof StringPtg); >+ } >+ >+ public void testWorksheetReferences() >+ { >+ HSSFWorkbook wb = new HSSFWorkbook(); >+ >+ wb.createSheet("NoQuotesNeeded"); >+ wb.createSheet("Quotes Needed Here &#$@"); >+ >+ HSSFSheet sheet = wb.createSheet("Test"); >+ HSSFRow row = sheet.createRow(0); >+ HSSFCell cell; >+ >+ cell = row.createCell((short)0); >+ cell.setCellFormula("NoQuotesNeeded!A1"); >+ >+ cell = row.createCell((short)1); >+ cell.setCellFormula("'Quotes Needed Here &#$@'!A1"); > } > > public static void main(String [] args) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 25457
:
9524
| 9541 |
9632