From: Dominik Stadler Date: Fri, 26 Oct 2018 09:32:43 +0000 (+0000) Subject: Typos and IDE warnings X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2148b7f27889288543a6ae5aed2d61382dc9b496;p=poi.git Typos and IDE warnings git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1844879 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/AddDimensionedImage.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/AddDimensionedImage.java index bee33a250d..480662554d 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/AddDimensionedImage.java +++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/AddDimensionedImage.java @@ -142,13 +142,13 @@ import org.apache.poi.ss.usermodel.ClientAnchor.AnchorType; public class AddDimensionedImage { // Four constants that determine how - and indeed whether - the rows - // and columns an image may overlie should be expanded to accomodate that + // and columns an image may overlie should be expanded to accommodate that // image. // Passing EXPAND_ROW will result in the height of a row being increased - // to accomodate the image if it is not already larger. The image will + // to accommodate the image if it is not already larger. The image will // be layed across one or more columns. // Passing EXPAND_COLUMN will result in the width of the column being - // increased to accomodate the image if it is not already larger. The image + // increased to accommodate the image if it is not already larger. The image // will be layed across one or many rows. // Passing EXPAND_ROW_AND_COLUMN will result in the height of the row // bing increased along with the width of the column to accomdate the @@ -266,7 +266,7 @@ public class AddDimensionedImage { } // Call methods to calculate how the image and sheet should be - // manipulated to accomodate the image; columns and then rows. + // manipulated to accommodate the image; columns and then rows. colClientAnchorDetail = this.fitImageToColumns(sheet, colNumber, reqImageWidthMM, resizeBehaviour); rowClientAnchorDetail = this.fitImageToRows(sheet, rowNumber, @@ -312,7 +312,7 @@ public class AddDimensionedImage { } /** - * Determines whether the sheets columns should be re-sized to accomodate + * Determines whether the sheets columns should be re-sized to accommodate * the image, adjusts the columns width if necessary and creates then * returns a ClientAnchorDetail object that facilitates construction of * an HSSFClientAnchor that will fix the image on the sheet and establish @@ -348,7 +348,7 @@ public class AddDimensionedImage { colWidthMM = ConvertImageUnits.widthUnits2Millimetres( (short)sheet.getColumnWidth(colNumber)); - // Check that the column's width will accomodate the image at the + // Check that the column's width will accommodate the image at the // required dimension. If the width of the column is LESS than the // required width of the image, decide how the application should // respond - resize the column or overlay the image across one or more @@ -396,7 +396,7 @@ public class AddDimensionedImage { } /** - * Determines whether the sheet's row should be re-sized to accomodate + * Determines whether the sheet's row should be re-sized to accommodate * the image, adjusts the rows height if necessary and creates then * returns a ClientAnchorDetail object that facilitates construction of * an HSSFClientAnchor that will fix the image on the sheet and establish @@ -436,7 +436,7 @@ public class AddDimensionedImage { // Get the row's height in millimetres double rowHeightMM = row.getHeightInPoints() / ConvertImageUnits.POINTS_PER_MILLIMETRE; - // Check that the row's height will accomodate the image at the required + // Check that the row's height will accommodate the image at the required // dimensions. If the height of the row is LESS than the required height // of the image, decide how the application should respond - resize the // row or overlay the image across a series of rows. diff --git a/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java b/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java index 177d0a6d97..fa5e233cf9 100644 --- a/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java +++ b/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java @@ -202,13 +202,13 @@ import org.apache.poi.util.IOUtils; public class AddDimensionedImage { // Four constants that determine how - and indeed whether - the rows - // and columns an image may overlie should be expanded to accomodate that + // and columns an image may overlie should be expanded to accommodate that // image. // Passing EXPAND_ROW will result in the height of a row being increased - // to accomodate the image if it is not already larger. The image will + // to accommodate the image if it is not already larger. The image will // be layed across one or more columns. // Passing EXPAND_COLUMN will result in the width of the column being - // increased to accomodate the image if it is not already larger. The image + // increased to accommodate the image if it is not already larger. The image // will be layed across one or many rows. // Passing EXPAND_ROW_AND_COLUMN will result in the height of the row // bing increased along with the width of the column to accomdate the @@ -348,7 +348,7 @@ public class AddDimensionedImage { } // Call methods to calculate how the image and sheet should be - // manipulated to accomodate the image; columns and then rows. + // manipulated to accommodate the image; columns and then rows. colClientAnchorDetail = this.fitImageToColumns(sheet, colNumber, reqImageWidthMM, resizeBehaviour); rowClientAnchorDetail = this.fitImageToRows(sheet, rowNumber, @@ -440,7 +440,7 @@ public class AddDimensionedImage { colWidthMM = ConvertImageUnits.widthUnits2Millimetres( (short)sheet.getColumnWidth(colNumber)); - // Check that the column's width will accomodate the image at the + // Check that the column's width will accommodate the image at the // required dimension. If the width of the column is LESS than the // required width of the image, decide how the application should // respond - resize the column or overlay the image across one or more @@ -500,7 +500,7 @@ public class AddDimensionedImage { } /** - * Determines whether the sheets row should be re-sized to accomodate + * Determines whether the sheets row should be re-sized to accommodate * the image, adjusts the rows height if necessary and creates then * returns a ClientAnchorDetail object that facilitates construction of * a ClientAnchor that will fix the image on the sheet and establish @@ -542,7 +542,7 @@ public class AddDimensionedImage { // Get the row's height in millimetres rowHeightMM = row.getHeightInPoints() / ConvertImageUnits.POINTS_PER_MILLIMETRE; - // Check that the row's height will accomodate the image at the required + // Check that the row's height will accommodate the image at the required // dimensions. If the height of the row is LESS than the required height // of the image, decide how the application should respond - resize the // row or overlay the image across a series of rows. diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/NewLinesInCells.java b/src/examples/src/org/apache/poi/xssf/usermodel/examples/NewLinesInCells.java index 08684ca1c0..c3b4c1c0a0 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/NewLinesInCells.java +++ b/src/examples/src/org/apache/poi/xssf/usermodel/examples/NewLinesInCells.java @@ -44,8 +44,8 @@ public class NewLinesInCells { cs.setWrapText(true); cell.setCellStyle(cs); - //increase row height to accomodate two lines of text - row.setHeightInPoints((2 * sheet.getDefaultRowHeightInPoints())); + //increase row height to accommodate two lines of text + row.setHeightInPoints(2 * sheet.getDefaultRowHeightInPoints()); //adjust column width to fit the content sheet.autoSizeColumn(2); @@ -55,5 +55,4 @@ public class NewLinesInCells { } } } - } diff --git a/src/java/org/apache/poi/ss/format/CellDateFormatter.java b/src/java/org/apache/poi/ss/format/CellDateFormatter.java index 42b71bddb1..b544d9ca16 100644 --- a/src/java/org/apache/poi/ss/format/CellDateFormatter.java +++ b/src/java/org/apache/poi/ss/format/CellDateFormatter.java @@ -50,6 +50,7 @@ public class CellDateFormatter extends CellFormatter { private int hStart = -1; private int hLen; + @Override public String handlePart(Matcher m, String part, CellFormatType type, StringBuffer desc) { diff --git a/src/java/org/apache/poi/ss/format/CellTextFormatter.java b/src/java/org/apache/poi/ss/format/CellTextFormatter.java index 5712bb24ab..08736fa584 100644 --- a/src/java/org/apache/poi/ss/format/CellTextFormatter.java +++ b/src/java/org/apache/poi/ss/format/CellTextFormatter.java @@ -16,10 +16,7 @@ ==================================================================== */ package org.apache.poi.ss.format; -import org.apache.poi.ss.format.CellFormatPart.PartHandler; - import java.util.Locale; -import java.util.regex.Matcher; /** * This class implements printing out text. @@ -38,15 +35,12 @@ public class CellTextFormatter extends CellFormatter { final int[] numPlaces = new int[1]; desc = CellFormatPart.parseFormat(format, CellFormatType.TEXT, - new PartHandler() { - public String handlePart(Matcher m, String part, - CellFormatType type, StringBuffer desc) { - if (part.equals("@")) { - numPlaces[0]++; - return "\u0000"; - } - return null; + (m, part, type, desc) -> { + if (part.equals("@")) { + numPlaces[0]++; + return "\u0000"; } + return null; }).toString(); // Remember the "@" positions in last-to-first order (to make insertion easier) @@ -66,8 +60,8 @@ public class CellTextFormatter extends CellFormatter { text = text.toUpperCase(Locale.ROOT); } toAppendTo.append(desc); - for (int i = 0; i < textPos.length; i++) { - int pos = start + textPos[i]; + for (int textPo : textPos) { + int pos = start + textPo; toAppendTo.replace(pos, pos + 1, text); } } diff --git a/src/java/org/apache/poi/ss/formula/ptg/RefPtgBase.java b/src/java/org/apache/poi/ss/formula/ptg/RefPtgBase.java index 6d63ed5a46..31a3a56be7 100644 --- a/src/java/org/apache/poi/ss/formula/ptg/RefPtgBase.java +++ b/src/java/org/apache/poi/ss/formula/ptg/RefPtgBase.java @@ -43,7 +43,7 @@ public abstract class RefPtgBase extends OperandPtg { /** * YK: subclasses of RefPtgBase are used by the FormulaParser and FormulaEvaluator accross HSSF and XSSF. - * The bit mask should accomodate the maximum number of avaiable columns, i.e. 0x3FFF. + * The bit mask should accommodate the maximum number of avaiable columns, i.e. 0x3FFF. * * @see org.apache.poi.ss.SpreadsheetVersion */ diff --git a/src/java/org/apache/poi/ss/util/CellUtil.java b/src/java/org/apache/poi/ss/util/CellUtil.java index 70dcffc289..3bcef4beb4 100644 --- a/src/java/org/apache/poi/ss/util/CellUtil.java +++ b/src/java/org/apache/poi/ss/util/CellUtil.java @@ -420,7 +420,7 @@ public final class CellUtil { } /** - * Utility method that returns the named short value form the given map. + * Utility method that returns the named short value from the given map. * * @param properties map of named properties (String -> Object) * @param name property name @@ -436,7 +436,7 @@ public final class CellUtil { } /** - * Utility method that returns the named int value form the given map. + * Utility method that returns the named int value from the given map. * * @param properties map of named properties (String -> Object) * @param name property name @@ -452,7 +452,7 @@ public final class CellUtil { } /** - * Utility method that returns the named BorderStyle value form the given map. + * Utility method that returns the named BorderStyle value from the given map. * * @param properties map of named properties (String -> Object) * @param name property name @@ -483,7 +483,7 @@ public final class CellUtil { } /** - * Utility method that returns the named FillPatternType value form the given map. + * Utility method that returns the named FillPatternType value from the given map. * * @param properties map of named properties (String -> Object) * @param name property name @@ -515,7 +515,7 @@ public final class CellUtil { } /** - * Utility method that returns the named HorizontalAlignment value form the given map. + * Utility method that returns the named HorizontalAlignment value from the given map. * * @param properties map of named properties (String -> Object) * @param name property name @@ -547,7 +547,7 @@ public final class CellUtil { } /** - * Utility method that returns the named VerticalAlignment value form the given map. + * Utility method that returns the named VerticalAlignment value from the given map. * * @param properties map of named properties (String -> Object) * @param name property name @@ -579,7 +579,7 @@ public final class CellUtil { } /** - * Utility method that returns the named boolean value form the given map. + * Utility method that returns the named boolean value from the given map. * * @param properties map of properties (String -> Object) * @param name property name @@ -594,7 +594,7 @@ public final class CellUtil { } return false; } - + /** * Utility method that puts the given value to the given map. * diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java index a0cd5bec7f..ef83956468 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -2993,13 +2993,21 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { cell.setCellStyle(style); // Everything is fine at this point, cell is red + XSSFColor actual = cell.getCellStyle().getFillBackgroundColorColor(); + assertNull(actual); + actual = cell.getCellStyle().getFillForegroundColorColor(); + assertNotNull(actual); + assertEquals(color.getARGBHex(), actual.getARGBHex()); Map properties = new HashMap<>(); properties.put(CellUtil.BORDER_BOTTOM, BorderStyle.THIN); CellUtil.setCellStyleProperties(cell, properties); // Now the cell is all black - XSSFColor actual = cell.getCellStyle().getFillBackgroundColorColor(); + actual = cell.getCellStyle().getFillBackgroundColorColor(); + assertNotNull(actual); + assertNull(actual.getARGBHex()); + actual = cell.getCellStyle().getFillForegroundColorColor(); assertNotNull(actual); assertEquals(color.getARGBHex(), actual.getARGBHex());