int getKerning();
void setKerning(int kern);
+
+ boolean isHighlighted();
+
+ // HWPF has colour indexes, XWPF has a highlight enum with the colours in
+// byte getHighlightedColor();
+// void setHighlighted(byte color);
+
+ // HWPF has colour indexes, XWPF colour names
+// int getColor();
+// void setColor(int color);
+
+ /**
+ * Gets the fonts which shall be used to display the text contents of
+ * this run. Specifies a font which shall be used to format all "normal"
+ * characters in the run
+ *
+ * @return a string representing the font
+ */
String getFontName();
/**
// short getSubSuperScriptIndex();
// void setSubSuperScriptIndex(short iss);
- // HWPF uses indexes, XWPF special vertical alignments
-// int getVerticalOffset();
-// void setVerticalOffset(int hpsPos);
-
- // HWPF has colour indexes, XWPF colour names
-// int getColor();
-// void setColor(int color);
-
// TODO Review these, and add to XWPFRun if possible
/*
boolean isFldVanished();
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.STHighlightColor;
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;\r
+import org.w3c.dom.Text;
\r
/**
* XWPFRun object defines a region of text with a common set of properties
kernmes.setVal(BigInteger.valueOf(kern));\r
}\r
\r
+ public boolean isHighlighted() {
+ CTRPr pr = run.getRPr();
+ if (pr == null || !pr.isSetHighlight())
+ return false;
+ if (pr.getHighlight().getVal() == STHighlightColor.NONE)
+ return false;
+ return true;
+ }
+ // TODO Provide a wrapper round STHighlightColor, then expose getter/setter
+ // for the highlight colour. Ideally also then add to CharacterRun interface
+
public int getCharacterSpacing() {\r
CTRPr pr = run.getRPr();\r
if (pr == null || !pr.isSetSpacing())\r
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;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STBrClear;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.STHighlightColor;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STOnOff;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STUnderline;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STVerticalAlignRun;
assertEquals(1, count);
}
+
+ public void testSetGetHighlight() throws Exception {
+ XWPFRun run = p.createRun();
+ assertEquals(false, run.isHighlighted());
+
+ // TODO Do this using XWPFRun methods
+ run.getCTR().addNewRPr().addNewHighlight().setVal(STHighlightColor.NONE);
+ assertEquals(false, run.isHighlighted());
+ run.getCTR().getRPr().getHighlight().setVal(STHighlightColor.CYAN);
+ assertEquals(true, run.isHighlighted());
+ run.getCTR().getRPr().getHighlight().setVal(STHighlightColor.NONE);
+ assertEquals(false, run.isHighlighted());
+ }
public void testAddPicture() throws Exception {
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("TestDocument.docx");
*
* @return TYPE_CHARACTER
*/
+ @SuppressWarnings("deprecation")
public int type()
{
return TYPE_CHARACTER;