From b0b6747ce32a008ed858825156da363b3a4f7f71 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Wed, 20 Jul 2022 21:06:13 +0000 Subject: [PATCH] test issue git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1902894 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/poi/xssf/usermodel/XSSFSheet.java | 8 ++++++-- .../java/org/apache/poi/hssf/usermodel/HSSFSheet.java | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java index 1ce3b03d53..deed5b68d2 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java @@ -1278,7 +1278,11 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet, OoxmlSheetEx @Deprecated @Removal(version = "7.0.0") public void setMargin(short margin, double size) { - setMargin(PageMargin.getByShortValue(margin), size); + final PageMargin pageMargin = PageMargin.getByShortValue(margin); + if (pageMargin == null) { + throw new IllegalArgumentException( "Unknown margin constant: " + margin ); + } + setMargin(pageMargin, size); } /** @@ -1311,7 +1315,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet, OoxmlSheetEx case FOOTER: pageMargins.setFooter(size); break; - default : + default: throw new IllegalArgumentException( "Unknown margin constant: " + margin ); } } diff --git a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFSheet.java b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFSheet.java index c94c35e6e8..4a48d6fc21 100644 --- a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFSheet.java +++ b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFSheet.java @@ -1355,7 +1355,11 @@ public final class HSSFSheet implements Sheet { @Deprecated @Removal(version = "7.0.0") public void setMargin(short margin, double size) { - setMargin(PageMargin.getByShortValue(margin), size); + final PageMargin pageMargin = PageMargin.getByShortValue(margin); + if (pageMargin == null) { + throw new IllegalArgumentException( "Unknown margin constant: " + margin ); + } + setMargin(pageMargin, size); } /** -- 2.39.5