You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2021/05/22 20:56:49 UTC
svn commit: r1890120 [14/43] - in /poi/trunk/poi/src:
main/java/org/apache/poi/ main/java/org/apache/poi/ddf/
main/java/org/apache/poi/extractor/ main/java/org/apache/poi/hpsf/
main/java/org/apache/poi/hssf/ main/java/org/apache/poi/hssf/dev/
main/java...
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HeaderFooter.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HeaderFooter.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HeaderFooter.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HeaderFooter.java Sat May 22 20:56:44 2021
@@ -23,325 +23,325 @@ package org.apache.poi.hssf.usermodel;
*/
public abstract class HeaderFooter implements org.apache.poi.ss.usermodel.HeaderFooter {
- protected HeaderFooter() {
- //
- }
-
- /**
- * @return the internal text representation (combining center, left and right parts).
- * Possibly empty string if no header or footer is set. Never <code>null</code>.
- */
- protected abstract String getRawText();
-
- private String[] splitParts() {
- String text = getRawText();
- // default values
- String _left = "";
- String _center = "";
- String _right = "";
+ protected HeaderFooter() {
+ //
+ }
+
+ /**
+ * @return the internal text representation (combining center, left and right parts).
+ * Possibly empty string if no header or footer is set. Never <code>null</code>.
+ */
+ protected abstract String getRawText();
+
+ private String[] splitParts() {
+ String text = getRawText();
+ // default values
+ String _left = "";
+ String _center = "";
+ String _right = "";
// FIXME: replace outer goto. just eww.
outer:
- while (text.length() > 1) {
- if (text.charAt(0) != '&') {
- // Mimics the behaviour of Excel, which would put it in the center.
- _center = text;
- break;
- }
- int pos = text.length();
- switch (text.charAt(1)) {
- case 'L':
- if (text.contains("&C")) {
- pos = Math.min(pos, text.indexOf("&C"));
- }
- if (text.contains("&R")) {
- pos = Math.min(pos, text.indexOf("&R"));
- }
- _left = text.substring(2, pos);
- text = text.substring(pos);
- break;
- case 'C':
- if (text.contains("&L")) {
- pos = Math.min(pos, text.indexOf("&L"));
- }
- if (text.contains("&R")) {
- pos = Math.min(pos, text.indexOf("&R"));
- }
- _center = text.substring(2, pos);
- text = text.substring(pos);
- break;
- case 'R':
- if (text.contains("&C")) {
- pos = Math.min(pos, text.indexOf("&C"));
- }
- if (text.contains("&L")) {
- pos = Math.min(pos, text.indexOf("&L"));
- }
- _right = text.substring(2, pos);
- text = text.substring(pos);
- break;
- default:
- // Mimics the behaviour of Excel, which would put it in the center.
- _center = text;
- break outer;
- }
- }
- return new String[] { _left, _center, _right, };
- }
-
- /**
- * @return the left side of the header or footer.
- */
- public final String getLeft() {
- return splitParts()[0];
- }
-
- /**
- * @param newLeft The string to set as the left side.
- */
- public final void setLeft(String newLeft) {
- updatePart(0, newLeft);
- }
-
- /**
- * @return the center of the header or footer.
- */
- public final String getCenter() {
- return splitParts()[1];
- }
-
- /**
- * @param newCenter The string to set as the center.
- */
- public final void setCenter(String newCenter) {
- updatePart(1, newCenter);
- }
-
- /**
- * @return The right side of the header or footer.
- */
- public final String getRight() {
- return splitParts()[2];
- }
-
- /**
- * @param newRight The string to set as the right side.
- */
- public final void setRight(String newRight) {
- updatePart(2, newRight);
- }
-
- private void updatePart(int partIndex, String newValue) {
- String[] parts = splitParts();
- parts[partIndex] = newValue == null ? "" : newValue;
- updateHeaderFooterText(parts);
- }
- /**
- * Creates the complete footer string based on the left, center, and middle
- * strings.
- */
- private void updateHeaderFooterText(String[] parts) {
- String _left = parts[0];
- String _center = parts[1];
- String _right = parts[2];
-
- if (_center.length() < 1 && _left.length() < 1 && _right.length() < 1) {
- setHeaderFooterText("");
- return;
- }
- StringBuilder sb = new StringBuilder(64);
- sb.append("&C");
- sb.append(_center);
- sb.append("&L");
- sb.append(_left);
- sb.append("&R");
- sb.append(_right);
- String text = sb.toString();
- setHeaderFooterText(text);
- }
-
- /**
- * @param text the new header footer text (contains mark-up tags). Possibly
- * empty string never <code>null</code>
- */
- protected abstract void setHeaderFooterText(String text);
-
- /**
- * @param size
- * the new font size
- * @return The mark-up tag representing a new font size
- */
- public static String fontSize(short size) {
- return "&" + size;
- }
-
- /**
- * @param font
- * the new font
- * @param style
- * the fonts style, one of regular, italic, bold, italic bold or
- * bold italic
- * @return The mark-up tag representing a new font size
- */
- public static String font(String font, String style) {
- return "&\"" + font + "," + style + "\"";
- }
-
- /**
- * @return The mark-up tag representing the current page number
- */
- public static String page() {
- return MarkupTag.PAGE_FIELD.getRepresentation();
- }
-
- /**
- * @return The mark-up tag representing the number of pages
- */
- public static String numPages() {
- return MarkupTag.NUM_PAGES_FIELD.getRepresentation();
- }
-
- /**
- * @return The mark-up tag representing the current date date
- */
- public static String date() {
- return MarkupTag.DATE_FIELD.getRepresentation();
- }
-
- /**
- * @return The mark-up tag representing current time
- */
- public static String time() {
- return MarkupTag.TIME_FIELD.getRepresentation();
- }
-
- /**
- * @return The mark-up tag representing the current file name
- */
- public static String file() {
- return MarkupTag.FILE_FIELD.getRepresentation();
- }
-
- /**
- * @return The mark-up tag representing the current tab (sheet) name
- */
- public static String tab() {
- return MarkupTag.SHEET_NAME_FIELD.getRepresentation();
- }
-
- /**
- * @return The mark-up tag for start bold
- */
- public static String startBold() {
- return MarkupTag.BOLD_FIELD.getRepresentation();
- }
-
- /**
- * @return The mark-up tag for end bold
- */
- public static String endBold() {
- return MarkupTag.BOLD_FIELD.getRepresentation();
- }
-
- /**
- * @return The mark-up tag for start underline
- */
- public static String startUnderline() {
- return MarkupTag.UNDERLINE_FIELD.getRepresentation();
- }
-
- /**
- * @return The mark-up tag for end underline
- */
- public static String endUnderline() {
- return MarkupTag.UNDERLINE_FIELD.getRepresentation();
- }
-
- /**
- * @return The mark-up tag for start double underline
- */
- public static String startDoubleUnderline() {
- return MarkupTag.DOUBLE_UNDERLINE_FIELD.getRepresentation();
- }
-
- /**
- * @return The mark-up tag for end double underline
- */
- public static String endDoubleUnderline() {
- return MarkupTag.DOUBLE_UNDERLINE_FIELD.getRepresentation();
- }
-
- /**
- * Removes any fields (eg macros, page markers etc) from the string.
- * Normally used to make some text suitable for showing to humans, and the
- * resultant text should not normally be saved back into the document!
- */
- public static String stripFields(String pText) {
- int pos;
-
- // Check we really got something to work on
- if (pText == null || pText.length() == 0) {
- return pText;
- }
-
- String text = pText;
-
- // Firstly, do the easy ones which are static
- for (MarkupTag mt : MarkupTag.values()) {
- String seq = mt.getRepresentation();
- while ((pos = text.indexOf(seq)) >= 0) {
- text = text.substring(0, pos) + text.substring(pos + seq.length());
- }
- }
-
- // Now do the tricky, dynamic ones
- // These are things like font sizes and font names
- text = text.replaceAll("\\&\\d+", "");
- text = text.replaceAll("\\&\".*?,.*?\"", "");
-
- // All done
- return text;
- }
-
- private enum MarkupTag {
- SHEET_NAME_FIELD ("&A", false),
- DATE_FIELD ("&D", false),
- FILE_FIELD ("&F", false),
- FULL_FILE_FIELD ("&Z", false),
- PAGE_FIELD ("&P", false),
- TIME_FIELD ("&T", false),
- NUM_PAGES_FIELD ("&N", false),
-
- PICTURE_FIELD ("&G", false),
-
- BOLD_FIELD ("&B", true),
- ITALIC_FIELD ("&I", true),
- STRIKETHROUGH_FIELD ("&S", true),
- SUBSCRIPT_FIELD ("&Y", true),
- SUPERSCRIPT_FIELD ("&X", true),
- UNDERLINE_FIELD ("&U", true),
- DOUBLE_UNDERLINE_FIELD ("&E", true),
- ;
-
- private final String _representation;
- private final boolean _occursInPairs;
- private MarkupTag(String sequence, boolean occursInPairs) {
- _representation = sequence;
- _occursInPairs = occursInPairs;
- }
- /**
- * @return The character sequence that marks this field
- */
- public String getRepresentation() {
- return _representation;
- }
-
- /**
- * @return true if this markup tag normally comes in a pair, eg turn on
- * underline / turn off underline
- */
- public boolean occursPairs() {
- return _occursInPairs;
- }
- }
+ while (text.length() > 1) {
+ if (text.charAt(0) != '&') {
+ // Mimics the behaviour of Excel, which would put it in the center.
+ _center = text;
+ break;
+ }
+ int pos = text.length();
+ switch (text.charAt(1)) {
+ case 'L':
+ if (text.contains("&C")) {
+ pos = Math.min(pos, text.indexOf("&C"));
+ }
+ if (text.contains("&R")) {
+ pos = Math.min(pos, text.indexOf("&R"));
+ }
+ _left = text.substring(2, pos);
+ text = text.substring(pos);
+ break;
+ case 'C':
+ if (text.contains("&L")) {
+ pos = Math.min(pos, text.indexOf("&L"));
+ }
+ if (text.contains("&R")) {
+ pos = Math.min(pos, text.indexOf("&R"));
+ }
+ _center = text.substring(2, pos);
+ text = text.substring(pos);
+ break;
+ case 'R':
+ if (text.contains("&C")) {
+ pos = Math.min(pos, text.indexOf("&C"));
+ }
+ if (text.contains("&L")) {
+ pos = Math.min(pos, text.indexOf("&L"));
+ }
+ _right = text.substring(2, pos);
+ text = text.substring(pos);
+ break;
+ default:
+ // Mimics the behaviour of Excel, which would put it in the center.
+ _center = text;
+ break outer;
+ }
+ }
+ return new String[] { _left, _center, _right, };
+ }
+
+ /**
+ * @return the left side of the header or footer.
+ */
+ public final String getLeft() {
+ return splitParts()[0];
+ }
+
+ /**
+ * @param newLeft The string to set as the left side.
+ */
+ public final void setLeft(String newLeft) {
+ updatePart(0, newLeft);
+ }
+
+ /**
+ * @return the center of the header or footer.
+ */
+ public final String getCenter() {
+ return splitParts()[1];
+ }
+
+ /**
+ * @param newCenter The string to set as the center.
+ */
+ public final void setCenter(String newCenter) {
+ updatePart(1, newCenter);
+ }
+
+ /**
+ * @return The right side of the header or footer.
+ */
+ public final String getRight() {
+ return splitParts()[2];
+ }
+
+ /**
+ * @param newRight The string to set as the right side.
+ */
+ public final void setRight(String newRight) {
+ updatePart(2, newRight);
+ }
+
+ private void updatePart(int partIndex, String newValue) {
+ String[] parts = splitParts();
+ parts[partIndex] = newValue == null ? "" : newValue;
+ updateHeaderFooterText(parts);
+ }
+ /**
+ * Creates the complete footer string based on the left, center, and middle
+ * strings.
+ */
+ private void updateHeaderFooterText(String[] parts) {
+ String _left = parts[0];
+ String _center = parts[1];
+ String _right = parts[2];
+
+ if (_center.length() < 1 && _left.length() < 1 && _right.length() < 1) {
+ setHeaderFooterText("");
+ return;
+ }
+ StringBuilder sb = new StringBuilder(64);
+ sb.append("&C");
+ sb.append(_center);
+ sb.append("&L");
+ sb.append(_left);
+ sb.append("&R");
+ sb.append(_right);
+ String text = sb.toString();
+ setHeaderFooterText(text);
+ }
+
+ /**
+ * @param text the new header footer text (contains mark-up tags). Possibly
+ * empty string never <code>null</code>
+ */
+ protected abstract void setHeaderFooterText(String text);
+
+ /**
+ * @param size
+ * the new font size
+ * @return The mark-up tag representing a new font size
+ */
+ public static String fontSize(short size) {
+ return "&" + size;
+ }
+
+ /**
+ * @param font
+ * the new font
+ * @param style
+ * the fonts style, one of regular, italic, bold, italic bold or
+ * bold italic
+ * @return The mark-up tag representing a new font size
+ */
+ public static String font(String font, String style) {
+ return "&\"" + font + "," + style + "\"";
+ }
+
+ /**
+ * @return The mark-up tag representing the current page number
+ */
+ public static String page() {
+ return MarkupTag.PAGE_FIELD.getRepresentation();
+ }
+
+ /**
+ * @return The mark-up tag representing the number of pages
+ */
+ public static String numPages() {
+ return MarkupTag.NUM_PAGES_FIELD.getRepresentation();
+ }
+
+ /**
+ * @return The mark-up tag representing the current date date
+ */
+ public static String date() {
+ return MarkupTag.DATE_FIELD.getRepresentation();
+ }
+
+ /**
+ * @return The mark-up tag representing current time
+ */
+ public static String time() {
+ return MarkupTag.TIME_FIELD.getRepresentation();
+ }
+
+ /**
+ * @return The mark-up tag representing the current file name
+ */
+ public static String file() {
+ return MarkupTag.FILE_FIELD.getRepresentation();
+ }
+
+ /**
+ * @return The mark-up tag representing the current tab (sheet) name
+ */
+ public static String tab() {
+ return MarkupTag.SHEET_NAME_FIELD.getRepresentation();
+ }
+
+ /**
+ * @return The mark-up tag for start bold
+ */
+ public static String startBold() {
+ return MarkupTag.BOLD_FIELD.getRepresentation();
+ }
+
+ /**
+ * @return The mark-up tag for end bold
+ */
+ public static String endBold() {
+ return MarkupTag.BOLD_FIELD.getRepresentation();
+ }
+
+ /**
+ * @return The mark-up tag for start underline
+ */
+ public static String startUnderline() {
+ return MarkupTag.UNDERLINE_FIELD.getRepresentation();
+ }
+
+ /**
+ * @return The mark-up tag for end underline
+ */
+ public static String endUnderline() {
+ return MarkupTag.UNDERLINE_FIELD.getRepresentation();
+ }
+
+ /**
+ * @return The mark-up tag for start double underline
+ */
+ public static String startDoubleUnderline() {
+ return MarkupTag.DOUBLE_UNDERLINE_FIELD.getRepresentation();
+ }
+
+ /**
+ * @return The mark-up tag for end double underline
+ */
+ public static String endDoubleUnderline() {
+ return MarkupTag.DOUBLE_UNDERLINE_FIELD.getRepresentation();
+ }
+
+ /**
+ * Removes any fields (eg macros, page markers etc) from the string.
+ * Normally used to make some text suitable for showing to humans, and the
+ * resultant text should not normally be saved back into the document!
+ */
+ public static String stripFields(String pText) {
+ int pos;
+
+ // Check we really got something to work on
+ if (pText == null || pText.length() == 0) {
+ return pText;
+ }
+
+ String text = pText;
+
+ // Firstly, do the easy ones which are static
+ for (MarkupTag mt : MarkupTag.values()) {
+ String seq = mt.getRepresentation();
+ while ((pos = text.indexOf(seq)) >= 0) {
+ text = text.substring(0, pos) + text.substring(pos + seq.length());
+ }
+ }
+
+ // Now do the tricky, dynamic ones
+ // These are things like font sizes and font names
+ text = text.replaceAll("\\&\\d+", "");
+ text = text.replaceAll("\\&\".*?,.*?\"", "");
+
+ // All done
+ return text;
+ }
+
+ private enum MarkupTag {
+ SHEET_NAME_FIELD ("&A", false),
+ DATE_FIELD ("&D", false),
+ FILE_FIELD ("&F", false),
+ FULL_FILE_FIELD ("&Z", false),
+ PAGE_FIELD ("&P", false),
+ TIME_FIELD ("&T", false),
+ NUM_PAGES_FIELD ("&N", false),
+
+ PICTURE_FIELD ("&G", false),
+
+ BOLD_FIELD ("&B", true),
+ ITALIC_FIELD ("&I", true),
+ STRIKETHROUGH_FIELD ("&S", true),
+ SUBSCRIPT_FIELD ("&Y", true),
+ SUPERSCRIPT_FIELD ("&X", true),
+ UNDERLINE_FIELD ("&U", true),
+ DOUBLE_UNDERLINE_FIELD ("&E", true),
+ ;
+
+ private final String _representation;
+ private final boolean _occursInPairs;
+ private MarkupTag(String sequence, boolean occursInPairs) {
+ _representation = sequence;
+ _occursInPairs = occursInPairs;
+ }
+ /**
+ * @return The character sequence that marks this field
+ */
+ public String getRepresentation() {
+ return _representation;
+ }
+
+ /**
+ * @return true if this markup tag normally comes in a pair, eg turn on
+ * underline / turn off underline
+ */
+ public boolean occursPairs() {
+ return _occursInPairs;
+ }
+ }
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/StaticFontMetrics.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/StaticFontMetrics.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/StaticFontMetrics.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/StaticFontMetrics.java Sat May 22 20:56:44 2021
@@ -38,69 +38,69 @@ import org.apache.logging.log4j.Logger;
*/
final class StaticFontMetrics {
private static final Logger LOGGER = LogManager.getLogger(StaticFontMetrics.class);
- /** The font metrics property file we're using */
- private static Properties fontMetricsProps;
- /** Our cache of font details we've already looked up */
- private static final Map<String, FontDetails> fontDetailsMap = new HashMap<>();
-
- private StaticFontMetrics() {}
-
- /**
- * Retrieves the fake font details for a given font.
- *
- * @param font
- * the font to lookup.
- * @return the fake font.
- */
- public static synchronized FontDetails getFontDetails(Font font) {
- // If we haven't already identified out font metrics file,
- // figure out which one to use and load it
- if (fontMetricsProps == null) {
- try {
- fontMetricsProps = loadMetrics();
- } catch (IOException e) {
- throw new RuntimeException("Could not load font metrics", e);
- }
- }
-
- // Grab the base name of the font they've asked about
- String fontName = font.getName();
-
- // Some fonts support plain/bold/italic/bolditalic variants
- // Others have different font instances for bold etc
- // (eg font.dialog.plain.* vs font.Californian FB Bold.*)
- String fontStyle = "";
- if (font.isPlain()) {
- fontStyle += "plain";
- }
- if (font.isBold()) {
- fontStyle += "bold";
- }
- if (font.isItalic()) {
- fontStyle += "italic";
- }
-
- // Do we have a definition for this font with just the name?
- // If not, check with the font style added
- String fontHeight = FontDetails.buildFontHeightProperty(fontName);
- String styleHeight = FontDetails.buildFontHeightProperty(fontName + "." + fontStyle);
-
- if (fontMetricsProps.get(fontHeight) == null
- && fontMetricsProps.get(styleHeight) != null) {
- // Need to add on the style to the font name
- fontName += "." + fontStyle;
- }
-
- // Get the details on this font
- FontDetails fontDetails = fontDetailsMap.get(fontName);
- if (fontDetails == null) {
- fontDetails = FontDetails.create(fontName, fontMetricsProps);
- fontDetailsMap.put(fontName, fontDetails);
- }
+ /** The font metrics property file we're using */
+ private static Properties fontMetricsProps;
+ /** Our cache of font details we've already looked up */
+ private static final Map<String, FontDetails> fontDetailsMap = new HashMap<>();
+
+ private StaticFontMetrics() {}
+
+ /**
+ * Retrieves the fake font details for a given font.
+ *
+ * @param font
+ * the font to lookup.
+ * @return the fake font.
+ */
+ public static synchronized FontDetails getFontDetails(Font font) {
+ // If we haven't already identified out font metrics file,
+ // figure out which one to use and load it
+ if (fontMetricsProps == null) {
+ try {
+ fontMetricsProps = loadMetrics();
+ } catch (IOException e) {
+ throw new RuntimeException("Could not load font metrics", e);
+ }
+ }
+
+ // Grab the base name of the font they've asked about
+ String fontName = font.getName();
+
+ // Some fonts support plain/bold/italic/bolditalic variants
+ // Others have different font instances for bold etc
+ // (eg font.dialog.plain.* vs font.Californian FB Bold.*)
+ String fontStyle = "";
+ if (font.isPlain()) {
+ fontStyle += "plain";
+ }
+ if (font.isBold()) {
+ fontStyle += "bold";
+ }
+ if (font.isItalic()) {
+ fontStyle += "italic";
+ }
+
+ // Do we have a definition for this font with just the name?
+ // If not, check with the font style added
+ String fontHeight = FontDetails.buildFontHeightProperty(fontName);
+ String styleHeight = FontDetails.buildFontHeightProperty(fontName + "." + fontStyle);
+
+ if (fontMetricsProps.get(fontHeight) == null
+ && fontMetricsProps.get(styleHeight) != null) {
+ // Need to add on the style to the font name
+ fontName += "." + fontStyle;
+ }
+
+ // Get the details on this font
+ FontDetails fontDetails = fontDetailsMap.get(fontName);
+ if (fontDetails == null) {
+ fontDetails = FontDetails.create(fontName, fontMetricsProps);
+ fontDetailsMap.put(fontName, fontDetails);
+ }
return fontDetails;
- }
+ }
- private static Properties loadMetrics() throws IOException {
+ private static Properties loadMetrics() throws IOException {
// Check to see if the font metric file was specified
// as a system property
File propFile = null;
@@ -109,7 +109,7 @@ final class StaticFontMetrics {
if (propFileName != null) {
propFile = new File(propFileName);
if (!propFile.exists()) {
- LOGGER.atWarn().log("font_metrics.properties not found at path {}", propFile.getAbsolutePath());
+ LOGGER.atWarn().log("font_metrics.properties not found at path {}", propFile.getAbsolutePath());
propFile = null;
}
}
@@ -118,18 +118,18 @@ final class StaticFontMetrics {
}
try (InputStream metricsIn = (propFile != null)
- ? new FileInputStream(propFile)
- : FontDetails.class.getResourceAsStream("/font_metrics.properties")
- ) {
- // Use the built-in font metrics file off the classpath
- if (metricsIn == null) {
- String err = "font_metrics.properties not found in classpath";
- throw new IOException(err);
- }
+ ? new FileInputStream(propFile)
+ : FontDetails.class.getResourceAsStream("/font_metrics.properties")
+ ) {
+ // Use the built-in font metrics file off the classpath
+ if (metricsIn == null) {
+ String err = "font_metrics.properties not found in classpath";
+ throw new IOException(err);
+ }
Properties props = new Properties();
props.load(metricsIn);
return props;
}
- }
+ }
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/hssf/util/CellRangeAddress8Bit.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/util/CellRangeAddress8Bit.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/util/CellRangeAddress8Bit.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/util/CellRangeAddress8Bit.java Sat May 22 20:56:44 2021
@@ -28,37 +28,37 @@ import org.apache.poi.util.LittleEndianO
*/
public final class CellRangeAddress8Bit extends CellRangeAddressBase {
- public static final int ENCODED_SIZE = 6;
+ public static final int ENCODED_SIZE = 6;
- public CellRangeAddress8Bit(int firstRow, int lastRow, int firstCol, int lastCol) {
- super(firstRow, lastRow, firstCol, lastCol);
- }
-
- public CellRangeAddress8Bit(LittleEndianInput in) {
- super(readUShortAndCheck(in), in.readUShort(), in.readUByte(), in.readUByte());
- }
-
- private static int readUShortAndCheck(LittleEndianInput in) {
- if (in.available() < ENCODED_SIZE) {
- // Ran out of data
- throw new RuntimeException("Ran out of data reading CellRangeAddress");
- }
- return in.readUShort();
- }
-
- public void serialize(LittleEndianOutput out) {
- out.writeShort(getFirstRow());
- out.writeShort(getLastRow());
- out.writeByte(getFirstColumn());
- out.writeByte(getLastColumn());
- }
-
- @Override
- public CellRangeAddress8Bit copy() {
- return new CellRangeAddress8Bit(getFirstRow(), getLastRow(), getFirstColumn(), getLastColumn());
- }
-
- public static int getEncodedSize(int numberOfItems) {
- return numberOfItems * ENCODED_SIZE;
- }
+ public CellRangeAddress8Bit(int firstRow, int lastRow, int firstCol, int lastCol) {
+ super(firstRow, lastRow, firstCol, lastCol);
+ }
+
+ public CellRangeAddress8Bit(LittleEndianInput in) {
+ super(readUShortAndCheck(in), in.readUShort(), in.readUByte(), in.readUByte());
+ }
+
+ private static int readUShortAndCheck(LittleEndianInput in) {
+ if (in.available() < ENCODED_SIZE) {
+ // Ran out of data
+ throw new RuntimeException("Ran out of data reading CellRangeAddress");
+ }
+ return in.readUShort();
+ }
+
+ public void serialize(LittleEndianOutput out) {
+ out.writeShort(getFirstRow());
+ out.writeShort(getLastRow());
+ out.writeByte(getFirstColumn());
+ out.writeByte(getLastColumn());
+ }
+
+ @Override
+ public CellRangeAddress8Bit copy() {
+ return new CellRangeAddress8Bit(getFirstRow(), getLastRow(), getFirstColumn(), getLastColumn());
+ }
+
+ public static int getEncodedSize(int numberOfItems) {
+ return numberOfItems * ENCODED_SIZE;
+ }
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/EncryptionHeader.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/EncryptionHeader.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/EncryptionHeader.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/EncryptionHeader.java Sat May 22 20:56:44 2021
@@ -119,7 +119,7 @@ public abstract class EncryptionHeader i
}
public int getBlockSize() {
- return blockSize;
+ return blockSize;
}
public void setBlockSize(int blockSize) {
Modified: poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/Encryptor.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/Encryptor.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/Encryptor.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/Encryptor.java Sat May 22 20:56:44 2021
@@ -57,8 +57,8 @@ public abstract class Encryptor implemen
public abstract void confirmPassword(String password);
- public static Encryptor getInstance(EncryptionInfo info) {
- return info.getEncryptor();
+ public static Encryptor getInstance(EncryptionInfo info) {
+ return info.getEncryptor();
}
public OutputStream getDataStream(POIFSFileSystem fs) throws IOException, GeneralSecurityException {
Modified: poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/HashAlgorithm.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/HashAlgorithm.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/HashAlgorithm.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/HashAlgorithm.java Sat May 22 20:56:44 2021
@@ -39,10 +39,10 @@ public enum HashAlgorithm {
;
/** the id used for initializing the JCE message digest **/
- public final String jceId;
- /** the id used for the BIFF encryption info header **/
- public final int ecmaId;
- /** the id used for OOXML encryption info header **/
+ public final String jceId;
+ /** the id used for the BIFF encryption info header **/
+ public final int ecmaId;
+ /** the id used for OOXML encryption info header **/
public final String ecmaString;
/** the length of the digest byte array **/
public final int hashSize;
Modified: poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/agile/AgileEncryptor.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/agile/AgileEncryptor.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/agile/AgileEncryptor.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/poifs/crypt/agile/AgileEncryptor.java Sat May 22 20:56:44 2021
@@ -73,12 +73,12 @@ public class AgileEncryptor extends Encr
private byte[] integritySalt;
private byte[] pwHash;
- protected AgileEncryptor() {}
+ protected AgileEncryptor() {}
protected AgileEncryptor(AgileEncryptor other) {
- super(other);
- integritySalt = (other.integritySalt == null) ? null : other.integritySalt.clone();
- pwHash = (other.pwHash == null) ? null : other.pwHash.clone();
+ super(other);
+ integritySalt = (other.integritySalt == null) ? null : other.integritySalt.clone();
+ pwHash = (other.pwHash == null) ? null : other.pwHash.clone();
}
@Override
@@ -104,7 +104,7 @@ public class AgileEncryptor extends Encr
confirmPassword(password, newKeySpec, newKeySalt, newVerifierSalt, newVerifier, newIntegritySalt);
}
- @Override
+ @Override
public void confirmPassword(String password, byte[] keySpec, byte[] keySalt, byte[] verifier, byte[] verifierSalt, byte[] integritySalt) {
AgileEncryptionVerifier ver = (AgileEncryptionVerifier)getEncryptionInfo().getVerifier();
AgileEncryptionHeader header = (AgileEncryptionHeader)getEncryptionInfo().getHeader();
@@ -204,7 +204,7 @@ public class AgileEncryptor extends Encr
} catch (GeneralSecurityException e) {
throw new EncryptedDocumentException(e);
}
- }
+ }
@Override
public OutputStream getDataStream(DirectoryNode dir)
Modified: poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/DocumentInputStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/DocumentInputStream.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/DocumentInputStream.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/DocumentInputStream.java Sat May 22 20:56:44 2021
@@ -201,72 +201,72 @@ public final class DocumentInputStream e
// Start again, then wind on to the required block
_data = _document.getBlockIterator();
_current_offset = 0;
- for(int i=0; i<_marked_offset_count; i++) {
- _buffer = _data.next();
- _current_offset += _buffer.remaining();
- }
+ for(int i=0; i<_marked_offset_count; i++) {
+ _buffer = _data.next();
+ _current_offset += _buffer.remaining();
+ }
_current_block_count = _marked_offset_count;
// Do we need to position within it?
if(_current_offset != _marked_offset) {
- // Grab the right block
+ // Grab the right block
_buffer = _data.next();
_current_block_count++;
- // Skip to the right place in it
+ // Skip to the right place in it
// (It should be positioned already at the start of the block,
// we need to move further inside the block)
int skipBy = _marked_offset - _current_offset;
- _buffer.position(_buffer.position() + skipBy);
+ _buffer.position(_buffer.position() + skipBy);
}
// All done
_current_offset = _marked_offset;
- }
+ }
@Override
- public long skip(long n) throws IOException {
- dieIfClosed();
- if (n < 0) {
- return 0;
- }
- long new_offset = _current_offset + n;
-
- if (new_offset < _current_offset) {
- // wrap around in converting a VERY large long to an int
- new_offset = _document_size;
- } else if (new_offset > _document_size) {
- new_offset = _document_size;
- }
-
- long rval = new_offset - _current_offset;
-
- // TODO Do this better
- byte[] skip = IOUtils.safelyAllocate(rval, Integer.MAX_VALUE);
- readFully(skip);
- return rval;
- }
-
- private void dieIfClosed() throws IOException {
- if (_closed) {
- throw new IOException("cannot perform requested operation on a closed stream");
- }
- }
-
- private boolean atEOD() {
- return _current_offset == _document_size;
- }
-
- private void checkAvaliable(int requestedSize) {
- if (_closed) {
- throw new IllegalStateException("cannot perform requested operation on a closed stream");
- }
- if (requestedSize > _document_size - _current_offset) {
- throw new RuntimeException("Buffer underrun - requested " + requestedSize
- + " bytes but " + (_document_size - _current_offset) + " was available");
- }
- }
+ public long skip(long n) throws IOException {
+ dieIfClosed();
+ if (n < 0) {
+ return 0;
+ }
+ long new_offset = _current_offset + n;
+
+ if (new_offset < _current_offset) {
+ // wrap around in converting a VERY large long to an int
+ new_offset = _document_size;
+ } else if (new_offset > _document_size) {
+ new_offset = _document_size;
+ }
+
+ long rval = new_offset - _current_offset;
+
+ // TODO Do this better
+ byte[] skip = IOUtils.safelyAllocate(rval, Integer.MAX_VALUE);
+ readFully(skip);
+ return rval;
+ }
+
+ private void dieIfClosed() throws IOException {
+ if (_closed) {
+ throw new IOException("cannot perform requested operation on a closed stream");
+ }
+ }
+
+ private boolean atEOD() {
+ return _current_offset == _document_size;
+ }
+
+ private void checkAvaliable(int requestedSize) {
+ if (_closed) {
+ throw new IllegalStateException("cannot perform requested operation on a closed stream");
+ }
+ if (requestedSize > _document_size - _current_offset) {
+ throw new RuntimeException("Buffer underrun - requested " + requestedSize
+ + " bytes but " + (_document_size - _current_offset) + " was available");
+ }
+ }
@Override
public void readFully(byte[] buf) {
@@ -274,26 +274,26 @@ public final class DocumentInputStream e
}
@Override
- public void readFully(byte[] buf, int off, int len) {
+ public void readFully(byte[] buf, int off, int len) {
if (len < 0) {
throw new RuntimeException("Can't read negative number of bytes");
}
- checkAvaliable(len);
+ checkAvaliable(len);
- int read = 0;
- while(read < len) {
- if(_buffer == null || _buffer.remaining() == 0) {
- _current_block_count++;
- _buffer = _data.next();
- }
+ int read = 0;
+ while(read < len) {
+ if(_buffer == null || _buffer.remaining() == 0) {
+ _current_block_count++;
+ _buffer = _data.next();
+ }
- int limit = Math.min(len-read, _buffer.remaining());
- _buffer.get(buf, off+read, limit);
+ int limit = Math.min(len-read, _buffer.remaining());
+ _buffer.get(buf, off+read, limit);
_current_offset += limit;
- read += limit;
- }
- }
+ read += limit;
+ }
+ }
@Override
public void readPlain(byte[] buf, int off, int len) {
@@ -312,12 +312,12 @@ public final class DocumentInputStream e
}
@Override
- public long readLong() {
- checkAvaliable(LONG_SIZE);
- byte[] data = new byte[LONG_SIZE];
- readFully(data, 0, LONG_SIZE);
- return LittleEndian.getLong(data, 0);
- }
+ public long readLong() {
+ checkAvaliable(LONG_SIZE);
+ byte[] data = new byte[LONG_SIZE];
+ readFully(data, 0, LONG_SIZE);
+ return LittleEndian.getLong(data, 0);
+ }
@Override
public short readShort() {
@@ -328,12 +328,12 @@ public final class DocumentInputStream e
}
@Override
- public int readInt() {
- checkAvaliable(INT_SIZE);
+ public int readInt() {
+ checkAvaliable(INT_SIZE);
byte[] data = new byte[INT_SIZE];
readFully(data, 0, INT_SIZE);
return LittleEndian.getInt(data);
- }
+ }
public long readUInt() {
int i = readInt();
@@ -341,12 +341,12 @@ public final class DocumentInputStream e
}
@Override
- public int readUShort() {
- checkAvaliable(SHORT_SIZE);
+ public int readUShort() {
+ checkAvaliable(SHORT_SIZE);
byte[] data = new byte[SHORT_SIZE];
readFully(data, 0, SHORT_SIZE);
return LittleEndian.getUShort(data);
- }
+ }
@Override
public int readUByte() {
Modified: poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/DocumentOutputStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/DocumentOutputStream.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/DocumentOutputStream.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/DocumentOutputStream.java Sat May 22 20:56:44 2021
@@ -30,48 +30,48 @@ import org.apache.poi.poifs.property.Doc
* {@link POIFSFileSystem} instance.
*/
public final class DocumentOutputStream extends OutputStream {
- /** the Document's size, i.e. the size of the big block data - mini block data is cached and not counted */
- private int _document_size = 0;
+ /** the Document's size, i.e. the size of the big block data - mini block data is cached and not counted */
+ private int _document_size = 0;
/** have we been closed? */
- private boolean _closed = false;
+ private boolean _closed = false;
- /** the actual Document */
- private final POIFSDocument _document;
- /** and its Property */
- private final DocumentProperty _property;
-
- /** our buffer, when null we're into normal blocks */
- private UnsynchronizedByteArrayOutputStream _buffer =
- new UnsynchronizedByteArrayOutputStream(POIFSConstants.BIG_BLOCK_MINIMUM_DOCUMENT_SIZE);
-
- /** our main block stream, when we're into normal blocks */
- private POIFSStream _stream;
- private OutputStream _stream_output;
+ /** the actual Document */
+ private final POIFSDocument _document;
+ /** and its Property */
+ private final DocumentProperty _property;
+
+ /** our buffer, when null we're into normal blocks */
+ private UnsynchronizedByteArrayOutputStream _buffer =
+ new UnsynchronizedByteArrayOutputStream(POIFSConstants.BIG_BLOCK_MINIMUM_DOCUMENT_SIZE);
+
+ /** our main block stream, when we're into normal blocks */
+ private POIFSStream _stream;
+ private OutputStream _stream_output;
/** a write limit or -1 if unlimited */
private final long _limit;
- /**
- * Create an OutputStream from the specified DocumentEntry.
- * The specified entry will be emptied.
- *
- * @param document the DocumentEntry to be written
- */
- public DocumentOutputStream(DocumentEntry document) throws IOException {
- this(document, -1);
- }
+ /**
+ * Create an OutputStream from the specified DocumentEntry.
+ * The specified entry will be emptied.
+ *
+ * @param document the DocumentEntry to be written
+ */
+ public DocumentOutputStream(DocumentEntry document) throws IOException {
+ this(document, -1);
+ }
/**
- * Create an OutputStream to create the specified new Entry
- *
- * @param parent Where to create the Entry
- * @param name Name of the new entry
- */
- public DocumentOutputStream(DirectoryEntry parent, String name) throws IOException {
- this(createDocument(parent, name), -1);
- }
+ * Create an OutputStream to create the specified new Entry
+ *
+ * @param parent Where to create the Entry
+ * @param name Name of the new entry
+ */
+ public DocumentOutputStream(DirectoryEntry parent, String name) throws IOException {
+ this(createDocument(parent, name), -1);
+ }
/**
* Create a DocumentOutputStream
@@ -169,6 +169,6 @@ public final class DocumentOutputStream
* @return the amount of written bytes
*/
public long size() {
- return _document_size + (_buffer == null ? 0L : _buffer.size());
+ return _document_size + (_buffer == null ? 0L : _buffer.size());
}
}
\ No newline at end of file
Modified: poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/EntryUtils.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/EntryUtils.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/EntryUtils.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/EntryUtils.java Sat May 22 20:56:44 2021
@@ -41,7 +41,7 @@ public final class EntryUtils {
public static void copyNodeRecursively( Entry entry, DirectoryEntry target )
throws IOException {
if ( entry.isDirectoryEntry() ) {
- DirectoryEntry dirEntry = (DirectoryEntry)entry;
+ DirectoryEntry dirEntry = (DirectoryEntry)entry;
DirectoryEntry newTarget = target.createDirectory( entry.getName() );
newTarget.setStorageClsid( dirEntry.getStorageClsid() );
Iterator<Entry> entries = dirEntry.getEntries();
Modified: poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/NotOLE2FileException.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/NotOLE2FileException.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/NotOLE2FileException.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/NotOLE2FileException.java Sat May 22 20:56:44 2021
@@ -24,7 +24,7 @@ import java.io.IOException;
* seem to actually be an OLE2 file after all
*/
public class NotOLE2FileException extends IOException {
- public NotOLE2FileException(String s) {
- super(s);
- }
+ public NotOLE2FileException(String s) {
+ super(s);
+ }
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/OfficeXmlFileException.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/OfficeXmlFileException.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/OfficeXmlFileException.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/OfficeXmlFileException.java Sat May 22 20:56:44 2021
@@ -25,7 +25,7 @@ import org.apache.poi.UnsupportedFileFor
* POIFS works with)
*/
public class OfficeXmlFileException extends UnsupportedFileFormatException {
- public OfficeXmlFileException(String s) {
- super(s);
- }
+ public OfficeXmlFileException(String s) {
+ super(s);
+ }
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/POIFSDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/POIFSDocument.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/POIFSDocument.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/poifs/filesystem/POIFSDocument.java Sat May 22 20:56:44 2021
@@ -48,7 +48,7 @@ public final class POIFSDocument impleme
private POIFSFileSystem _filesystem;
private POIFSStream _stream;
private int _block_size;
-
+
/**
* Constructor for an existing Document
*/
@@ -232,7 +232,7 @@ public final class POIFSDocument impleme
* Get an Iterator of objects, some of which may implement POIFSViewable
*
* @return an Iterator; may not be null, but may have an empty back end
- * store
+ * store
*/
public Iterator<Object> getViewableIterator() {
return emptyIterator();
@@ -243,7 +243,7 @@ public final class POIFSDocument impleme
* getViewableIterator
*
* @return <code>true</code> if a viewer should call getViewableArray,
- * <code>false</code> if a viewer should call getViewableIterator
+ * <code>false</code> if a viewer should call getViewableIterator
*/
public boolean preferArray() {
return true;
Modified: poi/trunk/poi/src/main/java/org/apache/poi/poifs/storage/HeaderBlock.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/poifs/storage/HeaderBlock.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/poifs/storage/HeaderBlock.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/poifs/storage/HeaderBlock.java Sat May 22 20:56:44 2021
@@ -42,135 +42,135 @@ import org.apache.poi.util.ShortField;
*/
public final class HeaderBlock implements HeaderBlockConstants {
- //arbitrarily selected; may need to increase
- private static final int MAX_RECORD_LENGTH = 100_000;
+ //arbitrarily selected; may need to increase
+ private static final int MAX_RECORD_LENGTH = 100_000;
- private static final byte _default_value = ( byte ) 0xFF;
+ private static final byte _default_value = ( byte ) 0xFF;
/**
- * What big block size the file uses. Most files
- * use 512 bytes, but a few use 4096
- */
- private final POIFSBigBlockSize bigBlockSize;
-
- /**
- * Number of big block allocation table blocks (int).
- * (Number of FAT Sectors in Microsoft parlance).
- */
- private int _bat_count;
-
- /**
- * Start of the property set block (int index of the property set
- * chain's first big block).
- */
- private int _property_start;
-
- /**
- * start of the small block allocation table (int index of small
- * block allocation table's first big block)
- */
- private int _sbat_start;
- /**
- * Number of small block allocation table blocks (int)
- * (Number of MiniFAT Sectors in Microsoft parlance)
- */
- private int _sbat_count;
-
- /**
- * Big block index for extension to the big block allocation table
- */
- private int _xbat_start;
- /**
- * Number of big block allocation table blocks (int)
- * (Number of DIFAT Sectors in Microsoft parlance)
- */
- private int _xbat_count;
-
- /**
- * The data. Only ever 512 bytes, because 4096 byte
- * files use zeros for the extra header space.
- */
- private final byte[] _data;
-
- /**
- * create a new HeaderBlockReader from an InputStream
- *
- * @param stream the source InputStream
- *
- * @exception IOException on errors or bad data
- */
- public HeaderBlock(InputStream stream) throws IOException {
- // Grab the first 512 bytes
- // (For 4096 sized blocks, the remaining 3584 bytes are zero)
- // Then, process the contents
- this(readFirst512(stream));
-
- // Fetch the rest of the block if needed
- if(bigBlockSize.getBigBlockSize() != 512) {
- int rest = bigBlockSize.getBigBlockSize() - 512;
- byte[] tmp = IOUtils.safelyAllocate(rest, MAX_RECORD_LENGTH);
- IOUtils.readFully(stream, tmp);
- }
- }
-
- public HeaderBlock(ByteBuffer buffer) throws IOException {
- this(IOUtils.toByteArray(buffer, POIFSConstants.SMALLER_BIG_BLOCK_SIZE));
- }
-
- private HeaderBlock(byte[] data) throws IOException {
- this._data = data.clone();
-
- // verify signature
- FileMagic fm = FileMagic.valueOf(data);
-
- switch (fm) {
- case OLE2:
- break;
- case OOXML:
+ * What big block size the file uses. Most files
+ * use 512 bytes, but a few use 4096
+ */
+ private final POIFSBigBlockSize bigBlockSize;
+
+ /**
+ * Number of big block allocation table blocks (int).
+ * (Number of FAT Sectors in Microsoft parlance).
+ */
+ private int _bat_count;
+
+ /**
+ * Start of the property set block (int index of the property set
+ * chain's first big block).
+ */
+ private int _property_start;
+
+ /**
+ * start of the small block allocation table (int index of small
+ * block allocation table's first big block)
+ */
+ private int _sbat_start;
+ /**
+ * Number of small block allocation table blocks (int)
+ * (Number of MiniFAT Sectors in Microsoft parlance)
+ */
+ private int _sbat_count;
+
+ /**
+ * Big block index for extension to the big block allocation table
+ */
+ private int _xbat_start;
+ /**
+ * Number of big block allocation table blocks (int)
+ * (Number of DIFAT Sectors in Microsoft parlance)
+ */
+ private int _xbat_count;
+
+ /**
+ * The data. Only ever 512 bytes, because 4096 byte
+ * files use zeros for the extra header space.
+ */
+ private final byte[] _data;
+
+ /**
+ * create a new HeaderBlockReader from an InputStream
+ *
+ * @param stream the source InputStream
+ *
+ * @exception IOException on errors or bad data
+ */
+ public HeaderBlock(InputStream stream) throws IOException {
+ // Grab the first 512 bytes
+ // (For 4096 sized blocks, the remaining 3584 bytes are zero)
+ // Then, process the contents
+ this(readFirst512(stream));
+
+ // Fetch the rest of the block if needed
+ if(bigBlockSize.getBigBlockSize() != 512) {
+ int rest = bigBlockSize.getBigBlockSize() - 512;
+ byte[] tmp = IOUtils.safelyAllocate(rest, MAX_RECORD_LENGTH);
+ IOUtils.readFully(stream, tmp);
+ }
+ }
+
+ public HeaderBlock(ByteBuffer buffer) throws IOException {
+ this(IOUtils.toByteArray(buffer, POIFSConstants.SMALLER_BIG_BLOCK_SIZE));
+ }
+
+ private HeaderBlock(byte[] data) throws IOException {
+ this._data = data.clone();
+
+ // verify signature
+ FileMagic fm = FileMagic.valueOf(data);
+
+ switch (fm) {
+ case OLE2:
+ break;
+ case OOXML:
throw new OfficeXmlFileException("The supplied data appears to be in the Office 2007+ XML. "
+ "You are calling the part of POI that deals with OLE2 Office Documents. "
+ "You need to call a different part of POI to process this data (eg XSSF instead of HSSF)");
- case XML:
+ case XML:
throw new NotOLE2FileException("The supplied data appears to be a raw XML file. "
+ "Formats such as Office 2003 XML are not supported");
- case MSWRITE:
+ case MSWRITE:
throw new NotOLE2FileException("The supplied data appears to be in the old MS Write format. "
+ "Apache POI doesn't currently support this format");
- case WORD2:
- throw new NotOLE2FileException("The supplied data appears to be an old Word version 2 file. "
- + "Apache POI doesn't currently support this format");
+ case WORD2:
+ throw new NotOLE2FileException("The supplied data appears to be an old Word version 2 file. "
+ + "Apache POI doesn't currently support this format");
case BIFF2:
case BIFF3:
case BIFF4:
throw new OldExcelFormatException("The supplied data appears to be in "+fm+" format. "
+ "HSSF only supports the BIFF8 format, try OldExcelExtractor");
- default:
+ default:
// Give a generic error if the OLE2 signature isn't found
- String exp = HexDump.longToHex(_signature);
- String act = HexDump.longToHex(LittleEndian.getLong(data, 0));
+ String exp = HexDump.longToHex(_signature);
+ String act = HexDump.longToHex(LittleEndian.getLong(data, 0));
throw new NotOLE2FileException(
"Invalid header signature; read " + act + ", expected " + exp +
" - Your file appears not to be a valid OLE2 document");
- }
-
- // Figure out our block size
- if (_data[30] == 12) {
- this.bigBlockSize = POIFSConstants.LARGER_BIG_BLOCK_SIZE_DETAILS;
- } else if(_data[30] == 9) {
- this.bigBlockSize = POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS;
- } else {
- throw new IOException("Unsupported blocksize (2^"+ _data[30] + "). Expected 2^9 or 2^12.");
- }
+ }
+
+ // Figure out our block size
+ if (_data[30] == 12) {
+ this.bigBlockSize = POIFSConstants.LARGER_BIG_BLOCK_SIZE_DETAILS;
+ } else if(_data[30] == 9) {
+ this.bigBlockSize = POIFSConstants.SMALLER_BIG_BLOCK_SIZE_DETAILS;
+ } else {
+ throw new IOException("Unsupported blocksize (2^"+ _data[30] + "). Expected 2^9 or 2^12.");
+ }
- // Setup the fields to read and write the counts and starts
+ // Setup the fields to read and write the counts and starts
_bat_count = new IntegerField(_bat_count_offset, data).get();
_property_start = new IntegerField(_property_start_offset,_data).get();
_sbat_start = new IntegerField(_sbat_start_offset, _data).get();
_sbat_count = new IntegerField(_sbat_block_count_offset, _data).get();
_xbat_start = new IntegerField(_xbat_start_offset, _data).get();
_xbat_count = new IntegerField(_xbat_count_offset, _data).get();
- }
-
+ }
+
/**
* Create a single instance initialized with default values
*/
@@ -208,7 +208,7 @@ public final class HeaderBlock implement
_xbat_start = POIFSConstants.END_OF_CHAIN;
}
- private static byte[] readFirst512(InputStream stream) throws IOException {
+ private static byte[] readFirst512(InputStream stream) throws IOException {
// Grab the first 512 bytes
// (For 4096 sized blocks, the remaining 3584 bytes are zero)
byte[] data = new byte[512];
@@ -217,30 +217,30 @@ public final class HeaderBlock implement
throw alertShortRead(bsCount);
}
return data;
- }
+ }
+
+ private static IOException alertShortRead(int pRead) {
+ int read;
+ if (pRead < 0) {
+ //Can't have -1 bytes read in the error message!
+ read = 0;
+ } else {
+ read = pRead;
+ }
+ String type = " byte" + (read == 1 ? (""): ("s"));
+
+ return new IOException("Unable to read entire header; "
+ + read + type + " read; expected 512 bytes");
+ }
- private static IOException alertShortRead(int pRead) {
- int read;
- if (pRead < 0) {
- //Can't have -1 bytes read in the error message!
- read = 0;
- } else {
- read = pRead;
- }
- String type = " byte" + (read == 1 ? (""): ("s"));
-
- return new IOException("Unable to read entire header; "
- + read + type + " read; expected 512 bytes");
- }
-
- /**
- * get start of Property Table
- *
- * @return the index of the first block of the Property Table
- */
- public int getPropertyStart() {
- return _property_start;
- }
+ /**
+ * get start of Property Table
+ *
+ * @return the index of the first block of the Property Table
+ */
+ public int getPropertyStart() {
+ return _property_start;
+ }
/**
* Set start of Property Table
*
@@ -250,16 +250,16 @@ public final class HeaderBlock implement
_property_start = startBlock;
}
- /**
- * @return start of small block (MiniFAT) allocation table
- */
- public int getSBATStart() {
- return _sbat_start;
- }
- public int getSBATCount() {
- return _sbat_count;
- }
-
+ /**
+ * @return start of small block (MiniFAT) allocation table
+ */
+ public int getSBATStart() {
+ return _sbat_start;
+ }
+ public int getSBATCount() {
+ return _sbat_count;
+ }
+
/**
* Set start of small block allocation table
*
@@ -279,12 +279,12 @@ public final class HeaderBlock implement
_sbat_count = count;
}
- /**
- * @return number of BAT blocks
- */
- public int getBATCount() {
- return _bat_count;
- }
+ /**
+ * @return number of BAT blocks
+ */
+ public int getBATCount() {
+ return _bat_count;
+ }
/**
* Sets the number of BAT blocks that are used.
* This is the number used in both the BAT and XBAT.
@@ -293,75 +293,75 @@ public final class HeaderBlock implement
_bat_count = count;
}
- /**
- * Returns the offsets to the first (up to) 109
- * BAT sectors.
- * Any additional BAT sectors are held in the XBAT (DIFAT)
- * sectors in a chain.
- * @return BAT offset array
- */
- public int[] getBATArray() {
+ /**
+ * Returns the offsets to the first (up to) 109
+ * BAT sectors.
+ * Any additional BAT sectors are held in the XBAT (DIFAT)
+ * sectors in a chain.
+ * @return BAT offset array
+ */
+ public int[] getBATArray() {
// Read them in
- int[] result = new int[ Math.min(_bat_count,_max_bats_in_header) ];
- int offset = _bat_array_offset;
- for (int j = 0; j < result.length; j++) {
- result[ j ] = LittleEndian.getInt(_data, offset);
- offset += LittleEndianConsts.INT_SIZE;
- }
- return result;
- }
- /**
- * Sets the offsets of the first (up to) 109
- * BAT sectors.
- */
- public void setBATArray(int[] bat_array) {
- int count = Math.min(bat_array.length, _max_bats_in_header);
- int blank = _max_bats_in_header - count;
-
+ int[] result = new int[ Math.min(_bat_count,_max_bats_in_header) ];
+ int offset = _bat_array_offset;
+ for (int j = 0; j < result.length; j++) {
+ result[ j ] = LittleEndian.getInt(_data, offset);
+ offset += LittleEndianConsts.INT_SIZE;
+ }
+ return result;
+ }
+ /**
+ * Sets the offsets of the first (up to) 109
+ * BAT sectors.
+ */
+ public void setBATArray(int[] bat_array) {
+ int count = Math.min(bat_array.length, _max_bats_in_header);
+ int blank = _max_bats_in_header - count;
+
int offset = _bat_array_offset;
- for(int i=0; i<count; i++) {
- LittleEndian.putInt(_data, offset, bat_array[i]);
+ for(int i=0; i<count; i++) {
+ LittleEndian.putInt(_data, offset, bat_array[i]);
offset += LittleEndianConsts.INT_SIZE;
- }
- for(int i=0; i<blank; i++) {
+ }
+ for(int i=0; i<blank; i++) {
LittleEndian.putInt(_data, offset, POIFSConstants.UNUSED_BLOCK);
offset += LittleEndianConsts.INT_SIZE;
- }
- }
+ }
+ }
+
+ /**
+ * @return XBAT (DIFAT) count
+ */
+ public int getXBATCount() {
+ return _xbat_count;
+ }
+ /**
+ * Sets the number of XBAT (DIFAT) blocks used
+ */
+ public void setXBATCount(final int count) {
+ _xbat_count = count;
+ }
- /**
- * @return XBAT (DIFAT) count
- */
- public int getXBATCount() {
- return _xbat_count;
- }
- /**
- * Sets the number of XBAT (DIFAT) blocks used
- */
- public void setXBATCount(final int count) {
- _xbat_count = count;
- }
-
- /**
- * @return XBAT (DIFAT) index
- */
- public int getXBATIndex() {
- return _xbat_start;
- }
- /**
- * Sets the first XBAT (DIFAT) block location
- */
+ /**
+ * @return XBAT (DIFAT) index
+ */
+ public int getXBATIndex() {
+ return _xbat_start;
+ }
+ /**
+ * Sets the first XBAT (DIFAT) block location
+ */
public void setXBATStart(final int startBlock) {
_xbat_start = startBlock;
}
- /**
- * @return The Big Block size, normally 512 bytes, sometimes 4096 bytes
- */
- public POIFSBigBlockSize getBigBlockSize() {
- return bigBlockSize;
- }
-
+ /**
+ * @return The Big Block size, normally 512 bytes, sometimes 4096 bytes
+ */
+ public POIFSBigBlockSize getBigBlockSize() {
+ return bigBlockSize;
+ }
+
/**
* Write the block's data to an OutputStream
*
Modified: poi/trunk/poi/src/main/java/org/apache/poi/sl/draw/DrawTexturePaint.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/sl/draw/DrawTexturePaint.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/sl/draw/DrawTexturePaint.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/sl/draw/DrawTexturePaint.java Sat May 22 20:56:44 2021
@@ -66,7 +66,7 @@ public class DrawTexturePaint extends ja
if (fill.isRotatedWithShape() || shape == null) {
usedBounds = userBounds;
} else {
- AffineTransform transform = new AffineTransform(xform);
+ AffineTransform transform = new AffineTransform(xform);
// Eliminate any post-translation
transform.preConcatenate(AffineTransform.getTranslateInstance(
Modified: poi/trunk/poi/src/main/java/org/apache/poi/sl/draw/geom/ArcToCommand.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/sl/draw/geom/ArcToCommand.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/sl/draw/geom/ArcToCommand.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/sl/draw/geom/ArcToCommand.java Sat May 22 20:56:44 2021
@@ -105,7 +105,7 @@ public class ArcToCommand implements Pat
double y0 = pt.getY() - ry * Math.sin(invStart) - ry;
Arc2D arc = new Arc2D.Double(x0, y0, 2 * rx, 2 * ry, awtStart, awtSweep, Arc2D.OPEN);
- path.append(arc, true);
+ path.append(arc, true);
}
/**
Modified: poi/trunk/poi/src/main/java/org/apache/poi/sl/draw/geom/Path.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/sl/draw/geom/Path.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/sl/draw/geom/Path.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/sl/draw/geom/Path.java Sat May 22 20:56:44 2021
@@ -118,7 +118,7 @@ public final class Path {
}
public long getW(){
- return w;
+ return w;
}
public void setW(long w) {
@@ -126,7 +126,7 @@ public final class Path {
}
public long getH(){
- return h;
+ return h;
}
public void setH(long h) {
Modified: poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/MasterSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/MasterSheet.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/MasterSheet.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/MasterSheet.java Sat May 22 20:56:44 2021
@@ -21,12 +21,12 @@ public interface MasterSheet<
S extends Shape<S,P>,
P extends TextParagraph<S,P,? extends TextRun>
> extends Sheet<S,P> {
- /**
- * Return the placeholder shape for the specified type
- *
- * @return the shape or {@code null} if it is not defined in this mastersheet
- *
- * @since POI 4.0.0
- */
+ /**
+ * Return the placeholder shape for the specified type
+ *
+ * @return the shape or {@code null} if it is not defined in this mastersheet
+ *
+ * @since POI 4.0.0
+ */
SimpleShape<S,P> getPlaceholder(Placeholder type);
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/Notes.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/Notes.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/Notes.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/Notes.java Sat May 22 20:56:44 2021
@@ -23,5 +23,5 @@ public interface Notes<
S extends Shape<S,P>,
P extends TextParagraph<S,P,? extends TextRun>
> extends Sheet<S,P> {
- List<? extends List<P>> getTextParagraphs();
+ List<? extends List<P>> getTextParagraphs();
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/PictureData.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/PictureData.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/PictureData.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/PictureData.java Sat May 22 20:56:44 2021
@@ -90,18 +90,18 @@ public interface PictureData {
*
* @return content type of this picture.
*/
- String getContentType();
-
- /**
- * @return the picture type
- */
- PictureType getType();
+ String getContentType();
+
+ /**
+ * @return the picture type
+ */
+ PictureType getType();
/**
* Returns the binary data of this Picture
* @return picture data
*/
- byte[] getData();
+ byte[] getData();
/**
* Sets the binary picture data
@@ -111,26 +111,26 @@ public interface PictureData {
*
* @param data picture data
*/
- void setData(byte[] data) throws IOException;
-
- /**
- * Gets the checksum - the checksum can be of various length -
- * mostly it's 8 (XSLF) or 16 (HSLF) bytes long.
- * @return the checksum
- */
- byte[] getChecksum();
-
+ void setData(byte[] data) throws IOException;
+
+ /**
+ * Gets the checksum - the checksum can be of various length -
+ * mostly it's 8 (XSLF) or 16 (HSLF) bytes long.
+ * @return the checksum
+ */
+ byte[] getChecksum();
+
/**
* Return the original image dimensions in points
* (for formats supported by BufferedImage).
*
* Will return a Dimension with a default width of 200x200 if the format unsupported.
*/
- Dimension getImageDimension();
-
+ Dimension getImageDimension();
+
/**
* Return the original image dimensions in pixels
* @see PictureData#getImageDimension()
*/
- Dimension getImageDimensionInPixels();
+ Dimension getImageDimensionInPixels();
}
\ No newline at end of file
Modified: poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/PictureShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/PictureShape.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/PictureShape.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/PictureShape.java Sat May 22 20:56:44 2021
@@ -30,21 +30,21 @@ public interface PictureShape<
*/
PictureData getPictureData();
- /**
- * Returns an alternative picture data, e.g. an embedded SVG image
- *
- * @return an alternative picture data
- *
- * @since POI 4.1.0
- */
+ /**
+ * Returns an alternative picture data, e.g. an embedded SVG image
+ *
+ * @return an alternative picture data
+ *
+ * @since POI 4.1.0
+ */
default PictureData getAlternativePictureData() { return null; }
- /**
- * Returns the clipping values as percent ratio relatively to the image size.
- * The clipping are returned as insets converted/scaled to 100000 (=100%).
- *
- * @return the clipping rectangle, which is given in percent in relation to the image width/height
- */
- Insets getClipping();
+ /**
+ * Returns the clipping values as percent ratio relatively to the image size.
+ * The clipping are returned as insets converted/scaled to 100000 (=100%).
+ *
+ * @return the clipping rectangle, which is given in percent in relation to the image width/height
+ */
+ Insets getClipping();
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/Shape.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/Shape.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/Shape.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/Shape.java Sat May 22 20:56:44 2021
@@ -24,7 +24,7 @@ public interface Shape<
S extends Shape<S,P>,
P extends TextParagraph<S,P,? extends TextRun>
> {
- ShapeContainer<S,P> getParent();
+ ShapeContainer<S,P> getParent();
/**
* @return the sheet this shape belongs to
Modified: poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/ShapeContainer.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/ShapeContainer.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/ShapeContainer.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/ShapeContainer.java Sat May 22 20:56:44 2021
@@ -31,9 +31,9 @@ public interface ShapeContainer<
* @return an list containing all of the elements in this container in proper
* sequence
*/
- List<S> getShapes();
+ List<S> getShapes();
- void addShape(S shape);
+ void addShape(S shape);
/**
* Removes the specified shape from this sheet, if it is present
@@ -45,7 +45,7 @@ public interface ShapeContainer<
* @throws IllegalArgumentException if the type of the specified shape
* is incompatible with this sheet (optional)
*/
- boolean removeShape(S shape);
+ boolean removeShape(S shape);
/**
* create a new shape with a predefined geometry and add it to this shape container
@@ -60,22 +60,22 @@ public interface ShapeContainer<
/**
* create a text box
*/
- TextBox<S,P> createTextBox();
+ TextBox<S,P> createTextBox();
/**
* create a connector
*/
- ConnectorShape<S,P> createConnector();
+ ConnectorShape<S,P> createConnector();
/**
* create a group of shapes belonging to this container
*/
- GroupShape<S,P> createGroup();
+ GroupShape<S,P> createGroup();
/**
* create a picture belonging to this container
*/
- PictureShape<S,P> createPicture(PictureData pictureData);
+ PictureShape<S,P> createPicture(PictureData pictureData);
/**
* Create a new Table of the given number of rows and columns
@@ -83,12 +83,12 @@ public interface ShapeContainer<
* @param numRows the number of rows
* @param numCols the number of columns
*/
- TableShape<S,P> createTable(int numRows, int numCols);
+ TableShape<S,P> createTable(int numRows, int numCols);
- /**
- * Create a new OLE object shape with the given pictureData as preview image
- *
- * @param pictureData the preview image
- */
+ /**
+ * Create a new OLE object shape with the given pictureData as preview image
+ *
+ * @param pictureData the preview image
+ */
ObjectShape<?,?> createOleShape(PictureData pictureData);
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/Sheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/Sheet.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/Sheet.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/Sheet.java Sat May 22 20:56:44 2021
@@ -27,33 +27,33 @@ public interface Sheet<
S extends Shape<S,P>,
P extends TextParagraph<S,P,? extends TextRun>
> extends ShapeContainer<S,P> {
- SlideShow<S,P> getSlideShow();
+ SlideShow<S,P> getSlideShow();
/**
* @return whether shapes on the master sheet should be shown. By default master graphics is turned off.
* Sheets that support the notion of master (slide, slideLayout) should override it and
* check this setting in the sheet XML
*/
- boolean getFollowMasterGraphics();
+ boolean getFollowMasterGraphics();
- MasterSheet<S,P> getMasterSheet();
+ MasterSheet<S,P> getMasterSheet();
- Background<S,P> getBackground();
+ Background<S,P> getBackground();
- /**
- * Convenience method to draw a sheet to a graphics context
- */
- void draw(Graphics2D graphics);
+ /**
+ * Convenience method to draw a sheet to a graphics context
+ */
+ void draw(Graphics2D graphics);
- /**
- * Get the placeholder details for the given placeholder type. Not all placeholders are also shapes -
- * this is especially true for old HSLF slideshows, which notes have header/footers elements which
- * aren't shapes.
- *
- * @param placeholder the placeholder type
- * @return the placeholder details or {@code null}, if the placeholder isn't contained in the sheet
- *
- * @since POI 4.0.0
- */
- PlaceholderDetails getPlaceholderDetails(Placeholder placeholder);
+ /**
+ * Get the placeholder details for the given placeholder type. Not all placeholders are also shapes -
+ * this is especially true for old HSLF slideshows, which notes have header/footers elements which
+ * aren't shapes.
+ *
+ * @param placeholder the placeholder type
+ * @return the placeholder details or {@code null}, if the placeholder isn't contained in the sheet
+ *
+ * @since POI 4.0.0
+ */
+ PlaceholderDetails getPlaceholderDetails(Placeholder placeholder);
}
Modified: poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/SimpleShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/SimpleShape.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/SimpleShape.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/SimpleShape.java Sat May 22 20:56:44 2021
@@ -83,7 +83,7 @@ public interface SimpleShape<
boolean isPlaceholder();
- Shadow<S,P> getShadow();
+ Shadow<S,P> getShadow();
/**
* Returns the solid color fill.
@@ -91,7 +91,7 @@ public interface SimpleShape<
* @return solid fill color of null if not set or fill color
* is not solid (pattern or gradient)
*/
- Color getFillColor();
+ Color getFillColor();
/**
* Specifies a solid color fill. The shape is filled entirely with the
@@ -100,7 +100,7 @@ public interface SimpleShape<
* @param color the solid color fill. The value of <code>null</code> unsets
* the solid fill attribute from the underlying implementation
*/
- void setFillColor(Color color);
+ void setFillColor(Color color);
/**
* Returns the hyperlink assigned to this shape
@@ -110,9 +110,9 @@ public interface SimpleShape<
*
* @since POI 3.14-Beta1
*/
- Hyperlink<S,P> getHyperlink();
-
- /**
+ Hyperlink<S,P> getHyperlink();
+
+ /**
* Creates a hyperlink and asigns it to this shape.
* If the shape has already a hyperlink assigned, return it instead
*
Modified: poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/SlideShow.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/SlideShow.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/SlideShow.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/sl/usermodel/SlideShow.java Sat May 22 20:56:44 2021
@@ -33,17 +33,17 @@ public interface SlideShow<
S extends Shape<S,P>,
P extends TextParagraph<S,P,? extends TextRun>
> extends Closeable {
- Slide<S,P> createSlide() throws IOException;
+ Slide<S,P> createSlide() throws IOException;
- List<? extends Slide<S,P>> getSlides();
+ List<? extends Slide<S,P>> getSlides();
MasterSheet<S,P> createMasterSheet() throws IOException;
- /**
+ /**
* Returns all slide masters.
* This doesn't include notes master and other arbitrary masters.
*/
- List<? extends MasterSheet<S,P>> getSlideMasters();
+ List<? extends MasterSheet<S,P>> getSlideMasters();
/**
* Returns the current page size
@@ -79,7 +79,7 @@ public interface SlideShow<
/**
* Adds a picture to the presentation.
*
- * @param is The stream to read the image from
+ * @param is The stream to read the image from
* @param format The format of the picture.
*
* @return the picture data reference.
Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/CellCacheEntry.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/CellCacheEntry.java?rev=1890120&r1=1890119&r2=1890120&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/CellCacheEntry.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/CellCacheEntry.java Sat May 22 20:56:44 2021
@@ -29,108 +29,108 @@ import org.apache.poi.ss.formula.IEvalua
* Stores the parameters that identify the evaluation of one cell.<br>
*/
abstract class CellCacheEntry implements ICacheEntry {
- public static final CellCacheEntry[] EMPTY_ARRAY = { };
+ public static final CellCacheEntry[] EMPTY_ARRAY = { };
- private final FormulaCellCacheEntrySet _consumingCells;
- private ValueEval _value;
+ private final FormulaCellCacheEntrySet _consumingCells;
+ private ValueEval _value;
- protected CellCacheEntry() {
- _consumingCells = new FormulaCellCacheEntrySet();
- }
- protected final void clearValue() {
- _value = null;
- }
-
- public final boolean updateValue(ValueEval value) {
- if (value == null) {
- throw new IllegalArgumentException("Did not expect to update to null");
- }
- boolean result = !areValuesEqual(_value, value);
- _value = value;
- return result;
- }
- public final ValueEval getValue() {
- return _value;
- }
-
- private static boolean areValuesEqual(ValueEval a, ValueEval b) {
- if (a == null) {
- return false;
- }
- Class<? extends ValueEval> cls = a.getClass();
- if (cls != b.getClass()) {
- // value type is changing
- return false;
- }
- if (a == BlankEval.instance) {
- return b == a;
- }
- if (cls == NumberEval.class) {
- return ((NumberEval)a).getNumberValue() == ((NumberEval)b).getNumberValue();
- }
- if (cls == StringEval.class) {
- return ((StringEval)a).getStringValue().equals(((StringEval)b).getStringValue());
- }
- if (cls == BoolEval.class) {
- return ((BoolEval)a).getBooleanValue() == ((BoolEval)b).getBooleanValue();
- }
- if (cls == ErrorEval.class) {
- return ((ErrorEval)a).getErrorCode() == ((ErrorEval)b).getErrorCode();
- }
- throw new IllegalStateException("Unexpected value class (" + cls.getName() + ")");
- }
-
- public final void addConsumingCell(FormulaCellCacheEntry cellLoc) {
- _consumingCells.add(cellLoc);
-
- }
- public final FormulaCellCacheEntry[] getConsumingCells() {
- return _consumingCells.toArray();
- }
-
- public final void clearConsumingCell(FormulaCellCacheEntry cce) {
- if(!_consumingCells.remove(cce)) {
- throw new IllegalStateException("Specified formula cell is not consumed by this cell");
- }
- }
- public final void recurseClearCachedFormulaResults(IEvaluationListener listener) {
- if (listener == null) {
- recurseClearCachedFormulaResults();
- } else {
- listener.onClearCachedValue(this);
- recurseClearCachedFormulaResults(listener, 1);
- }
- }
-
- /**
- * Calls formulaCell.setFormulaResult(null, null) recursively all the way up the tree of
- * dependencies. Calls usedCell.clearConsumingCell(fc) for each child of a cell that is
- * cleared along the way.
- * @param formulaCells
- */
- protected final void recurseClearCachedFormulaResults() {
- FormulaCellCacheEntry[] formulaCells = getConsumingCells();
-
- for (int i = 0; i < formulaCells.length; i++) {
- FormulaCellCacheEntry fc = formulaCells[i];
- fc.clearFormulaEntry();
- fc.recurseClearCachedFormulaResults();
- }
- }
-
- /**
- * Identical to {@link #recurseClearCachedFormulaResults()} except for the listener call-backs
- */
- protected final void recurseClearCachedFormulaResults(IEvaluationListener listener, int depth) {
- FormulaCellCacheEntry[] formulaCells = getConsumingCells();
-
- listener.sortDependentCachedValues(formulaCells);
- for (int i = 0; i < formulaCells.length; i++) {
- FormulaCellCacheEntry fc = formulaCells[i];
- listener.onClearDependentCachedValue(fc, depth);
- fc.clearFormulaEntry();
- fc.recurseClearCachedFormulaResults(listener, depth+1);
- }
- }
+ protected CellCacheEntry() {
+ _consumingCells = new FormulaCellCacheEntrySet();
+ }
+ protected final void clearValue() {
+ _value = null;
+ }
+
+ public final boolean updateValue(ValueEval value) {
+ if (value == null) {
+ throw new IllegalArgumentException("Did not expect to update to null");
+ }
+ boolean result = !areValuesEqual(_value, value);
+ _value = value;
+ return result;
+ }
+ public final ValueEval getValue() {
+ return _value;
+ }
+
+ private static boolean areValuesEqual(ValueEval a, ValueEval b) {
+ if (a == null) {
+ return false;
+ }
+ Class<? extends ValueEval> cls = a.getClass();
+ if (cls != b.getClass()) {
+ // value type is changing
+ return false;
+ }
+ if (a == BlankEval.instance) {
+ return b == a;
+ }
+ if (cls == NumberEval.class) {
+ return ((NumberEval)a).getNumberValue() == ((NumberEval)b).getNumberValue();
+ }
+ if (cls == StringEval.class) {
+ return ((StringEval)a).getStringValue().equals(((StringEval)b).getStringValue());
+ }
+ if (cls == BoolEval.class) {
+ return ((BoolEval)a).getBooleanValue() == ((BoolEval)b).getBooleanValue();
+ }
+ if (cls == ErrorEval.class) {
+ return ((ErrorEval)a).getErrorCode() == ((ErrorEval)b).getErrorCode();
+ }
+ throw new IllegalStateException("Unexpected value class (" + cls.getName() + ")");
+ }
+
+ public final void addConsumingCell(FormulaCellCacheEntry cellLoc) {
+ _consumingCells.add(cellLoc);
+
+ }
+ public final FormulaCellCacheEntry[] getConsumingCells() {
+ return _consumingCells.toArray();
+ }
+
+ public final void clearConsumingCell(FormulaCellCacheEntry cce) {
+ if(!_consumingCells.remove(cce)) {
+ throw new IllegalStateException("Specified formula cell is not consumed by this cell");
+ }
+ }
+ public final void recurseClearCachedFormulaResults(IEvaluationListener listener) {
+ if (listener == null) {
+ recurseClearCachedFormulaResults();
+ } else {
+ listener.onClearCachedValue(this);
+ recurseClearCachedFormulaResults(listener, 1);
+ }
+ }
+
+ /**
+ * Calls formulaCell.setFormulaResult(null, null) recursively all the way up the tree of
+ * dependencies. Calls usedCell.clearConsumingCell(fc) for each child of a cell that is
+ * cleared along the way.
+ * @param formulaCells
+ */
+ protected final void recurseClearCachedFormulaResults() {
+ FormulaCellCacheEntry[] formulaCells = getConsumingCells();
+
+ for (int i = 0; i < formulaCells.length; i++) {
+ FormulaCellCacheEntry fc = formulaCells[i];
+ fc.clearFormulaEntry();
+ fc.recurseClearCachedFormulaResults();
+ }
+ }
+
+ /**
+ * Identical to {@link #recurseClearCachedFormulaResults()} except for the listener call-backs
+ */
+ protected final void recurseClearCachedFormulaResults(IEvaluationListener listener, int depth) {
+ FormulaCellCacheEntry[] formulaCells = getConsumingCells();
+
+ listener.sortDependentCachedValues(formulaCells);
+ for (int i = 0; i < formulaCells.length; i++) {
+ FormulaCellCacheEntry fc = formulaCells[i];
+ listener.onClearDependentCachedValue(fc, depth);
+ fc.clearFormulaEntry();
+ fc.recurseClearCachedFormulaResults(listener, depth+1);
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org