/** * Get the number of characters covered by this records * * @return the number of characters covered by this records */ public int getCharactersCovered(){ int covered = 0; TextSpecInfoRun[] runs = getTextSpecInfoRuns(); for (int i = 0; i < runs.length; i++) covered += runs[i].len; return covered; }
/** * Get the number of characters covered by this records * * @return the number of characters covered by this records */ public int getCharactersCovered(){ int covered = 0; for (TextSpecInfoRun r : getTextSpecInfoRuns()) { covered += r.getLength(); } return covered; }
/** * Adapts the size by enlarging the last {@link TextSpecInfoRun} * or chopping the runs to the given length * * @param size */ public void setParentSize(int size) { assert(size > 0); int covered = 0; ByteArrayOutputStream bos = new ByteArrayOutputStream(); TextSpecInfoRun runs[] = getTextSpecInfoRuns(); assert(runs.length > 0); for (int i=0; i<runs.length && covered < size; i++) { TextSpecInfoRun run = runs[i]; if (covered + run.getLength() > size || i == runs.length-1) { run.setLength(size-covered); } covered += run.getLength(); try { run.writeOut(bos); } catch (IOException e) { throw new HSLFException(e); } } _data = bos.toByteArray(); // Update the size (header bytes 5-8) LittleEndian.putInt(_header, 4, _data.length); }