internal void Process(Run element, DocxNode node) { RunProperties properties = element.RunProperties; if (properties == null) { properties = new RunProperties(); } //Order of assigning styles to run property is important. The order should not change. CheckFonts(node, properties); string color = node.ExtractStyleValue(DocxColor.color); if (!string.IsNullOrEmpty(color)) { DocxColor.ApplyColor(color, properties); } CheckFontStyle(node, properties); ProcessBackGround(node, properties); ProcessVerticalAlign(node, properties); if (element.RunProperties == null && properties.HasChildren) { element.RunProperties = properties; } }
internal void Process(TableCell cell, DocxTableProperties docxProperties, DocxNode node) { TableCellProperties cellProperties = new TableCellProperties(); ProcessColSpan(node, cellProperties); ProcessWidth(node, cellProperties); if (HasRowSpan) { cellProperties.Append(new VerticalMerge() { Val = MergedCellValues.Restart }); } //Processing border should be after colspan ProcessBorders(node, docxProperties, cellProperties); string backgroundColor = node.ExtractStyleValue(DocxColor.backGroundColor); if (!string.IsNullOrEmpty(backgroundColor)) { DocxColor.ApplyBackGroundColor(backgroundColor, cellProperties); } ProcessVerticalAlignment(node, cellProperties); if (cellProperties.HasChildren) { cell.Append(cellProperties); } }
private static void GetBorderProperties(string borderStyle, out BorderValues borderType, out string color, out UInt32 width) { string _width = GetBorderWidth(ref borderStyle); borderType = GetBorderStyle(ref borderStyle); UInt32.TryParse(_width, out width); color = DocxColor.GetHexColor(borderStyle.Trim().ToLower()); }
private void ProcessBackGround(DocxNode node, RunProperties properties) { string backgroundColor = node.ExtractStyleValue(DocxColor.backGroundColor); string backGround = DocxColor.ExtractBackGround(node.ExtractStyleValue(DocxColor.backGround)); if (!string.IsNullOrEmpty(backgroundColor)) { DocxColor.ApplyBackGroundColor(backgroundColor, properties); } else if (!string.IsNullOrEmpty(backGround)) { DocxColor.ApplyBackGroundColor(backGround, properties); } }
internal void Process(Paragraph element, DocxNode node) { ParagraphProperties properties = element.ParagraphProperties; if (properties == null) { properties = new ParagraphProperties(); } //Order of assigning styles to paragraph property is important. The order should not change. ProcessBorder(node, properties); string backgroundColor = node.ExtractStyleValue(DocxColor.backGroundColor); string backGround = DocxColor.ExtractBackGround(node.ExtractStyleValue(DocxColor.backGround)); if (!string.IsNullOrEmpty(backgroundColor)) { DocxColor.ApplyBackGroundColor(backgroundColor, properties); } else if (!string.IsNullOrEmpty(backGround)) { DocxColor.ApplyBackGroundColor(backGround, properties); } DocxMargin margin = new DocxMargin(node); margin.ProcessParagraphMargin(properties); string textAlign = node.ExtractStyleValue(DocxAlignment.textAlign); if (!string.IsNullOrEmpty(textAlign)) { DocxAlignment.ApplyTextAlign(textAlign, properties); } if (element.ParagraphProperties == null && properties.HasChildren) { element.ParagraphProperties = properties; } }