From f597a1717ce7dda81a57b575f62f9d381a4b80d2 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Thu, 11 Feb 2016 15:13:01 +0000 Subject: [PATCH] Allow common tests to do auto-sizing even on SXSSF git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1729848 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/xssf/SXSSFITestDataProvider.java | 9 +++++++++ .../org/apache/poi/xssf/XSSFITestDataProvider.java | 4 ++++ .../org/apache/poi/hssf/HSSFITestDataProvider.java | 4 ++++ src/testcases/org/apache/poi/ss/ITestDataProvider.java | 7 +++++++ 4 files changed, 24 insertions(+) diff --git a/src/ooxml/testcases/org/apache/poi/xssf/SXSSFITestDataProvider.java b/src/ooxml/testcases/org/apache/poi/xssf/SXSSFITestDataProvider.java index 2e507d0821..04da561e04 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/SXSSFITestDataProvider.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/SXSSFITestDataProvider.java @@ -30,7 +30,9 @@ import org.apache.poi.POIDataSamples; import org.apache.poi.ss.ITestDataProvider; import org.apache.poi.ss.SpreadsheetVersion; import org.apache.poi.ss.usermodel.FormulaEvaluator; +import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.streaming.SXSSFSheet; import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator; import org.apache.poi.xssf.usermodel.XSSFWorkbook; @@ -85,6 +87,13 @@ public final class SXSSFITestDataProvider implements ITestDataProvider { return wb; } + @Override + public void trackColumnsForAutosizing(Sheet sheet, int...columns) { + for (int cn : columns) { + ((SXSSFSheet)sheet).trackColumnForAutoSizing(cn); + } + } + @Override public FormulaEvaluator createFormulaEvaluator(Workbook wb) { return new XSSFFormulaEvaluator(((SXSSFWorkbook) wb).getXSSFWorkbook()); diff --git a/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java b/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java index 3ceac02a57..ef9e8836f7 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java @@ -21,6 +21,7 @@ import org.apache.poi.POIDataSamples; import org.apache.poi.ss.ITestDataProvider; import org.apache.poi.ss.SpreadsheetVersion; import org.apache.poi.ss.usermodel.FormulaEvaluator; +import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator; import org.apache.poi.xssf.usermodel.XSSFWorkbook; @@ -53,6 +54,9 @@ public final class XSSFITestDataProvider implements ITestDataProvider { return new XSSFWorkbook(); } + @Override + public void trackColumnsForAutosizing(Sheet sheet, int...columns) {} + @Override public FormulaEvaluator createFormulaEvaluator(Workbook wb) { return new XSSFFormulaEvaluator((XSSFWorkbook) wb); diff --git a/src/testcases/org/apache/poi/hssf/HSSFITestDataProvider.java b/src/testcases/org/apache/poi/hssf/HSSFITestDataProvider.java index 20ec0965b3..ffbb828d2c 100644 --- a/src/testcases/org/apache/poi/hssf/HSSFITestDataProvider.java +++ b/src/testcases/org/apache/poi/hssf/HSSFITestDataProvider.java @@ -25,6 +25,7 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.ITestDataProvider; import org.apache.poi.ss.SpreadsheetVersion; import org.apache.poi.ss.usermodel.FormulaEvaluator; +import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; /** @@ -59,6 +60,9 @@ public final class HSSFITestDataProvider implements ITestDataProvider { return new HSSFWorkbook(); } + @Override + public void trackColumnsForAutosizing(Sheet sheet, int...columns) {} + @Override public FormulaEvaluator createFormulaEvaluator(Workbook wb) { return new HSSFFormulaEvaluator((HSSFWorkbook) wb); diff --git a/src/testcases/org/apache/poi/ss/ITestDataProvider.java b/src/testcases/org/apache/poi/ss/ITestDataProvider.java index 98d90e1038..4be5d25a2a 100644 --- a/src/testcases/org/apache/poi/ss/ITestDataProvider.java +++ b/src/testcases/org/apache/poi/ss/ITestDataProvider.java @@ -18,6 +18,7 @@ package org.apache.poi.ss; import org.apache.poi.ss.usermodel.FormulaEvaluator; +import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; /** @@ -45,6 +46,12 @@ public interface ITestDataProvider { * @return an instance of Workbook */ Workbook createWorkbook(); + + /** + * Only matters for SXSSF - enables tracking of the column + * widths so that autosizing can work. No-op on others. + */ + void trackColumnsForAutosizing(Sheet sheet, int...columns); /** * Creates the corresponding {@link FormulaEvaluator} for the -- 2.39.5