本文整理汇总了Java中org.apache.poi.xwpf.usermodel.XWPFRun.setBold方法的典型用法代码示例。如果您正苦于以下问题:Java XWPFRun.setBold方法的具体用法?Java XWPFRun.setBold怎么用?Java XWPFRun.setBold使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.poi.xwpf.usermodel.XWPFRun
的用法示例。
在下文中一共展示了XWPFRun.setBold方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyMStyle
import org.apache.poi.xwpf.usermodel.XWPFRun; //导入方法依赖的package包/类
/**
* Apply the given style to the given run. Background color is not taken into account here since it does not apply to runs.
*
* @param run
* The run to style
* @param style
* The style to apply, can be <code>null</code>
*/
private void applyMStyle(XWPFRun run, MStyle style) {
if (style.getFontSize() != -1) {
run.setFontSize(style.getFontSize());
}
if (style.getFontModifiers() != -1) {
run.setBold((style.getFontModifiers() & MStyle.FONT_BOLD) != 0);
run.setItalic((style.getFontModifiers() & MStyle.FONT_ITALIC) != 0);
if ((style.getFontModifiers() & MStyle.FONT_UNDERLINE) != 0) {
run.setUnderline(UnderlinePatterns.SINGLE);
}
run.setStrikeThrough((style.getFontModifiers() & MStyle.FONT_STRIKE_THROUGH) != 0);
}
if (style.getForegroundColor() != null) {
run.setColor(hexColor(style.getForegroundColor()));
}
}
示例2: insertPendingReference
import org.apache.poi.xwpf.usermodel.XWPFRun; //导入方法依赖的package包/类
/**
* Inserts a reference to the given {@link CTBookmark} with the given text in the given {@link XWPFParagraph}.
*
* @param paragraph
* the {@link XWPFParagraph}
* @param name
* the bookmark name
* @param text
* the text
* @return the {@link CTText} corresponding to the reference.
*/
private CTText insertPendingReference(XWPFParagraph paragraph, String name, String text) {
final byte[] id = getReferenceID(name);
final XWPFRun beginRun = paragraph.createRun();
beginRun.getCTR().setRsidR(id);
beginRun.getCTR().addNewFldChar().setFldCharType(STFldCharType.BEGIN);
final XWPFRun preservedRun = paragraph.createRun();
preservedRun.getCTR().setRsidR(id);
final CTText pgcttext = preservedRun.getCTR().addNewInstrText();
pgcttext.setSpace(Space.PRESERVE);
final XWPFRun separateRun = paragraph.createRun();
separateRun.getCTR().setRsidR(id);
separateRun.getCTR().addNewFldChar().setFldCharType(STFldCharType.SEPARATE);
final XWPFRun textRun = paragraph.createRun();
textRun.getCTR().setRsidR(id);
textRun.getCTR().addNewRPr().addNewNoProof();
textRun.setText(text);
textRun.setBold(true);
final XWPFRun endRun = paragraph.createRun();
endRun.getCTR().setRsidR(id);
endRun.getCTR().addNewFldChar().setFldCharType(STFldCharType.END);
return pgcttext;
}
示例3: saveStylesToDocxFile
import org.apache.poi.xwpf.usermodel.XWPFRun; //导入方法依赖的package包/类
/**
* ����text��������ʽ��docx��ʽ�ļ�
*/
@SuppressWarnings("deprecation")
public void saveStylesToDocxFile(StyledText text, XWPFDocument document) {
for (int i = 0; i < text.getLineCount(); ++i) {
int lineOffset = text.getOffsetAtLine(i);
String lineText = text.getLine(i);
XWPFParagraph paragraph = document.createParagraph();
paragraph.setFirstLineIndent(text.getIndent());
int lineAlignment = text.getLineAlignment(i);
switch (lineAlignment) {
case SWT.RIGHT:
paragraph.setAlignment(ParagraphAlignment.RIGHT);
break;
case SWT.CENTER:
paragraph.setAlignment(ParagraphAlignment.CENTER);
break;
}
// ����ÿһ�����ÿ���ַ�
for (int a = lineOffset; a < lineOffset + lineText.length(); ++a) {
StyleRange charStyle = text.getStyleRangeAtOffset(a);
String charText = text.getText(a, a);
XWPFRun run = paragraph.createRun();
run.setText(charText);
String fontname = null;
int fontsize = 0;
if (charStyle != null) {
// Color background = charStyle.background;
// Color foreground = charStyle.foreground;
if (charStyle.font != null) {
fontname = charStyle.font.getFontData()[0].getName();
if (b.text != null && text.equals(b.text))
fontsize = b.getFontRealSize(charStyle.font.getFontData()[0].getHeight());
else
fontsize = text.getFont().getFontData()[0].getHeight();
}
int fontstyle = charStyle.fontStyle;
switch (fontstyle) {
case SWT.BOLD:
run.setBold(true);
break;
case SWT.ITALIC:
run.setItalic(true);
break;
case SWT.BOLD | SWT.ITALIC:
run.setBold(true);
run.setItalic(true);
break;
}
run.setStrike(charStyle.strikeout);
if (charStyle.underline)
run.setUnderline(UnderlinePatterns.SINGLE);
run.setFontFamily(fontname, FontCharRange.eastAsia);
run.setFontSize(fontsize);
}
}
}
}
示例4: setRunMessage
import org.apache.poi.xwpf.usermodel.XWPFRun; //导入方法依赖的package包/类
/**
* Set the given message to the given {@link XWPFRun}.
*
* @param run
* the {@link XWPFRun}
* @param level
* the {@link ValidationMessageLevel}
* @param message
* the message
* @return the {@link TemplateValidationMessage}
*/
public static TemplateValidationMessage setRunMessage(XWPFRun run, ValidationMessageLevel level, String message) {
run.setText(message);
run.setBold(true);
run.setColor(getColor(level));
return new TemplateValidationMessage(level, message, run);
}