Click here to Skip to main content
12,399,471 members (55,528 online)
Click here to Skip to main content

Stats

140.4K views
7K downloads
201 bookmarked
Posted

RichText Builder (StringBuilder for RTF)

, 12 Nov 2008 CPOL
RichText Builder - use in place of StringBuilder to output RTF.



 

namespace RTF
{
    using System.Text;

    // ----------------------------------------------------------------------------------------
    //    _                ___        _..-._   Date: 12/11/08    23:50
    //    \`.|\..----...-'`   `-._.-'' _.-..'     
    //    /  ' `         ,       __.-'' 
    //    )/` _/     \   `-_,   /     Solution: RTFLib
    //    `-'" `"\_  ,_.-;_.-\_ ',    Project : RTFLib                                 
    //        _.-'_./   {_.'   ; /    Author  : Anton
    //       {_.-``-'         {_/     Assembly: 1.0.0.0
    //                                Copyright © 2005-2008, Rogue Trader/MWM
    //        Project Item Name:      RTFUtil.cs - Code
    //        Purpose:                A Work in Progress
    // ----------------------------------------------------------------------------------------
    /// <summary>
    /// A Work in Progress
    /// </summary>
    public class RTFUtil
    {
        #region Public Methods

        public void ParagraphBorderSide(StringBuilder sb, RTFBorderSide rTFBorderSide)
        {
            if (rTFBorderSide == RTFBorderSide.None)
            {
                return;
            }
            if ((rTFBorderSide & RTFBorderSide.Left) == RTFBorderSide.Left)
            {
                sb.Append("\\brdrl");
            }
            if ((rTFBorderSide & RTFBorderSide.Right) == RTFBorderSide.Right)
            {
                sb.Append("\\brdrr");
            }
            if ((rTFBorderSide & RTFBorderSide.Top) == RTFBorderSide.Top)
            {
                sb.Append("\\brdrt");
            }
            if ((rTFBorderSide & RTFBorderSide.Bottom) == RTFBorderSide.Bottom)
            {
                sb.Append("\\brdrb");
            }

            if ((rTFBorderSide & RTFBorderSide.DoubleThickness) == RTFBorderSide.DoubleThickness)
            {
                sb.Append("\\brdrth");
            }
            else
            {
                sb.Append("\\brdrs");
            }
            if ((rTFBorderSide & RTFBorderSide.DoubleBorder) == RTFBorderSide.DoubleBorder)
            {
                sb.Append("\\brdrdb");
            }
            sb.Append("\\brdrw10");
        }

        public void TableRowBorderSide(StringBuilder sb, RTFBorderSide rTFBorderSide)
        {
            if (rTFBorderSide == RTFBorderSide.None)
            {
                return;
            }
            if ((rTFBorderSide & RTFBorderSide.Left) == RTFBorderSide.Left)
            {
                sb.Append("\\trbrdrl");
            }
            if ((rTFBorderSide & RTFBorderSide.Right) == RTFBorderSide.Right)
            {
                sb.Append("\\trbrdrr");
            }
            if ((rTFBorderSide & RTFBorderSide.Top) == RTFBorderSide.Top)
            {
                sb.Append("\\trbrdrt");
            }
            if ((rTFBorderSide & RTFBorderSide.Bottom) == RTFBorderSide.Bottom)
            {
                sb.Append("\\trbrdrb");
            }
            if ((rTFBorderSide & RTFBorderSide.DoubleThickness) == RTFBorderSide.DoubleThickness)
            {
                sb.Append("\\brdrth");
            }
            else
            {
                sb.Append("\\brdrs");
            }
            if ((rTFBorderSide & RTFBorderSide.DoubleBorder) == RTFBorderSide.DoubleBorder)
            {
                sb.Append("\\brdrdb");
            }
            sb.Append("\\brdrw10");
        }

        #endregion
    }
}


By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

seeblunt
Australia Australia
Interested in financial math and programming theory in general. Working on medical applications in spare time. Happy to get feedback.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.160721.1 | Last Updated 12 Nov 2008
Article Copyright 2008 by seeblunt
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid