本文整理汇总了C#中NPOI.XWPF.UserModel.XWPFRun类的典型用法代码示例。如果您正苦于以下问题:C# XWPFRun类的具体用法?C# XWPFRun怎么用?C# XWPFRun使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XWPFRun类属于NPOI.XWPF.UserModel命名空间,在下文中一共展示了XWPFRun类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: XWPFSDTContent
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);
}
}
}
示例2: TestSetGetItalic
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);
}
示例3: TestSetGetItalic
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);
}
示例4: TestSetGetBold
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);
}
示例5: TestSetGetText
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");
}
示例6: TestAddCarriageReturn
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);
}
示例7: TestAddPageBreak
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());
}
示例8: TestAddTabsAndLineBreaks
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());
}
示例9: TestSetGetColor
public void TestSetGetColor()
{
XWPFRun run = new XWPFRun(ctRun, p);
run.SetColor("0F0F0F");
String clr = run.GetColor();
Assert.AreEqual("0F0F0F", clr);
}
示例10: TestSetGetTextForegroundBackground
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));
}
示例11: TestSetGetFontSize
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);
}
示例12: TestRuns
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));
}
示例13: AddRun
/**
* Adds a new Run to the Paragraph
*
* @param r
*/
public void AddRun(XWPFRun r)
{
if (!runs.Contains(r))
{
runs.Add(r);
}
}
示例14: TestSetGetStrike
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);
}
示例15: BuildRunsInOrderFromXml
/**
* 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);
}
}
}