<group name="Main">
<classfiles>
<fileset dir="${main.output.dir}">
- <exclude name=""/>
+ <exclude name="org/apache/poi/hssf/usermodel/DummyGraphics2d.class"/>
</fileset>
</classfiles>
<sourcefiles encoding="UTF-8">
import org.apache.poi.hssf.record.aggregates.DataValidityTable;
import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate;
import org.apache.poi.hssf.record.aggregates.WorksheetProtectionBlock;
+import org.apache.poi.hssf.util.PaneInformation;
+import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.ss.formula.FormulaShifter;
+import org.apache.poi.ss.formula.FormulaType;
+import org.apache.poi.ss.formula.ptg.Area3DPtg;
import org.apache.poi.ss.formula.ptg.MemFuncPtg;
import org.apache.poi.ss.formula.ptg.Ptg;
-import org.apache.poi.ss.formula.ptg.Area3DPtg;
import org.apache.poi.ss.formula.ptg.UnionPtg;
-import org.apache.poi.hssf.util.PaneInformation;
-import org.apache.poi.ss.SpreadsheetVersion;
-import org.apache.poi.ss.formula.FormulaType;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellRange;
import org.apache.poi.ss.usermodel.CellStyle;
*/
public void setZoom(int numerator, int denominator) {
if (numerator < 1 || numerator > 65535)
- throw new IllegalArgumentException("Numerator must be greater than 1 and less than 65536");
+ throw new IllegalArgumentException("Numerator must be greater than 0 and less than 65536");
if (denominator < 1 || denominator > 65535)
- throw new IllegalArgumentException("Denominator must be greater than 1 and less than 65536");
+ throw new IllegalArgumentException("Denominator must be greater than 0 and less than 65536");
SCLRecord sclRecord = new SCLRecord();
sclRecord.setNumerator((short) numerator);
*/
public class NullLogger extends POILogger
{
+ @Override
public void initialize(final String cat)
{
//do nothing
* @param obj1 The object to log.
*/
+ @Override
public void log(final int level, final Object obj1)
{
//do nothing
* @param level One of DEBUG, INFO, WARN, ERROR, FATAL
*/
+ @Override
public boolean check(final int level)
{
return false;
* @param obj2 second object to place in the message
*/
+ @Override
public void log(final int level, final Object obj1, final Object obj2)
{
//do nothing
* @param obj3 third Object to place in the message
*/
+ @Override
public void log(final int level, final Object obj1, final Object obj2,
final Object obj3)
{
* @param obj4 fourth Object to place in the message
*/
+ @Override
public void log(final int level, final Object obj1, final Object obj2,
final Object obj3, final Object obj4)
{
* @param obj5 fifth Object to place in the message
*/
+ @Override
public void log(final int level, final Object obj1, final Object obj2,
final Object obj3, final Object obj4, final Object obj5)
{
* @param obj6 sixth Object to place in the message
*/
+ @Override
public void log(final int level, final Object obj1, final Object obj2,
final Object obj3, final Object obj4, final Object obj5,
final Object obj6)
* @param obj7 seventh Object to place in the message
*/
+ @Override
public void log(final int level, final Object obj1, final Object obj2,
final Object obj3, final Object obj4, final Object obj5,
final Object obj6, final Object obj7)
* @param obj8 eighth Object to place in the message
*/
+ @Override
public void log(final int level, final Object obj1, final Object obj2,
final Object obj3, final Object obj4, final Object obj5,
final Object obj6, final Object obj7, final Object obj8)
* @param exception An exception to be logged
*/
+ @Override
public void log(final int level, final Object obj1,
final Throwable exception)
{
* @param exception An exception to be logged
*/
+ @Override
public void log(final int level, final Object obj1, final Object obj2,
final Throwable exception)
{
* @param exception An error message to be logged
*/
+ @Override
public void log(final int level, final Object obj1, final Object obj2,
final Object obj3, final Throwable exception)
{
* @param exception An exception to be logged
*/
+ @Override
public void log(final int level, final Object obj1, final Object obj2,
final Object obj3, final Object obj4,
final Throwable exception)
* @param exception An exception to be logged
*/
+ @Override
public void log(final int level, final Object obj1, final Object obj2,
final Object obj3, final Object obj4, final Object obj5,
final Throwable exception)
* @param exception An exception to be logged
*/
+ @Override
public void log(final int level, final Object obj1, final Object obj2,
final Object obj3, final Object obj4, final Object obj5,
final Object obj6, final Throwable exception)
* @param exception An exception to be logged
*/
+ @Override
public void log(final int level, final Object obj1, final Object obj2,
final Object obj3, final Object obj4, final Object obj5,
final Object obj6, final Object obj7,
* @param exception An exception to be logged
*/
+ @Override
public void log(final int level, final Object obj1, final Object obj2,
final Object obj3, final Object obj4, final Object obj5,
final Object obj6, final Object obj7, final Object obj8,
* @param obj1 The first object to match against.
*/
+ @Override
public void logFormatted(final int level, final String message,
final Object obj1)
{
* @param obj2 The second object to match against.
*/
+ @Override
public void logFormatted(final int level, final String message,
final Object obj1, final Object obj2)
{
* @param obj3 The third object to match against.
*/
+ @Override
public void logFormatted(final int level, final String message,
final Object obj1, final Object obj2,
final Object obj3)
* @param obj4 The forth object to match against.
*/
+ @Override
public void logFormatted(final int level, final String message,
final Object obj1, final Object obj2,
final Object obj3, final Object obj4)
package org.apache.poi.util;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Map;
/**
* Provides logging without clients having to mess with
* @return a POILogger for the specified class
*/
- public static POILogger getLogger(final Class theclass)
+ public static POILogger getLogger(final Class<?> theclass)
{
return getLogger(theclass.getName());
}
logger = _loggers.get(cat);
} else {
try {
- Class<? extends POILogger> loggerClass =
+ @SuppressWarnings("unchecked")
+ Class<? extends POILogger> loggerClass =
(Class<? extends POILogger>)Class.forName(_loggerClassName);
logger = loggerClass.newInstance();
logger.initialize(cat);
package org.apache.poi.xssf.streaming;
-import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.usermodel.BaseTestSheet;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.SXSSFITestDataProvider;
-import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
int expectedHashB = -14556;
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet hssfSheet = workbook.createSheet();
+ assertFalse(hssfSheet.getObjectProtect());
hssfSheet.protectSheet(passwordA);
+ assertTrue(hssfSheet.getObjectProtect());
+ assertEquals(expectedHashA, hssfSheet.getPassword());
assertEquals(expectedHashA, hssfSheet.getSheet().getProtectionBlock().getPasswordHash());
// Clone the sheet, and make sure the password hash is preserved
HSSFSheet sheet2 = workbook.cloneSheet(0);
+ assertTrue(hssfSheet.getObjectProtect());
assertEquals(expectedHashA, sheet2.getSheet().getProtectionBlock().getPasswordHash());
// change the password on the first sheet
hssfSheet.protectSheet(passwordB);
+ assertTrue(hssfSheet.getObjectProtect());
assertEquals(expectedHashB, hssfSheet.getSheet().getProtectionBlock().getPasswordHash());
+ assertEquals(expectedHashB, hssfSheet.getPassword());
// but the cloned sheet's password should remain unchanged
assertEquals(expectedHashA, sheet2.getSheet().getProtectionBlock().getPasswordHash());
}
int sclLoc = sheet.getSheet().findFirstRecordLocBySid(SCLRecord.sid);
int window2Loc = sheet.getSheet().findFirstRecordLocBySid(WindowTwoRecord.sid);
assertTrue(sclLoc == window2Loc + 1);
+
+ // verify limits
+ try {
+ sheet.setZoom(0, 2);
+ fail("Should catch Exception here");
+ } catch (IllegalArgumentException e) {
+ assertEquals("Numerator must be greater than 0 and less than 65536", e.getMessage());
+ }
+ try {
+ sheet.setZoom(65536, 2);
+ fail("Should catch Exception here");
+ } catch (IllegalArgumentException e) {
+ assertEquals("Numerator must be greater than 0 and less than 65536", e.getMessage());
+ }
+ try {
+ sheet.setZoom(2, 0);
+ fail("Should catch Exception here");
+ } catch (IllegalArgumentException e) {
+ assertEquals("Denominator must be greater than 0 and less than 65536", e.getMessage());
+ }
+ try {
+ sheet.setZoom(2, 65536);
+ fail("Should catch Exception here");
+ } catch (IllegalArgumentException e) {
+ assertEquals("Denominator must be greater than 0 and less than 65536", e.getMessage());
+ }
}
workbook = HSSFTestDataSamples.writeOutAndReadBack(workbook);
}
- public void testAutoSizeColumn() {
+ @SuppressWarnings("deprecation")
+ public void testAutoSizeColumn() {
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("43902.xls");
String sheetName = "my sheet";
HSSFSheet sheet = wb.getSheet(sheetName);
//create a region over the 2nd row and auto size the first column
sheet.addMergedRegion(new CellRangeAddress(1,1,0,1));
+ assertNotNull(sheet.getMergedRegionAt(0));
sheet.autoSizeColumn((short)0);
HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb);
}
assertEquals(40000, sheet.getColumnWidth((short)10));
}
+
+ public void testShowInPane() {
+ Workbook wb = new HSSFWorkbook();
+ Sheet sheet = wb.createSheet();
+ sheet.showInPane(2, 3);
+
+ try {
+ sheet.showInPane(Integer.MAX_VALUE, 3);
+ fail("Should catch exception here");
+ } catch (IllegalArgumentException e) {
+ assertEquals("Maximum row number is 65535", e.getMessage());
+ }
+ }
+
+ public void testDrawingRecords() {
+ HSSFWorkbook wb = new HSSFWorkbook();
+ HSSFSheet sheet = wb.createSheet();
+
+ /* TODO: NPE?
+ sheet.dumpDrawingRecords(false);
+ sheet.dumpDrawingRecords(true);*/
+ assertNull(sheet.getDrawingEscherAggregate());
+ }
}
}
}
+ public void testBaseZoom() {
+ Workbook wb = _testDataProvider.createWorkbook();
+ Sheet sheet = wb.createSheet();
+
+ // here we can only verify that setting some zoom values works, range-checking is different between the implementations
+ sheet.setZoom(3,4);
+ }
+
+ public void testBaseShowInPane() {
+ Workbook wb = _testDataProvider.createWorkbook();
+ Sheet sheet = wb.createSheet();
+ sheet.showInPane(2, 3);
+ }
}