Example #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;
			}
		}
	}

}
Example #2
0
// ****************************************************************************
//
//  Function Name:	RMergeData::ReadTabDelimitedString( )
//
//  Description:		Read a string that is tab delimited from the storage.
//							Eat the delimeter character also (eof, cr/lf, tab).
//
//  Returns:			Nothing
//
//  Exceptions:		Any File Exception, will not send through on kEndOfFile
//
// ****************************************************************************
//
RMergeData::EDataDelimiter RMergeData::ReadTabDelimitedString( RStorage& storage, RMBCString& string )
	{
	EDataDelimiter	delimiter	= kTab;

	try
		{
		uBYTE			ubChar( 0 );
		RCharacter	character;

		//	First, make sure the string is empty
		string.Empty( );

		//	Loop until I hit a EOF, TAB, CR, or LF
		while ( 1 )
			{
			storage >> ubChar;
			if ( (ubChar == '\t') || (ubChar == '\r') || (ubChar == '\n') )
				break;

			//	Check for multi-Byte
			character = ubChar;

			if ( character.IsLead( ) )
				{
				UntestedCode( );
				uBYTE	lead	= ubChar;
				uBYTE	trail;
				storage >> trail;
				character = RCharacter( lead, trail );
				}

			string += character;
			}

			//	If I found a CR or a LF, make sure the other is not also present.
			if ( (ubChar == '\r') || (ubChar == '\n') )
				{
				storage >> ubChar;
				//	If character is NOT a CR or LF, rewind one character
				if ( !((ubChar == '\r') || (ubChar == '\n')) )
					storage.SeekRelative( -1 );
				delimiter = kEOL;
				}
Example #3
0
// ****************************************************************************
//
//  Function Name:	RHLSpellCheckInterface::GetContext()
//
//  Description:		Return the context around the last word returned
//
//  Returns:			Nothing
//
//  Exceptions:		None
//
// ****************************************************************************
void RHLSpellCheckInterface::GetContext( RMBCString& context, int& nWordStart )
{
	//	Empty the context
	context.Empty( );

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

	nWordStart			= m_nWordStart;
	int nStartContext	= (m_nWordStart>kContextSize/2)? m_nWordStart-(kContextSize/2) : 0;
	iterator	+= nStartContext;

	//	Fill in at least kContextSize characters
	int	nLength = 0;
	while ( iterator != iteratorEnd )
	{
		context += (*iterator);
		++iterator;
		if ( ++nLength == kContextSize )
			break;
	}
}
Example #4
0
// ****************************************************************************
//
//  Function Name:	RHLSpellCheckInterface::RHLSpellCheckInterface()
//
//  Description:		Replace the current word with the given replacement
//
//  Returns:			TRUE if sucessful
//
//  Exceptions:		None
//
// ****************************************************************************
BOOLEAN RHLSpellCheckInterface::ReplaceWord( const RMBCString& original, const RMBCString& replacement )
{
	RMBCString				newText;
	RMBCStringIterator	iterator		= m_Text.Start( );
	RMBCStringIterator	iteratorEnd	= m_Text.End( );

	//	Empty the new string ( just to be paranoid );
	newText.Empty( );

	//	Copy the text before the word
	int	nLength = 0;
	while ( nLength++ < m_nWordStart )
	{
		newText	+= (*iterator);
		++iterator;
	}

	//	add the replacement word
	newText	+= replacement;
	//	skip over the original word
	iterator	+= original.GetStringLength( );

	//	add the remaining string
	while ( iterator != iteratorEnd )
	{
		newText	+= (*iterator);
		++iterator;
	}

	m_pDocument->SetHeadlineText( newText );
	m_Text			=	newText;
	m_nWordEnd		=	m_nWordStart + replacement.GetStringLength();

	//	Invalidate the render cache
	TpsAssertIsObject( RComponentView, m_pDocument->GetActiveView( ) );
	RComponentView* pView = static_cast< RComponentView* >( m_pDocument->GetActiveView( ) );
	pView->InvalidateRenderCache( );
	return TRUE;
}
Example #5
0
// ****************************************************************************
//
//  Function Name:	RHLSpellCheckInterface::FindNextWord()
//
//  Description:		Return the next word in the component
//
//  Returns:			TRUE if word found, FALSE if no more words
//
//  Exceptions:		None
//
// ****************************************************************************
BOOLEAN RHLSpellCheckInterface::FindNextWord( RMBCString& word )
{
	//	Empty the word
	word.Empty( );

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

	//	Advance to current word position
	iterator			+= m_nWordEnd;
	m_nWordStart	= m_nWordEnd;

	//	Try to find a word start.
	while ( iterator != iteratorEnd )
	{
		if ( !(*iterator).IsSpace( ) )
			break;
		++m_nWordStart;
		++iterator;
	}

	if ( iterator == iteratorEnd )
		return FALSE;

	//	Find the word end
	m_nWordEnd	= m_nWordStart;
	while ( iterator != iteratorEnd )
	{
		++m_nWordEnd;
		if ( (*iterator).IsSpace( ) )
			break;
		word	+=	(*iterator);
		++iterator;
	}

	return TRUE;
}