From: Andreas Beeker Date: Thu, 12 Sep 2019 20:04:50 +0000 (+0000) Subject: remove obsolete JDK6 workarounds X-Git-Tag: REL_4_1_1~28 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8e95d5d9c12e5476a9f5c2162a89eca89b12bb17;p=poi.git remove obsolete JDK6 workarounds git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1866862 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/integrationtest/log4j.properties b/src/integrationtest/log4j.properties index f2aea6851f..85a87f5248 100644 --- a/src/integrationtest/log4j.properties +++ b/src/integrationtest/log4j.properties @@ -30,7 +30,6 @@ log4j.logger.org.apache.poi.hdgf.chunks.Chunk=FATAL log4j.logger.org.apache.poi.hpsf.CodePageString=ERROR log4j.logger.org.apache.poi.hdgf.chunks.ChunkFactory=ERROR log4j.logger.org.apache.poi.hslf.model.textproperties.BitMaskTextProp=ERROR -log4j.logger.org.apache.poi.util.JvmBugs=ERROR log4j.logger.org.apache.poi.hslf.usermodel.HSLFTextParagraph=ERROR log4j.logger.org.apache.poi.openxml4j.opc.ZipPackage=ERROR log4j.logger.org.apache.poi.POIDocument=WARN diff --git a/src/java/org/apache/poi/util/JvmBugs.java b/src/java/org/apache/poi/util/JvmBugs.java deleted file mode 100644 index d79c8d65b5..0000000000 --- a/src/java/org/apache/poi/util/JvmBugs.java +++ /dev/null @@ -1,56 +0,0 @@ -/* ==================================================================== - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - 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. - See the License for the specific language governing permissions and - limitations under the License. -==================================================================== */ -package org.apache.poi.util; - -import java.util.Locale; - -public class JvmBugs { - private static final POILogger LOG = POILogFactory.getLogger(JvmBugs.class); - - /** - * The LineBreakMeasurer is used for calculating text bounds. - * The last official JDK 6 version (1.6.0_45) and also JDK 7 (1.7.0_21) - * for Windows are affected. For JDK 7 - update to a more recent version. - * For JDK 6 - replace the fontmanager.dll with the previous release (1.6.0_43). - * - * For performance reasons, this method only checks for a windows jvm - * with version 1.6.0_45 and 1.7.0_21. - * - * Set system property "org.apache.poi.JvmBugs.LineBreakMeasurer.ignore" to "true" - * to bypass this check and use the normal fonts. - * - * @return true, if jvm is bugged, caller code should use Lucida Sans - * instead of Calibri and Lucida Bright instead of Cambria - * - * @see Workaround for XSLF - * @see Workaround for XSSF and HSSF - * @see POI Bug #54904 - * @see JDK Bug #6501991 - * @see JDK Bug #8013716 - * @see LineBreakMeasurerTest - */ - public static boolean hasLineBreakMeasurerBug() { - String version = System.getProperty("java.version"); - String os = System.getProperty("os.name").toLowerCase(Locale.ROOT); - boolean ignore = Boolean.getBoolean("org.apache.poi.JvmBugs.LineBreakMeasurer.ignore"); - boolean hasBug = (!ignore && (os.contains("win") && ("1.6.0_45".equals(version) || "1.7.0_21".equals(version)))); - if (hasBug) { - LOG.log(POILogger.WARN, "JVM has LineBreakMeasurer bug - see POI bug #54904 - caller code might default to Lucida Sans"); - } - return hasBug; - } -} diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetAutosizeColumn.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetAutosizeColumn.java index 6004580383..870b2179e3 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetAutosizeColumn.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetAutosizeColumn.java @@ -25,7 +25,6 @@ import java.util.Locale; import org.apache.poi.ss.ITestDataProvider; import org.apache.poi.ss.util.CellRangeAddress; -import org.apache.poi.util.JvmBugs; import org.apache.poi.util.LocaleUtil; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -64,7 +63,6 @@ public abstract class BaseTestSheetAutosizeColumn { @Test public void numericCells() throws Exception { Workbook workbook = _testDataProvider.createWorkbook(); - fixFonts(workbook); DataFormat df = workbook.getCreationHelper().createDataFormat(); Sheet sheet = workbook.createSheet(); trackColumnsForAutoSizingIfSXSSF(sheet); @@ -107,7 +105,6 @@ public abstract class BaseTestSheetAutosizeColumn { @Test public void booleanCells() throws Exception { Workbook workbook = _testDataProvider.createWorkbook(); - fixFonts(workbook); Sheet sheet = workbook.createSheet(); trackColumnsForAutoSizingIfSXSSF(sheet); @@ -139,7 +136,6 @@ public abstract class BaseTestSheetAutosizeColumn { @Test public void dateCells() throws Exception { Workbook workbook = _testDataProvider.createWorkbook(); - fixFonts(workbook); Sheet sheet = workbook.createSheet(); trackColumnsForAutoSizingIfSXSSF(sheet); DataFormat df = workbook.getCreationHelper().createDataFormat(); @@ -207,7 +203,6 @@ public abstract class BaseTestSheetAutosizeColumn { @Test public void stringCells() throws Exception { Workbook workbook = _testDataProvider.createWorkbook(); - fixFonts(workbook); Sheet sheet = workbook.createSheet(); trackColumnsForAutoSizingIfSXSSF(sheet); Row row = sheet.createRow(0); @@ -234,8 +229,7 @@ public abstract class BaseTestSheetAutosizeColumn { assertTrue(2*sheet.getColumnWidth(0) < sheet.getColumnWidth(1)); // width is roughly proportional to the number of characters assertTrue(2*sheet.getColumnWidth(1) < sheet.getColumnWidth(2)); assertEquals(sheet.getColumnWidth(4), sheet.getColumnWidth(3)); - boolean ignoreFontSizeX2 = JvmBugs.hasLineBreakMeasurerBug(); - assertTrue(ignoreFontSizeX2 || sheet.getColumnWidth(5) > sheet.getColumnWidth(4)); //larger font results in a wider column width + assertTrue(sheet.getColumnWidth(5) > sheet.getColumnWidth(4)); //larger font results in a wider column width workbook.close(); } @@ -243,7 +237,6 @@ public abstract class BaseTestSheetAutosizeColumn { @Test public void rotatedText() throws Exception { Workbook workbook = _testDataProvider.createWorkbook(); - fixFonts(workbook); Sheet sheet = workbook.createSheet(); trackColumnsForAutoSizingIfSXSSF(sheet); Row row = sheet.createRow(0); @@ -271,7 +264,6 @@ public abstract class BaseTestSheetAutosizeColumn { @Test public void mergedCells() throws Exception { Workbook workbook = _testDataProvider.createWorkbook(); - fixFonts(workbook); Sheet sheet = workbook.createSheet(); trackColumnsForAutoSizingIfSXSSF(sheet); @@ -299,7 +291,6 @@ public abstract class BaseTestSheetAutosizeColumn { @Test public void largeRowNumbers() throws Exception { Workbook workbook = _testDataProvider.createWorkbook(); - fixFonts(workbook); Sheet sheet = workbook.createSheet(); trackColumnsForAutoSizingIfSXSSF(sheet); @@ -350,16 +341,4 @@ public abstract class BaseTestSheetAutosizeColumn { } } } - - protected static void fixFonts(Workbook workbook) { - if (!JvmBugs.hasLineBreakMeasurerBug()) return; - for (int i=workbook.getNumberOfFontsAsInt()-1; i>=0; i--) { - Font f = workbook.getFontAt(0); - if ("Calibri".equals(f.getFontName())) { - f.setFontName("Lucida Sans"); - } else if ("Cambria".equals(f.getFontName())) { - f.setFontName("Lucida Bright"); - } - } - } } \ No newline at end of file