Beispiel #1
0
        internal object Push(PDFOutlineRef outlineref)
        {
            if (null == outlineref)
            {
                throw RecordAndRaise.ArgumentNull("outlineref");
            }
            if (null == outlineref.Outline)
            {
                throw RecordAndRaise.ArgumentNull("outlineref.Outline");
            }
            if (null == outlineref.Outline.BelongsTo)
            {
                throw RecordAndRaise.ArgumentNull("outlineref.Outline.BelongsTo");
            }

            if (_stack.Count == 0)
            {
                _roots.Add(outlineref);
            }
            else
            {
                _stack.Peek().AddChild(outlineref);
            }

            _stack.Push(outlineref);

            return(outlineref.Outline.BelongsTo);
        }
Beispiel #2
0
 internal void AddChild(PDFOutlineRef outlineref)
 {
     if (null == _inneritems)
     {
         _inneritems = new PDFOutlineRefCollection();
     }
     _inneritems.Add(outlineref);
 }
Beispiel #3
0
        internal void Pop(IPDFComponent comp)
        {
            PDFOutlineRef last = _stack.Pop();

            if (last.Outline.BelongsTo != comp)
            {
                throw RecordAndRaise.Operation(Errors.UnbalancedOutlineStack);
            }
        }
Beispiel #4
0
        private PDFObjectRef RenderOutlineItem(PDFOutlineRef outlineref, PDFObjectRef parent, PDFObjectRef prev, PDFRenderContext context, PDFWriter writer, out int count)
        {
            PDFOutline outline = outlineref.Outline;

            Scryber.Drawing.PDFColor  c  = outlineref.GetColor();
            Scryber.Drawing.FontStyle fs = outlineref.GetFontStyle();
            bool isopen = outlineref.GetIsOpen();

            count = 1;//this one
            PDFObjectRef item = writer.BeginObject();

            writer.BeginDictionary();
            writer.WriteDictionaryObjectRefEntry("Parent", parent);
            writer.WriteDictionaryStringEntry("Title", outline.Title);
            writer.WriteDictionaryStringEntry("Dest", outline.DestinationName);
            if (null != c)
            {
                writer.BeginDictionaryEntry("C");
                writer.BeginArray();
                writer.WriteRealS(c.Red.Value, c.Green.Value, c.Blue.Value);
                writer.EndArray();
                writer.EndDictionaryEntry();
            }

            if (fs != Scryber.Drawing.FontStyle.Regular)
            {
                int f = 0;
                if ((fs & Scryber.Drawing.FontStyle.Bold) > 0)
                {
                    f = 2;
                }
                if ((fs & Scryber.Drawing.FontStyle.Italic) > 0)
                {
                    f += 1;
                }
                writer.WriteDictionaryNumberEntry("F", f);
            }

            if (null != prev)
            {
                writer.WriteDictionaryObjectRefEntry("Prev", prev);
            }

            if (context.ShouldLogVerbose)
            {
                context.TraceLog.Add(TraceLevel.Verbose, "Outline Stack", "Rendered outline item " + item + " with title '" + outline.Title + " and destination name " + outline.DestinationName);
            }

            if (outlineref.HasInnerItems)
            {
                if (context.ShouldLogDebug)
                {
                    context.TraceLog.Begin(TraceLevel.Debug, "Outline Stack", "Started rendering inner outline items");
                }


                int          opencount;
                PDFObjectRef childfirst, childlast;
                this.RenderOutlineCollection(outlineref.InnerItems, item, context, writer, out childfirst, out childlast, out opencount);

                writer.WriteDictionaryObjectRefEntry("First", childfirst);
                writer.WriteDictionaryObjectRefEntry("Last", childlast);
                if (opencount > 0)
                {
                    if (isopen)
                    {
                        writer.WriteDictionaryNumberEntry("Count", opencount);
                        count += opencount;
                    }
                    else
                    {
                        writer.WriteDictionaryNumberEntry("Count", -opencount);
                    }
                }

                if (context.ShouldLogDebug)
                {
                    context.TraceLog.End(TraceLevel.Debug, "Outlines", " Finished rendering inner outline items");
                }
            }

            //we don't close the dictionary here as we need the next entry written
            //It should be closed in the calling method

            return(item);
        }