Package org.docx4j.wml

Examples of org.docx4j.wml.P


    for( P p : fl.getStarts() ) {
      int index;
      if (p.getParent() instanceof ContentAccessor) {
        // 2.8.1
        index = ((ContentAccessor)p.getParent()).getContent().indexOf(p);
        P newP = FieldsPreprocessor.canonicalise(p, fieldRefs);
        log.debug("Canonicalised: " + XmlUtils.marshaltoString(newP, true, true));       
        ((ContentAccessor)p.getParent()).getContent().set(index, newP);
      } else if (p.getParent() instanceof java.util.List) {
        // 3.0
        index = ((java.util.List)p.getParent()).indexOf(p);
        P newP = FieldsPreprocessor.canonicalise(p, fieldRefs);
        log.debug("NewP length: " + newP.getContent().size() );
        ((java.util.List) p.getParent()).set(index, newP);
      } else if (p.getParent() instanceof CTTextbox) {
        // 3.0.1
        index = ((CTTextbox) p.getParent()).getTxbxContent().getContent().indexOf(p);
        P newP = FieldsPreprocessor.canonicalise(p, fieldRefs);
        log.debug("Canonicalised: "+ XmlUtils.marshaltoString(newP, true, true));
        ((CTTextbox) p.getParent()).getTxbxContent().getContent().set(index, newP);
      } else {
        throw new Docx4JException("Unexpected parent: "+ p.getParent().getClass().getName());
      }
View Full Code Here


   
    // Reset state
    listStack = new LinkedList<ListSpec>();
   
    List<Object> resultElts = new ArrayList<Object>();
    P paragraph = null;
   
    for (Object o : bodyElts) {
     
      if (o instanceof JAXBElement) {
        o = ((JAXBElement)o).getValue();
      }

      /*
       * We can nest lists, but any time a bare table
       * or paragraph etc is encountered (ie anything not a list item),
       * we'll finish the lists.
       */
         
      if (o instanceof P) {
       
        paragraph = (P)o;       
        PPr ppr = propertyResolver.getEffectivePPr(paragraph.getPPr());
       
        NumPr numPr = ppr.getNumPr();
       
        if (numPr==null) {
          closeAllLists();
View Full Code Here

    SdtBlock sdtShading = null;
    PBdr lastBorders = null;
    PBdr currentBorders = null;
    CTShd lastShading = null;
    CTShd currentShading = null;
    P paragraph = null;
   
    for (Object o : bodyElts) {
      if (o instanceof JAXBElement) {
        o = ((JAXBElement)o).getValue();
      }
      if (o instanceof P) {
        paragraph = (P)o;
        paragraphElts = groupRuns(paragraph.getContent());
        paragraph.getContent().clear();
        if (paragraphElts != null) {
          paragraph.getContent().addAll(paragraphElts);
        }

        currentBorders = null;
        currentShading = null;
        if (paragraph.getPPr() != null ) {
          // TODO: use effective ppr properties!
          // ie take styles into account       
          currentBorders = paragraph.getPPr().getPBdr();
          currentShading = paragraph.getPPr().getShd();
        }

        if ( bordersChanged(currentBorders, lastBorders )) {
          // could mean null to borders; borders to null; or bordersA to bordersB
          if (currentBorders == null) {
View Full Code Here

    // each list-item!!    
   
    for(Object o :  contentIn) {
     
      if (o instanceof P) {
        P p = (P)o;
        PPr effPPr = getEffectivePPr(p);
       
//        if (inList) {
//         
//          if (isListItem(effPPr)) {
//            // still in list; continue
//           
//          } else {
//            inList = false; // now continue
//          }
//         
//        } else {

          if (isListItem(effPPr)) {
            inList = true;
           
            if (hasBreakBefore(effPPr)) {
              // insert a p containing a break
              P newP = new P();
              newP.setPPr(new PPr());
              newP.getPPr().setPageBreakBefore(new BooleanDefaultTrue());
              newContent.add(newP);
             
              // turn off PageBreakBefore in this p
              PPr pPr = p.getPPr();
              if (pPr == null) {
View Full Code Here

    RunFontSelector rfs = createRunFontSelector(wordMLPackage);
   
    // For each w:p, test w:r/w:t
    for (int i=0; i<document.getContent().size(); i++) {
     
      P p = (P)document.getContent().get(i);
     
      PPr pPr = p.getPPr();
      RPr rPr = ((R)p.getContent().get(0)).getRPr();
     
      Text wmlText = (Text)XmlUtils.unwrap(((R)p.getContent().get(0)).getContent().get(0));
     
      log.debug(wmlText.getValue());
     
      Object result = rfs.fontSelector(pPr, rPr, wmlText);
//      System.out.println(result.getClass().getName());
View Full Code Here

//        }
//      }
     
      if (o instanceof P) {
       
        P p = (P)o;
       
        if ( p.getPPr()==null ) {
          p.setPPr( Context.getWmlObjectFactory().createPPr() );
        }
       
        if (p.getPPr().getPStyle()==null) {
                   
//            String newStyle = styleMapping.get(defaultParagraphStyle);
//            if (newStyle==null) {
//              newStyle=defaultParagraphStyle;
//            }
            String newStyle=defaultParagraphStyle;
            p.getPPr().setPStyle(Context.getWmlObjectFactory().createPPrBasePStyle() )
            if (tblStack.size()==0) {           
              p.getPPr().getPStyle().setVal(newStyle);
            } else {
              // We're in a table
              String resultStyle = getCellPStyle(newStyle, true);
              if (resultStyle==null) {
                p.getPPr().getPStyle().setVal(newStyle);               
              } else {
                p.getPPr().getPStyle().setVal(resultStyle);
              }
            }
          //}
        } else {       
          PStyle pstyle = p.getPPr().getPStyle();         
          String styleVal = pstyle.getVal();
          if (styleVal!=null) {
            if (tblStack.size()>0) {           
              log.debug("Fixing " + pstyle.getVal());
              String newStyle = getCellPStyle(styleVal,
                          styleVal.equals(defaultParagraphStyle));
              if (newStyle==null) {
                log.debug("getCellPStyle returned null, so leave as is");
              } else {
                p.getPPr().getPStyle().setVal(newStyle);
              }
            }
          }
        }
       
View Full Code Here

    RunFontSelector rfs = createRunFontSelector(wordMLPackage);
   
    // For each w:p, test w:r/w:t
    for (int i=0; i<document.getContent().size(); i++) {
     
      P p = (P)document.getContent().get(i);
     
      PPr pPr = p.getPPr();
      RPr rPr = ((R)p.getContent().get(0)).getRPr();
     
      Text wmlText = (Text)XmlUtils.unwrap(((R)p.getContent().get(0)).getContent().get(0));
     
      log.debug(wmlText.getValue());
     
      Object result = rfs.fontSelector(pPr, rPr, wmlText);
//      System.out.println(result.getClass().getName());
View Full Code Here

 

 
  protected P createNumberedP(int numId, int ilvl) {
   
    P p = wmlObjectFactory.createP();
        // Create object for pPr
        PPr ppr = wmlObjectFactory.createPPr();
        p.setPPr(ppr);
            // Create object for numPr
            PPrBase.NumPr pprbasenumpr = wmlObjectFactory.createPPrBaseNumPr();
            ppr.setNumPr(pprbasenumpr);
                // Create object for ilvl
                PPrBase.NumPr.Ilvl pprbasenumprilvl = wmlObjectFactory.createPPrBaseNumPrIlvl();
                pprbasenumpr.setIlvl(pprbasenumprilvl);
                    pprbasenumprilvl.setVal( BigInteger.valueOf( ilvl) );
                // Create object for numId
                PPrBase.NumPr.NumId pprbasenumprnumid = wmlObjectFactory.createPPrBaseNumPrNumId();
                pprbasenumpr.setNumId(pprbasenumprnumid);
                    pprbasenumprnumid.setVal( BigInteger.valueOf( numId) );
            // Create object for pStyle
//            PPrBase.PStyle pprbasepstyle = wmlObjectFactory.createPPrBasePStyle();
//            ppr.setPStyle(pprbasepstyle);
//                pprbasepstyle.setVal( "ListParagraph");
        // Create object for r
        R r = wmlObjectFactory.createR();
        p.getContent().add( r);
            // Create object for t (wrapped in JAXBElement)
            Text text = wmlObjectFactory.createText();
            JAXBElement<org.docx4j.wml.Text> textWrapped = wmlObjectFactory.createRT(text);
            r.getContent().add( textWrapped);
                text.setValue( "list " + numId + ", ilvl " + ilvl);
View Full Code Here

    return p;
    }
 
  protected P createUnnumberedP() {
   
    P p = wmlObjectFactory.createP();
        R r = wmlObjectFactory.createR();
        p.getContent().add( r);
            // Create object for t (wrapped in JAXBElement)
            Text text = wmlObjectFactory.createText();
            JAXBElement<org.docx4j.wml.Text> textWrapped = wmlObjectFactory.createRT(text);
            r.getContent().add( textWrapped);
                text.setValue( "UnnumberedP");
View Full Code Here

    else if (pos==0) {
      // Need to look in preceding run
      Object rParent = r.getParent();
      // Handle just the case where this is w:p for now
      if(rParent instanceof P) {
        P parentP = (P)rParent;
        pos = getPos(parentP.getContent(), r);
        if (pos<0) {
          log.error("Couldn't locate w:r in w:p");
        } else if (pos>0) {
          Object beforeR = parentP.getContent().get(pos-1);
          if (beforeR instanceof R) {
            List list = ((R)beforeR).getContent();
            Object previous = list.get(list.size()-1);
            if (previous instanceof Br) {
              firstBr=false;
View Full Code Here

TOP

Related Classes of org.docx4j.wml.P

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.