Package org.apache.poi.hwpf.usermodel

Examples of org.apache.poi.hwpf.usermodel.Paragraph


             for(int cn=0; cn<row.numCells(); cn++) {
                TableCell cell = row.getCell(cn);
                xhtml.startElement("td");

                for(int pn=0; pn<cell.numParagraphs(); pn++) {
                   Paragraph cellP = cell.getParagraph(pn);
                   handleParagraph(cellP, p.getTableLevel(), cell, document, pictures, pictureTable, xhtml);
                }
                xhtml.endElement("td");
             }
             xhtml.endElement("tr");
View Full Code Here


                    } else if ("Document".equals(name)) {
                        HWPFDocument doc = new HWPFDocument(data.getData());
                        //read the word document
                        Range r = doc.getRange();     
                        for(int k = 0; k < r.numParagraphs(); k++) {
                            Paragraph p = r.getParagraph(k);
                            System.out.println(p.text());
                         }

                        //save on disk
                        FileOutputStream out = new FileOutputStream(name + "-("+(j)+").doc");
                        doc.write(out);
                        out.close();
                     else {
                        System.err.println("Processing " + name);
                    }
                }

            }
        }

        //Pictures
        for (int i = 0; i < slide.length; i++) {
            Shape[] shape = slide[i].getShapes();
            for (int j = 0; j < shape.length; j++) {
                if (shape[j] instanceof Picture) {
                    Picture p = (Picture) shape[j];
                    PictureData data = p.getPictureData();
                    String name = p.getPictureName();
                    int type = data.getType();
                    String ext;
                    switch (type) {
                        case Picture.JPEG:
                            ext = ".jpg";
View Full Code Here

    parProps.setTableLevel((byte)1);

    int columns = props.getItcMac();
    for (int x = 0; x < rows; x++)
    {
      Paragraph cell = this.insertBefore(parProps, StyleSheet.NIL_STYLE);
      cell.insertAfter(String.valueOf('\u0007'));
      for(int y = 1; y < columns; y++)
      {
        cell = cell.insertAfter(parProps, StyleSheet.NIL_STYLE);
        cell.insertAfter(String.valueOf('\u0007'));
      }
      cell = cell.insertAfter(parProps, StyleSheet.NIL_STYLE, String.valueOf('\u0007'));
      cell.setTableRowEnd(props);
    }
    return new Table(_start, _start + (rows * (columns + 1)), this, 1);
  }
View Full Code Here

  {
    initParagraphs();
    PAPX papx = (PAPX)_paragraphs.get(index + _parStart);

    ParagraphProperties props = papx.getParagraphProperties(_doc.getStyleSheet());
    Paragraph pap = null;
    if (props.getIlfo() > 0)
    {
      pap = new ListEntry(papx, this, _doc.getListTables());
    }
    else
    {
      pap = new Paragraph(papx, this);
    }

    return pap;
  }
View Full Code Here

    try {
        Range r = doc.getRange();

      ret = new String[r.numParagraphs()];
      for(int i=0; i<ret.length; i++) {
        Paragraph p = r.getParagraph(i);
        ret[i] = p.text();
       
        // Fix the line ending
        if(ret[i].endsWith("\r")) {
          ret[i] = ret[i] + "\n";
        }
View Full Code Here

    public void testExtractFromModel() {
      Range r = doc.getRange();
     
      String[] text = new String[r.numParagraphs()];
      for(int i=0; i < r.numParagraphs(); i++) {
        Paragraph p = r.getParagraph(i);
        text[i] = p.text();
      }
     
      assertEquals(p_text.length, text.length);
      for(int i=0; i<p_text.length; i++) {
        assertEquals(p_text[i], text[i]);
View Full Code Here

    try {
        Range r = doc.getRange();

      ret = new String[r.numParagraphs()];
      for(int i=0; i<ret.length; i++) {
        Paragraph p = r.getParagraph(i);
        ret[i] = p.text();
       
        // Fix the line ending
        if(ret[i].endsWith("\r")) {
          ret[i] = ret[i] + "\n";
        }
View Full Code Here

    parProps.setFInTable((byte) 1);
    parProps.setTableLevel((byte) 1);

    int columns = props.getItcMac();
    for (int x = 0; x < rows; x++) {
      Paragraph cell = this.insertBefore(parProps, StyleSheet.NIL_STYLE);
      cell.insertAfter(String.valueOf('\u0007'));
      for (int y = 1; y < columns; y++) {
        cell = cell.insertAfter(parProps, StyleSheet.NIL_STYLE);
        cell.insertAfter(String.valueOf('\u0007'));
      }
      cell = cell.insertAfter(parProps, StyleSheet.NIL_STYLE, String.valueOf('\u0007'));
      cell.setTableRowEnd(props);
    }
    return new Table(_start, _start + (rows * (columns + 1)), this, 1);
  }
View Full Code Here

  public Paragraph getParagraph(int index) {
    initParagraphs();
    PAPX papx = (PAPX) _paragraphs.get(index + _parStart);

    ParagraphProperties props = papx.getParagraphProperties(_doc.getStyleSheet());
    Paragraph pap = null;
    if (props.getIlfo() > 0) {
      pap = new ListEntry(papx, this, _doc.getListTables());
    } else {
      pap = new Paragraph(papx, this);
    }

    return pap;
  }
View Full Code Here

        private String[] getParagraphText(Range r) {
                String[] ret;
                ret = new String[r.numParagraphs()];
                for (int i = 0; i < ret.length; i++) {
                        Paragraph p = r.getParagraph(i);
                        ret[i] = p.text();

                        // Fix the line ending
                        if (ret[i].endsWith("\r")) {
                                ret[i] = ret[i] + "\n";
                        }
View Full Code Here

TOP

Related Classes of org.apache.poi.hwpf.usermodel.Paragraph

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.