Beispiel #1
0
        public void TestStripFields()
        {
            String simple         = "I am a Test header";
            String withPage       = "I am a&P Test header";
            String withLots       = "I&A am&N a&P Test&T header&U";
            String withFont       = "I&22 am a&\"Arial,bold\" Test header";
            String withOtherAnds  = "I am a&P Test header&&";
            String withOtherAnds2 = "I am a&P Test header&a&b";

            Assert.AreEqual(simple, XSSFOddHeader.StripFields(simple));
            Assert.AreEqual(simple, XSSFOddHeader.StripFields(withPage));
            Assert.AreEqual(simple, XSSFOddHeader.StripFields(withLots));
            Assert.AreEqual(simple, XSSFOddHeader.StripFields(withFont));
            Assert.AreEqual(simple + "&&", XSSFOddHeader.StripFields(withOtherAnds));
            Assert.AreEqual(simple + "&a&b", XSSFOddHeader.StripFields(withOtherAnds2));

            // Now Test the default strip flag
            XSSFEvenHeader head = new XSSFEvenHeader(new CT_HeaderFooter());

            head.Center = ("Center");
            head.Left   = ("In the left");

            Assert.AreEqual("In the left", head.Left);
            Assert.AreEqual("Center", head.Center);
            Assert.AreEqual("", head.Right);

            head.Left = ("Top &P&F&D Left");
            Assert.AreEqual("Top &P&F&D Left", head.Left);
            Assert.IsFalse(head.AreFieldsStripped());

            head.SetAreFieldsStripped(true);
            Assert.AreEqual("Top  Left", head.Left);
            Assert.IsTrue(head.AreFieldsStripped());

            // Now even more complex
            head.Center = ("HEADER TEXT &P&N&D&T&Z&F&F&A&V");
            Assert.AreEqual("HEADER TEXT &V", head.Center);
        }
        public void TestStripFields()
        {
            String simple = "I am a Test header";
            String withPage = "I am a&P Test header";
            String withLots = "I&A am&N a&P Test&T header&U";
            String withFont = "I&22 am a&\"Arial,bold\" Test header";
            String withOtherAnds = "I am a&P Test header&&";
            String withOtherAnds2 = "I am a&P Test header&a&b";

            Assert.AreEqual(simple, XSSFOddHeader.StripFields(simple));
            Assert.AreEqual(simple, XSSFOddHeader.StripFields(withPage));
            Assert.AreEqual(simple, XSSFOddHeader.StripFields(withLots));
            Assert.AreEqual(simple, XSSFOddHeader.StripFields(withFont));
            Assert.AreEqual(simple + "&&", XSSFOddHeader.StripFields(withOtherAnds));
            Assert.AreEqual(simple + "&a&b", XSSFOddHeader.StripFields(withOtherAnds2));

            // Now Test the default strip flag
            XSSFEvenHeader head = new XSSFEvenHeader(new CT_HeaderFooter());
            head.Center = ("Center");
            head.Left = ("In the left");

            Assert.AreEqual("In the left", head.Left);
            Assert.AreEqual("Center", head.Center);
            Assert.AreEqual("", head.Right);

            head.Left = ("Top &P&F&D Left");
            Assert.AreEqual("Top &P&F&D Left", head.Left);
            Assert.IsFalse(head.AreFieldsStripped());

            head.SetAreFieldsStripped(true);
            Assert.AreEqual("Top  Left", head.Left);
            Assert.IsTrue(head.AreFieldsStripped());

            // Now even more complex
            head.Center = ("HEADER TEXT &P&N&D&T&Z&F&F&A&V");
            Assert.AreEqual("HEADER TEXT &V", head.Center);
        }