Beispiel #1
0
 public XWPFSDTContent(CT_SdtContentBlock block, IBody part, IRunBody parent)
 {
     
     foreach (object o in block.Items)
     {
         if (o is CT_P)
         {
             XWPFParagraph p = new XWPFParagraph((CT_P)o, part);
             bodyElements.Add(p);
             paragraphs.Add(p);
         }
         else if (o is CT_Tbl)
         {
             XWPFTable t = new XWPFTable((CT_Tbl)o, part);
             bodyElements.Add(t);
             tables.Add(t);
         }
         else if (o is CT_SdtBlock)
         {
             XWPFSDT c = new XWPFSDT(((CT_SdtBlock)o), part);
             bodyElements.Add(c);
             contentControls.Add(c);
         }
         else if (o is CT_R)
         {
             XWPFRun run = new XWPFRun((CT_R)o, parent);
             runs.Add(run);
             bodyElements.Add(run);
         }
     }
 }
Beispiel #2
0
 public XWPFSDTContent(CT_SdtContentRun sdtRun, IBody part, IRunBody parent)
 {
     foreach (CT_R ctr in sdtRun.GetRList())
     {
         XWPFRun run = new XWPFRun((CT_R)ctr, parent);
         runs.Add(run);
         bodyElements.Add(run);
     }
 }
Beispiel #3
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);
        }
Beispiel #4
0
        public void TestSetGetItalic()
        {
            CT_RPr rpr = ctRun.AddNewRPr();
            rpr.AddNewI().val = (ST_OnOff.True);

            XWPFRun run = new XWPFRun(ctRun, p);
            Assert.AreEqual(true, run.IsItalic());

            run.SetItalic(false);
            Assert.AreEqual(ST_OnOff.False, rpr.i.val);
        }
Beispiel #5
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);
        }
Beispiel #6
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);
        }
Beispiel #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.GetUnderline());

            run.SetUnderline(UnderlinePatterns.None);
            Assert.AreEqual(ST_Underline.none, rpr.u.val);
        }
Beispiel #8
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.GetSubscript());

            run.SetSubscript(VerticalAlign.BASELINE);
            Assert.AreEqual(ST_VerticalAlignRun.baseline, rpr.vertAlign.val);
        }
Beispiel #9
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.GetFontFamily());

            run.SetFontFamily("Verdana");
            Assert.AreEqual("Verdana", rpr.rFonts.ascii);
        }
Beispiel #10
0
        public void TestSetGetFontSize()
        {
            CT_RPr rpr = ctRun.AddNewRPr();

            rpr.AddNewSz().val = 14;

            XWPFRun run = new XWPFRun(ctRun, p);

            Assert.AreEqual(7, run.GetFontSize());

            run.SetFontSize(24);
            Assert.AreEqual(48, (int)rpr.sz.val);
        }
Beispiel #11
0
        public void SetText(string value, int pos)
        {
            int num = this.run.SizeOfTArray();

            if (pos > num)
            {
                throw new IndexOutOfRangeException("Value too large for the parameter position in XWPFrun.Text=(String value,int pos)");
            }
            CT_Text xs = pos >= num || pos < 0 ? this.run.AddNewT() : this.run.GetTArray(pos);

            xs.Value = value;
            XWPFRun.preserveSpaces(xs);
        }
Beispiel #12
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));
        }
Beispiel #13
0
        public void TestSetGetStrike()
        {
            CT_RPr rpr = ctRun.AddNewRPr();

            rpr.AddNewStrike().val = (ST_OnOff.True);

            XWPFRun run = new XWPFRun(ctRun, p);

            Assert.AreEqual(true, run.IsStrike());

            run.SetStrike(false);
            Assert.AreEqual(ST_OnOff.False, rpr.strike.val);
        }
        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));
        }
Beispiel #15
0
        public void Test58618()
        {
            XWPFDocument  doc  = XWPFTestDataSamples.OpenSampleDocument("58618.docx");
            XWPFParagraph para = (XWPFParagraph)doc.BodyElements[0];

            Assert.IsNotNull(para);
            Assert.AreEqual("Some text  some hyper links link link and some text.....", para.Text);
            XWPFRun run = para.InsertNewRun(para.Runs.Count);

            run.SetText("New Text");
            Assert.AreEqual("Some text  some hyper links link link and some text.....New Text", para.Text);
            para.RemoveRun(para.Runs.Count - 2);
            Assert.AreEqual("Some text  some hyper links link linkNew Text", para.Text);
        }
Beispiel #16
0
        public void testSetGetHighlight()
        {
            XWPFRun run = p.CreateRun();

            Assert.AreEqual(false, run.IsHighlighted);

            // TODO Do this using XWPFRun methods
            run.GetCTR().AddNewRPr().AddNewHighlight().val = (ST_HighlightColor.none);
            Assert.AreEqual(false, run.IsHighlighted);
            run.GetCTR().rPr.highlight.val = (ST_HighlightColor.cyan);
            Assert.AreEqual(true, run.IsHighlighted);
            run.GetCTR().rPr.highlight.val = (ST_HighlightColor.none);
            Assert.AreEqual(false, run.IsHighlighted);
        }
Beispiel #17
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.SetBold(false);
            Assert.AreEqual(false, run.IsBold);
            Assert.AreEqual(false, rpr.b.val);
        }
Beispiel #18
0
        public void TestAddPicture()
        {
            XWPFDocument  doc = XWPFTestDataSamples.OpenSampleDocument("TestDocument.docx");
            XWPFParagraph p   = doc.GetParagraphArray(2);
            XWPFRun       r   = p.GetRuns()[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);
        }
Beispiel #19
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);
            // Implementation detail: POI natively prefers <w:b w:val="false"/>,
            // but should correctly read val="0" and val="off"
            Assert.AreEqual(false, run.IsBold);
            Assert.AreEqual(false, rpr.b.val);
        }
Beispiel #20
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());
        }
Beispiel #21
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.SetText("T1");
            run.AddCarriageReturn();
            run.AddCarriageReturn();
            run.SetText("T2");
            run.AddCarriageReturn();
            Assert.AreEqual(3, run.GetCTR().GetCrList().Count);
        }
Beispiel #22
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");
        }
Beispiel #23
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");
        }
Beispiel #24
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.SetText("T1");
            run.AddCarriageReturn();
            run.AddCarriageReturn();
            run.SetText("T2");
            run.AddCarriageReturn();
            Assert.AreEqual(3, run.GetCTR().GetCrList().Count);
        }
        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));
        }
Beispiel #26
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());
        }
Beispiel #27
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);
        }
Beispiel #28
0
        public void TestFieldRuns()
        {
            XWPFDocument          doc = XWPFTestDataSamples.OpenSampleDocument("FldSimple.docx");
            IList <XWPFParagraph> ps  = doc.Paragraphs;

            Assert.AreEqual(1, ps.Count);

            XWPFParagraph p = ps[0];

            Assert.AreEqual(1, p.Runs.Count);
            Assert.AreEqual(1, p.IRuns.Count);

            XWPFRun r = p.Runs[0];

            Assert.AreEqual(typeof(XWPFFieldRun), r.GetType());

            XWPFFieldRun fr = (XWPFFieldRun)r;

            Assert.AreEqual(" FILENAME   \\* MERGEFORMAT ", fr.FieldInstruction);
            Assert.AreEqual("FldSimple.docx", fr.Text);
            Assert.AreEqual("FldSimple.docx", p.Text);
        }
Beispiel #29
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());
        }
Beispiel #30
0
        public void TestBug58922()
        {
            XWPFDocument document = new XWPFDocument();
            XWPFRun      run      = document.CreateParagraph().CreateRun();

            Assert.AreEqual(-1, run.FontSize);
            run.FontSize = 10;
            Assert.AreEqual(10, run.FontSize);
            run.FontSize = short.MaxValue - 1;
            Assert.AreEqual(short.MaxValue - 1, run.FontSize);
            run.FontSize = short.MaxValue;
            Assert.AreEqual(short.MaxValue, run.FontSize);
            run.FontSize = short.MaxValue + 1;
            Assert.AreEqual(short.MaxValue + 1, run.FontSize);
            run.FontSize = int.MaxValue - 1;
            Assert.AreEqual(int.MaxValue - 1, run.FontSize);
            run.FontSize = int.MaxValue;
            Assert.AreEqual(int.MaxValue, run.FontSize);
            run.FontSize = -1;
            Assert.AreEqual(-1, run.FontSize);
            Assert.AreEqual(-1, run.TextPosition);
            run.TextPosition = 10;
            Assert.AreEqual(10, run.TextPosition);
            run.TextPosition = short.MaxValue - 1;
            Assert.AreEqual(short.MaxValue - 1, run.TextPosition);
            run.TextPosition = short.MaxValue;
            Assert.AreEqual(short.MaxValue, run.TextPosition);
            run.TextPosition = short.MaxValue + 1;
            Assert.AreEqual(short.MaxValue + 1, run.TextPosition);
            run.TextPosition = short.MaxValue + 1;
            Assert.AreEqual(short.MaxValue + 1, run.TextPosition);
            run.TextPosition = int.MaxValue - 1;
            Assert.AreEqual(int.MaxValue - 1, run.TextPosition);
            run.TextPosition = int.MaxValue;
            Assert.AreEqual(int.MaxValue, run.TextPosition);
            run.TextPosition = -1;
            Assert.AreEqual(-1, run.TextPosition);
        }
Beispiel #31
0
 public XWPFPicture(CT_Picture ctPic, XWPFRun Run)
 {
     this.run = Run;
     this.ctPic = ctPic;
     description = ctPic.nvPicPr.cNvPr.descr;
 }
Beispiel #32
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));
        }
Beispiel #33
0
        /**
         * Identifies (in order) the parts of the paragraph /
         *  sub-paragraph that correspond to character text
         *  runs, and builds the appropriate runs for these.
         */
        private void BuildRunsInOrderFromXml(ArrayList items)
        {
            foreach (object o in items)
            {
                if (o is CT_R)
                {
                    XWPFRun r = new XWPFRun((CT_R)o, this);
                    runs.Add(r);
                    iRuns.Add(r);
                }
                if (o is CT_Hyperlink1)
                {
                    CT_Hyperlink1 link = (CT_Hyperlink1)o;
                    foreach (CT_R r in link.GetRList())
                    {
                        //runs.Add(new XWPFHyperlinkRun(link, r, this));
                        XWPFHyperlinkRun hr = new XWPFHyperlinkRun(link, r, this);
                        runs.Add(hr);
                        iRuns.Add(hr);

                    }
                }
                if (o is CT_SdtBlock)
                {
                    XWPFSDT cc = new XWPFSDT((CT_SdtBlock)o, part);
                    iRuns.Add(cc);
                }
                if (o is CT_SdtRun)
                {
                    XWPFSDT cc = new XWPFSDT((CT_SdtRun)o, part);
                    iRuns.Add(cc);
                }
                if (o is CT_RunTrackChange)
                {
                    foreach (CT_R r in ((CT_RunTrackChange)o).GetRList())
                    {
                        XWPFRun cr = new XWPFRun(r, this);
                        runs.Add(cr);
                        iRuns.Add(cr);
                    }
                }
                if (o is CT_SimpleField)
                {
                    foreach (CT_R r in ((CT_SimpleField)o).GetRList())
                    {
                        XWPFRun cr = new XWPFRun(r, this);
                        runs.Add(cr);
                        iRuns.Add(cr);
                    }
                }
                if (o is CT_SmartTagRun)
                {
                    // Smart Tags can be nested many times. 
                    // This implementation does not preserve the tagging information
                    BuildRunsInOrderFromXml((o as CT_SmartTagRun).Items);
                }
            }
        }
Beispiel #34
0
 public XWPFPicture(CT_Picture ctPic, XWPFRun Run)
 {
     this.run    = Run;
     this.ctPic  = ctPic;
     description = ctPic.nvPicPr.cNvPr.descr;
 }
Beispiel #35
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.SetText("T1");
            run.AddCarriageReturn();
            run.SetText("T2");
            run.AddTab();
            run.SetText("T3");
            Assert.AreEqual(1, run.GetCTR().GetCrList().Count);
            Assert.AreEqual(1, run.GetCTR().GetTabList().Count);

            Assert.AreEqual("T1\nT2\tT3", run.ToString());
        }
Beispiel #36
0
 public void TestSetGetColor()
 {
     XWPFRun run = new XWPFRun(ctRun, p);
     run.SetColor("0F0F0F");
     String clr = run.GetColor();
     Assert.AreEqual("0F0F0F", clr);
 }
Beispiel #37
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));
        }
Beispiel #38
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);
        }
Beispiel #39
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);
        }
Beispiel #40
0
 /**
  * Adds a new Run to the Paragraph
  * 
  * @param r
  */
 public void AddRun(XWPFRun r)
 {
     if (!runs.Contains(r))
     {
         runs.Add(r);
     }
 }
Beispiel #41
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);
        }
Beispiel #42
0
        /**
         * insert a new Run in RunArray
         * @param pos
         * @return  the inserted run
         */
        public XWPFRun InsertNewRun(int pos)
        {
            if (pos >= 0 && pos <= paragraph.SizeOfRArray())
            {
                CT_R ctRun = paragraph.InsertNewR(pos);
                XWPFRun newRun = new XWPFRun(ctRun, this);

                // To update the iRuns, find where we're going
                // in the normal Runs, and go in there
                int iPos = iRuns.Count;
                if (pos < runs.Count)
                {
                    XWPFRun oldAtPos = runs[(pos)];
                    int oldAt = iRuns.IndexOf(oldAtPos);
                    if (oldAt != -1)
                    {
                        iPos = oldAt;
                    }
                }
                iRuns.Insert(iPos, newRun);

                // Runs itself is easy to update
                runs.Insert(pos, newRun);

                return newRun;
            }
            return null;
        }
Beispiel #43
0
 /**
  * insert a new Run in RunArray
  * @param pos
  * @return  the inserted run
  */
 public XWPFRun InsertNewRun(int pos)
 {
     if (pos >= 0 && pos <= paragraph.SizeOfRArray())
     {
         CT_R ctRun = paragraph.InsertNewR(pos);
         XWPFRun newRun = new XWPFRun(ctRun, this);
         runs.Insert(pos, newRun);
         return newRun;
     }
     return null;
 }
Beispiel #44
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);
        }
Beispiel #45
0
 /// <summary>
 /// Appends a new run to this paragraph
 /// </summary>
 /// <returns>a new text run</returns>
 public XWPFRun CreateRun()
 {
     XWPFRun xwpfRun = new XWPFRun(paragraph.AddNewR(), this);
     runs.Add(xwpfRun);
     return xwpfRun;
 }
Beispiel #46
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);
        }