示例#1
0
        /*
         * (non-Javadoc)
         *
         * @see com.itextpdf.tool.xml.pipeline.Pipeline#close(com.itextpdf.tool
         * .xml.Tag, com.itextpdf.tool.xml.pipeline.ProcessObject)
         */
        public override IPipeline Close(IWorkerContext context, Tag t, ProcessObject po)
        {
            SvgPipelineContext hcc = (SvgPipelineContext)GetLocalContext(context);
            ITagProcessor      tp;
            IList <IElement>   elements = null;

            try {
                tp = hcc.ResolveProcessor(t.Name, t.NameSpace);

                if (tp.IsStackOwner())
                {
                    // remove the element from the StackKeeper Queue if end tag is found
                    StackKeeper tagStack;
                    try {
                        tagStack = hcc.Poll();
                    } catch (NoStackException e) {
                        throw new PipelineException(String.Format(
                                                        LocaleMessages.GetInstance().GetMessage(LocaleMessages.STACK_404), t.ToString()), e);
                    }
                    elements = tp.EndElement(context, t, tagStack.GetElements());
                }
                else
                {
                    elements = tp.EndElement(context, t, hcc.CurrentContent());
                    hcc.CurrentContent().Clear();
                }

                if (elements != null && elements.Count > 0)
                {
                    try {
                        StackKeeper stack = hcc.Peek();
                        foreach (IElement elem in elements)
                        {
                            stack.Add(elem);
                        }
                    } catch (NoStackException) {
                        //don't write definities, part of defs
                        if (!hcc.IsDefinition())
                        {
                            foreach (IElement elem in elements)
                            {
                                po.Add((IWritable)elem);
                            }
                        }
                    }
                }
            } catch (NoTagProcessorException e) {
                if (!hcc.AcceptUnknown())
                {
                    throw e;
                }
            }
            return(GetNext());
        }
示例#2
0
        /*
         * (non-Javadoc)
         *
         * @see com.itextpdf.tool.xml.pipeline.Pipeline#content(com.itextpdf.tool
         * .xml.Tag, java.lang.String, com.itextpdf.tool.xml.pipeline.ProcessObject)
         */
        public override IPipeline Content(IWorkerContext context, Tag t, String text, ProcessObject po)
        {
            SvgPipelineContext hcc = (SvgPipelineContext)GetLocalContext(context);
            ITagProcessor      tp;

            try {
                tp = hcc.ResolveProcessor(t.Name, t.NameSpace);
                //			String ctn = null;
                //			if (null != hcc.CharSet()) {
                //				try {
                //					ctn = new String(b, hcc.CharSet().Name());
                //				} catch (UnsupportedEncodingException e) {
                //					throw new RuntimeWorkerException(LocaleMessages.GetInstance().GetMessage(
                //							LocaleMessages.UNSUPPORTED_CHARSET), e);
                //				}
                //			} else {
                //				ctn = new String(b);
                //			}

                IList <IElement> elements = tp.Content(context, t, text);

                if (elements.Count > 0)
                {
                    StackKeeper peek;
                    try {
                        peek = hcc.Peek();
                        foreach (IElement e in elements)
                        {
                            peek.Add(e);
                        }
                    } catch (NoStackException) {
                        if (!hcc.IsDefinition())
                        {
                            foreach (IElement elem in elements)
                            {
                                po.Add((IWritable)elem);
                            }
                        }
                        //					po.Add(writableElement);
                    }
                }
            } catch (NoTagProcessorException e) {
                if (!hcc.AcceptUnknown())
                {
                    throw e;
                }
            }
            return(GetNext());
        }
示例#3
0
        /*
         * (non-Javadoc)
         *
         * @see com.itextpdf.tool.xml.pipeline.Pipeline#open(com.itextpdf.tool.
         * xml.Tag, com.itextpdf.tool.xml.pipeline.ProcessObject)
         */
        public override IPipeline Open(IWorkerContext context, Tag t, ProcessObject po)
        {
            SvgPipelineContext hcc = (SvgPipelineContext)GetLocalContext(context);

            try {
                ITagProcessor tp = hcc.ResolveProcessor(t.Name, t.Name);
                if (tp.IsStackOwner())
                {
                    hcc.AddFirst(new StackKeeper(t));
                }
                IList <IElement> content = tp.StartElement(context, t);
                if (content.Count > 0)
                {
                    if (tp.IsStackOwner())
                    {
                        StackKeeper peek;
                        try {
                            peek = hcc.Peek();
                            foreach (IElement elem in content)
                            {
                                peek.Add(elem);
                            }
                        } catch (NoStackException e) {
                            throw new PipelineException(String.Format(LocaleMessages.STACK_404, t.ToString()), e);
                        }
                    }
                    else
                    {
                        if (!hcc.IsDefinition())
                        {
                            foreach (IElement elem in content)
                            {
                                po.Add((Graphic)elem);
                            }
                        }
                    }
                }
            } catch (NoTagProcessorException e) {
                if (!hcc.AcceptUnknown())
                {
                    throw e;
                }
            }
            return(GetNext());
        }