Beispiel #1
0
        public void Remove(OutlineItem item)
        {
            if (base.Direct == null)
            {
                throw new PDFException("Attempt to remove from non-existing outline collection");
            }
            PDFDict dict1 = item.Dict;
            PDFDict dict2 = (dict1["Prev"] as PDFDict);
            PDFDict dict3 = (dict1["Next"] as PDFDict);

            if (dict2 != null)
            {
                dict2["Next"] = dict1["Next"];
            }
            else
            {
                this.Dict["First"] = dict1["Next"];
            }
            if (dict3 != null)
            {
                dict3["Prev"] = dict1["Prev"];
            }
            else
            {
                this.Dict["Last"] = dict1["Prev"];
            }
            PDFInteger integer1 = (this.Dict["Count"] as PDFInteger);

            if (integer1 == null)
            {
                throw new PDFSyntaxException(base.Direct, "Non-empty outlines collection missing Count item");
            }
            integer1.Value -= ((long)1);
        }
Beispiel #2
0
        public static OutlineItem Create(string title)
        {
            OutlineItem item1 = OutlineItem.Create();

            item1.Title = title;
            return(item1);
        }
Beispiel #3
0
        public static OutlineItem Create(string title, LinkDestination dest)
        {
            OutlineItem item1 = OutlineItem.Create();

            item1.Title       = title;
            item1.Destination = dest;
            return(item1);
        }
Beispiel #4
0
        public static OutlineItem Create(string title, Action action)
        {
            OutlineItem item1 = OutlineItem.Create();

            item1.Title  = title;
            item1.Action = action;
            return(item1);
        }
Beispiel #5
0
        public void Add(OutlineItem item)
        {
            PDFObject obj1;

            if (base.Direct == null)
            {
                obj1 = Library.CreateDict();
                this.mParentDict["Outlines"] = obj1;
                this.mDirect = (obj1 as PDFDirect);
            }
            PDFDict dict1 = item.Dict;
            PDFDict dict2 = (this.Dict["Last"] as PDFDict);

            if (dict2 != null)
            {
                dict2["Next"] = dict1;
                dict1["Prev"] = dict2;
                dict1.Remove("Next");
                this.Dict["Last"] = dict1;
            }
            else
            {
                obj1 = item.Direct;
                this.Dict["Last"]  = obj1;
                this.Dict["First"] = obj1;
                dict1.Remove("Prev");
                dict1.Remove("Next");
            }
            PDFInteger integer1 = (this.Dict["Count"] as PDFInteger);

            if (integer1 == null)
            {
                integer1           = Library.CreateInteger(((long)1));
                this.Dict["Count"] = integer1;
            }
            else
            {
                integer1.Value += ((long)1);
            }
            dict1["Parent"] = this.Dict;
        }
Beispiel #6
0
        public void Insert(int index, OutlineItem item)
        {
            PDFDict    dict2;
            PDFInteger integer1;
            PDFDict    dict3;
            PDFInteger integer2;
            PDFObject  obj1;

            if (base.Direct == null)
            {
                obj1 = Library.CreateDict();
                this.mParentDict["Outlines"] = obj1;
                this.mDirect = (obj1 as PDFDirect);
            }
            PDFDict dict1 = item.Dict;

            if (index == 0)
            {
                dict2 = (this.Dict["First"] as PDFDict);
                if (dict2 != null)
                {
                    dict2["Prev"] = dict1;
                    dict1["Next"] = dict2;
                    dict1.Remove("Prev");
                    this.Dict["First"] = dict1;
                }
                else
                {
                    obj1 = item.Direct;
                    this.Dict["Last"]  = obj1;
                    this.Dict["First"] = obj1;
                    dict1.Remove("Prev");
                    dict1.Remove("Next");
                }
                integer1 = (this.Dict["Count"] as PDFInteger);
                if (integer1 == null)
                {
                    integer1           = Library.CreateInteger(((long)1));
                    this.Dict["Count"] = integer1;
                }
                else
                {
                    integer1.Value += ((long)1);
                }
            }
            else if (index == this.Count)
            {
                this.Add(item);
            }
            else
            {
                dict3 = this.At(index);
                if (dict3 == null)
                {
                    throw new IndexOutOfRangeException("OutlineItem index out of range");
                }
                dict1["Prev"] = dict3["Prev"];
                dict1["Next"] = dict3;
                (dict3["Prev"] as PDFDict)["Next"] = dict1;
                integer2 = (this.Dict["Count"] as PDFInteger);
                if (integer2 == null)
                {
                    integer2           = Library.CreateInteger(((long)1));
                    this.Dict["Count"] = integer2;
                }
                else
                {
                    integer2.Value += ((long)1);
                }
            }
            dict1["Parent"] = this.Dict;
        }