Package org.apache.poi.hwpf.usermodel

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


          if (escherRecord instanceof EscherBSERecord) {
              EscherBSERecord bse = (EscherBSERecord) escherRecord;
              EscherBlipRecord blip = bse.getBlipRecord();
              if (blip != null)
              {
                  pictures.add(new Picture(blip));
              }
                else if ( bse.getOffset() > 0 )
                {
                    try
                    {
                        // 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 ) );
                        }
                    }
                    catch ( Exception exc )
                    {
                        logger.log(
View Full Code Here


        if (run==null) {
            continue;
        }

      Picture picture = extractPicture(run, false);
      if (picture != null) {
        pictures.add(picture);
      }
  }
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

          if (escherRecord instanceof EscherBSERecord) {
              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

        if (run==null) {
            continue;
        }

      Picture picture = extractPicture(run, false);
      if (picture != null) {
        pictures.add(picture);
      }
  }
View Full Code Here

    PicturesTable picB = docB.getPicturesTable();
    List picturesB = picB.getAllPictures();
   
    assertEquals(2, picturesB.size());
   
    Picture pic1 = (Picture)picturesB.get(0);
    Picture pic2 = (Picture)picturesB.get(1);
   
    assertNotNull(pic1);
    assertNotNull(pic2);
   
    // Check the same
    byte[] pic1B = readFile(imgAFile);
    byte[] pic2B = readFile(imgBFile);
   
    assertEquals(pic1B.length, pic1.getContent().length);
    assertEquals(pic2B.length, pic2.getContent().length);

    assertBytesSame(pic1B, pic1.getContent());
    assertBytesSame(pic2B, pic2.getContent());
  }
View Full Code Here

    PicturesTable picC = docC.getPicturesTable();
    List picturesC = picC.getAllPictures();
   
    assertEquals(1, picturesC.size());
   
    Picture pic = (Picture)picturesC.get(0);
    assertNotNull(pic);
   
    // Check the same
    byte[] picBytes = readFile(imgCFile);
   
    assertEquals(picBytes.length, pic.getContent().length);
    assertBytesSame(picBytes, pic.getContent());
  }
View Full Code Here

        HWPFDocument docD = new HWPFDocument(new FileInputStream(docDFile));
        List allPictures = docD.getPicturesTable().getAllPictures();
       
        assertEquals(1, allPictures.size());
       
        Picture pic = (Picture) allPictures.get(0);
        assertNotNull(pic);
        byte[] picD = readFile(imgDFile);
       
        assertEquals(picD.length, pic.getContent().length);
       
        assertBytesSame(picD, pic.getContent());
    }
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();
                        blip = (EscherBlipRecord) recordFactory.createRecord(_mainStream, bse.getOffset());
                        blip.fillFields(_mainStream, bse.getOffset(), recordFactory);
                        pictures.add(new Picture(blip.getPicturedata()));
                    }
                }

                // Recursive call.
                searchForPictures(escherRecord.getChildRecords(), pictures);
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.