Package org.docx4j.wml

Examples of org.docx4j.wml.P


        wordMLPackage.getMainDocumentPart().addParagraphOfText("TESTING " + testparagraphs[i]
                + ", " + testparagraphs[j] );
       
        // Test setup
        wordMLPackage.getMainDocumentPart().addParagraphOfText("first:");
        P pl = Differencer.loadParagraph(BASE_DIR + testparagraphs[i]);
        wordMLPackage.getMainDocumentPart().addObject(pl);
       
        wordMLPackage.getMainDocumentPart().addParagraphOfText("second:");
        P pr = Differencer.loadParagraph(BASE_DIR + testparagraphs[j]);
        wordMLPackage.getMainDocumentPart().addObject(pr);
       
        // Result format       
        JAXBContext jc = Context.jc;
        javax.xml.bind.util.JAXBResult result = new javax.xml.bind.util.JAXBResult(jc );
   
        // Run the diff
        Differencer pd = new Differencer();       
        pd.diff(pl, pr, result, null, null,
            null, null);
       
        try {
          P markedUpP = (org.docx4j.wml.P)result.getResult();
         
          wordMLPackage.getMainDocumentPart().addParagraphOfText("result:");
          wordMLPackage.getMainDocumentPart().addObject(markedUpP);
        } catch (RuntimeException e) {
          String msg = "failed to apply stylesheet to pre-processed! "
            + testparagraphs[i] + ", " + testparagraphs[j];
          System.out.println(msg);
          e.printStackTrace();
          wordMLPackage.getMainDocumentPart().addParagraphOfText(msg);
         
          StreamResult err = new StreamResult(System.out);
          pd.diff(pl, pr, err, null, null,
              null, null);
         
        }
       
        // Compare no pre-processor
        result = new javax.xml.bind.util.JAXBResult(jc );
        pd.diff(pl, pr, result, null, null,
            null, null);       
        try {
          P markedUpPsimple = (org.docx4j.wml.P)result.getResult();        
          wordMLPackage.getMainDocumentPart().addParagraphOfText("no preprocessing:");
          wordMLPackage.getMainDocumentPart().addObject(markedUpPsimple);       
        } catch (RuntimeException e) {
          String msg = "failed to apply stylesheet to naive! "
            + testparagraphs[i] + ", " + testparagraphs[j];
View Full Code Here


  @Test
  public void testBookmarked() throws JAXBException, IOException {
 
    List<FieldRef> fieldRefs = new ArrayList<FieldRef>();
    P resultP = FieldsPreprocessor.canonicalise(getP("Canon_bookmarked.xml"), fieldRefs);
   
    String xml = XmlUtils.marshaltoString(resultP, true, true);
   
    // bookmarks still present
    assertTrue(xml.contains("<w:bookmarkStart"));
View Full Code Here

 
  @Test
  public void testFORMTEXTwithDefault() throws JAXBException, IOException {
 
    List<FieldRef> fieldRefs = new ArrayList<FieldRef>();
    P resultP = FieldsPreprocessor.canonicalise(getP("Canon_FORMTEXT_default.xml"), fieldRefs);
   
   
    // Should contain 3 runs
    assertTrue(resultP.getContent().size()==3);
   
    // 2nd run is the result slot
    FieldRef fieldRef1 =  fieldRefs.get(0);
    assertTrue(resultP.getContent().get(1)==fieldRef1.getResultsSlot());
  }
View Full Code Here

  @Test
  public void testFORMTEXTwithSpaces() throws JAXBException, IOException {
 
    List<FieldRef> fieldRefs = new ArrayList<FieldRef>();
    P resultP = FieldsPreprocessor.canonicalise(getP("Canon_FORMTEXT-spaces.xml"), fieldRefs);
   
   
    // Should contain 3 runs
    assertTrue(resultP.getContent().size()==3);
   
    // 2nd run is the result slot
    FieldRef fieldRef1 =  fieldRefs.get(0);
    assertTrue(resultP.getContent().get(1)==fieldRef1.getResultsSlot());
   
    //System.out.println(XmlUtils.marshaltoString(fieldRef1.getResultsSlot(), true, true));
  }
View Full Code Here

 
  @Test
  public void testFORMTEXTdefault_trail() throws JAXBException, IOException {
 
    List<FieldRef> fieldRefs = new ArrayList<FieldRef>();
    P resultP = FieldsPreprocessor.canonicalise(getP("Canon_FORMTEXTdefault_trail.xml"), fieldRefs);
   
   
    // Should contain 3 + 1 runs
    assertTrue(resultP.getContent().size()==4);
   
    // 2nd run is the result slot
    FieldRef fieldRef1 =  fieldRefs.get(0);
    assertTrue(resultP.getContent().get(1)==fieldRef1.getResultsSlot());
  }
View Full Code Here

  @Test
  public void testLeadFORMTEXTdefault() throws JAXBException, IOException {
 
    List<FieldRef> fieldRefs = new ArrayList<FieldRef>();
    P resultP = FieldsPreprocessor.canonicalise(getP("Canon_lead_FORMTEXTdefault.xml"), fieldRefs);
   
   
    // Should contain 1 + 3 runs
    assertTrue(resultP.getContent().size()==4);
   
    // 3rd run is the result slot
    FieldRef fieldRef1 =  fieldRefs.get(0);
    assertTrue(resultP.getContent().get(2)==fieldRef1.getResultsSlot());
  }
View Full Code Here

  @Test
  public void testLeadMERGEFIELDMergeFormat() throws JAXBException, IOException {
 
    List<FieldRef> fieldRefs = new ArrayList<FieldRef>();
    P resultP = FieldsPreprocessor.canonicalise(getP("Canon_lead_MERGEFIELD-MERGEFORMAT.xml"), fieldRefs);
   
   
    // Should contain 1 + 3 + 1 runs
    assertTrue(resultP.getContent().size()==5);
   
    // 3rd run is the result slot
    FieldRef fieldRef1 =  fieldRefs.get(0);
    assertTrue(resultP.getContent().get(2)==fieldRef1.getResultsSlot());
  }
View Full Code Here

  @Test
  public void testLeadMERGEFIELDUpper() throws JAXBException, IOException {
 
    List<FieldRef> fieldRefs = new ArrayList<FieldRef>();
    P resultP = FieldsPreprocessor.canonicalise(getP("Canon_lead_MERGEFIELDUpper_tail.xml"), fieldRefs);
   
   
    // Should contain 1 + 3 + 1 runs
    assertTrue(resultP.getContent().size()==5);
   
    // 3rd run is the result slot
    FieldRef fieldRef1 =  fieldRefs.get(0);
    assertTrue(resultP.getContent().get(2)==fieldRef1.getResultsSlot());
  }
View Full Code Here

  @Test
  public void testLeadMERGEFIELD() throws JAXBException, IOException {
 
    List<FieldRef> fieldRefs = new ArrayList<FieldRef>();
    P resultP = FieldsPreprocessor.canonicalise(getP("Canon_MERGEFIELD.xml"), fieldRefs);
   
   
    // Should contain 3 runs
    assertTrue(resultP.getContent().size()==3);
   
    // 2nd run is the result slot
    FieldRef fieldRef1 =  fieldRefs.get(0);
    assertTrue(resultP.getContent().get(1)==fieldRef1.getResultsSlot());
  }
View Full Code Here

    // For each w:p, test w:r/w:t
    for (int i=0; i<document.getContent().size(); i++) {

//      System.out.println(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());
     
      Object result = rfs.fontSelector(pPr, rPr, wmlText);
//      System.out.println(result.getClass().getName());
View Full Code Here

TOP

Related Classes of org.docx4j.wml.P

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.