/// ------------------------------------------------------------------------------------ /// <summary> /// Get a string representing the border settings. These settings are optional /// and require an additional tag based on the values given /// </summary> /// ------------------------------------------------------------------------------------ private static string BorderAsString(IParaStyleInfo paraStyleInfo) { // Assume that there is no border unless proven otherwise string borderString = string.Empty; var border = new BorderThicknesses(0, 0, 0, 0); if (paraStyleInfo.BorderLeading != null) { border.Leading = paraStyleInfo.BorderLeading.Value; } if (paraStyleInfo.BorderTrailing != null) { border.Trailing = paraStyleInfo.BorderTrailing.Value; } if (paraStyleInfo.BorderTop != null) { border.Top = paraStyleInfo.BorderTop.Value; } if (paraStyleInfo.BorderBottom != null) { border.Bottom = paraStyleInfo.BorderBottom.Value; } string borderColorString = ((paraStyleInfo.BorderColor == null || paraStyleInfo.BorderColor.Value == Color.Empty) ? string.Empty : @"\brdrcf" + paraStyleInfo.BorderColor.Value.ToKnownColor()); if (border.Top > 0) { borderString += @"\brdrt\brdrs\brdrw" + ConvertMillipointsToTwips(border.Top) + @"\brsp20" + borderColorString; } if (border.Bottom > 0) { borderString += @"\brdrb\brdrs\brdrw" + ConvertMillipointsToTwips(border.Bottom) + @"\brsp20" + borderColorString; } if (border.Leading > 0) { borderString += @"\brdrl\brdrs\brdrw" + ConvertMillipointsToTwips(border.Leading) + @"\brsp80" + borderColorString; } if (border.Trailing > 0) { borderString += @"\brdrr\brdrs\brdrw" + ConvertMillipointsToTwips(border.Trailing) + @"\brsp80" + borderColorString; } return(borderString); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Get a string representing the line spacing setting. This setting is optional /// and requires an additional tag based on its value /// </summary> /// ------------------------------------------------------------------------------------ private static string LineSpacingAsString(IParaStyleInfo paraStyleInfo) { int height = 0; if (paraStyleInfo.LineHeight != null) { height = paraStyleInfo.LineHeight.Value.m_lineHeight; } // If the line spacing is not specified, then do not put anything into the style if (height == 0) { return(string.Empty); } if (paraStyleInfo.LineHeight.Value.m_relative) { switch (height) { case 10000: return(string.Empty); case 15000: return(@"\sl360\slmult1"); case 20000: return(@"\sl480\slmult1"); default: Debug.Assert(false); return(string.Empty); } } int lineSpacingInTwips = ConvertMillipointsToTwips(height); // Negative line spacing is interpreted as "exact" and requires an \slmult0 tag // following it. if (lineSpacingInTwips < 0) { return(@"\sl" + lineSpacingInTwips + @"\slmult0"); } return(@"\sl" + lineSpacingInTwips); }
private void ApplyParagraphStyleInfo(IParaStyleInfo paraInfo) { if(paraInfo == null) return; if(paraInfo.Alignment != null && paraInfo.Alignment.ValueIsSet) m_paraAlignment = paraInfo.Alignment.Value; if (paraInfo.LineHeight != null && paraInfo.LineHeight.ValueIsSet) m_lineHeight = paraInfo.LineHeight.Value.m_lineHeight; if (paraInfo.FirstLineIndent != null && paraInfo.FirstLineIndent.ValueIsSet) m_firstLineIndent = paraInfo.FirstLineIndent.Value; int borderLeading = 0; int borderTop = 0; int borderTrailing = 0; int borderBottom = 0; if(paraInfo.BorderColor != null && paraInfo.BorderColor.ValueIsSet) m_borderColor = paraInfo.BorderColor.Value; if (paraInfo.BorderLeading != null && paraInfo.BorderLeading.ValueIsSet) borderLeading = paraInfo.BorderLeading.Value; if (paraInfo.BorderTop != null && paraInfo.BorderTop.ValueIsSet) borderTop = paraInfo.BorderTop.Value; if (paraInfo.BorderTrailing != null && paraInfo.BorderTrailing.ValueIsSet) borderTrailing = paraInfo.BorderTrailing.Value; if (paraInfo.BorderBottom != null && paraInfo.BorderBottom.ValueIsSet) borderBottom = paraInfo.BorderBottom.Value; m_borders = new Thickness(borderLeading, borderTop, borderTrailing, borderBottom); int marginLeading = 0; int marginTop = 0; int marginTrailing = 0; int marginBottom = 0; if (paraInfo.MarginLeading != null && paraInfo.MarginLeading.ValueIsSet) marginLeading = paraInfo.MarginLeading.Value; if (paraInfo.MarginTop != null && paraInfo.MarginTop.ValueIsSet) marginTop = paraInfo.MarginTop.Value; if (paraInfo.MarginTrailing != null && paraInfo.MarginTrailing.ValueIsSet) marginTrailing = paraInfo.MarginTrailing.Value; if (paraInfo.MarginBottom != null && paraInfo.MarginBottom.ValueIsSet) marginBottom = paraInfo.MarginBottom.Value; m_margins = new Thickness(marginLeading, marginTop, marginTrailing, marginBottom); int padLeading = 0; int padTop = 0; int padTrailing = 0; int padBottom = 0; if (paraInfo.PadLeading != null && paraInfo.PadLeading.ValueIsSet) padLeading = paraInfo.PadLeading.Value; if (paraInfo.PadTop != null && paraInfo.PadTop.ValueIsSet) padTop = paraInfo.PadTop.Value; if (paraInfo.PadTrailing != null && paraInfo.PadTrailing.ValueIsSet) padTrailing = paraInfo.PadTrailing.Value; if (paraInfo.PadBottom != null && paraInfo.PadBottom.ValueIsSet) padBottom = paraInfo.PadBottom.Value; m_pads = new Thickness(padLeading, padTop, padTrailing, padBottom); }
public void RevertToCharStyle() { ParagraphStyleInfo = null; }