Package org.docx4j.wml

Examples of org.docx4j.wml.SectPr$Type


            mv.visitFieldInsn(Opcodes.GETFIELD, proxyClassFileName, FIELD_PROXIED_INSTANCE, Type.getDescriptor(classToProxy));

            int offset = 1;
            for (Class<?> aClass : delegatedMethod.getParameterTypes())
            {
                final Type type = Type.getType(aClass);
                mv.visitVarInsn(type.getOpcode(Opcodes.ILOAD), offset);
                offset += type.getSize();
            }

            final Type declaringClass = Type.getType(delegatedMethod.getDeclaringClass());
            mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, declaringClass.getInternalName(), delegatedMethod.getName(), methodDescriptor, false);

            generateReturn(mv, delegatedMethod);

            mv.visitMaxs(-1, -1);
View Full Code Here


            // now calculate the parameters
            int offset = 1;
            for (Class<?> aClass : delegatedMethod.getParameterTypes())
            {
                final Type type = Type.getType(aClass);
                mv.visitVarInsn(type.getOpcode(Opcodes.ILOAD), offset);
                offset += type.getSize();
            }

            // and finally invoke the target method on the provided Contextual Instance
            final Type declaringClass = Type.getType(delegatedMethod.getDeclaringClass());
            if (abstractMethod)
            {
                // generate an empty return block
            }
            else
            {
                // invoke the method on the super class;
                mv.visitMethodInsn(Opcodes.INVOKESPECIAL, declaringClass.getInternalName(), delegatedMethod.getName(), methodDescriptor, false);
            }

            generateReturn(mv, delegatedMethod);

            mv.visitMaxs(-1, -1);
View Full Code Here

            mv.visitFieldInsn(Opcodes.GETFIELD, proxyClassFileName, FIELD_PROXIED_INSTANCE, Type.getDescriptor(classToProxy));

            int offset = 1;
            for (Class<?> aClass : delegatedMethod.getParameterTypes())
            {
                final Type type = Type.getType(aClass);
                mv.visitVarInsn(type.getOpcode(Opcodes.ILOAD), offset);
                offset += type.getSize();
            }

            final Type declaringClass = Type.getType(delegatedMethod.getDeclaringClass());
            mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, declaringClass.getInternalName(), delegatedMethod.getName(), methodDescriptor, false);

            generateReturn(mv, delegatedMethod);

            mv.visitMaxs(-1, -1);
View Full Code Here

            // now calculate the parameters
            int offset = 1;
            for (Class<?> aClass : delegatedMethod.getParameterTypes())
            {
                final Type type = Type.getType(aClass);
                mv.visitVarInsn(type.getOpcode(Opcodes.ILOAD), offset);
                offset += type.getSize();
            }

            // and finally invoke the target method on the provided Contextual Instance
            final Type declaringClass = Type.getType(delegatedMethod.getDeclaringClass());
            boolean interfaceMethod = Modifier.isInterface(delegatedMethod.getDeclaringClass().getModifiers());
            mv.visitMethodInsn(interfaceMethod ? Opcodes.INVOKEINTERFACE : Opcodes.INVOKEVIRTUAL,
                               declaringClass.getInternalName(), delegatedMethod.getName(), methodDescriptor, interfaceMethod);

            generateReturn(mv, delegatedMethod);

            mv.visitMaxs(-1, -1);
View Full Code Here

            mv.visitFieldInsn(Opcodes.GETFIELD, proxyClassFileName, FIELD_PROXIED_INSTANCE, Type.getDescriptor(classToProxy));

            int offset = 1;
            for (Class<?> aClass : delegatedMethod.getParameterTypes())
            {
                final Type type = Type.getType(aClass);
                mv.visitVarInsn(type.getOpcode(Opcodes.ILOAD), offset);
                offset += type.getSize();
            }

            final Type declaringClass = Type.getType(delegatedMethod.getDeclaringClass());
            mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, declaringClass.getInternalName(), delegatedMethod.getName(), methodDescriptor, false);

            generateReturn(mv, delegatedMethod);

            mv.visitMaxs(-1, -1);
View Full Code Here

            // now calculate the parameters
            int offset = 1;
            for (Class<?> aClass : delegatedMethod.getParameterTypes())
            {
                final Type type = Type.getType(aClass);
                mv.visitVarInsn(type.getOpcode(Opcodes.ILOAD), offset);
                offset += type.getSize();
            }

            // and finally invoke the target method on the provided Contextual Instance
            final Type declaringClass = Type.getType(delegatedMethod.getDeclaringClass());
            boolean interfaceMethod = Modifier.isInterface(delegatedMethod.getDeclaringClass().getModifiers());
            mv.visitMethodInsn(interfaceMethod ? Opcodes.INVOKEINTERFACE : Opcodes.INVOKEVIRTUAL,
                               declaringClass.getInternalName(), delegatedMethod.getName(), methodDescriptor, interfaceMethod);

            generateReturn(mv, delegatedMethod);

            mv.visitMaxs(-1, -1);
View Full Code Here

            // now calculate the parameters
            int offset = 1;
            for (Class<?> aClass : delegatedMethod.getParameterTypes())
            {
                final Type type = Type.getType(aClass);
                mv.visitVarInsn(type.getOpcode(Opcodes.ILOAD), offset);
                offset += type.getSize();
            }

            // and finally invoke the target method on the provided Contextual Instance
            final Type declaringClass = Type.getType(delegatedMethod.getDeclaringClass());
            if (abstractMethod)
            {
                // generate an empty return block
            }
            else
            {
                // invoke the method on the super class;
                mv.visitMethodInsn(Opcodes.INVOKESPECIAL, declaringClass.getInternalName(), delegatedMethod.getName(), methodDescriptor, false);
            }

            generateReturn(mv, delegatedMethod);

            mv.visitMaxs(-1, -1);
View Full Code Here

            PPr ppr = ((P) block).getPPr();
            if (ppr == null) {
              ppr = Context.getWmlObjectFactory().createPPr();
              ((P) block).setPPr(ppr);
            }
            SectPr newSectPr = Context.getWmlObjectFactory()
                .createSectPr();
            SectPr.Type type = Context.getWmlObjectFactory()
                .createSectPrType();
            type.setVal("continuous");
            newSectPr.setType(type);

            ppr.setSectPr(newSectPr);
          } else {
            // Equally likely - its a table or something, so add a p
            P newP = Context.getWmlObjectFactory().createP();
            PPr ppr = Context.getWmlObjectFactory().createPPr();
            newP.setPPr(ppr);

            SectPr newSectPr = Context.getWmlObjectFactory()
                .createSectPr();
            SectPr.Type type = Context.getWmlObjectFactory()
                .createSectPrType();
            type.setVal("continuous");
            newSectPr.setType(type);
            ppr.setSectPr(newSectPr);

            bodyChildren.add(indexIntoBody.intValue(), newP); // add
                                      // before
                                      // altChunk
View Full Code Here

      // in the first section
     
      hfTemplates = new HashMap<CTRel, JaxbXmlPart>();
     
      SectionWrapper sw = input.getDocumentModel().getSections().get(0);
      SectPr sectPr = sw.getSectPr();
     
      List<CTRel> hdrFtrRefs = sectPr.getEGHdrFtrReferences();
      titlePage = sectPr.getTitlePg();
     
      for (CTRel rel : hdrFtrRefs) {
        String relId = rel.getId();
        log.debug("for h|f relId: " + relId);
       
        JaxbXmlPart part = (JaxbXmlPart)input.getMainDocumentPart().getRelationshipsPart().getPart(relId);
        FieldsPreprocessor.complexifyFields(part );
       
        log.debug("complexified: " + XmlUtils.marshaltoString(part.getJaxbElement(), true));
       
        hfTemplates.put(rel, part);
      }
    }
   
    // Create WordprocessingMLPackage target, by cloning
    OpcPackage result = null;
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    SaveToZipFile saver = new SaveToZipFile(input);
    saver.save(baos);
    byte[] template = baos.toByteArray();
    WordprocessingMLPackage target = WordprocessingMLPackage.load(
        new ByteArrayInputStream(template));
   
   
    // populate main document part
    SectPr documentSeparator = getDocumentSeparator(target);
    if (processHeadersAndFooters) {
      if (titlePage!=null
          && titlePage.isVal()) {
        documentSeparator.setTitlePg(titlePage);
      }
      documentSeparator.getEGHdrFtrReferences().clear();
    }
    target.getMainDocumentPart().getContent().clear();
   
    /*
     * What we're doing, effectively, is doing the
     * main content in a single hit (ie for all
     * instances), and then, for each instance,
     * doing the headers/footers.
     *
     * It is this way because that is how the code
     * has evolved.
     *
     * Since we have to do the headers/footers
     * instance by instance, it would probably
     * be neater to do the main content at
     * the same time (ie instead of using
     * performOverList at the start of this method).
     */
   
    int i = 0;
    for (List<Object> content : mdpResults) {
     
           
      // now inject the content
      target.getMainDocumentPart().getContent().addAll(content);

      log.debug(XmlUtils.marshaltoString(target.getMainDocumentPart().getJaxbElement(), true, true) );
     
      // add sectPr to final paragraph
      Object last = content.get( content.size()-1);
      P lastP = null;
      if (last instanceof P) {
        lastP = (P)last;
      } else {
        lastP = Context.getWmlObjectFactory().createP();
        target.getMainDocumentPart().getContent().add(lastP)
      }
      if (lastP.getPPr()==null) {
        lastP.setPPr(Context.getWmlObjectFactory().createPPr());       
      }
      SectPr thisSection = XmlUtils.deepCopy(documentSeparator);
      lastP.getPPr().setSectPr(thisSection);
     
      if (processHeadersAndFooters) {
        for( CTRel ctRel : hfTemplates.keySet()) {
         
          // Create a suitable part
          JaxbXmlPart part = hfTemplates.get(ctRel);
          JaxbXmlPart clonedPart = null;
          if (part instanceof HeaderPart) {
            clonedPart = new HeaderPart();
            clonedPart.setJaxbElement(Context.getWmlObjectFactory().createHdr());
          } else if (part instanceof FooterPart) {
            clonedPart = new FooterPart();
            clonedPart.setJaxbElement(Context.getWmlObjectFactory().createFtr());
          }
         
          // Populate it
          List<Object> newContent = performOnInstance(input,
              ((ContentAccessor)part).getContent(),
              data.get(i), formTextFieldNames )
          ((ContentAccessor)clonedPart).getContent().addAll(newContent);
         
          // Add it
          Relationship rel = target.getMainDocumentPart().addTargetPart(clonedPart, AddPartBehaviour.RENAME_IF_NAME_EXISTS);
         
          // Now add CTRel!
          CTRel newHfRef = XmlUtils.deepCopy(ctRel);
          newHfRef.setId(rel.getId());
         
          thisSection.getEGHdrFtrReferences().add(newHfRef);
         
        }
      }
      i++;
    }
View Full Code Here

   * @param template
   * @return
   */
  private static SectPr getDocumentSeparator(WordprocessingMLPackage template) {
       
       SectPr sectPr = template.getMainDocumentPart().getJaxbElement().getBody().getSectPr();
      
       if (sectPr==null) {
         // Maybe the last P already contains one?
         // Presumably Word would reuse this.
         List all = template.getMainDocumentPart().getContent();
          Object last = all.get( all.size()-1 );
          if (last instanceof P) {
            if (((P) last).getPPr()!=null
                && ((P) last).getPPr().getSectPr() !=null) {
              sectPr = ((P) last).getPPr().getSectPr();
            }
          }        
       }
      
       if (sectPr==null) {
        
        // Create a basic sectPr using our Page model
        String papersize= Docx4jProperties.getProperties().getProperty("docx4j.PageSize", "A4");
        log.info("Using paper size: " + papersize);
       
        String landscapeString = Docx4jProperties.getProperties().getProperty("docx4j.PageOrientationLandscape", "false");
        boolean landscape= Boolean.parseBoolean(landscapeString);
        log.info("Landscape orientation: " + landscape);
       
        PageDimensions page = new PageDimensions();
        page.setPgSize(PageSizePaper.valueOf(papersize), landscape);
       
        sectPr = Context.getWmlObjectFactory().createSectPr();
        sectPr.setPgSzpage.getPgSz() );
        sectPr.setPgMar( page.getPgMar() );       
       }
      
       // <w:pgNumType w:start="1"/>
       CTPageNumber pageNumber = sectPr.getPgNumType();
       if (pageNumber==null) {
         pageNumber = Context.getWmlObjectFactory().createCTPageNumber();
         sectPr.setPgNumType(pageNumber);
       }
       pageNumber.setStart(BigInteger.ONE);
      
       return sectPr;
    
View Full Code Here

TOP

Related Classes of org.docx4j.wml.SectPr$Type

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.