private DqStyleBasis GetDefaultFont(Styles wStyles, DqFontScheme dqFontScheme) => new DqStyleBasis { IsDefault = false, IsBold = false, FontSize = ConvertFontSize(wStyles.DocDefaults.RunPropertiesDefault.RunPropertiesBaseStyle.FontSize), FontName = GetFontName(wStyles.DocDefaults.RunPropertiesDefault.RunPropertiesBaseStyle.RunFonts, dqFontScheme), OutlineLevel = 0, Aligment = DqAligment.Left, OtherIndent = 0, Indent = 0, InlineLevel = 0, SpacingBetweenLines = 1, Numbering = null, };
public DqStyle GetParagraphStyle(Paragraph paragraph, DqStyleTable styleTable, DqFontScheme fontScheme, DqNumberingTable dqNumberingTable) { var value = paragraph.ParagraphProperties?.ParagraphStyleId?.Val?.Value; var basicStyle = styleTable.Paragraph[value] ?? styleTable.Paragraph.Default; var pPr = paragraph.ParagraphProperties; if (pPr == null) { return(basicStyle); } var localStyle = new DqStyle { BaseStyle = basicStyle }; if (pPr.SpacingBetweenLines != null) { localStyle.Current.SpacingBetweenLines = GetSpacingBetweenLines(pPr.SpacingBetweenLines.Line); } if (pPr.Indentation?.FirstLine != null) { localStyle.Current.Indent = Convertion.TwipToCm(int.Parse(pPr.Indentation.FirstLine.Value)); } if (pPr.Justification != null) { localStyle.Current.Aligment = Convert(pPr.Justification.Val); } if (pPr.GetFirstChild <NumberingProperties>() != null) { var id = pPr.GetFirstChild <NumberingProperties>().NumberingId; var numbering = dqNumberingTable[id.Val]; localStyle.Current.Numbering = numbering; var level = pPr.GetFirstChild <NumberingProperties>().NumberingLevelReference; if (level != null && level.Val < numbering.Levels.Count) { localStyle.Current.Indent = numbering.Levels[level.Val].Indent ?? localStyle.Indent; } } var rPr = (OpenXmlElement)pPr.ParagraphMarkRunProperties; if (rPr != null) { if (rPr.GetFirstChild <RunFonts>() != null) { localStyle.Current.FontName = GetFontName(rPr.GetFirstChild <RunFonts>(), fontScheme); } if (rPr.GetFirstChild <FontSize>() != null) { localStyle.Current.FontSize = ConvertFontSize(rPr.GetFirstChild <FontSize>()); } if (rPr.GetFirstChild <Bold>() != null) { localStyle.Current.IsBold = ConvertBold(rPr.GetFirstChild <Bold>()); } } var runs = paragraph.Descendants <Run>().ToList(); if (runs.Count == 1) { rPr = runs.Single().RunProperties; if (rPr != null) { if (rPr.GetFirstChild <RunFonts>() != null) { localStyle.Current.FontName = GetFontName(rPr.GetFirstChild <RunFonts>(), fontScheme); } if (rPr.GetFirstChild <FontSize>() != null) { localStyle.Current.FontSize = ConvertFontSize(rPr.GetFirstChild <FontSize>()); } if (rPr.GetFirstChild <Bold>() != null) { localStyle.Current.IsBold = ConvertBold(rPr.GetFirstChild <Bold>()); } } } return(localStyle); }
private DqStyle ConvertStyle(Style style, DqNumberingTable dqNumberingsTable, DqFontScheme fontScheme) =>
private IReadOnlyCollection <DqStyle> GetStyles(Styles wStyles, DqNumberingTable dqNumberingsTable, DqFontScheme dqFontScheme) => wStyles.Descendants <Style>().Select(wStyle => ConvertStyle(wStyle, dqNumberingsTable, dqFontScheme)).ToList();