Author: abearez Date: Tue May 21 00:14:12 2019 New Revision: 1859595 URL: http://svn.apache.org/viewvc?rev=1859595&view=rev Log: fix result of multiplication cast to wider type
Modified: poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/BigExample.java poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/HSSFReadWrite.java poi/trunk/src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java poi/trunk/src/java/org/apache/poi/ss/formula/atp/YearFracCalculator.java poi/trunk/src/java/org/apache/poi/ss/formula/functions/Days360.java poi/trunk/src/java/org/apache/poi/ss/usermodel/DateUtil.java poi/trunk/src/java/org/apache/poi/ss/usermodel/ExcelStyleDateFormatter.java poi/trunk/src/java/org/apache/poi/ss/util/ImageUtils.java poi/trunk/src/java/org/apache/poi/ss/util/cellwalk/CellWalk.java poi/trunk/src/java/org/apache/poi/util/StringUtil.java poi/trunk/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfComment.java poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/qcbits/QCTextBit.java poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/CurrentUserAtom.java poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/MasterTextPropAtom.java poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextCharsAtom.java poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoRun.java poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfDraw.java poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmUtils.java poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/TableSprmCompressor.java Modified: poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/BigExample.java URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/BigExample.java?rev=1859595&r1=1859594&r2=1859595&view=diff ============================================================================== --- poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/BigExample.java (original) +++ poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/BigExample.java Tue May 21 00:14:12 2019 @@ -102,9 +102,9 @@ public class BigExample { // create a numeric cell c = r.createCell(cellnum); // do some goofy math to demonstrate decimals - c.setCellValue(rownum * 10000 + cellnum - + (((double) rownum / 1000) - + ((double) cellnum / 10000))); + c.setCellValue((rownum * 10000.0) + cellnum + + (rownum / 1000.0) + + (cellnum / 10000.0)); // on every other row if ((rownum % 2) == 0) { Modified: poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/HSSFReadWrite.java URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/HSSFReadWrite.java?rev=1859595&r1=1859594&r2=1859595&view=diff ============================================================================== --- poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/HSSFReadWrite.java (original) +++ poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/HSSFReadWrite.java Tue May 21 00:14:12 2019 @@ -87,8 +87,8 @@ public final class HSSFReadWrite { for (int cellnum = 0; cellnum < 50; cellnum += 2) { HSSFCell c = r.createCell(cellnum); - c.setCellValue(rownum * 10000 + cellnum - + (((double) rownum / 1000) + ((double) cellnum / 10000))); + c.setCellValue((rownum * 10000.0) + cellnum + + (rownum / 1000.0) + (cellnum / 10000.0)); if ((rownum % 2) == 0) { c.setCellStyle(cs); } Modified: poi/trunk/src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java?rev=1859595&r1=1859594&r2=1859595&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java (original) +++ poi/trunk/src/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java Tue May 21 00:14:12 2019 @@ -759,6 +759,7 @@ public class POIFSFileSystem extends Blo * and buffers. After this, you will be unable to read or * write from the FileSystem. */ + @Override public void close() throws IOException { _data.close(); } @@ -834,6 +835,7 @@ public class POIFSFileSystem extends Blo * * @return an array of Object; may not be null, but may be empty */ + @Override public Object[] getViewableArray() { if (preferArray()) { return getRoot().getViewableArray(); @@ -850,6 +852,7 @@ public class POIFSFileSystem extends Blo * back end store */ + @Override public Iterator<Object> getViewableIterator() { if (!preferArray()) { return getRoot().getViewableIterator(); @@ -866,6 +869,7 @@ public class POIFSFileSystem extends Blo * a viewer should call getViewableIterator */ + @Override public boolean preferArray() { return getRoot().preferArray(); } @@ -877,6 +881,7 @@ public class POIFSFileSystem extends Blo * @return short description */ + @Override public String getShortDescription() { return "POIFS FileSystem"; } @@ -949,4 +954,3 @@ public class POIFSFileSystem extends Blo } } - Modified: poi/trunk/src/java/org/apache/poi/ss/formula/atp/YearFracCalculator.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/atp/YearFracCalculator.java?rev=1859595&r1=1859594&r2=1859595&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/ss/formula/atp/YearFracCalculator.java (original) +++ poi/trunk/src/java/org/apache/poi/ss/formula/atp/YearFracCalculator.java Tue May 21 00:14:12 2019 @@ -27,7 +27,7 @@ import org.apache.poi.util.LocaleUtil; /** * Internal calculation methods for Excel 'Analysis ToolPak' function YEARFRAC()<br> - * + * * Algorithm inspired by www.dwheeler.com/yearfrac */ final class YearFracCalculator { @@ -61,7 +61,7 @@ final class YearFracCalculator { int startDateVal = (int) Math.floor(pStartDateVal); int endDateVal = (int) Math.floor(pEndDateVal); if (startDateVal == endDateVal) { - // when dates are equal, result is zero + // when dates are equal, result is zero return 0; } // swap start and end if out of order @@ -92,7 +92,7 @@ final class YearFracCalculator { int date1day = startDate.day; int date2day = endDate.day; - // basis zero has funny adjustments to the day-of-month fields when at end-of-month + // basis zero has funny adjustments to the day-of-month fields when at end-of-month if (date1day == LONG_MONTH_LEN && date2day == LONG_MONTH_LEN) { date1day = SHORT_MONTH_LEN; date2day = SHORT_MONTH_LEN; @@ -155,7 +155,7 @@ final class YearFracCalculator { int date2day = endDate.day; - // basis four has funny adjustments to the day-of-month fields when at end-of-month + // basis four has funny adjustments to the day-of-month fields when at end-of-month if (date1day == LONG_MONTH_LEN) { date1day = SHORT_MONTH_LEN; } @@ -169,10 +169,10 @@ final class YearFracCalculator { private static double calculateAdjusted(SimpleDate startDate, SimpleDate endDate, int date1day, int date2day) { - double dayCount - = (endDate.year - startDate.year) * 360 - + (endDate.month - startDate.month) * SHORT_MONTH_LEN - + (date2day - date1day) * 1; + double dayCount + = (endDate.year - startDate.year) * 360.0 + + (endDate.month - startDate.month) * (double)SHORT_MONTH_LEN + + (date2day - date1day) * 1.0; return dayCount / 360; } @@ -223,7 +223,7 @@ final class YearFracCalculator { } return false; } - + if (isLeapYear(end.year)) { switch (end.month) { case SimpleDate.JANUARY: @@ -245,14 +245,14 @@ final class YearFracCalculator { private static int dateDiff(long startDateMS, long endDateMS) { long msDiff = endDateMS - startDateMS; - // some extra checks to make sure we don't hide some other bug with the rounding + // some extra checks to make sure we don't hide some other bug with the rounding int remainderHours = (int) ((msDiff % MS_PER_DAY) / MS_PER_HOUR); switch (remainderHours) { case 0: // normal case break; case 1: // transition from normal time to daylight savings adjusted case 23: // transition from daylight savings adjusted to normal time - // Unexpected since we are using UTC_TIME_ZONE + // Unexpected since we are using UTC_TIME_ZONE default: throw new RuntimeException("Unexpected date diff between " + startDateMS + " and " + endDateMS); Modified: poi/trunk/src/java/org/apache/poi/ss/formula/functions/Days360.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/functions/Days360.java?rev=1859595&r1=1859594&r2=1859595&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/ss/formula/functions/Days360.java (original) +++ poi/trunk/src/java/org/apache/poi/ss/formula/functions/Days360.java Tue May 21 00:14:12 2019 @@ -30,17 +30,17 @@ import org.apache.poi.util.LocaleUtil; * (twelve 30-day months), which is used in some accounting calculations. Use * this function to help compute payments if your accounting system is based on * twelve 30-day months.<p> - * + * * {@code DAYS360(start_date,end_date,[method])} - * + * * <ul> * <li>Start_date, end_date (required):<br> * The two dates between which you want to know the number of days.<br> * If start_date occurs after end_date, the DAYS360 function returns a negative number.</li> - * + * * <li>Method (optional):<br> * A logical value that specifies whether to use the U.S. or European method in the calculation</li> - * + * * <li>Method set to false or omitted:<br> * the DAYS360 function uses the U.S. (NASD) method. If the starting date is the 31st of a month, * it becomes equal to the 30th of the same month. If the ending date is the 31st of a month and @@ -51,7 +51,7 @@ import org.apache.poi.util.LocaleUtil; * because the DAYS360 function ignores the extra days added to February.<br> * On a leap year the function {@code =DAYS360("2/29/96","3/1/96", FALSE)} returns 1 day for * the same reason.</li> - * + * * <li>Method Set to true:<br> * When you set the method parameter to TRUE, the DAYS360 function uses the European method. * Starting dates or ending dates that occur on the 31st of a month become equal to the 30th of @@ -62,10 +62,11 @@ import org.apache.poi.util.LocaleUtil; * On a leap year the function {@code =DAYS360("2/29/96", "3/1/96", TRUE)} returns * 2 days for the same reason.</li> * </ul> - * + * * @see <a href="https://support.microsoft.com/en-us/kb/235575">DAYS360 Function Produces Different Values Depending on the Version of Excel</a> */ public class Days360 extends Var2or3ArgFunction { + @Override public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1) { try { double d0 = NumericFunction.singleOperandEvaluate(arg0, srcRowIndex, srcColumnIndex); @@ -76,6 +77,7 @@ public class Days360 extends Var2or3ArgF } } + @Override public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1, ValueEval arg2) { try { @@ -95,8 +97,8 @@ public class Days360 extends Var2or3ArgF int[] startingDate = getStartingDate(realStart, method); int[] endingDate = getEndingDate(realEnd, startingDate, method); return - (endingDate[0]*360+endingDate[1]*30+endingDate[2])- - (startingDate[0]*360+startingDate[1]*30+startingDate[2]); + (endingDate[0]*360.0+endingDate[1]*30.0+endingDate[2])- + (startingDate[0]*360.0+startingDate[1]*30.0+startingDate[2]); } private static Calendar getDate(double date) { @@ -109,9 +111,11 @@ public class Days360 extends Var2or3ArgF int yyyy = realStart.get(Calendar.YEAR); int mm = realStart.get(Calendar.MONTH); int dd = Math.min(30, realStart.get(Calendar.DAY_OF_MONTH)); - - if (!method && isLastDayOfMonth(realStart)) dd = 30; - + + if (!method && isLastDayOfMonth(realStart)) { + dd = 30; + } + return new int[]{yyyy,mm,dd}; } @@ -134,7 +138,7 @@ public class Days360 extends Var2or3ArgF return new int[]{yyyy,mm,dd}; } - + private static boolean isLastDayOfMonth(Calendar date) { int dayOfMonth = date.get(Calendar.DAY_OF_MONTH); int lastDayOfMonth = date.getActualMaximum(Calendar.DAY_OF_MONTH); Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/DateUtil.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/DateUtil.java?rev=1859595&r1=1859594&r2=1859595&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/ss/usermodel/DateUtil.java [UTF-8] (original) +++ poi/trunk/src/java/org/apache/poi/ss/usermodel/DateUtil.java [UTF-8] Tue May 21 00:14:12 2019 @@ -62,7 +62,7 @@ public class DateUtil { private static final Pattern date_ptrn3b = Pattern.compile("^[\\[\\]yYmMdDhHsS\\-T/\u5e74\u6708\u65e5,. :\"\\\\]+0*[ampAMP/]*$"); // elapsed time patterns: [h],[m] and [s] private static final Pattern date_ptrn4 = Pattern.compile("^\\[([hH]+|[mM]+|[sS]+)\\]"); - + // for format which start with "[DBNum1]" or "[DBNum2]" or "[DBNum3]" could be a Chinese date private static final Pattern date_ptrn5 = Pattern.compile("^\\[DBNum(1|2|3)\\]"); @@ -124,11 +124,11 @@ public class DateUtil { // be 4 hours. // E.g. 2004-03-28 04:00 CEST - 2004-03-28 00:00 CET is 3 hours // and 2004-10-31 04:00 CET - 2004-10-31 00:00 CEST is 5 hours - double fraction = (((date.get(Calendar.HOUR_OF_DAY) * 60 + double fraction = (((date.get(Calendar.HOUR_OF_DAY) * 60.0 + date.get(Calendar.MINUTE) - ) * 60 + date.get(Calendar.SECOND) - ) * 1000 + date.get(Calendar.MILLISECOND) - ) / ( double ) DAY_MILLISECONDS; + ) * 60.0 + date.get(Calendar.SECOND) + ) * 1000.0 + date.get(Calendar.MILLISECOND) + ) / DAY_MILLISECONDS; Calendar calStart = dayStart(date); double value = fraction + absoluteDay(calStart, use1904windowing); @@ -145,12 +145,12 @@ public class DateUtil { /** * Given an Excel date with using 1900 date windowing, and * converts it to a java.util.Date. - * - * Excel Dates and Times are stored without any timezone - * information. If you know (through other means) that your file + * + * Excel Dates and Times are stored without any timezone + * information. If you know (through other means) that your file * uses a different TimeZone to the system default, you can use * this version of the getJavaDate() method to handle it. - * + * * @param date The Excel date. * @param tz The TimeZone to evaluate the date in * @return Java representation of the date, or null if date is not a valid Excel date @@ -182,12 +182,12 @@ public class DateUtil { /** * Given an Excel date with either 1900 or 1904 date windowing, * converts it to a java.util.Date. - * - * Excel Dates and Times are stored without any timezone - * information. If you know (through other means) that your file + * + * Excel Dates and Times are stored without any timezone + * information. If you know (through other means) that your file * uses a different TimeZone to the system default, you can use * this version of the getJavaDate() method to handle it. - * + * * @param date The Excel date. * @param tz The TimeZone to evaluate the date in * @param use1904windowing true if date uses 1904 windowing, @@ -197,16 +197,16 @@ public class DateUtil { public static Date getJavaDate(double date, boolean use1904windowing, TimeZone tz) { return getJavaDate(date, use1904windowing, tz, false); } - + /** * Given an Excel date with either 1900 or 1904 date windowing, * converts it to a java.util.Date. - * - * Excel Dates and Times are stored without any timezone - * information. If you know (through other means) that your file + * + * Excel Dates and Times are stored without any timezone + * information. If you know (through other means) that your file * uses a different TimeZone to the system default, you can use * this version of the getJavaDate() method to handle it. - * + * * @param date The Excel date. * @param tz The TimeZone to evaluate the date in * @param use1904windowing true if date uses 1904 windowing, @@ -218,7 +218,7 @@ public class DateUtil { Calendar calendar = getJavaCalendar(date, use1904windowing, tz, roundSeconds); return calendar == null ? null : calendar.getTime(); } - + /** * Given an Excel date with either 1900 or 1904 date windowing, * converts it to a java.util.Date. @@ -314,7 +314,7 @@ public class DateUtil { public static Calendar getJavaCalendar(double date, boolean use1904windowing, TimeZone timeZone) { return getJavaCalendar(date, use1904windowing, timeZone, false); } - + /** * Get EXCEL date as Java Calendar with given time zone. * @param date The Excel date. @@ -345,13 +345,14 @@ public class DateUtil { // string represents a date format if the same string is passed multiple times. // see https://issues.apache.org/bugzilla/show_bug.cgi?id=55611 private static ThreadLocal<Integer> lastFormatIndex = new ThreadLocal<Integer>() { + @Override protected Integer initialValue() { return -1; } }; private static ThreadLocal<String> lastFormatString = new ThreadLocal<>(); private static ThreadLocal<Boolean> lastCachedResult = new ThreadLocal<>(); - + private static boolean isCached(String formatString, int formatIndex) { String cachedFormatString = lastFormatString.get(); return cachedFormatString != null && formatIndex == lastFormatIndex.get() @@ -378,12 +379,14 @@ public class DateUtil { * @see #isInternalDateFormat(int) */ public static boolean isADateFormat(ExcelNumberFormat numFmt) { - - if (numFmt == null) return false; - + + if (numFmt == null) { + return false; + } + return isADateFormat(numFmt.getIdx(), numFmt.getFormat()); } - + /** * Given a format ID and its format String, will check to see if the * format represents a date format or not. @@ -399,7 +402,7 @@ public class DateUtil { * @see #isInternalDateFormat(int) */ public static boolean isADateFormat(int formatIndex, String formatString) { - + // First up, is this an internal date format? if(isInternalDateFormat(formatIndex)) { cache(formatString, formatIndex, true); @@ -469,7 +472,7 @@ public class DateUtil { return true; } // If it starts with [DBNum1] or [DBNum2] or [DBNum3] - // then it could be a Chinese date + // then it could be a Chinese date fs = date_ptrn5.matcher(fs).replaceAll(""); // If it starts with [$-...], then could be a date, but // who knows what that starting bit is all about @@ -490,7 +493,7 @@ public class DateUtil { if (! date_ptrn3a.matcher(fs).find()) { return false; } - + // If we get here, check it's only made up, in any case, of: // y m d h s - \ / , . : [ ] T // optionally followed by AM/PM @@ -530,7 +533,7 @@ public class DateUtil { * Check if a cell contains a date * Since dates are stored internally in Excel as double values * we infer it is a date if it is formatted as such. - * @param cell + * @param cell * @return true if it looks like a date * @see #isADateFormat(int, String) * @see #isInternalDateFormat(int) @@ -538,32 +541,36 @@ public class DateUtil { public static boolean isCellDateFormatted(Cell cell) { return isCellDateFormatted(cell, null); } - + /** * Check if a cell contains a date * Since dates are stored internally in Excel as double values * we infer it is a date if it is formatted as such. * Format is determined from applicable conditional formatting, if * any, or cell style. - * @param cell + * @param cell * @param cfEvaluator if available, or null * @return true if it looks like a date * @see #isADateFormat(int, String) * @see #isInternalDateFormat(int) */ public static boolean isCellDateFormatted(Cell cell, ConditionalFormattingEvaluator cfEvaluator) { - if (cell == null) return false; + if (cell == null) { + return false; + } boolean bDate = false; double d = cell.getNumericCellValue(); if ( DateUtil.isValidExcelDate(d) ) { ExcelNumberFormat nf = ExcelNumberFormat.from(cell, cfEvaluator); - if(nf==null) return false; + if(nf==null) { + return false; + } bDate = isADateFormat(nf); } return bDate; } - + /** * Check if a cell contains a date, checking only for internal * excel date formats. @@ -573,7 +580,9 @@ public class DateUtil { * @see #isInternalDateFormat(int) */ public static boolean isCellInternalDateFormatted(Cell cell) { - if (cell == null) return false; + if (cell == null) { + return false; + } boolean bDate = false; double d = cell.getNumericCellValue(); @@ -691,7 +700,7 @@ public class DateUtil { int minutes = parseInt(minStr, "minute", MINUTES_PER_HOUR); int seconds = parseInt(secStr, "second", SECONDS_PER_MINUTE); - double totalSeconds = seconds + (minutes + (hours) * 60) * 60; + double totalSeconds = seconds + (minutes + (hours * 60.0)) * 60.0; return totalSeconds / (SECONDS_PER_DAY); } /** Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/ExcelStyleDateFormatter.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/ExcelStyleDateFormatter.java?rev=1859595&r1=1859594&r2=1859595&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/ss/usermodel/ExcelStyleDateFormatter.java (original) +++ poi/trunk/src/java/org/apache/poi/ss/usermodel/ExcelStyleDateFormatter.java Tue May 21 00:14:12 2019 @@ -16,13 +16,17 @@ ==================================================================== */ package org.apache.poi.ss.usermodel; -import java.util.*; +import java.math.RoundingMode; +import java.text.DateFormatSymbols; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.text.FieldPosition; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; import org.apache.poi.util.LocaleUtil; -import java.math.RoundingMode; -import java.text.*; - /** * A wrapper around a {@link SimpleDateFormat} instance, * which handles a few Excel-style extensions that @@ -60,7 +64,7 @@ public class ExcelStyleDateFormatter ext DataFormatter.setExcelStyleRoundingMode(format3digit); DataFormatter.setExcelStyleRoundingMode(format4digits); } - + { setTimeZone(LocaleUtil.getUserTimeZone()); } @@ -152,7 +156,7 @@ public class ExcelStyleDateFormatter ext } if (s.indexOf(S_BRACKET_SYMBOL) != -1 || s.indexOf(SS_BRACKET_SYMBOL) != -1) { - float seconds = (float) (dateToBeFormatted * 24.0 * 60.0 * 60.0); + float seconds = (float) (dateToBeFormatted * 24 * 60 * 60); s = s.replaceAll( String.valueOf(S_BRACKET_SYMBOL), format1digit.format(seconds) @@ -165,15 +169,15 @@ public class ExcelStyleDateFormatter ext if (s.indexOf(L_BRACKET_SYMBOL) != -1 || s.indexOf(LL_BRACKET_SYMBOL) != -1) { - float millisTemp = (float) ((dateToBeFormatted - Math.floor(dateToBeFormatted)) * 24.0 * 60.0 * 60.0); + float millisTemp = (float) ((dateToBeFormatted - Math.floor(dateToBeFormatted)) * 24 * 60 * 60); float millis = (millisTemp - (int) millisTemp); s = s.replaceAll( String.valueOf(L_BRACKET_SYMBOL), - format3digit.format(millis * 10) + format3digit.format(millis * 10.0) ); s = s.replaceAll( String.valueOf(LL_BRACKET_SYMBOL), - format4digits.format(millis * 100) + format4digits.format(millis * 100.0) ); } @@ -185,11 +189,11 @@ public class ExcelStyleDateFormatter ext if (!(o instanceof ExcelStyleDateFormatter)) { return false; } - + ExcelStyleDateFormatter other = (ExcelStyleDateFormatter) o; return dateToBeFormatted == other.dateToBeFormatted; } - + @Override public int hashCode() { return Double.valueOf(dateToBeFormatted).hashCode(); Modified: poi/trunk/src/java/org/apache/poi/ss/util/ImageUtils.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/util/ImageUtils.java?rev=1859595&r1=1859594&r2=1859595&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/ss/util/ImageUtils.java (original) +++ poi/trunk/src/java/org/apache/poi/ss/util/ImageUtils.java Tue May 21 00:14:12 2019 @@ -122,10 +122,14 @@ public class ImageUtils { NodeList lst; Element node = (Element)r.getImageMetadata(0).getAsTree("javax_imageio_1.0"); lst = node.getElementsByTagName("HorizontalPixelSize"); - if(lst != null && lst.getLength() == 1) hdpi = (int)(mm2inch/Float.parseFloat(((Element)lst.item(0)).getAttribute("value"))); + if(lst != null && lst.getLength() == 1) { + hdpi = (int)(mm2inch/Float.parseFloat(((Element)lst.item(0)).getAttribute("value"))); + } lst = node.getElementsByTagName("VerticalPixelSize"); - if(lst != null && lst.getLength() == 1) vdpi = (int)(mm2inch/Float.parseFloat(((Element)lst.item(0)).getAttribute("value"))); + if(lst != null && lst.getLength() == 1) { + vdpi = (int)(mm2inch/Float.parseFloat(((Element)lst.item(0)).getAttribute("value"))); + } return new int[]{hdpi, vdpi}; } @@ -142,7 +146,7 @@ public class ImageUtils { boolean isHSSF = (anchor instanceof HSSFClientAnchor); PictureData data = picture.getPictureData(); Sheet sheet = picture.getSheet(); - + // in pixel Dimension imgSize = getImageDimension(new ByteArrayInputStream(data.getData()), data.getPictureType()); // in emus @@ -163,11 +167,11 @@ public class ImageUtils { } else { w -= anchor.getDx1()/(double)EMU_PER_PIXEL; } - + while(w < scaledWidth){ w += sheet.getColumnWidthInPixels(col2++); } - + if(w > scaledWidth) { //calculate dx2, offset in the rightmost cell double cw = sheet.getColumnWidthInPixels(--col2); @@ -177,7 +181,9 @@ public class ImageUtils { } else { dx2 = (int)((cw-delta)*EMU_PER_PIXEL); } - if (dx2 < 0) dx2 = 0; + if (dx2 < 0) { + dx2 = 0; + } } anchor.setCol2(col2); anchor.setDx2(dx2); @@ -185,7 +191,7 @@ public class ImageUtils { double h = 0; int row2 = anchor.getRow1(); int dy2 = 0; - + h = getRowHeightInPixels(sheet,row2++); if (isHSSF) { h *= 1 - anchor.getDy1()/256d; @@ -196,7 +202,7 @@ public class ImageUtils { while(h < scaledHeight){ h += getRowHeightInPixels(sheet,row2++); } - + if(h > scaledHeight) { double ch = getRowHeightInPixels(sheet,--row2); double delta = h - scaledHeight; @@ -205,7 +211,9 @@ public class ImageUtils { } else { dy2 = (int)((ch-delta)*EMU_PER_PIXEL); } - if (dy2 < 0) dy2 = 0; + if (dy2 < 0) { + dy2 = 0; + } } anchor.setRow2(row2); @@ -238,20 +246,20 @@ public class ImageUtils { } else { w -= anchor.getDx1()/(double)EMU_PER_PIXEL; } - + while(col2 < anchor.getCol2()){ w += sheet.getColumnWidthInPixels(col2++); } - + if (isHSSF) { - w += sheet.getColumnWidthInPixels(col2) * anchor.getDx2()/1024d; + w += anchor.getDx2()/1024d * sheet.getColumnWidthInPixels(col2); } else { w += anchor.getDx2()/(double)EMU_PER_PIXEL; } double h = 0; int row2 = anchor.getRow1(); - + h = getRowHeightInPixels(sheet,row2++); if (isHSSF) { h *= 1 - anchor.getDy1()/256d; @@ -262,7 +270,7 @@ public class ImageUtils { while(row2 < anchor.getRow2()){ h += getRowHeightInPixels(sheet,row2++); } - + if (isHSSF) { h += getRowHeightInPixels(sheet,row2) * anchor.getDy2()/256; } else { @@ -271,11 +279,11 @@ public class ImageUtils { w *= EMU_PER_PIXEL; h *= EMU_PER_PIXEL; - + return new Dimension((int)Math.rint(w), (int)Math.rint(h)); } - - + + public static double getRowHeightInPixels(Sheet sheet, int rowNum) { Row r = sheet.getRow(rowNum); double points = (r == null) ? sheet.getDefaultRowHeightInPoints() : r.getHeightInPoints(); Modified: poi/trunk/src/java/org/apache/poi/ss/util/cellwalk/CellWalk.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/util/cellwalk/CellWalk.java?rev=1859595&r1=1859594&r2=1859595&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/ss/util/cellwalk/CellWalk.java (original) +++ poi/trunk/src/java/org/apache/poi/ss/util/cellwalk/CellWalk.java Tue May 21 00:14:12 2019 @@ -5,9 +5,9 @@ The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -116,14 +116,17 @@ public class CellWalk { public int rowNumber; public int colNumber; + @Override public long getOrdinalNumber() { return ordinalNumber; } + @Override public int getRowNumber() { return rowNumber; } + @Override public int getColumnNumber() { return colNumber; } Modified: poi/trunk/src/java/org/apache/poi/util/StringUtil.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/StringUtil.java?rev=1859595&r1=1859594&r2=1859595&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/util/StringUtil.java (original) +++ poi/trunk/src/java/org/apache/poi/util/StringUtil.java Tue May 21 00:14:12 2019 @@ -263,7 +263,7 @@ public class StringUtil { } public static String readUnicodeLE(LittleEndianInput in, int nChars) { - byte[] bytes = IOUtils.safelyAllocate(nChars * 2, MAX_RECORD_LENGTH); + byte[] bytes = IOUtils.safelyAllocate(nChars * 2L, MAX_RECORD_LENGTH); in.readFully(bytes); return new String(bytes, UTF16LE); } Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfComment.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfComment.java?rev=1859595&r1=1859594&r2=1859595&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfComment.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hemf/record/emf/HemfComment.java Tue May 21 00:14:12 2019 @@ -69,7 +69,9 @@ public class HemfComment { public static HemfCommentRecordType getById(long id, boolean isEmfPublic) { for (HemfCommentRecordType wrt : values()) { - if (wrt.id == id && wrt.isEmfPublic == isEmfPublic) return wrt; + if (wrt.id == id && wrt.isEmfPublic == isEmfPublic) { + return wrt; + } } return emfGeneric; } @@ -277,7 +279,7 @@ public class HemfComment { // The number of Unicode characters in the optional description string that follows. int nDescription = (int)leis.readUInt(); - byte[] buf = IOUtils.safelyAllocate(nDescription*2, MAX_RECORD_LENGTH); + byte[] buf = IOUtils.safelyAllocate(nDescription * 2L, MAX_RECORD_LENGTH); leis.readFully(buf); description = new String(buf, StandardCharsets.UTF_16LE); @@ -373,7 +375,9 @@ public class HemfComment { public static EmfFormatSignature getById(int id) { for (EmfFormatSignature wrt : values()) { - if (wrt.id == id) return wrt; + if (wrt.id == id) { + return wrt; + } } return null; } Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/qcbits/QCTextBit.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/qcbits/QCTextBit.java?rev=1859595&r1=1859594&r2=1859595&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/qcbits/QCTextBit.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hpbf/model/qcbits/QCTextBit.java Tue May 21 00:14:12 2019 @@ -41,7 +41,7 @@ public final class QCTextBit extends QCB } public void setText(String text) { - byte[] data = IOUtils.safelyAllocate(text.length() * 2, MAX_RECORD_LENGTH); + byte[] data = IOUtils.safelyAllocate(text.length() * 2L, MAX_RECORD_LENGTH); StringUtil.putUnicodeLE(text, data, 0); setData(data); } Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/CurrentUserAtom.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/CurrentUserAtom.java?rev=1859595&r1=1859594&r2=1859595&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/CurrentUserAtom.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/CurrentUserAtom.java Tue May 21 00:14:12 2019 @@ -15,7 +15,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ - + package org.apache.poi.hslf.record; @@ -73,7 +73,7 @@ public class CurrentUserAtom /** Only correct after reading in or writing out */ private byte[] _contents; - + /** Flag for encryption state of the whole file */ private boolean isEncrypted; @@ -96,7 +96,7 @@ public class CurrentUserAtom public boolean isEncrypted() { return isEncrypted; } public void setEncrypted(boolean isEncrypted) { this.isEncrypted = isEncrypted; } - + /* ********************* real code follows *************************** */ @@ -117,19 +117,19 @@ public class CurrentUserAtom } - /** + /** * Find the Current User in the filesystem, and create from that */ public CurrentUserAtom(DirectoryNode dir) throws IOException { // Decide how big it is DocumentEntry docProps = (DocumentEntry)dir.getEntry("Current User"); - + // If it's clearly junk, bail out if(docProps.getSize() > 131072) { throw new CorruptPowerPointFileException("The Current User stream is implausably long. It's normally 28-200 bytes long, but was " + docProps.getSize() + " bytes"); } - + // Grab the contents int len = docProps.getSize(); _contents = IOUtils.safelyAllocate(len, MAX_RECORD_LENGTH); @@ -140,8 +140,8 @@ public class CurrentUserAtom if (len != readLen) { throw new IOException("Current User input stream ended prematurely - expected "+len+" bytes - received "+readLen+" bytes"); } - - + + // See how long it is. If it's under 28 bytes long, we can't // read it if(_contents.length < 28) { @@ -169,9 +169,9 @@ public class CurrentUserAtom private void init() { // First up is the size, in 4 bytes, which is fixed // Then is the header - - isEncrypted = (LittleEndian.getInt(encHeaderToken) == LittleEndian.getInt(_contents,12)); - + + isEncrypted = (LittleEndian.getInt(encHeaderToken) == LittleEndian.getInt(_contents,12)); + // Grab the edit offset currentEditOffset = LittleEndian.getUInt(_contents,16); @@ -188,7 +188,7 @@ public class CurrentUserAtom usernameLen = 0; } - // Now we know the length of the username, + // Now we know the length of the username, // use this to grab the revision if(_contents.length >= 28+(int)usernameLen + 4) { releaseVersion = LittleEndian.getUInt(_contents,28+(int)usernameLen); @@ -227,7 +227,7 @@ public class CurrentUserAtom _contents = IOUtils.safelyAllocate(size, MAX_RECORD_LENGTH); // First we have a 8 byte atom header - System.arraycopy(atomHeader,0,_contents,0,4); + System.arraycopy(atomHeader,0,_contents,0,4); // Size is 20+user len + revision len(4) int atomSize = 20+4+lastEditUser.length(); LittleEndian.putInt(_contents,4,atomSize); @@ -241,14 +241,14 @@ public class CurrentUserAtom // Now the current edit offset LittleEndian.putInt(_contents,16,(int)currentEditOffset); - // The username gets stored twice, once as US + // The username gets stored twice, once as US // ascii, and again as unicode laster on byte[] asciiUN = IOUtils.safelyAllocate(lastEditUser.length(), MAX_RECORD_LENGTH); StringUtil.putCompressedUnicode(lastEditUser,asciiUN,0); - + // Now we're able to do the length of the last edited user LittleEndian.putShort(_contents,20,(short)asciiUN.length); - + // Now the file versions, 2+1+1 LittleEndian.putShort(_contents,22,(short)docFinalVersion); _contents[24] = docMajorNo; @@ -265,7 +265,7 @@ public class CurrentUserAtom LittleEndian.putInt(_contents,28+asciiUN.length,(int)releaseVersion); // username in unicode - byte [] ucUN = IOUtils.safelyAllocate(lastEditUser.length()*2, MAX_RECORD_LENGTH); + byte [] ucUN = IOUtils.safelyAllocate(lastEditUser.length() * 2L, MAX_RECORD_LENGTH); StringUtil.putUnicodeLE(lastEditUser,ucUN,0); System.arraycopy(ucUN,0,_contents,28+asciiUN.length+4,ucUN.length); @@ -280,7 +280,7 @@ public class CurrentUserAtom // Grab contents ByteArrayOutputStream baos = new ByteArrayOutputStream(); writeOut(baos); - ByteArrayInputStream bais = + ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); // Write out Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/MasterTextPropAtom.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/MasterTextPropAtom.java?rev=1859595&r1=1859594&r2=1859595&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/MasterTextPropAtom.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/MasterTextPropAtom.java Tue May 21 00:14:12 2019 @@ -59,7 +59,7 @@ public final class MasterTextPropAtom ex LittleEndian.putShort(_header, 2, (short)getRecordType()); LittleEndian.putInt(_header, 4, _data.length); - + indents = new ArrayList<>(); } @@ -92,6 +92,7 @@ public final class MasterTextPropAtom ex * * @return the record type. */ + @Override public long getRecordType() { return RecordTypes.MasterTextPropAtom.typeID; } @@ -103,12 +104,13 @@ public final class MasterTextPropAtom ex * @param out the output stream to write to. * @throws java.io.IOException if an error occurs. */ + @Override public void writeOut(OutputStream out) throws IOException { write(); out.write(_header); out.write(_data); } - + /** * Write the internal variables to the record bytes */ @@ -129,7 +131,7 @@ public final class MasterTextPropAtom ex private void read() { int pos = 0; indents = new ArrayList<>(_data.length / 6); - + while (pos <= _data.length - 6) { int count = LittleEndian.getInt(_data, pos); short indent = LittleEndian.getShort(_data, pos+4); @@ -137,7 +139,7 @@ public final class MasterTextPropAtom ex pos += 6; } } - + /** * Returns the indent that applies at the given text offset */ @@ -151,7 +153,7 @@ public final class MasterTextPropAtom ex } return -1; } - + public List<IndentProp> getIndents() { return Collections.unmodifiableList(indents); } Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextCharsAtom.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextCharsAtom.java?rev=1859595&r1=1859594&r2=1859595&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextCharsAtom.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextCharsAtom.java Tue May 21 00:14:12 2019 @@ -48,7 +48,7 @@ public final class TextCharsAtom extends /** Updates the text in the Atom. */ public void setText(String text) { // Convert to little endian unicode - _text = IOUtils.safelyAllocate(text.length()*2, MAX_RECORD_LENGTH); + _text = IOUtils.safelyAllocate(text.length() * 2L, MAX_RECORD_LENGTH); StringUtil.putUnicodeLE(text,_text,0); // Update the size (header bytes 5-8) Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoRun.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoRun.java?rev=1859595&r1=1859594&r2=1859595&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoRun.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoRun.java Tue May 21 00:14:12 2019 @@ -20,7 +20,10 @@ package org.apache.poi.hslf.record; import java.io.IOException; import java.io.OutputStream; -import org.apache.poi.util.*; +import org.apache.poi.util.BitField; +import org.apache.poi.util.IOUtils; +import org.apache.poi.util.LittleEndian; +import org.apache.poi.util.LittleEndianByteArrayInputStream; public class TextSpecInfoRun { @@ -39,14 +42,14 @@ public class TextSpecInfoRun { grammar(new BitField(4)), /** the text is spelled correct */ correct(new BitField(0)); - + final BitField bitField; - + SpellInfoEnum(BitField bitField) { this.bitField = bitField; } } - + /** A bit that specifies whether the spellInfo field exists. */ private static final BitField spellFld = new BitField(0X00000001); /** A bit that specifies whether the lid field exists. */ @@ -62,7 +65,7 @@ public class TextSpecInfoRun { // reserved1 - MUST be zero and MUST be ignored. /** A bit that specifies whether the smartTags field exists. */ private static final BitField smartTagFld = new BitField(0X00000200); - // reserved2 - MUST be zero and MUST be ignored. + // reserved2 - MUST be zero and MUST be ignored. /** * An optional unsigned integer that specifies an identifier for a character @@ -76,7 +79,7 @@ public class TextSpecInfoRun { * only if fPp10ext is TRUE. **/ private static final BitField grammarErrorFld = new BitField(0X80000000); - + //Length of special info run. private int length; @@ -97,7 +100,7 @@ public class TextSpecInfoRun { * reserved (13 bits): MUST be zero and MUST be ignored. */ private short spellInfo = -1; - + /** * An optional TxLCID that specifies the language identifier of this text. * It MUST exist if and only if lang is TRUE. @@ -108,13 +111,13 @@ public class TextSpecInfoRun { * > 0x0400 = A valid LCID as specified by [MS-LCID]. */ private short langId = -1; - + /** * An optional TxLCID that specifies the alternate language identifier of this text. * It MUST exist if and only if altLang is TRUE. */ private short altLangId = -1; - + /** * An optional signed integer that specifies whether the text contains bidirectional * characters. It MUST exist if and only if fBidi is TRUE. @@ -122,7 +125,7 @@ public class TextSpecInfoRun { * 0x0001 = Contains bidirectional characters. */ private short bidi = -1; - + private int pp10extMask = -1; private byte[] smartTagsBytes; @@ -135,7 +138,7 @@ public class TextSpecInfoRun { setLength(len); setLangId((short)0); } - + public TextSpecInfoRun(LittleEndianByteArrayInputStream source) { length = source.readInt(); mask = source.readInt(); @@ -157,7 +160,7 @@ public class TextSpecInfoRun { if (smartTagFld.isSet(mask)) { // An unsigned integer specifies the count of items in rgSmartTagIndex. int count = source.readInt(); - smartTagsBytes = IOUtils.safelyAllocate(4+count*4, MAX_RECORD_LENGTH); + smartTagsBytes = IOUtils.safelyAllocate(4 + count * 4L, MAX_RECORD_LENGTH); LittleEndian.putInt(smartTagsBytes, 0, count); // An array of SmartTagIndex that specifies the indices. // The count of items in the array is specified by count. @@ -186,11 +189,13 @@ public class TextSpecInfoRun { pp10extFld, pp10extMask, "pp10 extension field", smartTagFld, smartTagsBytes, "smart tags" }; - + for (int i=0; i<flds.length-1; i+=3) { BitField fld = (BitField)flds[i+0]; Object valO = flds[i+1]; - if (!fld.isSet(mask)) continue; + if (!fld.isSet(mask)) { + continue; + } boolean valid; if (valO instanceof byte[]) { byte[] bufB = (byte[]) valO; @@ -214,15 +219,19 @@ public class TextSpecInfoRun { throw new IOException(fval + " is activated, but its value is invalid"); } } - } - + } + /** * @return Spelling status of this text. null if not defined. */ public SpellInfoEnum getSpellInfo(){ - if (spellInfo == -1) return null; + if (spellInfo == -1) { + return null; + } for (SpellInfoEnum si : new SpellInfoEnum[]{SpellInfoEnum.clean,SpellInfoEnum.error,SpellInfoEnum.grammar}) { - if (si.bitField.isSet(spellInfo)) return si; + if (si.bitField.isSet(spellInfo)) { + return si; + } } return SpellInfoEnum.correct; } @@ -236,7 +245,7 @@ public class TextSpecInfoRun { : (short)spellInfo.bitField.set(0); mask = spellFld.setBoolean(mask, spellInfo != null); } - + /** * Windows LANGID for this text. * @@ -253,7 +262,7 @@ public class TextSpecInfoRun { this.langId = langId; mask = langFld.setBoolean(mask, langId != -1); } - + /** * Alternate Windows LANGID of this text; * must be a valid non-East Asian LANGID if the text has an East Asian language, @@ -313,15 +322,15 @@ public class TextSpecInfoRun { this.smartTagsBytes = (smartTagsBytes == null) ? null : smartTagsBytes.clone(); mask = smartTagFld.setBoolean(mask, smartTagsBytes != null); } - + /** * @return an identifier for a character run that contains StyleTextProp11 data. */ public int getPP10RunId() { return (pp10extMask == -1 || !pp10extFld.isSet(mask)) ? -1 : pp10runidFld.getValue(pp10extMask); - + } - + /** * @param pp10RunId an identifier for a character run that contains StyleTextProp11 data, -1 to unset */ @@ -334,11 +343,11 @@ public class TextSpecInfoRun { // if both parameters are invalid, remove the extension mask mask = pp10extFld.setBoolean(mask, pp10extMask != -1); } - + public Boolean getGrammarError() { return (pp10extMask == -1 || !pp10extFld.isSet(mask)) ? null : grammarErrorFld.isSet(pp10extMask); } - + public void getGrammarError(Boolean grammarError) { if (grammarError == null) { pp10extMask = (getPP10RunId() == -1) ? -1 : grammarErrorFld.clear(pp10extMask); Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfDraw.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfDraw.java?rev=1859595&r1=1859594&r2=1859595&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfDraw.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfDraw.java Tue May 21 00:14:12 2019 @@ -108,7 +108,7 @@ public class HwmfDraw { public static class WmfPolygon implements HwmfRecord { protected Path2D poly; - + @Override public HwmfRecordType getWmfRecordType() { return HwmfRecordType.polygon; @@ -266,8 +266,8 @@ public class HwmfDraw { Rectangle2D inner = ctx.getProperties().getRegion().getBounds(); double x = inner.getX()-width; double y = inner.getY()-height; - double w = inner.getWidth()+2*width; - double h = inner.getHeight()+2*height; + double w = inner.getWidth()+2.0*width; + double h = inner.getHeight()+2.0*height; Rectangle2D outer = new Rectangle2D.Double(x,y,w,h); Area frame = new Area(outer); frame.subtract(new Area(inner)); @@ -283,7 +283,7 @@ public class HwmfDraw { public static class WmfPolyPolygon implements HwmfRecord { protected final List<Path2D> polyList = new ArrayList<>(); - + @Override public HwmfRecordType getWmfRecordType() { return HwmfRecordType.polyPolygon; @@ -577,7 +577,6 @@ public class HwmfDraw { startAngle += 360; } - boolean fillShape; int arcClosure; switch (getWmfRecordType()) { default: @@ -671,7 +670,7 @@ public class HwmfDraw { return "{ index: "+objectIndex +" }"; } } - + static int readBounds(LittleEndianInputStream leis, Rectangle2D bounds) { /** * The 16-bit signed integers that defines the corners of the bounding rectangle. Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java?rev=1859595&r1=1859594&r2=1859595&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java Tue May 21 00:14:12 2019 @@ -92,7 +92,7 @@ public class WordToHtmlConverter extends /** * Creates new instance of {@link WordToHtmlConverter}. Can be used for * output several {@link HWPFDocument}s into single HTML document. - * + * * @param document XML DOM Document used as HTML document */ public WordToHtmlConverter( Document document ) { @@ -102,7 +102,7 @@ public class WordToHtmlConverter extends public WordToHtmlConverter( HtmlDocumentFacade htmlDocumentFacade ) { this.htmlDocumentFacade = htmlDocumentFacade; } - + private static String getSectionStyle( Section section ) { float leftMargin = section.getMarginLeft() / TWIPS_PER_INCH; @@ -132,9 +132,9 @@ public class WordToHtmlConverter extends /** * Java main() interface to interact with {@link WordToHtmlConverter}<p> - * + * * Usage: WordToHtmlConverter infile outfile<p> - * + * * Where infile is an input .doc file ( Word 95-2007) which will be rendered * as HTML into outfile */ @@ -344,11 +344,11 @@ public class WordToHtmlConverter extends if ( aspectRatioX > 0 ) { - imageWidth = picture.getDxaGoal() * aspectRatioX / 1000.f + imageWidth = aspectRatioX / 1000.f * picture.getDxaGoal() / TWIPS_PER_INCH; - cropRight = picture.getDxaCropRight() * aspectRatioX / 1000.f + cropRight = aspectRatioX / 1000.f * picture.getDxaCropRight() / TWIPS_PER_INCH; - cropLeft = picture.getDxaCropLeft() * aspectRatioX / 1000.f + cropLeft = aspectRatioX / 1000.f * picture.getDxaCropLeft() / TWIPS_PER_INCH; } else @@ -360,11 +360,11 @@ public class WordToHtmlConverter extends if ( aspectRatioY > 0 ) { - imageHeight = picture.getDyaGoal() * aspectRatioY / 1000.f + imageHeight = aspectRatioY / 1000.f * picture.getDyaGoal() / TWIPS_PER_INCH; - cropTop = picture.getDyaCropTop() * aspectRatioY / 1000.f + cropTop = aspectRatioY / 1000.f * picture.getDyaCropTop() / TWIPS_PER_INCH; - cropBottom = picture.getDyaCropBottom() * aspectRatioY / 1000.f + cropBottom = aspectRatioY / 1000.f * picture.getDyaCropBottom() / TWIPS_PER_INCH; } else Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmUtils.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmUtils.java?rev=1859595&r1=1859594&r2=1859595&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmUtils.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmUtils.java Tue May 21 00:14:12 2019 @@ -37,7 +37,7 @@ public final class SprmUtils public static byte[] shortArrayToByteArray(short[] convert) { - byte[] buf = IOUtils.safelyAllocate(convert.length * LittleEndian.SHORT_SIZE, MAX_RECORD_LENGTH); + byte[] buf = IOUtils.safelyAllocate(convert.length * (long)LittleEndian.SHORT_SIZE, MAX_RECORD_LENGTH); for (int x = 0; x < convert.length; x++) { @@ -102,7 +102,7 @@ public final class SprmUtils break; default: //should never happen - throw new RuntimeException("Invalid sprm type"); + throw new RuntimeException("Invalid sprm type"); } LittleEndian.putShort(sprm, 0, instruction); list.add(sprm); Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/TableSprmCompressor.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/TableSprmCompressor.java?rev=1859595&r1=1859594&r2=1859595&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/TableSprmCompressor.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/sprm/TableSprmCompressor.java Tue May 21 00:14:12 2019 @@ -81,7 +81,9 @@ public final class TableSprmCompressor { int itcMac = newTAP.getItcMac(); byte[] buf = IOUtils.safelyAllocate( - 1 + (LittleEndian.SHORT_SIZE*(itcMac + 1)) + (TableCellDescriptor.SIZE*itcMac), + 1 + + (LittleEndian.SHORT_SIZE*((long)itcMac + 1)) + + (TableCellDescriptor.SIZE*(long)itcMac), MAX_RECORD_LENGTH); buf[0] = (byte)itcMac; --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@poi.apache.org For additional commands, e-mail: commits-h...@poi.apache.org