View | Details | Raw Unified | Return to bug 61033
Collapse All | Expand All

(-)a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java (+21 lines)
Lines 2269-2274 public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss Link Here
2269
        return recalc != null && recalc.getEngineId() != 0;
2269
        return recalc != null && recalc.getEngineId() != 0;
2270
    }
2270
    }
2271
2271
2272
    /**
2273
     * Whether a call to {@link HSSFCell#setCellFormula(String)} will validate the formula or not.
2274
     *
2275
     * @param value true if the application will validate the formula is correct
2276
     * @since 3.17
2277
     */
2278
    @Override
2279
    public void setCellFormulaValidation(final boolean value) {
2280
        // currently {@link HSSFCell#setCellFormula(String)} does no validation anyway, ignore
2281
    }
2282
2283
    /**
2284
     * Whether a call to {@link HSSFCell#setCellFormula(String)} will validate the formula or not.
2285
     *
2286
     * @since 3.17
2287
     */
2288
    @Override
2289
    public boolean getCellFormulaValidation() {
2290
        return false;
2291
    }
2292
2272
	/**
2293
	/**
2273
	 * Changes an external referenced file to another file.
2294
	 * Changes an external referenced file to another file.
2274
	 * A formula in Excel which references a cell in another file is saved in two parts:
2295
	 * A formula in Excel which references a cell in another file is saved in two parts:
(-)a/src/java/org/apache/poi/ss/usermodel/Workbook.java (+15 lines)
Lines 686-689 public interface Workbook extends Closeable, Iterable<Sheet> { Link Here
686
     * @throws IOException if the object can't be embedded
686
     * @throws IOException if the object can't be embedded
687
     */
687
     */
688
    int addOlePackage(byte[] oleData, String label, String fileName, String command) throws IOException;
688
    int addOlePackage(byte[] oleData, String label, String fileName, String command) throws IOException;
689
690
    /**
691
     * Whether a call to {@link Cell#setCellFormula(String)} will validate the formula or not.
692
     *
693
     * @param value true if the application will validate the formula is correct
694
     * @since 3.17
695
     */
696
    void setCellFormulaValidation(boolean value);
697
698
    /**
699
     * Whether a call to {@link Cell#setCellFormula(String)} will validate the formula or not.
700
     *
701
     * @since 3.17
702
     */
703
    boolean getCellFormulaValidation();
689
}
704
}
(-)a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java (-1 / +22 lines)
Lines 1363-1368 public class SXSSFWorkbook implements Workbook { Link Here
1363
    public int addOlePackage(byte[] oleData, String label, String fileName, String command) throws IOException {
1363
    public int addOlePackage(byte[] oleData, String label, String fileName, String command) throws IOException {
1364
        return _wb.addOlePackage(oleData, label, fileName, command);
1364
        return _wb.addOlePackage(oleData, label, fileName, command);
1365
    }
1365
    }
1366
    
1366
1367
    /**
1368
     * Whether a call to {@link SXSSFCell#setCellFormula(String)} will validate the formula or not.
1369
     *
1370
     * @param value true if the application will validate the formula is correct
1371
     * @since 3.17
1372
     */
1373
    @Override
1374
    public void setCellFormulaValidation(final boolean value) {
1375
        // currently {@link SXSSFCell#setCellFormula(String)} does no validation anyway, ignore
1376
    }
1377
1378
    /**
1379
     * Whether a call to {@link SXSSFCell#setCellFormula(String)} will validate the formula or not.
1380
     *
1381
     * @since 3.17
1382
     */
1383
    @Override
1384
    public boolean getCellFormulaValidation() {
1385
        return false;
1386
    }
1387
1367
//end of interface implementation
1388
//end of interface implementation
1368
}
1389
}
(-)a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java (-3 / +5 lines)
Lines 561-569 public final class XSSFCell implements Cell { Link Here
561
            return;
561
            return;
562
        }
562
        }
563
563
564
        XSSFEvaluationWorkbook fpb = XSSFEvaluationWorkbook.create(wb);
564
        if(wb.getCellFormulaValidation()) {
565
        //validate through the FormulaParser
565
            XSSFEvaluationWorkbook fpb = XSSFEvaluationWorkbook.create(wb);
566
        FormulaParser.parse(formula, fpb, formulaType, wb.getSheetIndex(getSheet()), getRowIndex());
566
            //validate through the FormulaParser
567
            FormulaParser.parse(formula, fpb, formulaType, wb.getSheetIndex(getSheet()), getRowIndex());
568
        }
567
569
568
        CTCellFormula f = CTCellFormula.Factory.newInstance();
570
        CTCellFormula f = CTCellFormula.Factory.newInstance();
569
        f.setStringValue(formula);
571
        f.setStringValue(formula);
(-)a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java (-1 / +26 lines)
Lines 209-214 public class XSSFWorkbook extends POIXMLDocument implements Workbook { Link Here
209
    private MissingCellPolicy _missingCellPolicy = MissingCellPolicy.RETURN_NULL_AND_BLANK;
209
    private MissingCellPolicy _missingCellPolicy = MissingCellPolicy.RETURN_NULL_AND_BLANK;
210
210
211
    /**
211
    /**
212
     * Whether a call to {@link XSSFCell#setCellFormula(String)} will validate the formula or not.
213
     */
214
    private boolean cellFormulaValidation = true;
215
216
    /**
212
     * array of pictures for this workbook
217
     * array of pictures for this workbook
213
     */
218
     */
214
    private List<XSSFPictureData> pictures;
219
    private List<XSSFPictureData> pictures;
Lines 2470-2473 public class XSSFWorkbook extends POIXMLDocument implements Workbook { Link Here
2470
2475
2471
        return oleId;
2476
        return oleId;
2472
    }
2477
    }
2478
2479
    /**
2480
     * Whether a call to {@link XSSFCell#setCellFormula(String)} will validate the formula or not.
2481
     *
2482
     * @param value true if the application will validate the formula is correct
2483
     * @since 3.17
2484
     */
2485
    @Override
2486
    public void setCellFormulaValidation(final boolean value) {
2487
        this.cellFormulaValidation = value;
2488
    }
2489
2490
    /**
2491
     * Whether a call to {@link XSSFCell#setCellFormula(String)} will validate the formula or not.
2492
     *
2493
     * @since 3.17
2494
     */
2495
    @Override
2496
    public boolean getCellFormulaValidation() {
2497
        return this.cellFormulaValidation;
2498
    }
2473
}
2499
}
2474
- 

Return to bug 61033