private void ProcessTableBorder(DocxNode node, DocxTableProperties docxProperties, TableProperties tableProperties) { string borderStyle = node.ExtractAttributeValue(DocxBorder.borderName); if (borderStyle == "1") { TableBorders tableBorders = new TableBorders(); DocxBorder.ApplyDefaultBorders(tableBorders); tableProperties.Append(tableBorders); } else { borderStyle = node.ExtractStyleValue(DocxBorder.borderName); string leftBorder = node.ExtractStyleValue(DocxBorder.leftBorderName); string topBorder = node.ExtractStyleValue(DocxBorder.topBorderName); string rightBorder = node.ExtractStyleValue(DocxBorder.rightBorderName); string bottomBorder = node.ExtractStyleValue(DocxBorder.bottomBorderName); TableBorders tableBorders = new TableBorders(); DocxBorder.ApplyBorders(tableBorders, borderStyle, leftBorder, topBorder, rightBorder, bottomBorder, docxProperties.HasDefaultBorder); if (tableBorders.HasChildren) { tableProperties.Append(tableBorders); } } }
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 string GetTopMargin() { string topMargin = node.ExtractStyleValue(marginTop); if (string.IsNullOrEmpty(topMargin)) { topMargin = node.ExtractStyleValue(margin); } return(topMargin); }
private void CheckFontStyle(DocxNode node, RunProperties properties) { string fontSize = node.ExtractStyleValue(DocxFontStyle.fontSize); string textDecoration = node.ExtractStyleValue(DocxFontStyle.textDecoration); if (!string.IsNullOrEmpty(fontSize)) { DocxFontStyle.ApplyFontSize(fontSize, properties); } if (!string.IsNullOrEmpty(textDecoration)) { DocxFontStyle.ApplyTextDecoration(textDecoration, properties); } }
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 void ProcessWidth(DocxNode node, TableProperties tableProperties) { string width = node.ExtractAttributeValue(DocxUnits.width); string styleWidth = node.ExtractStyleValue(DocxUnits.width); if (!string.IsNullOrEmpty(styleWidth)) { width = styleWidth; } if (!string.IsNullOrEmpty(width)) { decimal value; TableWidthUnitValues unit; if (DocxUnits.TableUnitsFromStyle(width, out value, out unit)) { TableWidth tableWidth = new TableWidth() { Width = value.ToString(), Type = unit }; tableProperties.Append(tableWidth); } } }
private void ProcessBorder(DocxNode node, ParagraphProperties properties) { ParagraphBorders paragraphBorders = new ParagraphBorders(); DocxBorder.ApplyBorders(paragraphBorders, node.ExtractStyleValue(DocxBorder.borderName), node.ExtractStyleValue(DocxBorder.leftBorderName), node.ExtractStyleValue(DocxBorder.topBorderName), node.ExtractStyleValue(DocxBorder.rightBorderName), node.ExtractStyleValue(DocxBorder.bottomBorderName), false); if (paragraphBorders.HasChildren) { properties.Append(paragraphBorders); } }
private void ProcessVerticalAlign(DocxNode node, RunProperties properties) { string verticalAlign = node.ExtractStyleValue(DocxAlignment.verticalAlign); if(!string.IsNullOrEmpty(verticalAlign)) { DocxAlignment.ApplyVerticalTextAlign(verticalAlign, properties); } }
private void SetThStyleToRun(DocxNode run) { string value = run.ExtractStyleValue(DocxFontStyle.fontWeight); if (string.IsNullOrEmpty(value)) { run.SetExtentedStyle(DocxFontStyle.fontWeight, DocxFontStyle.bold); } }
private void SetStyle(DocxNode node) { string value = node.ExtractStyleValue(DocxFontStyle.italic); if (string.IsNullOrEmpty(value)) { node.SetExtentedStyle(DocxFontStyle.fontStyle, DocxFontStyle.italic); } }
private void ProcessVerticalAlign(DocxNode node, RunProperties properties) { string verticalAlign = node.ExtractStyleValue(DocxAlignment.verticalAlign); if (!string.IsNullOrEmpty(verticalAlign)) { DocxAlignment.ApplyVerticalTextAlign(verticalAlign, properties); } }
private void ProcessBorders(DocxNode node, DocxTableProperties docxProperties, TableCellProperties cellProperties) { string borderStyle = node.ExtractStyleValue(DocxBorder.borderName); string leftBorder = node.ExtractStyleValue(DocxBorder.leftBorderName); string topBorder = node.ExtractStyleValue(DocxBorder.topBorderName); string rightBorder = node.ExtractStyleValue(DocxBorder.rightBorderName); string bottomBorder = node.ExtractStyleValue(DocxBorder.bottomBorderName); TableCellBorders cellBorders = new TableCellBorders(); DocxBorder.ApplyBorders(cellBorders, borderStyle, leftBorder, topBorder, rightBorder, bottomBorder, docxProperties.HasDefaultBorder); if (cellBorders.HasChildren) { cellProperties.Append(cellBorders); } }
protected bool IsHidden(DocxNode node) { if (node == null) { return(false); } string display = node.ExtractStyleValue("display"); return(display.CompareStringOrdinalIgnoreCase("none")); }
private void CheckFonts(DocxNode node, RunProperties properties) { string fontFamily = node.ExtractStyleValue(DocxFontStyle.fontFamily); string fontWeight = node.ExtractStyleValue(DocxFontStyle.fontWeight); string fontStyle = node.ExtractStyleValue(DocxFontStyle.fontStyle); if (!string.IsNullOrEmpty(fontFamily)) { DocxFontStyle.ApplyFontFamily(fontFamily, properties); } if (!string.IsNullOrEmpty(fontWeight)) { DocxFontStyle.ApplyFontWeight(fontWeight, properties); } if (!string.IsNullOrEmpty(fontStyle)) { DocxFontStyle.ApplyFontStyle(fontStyle, 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; } }
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; } }
private void ProcessVerticalAlignment(DocxNode node, TableCellProperties cellProperties) { string alignment = node.ExtractStyleValue(DocxAlignment.verticalAlign); if (!string.IsNullOrEmpty(alignment)) { TableVerticalAlignmentValues value; if (DocxAlignment.GetCellVerticalAlignment(alignment, out value)) { cellProperties.Append(new TableCellVerticalAlignment(){ Val = value }); } } }
private void ProcessVerticalAlignment(DocxNode node, TableCellProperties cellProperties) { string alignment = node.ExtractStyleValue(DocxAlignment.verticalAlign); if (!string.IsNullOrEmpty(alignment)) { if (DocxAlignment.GetCellVerticalAlignment(alignment, out TableVerticalAlignmentValues value)) { cellProperties.Append(new TableCellVerticalAlignment() { Val = value }); } } }
private void ProcessWidth(DocxNode node, TableCellProperties cellProperties) { string width = node.ExtractStyleValue(DocxUnits.width); if (!string.IsNullOrEmpty(width)) { if (DocxUnits.TableUnitsFromStyle(width, out decimal value, out TableWidthUnitValues unit)) { TableCellWidth cellWidth = new TableCellWidth() { Width = value.ToString(), Type = unit }; cellProperties.Append(cellWidth); } } }
private void ProcessWidth(DocxNode node, TableCellProperties cellProperties) { string width = node.ExtractStyleValue(DocxUnits.width); if (!string.IsNullOrEmpty(width)) { decimal value; TableWidthUnitValues unit; if (DocxUnits.TableUnitsFromStyle(width, out value, out unit)) { TableCellWidth cellWidth = new TableCellWidth() { Width = value.ToString(), Type = unit }; cellProperties.Append(cellWidth); } } }
protected bool IsHidden(DocxNode node) { if (node == null) { return false; } string display = node.ExtractStyleValue("display"); return display.CompareStringInvariantCultureIgnoreCase("none"); }