Package org.docx4j.model.structure

Examples of org.docx4j.model.structure.HeaderFooterPolicy


    List<SectionWrapper> sectionWrappers = wordMLPackage.getDocumentModel()
        .getSections();
    HeaderPart header = null;
    for (SectionWrapper sw : sectionWrappers) {
      HeaderFooterPolicy hfp = sw.getHeaderFooterPolicy();
      if (hfp.getDefaultHeader() != null) {
        header = hfp.getDefaultHeader();
      }
    }
   
    // Since the JAXB binding stuff seems to remember
    // old artifacts, we'll first create a 'clean' object here
View Full Code Here


    List<SectionWrapper> sectionWrappers = wordMLPackage.getDocumentModel()
        .getSections();
    HeaderPart header = null;
    for (SectionWrapper sw : sectionWrappers) {
      HeaderFooterPolicy hfp = sw.getHeaderFooterPolicy();
      if (hfp.getDefaultHeader() != null) {
        header = hfp.getDefaultHeader();
      }
    }

    // Since the JAXB binding stuff seems to remember
    // old artifacts, we'll first create a 'clean' object here
View Full Code Here

public class PageNumberInformationCollector {

  public static PageNumberInformation process(ConversionSectionWrapper sectionWrapper, boolean dummyPageNumbering) {
  PageNumberInformation ret = new PageNumberInformation(sectionWrapper.getSectPr());
  FieldVisitor fldVisitor = null;
  HeaderFooterPolicy headerFooterPolicy = sectionWrapper.getHeaderFooterPolicy();
    //If it is a dummyPageNumberInformation the data is read from the sectPr,
    //and it is assumed that there are no NUMPAGES and SECTIONPAGES fields
    //the result will allways be a single pass conversion.
    if (!dummyPageNumbering) {
      fldVisitor = new FieldVisitor(ret);
      TraversalUtil.visit(sectionWrapper.getContent(), fldVisitor);
      process(headerFooterPolicy.getFirstHeader(), fldVisitor);
      process(headerFooterPolicy.getFirstFooter(), fldVisitor);
      process(headerFooterPolicy.getDefaultHeader(), fldVisitor);
      process(headerFooterPolicy.getDefaultFooter(), fldVisitor);
      process(headerFooterPolicy.getEvenHeader(), fldVisitor);
      process(headerFooterPolicy.getEvenFooter(), fldVisitor);
    }
    return ret;
  }
View Full Code Here

    ConversionSectionWrapper section = null;
   
    for(int i=0; i<sections.size(); i++) {
     
      section = sections.get(i);
      HeaderFooterPolicy hf = section.getHeaderFooterPolicy();
      String sectionName = "s" + Integer.toString(i + 1);
     
      // FIRST, create simple-page-masters
      // has first header or footer?
      if (hf.getFirstHeader()!=null || hf.getFirstFooter()!=null) {
        // per spec, HeaderFooterPolicy checks the titlePg elememt
       
        lms.getSimplePageMasterOrPageSequenceMaster().add(
          createSimplePageMaster(sectionName + "-firstpage",
              section.getPageDimensions(),
              "firstpage",
            (hf.getFirstHeader()!=null),
            (hf.getFirstFooter()!=null) ));
      }
     
      // has even or odd header or footer?
        /*
         *       <w:headerReference w:type="even" r:id="rId12"/>
         *       <w:headerReference w:type="default" r:id="rId13"/>
         *      
         *       the default one is treated as odd.
         */
      if (hf.getEvenHeader()!=null || hf.getEvenFooter()!=null) {
       
        lms.getSimplePageMasterOrPageSequenceMaster().add(
          createSimplePageMaster(sectionName + "-evenpage"
              section.getPageDimensions(),
              "evenpage",
            (hf.getEvenHeader()!=null),
            (hf.getEvenFooter()!=null) ));
       
        // the xslt outputs a "-default" page as the odd-page
      }
     
      if (hf.getDefaultHeader()!=null
          || hf.getDefaultFooter()!=null) {
       
        lms.getSimplePageMasterOrPageSequenceMaster().add(
          createSimplePageMaster(sectionName + "-default"
              section.getPageDimensions(),
              "default",
            (hf.getDefaultHeader()!=null),
            (hf.getDefaultFooter()!=null) ));       
      }

      // simple: no headers and footers - after the first page anyway/
      // We still need this where there is just a first page header/footer,
      // since otherwise there'd be no page sequence for any content
      // after the first page, and you'd get:
      //    org.apache.fop.fo.pagination.PageProductionException:
      //    Subsequences exhausted in page-sequence-master ..., cannot recover.
      //
      // <w:sectPr>
      //   <w:headerReference w:type="first" r:id="rId7"/>
      // </w:sectPr>     
      if (
        (hf.getDefaultHeader() == null) && (hf.getDefaultFooter() == null)) {
        lms.getSimplePageMasterOrPageSequenceMaster().add(
            createSimplePageMaster(sectionName + "-simple"
                section.getPageDimensions(),
                "simple",
              true, true));
View Full Code Here

   
    log.debug("starting");
   
    List<ConversionSectionWrapper> conversionSections = new ArrayList<ConversionSectionWrapper>();
    ConversionSectionWrapper currentSectionWrapper = null;
    HeaderFooterPolicy previousHF =
        new HeaderFooterPolicy(document.getBody().getSectPr(), null, rels, evenAndOddHeaders);
 
    // SectionWrapper does work where sectPr is null (ie document has no body level sectPr),
    // so document.getBody().getSectPr() is ok
 
    currentSectionWrapper = createSectionWrapper(
View Full Code Here

    List<SectPr> sectPrs =  getSectPrs(document);

    // Local vars
    List<ConversionSectionWrapper> conversionSections = new ArrayList<ConversionSectionWrapper>();
    ConversionSectionWrapper currentSectionWrapper = null;
    HeaderFooterPolicy previousHF = null;
    int conversionSectionIndex = 0;
    List<Object> sectionContent = new ArrayList<Object>();
   
    // Now go through the document content,
   
    int sectPrIndex = 0; // includes continuous ones
    for (Object o : document.getBody().getContent() ) {
     
      if (o instanceof org.docx4j.wml.P) {
       
        if (((org.docx4j.wml.P)o).getPPr() != null ) {
         
          org.docx4j.wml.PPr ppr = ((org.docx4j.wml.P)o).getPPr();
          if (ppr.getSectPr()!=null) {

            /* If the *following* section is continuous,
             * don't add *this* section, because we want our
             * sectionWrapper to surround the content preceding
             * both sectPr.
             *
             * When we do eventually create that section wrapper,
             * it must use the header/footer settings from
             * *this* section.
             *
             * There is a special case to consider:
             * 
                    <w:sectPr>
                      <w:type w:val="continuous"/>
                      <w:pgSz <---- different values from previous sectPr
             *
             * In this case, Word will render a page break,
             * but:
             * 1. still show it as continuous
             * 2. still use the headers/footers from this section
             * 
             */
           
            boolean ignoreThisSection = false;
            SectPr followingSectPr = sectPrs.get(++sectPrIndex);
            if ( followingSectPr.getType()!=null
                     && followingSectPr.getType().getVal().equals("continuous")) {

              log.info("following sectPr is continuous; this section wrapper must include its contents ");
              ignoreThisSection = true;
             
            }
           
           
            if (ignoreThisSection) {
              // In case there are some headers/footers that apply to both this content and the
              // content before the continuous sectPr,
              // or that need to get inherited by the section after the continuous sectPr
              previousHF = new HeaderFooterPolicy(ppr.getSectPr(), previousHF, rels, evenAndOddHeaders);

             
              PgSz pgSzThis = ppr.getSectPr().getPgSz();
              PgSz pgSzNext = followingSectPr.getPgSz();
              if (insertPageBreak( pgSzThis,  pgSzNext)) {
View Full Code Here

        .load(new java.io.File(inputfilepath));

    List<SectionWrapper> sectionWrappers = wordMLPackage.getDocumentModel().getSections();
   
    for (SectionWrapper sw : sectionWrappers) {
      HeaderFooterPolicy hfp = sw.getHeaderFooterPolicy();
     
      System.out.println("\n\nSECTION  \n");
     
      System.out.println("Headers:");
      if (hfp.getFirstHeader()!=null) System.out.println("-first");
      if (hfp.getDefaultHeader()!=null) System.out.println("-default");
      if (hfp.getEvenHeader()!=null) System.out.println("-even");
     
      System.out.println("\nFooters:");
      if (hfp.getFirstFooter()!=null) System.out.println("-first");
      if (hfp.getDefaultFooter()!=null) System.out.println("-default");
      if (hfp.getEvenFooter()!=null) System.out.println("-even");
     
    }
   
  }
View Full Code Here

            texts = collectAliasesCallback.textWrappers;

            //collect data from headers
            List<SectionWrapper> sectionWrappers = wordprocessingMLPackage.getDocumentModel().getSections();
            for (SectionWrapper sw : sectionWrappers) {
                HeaderFooterPolicy hfp = sw.getHeaderFooterPolicy();
                collectDataFromObjects(hfp.getFirstHeader(), hfp.getDefaultHeader(), hfp.getEvenHeader(), hfp.getFirstFooter(), hfp.getDefaultFooter(), hfp.getEvenFooter());
            }
        }
View Full Code Here

TOP

Related Classes of org.docx4j.model.structure.HeaderFooterPolicy

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.