From e89f19bef38a6e02fbddd623db4f01423caae21f Mon Sep 17 00:00:00 2001
From: Javen O'Neal
- * This formatting property is a toggle property, which specifies that its
- * behavior differs between its use within a style definition and its use as
+ */
+ public boolean isBold() {
+ CTRPr pr = run.getRPr();
+ if (pr == null || !pr.isSetB()) {
+ return false;
+ }
+ return isCTOnOff(pr.getB());
+ }
+
+ /**
+ * Whether the bold property shall be applied to all non-complex script
+ * characters in the contents of this run when displayed in a document.
+ *
+ * This formatting property is a toggle property, which specifies that its
+ * behavior differs between its use within a style definition and its use as
* direct formatting. When used as part of a style definition, setting this
* property shall toggle the current state of that property as specified up
* to this point in the hierarchy (i.e. applied to not applied, and vice
@@ -292,26 +292,26 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
}
/**
- * Get text color. The returned value is a string in the hex form "RRGGBB".
- */
- public String getColor() {
- String color = null;
- if (run.isSetRPr()) {
- CTRPr pr = run.getRPr();
- if (pr.isSetColor()) {
- CTColor clr = pr.getColor();
- color = clr.xgetVal().getStringValue();
- }
- }
- return color;
- }
-
- /**
- * Set text color.
- *
- * @param rgbStr - the desired color, in the hex form "RRGGBB".
- */
- public void setColor(String rgbStr) {
+ * Get text color. The returned value is a string in the hex form "RRGGBB".
+ */
+ public String getColor() {
+ String color = null;
+ if (run.isSetRPr()) {
+ CTRPr pr = run.getRPr();
+ if (pr.isSetColor()) {
+ CTColor clr = pr.getColor();
+ color = clr.xgetVal().getStringValue();
+ }
+ }
+ return color;
+ }
+
+ /**
+ * Set text color.
+ *
+ * @param rgbStr - the desired color, in the hex form "RRGGBB".
+ */
+ public void setColor(String rgbStr) {
CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
CTColor color = pr.isSetColor() ? pr.getColor() : pr.addNewColor();
color.setVal(rgbStr);
@@ -337,24 +337,24 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
/**
* Sets the text of this text run
*
- * @param value the literal text which shall be displayed in the document
- */
- public void setText(String value) {
- setText(value, run.sizeOfTArray());
- }
-
- /**
- * Sets the text of this text run in the
- *
- * @param value the literal text which shall be displayed in the document
- * @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)");
- CTText t = (pos < run.sizeOfTArray() && pos >= 0) ? run.getTArray(pos) : run.addNewT();
- t.setStringValue(value);
- preserveSpaces(t);
+ * @param value the literal text which shall be displayed in the document
+ */
+ public void setText(String value) {
+ setText(value, run.sizeOfTArray());
+ }
+
+ /**
+ * Sets the text of this text run in the
+ *
+ * @param value the literal text which shall be displayed in the document
+ * @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)");
+ CTText t = (pos < run.sizeOfTArray() && pos >= 0) ? run.getTArray(pos) : run.addNewT();
+ t.setStringValue(value);
+ preserveSpaces(t);
}
/**
@@ -362,13 +362,13 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
* characters in the contents of this run when displayed in a document.
*
* @return null
if parent structure (paragraph > document) is not properly set.
- */
- public XWPFDocument getDocument() {
- if (parent != null) {
+
+ /**
+ * 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() {
+ if (parent instanceof XWPFParagraph)
+ return (XWPFParagraph) parent;
+ return null;
+ }
+
+ /**
+ * @return The {@link XWPFDocument} instance, this run belongs to, or
+ * null
if parent structure (paragraph > document) is not properly set.
+ */
+ public XWPFDocument getDocument() {
+ if (parent != null) {
return parent.getDocument();
}
return null;
}
/**
- * For isBold, isItalic etc
- */
- private boolean isCTOnOff(CTOnOff onoff) {
- if (!onoff.isSetVal())
- return true;
- if (onoff.getVal() == STOnOff.ON)
- return true;
- if (onoff.getVal() == STOnOff.TRUE)
- return true;
- return false;
- }
+ * For isBold, isItalic etc
+ */
+ private boolean isCTOnOff(CTOnOff onoff) {
+ if (!onoff.isSetVal())
+ return true;
+ if (onoff.getVal() == STOnOff.ON)
+ return true;
+ if (onoff.getVal() == STOnOff.TRUE)
+ return true;
+ return false;
+ }
/**
* Whether the bold property shall be applied to all non-complex script
* characters in the contents of this run when displayed in a document
*
* @return true
if the bold property is applied
- */
- public boolean isBold() {
- CTRPr pr = run.getRPr();
- if (pr == null || !pr.isSetB()) {
- return false;
- }
- return isCTOnOff(pr.getB());
- }
-
- /**
- * Whether the bold property shall be applied to all non-complex script
- * characters in the contents of this run when displayed in a document.
- * true
if the italic property is applied
- */
- public boolean isItalic() {
- CTRPr pr = run.getRPr();
- if (pr == null || !pr.isSetI())
- return false;
- return isCTOnOff(pr.getI());
- }
+ */
+ public boolean isItalic() {
+ CTRPr pr = run.getRPr();
+ if (pr == null || !pr.isSetI())
+ return false;
+ return isCTOnOff(pr.getI());
+ }
/**
* Whether the bold property shall be applied to all non-complex script
@@ -407,14 +407,14 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
*
* @return the Underline pattern applyed to this run
* @see UnderlinePatterns
- */
- public UnderlinePatterns getUnderline() {
- CTRPr pr = run.getRPr();
- return (pr != null && pr.isSetU() && pr.getU().getVal() != null)
- ? UnderlinePatterns.valueOf(pr.getU().getVal().intValue())
- : UnderlinePatterns.NONE;
- }
-
+ */
+ public UnderlinePatterns getUnderline() {
+ CTRPr pr = run.getRPr();
+ return (pr != null && pr.isSetU() && pr.getU().getVal() != null)
+ ? UnderlinePatterns.valueOf(pr.getU().getVal().intValue())
+ : UnderlinePatterns.NONE;
+ }
+
/**
* Specifies that the contents of this run should be displayed along with an
* underline appearing directly below the character heigh
@@ -441,16 +441,16 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
* horizontal line through the center of the line.
*
* @return true
if the strike property is applied
- */
- public boolean isStrikeThrough() {
- CTRPr pr = run.getRPr();
- if (pr == null || !pr.isSetStrike())
- return false;
- return isCTOnOff(pr.getStrike());
- }
-
- /**
- * Specifies that the contents of this run shall be displayed with a single
+ */
+ public boolean isStrikeThrough() {
+ CTRPr pr = run.getRPr();
+ if (pr == null || !pr.isSetStrike())
+ return false;
+ return isCTOnOff(pr.getStrike());
+ }
+
+ /**
+ * Specifies that the contents of this run shall be displayed with a single
* horizontal line through the center of the line.
* true
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) {
+ 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 true
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) {
CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
CTOnOff dstrike = pr.isSetDstrike() ? pr.getDstrike() : pr.addNewDstrike();
dstrike.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
}
-
- public boolean isSmallCaps() {
- CTRPr pr = run.getRPr();
- if (pr == null || !pr.isSetSmallCaps())
- 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();
- caps.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
- }
-
- public boolean isShadowed() {
- CTRPr pr = run.getRPr();
- if (pr == null || !pr.isSetShadow())
- 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();
- shadow.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
- }
-
- public boolean isImprinted() {
- CTRPr pr = run.getRPr();
- if (pr == null || !pr.isSetImprint())
- 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();
- imprinted.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
- }
-
- public boolean isEmbossed() {
- CTRPr pr = run.getRPr();
- if (pr == null || !pr.isSetEmboss())
- 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();
- emboss.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
- }
-
- /**
- * Specifies the alignment which shall be applied to the contents of this
- * run in relation to the default appearance of the run's text.
+
+ public boolean isSmallCaps() {
+ CTRPr pr = run.getRPr();
+ if (pr == null || !pr.isSetSmallCaps())
+ 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();
+ caps.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
+ }
+
+ public boolean isShadowed() {
+ CTRPr pr = run.getRPr();
+ if (pr == null || !pr.isSetShadow())
+ 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();
+ shadow.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
+ }
+
+ public boolean isImprinted() {
+ CTRPr pr = run.getRPr();
+ if (pr == null || !pr.isSetImprint())
+ 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();
+ imprinted.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
+ }
+
+ public boolean isEmbossed() {
+ CTRPr pr = run.getRPr();
+ if (pr == null || !pr.isSetEmboss())
+ 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();
+ emboss.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
+ }
+
+ /**
+ * Specifies the alignment which shall be applied to the contents of this
+ * run in relation to the default appearance of the run's text.
* This allows the text to be repositioned as subscript or superscript without
* altering the font size of the run properties.
*
@@ -614,20 +614,20 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
CTVerticalAlignRun ctValign = pr.isSetVertAlign() ? pr.getVertAlign() : pr.addNewVertAlign();
ctValign.setVal(STVerticalAlignRun.Enum.forInt(valign.getValue()));
}
-
- public int getKerning() {
- CTRPr pr = run.getRPr();
- if (pr == null || !pr.isSetKern())
- 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();
- kernmes.setVal(BigInteger.valueOf(kern));
- }
-
+
+ public int getKerning() {
+ CTRPr pr = run.getRPr();
+ if (pr == null || !pr.isSetKern())
+ 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();
+ kernmes.setVal(BigInteger.valueOf(kern));
+ }
+
public boolean isHighlighted() {
CTRPr pr = run.getRPr();
if (pr == null || !pr.isSetHighlight())
@@ -639,92 +639,92 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
// TODO Provide a wrapper round STHighlightColor, then expose getter/setter
// for the highlight colour. Ideally also then add to CharacterRun interface
- public int getCharacterSpacing() {
- CTRPr pr = run.getRPr();
- if (pr == null || !pr.isSetSpacing())
- 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();
- spc.setVal(BigInteger.valueOf(twips));
- }
-
- /**
- * 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 characters
+ public int getCharacterSpacing() {
+ CTRPr pr = run.getRPr();
+ if (pr == null || !pr.isSetSpacing())
+ 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();
+ spc.setVal(BigInteger.valueOf(twips));
+ }
+
+ /**
+ * 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 characters
* in the ASCII range (0 - 127) within the parent run
*
* @return a string representing the font family
*/
- 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.
- *
- * 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()}
- */
- public String getFontName() {
+ 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.
+ *
+ * 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()}
+ */
+ public String getFontName() {
return getFontFamily();
}
/**
* Gets the font family for the specified font char range.
- * If fcr is null, the font char range "ascii" is used
- *
- * @param fcr the font char range, defaults to "ansi"
- * @return a string representing the font famil
- */
- public String getFontFamily(FontCharRange fcr) {
- CTRPr pr = run.getRPr();
- if (pr == null || !pr.isSetRFonts()) return null;
-
- CTFonts fonts = pr.getRFonts();
- switch (fcr == null ? FontCharRange.ascii : fcr) {
- default:
- case ascii:
- return fonts.getAscii();
- case cs:
- return fonts.getCs();
- case eastAsia:
- return fonts.getEastAsia();
- case hAnsi:
- return fonts.getHAnsi();
- }
- }
-
- /**
- * 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
- * ascii font char range with the given font family and also set all not
- * specified font ranges
- *
- * @param fontFamily
- * @param fcr FontCharRange or null for default handling
- */
- public void setFontFamily(String fontFamily, FontCharRange fcr) {
- CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
- CTFonts fonts = pr.isSetRFonts() ? pr.getRFonts() : pr.addNewRFonts();
-
- if (fcr == null) {
- fonts.setAscii(fontFamily);
- if (!fonts.isSetHAnsi()) {
+ * If fcr is null, the font char range "ascii" is used
+ *
+ * @param fcr the font char range, defaults to "ansi"
+ * @return a string representing the font famil
+ */
+ public String getFontFamily(FontCharRange fcr) {
+ CTRPr pr = run.getRPr();
+ if (pr == null || !pr.isSetRFonts()) return null;
+
+ CTFonts fonts = pr.getRFonts();
+ switch (fcr == null ? FontCharRange.ascii : fcr) {
+ default:
+ case ascii:
+ return fonts.getAscii();
+ case cs:
+ return fonts.getCs();
+ case eastAsia:
+ return fonts.getEastAsia();
+ case hAnsi:
+ return fonts.getHAnsi();
+ }
+ }
+
+ /**
+ * 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
+ * ascii font char range with the given font family and also set all not
+ * specified font ranges
+ *
+ * @param fontFamily
+ * @param fcr FontCharRange or null for default handling
+ */
+ public void setFontFamily(String fontFamily, FontCharRange fcr) {
+ CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
+ CTFonts fonts = pr.isSetRFonts() ? pr.getRFonts() : pr.addNewRFonts();
+
+ if (fcr == null) {
+ fonts.setAscii(fontFamily);
+ if (!fonts.isSetHAnsi()) {
fonts.setHAnsi(fontFamily);
}
if (!fonts.isSetCs()) {
@@ -732,24 +732,24 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
}
if (!fonts.isSetEastAsia()) {
fonts.setEastAsia(fontFamily);
- }
- } else {
- switch (fcr) {
- case ascii:
- fonts.setAscii(fontFamily);
- break;
- case cs:
- fonts.setCs(fontFamily);
- break;
- case eastAsia:
- fonts.setEastAsia(fontFamily);
- break;
- case hAnsi:
- fonts.setHAnsi(fontFamily);
- break;
- }
- }
- }
+ }
+ } else {
+ switch (fcr) {
+ case ascii:
+ fonts.setAscii(fontFamily);
+ break;
+ case cs:
+ fonts.setCs(fontFamily);
+ break;
+ case eastAsia:
+ fonts.setEastAsia(fontFamily);
+ break;
+ case hAnsi:
+ fonts.setHAnsi(fontFamily);
+ break;
+ }
+ }
+ }
/**
* Specifies the font size which shall be applied to all non complex script
@@ -772,13 +772,13 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
* be used for non complex script characters.
*
* The behavior of this break character (the - * location where text shall be restarted after this break) shall be - * determined by its type values. - *
- * - * @see BreakType - */ - public void addBreak(BreakType type) { - CTBr br = run.addNewBr(); - br.setType(STBrType.Enum.forInt(type.getValue())); - } - + * location where text shall be restarted after this break) shall be + * determined by its type values. + * + * + * @see BreakType + */ + public void addBreak(BreakType type) { + CTBr br = run.addNewBr(); + br.setType(STBrType.Enum.forInt(type.getValue())); + } + /** * Specifies that a break shall be placed at the current location in the run * content. A break is a special character which is used to override the @@ -870,32 +870,32 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun { * of the document's contents. ** The behavior of this break character (the - * 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. - *
- * - * @see BreakClear - */ - public void addBreak(BreakClear clear) { - CTBr br = run.addNewBr(); - br.setType(STBrType.Enum.forInt(BreakType.TEXT_WRAPPING.getValue())); - br.setClear(STBrClear.Enum.forInt(clear.getValue())); - } - - /** - * Specifies that a tab shall be placed at the current location in - * the run content. - */ - public void addTab() { - run.addNewTab(); - } - - public void removeTab() { - //TODO - } - - /** - * Specifies that a carriage return shall be placed at the + * 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. + * + * + * @see BreakClear + */ + public void addBreak(BreakClear clear) { + CTBr br = run.addNewBr(); + br.setType(STBrType.Enum.forInt(BreakType.TEXT_WRAPPING.getValue())); + br.setClear(STBrClear.Enum.forInt(clear.getValue())); + } + + /** + * Specifies that a tab shall be placed at the current location in + * the run content. + */ + public void addTab() { + run.addNewTab(); + } + + public void removeTab() { + //TODO + } + + /** + * Specifies that a carriage return shall be placed at the * current location in the run content. * A carriage return is used to end the current line of text in * Wordprocess. @@ -909,29 +909,29 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun { public void addCarriageReturn() { run.addNewCr(); } - - public void removeCarriageReturn() { - //TODO - } - - /** - * Adds a picture to the run. This method handles - * attaching the picture data to the overall file. - * - * @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) + + public void removeCarriageReturn() { + //TODO + } + + /** + * Adds a picture to the run. This method handles + * attaching the picture data to the overall file. + * + * @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 { String relationId; XWPFPictureData picData; @@ -954,20 +954,20 @@ public class XWPFRun implements ISDTContents, IRunElement, CharacterRun { try { CTDrawing drawing = run.addNewDrawing(); CTInline inline = drawing.addNewInline(); - - // Do the fiddly namespace bits on the inline - // (We need full control of what goes where and as what) - String xml = - "