aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2015-02-05 17:35:09 +0000
committerNick Burch <nick@apache.org>2015-02-05 17:35:09 +0000
commit5c86e51b65d6b874f22186bf5a70be2bbb3ee4f9 (patch)
treedeaac823ec5a35a025e12c2d16de6cdb18e66b71
parent20349c8ce05853f6fef55920363f88d86361e66f (diff)
downloadpoi-5c86e51b65d6b874f22186bf5a70be2bbb3ee4f9.tar.gz
poi-5c86e51b65d6b874f22186bf5a70be2bbb3ee4f9.zip
More common HWPF/XWPF interfaces
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1657634 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/ooxml/java/org/apache/poi/xwpf/usermodel/IRunBody.java3
-rw-r--r--src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java1
-rw-r--r--src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java8
-rw-r--r--src/scratchpad/src/org/apache/poi/wp/usermodel/CharacterRun.java48
4 files changed, 38 insertions, 22 deletions
diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/IRunBody.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/IRunBody.java
index 55510ce4da..3ea4acabee 100644
--- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/IRunBody.java
+++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/IRunBody.java
@@ -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();
diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java
index 5a4d7b33b7..1d11c032a4 100644
--- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java
+++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFParagraph.java
@@ -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;
diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java
index 8bbb1849df..07debb98c6 100644
--- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java
+++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java
@@ -965,10 +965,16 @@ 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
diff --git a/src/scratchpad/src/org/apache/poi/wp/usermodel/CharacterRun.java b/src/scratchpad/src/org/apache/poi/wp/usermodel/CharacterRun.java
index 5712dc0527..34165463aa 100644
--- a/src/scratchpad/src/org/apache/poi/wp/usermodel/CharacterRun.java
+++ b/src/scratchpad/src/org/apache/poi/wp/usermodel/CharacterRun.java
@@ -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 boolean isOutlined();
+ public void setOutline(boolean outlined);
+
+ public boolean isVanished();
+ public void setVanished(boolean vanish);
- public String getFontName();
+ public boolean isMarkedDeleted();
+ public void markDeleted(boolean mark);
+
+ public boolean isMarkedInserted();
+ public void markInserted(boolean mark);
+*/
}