virtual public void SetUp() { t = new Tag("root"); sk = new StackKeeper(t); a = new Chunk("a"); sk.Add(a); b = new Chunk("b"); sk.Add(b); c = new Chunk("c"); sk.Add(c); }
/* * (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()); }
/** * Retrieves and removes the top of the stack. * @return a StackKeeper * @throws NoStackException if there are no elements on the stack */ protected internal StackKeeper Poll() { try { StackKeeper first = this.queue.First.Value; this.queue.RemoveFirst(); return(first); } catch (InvalidOperationException) { throw new NoStackException(); } }
/** * Add a {@link StackKeeper} to the top of the stack list. * @param stackKeeper the {@link StackKeeper} */ virtual protected internal void AddFirst(StackKeeper stackKeeper) { this.queue.AddFirst(stackKeeper); }
/** * Add a {@link StackKeeper} to the top of the stack list. * @param stackKeeper the {@link StackKeeper} */ protected internal void AddFirst(StackKeeper stackKeeper) { this.queue.AddFirst(stackKeeper); }