private PicturesSource(HWPFDocument doc) { picturesTable = doc.getPicturesTable(); all = picturesTable.getAllPictures(); // Build the Offset-Picture lookup map lookup = new HashMap<Integer, Picture>(); for (Picture p : all) { lookup.put(p.getStartOffset(), p); } // Work out which Pictures aren't referenced by // a \u0001 in the main text // These are \u0008 escher floating ones, ones // found outside the normal text, and who // knows what else... nonU1based = new ArrayList<Picture>(); 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); } } }
private boolean isBlockContainsImage(int i) { return isPictureRecognized(getBlockType(_dataStream, i), getMmMode(_dataStream, i)); }
private boolean isBlockContainsHorizontalLine(int i) { return getBlockType(_dataStream, i)==TYPE_HORIZONTAL_LINE && getMmMode(_dataStream, i)==0x64; }
private boolean hasPicture(CharacterRun cr) { return picturesTable.hasPicture(cr); }
.hasPicture( characterRun ) ) Picture picture = newFormat.getPicturesTable().extractPicture( characterRun, true );
private void dumpPictures() { if ( _doc instanceof HWPFOldDocument ) { System.out.println( "Word 95 not supported so far" ); return; } List<Picture> allPictures = ( (HWPFDocument) _doc ).getPicturesTable() .getAllPictures(); for ( Picture picture : allPictures ) { System.out.println(picture); } }
/** * Not all documents have all the images concatenated in the data stream * although MS claims so. The best approach is to scan all character runs. * * @return a list of Picture objects found in current document */ public List<Picture> getAllPictures() { ArrayList<Picture> pictures = new ArrayList<>(); Range range = _document.getOverallRange(); for (int i = 0; i < range.numCharacterRuns(); i++) { CharacterRun run = range.getCharacterRun(i); if (run==null) { continue; } Picture picture = extractPicture(run, false); if (picture != null) { pictures.add(picture); } } searchForPictures(_dgg.getEscherRecords(), pictures); return pictures; }
/** * determines whether specified CharacterRun contains reference to a picture * @param run */ public boolean hasHorizontalLine(CharacterRun run) { if (run.isSpecialCharacter() && "\u0001".equals(run.text())) { return isBlockContainsHorizontalLine(run.getPicOffset()); } return false; }
/** * determines whether specified CharacterRun contains reference to a picture * @param run */ public boolean hasPicture(CharacterRun run) { if (run==null) { return false; } if (run.isSpecialCharacter() && !run.isObj() && !run.isOle2() && !run.isData()) { // Image should be in it's own run, or in a run with the end-of-special marker if("\u0001".equals(run.text()) || "\u0001\u0015".equals(run.text())) { return isBlockContainsImage(run.getPicOffset()); } } return false; }
searchForPictures(escherRecord.getChildRecords(), pictures);
_pictures = new PicturesTable(this, _dataStream, _mainStream, _fspaMain, _escherRecordHolder);
if (pictures.hasPicture(cr)) { Picture picture = pictures.getFor(cr); handlePictureCharacterRun(cr, picture, pictures, xhtml);
.hasPicture( characterRun ) ) Picture picture = newFormat.getPicturesTable().extractPicture( characterRun, true );
private void dumpPictures() { if ( _doc instanceof HWPFOldDocument ) { System.out.println( "Word 95 not supported so far" ); return; } List<Picture> allPictures = ( (HWPFDocument) _doc ).getPicturesTable() .getAllPictures(); for ( Picture picture : allPictures ) { System.out.println( picture.toString() ); } }
private boolean isBlockContainsHorizontalLine(int i) { return getBlockType(_dataStream, i)==TYPE_HORIZONTAL_LINE && getMmMode(_dataStream, i)==0x64; }
/** * Not all documents have all the images concatenated in the data stream * although MS claims so. The best approach is to scan all character runs. * * @return a list of Picture objects found in current document */ public List<Picture> getAllPictures() { ArrayList<Picture> pictures = new ArrayList<Picture>(); Range range = _document.getOverallRange(); for (int i = 0; i < range.numCharacterRuns(); i++) { CharacterRun run = range.getCharacterRun(i); if (run==null) { continue; } Picture picture = extractPicture(run, false); if (picture != null) { pictures.add(picture); } } searchForPictures(_dgg.getEscherRecords(), pictures); return pictures; }
/** * determines whether specified CharacterRun contains reference to a picture * @param run */ public boolean hasHorizontalLine(CharacterRun run) { if (run.isSpecialCharacter() && "\u0001".equals(run.text())) { return isBlockContainsHorizontalLine(run.getPicOffset()); } return false; }
/** * determines whether specified CharacterRun contains reference to a picture * @param run */ public boolean hasPicture(CharacterRun run) { if (run==null) { return false; } if (run.isSpecialCharacter() && !run.isObj() && !run.isOle2() && !run.isData()) { // Image should be in it's own run, or in a run with the end-of-special marker if("\u0001".equals(run.text()) || "\u0001\u0015".equals(run.text())) { return isBlockContainsImage(run.getPicOffset()); } } return false; }
searchForPictures(escherRecord.getChildRecords(), pictures);
_pictures = new PicturesTable(this, _dataStream, _mainStream, _fspaMain, _escherRecordHolder);