Exemplo n.º 1
0
Bool scContUnit::ReplaceWord( CharRecordP&		startChRec,
							  scSpecRecord*&	specRec,
							  long				startOffset,
							  long&				endOffset,
							  long&				limitOffset,
							  UCS2*				chBuf,
							  UCS2*				replaceBuf )
{
	long	deltaLen;
			
	deltaLen = CharacterBufLen( replaceBuf ) - CharacterBufLen( chBuf );
	
	if ( !deltaLen ) {
		LoadNewWord( startChRec + startOffset,
					 replaceBuf,
					 endOffset - startOffset );
		return false;
	}
	
		// need to grow or shrink memory
//	if ( deltaLen > 0 )	// grow the memory - first resize and then move
//		PARASetChSize( p, startChRec, deltaLen );
		

//	memmove( *startChRec + *endOffset + deltaLen,
//			*startChRec + *endOffset,
//			(size_t)( p->fChSize - *endOffset + 1 ) * sizeof( CharRecord ) );
//	p->fChSize		+= deltaLen;
//	*limitOffset	+= deltaLen;
//	*endOffset		+= deltaLen;

//	scAssert( (*startChRec + p->fChSize)->character == 0 );					

//	if ( deltaLen < 0 ) // shrink the memory - first move and then resize
//		PARASetChSize(  p, startChRec, deltaLen );

	
	LoadNewWord( startChRec + startOffset, replaceBuf, endOffset - startOffset );

	fSpecRun.BumpOffset( endOffset - deltaLen, deltaLen );
	specRec = fSpecRun.ptr( );

	return true;
}
Exemplo n.º 2
0
/* ==================================================================== */
scRubiData::scRubiData( const UCS2 *ch, long start, long end, TypeSpec ts )
{
	int len = MIN( CharacterBufLen( ch ), 16 );
	
	memcpy( fCh, ch, len * sizeof( UCS2 ) );
	fCh[len] = 0;
	fStartOffset		= start;
	fEndOffset			= end;
	fRubiSpec			= ts;	
	fOrg.Set( 0, 0 );
	fExtents.Set( 0, 0, 0, 0 );
}
Exemplo n.º 3
0
Bool scContUnit::FindString( const UCS2*	findString, 
							 const SearchState&	flags,
							 long&			startOffset,
							 long&			endOffset )
{
	stUnivString ustr;
	ustr.ptr = findString;
	ustr.len = CharacterBufLen( findString );

	if ( fCharArray.FindString( ustr, flags, startOffset, endOffset, startOffset ) ) {
		endOffset = startOffset + ustr.len;
		return true;
	}
	return false;
}
Exemplo n.º 4
0
// draw japanese rubi
void scDrawLine::DrawRubi( const scRubiData& rd )
{
	int 			i,
					count		= CharacterBufLen( rd.fCh );
	MicroPoint		hEscapement;
	MicroPoint		vEscapement;
	scXRect 		xrect( rd.fExtents );
	scMuPoint		org 		= rd.fOrg;
	scMuPoint		trans;
	TSJust			rubiJust	= TSRubiJust(  rd.fRubiSpec );
	MicroPoint		letterspace;
	
	scCachedStyle::GetCachedStyle( rd.fRubiSpec );
	SetRubiCharData( rd, fFlowDir, rubiJust, count, letterspace );
	
	trans = fOrigin;
	if ( fFlowDir.IsHorizontal() ) {
		switch ( scCachedStyle::GetCachedStyle().GetHorzBaseline() ) {
			case kTopBaseline:
				trans.y = fBaselinePositions.fTop;
				break;
			case kMiddleBaseline:
				trans.y = fBaselinePositions.fMiddle;
				break;
			case kBottomBaseline:
				trans.y = fBaselinePositions.fBottom;
				break;
			default:
			case kRomanBaseline:
				trans.y = fBaselinePositions.fRoman;
				break;
		}
	}
	else {
		switch ( scCachedStyle::GetCachedStyle().GetVertBaseline() ) {		
			case kLeftBaseline:
				trans.x = fBaselinePositions.fLeft;
				break;
			default:
			case kCenterBaseline:
				trans.x = fBaselinePositions.fMiddle;
				break;
			case kRightBaseline:
				trans.x = fBaselinePositions.fRight;
				break;
		}			
	}

	org.Translate( trans );
	fCurPos = org;

	if ( fFlowDir.IsVertical() ) {
		hEscapement = 0;
		vEscapement = fGlyphInfo.pointsize + letterspace;		
	}
	else {
		hEscapement = fGlyphInfo.setsize + letterspace;
		vEscapement = 0;
	}
	
	fChA	= fChArray;
	for ( i = 0; i < count; i++ ) {
		fChA[i].ch			= rd.fCh[i];
		fChA[i].flags.ClearFlags();
		fChA[i].hEscapement = hEscapement;
		fChA[i].vEscapement = vEscapement;		
	}

	APPDrawStartLine( fDawContext, org.x, org.y, hrect );
	APPDrawString( fDrawContext, fChArray, count, org.x, org.y, fGlyphInfo );
	APPDrawEndLine( fDrawContext ); 
}