GetMemory() public method

public GetMemory ( ) : Object>.IDictionary
return Object>.IDictionary
コード例 #1
0
        /*
         * (non-Javadoc)
         *
         * @see
         * com.itextpdf.tool.xml.pipeline.IPipeline#close(com.itextpdf.tool
         * .xml.Tag, com.itextpdf.tool.xml.pipeline.ProcessObject)
         */
        public override IPipeline Close(IWorkerContext context, Tag t, ProcessObject po)
        {
            HtmlPipelineContext hcc = (HtmlPipelineContext)GetLocalContext(context);
            ITagProcessor       tp;

            try {
                if (t.LastMarginBottom != null)
                {
                    hcc.GetMemory()[HtmlPipelineContext.LAST_MARGIN_BOTTOM] = t.LastMarginBottom;
                }
                else
                {
                    hcc.GetMemory().Remove(HtmlPipelineContext.LAST_MARGIN_BOTTOM);
                }
                tp = hcc.ResolveProcessor(t.Name, t.NameSpace);
                IList <IElement> elems = null;
                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);
                    }
                    elems = tp.EndElement(context, t, tagStack.GetElements());
                }
                else
                {
                    elems = tp.EndElement(context, t, hcc.CurrentContent());
                    hcc.CurrentContent().Clear();
                }
                if (elems.Count > 0)
                {
                    StackKeeper stack = hcc.Peek();

                    if (stack != null)
                    {
                        foreach (IElement elem in elems)
                        {
                            stack.Add(elem);
                        }
                    }
                    else
                    {
                        WritableElement writableElement = new WritableElement();
                        po.Add(writableElement);
                        writableElement.AddAll(elems);
                    }
                }
            } catch (NoTagProcessorException e) {
                if (!hcc.AcceptUnknown())
                {
                    throw e;
                }
            }
            return(GetNext());
        }
コード例 #2
0
        /*
         * (non-Javadoc)
         *
         * @see
         * com.itextpdf.tool.xml.pipeline.IPipeline#open(com.itextpdf.tool.
         * xml.Tag, com.itextpdf.tool.xml.pipeline.ProcessObject)
         */
        public override IPipeline Open(IWorkerContext context, Tag t, ProcessObject po)
        {
            HtmlPipelineContext hcc = (HtmlPipelineContext)GetLocalContext(context);

            try {
                Object lastMarginBottom = null;
                if (hcc.GetMemory().TryGetValue(HtmlPipelineContext.LAST_MARGIN_BOTTOM, out lastMarginBottom))
                {
                    t.LastMarginBottom = lastMarginBottom;
                    hcc.GetMemory().Remove(HtmlPipelineContext.LAST_MARGIN_BOTTOM);
                }
                ITagProcessor tp = hcc.ResolveProcessor(t.Name, t.NameSpace);
                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
                    {
                        foreach (IElement elem in content)
                        {
                            hcc.CurrentContent().Add(elem);
                            if (elem.Type == Element.BODY)
                            {
                                WritableElement writableElement = new WritableElement();
                                writableElement.Add(elem);
                                po.Add(writableElement);
                                hcc.CurrentContent().Remove(elem);
                            }
                        }
                    }
                }
            } catch (NoTagProcessorException e) {
                if (!hcc.AcceptUnknown())
                {
                    throw e;
                }
            }
            return(GetNext());
        }
コード例 #3
0
ファイル: CssUtils.cs プロジェクト: boecko/iTextSharp
 /**
  * Calculates the margin top or spacingBefore based on the given value and the last margin bottom.
  * <br /><br />
  * In HTML the margin-bottom of a tag overlaps with the margin-top of a following tag.
  * This method simulates this behavior by subtracting the margin-top value of the given tag from the margin-bottom of the previous tag. The remaining value is returned or if the margin-bottom value is the largest, 0 is returned
  * @param value float containing the margin-top value.
  * @param configuration XmlWorkerConfig containing the last margin bottom.
  * @return an offset
  */
 public float CalculateMarginTop(float value, HtmlPipelineContext configuration)
 {
     float marginTop = value;
     IDictionary<String, Object> memory = configuration.GetMemory();
     Object mb;
     memory.TryGetValue(HtmlPipelineContext.LAST_MARGIN_BOTTOM, out mb);
     if (mb != null) {
         float marginBottom = (float)mb;
         marginTop = (marginTop>marginBottom)?marginTop-marginBottom:0;
     }
     return marginTop;
 }