Example #1
0
        private void RevertCharFormat()
        {
            StringBuilder  stringBuilder  = null;
            FlagProperties effectiveFlags = base.GetEffectiveFlags();

            if (effectiveFlags.IsDefinedAndOn(PropertyId.Underline))
            {
                if (stringBuilder == null)
                {
                    stringBuilder = new StringBuilder();
                }
                stringBuilder.Append("</Underline>");
            }
            if (effectiveFlags.IsDefinedAndOn(PropertyId.Italic))
            {
                if (stringBuilder == null)
                {
                    stringBuilder = new StringBuilder();
                }
                stringBuilder.Append("</Italic>");
            }
            if (effectiveFlags.IsDefinedAndOn(PropertyId.FirstFlag))
            {
                if (stringBuilder == null)
                {
                    stringBuilder = new StringBuilder();
                }
                stringBuilder.Append("</Bold>");
            }
            PropertyValue value = base.GetEffectiveProperty(PropertyId.FontColor);

            if (value.IsEnum)
            {
                value = HtmlSupport.TranslateSystemColor(value);
            }
            if (value.IsColor && value.Color.RGB != 0U)
            {
                if (stringBuilder == null)
                {
                    stringBuilder = new StringBuilder();
                }
                stringBuilder.Append("</Color>");
            }
            PropertyValue effectiveProperty  = base.GetEffectiveProperty(PropertyId.FontFace);
            PropertyValue effectiveProperty2 = base.GetEffectiveProperty(PropertyId.FontSize);

            if (!effectiveProperty.IsNull && effectiveProperty.IsString && base.FormatStore.GetStringValue(effectiveProperty).GetString().Equals("Courier New") && !effectiveProperty2.IsNull && effectiveProperty2.IsRelativeHtmlFontUnits && effectiveProperty2.RelativeHtmlFontUnits == -1)
            {
                if (stringBuilder == null)
                {
                    stringBuilder = new StringBuilder();
                }
                stringBuilder.Append("</Fixed>");
            }
            else
            {
                if (!effectiveProperty2.IsNull && !effectiveProperty2.IsAbsLength && !effectiveProperty2.IsHtmlFontUnits && effectiveProperty2.IsRelativeHtmlFontUnits && effectiveProperty2.RelativeHtmlFontUnits != 0)
                {
                    if (stringBuilder == null)
                    {
                        stringBuilder = new StringBuilder();
                    }
                    if (effectiveProperty2.RelativeHtmlFontUnits > 0)
                    {
                        stringBuilder.Append("</Bigger>");
                        for (int i = 1; i < effectiveProperty2.RelativeHtmlFontUnits; i++)
                        {
                            stringBuilder.Append("</Bigger>");
                        }
                    }
                    else
                    {
                        stringBuilder.Append("</Smaller>");
                        for (int j = -1; j > effectiveProperty2.RelativeHtmlFontUnits; j--)
                        {
                            stringBuilder.Append("</Smaller>");
                        }
                    }
                }
                if (!effectiveProperty.IsNull)
                {
                    string text = null;
                    if (effectiveProperty.IsMultiValue)
                    {
                        MultiValue multiValue = base.FormatStore.GetMultiValue(effectiveProperty);
                        if (multiValue.Length != 0)
                        {
                            text = multiValue.GetStringValue(0).GetString();
                        }
                    }
                    else
                    {
                        text = base.FormatStore.GetStringValue(effectiveProperty).GetString();
                    }
                    if (text != null)
                    {
                        if (stringBuilder == null)
                        {
                            stringBuilder = new StringBuilder();
                        }
                        stringBuilder.Append("</FontFamily>");
                    }
                }
            }
            if (stringBuilder != null && stringBuilder.Length != 0)
            {
                this.lineLength += stringBuilder.Length;
                this.output.Write(stringBuilder.ToString());
            }
        }
Example #2
0
        private void ApplyCharFormat()
        {
            StringBuilder  stringBuilder      = null;
            FlagProperties effectiveFlags     = base.GetEffectiveFlags();
            PropertyValue  effectiveProperty  = base.GetEffectiveProperty(PropertyId.FontFace);
            PropertyValue  effectiveProperty2 = base.GetEffectiveProperty(PropertyId.FontSize);

            if (!effectiveProperty.IsNull && effectiveProperty.IsString && base.FormatStore.GetStringValue(effectiveProperty).GetString().Equals("Courier New") && !effectiveProperty2.IsNull && effectiveProperty2.IsRelativeHtmlFontUnits && effectiveProperty2.RelativeHtmlFontUnits == -1)
            {
                if (stringBuilder == null)
                {
                    stringBuilder = new StringBuilder();
                }
                stringBuilder.Append("<Fixed>");
            }
            else
            {
                if (!effectiveProperty.IsNull)
                {
                    string text = null;
                    if (effectiveProperty.IsMultiValue)
                    {
                        MultiValue multiValue = base.FormatStore.GetMultiValue(effectiveProperty);
                        if (multiValue.Length != 0)
                        {
                            text = multiValue.GetStringValue(0).GetString();
                        }
                    }
                    else
                    {
                        text = base.FormatStore.GetStringValue(effectiveProperty).GetString();
                    }
                    if (text != null)
                    {
                        if (stringBuilder == null)
                        {
                            stringBuilder = new StringBuilder();
                        }
                        stringBuilder.Append("<FontFamily><Param>");
                        stringBuilder.Append(text);
                        stringBuilder.Append("</Param>");
                    }
                }
                if (!effectiveProperty2.IsNull && !effectiveProperty2.IsAbsLength && !effectiveProperty2.IsHtmlFontUnits && effectiveProperty2.IsRelativeHtmlFontUnits && effectiveProperty2.RelativeHtmlFontUnits != 0)
                {
                    if (stringBuilder == null)
                    {
                        stringBuilder = new StringBuilder();
                    }
                    if (effectiveProperty2.RelativeHtmlFontUnits > 0)
                    {
                        stringBuilder.Append("<Bigger>");
                        for (int i = 1; i < effectiveProperty2.RelativeHtmlFontUnits; i++)
                        {
                            stringBuilder.Append("<Bigger>");
                        }
                    }
                    else
                    {
                        stringBuilder.Append("<Smaller>");
                        for (int j = -1; j > effectiveProperty2.RelativeHtmlFontUnits; j--)
                        {
                            stringBuilder.Append("<Smaller>");
                        }
                    }
                }
            }
            PropertyValue value = base.GetEffectiveProperty(PropertyId.FontColor);

            if (value.IsEnum)
            {
                value = HtmlSupport.TranslateSystemColor(value);
            }
            if (value.IsColor && value.Color.RGB != 0U)
            {
                if (stringBuilder == null)
                {
                    stringBuilder = new StringBuilder();
                }
                uint num  = value.Color.Red << 8;
                uint num2 = value.Color.Green << 8;
                uint num3 = value.Color.Blue << 8;
                if ((num & 256U) != 0U)
                {
                    num += 255U;
                }
                if ((num2 & 256U) != 0U)
                {
                    num2 += 255U;
                }
                if ((num3 & 256U) != 0U)
                {
                    num3 += 255U;
                }
                stringBuilder.Append("<Color><Param>");
                stringBuilder.Append(string.Format("{0:X4},{1:X4},{2:X4}", num, num2, num3));
                stringBuilder.Append("</Param>");
            }
            if (effectiveFlags.IsDefinedAndOn(PropertyId.FirstFlag))
            {
                if (stringBuilder == null)
                {
                    stringBuilder = new StringBuilder();
                }
                stringBuilder.Append("<Bold>");
            }
            if (effectiveFlags.IsDefinedAndOn(PropertyId.Italic))
            {
                if (stringBuilder == null)
                {
                    stringBuilder = new StringBuilder();
                }
                stringBuilder.Append("<Italic>");
            }
            if (effectiveFlags.IsDefinedAndOn(PropertyId.Underline))
            {
                if (stringBuilder == null)
                {
                    stringBuilder = new StringBuilder();
                }
                stringBuilder.Append("<Underline>");
            }
            if (stringBuilder != null && stringBuilder.Length != 0)
            {
                this.lineLength += stringBuilder.Length;
                this.output.Write(stringBuilder.ToString());
            }
        }