📄 rtfparagraphstyle.java
字号:
*/ public void setFirstLineIndent(int firstLineIndent) { this.firstLineIndent = firstLineIndent; } /** * Gets the left indentation of this RtfParagraphStyle. * * @return The left indentation of this RtfParagraphStyle. */ public int getIndentLeft() { return this.indentLeft; } /** * Sets the left indentation of this RtfParagraphStyle. * * @param indentLeft The left indentation to use. */ public void setIndentLeft(int indentLeft) { this.modified = this.modified | MODIFIED_INDENT_LEFT; this.indentLeft = indentLeft; } /** * Gets the right indentation of this RtfParagraphStyle. * * @return The right indentation of this RtfParagraphStyle. */ public int getIndentRight() { return this.indentRight; } /** * Sets the right indentation of this RtfParagraphStyle. * * @param indentRight The right indentation to use. */ public void setIndentRight(int indentRight) { this.modified = this.modified | MODIFIED_INDENT_RIGHT; this.indentRight = indentRight; } /** * Gets the space before the paragraph of this RtfParagraphStyle.. * * @return The space before the paragraph. */ public int getSpacingBefore() { return this.spacingBefore; } /** * Sets the space before the paragraph of this RtfParagraphStyle. * * @param spacingBefore The space before to use. */ public void setSpacingBefore(int spacingBefore) { this.modified = this.modified | MODIFIED_SPACING_BEFORE; this.spacingBefore = spacingBefore; } /** * Gets the space after the paragraph of this RtfParagraphStyle. * * @return The space after the paragraph. */ public int getSpacingAfter() { return this.spacingAfter; } /** * Sets the space after the paragraph of this RtfParagraphStyle. * * @param spacingAfter The space after to use. */ public void setSpacingAfter(int spacingAfter) { this.modified = this.modified | MODIFIED_SPACING_AFTER; this.spacingAfter = spacingAfter; } /** * Sets the font name of this RtfParagraphStyle. * * @param fontName The font name to use */ public void setFontName(String fontName) { this.modified = this.modified | MODIFIED_FONT_NAME; super.setFontName(fontName); } /** * Sets the font size of this RtfParagraphStyle. * * @param fontSize The font size to use. */ public void setSize(float fontSize) { this.modified = this.modified | MODIFIED_FONT_SIZE; super.setSize(fontSize); } /** * Sets the font style of this RtfParagraphStyle. * * @param fontStyle The font style to use. */ public void setStyle(int fontStyle) { this.modified = this.modified | MODIFIED_FONT_STYLE; super.setStyle(fontStyle); } /** * Sets the color of this RtfParagraphStyle. * * @param color The Color to use. */ public void setColor(Color color) { this.modified = this.modified | MODIFIED_FONT_COLOR; super.setColor(color); } /** * Gets the line leading of this RtfParagraphStyle. * * @return The line leading of this RtfParagraphStyle. */ public int getLineLeading() { return this.lineLeading; } /** * Sets the line leading of this RtfParagraphStyle. * * @param lineLeading The line leading to use. */ public void setLineLeading(int lineLeading) { this.lineLeading = lineLeading; this.modified = this.modified | MODIFIED_LINE_LEADING; } /** * Gets whether the lines in the paragraph should be kept together in * this RtfParagraphStyle. * * @return Whether the lines in the paragraph should be kept together. */ public boolean getKeepTogether() { return this.keepTogether; } /** * Sets whether the lines in the paragraph should be kept together in * this RtfParagraphStyle. * * @param keepTogether Whether the lines in the paragraph should be kept together. */ public void setKeepTogether(boolean keepTogether) { this.keepTogether = keepTogether; this.modified = this.modified | MODIFIED_KEEP_TOGETHER; } /** * Gets whether the paragraph should be kept together with the next in * this RtfParagraphStyle. * * @return Whether the paragraph should be kept together with the next. */ public boolean getKeepTogetherWithNext() { return this.keepTogetherWithNext; } /** * Sets whether the paragraph should be kept together with the next in * this RtfParagraphStyle. * * @param keepTogetherWithNext Whether the paragraph should be kept together with the next. */ public void setKeepTogetherWithNext(boolean keepTogetherWithNext) { this.keepTogetherWithNext = keepTogetherWithNext; this.modified = this.modified | MODIFIED_KEEP_TOGETHER_WITH_NEXT; } /** * Handles the inheritance of paragraph style settings. All settings that * have not been modified will be inherited from the base RtfParagraphStyle. * If this RtfParagraphStyle is not based on another one, then nothing happens. */ public void handleInheritance() { if(this.basedOnName != null && this.document.getDocumentHeader().getRtfParagraphStyle(this.basedOnName) != null) { this.baseStyle = this.document.getDocumentHeader().getRtfParagraphStyle(this.basedOnName); this.baseStyle.handleInheritance(); if(!((this.modified & MODIFIED_ALIGNMENT) == MODIFIED_ALIGNMENT)) { this.alignment = this.baseStyle.getAlignment(); } if(!((this.modified & MODIFIED_INDENT_LEFT) == MODIFIED_INDENT_LEFT)) { this.indentLeft = this.baseStyle.getIndentLeft(); } if(!((this.modified & MODIFIED_INDENT_RIGHT) == MODIFIED_INDENT_RIGHT)) { this.indentRight = this.baseStyle.getIndentRight(); } if(!((this.modified & MODIFIED_SPACING_BEFORE) == MODIFIED_SPACING_BEFORE)) { this.spacingBefore = this.baseStyle.getSpacingBefore(); } if(!((this.modified & MODIFIED_SPACING_AFTER) == MODIFIED_SPACING_AFTER)) { this.spacingAfter = this.baseStyle.getSpacingAfter(); } if(!((this.modified & MODIFIED_FONT_NAME) == MODIFIED_FONT_NAME)) { setFontName(this.baseStyle.getFontName()); } if(!((this.modified & MODIFIED_FONT_SIZE) == MODIFIED_FONT_SIZE)) { setSize(this.baseStyle.getFontSize()); } if(!((this.modified & MODIFIED_FONT_STYLE) == MODIFIED_FONT_STYLE)) { setStyle(this.baseStyle.getFontStyle()); } if(!((this.modified & MODIFIED_FONT_COLOR) == MODIFIED_FONT_COLOR)) { setColor(this.baseStyle.getColor()); } if(!((this.modified & MODIFIED_LINE_LEADING) == MODIFIED_LINE_LEADING)) { setLineLeading(this.baseStyle.getLineLeading()); } if(!((this.modified & MODIFIED_KEEP_TOGETHER) == MODIFIED_KEEP_TOGETHER)) { setKeepTogether(this.baseStyle.getKeepTogether()); } if(!((this.modified & MODIFIED_KEEP_TOGETHER_WITH_NEXT) == MODIFIED_KEEP_TOGETHER_WITH_NEXT)) { setKeepTogetherWithNext(this.baseStyle.getKeepTogetherWithNext()); } } } /** * Writes the settings of this RtfParagraphStyle. * * @param result The <code>OutputStream</code> to write to. * @throws IOException On i/o errors. */ private void writeParagraphSettings(final OutputStream result) throws IOException { if(this.keepTogether) { result.write(RtfParagraphStyle.KEEP_TOGETHER); } if(this.keepTogetherWithNext) { result.write(RtfParagraphStyle.KEEP_TOGETHER_WITH_NEXT); } switch (alignment) { case Element.ALIGN_LEFT: result.write(RtfParagraphStyle.ALIGN_LEFT); break; case Element.ALIGN_RIGHT: result.write(RtfParagraphStyle.ALIGN_RIGHT); break; case Element.ALIGN_CENTER: result.write(RtfParagraphStyle.ALIGN_CENTER); break; case Element.ALIGN_JUSTIFIED: case Element.ALIGN_JUSTIFIED_ALL: result.write(RtfParagraphStyle.ALIGN_JUSTIFY); break; } result.write(FIRST_LINE_INDENT); result.write(intToByteArray(this.firstLineIndent)); result.write(RtfParagraphStyle.INDENT_LEFT); result.write(intToByteArray(indentLeft)); result.write(RtfParagraphStyle.INDENT_RIGHT); result.write(intToByteArray(indentRight)); if(this.spacingBefore > 0) { result.write(RtfParagraphStyle.SPACING_BEFORE); result.write(intToByteArray(this.spacingBefore)); } if(this.spacingAfter > 0) { result.write(RtfParagraphStyle.SPACING_AFTER); result.write(intToByteArray(this.spacingAfter)); } if(this.lineLeading > 0) { result.write(RtfParagraph.LINE_SPACING); result.write(intToByteArray(this.lineLeading)); } } /** * Writes the definition of this RtfParagraphStyle for the stylesheet list. */ public void writeDefinition(final OutputStream result) throws IOException { result.write("{".getBytes()); result.write("\\style".getBytes()); result.write("\\s".getBytes()); result.write(intToByteArray(this.styleNumber)); result.write(RtfBasicElement.DELIMITER); writeParagraphSettings(result); super.writeBegin(result); result.write(RtfBasicElement.DELIMITER); result.write(this.styleName.getBytes()); result.write(";".getBytes()); result.write("}".getBytes()); if(this.document.getDocumentSettings().isOutputDebugLineBreaks()) { result.write('\n'); } } /** * Writes the start information of this RtfParagraphStyle. * * @param result The <code>OutputStream</code> to write to. * @throws IOException On i/o errors. */ public void writeBegin(final OutputStream result) throws IOException { result.write("\\s".getBytes()); result.write(intToByteArray(this.styleNumber)); writeParagraphSettings(result); } /** * Unused * * @param result The <code>OutputStream</code> that nothing is written to * @throws IOException On i/o errors. */ public void writeEnd(final OutputStream result) throws IOException { } /** * unused */ public void writeContent(final OutputStream out) throws IOException { } /** * Tests whether two RtfParagraphStyles are equal. Equality * is determined via the name. */ public boolean equals(Object o) { if(!(o instanceof RtfParagraphStyle)) { return false; } RtfParagraphStyle paragraphStyle = (RtfParagraphStyle) o; boolean result = this.getStyleName().equals(paragraphStyle.getStyleName()); return result; } /** * Gets the hash code of this RtfParagraphStyle. */ public int hashCode() { return this.styleName.hashCode(); } /** * Gets the number of this RtfParagraphStyle in the stylesheet list. * * @return The number of this RtfParagraphStyle in the stylesheet list. */ private int getStyleNumber() { return this.styleNumber; } /** * Sets the number of this RtfParagraphStyle in the stylesheet list. * * @param styleNumber The number to use. */ protected void setStyleNumber(int styleNumber) { this.styleNumber = styleNumber; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -