IsNull() public méthode

public IsNull ( ) : bool
Résultat bool
Exemple #1
0
 internal void AddDefaultColor(PdfName name, PdfObject obj)
 {
     if (obj == null || obj.IsNull())
     {
         colorDictionary.Remove(name);
     }
     else
     {
         colorDictionary.Put(name, obj);
     }
 }
 public void Put(PdfName key, PdfObject value)
 {
     if (value == null || value.IsNull())
     {
         HashMap.Remove(key);
     }
     else
     {
         HashMap[key] = value;
     }
 }
        // methods concerning the Hashtable member value

        /**
         * Adds a <CODE>PdfObject</CODE> and its key to the <CODE>PdfDictionary</CODE>.
         * If the value is <CODE>null</CODE> or <CODE>PdfNull</CODE> the key is deleted.
         *
         * @param        key        key of the entry (a <CODE>PdfName</CODE>)
         * @param        value    value of the entry (a <CODE>PdfObject</CODE>)
         */
        virtual public void Put(PdfName key, PdfObject value)
        {
            if (key == null)
            {
                throw new ArgumentNullException(MessageLocalization.GetComposedMessage("key.is.null"));
            }
            if (value == null || value.IsNull())
            {
                hashMap.Remove(key);
            }
            else
            {
                hashMap[key] = value;
            }
        }
Exemple #4
0
 /**
 * Sets the default colorspace that will be applied to all the document.
 * The colorspace is only applied if another colorspace with the same name
 * is not present in the content.
 * <p>
 * The colorspace is applied immediately when creating templates and at the page
 * end for the main document content.
 * @param key the name of the colorspace. It can be <CODE>PdfName.DEFAULTGRAY</CODE>, <CODE>PdfName.DEFAULTRGB</CODE>
 * or <CODE>PdfName.DEFAULTCMYK</CODE>
 * @param cs the colorspace. A <CODE>null</CODE> or <CODE>PdfNull</CODE> removes any colorspace with the same name
 */    
 public void SetDefaultColorspace(PdfName key, PdfObject cs) {
     if (cs == null || cs.IsNull())
         defaultColorspace.Remove(key);
     defaultColorspace.Put(key, cs);
 }
Exemple #5
0
 internal void AddDefaultColor(PdfName name, PdfObject obj) {
     if (obj == null || obj.IsNull())
         colorDictionary.Remove(name);
     else
         colorDictionary.Put(name, obj);
 }
Exemple #6
0
 // methods concerning the Hashtable member value
 /**
  * Adds a <CODE>PdfObject</CODE> and its key to the <CODE>PdfDictionary</CODE>.
  * If the value is <CODE>null</CODE> or <CODE>PdfNull</CODE> the key is deleted.
  *
  * @param        key        key of the entry (a <CODE>PdfName</CODE>)
  * @param        value    value of the entry (a <CODE>PdfObject</CODE>)
  */
 public void Put(PdfName key, PdfObject value)
 {
     if (value == null || value.IsNull())
         hashMap.Remove(key);
     else
         hashMap[key] = value;
 }
Exemple #7
0
        public static bool CompareObjects(PdfObject value1, PdfObject value2) {
            value2 = GetDirectObject(value2);
            if (value2 == null)
                return false;
            if (value1.Type != value2.Type)
                return false;

            if (value1.IsBoolean()){
                if (value1 == value2)
                    return true;
                if (value2 is PdfBoolean) {
                    return ((PdfBoolean)value1).BooleanValue == ((PdfBoolean)value2).BooleanValue;
                }
                return false;
            } else if (value1.IsName()) {
                return value1.Equals(value2);
            } else if (value1.IsNumber()){
                if (value1 == value2)
                    return true;
                if (value2 is PdfNumber) {
                    return ((PdfNumber)value1).DoubleValue == ((PdfNumber)value2).DoubleValue;
                }
                return false;
            } else if (value1.IsNull()){
                if (value1 == value2)
                    return true;
                if (value2 is PdfNull)
                    return true;
                return false;
            } else if (value1.IsString()){
                if (value1 == value2)
                    return true;
                if (value2 is PdfString) {
                    return ((value2 == null && value1.ToString() == null)
                        || value1.ToString() == value2.ToString());
                }
                return false;
            }
            if (value1.IsArray()) {
                PdfArray array1 = (PdfArray)value1;
                PdfArray array2 = (PdfArray)value2;
                if (array1.Size != array2.Size)
                    return false;
                for (int i = 0; i < array1.Size; ++i)
                    if (!CompareObjects(array1[i],array2[i]))
                        return false;
                return true;
            }
            if (value1.IsDictionary()) {
                PdfDictionary first = (PdfDictionary)value1;
                PdfDictionary second = (PdfDictionary)value2;
                if (first.Size != second.Size)
                    return false;
                foreach (PdfName name in first.hashMap.Keys) {
                    if (!CompareObjects(first.Get(name),second.Get(name)))
                        return false;
                }
                return true;
            }
            return false;
        }
Exemple #8
0
        public static bool CompareObjects(PdfObject value1, PdfObject value2)
        {
            value2 = GetDirectObject(value2);
            if (value2 == null)
            {
                return(false);
            }
            if (value1.Type != value2.Type)
            {
                return(false);
            }

            if (value1.IsBoolean())
            {
                if (value1 == value2)
                {
                    return(true);
                }
                if (value2 is PdfBoolean)
                {
                    return(((PdfBoolean)value1).BooleanValue == ((PdfBoolean)value2).BooleanValue);
                }
                return(false);
            }
            else if (value1.IsName())
            {
                return(value1.Equals(value2));
            }
            else if (value1.IsNumber())
            {
                if (value1 == value2)
                {
                    return(true);
                }
                if (value2 is PdfNumber)
                {
                    return(((PdfNumber)value1).DoubleValue == ((PdfNumber)value2).DoubleValue);
                }
                return(false);
            }
            else if (value1.IsNull())
            {
                if (value1 == value2)
                {
                    return(true);
                }
                if (value2 is PdfNull)
                {
                    return(true);
                }
                return(false);
            }
            else if (value1.IsString())
            {
                if (value1 == value2)
                {
                    return(true);
                }
                if (value2 is PdfString)
                {
                    return((value2 == null && value1.ToString() == null) ||
                           value1.ToString() == value2.ToString());
                }
                return(false);
            }
            if (value1.IsArray())
            {
                PdfArray array1 = (PdfArray)value1;
                PdfArray array2 = (PdfArray)value2;
                if (array1.Size != array2.Size)
                {
                    return(false);
                }
                for (int i = 0; i < array1.Size; ++i)
                {
                    if (!CompareObjects(array1[i], array2[i]))
                    {
                        return(false);
                    }
                }
                return(true);
            }
            if (value1.IsDictionary())
            {
                PdfDictionary first  = (PdfDictionary)value1;
                PdfDictionary second = (PdfDictionary)value2;
                if (first.Size != second.Size)
                {
                    return(false);
                }
                foreach (PdfName name in first.hashMap.Keys)
                {
                    if (!CompareObjects(first.Get(name), second.Get(name)))
                    {
                        return(false);
                    }
                }
                return(true);
            }
            return(false);
        }
Exemple #9
0
 /**
 * Eliminates the reference to the object freeing the memory used by it and clearing
 * the xref entry.
 * @param obj the object. If it's an indirect reference it will be eliminated
 * @return the object or the already erased dereferenced object
 */    
 public static PdfObject KillIndirect(PdfObject obj) {
     if (obj == null || obj.IsNull())
         return null;
     PdfObject ret = GetPdfObjectRelease(obj);
     if (obj.IsIndirect()) {
         PRIndirectReference refi = (PRIndirectReference)obj;
         PdfReader reader = refi.Reader;
         int n = refi.Number;
         reader.xrefObj[n] = null;
         if (reader.partial)
             reader.xref[n * 2] = -1;
     }
     return ret;
 }
Exemple #10
0
 public override PdfIndirectObject AddToBody(PdfObject objecta, PdfIndirectReference refa, bool formBranching) {
     if (formBranching) {
         UpdateReferences(objecta);
     }
     PdfIndirectObject iobj;
     if ((tagged || mergeFields) && indirectObjects != null && (objecta.IsArray() || objecta.IsDictionary() || objecta.IsStream() || objecta.IsNull()))
     {
         RefKey key = new RefKey(refa);
         PdfIndirectObject obj;
         if (!indirectObjects.TryGetValue(key, out obj)) {
             obj = new PdfIndirectObject(refa, objecta, this);
             indirectObjects[key] = obj;
         }
         iobj = obj;
     } else {
         iobj = base.AddToBody(objecta, refa);
     }
     if (mergeFields && objecta.IsDictionary()) {
         PdfNumber annotId = ((PdfDictionary)objecta).GetAsNumber(PdfCopy.annotId);
         if (annotId != null) {
             if (formBranching) {
                 mergedMap[annotId.IntValue] = iobj;
                 mergedSet.Add(iobj);
             } else {
                 unmergedMap[annotId.IntValue] = iobj;
                 unmergedSet.Add(iobj);
             }
         }
     }
     return iobj;
 }