diff options
author | PJ Fanning <fanningpj@apache.org> | 2022-02-10 22:41:04 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2022-02-10 22:41:04 +0000 |
commit | 98091532bf3faf3a338c89e557db7189d956de48 (patch) | |
tree | d5ec3c33a8d29550ad8b65d08160fd36c6592162 | |
parent | 078375914ef7779856d985d414bbe92816306e8e (diff) | |
download | poi-98091532bf3faf3a338c89e557db7189d956de48.tar.gz poi-98091532bf3faf3a338c89e557db7189d956de48.zip |
add XWPFDocument.getSettings
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1897949 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java | 8 | ||||
-rw-r--r-- | poi/src/main/java/org/apache/poi/ss/formula/atp/WorkdayCalculator.java | 12 |
2 files changed, 16 insertions, 4 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java index 7274f9bbe7..65936bf9dc 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java @@ -1448,6 +1448,14 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody { return Collections.unmodifiableList(result); } + /** + * @return document level settings + * @since POI 5.2.1 + */ + public XWPFSettings getSettings() { + return settings; + } + void registerPackagePictureData(XWPFPictureData picData) { List<XWPFPictureData> list = packagePictures.computeIfAbsent(picData.getChecksum(), k -> new ArrayList<>(1)); if (!list.contains(picData)) { diff --git a/poi/src/main/java/org/apache/poi/ss/formula/atp/WorkdayCalculator.java b/poi/src/main/java/org/apache/poi/ss/formula/atp/WorkdayCalculator.java index 1abcb549a0..f6293f5e20 100644 --- a/poi/src/main/java/org/apache/poi/ss/formula/atp/WorkdayCalculator.java +++ b/poi/src/main/java/org/apache/poi/ss/formula/atp/WorkdayCalculator.java @@ -69,9 +69,7 @@ public class WorkdayCalculator { while (workdays != 0) { endDate.add(Calendar.DAY_OF_YEAR, direction); excelEndDate += direction; - if (endDate.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY - && endDate.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY - && !isHoliday(excelEndDate, holidays)) { + if (!isWeekend(endDate) && !isHoliday(excelEndDate, holidays)) { workdays -= direction; } } @@ -129,7 +127,12 @@ public class WorkdayCalculator { protected boolean isWeekend(double aDate) { Calendar date = LocaleUtil.getLocaleCalendar(); date.setTime(DateUtil.getJavaDate(aDate)); - return date.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || date.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY; + return isWeekend(date); + } + + private boolean isWeekend(Calendar date) { + return date.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY + && date.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY; } /** @@ -155,4 +158,5 @@ public class WorkdayCalculator { protected boolean isInARange(double start, double end, double aDate) { return aDate >= start && aDate <= end; } + } |