private void addTextRun(R r, String val, List<Object> replacementContent) { R rnew = new R(); rnew.setRPr( r.getRPr() ); // point at old rPr, if any Text text = Context.getWmlObjectFactory().createText(); text.setValue(val); if (val.startsWith(" ") || val.endsWith(" ") ) { text.setSpace("preserve"); } rnew.getContent().add(text); replacementContent.add(rnew); }
private void addRunToDocFrag(JaxbXmlPart sourcePart, List<Object> contents, String string, RPr rPr) { org.docx4j.wml.R run = Context.getWmlObjectFactory().createR(); if (rPr!=null) { run.setRPr(rPr); } org.docx4j.wml.Text text = Context.getWmlObjectFactory().createText(); run.getRunContent().add(text); if (string.startsWith(" ") || string.endsWith(" ") ) { // TODO: tab character? text.setSpace("preserve"); } text.setValue(string); contents.add(run); }
public void setResult(String val) { resultsSlot.getContent().clear(); StringTokenizer st = new StringTokenizer(val, "\n\r\f"); // tokenize on the newline character, the carriage-return character, and the form-feed character // our docfrag may contain several runs boolean firsttoken = true; while (st.hasMoreTokens()) { String line = (String) st.nextToken(); if (firsttoken) { firsttoken = false; } else { resultsSlot.getContent().add(Context.getWmlObjectFactory().createBr()); } org.docx4j.wml.Text text = Context.getWmlObjectFactory().createText(); resultsSlot.getContent().add(text); if (line.startsWith(" ") || line.endsWith(" ") ) { // TODO: tab character? text.setSpace("preserve"); } text.setValue(line); } }
private static org.docx4j.wml.R createRunStructure(String textVal, P existingP, int rIndex ) { org.docx4j.wml.R newR = wmlFactory.createR(); org.docx4j.wml.Text newT = wmlFactory.createText(); newR.getRunContent().add(newT); newT.setValue(textVal); newT.setSpace("preserve"); org.docx4j.wml.RPr existingRPr = ((org.docx4j.wml.R)existingP.getParagraphContent().get(rIndex)).getRPr(); if ( existingRPr !=null ) newR.setRPr(existingRPr); return newR; }
private void addRunToDocFrag(JaxbXmlPart sourcePart, DocumentFragment docfrag, String string, RPr rPr) { org.docx4j.wml.R run = Context.getWmlObjectFactory().createR(); if (rPr!=null) { run.setRPr(rPr); } org.docx4j.wml.Text text = Context.getWmlObjectFactory().createText(); run.getRunContent().add(text); if (string.startsWith(" ") || string.endsWith(" ") ) { // TODO: tab character? log.debug("setting xml:space=preserve for '" + string + "'"); text.setSpace("preserve"); } text.setValue(string); Document tmpDoc = XmlUtils.marshaltoW3CDomDocument(run); // avoid WRONG_DOCUMENT_ERR: A node is used in a different document than the one that created it. // but NOT_SUPPORTED_ERR: The implementation does not support the requested type of object or operation. // at com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.importNode // docfrag.appendChild(fragdoc.importNode(document, true)); // so: XmlUtils.treeCopy(tmpDoc.getDocumentElement(), docfrag); }
r3.getContent().add(textWrapped2); text2.setValue(tocInstruction); text2.setSpace(PRESERVE);
((Text)XmlUtils.unwrap(currentT)).setSpace("preserve");
JAXBElement<Text> textWrapped6 = wmlObjectFactory.createRT(t); r.getContent().add(textWrapped6); t.setSpace("preserve");
r16.getContent().add(textWrapped7); text7.setValue(String.format(PAGEREF_MASK, anchorValue)); text7.setSpace(PRESERVE);
@Override public Text text(final String text) { R r = createR(); Text textElem = addWrappedText(); textElem.setValue(text); textElem.setSpace(RunFormatProvider.SPACE_PRESERVE); return textElem; }
r2.getContent().add(textWrapped); text.setValue(String.format(" HYPERLINK \"%s\" \\o \"%s\" ", linkUrlText, linkTitle)); text.setSpace(RunFormatProvider.SPACE_PRESERVE);
JAXBElement<Text> textWrapped = myFactory.createRT(text1); r2.getContent().add(textWrapped); text1.setSpace(RunFormatProvider.SPACE_PRESERVE); text1.setValue("\t"); p.getContent().add(r2);
/** * Sets the text of the given run to the given value. * * @param run the run whose text to change. * @param text the text to set. */ public static void setText(R run, String text) { run.getContent().clear(); Text textObj = factory.createText(); textObj.setSpace("preserve"); textObj.setValue(text); textObj.setSpace("preserve"); // make the text preserve spaces run.getContent().add(textObj); }
private void addTextRun(R r, String val, List<Object> replacementContent) { R rnew = new R(); rnew.setRPr( r.getRPr() ); // point at old rPr, if any Text text = Context.getWmlObjectFactory().createText(); text.setValue(val); if (val.startsWith(" ") || val.endsWith(" ") ) { text.setSpace("preserve"); } rnew.getContent().add(text); replacementContent.add(rnew); }
private void addRunToDocFrag(JaxbXmlPart sourcePart, List<Object> contents, String string, RPr rPr) { org.docx4j.wml.R run = Context.getWmlObjectFactory().createR(); if (rPr!=null) { run.setRPr(rPr); } org.docx4j.wml.Text text = Context.getWmlObjectFactory().createText(); run.getRunContent().add(text); if (string.startsWith(" ") || string.endsWith(" ") ) { // TODO: tab character? text.setSpace("preserve"); } text.setValue(string); contents.add(run); }
public void setResult(String val) { resultsSlot.getContent().clear(); StringTokenizer st = new StringTokenizer(val, "\n\r\f"); // tokenize on the newline character, the carriage-return character, and the form-feed character // our docfrag may contain several runs boolean firsttoken = true; while (st.hasMoreTokens()) { String line = (String) st.nextToken(); if (firsttoken) { firsttoken = false; } else { resultsSlot.getContent().add(Context.getWmlObjectFactory().createBr()); } org.docx4j.wml.Text text = Context.getWmlObjectFactory().createText(); resultsSlot.getContent().add(text); if (line.startsWith(" ") || line.endsWith(" ") ) { // TODO: tab character? text.setSpace("preserve"); } text.setValue(line); } }
private static org.docx4j.wml.R createRunStructure(String textVal, P existingP, int rIndex ) { org.docx4j.wml.R newR = wmlFactory.createR(); org.docx4j.wml.Text newT = wmlFactory.createText(); newR.getRunContent().add(newT); newT.setValue(textVal); newT.setSpace("preserve"); org.docx4j.wml.RPr existingRPr = ((org.docx4j.wml.R)existingP.getParagraphContent().get(rIndex)).getRPr(); if ( existingRPr !=null ) newR.setRPr(existingRPr); return newR; }
private void addRunToDocFrag(JaxbXmlPart sourcePart, DocumentFragment docfrag, String string, RPr rPr) { org.docx4j.wml.R run = Context.getWmlObjectFactory().createR(); if (rPr!=null) { run.setRPr(rPr); } org.docx4j.wml.Text text = Context.getWmlObjectFactory().createText(); run.getRunContent().add(text); if (string.startsWith(" ") || string.endsWith(" ") ) { // TODO: tab character? log.debug("setting xml:space=preserve for '" + string + "'"); text.setSpace("preserve"); } text.setValue(string); Document tmpDoc = XmlUtils.marshaltoW3CDomDocument(run); // avoid WRONG_DOCUMENT_ERR: A node is used in a different document than the one that created it. // but NOT_SUPPORTED_ERR: The implementation does not support the requested type of object or operation. // at com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.importNode // docfrag.appendChild(fragdoc.importNode(document, true)); // so: XmlUtils.treeCopy(tmpDoc.getDocumentElement(), docfrag); }
text.setSpace("preserve");
private void addRun( String cssClass, Map<String, CSSValue> cssMap, String theText, boolean isRTL) { R run = Context.getWmlObjectFactory().createR(); Text text = Context.getWmlObjectFactory().createText(); text.setValue( theText ); if (theText.startsWith(" ") || theText.endsWith(" ") ) { text.setSpace("preserve"); } run.getContent().add(text); getListForRun().getContent().add(run); // Run level styling RPr rPr = Context.getWmlObjectFactory().createRPr(); run.setRPr(rPr); formatRPr(rPr, cssClass, cssMap); if (isRTL) { rPr.setRtl(new BooleanDefaultTrue()); } }