From 40e715a54b7facd9c61461dbbb197b6a18e241af Mon Sep 17 00:00:00 2001 From: Javen O'Neal Date: Thu, 7 Jul 2016 22:29:28 +0000 Subject: [PATCH] whitespace (tabs to spaces) git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1751838 13f79535-47bb-0310-9956-ffa450edef68 --- .../hssf/usermodel/HSSFEvaluationSheet.java | 52 ++--- .../poi/ss/formula/EvaluationSheet.java | 10 +- .../eval/forked/ForkedEvaluationSheet.java | 208 +++++++++--------- .../eval/forked/ForkedEvaluationWorkbook.java | 150 ++++++------- 4 files changed, 210 insertions(+), 210 deletions(-) diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFEvaluationSheet.java b/src/java/org/apache/poi/hssf/usermodel/HSSFEvaluationSheet.java index 3c9f801a30..229788600e 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFEvaluationSheet.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFEvaluationSheet.java @@ -25,30 +25,30 @@ import org.apache.poi.ss.formula.EvaluationSheet; */ final class HSSFEvaluationSheet implements EvaluationSheet { - private final HSSFSheet _hs; - - public HSSFEvaluationSheet(HSSFSheet hs) { - _hs = hs; - } - - public HSSFSheet getHSSFSheet() { - return _hs; - } - @Override - public EvaluationCell getCell(int rowIndex, int columnIndex) { - HSSFRow row = _hs.getRow(rowIndex); - if (row == null) { - return null; - } - HSSFCell cell = row.getCell(columnIndex); - if (cell == null) { - return null; - } - return new HSSFEvaluationCell(cell, this); - } - - @Override - public void clearAllCachedResultValues() { - // nothing to do - } + private final HSSFSheet _hs; + + public HSSFEvaluationSheet(HSSFSheet hs) { + _hs = hs; + } + + public HSSFSheet getHSSFSheet() { + return _hs; + } + @Override + public EvaluationCell getCell(int rowIndex, int columnIndex) { + HSSFRow row = _hs.getRow(rowIndex); + if (row == null) { + return null; + } + HSSFCell cell = row.getCell(columnIndex); + if (cell == null) { + return null; + } + return new HSSFEvaluationCell(cell, this); + } + + @Override + public void clearAllCachedResultValues() { + // nothing to do + } } diff --git a/src/java/org/apache/poi/ss/formula/EvaluationSheet.java b/src/java/org/apache/poi/ss/formula/EvaluationSheet.java index 3cc292dc54..06fb6b5337 100644 --- a/src/java/org/apache/poi/ss/formula/EvaluationSheet.java +++ b/src/java/org/apache/poi/ss/formula/EvaluationSheet.java @@ -26,11 +26,11 @@ package org.apache.poi.ss.formula; */ public interface EvaluationSheet { - /** - * @return null if there is no cell at the specified coordinates - */ - EvaluationCell getCell(int rowIndex, int columnIndex); - + /** + * @return null if there is no cell at the specified coordinates + */ + EvaluationCell getCell(int rowIndex, int columnIndex); + /** * Propagated from {@link EvaluationWorkbook#clearAllCachedResultValues()} to clear locally cached data. * diff --git a/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationSheet.java b/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationSheet.java index 0ba3a66ed1..d15a3461a7 100644 --- a/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationSheet.java +++ b/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationSheet.java @@ -39,109 +39,109 @@ import org.apache.poi.ss.util.CellReference; */ final class ForkedEvaluationSheet implements EvaluationSheet { - private final EvaluationSheet _masterSheet; - /** - * Only cells which have been split are put in this map. (This has been done to conserve memory). - */ - private final Map _sharedCellsByRowCol; - - public ForkedEvaluationSheet(EvaluationSheet masterSheet) { - _masterSheet = masterSheet; - _sharedCellsByRowCol = new HashMap(); - } - - @Override - public EvaluationCell getCell(int rowIndex, int columnIndex) { - RowColKey key = new RowColKey(rowIndex, columnIndex); - - ForkedEvaluationCell result = _sharedCellsByRowCol.get(key); - if (result == null) { - return _masterSheet.getCell(rowIndex, columnIndex); - } - return result; - } - - public ForkedEvaluationCell getOrCreateUpdatableCell(int rowIndex, int columnIndex) { - RowColKey key = new RowColKey(rowIndex, columnIndex); - - ForkedEvaluationCell result = _sharedCellsByRowCol.get(key); - if (result == null) { - EvaluationCell mcell = _masterSheet.getCell(rowIndex, columnIndex); - if (mcell == null) { - CellReference cr = new CellReference(rowIndex, columnIndex); - throw new UnsupportedOperationException("Underlying cell '" - + cr.formatAsString() + "' is missing in master sheet."); - } - result = new ForkedEvaluationCell(this, mcell); - _sharedCellsByRowCol.put(key, result); - } - return result; - } - - public void copyUpdatedCells(Sheet sheet) { - RowColKey[] keys = new RowColKey[_sharedCellsByRowCol.size()]; - _sharedCellsByRowCol.keySet().toArray(keys); - Arrays.sort(keys); - for (int i = 0; i < keys.length; i++) { - RowColKey key = keys[i]; - Row row = sheet.getRow(key.getRowIndex()); - if (row == null) { - row = sheet.createRow(key.getRowIndex()); - } - Cell destCell = row.getCell(key.getColumnIndex()); - if (destCell == null) { - destCell = row.createCell(key.getColumnIndex()); - } - - ForkedEvaluationCell srcCell = _sharedCellsByRowCol.get(key); - srcCell.copyValue(destCell); - } - } - - public int getSheetIndex(EvaluationWorkbook mewb) { - return mewb.getSheetIndex(_masterSheet); - } - - /* (non-Javadoc) - * leave the map alone, if it needs resetting, reusing this class is probably a bad idea. - * @see org.apache.poi.ss.formula.EvaluationSheet#clearAllCachedResultValues() - */ - @Override - public void clearAllCachedResultValues() { - _masterSheet.clearAllCachedResultValues(); - } - + private final EvaluationSheet _masterSheet; + /** + * Only cells which have been split are put in this map. (This has been done to conserve memory). + */ + private final Map _sharedCellsByRowCol; + + public ForkedEvaluationSheet(EvaluationSheet masterSheet) { + _masterSheet = masterSheet; + _sharedCellsByRowCol = new HashMap(); + } + + @Override + public EvaluationCell getCell(int rowIndex, int columnIndex) { + RowColKey key = new RowColKey(rowIndex, columnIndex); + + ForkedEvaluationCell result = _sharedCellsByRowCol.get(key); + if (result == null) { + return _masterSheet.getCell(rowIndex, columnIndex); + } + return result; + } + + public ForkedEvaluationCell getOrCreateUpdatableCell(int rowIndex, int columnIndex) { + RowColKey key = new RowColKey(rowIndex, columnIndex); + + ForkedEvaluationCell result = _sharedCellsByRowCol.get(key); + if (result == null) { + EvaluationCell mcell = _masterSheet.getCell(rowIndex, columnIndex); + if (mcell == null) { + CellReference cr = new CellReference(rowIndex, columnIndex); + throw new UnsupportedOperationException("Underlying cell '" + + cr.formatAsString() + "' is missing in master sheet."); + } + result = new ForkedEvaluationCell(this, mcell); + _sharedCellsByRowCol.put(key, result); + } + return result; + } + + public void copyUpdatedCells(Sheet sheet) { + RowColKey[] keys = new RowColKey[_sharedCellsByRowCol.size()]; + _sharedCellsByRowCol.keySet().toArray(keys); + Arrays.sort(keys); + for (int i = 0; i < keys.length; i++) { + RowColKey key = keys[i]; + Row row = sheet.getRow(key.getRowIndex()); + if (row == null) { + row = sheet.createRow(key.getRowIndex()); + } + Cell destCell = row.getCell(key.getColumnIndex()); + if (destCell == null) { + destCell = row.createCell(key.getColumnIndex()); + } + + ForkedEvaluationCell srcCell = _sharedCellsByRowCol.get(key); + srcCell.copyValue(destCell); + } + } + + public int getSheetIndex(EvaluationWorkbook mewb) { + return mewb.getSheetIndex(_masterSheet); + } + + /* (non-Javadoc) + * leave the map alone, if it needs resetting, reusing this class is probably a bad idea. + * @see org.apache.poi.ss.formula.EvaluationSheet#clearAllCachedResultValues() + */ + @Override + public void clearAllCachedResultValues() { + _masterSheet.clearAllCachedResultValues(); + } + // FIXME: serves same purpose as org.apache.poi.xssf.usermodel.XSSFEvaluationSheet$CellKey - private static final class RowColKey implements Comparable{ - private final int _rowIndex; - private final int _columnIndex; - - public RowColKey(int rowIndex, int columnIndex) { - _rowIndex = rowIndex; - _columnIndex = columnIndex; - } - @Override - public boolean equals(Object obj) { - assert obj instanceof RowColKey : "these private cache key instances are only compared to themselves"; - RowColKey other = (RowColKey) obj; - return _rowIndex == other._rowIndex && _columnIndex == other._columnIndex; - } - @Override - public int hashCode() { - return _rowIndex ^ _columnIndex; - } - public int compareTo(RowColKey o) { - int cmp = _rowIndex - o._rowIndex; - if (cmp != 0) { - return cmp; - } - return _columnIndex - o._columnIndex; - } - public int getRowIndex() { - return _rowIndex; - } - public int getColumnIndex() { - return _columnIndex; - } - } + private static final class RowColKey implements Comparable{ + private final int _rowIndex; + private final int _columnIndex; + + public RowColKey(int rowIndex, int columnIndex) { + _rowIndex = rowIndex; + _columnIndex = columnIndex; + } + @Override + public boolean equals(Object obj) { + assert obj instanceof RowColKey : "these private cache key instances are only compared to themselves"; + RowColKey other = (RowColKey) obj; + return _rowIndex == other._rowIndex && _columnIndex == other._columnIndex; + } + @Override + public int hashCode() { + return _rowIndex ^ _columnIndex; + } + public int compareTo(RowColKey o) { + int cmp = _rowIndex - o._rowIndex; + if (cmp != 0) { + return cmp; + } + return _columnIndex - o._columnIndex; + } + public int getRowIndex() { + return _rowIndex; + } + public int getColumnIndex() { + return _columnIndex; + } + } } diff --git a/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationWorkbook.java b/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationWorkbook.java index cb50f6871a..54cbd644c6 100644 --- a/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationWorkbook.java +++ b/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationWorkbook.java @@ -37,71 +37,71 @@ import org.apache.poi.ss.usermodel.Workbook; */ final class ForkedEvaluationWorkbook implements EvaluationWorkbook { - private final EvaluationWorkbook _masterBook; - private final Map _sharedSheetsByName; - - public ForkedEvaluationWorkbook(EvaluationWorkbook master) { - _masterBook = master; - _sharedSheetsByName = new HashMap(); - } - - public ForkedEvaluationCell getOrCreateUpdatableCell(String sheetName, int rowIndex, - int columnIndex) { - ForkedEvaluationSheet sheet = getSharedSheet(sheetName); - return sheet.getOrCreateUpdatableCell(rowIndex, columnIndex); - } - - public EvaluationCell getEvaluationCell(String sheetName, int rowIndex, int columnIndex) { - ForkedEvaluationSheet sheet = getSharedSheet(sheetName); - return sheet.getCell(rowIndex, columnIndex); - } - - private ForkedEvaluationSheet getSharedSheet(String sheetName) { - ForkedEvaluationSheet result = _sharedSheetsByName.get(sheetName); - if (result == null) { - result = new ForkedEvaluationSheet(_masterBook.getSheet(_masterBook - .getSheetIndex(sheetName))); - _sharedSheetsByName.put(sheetName, result); - } - return result; - } - - public void copyUpdatedCells(Workbook workbook) { + private final EvaluationWorkbook _masterBook; + private final Map _sharedSheetsByName; + + public ForkedEvaluationWorkbook(EvaluationWorkbook master) { + _masterBook = master; + _sharedSheetsByName = new HashMap(); + } + + public ForkedEvaluationCell getOrCreateUpdatableCell(String sheetName, int rowIndex, + int columnIndex) { + ForkedEvaluationSheet sheet = getSharedSheet(sheetName); + return sheet.getOrCreateUpdatableCell(rowIndex, columnIndex); + } + + public EvaluationCell getEvaluationCell(String sheetName, int rowIndex, int columnIndex) { + ForkedEvaluationSheet sheet = getSharedSheet(sheetName); + return sheet.getCell(rowIndex, columnIndex); + } + + private ForkedEvaluationSheet getSharedSheet(String sheetName) { + ForkedEvaluationSheet result = _sharedSheetsByName.get(sheetName); + if (result == null) { + result = new ForkedEvaluationSheet(_masterBook.getSheet(_masterBook + .getSheetIndex(sheetName))); + _sharedSheetsByName.put(sheetName, result); + } + return result; + } + + public void copyUpdatedCells(Workbook workbook) { String[] sheetNames = new String[_sharedSheetsByName.size()]; _sharedSheetsByName.keySet().toArray(sheetNames); - for (String sheetName : sheetNames) { - ForkedEvaluationSheet sheet = _sharedSheetsByName.get(sheetName); - sheet.copyUpdatedCells(workbook.getSheet(sheetName)); - } - } + for (String sheetName : sheetNames) { + ForkedEvaluationSheet sheet = _sharedSheetsByName.get(sheetName); + sheet.copyUpdatedCells(workbook.getSheet(sheetName)); + } + } @Override - public int convertFromExternSheetIndex(int externSheetIndex) { - return _masterBook.convertFromExternSheetIndex(externSheetIndex); - } + public int convertFromExternSheetIndex(int externSheetIndex) { + return _masterBook.convertFromExternSheetIndex(externSheetIndex); + } @Override - public ExternalSheet getExternalSheet(int externSheetIndex) { - return _masterBook.getExternalSheet(externSheetIndex); - } + public ExternalSheet getExternalSheet(int externSheetIndex) { + return _masterBook.getExternalSheet(externSheetIndex); + } @Override - public ExternalSheet getExternalSheet(String firstSheetName, String lastSheetName, int externalWorkbookNumber) { + public ExternalSheet getExternalSheet(String firstSheetName, String lastSheetName, int externalWorkbookNumber) { return _masterBook.getExternalSheet(firstSheetName, lastSheetName, externalWorkbookNumber); } @Override public Ptg[] getFormulaTokens(EvaluationCell cell) { - if (cell instanceof ForkedEvaluationCell) { - // doesn't happen yet because formulas cannot be modified from the master workbook - throw new RuntimeException("Updated formulas not supported yet"); - } - return _masterBook.getFormulaTokens(cell); - } + if (cell instanceof ForkedEvaluationCell) { + // doesn't happen yet because formulas cannot be modified from the master workbook + throw new RuntimeException("Updated formulas not supported yet"); + } + return _masterBook.getFormulaTokens(cell); + } @Override - public EvaluationName getName(NamePtg namePtg) { - return _masterBook.getName(namePtg); - } + public EvaluationName getName(NamePtg namePtg) { + return _masterBook.getName(namePtg); + } @Override public EvaluationName getName(String name, int sheetIndex){ @@ -109,42 +109,42 @@ final class ForkedEvaluationWorkbook implements EvaluationWorkbook { } @Override - public EvaluationSheet getSheet(int sheetIndex) { - return getSharedSheet(getSheetName(sheetIndex)); - } - + public EvaluationSheet getSheet(int sheetIndex) { + return getSharedSheet(getSheetName(sheetIndex)); + } + @Override - public ExternalName getExternalName(int externSheetIndex, int externNameIndex) { - return _masterBook.getExternalName(externSheetIndex, externNameIndex); - } + public ExternalName getExternalName(int externSheetIndex, int externNameIndex) { + return _masterBook.getExternalName(externSheetIndex, externNameIndex); + } @Override - public ExternalName getExternalName(String nameName, String sheetName, int externalWorkbookNumber) { - return _masterBook.getExternalName(nameName, sheetName, externalWorkbookNumber); + public ExternalName getExternalName(String nameName, String sheetName, int externalWorkbookNumber) { + return _masterBook.getExternalName(nameName, sheetName, externalWorkbookNumber); } @Override public int getSheetIndex(EvaluationSheet sheet) { - if (sheet instanceof ForkedEvaluationSheet) { - ForkedEvaluationSheet mes = (ForkedEvaluationSheet) sheet; - return mes.getSheetIndex(_masterBook); - } - return _masterBook.getSheetIndex(sheet); - } + if (sheet instanceof ForkedEvaluationSheet) { + ForkedEvaluationSheet mes = (ForkedEvaluationSheet) sheet; + return mes.getSheetIndex(_masterBook); + } + return _masterBook.getSheetIndex(sheet); + } @Override - public int getSheetIndex(String sheetName) { - return _masterBook.getSheetIndex(sheetName); - } + public int getSheetIndex(String sheetName) { + return _masterBook.getSheetIndex(sheetName); + } @Override - public String getSheetName(int sheetIndex) { - return _masterBook.getSheetName(sheetIndex); - } + public String getSheetName(int sheetIndex) { + return _masterBook.getSheetName(sheetIndex); + } @Override - public String resolveNameXText(NameXPtg ptg) { - return _masterBook.resolveNameXText(ptg); - } + public String resolveNameXText(NameXPtg ptg) { + return _masterBook.resolveNameXText(ptg); + } @Override public UDFFinder getUDFFinder() { -- 2.39.5