本文整理汇总了C#中Novacode.Paragraph类的典型用法代码示例。如果您正苦于以下问题:C# Paragraph类的具体用法?C# Paragraph怎么用?C# Paragraph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Paragraph类属于Novacode命名空间,在下文中一共展示了Paragraph类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DocumentDependencies
internal static Paragraph DocumentDependencies(this DocX body, string input, Paragraph parent = null)
{
if (string.IsNullOrEmpty(input))
return null;
Paragraph paragraph = parent ?? body.InsertParagraph();
paragraph.IndentationBefore = parent == null ? 3 : parent.IndentationBefore + 1;
paragraph.InsertText("Dependent activities: ", false, new Formatting
{
Bold = true,
Size = 10,
});
paragraph.InsertText(input, false, new Formatting
{
FontColor = Color.Black,
FontFamily = new FontFamily(System.Drawing.Text.GenericFontFamilies.Serif),
Size = 9,
});
body.InsertParagraph();
return paragraph;
}
示例2: createForParagraph
private BaseConverter createForParagraph( DocX doc, Paragraph paragraph ) {
var isList = paragraph.IsListItem;
if( isList ) return createConverterForList( doc, paragraph );
var type = Type.GetType( "DocXToMarkdown.Converter." + _converters[paragraph.StyleName] );
return (BaseConverter)Activator.CreateInstance( type, new object[] { doc, paragraph } );
}
示例3: BaseConverter
public BaseConverter( DocX d, Paragraph p ) {
_paragraph = p;
_document = d;
_text = Sanitize( _paragraph.Text );
CheckHiperlinks();
CheckPictures();
}
示例4: _Create
private void _Create(string file, IEnumerable<OXmlElement> elements)
{
using (_document = DocX.Create(file))
{
foreach (OXmlElement element in elements)
{
switch (element.Type)
{
//case zDocXElementType.BeginParagraph:
// _paragraph = _document.InsertParagraph();
// break;
//case zDocXElementType.EndParagraph:
// _paragraph = null;
// break;
case OXmlElementType.Paragraph:
_paragraph = _document.InsertParagraph();
break;
case OXmlElementType.Text:
AddText(element);
break;
case OXmlElementType.Line:
AddLine();
break;
case OXmlElementType.Picture:
AddPicture(element);
break;
}
}
_document.Save();
}
}
示例5: AddItemWithStartValue
public void AddItemWithStartValue(Paragraph paragraph, int start)
{
//TODO: Update the numbering
UpdateNumberingForLevelStartNumber(int.Parse(paragraph.IndentLevel.ToString()), start);
if (ContainsLevel(start))
throw new InvalidOperationException("Cannot add a paragraph with a start value if another element already exists in this list with that level.");
AddItem(paragraph);
}
示例6: InsertParagraphBeforeSelf
public virtual Paragraph InsertParagraphBeforeSelf(Paragraph p)
{
Xml.AddBeforeSelf(p.Xml);
XElement newlyInserted = Xml.ElementsBeforeSelf().First();
p.Xml = newlyInserted;
return p;
}
示例7: Cell
internal Cell(DocX document, XElement xml)
{
this.document = document;
this.xml = xml;
XElement properties = xml.Element(XName.Get("tcPr", DocX.w.NamespaceName));
p = new Paragraph(document, 0, xml.Element(XName.Get("p", DocX.w.NamespaceName)));
}
示例8: AddItem
/// <summary>
/// Adds an item to the list.
/// </summary>
/// <param name="paragraph"></param>
/// <exception cref="InvalidOperationException">
/// Throws an InvalidOperationException if the item cannot be added to the list.
/// </exception>
public void AddItem(Paragraph paragraph)
{
if (paragraph.IsListItem)
{
var numIdNode = paragraph.Xml.Descendants().First(s => s.Name.LocalName == "numId");
var numId = Int32.Parse(numIdNode.Attribute(DocX.w + "val").Value);
if (CanAddListItem(paragraph))
{
NumId = numId;
Items.Add(paragraph);
}
else
throw new InvalidOperationException("New list items can only be added to this list if they are have the same numId.");
}
}
示例9: CanAddListItem
/// <summary>
/// Determine if it is able to add the item to the list
/// </summary>
/// <param name="paragraph"></param>
/// <returns>
/// Return true if AddItem(...) will succeed with the given paragraph.
/// </returns>
public bool CanAddListItem(Paragraph paragraph)
{
if (paragraph.IsListItem)
{
//var lvlNode = paragraph.Xml.Descendants().First(s => s.Name.LocalName == "ilvl");
var numIdNode = paragraph.Xml.Descendants().First(s => s.Name.LocalName == "numId");
var numId = Int32.Parse(numIdNode.Attribute(DocX.w + "val").Value);
//Level = Int32.Parse(lvlNode.Attribute(DocX.w + "val").Value);
if (NumId == 0 || (numId == NumId && numId > 0))
{
return true;
}
}
return false;
}
示例10: DocumentDescription
internal static Paragraph DocumentDescription(this DocX body, string input, Paragraph parent = null)
{
if (string.IsNullOrEmpty(input))
return null;
Paragraph paragraph = parent ?? body.InsertParagraph();
paragraph.IndentationBefore = parent == null ? 3 : parent.IndentationBefore + 1;
paragraph.InsertText(input, false, new Formatting
{
FontColor = Color.Black,
Size = 10,
});
body.InsertParagraph();
return paragraph;
}
示例11: DocumentLeafActivity
internal static Paragraph DocumentLeafActivity(this DocX body, string input, Paragraph parent = null)
{
if (string.IsNullOrEmpty(input))
return null;
Paragraph paragraph = parent ?? body.InsertParagraph();
paragraph.IndentationBefore = parent == null ? 3 : parent.IndentationBefore;
paragraph.InsertText(input, false, new Formatting
{
FontColor = Color.Green,
Size = 12,
});
body.InsertParagraph();
return paragraph;
}
示例12: DocumentCompositeActivity
internal static Paragraph DocumentCompositeActivity(this DocX body, string input, Paragraph parent = null)
{
if (string.IsNullOrEmpty(input))
return null;
Paragraph paragraph = parent ?? body.InsertParagraph();
paragraph.IndentationBefore = parent == null ? 3 : parent.IndentationBefore + 1;
paragraph.InsertText(input, false, new Formatting
{
FontColor = Color.Black,
Size = 16,
Bold = false,
Italic = false,
UnderlineStyle = UnderlineStyle.dash,
UnderlineColor = Color.Gray
});
body.InsertParagraph();
return paragraph;
}
示例13: RemoveParagraph
/// <summary>
/// Removes paragraph
/// </summary>
/// <param name="p">Paragraph to remove</param>
/// <returns>True if removed</returns>
public bool RemoveParagraph(Paragraph p)
{
foreach (var paragraph in Xml.Descendants(DocX.w + "p"))
{
if (paragraph.Equals(p.Xml))
{
paragraph.Remove();
return true;
}
}
return false;
}
示例14: InsertParagraph
public virtual Paragraph InsertParagraph(string text, bool trackChanges, Formatting formatting)
{
XElement newParagraph = new XElement
(
XName.Get("p", DocX.w.NamespaceName), new XElement(XName.Get("pPr", DocX.w.NamespaceName)), HelperFunctions.FormatInput(text, formatting.Xml)
);
if (trackChanges)
newParagraph = HelperFunctions.CreateEdit(EditType.ins, DateTime.Now, newParagraph);
Xml.Add(newParagraph);
var paragraphAdded = new Paragraph(Document, newParagraph, 0);
if (this is Cell)
{
var cell = this as Cell;
paragraphAdded.PackagePart = cell.mainPart;
}
else if (this is DocX)
{
paragraphAdded.PackagePart = Document.mainPart;
}
else if (this is Footer)
{
var f = this as Footer;
paragraphAdded.mainPart = f.mainPart;
}
else if (this is Header)
{
var h = this as Header;
paragraphAdded.mainPart = h.mainPart;
}
else
{
Console.WriteLine("No idea what we are {0}", this);
paragraphAdded.PackagePart = Document.mainPart;
}
GetParent(paragraphAdded);
return paragraphAdded;
}
示例15: InsertParagraphBeforeSelf
/// <summary>
/// Insert a Paragraph before this Paragraph, this Paragraph may have come from the same or another document.
/// </summary>
/// <param name="p">The Paragraph to insert.</param>
/// <returns>The Paragraph now associated with this document.</returns>
/// <example>
/// Take a Paragraph from document a, and insert it into document b before this Paragraph.
/// <code>
/// // Place holder for a Paragraph.
/// Paragraph p;
///
/// // Load document a.
/// using (DocX documentA = DocX.Load(@"a.docx"))
/// {
/// // Get the first paragraph from this document.
/// p = documentA.Paragraphs[0];
/// }
///
/// // Load document b.
/// using (DocX documentB = DocX.Load(@"b.docx"))
/// {
/// // Get the first Paragraph in document b.
/// Paragraph p2 = documentB.Paragraphs[0];
///
/// // Insert the Paragraph from document a before this Paragraph.
/// Paragraph newParagraph = p2.InsertParagraphBeforeSelf(p);
///
/// // Save all changes made to document b.
/// documentB.Save();
/// }// Release this document from memory.
/// </code>
/// </example>
public override Paragraph InsertParagraphBeforeSelf(Paragraph p)
{
Paragraph p2 = base.InsertParagraphBeforeSelf(p);
p2.PackagePart = mainPart;
return p2;
}