You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2021/05/21 21:22:41 UTC
svn commit: r1890089 [3/6] - in /poi/trunk: ./ poi-examples/
poi-examples/src/main/java/org/apache/poi/examples/hpsf/
poi-examples/src/main/java/org/apache/poi/examples/xssf/eventusermodel/
poi-examples/src/main/java/org/apache/poi/examples/xssf/stream...
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/IBody.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/IBody.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/IBody.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/IBody.java Fri May 21 21:22:40 2021
@@ -41,7 +41,7 @@ public interface IBody {
*
* @return the Part, to which the body belongs
*/
- public POIXMLDocumentPart getPart();
+ POIXMLDocumentPart getPart();
/**
* get the PartType of the body, for example
@@ -49,26 +49,26 @@ public interface IBody {
*
* @return the PartType of the body
*/
- public BodyType getPartType();
+ BodyType getPartType();
/**
* Returns an Iterator with paragraphs and tables,
* in the order that they occur in the text.
*/
- public List<IBodyElement> getBodyElements();
+ List<IBodyElement> getBodyElements();
/**
* Returns the paragraph(s) that holds
* the text of the header or footer.
*/
- public List<XWPFParagraph> getParagraphs();
+ List<XWPFParagraph> getParagraphs();
/**
* Return the table(s) that holds the text
* of the IBodyPart, for complex cases
* where a paragraph isn't used.
*/
- public List<XWPFTable> getTables();
+ List<XWPFTable> getTables();
/**
* Returns the paragraph corresponding to the provided {@link CTP}.
@@ -77,58 +77,47 @@ public interface IBody {
* @return The paragraph corresponding to the {@link CTP}, or {@code null} if there is no corresponding paragraph in
* this body.
*/
- public XWPFParagraph getParagraph(CTP p);
+ XWPFParagraph getParagraph(CTP p);
/**
* if there is a corresponding {@link XWPFTable} of the parameter ctTable in the tableList of this header
* the method will return this table
* if there is no corresponding {@link XWPFTable} the method will return null
- *
- * @param ctTable
*/
- public XWPFTable getTable(CTTbl ctTable);
+ XWPFTable getTable(CTTbl ctTable);
/**
* Returns the paragraph that of position pos
*/
- public XWPFParagraph getParagraphArray(int pos);
+ XWPFParagraph getParagraphArray(int pos);
/**
* Returns the table at position pos
*/
- public XWPFTable getTableArray(int pos);
+ XWPFTable getTableArray(int pos);
/**
* inserts a new paragraph at position of the cursor
- *
- * @param cursor
*/
- public XWPFParagraph insertNewParagraph(XmlCursor cursor);
+ XWPFParagraph insertNewParagraph(XmlCursor cursor);
/**
* inserts a new Table at the cursor position.
- *
- * @param cursor
*/
- public XWPFTable insertNewTbl(XmlCursor cursor);
+ XWPFTable insertNewTbl(XmlCursor cursor);
/**
* inserts a new Table at position pos
- *
- * @param pos
- * @param table
*/
void insertTable(int pos, XWPFTable table);
/**
* returns the TableCell to which the Table belongs
- *
- * @param cell
*/
- public XWPFTableCell getTableCell(CTTc cell);
+ XWPFTableCell getTableCell(CTTc cell);
/**
* Return XWPFDocument
*/
- public XWPFDocument getXWPFDocument();
+ XWPFDocument getXWPFDocument();
}
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/ISDTContent.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/ISDTContent.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/ISDTContent.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/ISDTContent.java Fri May 21 21:22:40 2021
@@ -17,18 +17,17 @@
package org.apache.poi.xwpf.usermodel;
+import org.apache.poi.util.Beta;
+
/**
* Experimental interface to offer rudimentary read-only processing of
* of the contentblock of an SDT/ContentControl.
- * <p>
- * <p>
- * <p>
- * WARNING - APIs expected to change rapidly
*/
+@Beta
public interface ISDTContent {
- public String getText();
+ String getText();
- public String toString();
+ String toString();
}
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFChart.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFChart.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFChart.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFChart.java Fri May 21 21:22:40 2021
@@ -68,7 +68,7 @@ public class XWPFChart extends XDDFChart
* Construct a chart from a package part.
*
* @param part the package part holding the chart data,
- * the content type must be <code>application/vnd.openxmlformats-officedocument.drawingml.chart+xml</code>
+ * the content type must be {@code application/vnd.openxmlformats-officedocument.drawingml.chart+xml}
* @since POI 4.0.0
*/
protected XWPFChart(PackagePart part) throws IOException, XmlException {
@@ -105,30 +105,7 @@ public class XWPFChart extends XDDFChart
@Override
public boolean equals(Object obj) {
- /**
- * In case two objects ARE equal, but its not the same instance, this
- * implementation will always run through the whole
- * byte-array-comparison before returning true. If this will turn into a
- * performance issue, two possible approaches are available:<br>
- * a) Use the checksum only and take the risk that two images might have
- * the same CRC32 sum, although they are not the same.<br>
- * b) Use a second (or third) checksum algorithm to minimise the chance
- * that two images have the same checksums but are not equal (e.g.
- * CRC32, MD5 and SHA-1 checksums, additionally compare the
- * data-byte-array lengths).
- */
- if (obj == this) {
- return true;
- }
-
- if (obj == null) {
- return false;
- }
-
- if (!(obj instanceof XWPFChart)) {
- return false;
- }
- return false;
+ return obj == this;
}
@Override
@@ -141,8 +118,6 @@ public class XWPFChart extends XDDFChart
*
* @param chartRelId the relation id of this chart in its parent document.
* @param run the text run to which this chart will be inlined.
- * @throws InvalidFormatException
- * @throws IOException
* @since POI 4.0.0
*/
protected void attach(String chartRelId, XWPFRun run)
@@ -215,7 +190,6 @@ public class XWPFChart extends XDDFChart
/**
* get margin from Top
*
- * @param margin
* @since POI 4.0.0
*/
public long getChartTopMargin(long margin) {
@@ -235,7 +209,6 @@ public class XWPFChart extends XDDFChart
/**
* get margin from Bottom
*
- * @param margin
* @since POI 4.0.0
*/
public long getChartBottomMargin(long margin) {
@@ -255,7 +228,6 @@ public class XWPFChart extends XDDFChart
/**
* get margin from left
*
- * @param margin
* @since POI 4.0.0
*/
public long getChartLeftMargin(long margin) {
@@ -275,7 +247,6 @@ public class XWPFChart extends XDDFChart
/**
* get margin from Right
*
- * @param margin
* @since POI 4.0.0
*/
public long getChartRightMargin(long margin) {
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFComments.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFComments.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFComments.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFComments.java Fri May 21 21:22:40 2021
@@ -47,8 +47,8 @@ import static org.apache.poi.ooxml.POIXM
public class XWPFComments extends POIXMLDocumentPart {
XWPFDocument document;
- private List<XWPFComment> comments = new ArrayList<>();
- private List<XWPFPictureData> pictures = new ArrayList<>();
+ private final List<XWPFComment> comments = new ArrayList<>();
+ private final List<XWPFPictureData> pictures = new ArrayList<>();
private CTComments ctComments;
/**
@@ -192,8 +192,6 @@ public class XWPFComments extends POIXML
/**
* Get the list of {@link XWPFComment} in the Comments part.
- *
- * @return
*/
public List<XWPFComment> getComments() {
return comments;
@@ -203,7 +201,6 @@ public class XWPFComments extends POIXML
* Get the specified comment by position
*
* @param pos Array position of the comment
- * @return
*/
public XWPFComment getComment(int pos) {
if (pos >= 0 && pos < ctComments.sizeOfCommentArray()) {
@@ -229,14 +226,11 @@ public class XWPFComments extends POIXML
/**
* Get the specified comment by ctComment
- *
- * @param ctComment
- * @return
*/
public XWPFComment getComment(CTComment ctComment) {
- for (int i = 0; i < comments.size(); i++) {
- if (comments.get(i).getCtComment() == ctComment) {
- return comments.get(i);
+ for (XWPFComment comment : comments) {
+ if (comment.getCtComment() == ctComment) {
+ return comment;
}
}
return null;
@@ -246,7 +240,6 @@ public class XWPFComments extends POIXML
* Create a new comment and add it to the document.
*
* @param cid comment Id
- * @return
*/
public XWPFComment createComment(BigInteger cid) {
CTComment ctComment = ctComments.addNewComment();
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFFooter.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFFooter.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFFooter.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFFooter.java Fri May 21 21:22:40 2021
@@ -89,7 +89,7 @@ public class XWPFFooter extends XWPFHead
@Override
protected void onDocumentRead() throws IOException {
super.onDocumentRead();
- FtrDocument ftrDocument = null;
+ FtrDocument ftrDocument;
try (InputStream is = getPackagePart().getInputStream()) {
ftrDocument = FtrDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
headerFooter = ftrDocument.getFtr();
@@ -125,6 +125,7 @@ public class XWPFFooter extends XWPFHead
*
* @see org.apache.poi.xwpf.usermodel.IBody#getPartType()
*/
+ @Override
public BodyType getPartType() {
return BodyType.FOOTER;
}
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFHeader.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFHeader.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFHeader.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFHeader.java Fri May 21 21:22:40 2021
@@ -86,13 +86,11 @@ public class XWPFHeader extends XWPFHead
/**
* reads the document
- *
- * @throws IOException
*/
@Override
protected void onDocumentRead() throws IOException {
super.onDocumentRead();
- HdrDocument hdrDocument = null;
+ HdrDocument hdrDocument;
try (InputStream is = getPackagePart().getInputStream()) {
hdrDocument = HdrDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
headerFooter = hdrDocument.getHdr();
@@ -128,6 +126,7 @@ public class XWPFHeader extends XWPFHead
*
* @see org.apache.poi.xwpf.usermodel.IBody#getPartType()
*/
+ @Override
public BodyType getPartType() {
return BodyType.HEADER;
}
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFNumbering.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFNumbering.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFNumbering.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFNumbering.java Fri May 21 21:22:40 2021
@@ -68,7 +68,7 @@ public class XWPFNumbering extends POIXM
*/
@Override
protected void onDocumentRead() throws IOException {
- NumberingDocument numberingDoc = null;
+ NumberingDocument numberingDoc;
InputStream is;
is = getPackagePart().getInputStream();
try {
@@ -105,8 +105,6 @@ public class XWPFNumbering extends POIXM
/**
* Sets the ctNumbering
- *
- * @param numbering
*/
public void setNumbering(CTNumbering numbering) {
ctNumbering = numbering;
@@ -116,7 +114,6 @@ public class XWPFNumbering extends POIXM
/**
* Checks whether number with numID exists
*
- * @param numID
* @return boolean true if num exist, false if num not exist
*/
public boolean numExist(BigInteger numID) {
@@ -129,8 +126,6 @@ public class XWPFNumbering extends POIXM
/**
* add a new number to the numbering document
- *
- * @param num
*/
public BigInteger addNum(XWPFNum num) {
ctNumbering.addNewNum();
@@ -157,9 +152,6 @@ public class XWPFNumbering extends POIXM
/**
* Add a new num with an abstractNumID and a numID
- *
- * @param abstractNumID
- * @param numID
*/
public void addNum(BigInteger abstractNumID, BigInteger numID) {
CTNum ctNum = this.ctNumbering.addNewNum();
@@ -173,7 +165,6 @@ public class XWPFNumbering extends POIXM
/**
* get Num by NumID
*
- * @param numID
* @return abstractNum with NumId if no Num exists with that NumID
* null will be returned
*/
@@ -188,7 +179,6 @@ public class XWPFNumbering extends POIXM
/**
* get AbstractNum by abstractNumID
*
- * @param abstractNumID
* @return abstractNum with abstractNumId if no abstractNum exists with that abstractNumID
* null will be returned
*/
@@ -207,7 +197,6 @@ public class XWPFNumbering extends POIXM
* the BigInteger Value of it will be returned.
* If no equal abstractNum is existing null will be returned
*
- * @param abstractNum
* @return BigInteger
*/
public BigInteger getIdOfAbstractNum(XWPFAbstractNum abstractNum) {
@@ -227,8 +216,6 @@ public class XWPFNumbering extends POIXM
/**
* add a new AbstractNum and return its AbstractNumID
- *
- * @param abstractNum
*/
public BigInteger addAbstractNum(XWPFAbstractNum abstractNum) {
int pos = abstractNums.size();
@@ -246,7 +233,6 @@ public class XWPFNumbering extends POIXM
/**
* remove an existing abstractNum
*
- * @param abstractNumID
* @return true if abstractNum with abstractNumID exists in NumberingArray,
* false if abstractNum with abstractNumID not exists
*/
@@ -268,7 +254,6 @@ public class XWPFNumbering extends POIXM
* If the AbstractNumID not exists
* return null
*
- * @param numID
* @return abstractNumID
*/
public BigInteger getAbstractNumID(BigInteger numID) {
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFPicture.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFPicture.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFPicture.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFPicture.java Fri May 21 21:22:40 2021
@@ -25,9 +25,9 @@ import org.openxmlformats.schemas.drawin
public class XWPFPicture {
- private CTPicture ctPic;
- private String description;
- private XWPFRun run;
+ private final CTPicture ctPic;
+ private final String description;
+ private final XWPFRun run;
public XWPFPicture(CTPicture ctPic, XWPFRun run) {
this.run = run;
@@ -37,8 +37,6 @@ public class XWPFPicture {
/**
* Link Picture with PictureData
- *
- * @param rel
*/
public void setPictureReference(PackageRelationship rel) {
ctPic.getBlipFill().getBlip().setEmbed(rel.getId());
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java Fri May 21 21:22:40 2021
@@ -19,6 +19,7 @@ package org.apache.poi.xwpf.usermodel;
import java.util.ArrayList;
import java.util.List;
+import org.apache.poi.util.Beta;
import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlObject;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
@@ -26,11 +27,8 @@ import org.openxmlformats.schemas.wordpr
/**
* Experimental class to offer rudimentary read-only processing of
* of the contentblock of an SDT/ContentControl.
- * <p>
- * <p>
- * <p>
- * WARNING - APIs expected to change rapidly
*/
+@Beta
public class XWPFSDTContent implements ISDTContent {
// private final IBody part;
@@ -39,7 +37,7 @@ public class XWPFSDTContent implements I
// private List<XWPFTable> tables = new ArrayList<>();
// private List<XWPFRun> runs = new ArrayList<>();
// private List<XWPFSDT> contentControls = new ArrayList<>();
- private List<ISDTContents> bodyElements = new ArrayList<>();
+ private final List<ISDTContents> bodyElements = new ArrayList<>();
public XWPFSDTContent(CTSdtContentRun sdtRun, IBody part, IRunBody parent) {
if (sdtRun == null) {
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFStyle.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFStyle.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFStyle.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFStyle.java Fri May 21 21:22:40 2021
@@ -25,21 +25,10 @@ public class XWPFStyle {
protected XWPFStyles styles;
private CTStyle ctStyle;
- /**
- * constructor
- *
- * @param style
- */
public XWPFStyle(CTStyle style) {
this(style, null);
}
- /**
- * constructor
- *
- * @param style
- * @param styles
- */
public XWPFStyle(CTStyle style, XWPFStyles styles) {
this.ctStyle = style;
this.styles = styles;
@@ -56,8 +45,6 @@ public class XWPFStyle {
/**
* set styleID
- *
- * @param styleId
*/
public void setStyleId(String styleId) {
ctStyle.setStyleId(styleId);
@@ -74,8 +61,6 @@ public class XWPFStyle {
/**
* set styleType
- *
- * @param type
*/
public void setType(STStyleType.Enum type) {
ctStyle.setType(type);
@@ -83,8 +68,6 @@ public class XWPFStyle {
/**
* set style
- *
- * @param style
*/
public void setStyle(CTStyle style) {
this.ctStyle = style;
@@ -144,8 +127,6 @@ public class XWPFStyle {
/**
* compares the names of the Styles
- *
- * @param compStyle
*/
public boolean hasSameName(XWPFStyle compStyle) {
CTStyle ctCompStyle = compStyle.getCTStyle();
@@ -153,4 +134,4 @@ public class XWPFStyle {
return name.equals(ctStyle.getName().getVal());
}
-}//end class
+}
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTable.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTable.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTable.java Fri May 21 21:22:40 2021
@@ -141,7 +141,7 @@ public class XWPFTable implements IBodyE
// Unused: UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD
//protected List<String> styleIDs;
protected IBody part;
- private CTTbl ctTbl;
+ private final CTTbl ctTbl;
public XWPFTable(CTTbl table, IBody part, int row, int col) {
this(table, part);
@@ -243,8 +243,8 @@ public class XWPFTable implements IBodyE
if (tableRows.size() == 0) {
createRow();
}
- for (int i = 0; i < tableRows.size(); i++) {
- tableRows.get(i).createCell();
+ for (XWPFTableRow tableRow : tableRows) {
+ tableRow.createCell();
}
}
@@ -1046,7 +1046,6 @@ public class XWPFTable implements IBodyE
/**
* inserts a new tablerow
*
- * @param pos
* @return the inserted row
*/
public XWPFTableRow insertNewTableRow(int pos) {
@@ -1081,8 +1080,6 @@ public class XWPFTable implements IBodyE
/**
* returns the type of the BodyElement Table
- *
- * @see org.apache.poi.xwpf.usermodel.IBodyElement#getElementType()
*/
@Override
public BodyElementType getElementType() {
@@ -1195,14 +1192,12 @@ public class XWPFTable implements IBodyE
switch (typeValue.intValue()) {
case STTblWidth.INT_NIL:
return TableWidthType.NIL;
- case STTblWidth.INT_AUTO:
- return TableWidthType.AUTO;
case STTblWidth.INT_DXA:
return TableWidthType.DXA;
case STTblWidth.INT_PCT:
return TableWidthType.PCT;
default:
- // Should never get here
+ case STTblWidth.INT_AUTO:
return TableWidthType.AUTO;
}
}
@@ -1284,11 +1279,9 @@ public class XWPFTable implements IBodyE
if (!currentType.equals(widthType)) {
STTblWidth.Enum stWidthType = widthType.getStWidthType();
ctWidth.setType(stWidthType);
- switch (stWidthType.intValue()) {
- case STTblWidth.INT_PCT:
+ if (stWidthType.intValue() == STTblWidth.INT_PCT) {
setWidthPercentage(ctWidth, DEFAULT_PERCENTAGE_WIDTH);
- break;
- default:
+ } else {
ctWidth.setW(BigInteger.ZERO);
}
}
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableCell.java Fri May 21 21:22:40 2021
@@ -119,9 +119,8 @@ public class XWPFTableCell implements IB
/**
* returns an Iterator with paragraphs and tables
- *
- * @see org.apache.poi.xwpf.usermodel.IBody#getBodyElements()
*/
+ @Override
public List<IBodyElement> getBodyElements() {
return Collections.unmodifiableList(bodyElements);
}
@@ -136,6 +135,7 @@ public class XWPFTableCell implements IB
/**
* returns a list of paragraphs
*/
+ @Override
public List<XWPFParagraph> getParagraphs() {
return Collections.unmodifiableList(paragraphs);
}
@@ -221,7 +221,7 @@ public class XWPFTableCell implements IB
/**
* Get the vertical alignment of the cell.
*
- * @return the cell alignment enum value or <code>null</code>
+ * @return the cell alignment enum value or {@code null}
* if no vertical alignment is set.
*/
public XWPFVertAlign getVerticalAlignment() {
@@ -253,6 +253,7 @@ public class XWPFTableCell implements IB
* @param cursor The XmlCursor structure created with XmlBeans
* @return the inserted paragraph
*/
+ @Override
public XWPFParagraph insertNewParagraph(final XmlCursor cursor) {
if (!isCursorInTableCell(cursor)) {
return null;
@@ -291,6 +292,7 @@ public class XWPFTableCell implements IB
return newP;
}
+ @Override
public XWPFTable insertNewTbl(final XmlCursor cursor) {
if (isCursorInTableCell(cursor)) {
String uri = CTTbl.type.getName().getNamespaceURI();
@@ -339,9 +341,7 @@ public class XWPFTableCell implements IB
return result;
}
- /**
- * @see org.apache.poi.xwpf.usermodel.IBody#getParagraphArray(int)
- */
+ @Override
public XWPFParagraph getParagraphArray(int pos) {
if (pos >= 0 && pos < paragraphs.size()) {
return paragraphs.get(pos);
@@ -351,25 +351,21 @@ public class XWPFTableCell implements IB
/**
* get the to which the TableCell belongs
- *
- * @see org.apache.poi.xwpf.usermodel.IBody#getPart()
*/
+ @Override
public POIXMLDocumentPart getPart() {
return tableRow.getTable().getPart();
}
- /**
- * @see org.apache.poi.xwpf.usermodel.IBody#getPartType()
- */
+ @Override
public BodyType getPartType() {
return BodyType.TABLECELL;
}
/**
* get a table by its CTTbl-Object
- *
- * @see org.apache.poi.xwpf.usermodel.IBody#getTable(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl)
*/
+ @Override
public XWPFTable getTable(CTTbl ctTable) {
for (int i = 0; i < tables.size(); i++) {
if (getTables().get(i).getCTTbl() == ctTable) return getTables().get(i);
@@ -377,9 +373,7 @@ public class XWPFTableCell implements IB
return null;
}
- /**
- * @see org.apache.poi.xwpf.usermodel.IBody#getTableArray(int)
- */
+ @Override
public XWPFTable getTableArray(int pos) {
if(pos >= 0 && pos < tables.size()) {
return tables.get(pos);
@@ -387,18 +381,15 @@ public class XWPFTableCell implements IB
return null;
}
- /**
- * @see org.apache.poi.xwpf.usermodel.IBody#getTables()
- */
+ @Override
public List<XWPFTable> getTables() {
return Collections.unmodifiableList(tables);
}
/**
* inserts an existing XWPFTable to the arrays bodyElements and tables
- *
- * @see org.apache.poi.xwpf.usermodel.IBody#insertTable(int, org.apache.poi.xwpf.usermodel.XWPFTable)
*/
+ @Override
public void insertTable(int pos, XWPFTable table) {
bodyElements.add(pos, table);
int i = 0;
@@ -482,6 +473,7 @@ public class XWPFTableCell implements IB
/**
* get the TableCell which belongs to the TableCell
*/
+ @Override
public XWPFTableCell getTableCell(CTTc cell) {
XmlCursor cursor = cell.newCursor();
cursor.toParent();
@@ -508,6 +500,7 @@ public class XWPFTableCell implements IB
return tr.getTableCell(cell);
}
+ @Override
public XWPFDocument getXWPFDocument() {
return part.getXWPFDocument();
}
Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableRow.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableRow.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableRow.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFTableRow.java Fri May 21 21:22:40 2021
@@ -41,8 +41,8 @@ import org.openxmlformats.schemas.wordpr
* the child {@link XWPFTableCell}s
*/
public class XWPFTableRow {
- private CTRow ctRow;
- private XWPFTable table;
+ private final CTRow ctRow;
+ private final XWPFTable table;
private List<XWPFTableCell> tableCells;
public XWPFTableRow(CTRow row, XWPFTable table) {
@@ -123,8 +123,6 @@ public class XWPFTableRow {
* its attribute values). If omitted, then the table row shall automatically
* resize its height to the height required by its contents (the equivalent
* of an hRule value of auto).
- *
- * @param height
*/
public void setHeight(int height) {
CTTrPr properties = getTrPr();
@@ -221,9 +219,9 @@ public class XWPFTableRow {
* if there is no XWPFTableCell which belongs to the parameter CTTc cell null will be returned
*/
public XWPFTableCell getTableCell(CTTc cell) {
- for (int i = 0; i < tableCells.size(); i++) {
- if (tableCells.get(i).getCTTc() == cell)
- return tableCells.get(i);
+ for (XWPFTableCell tableCell : tableCells) {
+ if (tableCell.getCTTc() == cell)
+ return tableCell;
}
return null;
}
Modified: poi/trunk/poi-ooxml/src/test/java/org/apache/poi/xdgf/usermodel/section/TestCombinedIterator.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/test/java/org/apache/poi/xdgf/usermodel/section/TestCombinedIterator.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/test/java/org/apache/poi/xdgf/usermodel/section/TestCombinedIterator.java (original)
+++ poi/trunk/poi-ooxml/src/test/java/org/apache/poi/xdgf/usermodel/section/TestCombinedIterator.java Fri May 21 21:22:40 2021
@@ -29,7 +29,7 @@ import org.junit.jupiter.api.Test;
class TestCombinedIterator {
- void testIteration(CombinedIterable<String> iterable, String... expected) {
+ void testIteration(Iterable<String> iterable, String... expected) {
Iterator<String> iter = iterable.iterator();
@@ -49,8 +49,7 @@ class TestCombinedIterator {
base.put(2L, "B2");
base.put(3L, "B3");
- testIteration(new CombinedIterable<>(base, null), "B1", "B2",
- "B3");
+ testIteration(createIter(base, null), "B1", "B2", "B3");
}
@Test
@@ -66,8 +65,7 @@ class TestCombinedIterator {
master.put(5L, "M5");
master.put(6L, "M6");
- testIteration(new CombinedIterable<>(base, master), "B1", "B2",
- "B3", "M4", "M5", "M6");
+ testIteration(createIter(base, master), "B1", "B2", "B3", "M4", "M5", "M6");
}
@Test
@@ -83,8 +81,7 @@ class TestCombinedIterator {
master.put(2L, "M2");
master.put(3L, "M3");
- testIteration(new CombinedIterable<>(base, master), "M1", "M2",
- "M3", "B4", "B5", "B6");
+ testIteration(createIter(base, master), "M1", "M2", "M3", "B4", "B5", "B6");
}
@Test
@@ -100,8 +97,7 @@ class TestCombinedIterator {
master.put(4L, "M4");
master.put(6L, "M6");
- testIteration(new CombinedIterable<>(base, master), "B1", "M2",
- "B3", "M4", "B5", "M6");
+ testIteration(createIter(base, master), "B1", "M2", "B3", "M4", "B5", "M6");
}
@Test
@@ -119,8 +115,7 @@ class TestCombinedIterator {
master.put(7L, "M7");
master.put(8L, "M8");
- testIteration(new CombinedIterable<>(base, master), "B1", "B2",
- "M3", "M4", "B5", "B6", "M7", "M8");
+ testIteration(createIter(base, master), "B1", "B2", "M3", "M4", "B5", "B6", "M7", "M8");
}
@Test
@@ -136,8 +131,7 @@ class TestCombinedIterator {
master.put(2L, "M2");
master.put(3L, "M3");
- testIteration(new CombinedIterable<>(base, master), "B1", "B2",
- "B3");
+ testIteration(createIter(base, master), "B1", "B2", "B3");
}
@Test
@@ -154,7 +148,12 @@ class TestCombinedIterator {
master.put(3L, "M3");
master.put(4L, "M4");
- testIteration(new CombinedIterable<>(base, master), "B1", "B2",
- "B3", "M4");
+ testIteration(createIter(base, master), "B1", "B2", "B3", "M4");
+ }
+
+
+ private static <T> Iterable<T> createIter(SortedMap<Long, T> map1, SortedMap<Long, T> map2) {
+ // TODO: try to use commons collection and remove CombinedIterable
+ return new CombinedIterable<>(map1, map2);
}
}
Modified: poi/trunk/poi-scratchpad/build.gradle
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/build.gradle?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/build.gradle (original)
+++ poi/trunk/poi-scratchpad/build.gradle Fri May 21 21:22:40 2021
@@ -56,13 +56,6 @@ final Pattern MODULE_REGEX = ~'\\.jar$'
final List MAIN_MODULE_PATH = sourceSets.main.runtimeClasspath.findAll{ it.path =~ MODULE_REGEX }.collect{ it.parent }.unique()
final List TEST_MODULE_PATH = sourceSets.test.runtimeClasspath.findAll{ it.path =~ MODULE_REGEX && !(it.path =~ MODULE_NOT_REGEX) }.collect{ it.parent }.unique()
-java {
- sourceCompatibility = JavaVersion.VERSION_1_8
- targetCompatibility = JavaVersion.VERSION_1_8
- withJavadocJar()
- withSourcesJar()
-}
-
task compileJava9(type: JavaCompile) {
dependsOn 'compileJava', ':poi:jar'
@@ -142,23 +135,9 @@ task testJar(type: Jar, dependsOn: testC
}
}
-sourcesJar {
- destinationDirectory = file("../build/dist/maven/${project.archivesBaseName}")
- exclude 'META-INF/services/**'
-}
-
javadoc {
- failOnError = true
doFirst {
options {
- if (JavaVersion.current().isJava9Compatible()) {
- addBooleanOption('html5', true)
- }
- links 'https://poi.apache.org/apidocs/dev/'
- links 'https://docs.oracle.com/javase/8/docs/api/'
- use = true
- splitIndex = true
- source = "1.8"
classpath += configurations.javadocs.files
}
}
@@ -171,39 +150,10 @@ artifacts {
test {
dependsOn { testJar }
- useJUnitPlatform()
-
doFirst {
- jvmArgs = [
- '-Djava.io.tmpdir=build',
- '-DPOI.testdata.path=../test-data',
- '-Djava.awt.headless=true',
- '-Djava.locale.providers=JRE,CLDR',
- '-Duser.language=en',
- '-Duser.country=US',
- '-Djavax.xml.stream.XMLInputFactory=com.sun.xml.internal.stream.XMLInputFactoryImpl',
- "-Dversion.id=${project.version}",
- '-ea',
- '-Djunit.jupiter.execution.parallel.enabled=true',
- '-Djunit.jupiter.execution.parallel.config.strategy=fixed',
- '-Djunit.jupiter.execution.parallel.config.fixed.parallelism=3'
- // -Xjit:verbose={compileStart|compileEnd},vlog=build/jit.log${no.jit.sherlock} ... if ${isIBMVM}
- ]
if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
jvmArgs += [
- '-Dsun.reflect.debugModuleAccessChecks=true',
- '-Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize=true',
- '--illegal-access=warn',
-
'--add-modules', MODULE_NAME,
-
- // see https://github.com/java9-modularity/gradle-modules-plugin/issues/97
- // opposed to the recommendation there, it doesn't work to add ... to the dependencies
- // testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.7.1'
- // gradles gradle-worker.jar is still not a JPMS module and thus runs as unnamed module
- '--add-exports','org.junit.platform.commons/org.junit.platform.commons.util=ALL-UNNAMED',
- '--add-exports','org.junit.platform.commons/org.junit.platform.commons.logging=ALL-UNNAMED',
-
'--module-path', '../build/dist/maven/poi-scratchpad-tests:' + files(TEST_MODULE_PATH).asPath,
]
}
@@ -213,10 +163,6 @@ test {
publishing {
publications {
POI(MavenPublication) {
- artifactId project.archivesBaseName
-
- from components.java
-
pom {
name = 'Apache POI'
description = 'Apache POI - Java API To Access Microsoft Format Files (Scratchpad)'
@@ -224,5 +170,3 @@ publishing {
}
}
}
-
-generatePomFileForPOIPublication.destination = "../build/dist/maven/${project.archivesBaseName}/${project.archivesBaseName}-${project.version}.pom"
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/extractor/QuickButCruddyTextExtractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/extractor/QuickButCruddyTextExtractor.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/extractor/QuickButCruddyTextExtractor.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/extractor/QuickButCruddyTextExtractor.java Fri May 21 21:22:40 2021
@@ -55,7 +55,7 @@ import org.apache.poi.util.LittleEndian;
public final class QuickButCruddyTextExtractor {
private POIFSFileSystem fs;
private InputStream is;
- private byte[] pptContents;
+ private final byte[] pptContents;
/**
* Really basic text extractor, that will also return lots of crud text.
@@ -78,7 +78,6 @@ public final class QuickButCruddyTextExt
/**
* Creates an extractor from a given file name
- * @param fileName
*/
@SuppressWarnings("resource")
public QuickButCruddyTextExtractor(String fileName) throws IOException {
@@ -87,7 +86,6 @@ public final class QuickButCruddyTextExt
/**
* Creates an extractor from a given input stream
- * @param iStream
*/
@SuppressWarnings("resource")
public QuickButCruddyTextExtractor(InputStream iStream) throws IOException {
@@ -97,7 +95,6 @@ public final class QuickButCruddyTextExt
/**
* Creates an extractor from a POIFS Filesystem
- * @param poifs
*/
public QuickButCruddyTextExtractor(POIFSFileSystem poifs) throws IOException {
fs = poifs;
@@ -192,9 +189,7 @@ public final class QuickButCruddyTextExt
String text = cs.getText();
// Ignore the ones we know to be rubbish
- if(text.equals("___PPT10")) {
- } else if(text.equals("Default Design")) {
- } else {
+ if (!"___PPT10".equals(text) && !"Default Design".equals(text)) {
textV.add(text);
}
}
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/ActiveXShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/ActiveXShape.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/ActiveXShape.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/ActiveXShape.java Fri May 21 21:22:40 2021
@@ -46,7 +46,7 @@ public final class ActiveXShape extends
public static final int DEFAULT_ACTIVEX_THUMBNAIL = -1;
/**
- * Create a new <code>Picture</code>
+ * Create a new {@code Picture}
*
* @param pictureData the picture data
*/
@@ -56,10 +56,10 @@ public final class ActiveXShape extends
}
/**
- * Create a <code>Picture</code> object
+ * Create a {@code Picture} object
*
- * @param escherRecord the <code>EscherSpContainer</code> record which holds information about
- * this picture in the <code>Slide</code>
+ * @param escherRecord the {@code EscherSpContainer} record which holds information about
+ * this picture in the {@code Slide}
* @param parent the parent shape of this picture
*/
protected ActiveXShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
@@ -69,13 +69,14 @@ public final class ActiveXShape extends
/**
* Create a new Placeholder and initialize internal structures
*
- * @return the created <code>EscherContainerRecord</code> which holds shape data
+ * @return the created {@code EscherContainerRecord} which holds shape data
*/
@Override
protected EscherContainerRecord createSpContainer(int idx, boolean isChild) {
EscherContainerRecord ecr = super.createSpContainer(idx, isChild);
EscherSpRecord spRecord = ecr.getChildById(EscherSpRecord.RECORD_ID);
+ assert(spRecord != null);
spRecord.setFlags(EscherSpRecord.FLAG_HAVEANCHOR | EscherSpRecord.FLAG_HASSHAPETYPE | EscherSpRecord.FLAG_OLESHAPE);
setShapeType(ShapeType.HOST_CONTROL);
@@ -114,8 +115,6 @@ public final class ActiveXShape extends
/**
* Set a property of this ActiveX control
- * @param key
- * @param value
*/
public void setProperty(String key, String value){
@@ -133,7 +132,7 @@ public final class ActiveXShape extends
if (lst == null) {
return null;
}
-
+
for (Record ch : lst.getChildRecords()) {
if(ch instanceof ExControl){
ExControl c = (ExControl)ch;
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/Polygon.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/Polygon.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/Polygon.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/Polygon.java Fri May 21 21:22:40 2021
@@ -40,7 +40,7 @@ public final class Polygon extends HSLFA
/**
* Create a Polygon object and initialize it from the supplied Record container.
*
- * @param escherRecord <code>EscherSpContainer</code> container which holds information about this shape
+ * @param escherRecord {@code EscherSpContainer} container which holds information about this shape
* @param parent the parent of the shape
*/
protected Polygon(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
@@ -69,9 +69,6 @@ public final class Polygon extends HSLFA
/**
* Set the polygon vertices
- *
- * @param xPoints
- * @param yPoints
*/
public void setPoints(float[] xPoints, float[] yPoints)
{
@@ -147,10 +144,9 @@ public final class Polygon extends HSLFA
private float findBiggest( float[] values )
{
float result = Float.MIN_VALUE;
- for ( int i = 0; i < values.length; i++ )
- {
- if (values[i] > result)
- result = values[i];
+ for (float value : values) {
+ if (value > result)
+ result = value;
}
return result;
}
@@ -158,10 +154,9 @@ public final class Polygon extends HSLFA
private float findSmallest( float[] values )
{
float result = Float.MAX_VALUE;
- for ( int i = 0; i < values.length; i++ )
- {
- if (values[i] < result)
- result = values[i];
+ for (float value : values) {
+ if (value < result)
+ result = value;
}
return result;
}
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/textproperties/BitMaskTextProp.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/textproperties/BitMaskTextProp.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/textproperties/BitMaskTextProp.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/model/textproperties/BitMaskTextProp.java Fri May 21 21:22:40 2021
@@ -37,9 +37,9 @@ import org.apache.poi.util.GenericRecord
public abstract class BitMaskTextProp extends TextProp {
protected static final Logger LOG = LogManager.getLogger(BitMaskTextProp.class);
- private String[] subPropNames;
- private int[] subPropMasks;
- private boolean[] subPropMatches;
+ private final String[] subPropNames;
+ private final int[] subPropMasks;
+ private final boolean[] subPropMatches;
/** Fetch the list of the names of the sub properties */
public String[] getSubPropNames() { return subPropNames; }
@@ -141,9 +141,6 @@ public abstract class BitMaskTextProp ex
/**
* Convenience method to set a value with mask, without splitting it into the subvalues
- *
- * @param val
- * @param writeMask
*/
public void setValueWithMask(int val, int writeMask) {
setWriteMask(writeMask);
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlideListWithText.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlideListWithText.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlideListWithText.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/record/SlideListWithText.java Fri May 21 21:22:40 2021
@@ -64,7 +64,7 @@ public final class SlideListWithText ext
*/
public static final int NOTES = 2;
- private byte[] _header;
+ private final byte[] _header;
private SlideAtomsSet[] slideAtomsSets;
@@ -124,7 +124,6 @@ public final class SlideListWithText ext
/**
* Add a new SlidePersistAtom, to the end of the current list,
* and update the internal list of SlidePersistAtoms
- * @param spa
*/
public void addSlidePersistAtom(SlidePersistAtom spa) {
// Add the new SlidePersistAtom at the end
@@ -164,12 +163,14 @@ public final class SlideListWithText ext
/**
* Return the value we were given at creation
*/
+ @Override
public long getRecordType() { return _type; }
/**
* Write the contents of the record back, so it can be written
* to disk
*/
+ @Override
public void writeOut(OutputStream out) throws IOException {
writeOut(_header[0],_header[1],_type,_children,out);
}
@@ -182,8 +183,8 @@ public final class SlideListWithText ext
* along with some others.
*/
public static class SlideAtomsSet {
- private SlidePersistAtom slidePersistAtom;
- private org.apache.poi.hslf.record.Record[] slideRecords;
+ private final SlidePersistAtom slidePersistAtom;
+ private final org.apache.poi.hslf.record.Record[] slideRecords;
/** Get the SlidePersistAtom, which gives details on the Slide this text is associated with */
public SlidePersistAtom getSlidePersistAtom() { return slidePersistAtom; }
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFBackground.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFBackground.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFBackground.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFBackground.java Fri May 21 21:22:40 2021
@@ -30,6 +30,7 @@ public final class HSLFBackground extend
super(escherRecord, parent);
}
+ @Override
protected EscherContainerRecord createSpContainer(boolean isChild) {
return null;
}
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFComment.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFComment.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFComment.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFComment.java Fri May 21 21:22:40 2021
@@ -25,7 +25,7 @@ import java.awt.geom.Point2D;
import java.util.Date;
public final class HSLFComment implements Comment {
- private Comment2000 _comment2000;
+ private final Comment2000 _comment2000;
public HSLFComment(Comment2000 comment2000) {
_comment2000 = comment2000;
@@ -38,6 +38,7 @@ public final class HSLFComment implement
/**
* Get the Author of this comment
*/
+ @Override
public String getAuthor() {
return _comment2000.getAuthor();
}
@@ -45,6 +46,7 @@ public final class HSLFComment implement
/**
* Set the Author of this comment
*/
+ @Override
public void setAuthor(String author) {
_comment2000.setAuthor(author);
}
@@ -52,6 +54,7 @@ public final class HSLFComment implement
/**
* Get the Author's Initials of this comment
*/
+ @Override
public String getAuthorInitials() {
return _comment2000.getAuthorInitials();
}
@@ -59,6 +62,7 @@ public final class HSLFComment implement
/**
* Set the Author's Initials of this comment
*/
+ @Override
public void setAuthorInitials(String initials) {
_comment2000.setAuthorInitials(initials);
}
@@ -66,6 +70,7 @@ public final class HSLFComment implement
/**
* Get the text of this comment
*/
+ @Override
public String getText() {
return _comment2000.getText();
}
@@ -73,6 +78,7 @@ public final class HSLFComment implement
/**
* Set the text of this comment
*/
+ @Override
public void setText(String text) {
_comment2000.setText(text);
}
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFShape.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFShape.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFShape.java Fri May 21 21:22:40 2021
@@ -55,18 +55,14 @@ import org.apache.poi.util.StringUtil;
import org.apache.poi.util.Units;
/**
- * <p>
- * Represents a Shape which is the elemental object that composes a drawing.
+ * Represents a Shape which is the elemental object that composes a drawing.
* This class is a wrapper around EscherSpContainer which holds all information
* about a shape in PowerPoint document.
- * </p>
* <p>
* When you add a shape, you usually specify the dimensions of the shape and the position
* of the upper'left corner of the bounding box for the shape relative to the upper'left
* corner of the page, worksheet, or slide. Distances in the drawing layer are measured
* in points (72 points = 1 inch).
- * </p>
- * <p>
*/
public abstract class HSLFShape implements Shape<HSLFShape,HSLFTextParagraph> {
private static final Logger LOG = LogManager.getLogger(HSLFShape.class);
@@ -79,12 +75,12 @@ public abstract class HSLFShape implemen
/**
* Parent of this shape.
- * <code>null</code> for the topmost shapes.
+ * {@code null} for the topmost shapes.
*/
- private ShapeContainer<HSLFShape,HSLFTextParagraph> _parent;
+ private final ShapeContainer<HSLFShape,HSLFTextParagraph> _parent;
/**
- * The <code>Sheet</code> this shape belongs to
+ * The {@code Sheet} this shape belongs to
*/
private HSLFSheet _sheet;
@@ -92,11 +88,11 @@ public abstract class HSLFShape implemen
* Fill
*/
private HSLFFill _fill;
-
+
/**
* Create a Shape object. This constructor is used when an existing Shape is read from from a PowerPoint document.
*
- * @param escherRecord <code>EscherSpContainer</code> container which holds information about this shape
+ * @param escherRecord {@code EscherSpContainer} container which holds information about this shape
* @param parent the parent of this Shape
*/
protected HSLFShape(EscherContainerRecord escherRecord, ShapeContainer<HSLFShape,HSLFTextParagraph> parent){
@@ -233,12 +229,12 @@ public abstract class HSLFShape implemen
/**
* Helper method to return escher child by record ID
*
- * @return escher record or <code>null</code> if not found.
+ * @return escher record or {@code null} if not found.
*/
public static <T extends EscherRecord> T getEscherChild(EscherContainerRecord owner, int recordId){
return owner.getChildById((short)recordId);
}
-
+
/**
* @since POI 3.14-Beta2
*/
@@ -249,18 +245,18 @@ public abstract class HSLFShape implemen
public <T extends EscherRecord> T getEscherChild(int recordId){
return _escherContainer.getChildById((short)recordId);
}
-
+
/**
* @since POI 3.14-Beta2
*/
public <T extends EscherRecord> T getEscherChild(EscherRecordTypes recordId){
return getEscherChild(recordId.typeID);
}
-
+
/**
* Returns escher property by id.
*
- * @return escher property or <code>null</code> if not found.
+ * @return escher property or {@code null} if not found.
*
* @deprecated use {@link #getEscherProperty(EscherPropertyTypes)} instead
*/
@@ -273,7 +269,7 @@ public abstract class HSLFShape implemen
/**
* Returns escher property by type.
*
- * @return escher property or <code>null</code> if not found.
+ * @return escher property or {@code null} if not found.
*/
public static <T extends EscherProperty> T getEscherProperty(AbstractEscherOptRecord opt, EscherPropertyTypes type){
return (opt == null) ? null : opt.lookup(type);
@@ -428,7 +424,7 @@ public abstract class HSLFShape implemen
}
/**
- * @return the <code>SlideShow</code> this shape belongs to
+ * @return the {@code SlideShow} this shape belongs to
*/
@Override
public HSLFSheet getSheet(){
@@ -436,7 +432,7 @@ public abstract class HSLFShape implemen
}
/**
- * Assign the <code>SlideShow</code> this shape belongs to
+ * Assign the {@code SlideShow} this shape belongs to
*
* @param sheet owner of this shape
*/
@@ -491,10 +487,10 @@ public abstract class HSLFShape implemen
col = applySysIndexProcedure(ecr, col);
return col;
}
-
+
return new Color(rgb[0], rgb[1], rgb[2]);
}
-
+
private Color getSysIndexColor(EscherColorRef ecr) {
SysIndexSource sis = ecr.getSysIndexSource();
if (sis == null) {
@@ -502,7 +498,7 @@ public abstract class HSLFShape implemen
PresetColor pc = PresetColor.valueOfNativeId(sysIdx);
return (pc != null) ? pc.color : null;
}
-
+
// TODO: check for recursive loops, when color getter also reference
// a different color type
switch (sis) {
@@ -554,17 +550,17 @@ public abstract class HSLFShape implemen
default:
break;
}
-
+
return null;
}
-
+
private Color applySysIndexProcedure(EscherColorRef ecr, Color col) {
-
+
final SysIndexProcedure sip = ecr.getSysIndexProcedure();
if (col == null || sip == null) {
return col;
}
-
+
switch (sip) {
case DARKEN_COLOR: {
// see java.awt.Color#darken()
@@ -572,29 +568,29 @@ public abstract class HSLFShape implemen
int r = (int)Math.rint(col.getRed()*FACTOR);
int g = (int)Math.rint(col.getGreen()*FACTOR);
int b = (int)Math.rint(col.getBlue()*FACTOR);
- return new Color(r,g,b);
+ return new Color(r,g,b);
}
case LIGHTEN_COLOR: {
double FACTOR = (0xFF-ecr.getRGB()[2])/255.;
-
+
int r = col.getRed();
int g = col.getGreen();
int b = col.getBlue();
-
+
r += Math.rint((0xFF-r)*FACTOR);
g += Math.rint((0xFF-g)*FACTOR);
b += Math.rint((0xFF-b)*FACTOR);
-
+
return new Color(r,g,b);
}
default:
// TODO ...
break;
}
-
+
return col;
}
-
+
double getAlpha(EscherPropertyTypes opacityProperty) {
AbstractEscherOptRecord opt = getEscherOptRecord();
EscherSimpleProperty op = getEscherProperty(opt, opacityProperty);
@@ -602,7 +598,7 @@ public abstract class HSLFShape implemen
int opacity = (op == null) ? defaultOpacity : op.getPropertyValue();
return Units.fixedPointToDouble(opacity);
}
-
+
Color toRGB(int val){
int a = (val >> 24) & 0xFF;
int b = (val >> 16) & 0xFF;
@@ -669,12 +665,12 @@ public abstract class HSLFShape implemen
}
return opt;
}
-
+
public boolean getFlipHorizontal(){
EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
return (spRecord.getFlags()& EscherSpRecord.FLAG_FLIPHORIZ) != 0;
}
-
+
public void setFlipHorizontal(boolean flip) {
EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
int flag = spRecord.getFlags() | EscherSpRecord.FLAG_FLIPHORIZ;
@@ -685,7 +681,7 @@ public abstract class HSLFShape implemen
EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
return (spRecord.getFlags()& EscherSpRecord.FLAG_FLIPVERT) != 0;
}
-
+
public void setFlipVertical(boolean flip) {
EscherSpRecord spRecord = getEscherChild(EscherSpRecord.RECORD_ID);
int flag = spRecord.getFlags() | EscherSpRecord.FLAG_FLIPVERT;
@@ -696,7 +692,7 @@ public abstract class HSLFShape implemen
int rot = getEscherProperty(EscherPropertyTypes.TRANSFORM__ROTATION);
return Units.fixedPointToDouble(rot);
}
-
+
public void setRotation(double theta){
int rot = Units.doubleToFixedPoint(theta % 360.0);
setEscherProperty(EscherPropertyTypes.TRANSFORM__ROTATION, rot);
@@ -726,7 +722,7 @@ public abstract class HSLFShape implemen
/**
* Search for EscherClientDataRecord, if found, convert its contents into an array of HSLF records
*
- * @return an array of HSLF records contained in the shape's EscherClientDataRecord or <code>null</code>
+ * @return an array of HSLF records contained in the shape's EscherClientDataRecord or {@code null}
*/
protected List<? extends Record> getClientRecords() {
HSLFEscherClientDataRecord clientData = getClientData(false);
@@ -736,7 +732,7 @@ public abstract class HSLFShape implemen
/**
* Create a new HSLF-specific EscherClientDataRecord
*
- * @param create if true, create the missing record
+ * @param create if true, create the missing record
* @return the client record or null if it was missing and create wasn't activated
*/
protected HSLFEscherClientDataRecord getClientData(boolean create) {
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFTextParagraph.java Fri May 21 21:22:40 2021
@@ -86,14 +86,6 @@ import org.apache.poi.util.Units;
public final class HSLFTextParagraph implements TextParagraph<HSLFShape,HSLFTextParagraph,HSLFTextRun> {
private static final Logger LOG = LogManager.getLogger(HSLFTextParagraph.class);
- /**
- * How to align the text
- */
- /* package */static final int AlignLeft = 0;
- /* package */static final int AlignCenter = 1;
- /* package */static final int AlignRight = 2;
- /* package */static final int AlignJustify = 3;
-
// Note: These fields are protected to help with unit testing
// Other classes shouldn't really go playing with them!
private final TextHeaderAtom _headerAtom;
@@ -120,19 +112,23 @@ public final class HSLFTextParagraph imp
this.tabStop = tabStop;
}
+ @Override
public double getPositionInPoints() {
return tabStop.getPositionInPoints();
}
+ @Override
public void setPositionInPoints(double position) {
tabStop.setPositionInPoints(position);
setDirty();
}
+ @Override
public TabStopType getType() {
return tabStop.getType();
}
+ @Override
public void setType(TabStopType type) {
tabStop.setType(type);
setDirty();
@@ -165,18 +161,6 @@ public final class HSLFTextParagraph imp
setParagraphStyle(new TextPropCollection(1, TextPropType.paragraph));
}
- /* package */HSLFTextParagraph(HSLFTextParagraph other) {
- _headerAtom = other._headerAtom;
- _byteAtom = other._byteAtom;
- _charAtom = other._charAtom;
- _parentShape = other._parentShape;
- _sheet = other._sheet;
- _ruler = other._ruler;
- shapeId = other.shapeId;
- parentList = other.parentList;
- setParagraphStyle(other._paragraphStyle);
- }
-
public void addTextRun(HSLFTextRun run) {
_runs.add(run);
}
@@ -248,8 +232,6 @@ public final class HSLFTextParagraph imp
/**
* Sets the index of the paragraph in the SLWT container
- *
- * @param index
*/
protected void setIndex(int index) {
if (_headerAtom != null) {
@@ -636,7 +618,7 @@ public final class HSLFTextParagraph imp
* Sets the bullet character
*/
public void setBulletChar(Character c) {
- Integer val = (c == null) ? null : (int)c.charValue();
+ Integer val = (c == null) ? null : (int) c;
setParagraphTextPropVal("bullet.char", val);
}
@@ -765,23 +747,21 @@ public final class HSLFTextParagraph imp
@Override
public List<? extends TabStop> getTabStops() {
final List<HSLFTabStop> tabStops;
- final TextRulerAtom textRuler;
if (getSheet() instanceof HSLFSlideMaster) {
final HSLFTabStopPropCollection tpc = getMasterPropVal(_paragraphStyle, HSLFTabStopPropCollection.NAME);
if (tpc == null) {
return null;
}
tabStops = tpc.getTabStops();
- textRuler = null;
} else {
- textRuler = (TextRulerAtom)_headerAtom.getParentRecord().findFirstOfType(RecordTypes.TextRulerAtom.typeID);
+ final TextRulerAtom textRuler = (TextRulerAtom) _headerAtom.getParentRecord().findFirstOfType(RecordTypes.TextRulerAtom.typeID);
if (textRuler == null) {
return null;
}
tabStops = textRuler.getTabStops();
}
- return tabStops.stream().map((tabStop) -> new HSLFTabStopDecorator(tabStop)).collect(Collectors.toList());
+ return tabStops.stream().map(HSLFTabStopDecorator::new).collect(Collectors.toList());
}
@Override
@@ -836,11 +816,11 @@ public final class HSLFTextParagraph imp
private boolean getFlag(int index) {
BitMaskTextProp tp = getPropVal(_paragraphStyle, ParagraphFlagsTextProp.NAME);
- return (tp == null) ? false : tp.getSubValue(index);
+ return tp != null && tp.getSubValue(index);
}
private void setFlag(int index, boolean value) {
- BitMaskTextProp tp = (BitMaskTextProp)_paragraphStyle.addWithName(ParagraphFlagsTextProp.NAME);
+ BitMaskTextProp tp = _paragraphStyle.addWithName(ParagraphFlagsTextProp.NAME);
tp.setSubValue(value, index);
setDirty();
}
@@ -1047,7 +1027,6 @@ public final class HSLFTextParagraph imp
StringUtil.putCompressedUnicode(rawText, byteText, 0);
byteAtom.setText(byteText);
}
- assert (newRecord != null);
RecordContainer _txtbox = headerAtom.getParentRecord();
Record[] cr = _txtbox.getChildRecords();
@@ -1528,7 +1507,7 @@ public final class HSLFTextParagraph imp
break;
}
List<HSLFTextRun> runs = p.getTextRuns();
- for (int rlen=0,rIdx=0; rIdx < runs.size(); csIdx+=rlen, rIdx++) {
+ for (int rlen,rIdx=0; rIdx < runs.size(); csIdx+=rlen, rIdx++) {
HSLFTextRun run = runs.get(rIdx);
rlen = run.getLength();
if (csIdx < h.getEndIndex() && h.getStartIndex() < csIdx+rlen) {
@@ -1722,8 +1701,6 @@ public final class HSLFTextParagraph imp
}
/**
- * {@inheritDoc}
- *
* @see RoundTripHFPlaceholder12
*/
@Override
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwmf/draw/HwmfDrawProperties.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwmf/draw/HwmfDrawProperties.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwmf/draw/HwmfDrawProperties.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwmf/draw/HwmfDrawProperties.java Fri May 21 21:22:40 2021
@@ -322,8 +322,6 @@ public class HwmfDrawProperties {
/**
* Sets the current palette.
* It's the callers duty to set a modifiable copy of the palette.
- *
- * @param palette
*/
public void setPalette(List<PaletteEntry> palette) {
this.palette = palette;
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfEscape.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfEscape.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfEscape.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfEscape.java Fri May 21 21:22:40 2021
@@ -223,6 +223,7 @@ public class HwmfEscape implements HwmfR
return escapeFunction;
}
+ @SuppressWarnings("unchecked")
public <T extends HwmfEscapeData> T getEscapeData() {
return (T)escapeData;
}
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfFill.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfFill.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfFill.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfFill.java Fri May 21 21:22:40 2021
@@ -171,10 +171,12 @@ public class HwmfFill {
*/
int regionIndex;
+ @Override
public HwmfRecordType getWmfRecordType() {
return HwmfRecordType.paintRegion;
}
+ @Override
public int init(LittleEndianInputStream leis, long recordSize, int recordFunction) throws IOException {
regionIndex = leis.readUShort();
return LittleEndianConsts.SHORT_SIZE;
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfRecord.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfRecord.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwmf/record/HwmfRecord.java Fri May 21 21:22:40 2021
@@ -31,10 +31,9 @@ public interface HwmfRecord extends Gene
*
* @param leis the little endian input stream
* @return count of processed bytes
- * @throws IOException
*/
int init(LittleEndianInputStream leis, long recordSize, int recordFunction) throws IOException;
-
+
/**
* Apply the record settings to the graphics context
*
@@ -43,7 +42,7 @@ public interface HwmfRecord extends Gene
void draw(HwmfGraphics ctx);
@Override
- default Enum getGenericRecordType() {
+ default Enum<?> getGenericRecordType() {
return getWmfRecordType();
}
}
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/CharIndexTranslator.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/CharIndexTranslator.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/CharIndexTranslator.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/CharIndexTranslator.java Fri May 21 21:22:40 2021
@@ -44,7 +44,6 @@ public interface CharIndexTranslator {
/**
* Check if index is in table
*
- * @param bytePos
* @return true if index in table, false if not
*/
boolean isIndexInTable(int bytePos);
@@ -52,7 +51,6 @@ public interface CharIndexTranslator {
/**
* Return first index >= bytePos that is in table
*
- * @param bytePos
* @return first index greater or equal to bytePos that is in table
*/
int lookIndexForward(int bytePos);
@@ -60,7 +58,6 @@ public interface CharIndexTranslator {
/**
* Return last index <= bytePos that is in table
*
- * @param bytePos
* @return last index less of equal to bytePos that is in table
*/
int lookIndexBackward(int bytePos);
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/FileInformationBlock.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/FileInformationBlock.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/FileInformationBlock.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/FileInformationBlock.java Fri May 21 21:22:40 2021
@@ -38,7 +38,7 @@ import static org.apache.logging.log4j.u
/**
* <p>The File Information Block (FIB). Holds pointers
* to various bits of the file, and lots of flags which
- * specify properties of the document.<p>
+ * specify properties of the document.
* <ul>
* <li>The {@link FibBase} class, holds the first 32 bytes.</li>
* <li>The next part, the fibRgW / FibRgW97, is handled by the {@link FibRgW97}.</li>
@@ -244,12 +244,12 @@ public final class FileInformationBlock
// field info
for ( FieldsDocumentPart part : FieldsDocumentPart.values() )
- knownFieldSet.add( Integer.valueOf( part.getFibFieldsField() ) );
+ knownFieldSet.add(part.getFibFieldsField());
// bookmarks
- knownFieldSet.add( Integer.valueOf( FIBFieldHandler.PLCFBKF ) );
- knownFieldSet.add( Integer.valueOf( FIBFieldHandler.PLCFBKL ) );
- knownFieldSet.add( Integer.valueOf( FIBFieldHandler.STTBFBKMK ) );
+ knownFieldSet.add(FIBFieldHandler.PLCFBKF);
+ knownFieldSet.add(FIBFieldHandler.PLCFBKL);
+ knownFieldSet.add(FIBFieldHandler.STTBFBKMK);
// notes
for ( NoteType noteType : NoteType.values() ) {
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldCHPBinTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldCHPBinTable.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldCHPBinTable.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldCHPBinTable.java Fri May 21 21:22:40 2021
@@ -33,13 +33,7 @@ import org.apache.poi.util.LittleEndian;
public final class OldCHPBinTable extends CHPBinTable
{
/**
- * Constructor used to read an old-style binTable
- * in from a Word document.
- *
- * @param documentStream
- * @param offset
- * @param size
- * @param fcMin
+ * Constructor used to read an old-style binTable in from a Word document.
*/
public OldCHPBinTable(byte[] documentStream, int offset,
int size, int fcMin, OldTextPieceTable tpt)
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldTextPiece.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldTextPiece.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldTextPiece.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldTextPiece.java Fri May 21 21:22:40 2021
@@ -52,7 +52,6 @@ public class OldTextPiece extends TextPi
/**
* @return nothing, ever. Always throws an UnsupportedOperationException
- * @throws UnsupportedOperationException
*/
@NotImplemented
@Override
@@ -77,8 +76,8 @@ public class OldTextPiece extends TextPi
*
* @param start Local start position, in characters
* @param end Local end position, in characters
- * @throws UnsupportedOperationException
*/
+ @Override
@Deprecated
@NotImplemented
public String substring(int start, int end) {
@@ -89,6 +88,7 @@ public class OldTextPiece extends TextPi
* Not implemented for OldTextPiece.
* Always throws UnsupportedOperationException
*/
+ @Override
@Deprecated
@NotImplemented
public void adjustForDelete(int start, int length) {
@@ -98,6 +98,7 @@ public class OldTextPiece extends TextPi
/**
* Returns the length, in bytes
*/
+ @Override
public int bytesLength() {
return rawBytes.length;
}
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldTextPieceTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldTextPieceTable.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldTextPieceTable.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/OldTextPieceTable.java Fri May 21 21:22:40 2021
@@ -94,7 +94,7 @@ public class OldTextPieceTable extends T
// into order, if they're not already
Collections.sort(_textPieces);
_textPiecesFCOrder = new ArrayList<>(_textPieces);
- _textPiecesFCOrder.sort(new FCComparator());
+ _textPiecesFCOrder.sort(byFilePosition());
}
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PlexOfCps.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PlexOfCps.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PlexOfCps.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PlexOfCps.java Fri May 21 21:22:40 2021
@@ -39,8 +39,8 @@ public final class PlexOfCps {
private static final int MAX_RECORD_LENGTH = 10_485_760;
private int _iMac;
- private int _cbStruct;
- private List<GenericPropertyNode> _props;
+ private final int _cbStruct;
+ private final List<GenericPropertyNode> _props;
public PlexOfCps(int sizeOfStruct) {
_props = new ArrayList<>();
@@ -69,18 +69,10 @@ public final class PlexOfCps {
void adjust(int startCp, int shift) {
for (GenericPropertyNode node : _props) {
if (node.getStart() > startCp) {
- if (node.getStart() + shift < startCp) {
- node.setStart(startCp);
- } else {
- node.setStart(node.getStart() + shift);
- }
+ node.setStart(Math.max(node.getStart() + shift, startCp));
}
if (node.getEnd() >= startCp) {
- if (node.getEnd() + shift < startCp) {
- node.setEnd(startCp);
- } else {
- node.setEnd(node.getEnd() + shift);
- }
+ node.setEnd(Math.max(node.getEnd() + shift, startCp));
}
}
}
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PlfLfo.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PlfLfo.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PlfLfo.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/PlfLfo.java Fri May 21 21:22:40 2021
@@ -162,7 +162,6 @@ public class PlfLfo
/**
* @param ilfo 1-based index
* @return The {@link LFO} stored at the given index
- * @throws NoSuchElementException
*/
public LFO getLfo( int ilfo ) throws NoSuchElementException
{
@@ -177,7 +176,6 @@ public class PlfLfo
/**
* @param ilfo 1-based index
* @return The {@link LFOData} stored at the given index
- * @throws NoSuchElementException
*/
public LFOData getLfoData( int ilfo ) throws NoSuchElementException
{
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPiece.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPiece.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPiece.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPiece.java Fri May 21 21:22:40 2021
@@ -32,9 +32,9 @@ import org.apache.poi.util.StringUtil;
*/
@Internal
public class TextPiece extends PropertyNode<TextPiece> {
- private boolean _usesUnicode;
+ private final boolean _usesUnicode;
- private PieceDescriptor _pd;
+ private final PieceDescriptor _pd;
public TextPiece(TextPiece other) {
super(other);
@@ -142,6 +142,7 @@ public class TextPiece extends PropertyN
* @param start The start position for the delete, in characters
* @param length The number of characters to delete
*/
+ @Override
@Deprecated
public void adjustForDelete(int start, int length) {
int myStart = getStart();
Modified: poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPieceTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPieceTable.java?rev=1890089&r1=1890088&r2=1890089&view=diff
==============================================================================
--- poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPieceTable.java (original)
+++ poi/trunk/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/TextPieceTable.java Fri May 21 21:22:40 2021
@@ -18,7 +18,6 @@ package org.apache.poi.hwpf.model;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
-import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -114,7 +113,7 @@ public class TextPieceTable implements C
// into order, if they're not already
Collections.sort(_textPieces);
_textPiecesFCOrder = new ArrayList<>(_textPieces);
- _textPiecesFCOrder.sort(new FCComparator());
+ _textPiecesFCOrder.sort(byFilePosition());
}
protected TextPiece newTextPiece(int nodeStartChars, int nodeEndChars, byte[] buf, PieceDescriptor pd) {
@@ -125,7 +124,7 @@ public class TextPieceTable implements C
_textPieces.add(piece);
_textPiecesFCOrder.add(piece);
Collections.sort(_textPieces);
- _textPiecesFCOrder.sort(new FCComparator());
+ _textPiecesFCOrder.sort(byFilePosition());
}
/**
@@ -169,6 +168,7 @@ public class TextPieceTable implements C
return false;
}
+ @Override
public int getByteIndex(int charPos) {
int byteCount = 0;
for (TextPiece tp : _textPieces) {
@@ -308,6 +308,7 @@ public class TextPieceTable implements C
return _textPieces.hashCode();
}
+ @Override
public boolean isIndexInTable(int bytePos) {
for (TextPiece tp : _textPiecesFCOrder) {
int pieceStart = tp.getPieceDescriptor().getFilePosition();
@@ -339,6 +340,7 @@ public class TextPieceTable implements C
return false;
}
+ @Override
public int lookIndexBackward(final int startBytePos) {
int bytePos = startBytePos;
int lastEnd = 0;
@@ -361,6 +363,7 @@ public class TextPieceTable implements C
return bytePos;
}
+ @Override
public int lookIndexForward(final int startBytePos) {
if (_textPiecesFCOrder.isEmpty())
throw new IllegalStateException("Text pieces table is empty");
@@ -433,10 +436,7 @@ public class TextPieceTable implements C
return textPlex.toByteArray();
}
- protected static class FCComparator implements Comparator<TextPiece>, Serializable {
- public int compare(TextPiece textPiece, TextPiece textPiece1) {
- return Integer.compare(textPiece.getPieceDescriptor().fc, textPiece1
- .getPieceDescriptor().fc);
- }
+ static Comparator<TextPiece> byFilePosition() {
+ return Comparator.comparing(t -> t.getPieceDescriptor().getFilePosition());
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org