You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
2.5 KiB
C#
109 lines
2.5 KiB
C#
// <copyright file="RtfToken.cs" company="PlaceholderCompany">
|
|
// Copyright (c) PlaceholderCompany. All rights reserved.
|
|
// </copyright>
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace UCDraw.RTF
|
|
{
|
|
/// <summary>
|
|
/// [<NumericParameter/>]
|
|
/// </summary>
|
|
public class RtfToken
|
|
{
|
|
private RtfTokenType intType = RtfTokenType.None;
|
|
/// <summary>
|
|
/// type
|
|
/// </summary>
|
|
public RtfTokenType Type
|
|
{
|
|
get { return intType; }
|
|
set { intType = value; }
|
|
}
|
|
|
|
private string strKey = null;
|
|
/// <summary>
|
|
/// keyword
|
|
/// </summary>
|
|
public string Key
|
|
{
|
|
get { return strKey; }
|
|
set { strKey = value; }
|
|
}
|
|
|
|
private bool bolHasParam = false;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public bool HasParam
|
|
{
|
|
get { return bolHasParam; }
|
|
set { bolHasParam = value; }
|
|
}
|
|
|
|
private int intParam = 0;
|
|
public int Param
|
|
{
|
|
get { return intParam; }
|
|
set { intParam = value; }
|
|
}
|
|
|
|
private RtfToken myParent = null;
|
|
/// <summary>
|
|
/// parent token
|
|
/// </summary>
|
|
public RtfToken Parent
|
|
{
|
|
get { return myParent; }
|
|
set { myParent = value; }
|
|
}
|
|
public bool IsTextToken
|
|
{
|
|
get
|
|
{
|
|
if (intType == RtfTokenType.Text)
|
|
return true;
|
|
if (intType == RtfTokenType.Control && strKey == "'" && bolHasParam)
|
|
return true;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
if (intType == RtfTokenType.Keyword)
|
|
{
|
|
return this.Key + this.Param;
|
|
}
|
|
else if (intType == RtfTokenType.GroupStart)
|
|
{
|
|
return "{";
|
|
}
|
|
else if (intType == RtfTokenType.GroupEnd)
|
|
{
|
|
return "}";
|
|
}
|
|
else if (intType == RtfTokenType.Text)
|
|
{
|
|
return "Text:" + this.Param;
|
|
}
|
|
return intType.ToString() + ":" + this.Key + " " + this.Param;
|
|
}
|
|
}
|
|
public enum RtfTokenType
|
|
{
|
|
None,
|
|
Keyword,
|
|
ExtKeyword,
|
|
Control,
|
|
Text,
|
|
Eof,
|
|
GroupStart,
|
|
GroupEnd
|
|
}
|
|
}
|