private static int binarySearch( List<CHPX> chpxs, int startPosition ) { int low = 0; int high = chpxs.size() - 1; while ( low <= high ) { int mid = ( low + high ) >>> 1; CHPX midVal = chpxs.get( mid ); int midValue = midVal.getStart(); if ( midValue < startPosition ) low = mid + 1; else if ( midValue > startPosition ) high = mid - 1; else return mid; // key found } return -( low + 1 ); // key not found. }
public String toString() { return "CHPX from " + getStart() + " to " + getEnd() + " (in bytes " + getStartBytes() + " to " + getEndBytes() + ")"; } }
private static int binarySearch( List<CHPX> chpxs, int startPosition ) { int low = 0; int high = chpxs.size() - 1; while ( low <= high ) { int mid = ( low + high ) >>> 1; CHPX midVal = chpxs.get( mid ); int midValue = midVal.getStart(); if ( midValue < startPosition ) low = mid + 1; else if ( midValue > startPosition ) high = mid - 1; else return mid; // key found } return -( low + 1 ); // key not found. }
public String toString() { return "CHPX from " + getStart() + " to " + getEnd() + " (in bytes " + getStartBytes() + " to " + getEndBytes() + ")"; } }
/** * * @param chpx The chpx this object is based on. * @param ss The stylesheet for the document this run belongs to. * @param istd The style index if this run's base style. * @param parent The parent range of this character run (usually a paragraph). */ CharacterRun(CHPX chpx, StyleSheet ss, short istd, Range parent) { super(Math.max(parent._start, chpx.getStart()), Math.min(parent._end, chpx.getEnd()), parent); _props = chpx.getCharacterProperties(ss, istd); _chpx = chpx.getSprmBuf(); }
/** * * @param chpx The chpx this object is based on. * @param ss The stylesheet for the document this run belongs to. * @param istd The style index if this run's base style. * @param parent The parent range of this character run (usually a paragraph). */ CharacterRun(CHPX chpx, StyleSheet ss, short istd, Range parent) { super(Math.max(parent._start, chpx.getStart()), Math.min(parent._end, chpx.getEnd()), parent); _props = chpx.getCharacterProperties(ss, istd); _chpx = chpx.getSprmBuf(); _istd = istd; }
int left = Math.max( this._start, chpx.getStart() ); int right = Math.min( this._end, chpx.getEnd() );
public void adjustForInsert(int listIndex, int length) { int size = _textRuns.size(); CHPX chpx = _textRuns.get(listIndex); chpx.setEnd(chpx.getEnd() + length); for (int x = listIndex + 1; x < size; x++) { chpx = _textRuns.get(x); chpx.setStart(chpx.getStart() + length); chpx.setEnd(chpx.getEnd() + length); } }
public void adjustForInsert(int listIndex, int length) { int size = _textRuns.size(); CHPX chpx = _textRuns.get(listIndex); chpx.setEnd(chpx.getEnd() + length); for (int x = listIndex + 1; x < size; x++) { chpx = _textRuns.get(x); chpx.setStart(chpx.getStart() + length); chpx.setEnd(chpx.getEnd() + length); } }
Math.max( chpx.getStart(), _start ), Math.min( chpx.getEnd(), _end ) );
Math.max( chpx.getStart(), _start ), Math.min( chpx.getEnd(), _end ) );
public void dumpChpx( boolean withProperties, boolean withSprms ) { for ( CHPX chpx : _doc.getCharacterTable().getTextRuns() ) { System.out.println( chpx ); if ( withProperties ) { System.out.println( chpx.getCharacterProperties( _doc.getStyleSheet(), (short) StyleSheet.NIL_STYLE ) ); } if ( withSprms ) { SprmIterator sprmIt = new SprmIterator( chpx.getGrpprl(), 0 ); while ( sprmIt.hasNext() ) { SprmOperation sprm = sprmIt.next(); System.out.println( "\t" + sprm); } } String text = new Range( chpx.getStart(), chpx.getEnd(), _doc.getOverallRange() ) { public String toString() { return "CHPX range (" + super.toString() + ")"; } }.text(); StringBuilder stringBuilder = new StringBuilder(); for ( char c : text.toCharArray() ) { if ( c < 30 ) stringBuilder.append("\\0x").append(Integer.toHexString(c)); else stringBuilder.append( c ); } System.out.println( stringBuilder ); } }
if (chpx.getStart() < cpStart)
chpx.setStart(chpx.getStart() - length); chpx.setEnd(chpx.getEnd() - length);
int left = Math.max( this._start, chpx.getStart() ); int right = Math.min( this._end, chpx.getEnd() ); DocumentFormatException.check(left < right, "left must be < right");
if (chpx.getStart() < cpStart)
chpx.setStart(chpx.getStart() - length); chpx.setEnd(chpx.getEnd() - length);
String text = new Range( chpx.getStart(), chpx.getEnd(), _doc.getOverallRange() )
int runStart = chpx.getStart() + fcMin; int runEnd = chpx.getEnd() + fcMin;