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 insert(int listIndex, int cpStart, SprmBuffer buf) CHPX insertChpx = new CHPX(0, 0, buf); insertChpx.setStart(cpStart); insertChpx.setEnd(cpStart); if (chpx.getStart() < cpStart) CHPX clone = new CHPX(0, 0, chpx.getSprmBuf()); clone.setStart(cpStart); clone.setEnd(chpx.getEnd()); chpx.setEnd(cpStart);
/** * * @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(); }
public String toString() { return "CHPX from " + getStart() + " to " + getEnd() + " (in bytes " + getStartBytes() + " to " + getEndBytes() + ")"; } }
CHPX chpx = new CHPX( textPiece.getStart(), textPiece.getEnd(), newSprmBuffer ); _textRuns.add( chpx ); textRunsBoundariesSet.add( Integer.valueOf( chpx.getStart() ) ); textRunsBoundariesSet.add( Integer.valueOf( chpx.getEnd() ) ); startPosition--; while ( startPosition > 0 && oldChpxSortedByStartPos.get( startPosition ).getStart() >= boundary ) startPosition--; if ( boundary < chpx.getStart() ) break; int left = Math.max( startInclusive, chpx.getStart() ); int right = Math.min(boundary, chpx.getEnd() ); CHPX chpx = new CHPX( startInclusive, boundary, new SprmBuffer( 0 ) ); newChpxs.add( chpx ); if ( existing.getStart() == startInclusive && existing.getEnd() == boundary) sprmBuffer.append( chpx.getGrpprl(), 0 ); CHPX newChpx = new CHPX( startInclusive, boundary, sprmBuffer ); newChpxs.add( newChpx );
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 ); } }
public CharacterProperties getCharacterProperties(StyleSheet ss, short istd) { if (ss == null) { // TODO Fix up for Word 6/95 return new CharacterProperties(); } CharacterProperties baseStyle = ss.getCharacterStyle(istd); return CharacterSprmUncompressor.uncompressCHP( ss, baseStyle, getGrpprl(), 0); }
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. }
_textRuns.add( new CHPX( 0, 0, new SprmBuffer( 0 ) ) );
chpx.adjustForDelete(_start, _end - _start);
CHPX chpx = new CHPX( textPiece.getStart(), textPiece.getEnd(), newSprmBuffer ); _textRuns.add( chpx ); textRunsBoundariesSet.add( Integer.valueOf( chpx.getStart() ) ); textRunsBoundariesSet.add( Integer.valueOf( chpx.getEnd() ) ); startPosition--; while ( startPosition > 0 && oldChpxSortedByStartPos.get( startPosition ).getStart() >= boundary ) startPosition--; if ( boundary < chpx.getStart() ) break; int left = Math.max( startInclusive, chpx.getStart() ); int right = Math.min( endExclusive, chpx.getEnd() ); CHPX chpx = new CHPX( startInclusive, endExclusive, new SprmBuffer( 0 ) ); newChpxs.add( chpx ); if ( existing.getStart() == startInclusive && existing.getEnd() == endExclusive ) sprmBuffer.append( chpx.getGrpprl(), 0 ); CHPX newChpx = new CHPX( startInclusive, endExclusive, sprmBuffer ); newChpxs.add( newChpx );
for ( ; index < size; index++ ) int grpprlLength = ( _chpxList.get( index ) ).getGrpprl().length; int chpxStart = translator.getByteIndex( chpx.getStart() ); chpxEnd = translator.getByteIndex( chpx.getEnd() ); LittleEndian.putInt( buf, fcOffset, chpxStart ); byte[] grpprl = chpx.getGrpprl(); grpprlOffset -= ( 1 + grpprl.length ); grpprlOffset -= ( grpprlOffset % 2 );
System.out.println( chpx.getCharacterProperties( _doc.getStyleSheet(), (short) StyleSheet.NIL_STYLE ) ); SprmIterator sprmIt = new SprmIterator( chpx.getGrpprl(), 0 ); while ( sprmIt.hasNext() ) String text = new Range( chpx.getStart(), chpx.getEnd(), _doc.getOverallRange() )
public String toString() { return "CHPX from " + getStart() + " to " + getEnd() + " (in bytes " + getStartBytes() + " to " + getEndBytes() + ")"; } }
public CharacterProperties getCharacterProperties( StyleSheet ss, short istd ) { if ( ss == null ) { // TODO Fix up for Word 6/95 return new CharacterProperties(); } CharacterProperties baseStyle = ss.getCharacterStyle( istd ); if (baseStyle == null) baseStyle = new CharacterProperties(); CharacterProperties props = CharacterSprmUncompressor.uncompressCHP( baseStyle, getGrpprl(), 0 ); return props; }
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. }
_textRuns.add( new CHPX( 0, 0, new SprmBuffer( 0 ) ) );