Package org.apache.poi.hwpf.usermodel

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


   * @return a Picture object if picture exists for specified CharacterRun, null otherwise. PicturesTable.hasPicture is used to determine this.
   * @see #hasPicture(org.apache.poi.hwpf.usermodel.CharacterRun)
   */
  public Picture extractPicture(CharacterRun run, boolean fillBytes) {
    if (hasPicture(run)) {
      return new Picture(run.getPicOffset(), _dataStream, fillBytes);
    }
    return null;
  }
View Full Code Here


    int pos = 0;
    boolean atEnd = false;
   
    while(pos<_dataStream.length && !atEnd) {
      if (isBlockContainsImage(pos)) {
        pictures.add(new Picture(pos, _dataStream, false));
      }
     
      int skipOn = LittleEndian.getInt(_dataStream, pos);
      if(skipOn <= 0) { atEnd = true; }
      pos += skipOn;
View Full Code Here

   * @return a Picture object if picture exists for specified CharacterRun, null otherwise. PicturesTable.hasPicture is used to determine this.
   * @see #hasPicture(org.apache.poi.hwpf.usermodel.CharacterRun)
   */
  public Picture extractPicture(CharacterRun run, boolean fillBytes) {
    if (hasPicture(run)) {
      return new Picture(run.getPicOffset(), _dataStream, fillBytes);
    }
    return null;
  }
View Full Code Here

                {
                    EscherBSERecord bse = (EscherBSERecord) escherRecord;
                    EscherBlipRecord blip = bse.getBlipRecord();
                    if (blip != null)
                    {
                        pictures.add(new Picture(blip.getPicturedata()));
                    }
                    else if (bse.getOffset() > 0)
                    {
                        // Blip stored in delay stream, which in a word doc, is the main stream
                        EscherRecordFactory recordFactory = new DefaultEscherRecordFactory();
                        EscherRecord record = recordFactory.createRecord(_mainStream, bse.getOffset());

                        if (record instanceof EscherBlipRecord) {
                            record.fillFields(_mainStream, bse.getOffset(), recordFactory);
                            blip = (EscherBlipRecord) record;
                            pictures.add(new Picture(blip.getPicturedata()));
                        }
                    }
                }

                // Recursive call.
View Full Code Here

    Range range = _document.getOverallRange();
    for (int i = 0; i < range.numCharacterRuns(); i++) {
      CharacterRun run = range.getCharacterRun(i);
      String text = run.text();
      Picture picture = extractPicture(run, false);
      if (picture != null) {
        pictures.add(picture);
      }
  }
View Full Code Here

      //Process image
      if (doc instanceof HWPFDocument
          && ((HWPFDocument) doc).getPicturesTable().hasPicture(run)) {
       
        Picture picture = doc.getPicturesTable().extractPicture(run,
            true);
        Inline inline;
        try {
          BinaryPartAbstractImage imagePart = BinaryPartAbstractImage
              .createImagePart(wordMLPackage, picture.getContent());

          long cx = UnitsOfMeasurement
              .twipToEMU(Math.round((double) imagePart
                  .getImageInfo().getSize().getWidthMpt()
                  * ((double) picture
                      .getHorizontalScalingFactor() * 0.00001d))) * 2L;
          long cy = UnitsOfMeasurement
              .twipToEMU(Math.round((double) imagePart
                  .getImageInfo().getSize().getHeightMpt()
                  * ((double) picture
                      .getVerticalScalingFactor() * 0.00001d))) * 2L;

          inline = imagePart.createImageInline(null, "", ID1++,
              ID2++, cx, cy, false);

View Full Code Here

             j += handleSpecialCharacterRuns(p, j, tas.isHeading(), pictures, xhtml);
          } else if(cr.text().startsWith("\u0008")) {
             // Floating Picture(s)
             for(int pn=0; pn<cr.text().length(); pn++) {
                // Assume they're in the order from the unclaimed list...
                Picture picture = pictures.nextUnclaimed();
               
                // Output
                handlePictureCharacterRun(cr, picture, pictures, xhtml);
             }
          } else if(pictureTable.hasPicture(cr)) {
             // Inline Picture
             Picture picture = pictures.getFor(cr);
             handlePictureCharacterRun(cr, picture, pictures, xhtml);
          } else {
             handleCharacterRun(cr, tas.isHeading(), xhtml);
          }
       }
View Full Code Here

             xhtml.endElement("a");
          } else {
             // Just output the text ones
             for(CharacterRun cr : texts) {
                if(pictures.hasPicture(cr)) {
                   Picture picture = pictures.getFor(cr);
                   handlePictureCharacterRun(cr, picture, pictures, xhtml);
                } else {
                   handleCharacterRun(cr, skipStyling, xhtml);
                }
             }
View Full Code Here

          nonU1based.addAll(all);
          Range r = doc.getRange();
          for(int i=0; i<r.numCharacterRuns(); i++) {
             CharacterRun cr = r.getCharacterRun(i);
             if(picturesTable.hasPicture(cr)) {
                Picture p = getFor(cr);
                int at = nonU1based.indexOf(p);
                nonU1based.set(at, null);
             }
          }
       }
View Full Code Here

       /**
        * Return the next unclaimed one, used towards
        *  the end
        */
       private Picture nextUnclaimed() {
          Picture p = null;
          while(pn < nonU1based.size()) {
             p = nonU1based.get(pn);
             pn++;
             if(p != null) return p;
          }
View Full Code Here

TOP

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

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.