Пример #1
0
 /// <summary>
 /// Clears all of the renderer's layout parameter stacks.
 /// </summary>
 public void ClearLayoutStacks()
 {
     StyleStack.Clear();
     FontStack.Clear();
     ColorStack.Clear();
     GlyphShaderStack.Clear();
     LinkStack.Clear();
 }
Пример #2
0
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public override void RenderEndTag()
        {
            base.RenderEndTag();

            SetTagSupports();
            if (Supports(FONT_PROPAGATE))
            {
                FontStack.Pop();
            }
        }
Пример #3
0
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        protected override bool OnTagRender(string name, HtmlTextWriterTag key)
        {
            // handle any tags that do not work downlevel

            SetTagSupports();
            if (Supports(FONT_PROPAGATE))
            {
                FontStack.Push(new FontStackItem());
            }

            // div->table substitution.
            // Make tag look like a table. This must be done after we establish tag support.
            if (key == HtmlTextWriterTag.Div && ShouldPerformDivTableSubstitution)
            {
                TagKey = HtmlTextWriterTag.Table;
            }

            return(base.OnTagRender(name, key));
        }
Пример #4
0
            public void PopStyleScope()
            {
                var scope = StyleStack.Count;

                while (FontStack.Count > 0 && FontStack.Peek().Scope == scope)
                {
                    FontStack.Pop();
                }

                while (ColorStack.Count > 0 && ColorStack.Peek().Scope == scope)
                {
                    ColorStack.Pop();
                }

                while (GlyphShaderStack.Count > 0 && GlyphShaderStack.Peek().Scope == scope)
                {
                    GlyphShaderStack.Pop();
                }
            }
Пример #5
0
        public PPTXSlide CreateNewSlide()
        {
            if (currentSlide != null)
            {
                EndSheet(currentSlide);
            }
            currentSlide = new PPTXSlide()
            {
                SlideLayout = EPPTXSlideLayoutType.BlankSheet
            };
            document.Slides.Add(currentSlide);

            FontStack.Clear();
            LastAddedItemTransform       = new PPTXTransform();
            LastAddedItemTransform.SizeY = Settings.Margin.Top;


            TextManager.Init(this);
            TableManager.Init(this);

            return(currentSlide);
        }
Пример #6
0
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        protected override bool OnStyleAttributeRender(string name, string value, HtmlTextWriterStyle key)
        {
            string s;

            if (Supports(FONT_AROUND_CONTENT))
            {
                // tag supports downlevel fonts
                switch (key)
                {
                case HtmlTextWriterStyle.FontFamily:
                    _fontFace      = value;
                    _renderFontTag = true;
                    break;

                case HtmlTextWriterStyle.Color:
                    _fontColor     = value;
                    _renderFontTag = true;
                    break;

                case HtmlTextWriterStyle.FontSize:
                    _fontSize = ConvertToHtmlFontSize(value);
                    if (_fontSize != null)
                    {
                        _renderFontTag = true;
                    }
                    break;

                case HtmlTextWriterStyle.FontWeight:
                    if (StringUtil.EqualsIgnoreCase(value, "bold") && SupportsBold)
                    {
                        AppendOtherTag("b");
                    }
                    break;

                case HtmlTextWriterStyle.FontStyle:
                    if (!StringUtil.EqualsIgnoreCase(value, "normal") && SupportsItalic)
                    {
                        AppendOtherTag("i");
                    }
                    break;

                case HtmlTextWriterStyle.TextDecoration:
                    s = value.ToLower(CultureInfo.InvariantCulture);
                    if (s.IndexOf("underline", StringComparison.Ordinal) != -1)
                    {
                        AppendOtherTag("u");
                    }
                    if (s.IndexOf("line-through", StringComparison.Ordinal) != -1)
                    {
                        AppendOtherTag("strike");
                    }
                    break;
                }
            }
            else if (Supports(FONT_PROPAGATE))
            {
                FontStackItem font = (FontStackItem)FontStack.Peek();

                switch (key)
                {
                case HtmlTextWriterStyle.FontFamily:
                    font.name = value;
                    break;

                case HtmlTextWriterStyle.Color:
                    font.color = value;
                    break;

                case HtmlTextWriterStyle.FontSize:
                    font.size = ConvertToHtmlFontSize(value);
                    break;

                case HtmlTextWriterStyle.FontWeight:
                    if (StringUtil.EqualsIgnoreCase(value, "bold"))
                    {
                        font.bold = true;
                    }
                    break;

                case HtmlTextWriterStyle.FontStyle:
                    if (!StringUtil.EqualsIgnoreCase(value, "normal"))
                    {
                        font.italic = true;
                    }
                    break;

                case HtmlTextWriterStyle.TextDecoration:
                    s = value.ToLower(CultureInfo.InvariantCulture);
                    if (s.IndexOf("underline", StringComparison.Ordinal) != -1)
                    {
                        font.underline = true;
                    }
                    if (s.IndexOf("line-through", StringComparison.Ordinal) != -1)
                    {
                        font.strikeout = true;
                    }
                    break;
                }
            }

            if (Supports(SUPPORTS_BORDER) && key == HtmlTextWriterStyle.BorderWidth)
            {
                s = ConvertToHtmlSize(value);
                if (s != null)
                {
                    AddAttribute(HtmlTextWriterAttribute.Border, s);
                }
            }

            if (Supports(SUPPORTS_NOWRAP) && key == HtmlTextWriterStyle.WhiteSpace)
            {
                AddAttribute(HtmlTextWriterAttribute.Nowrap, value);
            }

            if (Supports(SUPPORTS_HEIGHT_WIDTH))
            {
                switch (key)
                {
                case HtmlTextWriterStyle.Height:
                    s = ConvertToHtmlSize(value);
                    if (s != null)
                    {
                        AddAttribute(HtmlTextWriterAttribute.Height, s);
                    }
                    break;

                case HtmlTextWriterStyle.Width:
                    s = ConvertToHtmlSize(value);
                    if (s != null)
                    {
                        AddAttribute(HtmlTextWriterAttribute.Width, s);
                    }
                    break;
                }
            }

            if (Supports(TABLE_ATTRIBUTES) || Supports(TABLE_AROUND_CONTENT))
            {
                // tag supports downlevel table attributes
                switch (key)
                {
                case HtmlTextWriterStyle.BorderColor:
                    switch (TagKey)
                    {
                    case HtmlTextWriterTag.Div:
                        if (ShouldPerformDivTableSubstitution)
                        {
                            AddAttribute(HtmlTextWriterAttribute.Bordercolor, value);
                        }
                        break;
                    }
                    break;

                case HtmlTextWriterStyle.BackgroundColor:
                    switch (TagKey)
                    {
                    case HtmlTextWriterTag.Table:
                    case HtmlTextWriterTag.Tr:
                    case HtmlTextWriterTag.Td:
                    case HtmlTextWriterTag.Th:
                    case HtmlTextWriterTag.Body:
                        AddAttribute(HtmlTextWriterAttribute.Bgcolor, value);
                        break;

                    // div->table substitution.
                    case HtmlTextWriterTag.Div:
                        if (ShouldPerformDivTableSubstitution)
                        {
                            AddAttribute(HtmlTextWriterAttribute.Bgcolor, value);
                        }
                        break;
                    }
                    break;

                case HtmlTextWriterStyle.BackgroundImage:
                    switch (TagKey)
                    {
                    case HtmlTextWriterTag.Table:
                    case HtmlTextWriterTag.Td:
                    case HtmlTextWriterTag.Th:
                    case HtmlTextWriterTag.Body:
                        // strip url(...) from value
                        if (StringUtil.StringStartsWith(value, "url("))
                        {
                            value = value.Substring(4, value.Length - 5);
                        }
                        AddAttribute(HtmlTextWriterAttribute.Background, value);
                        break;

                    // div->table substitution.
                    case HtmlTextWriterTag.Div:
                        if (ShouldPerformDivTableSubstitution)
                        {
                            if (StringUtil.StringStartsWith(value, "url("))
                            {
                                value = value.Substring(4, value.Length - 5);
                            }
                            AddAttribute(HtmlTextWriterAttribute.Background, value);
                        }
                        break;
                    }
                    break;
                }
            }

            switch (key)
            {
            case HtmlTextWriterStyle.ListStyleType:
                switch (value)
                {
                case "decimal":
                    AddAttribute(HtmlTextWriterAttribute.Type, "1");
                    break;

                case "lower-alpha":
                    AddAttribute(HtmlTextWriterAttribute.Type, "a");
                    break;

                case "upper-alpha":
                    AddAttribute(HtmlTextWriterAttribute.Type, "A");
                    break;

                case "lower-roman":
                    AddAttribute(HtmlTextWriterAttribute.Type, "i");
                    break;

                case "upper-roman":
                    AddAttribute(HtmlTextWriterAttribute.Type, "I");
                    break;

                case "disc":
                case "circle":
                case "square":
                    AddAttribute(HtmlTextWriterAttribute.Type, value);
                    break;

                default:
                    AddAttribute(HtmlTextWriterAttribute.Type, "disc");
                    Debug.Assert(false, "Invalid BulletStyle for HTML32.");
                    break;
                }
                break;

            case HtmlTextWriterStyle.TextAlign:
                AddAttribute(HtmlTextWriterAttribute.Align, value);
                break;

            case HtmlTextWriterStyle.VerticalAlign:
                AddAttribute(HtmlTextWriterAttribute.Valign, value);
                break;

            // Netscape 4.72 can properly handle the Display style attribute, so allow it
            // to be rendered.
            case HtmlTextWriterStyle.Display:
                return(true);
            }

            return(false);
        }
Пример #7
0
        private void ConsumeFont(StringBuilder sbBegin, StringBuilder sbEnd)
        {
            if (FontStack.Count > 0)
            {
                string fontFace  = null;
                string fontColor = null;
                string fontSize  = null;
                bool   underline = false;
                bool   italic    = false;
                bool   bold      = false;
                bool   strikeout = false;

                IEnumerator e = FontStack.GetEnumerator();
                while (e.MoveNext())
                {
                    FontStackItem fontInfo = (FontStackItem)e.Current;
                    if (fontFace == null)
                    {
                        fontFace = fontInfo.name;
                    }
                    if (fontColor == null)
                    {
                        fontColor = fontInfo.color;
                    }
                    if (fontSize == null)
                    {
                        fontSize = fontInfo.size;
                    }
                    if (!underline)
                    {
                        underline = fontInfo.underline;
                    }
                    if (!italic)
                    {
                        italic = fontInfo.italic;
                    }
                    if (!bold)
                    {
                        bold = fontInfo.bold;
                    }
                    if (!strikeout)
                    {
                        strikeout = fontInfo.strikeout;
                    }
                }

                if ((fontFace != null) || (fontColor != null) || (fontSize != null))
                {
                    AppendFontTag(fontFace, fontColor, fontSize, sbBegin, sbEnd);
                }
                if (underline)
                {
                    AppendOtherTag("u", sbBegin, sbEnd);
                }
                if (italic && SupportsItalic)
                {
                    AppendOtherTag("i", sbBegin, sbEnd);
                }
                if (bold && SupportsBold)
                {
                    AppendOtherTag("b", sbBegin, sbEnd);
                }
                if (strikeout)
                {
                    AppendOtherTag("strike", sbBegin, sbEnd);
                }
            }
        }
Пример #8
0
 public void PopInline()
 {
     FontStack.Pop();
 }
Пример #9
0
 public void PushInlineSetting(PPTXInlineSetting InlieSetting)
 {
     FontStack.Push(InlieSetting.Font);
 }
Пример #10
0
 public void PopBlockSetting()
 {
     this.BlockSetting = null;
     FontStack.Pop();
 }
Пример #11
0
 public void PushBlockSetting(PPTXBlockSetting BlockSetting)
 {
     this.BlockSetting = BlockSetting;
     FontStack.Push(BlockSetting.Font);
 }