示例#1
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);
        }
示例#2
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);
 }