From f58182531e97ad7f9c15afcea821113aaaa55b84 Mon Sep 17 00:00:00 2001 From: XenoAmess Date: Sat, 16 Jul 2022 02:46:59 +0800 Subject: [PATCH] refine int cast long --- .../java/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java | 2 +- .../src/main/java/org/apache/poi/hslf/record/Notes.java | 2 +- .../src/main/java/org/apache/poi/hslf/record/NotesAtom.java | 2 +- .../src/main/java/org/apache/poi/hslf/record/Slide.java | 2 +- .../src/main/java/org/apache/poi/hslf/record/SlideAtom.java | 2 +- .../java/org/apache/poi/hslf/record/SlidePersistAtom.java | 2 +- .../src/main/java/org/apache/poi/hsmf/datatypes/Chunks.java | 2 +- .../main/java/org/apache/poi/hsmf/datatypes/NameIdChunks.java | 4 ++-- .../apache/poi/hslf/record/TestDocumentEncryptionAtom.java | 4 ++-- .../test/java/org/apache/poi/hslf/record/TestExObjList.java | 2 +- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java index 1c3690f1017..4e4e51a5e2f 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java @@ -185,7 +185,7 @@ void test62872() throws Exception { cell = row.createCell(j - 1); //make some noise - cell.setCellValue(new Date(i * TEN_MINUTES + (j * TEN_MINUTES) / COLUMN_COUNT)); + cell.setCellValue(new Date((long) i * TEN_MINUTES + (j * TEN_MINUTES) / COLUMN_COUNT)); } i++; } diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Notes.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Notes.java index dacbde35c88..25691641a67 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Notes.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Notes.java @@ -29,7 +29,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more public final class Notes extends SheetContainer { private byte[] _header; - private static long _type = 1008l; + private static long _type = 1008L; // Links to our more interesting children private NotesAtom notesAtom; diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/NotesAtom.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/NotesAtom.java index 606cb042c8c..82ab6d13de7 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/NotesAtom.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/NotesAtom.java @@ -35,7 +35,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more public final class NotesAtom extends RecordAtom { private byte[] _header; - private static long _type = 1009l; + private static long _type = 1009L; private int slideID; private boolean followMasterObjects; diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Slide.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Slide.java index 20f5a7d9db1..98e5214bed4 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Slide.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/Slide.java @@ -31,7 +31,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more public final class Slide extends SheetContainer { private byte[] _header; - private static long _type = 1006l; + private static long _type = 1006L; // Links to our more interesting children private SlideAtom slideAtom; diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlideAtom.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlideAtom.java index b7dcd38220c..605539b8d2a 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlideAtom.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlideAtom.java @@ -39,7 +39,7 @@ public final class SlideAtom extends RecordAtom { // private static final int MASTER_SLIDE_ID = 0x00000000; private byte[] _header; - private static long _type = 1007l; + private static long _type = 1007L; private int masterID; private int notesID; diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlidePersistAtom.java b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlidePersistAtom.java index b6ea7c93e21..28638211a85 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlidePersistAtom.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlidePersistAtom.java @@ -38,7 +38,7 @@ public final class SlidePersistAtom extends RecordAtom { //arbitrarily selected; may need to increase private static final int MAX_RECORD_LENGTH = 32; - private static final long _type = 1011l; + private static final long _type = 1011L; private static final int HAS_SHAPES_OTHER_THAN_PLACEHOLDERS = 4; private static final int[] FLAGS_MASKS = { HAS_SHAPES_OTHER_THAN_PLACEHOLDERS }; diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/Chunks.java b/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/Chunks.java index 041ab37556a..c24c00add69 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/Chunks.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/Chunks.java @@ -195,7 +195,7 @@ public void record(Chunk chunk) { // Work out what MAPIProperty this corresponds to MAPIProperty prop = MAPIProperty.get(chunk.getChunkId()); if (prop == MAPIProperty.UNKNOWN) { - long id = (chunk.getChunkId() << 16) + (long)chunk.getType().getId(); + long id = ((long) chunk.getChunkId() << 16) + (long)chunk.getType().getId(); prop = unknownProperties.get(id); if (prop == null) { prop = MAPIProperty.createCustom(chunk.getChunkId(), chunk.getType(), chunk.getEntryName()); diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/NameIdChunks.java b/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/NameIdChunks.java index 6af621e26f3..18c36596776 100644 --- a/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/NameIdChunks.java +++ b/poi-scratchpad/src/main/java/org/apache/poi/hsmf/datatypes/NameIdChunks.java @@ -229,7 +229,7 @@ private long getStreamID(int propertyKind, int nameOffset, ClassID guid, int gui Consumer propertyNameSetter, Consumer propertyNameCRC32Setter) { if (propertyKind == 0) { // numerical named property - return 0x1000L + (nameOffset ^ (guidIndex << 1)) % 0x1F; + return 0x1000L + (nameOffset ^ ((long) guidIndex << 1)) % 0x1F; } // string named property @@ -250,7 +250,7 @@ private long getStreamID(int propertyKind, int nameOffset, ClassID guid, int gui propertyNameCRC32Setter.accept(propertyNameCRC32); } } - return 0x1000 + (propertyNameCRC32 ^ ((guidIndex << 1) | 1)) % 0x1F; + return 0x1000 + (propertyNameCRC32 ^ (((long) guidIndex << 1) | 1)) % 0x1F; } /** diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentEncryptionAtom.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentEncryptionAtom.java index eb1c6fba04f..a75ecc310ec 100644 --- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentEncryptionAtom.java +++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestDocumentEncryptionAtom.java @@ -89,10 +89,10 @@ public final class TestDocumentEncryptionAtom { @Test void recordType() throws IOException { DocumentEncryptionAtom dea1 = new DocumentEncryptionAtom(data_a, 0, data_a.length); - assertEquals(12052l, dea1.getRecordType()); + assertEquals(12052L, dea1.getRecordType()); DocumentEncryptionAtom dea2 = new DocumentEncryptionAtom(data_b, 0, data_b.length); - assertEquals(12052l, dea2.getRecordType()); + assertEquals(12052L, dea2.getRecordType()); assertEquals(199, data_a.length); assertEquals(198, data_b.length); diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExObjList.java b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExObjList.java index 56cc3ed6770..0e058218229 100644 --- a/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExObjList.java +++ b/poi-scratchpad/src/test/java/org/apache/poi/hslf/record/TestExObjList.java @@ -39,7 +39,7 @@ void testRealFile() throws Exception { // Get the ExObjList ExObjList exObjList = doc.getExObjList(false); assertNotNull(exObjList); - assertEquals(1033l, exObjList.getRecordType()); + assertEquals(1033L, exObjList.getRecordType()); // Check the atom assertNotNull(exObjList.getExObjListAtom());