public static bool ReachedSentenceBreaker(this OpenXmlLeafElement openXmlLeafElement) { return(openXmlLeafElement.InnerText.IsVB() || openXmlLeafElement.InnerText.IsPast() || openXmlLeafElement.InnerText.RemoveWhiteSpaces() == "PRES" || openXmlLeafElement.InnerText.IsBreakerPunctuation()); }
internal static void Validate(ValidationContext validationContext) { OpenXmlLeafElement leafElement = (OpenXmlLeafElement)validationContext.Element; ValidationErrorInfo errorInfo; if (leafElement.ShadowElement != null) { foreach (var child in leafElement.ShadowElement.ChildElements) { if (!(child is OpenXmlMiscNode)) { errorInfo = validationContext.ComposeSchemaValidationError(leafElement, null, "Sch_InvalidChildinLeafElement", leafElement.XmlQualifiedName.ToString()); validationContext.AddError(errorInfo); return; // just return one error is enough. } } } }
Table GetTable(TableElement tableElement) { var table = new Table(); var tableProperties = new TableProperties(); if (tableElement.Style != null) { var style = tableElement.Style; var borders = new OpenXmlElement[] { GetBorder <LeftBorder>(style.BorderLeft), GetBorder <TopBorder>(style.BorderTop), GetBorder <RightBorder>(style.BorderRight), GetBorder <BottomBorder>(style.BorderBottom) } .Where(b => b != null); if (borders.Any()) { tableProperties.Append(new TableBorders(borders)); } if (tableElement.Style.Width.HasValue) { tableProperties.Append(new TableWidth { Width = $"{(5000 / 100 * tableElement.Style.Width)}", Type = TableWidthUnitValues.Pct }); } table.Append(tableProperties); } var rows = tableElement.Rows.Select(row => { var rowProps = new TableRowProperties(); var tableRow = new TableRow(row.Cells.Select(cell => { var tableCell = new TableCell(cell.Elements.Select(e => { e.Style = e.Style ?? (cell.Style ?? row.Style); return(GetParagraph(e as ParagraphElement)); })); var style = cell.Style ?? row.Style; if (style != null) { var props = new TableCellProperties(); var borders = new OpenXmlLeafElement[] { GetBorder <LeftBorder>(style.BorderLeft), GetBorder <TopBorder>(style.BorderTop), GetBorder <RightBorder>(style.BorderRight), GetBorder <BottomBorder>(style.BorderBottom) } .Where(b => b != null); if (borders.Any()) { props.Append(new TableBorders(borders)); } if (style.BackgroundColor != null) { props.Append(new Shading { Color = "auto", Fill = style.BackgroundColor, Val = ShadingPatternValues.Clear }); } if (style.VerticalAlignment.HasValue) { props.Append(new TableCellVerticalAlignment { Val = new EnumValue <TableVerticalAlignmentValues>((TableVerticalAlignmentValues)style.VerticalAlignment.Value) }); } //if (style.HorizontalAlignment.HasValue) //{ // props.Append(new Justification // { // Val = new EnumValue<JustificationValues>((JustificationValues)style.HorizontalAlignment.Value) // }); //} if (style.Width.HasValue) { props.Append(new TableCellWidth { Type = TableWidthUnitValues.Dxa, Width = $"{style.Width.Value * 1000}", }); } tableCell.Append(props); } return(tableCell); })); if (row.Style != null) { if (row.Style.Height.HasValue) { rowProps.Append(new TableRowHeight { Val = row.Style.Height.Value * 20 }); } } tableRow.Append(rowProps); return(tableRow); }); table.Append(rows); return(table); }
//IsVbVbaPast public static bool IsVbVbaPast(this OpenXmlLeafElement openXmlLeafElement) { return(openXmlLeafElement.InnerText.IsVB() || openXmlLeafElement.InnerText.IsVBA() || openXmlLeafElement.InnerText.IsPast()); }
public static bool IsVbPastPres(this OpenXmlLeafElement openXmlLeafElement) { return(openXmlLeafElement.InnerText.IsVB() || openXmlLeafElement.InnerText.IsPast() || openXmlLeafElement.InnerText.RemoveWhiteSpaces() == "PRES"); }
public static bool IsAdverb(this OpenXmlLeafElement openXmlLeafElement) { return(openXmlLeafElement.InnerText.RemoveWhiteSpaces() == TagMarks.Adverb); }
public static bool IsDG(this OpenXmlLeafElement openXmlLeafElement) { return(openXmlLeafElement.InnerText.IsDG()); }