public static bool IsImportant(OpenXmlElement c, INodeProvider nodeProvider) { if (nodeProvider.IsParagraph(c)) { return(true); } if (nodeProvider.IsRun(c)) { var text = c.ChildElements.Where(a => !nodeProvider.IsRunProperties(a)).Only(); if (nodeProvider.IsText(text) && string.IsNullOrWhiteSpace(nodeProvider.GetText(text !))) { return(false); } return(true); } if (c is BaseNode) { return(true); } return(false); }
private void FixNakedText(OpenXmlCompositeElement par, INodeProvider nodeProvider) //Simple Spreadsheets cells { if (par.ChildElements.Count != 1) { return; } var only = par.ChildElements.Only(); if (!nodeProvider.IsText(only)) { return; } var text = nodeProvider.GetText(only); if (!TemplateUtils.KeywordsRegex.IsMatch(text)) { return; } par.RemoveChild(only); par.AppendChild(nodeProvider.WrapInRun(only)); }