richtextrun.java
来自「EXCEL read and write」· Java 代码 · 共 795 行 · 第 1/2 页
JAVA
795 行
return isCharFlagsTextPropVal(CharFlagsTextProp.SHADOW_IDX); } /** * Does the text have a shadow? */ public void setShadowed(boolean flag) { setCharFlagsTextPropVal(CharFlagsTextProp.SHADOW_IDX, flag); } /** * Is this text embossed? */ public boolean isEmbossed() { return isCharFlagsTextPropVal(CharFlagsTextProp.RELIEF_IDX); } /** * Is this text embossed? */ public void setEmbossed(boolean flag) { setCharFlagsTextPropVal(CharFlagsTextProp.RELIEF_IDX, flag); } /** * Gets the strikethrough flag */ public boolean isStrikethrough() { return isCharFlagsTextPropVal(CharFlagsTextProp.STRIKETHROUGH_IDX); } /** * Sets the strikethrough flag */ public void setStrikethrough(boolean flag) { setCharFlagsTextPropVal(CharFlagsTextProp.STRIKETHROUGH_IDX, flag); } /** * Gets the subscript/superscript option * * @return the percentage of the font size. If the value is positive, it is superscript, otherwise it is subscript */ public int getSuperscript() { int val = getCharTextPropVal("superscript"); return val == -1 ? 0 : val; } /** * Sets the subscript/superscript option * * @param val the percentage of the font size. If the value is positive, it is superscript, otherwise it is subscript */ public void setSuperscript(int val) { setCharTextPropVal("superscript", val); } /** * Gets the font size */ public int getFontSize() { return getCharTextPropVal("font.size"); } /** * Sets the font size */ public void setFontSize(int fontSize) { setCharTextPropVal("font.size", fontSize); } /** * Gets the font index */ public int getFontIndex() { return getCharTextPropVal("font.index"); } /** * Sets the font index */ public void setFontIndex(int idx) { setCharTextPropVal("font.index", idx); } /** * Sets the font name to use */ public void setFontName(String fontName) { if (slideShow == null) { //we can't set font since slideshow is not assigned yet _fontname = fontName; } else { // Get the index for this font (adding if needed) int fontIdx = slideShow.getFontCollection().addFont(fontName); setCharTextPropVal("font.index", fontIdx); } } /** * Gets the font name */ public String getFontName() { if (slideShow == null) { return _fontname; } else { int fontIdx = getCharTextPropVal("font.index"); if(fontIdx == -1) { return null; } return slideShow.getFontCollection().getFontWithId(fontIdx); } } /** * @return font color as RGB value * @see java.awt.Color */ public Color getFontColor() { int rgb = getCharTextPropVal("font.color"); int cidx = rgb >> 24; if (rgb % 0x1000000 == 0){ ColorSchemeAtom ca = parentRun.getSheet().getColorScheme(); if(cidx >= 0 && cidx <= 7) rgb = ca.getColor(cidx); } Color tmp = new Color(rgb, true); return new Color(tmp.getBlue(), tmp.getGreen(), tmp.getRed()); } /** * Sets color of the text, as a int bgr. * (PowerPoint stores as BlueGreenRed, not the more * usual RedGreenBlue) * @see java.awt.Color */ public void setFontColor(int bgr) { setCharTextPropVal("font.color", bgr); } /** * Sets color of the text, as a java.awt.Color */ public void setFontColor(Color color) { // In PowerPont RGB bytes are swapped, as BGR int rgb = new Color(color.getBlue(), color.getGreen(), color.getRed(), 254).getRGB(); setFontColor(rgb); } /** * Sets the type of horizontal alignment for the text. * One of the <code>Align*</code> constants defined in the <code>TextBox</code> class. * * @param align - the type of alignment */ public void setAlignment(int align) { setParaTextPropVal("alignment", align); } /** * Returns the type of horizontal alignment for the text. * One of the <code>Align*</code> constants defined in the <code>TextBox</class> class. * * @return the type of alignment */ public int getAlignment() { return getParaTextPropVal("alignment"); } /** * * @return indentation level */ public int getIndentLevel() { return paragraphStyle == null ? 0 : paragraphStyle.getReservedField(); } /** * Sets indentation level * * @param level indentation level. Must be in the range [0, 4] */ public void setIndentLevel(int level) { if(paragraphStyle != null ) paragraphStyle.setReservedField((short)level); } /** * Sets whether this rich text run has bullets */ public void setBullet(boolean flag) { setFlag(false, ParagraphFlagsTextProp.BULLET_IDX, flag); } /** * Returns whether this rich text run has bullets */ public boolean isBullet() { return getFlag(false, ParagraphFlagsTextProp.BULLET_IDX); } /** * Returns whether this rich text run has bullets */ public boolean isBulletHard() { return getFlag(false, ParagraphFlagsTextProp.BULLET_IDX); } /** * Sets the bullet character */ public void setBulletChar(char c) { setParaTextPropVal("bullet.char", c); } /** * Returns the bullet character */ public char getBulletChar() { return (char)getParaTextPropVal("bullet.char"); } /** * Sets the bullet offset */ public void setBulletOffset(int offset) { setParaTextPropVal("bullet.offset", offset*Shape.MASTER_DPI/Shape.POINT_DPI); } /** * Returns the bullet offset */ public int getBulletOffset() { return getParaTextPropVal("bullet.offset")*Shape.POINT_DPI/Shape.MASTER_DPI; } /** * Sets the text offset */ public void setTextOffset(int offset) { setParaTextPropVal("text.offset", offset*Shape.MASTER_DPI/Shape.POINT_DPI); } /** * Returns the text offset */ public int getTextOffset() { return getParaTextPropVal("text.offset")*Shape.POINT_DPI/Shape.MASTER_DPI; } /** * Sets the bullet size */ public void setBulletSize(int size) { setParaTextPropVal("bullet.size", size); } /** * Returns the bullet size */ public int getBulletSize() { return getParaTextPropVal("bullet.size"); } /** * Sets the bullet color */ public void setBulletColor(Color color) { int rgb = new Color(color.getBlue(), color.getGreen(), color.getRed(), 254).getRGB(); setParaTextPropVal("bullet.color", rgb); } /** * Returns the bullet color */ public Color getBulletColor() { int rgb = getParaTextPropVal("bullet.color"); if(rgb == -1) return getFontColor(); int cidx = rgb >> 24; if (rgb % 0x1000000 == 0){ ColorSchemeAtom ca = parentRun.getSheet().getColorScheme(); if(cidx >= 0 && cidx <= 7) rgb = ca.getColor(cidx); } Color tmp = new Color(rgb, true); return new Color(tmp.getBlue(), tmp.getGreen(), tmp.getRed()); } /** * Sets the bullet font */ public void setBulletFont(int idx) { setParaTextPropVal("bullet.font", idx); setFlag(false, ParagraphFlagsTextProp.BULLET_HARDFONT_IDX, true); } /** * Returns the bullet font */ public int getBulletFont() { return getParaTextPropVal("bullet.font"); } /** * Sets the line spacing. * <p> * If linespacing >= 0, then linespacing is a percentage of normal line height. * If linespacing < 0, the absolute value of linespacing is the spacing in master coordinates. * </p> */ public void setLineSpacing(int val) { setParaTextPropVal("linespacing", val); } /** * Returns the line spacing * <p> * If linespacing >= 0, then linespacing is a percentage of normal line height. * If linespacing < 0, the absolute value of linespacing is the spacing in master coordinates. * </p> * * @return the spacing between lines */ public int getLineSpacing() { int val = getParaTextPropVal("linespacing"); return val == -1 ? 0 : val; } /** * Sets spacing before a paragraph. * <p> * If spacebefore >= 0, then spacebefore is a percentage of normal line height. * If spacebefore < 0, the absolute value of spacebefore is the spacing in master coordinates. * </p> */ public void setSpaceBefore(int val) { setParaTextPropVal("spacebefore", val); } /** * Returns spacing before a paragraph * <p> * If spacebefore >= 0, then spacebefore is a percentage of normal line height. * If spacebefore < 0, the absolute value of spacebefore is the spacing in master coordinates. * </p> * * @return the spacing before a paragraph */ public int getSpaceBefore() { int val = getParaTextPropVal("spacebefore"); return val == -1 ? 0 : val; } /** * Sets spacing after a paragraph. * <p> * If spaceafter >= 0, then spaceafter is a percentage of normal line height. * If spaceafter < 0, the absolute value of spaceafter is the spacing in master coordinates. * </p> */ public void setSpaceAfter(int val) { setParaTextPropVal("spaceafter", val); } /** * Returns spacing after a paragraph * <p> * If spaceafter >= 0, then spaceafter is a percentage of normal line height. * If spaceafter < 0, the absolute value of spaceafter is the spacing in master coordinates. * </p> * * @return the spacing before a paragraph */ public int getSpaceAfter() { int val = getParaTextPropVal("spaceafter"); return val == -1 ? 0 : val; } // --------------- Internal HSLF methods, not intended for end-user use! ------- /** * Internal Use Only - get the underlying paragraph style collection. * For normal use, use the friendly setters and getters */ public TextPropCollection _getRawParagraphStyle() { return paragraphStyle; } /** * Internal Use Only - get the underlying character style collection. * For normal use, use the friendly setters and getters */ public TextPropCollection _getRawCharacterStyle() { return characterStyle; } /** * Internal Use Only - are the Paragraph styles shared? */ public boolean _isParagraphStyleShared() { return sharingParagraphStyle; } /** * Internal Use Only - are the Character styles shared? */ public boolean _isCharacterStyleShared() { return sharingCharacterStyle; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?