﻿//------------------------------------------------------------------------------
//
// ADOBE SYSTEMS INCORPORATED
// Copyright 2003 Adobe Systems Incorporated 
// All Rights Reserved
//
// NOTICE: Adobe permits you to use, modify, and distribute 
// this file in accordance with the terms of the Adobe license 
// agreement accompanying it. If you have received this file 
// from a source other than Adobe, then your use, modification, 
// or distribution of it requires the prior written permission 
// of Adobe.
//
//------------------------------------------------------------------------------

function RTFEntry( type, character, group )
{
	this.type	= type;
	this.group	= group;
	this.name	= character;
	this.value	= '';
	
	switch( this.type )
	{
		case 'ctrlWord':
			this.splitValue();
			break;
			
		case 'character':
			this.name = '';
			this.value = character;
			break;
	}
}

RTFEntry.prototype.addCharacter = function( ch )
{
	this.value += ch;
}

RTFEntry.prototype.splitValue = function()
{
	// split name and numeric value
	var name  = '';
	var value = '';
	
	var n = true;
	
	for( var i=0; i<this.name.length; i++ )
	{
		var c = this.name[i];

		if( c != ' ' )
		{		
			if( n )
			{
				// get name
				if( isNaN(parseInt(c)) )
				{
					name += c;
				}
				else
				{
					value += c;
					n = false;
				}
			}
			else
			{
				// get value
				value += c
			}
		}
	}
	
	this.name  = name;
	this.value = parseInt( value );
	
	// get default value	
	if( isNaN(this.value) )
	{
		var entry = null;
		
		for( var i=0; i<rtf2html.length && entry == null; i++ )
		{
			if( rtf2html[i][0] == this.name )
				entry = rtf2html[i];
		}
		
		if( entry != null )
			this.value = entry[4];
	}
}