CTFonts fonts = pr.isSetRFonts() ? pr.getRFonts() : pr.addNewRFonts();
/** * Get the vertical alignment value * * @return {@link STVerticalAlignRun.Enum} value (see 22.9.2.17 ST_VerticalAlignRun (Vertical Positioning Location)) * @since 4.0.0 */ public STVerticalAlignRun.Enum getVerticalAlignment() { CTRPr pr = getRunProperties(true); CTVerticalAlignRun vertAlign = pr.isSetVertAlign() ? pr.getVertAlign() : pr.addNewVertAlign(); STVerticalAlignRun.Enum val = vertAlign.getVal(); if (val == null) { val = STVerticalAlignRun.BASELINE; } return val; }
/** * 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 <code>true</code> if the bold property is applied */ @Override public boolean isBold() { CTRPr pr = getRunProperties(false); return pr != null && pr.isSetB() && isCTOnOff(pr.getB()); }
/** * Get the CTUnderline for the run. * @param create Create a new underline if necessary * @return The underline, or null create is false and there is no underline. */ private CTUnderline getCTUnderline(boolean create) { CTRPr pr = getRunProperties(true); CTUnderline underline = pr.getU(); if (create && underline == null) { underline = pr.addNewU(); } return underline; }
/** * Set text color. * * @param rgbStr - the desired color, in the hex form "RRGGBB". */ public void setColor(String rgbStr) { CTRPr pr = getRunProperties(true); CTColor color = pr.isSetColor() ? pr.getColor() : pr.addNewColor(); color.setVal(rgbStr); }
CTFonts fonts = ctParaRPr.getRFonts(); if ( fonts != null ) else if ( ctParaRPr.getB() != null && STOnOff.TRUE.equals( ctParaRPr.getB().xgetVal() ) ) else if ( ctParaRPr.getI() != null && STOnOff.TRUE.equals( ctParaRPr.getI().xgetVal() ) ) CTHpsMeasure hpsMeasure = ctParaRPr.getSz(); if ( hpsMeasure != null ) cssStyleSheet.setCSSProperty( FONT_SIZE, String.valueOf( size ) ); CTUnderline underline = ctParaRPr.getU(); CTColor ctColor = ctParaRPr.getColor(); if ( ctColor != null )
public TOC(CTSdtBlock block) { this.block = block; CTSdtPr sdtPr = block.addNewSdtPr(); CTDecimalNumber id = sdtPr.addNewId(); id.setVal(new BigInteger("4844945")); sdtPr.addNewDocPartObj().addNewDocPartGallery().setVal("Table of contents"); CTSdtEndPr sdtEndPr = block.addNewSdtEndPr(); CTRPr rPr = sdtEndPr.addNewRPr(); CTFonts fonts = rPr.addNewRFonts(); fonts.setAsciiTheme(STTheme.MINOR_H_ANSI); fonts.setEastAsiaTheme(STTheme.MINOR_H_ANSI); fonts.setHAnsiTheme(STTheme.MINOR_H_ANSI); fonts.setCstheme(STTheme.MINOR_BIDI); rPr.addNewB().setVal(STOnOff.OFF); rPr.addNewBCs().setVal(STOnOff.OFF); rPr.addNewColor().setVal("auto"); rPr.addNewSz().setVal(new BigInteger("24")); rPr.addNewSzCs().setVal(new BigInteger("24")); CTSdtContentBlock content = block.addNewSdtContent(); CTP p = content.addNewP(); p.setRsidR("00EF7E24".getBytes(LocaleUtil.CHARSET_1252)); p.setRsidRDefault("00EF7E24".getBytes(LocaleUtil.CHARSET_1252)); p.addNewPPr().addNewPStyle().setVal("TOCHeading"); p.addNewR().addNewT().setStringValue("Table of Contents"); }
/** * Whether the italic property should be applied to all non-complex script * characters in the contents of this run when displayed in a document. * * @return <code>true</code> if the italic property is applied */ @Override public boolean isItalic() { CTRPr pr = getRunProperties(false); return pr != null && pr.isSetI() && isCTOnOff(pr.getI()); }
boolean hasTexStyles = rPr != null && (rPr.getHighlight() != null || rPr.getStrike() != null || rPr.getDstrike() != null || rPr.getVertAlign() != null ) ; StringBuilder text = new StringBuilder();
/** * Specifies the font size which shall be applied to all non complex script * characters in the contents of this run when displayed. * <p> * If this element is not present, the default value is to leave the value * applied at previous level in the style hierarchy. If this element is * never applied in the style hierarchy, then any appropriate font size may * be used for non complex script characters. * </p> * * @param size The font size as number of point measurements. */ @Override public void setFontSize(int size) { BigInteger bint = new BigInteger(Integer.toString(size)); CTRPr pr = getRunProperties(true); CTHpsMeasure ctSize = pr.isSetSz() ? pr.getSz() : pr.addNewSz(); ctSize.setVal(bint.multiply(new BigInteger("2"))); }
/** * 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 = getRunProperties(false); 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(); } }
/** * Whether the bold property shall be applied to all non-complex script * characters in the contents of this run when displayed in a document. * <p> * 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 * versa). Setting it to <code>false</code> (or an equivalent) shall * result in the current setting remaining unchanged. However, when used as * direct formatting, setting this property to true or false shall set the * absolute state of the resulting property. * </p> * <p> * If this element is not present, the default value is to leave the * formatting applied at previous level in the style hierarchy. If this * element is never applied in the style hierarchy, then bold shall not be * applied to non-complex script characters. * </p> * * @param value <code>true</code> if the bold property is applied to * this run */ @Override public void setBold(boolean value) { CTRPr pr = getRunProperties(true); CTOnOff bold = pr.isSetB() ? pr.getB() : pr.addNewB(); bold.setVal(value ? STOnOff.TRUE : STOnOff.FALSE); }
private CTFonts getRFonts( CTRPr ppr ) { if ( ppr == null ) { return null; } return ppr.getRFonts(); }
if(color != null) cssStyle.addProperty(CSSStylePropertyConstants.BACKGROUND_COLOR, StringUtils.toHexString(color)); if(Boolean.TRUE.equals(RunFontStyleStrikeValueProvider.INSTANCE.getValue(rPr, getStylesDocument())) || rPr.getDstrike() != null) cssStyle.addProperty("text-decoration", "line-through"); if(rPr.getVertAlign() != null) { int align = rPr.getVertAlign().getVal().intValue(); if(STVerticalAlignRun.INT_SUPERSCRIPT == align) { cssStyle.addProperty("vertical-align", "super");
/** * 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. * * @return VerticalAlign * @see {@link VerticalAlign} all possible value that could be applyed to this run * @deprecated use {@link XWPFRun.getVerticalAlignment} */ @Removal(version = "4.2") public VerticalAlign getSubscript() { CTRPr pr = getRunProperties(false); return (pr != null && pr.isSetVertAlign()) ? VerticalAlign.valueOf(pr.getVertAlign().getVal().intValue()) : VerticalAlign.BASELINE; }
/** * 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 = getRunProperties(false); if (pr != null && pr.isSetColor()) { CTColor clr = pr.getColor(); color = clr.xgetVal().getStringValue(); } } return color; }
/** * 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 */ @Override public void setDoubleStrikethrough(boolean value) { CTRPr pr = getRunProperties(true); CTOnOff dstrike = pr.isSetDstrike() ? pr.getDstrike() : pr.addNewDstrike(); dstrike.setVal(value ? STOnOff.TRUE : STOnOff.FALSE); }