Exemple #1
0
// ****************************************************************************
//
//  Function Name:	RNameAddress::FormatNameAddress( )
//
//  Description:		Perform the formatting described in the format string to
//							the given inputs and put the result into output
//
//  Returns:			Nothing
//
//  Exceptions:		kMemory
//
// ****************************************************************************
//
void RNameAddress::FormatNameAddress( RMBCString& output, const RMBCString& format,
									const RMBCString& firstName, const RMBCString& lastName, const RMBCString& address,
									const RMBCString& city, const RMBCString& state, const RMBCString& zip,
									const RMBCString& country )
{
	output.Empty( );

	RMBCStringIterator	iterator		= format.Start( );
	RMBCStringIterator	iteratorEnd	= format.End( );

	for ( ; iterator != iteratorEnd; ++iterator )
	{
		RCharacter	ch	= ( *iterator );
		if ( ch == kFormatIdentifierTag )
		{
			++iterator;
			TpsAssert( iterator!=iteratorEnd, "Format Identifier found at end of stream" );
			ch = ( *iterator );
			if ( ch == kFormatIdentifierTag )
				output	+= kFormatIdentifierTag;
			else if ( ch == kFirstNameIdentifierTag )
				output	+= firstName;
			else if ( ch == kLastNameIdentifierTag )
				output	+= lastName;
			else if ( ch == kAddressIdentifierTag )
				output	+= address;
			else if ( ch == kCityIdentifierTag )
				output	+= city;
			else if ( ch == kStateIdentifierTag )
				output	+= state;
			else if ( ch == kZipIdentifierTag )
				output	+= zip;
			else if ( ch == kCountryIdentifierTag )
				output	+= country;
			else
			{
				TpsAssertAlways( "Unknown format tag found" );
			}
		}
		else
		{
			if ( ch == kSpaceTag )
				output	+= ch;
			else if ( ch == kReturnTag )
				output	+= ch;
			else if ( ch == kTabTag )
				output	+= ch;
			else if ( ch == kCommaTag )
				output	+= ch;
			else
			{
				//TpsAssertAlways( "Unsupported Character, If it is necessary add it to the MergeField info and here" );
				output	+= ch;
			}
		}
	}

}
Exemple #2
0
// ****************************************************************************
//
//  Function Name:	RFont::GetStringWidth( )
//
//  Description:		Return the width of the given string of characters
//
//  Returns:			The requested string size
//
//  Exceptions:		Nothing
//
// ****************************************************************************
//
YFontSize RFont::GetStringWidth( const RMBCString& string ) const
	{
	YFontSize				size = 0;

	RDataObjectLocker	locker( m_pWidthsTable );
	for ( RMBCStringIterator cz = string.Start(); cz != string.End(); ++cz )
		size += m_pWidthsTable->GetCharacterWidth( *cz );

	return size;
	}
Exemple #3
0
// ****************************************************************************
//
//  Function Name:	RNameAddress::FormatNameAddress( )
//
//  Description:		Perform the formatting described in the format string to
//							the given inputs and put the result into address
//
//  Returns:			Nothing
//
//  Exceptions:		kMemory
//
// ****************************************************************************
//
void RNameAddress::FormatNameAddress( RMergeFieldContainer& output, const RMBCString& format,
										YMergeId firstName, YMergeId lastName, YMergeId address,
										YMergeId city, YMergeId state, YMergeId zip, YMergeId country )
{
	output.Empty( );

	RMBCStringIterator	iterator		= format.Start( );
	RMBCStringIterator	iteratorEnd	= format.End( );

	for ( ; iterator != iteratorEnd; ++iterator )
	{
		RCharacter	ch	= ( *iterator );
		if ( ch == kFormatIdentifierTag )
		{
			++iterator;
			TpsAssert( iterator!=iteratorEnd, "Format Identifier found at end of stream" );
			ch = ( *iterator );
			if ( ch == kFirstNameIdentifierTag )
				output.InsertAtEnd( firstName );
			else if ( ch == kLastNameIdentifierTag )
				output.InsertAtEnd( lastName );
			else if ( ch == kAddressIdentifierTag )
				output.InsertAtEnd( address );
			else if ( ch == kCityIdentifierTag )
				output.InsertAtEnd( city );
			else if ( ch == kStateIdentifierTag )
				output.InsertAtEnd( state );
			else if ( ch == kZipIdentifierTag )
				output.InsertAtEnd( zip );
			else if ( ch == kCountryIdentifierTag )
				output.InsertAtEnd( country );
			else
			{
				TpsAssertAlways( "Unknown format tag found" );
			}
		}
		else
		{
			if ( ch == kSpaceTag )
				output.InsertAtEnd( kMergeFieldSpace );
			else if ( ch == kReturnTag )
				output.InsertAtEnd( kMergeFieldReturn );
			else if ( ch == kTabTag )
				output.InsertAtEnd( kMergeFieldTab );
			else if ( ch == kCommaTag )
				output.InsertAtEnd( kMergeFieldComma );
			else
			{
				TpsAssertAlways( "Unsupported Character, If it is necessary add it to the MergeField info and here" );
			}
		}
	}

}
Exemple #4
0
// ****************************************************************************
//
//  Function Name:	RFont::GetStringWidth( )
//
//  Description:		Return the width of the given string of characters
//
//  Returns:			The requested string size
//
//  Exceptions:		Nothing
//
// ****************************************************************************
//
YFontSize RFont::GetStringWidth( const RMBCString& string, BOOLEAN fKern ) const
	{
	YFontSize				size = GetStringWidth( string );
	RMBCStringIterator	cz;
	RCharacter				character, next;

	if ( fKern )
		{
		cz = string.Start(); 
		character = *cz;
		++cz;
		while ( cz != string.End() )
			{
			next = *cz;
			size += GetKernAmount( character, next );
			character = next;
			++cz;
			}
		}

	return size;
	}