From 1c21c4efc65d7d16879ae90382b9d1f5bd9d8b8d Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Tue, 1 Sep 2015 19:01:36 +0000 Subject: [PATCH] Fix some Forbidden APIs errors git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1700642 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/poi/dev/RecordGenerator.java | 6 ++++-- .../org/apache/poi/ss/format/CellElapsedFormatter.java | 7 ++++--- .../apache/poi/ss/formula/functions/TextFunction.java | 9 +++++---- src/java/org/apache/poi/ss/util/CellUtil.java | 3 ++- src/java/org/apache/poi/ss/util/DateFormatConverter.java | 2 +- .../org/apache/poi/xslf/usermodel/XSLFSlideMaster.java | 7 ++++--- .../org/apache/poi/xssf/usermodel/XSSFSimpleShape.java | 9 +++++---- .../apache/poi/hsmf/extractor/OutlookTextExtactor.java | 3 ++- .../org/apache/poi/hslf/extractor/TestExtractor.java | 3 ++- .../testcases/org/apache/poi/hwpf/sprm/TestSprms.java | 3 ++- 10 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/java/org/apache/poi/dev/RecordGenerator.java b/src/java/org/apache/poi/dev/RecordGenerator.java index 9aa074de25..588724d06f 100644 --- a/src/java/org/apache/poi/dev/RecordGenerator.java +++ b/src/java/org/apache/poi/dev/RecordGenerator.java @@ -22,6 +22,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.Reader; +import java.util.Locale; import java.util.Properties; import javax.xml.parsers.DocumentBuilder; @@ -92,7 +93,8 @@ public class RecordGenerator { File destinationPathFile = new File(destinationPath); destinationPathFile.mkdirs(); String destinationFilepath = destinationPath + "/" + recordName + suffix + ".java"; - transform(file, new File(destinationFilepath), new File(recordStyleDir + "/" + extendstg.toLowerCase() + ".xsl")); + transform(file, new File(destinationFilepath), + new File(recordStyleDir + "/" + extendstg.toLowerCase(Locale.ROOT) + ".xsl")); System.out.println("Generated " + suffix + ": " + destinationFilepath); // Generate test (if not already generated) @@ -101,7 +103,7 @@ public class RecordGenerator { destinationPathFile.mkdirs(); destinationFilepath = destinationPath + "/Test" + recordName + suffix + ".java"; if (new File(destinationFilepath).exists() == false) { - String temp = (recordStyleDir + "/" + extendstg.toLowerCase() + "_test.xsl"); + String temp = (recordStyleDir + "/" + extendstg.toLowerCase(Locale.ROOT) + "_test.xsl"); transform(file, new File(destinationFilepath), new File(temp)); System.out.println("Generated test: " + destinationFilepath); } else { diff --git a/src/java/org/apache/poi/ss/format/CellElapsedFormatter.java b/src/java/org/apache/poi/ss/format/CellElapsedFormatter.java index 716ade9065..72a9a1fd1e 100644 --- a/src/java/org/apache/poi/ss/format/CellElapsedFormatter.java +++ b/src/java/org/apache/poi/ss/format/CellElapsedFormatter.java @@ -20,6 +20,7 @@ import java.util.ArrayList; import java.util.Formatter; import java.util.List; import java.util.ListIterator; +import java.util.Locale; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -85,7 +86,7 @@ public class CellElapsedFormatter extends CellFormatter { if (topmost != null) throw new IllegalArgumentException( "Duplicate '[' times in format"); - part = part.toLowerCase(); + part = part.toLowerCase(Locale.ROOT); int specLen = part.length() - 2; topmost = assignSpec(part.charAt(1), pos, specLen); return part.substring(1, 1 + specLen); @@ -94,7 +95,7 @@ public class CellElapsedFormatter extends CellFormatter { case 'm': case 's': case '0': - part = part.toLowerCase(); + part = part.toLowerCase(Locale.ROOT); assignSpec(part.charAt(0), pos, part.length()); return part; @@ -216,4 +217,4 @@ public class CellElapsedFormatter extends CellFormatter { public void simpleValue(StringBuffer toAppendTo, Object value) { formatValue(toAppendTo, value); } -} \ No newline at end of file +} diff --git a/src/java/org/apache/poi/ss/formula/functions/TextFunction.java b/src/java/org/apache/poi/ss/formula/functions/TextFunction.java index ca69b27f72..eddd7aaa45 100644 --- a/src/java/org/apache/poi/ss/formula/functions/TextFunction.java +++ b/src/java/org/apache/poi/ss/formula/functions/TextFunction.java @@ -17,6 +17,7 @@ package org.apache.poi.ss.formula.functions; +import java.util.Locale; import java.util.regex.Pattern; import org.apache.poi.ss.formula.eval.BoolEval; @@ -106,12 +107,12 @@ public abstract class TextFunction implements Function { }; public static final Function LOWER = new SingleArgTextFunc() { protected ValueEval evaluate(String arg) { - return new StringEval(arg.toLowerCase()); + return new StringEval(arg.toLowerCase(Locale.ROOT)); } }; public static final Function UPPER = new SingleArgTextFunc() { protected ValueEval evaluate(String arg) { - return new StringEval(arg.toUpperCase()); + return new StringEval(arg.toUpperCase(Locale.ROOT)); } }; @@ -125,8 +126,8 @@ public abstract class TextFunction implements Function { protected ValueEval evaluate(String text) { StringBuilder sb = new StringBuilder(); boolean shouldMakeUppercase = true; - String lowercaseText = text.toLowerCase(); - String uppercaseText = text.toUpperCase(); + String lowercaseText = text.toLowerCase(Locale.ROOT); + String uppercaseText = text.toUpperCase(Locale.ROOT); for(int i = 0; i < text.length(); ++i) { if (shouldMakeUppercase) { sb.append(uppercaseText.charAt(i)); diff --git a/src/java/org/apache/poi/ss/util/CellUtil.java b/src/java/org/apache/poi/ss/util/CellUtil.java index 7a1ce9e63b..f3ef6fd59a 100644 --- a/src/java/org/apache/poi/ss/util/CellUtil.java +++ b/src/java/org/apache/poi/ss/util/CellUtil.java @@ -18,6 +18,7 @@ package org.apache.poi.ss.util; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import org.apache.poi.ss.usermodel.Cell; @@ -336,7 +337,7 @@ public final class CellUtil { String s = cell.getRichStringCellValue().getString(); boolean foundUnicode = false; - String lowerCaseStr = s.toLowerCase(); + String lowerCaseStr = s.toLowerCase(Locale.ROOT); for (int i = 0; i < unicodeMappings.length; i++) { UnicodeMapping entry = unicodeMappings[i]; diff --git a/src/java/org/apache/poi/ss/util/DateFormatConverter.java b/src/java/org/apache/poi/ss/util/DateFormatConverter.java index bca998e806..7d9248b164 100644 --- a/src/java/org/apache/poi/ss/util/DateFormatConverter.java +++ b/src/java/org/apache/poi/ss/util/DateFormatConverter.java @@ -331,7 +331,7 @@ public class DateFormatConverter { } public static String getPrefixForLocale( Locale locale ) { - String localeString = locale.toString().toLowerCase(); + String localeString = locale.toString().toLowerCase(locale); String result = localePrefixes.get( localeString ); if( result == null ) { result = localePrefixes.get( localeString.substring( 0, 2 ) ); diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java index 776cbf6772..e16b48031b 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java @@ -18,6 +18,7 @@ package org.apache.poi.xslf.usermodel; import java.io.IOException; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import org.apache.poi.POIXMLDocumentPart; @@ -94,7 +95,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.SldMasterDocument; for (POIXMLDocumentPart p : getRelations()) { if (p instanceof XSLFSlideLayout){ XSLFSlideLayout layout = (XSLFSlideLayout)p; - _layouts.put(layout.getName().toLowerCase(), layout); + _layouts.put(layout.getName().toLowerCase(Locale.ROOT), layout); } } } @@ -133,7 +134,7 @@ import org.openxmlformats.schemas.presentationml.x2006.main.SldMasterDocument; * @return the layout found or null on failure */ public XSLFSlideLayout getLayout(String name) { - return getLayouts().get(name.toLowerCase()); + return getLayouts().get(name.toLowerCase(Locale.ROOT)); } @@ -198,4 +199,4 @@ import org.openxmlformats.schemas.presentationml.x2006.main.SldMasterDocument; return null; } } -} \ No newline at end of file +} diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSimpleShape.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSimpleShape.java index 03754e8218..3d58993404 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSimpleShape.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSimpleShape.java @@ -20,6 +20,7 @@ package org.apache.poi.xssf.usermodel; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.Locale; import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.ss.usermodel.VerticalAlignment; @@ -254,7 +255,7 @@ public class XSSFSimpleShape extends XSSFShape implements Iterable