More common HWPF/XWPF interfaces

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1657634 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2015-02-05 17:35:09 +00:00
parent 1f2fc6c08b
commit c526206e0d
4 changed files with 38 additions and 22 deletions

View File

@ -17,10 +17,13 @@
package org.apache.poi.xwpf.usermodel;
import org.apache.poi.POIXMLDocumentPart;
import org.apache.poi.wp.usermodel.Paragraph;
/**
* Simple interface describing both {@link XWPFParagraph}
* and {@link XWPFSDT}
*
* TODO Should this be based on / extend {@link Paragraph}?
*/
public interface IRunBody {
public XWPFDocument getDocument();

View File

@ -23,6 +23,7 @@ import java.util.List;
import org.apache.poi.POIXMLDocumentPart;
import org.apache.poi.util.Internal;
import org.apache.poi.wp.usermodel.Paragraph;
import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlObject;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTAbstractNum;

View File

@ -964,11 +964,17 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
}
}
/**
* 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.
*/
public String toString() {
public String text() {
StringBuffer text = new StringBuffer();
// Grab the text and tabs of the text run

View File

@ -20,7 +20,7 @@ package org.apache.poi.wp.usermodel;
/**
* This class represents a run of text that share common properties.
*/
public interface CharacterRun {// extends Range {
public interface CharacterRun {
public boolean isBold();
public void setBold(boolean bold);
@ -33,23 +33,6 @@ public interface CharacterRun {// extends Range {
public boolean isCapitalized();
public void setCapitalized(boolean caps);
/*
public boolean isFldVanished();
public void setFldVanish(boolean fldVanish);
public boolean isOutlined();
public void setOutline(boolean outlined);
public boolean isVanished();
public void setVanished(boolean vanish);
public boolean isMarkedDeleted();
public void markDeleted(boolean mark);
public boolean isMarkedInserted();
public void markInserted(boolean mark);
*/
public boolean isStrikeThrough();
public void setStrikeThrough(boolean strike);
public boolean isDoubleStrikeThrough();
@ -70,6 +53,16 @@ public interface CharacterRun {// extends Range {
public int getCharacterSpacing();
public void setCharacterSpacing(int twips);
public int getKerning();
public void setKerning(int kern);
public String getFontName();
/**
* @return The text of the run, including any tabs/spaces/etc
*/
public String text();
// HWPF uses indexes, XWPF special
// public int getUnderlineCode();
// public void setUnderlineCode(int kul);
@ -86,8 +79,21 @@ public interface CharacterRun {// extends Range {
// public int getColor();
// public void setColor(int color);
public int getKerning();
public void setKerning(int kern);
// TODO Review these, and add to XWPFRun if possible
/*
public boolean isFldVanished();
public void setFldVanish(boolean fldVanish);
public String getFontName();
public boolean isOutlined();
public void setOutline(boolean outlined);
public boolean isVanished();
public void setVanished(boolean vanish);
public boolean isMarkedDeleted();
public void markDeleted(boolean mark);
public boolean isMarkedInserted();
public void markInserted(boolean mark);
*/
}