diff --git a/poi-ooxml/build.gradle b/poi-ooxml/build.gradle index 5571000b27..9f67a73103 100644 --- a/poi-ooxml/build.gradle +++ b/poi-ooxml/build.gradle @@ -49,10 +49,9 @@ configurations { exclude group: 'xml-apis', module: 'xml-apis' } } - broken - tests + javadocs } dependencies { @@ -87,6 +86,9 @@ dependencies { testImplementation 'com.google.guava:guava:30.0-jre' broken "org.apache.xmlgraphics:batik-script:${batikVersion}" + + javadocs project(':poi') + javadocs project(':poi-scratchpad') } final String MODULE_NAME = 'org.apache.poi.ooxml' @@ -208,11 +210,20 @@ task fixBatik(type: Zip) { } javadoc { -// fails currently, need to fix the sources - failOnError = false -// if(JavaVersion.current().isJava9Compatible()) { -// options.addBooleanOption('html5', true) -// } + 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 + } + } } artifacts { diff --git a/poi-ooxml/src/main/java/org/apache/poi/ooxml/util/XPathHelper.java b/poi-ooxml/src/main/java/org/apache/poi/ooxml/util/XPathHelper.java index 6677f01fb9..c374c12798 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/ooxml/util/XPathHelper.java +++ b/poi-ooxml/src/main/java/org/apache/poi/ooxml/util/XPathHelper.java @@ -73,7 +73,7 @@ public final class XPathHelper { /** * Internal code - API may change any time! *
- * The {@link #selectProperty(Class, String)} xquery method has some performance penalties, + * The XSLFShape.selectProperty(Class, String) xquery method has some performance penalties, * which can be workaround by using {@link XmlCursor}. This method also takes into account * that {@code AlternateContent} tags can occur anywhere on the given path. *
@@ -83,8 +83,7 @@ public final class XPathHelper { *
null.
+ * '/word/document.xml' => 'media/image1.gif') else
+ * {@code null}.
*/
public static URI relativizeURI(URI sourceURI, URI targetURI, boolean msCompatible) {
StringBuilder retVal = new StringBuilder();
@@ -390,8 +390,8 @@ public final class PackagingURIHelper {
* @param targetURI
* The target part URI.
* @return A fully relativize part name URI ('word/media/image1.gif',
- * '/word/document.xml' => 'media/image1.gif') else
- * null.
+ * '/word/document.xml' => 'media/image1.gif') else
+ * {@code null}.
*/
public static URI relativizeURI(URI sourceURI, URI targetURI) {
return relativizeURI(sourceURI, targetURI, false);
@@ -620,7 +620,7 @@ public final class PackagingURIHelper {
/**
* Build a part name where the relationship should be stored ((ex
- * /word/document.xml -> /word/_rels/document.xml.rels)
+ * /word/document.xml -> /word/_rels/document.xml.rels)
*
* @param partName
* Source part URI
@@ -728,10 +728,10 @@ public final class PackagingURIHelper {
* percent-encode white spaces and characters above 0x80.
* * Examples: - *
+ * } * @param s the string to encode * @return the encoded string */ diff --git a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/ContentTypeManager.java b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/ContentTypeManager.java index 5b356843c8..f9df88da44 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/ContentTypeManager.java +++ b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/ContentTypeManager.java @@ -114,7 +114,7 @@ public abstract class ContentTypeManager { } /** - * Build association extention-> content type (will be stored in + * Build association extension-> content type (will be stored in * [Content_Types].xml) for example ContentType="image/png" Extension="png" *+ *{@code * 'Apache POI' --> 'Apache%20POI' * 'Apache\u0410POI' --> 'Apache%04%10POI' - *
* [M2.8]: When adding a new part to a package, the package implementer @@ -286,7 +286,7 @@ public abstract class ContentTypeManager { throw new IllegalArgumentException("contentType"); } - return (this.defaultContentType.containsValue(contentType) || + return (this.defaultContentType.containsValue(contentType) || (this.overrideContentType != null && this.overrideContentType.containsValue(contentType))); } diff --git a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/unmarshallers/PackagePropertiesUnmarshaller.java b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/unmarshallers/PackagePropertiesUnmarshaller.java index 278bffd9a1..20d30c443f 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/unmarshallers/PackagePropertiesUnmarshaller.java +++ b/poi-ooxml/src/main/java/org/apache/poi/openxml4j/opc/internal/unmarshallers/PackagePropertiesUnmarshaller.java @@ -217,23 +217,22 @@ public final class PackagePropertiesUnmarshaller implements PartUnmarshaller { *
* Rule M4.2: A format consumer shall consider the use of the Markup * Compatibility namespace to be an error. - *
+ *
* Rule M4.3: Producers shall not create a document element that contains
* refinements to the Dublin Core elements, except for the two specified in
- * the schema:
+ *
* Rule M4.4: Producers shall not create a document element that contains * the xml:lang attribute. Consumers shall consider a document element that * violates this constraint to be an error. - *
+ *
* Rule M4.5: Producers shall not create a document element that contains
- * the xsi:type attribute, except for a
Note that each SI entry can have multiple T elements, if the * string is made up of bits with different formatting. *
Example input: - *
-<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> -<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="2" uniqueCount="2"> - <si> - <r> - <rPr> - <b /> - <sz val="11" /> - <color theme="1" /> - <rFont val="Calibri" /> - <family val="2" /> - <scheme val="minor" /> - </rPr> - <t>This:</t> - </r> - <r> - <rPr> - <sz val="11" /> - <color theme="1" /> - <rFont val="Calibri" /> - <family val="2" /> - <scheme val="minor" /> - </rPr> - <t xml:space="preserve">Causes Problems</t> - </r> - </si> - <si> - <t>This does not</t> - </si> -</sst> -*+ *
{@code
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * This:
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * Causes Problems
+ *
+ *
+ *
+ * This does not
+ *
+ *
+ * }
*
*/
public class ReadOnlySharedStringsTable extends DefaultHandler implements SharedStrings {
@@ -157,7 +157,7 @@ public class ReadOnlySharedStringsTable extends DefaultHandler implements Shared
this.includePhoneticRuns = includePhoneticRuns;
readFrom(part.getInputStream());
}
-
+
/**
* Read this shared strings table from an XML file.
*
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/model/StylesTable.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/model/StylesTable.java
index a007608e26..767b69e226 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/model/StylesTable.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/model/StylesTable.java
@@ -89,8 +89,8 @@ public class StylesTable extends POIXMLDocumentPart implements Styles {
* Changes the maximum number of data formats that may be in a style table
*
* @param num the upper limit on number of data formats in the styles table when adding new data formats
- * @throws IllegalArgumentException if num < 0
- * @throws IllegalStateException if num < current number of data formats in the style table.
+ * @throws IllegalArgumentException if {@code num < 0}
+ * @throws IllegalStateException if {@code num < current number of data formats in the style table}.
* Data formats must be explicitly removed before the limit can be decreased.
*/
public void setMaxNumberOfDataFormats(int num) {
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFRow.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFRow.java
index 8d6e903d9d..531261e056 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFRow.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFRow.java
@@ -113,11 +113,11 @@ public class SXSSFRow implements Row, Comparable
* The cell that is returned is a {@link CellType#BLANK}. The type can be changed
- * either through calling setCellValue or setCellType.
+ * either through calling {@code setCellValue} or {@code setCellType}.
*
* @param column - the column number this cell represents
* @return Cell a high level representation of the created cell.
- * @throws IllegalArgumentException if columnIndex < 0 or greater than the maximum number of supported columns
+ * @throws IllegalArgumentException if columnIndex < 0 or greater than the maximum number of supported columns
* (255 for *.xls, 1048576 for *.xlsx)
*/
@Override
@@ -134,7 +134,7 @@ public class SXSSFRow implements Row, Comparable
* Schematically something like this: - * <tr><tc/><tc/><sdt><tc/></sdt></tr> + * {@code
The only significant difference between footnotes and * end notes is which part they go on. Footnotes are managed by the Footnotes part * {@link XWPFFootnotes} and end notes are managed by the Endnotes part {@link XWPFEndnotes}.
@@ -43,10 +43,10 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc; */ public abstract class XWPFAbstractFootnoteEndnote implements IterableUse {@link XWPFDocument#createFootnote()} to create new footnotes.
* @param footnote The CTFtnEdn object that will underly the footnote. */ public void setCTFtnEdn(CTFtnEdn footnote) { @@ -155,8 +159,8 @@ public abstract class XWPFAbstractFootnoteEndnote implements IterableThis method is for the first paragraph in the footnote, not * paragraphs that will refer to the footnote. For references to - * the footnote, use {@link XWPFParagraph#addFootnoteReference(XWPFFootnote)}. + * the footnote, use {@link XWPFParagraph#addFootnoteReference(XWPFAbstractFootnoteEndnote)}. *
*The first run of the first paragraph in a footnote should * contain a {@link CTFtnEdnRef} object.
@@ -491,7 +486,7 @@ public abstract class XWPFAbstractFootnoteEndnote implements IterableCreate a new footnote using {@link XWPFDocument#createEndnote()} or - * {@link XWPFEndnotes#createFootnote()}.
+ * {@link XWPFEndnotes#createEndnote()}. *The first body element of a footnote should (or possibly must) be a paragraph * with the first run containing a CTFtnEdnRef object. The {@link XWPFFootnote#createParagraph()} * and {@link XWPFFootnote#createTable()} methods do this for you.
*Footnotes have IDs that are unique across all footnotes in the document. You use * the footnote ID to create a reference to a footnote from within a paragraph.
*To create a reference to a footnote within a paragraph you create a run - * with a CTFtnEdnRef that specifies the ID of the target paragraph. + * with a CTFtnEdnRef that specifies the ID of the target paragraph. * The {@link XWPFParagraph#addFootnoteReference(XWPFAbstractFootnoteEndnote)} * method does this for you.
* @since 4.0.0 @@ -55,9 +55,9 @@ public class XWPFEndnote extends XWPFAbstractFootnoteEndnote { /** * Ensure that the specified paragraph has a reference marker for this * end note by adding a footnote reference if one is not found. - *This method is for the first paragraph in the footnote, not + *
This method is for the first paragraph in the footnote, not * paragraphs that will refer to the footnote. For references to - * the footnote, use {@link XWPFParagraph#addFootnoteReference(XWPFAbstractFootnoteEndnote))}. + * the footnote, use {@link XWPFParagraph#addFootnoteReference(XWPFAbstractFootnoteEndnote)}. *
*The first run of the first paragraph in a footnote should * contain a {@link CTFtnEdnRef} object.
@@ -66,7 +66,7 @@ public class XWPFEndnote extends XWPFAbstractFootnoteEndnote { * @since 4.0.0 */ public void ensureFootnoteRef(XWPFParagraph p) { - + XWPFRun r = null; if (p.getRuns().size() > 0) { r = p.getRuns().get(0); @@ -86,7 +86,7 @@ public class XWPFEndnote extends XWPFAbstractFootnoteEndnote { ctr.addNewRPr().addNewRStyle().setVal("FootnoteReference"); ctr.addNewEndnoteRef(); } - + } } diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFFootnote.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFFootnote.java index 77459ecc87..52584c310c 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFFootnote.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFFootnote.java @@ -31,12 +31,12 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR; *Footnotes have IDs that are unique across all footnotes in the document. You use * the footnote ID to create a reference to a footnote from within a paragraph.
*To create a reference to a footnote within a paragraph you create a run - * with a CTFtnEdnRef that specifies the ID of the target paragraph. + * with a CTFtnEdnRef that specifies the ID of the target paragraph. * The {@link XWPFParagraph#addFootnoteReference(XWPFAbstractFootnoteEndnote)} * method does this for you.
*/ public class XWPFFootnote extends XWPFAbstractFootnoteEndnote { - + @Internal public XWPFFootnote(CTFtnEdn note, XWPFAbstractFootnotesEndnotes xFootnotes) { super(note, xFootnotes); @@ -46,13 +46,13 @@ public class XWPFFootnote extends XWPFAbstractFootnoteEndnote { public XWPFFootnote(XWPFDocument document, CTFtnEdn body) { super(document, body); } - + /** * Ensure that the specified paragraph has a reference marker for this * footnote by adding a footnote reference if one is not found. - *This method is for the first paragraph in the footnote, not + *
This method is for the first paragraph in the footnote, not * paragraphs that will refer to the footnote. For references to - * the footnote, use {@link XWPFParagraph#addFootnoteReference(XWPFFootnote)}. + * the footnote, use {@link XWPFParagraph#addFootnoteReference(XWPFAbstractFootnoteEndnote)}. *
*The first run of the first paragraph in a footnote should * contain a {@link CTFtnEdnRef} object.
@@ -61,7 +61,7 @@ public class XWPFFootnote extends XWPFAbstractFootnoteEndnote { * @since 4.0.0 */ public void ensureFootnoteRef(XWPFParagraph p) { - + XWPFRun r = null; if (p.getRuns().size() > 0) { r = p.getRuns().get(0); @@ -81,6 +81,6 @@ public class XWPFFootnote extends XWPFAbstractFootnoteEndnote { ctr.addNewRPr().addNewRStyle().setVal("FootnoteReference"); ctr.addNewFootnoteRef(); } - + } } diff --git a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRun.java b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRun.java index ee741bace4..c9176437a7 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRun.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xwpf/usermodel/XWPFRun.java @@ -215,7 +215,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun { /** * @return The {@link XWPFDocument} instance, this run belongs to, or - *null if parent structure (paragraph > document) is not properly set.
+ * {@code null} if parent structure (paragraph > document) is not properly set.
*/
public XWPFDocument getDocument() {
if (parent != null) {
@@ -258,7 +258,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
* Whether the bold property shall be applied to all non-complex script
* characters in the contents of this run when displayed in a document
*
- * @return true if the bold property is applied
+ * @return {@code true} if the bold property is applied
*/
@Override
public boolean isBold() {
@@ -275,7 +275,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
* direct formatting. When used as part of a style definition, setting this
* property shall toggle the current state of that property as specified up
* to this point in the hierarchy (i.e. applied to not applied, and vice
- * versa). Setting it to false (or an equivalent) shall
+ * versa). Setting it to {@code false} (or an equivalent) shall
* result in the current setting remaining unchanged. However, when used as
* direct formatting, setting this property to true or false shall set the
* absolute state of the resulting property.
@@ -287,7 +287,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
* applied to non-complex script characters.
*
*
- * @param value true if the bold property is applied to
+ * @param value {@code true} if the bold property is applied to
* this run
*/
@Override
@@ -326,7 +326,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
/**
* Return the string content of this text run
*
- * @return the text of this text run or null if not set
+ * @return the text of this text run or {@code null} if not set
*/
public String getText(int pos) {
return run.sizeOfTArray() == 0 ? null : run.getTArray(pos)
@@ -368,7 +368,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
* Whether the italic property should be applied to all non-complex script
* characters in the contents of this run when displayed in a document.
*
- * @return true if the italic property is applied
+ * @return {@code true} if the italic property is applied
*/
@Override
public boolean isItalic() {
@@ -380,25 +380,22 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
* Whether the bold property shall be applied to all non-complex script
* characters in the contents of this run when displayed in a document
* - *
* This formatting property is a toggle property, which specifies that its
* behavior differs between its use within a style definition and its use as
* direct formatting. When used as part of a style definition, setting this
* property shall toggle the current state of that property as specified up
* to this point in the hierarchy (i.e. applied to not applied, and vice
- * versa). Setting it to false (or an equivalent) shall
+ * versa). Setting it to {@code false} (or an equivalent) shall
* result in the current setting remaining unchanged. However, when used as
* direct formatting, setting this property to true or false shall set the
* absolute state of the resulting property.
- *
* If this element is not present, the default value is to leave the * formatting applied at previous level in the style hierarchy. If this * element is never applied in the style hierarchy, then bold shall not be * applied to non-complex script characters. - *
* - * @param valuetrue if the italic property is applied to
+ * @param value {@code true} if the italic property is applied to
* this run
*/
@Override
@@ -412,7 +409,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
* Get the underline setting for the run.
*
* @return the Underline pattern applied to this run
- * @see (@link UnderlinePatterns}
+ * @see UnderlinePatterns
*/
public UnderlinePatterns getUnderline() {
UnderlinePatterns value = UnderlinePatterns.NONE;
@@ -438,10 +435,11 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*
* @param value -
* underline type
- * @see {@link UnderlinePatterns} : all possible patterns that could be applied
+ * @see UnderlinePatterns
*/
public void setUnderline(UnderlinePatterns value) {
CTUnderline underline = getCTUnderline(true);
+ assert(underline != null);
underline.setVal(STUnderline.Enum.forInt(value.getValue()));
}
@@ -463,7 +461,8 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*/
public void setUnderlineColor(String color) {
CTUnderline underline = getCTUnderline(true);
- SimpleValue svColor = null;
+ assert(underline != null);
+ SimpleValue svColor;
if (color.equals("auto")) {
STHexColorAuto hexColor = STHexColorAuto.Factory.newInstance();
hexColor.setEnumValue(STHexColorAuto.Enum.forString(color));
@@ -484,6 +483,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*/
public void setUnderlineThemeColor(String themeColor) {
CTUnderline underline = getCTUnderline(true);
+ assert(underline != null);
STThemeColor.Enum val = STThemeColor.Enum.forString(themeColor);
if (val != null) {
underline.setThemeColor(val);
@@ -513,6 +513,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*/
public String getUnderlineColor() {
CTUnderline underline = getCTUnderline(true);
+ assert(underline != null);
String colorName = "auto";
Object rawValue = underline.getColor();
if (rawValue != null) {
@@ -530,7 +531,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
* Specifies that the contents of this run shall be displayed with a single
* horizontal line through the center of the line.
*
- * @return true if the strike property is applied
+ * @return {@code true} if the strike property is applied
*/
@Override
public boolean isStrikeThrough() {
@@ -559,7 +560,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
* not be applied to the contents of this run.
*
*
- * @param value true if the strike property is applied to
+ * @param value {@code true} if the strike property is applied to
* this run
*/
@Override
@@ -583,7 +584,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
* Specifies that the contents of this run shall be displayed with a double
* horizontal line through the center of the line.
*
- * @return true if the double strike property is applied
+ * @return {@code true} if the double strike property is applied
*/
@Override
public boolean isDoubleStrikeThrough() {
@@ -714,10 +715,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
return false;
}
STHighlightColor.Enum val = pr.getHighlightArray(0).getVal();
- if (val == null || val == STHighlightColor.NONE) {
- return false;
- }
- return true;
+ return val != null && val != STHighlightColor.NONE;
}
// TODO Provide a wrapper round STHighlightColor, then expose getter/setter
// for the highlight colour. Ideally also then add to CharacterRun interface
@@ -1178,13 +1176,10 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
* this method add chart template into document
*
* @param chartRelId relation id of chart in document relation file
- * @throws InvalidFormatException
- * @throws IOException
* @since POI 4.0.0
*/
@Internal
- public CTInline addChart(String chartRelId)
- throws InvalidFormatException, IOException {
+ public CTInline addChart(String chartRelId) throws InvalidFormatException, IOException {
try {
CTInline inline = run.addNewDrawing().addNewInline();
@@ -1422,7 +1417,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
/**
* @see [MS-OI29500] Run Fonts
*/
- public static enum FontCharRange {
+ public enum FontCharRange {
ascii /* char 0-127 */,
cs /* complex symbol */,
eastAsia /* east asia */,
@@ -1461,7 +1456,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
/**
* Set the highlight color for the run. Silently does nothing of colorName is not a recognized value.
*
- * @param colorName The name of the color as defined in the ST_HighlightColor simple type ({@link STHightlightColor})
+ * @param colorName The name of the color as defined in the ST_HighlightColor simple type ({@link STHighlightColor})
* @since 4.0.0
*/
public void setTextHighlightColor(String colorName) {
diff --git a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/types/CHPAbstractType.java b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/types/CHPAbstractType.java
index e18a3e724b..4e9c83f585 100644
--- a/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/types/CHPAbstractType.java
+++ b/poi-scratchpad/src/main/java/org/apache/poi/hwpf/model/types/CHPAbstractType.java
@@ -924,12 +924,7 @@ public abstract class CHPAbstractType {
/**
* Emphasis mark.
*
- * @return One of
- *