From: PJ Fanning Date: Sat, 27 Jun 2020 10:08:14 +0000 (+0000) Subject: try to fix test compile X-Git-Tag: before_ooxml_3rd_edition~224 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=33261cd4d2bd88b279dd32f9ada75bfa4dd41d2b;p=poi.git try to fix test compile git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1879257 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java index 22a737c413..9a53d24d1e 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java @@ -1018,6 +1018,25 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su return Collections.unmodifiableList(namedRangesByName.get(name.toLowerCase(Locale.ENGLISH))); } + /** + * Get the named range at the given index. No longer public and only used in tests. + * + * @param nameIndex the index of the named range + * @return the XSSFName at the given index + */ + @Deprecated + XSSFName getNameAt(int nameIndex) { + int nNames = namedRanges.size(); + if (nNames < 1) { + throw new IllegalStateException("There are no defined names in this workbook"); + } + if (nameIndex < 0 || nameIndex > nNames) { + throw new IllegalArgumentException("Specified name index " + nameIndex + + " is outside the allowable range (0.." + (nNames-1) + ")."); + } + return namedRanges.get(nameIndex); + } + /** * Get a list of all the named ranges in the workbook. * @@ -1028,6 +1047,24 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su return Collections.unmodifiableList(namedRanges); } + /** + * Gets the named range index by name. No longer public and only used in tests. + * + * @param name named range name + * @return named range index. -1 is returned if no named ranges could be found. + * + * @deprecated 3.16. New projects should avoid accessing named ranges by index. + * Use {@link #getName(String)} instead. + */ + @Deprecated + int getNameIndex(String name) { + XSSFName nm = getName(name); + if (nm != null) { + return namedRanges.indexOf(nm); + } + return -1; + } + /** * Get the number of styles the workbook contains * @@ -1225,9 +1262,6 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su } /** - * As {@link #removeName(String)} is not necessarily unique - * (name + sheet index is unique), this method is more accurate. - * * @param name the name to remove. * * @throws IllegalArgumentException if the named range is not a part of this XSSFWorkbook