Example #1
0
        internal virtual void InsertInFosterParent(iText.StyledXmlParser.Jsoup.Nodes.Node @in)
        {
            iText.StyledXmlParser.Jsoup.Nodes.Element fosterParent;
            iText.StyledXmlParser.Jsoup.Nodes.Element lastTable = GetFromStack("table");
            bool isLastTableParent = false;

            if (lastTable != null)
            {
                if (lastTable.Parent() != null)
                {
                    fosterParent      = (iText.StyledXmlParser.Jsoup.Nodes.Element)lastTable.Parent();
                    isLastTableParent = true;
                }
                else
                {
                    fosterParent = AboveOnStack(lastTable);
                }
            }
            else
            {
                // no table == frag
                fosterParent = stack[0];
            }
            if (isLastTableParent)
            {
                Validate.NotNull(lastTable);
                // last table cannot be null by this point.
                lastTable.Before(@in);
            }
            else
            {
                fosterParent.AppendChild(@in);
            }
        }