Esempio n. 1
0
        public void Delete(int nr)
        {
            PDFDict  dict3;
            PDFDict  dict1  = this[nr].Dict;
            PDFDict  dict2  = ((PDFDict)dict1["Parent"]);
            PDFArray array1 = ((PDFArray)dict2["Kids"]);
            int      num1   = 0;

            while ((num1 < array1.Count))
            {
                if (array1[num1].Indirect.Id == dict1.Indirect.Id)
                {
                    break;
                }
                num1 += 1;
            }
            if (num1 == array1.Count)
            {
                throw new PDFException(string.Format("Invalid page tree - invalid parent pointer in page {0}", nr));
            }
            array1.RemoveAt(num1);
            for (dict3 = dict2; (dict3 != null); dict3 = ((PDFDict)dict3["Parent"]))
            {
                PDFInteger integer1 = ((PDFInteger)dict2["Count"]);
                ((PDFInteger)dict2["Count"]).Value = (integer1.Value - ((long)1));
            }
        }
Esempio n. 2
0
        private void SetArraySize(int size)
        {
            PDFArray array1 = (base.Direct as PDFArray);

            while ((size < array1.Count))
            {
                array1.RemoveAt((array1.Count - 1));
            }
            while ((size > array1.Count))
            {
                array1.Add(Library.CreateNull());
            }
        }
        protected void _RemoveAt(int index)
        {
            if (index >= this.Count)
            {
                throw new IndexOutOfRangeException("Index is out of range");
            }
            PDFArray array1 = (this.mDirect as PDFArray);

            if (array1 != null)
            {
                array1.RemoveAt(index);
            }
        }
        public void RemoveAt_Test()
        {
            IFileObject[] all    = new IFileObject[] { new PDFNumber(1), new PDFNumber(2), new PDFNumber(3) };
            PDFArray      target = new PDFArray(all);
            int           index  = 1;

            Assert.AreEqual(3, target.Count);
            target.RemoveAt(index);
            Assert.AreEqual(2, target.Count);

            Assert.AreEqual(all[0], target[0]);
            Assert.AreEqual(all[2], target[1]);
        }
        protected void _RemoveAt(int index)
        {
            if (index >= this.Count)
            {
                throw new IndexOutOfRangeException("Index is out of range");
            }
            PDFObject obj1   = this.mBaseDict[this.mBaseKeyName];
            PDFArray  array1 = (obj1 as PDFArray);

            if (array1 != null)
            {
                array1.RemoveAt(index);
                return;
            }
            this.mBaseDict.Remove(this.mBaseKeyName);
        }
Esempio n. 6
0
        private PDFDict SplitNode(PDFDict curr, int index, PDFDict splinter)
        {
            PDFDict  dict1;
            PDFArray array2;
            int      num1;
            PDFArray array3;
            PDFArray array4;
            PDFArray array1 = (curr["Kids"] as PDFArray);

            if (index == (array1.Count - 1))
            {
                array1.Add(splinter);
            }
            else
            {
                array1.Insert((index + 1), splinter);
            }
            if (array1.Count > this.mMaxKids)
            {
                dict1 = Library.CreateDict();
                Library.CreateIndirect(dict1);
                array2        = Library.CreateArray();
                dict1["Kids"] = array2;
                num1          = (array1.Count / 2);
                while ((array1.Count > num1))
                {
                    array2.Insert(0, array1.RemoveAt((array1.Count - 1)));
                }
                array3          = Library.CreateArray(2);
                dict1["Limits"] = array3;
                array3[0]       = ((array2[0] as PDFDict)["Limits"] as PDFArray)[0];
                array3[1]       = ((array2[(array2.Count - 1)] as PDFDict)["Limits"] as PDFArray)[1];
                array4          = Library.CreateArray(2);
                array4[0]       = ((array1[0] as PDFDict)["Limits"] as PDFArray)[0];
                array4[1]       = ((array1[(array1.Count - 1)] as PDFDict)["Limits"] as PDFArray)[1];
                curr["Limits"]  = array4;
                return(dict1);
            }
            return(null);
        }
Esempio n. 7
0
 private PDFDict SetItem(PDFDict curr, string index, PDFObject value)
 {
     bool flag1;
     int num1;
     PDFString text1;
     PDFArray array3;
     int num2;
     PDFArray array4;
     PDFDict dict1;
     PDFArray array5;
     PDFArray array6;
     int num3;
     PDFDict dict2;
     PDFArray array7;
     PDFString text2;
     PDFString text3;
     PDFDict dict3;
     PDFArray array8;
     PDFObject obj1;
     PDFArray array1 = (curr["Names"] as PDFArray);
     PDFArray array2 = (curr["Kids"] as PDFArray);
     if (array1 != null)
     {
         if ((array1.Count % 2) != 0)
         {
             throw new InvalidOperationException("Attempt to manipulate invalid name tree");
         }
         flag1 = true;
         for (num1 = 0; (num1 < (array1.Count / 2)); num1 += 1)
         {
             text1 = (array1[(2 * num1)] as PDFString);
             if (text1 == null)
             {
                 throw new InvalidOperationException("Attempt to manipulate invalid name tree");
             }
             if (text1.Value == index)
             {
                 array1[((2 * num1) + 1)] = value;
                 return null;
             }
             if (string.Compare(text1.Value, index, false) > 0)
             {
                 array1.Insert((2 * num1), value);
                 array1.Insert((2 * num1), PDF.O(index));
                 flag1 = false;
                 break;
             }
         }
         if (flag1)
         {
             array1.Add(PDF.O(index));
             array1.Add(value);
             array3 = (curr["Limits"] as PDFArray);
             if (array3 != null)
             {
                 ((PDFString) array3[1]).Value = index;
             }
         }
         if ((array1.Count / 2) > this.mMaxKids)
         {
             num2 = (array1.Count / 2);
             array4 = Library.CreateArray(0);
             dict1 = Library.CreateDict();
             Library.CreateIndirect(dict1);
             while ((array1.Count > num2))
             {
                 array4.Insert(0, array1.RemoveAt((array1.Count - 1)));
                 array4.Insert(0, array1.RemoveAt((array1.Count - 1)));
             }
             array5 = Library.CreateArray(1);
             array5[0] = array1[0];
             array5[1] = array1[(array1.Count - 2)];
             curr["Limits"] = array5;
             dict1["Names"] = array4;
             array6 = Library.CreateArray(0);
             array6[0] = array4[0];
             array6[1] = array4[(array4.Count - 2)];
             dict1["Limits"] = array6;
             return dict1;
         }
         return null;
     }
     if (array2 != null)
     {
         for (num3 = 0; (num3 < array2.Count); num3 += 1)
         {
             dict2 = (array2[num3] as PDFDict);
             if (dict2 == null)
             {
                 throw new InvalidOperationException("Attempt to manipulate invalid name tree");
             }
             array7 = (dict2["Limits"] as PDFArray);
             if (array7.Count != 2)
             {
                 throw new InvalidOperationException("Attempt to manipulate invalid name tree");
             }
             text2 = (array7[0] as PDFString);
             text3 = (array7[1] as PDFString);
             if ((text2 == null) || (text3 == null))
             {
                 throw new InvalidOperationException("Attempt to manipulate invalid name tree");
             }
             if (((string.Compare(index, text2.Value) < 0) || (string.Compare(index, text3.Value) < 0)) || ((num3 + 1) == array2.Count))
             {
                 dict3 = this.SetItem(dict2, index, value);
                 if (string.Compare(index, text2.Value) < 0)
                 {
                     array7[0] = PDF.O(index);
                 }
                 if (dict3 != null)
                 {
                     return this.SplitNode(curr, num3, dict3);
                 }
                 return null;
             }
         }
     }
     else
     {
         array1 = Library.CreateArray(2);
         curr["Names"] = array1;
         array8 = Library.CreateArray(2);
         obj1 = PDF.O(index);
         array1[0] = obj1;
         obj1 = obj1;
         array8[1] = obj1;
         array8[0] = obj1;
         array1[1] = value;
     }
     return null;
 }
 private void updateArrayValue(PDFArray array, int index, PDFObject newVal)
 {
     array.RemoveAt(index);
     array.Insert(index, newVal);
 }
Esempio n. 9
0
 /// <summary>
 /// Removes page by index
 /// </summary>
 /// <param name="index">Index to the page reference to be removes</param>
 /// <returns>True if success</returns>
 public bool RemovePageRefAt(int index)
 {
     _arrkids.RemoveAt(index);
     return(true);
 }