/** * 重复样式 * * @param destRun 新建的run * @param srcRun 原始run */ public static void styleRun(XWPFRun destRun, XWPFRun srcRun) { if (null == destRun || null == srcRun) return; CTR ctr = srcRun.getCTR(); if (ctr.isSetRPr() && ctr.getRPr().isSetRStyle()){ String val = ctr.getRPr().getRStyle().getVal(); if (StringUtils.isNotBlank(val)) { CTRPr pr = destRun.getCTR().isSetRPr() ? destRun.getCTR().getRPr() : destRun.getCTR().addNewRPr(); CTString rStyle = pr.isSetRStyle() ? pr.getRStyle() : pr.addNewRStyle(); rStyle.setVal(val); } } if (Boolean.TRUE.equals(srcRun.isBold())) destRun.setBold(srcRun.isBold()); destRun.setColor(srcRun.getColor()); // destRun.setCharacterSpacing(srcRun.getCharacterSpacing()); if (StringUtils.isNotBlank(srcRun.getFontFamily())) destRun.setFontFamily(srcRun.getFontFamily()); int fontSize = srcRun.getFontSize(); if (-1 != fontSize) destRun.setFontSize(fontSize); if (Boolean.TRUE.equals(srcRun.isItalic())) destRun.setItalic(srcRun.isItalic()); if (Boolean.TRUE.equals(srcRun.isStrikeThrough())) destRun.setStrikeThrough(srcRun.isStrikeThrough()); destRun.setUnderline(srcRun.getUnderline()); }
int fontSize = run.getFontSize(); System.out.println("run text = '" + textInRun + "' , fontSize = " + fontSize); newRun.setFontSize( ( fontSize == -1) ? DEFAULT_FONT_SIZE : run.getFontSize() ); newRun.setFontFamily( run.getFontFamily() ); newRun.setBold( run.isBold() );
float fontSize = run.getFontSize(); if ( fontSize == -1 )
float fontSize = run.getFontSize();
if(run.getFontSize() <= 0) { run.setFontSize(getStylesDocument().getFontSize(run).intValue());
if(run.getFontSize() <= 0) { run.setFontSize(getStylesDocument().getFontSize(run).intValue());
run.setFontFamily(refRun.getFontFamily()); run.setColor(refRun.getColor()); if(refRun.getFontSize()>0){ run.setFontSize(refRun.getFontSize());
run.setColor(refRun.getColor()); if(refRun.getFontSize()<0){ run.setFontSize(this.defaultReplaceFontSize); //处理空字符引起的-1带来文字无限大问题 }else{ run.setFontSize(refRun.getFontSize());
run.setFontFamily(refRun.getFontFamily()); run.setColor(refRun.getColor()); run.setFontSize(refRun.getFontSize()); run.setStrike(refRun.isStrike()); run.setUnderline(refRun.getUnderline());
cellR.setColor(tmpR.getColor()); cellR.setTextPosition(tmpR.getTextPosition()); if (tmpR.getFontSize() != -1) { cellR.setFontSize(tmpR.getFontSize());