Package org.docx4j.model.listnumbering.Emulator

Examples of org.docx4j.model.listnumbering.Emulator.ResultTriple


            if (p.getPPr().getNumPr().getIlvl()!=null) {
              levelId = p.getPPr().getNumPr().getIlvl().getVal().toString();
            }
          }
         
          ResultTriple rt = Emulator.getNumber(wordMLPackage, pStyleVal, numId, levelId);
         
          Text text = (Text)XmlUtils.unwrap(
              ((R)p.getContent().get(0)).getContent().get(0));
          String content = text.getValue();
         
View Full Code Here


      if (pPrDirect.getNumPr()!=null) {
        numId = pPrDirect.getNumPr().getNumId()==null ? null : pPrDirect.getNumPr().getNumId().getVal().toString();
        levelId = pPrDirect.getNumPr().getIlvl()==null ? null : pPrDirect.getNumPr().getIlvl().getVal().toString();
      }
     
          ResultTriple triple = org.docx4j.model.listnumbering.Emulator.getNumber(
              conversionContext.getWmlPackage(), pStyleVal, numId, levelId);  
         

      if (triple==null) {
        getLog().debug("computed number ResultTriple was null");
          } else {
        if (triple.getBullet() != null) {
          //numberText = (triple.getBullet() + " ");
          numberText = "\u2022  ";
        } else if (triple.getNumString() == null) {
          getLog().error("computed NumString was null!");
          numberText = ("?");
        } else {
          numberText = (triple.getNumString() + " ");
        }
          }
      if (numberText!=null) {
        currentParent.appendChild(document.createTextNode(
            numberText + " "));       
View Full Code Here

        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());
                } else {
                 
              createFoAttributes(context.getWmlPackage(), rPrParagraphMark, foListItemLabel );                 
              createFoAttributes(context.getWmlPackage(), rPrParagraphMark, foListItemBody )
             
//                  setFont( context,  foListItemLabelBody, rPrParagraphMark.getRFonts());                  
                  setFont( context,  foListItemLabelBody,  pPr,  rPrParagraphMark,  triple.getNumString());
                }
               
              } else {
                RPr actual = XmlUtils.deepCopy(triple.getRPr()); // clone, so the ilvl rpr is not altered
//                System.out.println(XmlUtils.marshaltoString(rPrParagraphMark));
               
                // pMark overrides numbering, except for font
                // (which makes sense, since that would change the bullet)
                // so set the font
                setFont( context,  foListItemLabelBody,  pPr,  actual,  triple.getNumString());
                // .. before taking rPrParagraphMark into account
                  StyleUtil.apply(rPrParagraphMark, actual);
//                System.out.println(XmlUtils.marshaltoString(actual));
                 
            createFoAttributes(context.getWmlPackage(), actual, foListItemLabel );
            createFoAttributes(context.getWmlPackage(), actual, foListItemBody );
           
              }
                           
             
              int numChars=1;
              if (triple.getBullet()!=null ) {
                foListItemLabelBody.setTextContent(triple.getBullet() );
              } else if (triple.getNumString()==null) {
                log.debug("computed NumString was null!");
                if (log.isDebugEnabled() ) {
                  foListItemLabelBody.setAttribute("color", "red");
                  foListItemLabelBody.setTextContent("null#");
                }
                numChars=0;
            } else {
            Text number = document.createTextNode( triple.getNumString() );
            foListItemLabelBody.appendChild(number);
            numChars = triple.getNumString().length();
            }
             
              // Indent (setting provisional-distance-between-starts)
              // Indent on direct pPr trumps indent in pPr in numbering, which trumps indent
            // specified in a style.  Well, not exactly, components which aren't set in
              // the direct formatting will be contributed by the numbering's indent settings
              Indent indent = new Indent(pPrDirect.getInd(), triple.getIndent());
              if (indent.isHanging() ) {
              indent.setXslFOListBlock(foListBlock, -1);               
              } else {
               
                int numWidth = 90 * numChars; // crude .. TODO take font size into account
View Full Code Here

     
      context.getLog().debug("numbering, using style '" + pStyleVal + "'; numId=" + numId + "; ilvl " + levelId);     
     
        try {
                   
          ResultTriple triple = org.docx4j.model.listnumbering.Emulator.getNumber(
              context.getWmlPackage(), pStyleVal, numId, levelId);  
         

      if (triple==null) {
        context.getLog().debug("computed number ResultTriple was null");
            return null;
          }
     
      String styleVal = "";
     
        if (triple.getBullet()!=null ) {
          //return (triple.getBullet() + " " ); 
          // The old code did that:-
          // https://github.com/plutext/docx4j/commit/7627863e47c5dc7b3c91290b8d993ae5a7cd9fab#docx4j/src/main/java/org/docx4j/convert/out/html/AbstractHtmlExporter.java
          //What is wrong with that approach?
          //
          return "\u2022  ";
        // see notes in docx2xhtmlNG2.xslt as to why we don't use •
         
        } else if (triple.getNumString()==null) {
          context.getLog().debug("computed NumString was null (which may be ok)");
          return " ";
         
        } else {
        return triple.getNumString() + " " ;
        }
     
    } catch (Exception e) {
      e.printStackTrace();
      // System.out.println(e.toString() );
View Full Code Here

        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(
                conversionContext.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(
                    conversionContext.getWmlPackage(), pStyleVal,
                    pPr.getNumPr().getNumId().getVal().toString(),
                    ilvlString );              
              }
            }
       
        if (triple==null) {
          getLog().warn("computed number ResultTriple was null");
              if (getLog().isDebugEnabled() ) {
                foListItemLabelBody.setTextContent("nrt");
              }
            } 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
                  XsltFOFunctions.setFont( conversionContext,  foListItemLabelBody, pPr, rPr,  triple.getNumString());               
                } else {

                  createFoAttributes(conversionContext.getWmlPackage(), rPrParagraphMark, foListItemLabel );                 
                  createFoAttributes(conversionContext.getWmlPackage(), rPrParagraphMark, foListItemBody );
                 
              XsltFOFunctions.setFont( conversionContext,  foListItemLabelBody, pPr, rPrParagraphMark,  triple.getNumString());                 
                }
               
              } else {
                RPr actual = XmlUtils.deepCopy(triple.getRPr()); // clone, so the ilvl rpr is not altered
//                System.out.println(XmlUtils.marshaltoString(rPrParagraphMark));
               
                // pMark overrides numbering, except for font
                // (which makes sense, since that would change the bullet)
                // so set the font
                XsltFOFunctions.setFont( conversionContext,  foListItemLabelBody,  pPr,  actual,  triple.getNumString());
                // .. before taking rPrParagraphMark into account
                  StyleUtil.apply(rPrParagraphMark, actual);
//                System.out.println(XmlUtils.marshaltoString(actual));
                 
            createFoAttributes(conversionContext.getWmlPackage(), actual, foListItemLabel );
            createFoAttributes(conversionContext.getWmlPackage(), actual, foListItemBody );               
              }             

/*             
              // Indent (in combination with provisional-distance-between-starts
              // above
              if (triple.getIndent()!=null) {
                Indent indent = new Indent(triple.getIndent());
              //foListBlock.setAttribute(Indent.FO_NAME, "2in");
              indent.setXslFO(foListBlock);
              }
             
  */     
            }

          int numChars=1;             
            if (triple.getBullet()!=null ) {
              foListItemLabelBody.setTextContent(triple.getBullet() );
            } else if (triple.getNumString()==null) {
              getLog().warn("computed NumString was null!");
              if (getLog().isDebugEnabled() ) {
                foListItemLabelBody.setTextContent("nns");
              }
              numChars=0;               
          } else {
          Text number = document.createTextNode( triple.getNumString() );
          foListItemLabelBody.appendChild(number);
          numChars = triple.getNumString().length();           
          }
       
            // Indent (setting provisional-distance-between-starts)
            // Indent on direct pPr trumps indent in pPr in numbering, which trumps indent
          // specified in a style.  Well, not exactly, components which aren't set in
            // the direct formatting will be contributed by the numbering's indent settings
            Indent indent = new Indent(pPrDirect.getInd(), triple.getIndent());
            if (indent.isHanging() ) {
            indent.setXslFOListBlock(foListBlock, -1);               
            } else {
             
              int numWidth = 90 * numChars; // crude .. TODO take font size into account
View Full Code Here

TOP

Related Classes of org.docx4j.model.listnumbering.Emulator.ResultTriple

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.