}
try (Workbook wb = WorkbookFactory.create(new File(args[0]))) {
+ if (wb == null) {
+ System.out.println("Workbook "+args[0]+" can't be loaded.");
+ return;
+ }
DataFormatter formatter = new DataFormatter();
for (int sn = 0; sn < wb.getNumberOfSheets(); sn++) {
File workbookFile = new File( args[0] ) ;
try (Workbook workbook = WorkbookFactory.create(workbookFile, null, true)) {
+ if (workbook == null) {
+ System.out.println("Workbook "+workbookFile+" can't be loaded.");
+ return;
+ }
String[] functionNames = {"calculatePayment"};
FreeRefFunction[] functionImpls = {new CalculateMortgage()};
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
* in the integration tests, mostly text-extraction related at the moment.
*/
public abstract class AbstractFileHandler implements FileHandler {
- public static final Set<String> EXPECTED_EXTRACTOR_FAILURES = new HashSet<>();
- static {
+ public static final Set<String> EXPECTED_EXTRACTOR_FAILURES = new HashSet<>(Arrays.asList(
// password protected files without password
// ... currently none ...
// unsupported file-types, no supported OLE2 parts
- EXPECTED_EXTRACTOR_FAILURES.add("hmef/quick-winmail.dat");
- EXPECTED_EXTRACTOR_FAILURES.add("hmef/winmail-sample1.dat");
- EXPECTED_EXTRACTOR_FAILURES.add("hmef/bug52400-winmail-simple.dat");
- EXPECTED_EXTRACTOR_FAILURES.add("hmef/bug52400-winmail-with-attachments.dat");
- EXPECTED_EXTRACTOR_FAILURES.add("hmef/bug63955-winmail.dat");
- EXPECTED_EXTRACTOR_FAILURES.add("hpsf/Test0313rur.adm");
- EXPECTED_EXTRACTOR_FAILURES.add("poifs/Notes.ole2");
- EXPECTED_EXTRACTOR_FAILURES.add("poifs/64322.ole2");
+ "hmef/quick-winmail.dat",
+ "hmef/winmail-sample1.dat",
+ "hmef/bug52400-winmail-simple.dat",
+ "hmef/bug52400-winmail-with-attachments.dat",
+ "hmef/bug63955-winmail.dat",
+ "hpsf/Test0313rur.adm",
+ "poifs/Notes.ole2",
+ "poifs/64322.ole2",
//commons-compress 1.21 no longer supports truncated files
- EXPECTED_EXTRACTOR_FAILURES.add("document/truncated62886.docx");
- }
+ "document/truncated62886.docx"
+ ));
@Override
public void handleExtracting(File file) throws Exception {
import org.apache.poi.ooxml.POIXMLDocumentPart;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.ss.SpreadsheetVersion;
-import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.usermodel.BuiltinFormats;
+import org.apache.poi.ss.usermodel.Color;
+import org.apache.poi.ss.usermodel.FontFamily;
+import org.apache.poi.ss.usermodel.FontScheme;
+import org.apache.poi.ss.usermodel.TableStyle;
import org.apache.poi.util.Internal;
import org.apache.poi.xssf.usermodel.CustomIndexedColorMap;
import org.apache.poi.xssf.usermodel.DefaultIndexedColorMap;
import org.apache.poi.xssf.usermodel.IndexedColorMap;
import org.apache.poi.xssf.usermodel.XSSFBuiltinTableStyle;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
-import org.apache.poi.xssf.usermodel.XSSFFactory;
import org.apache.poi.xssf.usermodel.XSSFFont;
import org.apache.poi.xssf.usermodel.XSSFRelation;
import org.apache.poi.xssf.usermodel.XSSFTableStyle;
import org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder;
import org.apache.poi.xssf.usermodel.extensions.XSSFCellFill;
import org.apache.xmlbeans.XmlException;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorders;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellStyleXfs;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellXfs;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDxf;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDxfs;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFills;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFonts;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTNumFmt;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTNumFmts;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTStylesheet;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTableStyle;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTableStyles;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPatternType;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.StyleSheetDocument;
/**
* Table of styles shared across all sheets in a workbook.
* After this, calls to {@link #getTheme()} won't give null
*/
public void ensureThemesTable() {
- if (theme != null) return;
-
- XSSFFactory factory = workbook == null ? XSSFFactory.getInstance() : workbook.getXssfFactory();
- setTheme((ThemesTable)workbook.createRelationship(XSSFRelation.THEME, factory));
+ if (theme == null && workbook != null) {
+ setTheme((ThemesTable) workbook.createRelationship(XSSFRelation.THEME, workbook.getXssfFactory()));
+ }
}
/**
}
/**
- * Puts <code>fmt</code> in the numberFormats map if the format is not
+ * Puts {@code fmt} in the numberFormats map if the format is not
* already in the the number format style table.
- * Does nothing if <code>fmt</code> is already in number format style table.
+ * Does nothing if {@code fmt} is already in number format style table.
*
* @param fmt the number format to add to number format style table
- * @return the index of <code>fmt</code> in the number format style table
+ * @return the index of {@code fmt} in the number format style table
* @throws IllegalStateException if adding the number format to the styles table
* would exceed the {@link #MAXIMUM_NUMBER_OF_DATA_FORMATS} allowed.
*/
/**
* Add a number format with a specific ID into the numberFormats map.
* If a format with the same ID already exists, overwrite the format code
- * with <code>fmt</code>
+ * with {@code fmt}
* This may be used to override built-in number formats.
*
* @param index the number format ID
import java.io.File;
import java.io.PrintStream;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@Isolated // this test changes global static BYTE_ARRAY_MAX_OVERRIDE
public abstract class BaseTestPPTIterating {
- protected static final Set<String> OLD_FILES = new HashSet<>();
- static {
- OLD_FILES.add("PPT95.ppt");
- OLD_FILES.add("pp40only.ppt");
- }
-
- protected static final Set<String> ENCRYPTED_FILES = new HashSet<>();
- static {
- ENCRYPTED_FILES.add("cryptoapi-proc2356.ppt");
- ENCRYPTED_FILES.add("Password_Protected-np-hello.ppt");
- ENCRYPTED_FILES.add("Password_Protected-56-hello.ppt");
- ENCRYPTED_FILES.add("Password_Protected-hello.ppt");
- ENCRYPTED_FILES.add("ppt_with_png_encrypted.ppt");
- }
-
- protected static final Map<String,Class<? extends Throwable>> EXCLUDED =
- new HashMap<>();
+ static final Set<String> OLD_FILES = new HashSet<>(Arrays.asList(
+ "PPT95.ppt", "pp40only.ppt"
+ ));
+
+ static final Set<String> ENCRYPTED_FILES = new HashSet<>(Arrays.asList(
+ "cryptoapi-proc2356.ppt",
+ "Password_Protected-np-hello.ppt",
+ "Password_Protected-56-hello.ppt",
+ "Password_Protected-hello.ppt",
+ "ppt_with_png_encrypted.ppt"
+ ));
+
+ static final Map<String,Class<? extends Throwable>> EXCLUDED = new HashMap<>();
public static Stream<Arguments> files() {
String dataDirName = System.getProperty(POIDataSamples.TEST_PROPERTY);
/**
* Common parent of Slides, Notes and Masters
*/
+@SuppressWarnings("java:S1452")
public interface Sheet<
S extends Shape<S,P>,
P extends TextParagraph<S,P,? extends TextRun>
boolean getDisplayPlaceholder(Placeholder placeholder);
/**
- * Sets the slide visibility
+ * Sets the slide visibility
*
* @param hidden slide visibility, if {@code true} the slide is hidden, {@code false} shows the slide
- *
+ *
* @since POI 4.0.0
*/
void setHidden(boolean hidden);
/**
* @return the slide visibility, the slide is hidden when {@code true} - or shown when {@code false}
- *
+ *
* @since POI 4.0.0
*/
boolean isHidden();
/**
* @return the comment(s) for this slide
*/
+ @SuppressWarnings("java:S1452")
List<? extends Comment> getComments();
/**
import org.apache.poi.extractor.POITextExtractor;
import org.apache.poi.sl.usermodel.PictureData.PictureType;
+@SuppressWarnings("java:S1452")
public interface SlideShow<
S extends Shape<S,P>,
P extends TextParagraph<S,P,? extends TextRun>
* @param pgsize page size (in points)
*/
void setPageSize(Dimension pgsize);
-
+
/**
* Returns all Pictures of this slideshow.
- * The returned {@link List} is unmodifiable.
+ * The returned {@link List} is unmodifiable.
* @return a {@link List} of {@link PictureData}.
*/
List<? extends PictureData> getPictureData();
* @since 3.15 beta 1
*/
PictureData addPicture(File pict, PictureType format) throws IOException;
-
+
/**
* check if a picture with this picture data already exists in this presentation
- *
+ *
* @param pictureData The picture data to find in the SlideShow
* @return {@code null} if picture data is not found in this slideshow
* @since 3.15 beta 3
/**
* @return an extractor for the slideshow metadata
- *
+ *
* @since POI 4.0.0
*/
POITextExtractor getMetadataTextExtractor();
import org.apache.poi.poifs.filesystem.FileMagic;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+@SuppressWarnings("java:S1452")
public final class SlideShowFactory {
private static class Singleton {
*
* @since POI 4.0.0
*/
+ @SuppressWarnings("java:S1452")
List<? extends TabStop> getTabStops();
/**
/**
* Some text.
*/
-@SuppressWarnings("unused")
+@SuppressWarnings({"unused","java:S1452"})
public interface TextRun {
/**
* Type of text capitals
SMALL,
ALL
}
-
+
/**
* Type of placeholder fields
*/
void setFontSize(Double fontSize);
/**
- * Get the font family - convenience method for {@link #getFontInfo(FontGroup)}
- *
+ * Get the font family - convenience method for {@link #getFontInfo(FontGroup)}
+ *
* @return font family or null if not set
*/
String getFontFamily();
/**
* Get the font family - convenience method for {@link #getFontInfo(FontGroup)}
- *
+ *
* @param fontGroup the font group, i.e. the range of glpyhs to be covered.
- * if {@code null}, the font group matching the first character will be returned
- *
+ * if {@code null}, the font group matching the first character will be returned
+ *
* @return font family or null if not set
*/
String getFontFamily(FontGroup fontGroup);
* @param typeface the font to apply to this text run.
* The value of {@code null} removes the run specific font setting, so the default setting is activated again.
* @param fontGroup the font group, i.e. the range of glpyhs to be covered.
- * if {@code null}, the font group matching the first character will be returned
+ * if {@code null}, the font group matching the first character will be returned
*/
void setFontFamily(String typeface, FontGroup fontGroup);
/**
* Get the font info for the given font group
- *
+ *
* @param fontGroup the font group, i.e. the range of glpyhs to be covered.
- * if {@code null}, the font group matching the first character will be returned
+ * if {@code null}, the font group matching the first character will be returned
* @return font info or {@code null} if not set
- *
+ *
* @since POI 3.17-beta2
*/
FontInfo getFontInfo(FontGroup fontGroup);
* @param fontInfo the font to apply to this text run.
* The value of {@code null} removes the run specific font setting, so the default setting is activated again.
* @param fontGroup the font group, i.e. the range of glpyhs to be covered. defaults to latin, if {@code null}.
- *
+ *
* @since POI 3.17-beta2
*/
void setFontInfo(FontInfo fontInfo, FontGroup fontGroup);
-
+
/**
* @return true, if text is bold
*/
* @param bold set to true for bold text, false for normal weight
*/
void setBold(boolean bold);
-
+
/**
* @return true, if text is italic
*/
/**
* Return the associated hyperlink
- *
+ *
* @return the associated hyperlink or null if no hyperlink was set
- *
+ *
* @since POI 3.14-Beta2
*/
Hyperlink<?,?> getHyperlink();
-
-
+
+
/**
* Creates a new hyperlink and assigns it to this text run.
* If the text run has already a hyperlink assigned, return it instead
*
* @return the associated hyperlink
- *
+ *
* @since POI 3.14-Beta2
*/
Hyperlink<?,?> createHyperlink();
-
+
/**
* Experimental method to determine the field type, e.g. slide number
*
import java.util.function.Supplier;
import java.util.stream.Collectors;
+@SuppressWarnings("java:S1452")
@Internal
public final class GenericRecordUtil {
private GenericRecordUtil() {}
printObject("error", errorMsg);
}
+ @SuppressWarnings("java:S1452")
protected Stream<Map.Entry<String,Supplier<?>>> writeProp(Map.Entry<String,Supplier<?>> me) {
Object obj = me.getValue().get();
if (obj == null) {