Example #1
0
        public void TestSetGetStrike()
        {
            CT_RPr rpr = ctRun.AddNewRPr();

            rpr.AddNewStrike().val = true;

            XWPFRun run = new XWPFRun(ctRun, p);

            Assert.AreEqual(true, run.IsStrike);

            run.SetStrike(false);
            Assert.AreEqual(false, rpr.strike.val);
        }
Example #2
0
        public void TestSetGetItalic()
        {
            CT_RPr rpr = ctRun.AddNewRPr();

            rpr.AddNewI().val = true;

            XWPFRun run = new XWPFRun(ctRun, p);

            Assert.AreEqual(true, run.IsItalic);

            run.IsItalic = false;
            Assert.AreEqual(false, rpr.i.val);
        }
Example #3
0
        public void TestSetGetTextForegroundBackground()
        {
            CT_RPr rpr = ctRun.AddNewRPr();

            rpr.AddNewPosition().val = "4000";

            XWPFRun run = new XWPFRun(ctRun, p);

            Assert.AreEqual(4000, run.GetTextPosition());

            run.SetTextPosition(2400);
            Assert.AreEqual(2400, int.Parse(rpr.position.val));
        }
Example #4
0
        public void TestSetGetFontSize()
        {
            CT_RPr rpr = ctRun.AddNewRPr();

            rpr.AddNewSz().val = 14;

            XWPFRun run = new XWPFRun(ctRun, p);

            Assert.AreEqual(7, run.FontSize);

            run.FontSize = (24);
            Assert.AreEqual(48, (int)rpr.sz.val);
        }
Example #5
0
        public void TestSetGetFontFamily()
        {
            CT_RPr rpr = ctRun.AddNewRPr();

            rpr.AddNewRFonts().ascii = ("Times New Roman");

            XWPFRun run = new XWPFRun(ctRun, p);

            Assert.AreEqual("Times New Roman", run.FontFamily);

            run.FontFamily = ("Verdana");
            Assert.AreEqual("Verdana", rpr.rFonts.ascii);
        }
Example #6
0
        public void TestSetGetVAlign()
        {
            CT_RPr rpr = ctRun.AddNewRPr();

            rpr.AddNewVertAlign().val = (ST_VerticalAlignRun.subscript);

            XWPFRun run = new XWPFRun(ctRun, p);

            Assert.AreEqual(VerticalAlign.SUBSCRIPT, run.Subscript);

            run.Subscript = (VerticalAlign.BASELINE);
            Assert.AreEqual(ST_VerticalAlignRun.baseline, rpr.vertAlign.val);
        }
Example #7
0
        public void TestSetGetUnderline()
        {
            CT_RPr rpr = ctRun.AddNewRPr();

            rpr.AddNewU().val = (ST_Underline.dash);

            XWPFRun run = new XWPFRun(ctRun, p);

            Assert.AreEqual(UnderlinePatterns.Dash, run.Underline);

            run.SetUnderline(UnderlinePatterns.None);
            Assert.AreEqual(ST_Underline.none, rpr.u.val);
        }
Example #8
0
        public void TestRuns()
        {
            XWPFDocument  doc = new XWPFDocument();
            XWPFParagraph p   = doc.CreateParagraph();

            CT_R    run = new CT_R();
            XWPFRun r   = new XWPFRun(run, doc.CreateParagraph());

            p.AddRun(r);
            p.AddRun(r);

            Assert.IsNotNull(p.GetRun(run));
            Assert.IsNull(p.GetRun(null));
        }
Example #9
0
        public void TestSetGetBold()
        {
            CT_RPr rpr = ctRun.AddNewRPr();

            rpr.AddNewB().val = true;

            XWPFRun run = new XWPFRun(ctRun, p);

            Assert.AreEqual(true, run.IsBold);

            run.IsBold = (false);
            Assert.AreEqual(false, run.IsBold);
            Assert.AreEqual(false, rpr.b.val);
        }
Example #10
0
        public void TestAddPicture()
        {
            XWPFDocument  doc = XWPFTestDataSamples.OpenSampleDocument("TestDocument.docx");
            XWPFParagraph p   = doc.GetParagraphArray(2);
            XWPFRun       r   = p.Runs[0];

            Assert.AreEqual(0, doc.AllPictures.Count);
            Assert.AreEqual(0, r.GetEmbeddedPictures().Count);

            r.AddPicture(new MemoryStream(new byte[0]), (int)PictureType.JPEG, "test.jpg", 21, 32);

            Assert.AreEqual(1, doc.AllPictures.Count);
            Assert.AreEqual(1, r.GetEmbeddedPictures().Count);
        }
Example #11
0
        public void TestSetGetText()
        {
            ctRun.AddNewT().Value = ("TEST STRING");
            ctRun.AddNewT().Value = ("TEST2 STRING");
            ctRun.AddNewT().Value = ("TEST3 STRING");

            Assert.AreEqual(3, ctRun.SizeOfTArray());
            XWPFRun run = new XWPFRun(ctRun, p);

            Assert.AreEqual("TEST2 STRING", run.GetText(1));

            run.SetText("NEW STRING", 0);
            Assert.AreEqual("NEW STRING", run.GetText(0));

            //Run.Text=("xxx",14);
            //Assert.Fail("Position wrong");
        }
Example #12
0
        public void TestAddingRuns()
        {
            XWPFDocument doc = XWPFTestDataSamples.OpenSampleDocument("sample.docx");

            XWPFParagraph p = doc.Paragraphs[0];

            Assert.AreEqual(2, p.Runs.Count);

            XWPFRun r = p.CreateRun();

            Assert.AreEqual(3, p.Runs.Count);
            Assert.AreEqual(2, p.Runs.IndexOf(r));

            XWPFRun r2 = p.InsertNewRun(1);

            Assert.AreEqual(4, p.Runs.Count);
            Assert.AreEqual(1, p.Runs.IndexOf(r2));
            Assert.AreEqual(3, p.Runs.IndexOf(r));
        }
Example #13
0
        public void TestAddCarriageReturn()
        {
            ctRun.AddNewT().Value = ("TEST STRING");
            ctRun.AddNewCr();
            ctRun.AddNewT().Value = ("TEST2 STRING");
            ctRun.AddNewCr();
            ctRun.AddNewT().Value = ("TEST3 STRING");
            Assert.AreEqual(2, ctRun.SizeOfCrArray());

            XWPFRun run = new XWPFRun(new CT_R(), p);

            run.AppendText("T1");
            run.AddCarriageReturn();
            run.AddCarriageReturn();
            run.AppendText("T2");
            run.AddCarriageReturn();
            Assert.AreEqual(3, run.GetCTR().GetCrList().Count);
            Assert.AreEqual("T1\n\nT2\n", run.ToString());
        }
Example #14
0
        public void TestAddPageBreak()
        {
            ctRun.AddNewT().Value = ("TEST STRING");
            ctRun.AddNewBr();
            ctRun.AddNewT().Value = ("TEST2 STRING");
            CT_Br breac           = ctRun.AddNewBr();

            breac.clear = (ST_BrClear.left);
            ctRun.AddNewT().Value = ("TEST3 STRING");
            Assert.AreEqual(2, ctRun.SizeOfBrArray());

            XWPFRun run = new XWPFRun(new CT_R(), p);

            run.SetText("TEXT1");
            run.AddBreak();
            run.SetText("TEXT2");
            run.AddBreak(BreakType.TEXTWRAPPING);
            Assert.AreEqual(2, run.GetCTR().SizeOfBrArray());
        }
Example #15
0
        public void integration()
        {
            XWPFDocument doc = new XWPFDocument();

            XWPFParagraph p1 = doc.CreateParagraph();

            XWPFRun r1 = p1.CreateRun();

            r1.SetText("Lorem ipsum dolor sit amet.");
            doc.IsTrackRevisions = (true);

            MemoryStream out1 = new MemoryStream();

            doc.Write(out1);

            MemoryStream inputStream = new MemoryStream(out1.ToArray());
            XWPFDocument document    = new XWPFDocument(inputStream);

            inputStream.Close();

            Assert.IsTrue(document.IsTrackRevisions);
        }
Example #16
0
        public void TestAddTabsAndLineBreaks()
        {
            ctRun.AddNewT().Value = ("TEST STRING");
            ctRun.AddNewCr();
            ctRun.AddNewT().Value = (/*setter*/ "TEST2 STRING");
            ctRun.AddNewTab();
            ctRun.AddNewT().Value = (/*setter*/ "TEST3 STRING");
            Assert.AreEqual(1, ctRun.SizeOfCrArray());
            Assert.AreEqual(1, ctRun.SizeOfTabArray());

            XWPFRun run = new XWPFRun(new CT_R(), p);

            run.AppendText("T1");
            run.AddCarriageReturn();
            run.AppendText("T2");
            run.AddTab();
            run.AppendText("T3");
            Assert.AreEqual(1, run.GetCTR().GetCrList().Count);
            Assert.AreEqual(1, run.GetCTR().GetTabList().Count);

            Assert.AreEqual("T1\nT2\tT3", run.ToString());
        }
Example #17
0
 public XWPFPicture(CT_Picture ctPic, XWPFRun Run)
 {
     this.run    = Run;
     this.ctPic  = ctPic;
     description = ctPic.nvPicPr.cNvPr.descr;
 }