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 2015/07/19 21:00:38 UTC
svn commit: r1691843 [15/30] - in /poi/branches/common_sl: ./ .settings/
legal/ osgi/ osgi/src/ src/examples/src/org/apache/poi/hpsf/examples/
src/examples/src/org/apache/poi/hssf/usermodel/examples/
src/examples/src/org/apache/poi/ss/examples/ src/exa...
Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/IBody.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/IBody.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/IBody.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/IBody.java Sun Jul 19 19:00:32 2015
@@ -27,64 +27,68 @@ import org.openxmlformats.schemas.wordpr
/**
* <p>An IBody represents the different parts of the document which
- * can contain collections of Paragraphs and Tables. It provides a
- * common way to work with these and their contents.</p>
- * <p>Typically, this is something like a XWPFDocument, or one of
- * the parts in it like XWPFHeader, XWPFFooter, XWPFTableCell
- * </p>
- */
-public interface IBody {
- /**
- * returns the Part, to which the body belongs, which you need for adding relationship to other parts
- * Actually it is needed of the class XWPFTableCell. Because you have to know to which part the tableCell
- * belongs.
- * @return the Part, to which the body belongs
- */
- public POIXMLDocumentPart getPart();
-
- /**
- * get the PartType of the body, for example
- * DOCUMENT, HEADER, FOOTER, FOOTNOTE,
- * @return the PartType of the body
- */
- public BodyType getPartType();
-
- /**
- * Returns an Iterator with paragraphs and tables,
- * in the order that they occur in the text.
- */
- public List<IBodyElement> getBodyElements();
-
- /**
- * Returns the paragraph(s) that holds
- * the text of the header or footer.
- */
- public 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();
-
- /**
- * if there is a corresponding {@link XWPFParagraph} of the parameter ctTable in the paragraphList of this header or footer
- * the method will return this paragraph
- * if there is no corresponding {@link XWPFParagraph} the method will return null
- * @param p is instance of CTP and is searching for an XWPFParagraph
- * @return null if there is no XWPFParagraph with an corresponding CTPparagraph in the paragraphList of this header or footer
- * XWPFParagraph with the correspondig CTP p
- */
- public 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);
+ * can contain collections of Paragraphs and Tables. It provides a
+ * common way to work with these and their contents.</p>
+ * <p>Typically, this is something like a XWPFDocument, or one of
+ * the parts in it like XWPFHeader, XWPFFooter, XWPFTableCell
+ * </p>
+ */
+public interface IBody {
+ /**
+ * returns the Part, to which the body belongs, which you need for adding relationship to other parts
+ * Actually it is needed of the class XWPFTableCell. Because you have to know to which part the tableCell
+ * belongs.
+ *
+ * @return the Part, to which the body belongs
+ */
+ public POIXMLDocumentPart getPart();
+
+ /**
+ * get the PartType of the body, for example
+ * DOCUMENT, HEADER, FOOTER, FOOTNOTE,
+ *
+ * @return the PartType of the body
+ */
+ public BodyType getPartType();
+
+ /**
+ * Returns an Iterator with paragraphs and tables,
+ * in the order that they occur in the text.
+ */
+ public List<IBodyElement> getBodyElements();
+
+ /**
+ * Returns the paragraph(s) that holds
+ * the text of the header or footer.
+ */
+ public 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();
+
+ /**
+ * if there is a corresponding {@link XWPFParagraph} of the parameter ctTable in the paragraphList of this header or footer
+ * the method will return this paragraph
+ * if there is no corresponding {@link XWPFParagraph} the method will return null
+ *
+ * @param p is instance of CTP and is searching for an XWPFParagraph
+ * @return null if there is no XWPFParagraph with an corresponding CTPparagraph in the paragraphList of this header or footer
+ * XWPFParagraph with the correspondig CTP p
+ */
+ public 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);
/**
* Returns the paragraph that of position pos
@@ -94,32 +98,36 @@ public interface IBody {
/**
* Returns the table at position pos
*/
- public XWPFTable getTableArray(int pos);
-
- /**
- *inserts a new paragraph at position of the cursor
- * @param cursor
- */
- public XWPFParagraph insertNewParagraph(XmlCursor cursor);
-
- /**
- * inserts a new Table at the cursor position.
- * @param cursor
- */
- public XWPFTable insertNewTbl(XmlCursor cursor);
-
- /**
- * inserts a new Table at position pos
- * @param pos
- * @param table
- */
+ public XWPFTable getTableArray(int pos);
+
+ /**
+ * inserts a new paragraph at position of the cursor
+ *
+ * @param cursor
+ */
+ public XWPFParagraph insertNewParagraph(XmlCursor cursor);
+
+ /**
+ * inserts a new Table at the cursor position.
+ *
+ * @param cursor
+ */
+ public 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);
+
+ /**
+ * returns the TableCell to which the Table belongs
+ *
+ * @param cell
+ */
+ public XWPFTableCell getTableCell(CTTc cell);
/**
* Return XWPFDocument
Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/IBodyElement.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/IBodyElement.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/IBodyElement.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/IBodyElement.java Sun Jul 19 19:00:32 2015
@@ -18,15 +18,18 @@
package org.apache.poi.xwpf.usermodel;
import org.apache.poi.POIXMLDocumentPart;
-
-/**
- * 9 Jan 2010
- * @author Philipp Epp
- *
- */
-public interface IBodyElement{
- IBody getBody();
- POIXMLDocumentPart getPart();
- BodyType getPartType();
- BodyElementType getElementType();
-}
+
+/**
+ * 9 Jan 2010
+ *
+ * @author Philipp Epp
+ */
+public interface IBodyElement {
+ IBody getBody();
+
+ POIXMLDocumentPart getPart();
+
+ BodyType getPartType();
+
+ BodyElementType getElementType();
+}
Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/ICell.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/ICell.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/ICell.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/ICell.java Sun Jul 19 19:00:32 2015
@@ -15,13 +15,13 @@
limitations under the License.
==================================================================== */
package org.apache.poi.xwpf.usermodel;
-
-/**
- * Interface for anything that can be at a table cell level:
- * {@link XWPFTableCell}, {@link XWPFSDTCell}
- * <p>
- * Schematically something like this:
- * <tr><tc/><tc/><sdt><tc/></sdt></tr>
- */
-public interface ICell {
-}
+
+/**
+ * Interface for anything that can be at a table cell level:
+ * {@link XWPFTableCell}, {@link XWPFSDTCell}
+ * <p/>
+ * Schematically something like this:
+ * <tr><tc/><tc/><sdt><tc/></sdt></tr>
+ */
+public interface ICell {
+}
Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/IRunBody.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/IRunBody.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/IRunBody.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/IRunBody.java Sun Jul 19 19:00:32 2015
@@ -22,10 +22,11 @@ import org.apache.poi.wp.usermodel.Parag
/**
* Simple interface describing both {@link XWPFParagraph}
* and {@link XWPFSDT}
- *
+ * <p/>
* TODO Should this be based on / extend {@link Paragraph}?
*/
public interface IRunBody {
- public XWPFDocument getDocument();
- public POIXMLDocumentPart getPart();
+ public XWPFDocument getDocument();
+
+ public POIXMLDocumentPart getPart();
}
Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/IRunElement.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/IRunElement.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/IRunElement.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/IRunElement.java Sun Jul 19 19:00:32 2015
@@ -20,11 +20,10 @@ import org.apache.poi.wp.usermodel.Chara
/**
* Common interface for things that can occur
- * where a run (text with common stylings) can,
- * eg {@link XWPFRun} or {@link XWPFSDT}.
+ * where a run (text with common stylings) can,
+ * eg {@link XWPFRun} or {@link XWPFSDT}.
* TODO More methods to follow shortly!
- *
+ * <p/>
* TODO Make this based on {@link CharacterRun}
*/
-public interface IRunElement {
-}
\ No newline at end of file
+public interface IRunElement {}
\ No newline at end of file
Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/ISDTContent.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/ISDTContent.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/ISDTContent.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/ISDTContent.java Sun Jul 19 19:00:32 2015
@@ -15,21 +15,20 @@
limitations under the License.
==================================================================== */
package org.apache.poi.xwpf.usermodel;
-
-
-/**
- * Experimental interface to offer rudimentary read-only processing of
- * of the contentblock of an SDT/ContentControl.
- *
- *
- *
- * WARNING - APIs expected to change rapidly
- *
- */
-public interface ISDTContent {
-
- public String getText();
-
- public String toString();
-
+
+
+/**
+ * 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
+ */
+public interface ISDTContent {
+
+ public String getText();
+
+ public String toString();
+
}
Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/ISDTContents.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/ISDTContents.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/ISDTContents.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/ISDTContents.java Sun Jul 19 19:00:32 2015
@@ -18,8 +18,8 @@ package org.apache.poi.xwpf.usermodel;
/**
* Interface for anything that can be within an SDT:
- * {@link XWPFRun}, {@link XWPFTable}, {@link XWPFParagraph},
- * {@link XWPFSDT} etc
+ * {@link XWPFRun}, {@link XWPFTable}, {@link XWPFParagraph},
+ * {@link XWPFSDT} etc
*/
public interface ISDTContents {
}
Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/LineSpacingRule.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/LineSpacingRule.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/LineSpacingRule.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/LineSpacingRule.java Sun Jul 19 19:00:32 2015
@@ -19,13 +19,13 @@ package org.apache.poi.xwpf.usermodel;
import java.util.HashMap;
import java.util.Map;
-/**
- * Specifies the logic which shall be used to calculate the line spacing of the
- * parent object when it is displayed in the document.
- *
- * @author Gisella Bronzetti
- */
-public enum LineSpacingRule {
+/**
+ * Specifies the logic which shall be used to calculate the line spacing of the
+ * parent object when it is displayed in the document.
+ *
+ * @author Gisella Bronzetti
+ */
+public enum LineSpacingRule {
/**
* Specifies that the line spacing of the parent object shall be
@@ -45,31 +45,32 @@ public enum LineSpacingRule {
/**
* Specifies that the height of the line shall be at least the value
* specified, but may be expanded to fit its content as needed.
- */
- AT_LEAST(3);
-
-
- private final int value;
-
- private LineSpacingRule(int val) {
- value = val;
- }
-
- public int getValue() {
- return value;
- }
-
- private static Map<Integer, LineSpacingRule> imap = new HashMap<Integer, LineSpacingRule>();
- static {
- for (LineSpacingRule p : values()) {
- imap.put(new Integer(p.getValue()), p);
- }
- }
-
- public static LineSpacingRule valueOf(int type) {
- LineSpacingRule lineType = imap.get(new Integer(type));
- if (lineType == null)
- throw new IllegalArgumentException("Unknown line type: " + type);
- return lineType;
- }
-}
+ */
+ AT_LEAST(3);
+
+
+ private static Map<Integer, LineSpacingRule> imap = new HashMap<Integer, LineSpacingRule>();
+
+ static {
+ for (LineSpacingRule p : values()) {
+ imap.put(new Integer(p.getValue()), p);
+ }
+ }
+
+ private final int value;
+
+ private LineSpacingRule(int val) {
+ value = val;
+ }
+
+ public static LineSpacingRule valueOf(int type) {
+ LineSpacingRule lineType = imap.get(new Integer(type));
+ if (lineType == null)
+ throw new IllegalArgumentException("Unknown line type: " + type);
+ return lineType;
+ }
+
+ public int getValue() {
+ return value;
+ }
+}
Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/ParagraphAlignment.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/ParagraphAlignment.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/ParagraphAlignment.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/ParagraphAlignment.java Sun Jul 19 19:00:32 2015
@@ -37,30 +37,31 @@ public enum ParagraphAlignment {
DISTRIBUTE(6),
NUM_TAB(7),
HIGH_KASHIDA(8),
- LOW_KASHIDA(9),
- THAI_DISTRIBUTE(10);
-
- private final int value;
-
- private ParagraphAlignment(int val){
- value = val;
- }
-
- public int getValue(){
- return value;
- }
-
- private static Map<Integer, ParagraphAlignment> imap = new HashMap<Integer, ParagraphAlignment>();
- static{
- for (ParagraphAlignment p : values()) {
- imap.put(new Integer(p.getValue()), p);
- }
- }
-
- public static ParagraphAlignment valueOf(int type){
- ParagraphAlignment err = imap.get(new Integer(type));
- if(err == null) throw new IllegalArgumentException("Unknown paragraph alignment: " + type);
- return err;
- }
-
-}
+ LOW_KASHIDA(9),
+ THAI_DISTRIBUTE(10);
+
+ private static Map<Integer, ParagraphAlignment> imap = new HashMap<Integer, ParagraphAlignment>();
+
+ static {
+ for (ParagraphAlignment p : values()) {
+ imap.put(new Integer(p.getValue()), p);
+ }
+ }
+
+ private final int value;
+
+ private ParagraphAlignment(int val) {
+ value = val;
+ }
+
+ public static ParagraphAlignment valueOf(int type) {
+ ParagraphAlignment err = imap.get(new Integer(type));
+ if (err == null) throw new IllegalArgumentException("Unknown paragraph alignment: " + type);
+ return err;
+ }
+
+ public int getValue() {
+ return value;
+ }
+
+}
Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/PositionInParagraph.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/PositionInParagraph.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/PositionInParagraph.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/PositionInParagraph.java Sun Jul 19 19:00:32 2015
@@ -17,49 +17,47 @@
package org.apache.poi.xwpf.usermodel;
-
-/**
- * postion of a character in a paragrapho
-* 1st RunPositon
-* 2nd TextPosition
-* 3rd CharacterPosition
-*
-*
-*/
-public class PositionInParagraph {
- private int posRun = 0, posText = 0, posChar = 0;
-
- public PositionInParagraph(){
- }
-
- public PositionInParagraph(int posRun, int posText, int posChar){
- this.posRun=posRun;
- this.posChar=posChar;
- this.posText= posText;
- }
-
- public int getRun() {
- return posRun;
- }
-
- public void setRun(int beginRun) {
- this.posRun = beginRun;
- }
-
- public int getText() {
- return posText;
- }
-
- public void setText(int beginText) {
- this.posText = beginText;
- }
-
- public int getChar() {
- return posChar;
- }
-
- public void setChar(int beginChar) {
- this.posChar = beginChar;
- }
-
-}
+
+/**
+ * postion of a character in a paragrapho
+ * 1st RunPositon
+ * 2nd TextPosition
+ * 3rd CharacterPosition
+ */
+public class PositionInParagraph {
+ private int posRun = 0, posText = 0, posChar = 0;
+
+ public PositionInParagraph() {
+ }
+
+ public PositionInParagraph(int posRun, int posText, int posChar) {
+ this.posRun = posRun;
+ this.posChar = posChar;
+ this.posText = posText;
+ }
+
+ public int getRun() {
+ return posRun;
+ }
+
+ public void setRun(int beginRun) {
+ this.posRun = beginRun;
+ }
+
+ public int getText() {
+ return posText;
+ }
+
+ public void setText(int beginText) {
+ this.posText = beginText;
+ }
+
+ public int getChar() {
+ return posChar;
+ }
+
+ public void setChar(int beginChar) {
+ this.posChar = beginChar;
+ }
+
+}
Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/TOC.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/TOC.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/TOC.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/TOC.java Sun Jul 19 19:00:32 2015
@@ -38,85 +38,85 @@ import org.openxmlformats.schemas.wordpr
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTabJc;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTabTlc;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTheme;
-
-public class TOC {
-
- CTSdtBlock block;
-
- public TOC() {
- this(CTSdtBlock.Factory.newInstance());
- }
-
- public TOC(CTSdtBlock block) {
- this.block = block;
- CTSdtPr sdtPr = block.addNewSdtPr();
- CTDecimalNumber id = sdtPr.addNewId();
- id.setVal(new BigInteger("4844945"));
- sdtPr.addNewDocPartObj().addNewDocPartGallery().setVal("Table of contents");
- CTSdtEndPr sdtEndPr = block.addNewSdtEndPr();
- CTRPr rPr = sdtEndPr.addNewRPr();
- CTFonts fonts = rPr.addNewRFonts();
- fonts.setAsciiTheme(STTheme.MINOR_H_ANSI);
- fonts.setEastAsiaTheme(STTheme.MINOR_H_ANSI);
- fonts.setHAnsiTheme(STTheme.MINOR_H_ANSI);
- fonts.setCstheme(STTheme.MINOR_BIDI);
- rPr.addNewB().setVal(STOnOff.OFF);
- rPr.addNewBCs().setVal(STOnOff.OFF);
- rPr.addNewColor().setVal("auto");
- rPr.addNewSz().setVal(new BigInteger("24"));
- rPr.addNewSzCs().setVal(new BigInteger("24"));
- CTSdtContentBlock content = block.addNewSdtContent();
- CTP p = content.addNewP();
- p.setRsidR("00EF7E24".getBytes());
- p.setRsidRDefault("00EF7E24".getBytes());
- p.addNewPPr().addNewPStyle().setVal("TOCHeading");
- p.addNewR().addNewT().setStringValue("Table of Contents");
- }
-
- @Internal
- public CTSdtBlock getBlock() {
- return this.block;
- }
-
- public void addRow(int level, String title, int page, String bookmarkRef) {
- CTSdtContentBlock contentBlock = this.block.getSdtContent();
- CTP p = contentBlock.addNewP();
- p.setRsidR("00EF7E24".getBytes());
- p.setRsidRDefault("00EF7E24".getBytes());
- CTPPr pPr = p.addNewPPr();
- pPr.addNewPStyle().setVal("TOC" + level);
- CTTabs tabs = pPr.addNewTabs();
- CTTabStop tab = tabs.addNewTab();
- tab.setVal(STTabJc.RIGHT);
- tab.setLeader(STTabTlc.DOT);
- tab.setPos(new BigInteger("8290"));
- pPr.addNewRPr().addNewNoProof();
- CTR run = p.addNewR();
- run.addNewRPr().addNewNoProof();
- run.addNewT().setStringValue(title);
- run = p.addNewR();
- run.addNewRPr().addNewNoProof();
- run.addNewTab();
- run = p.addNewR();
- run.addNewRPr().addNewNoProof();
- run.addNewFldChar().setFldCharType(STFldCharType.BEGIN);
- // pageref run
- run = p.addNewR();
- run.addNewRPr().addNewNoProof();
- CTText text = run.addNewInstrText();
- text.setSpace(Space.PRESERVE);
- // bookmark reference
- text.setStringValue(" PAGEREF _Toc" + bookmarkRef + " \\h ");
- p.addNewR().addNewRPr().addNewNoProof();
- run = p.addNewR();
- run.addNewRPr().addNewNoProof();
- run.addNewFldChar().setFldCharType(STFldCharType.SEPARATE);
- // page number run
- run = p.addNewR();
- run.addNewRPr().addNewNoProof();
- run.addNewT().setStringValue(Integer.valueOf(page).toString());
- run = p.addNewR();
- run.addNewRPr().addNewNoProof();
- run.addNewFldChar().setFldCharType(STFldCharType.END);
- }
-}
+
+public class TOC {
+
+ CTSdtBlock block;
+
+ public TOC() {
+ this(CTSdtBlock.Factory.newInstance());
+ }
+
+ public TOC(CTSdtBlock block) {
+ this.block = block;
+ CTSdtPr sdtPr = block.addNewSdtPr();
+ CTDecimalNumber id = sdtPr.addNewId();
+ id.setVal(new BigInteger("4844945"));
+ sdtPr.addNewDocPartObj().addNewDocPartGallery().setVal("Table of contents");
+ CTSdtEndPr sdtEndPr = block.addNewSdtEndPr();
+ CTRPr rPr = sdtEndPr.addNewRPr();
+ CTFonts fonts = rPr.addNewRFonts();
+ fonts.setAsciiTheme(STTheme.MINOR_H_ANSI);
+ fonts.setEastAsiaTheme(STTheme.MINOR_H_ANSI);
+ fonts.setHAnsiTheme(STTheme.MINOR_H_ANSI);
+ fonts.setCstheme(STTheme.MINOR_BIDI);
+ rPr.addNewB().setVal(STOnOff.OFF);
+ rPr.addNewBCs().setVal(STOnOff.OFF);
+ rPr.addNewColor().setVal("auto");
+ rPr.addNewSz().setVal(new BigInteger("24"));
+ rPr.addNewSzCs().setVal(new BigInteger("24"));
+ CTSdtContentBlock content = block.addNewSdtContent();
+ CTP p = content.addNewP();
+ p.setRsidR("00EF7E24".getBytes());
+ p.setRsidRDefault("00EF7E24".getBytes());
+ p.addNewPPr().addNewPStyle().setVal("TOCHeading");
+ p.addNewR().addNewT().setStringValue("Table of Contents");
+ }
+
+ @Internal
+ public CTSdtBlock getBlock() {
+ return this.block;
+ }
+
+ public void addRow(int level, String title, int page, String bookmarkRef) {
+ CTSdtContentBlock contentBlock = this.block.getSdtContent();
+ CTP p = contentBlock.addNewP();
+ p.setRsidR("00EF7E24".getBytes());
+ p.setRsidRDefault("00EF7E24".getBytes());
+ CTPPr pPr = p.addNewPPr();
+ pPr.addNewPStyle().setVal("TOC" + level);
+ CTTabs tabs = pPr.addNewTabs();
+ CTTabStop tab = tabs.addNewTab();
+ tab.setVal(STTabJc.RIGHT);
+ tab.setLeader(STTabTlc.DOT);
+ tab.setPos(new BigInteger("8290"));
+ pPr.addNewRPr().addNewNoProof();
+ CTR run = p.addNewR();
+ run.addNewRPr().addNewNoProof();
+ run.addNewT().setStringValue(title);
+ run = p.addNewR();
+ run.addNewRPr().addNewNoProof();
+ run.addNewTab();
+ run = p.addNewR();
+ run.addNewRPr().addNewNoProof();
+ run.addNewFldChar().setFldCharType(STFldCharType.BEGIN);
+ // pageref run
+ run = p.addNewR();
+ run.addNewRPr().addNewNoProof();
+ CTText text = run.addNewInstrText();
+ text.setSpace(Space.PRESERVE);
+ // bookmark reference
+ text.setStringValue(" PAGEREF _Toc" + bookmarkRef + " \\h ");
+ p.addNewR().addNewRPr().addNewNoProof();
+ run = p.addNewR();
+ run.addNewRPr().addNewNoProof();
+ run.addNewFldChar().setFldCharType(STFldCharType.SEPARATE);
+ // page number run
+ run = p.addNewR();
+ run.addNewRPr().addNewNoProof();
+ run.addNewT().setStringValue(Integer.valueOf(page).toString());
+ run = p.addNewR();
+ run.addNewRPr().addNewNoProof();
+ run.addNewFldChar().setFldCharType(STFldCharType.END);
+ }
+}
Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/TextAlignment.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/TextAlignment.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/TextAlignment.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/TextAlignment.java Sun Jul 19 19:00:32 2015
@@ -17,25 +17,25 @@
package org.apache.poi.xwpf.usermodel;
import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Specifies all types of vertical alignment which are available to be applied to of all text
- * on each line displayed within a paragraph.
- *
- * @author Gisella Bronzetti
- */
-public enum TextAlignment {
- /**
- * Specifies that all text in the parent object shall be
- * aligned to the top of each character when displayed
- */
- TOP(1),
- /**
- * Specifies that all text in the parent object shall be
- * aligned to the center of each character when displayed.
- */
- CENTER(2),
+import java.util.Map;
+
+/**
+ * Specifies all types of vertical alignment which are available to be applied to of all text
+ * on each line displayed within a paragraph.
+ *
+ * @author Gisella Bronzetti
+ */
+public enum TextAlignment {
+ /**
+ * Specifies that all text in the parent object shall be
+ * aligned to the top of each character when displayed
+ */
+ TOP(1),
+ /**
+ * Specifies that all text in the parent object shall be
+ * aligned to the center of each character when displayed.
+ */
+ CENTER(2),
/**
* Specifies that all text in the parent object shall be
* aligned to the baseline of each character when displayed.
@@ -44,34 +44,35 @@ public enum TextAlignment {
/**
* Specifies that all text in the parent object shall be
* aligned to the bottom of each character when displayed.
- */
- BOTTOM(4),
- /**
- * Specifies that all text in the parent object shall be
- * aligned automatically when displayed.
- */
- AUTO(5);
-
- private final int value;
-
- private TextAlignment(int val){
- value = val;
- }
-
- public int getValue(){
- return value;
- }
-
- private static Map<Integer, TextAlignment> imap = new HashMap<Integer, TextAlignment>();
- static{
- for (TextAlignment p : values()) {
- imap.put(new Integer(p.getValue()), p);
- }
- }
-
- public static TextAlignment valueOf(int type){
- TextAlignment align = imap.get(new Integer(type));
- if(align == null) throw new IllegalArgumentException("Unknown text alignment: " + type);
- return align;
- }
-}
+ */
+ BOTTOM(4),
+ /**
+ * Specifies that all text in the parent object shall be
+ * aligned automatically when displayed.
+ */
+ AUTO(5);
+
+ private static Map<Integer, TextAlignment> imap = new HashMap<Integer, TextAlignment>();
+
+ static {
+ for (TextAlignment p : values()) {
+ imap.put(new Integer(p.getValue()), p);
+ }
+ }
+
+ private final int value;
+
+ private TextAlignment(int val) {
+ value = val;
+ }
+
+ public static TextAlignment valueOf(int type) {
+ TextAlignment align = imap.get(new Integer(type));
+ if (align == null) throw new IllegalArgumentException("Unknown text alignment: " + type);
+ return align;
+ }
+
+ public int getValue() {
+ return value;
+ }
+}
Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/TextSegement.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/TextSegement.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/TextSegement.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/TextSegement.java Sun Jul 19 19:00:32 2015
@@ -16,83 +16,84 @@
==================================================================== */
package org.apache.poi.xwpf.usermodel;
-
-/**
- * saves the begin and end position of a text in a Paragraph
-*/
-public class TextSegement {
- private PositionInParagraph beginPos;
- private PositionInParagraph endPos;
-
- public TextSegement(){
- this.beginPos = new PositionInParagraph();
- this. endPos = new PositionInParagraph();
- }
-
- public TextSegement(int beginRun, int endRun, int beginText, int endText, int beginChar, int endChar){
- PositionInParagraph beginPos = new PositionInParagraph(beginRun, beginText, beginChar);
- PositionInParagraph endPos = new PositionInParagraph(endRun, endText, endChar);
- this.beginPos = beginPos;
- this.endPos = endPos;
- }
-
- public TextSegement(PositionInParagraph beginPos, PositionInParagraph endPos){
- this.beginPos = beginPos;
- this.endPos = endPos;
- }
-
- public PositionInParagraph getBeginPos(){
- return beginPos;
- }
-
- public PositionInParagraph getEndPos(){
- return endPos;
- }
-
- public int getBeginRun(){
- return beginPos.getRun();
- }
-
- public void setBeginRun(int beginRun){
- beginPos.setRun(beginRun);
- }
-
- public int getBeginText(){
- return beginPos.getText();
- }
-
- public void setBeginText(int beginText){
- beginPos.setText(beginText);
- }
-
- public int getBeginChar(){
- return beginPos.getChar();
- }
-
- public void setBeginChar(int beginChar){
- beginPos.setChar(beginChar);
- }
- public int getEndRun(){
- return endPos.getRun();
- }
-
- public void setEndRun(int endRun){
- endPos.setRun(endRun);
- }
-
- public int getEndText(){
- return endPos.getText();
- }
-
- public void setEndText(int endText){
- endPos.setText(endText);
- }
-
- public int getEndChar(){
- return endPos.getChar();
- }
-
- public void setEndChar(int endChar){
- endPos.setChar(endChar);
- }
-}
+
+/**
+ * saves the begin and end position of a text in a Paragraph
+ */
+public class TextSegement {
+ private PositionInParagraph beginPos;
+ private PositionInParagraph endPos;
+
+ public TextSegement() {
+ this.beginPos = new PositionInParagraph();
+ this.endPos = new PositionInParagraph();
+ }
+
+ public TextSegement(int beginRun, int endRun, int beginText, int endText, int beginChar, int endChar) {
+ PositionInParagraph beginPos = new PositionInParagraph(beginRun, beginText, beginChar);
+ PositionInParagraph endPos = new PositionInParagraph(endRun, endText, endChar);
+ this.beginPos = beginPos;
+ this.endPos = endPos;
+ }
+
+ public TextSegement(PositionInParagraph beginPos, PositionInParagraph endPos) {
+ this.beginPos = beginPos;
+ this.endPos = endPos;
+ }
+
+ public PositionInParagraph getBeginPos() {
+ return beginPos;
+ }
+
+ public PositionInParagraph getEndPos() {
+ return endPos;
+ }
+
+ public int getBeginRun() {
+ return beginPos.getRun();
+ }
+
+ public void setBeginRun(int beginRun) {
+ beginPos.setRun(beginRun);
+ }
+
+ public int getBeginText() {
+ return beginPos.getText();
+ }
+
+ public void setBeginText(int beginText) {
+ beginPos.setText(beginText);
+ }
+
+ public int getBeginChar() {
+ return beginPos.getChar();
+ }
+
+ public void setBeginChar(int beginChar) {
+ beginPos.setChar(beginChar);
+ }
+
+ public int getEndRun() {
+ return endPos.getRun();
+ }
+
+ public void setEndRun(int endRun) {
+ endPos.setRun(endRun);
+ }
+
+ public int getEndText() {
+ return endPos.getText();
+ }
+
+ public void setEndText(int endText) {
+ endPos.setText(endText);
+ }
+
+ public int getEndChar() {
+ return endPos.getChar();
+ }
+
+ public void setEndChar(int endChar) {
+ endPos.setChar(endChar);
+ }
+}
Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/UnderlinePatterns.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/UnderlinePatterns.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/UnderlinePatterns.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/UnderlinePatterns.java Sun Jul 19 19:00:32 2015
@@ -19,13 +19,13 @@ package org.apache.poi.xwpf.usermodel;
import java.util.HashMap;
import java.util.Map;
-/**
- * Specifies the types of patterns which may be used to create the underline
- * applied beneath the text in a run.
- *
- * @author Gisella Bronzetti
- */
-public enum UnderlinePatterns {
+/**
+ * Specifies the types of patterns which may be used to create the underline
+ * applied beneath the text in a run.
+ *
+ * @author Gisella Bronzetti
+ */
+public enum UnderlinePatterns {
/**
* Specifies an underline consisting of a single line beneath all characters
@@ -132,31 +132,32 @@ public enum UnderlinePatterns {
/**
* Specifies no underline beneath this run.
- */
- NONE(18);
-
- private final int value;
-
- private UnderlinePatterns(int val) {
- value = val;
- }
-
- public int getValue() {
- return value;
- }
-
- private static Map<Integer, UnderlinePatterns> imap = new HashMap<Integer, UnderlinePatterns>();
- static {
- for (UnderlinePatterns p : values()) {
- imap.put(new Integer(p.getValue()), p);
- }
- }
-
- public static UnderlinePatterns valueOf(int type) {
- UnderlinePatterns align = imap.get(new Integer(type));
- if (align == null)
- throw new IllegalArgumentException("Unknown underline pattern: "
- + type);
- return align;
- }
-}
+ */
+ NONE(18);
+
+ private static Map<Integer, UnderlinePatterns> imap = new HashMap<Integer, UnderlinePatterns>();
+
+ static {
+ for (UnderlinePatterns p : values()) {
+ imap.put(new Integer(p.getValue()), p);
+ }
+ }
+
+ private final int value;
+
+ private UnderlinePatterns(int val) {
+ value = val;
+ }
+
+ public static UnderlinePatterns valueOf(int type) {
+ UnderlinePatterns align = imap.get(new Integer(type));
+ if (align == null)
+ throw new IllegalArgumentException("Unknown underline pattern: "
+ + type);
+ return align;
+ }
+
+ public int getValue() {
+ return value;
+ }
+}
Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/VerticalAlign.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/VerticalAlign.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/VerticalAlign.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/VerticalAlign.java Sun Jul 19 19:00:32 2015
@@ -21,13 +21,13 @@ import java.util.Map;
/**
* Specifies possible values for the alignment of the contents of this run in
- * relation to the default appearance of the run's text. This allows the text to
- * be repositioned as subscript or superscript without altering the font size of
- * the run properties.
- *
- * @author Gisella Bronzetti
- */
-public enum VerticalAlign {
+ * relation to the default appearance of the run's text. This allows the text to
+ * be repositioned as subscript or superscript without altering the font size of
+ * the run properties.
+ *
+ * @author Gisella Bronzetti
+ */
+public enum VerticalAlign {
/**
* Specifies that the text in the parent run shall be located at the
@@ -44,31 +44,32 @@ public enum VerticalAlign {
* Specifies that this text should be superscript. This setting shall raise
* the text in this run above the baseline and change it to a smaller size,
* if a smaller size is available.
- */
- SUBSCRIPT(3);
-
- private final int value;
-
- private VerticalAlign(int val) {
- value = val;
- }
-
- public int getValue() {
- return value;
- }
-
- private static Map<Integer, VerticalAlign> imap = new HashMap<Integer, VerticalAlign>();
- static {
- for (VerticalAlign p : values()) {
- imap.put(new Integer(p.getValue()), p);
- }
- }
-
- public static VerticalAlign valueOf(int type) {
- VerticalAlign align = imap.get(new Integer(type));
- if (align == null)
- throw new IllegalArgumentException("Unknown vertical alignment: "
- + type);
- return align;
- }
-}
+ */
+ SUBSCRIPT(3);
+
+ private static Map<Integer, VerticalAlign> imap = new HashMap<Integer, VerticalAlign>();
+
+ static {
+ for (VerticalAlign p : values()) {
+ imap.put(new Integer(p.getValue()), p);
+ }
+ }
+
+ private final int value;
+
+ private VerticalAlign(int val) {
+ value = val;
+ }
+
+ public static VerticalAlign valueOf(int type) {
+ VerticalAlign align = imap.get(new Integer(type));
+ if (align == null)
+ throw new IllegalArgumentException("Unknown vertical alignment: "
+ + type);
+ return align;
+ }
+
+ public int getValue() {
+ return value;
+ }
+}
Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFAbstractNum.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFAbstractNum.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFAbstractNum.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFAbstractNum.java Sun Jul 19 19:00:32 2015
@@ -18,42 +18,43 @@
package org.apache.poi.xwpf.usermodel;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTAbstractNum;
-
-/**
- * @author Philipp Epp
- *
- */
-public class XWPFAbstractNum {
- private CTAbstractNum ctAbstractNum;
- protected XWPFNumbering numbering;
-
- protected XWPFAbstractNum() {
- this.ctAbstractNum = null;
- this.numbering = null;
-
- }
- public XWPFAbstractNum(CTAbstractNum abstractNum){
- this.ctAbstractNum = abstractNum;
- }
-
- public XWPFAbstractNum(CTAbstractNum ctAbstractNum, XWPFNumbering numbering){
- this.ctAbstractNum = ctAbstractNum;
- this.numbering = numbering;
- }
- public CTAbstractNum getAbstractNum(){
- return ctAbstractNum;
- }
-
- public XWPFNumbering getNumbering(){
- return numbering;
- }
-
- public CTAbstractNum getCTAbstractNum(){
- return ctAbstractNum;
- }
-
- public void setNumbering(XWPFNumbering numbering){
- this.numbering = numbering;
- }
-
-}
+
+/**
+ * @author Philipp Epp
+ */
+public class XWPFAbstractNum {
+ protected XWPFNumbering numbering;
+ private CTAbstractNum ctAbstractNum;
+
+ protected XWPFAbstractNum() {
+ this.ctAbstractNum = null;
+ this.numbering = null;
+
+ }
+
+ public XWPFAbstractNum(CTAbstractNum abstractNum) {
+ this.ctAbstractNum = abstractNum;
+ }
+
+ public XWPFAbstractNum(CTAbstractNum ctAbstractNum, XWPFNumbering numbering) {
+ this.ctAbstractNum = ctAbstractNum;
+ this.numbering = numbering;
+ }
+
+ public CTAbstractNum getAbstractNum() {
+ return ctAbstractNum;
+ }
+
+ public XWPFNumbering getNumbering() {
+ return numbering;
+ }
+
+ public void setNumbering(XWPFNumbering numbering) {
+ this.numbering = numbering;
+ }
+
+ public CTAbstractNum getCTAbstractNum() {
+ return ctAbstractNum;
+ }
+
+}
Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFComment.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFComment.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFComment.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFComment.java Sun Jul 19 19:00:32 2015
@@ -21,42 +21,35 @@ import org.openxmlformats.schemas.wordpr
/**
* Sketch of XWPF comment class
- *
-* @author Yury Batrakov (batrakov at gmail.com)
- *
+ *
+ * @author Yury Batrakov (batrakov at gmail.com)
*/
-public class XWPFComment
-{
+public class XWPFComment {
protected String id;
protected String author;
protected StringBuffer text;
-
+
@SuppressWarnings("deprecation")
- public XWPFComment(CTComment comment, XWPFDocument document)
- {
+ public XWPFComment(CTComment comment, XWPFDocument document) {
text = new StringBuffer();
id = comment.getId().toString();
author = comment.getAuthor();
-
- for(CTP ctp : comment.getPArray())
- {
+
+ for (CTP ctp : comment.getPArray()) {
XWPFParagraph p = new XWPFParagraph(ctp, document);
text.append(p.getText());
}
}
-
- public String getId()
- {
+
+ public String getId() {
return id;
}
-
- public String getAuthor()
- {
+
+ public String getAuthor() {
return author;
}
-
- public String getText()
- {
+
+ public String getText() {
return text.toString();
}
}
Modified: poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
URL: http://svn.apache.org/viewvc/poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java?rev=1691843&r1=1691842&r2=1691843&view=diff
==============================================================================
--- poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java (original)
+++ poi/branches/common_sl/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java Sun Jul 19 19:00:32 2015
@@ -76,23 +76,17 @@ import org.openxmlformats.schemas.wordpr
/**
* <p>High(ish) level class for working with .docx files.</p>
- *
+ * <p/>
* <p>This class tries to hide some of the complexity
- * of the underlying file format, but as it's not a
- * mature and stable API yet, certain parts of the
- * XML structure come through. You'll therefore almost
- * certainly need to refer to the OOXML specifications
- * from
- * http://www.ecma-international.org/publications/standards/Ecma-376.htm
- * at some point in your use.</p>
+ * of the underlying file format, but as it's not a
+ * mature and stable API yet, certain parts of the
+ * XML structure come through. You'll therefore almost
+ * certainly need to refer to the OOXML specifications
+ * from
+ * http://www.ecma-international.org/publications/standards/Ecma-376.htm
+ * at some point in your use.</p>
*/
public class XWPFDocument extends POIXMLDocument implements Document, IBody {
- private CTDocument1 ctDocument;
- private XWPFSettings settings;
- /**
- * Keeps track on all id-values used in this document and included parts, like headers, footers, etc.
- */
- private IdentifierManager drawingIdManager = new IdentifierManager(1L,4294967295L);
protected List<XWPFFooter> footers = new ArrayList<XWPFFooter>();
protected List<XWPFHeader> headers = new ArrayList<XWPFHeader>();
protected List<XWPFComment> comments = new ArrayList<XWPFComment>();
@@ -107,8 +101,15 @@ public class XWPFDocument extends POIXML
protected XWPFNumbering numbering;
protected XWPFStyles styles;
protected XWPFFootnotes footnotes;
-
- /** Handles the joy of different headers/footers for different pages */
+ private CTDocument1 ctDocument;
+ private XWPFSettings settings;
+ /**
+ * Keeps track on all id-values used in this document and included parts, like headers, footers, etc.
+ */
+ private IdentifierManager drawingIdManager = new IdentifierManager(0L, 4294967295L);
+ /**
+ * Handles the joy of different headers/footers for different pages
+ */
private XWPFHeaderFooterPolicy headerFooterPolicy;
public XWPFDocument(OPCPackage pkg) throws IOException {
@@ -125,11 +126,32 @@ public class XWPFDocument extends POIXML
load(XWPFFactory.getInstance());
}
- public XWPFDocument(){
+ public XWPFDocument() {
super(newPackage());
onDocumentCreate();
}
+ /**
+ * Create a new WordProcessingML package and setup the default minimal content
+ */
+ protected static OPCPackage newPackage() {
+ try {
+ OPCPackage pkg = OPCPackage.create(new ByteArrayOutputStream());
+ // Main part
+ PackagePartName corePartName = PackagingURIHelper.createPartName(XWPFRelation.DOCUMENT.getDefaultFileName());
+ // Create main part relationship
+ pkg.addRelationship(corePartName, TargetMode.INTERNAL, PackageRelationshipTypes.CORE_DOCUMENT);
+ // Create main document part
+ pkg.createPart(corePartName, XWPFRelation.DOCUMENT.getContentType());
+
+ pkg.getPackageProperties().setCreatorProperty(DOCUMENT_CREATOR);
+
+ return pkg;
+ } catch (Exception e) {
+ throw new POIXMLException(e);
+ }
+ }
+
@Override
protected void onDocumentRead() throws IOException {
try {
@@ -152,11 +174,11 @@ public class XWPFDocument extends POIXML
XWPFTable t = new XWPFTable((CTTbl) o, this);
bodyElements.add(t);
tables.add(t);
- } else if (o instanceof CTSdtBlock){
- XWPFSDT c = new XWPFSDT((CTSdtBlock)o, this);
- bodyElements.add(c);
- contentControls.add(c);
- }
+ } else if (o instanceof CTSdtBlock) {
+ XWPFSDT c = new XWPFSDT((CTSdtBlock) o, this);
+ bodyElements.add(c);
+ contentControls.add(c);
+ }
}
cursor.dispose();
@@ -205,7 +227,7 @@ public class XWPFDocument extends POIXML
Method onDocumentRead = gp.getClass().getDeclaredMethod("onDocumentRead");
onDocumentRead.setAccessible(true);
onDocumentRead.invoke(gp);
- } catch(Exception e) {
+ } catch (Exception e) {
throw new POIXMLException(e);
}
}
@@ -217,32 +239,32 @@ public class XWPFDocument extends POIXML
}
}
- private void initHyperlinks(){
+ private void initHyperlinks() {
// Get the hyperlinks
// TODO: make me optional/separated in private function
try {
Iterator<PackageRelationship> relIter =
getPackagePart().getRelationshipsByType(XWPFRelation.HYPERLINK.getRelation()).iterator();
- while(relIter.hasNext()) {
+ while (relIter.hasNext()) {
PackageRelationship rel = relIter.next();
hyperlinks.add(new XWPFHyperlink(rel.getId(), rel.getTargetURI().toString()));
}
- } catch (InvalidFormatException e){
+ } catch (InvalidFormatException e) {
throw new POIXMLException(e);
}
}
@SuppressWarnings("deprecation")
private void initFootnotes() throws XmlException, IOException {
- for(POIXMLDocumentPart p : getRelations()){
+ for (POIXMLDocumentPart p : getRelations()) {
String relation = p.getPackageRelationship().getRelationshipType();
if (relation.equals(XWPFRelation.FOOTNOTE.getRelation())) {
- this.footnotes = (XWPFFootnotes)p;
+ this.footnotes = (XWPFFootnotes) p;
this.footnotes.onDocumentRead();
- } else if (relation.equals(XWPFRelation.ENDNOTE.getRelation())){
+ } else if (relation.equals(XWPFRelation.ENDNOTE.getRelation())) {
EndnotesDocument endnotesDocument = EndnotesDocument.Factory.parse(p.getPackagePart().getInputStream());
- for(CTFtnEdn ctFtnEdn : endnotesDocument.getEndnotes().getEndnoteArray()) {
+ for (CTFtnEdn ctFtnEdn : endnotesDocument.getEndnotes().getEndnoteArray()) {
endnotes.put(ctFtnEdn.getId().intValue(), new XWPFFootnote(this, ctFtnEdn));
}
}
@@ -250,27 +272,6 @@ public class XWPFDocument extends POIXML
}
/**
- * Create a new WordProcessingML package and setup the default minimal content
- */
- protected static OPCPackage newPackage() {
- try {
- OPCPackage pkg = OPCPackage.create(new ByteArrayOutputStream());
- // Main part
- PackagePartName corePartName = PackagingURIHelper.createPartName(XWPFRelation.DOCUMENT.getDefaultFileName());
- // Create main part relationship
- pkg.addRelationship(corePartName, TargetMode.INTERNAL, PackageRelationshipTypes.CORE_DOCUMENT);
- // Create main document part
- pkg.createPart(corePartName, XWPFRelation.DOCUMENT.getContentType());
-
- pkg.getPackageProperties().setCreatorProperty(DOCUMENT_CREATOR);
-
- return pkg;
- } catch (Exception e){
- throw new POIXMLException(e);
- }
- }
-
- /**
* Create a new CTWorkbook with all values set to default
*/
@Override
@@ -278,7 +279,7 @@ public class XWPFDocument extends POIXML
ctDocument = CTDocument1.Factory.newInstance();
ctDocument.addNewBody();
- settings = (XWPFSettings) createRelationship(XWPFRelation.SETTINGS,XWPFFactory.getInstance());
+ settings = (XWPFSettings) createRelationship(XWPFRelation.SETTINGS, XWPFFactory.getInstance());
POIXMLProperties.ExtendedProperties expProps = getProperties().getExtendedProperties();
expProps.getUnderlyingProperties().setApplication(DOCUMENT_CREATOR);
@@ -298,6 +299,7 @@ public class XWPFDocument extends POIXML
/**
* returns an Iterator with paragraphs and tables
+ *
* @see org.apache.poi.xwpf.usermodel.IBody#getBodyElements()
*/
@Override
@@ -313,7 +315,7 @@ public class XWPFDocument extends POIXML
* @see org.apache.poi.xwpf.usermodel.IBody#getParagraphs()
*/
@Override
- public List<XWPFParagraph> getParagraphs(){
+ public List<XWPFParagraph> getParagraphs() {
return Collections.unmodifiableList(paragraphs);
}
@@ -321,7 +323,7 @@ public class XWPFDocument extends POIXML
* @see org.apache.poi.xwpf.usermodel.IBody#getTables()
*/
@Override
- public List<XWPFTable> getTables(){
+ public List<XWPFTable> getTables() {
return Collections.unmodifiableList(tables);
}
@@ -330,37 +332,35 @@ public class XWPFDocument extends POIXML
*/
@Override
public XWPFTable getTableArray(int pos) {
- if (pos > 0 && pos < tables.size()){
+ if (pos > 0 && pos < tables.size()) {
return tables.get(pos);
}
return null;
}
/**
- *
- * @return the list of footers
+ * @return the list of footers
*/
- public List<XWPFFooter> getFooterList(){
+ public List<XWPFFooter> getFooterList() {
return Collections.unmodifiableList(footers);
}
- public XWPFFooter getFooterArray(int pos){
+ public XWPFFooter getFooterArray(int pos) {
return footers.get(pos);
}
/**
- *
- * @return the list of headers
+ * @return the list of headers
*/
- public List<XWPFHeader> getHeaderList(){
+ public List<XWPFHeader> getHeaderList() {
return Collections.unmodifiableList(headers);
}
- public XWPFHeader getHeaderArray(int pos){
+ public XWPFHeader getHeaderArray(int pos) {
return headers.get(pos);
}
- public String getTblStyle(XWPFTable table){
+ public String getTblStyle(XWPFTable table) {
return table.getStyleID();
}
@@ -374,17 +374,17 @@ public class XWPFDocument extends POIXML
}
public XWPFFootnote getFootnoteByID(int id) {
- if(footnotes == null) return null;
+ if (footnotes == null) return null;
return footnotes.getFootnoteById(id);
}
public XWPFFootnote getEndnoteByID(int id) {
- if(endnotes == null) return null;
+ if (endnotes == null) return null;
return endnotes.get(id);
}
public List<XWPFFootnote> getFootnotes() {
- if(footnotes == null) {
+ if (footnotes == null) {
return Collections.emptyList();
}
return footnotes.getFootnotesList();
@@ -409,7 +409,7 @@ public class XWPFDocument extends POIXML
/**
* Get the document part that's defined as the
- * given relationship of the core document.
+ * given relationship of the core document.
*/
public PackagePart getPartById(String id) {
try {
@@ -422,7 +422,7 @@ public class XWPFDocument extends POIXML
/**
* Returns the policy on headers and footers, which
- * also provides a way to get at them.
+ * also provides a way to get at them.
*/
public XWPFHeaderFooterPolicy getHeaderFooterPolicy() {
return headerFooterPolicy;
@@ -436,10 +436,10 @@ public class XWPFDocument extends POIXML
PackagePart[] parts;
try {
parts = getRelatedByType(XWPFRelation.STYLES.getRelation());
- } catch(InvalidFormatException e) {
+ } catch (InvalidFormatException e) {
throw new IllegalStateException(e);
}
- if(parts.length != 1) {
+ if (parts.length != 1) {
throw new IllegalStateException("Expecting one Styles document part, but found " + parts.length);
}
@@ -471,57 +471,56 @@ public class XWPFDocument extends POIXML
* Finds that for example the 2nd entry in the body list is the 1st paragraph
*/
private int getBodyElementSpecificPos(int pos, List<? extends IBodyElement> list) {
- // If there's nothing to find, skip it
- if(list.size() == 0) {
- return -1;
- }
-
- if(pos >= 0 && pos < bodyElements.size()) {
- // Ensure the type is correct
- IBodyElement needle = bodyElements.get(pos);
- if(needle.getElementType() != list.get(0).getElementType()) {
- // Wrong type
- return -1;
- }
-
- // Work back until we find it
- int startPos = Math.min(pos, list.size()-1);
- for(int i=startPos; i>=0; i--) {
- if(list.get(i) == needle) {
- return i;
- }
- }
- }
+ // If there's nothing to find, skip it
+ if (list.size() == 0) {
+ return -1;
+ }
- // Couldn't be found
- return -1;
+ if (pos >= 0 && pos < bodyElements.size()) {
+ // Ensure the type is correct
+ IBodyElement needle = bodyElements.get(pos);
+ if (needle.getElementType() != list.get(0).getElementType()) {
+ // Wrong type
+ return -1;
+ }
+
+ // Work back until we find it
+ int startPos = Math.min(pos, list.size() - 1);
+ for (int i = startPos; i >= 0; i--) {
+ if (list.get(i) == needle) {
+ return i;
+ }
+ }
+ }
+
+ // Couldn't be found
+ return -1;
}
-
+
/**
* Look up the paragraph at the specified position in the body elements list
* and return this paragraphs position in the paragraphs list
- *
- * @param pos
- * The position of the relevant paragraph in the body elements
+ *
+ * @param pos The position of the relevant paragraph in the body elements
* list
* @return the position of the paragraph in the paragraphs list, if there is
- * a paragraph at the position in the bodyelements list. Else it
- * will return -1
- *
+ * a paragraph at the position in the bodyelements list. Else it
+ * will return -1
*/
public int getParagraphPos(int pos) {
- return getBodyElementSpecificPos(pos, paragraphs);
+ return getBodyElementSpecificPos(pos, paragraphs);
}
/**
- * get with the position of a table in the bodyelement array list
+ * get with the position of a table in the bodyelement array list
* the position of this table in the table array list
+ *
* @param pos position of the table in the bodyelement array list
* @return if there is a table at the position in the bodyelement array list,
- * else it will return null.
+ * else it will return null.
*/
public int getTablePos(int pos) {
- return getBodyElementSpecificPos(pos, tables);
+ return getBodyElementSpecificPos(pos, tables);
}
/**
@@ -530,10 +529,10 @@ public class XWPFDocument extends POIXML
* of the documents body. When this method is done, the cursor passed as
* parameter points to the {@link org.apache.xmlbeans.XmlCursor.TokenType#END}
* of the newly inserted paragraph.
- *
+ *
* @param cursor
* @return the {@link XWPFParagraph} object representing the newly inserted
- * CTP object
+ * CTP object
*/
@Override
public XWPFParagraph insertNewParagraph(XmlCursor cursor) {
@@ -635,8 +634,7 @@ public class XWPFDocument extends POIXML
cursor.toCursor(tableCursor);
cursor.toEndToken();
return newT;
- }
- finally {
+ } finally {
tableCursor.dispose();
}
}
@@ -645,6 +643,7 @@ public class XWPFDocument extends POIXML
/**
* verifies that cursor is on the right position
+ *
* @param cursor
*/
private boolean isCursorInBody(XmlCursor cursor) {
@@ -659,11 +658,11 @@ public class XWPFDocument extends POIXML
private int getPosOfBodyElement(IBodyElement needle) {
BodyElementType type = needle.getElementType();
- IBodyElement current;
- for(int i=0; i<bodyElements.size(); i++) {
+ IBodyElement current;
+ for (int i = 0; i < bodyElements.size(); i++) {
current = bodyElements.get(i);
- if(current.getElementType() == type) {
- if(current.equals(needle)) {
+ if (current.getElementType() == type) {
+ if (current.equals(needle)) {
return i;
}
}
@@ -673,21 +672,23 @@ public class XWPFDocument extends POIXML
/**
* Get the position of the paragraph, within the list
- * of all the body elements.
+ * of all the body elements.
+ *
* @param p The paragraph to find
- * @return The location, or -1 if the paragraph couldn't be found
+ * @return The location, or -1 if the paragraph couldn't be found
*/
- public int getPosOfParagraph(XWPFParagraph p){
+ public int getPosOfParagraph(XWPFParagraph p) {
return getPosOfBodyElement(p);
}
/**
* Get the position of the table, within the list of
- * all the body elements.
+ * all the body elements.
+ *
* @param t The table to find
* @return The location, or -1 if the table couldn't be found
*/
- public int getPosOfTable(XWPFTable t){
+ public int getPosOfTable(XWPFTable t) {
return getPosOfBodyElement(t);
}
@@ -718,23 +719,25 @@ public class XWPFDocument extends POIXML
/**
* Gets the index of the relation we're trying to create
+ *
* @param relation
* @return i
*/
private int getRelationIndex(XWPFRelation relation) {
List<POIXMLDocumentPart> relations = getRelations();
int i = 1;
- for (Iterator<POIXMLDocumentPart> it = relations.iterator(); it.hasNext() ; ) {
- POIXMLDocumentPart item = it.next();
- if (item.getPackageRelationship().getRelationshipType().equals(relation.getRelation())) {
- i++;
- }
+ for (Iterator<POIXMLDocumentPart> it = relations.iterator(); it.hasNext(); ) {
+ POIXMLDocumentPart item = it.next();
+ if (item.getPackageRelationship().getRelationshipType().equals(relation.getRelation())) {
+ i++;
+ }
}
return i;
}
/**
* Appends a new paragraph to this document
+ *
* @return a new paragraph
*/
public XWPFParagraph createParagraph() {
@@ -746,16 +749,17 @@ public class XWPFDocument extends POIXML
/**
* Creates an empty numbering if one does not already exist and sets the numbering member
+ *
* @return numbering
*/
public XWPFNumbering createNumbering() {
- if(numbering == null) {
+ if (numbering == null) {
NumberingDocument numberingDoc = NumberingDocument.Factory.newInstance();
XWPFRelation relation = XWPFRelation.NUMBERING;
int i = getRelationIndex(relation);
- XWPFNumbering wrapper = (XWPFNumbering)createRelationship(relation, XWPFFactory.getInstance(), i);
+ XWPFNumbering wrapper = (XWPFNumbering) createRelationship(relation, XWPFFactory.getInstance(), i);
wrapper.setNumbering(numberingDoc.addNewNumbering());
numbering = wrapper;
}
@@ -765,61 +769,64 @@ public class XWPFDocument extends POIXML
/**
* Creates an empty styles for the document if one does not already exist
+ *
* @return styles
*/
public XWPFStyles createStyles() {
- if(styles == null) {
- StylesDocument stylesDoc = StylesDocument.Factory.newInstance();
+ if (styles == null) {
+ StylesDocument stylesDoc = StylesDocument.Factory.newInstance();
- XWPFRelation relation = XWPFRelation.STYLES;
- int i = getRelationIndex(relation);
+ XWPFRelation relation = XWPFRelation.STYLES;
+ int i = getRelationIndex(relation);
- XWPFStyles wrapper = (XWPFStyles)createRelationship(relation, XWPFFactory.getInstance(), i);
- wrapper.setStyles(stylesDoc.addNewStyles());
- styles = wrapper;
- }
+ XWPFStyles wrapper = (XWPFStyles) createRelationship(relation, XWPFFactory.getInstance(), i);
+ wrapper.setStyles(stylesDoc.addNewStyles());
+ styles = wrapper;
+ }
- return styles;
+ return styles;
}
/**
* Creates an empty footnotes element for the document if one does not already exist
+ *
* @return footnotes
*/
public XWPFFootnotes createFootnotes() {
- if(footnotes == null) {
- FootnotesDocument footnotesDoc = FootnotesDocument.Factory.newInstance();
+ if (footnotes == null) {
+ FootnotesDocument footnotesDoc = FootnotesDocument.Factory.newInstance();
- XWPFRelation relation = XWPFRelation.FOOTNOTE;
- int i = getRelationIndex(relation);
+ XWPFRelation relation = XWPFRelation.FOOTNOTE;
+ int i = getRelationIndex(relation);
- XWPFFootnotes wrapper = (XWPFFootnotes)createRelationship(relation, XWPFFactory.getInstance(), i);
- wrapper.setFootnotes(footnotesDoc.addNewFootnotes());
- footnotes = wrapper;
- }
+ XWPFFootnotes wrapper = (XWPFFootnotes) createRelationship(relation, XWPFFactory.getInstance(), i);
+ wrapper.setFootnotes(footnotesDoc.addNewFootnotes());
+ footnotes = wrapper;
+ }
- return footnotes;
+ return footnotes;
}
public XWPFFootnote addFootnote(CTFtnEdn note) {
- return footnotes.addFootnote(note);
+ return footnotes.addFootnote(note);
}
public XWPFFootnote addEndnote(CTFtnEdn note) {
- XWPFFootnote endnote = new XWPFFootnote(this, note);
- endnotes.put(note.getId().intValue(), endnote);
- return endnote;
+ XWPFFootnote endnote = new XWPFFootnote(this, note);
+ endnotes.put(note.getId().intValue(), endnote);
+ return endnote;
}
/**
- * remove a BodyElement from bodyElements array list
+ * remove a BodyElement from bodyElements array list
+ *
* @param pos
* @return true if removing was successfully, else return false
*/
public boolean removeBodyElement(int pos) {
if (pos >= 0 && pos < bodyElements.size()) {
- BodyElementType type = bodyElements.get(pos).getElementType();
- if (type == BodyElementType.TABLE){
+ BodyElementType type = bodyElements.get(pos).getElementType();
+ if (type == BodyElementType.TABLE) {
int tablePos = getTablePos(pos);
tables.remove(tablePos);
ctDocument.getBody().removeTbl(tablePos);
@@ -830,13 +837,14 @@ public class XWPFDocument extends POIXML
ctDocument.getBody().removeP(paraPos);
}
bodyElements.remove(pos);
- return true;
+ return true;
}
return false;
}
/**
* copies content of a paragraph to a existing paragraph in the list paragraphs at position pos
+ *
* @param paragraph
* @param pos
*/
@@ -859,6 +867,7 @@ public class XWPFDocument extends POIXML
/**
* Create an empty table with one row and one column as default.
+ *
* @return a new table
*/
public XWPFTable createTable() {
@@ -870,19 +879,20 @@ public class XWPFDocument extends POIXML
/**
* Create an empty table with a number of rows and cols specified
+ *
* @param rows
* @param cols
* @return table
*/
public XWPFTable createTable(int rows, int cols) {
- XWPFTable table = new XWPFTable(ctDocument.getBody().addNewTbl(), this, rows, cols);
- bodyElements.add(table);
- tables.add(table);
- return table;
+ XWPFTable table = new XWPFTable(ctDocument.getBody().addNewTbl(), this, rows, cols);
+ bodyElements.add(table);
+ tables.add(table);
+ return table;
}
/**
- *
+ *
*/
public void createTOC() {
CTSdtBlock block = this.getDocument().getBody().addNewSdt();
@@ -900,7 +910,9 @@ public class XWPFDocument extends POIXML
}
}
- /**Replace content of table in array tables at position pos with a
+ /**
+ * Replace content of table in array tables at position pos with a
+ *
* @param pos
* @param table
*/
@@ -919,7 +931,7 @@ public class XWPFDocument extends POIXML
* <w:settings ... >
* <w:documentProtection w:edit="readOnly" w:enforcement="1"/>
* </pre>
- *
+ *
* @return true if documentProtection is enforced with option readOnly
*/
public boolean isEnforcedReadonlyProtection() {
@@ -936,7 +948,7 @@ public class XWPFDocument extends POIXML
* <w:settings ... >
* <w:documentProtection w:edit="forms" w:enforcement="1"/>
* </pre>
- *
+ *
* @return true if documentProtection is enforced with option forms
*/
public boolean isEnforcedFillingFormsProtection() {
@@ -953,7 +965,7 @@ public class XWPFDocument extends POIXML
* <w:settings ... >
* <w:documentProtection w:edit="comments" w:enforcement="1"/>
* </pre>
- *
+ *
* @return true if documentProtection is enforced with option comments
*/
public boolean isEnforcedCommentsProtection() {
@@ -970,7 +982,7 @@ public class XWPFDocument extends POIXML
* <w:settings ... >
* <w:documentProtection w:edit="trackedChanges" w:enforcement="1"/>
* </pre>
- *
+ *
* @return true if documentProtection is enforced with option trackedChanges
*/
public boolean isEnforcedTrackedChangesProtection() {
@@ -1002,21 +1014,21 @@ public class XWPFDocument extends POIXML
* <br/>
* sample snippet from settings.xml
* <pre>
- * <w:documentProtection w:edit="readOnly" w:enforcement="1"
+ * <w:documentProtection w:edit="readOnly" w:enforcement="1"
* w:cryptProviderType="rsaAES" w:cryptAlgorithmClass="hash"
* w:cryptAlgorithmType="typeAny" w:cryptAlgorithmSid="14"
* w:cryptSpinCount="100000" w:hash="..." w:salt="...."
* />
* </pre>
- *
+ *
* @param password the plaintext password, if null no password will be applied
* @param hashAlgo the hash algorithm - only md2, m5, sha1, sha256, sha384 and sha512 are supported.
- * if null, it will default default to sha1
+ * if null, it will default default to sha1
*/
public void enforceReadonlyProtection(String password, HashAlgorithm hashAlgo) {
settings.setEnforcementEditValue(STDocProtect.READ_ONLY, password, hashAlgo);
}
-
+
/**
* Enforce the Filling Forms protection.<br/>
* In the documentProtection tag inside settings.xml file, <br/>
@@ -1038,21 +1050,21 @@ public class XWPFDocument extends POIXML
* <br/>
* sample snippet from settings.xml
* <pre>
- * <w:documentProtection w:edit="forms" w:enforcement="1"
+ * <w:documentProtection w:edit="forms" w:enforcement="1"
* w:cryptProviderType="rsaAES" w:cryptAlgorithmClass="hash"
* w:cryptAlgorithmType="typeAny" w:cryptAlgorithmSid="14"
* w:cryptSpinCount="100000" w:hash="..." w:salt="...."
* />
* </pre>
- *
+ *
* @param password the plaintext password, if null no password will be applied
* @param hashAlgo the hash algorithm - only md2, m5, sha1, sha256, sha384 and sha512 are supported.
- * if null, it will default default to sha1
+ * if null, it will default default to sha1
*/
public void enforceFillingFormsProtection(String password, HashAlgorithm hashAlgo) {
settings.setEnforcementEditValue(STDocProtect.FORMS, password, hashAlgo);
}
-
+
/**
* Enforce the Comments protection.<br/>
* In the documentProtection tag inside settings.xml file,<br/>
@@ -1074,21 +1086,21 @@ public class XWPFDocument extends POIXML
* <br/>
* sample snippet from settings.xml
* <pre>
- * <w:documentProtection w:edit="comments" w:enforcement="1"
+ * <w:documentProtection w:edit="comments" w:enforcement="1"
* w:cryptProviderType="rsaAES" w:cryptAlgorithmClass="hash"
* w:cryptAlgorithmType="typeAny" w:cryptAlgorithmSid="14"
* w:cryptSpinCount="100000" w:hash="..." w:salt="...."
* />
* </pre>
- *
+ *
* @param password the plaintext password, if null no password will be applied
* @param hashAlgo the hash algorithm - only md2, m5, sha1, sha256, sha384 and sha512 are supported.
- * if null, it will default default to sha1
+ * if null, it will default default to sha1
*/
public void enforceCommentsProtection(String password, HashAlgorithm hashAlgo) {
settings.setEnforcementEditValue(STDocProtect.COMMENTS, password, hashAlgo);
}
-
+
/**
* Enforce the Tracked Changes protection.<br/>
* In the documentProtection tag inside settings.xml file, <br/>
@@ -1110,16 +1122,16 @@ public class XWPFDocument extends POIXML
* <br/>
* sample snippet from settings.xml
* <pre>
- * <w:documentProtection w:edit="trackedChanges" w:enforcement="1"
+ * <w:documentProtection w:edit="trackedChanges" w:enforcement="1"
* w:cryptProviderType="rsaAES" w:cryptAlgorithmClass="hash"
* w:cryptAlgorithmType="typeAny" w:cryptAlgorithmSid="14"
* w:cryptSpinCount="100000" w:hash="..." w:salt="...."
* />
* </pre>
- *
+ *
* @param password the plaintext password, if null no password will be applied
* @param hashAlgo the hash algorithm - only md2, m5, sha1, sha256, sha384 and sha512 are supported.
- * if null, it will default default to sha1
+ * if null, it will default default to sha1
*/
public void enforceTrackedChangesProtection(String password, HashAlgorithm hashAlgo) {
settings.setEnforcementEditValue(STDocProtect.TRACKED_CHANGES, password, hashAlgo);
@@ -1134,7 +1146,7 @@ public class XWPFDocument extends POIXML
public boolean validateProtectionPassword(String password) {
return settings.validateProtectionPassword(password);
}
-
+
/**
* Remove protection enforcement.<br/>
* In the documentProtection tag inside settings.xml file <br/>
@@ -1148,38 +1160,39 @@ public class XWPFDocument extends POIXML
* Enforces fields update on document open (in Word).
* In the settings.xml file <br/>
* sets the updateSettings value to true (w:updateSettings w:val="true")
- *
- * NOTICES:
- * <ul>
- * <li>Causing Word to ask on open: "This document contains fields that may refer to other files. Do you want to update the fields in this document?"
- * (if "Update automatic links at open" is enabled)</li>
- * <li>Flag is removed after saving with changes in Word </li>
- * </ul>
+ * <p/>
+ * NOTICES:
+ * <ul>
+ * <li>Causing Word to ask on open: "This document contains fields that may refer to other files. Do you want to update the fields in this document?"
+ * (if "Update automatic links at open" is enabled)</li>
+ * <li>Flag is removed after saving with changes in Word </li>
+ * </ul>
*/
public void enforceUpdateFields() {
settings.setUpdateFields();
}
-
+
/**
- * Check if revision tracking is turned on.
- *
- * @return <code>true</code> if revision tracking is turned on
- */
- public boolean isTrackRevisions() {
- return settings.isTrackRevisions();
- }
-
- /**
- * Enable or disable revision tracking.
- *
- * @param enable <code>true</code> to turn on revision tracking, <code>false</code> to turn off revision tracking
- */
- public void setTrackRevisions(boolean enable) {
- settings.setTrackRevisions(enable);
- }
+ * Check if revision tracking is turned on.
+ *
+ * @return <code>true</code> if revision tracking is turned on
+ */
+ public boolean isTrackRevisions() {
+ return settings.isTrackRevisions();
+ }
+
+ /**
+ * Enable or disable revision tracking.
+ *
+ * @param enable <code>true</code> to turn on revision tracking, <code>false</code> to turn off revision tracking
+ */
+ public void setTrackRevisions(boolean enable) {
+ settings.setTrackRevisions(enable);
+ }
/**
* inserts an existing XWPFTable to the arrays bodyElements and tables
+ *
* @param pos
* @param table
*/
@@ -1199,6 +1212,7 @@ public class XWPFDocument extends POIXML
/**
* Returns all Pictures, which are referenced from the document itself.
+ *
* @return a {@link List} of {@link XWPFPictureData}. The returned {@link List} is unmodifiable. Use #a
*/
public List<XWPFPictureData> getAllPictures() {
@@ -1223,14 +1237,12 @@ public class XWPFDocument extends POIXML
list = new ArrayList<XWPFPictureData>(1);
packagePictures.put(picData.getChecksum(), list);
}
- if (!list.contains(picData))
- {
+ if (!list.contains(picData)) {
list.add(picData);
}
}
-
- XWPFPictureData findPackagePictureData(byte[] pictureData, int format)
- {
+
+ XWPFPictureData findPackagePictureData(byte[] pictureData, int format) {
long checksum = IOUtils.calculateChecksum(pictureData);
XWPFPictureData xwpfPicData = null;
/*
@@ -1246,20 +1258,18 @@ public class XWPFDocument extends POIXML
xwpfPicData = curElem;
}
}
- }
+ }
return xwpfPicData;
}
- public String addPictureData(byte[] pictureData,int format) throws InvalidFormatException
- {
+ public String addPictureData(byte[] pictureData, int format) throws InvalidFormatException {
XWPFPictureData xwpfPicData = findPackagePictureData(pictureData, format);
POIXMLRelation relDesc = XWPFPictureData.RELATIONS[format];
-
- if (xwpfPicData == null)
- {
+
+ if (xwpfPicData == null) {
/* Part doesn't exist, create a new one */
int idx = getNextPicNameNumber(format);
- xwpfPicData = (XWPFPictureData) createRelationship(relDesc, XWPFFactory.getInstance(),idx);
+ xwpfPicData = (XWPFPictureData) createRelationship(relDesc, XWPFFactory.getInstance(), idx);
/* write bytes to new part */
PackagePart picDataPart = xwpfPicData.getPackagePart();
OutputStream out = null;
@@ -1278,11 +1288,9 @@ public class XWPFDocument extends POIXML
registerPackagePictureData(xwpfPicData);
pictures.add(xwpfPicData);
-
+
return getRelationId(xwpfPicData);
- }
- else if (!getRelations().contains(xwpfPicData))
- {
+ } else if (!getRelations().contains(xwpfPicData)) {
/*
* Part already existed, but was not related so far. Create
* relationship to the already existing part and update
@@ -1293,21 +1301,18 @@ public class XWPFDocument extends POIXML
TargetMode targetMode = TargetMode.INTERNAL;
PackagePartName partName = picDataPart.getPartName();
String relation = relDesc.getRelation();
- PackageRelationship relShip = getPackagePart().addRelationship(partName,targetMode,relation);
+ PackageRelationship relShip = getPackagePart().addRelationship(partName, targetMode, relation);
String id = relShip.getId();
- addRelation(id,xwpfPicData);
+ addRelation(id, xwpfPicData);
pictures.add(xwpfPicData);
return id;
- }
- else
- {
+ } else {
/* Part already existed, get relation id and return it */
return getRelationId(xwpfPicData);
}
}
-
- public String addPictureData(InputStream is,int format) throws InvalidFormatException
- {
+
+ public String addPictureData(InputStream is, int format) throws InvalidFormatException {
try {
byte[] data = IOUtils.toByteArray(is);
return addPictureData(data, format);
@@ -1318,9 +1323,10 @@ public class XWPFDocument extends POIXML
/**
* get the next free ImageNumber
+ *
* @param format
* @return the next free ImageNumber
- * @throws InvalidFormatException
+ * @throws InvalidFormatException
*/
public int getNextPicNameNumber(int format) throws InvalidFormatException {
int img = getAllPackagePictures().size() + 1;
@@ -1336,6 +1342,7 @@ public class XWPFDocument extends POIXML
/**
* returns the PictureData by blipID
+ *
* @param blipID
* @return XWPFPictureData of a specificID
*/
@@ -1350,6 +1357,7 @@ public class XWPFDocument extends POIXML
/**
* getNumbering
+ *
* @return numbering
*/
public XWPFNumbering getNumbering() {
@@ -1358,6 +1366,7 @@ public class XWPFDocument extends POIXML
/**
* get Styles
+ *
* @return styles for this document
*/
public XWPFStyles getStyles() {
@@ -1366,7 +1375,7 @@ public class XWPFDocument extends POIXML
/**
* get the paragraph with the CTP class p
- *
+ *
* @param p
* @return the paragraph with the CTP class p
*/
@@ -1382,9 +1391,10 @@ public class XWPFDocument extends POIXML
/**
* get a table by its CTTbl-Object
+ *
* @param ctTbl
- * @see org.apache.poi.xwpf.usermodel.IBody#getTable(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl)
* @return a table by its CTTbl-Object or null
+ * @see org.apache.poi.xwpf.usermodel.IBody#getTable(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl)
*/
@Override
public XWPFTable getTable(CTTbl ctTbl) {
@@ -1406,6 +1416,7 @@ public class XWPFDocument extends POIXML
/**
* Returns the paragraph that of position pos
+ *
* @see org.apache.poi.xwpf.usermodel.IBody#getParagraphArray(int)
*/
@Override
@@ -1420,6 +1431,7 @@ public class XWPFDocument extends POIXML
* returns the Part, to which the body belongs, which you need for adding relationship to other parts
* Actually it is needed of the class XWPFTableCell. Because you have to know to which part the tableCell
* belongs.
+ *
* @see org.apache.poi.xwpf.usermodel.IBody#getPart()
*/
@Override
@@ -1441,6 +1453,7 @@ public class XWPFDocument extends POIXML
/**
* get the TableCell which belongs to the TableCell
+ *
* @param cell
*/
@Override
@@ -1448,19 +1461,19 @@ public class XWPFDocument extends POIXML
XmlCursor cursor = cell.newCursor();
cursor.toParent();
XmlObject o = cursor.getObject();
- if(!(o instanceof CTRow)){
+ if (!(o instanceof CTRow)) {
return null;
}
- CTRow row = (CTRow)o;
+ CTRow row = (CTRow) o;
cursor.toParent();
o = cursor.getObject();
cursor.dispose();
- if(! (o instanceof CTTbl)){
+ if (!(o instanceof CTTbl)) {
return null;
}
CTTbl tbl = (CTTbl) o;
XWPFTable table = getTable(tbl);
- if(table == null){
+ if (table == null) {
return null;
}
XWPFTableRow tableRow = table.getRow(row);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org