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; }
previousHF= new HeaderFooterPolicy(); setHeaderReferences(hdrFtrRefs, rels, titlePage ); setFooterReferences(hdrFtrRefs, rels, titlePage ); firstHeaderActive = getDummyHeader(); firstFooterActive = getDummyFooter(); evenHeader = getDummyHeader(); evenFooter = getDummyFooter(); defaultHeader = getDummyHeader(); defaultFooter = getDummyFooter();
public static boolean hasDefaultHeaderOrFooter(AbstractWmlConversionContext context) { ConversionSectionWrapper currentSection = context.getSections().getCurrentSection(); return (currentSection.getHeaderFooterPolicy().getDefaultHeader()!=null) || (currentSection.getHeaderFooterPolicy().getDefaultFooter()!=null); }
List<SectionWrapper> sectionWrappers = template.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"); hfp.getFirstHeader().variableReplace(variables); } if (hfp.getDefaultHeader()!=null) { System.out.println("-default"); hfp.getDefaultHeader().variableReplace(variables); } if (hfp.getEvenHeader()!=null) { System.out.println("-even"); hfp.getEvenHeader().variableReplace(variables); } }
public static boolean hasDefaultHeader(AbstractWmlConversionContext context) { ConversionSectionWrapper currentSection = context.getSections().getCurrentSection(); return (currentSection.getHeaderFooterPolicy().getDefaultHeader() != null); }
public static boolean hasEvenHeader(AbstractWmlConversionContext context) { ConversionSectionWrapper currentSection = context.getSections().getCurrentSection(); return (currentSection.getHeaderFooterPolicy().getEvenHeader() != null); }
public static boolean hasFirstHeader(AbstractWmlConversionContext context) { ConversionSectionWrapper currentSection = context.getSections().getCurrentSection(); return (currentSection.getHeaderFooterPolicy().getFirstHeader() != null); }
public static boolean hasDefaultFooter(AbstractWmlConversionContext context) { ConversionSectionWrapper currentSection = context.getSections().getCurrentSection(); return (currentSection.getHeaderFooterPolicy().getDefaultFooter() != null); }
public static boolean hasEvenFooter(AbstractWmlConversionContext context) { ConversionSectionWrapper currentSection = context.getSections().getCurrentSection(); return (currentSection.getHeaderFooterPolicy().getEvenFooter() != null); }
public static boolean hasFirstFooter(AbstractWmlConversionContext context) { ConversionSectionWrapper currentSection = context.getSections().getCurrentSection(); return (currentSection.getHeaderFooterPolicy().getFirstFooter() != null); }
protected SectionWrapper(SectPr sectPr, HeaderFooterPolicy previousHF, RelationshipsPart rels, BooleanDefaultTrue evenAndOddHeaders) { // This should work even if sectPr is null this.sectPr = sectPr; if (sectPr==null) { log.warn("No (document level?) sectPr!"); } this.headerFooterPolicy = new HeaderFooterPolicy(sectPr, previousHF, rels, evenAndOddHeaders); page = new PageDimensions(sectPr); }
@Override protected void appendSectionHeader(HTMLConversionContext conversionContext, Document document, ConversionSectionWrapper sectionWrapper, Element currentParent) throws Docx4JException { if (XsltCommonFunctions.hasDefaultHeader(conversionContext)) { appendPartContent( conversionContext, document, sectionWrapper, currentParent, "header", sectionWrapper.getHeaderFooterPolicy().getDefaultHeader(), sectionWrapper.getHeaderFooterPolicy().getDefaultHeader().getJaxbElement().getContent()); } }
public static boolean hasDefaultHeaderOrFooter(AbstractWmlConversionContext context) { ConversionSectionWrapper currentSection = context.getSections().getCurrentSection(); return (currentSection.getHeaderFooterPolicy().getDefaultHeader()!=null) || (currentSection.getHeaderFooterPolicy().getDefaultFooter()!=null); }
public static void inEvenHeader(AbstractWmlConversionContext context) { ConversionSectionWrapper currentSection = context.getSections().getCurrentSection(); setCurrentPart(context, currentSection.getHeaderFooterPolicy().getEvenHeader()); }
public static void inFirstHeader(AbstractWmlConversionContext context) { ConversionSectionWrapper currentSection = context.getSections().getCurrentSection(); setCurrentPart(context, currentSection.getHeaderFooterPolicy().getFirstHeader()); }
@Override protected void appendSectionFooter(HTMLConversionContext conversionContext, Document document, ConversionSectionWrapper sectionWrapper, Element currentParent) throws Docx4JException { if (XsltCommonFunctions.hasDefaultFooter(conversionContext)) { appendPartContent( conversionContext, document, sectionWrapper, currentParent, "footer", sectionWrapper.getHeaderFooterPolicy().getDefaultFooter(), sectionWrapper.getHeaderFooterPolicy().getDefaultFooter().getJaxbElement().getContent()); } }
public static void inEvenFooter(AbstractWmlConversionContext context) { ConversionSectionWrapper currentSection = context.getSections().getCurrentSection(); setCurrentPart(context, currentSection.getHeaderFooterPolicy().getEvenFooter()); }
public static void inFirstFooter(AbstractWmlConversionContext context) { ConversionSectionWrapper currentSection = context.getSections().getCurrentSection(); setCurrentPart(context, currentSection.getHeaderFooterPolicy().getFirstFooter()); }
/** The dummy section wrappers only contains one section with all the document. Therefore * any sections within the document are ignored in the conversion process. As it doesn't * need to check for sections it is faster and the html-Output only uses one section.<br> * It will use the Header/Footer of the body sectPr. This isn't correct, if there are * several Sections in the document, but to find the correct SectPr it would need to check * the document content - and the aim of this method is a low overhead. * * @param wmlPackage * @param dummyPageNumbering * @return */ protected static List<ConversionSectionWrapper> processDummy(WordprocessingMLPackage wmlPackage, Document document, RelationshipsPart rels, BooleanDefaultTrue evenAndOddHeaders, boolean dummyPageNumbering) { 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( document.getBody().getSectPr(), previousHF, rels, evenAndOddHeaders, 1, document.getBody().getContent(), dummyPageNumbering); conversionSections.add(currentSectionWrapper); return conversionSections; }
protected void collectHeadersAndFooters() {//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()); } }