Refine search
/** * Get the run properties for the run. * * @param create If true, create the properties, if false, do not. * @return The run properties or null if there are no properties and create is false. */ private CTRPr getRunProperties(boolean create) { CTRPr pr = run.isSetRPr() ? run.getRPr() : null; if (create && pr == null) { pr = run.addNewRPr(); } return pr; }
CTDrawing drawing = run.addNewDrawing(); CTInline inline = drawing.addNewInline(); long id = getParent().getDocument().getDrawingIdManager().reserveNew(); docPr.setId(id); CTPicture pic = getCTPictures(graphicData).get(0);
/** * Sets the text of this text run in the * * @param value the literal text which shall be displayed in the document * @param pos - position in the text array (NB: 0 based) */ public void setText(String value, int pos) { if (pos > run.sizeOfTArray()) { throw new ArrayIndexOutOfBoundsException("Value too large for the parameter position in XWPFRun.setText(String value,int pos)"); } CTText t = (pos < run.sizeOfTArray() && pos >= 0) ? run.getTArray(pos) : run.addNewT(); t.setStringValue(value); preserveSpaces(t); }
/** * Set the style ID for the run. * * @param styleId ID (not name) of the style to set for the run, e.g. "BoldItalic" (not "Bold Italic"). */ public void setStyle(String styleId) { CTRPr pr = getCTR().getRPr(); if (null == pr) { pr = getCTR().addNewRPr(); } CTString style = pr.getRStyle() != null ? pr.getRStyle() : pr.addNewRStyle(); style.setVal(styleId); }
/** * 重复样式 * * @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()); }
cellR.setText(text); cellR.setBold(tmpR.isBold()); cellR.setItalic(tmpR.isItalic()); cellR.setStrike(tmpR.isStrike()); if (tmpR.getCTR() != null) { if (tmpR.getCTR().isSetRPr()) { CTRPr tmpRPr = tmpR.getCTR().getRPr(); if (tmpRPr.isSetRFonts()) { CTFonts tmpFonts = tmpRPr.getRFonts(); CTRPr cellRPr = cellR.getCTR().isSetRPr() ? cellR.getCTR().getRPr() : cellR.getCTR().addNewRPr(); CTFonts cellFonts = cellRPr.isSetRFonts() ? cellRPr.getRFonts() : cellRPr.addNewRFonts(); cellFonts.setAscii(tmpFonts.getAscii());
if(text.equals("$[PAGE]")){ r1 = para.createRun(); CTFldChar fldChar = r1.getCTR().addNewFldChar(); fldChar.setFldCharType(STFldCharType.Enum.forString("begin")); CTText ctText = r1.getCTR().addNewInstrText(); ctText.setStringValue("PAGE \\* MERGEFORMAT"); ctText.setSpace(SpaceAttribute.Space.Enum.forString("preserve")); if(hf.getFontSize()>1){ r1.setFontSize(hf.getFontSize()); CTRPr rpr = r1.getCTR().isSetRPr() ? r1.getCTR().getRPr() : r1.getCTR().addNewRPr(); CTFonts fonts = rpr.isSetRFonts() ? rpr.getRFonts() : rpr.addNewRFonts(); String fontName=hf.getFontFamily(); fldChar = r1.getCTR().addNewFldChar(); fldChar.setFldCharType(STFldCharType.Enum.forString("end")); }else if(text.equals("$[PAGES]")){ r1 = para.createRun(); CTFldChar fldChar = r1.getCTR().addNewFldChar(); fldChar.setFldCharType(STFldCharType.Enum.forString("begin")); CTText ctText = r1.getCTR().addNewInstrText(); ctText.setStringValue("NUMPAGES \\* MERGEFORMAT "); ctText.setSpace(SpaceAttribute.Space.Enum.forString("preserve")); CTRPr rpr = r1.getCTR().isSetRPr() ? r1.getCTR().getRPr() : r1.getCTR().addNewRPr(); CTFonts fonts = rpr.isSetRFonts() ? rpr.getRFonts() : rpr.addNewRFonts(); String fontName=hf.getFontFamily(); fldChar = r1.getCTR().addNewFldChar();
Boolean strike = style.isStrike(); Boolean underLine = style.isUnderLine(); if (StringUtils.isNotBlank(color)) run.setColor(color); if (0 != fontSize) run.setFontSize(fontSize); if (StringUtils.isNotBlank(fontFamily)) { run.setFontFamily(fontFamily); CTRPr pr = run.getCTR().isSetRPr() ? run.getCTR().getRPr() : run.getCTR().addNewRPr(); CTFonts fonts = pr.isSetRFonts() ? pr.getRFonts() : pr.addNewRFonts(); fonts.setAscii(fontFamily);
CTInline inline = run.getCTR().addNewDrawing().addNewInline();
for (int i = 0; i <= runCount; i++) { if (i >= runNum && i <= lastRunNum) { sb.append(paragraph.getRuns().get(i).getText(0)); run.setText(textForLine, 0); run.addCarriageReturn(); } else { paragraph.insertNewRun(runNum + 1); XWPFRun newRun = paragraph.getRuns().get(runNum + 1); CTRPr rPr = newRun.getCTR().isSetRPr() ? newRun.getCTR().getRPr() : newRun.getCTR().addNewRPr(); rPr.set(run.getCTR().getRPr()); newRun.setText(textForLine);
CTR ctr = run.getCTR(); CTRPr rPr = ctr.getRPr(); boolean hasTexStyles = rPr != null && (rPr.getHighlight() != null || rPr.getStrike() != null || rPr.getDstrike() != null || rPr.getVertAlign() != null ) ; XmlCursor c = ctr.newCursor(); c.selectPath( "./*" ); while ( c.toNextSelection() ) if ( "w:tab".equals( tagName ) ) CTTabs tabs = stylesDocument.getParagraphTabs( run.getParagraph() ); visitTabs( tabs, paragraphContainer );
height *= EMU; String blipId = getAllPictures().get(id).getPackageRelationship().getId(); CTInline inline = paragraph.createRun().getCTR().addNewDrawing().addNewInline(); paragraph.createRun().setText(path); String picXml = new StringBuilder().append( "<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"><a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/picture\"><pic:pic xmlns:pic=\"http://schemas.openxmlformats.org/drawingml/2006/picture\"><pic:nvPicPr><pic:cNvPr id=\"")
run.setText("The Body:"); run.setText("Lorem ipsum...."); XWPFParagraph textboxparagraph = new XWPFParagraph(ctTxbxContent.addNewP(), (IBody)header); XWPFRun textboxrun = textboxparagraph.createRun(); textboxrun.setText("The TextBox 1..."); textboxrun.setFontSize(10); CTPicture ctPicture = CTPicture.Factory.parse(ctGroupNode); CTR cTR = run.getCTR(); cTR.addNewPict(); cTR.setPictArray(0, ctPicture); ctPicture = CTPicture.Factory.parse(ctGroupNode); cTR = run.getCTR(); cTR.addNewPict(); cTR.setPictArray(0, ctPicture);
throws Exception if(run.getParent() instanceof XWPFParagraph) { this.currentParagraph = (XWPFParagraph) run.getParent(); XWPFParagraph paragraph = run.getParagraph(); CTRPr rPr = run.getCTR().getRPr(); CSSStyle cssStyle = getStylesDocument().createCSSStyle( rPr ); this.currentRunAttributes = createStyleAttribute( cssStyle, currentRunAttributes );
/** * Add a new run with a reference to the specified footnote. * The footnote reference run will have the style name "FootnoteReference". * * @param footnote Footnote to which to add a reference. * @since 4.0.0 */ public void addFootnoteReference(XWPFAbstractFootnoteEndnote footnote) { XWPFRun run = createRun(); CTR ctRun = run.getCTR(); ctRun.addNewRPr().addNewRStyle().setVal("FootnoteReference"); if (footnote instanceof XWPFEndnote) { ctRun.addNewEndnoteReference().setId(footnote.getId()); } else { ctRun.addNewFootnoteReference().setId(footnote.getId()); } } }
r = p.createRun(); CTR ctr = r.getCTR(); boolean foundRef = false; for (CTFtnEdnRef ref : ctr.getFootnoteReferenceList()) { if (getId().equals(ref.getId())) { foundRef = true; ctr.addNewRPr().addNewRStyle().setVal("FootnoteReference"); ctr.addNewFootnoteRef();
r = p.createRun(); CTR ctr = r.getCTR(); boolean foundRef = false; for (CTFtnEdnRef ref : ctr.getEndnoteReferenceList()) { if (getId().equals(ref.getId())) { foundRef = true; ctr.addNewRPr().addNewRStyle().setVal("FootnoteReference"); ctr.addNewEndnoteRef();
pPr.addNewRPr().addNewNoProof(); CTR run = p.addNewR(); run.addNewRPr().addNewNoProof(); run.addNewT().setStringValue(title); run = p.addNewR(); run.addNewRPr().addNewNoProof(); run.addNewTab(); run = p.addNewR(); run.addNewRPr().addNewNoProof(); run.addNewFldChar().setFldCharType(STFldCharType.BEGIN); run.addNewRPr().addNewNoProof(); CTText text = run.addNewInstrText(); text.setSpace(Space.PRESERVE); p.addNewR().addNewRPr().addNewNoProof(); run = p.addNewR(); run.addNewRPr().addNewNoProof(); run.addNewFldChar().setFldCharType(STFldCharType.SEPARATE); run.addNewRPr().addNewNoProof(); run.addNewT().setStringValue(Integer.toString(page)); run = p.addNewR(); run.addNewRPr().addNewNoProof(); run.addNewFldChar().setFldCharType(STFldCharType.END);