private static void pasteSectPr(List<Object> contentList, SectPr sectPr) { P p = new P(); PPr ppr = Context.getWmlObjectFactory().createPPr(); p.setPPr(ppr); ppr.setSectPr(sectPr); contentList.add(1, p); }
private P generateTocEntry(TocStyles tocStyles){ // Create object for p P p3 = wmlObjectFactory.createP(); p3.setPPr(generateTocEntryPPr(tocStyles)); if(hyperlink){ p3.getContent().add(generateTocEntryHyperlink()); } else { p3.getContent().addAll(generateTocEntryContent()); } return p3; }
private P canonicaliseInstance(P p) { P newP = Context.getWmlObjectFactory().createP(); newP.setPPr(p.getPPr()); newR = Context.getWmlObjectFactory().createR(); // fieldRPr = null; stack = new LinkedList<FieldRef>(); if(log.isDebugEnabled()) { log.debug(XmlUtils.marshaltoString(p)); } handleContent(p.getContent(), newP); // log.debug(XmlUtils.marshaltoString(newP, true)); return newP; }
private static void updateParagraph(P paragraph) { boolean containsPageBreak = checkPageBreak(paragraph.getContent()); if (containsPageBreak) { if (paragraph.getPPr() == null) { paragraph.setPPr(new PPr()); } paragraph.getPPr().setPageBreakBefore(new BooleanDefaultTrue()); } }
private static P generateTocHeading(String headingStyleId, String tocHeading) { // Create object for p P p = wmlObjectFactory.createP(); // Create object for pPr PPr ppr = wmlObjectFactory.createPPr(); p.setPPr(ppr); // Create object for pStyle PPrBase.PStyle pprbasepstyle = wmlObjectFactory.createPPrBasePStyle(); ppr.setPStyle(pprbasepstyle); pprbasepstyle.setVal(headingStyleId); // Create object for r R r = wmlObjectFactory.createR(); p.getContent().add(r); // Create object for t (wrapped in JAXBElement) Text text = wmlObjectFactory.createText(); JAXBElement<Text> textWrapped = wmlObjectFactory.createRT(text); r.getContent().add(textWrapped); text.setValue(tocHeading); return p; }
/** * Create a paragraph containing the string simpleText, styled * using the specified style (up to user to ensure it is a paragraph style) * without adding it to the document. * * @param styleId * @param text * @return */ public org.docx4j.wml.P createStyledParagraphOfText(String styleId, String text) { org.docx4j.wml.P p = createParagraphOfText(text); if (getPropertyResolver().activateStyle(styleId)) { // Style is available org.docx4j.wml.ObjectFactory factory = Context.getWmlObjectFactory(); org.docx4j.wml.PPr pPr = factory.createPPr(); p.setPPr(pPr); org.docx4j.wml.PPrBase.PStyle pStyle = factory.createPPrBasePStyle(); pPr.setPStyle(pStyle); pStyle.setVal(styleId); } return p; }
lastP.setPPr(Context.getWmlObjectFactory().createPPr());
p.setPPr( Context.getWmlObjectFactory().createPPr() );
@Override public P createP(String style) { P p = myFactory.createP(); PPr pPr = myFactory.createPPr(); p.setPPr(pPr); myParaContainer.addP(p); if (style == null) { myBlockFormatProvider.getPPr(pPr); myBlockFormatProvider.adjustPPrForFormatting(pPr); if (StyleUtil.isEmpty(p.getPPr())) { p.setPPr(null); } else if (StyleUtil.isEmpty(p.getPPr().getRPr())) { p.getPPr().setRPr(null); } } else { createPStyle(style); } return p; }
@Override public void addBlankLine(final BigInteger size, final String styleId) { if (size.compareTo(BigInteger.ZERO) > 0) { // now add empty for spacing P p = myFactory.createP(); PPr pPr = myFactory.createPPr(); p.setPPr(pPr); myParaContainer.addP(p); if (styleId != null && !styleId.isEmpty()) { if (pPr.getPStyle() == null) { PStyle pStyle = myDocxHelper.myFactory.createPPrBasePStyle(); pPr.setPStyle(pStyle); } pPr.getPStyle().setVal(styleId); } // Create new Spacing which we override Spacing spacing = myFactory.createPPrBaseSpacing(); pPr.setSpacing(spacing); spacing.setBefore(BigInteger.ZERO); spacing.setAfter(BigInteger.ZERO); spacing.setLine(size); spacing.setLineRule(STLineSpacingRule.EXACT); } }
p.setPPr(pPr);
private static void pasteSectPr(List<Object> contentList, SectPr sectPr) { P p = new P(); PPr ppr = Context.getWmlObjectFactory().createPPr(); p.setPPr(ppr); ppr.setSectPr(sectPr); contentList.add(1, p); }
private P generateTocEntry(TocStyles tocStyles){ // Create object for p P p3 = wmlObjectFactory.createP(); p3.setPPr(generateTocEntryPPr(tocStyles)); if(hyperlink){ p3.getContent().add(generateTocEntryHyperlink()); } else { p3.getContent().addAll(generateTocEntryContent()); } return p3; }
private P canonicaliseInstance(P p) { P newP = Context.getWmlObjectFactory().createP(); newP.setPPr(p.getPPr()); newR = Context.getWmlObjectFactory().createR(); // fieldRPr = null; stack = new LinkedList<FieldRef>(); if(log.isDebugEnabled()) { log.debug(XmlUtils.marshaltoString(p)); } handleContent(p.getContent(), newP); // log.debug(XmlUtils.marshaltoString(newP, true)); return newP; }
private static int countHeader = 0; public static void createHeaderForSection(WordprocessingMLPackage wordprocessingMLPackage, String headerString) throws Exception { MainDocumentPart documentPart = wordprocessingMLPackage.getMainDocumentPart(); HeaderPart headerPart = new HeaderPart(new PartName("/word/header"+ (++countHeader) +".xml")); headerPart.setPackage(wordprocessingMLPackage); headerPart.addAltChunk(AltChunkType.Html, headerString.getBytes("UTF-8")); headerPart.setRelationshipType(Namespaces.HEADER); Relationship relationship = documentPart.addTargetPart(headerPart); SectPr sectPr = objectFactory.createSectPr(); HeaderReference headerReference = factory.createHeaderReference(); headerReference.setId(relationship.getId()); headerReference.setType(HdrFtrRef.DEFAULT); sectPr.getEGHdrFtrReferences().add(headerReference); P p = objectFactory.createP(); PPr ppr = objectFactory.createPPr(); p.setPPr(ppr); ppr.setSectPr(sectPr); wordprocessingMLPackage.getMainDocumentPart().getContent().add(p); }
private static void updateParagraph(P paragraph) { boolean containsPageBreak = checkPageBreak(paragraph.getContent()); if (containsPageBreak) { if (paragraph.getPPr() == null) { paragraph.setPPr(new PPr()); } paragraph.getPPr().setPageBreakBefore(new BooleanDefaultTrue()); } }
private static P generateTocHeading(String headingStyleId, String tocHeading) { // Create object for p P p = wmlObjectFactory.createP(); // Create object for pPr PPr ppr = wmlObjectFactory.createPPr(); p.setPPr(ppr); // Create object for pStyle PPrBase.PStyle pprbasepstyle = wmlObjectFactory.createPPrBasePStyle(); ppr.setPStyle(pprbasepstyle); pprbasepstyle.setVal(headingStyleId); // Create object for r R r = wmlObjectFactory.createR(); p.getContent().add(r); // Create object for t (wrapped in JAXBElement) Text text = wmlObjectFactory.createText(); JAXBElement<Text> textWrapped = wmlObjectFactory.createRT(text); r.getContent().add(textWrapped); text.setValue(tocHeading); return p; }
/** * Create a paragraph containing the string simpleText, styled * using the specified style (up to user to ensure it is a paragraph style) * without adding it to the document. * * @param styleId * @param text * @return */ public org.docx4j.wml.P createStyledParagraphOfText(String styleId, String text) { org.docx4j.wml.P p = createParagraphOfText(text); if (getPropertyResolver().activateStyle(styleId)) { // Style is available org.docx4j.wml.ObjectFactory factory = Context.getWmlObjectFactory(); org.docx4j.wml.PPr pPr = factory.createPPr(); p.setPPr(pPr); org.docx4j.wml.PPrBase.PStyle pStyle = factory.createPPrBasePStyle(); pPr.setPStyle(pStyle); pStyle.setVal(styleId); } return p; }