Ejemplo n.º 1
0
 public void TestEmpty()
 {
     XSSFRichTextString rt = new XSSFRichTextString();
     Assert.AreEqual(0, rt.GetIndexOfFormattingRun(9999));
     Assert.AreEqual(-1, rt.GetLengthOfFormattingRun(9999));
     Assert.IsNull(rt.GetFontAtIndex(9999));
 }
Ejemplo n.º 2
0
        public void TestApplyFont()
        {
            XSSFRichTextString rt = new XSSFRichTextString();

            rt.Append("123");
            rt.Append("4567");
            rt.Append("89");

            Assert.AreEqual("123456789", rt.String);

            XSSFFont font1 = new XSSFFont();

            font1.IsBold = (true);

            rt.ApplyFont(2, 5, font1);

            Assert.AreEqual(4, rt.NumFormattingRuns);
            Assert.AreEqual(0, rt.GetIndexOfFormattingRun(0));
            Assert.AreEqual("12", rt.GetCTRst().GetRArray(0).t);

            Assert.AreEqual(2, rt.GetIndexOfFormattingRun(1));
            Assert.AreEqual("345", rt.GetCTRst().GetRArray(1).t);

            Assert.AreEqual(5, rt.GetIndexOfFormattingRun(2));
            Assert.AreEqual(2, rt.GetLengthOfFormattingRun(2));
            Assert.AreEqual("67", rt.GetCTRst().GetRArray(2).t);

            Assert.AreEqual(7, rt.GetIndexOfFormattingRun(3));
            Assert.AreEqual(2, rt.GetLengthOfFormattingRun(3));
            Assert.AreEqual("89", rt.GetCTRst().GetRArray(3).t);

            Assert.AreEqual(-1, rt.GetIndexOfFormattingRun(9999));
            Assert.AreEqual(-1, rt.GetLengthOfFormattingRun(9999));
            Assert.IsNull(rt.GetFontAtIndex(9999));
        }
Ejemplo n.º 3
0
        public void TestEmpty()
        {
            XSSFRichTextString rt = new XSSFRichTextString();

            Assert.AreEqual(0, rt.GetIndexOfFormattingRun(9999));
            Assert.AreEqual(-1, rt.GetLengthOfFormattingRun(9999));
            Assert.IsNull(rt.GetFontAtIndex(9999));
        }
Ejemplo n.º 4
0
        public void TestApplyFontIndex()
        {
            XSSFRichTextString rt = new XSSFRichTextString("Apache POI");

            rt.ApplyFont(0, 10, (short)1);

            rt.ApplyFont((short)1);

            Assert.IsNotNull(rt.GetFontAtIndex(0));
        }
Ejemplo n.º 5
0
        public void Test59008Font()
        {
            XSSFFont font = new XSSFFont(new CT_Font());

            XSSFRichTextString rts = new XSSFRichTextString();

            rts.Append("This is correct ");
            int s1 = rts.Length;

            rts.Append("This is Bold Red", font);
            int s2 = rts.Length;

            rts.Append(" This uses the default font rather than the cell style font");
            int s3 = rts.Length;

            Assert.AreEqual("<xml-fragment/>", rts.GetFontAtIndex(s1 - 1).ToString());
            Assert.AreEqual(font, rts.GetFontAtIndex(s2 - 1));
            Assert.AreEqual("<xml-fragment/>", rts.GetFontAtIndex(s3 - 1).ToString());
        }
Ejemplo n.º 6
0
        public void TestApplyFontIndex()
        {
            XSSFRichTextString rt = new XSSFRichTextString("Apache POI");
            rt.ApplyFont(0, 10, (short)1);

            rt.ApplyFont((short)1);

            Assert.IsNotNull(rt.GetFontAtIndex(0));
        }
Ejemplo n.º 7
0
        public void TestApplyFont()
        {

            XSSFRichTextString rt = new XSSFRichTextString();
            rt.Append("123");
            rt.Append("4567");
            rt.Append("89");

            Assert.AreEqual("123456789", rt.String);

            XSSFFont font1 = new XSSFFont();
            font1.IsBold = (true);

            rt.ApplyFont(2, 5, font1);

            Assert.AreEqual(4, rt.NumFormattingRuns);
            Assert.AreEqual(0, rt.GetIndexOfFormattingRun(0));
            Assert.AreEqual("12", rt.GetCTRst().GetRArray(0).t);

            Assert.AreEqual(2, rt.GetIndexOfFormattingRun(1));
            Assert.AreEqual("345", rt.GetCTRst().GetRArray(1).t);

            Assert.AreEqual(5, rt.GetIndexOfFormattingRun(2));
            Assert.AreEqual(2, rt.GetLengthOfFormattingRun(2));
            Assert.AreEqual("67", rt.GetCTRst().GetRArray(2).t);

            Assert.AreEqual(7, rt.GetIndexOfFormattingRun(3));
            Assert.AreEqual(2, rt.GetLengthOfFormattingRun(3));
            Assert.AreEqual("89", rt.GetCTRst().GetRArray(3).t);

            Assert.AreEqual(-1, rt.GetIndexOfFormattingRun(9999));
            Assert.AreEqual(-1, rt.GetLengthOfFormattingRun(9999));
            Assert.IsNull(rt.GetFontAtIndex(9999));

        }