Exemplo n.º 1
0
        public void FormatTwiceBasicScenario()
        {
            RtfFormatter formatter = new RtfFormatter();

            string input          = @"{\rtf\ansi\ansicpg1252\uc1\deff0\deflang1033{\fonttbl{\f0 Verdana;}{\f1 Symbol;}}{\pard Urbem Romam a principio reges habuere; libertatem et consulatum L. Brutus instituit. dictaturae ad tempus sumebantur; neque decemviralis potestas ultra biennium, neque tribunorum militum consulare ius diu valuit. \sa200 \par}{\pard Second paragraph. \par}}";
            string expectedOutput = shortRtfFormatted;

            string output = formatter.GetFormattedText(input);

            Assert.AreEqual(expectedOutput, output);

            output = formatter.GetFormattedText(input);

            Assert.AreEqual(expectedOutput, output);
        }
Exemplo n.º 2
0
        public void NonRtfText()
        {
            RtfFormatter formatter = new RtfFormatter();

            string input  = @"fsdfd";
            string output = formatter.GetFormattedText(input);
        }
Exemplo n.º 3
0
        public void EscapedBracketsAreNotTreatedAsBlockBegining()
        {
            RtfFormatter formatter = new RtfFormatter();

            string input          = @"{\rtf{\pard\listtext \{0\}.}\par}}";
            string expectedOutput = @"{\rtf
{\pard\listtext \{0\}.}
\par}}";

            string output = formatter.GetFormattedText(input);

            Assert.AreEqual(expectedOutput, output);

            output = formatter.GetFormattedText(input);

            Assert.AreEqual(expectedOutput, output);
        }
Exemplo n.º 4
0
        public void TextContainsBlocksWithoutCurlyBrackets()
        {
            RtfFormatter formatter = new RtfFormatter();

            string input          = @"{\rtf\ansi\ansicpg1252\uc1\deff0\deflang1033{\fonttbl{\f0 Verdana;}{\f1 Symbol;}}\pard First paragraph \sa200 \par{\pard Second paragraph. \par}}";
            string expectedOutput = this.rtfParWithoutBracketsFormatted;

            string output = formatter.GetFormattedText(input);

            Assert.AreEqual(expectedOutput, output);
        }
Exemplo n.º 5
0
        public void TextAlreadyFormatted()
        {
            RtfFormatter formatter = new RtfFormatter();

            string input          = shortRtfFormatted;
            string expectedOutput = shortRtfFormatted;

            string output = formatter.GetFormattedText(input);

            Assert.AreEqual(expectedOutput, output);
        }
Exemplo n.º 6
0
        public void LongRtf()
        {
            RtfFormatter formatter = new RtfFormatter();

            Stream stream = File.OpenRead(@"..\..\LongRtf.txt");
            string input  = "";

            using (stream)
            {
                StreamReader reader = new StreamReader(stream);
                input = reader.ReadToEnd();
            }

            string output = formatter.GetFormattedText(input);
        }
Exemplo n.º 7
0
        private static void FormatRtf()
        {
            IntPtr           currentScint     = PluginBase.GetCurrentScintilla();
            ScintillaGateway scintillaGateway = new ScintillaGateway(currentScint);

            string allText = scintillaGateway.GetAllText();

            if (!IsTextRtf(allText))
            {
                return;
            }

            string newText = rtfFormatter.GetFormattedText(allText);

            if (allText != newText)
            {
                scintillaGateway.SetText(newText);
            }
        }