POI-57975: clean up white spaces and other style issues in XWPF

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1682473 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Tim Allison 2015-05-29 14:01:31 +00:00
parent 179e46232b
commit 0a914712bc
84 changed files with 6434 additions and 6255 deletions

View File

@ -35,11 +35,9 @@ import java.util.jar.JarFile;
import java.util.regex.Pattern;
import junit.framework.TestCase;
import org.junit.Test;
import org.junit.internal.TextListener;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.JUnitCore;import org.junit.runner.Result;
/**
* Build a 'lite' version of the ooxml-schemas.jar

View File

@ -58,20 +58,12 @@ public class XWPFWordExtractor extends POIXMLTextExtractor {
public XWPFWordExtractor(OPCPackage container) throws XmlException, OpenXML4JException, IOException {
this(new XWPFDocument(container));
}
public XWPFWordExtractor(XWPFDocument document) {
super(document);
this.document = document;
}
/**
* Should we also fetch the hyperlinks, when fetching
* the text content? Default is to only output the
* hyperlink label, and not the contents
*/
public void setFetchHyperlinks(boolean fetch) {
fetchHyperlinks = fetch;
}
public static void main(String[] args) throws Exception {
if (args.length < 1) {
System.err.println("Use:");
@ -86,6 +78,15 @@ public class XWPFWordExtractor extends POIXMLTextExtractor {
extractor.close();
}
/**
* Should we also fetch the hyperlinks, when fetching
* the text content? Default is to only output the
* hyperlink label, and not the contents
*/
public void setFetchHyperlinks(boolean fetch) {
fetchHyperlinks = fetch;
}
public String getText() {
StringBuffer text = new StringBuffer();
XWPFHeaderFooterPolicy hfPolicy = document.getHeaderFooterPolicy();

View File

@ -22,7 +22,6 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
* Base class for XWPF paragraphs
*
* @author Yury Batrakov (batrakov at gmail.com)
*
*/
public class XMLParagraph {
protected CTP paragraph;

View File

@ -25,7 +25,6 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTMarkupRange;
* found in paragraph to its text
*
* @author Yury Batrakov (batrakov at gmail.com)
*
*/
public class XWPFCommentsDecorator extends XWPFParagraphDecorator {
private StringBuffer commentText;
@ -41,8 +40,7 @@ public class XWPFCommentsDecorator extends XWPFParagraphDecorator {
XWPFComment comment;
commentText = new StringBuffer();
for(CTMarkupRange anchor : paragraph.getCTP().getCommentRangeStartArray())
{
for (CTMarkupRange anchor : paragraph.getCTP().getCommentRangeStartArray()) {
if ((comment = paragraph.getDocument().getCommentByID(anchor.getId().toString())) != null)
commentText.append("\tComment by " + comment.getAuthor() + ": " + comment.getText());
}

View File

@ -45,7 +45,6 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.FtrDocument;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.HdrDocument;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr.Enum;
import schemasMicrosoftComOfficeOffice.CTLock;
import schemasMicrosoftComOfficeOffice.STConnectType;
import schemasMicrosoftComVml.CTFormulas;
@ -119,8 +118,7 @@ public class XWPFHeaderFooterPolicy {
CTHdrFtrRef ref = sectPr.getFooterReferenceArray(i);
POIXMLDocumentPart relatedPart = doc.getRelationById(ref.getId());
XWPFFooter ftr = null;
if (relatedPart != null && relatedPart instanceof XWPFFooter)
{
if (relatedPart != null && relatedPart instanceof XWPFFooter) {
ftr = (XWPFFooter) relatedPart;
}
// Assign it
@ -251,8 +249,7 @@ public class XWPFHeaderFooterPolicy {
//ftr.setPArray(0, paragraphs[i].getCTP()); // MB 23 May 2010
ftr.setPArray(i, paragraphs[i].getCTP()); // MB 23 May 2010
}
}
else {
} else {
CTP p = ftr.addNewP();
byte[] rsidr = doc.getDocument().getBody().getPArray(0).getRsidR();
byte[] rsidrdefault = doc.getDocument().getBody().getPArray(0).getRsidRDefault();
@ -283,8 +280,7 @@ public class XWPFHeaderFooterPolicy {
CTP p = ftr.addNewP();
ftr.setPArray(i, paragraphs[i].getCTP());
}
}
else {
} else {
CTP p = ftr.addNewP();
byte[] rsidr = doc.getDocument().getBody().getPArray(0).getRsidR();
byte[] rsidrdefault = doc.getDocument().getBody().getPArray(0).getRsidRDefault();
@ -330,9 +326,11 @@ public class XWPFHeaderFooterPolicy {
public XWPFHeader getFirstPageHeader() {
return firstPageHeader;
}
public XWPFFooter getFirstPageFooter() {
return firstPageFooter;
}
/**
* Returns the odd page header. This is
* also the same as the default one...
@ -340,6 +338,7 @@ public class XWPFHeaderFooterPolicy {
public XWPFHeader getOddPageHeader() {
return defaultHeader;
}
/**
* Returns the odd page footer. This is
* also the same as the default one...
@ -347,15 +346,19 @@ public class XWPFHeaderFooterPolicy {
public XWPFFooter getOddPageFooter() {
return defaultFooter;
}
public XWPFHeader getEvenPageHeader() {
return evenPageHeader;
}
public XWPFFooter getEvenPageFooter() {
return evenPageFooter;
}
public XWPFHeader getDefaultHeader() {
return defaultHeader;
}
public XWPFFooter getDefaultFooter() {
return defaultFooter;
}
@ -363,6 +366,7 @@ public class XWPFHeaderFooterPolicy {
/**
* Get the header that applies to the given
* (1 based) page.
*
* @param pageNumber The one based page number
*/
public XWPFHeader getHeader(int pageNumber) {
@ -374,9 +378,11 @@ public class XWPFHeaderFooterPolicy {
}
return defaultHeader;
}
/**
* Get the footer that applies to the given
* (1 based) page.
*
* @param pageNumber The one based page number
*/
public XWPFFooter getFooter(int pageNumber) {

View File

@ -25,7 +25,7 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTText;
/**
* Decorator class for XWPFParagraph allowing to add hyperlinks
* found in paragraph to its text.
*
* <p/>
* Note - adds the hyperlink at the end, not in the right place...
*
* @deprecated Use {@link XWPFHyperlinkRun} instead
@ -65,8 +65,7 @@ public class XWPFHyperlinkDecorator extends XWPFParagraphDecorator {
}
}
public String getText()
{
public String getText() {
return super.getText() + hyperlinkText;
}
}

View File

@ -16,19 +16,16 @@
==================================================================== */
package org.apache.poi.xwpf.usermodel;
import java.util.List;
import org.apache.poi.POIXMLDocumentPart;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtPr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTString;
/**
* Experimental abstract class that is a base for XWPFSDT and XWPFSDTCell
*
* <p/>
* WARNING - APIs expected to change rapidly.
*
* <p/>
* These classes have so far been built only for read-only processing.
*
*/
public abstract class AbstractXWPFSDT implements ISDTContents {
private final String title;
@ -55,7 +52,6 @@ public abstract class AbstractXWPFSDT implements ISDTContents {
}
/**
*
* @return first SDT Title
*/
public String getTitle() {
@ -63,7 +59,6 @@ public abstract class AbstractXWPFSDT implements ISDTContents {
}
/**
*
* @return first SDT Tag
*/
public String getTag() {
@ -71,13 +66,11 @@ public abstract class AbstractXWPFSDT implements ISDTContents {
}
/**
*
* @return the content object
*/
public abstract ISDTContent getContent();
/**
*
* @return null
*/
public IBody getBody() {
@ -85,7 +78,6 @@ public abstract class AbstractXWPFSDT implements ISDTContents {
}
/**
*
* @return document part
*/
public POIXMLDocumentPart getPart() {
@ -93,7 +85,6 @@ public abstract class AbstractXWPFSDT implements ISDTContents {
}
/**
*
* @return partType
*/
public BodyType getPartType() {
@ -101,7 +92,6 @@ public abstract class AbstractXWPFSDT implements ISDTContents {
}
/**
*
* @return element type
*/
public BodyElementType getElementType() {

View File

@ -24,12 +24,11 @@ package org.apache.poi.xwpf.usermodel;
* <p>
* // TODO insert Javadoc here!
* </p>
* @author epp
*
* @author epp
*/
public enum BodyElementType {
CONTENTCONTROL,
PARAGRAPH,
TABLE,
}

View File

@ -34,6 +34,7 @@ import java.util.Map;
* element
* </li>
* </ul>
*
* @author Gisella Bronzetti
*/
public enum Borders {
@ -599,23 +600,20 @@ public enum Borders {
ZIG_ZAG_STITCH(191);
private final int value;
private Borders(int val) {
value = val;
}
public int getValue() {
return value;
}
private static Map<Integer, Borders> imap = new HashMap<Integer, Borders>();
static {
for (Borders p : values()) {
imap.put(Integer.valueOf(p.getValue()), p);
}
}
private final int value;
private Borders(int val) {
value = val;
}
public static Borders valueOf(int type) {
Borders pBorder = imap.get(Integer.valueOf(type));
if (pBorder == null) {
@ -623,4 +621,8 @@ public enum Borders {
}
return pBorder;
}
public int getValue() {
return value;
}
}

View File

@ -33,7 +33,7 @@ public enum BreakClear {
* line in the WordprocessingML document, regardless of its position left to
* right or the presence of any floating objects which intersect with the
* line,
*
* <p/>
* This is the setting for a typical line break in a document.
*/
@ -83,23 +83,20 @@ public enum BreakClear {
*/
ALL(4);
private final int value;
private BreakClear(int val) {
value = val;
}
public int getValue() {
return value;
}
private static Map<Integer, BreakClear> imap = new HashMap<Integer, BreakClear>();
static {
for (BreakClear p : values()) {
imap.put(new Integer(p.getValue()), p);
}
}
private final int value;
private BreakClear(int val) {
value = val;
}
public static BreakClear valueOf(int type) {
BreakClear bType = imap.get(new Integer(type));
if (bType == null)
@ -107,4 +104,8 @@ public enum BreakClear {
+ type);
return bType;
}
public int getValue() {
return value;
}
}

View File

@ -56,23 +56,20 @@ public enum BreakType {
*/
TEXT_WRAPPING(3);
private final int value;
private BreakType(int val) {
value = val;
}
public int getValue() {
return value;
}
private static Map<Integer, BreakType> imap = new HashMap<Integer, BreakType>();
static {
for (BreakType p : values()) {
imap.put(new Integer(p.getValue()), p);
}
}
private final int value;
private BreakType(int val) {
value = val;
}
public static BreakType valueOf(int type) {
BreakType bType = imap.get(new Integer(type));
if (bType == null)
@ -80,4 +77,8 @@ public enum BreakType {
+ type);
return bType;
}
public int getValue() {
return value;
}
}

View File

@ -17,25 +17,39 @@
package org.apache.poi.xwpf.usermodel;
public interface Document {
/** Extended windows meta file */
/**
* Extended windows meta file
*/
public static final int PICTURE_TYPE_EMF = 2;
/** Windows Meta File */
/**
* Windows Meta File
*/
public static final int PICTURE_TYPE_WMF = 3;
/** Mac PICT format */
/**
* Mac PICT format
*/
public static final int PICTURE_TYPE_PICT = 4;
/** JPEG format */
/**
* JPEG format
*/
public static final int PICTURE_TYPE_JPEG = 5;
/** PNG format */
/**
* PNG format
*/
public static final int PICTURE_TYPE_PNG = 6;
/** Device independent bitmap */
/**
* Device independent bitmap
*/
public static final int PICTURE_TYPE_DIB = 7;
/** GIF image format */
/**
* GIF image format
*/
public static final int PICTURE_TYPE_GIF = 8;
/**

View File

@ -38,6 +38,7 @@ 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();
@ -45,6 +46,7 @@ public interface IBody {
/**
* get the PartType of the body, for example
* DOCUMENT, HEADER, FOOTER, FOOTNOTE,
*
* @return the PartType of the body
*/
public BodyType getPartType();
@ -72,6 +74,7 @@ public interface IBody {
* 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
@ -82,6 +85,7 @@ public interface IBody {
* 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);
@ -98,18 +102,21 @@ public interface IBody {
/**
* 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
*/
@ -117,6 +124,7 @@ public interface IBody {
/**
* returns the TableCell to which the Table belongs
*
* @param cell
*/
public XWPFTableCell getTableCell(CTTc cell);

View File

@ -21,12 +21,15 @@ import org.apache.poi.POIXMLDocumentPart;
/**
* 9 Jan 2010
* @author Philipp Epp
*
* @author Philipp Epp
*/
public interface IBodyElement {
IBody getBody();
POIXMLDocumentPart getPart();
BodyType getPartType();
BodyElementType getElementType();
}

View File

@ -19,7 +19,7 @@ package org.apache.poi.xwpf.usermodel;
/**
* Interface for anything that can be at a table cell level:
* {@link XWPFTableCell}, {@link XWPFSDTCell}
* <p>
* <p/>
* Schematically something like this:
* &lt;tr&gt;&lt;tc/&gt;&lt;tc/&gt;&lt;sdt&gt&lt;tc/&gt;&lt;/sdt&gt;&lt;/tr&gt;
*/

View File

@ -22,10 +22,11 @@ import org.apache.poi.wp.usermodel.Paragraph;
/**
* 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();
}

View File

@ -23,8 +23,7 @@ import org.apache.poi.wp.usermodel.CharacterRun;
* 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 {
}
public interface IRunElement {}

View File

@ -20,11 +20,10 @@ package org.apache.poi.xwpf.usermodel;
/**
* 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 {

View File

@ -49,27 +49,28 @@ public enum LineSpacingRule {
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);
}
}
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;
}
}

View File

@ -40,27 +40,28 @@ public enum ParagraphAlignment {
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);
}
}
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;
}
}

View File

@ -23,8 +23,6 @@ package org.apache.poi.xwpf.usermodel;
* 1st RunPositon
* 2nd TextPosition
* 3rd CharacterPosition
*
*
*/
public class PositionInParagraph {
private int posRun = 0, posText = 0, posChar = 0;

View File

@ -52,26 +52,27 @@ public enum TextAlignment {
*/
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);
}
}
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;
}
}

View File

@ -72,6 +72,7 @@ public class TextSegement {
public void setBeginChar(int beginChar) {
beginPos.setChar(beginChar);
}
public int getEndRun() {
return endPos.getRun();
}

View File

@ -135,23 +135,20 @@ public enum UnderlinePatterns {
*/
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);
}
}
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)
@ -159,4 +156,8 @@ public enum UnderlinePatterns {
+ type);
return align;
}
public int getValue() {
return value;
}
}

View File

@ -47,23 +47,20 @@ public enum VerticalAlign {
*/
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);
}
}
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)
@ -71,4 +68,8 @@ public enum VerticalAlign {
+ type);
return align;
}
public int getValue() {
return value;
}
}

View File

@ -21,17 +21,17 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTAbstractNum;
/**
* @author Philipp Epp
*
*/
public class XWPFAbstractNum {
private CTAbstractNum ctAbstractNum;
protected XWPFNumbering numbering;
private CTAbstractNum ctAbstractNum;
protected XWPFAbstractNum() {
this.ctAbstractNum = null;
this.numbering = null;
}
public XWPFAbstractNum(CTAbstractNum abstractNum) {
this.ctAbstractNum = abstractNum;
}
@ -40,6 +40,7 @@ public class XWPFAbstractNum {
this.ctAbstractNum = ctAbstractNum;
this.numbering = numbering;
}
public CTAbstractNum getAbstractNum() {
return ctAbstractNum;
}
@ -48,12 +49,12 @@ public class XWPFAbstractNum {
return numbering;
}
public CTAbstractNum getCTAbstractNum(){
return ctAbstractNum;
}
public void setNumbering(XWPFNumbering numbering) {
this.numbering = numbering;
}
public CTAbstractNum getCTAbstractNum() {
return ctAbstractNum;
}
}

View File

@ -23,40 +23,33 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
* Sketch of XWPF comment class
*
* @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();
}
}

View File

@ -76,7 +76,7 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.StylesDocument;
/**
* <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
@ -87,12 +87,6 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.StylesDocument;
* 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(0L,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 POIXMLDocument implements Document, IBody {
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 {
@ -130,6 +131,27 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
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 {
@ -249,27 +271,6 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
}
}
/**
* 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
*/
@ -298,6 +299,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
/**
* returns an Iterator with paragraphs and tables
*
* @see org.apache.poi.xwpf.usermodel.IBody#getBodyElements()
*/
@Override
@ -337,7 +339,6 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
}
/**
*
* @return the list of footers
*/
public List<XWPFFooter> getFooterList() {
@ -349,7 +350,6 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
}
/**
*
* @return the list of headers
*/
public List<XWPFHeader> getHeaderList() {
@ -501,13 +501,11 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
* 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
*
*/
public int getParagraphPos(int pos) {
return getBodyElementSpecificPos(pos, paragraphs);
@ -516,6 +514,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
/**
* 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.
@ -635,8 +634,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
cursor.toCursor(tableCursor);
cursor.toEndToken();
return newT;
}
finally {
} finally {
tableCursor.dispose();
}
}
@ -645,6 +643,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
/**
* verifies that cursor is on the right position
*
* @param cursor
*/
private boolean isCursorInBody(XmlCursor cursor) {
@ -674,6 +673,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
/**
* Get the position of the paragraph, within the list
* of all the body elements.
*
* @param p The paragraph to find
* @return The location, or -1 if the paragraph couldn't be found
*/
@ -684,6 +684,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
/**
* Get the position of the table, within the list of
* all the body elements.
*
* @param t The table to find
* @return The location, or -1 if the table couldn't be found
*/
@ -718,6 +719,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
/**
* Gets the index of the relation we're trying to create
*
* @param relation
* @return i
*/
@ -735,6 +737,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
/**
* Appends a new paragraph to this document
*
* @return a new paragraph
*/
public XWPFParagraph createParagraph() {
@ -746,6 +749,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
/**
* Creates an empty numbering if one does not already exist and sets the numbering member
*
* @return numbering
*/
public XWPFNumbering createNumbering() {
@ -765,6 +769,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
/**
* Creates an empty styles for the document if one does not already exist
*
* @return styles
*/
public XWPFStyles createStyles() {
@ -784,6 +789,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
/**
* Creates an empty footnotes element for the document if one does not already exist
*
* @return footnotes
*/
public XWPFFootnotes createFootnotes() {
@ -813,6 +819,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
/**
* remove a BodyElement from bodyElements array list
*
* @param pos
* @return true if removing was successfully, else return false
*/
@ -837,6 +844,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
/**
* 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 POIXMLDocument implements Document, IBody {
/**
* Create an empty table with one row and one column as default.
*
* @return a new table
*/
public XWPFTable createTable() {
@ -870,6 +879,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
/**
* Create an empty table with a number of rows and cols specified
*
* @param rows
* @param cols
* @return table
@ -900,7 +910,9 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
}
}
/**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
*/
@ -1148,7 +1160,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
* 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")
*
* <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?"
@ -1180,6 +1192,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
/**
* inserts an existing XWPFTable to the arrays bodyElements and tables
*
* @param pos
* @param table
*/
@ -1199,6 +1212,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
/**
* 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 POIXMLDocument implements Document, IBody {
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;
/*
@ -1250,13 +1262,11 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
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);
@ -1280,9 +1290,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
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
@ -1298,16 +1306,13 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
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,6 +1323,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
/**
* get the next free ImageNumber
*
* @param format
* @return the next free ImageNumber
* @throws InvalidFormatException
@ -1336,6 +1342,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
/**
* returns the PictureData by blipID
*
* @param blipID
* @return XWPFPictureData of a specificID
*/
@ -1350,6 +1357,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
/**
* getNumbering
*
* @return numbering
*/
public XWPFNumbering getNumbering() {
@ -1358,6 +1366,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
/**
* get Styles
*
* @return styles for this document
*/
public XWPFStyles getStyles() {
@ -1382,9 +1391,10 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
/**
* 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 POIXMLDocument implements Document, IBody {
/**
* 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 POIXMLDocument implements Document, 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.
*
* @see org.apache.poi.xwpf.usermodel.IBody#getPart()
*/
@Override
@ -1441,6 +1453,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
/**
* get the TableCell which belongs to the TableCell
*
* @param cell
*/
@Override

View File

@ -34,13 +34,12 @@ import org.apache.poi.util.POILogger;
public final class XWPFFactory extends POIXMLFactory {
private static final POILogger logger = POILogFactory.getLogger(XWPFFactory.class);
private static final XWPFFactory inst = new XWPFFactory();
private XWPFFactory() {
}
private static final XWPFFactory inst = new XWPFFactory();
public static XWPFFactory getInstance() {
return inst;
}

View File

@ -133,6 +133,7 @@ public class XWPFFooter extends XWPFHeaderFooter {
/**
* get the PartType of the body
*
* @see org.apache.poi.xwpf.usermodel.IBody#getPartType()
*/
public BodyType getPartType() {

View File

@ -119,6 +119,7 @@ public class XWPFFootnote implements Iterable<XWPFParagraph>,IBody {
/**
* inserts an existing XWPFTable to the arrays bodyElements and tables
*
* @param pos
* @param table
* @see org.apache.poi.xwpf.usermodel.IBody#insertTable(int pos, XWPFTable table)
@ -141,6 +142,7 @@ public class XWPFFootnote implements Iterable<XWPFParagraph>,IBody {
* 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
* @see org.apache.poi.xwpf.usermodel.IBody#getTable(CTTbl ctTable)
*/
@ -158,6 +160,7 @@ public class XWPFFootnote implements Iterable<XWPFParagraph>,IBody {
* 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
@ -174,6 +177,7 @@ public class XWPFFootnote implements Iterable<XWPFParagraph>,IBody {
/**
* Returns the paragraph that holds
* the text of the header or footer.
*
* @see org.apache.poi.xwpf.usermodel.IBody#getParagraphArray(int pos)
*/
public XWPFParagraph getParagraphArray(int pos) {
@ -183,6 +187,7 @@ public class XWPFFootnote implements Iterable<XWPFParagraph>,IBody {
/**
* get the TableCell which belongs to the TableCell
*
* @param cell
* @see org.apache.poi.xwpf.usermodel.IBody#getTableCell(CTTc cell)
*/
@ -214,6 +219,7 @@ public class XWPFFootnote implements Iterable<XWPFParagraph>,IBody {
/**
* verifies that cursor is on the right position
*
* @param cursor
*/
private boolean isCursorInFtn(XmlCursor cursor) {
@ -230,7 +236,6 @@ public class XWPFFootnote implements Iterable<XWPFParagraph>,IBody {
}
/**
*
* @param cursor
* @return the inserted table
* @see org.apache.poi.xwpf.usermodel.IBody#insertNewTbl(XmlCursor cursor)
@ -250,8 +255,7 @@ public class XWPFFootnote implements Iterable<XWPFParagraph>,IBody {
}
if (!(o instanceof CTTbl)) {
tables.add(0, newT);
}
else{
} else {
int pos = tables.indexOf(getTable((CTTbl) o)) + 1;
tables.add(pos, newT);
}
@ -272,6 +276,7 @@ public class XWPFFootnote implements Iterable<XWPFParagraph>,IBody {
/**
* add a new paragraph at position of the cursor
*
* @param cursor
* @return the inserted paragraph
* @see org.apache.poi.xwpf.usermodel.IBody#insertNewParagraph(XmlCursor cursor)
@ -290,8 +295,7 @@ public class XWPFFootnote implements Iterable<XWPFParagraph>,IBody {
}
if ((!(o instanceof CTP)) || (CTP) o == p) {
paragraphs.add(0, newP);
}
else{
} else {
int pos = paragraphs.indexOf(getParagraph((CTP) o)) + 1;
paragraphs.add(pos, newP);
}
@ -312,6 +316,7 @@ public class XWPFFootnote implements Iterable<XWPFParagraph>,IBody {
/**
* add a new table to the end of the footnote
*
* @param table
* @return the added XWPFTable
*/
@ -325,6 +330,7 @@ public class XWPFFootnote implements Iterable<XWPFParagraph>,IBody {
/**
* add a new paragraph to the end of the footnote
*
* @param paragraph
* @return the added XWPFParagraph
*/
@ -345,6 +351,7 @@ public class XWPFFootnote implements Iterable<XWPFParagraph>,IBody {
/**
* returns the Part, to which the body belongs, which you need for adding relationship to other parts
*
* @see org.apache.poi.xwpf.usermodel.IBody#getPart()
*/
public POIXMLDocumentPart getPart() {
@ -353,6 +360,7 @@ public class XWPFFootnote implements Iterable<XWPFParagraph>,IBody {
/**
* get the PartType of the body
*
* @see org.apache.poi.xwpf.usermodel.IBody#getPartType()
*/
public BodyType getPartType() {

View File

@ -34,19 +34,18 @@ import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlOptions;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFtnEdn;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFootnotes;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFtnEdn;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.FootnotesDocument;
/**
* Looks after the collection of Footnotes for a document
*/
public class XWPFFootnotes extends POIXMLDocumentPart {
protected XWPFDocument document;
private List<XWPFFootnote> listFootnote = new ArrayList<XWPFFootnote>();
private CTFootnotes ctFootnotes;
protected XWPFDocument document;
/**
* Construct XWPFFootnotes from a package part
*
@ -112,6 +111,7 @@ public class XWPFFootnotes extends POIXMLDocumentPart {
/**
* Sets the ctFootnotes
*
* @param footnotes
*/
public void setFootnotes(CTFootnotes footnotes) {
@ -120,6 +120,7 @@ public class XWPFFootnotes extends POIXMLDocumentPart {
/**
* add an XWPFFootnote to the document
*
* @param footnote
* @throws IOException
*/
@ -130,6 +131,7 @@ public class XWPFFootnotes extends POIXMLDocumentPart {
/**
* add a footnote to the document
*
* @param note
* @throws IOException
*/
@ -141,10 +143,6 @@ public class XWPFFootnotes extends POIXMLDocumentPart {
return xNote;
}
public void setXWPFDocument(XWPFDocument doc) {
document = doc;
}
/**
* @see org.apache.poi.xwpf.usermodel.IBody#getPart()
*/
@ -155,4 +153,8 @@ public class XWPFFootnotes extends POIXMLDocumentPart {
return (XWPFDocument) getParent();
}
}
public void setXWPFDocument(XWPFDocument doc) {
document = doc;
}
}

View File

@ -95,6 +95,7 @@ public class XWPFHeader extends XWPFHeaderFooter {
/**
* reads the document
*
* @throws IOException
*/
@Override
@ -135,6 +136,7 @@ public class XWPFHeader extends XWPFHeaderFooter {
/**
* get the PartType of the body
*
* @see org.apache.poi.xwpf.usermodel.IBody#getPartType()
*/
public BodyType getPartType() {

View File

@ -122,7 +122,6 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo
}
/**
* Returns the textual content of the header/footer,
* by flattening out the text of its paragraph(s)
@ -169,6 +168,7 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo
* 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) {
@ -185,6 +185,7 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo
* 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
@ -209,6 +210,7 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo
/**
* get a List of all Paragraphs
*
* @return a list of {@link XWPFParagraph}
*/
public List<XWPFParagraph> getListParagraph() {
@ -221,6 +223,7 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo
/**
* get all Pictures in this package
*
* @return all Pictures in this package
*/
public List<XWPFPictureData> getAllPackagePictures() {
@ -233,17 +236,14 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo
*
* @param pictureData The picture data
* @param format The format of the picture.
*
* @return the index to this picture (0 based), the added picture can be obtained from {@link #getAllPictures()} .
* @throws InvalidFormatException
*/
public String addPictureData(byte[] pictureData,int format) throws InvalidFormatException
{
public String addPictureData(byte[] pictureData, int format) throws InvalidFormatException {
XWPFPictureData xwpfPicData = document.findPackagePictureData(pictureData, format);
POIXMLRelation relDesc = XWPFPictureData.RELATIONS[format];
if (xwpfPicData == null)
{
if (xwpfPicData == null) {
/* Part doesn't exist, create a new one */
int idx = document.getNextPicNameNumber(format);
xwpfPicData = (XWPFPictureData) createRelationship(relDesc, XWPFFactory.getInstance(), idx);
@ -266,9 +266,7 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo
document.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
@ -284,9 +282,7 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo
addRelation(id, xwpfPicData);
pictures.add(xwpfPicData);
return id;
}
else
{
} else {
/* Part already existed, get relation id and return it */
return getRelationId(xwpfPicData);
}
@ -297,7 +293,6 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo
*
* @param is The stream to read image from
* @param format The format of the picture.
*
* @return the index to this picture (0 based), the added picture can be obtained from {@link #getAllPictures()} .
* @throws InvalidFormatException
* @throws IOException
@ -309,6 +304,7 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo
/**
* returns the PictureData by blipID
*
* @param blipID
* @return XWPFPictureData of a specificID
* @throws Exception
@ -323,6 +319,7 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo
/**
* add a new paragraph at position of the cursor
*
* @param cursor
* @return the inserted paragraph
*/
@ -340,8 +337,7 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo
}
if ((!(o instanceof CTP)) || (CTP) o == p) {
paragraphs.add(0, newP);
}
else{
} else {
int pos = paragraphs.indexOf(getParagraph((CTP) o)) + 1;
paragraphs.add(pos, newP);
}
@ -362,7 +358,6 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo
/**
*
* @param cursor
* @return the inserted table
*/
@ -381,8 +376,7 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo
}
if (!(o instanceof CTTbl)) {
tables.add(0, newT);
}
else{
} else {
int pos = tables.indexOf(getTable((CTTbl) o)) + 1;
tables.add(pos, newT);
}
@ -403,6 +397,7 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo
/**
* verifies that cursor is on the right position
*
* @param cursor
*/
private boolean isCursorInHdrF(XmlCursor cursor) {
@ -421,6 +416,7 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo
/**
* Returns the table at position pos
*
* @see org.apache.poi.xwpf.usermodel.IBody#getTableArray(int)
*/
public XWPFTable getTableArray(int pos) {
@ -433,6 +429,7 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo
/**
* inserts an existing XWPFTable to the arrays bodyElements and tables
*
* @param pos
* @param table
*/
@ -476,6 +473,7 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo
/**
* get the TableCell which belongs to the TableCell
*
* @param cell
*/
public XWPFTableCell getTableCell(CTTc cell) {
@ -504,10 +502,6 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo
return tableRow.getTableCell(cell);
}
public void setXWPFDocument(XWPFDocument doc) {
document = doc;
}
public XWPFDocument getXWPFDocument() {
if (document != null) {
return document;
@ -516,8 +510,13 @@ public abstract class XWPFHeaderFooter extends POIXMLDocumentPart implements IBo
}
}
public void setXWPFDocument(XWPFDocument doc) {
document = doc;
}
/**
* returns the Part, to which the body belongs, which you need for adding relationship to other parts
*
* @see org.apache.poi.xwpf.usermodel.IBody#getPart()
*/
public POIXMLDocumentPart getPart() {

View File

@ -20,24 +20,20 @@ package org.apache.poi.xwpf.usermodel;
* Sketch of XWPF hyperlink class
*
* @author Yury Batrakov (batrakov at gmail.com)
*
*/
public class XWPFHyperlink
{
public class XWPFHyperlink {
String id, url;
public XWPFHyperlink(String id, String url)
{
public XWPFHyperlink(String id, String url) {
this.id = id;
this.url = url;
}
public String getId()
{
public String getId() {
return id;
}
public String getURL()
{
public String getURL() {
return url;
}
}

View File

@ -23,8 +23,7 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR;
* A run of text with a Hyperlink applied to it.
* Any given Hyperlink may be made up of multiple of these.
*/
public class XWPFHyperlinkRun extends XWPFRun
{
public class XWPFHyperlinkRun extends XWPFRun {
private CTHyperlink hyperlink;
public XWPFHyperlinkRun(CTHyperlink hyperlink, CTR run, IRunBody p) {
@ -46,6 +45,7 @@ public class XWPFHyperlinkRun extends XWPFRun
public String getHyperlinkId() {
return hyperlink.getId();
}
public void setHyperlinkId(String id) {
hyperlink.setId(id);
}

View File

@ -20,8 +20,8 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLatentStyles;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLsdException;
public class XWPFLatentStyles {
private CTLatentStyles latentStyles;
protected XWPFStyles styles; //LatentStyle shall know styles
private CTLatentStyles latentStyles;
protected XWPFLatentStyles() {
}

View File

@ -21,11 +21,10 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTNum;
/**
* @author Philipp Epp
*
*/
public class XWPFNum {
private CTNum ctNum;
protected XWPFNumbering numbering;
private CTNum ctNum;
public XWPFNum() {
this.ctNum = null;
@ -51,14 +50,14 @@ public class XWPFNum {
return numbering;
}
public CTNum getCTNum(){
return ctNum;
}
public void setNumbering(XWPFNumbering numbering) {
this.numbering = numbering;
}
public CTNum getCTNum() {
return ctNum;
}
public void setCTNum(CTNum ctNum) {
this.ctNum = ctNum;
}

View File

@ -41,14 +41,12 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.NumberingDocument;
/**
* @author Philipp Epp
*
*/
public class XWPFNumbering extends POIXMLDocumentPart {
protected List<XWPFAbstractNum> abstractNums = new ArrayList<XWPFAbstractNum>();
protected List<XWPFNum> nums = new ArrayList<XWPFNum>();
private CTNumbering ctNumbering;
boolean isNew;
private CTNumbering ctNumbering;
/**
* create a new styles object with an existing document
@ -119,6 +117,7 @@ public class XWPFNumbering extends POIXMLDocumentPart {
/**
* Sets the ctNumbering
*
* @param numbering
*/
public void setNumbering(CTNumbering numbering) {
@ -128,6 +127,7 @@ public class XWPFNumbering extends POIXMLDocumentPart {
/**
* Checks whether number with numID exists
*
* @param numID
* @return boolean true if num exist, false if num not exist
*/
@ -141,6 +141,7 @@ public class XWPFNumbering extends POIXMLDocumentPart {
/**
* add a new number to the numbering document
*
* @param num
*/
public BigInteger addNum(XWPFNum num) {
@ -153,6 +154,7 @@ public class XWPFNumbering extends POIXMLDocumentPart {
/**
* Add a new num with an abstractNumID
*
* @return return NumId of the added num
*/
public BigInteger addNum(BigInteger abstractNumID) {
@ -167,6 +169,7 @@ public class XWPFNumbering extends POIXMLDocumentPart {
/**
* Add a new num with an abstractNumID and a numID
*
* @param abstractNumID
* @param numID
*/
@ -181,6 +184,7 @@ public class XWPFNumbering extends POIXMLDocumentPart {
/**
* get Num by NumID
*
* @param numID
* @return abstractNum with NumId if no Num exists with that NumID
* null will be returned
@ -192,8 +196,10 @@ public class XWPFNumbering extends POIXMLDocumentPart {
}
return null;
}
/**
* get AbstractNum by abstractNumID
*
* @param abstractNumID
* @return abstractNum with abstractNumId if no abstractNum exists with that abstractNumID
* null will be returned
@ -206,6 +212,7 @@ public class XWPFNumbering extends POIXMLDocumentPart {
}
return null;
}
/**
* Compare AbstractNum with abstractNums of this numbering document.
* If the content of abstractNum equals with an abstractNum of the List in numbering
@ -232,6 +239,7 @@ public class XWPFNumbering extends POIXMLDocumentPart {
/**
* add a new AbstractNum and return its AbstractNumID
*
* @param abstractNum
*/
public BigInteger addAbstractNum(XWPFAbstractNum abstractNum) {
@ -249,6 +257,7 @@ public class XWPFNumbering extends POIXMLDocumentPart {
/**
* remove an existing abstractNum
*
* @param abstractNumID
* @return true if abstractNum with abstractNumID exists in NumberingArray,
* false if abstractNum with abstractNumID not exists
@ -261,10 +270,12 @@ public class XWPFNumbering extends POIXMLDocumentPart {
}
return false;
}
/**
* return the abstractNumID
* If the AbstractNumID not exists
* return null
*
* @param numID
* @return abstractNumID
*/

View File

@ -20,6 +20,7 @@ import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.poi.POIXMLDocumentPart;
import org.apache.poi.util.Internal;
import org.apache.poi.wp.usermodel.Paragraph;
@ -59,7 +60,7 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTextAlignment;
/**
* <p>A Paragraph within a Document, Table, Header etc.</p>
*
* <p/>
* <p>A paragraph has a lot of styling information, but the
* actual text (possibly along with more styling) is held on
* the child {@link XWPFRun}s.</p>
@ -67,7 +68,9 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTextAlignment;
public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Paragraph {
private final CTP paragraph;
protected IBody part;
/** For access to the document's hyperlink, comments, tables etc */
/**
* For access to the document's hyperlink, comments, tables etc
*/
protected XWPFDocument document;
protected List<XWPFRun> runs;
protected List<IRunElement> iruns;
@ -188,6 +191,7 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
/**
* Return literal runs and sdt/content control objects.
*
* @return List<IRunElement>
*/
public List<IRunElement> getIRuns() {
@ -222,6 +226,7 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
/**
* Return styleID of the paragraph if style exist for this paragraph
* if not, null will be returned
*
* @return styleID as String
*/
public String getStyleID() {
@ -233,10 +238,12 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
}
return null;
}
/**
* If style exist for this paragraph
* NumId of the paragraph will be returned.
* If style not exist null will be returned
*
* @return NumID as BigInteger
*/
public BigInteger getNumID() {
@ -249,9 +256,26 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
return null;
}
/**
* setNumID of Paragraph
*
* @param numPos
*/
public void setNumID(BigInteger numPos) {
if (paragraph.getPPr() == null)
paragraph.addNewPPr();
if (paragraph.getPPr().getNumPr() == null)
paragraph.getPPr().addNewNumPr();
if (paragraph.getPPr().getNumPr().getNumId() == null) {
paragraph.getPPr().getNumPr().addNewNumId();
}
paragraph.getPPr().getNumPr().getNumId().setVal(numPos);
}
/**
* Returns Ilvl of the numeric style for this paragraph.
* Returns null if this paragraph does not have numeric style.
*
* @return Ilvl as BigInteger
*/
public BigInteger getNumIlvl() {
@ -344,9 +368,9 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
return null;
}
/**
* Gets the numstartOverride for the paragraph numbering for this paragraph.
*
* @return returns the overridden start number or null if there is no override for this paragraph.
*/
public BigInteger getNumStartOverride() {
@ -377,20 +401,6 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
}
return null;
}
/**
* setNumID of Paragraph
* @param numPos
*/
public void setNumID(BigInteger numPos) {
if(paragraph.getPPr()==null)
paragraph.addNewPPr();
if(paragraph.getPPr().getNumPr()==null)
paragraph.getPPr().addNewNumPr();
if(paragraph.getPPr().getNumPr().getNumId()==null){
paragraph.getPPr().getNumPr().addNewNumId();
}
paragraph.getPPr().getNumPr().getNumId().setVal(numPos);
}
/**
* Returns the text of the paragraph, but not of any objects in the
@ -471,6 +481,7 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
public int getFontAlignment() {
return getAlignment().getValue();
}
public void setFontAlignment(int align) {
ParagraphAlignment pAlign = ParagraphAlignment.valueOf(align);
setAlignment(pAlign);
@ -529,6 +540,24 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
textAlignment.setVal(en);
}
/**
* Specifies the border which shall be displayed above a set of paragraphs
* which have the same set of paragraph border settings.
*
* @return paragraphBorder - the top border for the paragraph
* @see #setBorderTop(Borders)
* @see Borders a list of all types of borders
*/
public Borders getBorderTop() {
CTPBdr border = getCTPBrd(false);
CTBorder ct = null;
if (border != null) {
ct = border.getTop();
}
STBorder.Enum ptrn = (ct != null) ? ct.getVal() : STBorder.NONE;
return Borders.valueOf(ptrn.intValue());
}
/**
* Specifies the border which shall be displayed above a set of paragraphs
* which have the same set of paragraph border settings.
@ -570,20 +599,20 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
}
/**
* Specifies the border which shall be displayed above a set of paragraphs
* which have the same set of paragraph border settings.
* Specifies the border which shall be displayed below a set of
* paragraphs which have the same set of paragraph border settings.
*
* @return paragraphBorder - the top border for the paragraph
* @see #setBorderTop(Borders)
* @return paragraphBorder - the bottom border for the paragraph
* @see #setBorderBottom(Borders)
* @see Borders a list of all types of borders
*/
public Borders getBorderTop() {
public Borders getBorderBottom() {
CTPBdr border = getCTPBrd(false);
CTBorder ct = null;
if (border != null) {
ct = border.getTop();
ct = border.getBottom();
}
STBorder.Enum ptrn = (ct != null) ? ct.getVal() : STBorder.NONE;
STBorder.Enum ptrn = ct != null ? ct.getVal() : STBorder.NONE;
return Borders.valueOf(ptrn.intValue());
}
@ -624,18 +653,18 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
}
/**
* Specifies the border which shall be displayed below a set of
* paragraphs which have the same set of paragraph border settings.
* Specifies the border which shall be displayed on the left side of the
* page around the specified paragraph.
*
* @return paragraphBorder - the bottom border for the paragraph
* @see #setBorderBottom(Borders)
* @see Borders a list of all types of borders
* @return ParagraphBorder - the left border for the paragraph
* @see #setBorderLeft(Borders)
* @see Borders for a list of all possible borders
*/
public Borders getBorderBottom() {
public Borders getBorderLeft() {
CTPBdr border = getCTPBrd(false);
CTBorder ct = null;
if (border != null) {
ct = border.getBottom();
ct = border.getLeft();
}
STBorder.Enum ptrn = ct != null ? ct.getVal() : STBorder.NONE;
return Borders.valueOf(ptrn.intValue());
@ -673,18 +702,18 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
}
/**
* Specifies the border which shall be displayed on the left side of the
* Specifies the border which shall be displayed on the right side of the
* page around the specified paragraph.
*
* @return ParagraphBorder - the left border for the paragraph
* @see #setBorderLeft(Borders)
* @return ParagraphBorder - the right border for the paragraph
* @see #setBorderRight(Borders)
* @see Borders for a list of all possible borders
*/
public Borders getBorderLeft() {
public Borders getBorderRight() {
CTPBdr border = getCTPBrd(false);
CTBorder ct = null;
if (border != null) {
ct = border.getLeft();
ct = border.getRight();
}
STBorder.Enum ptrn = ct != null ? ct.getVal() : STBorder.NONE;
return Borders.valueOf(ptrn.intValue());
@ -722,18 +751,18 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
}
/**
* Specifies the border which shall be displayed on the right side of the
* page around the specified paragraph.
* Specifies the border which shall be displayed between each paragraph in a
* set of paragraphs which have the same set of paragraph border settings.
*
* @return ParagraphBorder - the right border for the paragraph
* @see #setBorderRight(Borders)
* @return ParagraphBorder - the between border for the paragraph
* @see #setBorderBetween(Borders)
* @see Borders for a list of all possible borders
*/
public Borders getBorderRight() {
public Borders getBorderBetween() {
CTPBdr border = getCTPBrd(false);
CTBorder ct = null;
if (border != null) {
ct = border.getRight();
ct = border.getBetween();
}
STBorder.Enum ptrn = ct != null ? ct.getVal() : STBorder.NONE;
return Borders.valueOf(ptrn.intValue());
@ -775,21 +804,29 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
}
/**
* Specifies the border which shall be displayed between each paragraph in a
* set of paragraphs which have the same set of paragraph border settings.
* Specifies that when rendering this document in a paginated
* view, the contents of this paragraph are rendered on the start of a new
* page in the document.
* <p/>
* If this element is omitted on a given paragraph,
* its value is determined by the setting previously set at any level of the
* style hierarchy (i.e. that previous setting remains unchanged). If this
* setting is never specified in the style hierarchy, then this property
* shall not be applied. Since the paragraph is specified to start on a new
* page, it begins page two even though it could have fit on page one.
* </p>
*
* @return ParagraphBorder - the between border for the paragraph
* @see #setBorderBetween(Borders)
* @see Borders for a list of all possible borders
* @return boolean - if page break is set
*/
public Borders getBorderBetween() {
CTPBdr border = getCTPBrd(false);
CTBorder ct = null;
if (border != null) {
ct = border.getBetween();
public boolean isPageBreak() {
CTPPr ppr = getCTPPr();
CTOnOff ct_pageBreak = ppr.isSetPageBreakBefore() ? ppr
.getPageBreakBefore() : null;
if (ct_pageBreak != null
&& ct_pageBreak.getVal().intValue() == STOnOff.INT_TRUE) {
return true;
}
STBorder.Enum ptrn = ct != null ? ct.getVal() : STBorder.NONE;
return Borders.valueOf(ptrn.intValue());
return false;
}
/**
@ -819,29 +856,14 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
}
/**
* Specifies that when rendering this document in a paginated
* view, the contents of this paragraph are rendered on the start of a new
* page in the document.
* <p/>
* If this element is omitted on a given paragraph,
* its value is determined by the setting previously set at any level of the
* style hierarchy (i.e. that previous setting remains unchanged). If this
* setting is never specified in the style hierarchy, then this property
* shall not be applied. Since the paragraph is specified to start on a new
* page, it begins page two even though it could have fit on page one.
* </p>
* Specifies the spacing that should be added after the last line in this
* paragraph in the document in absolute units.
*
* @return boolean - if page break is set
* @return int - value representing the spacing after the paragraph
*/
public boolean isPageBreak() {
CTPPr ppr = getCTPPr();
CTOnOff ct_pageBreak = ppr.isSetPageBreakBefore() ? ppr
.getPageBreakBefore() : null;
if (ct_pageBreak != null
&& ct_pageBreak.getVal().intValue() == STOnOff.INT_TRUE) {
return true;
}
return false;
public int getSpacingAfter() {
CTSpacing spacing = getCTSpacing(false);
return (spacing != null && spacing.isSetAfter()) ? spacing.getAfter().intValue() : -1;
}
/**
@ -869,11 +891,12 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
* Specifies the spacing that should be added after the last line in this
* paragraph in the document in absolute units.
*
* @return int - value representing the spacing after the paragraph
* @return bigInteger - value representing the spacing after the paragraph
* @see #setSpacingAfterLines(int)
*/
public int getSpacingAfter() {
public int getSpacingAfterLines() {
CTSpacing spacing = getCTSpacing(false);
return (spacing != null && spacing.isSetAfter()) ? spacing.getAfter().intValue() : -1;
return (spacing != null && spacing.isSetAfterLines()) ? spacing.getAfterLines().intValue() : -1;
}
/**
@ -899,20 +922,18 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
spacing.setAfterLines(bi);
}
/**
* Specifies the spacing that should be added after the last line in this
* Specifies the spacing that should be added above the first line in this
* paragraph in the document in absolute units.
*
* @return bigInteger - value representing the spacing after the paragraph
* @see #setSpacingAfterLines(int)
* @return the spacing that should be added above the first line
* @see #setSpacingBefore(int)
*/
public int getSpacingAfterLines() {
public int getSpacingBefore() {
CTSpacing spacing = getCTSpacing(false);
return (spacing != null && spacing.isSetAfterLines()) ? spacing.getAfterLines().intValue() : -1;
return (spacing != null && spacing.isSetBefore()) ? spacing.getBefore().intValue() : -1;
}
/**
* Specifies the spacing that should be added above the first line in this
* paragraph in the document in absolute units.
@ -930,15 +951,16 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
}
/**
* Specifies the spacing that should be added above the first line in this
* paragraph in the document in absolute units.
* Specifies the spacing that should be added before the first line in this paragraph in the
* document in line units.
* The value of this attribute is specified in one hundredths of a line.
*
* @return the spacing that should be added above the first line
* @see #setSpacingBefore(int)
* @return the spacing that should be added before the first line in this paragraph
* @see #setSpacingBeforeLines(int)
*/
public int getSpacingBefore() {
public int getSpacingBeforeLines() {
CTSpacing spacing = getCTSpacing(false);
return (spacing != null && spacing.isSetBefore()) ? spacing.getBefore().intValue() : -1;
return (spacing != null && spacing.isSetBeforeLines()) ? spacing.getBeforeLines().intValue() : -1;
}
/**
@ -959,33 +981,6 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
spacing.setBeforeLines(bi);
}
/**
* Specifies the spacing that should be added before the first line in this paragraph in the
* document in line units.
* The value of this attribute is specified in one hundredths of a line.
*
* @return the spacing that should be added before the first line in this paragraph
* @see #setSpacingBeforeLines(int)
*/
public int getSpacingBeforeLines() {
CTSpacing spacing = getCTSpacing(false);
return (spacing != null && spacing.isSetBeforeLines()) ? spacing.getBeforeLines().intValue() : -1;
}
/**
* Specifies how the spacing between lines is calculated as stored in the
* line attribute. If this attribute is omitted, then it shall be assumed to
* be of a value auto if a line attribute value is present.
*
* @param rule
* @see LineSpacingRule
*/
public void setSpacingLineRule(LineSpacingRule rule) {
CTSpacing spacing = getCTSpacing(true);
spacing.setLineRule(STLineSpacingRule.Enum.forInt(rule.getValue()));
}
/**
* Specifies how the spacing between lines is calculated as stored in the
* line attribute. If this attribute is omitted, then it shall be assumed to
@ -1001,24 +996,17 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
.getLineRule().intValue()) : LineSpacingRule.AUTO;
}
/**
* Specifies the indentation which shall be placed between the left text
* margin for this paragraph and the left edge of that paragraph's content
* in a left to right paragraph, and the right text margin and the right
* edge of that paragraph's text in a right to left paragraph
* <p/>
* If this attribute is omitted, its value shall be assumed to be zero.
* Negative values are defined such that the text is moved past the text margin,
* positive values move the text inside the text margin.
* </p>
* Specifies how the spacing between lines is calculated as stored in the
* line attribute. If this attribute is omitted, then it shall be assumed to
* be of a value auto if a line attribute value is present.
*
* @param indentation
* @param rule
* @see LineSpacingRule
*/
public void setIndentationLeft(int indentation) {
CTInd indent = getCTInd(true);
BigInteger bi = new BigInteger("" + indentation);
indent.setLeft(bi);
public void setSpacingLineRule(LineSpacingRule rule) {
CTSpacing spacing = getCTSpacing(true);
spacing.setLineRule(STLineSpacingRule.Enum.forInt(rule.getValue()));
}
/**
@ -1041,8 +1029,8 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
}
/**
* Specifies the indentation which shall be placed between the right text
* margin for this paragraph and the right edge of that paragraph's content
* Specifies the indentation which shall be placed between the left text
* margin for this paragraph and the left edge of that paragraph's content
* in a left to right paragraph, and the right text margin and the right
* edge of that paragraph's text in a right to left paragraph
* <p/>
@ -1053,10 +1041,10 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
*
* @param indentation
*/
public void setIndentationRight(int indentation) {
public void setIndentationLeft(int indentation) {
CTInd indent = getCTInd(true);
BigInteger bi = new BigInteger("" + indentation);
indent.setRight(bi);
indent.setLeft(bi);
}
/**
@ -1080,23 +1068,22 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
}
/**
* Specifies the indentation which shall be removed from the first line of
* the parent paragraph, by moving the indentation on the first line back
* towards the beginning of the direction of text flow.
* This indentation is specified relative to the paragraph indentation which is specified for
* all other lines in the parent paragraph.
* Specifies the indentation which shall be placed between the right text
* margin for this paragraph and the right edge of that paragraph's content
* in a left to right paragraph, and the right text margin and the right
* edge of that paragraph's text in a right to left paragraph
* <p/>
* The firstLine and hanging attributes are mutually exclusive, if both are specified, then the
* firstLine value is ignored.
* If this attribute is omitted, its value shall be assumed to be zero.
* Negative values are defined such that the text is moved past the text margin,
* positive values move the text inside the text margin.
* </p>
*
* @param indentation
*/
public void setIndentationHanging(int indentation) {
public void setIndentationRight(int indentation) {
CTInd indent = getCTInd(true);
BigInteger bi = new BigInteger("" + indentation);
indent.setHanging(bi);
indent.setRight(bi);
}
/**
@ -1118,23 +1105,23 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
}
/**
* Specifies the additional indentation which shall be applied to the first
* line of the parent paragraph. This additional indentation is specified
* relative to the paragraph indentation which is specified for all other
* lines in the parent paragraph.
* The firstLine and hanging attributes are
* mutually exclusive, if both are specified, then the firstLine value is
* ignored.
* If the firstLineChars attribute is also specified, then this
* value is ignored. If this attribute is omitted, then its value shall be
* assumed to be zero (if needed).
* Specifies the indentation which shall be removed from the first line of
* the parent paragraph, by moving the indentation on the first line back
* towards the beginning of the direction of text flow.
* This indentation is specified relative to the paragraph indentation which is specified for
* all other lines in the parent paragraph.
* <p/>
* The firstLine and hanging attributes are mutually exclusive, if both are specified, then the
* firstLine value is ignored.
* </p>
*
* @param indentation
*/
public void setIndentationFirstLine(int indentation) {
public void setIndentationHanging(int indentation) {
CTInd indent = getCTInd(true);
BigInteger bi = new BigInteger("" + indentation);
indent.setFirstLine(bi);
indent.setHanging(bi);
}
/**
@ -1158,9 +1145,30 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
: -1;
}
/**
* Specifies the additional indentation which shall be applied to the first
* line of the parent paragraph. This additional indentation is specified
* relative to the paragraph indentation which is specified for all other
* lines in the parent paragraph.
* The firstLine and hanging attributes are
* mutually exclusive, if both are specified, then the firstLine value is
* ignored.
* If the firstLineChars attribute is also specified, then this
* value is ignored. If this attribute is omitted, then its value shall be
* assumed to be zero (if needed).
*
* @param indentation
*/
public void setIndentationFirstLine(int indentation) {
CTInd indent = getCTInd(true);
BigInteger bi = new BigInteger("" + indentation);
indent.setFirstLine(bi);
}
public int getIndentFromLeft() {
return getIndentFromLeft();
}
public void setIndentFromLeft(int dxaLeft) {
setIndentationLeft(dxaLeft);
}
@ -1168,6 +1176,7 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
public int getIndentFromRight() {
return getIndentFromRight();
}
public void setIndentFromRight(int dxaRight) {
setIndentationRight(dxaRight);
}
@ -1175,31 +1184,11 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
public int getFirstLineIndent() {
return getIndentationFirstLine();
}
public void setFirstLineIndent(int first) {
setIndentationFirstLine(first);
}
/**
* This element specifies whether a consumer shall break Latin text which
* exceeds the text extents of a line by breaking the word across two lines
* (breaking on the character level) or by moving the word to the following
* line (breaking on the word level).
*
* @param wrap - boolean
*/
public void setWordWrapped(boolean wrap) {
CTOnOff wordWrap = getCTPPr().isSetWordWrap() ? getCTPPr()
.getWordWrap() : getCTPPr().addNewWordWrap();
if (wrap)
wordWrap.setVal(STOnOff.TRUE);
else
wordWrap.unsetVal();
}
@Deprecated
public void setWordWrap(boolean wrap) {
setWordWrapped(wrap);
}
/**
* This element specifies whether a consumer shall break Latin text which
* exceeds the text extents of a line by breaking the word across two lines
@ -1218,19 +1207,31 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
}
return false;
}
/**
* This element specifies whether a consumer shall break Latin text which
* exceeds the text extents of a line by breaking the word across two lines
* (breaking on the character level) or by moving the word to the following
* line (breaking on the word level).
*
* @param wrap - boolean
*/
public void setWordWrapped(boolean wrap) {
CTOnOff wordWrap = getCTPPr().isSetWordWrap() ? getCTPPr()
.getWordWrap() : getCTPPr().addNewWordWrap();
if (wrap)
wordWrap.setVal(STOnOff.TRUE);
else
wordWrap.unsetVal();
}
public boolean isWordWrap() {
return isWordWrapped();
}
/**
* This method provides a style to the paragraph
* This is useful when, e.g. an Heading style has to be assigned
* @param newStyle
*/
public void setStyle(String newStyle) {
CTPPr pr = getCTPPr();
CTString style = pr.getPStyle() != null ? pr.getPStyle() : pr.addNewPStyle();
style.setVal(newStyle);
@Deprecated
public void setWordWrap(boolean wrap) {
setWordWrapped(wrap);
}
/**
@ -1242,6 +1243,18 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
return style != null ? style.getVal() : null;
}
/**
* This method provides a style to the paragraph
* This is useful when, e.g. an Heading style has to be assigned
*
* @param newStyle
*/
public void setStyle(String newStyle) {
CTPPr pr = getCTPPr();
CTString style = pr.getPStyle() != null ? pr.getPStyle() : pr.addNewPStyle();
style.setVal(newStyle);
}
/**
* Get a <b>copy</b> of the currently used CTPBrd, if none is used, return
* a new instance.
@ -1292,6 +1305,7 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
/**
* add a new run at the end of the position of
* the content of parameter run
*
* @param run
*/
protected void addRun(CTR run) {
@ -1315,6 +1329,7 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
/**
* insert a new Run in RunArray
*
* @param pos
* @return the inserted run
*/
@ -1347,6 +1362,7 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
* this methods parse the paragraph and search for the string searched.
* If it finds the string, it will return true and the position of the String
* will be saved in the parameter startPos.
*
* @param searched
* @param startPos
*/
@ -1392,18 +1408,15 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
segement.setEndChar(charPos);
return segement;
}
}
else {
} else {
candCharPos = 0;
}
}
}
textPos++;
}
else if(o instanceof CTProofErr){
} else if (o instanceof CTProofErr) {
c.removeXml();
}
else if(o instanceof CTRPr);
} else if (o instanceof CTRPr) ;
//do nothing
else
candCharPos = 0;
@ -1416,6 +1429,7 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
/**
* get a Text
*
* @param segment
*/
public String getText(TextSegement segment) {
@ -1450,6 +1464,7 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
/**
* removes a Run at the position pos in the paragraph
*
* @param pos
* @return true if the run was removed
*/
@ -1468,19 +1483,20 @@ public class XWPFParagraph implements IBodyElement, IRunBody, ISDTContents, Para
/**
* returns the type of the BodyElement Paragraph
*
* @see org.apache.poi.xwpf.usermodel.IBodyElement#getElementType()
*/
public BodyElementType getElementType() {
return BodyElementType.PARAGRAPH;
}
public IBody getBody()
{
public IBody getBody() {
return part;
}
/**
* returns the part of the bodyElement
*
* @see org.apache.poi.xwpf.usermodel.IBody#getPart()
*/
public POIXMLDocumentPart getPart() {

View File

@ -39,6 +39,7 @@ public class XWPFPicture {
/**
* Link Picture with PictureData
*
* @param rel
*/
public void setPictureReference(PackageRelationship rel) {
@ -68,8 +69,7 @@ public class XWPFPicture {
String blipId = blipProps.getBlip().getEmbed();
POIXMLDocumentPart part = run.getParent().getPart();
if (part != null)
{
if (part != null) {
POIXMLDocumentPart relatedPart = part.getRelationById(blipId);
if (relatedPart instanceof XWPFPictureData) {
return (XWPFPictureData) relatedPart;

View File

@ -43,6 +43,7 @@ public class XWPFPictureData extends POIXMLDocumentPart {
* Relationships for each known picture type
*/
protected static final POIXMLRelation[] RELATIONS;
static {
RELATIONS = new POIXMLRelation[13];
RELATIONS[Document.PICTURE_TYPE_EMF] = XWPFRelation.IMAGE_EMF;
@ -62,7 +63,6 @@ public class XWPFPictureData extends POIXMLDocumentPart {
/**
* Create a new XWPFGraphicData node
*
*/
protected XWPFPictureData() {
super();
@ -94,6 +94,7 @@ public class XWPFPictureData extends POIXMLDocumentPart {
* InputStream is = getPackagePart().getInputStream();
* </code>
* </p>
*
* @return the Picture data.
*/
public byte[] getData() {
@ -118,6 +119,7 @@ public class XWPFPictureData extends POIXMLDocumentPart {
/**
* Suggests a file extension for this image.
*
* @return the file extension.
*/
public String suggestFileExtension() {

View File

@ -33,7 +33,6 @@ public final class XWPFRelation extends POIXMLRelation {
*/
protected static final Map<String, XWPFRelation> _table = new HashMap<String, XWPFRelation>();
public static final XWPFRelation DOCUMENT = new XWPFRelation(
"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",
@ -64,7 +63,6 @@ public final class XWPFRelation extends POIXMLRelation {
"/word/glossary/document.xml",
null
);
public static final XWPFRelation NUMBERING = new XWPFRelation(
"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml",
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",
@ -137,7 +135,6 @@ public final class XWPFRelation extends POIXMLRelation {
null,
null
);
/**
* Supported image formats
*/
@ -207,7 +204,6 @@ public final class XWPFRelation extends POIXMLRelation {
"/word/media/image#.wpg",
XWPFPictureData.class
);
public static final XWPFRelation IMAGES = new XWPFRelation(
null,
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
@ -215,7 +211,6 @@ public final class XWPFRelation extends POIXMLRelation {
null
);
private XWPFRelation(String type, String rel, String defaultName, Class<? extends POIXMLDocumentPart> cls) {
super(type, rel, defaultName, cls);

View File

@ -35,13 +35,46 @@ import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlString;
import org.apache.xmlbeans.XmlToken;
import org.apache.xmlbeans.impl.values.XmlAnyTypeImpl;
import org.openxmlformats.schemas.drawingml.x2006.main.*;
import org.openxmlformats.schemas.drawingml.x2006.main.CTBlip;
import org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties;
import org.openxmlformats.schemas.drawingml.x2006.main.CTGraphicalObject;
import org.openxmlformats.schemas.drawingml.x2006.main.CTGraphicalObjectData;
import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualPictureProperties;
import org.openxmlformats.schemas.drawingml.x2006.main.CTPoint2D;
import org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D;
import org.openxmlformats.schemas.drawingml.x2006.main.CTPresetGeometry2D;
import org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties;
import org.openxmlformats.schemas.drawingml.x2006.main.CTTransform2D;
import org.openxmlformats.schemas.drawingml.x2006.main.STShapeType;
import org.openxmlformats.schemas.drawingml.x2006.picture.CTPicture;
import org.openxmlformats.schemas.drawingml.x2006.picture.CTPictureNonVisual;
import org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTAnchor;
import org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTInline;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTColor;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDrawing;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTEmpty;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFFCheckBox;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFldChar;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFonts;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFtnEdnRef;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHpsMeasure;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPTab;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSignedHpsMeasure;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSignedTwipsMeasure;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTText;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTUnderline;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTVerticalAlignRun;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STBrClear;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STBrType;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STFldCharType;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STUnderline;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STVerticalAlignRun;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
@ -54,16 +87,6 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
private IRunBody parent;
private List<XWPFPicture> pictures;
/**
* @see <a href="http://msdn.microsoft.com/en-us/library/ff533743(v=office.12).aspx">[MS-OI29500] Run Fonts</a>
*/
public static enum FontCharRange {
ascii /* char 0-127 */,
cs /* complex symbol */,
eastAsia /* east asia */,
hAnsi /* high ansi */
};
/**
* @param r the CTR bean which holds the run attributes
* @param p the parent paragraph
@ -120,6 +143,9 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
}
}
}
;
/**
* @deprecated Use {@link XWPFRun#XWPFRun(CTR, IRunBody)}
*/
@ -127,6 +153,21 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
this(r, (IRunBody) p);
}
/**
* Add the xml:spaces="preserve" attribute if the string has leading or trailing white spaces
*
* @param xs the string to check
*/
static void preserveSpaces(XmlString xs) {
String text = xs.getStringValue();
if (text != null && (text.startsWith(" ") || text.endsWith(" "))) {
XmlCursor c = xs.newCursor();
c.toNextToken();
c.insertAttributeWithValue(new QName("http://www.w3.org/XML/1998/namespace", "space"), "preserve");
c.dispose();
}
}
private List<CTPicture> getCTPictures(XmlObject o) {
List<CTPicture> pictures = new ArrayList<CTPicture>();
XmlObject[] picts = o.selectPath("declare namespace pic='" + CTPicture.type.getName().getNamespaceURI() + "' .//pic:pic");
@ -148,6 +189,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
/**
* Get the currently used CTR object
*
* @return ctr object
*/
@Internal
@ -157,13 +199,16 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
/**
* Get the currently referenced paragraph/SDT object
*
* @return current parent
*/
public IRunBody getParent() {
return parent;
}
/**
* Get the currently referenced paragraph, or null if a SDT object
*
* @deprecated use {@link XWPFRun#getParent()} instead
*/
public XWPFParagraph getParagraph() {
@ -257,6 +302,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
/**
* Set text color.
*
* @param rgbStr - the desired color, in the hex form "RRGGBB".
*/
public void setColor(String rgbStr) {
@ -298,7 +344,8 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
* @param pos - position in the text array (NB: 0 based)
*/
public void setText(String value, int pos) {
if(pos > run.sizeOfTArray()) throw new ArrayIndexOutOfBoundsException("Value too large for the parameter position in XWPFRun.setText(String value,int pos)");
if (pos > run.sizeOfTArray())
throw new ArrayIndexOutOfBoundsException("Value too large for the parameter position in XWPFRun.setText(String value,int pos)");
CTText t = (pos < run.sizeOfTArray() && pos >= 0) ? run.getTArray(pos) : run.addNewT();
t.setStringValue(value);
preserveSpaces(t);
@ -395,22 +442,6 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
return false;
return isCTOnOff(pr.getStrike());
}
@Deprecated
public boolean isStrike() {
return isStrikeThrough();
}
/**
* Specifies that the contents of this run shall be displayed with a double
* horizontal line through the center of the line.
*
* @return <code>true</code> if the double strike property is applied
*/
public boolean isDoubleStrikeThrough() {
CTRPr pr = run.getRPr();
if(pr == null || !pr.isSetDstrike())
return false;
return isCTOnOff(pr.getDstrike());
}
/**
* Specifies that the contents of this run shall be displayed with a single
@ -441,13 +472,34 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
CTOnOff strike = pr.isSetStrike() ? pr.getStrike() : pr.addNewStrike();
strike.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
}
@Deprecated
public boolean isStrike() {
return isStrikeThrough();
}
@Deprecated
public void setStrike(boolean value) {
setStrikeThrough(value);
}
/**
* Specifies that the contents of this run shall be displayed with a double
* horizontal line through the center of the line.
*
* @return <code>true</code> if the double strike property is applied
*/
public boolean isDoubleStrikeThrough() {
CTRPr pr = run.getRPr();
if (pr == null || !pr.isSetDstrike())
return false;
return isCTOnOff(pr.getDstrike());
}
/**
* Specifies that the contents of this run shall be displayed with a
* double horizontal line through the center of the line.
*
* @see #setStrikeThrough(boolean) for the rules about this
*/
public void setDoubleStrikethrough(boolean value) {
@ -462,17 +514,20 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
return false;
return isCTOnOff(pr.getSmallCaps());
}
public void setSmallCaps(boolean value) {
CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
CTOnOff caps = pr.isSetSmallCaps() ? pr.getSmallCaps() : pr.addNewSmallCaps();
caps.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
}
public boolean isCapitalized() {
CTRPr pr = run.getRPr();
if (pr == null || !pr.isSetCaps())
return false;
return isCTOnOff(pr.getCaps());
}
public void setCapitalized(boolean value) {
CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
CTOnOff caps = pr.isSetCaps() ? pr.getCaps() : pr.addNewCaps();
@ -485,6 +540,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
return false;
return isCTOnOff(pr.getShadow());
}
public void setShadow(boolean value) {
CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
CTOnOff shadow = pr.isSetShadow() ? pr.getShadow() : pr.addNewShadow();
@ -497,6 +553,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
return false;
return isCTOnOff(pr.getImprint());
}
public void setImprinted(boolean value) {
CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
CTOnOff imprinted = pr.isSetImprint() ? pr.getImprint() : pr.addNewImprint();
@ -509,6 +566,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
return false;
return isCTOnOff(pr.getEmboss());
}
public void setEmbossed(boolean value) {
CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
CTOnOff emboss = pr.isSetEmboss() ? pr.getEmboss() : pr.addNewEmboss();
@ -557,6 +615,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
return 0;
return pr.getKern().getVal().intValue();
}
public void setKerning(int kern) {
CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
CTHpsMeasure kernmes = pr.isSetKern() ? pr.getKern() : pr.addNewKern();
@ -569,6 +628,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
return 0;
return pr.getSpacing().getVal().intValue();
}
public void setCharacterSpacing(int twips) {
CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
CTSignedTwipsMeasure spc = pr.isSetSpacing() ? pr.getSpacing() : pr.addNewSpacing();
@ -585,6 +645,21 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
public String getFontFamily() {
return getFontFamily(null);
}
/**
* Specifies the fonts which shall be used to display the text contents of
* this run. Specifies a font which shall be used to format all characters
* in the ASCII range (0 - 127) within the parent run.
* <p/>
* Also sets the other font ranges, if they haven't been set before
*
* @param fontFamily
* @see FontCharRange
*/
public void setFontFamily(String fontFamily) {
setFontFamily(fontFamily, null);
}
/**
* Alias for {@link #getFontFamily()}
*/
@ -617,22 +692,6 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
}
}
/**
* Specifies the fonts which shall be used to display the text contents of
* this run. Specifies a font which shall be used to format all characters
* in the ASCII range (0 - 127) within the parent run.
*
* Also sets the other font ranges, if they haven't been set before
*
* @param fontFamily
*
* @see FontCharRange
*/
public void setFontFamily(String fontFamily) {
setFontFamily(fontFamily, null);
}
/**
* Specifies the fonts which shall be used to display the text contents of
* this run. The default handling for fcr == null is to overwrite the
@ -761,6 +820,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
* A break is a special character which is used to override the
* normal line breaking that would be performed based on the normal layout
* of the document's contents.
*
* @see #addCarriageReturn()
*/
public void addBreak() {
@ -778,6 +838,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
* location where text shall be restarted after this break) shall be
* determined by its type values.
* </p>
*
* @see BreakType
*/
public void addBreak(BreakType type) {
@ -795,6 +856,7 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
* location where text shall be restarted after this break) shall be
* determined by its type (in this case is BreakType.TEXT_WRAPPING as default) and clear attribute values.
* </p>
*
* @see BreakClear
*/
public void addBreak(BreakClear clear) {
@ -839,19 +901,18 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
* Adds a picture to the run. This method handles
* attaching the picture data to the overall file.
*
* @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_EMF
* @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_WMF
* @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_PICT
* @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_JPEG
* @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_PNG
* @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_DIB
*
* @param pictureData The raw picture data
* @param pictureType The type of the picture, eg {@link Document#PICTURE_TYPE_JPEG}
* @param width width in EMUs. To convert to / from points use {@link org.apache.poi.util.Units}
* @param height height in EMUs. To convert to / from points use {@link org.apache.poi.util.Units}
* @throws org.apache.poi.openxml4j.exceptions.InvalidFormatException
* @throws IOException
* @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_EMF
* @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_WMF
* @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_PICT
* @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_JPEG
* @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_PNG
* @see org.apache.poi.xwpf.usermodel.Document#PICTURE_TYPE_DIB
*/
public XWPFPicture addPicture(InputStream pictureData, int pictureType, String filename, int width, int height)
throws InvalidFormatException, IOException {
@ -949,27 +1010,13 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
return pictures;
}
/**
* Add the xml:spaces="preserve" attribute if the string has leading or trailing white spaces
*
* @param xs the string to check
*/
static void preserveSpaces(XmlString xs) {
String text = xs.getStringValue();
if (text != null && (text.startsWith(" ") || text.endsWith(" "))) {
XmlCursor c = xs.newCursor();
c.toNextToken();
c.insertAttributeWithValue(new QName("http://www.w3.org/XML/1998/namespace", "space"), "preserve");
c.dispose();
}
}
/**
* Returns the string version of the text
*/
public String toString() {
return text();
}
/**
* Returns the string version of the text, with tabs and
* carriage returns in place of their xml equivalents.
@ -1049,4 +1096,14 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
return text.toString();
}
/**
* @see <a href="http://msdn.microsoft.com/en-us/library/ff533743(v=office.12).aspx">[MS-OI29500] Run Fonts</a>
*/
public static enum FontCharRange {
ascii /* char 0-127 */,
cs /* complex symbol */,
eastAsia /* east asia */,
hAnsi /* high ansi */
}
}

View File

@ -22,9 +22,8 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtRun;
/**
* Experimental class to offer rudimentary read-only processing of
* of StructuredDocumentTags/ContentControl
*
* <p/>
* WARNING - APIs expected to change rapidly
*
*/
public class XWPFSDT extends AbstractXWPFSDT
implements IBodyElement, IRunBody, ISDTContents, IRunElement {

View File

@ -22,11 +22,10 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtCell;
* Experimental class to offer rudimentary read-only processing of
* of StructuredDocumentTags/ContentControl that can appear
* in a table row as if a table cell.
* <p>
* <p/>
* These can contain one or more cells or other SDTs within them.
*
* <p/>
* WARNING - APIs expected to change rapidly
*
*/
public class XWPFSDTCell extends AbstractXWPFSDT implements ICell {
private final XWPFSDTContentCell cellContent;

View File

@ -19,12 +19,10 @@ package org.apache.poi.xwpf.usermodel;
import java.util.ArrayList;
import java.util.List;
import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlObject;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtBlock;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtContentBlock;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtContentRun;
@ -33,11 +31,10 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl;
/**
* Experimental class to offer rudimentary read-only processing of
* of the contentblock of an SDT/ContentControl.
*
*
*
* <p/>
* <p/>
* <p/>
* WARNING - APIs expected to change rapidly
*
*/
public class XWPFSDTContent implements ISDTContent {
@ -56,6 +53,7 @@ public class XWPFSDTContent implements ISDTContent {
bodyElements.add(run);
}
}
public XWPFSDTContent(CTSdtContentBlock block, IBody part, IRunBody parent) {
XmlCursor cursor = block.newCursor();
cursor.selectPath("./*");

View File

@ -21,17 +21,14 @@ import javax.xml.namespace.QName;
import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlCursor.TokenType;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtContentCell;
/**
* Experimental class to offer rudimentary read-only processing of
* of the XWPFSDTCellContent.
* <p/>
* WARNING - APIs expected to change rapidly
*
*/
public class XWPFSDTContentCell implements ISDTContent {
@ -44,6 +41,7 @@ public class XWPFSDTContentCell implements ISDTContent {
//private List<ICell> cells = new ArrayList<ICell>().
private String text = "";
public XWPFSDTContentCell(CTSdtContentCell sdtContentCell,
XWPFTableRow xwpfTableRow, IBody part) {
super();
@ -90,7 +88,6 @@ public class XWPFSDTContentCell implements ISDTContent {
}
private boolean isStartToken(XmlCursor cursor, String string) {
if (!cursor.isStart()) {
return false;

View File

@ -59,8 +59,7 @@ public class XWPFSettings extends POIXMLDocumentPart {
}
@Override
protected void onDocumentRead() throws IOException
{
protected void onDocumentRead() throws IOException {
super.onDocumentRead();
readFrom(getPackagePart().getInputStream());
}
@ -74,6 +73,7 @@ public class XWPFSettings extends POIXMLDocumentPart {
* <pre>
* &lt;w:zoom w:percent="50" /&gt;
* <pre>
*
* @return percentage as an integer of zoom level
*/
public long getZoomPercent() {
@ -109,7 +109,7 @@ public class XWPFSettings extends POIXMLDocumentPart {
* Verifies the documentProtection tag inside settings.xml file <br/>
* if the protection is enforced (w:enforcement="1") <br/>
* and if the kind of protection equals to passed (STDocProtect.Enum editValue) <br/>
*
* <p/>
* <br/>
* sample snippet from settings.xml
* <pre>
@ -276,14 +276,29 @@ public class XWPFSettings extends POIXMLDocumentPart {
HashAlgorithm hashAlgo;
switch (sid.intValue()) {
case 1: hashAlgo = HashAlgorithm.md2; break;
case 2: hashAlgo = HashAlgorithm.md4; break;
case 3: hashAlgo = HashAlgorithm.md5; break;
case 4: hashAlgo = HashAlgorithm.sha1; break;
case 12: hashAlgo = HashAlgorithm.sha256; break;
case 13: hashAlgo = HashAlgorithm.sha384; break;
case 14: hashAlgo = HashAlgorithm.sha512; break;
default: return false;
case 1:
hashAlgo = HashAlgorithm.md2;
break;
case 2:
hashAlgo = HashAlgorithm.md4;
break;
case 3:
hashAlgo = HashAlgorithm.md5;
break;
case 4:
hashAlgo = HashAlgorithm.sha1;
break;
case 12:
hashAlgo = HashAlgorithm.sha256;
break;
case 13:
hashAlgo = HashAlgorithm.sha384;
break;
case 14:
hashAlgo = HashAlgorithm.sha512;
break;
default:
return false;
}
String legacyHash = CryptoFunctions.xorHashPasswordReversed(password);
@ -308,7 +323,7 @@ public class XWPFSettings extends POIXMLDocumentPart {
* 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")
*
* <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?"

View File

@ -22,22 +22,24 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.STStyleType;
/**
* @author Philipp Epp
*
*/
public class XWPFStyle {
private CTStyle ctStyle;
protected XWPFStyles styles;
private CTStyle ctStyle;
/**
* constructor
*
* @param style
*/
public XWPFStyle(CTStyle style) {
this(style, null);
}
/**
* constructor
*
* @param style
* @param styles
*/
@ -48,51 +50,61 @@ public class XWPFStyle {
/**
* get StyleID of the style
*
* @return styleID StyleID of the style
*/
public String getStyleId() {
return ctStyle.getStyleId();
}
/**
* get Type of the Style
* @return ctType
*/
public STStyleType.Enum getType(){
return ctStyle.getType();
}
/**
* set style
* @param style
*/
public void setStyle(CTStyle style){
this.ctStyle = style;
}
/**
* get ctStyle
* @return ctStyle
*/
public CTStyle getCTStyle(){
return this.ctStyle;
}
/**
* set styleID
*
* @param styleId
*/
public void setStyleId(String styleId) {
ctStyle.setStyleId(styleId);
}
/**
* get Type of the Style
*
* @return ctType
*/
public STStyleType.Enum getType() {
return ctStyle.getType();
}
/**
* set styleType
*
* @param type
*/
public void setType(STStyleType.Enum type) {
ctStyle.setType(type);
}
/**
* set style
*
* @param style
*/
public void setStyle(CTStyle style) {
this.ctStyle = style;
}
/**
* get ctStyle
*
* @return ctStyle
*/
public CTStyle getCTStyle() {
return this.ctStyle;
}
/**
* get styles
*
* @return styles the styles to which this style belongs
*/
public XWPFStyles getStyles() {
@ -135,6 +147,7 @@ public class XWPFStyle {
/**
* compares the names of the Styles
*
* @param compStyle
*/
public boolean hasSameName(XWPFStyle compStyle) {

View File

@ -34,15 +34,16 @@ import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlOptions;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDocDefaults;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFonts;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLanguage;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPrDefault;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPrDefault;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyle;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTStyles;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.StylesDocument;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPrDefault;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLanguage;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFonts;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDocDefaults;
/**
* Holds details of built-in, default and user styles, which
* apply to tables / paragraphs / lists etc.
@ -129,6 +130,7 @@ public class XWPFStyles extends POIXMLDocumentPart{
/**
* Sets the ctStyles
*
* @param styles
*/
@SuppressWarnings("deprecation")
@ -154,6 +156,7 @@ public class XWPFStyles extends POIXMLDocumentPart{
/**
* checks whether style with styleID exist
*
* @param styleID styleID of the Style in the style-Document
* @return true if style exist, false if style not exist
*/
@ -164,8 +167,10 @@ public class XWPFStyles extends POIXMLDocumentPart{
}
return false;
}
/**
* add a style to the document
*
* @param style
* @throws IOException
*/
@ -175,8 +180,10 @@ public class XWPFStyles extends POIXMLDocumentPart{
int pos = ctStyles.sizeOfStyleArray() - 1;
ctStyles.setStyleArray(pos, style.getCTStyle());
}
/**
* Get style by a styleID
*
* @param styleID styleID of the searched style
* @return style
*/
@ -187,6 +194,7 @@ public class XWPFStyles extends POIXMLDocumentPart{
}
return null;
}
public int getNumberOfStyles() {
return listStyle.size();
}
@ -194,6 +202,7 @@ public class XWPFStyles extends POIXMLDocumentPart{
/**
* get the styles which are related to the parameter style and their relatives
* this method can be used to copy all styles from one document to another document
*
* @param style
* @return a list of all styles which were used by this method
*/
@ -205,6 +214,7 @@ public class XWPFStyles extends POIXMLDocumentPart{
/**
* get the styles which are related to parameter style
*
* @param style
* @return all Styles of the parameterList
*/
@ -246,6 +256,7 @@ public class XWPFStyles extends POIXMLDocumentPart{
/**
* Sets the default spelling language on ctStyles DocDefaults parameter
*
* @param strSpellingLanguage
*/
public void setSpellingLanguage(String strSpellingLanguage) {
@ -256,6 +267,7 @@ public class XWPFStyles extends POIXMLDocumentPart{
/**
* Sets the default East Asia spelling language on ctStyles DocDefaults parameter
*
* @param strEastAsia
*/
public void setEastAsia(String strEastAsia) {

View File

@ -44,19 +44,10 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTblWidth;
* of paragraphs (and other block-level content) arranged in rows and columns.</p>
*/
public class XWPFTable implements IBodyElement, ISDTContents {
protected StringBuffer text = new StringBuffer();
private CTTbl ctTbl;
protected List<XWPFTableRow> tableRows;
protected List<String> styleIDs;
// Create a map from this XWPF-level enum to the STBorder.Enum values
public static enum XWPFBorderType { NIL, NONE, SINGLE, THICK, DOUBLE, DOTTED, DASHED, DOT_DASH };
private static EnumMap<XWPFBorderType, STBorder.Enum> xwpfBorderTypeMap;
// Create a map from the STBorder.Enum values to the XWPF-level enums
private static HashMap<Integer, XWPFBorderType> stBorderTypeMap;
protected IBody part;
static {
// populate enum maps
xwpfBorderTypeMap = new EnumMap<XWPFBorderType, STBorder.Enum>(XWPFBorderType.class);
@ -80,6 +71,14 @@ public class XWPFTable implements IBodyElement, ISDTContents {
stBorderTypeMap.put(STBorder.INT_DOT_DASH, XWPFBorderType.DOT_DASH);
}
protected StringBuffer text = new StringBuffer();
protected List<XWPFTableRow> tableRows;
;
protected List<String> styleIDs;
protected IBody part;
private CTTbl ctTbl;
public XWPFTable(CTTbl table, IBody part, int row, int col) {
this(table, part);
@ -163,7 +162,7 @@ public class XWPFTable implements IBodyElement, ISDTContents {
* Convenience method to extract text in cells. This
* does not extract text recursively in cells, and it does not
* currently include text in SDT (form) components.
* <p>
* <p/>
* To get all text within a table, see XWPFWordExtractor's appendTableText
* as an example.
*
@ -216,6 +215,13 @@ public class XWPFTable implements IBodyElement, ISDTContents {
return null;
}
/**
* @return width value
*/
public int getWidth() {
CTTblPr tblPr = getTrPr();
return tblPr.isSetTblW() ? tblPr.getTblW().getW().intValue() : -1;
}
/**
* @param width
@ -226,14 +232,6 @@ public class XWPFTable implements IBodyElement, ISDTContents {
tblWidth.setW(new BigInteger("" + width));
}
/**
* @return width value
*/
public int getWidth() {
CTTblPr tblPr = getTrPr();
return tblPr.isSetTblW() ? tblPr.getTblW().getW().intValue() : -1;
}
/**
* @return number of rows in table
*/
@ -256,6 +254,7 @@ public class XWPFTable implements IBodyElement, ISDTContents {
/**
* get the StyleID of the table
*
* @return style-ID of the table
*/
public String getStyleID() {
@ -273,6 +272,7 @@ public class XWPFTable implements IBodyElement, ISDTContents {
/**
* Set the table style. If the style is not defined in the document, MS Word
* will set the table style to "Normal".
*
* @param styleName - the style name to apply to this table
*/
public void setStyleID(String styleName) {
@ -535,6 +535,7 @@ public class XWPFTable implements IBodyElement, ISDTContents {
/**
* add a new Row to the table
* at position pos
*
* @param row the row which should be added
*/
public boolean addRow(XWPFTableRow row, int pos) {
@ -549,6 +550,7 @@ public class XWPFTable implements IBodyElement, ISDTContents {
/**
* inserts a new tablerow
*
* @param pos
* @return the inserted row
*/
@ -562,9 +564,9 @@ public class XWPFTable implements IBodyElement, ISDTContents {
return null;
}
/**
* Remove a row at position pos from the table
*
* @param pos position the Row in the Table
*/
public boolean removeRow(int pos) throws IndexOutOfBoundsException {
@ -582,9 +584,9 @@ public class XWPFTable implements IBodyElement, ISDTContents {
return tableRows;
}
/**
* returns the type of the BodyElement Table
*
* @see org.apache.poi.xwpf.usermodel.IBodyElement#getElementType()
*/
public BodyElementType getElementType() {
@ -597,6 +599,7 @@ public class XWPFTable implements IBodyElement, ISDTContents {
/**
* returns the part of the bodyElement
*
* @see org.apache.poi.xwpf.usermodel.IBody#getPart()
*/
public POIXMLDocumentPart getPart() {
@ -608,6 +611,7 @@ public class XWPFTable implements IBodyElement, ISDTContents {
/**
* returns the partType of the bodyPart which owns the bodyElement
*
* @see org.apache.poi.xwpf.usermodel.IBody#getPartType()
*/
public BodyType getPartType() {
@ -624,4 +628,9 @@ public class XWPFTable implements IBodyElement, ISDTContents {
}
return null;
}
// Create a map from this XWPF-level enum to the STBorder.Enum values
public static enum XWPFBorderType {
NIL, NONE, SINGLE, THICK, DOUBLE, DOTTED, DASHED, DOT_DASH
}
}

View File

@ -43,14 +43,6 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.STVerticalJc;
* Cell is the thing that holds the actual content (paragraphs etc)
*/
public class XWPFTableCell implements IBody, ICell {
private final CTTc ctTc;
protected List<XWPFParagraph> paragraphs = null;
protected List<XWPFTable> tables = null;
protected List<IBodyElement> bodyElements = null;
protected IBody part;
private XWPFTableRow tableRow = null;
// Create a map from this XWPF-level enum to the STVerticalJc.Enum values
public static enum XWPFVertAlign { TOP, CENTER, BOTH, BOTTOM };
private static EnumMap<XWPFVertAlign, STVerticalJc.Enum> alignMap;
// Create a map from the STVerticalJc.Enum values to the XWPF-level enums
private static HashMap<Integer, XWPFVertAlign> stVertAlignTypeMap;
@ -71,6 +63,15 @@ public class XWPFTableCell implements IBody, ICell {
}
private final CTTc ctTc;
protected List<XWPFParagraph> paragraphs = null;
protected List<XWPFTable> tables = null;
protected List<IBodyElement> bodyElements = null;
;
protected IBody part;
private XWPFTableRow tableRow = null;
/**
* If a table cell does not include at least one block-level element, then this document shall be considered corrupt
*/
@ -112,7 +113,6 @@ public class XWPFTableCell implements IBody, ICell {
cursor.dispose();
}
@Internal
public CTTc getCTTc() {
return ctTc;
@ -120,6 +120,7 @@ public class XWPFTableCell implements IBody, ICell {
/**
* returns an Iterator with paragraphs and tables
*
* @see org.apache.poi.xwpf.usermodel.IBody#getBodyElements()
*/
public List<IBodyElement> getBodyElements() {
@ -142,6 +143,7 @@ public class XWPFTableCell implements IBody, ICell {
/**
* Add a Paragraph to this Table Cell
*
* @return The paragraph which was added
*/
public XWPFParagraph addParagraph() {
@ -152,6 +154,7 @@ public class XWPFTableCell implements IBody, ICell {
/**
* add a Paragraph to this TableCell
*
* @param p the paragaph which has to be added
*/
public void addParagraph(XWPFParagraph p) {
@ -160,6 +163,7 @@ public class XWPFTableCell implements IBody, ICell {
/**
* removes a paragraph of this tablecell
*
* @param pos
*/
public void removeParagraph(int pos) {
@ -171,6 +175,7 @@ public class XWPFTableCell implements IBody, ICell {
* if there is a corresponding {@link XWPFParagraph} of the parameter ctTable in the paragraphList of this table
* 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 table
* XWPFParagraph with the correspondig CTP p
@ -184,31 +189,13 @@ public class XWPFTableCell implements IBody, ICell {
return null;
}
public void setText(String text) {
CTP ctP = (ctTc.sizeOfPArray() == 0) ? ctTc.addNewP() : ctTc.getPArray(0);
XWPFParagraph par = new XWPFParagraph(ctP, this);
par.createRun().setText(text);
}
public XWPFTableRow getTableRow() {
return tableRow;
}
/**
* Set cell color. This sets some associated values; for finer control
* you may want to access these elements individually.
* @param rgbStr - the desired cell color, in the hex form "RRGGBB".
*/
public void setColor(String rgbStr) {
CTTcPr tcpr = ctTc.isSetTcPr() ? ctTc.getTcPr() : ctTc.addNewTcPr();
CTShd ctshd = tcpr.isSetShd() ? tcpr.getShd() : tcpr.addNewShd();
ctshd.setColor("auto");
ctshd.setVal(STShd.CLEAR);
ctshd.setFill(rgbStr);
}
/**
* Get cell color. Note that this method only returns the "fill" value.
*
* @return RGB string of cell color
*/
public String getColor() {
@ -224,17 +211,22 @@ public class XWPFTableCell implements IBody, ICell {
}
/**
* Set the vertical alignment of the cell.
* @param vAlign - the desired alignment enum value
* Set cell color. This sets some associated values; for finer control
* you may want to access these elements individually.
*
* @param rgbStr - the desired cell color, in the hex form "RRGGBB".
*/
public void setVerticalAlignment(XWPFVertAlign vAlign) {
public void setColor(String rgbStr) {
CTTcPr tcpr = ctTc.isSetTcPr() ? ctTc.getTcPr() : ctTc.addNewTcPr();
CTVerticalJc va = tcpr.addNewVAlign();
va.setVal(alignMap.get(vAlign));
CTShd ctshd = tcpr.isSetShd() ? tcpr.getShd() : tcpr.addNewShd();
ctshd.setColor("auto");
ctshd.setVal(STShd.CLEAR);
ctshd.setFill(rgbStr);
}
/**
* Get the vertical alignment of the cell.
*
* @return the cell alignment enum value
*/
public XWPFVertAlign getVerticalAlignment() {
@ -247,8 +239,20 @@ public class XWPFTableCell implements IBody, ICell {
return vAlign;
}
/**
* Set the vertical alignment of the cell.
*
* @param vAlign - the desired alignment enum value
*/
public void setVerticalAlignment(XWPFVertAlign vAlign) {
CTTcPr tcpr = ctTc.isSetTcPr() ? ctTc.getTcPr() : ctTc.addNewTcPr();
CTVerticalJc va = tcpr.addNewVAlign();
va.setVal(alignMap.get(vAlign));
}
/**
* add a new paragraph at position of the cursor
*
* @param cursor
* @return the inserted paragraph
*/
@ -269,8 +273,7 @@ public class XWPFTableCell implements IBody, ICell {
}
if ((!(o instanceof CTP)) || (CTP) o == p) {
paragraphs.add(0, newP);
}
else{
} else {
int pos = paragraphs.indexOf(getParagraph((CTP) o)) + 1;
paragraphs.add(pos, newP);
}
@ -302,8 +305,7 @@ public class XWPFTableCell implements IBody, ICell {
}
if (!(o instanceof CTTbl)) {
tables.add(0, newT);
}
else{
} else {
int pos = tables.indexOf(getTable((CTTbl) o)) + 1;
tables.add(pos, newT);
}
@ -334,8 +336,6 @@ public class XWPFTableCell implements IBody, ICell {
return false;
}
/**
* @see org.apache.poi.xwpf.usermodel.IBody#getParagraphArray(int)
*/
@ -362,9 +362,9 @@ public class XWPFTableCell implements IBody, ICell {
return BodyType.TABLECELL;
}
/**
* get a table by its CTTbl-Object
*
* @see org.apache.poi.xwpf.usermodel.IBody#getTable(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl)
*/
public XWPFTable getTable(CTTbl ctTable) {
@ -374,7 +374,6 @@ public class XWPFTableCell implements IBody, ICell {
return null;
}
/**
* @see org.apache.poi.xwpf.usermodel.IBody#getTableArray(int)
*/
@ -385,7 +384,6 @@ public class XWPFTableCell implements IBody, ICell {
return null;
}
/**
* @see org.apache.poi.xwpf.usermodel.IBody#getTables()
*/
@ -393,9 +391,9 @@ public class XWPFTableCell implements IBody, ICell {
return Collections.unmodifiableList(tables);
}
/**
* inserts an existing XWPFTable to the arrays bodyElements and tables
*
* @see org.apache.poi.xwpf.usermodel.IBody#insertTable(int, org.apache.poi.xwpf.usermodel.XWPFTable)
*/
@SuppressWarnings("deprecation")
@ -419,6 +417,12 @@ public class XWPFTableCell implements IBody, ICell {
return text.toString();
}
public void setText(String text) {
CTP ctP = (ctTc.sizeOfPArray() == 0) ? ctTc.addNewP() : ctTc.getPArray(0);
XWPFParagraph par = new XWPFParagraph(ctP, this);
par.createRun().setText(text);
}
/**
* extracts all text recursively through embedded tables and embedded SDTs
*/
@ -494,4 +498,9 @@ public class XWPFTableCell implements IBody, ICell {
public XWPFDocument getXWPFDocument() {
return part.getXWPFDocument();
}
// Create a map from this XWPF-level enum to the STVerticalJc.Enum values
public static enum XWPFVertAlign {
TOP, CENTER, BOTH, BOTTOM
}
}

View File

@ -55,6 +55,7 @@ public class XWPFTableRow {
/**
* create a new XWPFTableCell and add it to the tableCell-list of this tableRow
*
* @return the newly created XWPFTableCell
*/
public XWPFTableCell createCell() {
@ -75,6 +76,7 @@ public class XWPFTableRow {
tableCells.remove(pos);
}
}
/**
* adds a new TableCell at the end of this tableRow
*/
@ -93,12 +95,11 @@ public class XWPFTableRow {
* resize its height to the height required by its contents (the equivalent
* of an hRule value of auto).
*
* @param height
* @return height
*/
public void setHeight(int height) {
public int getHeight() {
CTTrPr properties = getTrPr();
CTHeight h = properties.sizeOfTrHeightArray() == 0 ? properties.addNewTrHeight() : properties.getTrHeightArray(0);
h.setVal(new BigInteger("" + height));
return properties.sizeOfTrHeightArray() == 0 ? 0 : properties.getTrHeightArray(0).getVal().intValue();
}
/**
@ -109,11 +110,12 @@ public class XWPFTableRow {
* resize its height to the height required by its contents (the equivalent
* of an hRule value of auto).
*
* @return height
* @param height
*/
public int getHeight() {
public void setHeight(int height) {
CTTrPr properties = getTrPr();
return properties.sizeOfTrHeightArray() == 0 ? 0 : properties.getTrHeightArray(0).getVal().intValue();
CTHeight h = properties.sizeOfTrHeightArray() == 0 ? properties.addNewTrHeight() : properties.getTrHeightArray(0);
h.setVal(new BigInteger("" + height));
}
private CTTrPr getTrPr() {
@ -127,6 +129,7 @@ public class XWPFTableRow {
/**
* create and return a list of all XWPFTableCell
* who belongs to this row
*
* @return a list of {@link XWPFTableCell}
*/
public List<ICell> getTableICells() {
@ -150,6 +153,7 @@ public class XWPFTableRow {
/**
* create and return a list of all XWPFTableCell
* who belongs to this row
*
* @return a list of {@link XWPFTableCell}
*/
@SuppressWarnings("deprecation")
@ -179,23 +183,11 @@ public class XWPFTableRow {
return null;
}
/**
* This attribute controls whether to allow table rows to split across pages.
* The logic for this attribute is a little unusual: a true value means
* DON'T allow rows to split, false means allow rows to split.
* @param split - if true, don't allow rows to be split. If false, allow
* rows to be split.
*/
public void setCantSplitRow(boolean split) {
CTTrPr trpr = getTrPr();
CTOnOff onoff = trpr.addNewCantSplit();
onoff.setVal(split ? STOnOff.ON : STOnOff.OFF);
}
/**
* Return true if the "can't split row" value is true. The logic for this
* attribute is a little unusual: a TRUE value means DON'T allow rows to
* split, FALSE means allow rows to split.
*
* @return true if rows can't be split, false otherwise.
*/
public boolean isCantSplitRow() {
@ -209,20 +201,23 @@ public class XWPFTableRow {
}
/**
* This attribute controls whether to repeat a table's header row at the top
* of a table split across pages.
* @param repeat - if TRUE, repeat header row at the top of each page of table;
* if FALSE, don't repeat header row.
* This attribute controls whether to allow table rows to split across pages.
* The logic for this attribute is a little unusual: a true value means
* DON'T allow rows to split, false means allow rows to split.
*
* @param split - if true, don't allow rows to be split. If false, allow
* rows to be split.
*/
public void setRepeatHeader(boolean repeat) {
public void setCantSplitRow(boolean split) {
CTTrPr trpr = getTrPr();
CTOnOff onoff = trpr.addNewTblHeader();
onoff.setVal(repeat ? STOnOff.ON : STOnOff.OFF);
CTOnOff onoff = trpr.addNewCantSplit();
onoff.setVal(split ? STOnOff.ON : STOnOff.OFF);
}
/**
* Return true if a table's header row should be repeated at the top of a
* table split across pages.
*
* @return true if table's header row should be repeated at the top of each
* page of table, false otherwise.
*/
@ -235,4 +230,17 @@ public class XWPFTableRow {
}
return repeat;
}
/**
* This attribute controls whether to repeat a table's header row at the top
* of a table split across pages.
*
* @param repeat - if TRUE, repeat header row at the top of each page of table;
* if FALSE, don't repeat header row.
*/
public void setRepeatHeader(boolean repeat) {
CTTrPr trpr = getTrPr();
CTOnOff onoff = trpr.addNewTblHeader();
onoff.setVal(repeat ? STOnOff.ON : STOnOff.OFF);
}
}

View File

@ -20,7 +20,6 @@ package org.apache.poi.xwpf;
import java.io.IOException;
import junit.framework.TestCase;
import org.apache.poi.POIXMLProperties.CoreProperties;
import org.apache.poi.openxml4j.opc.PackageProperties;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
@ -34,13 +33,12 @@ import org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.CTVect
* submitted because even though the
* {@link PackageProperties#getKeywordsProperty()} had been present before, the
* {@link CoreProperties#getKeywords()} had been missing.
*
* <p/>
* The author of this has added {@link CoreProperties#getKeywords()} and
* {@link CoreProperties#setKeywords(String)} and this test is supposed to test
* them.
*
* @author Antoni Mylka
*
*/
public final class TestAllExtendedProperties extends TestCase {
public void testGetAllExtendedProperties() throws IOException {

View File

@ -20,7 +20,6 @@ package org.apache.poi.xwpf;
import java.io.IOException;
import junit.framework.TestCase;
import org.apache.poi.POIXMLProperties.CoreProperties;
import org.apache.poi.openxml4j.opc.PackageProperties;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
@ -30,13 +29,12 @@ import org.apache.poi.xwpf.usermodel.XWPFDocument;
* submitted because even though the
* {@link PackageProperties#getKeywordsProperty()} had been present before, the
* {@link CoreProperties#getKeywords()} had been missing.
*
* <p/>
* The author of this has added {@link CoreProperties#getKeywords()} and
* {@link CoreProperties#setKeywords(String)} and this test is supposed to test
* them.
*
* @author Antoni Mylka
*
*/
public final class TestPackageCorePropertiesGetKeywords extends TestCase {
public void testGetSetKeywords() throws IOException {

View File

@ -20,7 +20,6 @@ package org.apache.poi.xwpf.extractor;
import java.io.IOException;
import junit.framework.TestCase;
import org.apache.poi.xwpf.XWPFTestDataSamples;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
@ -28,6 +27,7 @@ public class TestExternalEntities extends TestCase {
/**
* Get text out of the simple file
*
* @throws IOException
*/
public void testFile() throws IOException {

View File

@ -22,7 +22,6 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import junit.framework.TestCase;
import org.apache.poi.xwpf.XWPFTestDataSamples;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
@ -33,6 +32,7 @@ public class TestXWPFWordExtractor extends TestCase {
/**
* Get text out of the simple file
*
* @throws IOException
*/
public void testGetSimpleText() throws IOException {
@ -65,6 +65,7 @@ public class TestXWPFWordExtractor extends TestCase {
/**
* Tests getting the text out of a complex file
*
* @throws IOException
*/
public void testGetComplexText() throws IOException {
@ -242,6 +243,7 @@ public class TestXWPFWordExtractor extends TestCase {
/**
* Test that we can open and process .docm
* (macro enabled) docx files (bug #45690)
*
* @throws IOException
*/
public void testDOCMFiles() throws IOException {
@ -259,6 +261,7 @@ public class TestXWPFWordExtractor extends TestCase {
* Test that we handle things like tabs and
* carriage returns properly in the text that
* we're extracting (bug #49189)
*
* @throws IOException
*/
public void testDocTabs() throws IOException {
@ -279,6 +282,7 @@ public class TestXWPFWordExtractor extends TestCase {
/**
* The output should not contain field codes, e.g. those specified in the
* w:instrText tag (spec sec. 17.16.23)
*
* @throws IOException
*/
public void testNoFieldCodes() throws IOException {
@ -295,6 +299,7 @@ public class TestXWPFWordExtractor extends TestCase {
/**
* The output should contain the values of simple fields, those specified
* with the fldSimple element (spec sec. 17.16.19)
*
* @throws IOException
*/
public void testFldSimpleContent() throws IOException {
@ -322,6 +327,7 @@ public class TestXWPFWordExtractor extends TestCase {
/**
* Test for basic extraction of SDT content
*
* @throws IOException
*/
public void testSimpleControlContent() throws IOException {
@ -388,7 +394,9 @@ public class TestXWPFWordExtractor extends TestCase {
ex.close();
}
/** No Header or Footer in document */
/**
* No Header or Footer in document
*/
public void testBug55733() throws Exception {
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("55733.docx");
XWPFWordExtractor extractor = new XWPFWordExtractor(doc);

View File

@ -20,7 +20,6 @@ package org.apache.poi.xwpf.model;
import java.io.IOException;
import junit.framework.TestCase;
import org.apache.poi.xwpf.XWPFTestDataSamples;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFHyperlinkRun;

View File

@ -20,7 +20,6 @@ package org.apache.poi.xwpf.model;
import java.io.IOException;
import junit.framework.TestCase;
import org.apache.poi.xwpf.XWPFTestDataSamples;
import org.apache.poi.xwpf.usermodel.XWPFDocument;

View File

@ -19,11 +19,9 @@ package org.apache.poi.xwpf.usermodel;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.io.FileInputStream;
import java.io.IOException;
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.xwpf.XWPFTestDataSamples;
import org.apache.poi.xwpf.usermodel.XWPFRun.FontCharRange;
import org.junit.Test;

View File

@ -23,7 +23,6 @@ import java.util.Arrays;
import java.util.List;
import junit.framework.TestCase;
import org.apache.poi.POIXMLDocumentPart;
import org.apache.poi.POIXMLProperties;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
@ -133,11 +132,11 @@ public final class TestXWPFDocument extends TestCase {
byte[] newJpeg = ((XWPFPictureData) doc.getRelationById(relationId)).getData();
assertEquals(newJpeg.length, jpeg.length);
for (int i = 0 ; i < jpeg.length ; i++)
{
for (int i = 0; i < jpeg.length; i++) {
assertEquals(newJpeg[i], jpeg[i]);
}
}
public void testAllPictureFormats() throws IOException, InvalidFormatException {
XWPFDocument doc = new XWPFDocument();
@ -336,6 +335,7 @@ public final class TestXWPFDocument extends TestCase {
doc.getPackage().revert();
}
public void testZeroLengthLibreOfficeDocumentWithWaterMarkHeader() throws IOException {
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("zero-length.docx");
POIXMLProperties properties = doc.getProperties();

View File

@ -22,9 +22,7 @@ import java.math.BigInteger;
import java.util.List;
import junit.framework.TestCase;
import org.apache.poi.xwpf.XWPFTestDataSamples;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFtnEdn;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STFtnEdn;

View File

@ -20,7 +20,6 @@ package org.apache.poi.xwpf.usermodel;
import java.io.IOException;
import junit.framework.TestCase;
import org.apache.poi.xwpf.XWPFTestDataSamples;
import org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;

View File

@ -19,7 +19,6 @@ package org.apache.poi.xwpf.usermodel;
import java.io.IOException;
import junit.framework.TestCase;
import org.apache.poi.xwpf.XWPFTestDataSamples;
import org.apache.xmlbeans.XmlException;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSdtBlock;

View File

@ -21,7 +21,6 @@ import java.io.IOException;
import java.math.BigInteger;
import junit.framework.TestCase;
import org.apache.poi.xwpf.XWPFTestDataSamples;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTNum;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTNumLvl;

View File

@ -22,12 +22,26 @@ import java.math.BigInteger;
import java.util.List;
import junit.framework.TestCase;
import org.apache.poi.xwpf.XWPFTestDataSamples;
import org.openxmlformats.schemas.drawingml.x2006.picture.CTPicture;
import org.openxmlformats.schemas.drawingml.x2006.picture.PicDocument;
import org.openxmlformats.schemas.drawingml.x2006.picture.impl.PicDocumentImpl;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBookmark;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBorder;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTInd;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTJc;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPBdr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTPPr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSpacing;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTextAlignment;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STBorder;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STJc;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STLineSpacingRule;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTextAlignment;
/**
* Tests for XWPF Paragraphs
@ -36,6 +50,7 @@ public final class TestXWPFParagraph extends TestCase {
/**
* Check that we get the right paragraph from the header
*
* @throws IOException
*/
public void disabled_testHeaderParagraph() throws IOException {
@ -55,6 +70,7 @@ public final class TestXWPFParagraph extends TestCase {
/**
* Check that we get the right paragraphs from the document
*
* @throws IOException
*/
public void disabled_testDocumentParagraph() throws IOException {

View File

@ -23,7 +23,6 @@ import java.io.IOException;
import java.util.List;
import junit.framework.TestCase;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.opc.PackageRelationship;
import org.apache.poi.xssf.usermodel.XSSFRelation;
@ -32,15 +31,13 @@ import org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy;
public class TestXWPFPictureData extends TestCase {
public void testRead() throws InvalidFormatException, IOException
{
public void testRead() throws InvalidFormatException, IOException {
XWPFDocument sampleDoc = XWPFTestDataSamples.openSampleDocument("VariousPictures.docx");
List<XWPFPictureData> pictures = sampleDoc.getAllPictures();
assertEquals(5, pictures.size());
String[] ext = {"wmf", "png", "emf", "emf", "jpeg"};
for (int i = 0 ; i < pictures.size() ; i++)
{
for (int i = 0; i < pictures.size(); i++) {
assertEquals(ext[i], pictures.get(i).suggestFileExtension());
}
@ -56,8 +53,7 @@ public class TestXWPFPictureData extends TestCase {
assertArrayEquals(pictureData, pict.getData());
}
public void testPictureInHeader() throws IOException
{
public void testPictureInHeader() throws IOException {
XWPFDocument sampleDoc = XWPFTestDataSamples.openSampleDocument("headerPic.docx");
verifyOneHeaderPicture(sampleDoc);
@ -74,8 +70,7 @@ public class TestXWPFPictureData extends TestCase {
assertEquals(1, pictures.size());
}
public void testNew() throws InvalidFormatException, IOException
{
public void testNew() throws InvalidFormatException, IOException {
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("EmptyDocumentWithHeaderFooter.docx");
byte[] jpegData = XWPFTestDataSamples.getImage("nature1.jpg");
assertNotNull(jpegData);
@ -89,10 +84,8 @@ public class TestXWPFPictureData extends TestCase {
// Document shouldn't have any image relationships
assertEquals(13, doc.getPackagePart().getRelationships().size());
for (PackageRelationship rel : doc.getPackagePart().getRelationships())
{
if (rel.getRelationshipType().equals(XSSFRelation.IMAGE_JPEG.getRelation()))
{
for (PackageRelationship rel : doc.getPackagePart().getRelationships()) {
if (rel.getRelationshipType().equals(XSSFRelation.IMAGE_JPEG.getRelation())) {
fail("Shouldn't have JPEG yet");
}
}
@ -107,10 +100,8 @@ public class TestXWPFPictureData extends TestCase {
// Ensure it now has one
assertEquals(14, doc.getPackagePart().getRelationships().size());
PackageRelationship jpegRel = null;
for (PackageRelationship rel : doc.getPackagePart().getRelationships())
{
if (rel.getRelationshipType().equals(XWPFRelation.IMAGE_JPEG.getRelation()))
{
for (PackageRelationship rel : doc.getPackagePart().getRelationships()) {
if (rel.getRelationshipType().equals(XWPFRelation.IMAGE_JPEG.getRelation())) {
if (jpegRel != null)
fail("Found 2 jpegs!");
jpegRel = rel;

View File

@ -23,7 +23,6 @@ import java.util.Iterator;
import java.util.List;
import junit.framework.TestCase;
import org.apache.poi.xwpf.XWPFTestDataSamples;
import org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBr;
@ -226,6 +225,7 @@ public class TestXWPFRun extends TestCase {
/**
* Test that on an existing document, we do the
* right thing with it
*
* @throws IOException
*/
public void testExisting() throws IOException {

View File

@ -18,19 +18,17 @@
package org.apache.poi.xwpf.usermodel;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import junit.framework.TestCase;
import org.apache.poi.xwpf.XWPFTestDataSamples;
public final class TestXWPFSDT extends TestCase {
/**
* Test simple tag and title extraction from SDT
*
* @throws Exception
*/
public void testTagTitle() throws Exception {
@ -80,6 +78,7 @@ public final class TestXWPFSDT extends TestCase {
assertEquals(i + ": " + contents[i], contents[i], sdt.getContent().toString());
}
}
/**
* POI-54771 and TIKA-1317
*/

View File

@ -19,7 +19,6 @@ package org.apache.poi.xwpf.usermodel;
import java.io.IOException;
import junit.framework.TestCase;
import org.apache.poi.xwpf.XWPFTestDataSamples;
/**

View File

@ -22,7 +22,6 @@ import java.util.ArrayList;
import java.util.List;
import junit.framework.TestCase;
import org.apache.poi.xwpf.XWPFTestDataSamples;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFonts;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTLatentStyles;

View File

@ -20,7 +20,6 @@ import java.math.BigInteger;
import java.util.List;
import junit.framework.TestCase;
import org.apache.poi.xwpf.XWPFTestDataSamples;
import org.apache.poi.xwpf.usermodel.XWPFTable.XWPFBorderType;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP;
@ -244,11 +243,9 @@ public class TestXWPFTable extends TestCase {
// assert the table is empty
List<XWPFTableRow> rows = table.getRows();
assertEquals("Table has less rows than requested.", noRows, rows.size());
for (XWPFTableRow xwpfRow : rows)
{
for (XWPFTableRow xwpfRow : rows) {
assertNotNull(xwpfRow);
for (int i = 0 ; i < 7 ; i++)
{
for (int i = 0; i < 7; i++) {
XWPFTableCell xwpfCell = xwpfRow.getCell(i);
assertNotNull(xwpfCell);
assertEquals("Empty cells should not have one paragraph.", 1, xwpfCell.getParagraphs().size());

View File

@ -20,9 +20,18 @@
package org.apache.poi.xwpf.usermodel;
import junit.framework.TestCase;
import org.apache.poi.xwpf.usermodel.XWPFTableCell.XWPFVertAlign;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHMerge;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTShd;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTcBorders;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTcPr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTVMerge;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTVerticalJc;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STMerge;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STShd;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STVerticalJc;
public class TestXWPFTableCell extends TestCase {

View File

@ -18,7 +18,6 @@
package org.apache.poi.xwpf.usermodel;
import junit.framework.TestCase;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRow;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl;