Examples of PPr


Examples of org.docx4j.wml.PPr

      HpsMeasure expressStyleFontSize = null;
      if (expressStyle.getRPr()!=null) {
        expressStyleFontSize=expressStyle.getRPr().getSz();
      }
      // Font size and jc for the style following its based on values
      PPr effectivePPr = propertyResolver.getEffectivePPr(styleVal);
      Jc effectiveJc = effectivePPr.getJc();
     
      RPr effectiveRPr = propertyResolver.getEffectiveRPr(styleVal);
      HpsMeasure effectiveFontSize = null;
      if (effectiveRPr!=null) {
        effectiveFontSize=effectiveRPr.getSz();
View Full Code Here

Examples of org.docx4j.wml.PPr

    // 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());
View Full Code Here

Examples of org.docx4j.wml.PPr

//      log.info("childResults:" + childResults.getClass().getName() );
     
     
        try {
         
          PPr pPrDirect = null;
         
          // Get the pPr node as a JAXB object,
          // so we can read it using our standard
          // methods.  Its a bit sad that we
          // can't just adorn our DOM tree with the
          // original JAXB objects?
          PPr pPr = null;
          RPr rPr = null;
          RPr rPrParagraphMark = null// required for list item label
          if (pPrNodeIt==null) {  // Never happens?           
          if (log.isDebugEnabled()) {
            log.debug("Here after all!!");
          }
            pPr = propertyResolver.getEffectivePPr(defaultParagraphStyleId);
            rPr = propertyResolver.getEffectiveRPr(defaultParagraphStyleId);
            rPrParagraphMark = rPr;
          } else {
            Node n = pPrNodeIt.nextNode();
            if (n==null) {
              if (log.isDebugEnabled()) {
                log.debug("pPrNodeIt.nextNode() was null (ie there is no pPr in this p)");
              }
                pPr = propertyResolver.getEffectivePPr(defaultParagraphStyleId);
                rPr = propertyResolver.getEffectiveRPr(defaultParagraphStyleId);
                // TODO - in this case, we should be able to compute once,
                // and on subsequent calls, just return pre computed value
            } else {
              if (log.isDebugEnabled()) {
                log.debug( "P actual pPr: "+ XmlUtils.w3CDomNodeToString(n) );
              }
              Unmarshaller u = Context.jc.createUnmarshaller();     
              u.setEventHandler(new org.docx4j.jaxb.JaxbValidationEventHandler());
              Object jaxb = u.unmarshal(n);
            pPrDirect =  (PPr)jaxb;
            pPr = propertyResolver.getEffectivePPr(pPrDirect)
            if ((pPr==null) && (log.isDebugEnabled())) {
              log.debug("pPr null; obtained from: " + XmlUtils.w3CDomNodeToString(n) );
            }
           
            // On the block representing the w:p, we want to put both
              // pPr and rPr attributes.
           
            if (log.isDebugEnabled()) {
              log.debug("getting rPr for paragraph style");
            }
            rPr = propertyResolver.getEffectiveRPr(null, pPrDirect);
              // rPr in pPr direct formatting only applies to paragraph mark,
              // and by virtue of that, to list item label,
              // so pass null here
            // Now, work out the value for list item label
                rPrParagraphMark = XmlUtils.deepCopy(rPr);
//              System.out.println("p rpr-->" + XmlUtils.marshaltoString(pPrDirect.getRPr()));
               
                StyleUtil.apply(pPrDirect.getRPr(), rPrParagraphMark);
           
            }
          }         

      if (log.isDebugEnabled() && pPr!=null) {       
        log.debug("P effective pPr: "+ XmlUtils.marshaltoString(pPr, true, true));         
      }
         
            // Create a DOM builder and parse the fragment     
      Document document = XmlUtils.getNewDocumentBuilder().newDocument();
     
      //log.info("Document: " + document.getClass().getName() );
     
      boolean indentHandledByNumbering = false;
     
      Element foBlockElement;
      Element foListBlock = null;
      if (pPr!=null
          && pPr.getNumPr()!=null
          && pPr.getNumPr().getNumId()!=null
          && pPr.getNumPr().getNumId().getVal().longValue()!=0 //zero means no numbering
          ) {
       
       
        // Its a list item.  At present we make a new list-block for
        // each list-item. This is not great; DocumentModel will ultimately
        // allow us to use fo:list-block properly.

        /* Create something like:
         *      
          <fo:list-block provisional-distance-between-starts="0.5in" start-indent="0.5in">
            <fo:list-item>
              <fo:list-item-label>
                <fo:block font-family="Times New Roman">-</fo:block>
              </fo:list-item-label>
              <fo:list-item-body start-indent="body-start()">
                <fo:block font-family="Times New Roman" font-size="9.0pt" line-height="100%" space-after="0.08in" space-before="0.08in" text-align="justify">
                  <inline xmlns="http://www.w3.org/1999/XSL/Format" id="clauseDPI5123341"/>Content goes here...
                </fo:block>
              </fo:list-item-body>
            </fo:list-item>
          </fo:list-block>
         */       

        foListBlock = document.createElementNS("http://www.w3.org/1999/XSL/Format",
            "fo:list-block");
        document.appendChild(foListBlock);
               
//        foListBlock.setAttribute("provisional-distance-between-starts", "0.5in");
       
        // Need to apply shading at fo:list-block level
        if (pPr.getShd()!=null) {
          PShading pShading = new PShading(pPr.getShd());
          pShading.setXslFO(foListBlock);
        }
       
        Element foListItem = document.createElementNS("http://www.w3.org/1999/XSL/Format",
            "fo:list-item");
        foListBlock.appendChild(foListItem);       

       
        Element foListItemLabel = document.createElementNS("http://www.w3.org/1999/XSL/Format",
            "fo:list-item-label");
        foListItem.appendChild(foListItemLabel);
       
        Element foListItemLabelBody = document.createElementNS("http://www.w3.org/1999/XSL/Format",
            "fo:block");
        foListItemLabel.appendChild(foListItemLabelBody);
       
        Element foListItemBody = document.createElementNS("http://www.w3.org/1999/XSL/Format",
            "fo:list-item-body");
        foListItem.appendChild(foListItemBody)
        foListItemBody.setAttribute(Indent.FO_NAME, "body-start()");
       
            ResultTriple triple;
            if (pPrDirect!=null && pPrDirect.getNumPr()!=null) {
              triple = org.docx4j.model.listnumbering.Emulator.getNumber(
                context.getWmlPackage(), pStyleVal,
                pPrDirect.getNumPr().getNumId().getVal().toString(),
                pPrDirect.getNumPr().getIlvl().getVal().toString() );
            } else {
              // Get the effective values; since we already know this,
              // save the effort of doing this again in Emulator
              Ilvl ilvl = pPr.getNumPr().getIlvl();
              String ilvlString = ilvl == null ? "0" : ilvl.getVal().toString();
              triple = null;
              if (pPr.getNumPr().getNumId()!=null) {
                triple = org.docx4j.model.listnumbering.Emulator.getNumber(
                    context.getWmlPackage(), pStyleVal,
                    pPr.getNumPr().getNumId().getVal().toString(),
                    ilvlString );              
              }
            }
           
           
       
        if (triple==null) {
          log.warn("computed number ResultTriple was null");
              if (log.isDebugEnabled() ) {
                foListItemLabelBody.setAttribute("color", "red");
                foListItemLabelBody.setTextContent("null#");
              }
            } else {

              /* Format the list item label
               *
               * Since it turns out (in FOP at least) that the label and the body
               * don't have the same vertical alignment
               * unless font size is applied at the same level
               * (ie to both -label and -body, or to the block inside each),
               * we have to format the list-item-body as well.
               * This issue only manifests itself if the font size on
               * the outer list-block is larger than the font sizes
               * set inside it.
               */
             
              // OK just to override specific values
              // Values come from numbering rPr, unless overridden in p-level rpr
              if(triple.getRPr()==null) {
               
                if (pPr.getRPr()==null) {
                  // do nothing, since we're already inheriting the formatting in the style
                  // (as opposed to the paragraph mark formatting)
                  // EXCEPT for font
//                  setFont( context,  foListItemLabelBody, rPr.getRFonts());
                  setFont( context,  foListItemLabelBody,  pPr,  rPr,  triple.getNumString());
View Full Code Here

Examples of org.docx4j.wml.PPr

 
  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
View Full Code Here

Examples of org.docx4j.wml.PPr

    public static DocumentFragment fontSelector(AbstractWmlConversionContext conversionContext,
        NodeIterator pPrNodeIt,
        NodeIterator rPrNodeIt,
        NodeIterator textNodeIt) {

    PPr pPr = null;
    RPr rPr = null;
    Text text = null;
     
//      if (rPrNodeIt!=null)
    {
View Full Code Here

Examples of org.docx4j.wml.PPr

          // Get the pPr node as a JAXB object,
          // so we can read it using our standard
          // methods.  Its a bit sad that we
          // can't just adorn our DOM tree with the
          // original JAXB objects?
          PPr pPr = null;
          if (pPrNodeIt!=null) { //It is never null
            Node n = pPrNodeIt.nextNode();
            if (n!=null) {
              Unmarshaller u = Context.jc.createUnmarshaller();     
              u.setEventHandler(new org.docx4j.jaxb.JaxbValidationEventHandler());
              Object jaxb = u.unmarshal(n);
              try {
                pPr =  (PPr)jaxb;
              } catch (ClassCastException e) {
                context.getLog().error("Couldn't cast " + jaxb.getClass().getName() + " to PPr!");
              }                       
            }
          }
         
            // Create a DOM document to take the results     
      Document document = XmlUtils.getNewDocumentBuilder().newDocument();     
        //log.info("Document: " + document.getClass().getName() );
      Element xhtmlBlock = document.createElement(htmlElementName);     
      document.appendChild(xhtmlBlock);
             
      if (context.getLog().isDebugEnabled() && pPr!=null) {         
        context.getLog().debug(XmlUtils.marshaltoString(pPr, true, true));         
      }       
       
      // Set @class
      context.getLog().debug(pStyleVal);
      Tree<AugmentedStyle> pTree = styleTree.getParagraphStylesTree();   
      org.docx4j.model.styles.Node<AugmentedStyle> asn = pTree.get(pStyleVal);
      String classVal = StyleTree.getHtmlClassAttributeValue(pTree, asn);     
      xhtmlBlock.setAttribute("class", classVal);
   
     
      // Does our pPr contain anything else?
      boolean ignoreBorders = (htmlElementName.equals("p"));
      if (pPr!=null) {
       
        // Is there numbering indentation to honour?
        if (pPr.getNumPr()!=null
            && pPr.getNumPr().getNumId()!=null
            && pPr.getNumPr().getNumId().getVal().longValue()!=0 //zero means no numbering
            ) {
          Ind numInd = org.docx4j.model.listnumbering.Emulator.getInd(
                context.getWmlPackage(), pStyleVal,
                pPr.getNumPr().getNumId().getVal().toString(),
                pPr.getNumPr().getIlvl().getVal().toString() );
          if (numInd!=null) {
                Indent indent = new Indent(pPr.getInd(), numInd);
                pPr.setInd((Ind)indent.getObject());           
          }
        }
       
        StringBuilder inlineStyle =  new StringBuilder();
        HtmlCssHelper.createCss(context.getWmlPackage(), pPr, inlineStyle, ignoreBorders);       
View Full Code Here

Examples of org.docx4j.wml.PPr

  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());
    }
  }
View Full Code Here

Examples of org.docx4j.wml.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);
   
  }
View Full Code Here

Examples of org.docx4j.wml.PPr

      //          by 29068 millipoints. (See position 1:1038)


      // now add the sectPr
        P p = Context.getWmlObjectFactory().createP();
          PPr ppr = Context.getWmlObjectFactory().createPPr();
          p.setPPr(ppr);
          ppr.setSectPr(sectPr);
         
      contents.add(p);
     
    }
   
View Full Code Here

Examples of org.docx4j.wml.PPr

      org.docx4j.wml.ObjectFactory wmlObjectFactory = Context.getWmlObjectFactory();

      P p = wmlObjectFactory.createP();
          // Create object for pPr
          PPr ppr = wmlObjectFactory.createPPr();
          p.setPPr(ppr);
              // Create object for rPr
              ParaRPr pararpr = wmlObjectFactory.createParaRPr();

              // Create object for spacing
              PPrBase.Spacing pprbasespacing = wmlObjectFactory.createPPrBaseSpacing();
              ppr.setSpacing(pprbasespacing);
                  pprbasespacing.setBefore( BigInteger.valueOf( 800) );
                  pprbasespacing.setAfter( BigInteger.valueOf( 800) );
          // Create object for r
          R r = wmlObjectFactory.createR();
          p.getContent().add( r);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.