mirror of https://github.com/apache/poi.git
Apply IDE suggestions, adjust tests, ...
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1895596 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a3967026a3
commit
d5538d24d8
|
@ -55,7 +55,7 @@ import org.apache.poi.util.TempFile;
|
|||
} else {
|
||||
tempFile = TempFile.createTempFile("poi-zip-entry", ".tmp");
|
||||
LOG.atInfo().log("created for temp file {} for zip entry {} of size {} bytes",
|
||||
() -> tempFile.getAbsolutePath(), () -> entry.getName(), () -> entrySize);
|
||||
() -> tempFile.getAbsolutePath(), entry::getName, () -> entrySize);
|
||||
IOUtils.copy(inp, tempFile);
|
||||
}
|
||||
} else {
|
||||
|
@ -97,7 +97,7 @@ import org.apache.poi.util.TempFile;
|
|||
|
||||
/**
|
||||
* Deletes any temp files and releases any byte arrays.
|
||||
* @throws IOException
|
||||
* @throws IOException If closing the entry fails.
|
||||
* @since POI 5.1.0
|
||||
*/
|
||||
@Override
|
||||
|
|
|
@ -100,7 +100,7 @@ public class EncryptedTempData {
|
|||
*/
|
||||
public void dispose() {
|
||||
if (!tempFile.delete()) {
|
||||
LOG.atWarn().log("{} can't be removed (or was already removed).", () -> tempFile.getAbsolutePath());
|
||||
LOG.atWarn().log("{} can't be removed (or was already removed).", tempFile::getAbsolutePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,6 @@ public class XmlVisioDocument extends POIXMLDocument {
|
|||
|
||||
@Override
|
||||
protected void onDocumentRead() {
|
||||
|
||||
// by the time this gets called, all other document parts should
|
||||
// have been loaded, so it's safe to build the document structure
|
||||
|
||||
|
@ -90,17 +89,17 @@ public class XmlVisioDocument extends POIXMLDocument {
|
|||
// loaded yet, so it's not quite safe
|
||||
|
||||
for (POIXMLDocumentPart part : getRelations()) {
|
||||
|
||||
// organize the document pieces
|
||||
if (part instanceof XDGFPages)
|
||||
if (part instanceof XDGFPages) {
|
||||
_pages = (XDGFPages) part;
|
||||
|
||||
else if (part instanceof XDGFMasters)
|
||||
} else if (part instanceof XDGFMasters) {
|
||||
_masters = (XDGFMasters) part;
|
||||
}
|
||||
}
|
||||
|
||||
if (_masters != null)
|
||||
if (_masters != null) {
|
||||
_masters.onDocumentRead();
|
||||
}
|
||||
|
||||
_pages.onDocumentRead();
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ class TestXWPFBugs {
|
|||
assertThrows(IOException.class, () -> {
|
||||
try (InputStream fis = samples.openResourceAsStream("truncated62886.docx");
|
||||
OPCPackage opc = OPCPackage.open(fis)) {
|
||||
assertNotNull(opc);
|
||||
//XWPFWordExtractor ext = new XWPFWordExtractor(opc)) {
|
||||
//assertNotNull(ext.getText());
|
||||
}
|
||||
|
@ -59,7 +60,7 @@ class TestXWPFBugs {
|
|||
}
|
||||
|
||||
/**
|
||||
* A word document that's encrypted with non-standard
|
||||
* A Word document that's encrypted with non-standard
|
||||
* Encryption options, and no cspname section. See bug 53475
|
||||
*/
|
||||
@Test
|
||||
|
@ -77,7 +78,7 @@ class TestXWPFBugs {
|
|||
Decryptor d = Decryptor.getInstance(info);
|
||||
assertTrue(d.verifyPassword("solrcell"), "Unable to process: document is encrypted");
|
||||
|
||||
// Check we can read the word document in that
|
||||
// Check we can read the Word document in that
|
||||
InputStream dataStream = d.getDataStream(filesystem);
|
||||
OPCPackage opc = OPCPackage.open(dataStream);
|
||||
XWPFDocument doc = new XWPFDocument(opc);
|
||||
|
@ -91,7 +92,7 @@ class TestXWPFBugs {
|
|||
}
|
||||
|
||||
/**
|
||||
* A word document with aes-256, i.e. aes is always 128 bit (= 128 bit block size),
|
||||
* A Word document with aes-256, i.e. aes is always 128 bit (= 128 bit block size),
|
||||
* but the key can be 128/192/256 bits
|
||||
*/
|
||||
@Test
|
||||
|
@ -113,7 +114,7 @@ class TestXWPFBugs {
|
|||
Decryptor d = Decryptor.getInstance(info);
|
||||
assertTrue(d.verifyPassword("pass"), "Unable to process: document is encrypted");
|
||||
|
||||
// Check we can read the word document in that
|
||||
// Check we can read the Word document in that
|
||||
InputStream dataStream = d.getDataStream(filesystem);
|
||||
OPCPackage opc = OPCPackage.open(dataStream);
|
||||
XWPFDocument doc = new XWPFDocument(opc);
|
||||
|
@ -158,4 +159,4 @@ class TestXWPFBugs {
|
|||
assertEquals(731, document.getParagraphs().size());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -207,7 +207,7 @@ public abstract class QCPLCBit extends QCBit {
|
|||
* of the text area that this applies to.
|
||||
*/
|
||||
public static class Type12 extends QCPLCBit {
|
||||
private String[] hyperlinks;
|
||||
private final String[] hyperlinks;
|
||||
|
||||
private static final int oneStartsAt = 0x4c;
|
||||
private static final int twoStartsAt = 0x68;
|
||||
|
|
|
@ -214,6 +214,7 @@ public final class HWPFDocument extends HWPFDocumentCore {
|
|||
* @param istream The InputStream that contains the Word document.
|
||||
* @throws IOException If there is an unexpected IOException from the passed
|
||||
* in InputStream.
|
||||
* @throws org.apache.poi.EmptyFileException If the given stream is empty
|
||||
*/
|
||||
public HWPFDocument(InputStream istream) throws IOException {
|
||||
//do Ole stuff
|
||||
|
|
|
@ -46,6 +46,7 @@ import org.apache.poi.sl.usermodel.BaseTestSlideShow;
|
|||
import org.apache.poi.sl.usermodel.PlaceholderDetails;
|
||||
import org.apache.poi.util.LocaleUtil;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.opentest4j.AssertionFailedError;
|
||||
|
||||
/**
|
||||
* Tests for TextRuns
|
||||
|
@ -603,16 +604,21 @@ public final class TestTextRun {
|
|||
.mapToInt(r -> ((DateTimeMCAtom)r).getIndex()).toArray();
|
||||
assertArrayEquals(expFormatId, actFormatId);
|
||||
|
||||
List<HSLFShapePlaceholderDetails> phs = shapes.stream().map(HSLFSimpleShape::getPlaceholderDetails).collect(Collectors.toList());
|
||||
List<HSLFShapePlaceholderDetails> phs =
|
||||
shapes.stream().map(HSLFSimpleShape::getPlaceholderDetails).collect(Collectors.toList());
|
||||
|
||||
for (Map.Entry<Locale,String[]> me : formats.entrySet()) {
|
||||
LocaleUtil.setUserLocale(me.getKey());
|
||||
|
||||
// refresh internal members
|
||||
phs.forEach(PlaceholderDetails::getPlaceholder);
|
||||
try {
|
||||
// refresh internal members
|
||||
phs.forEach(PlaceholderDetails::getPlaceholder);
|
||||
|
||||
String[] actDate = phs.stream().map(PlaceholderDetails::getDateFormat).map(ldt::format).toArray(String[]::new);
|
||||
assertArrayEquals(me.getValue(), actDate);
|
||||
String[] actDate = phs.stream().map(PlaceholderDetails::getDateFormat).map(ldt::format).toArray(String[]::new);
|
||||
assertArrayEquals(me.getValue(), actDate);
|
||||
} catch (AssertionFailedError e) {
|
||||
throw new AssertionFailedError("While handling local " + me.getKey());
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
LocaleUtil.resetUserLocale();
|
||||
|
|
|
@ -242,7 +242,7 @@ public final class SupBookRecord extends StandardRecord {
|
|||
|
||||
public void setURL(String pUrl) {
|
||||
//Keep the first marker character!
|
||||
field_2_encoded_url = field_2_encoded_url.substring(0, 1) + pUrl;
|
||||
field_2_encoded_url = field_2_encoded_url.charAt(0) + pUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -34,16 +34,16 @@ import org.apache.poi.util.LittleEndianOutput;
|
|||
public final class ChartFRTInfoRecord extends StandardRecord {
|
||||
public static final short sid = 0x850;
|
||||
|
||||
private short rt;
|
||||
private short grbitFrt;
|
||||
private byte verOriginator;
|
||||
private byte verWriter;
|
||||
private final short rt;
|
||||
private final short grbitFrt;
|
||||
private final byte verOriginator;
|
||||
private final byte verWriter;
|
||||
private CFRTID[] rgCFRTID;
|
||||
|
||||
private static final class CFRTID {
|
||||
public static final int ENCODED_SIZE = 4;
|
||||
private int rtFirst;
|
||||
private int rtLast;
|
||||
private final int rtFirst;
|
||||
private final int rtLast;
|
||||
|
||||
public CFRTID(CFRTID other) {
|
||||
rtFirst = other.rtFirst;
|
||||
|
|
Loading…
Reference in New Issue