HasAttributes() public method

Checks the attributes of this Chunk.
public HasAttributes ( ) : bool
return bool
Exemplo n.º 1
0
        /// <summary>
        /// Adds a Chunk.
        /// </summary>
        /// <remarks>
        /// This method is a hack to solve a problem I had with phrases that were split between chunks
        /// in the wrong place.
        /// </remarks>
        /// <param name="chunk">a Chunk</param>
        /// <returns>a bool</returns>
        virtual protected bool AddChunk(Chunk chunk)
        {
            Font   f = chunk.Font;
            String c = chunk.Content;

            if (font != null && !font.IsStandardFont())
            {
                f = font.Difference(chunk.Font);
            }
            if (Count > 0 && !chunk.HasAttributes())
            {
                try {
                    Chunk   previous     = (Chunk)this[Count - 1];
                    PdfName previousRole = previous.Role;
                    PdfName chunkRole    = chunk.Role;
                    Boolean sameRole;
                    if (previousRole == null || chunkRole == null)
                    {
                        //Set the value to true if either are null since the overwriting of the role will not matter
                        sameRole = true;
                    }
                    else
                    {
                        sameRole = previousRole.Equals(chunkRole);
                    }
                    if (sameRole && !previous.HasAttributes() && !chunk.HasAccessibleAttributes() && !previous.HasAccessibleAttributes() &&
                        (f == null ||
                         f.CompareTo(previous.Font) == 0) &&
                        previous.Font.CompareTo(f) == 0 &&
                        !"".Equals(previous.Content.Trim()) &&
                        !"".Equals(c.Trim()))
                    {
                        previous.Append(c);
                        return(true);
                    }
                }
                catch {
                }
            }
            Chunk newChunk = new Chunk(c, f);

            newChunk.Attributes           = chunk.Attributes;
            newChunk.role                 = chunk.Role;
            newChunk.accessibleAttributes = chunk.GetAccessibleAttributes();
            if (hyphenation != null && newChunk.GetHyphenation() == null && !newChunk.IsEmpty())
            {
                newChunk.SetHyphenation(hyphenation);
            }
            base.Add(newChunk);
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds a Chunk.
        /// </summary>
        /// <remarks>
        /// This method is a hack to solve a problem I had with phrases that were split between chunks
        /// in the wrong place.
        /// </remarks>
        /// <param name="chunk">a Chunk</param>
        /// <returns>a bool</returns>
        virtual protected bool AddChunk(Chunk chunk)
        {
            Font   f = chunk.Font;
            String c = chunk.Content;

            if (font != null && !font.IsStandardFont())
            {
                f = font.Difference(chunk.Font);
            }
            if (Count > 0 && !chunk.HasAttributes())
            {
                try {
                    Chunk previous = (Chunk)this[Count - 1];
                    if (!previous.HasAttributes() && !chunk.HasAccessibleAttributes() &&
                        (f == null ||
                         f.CompareTo(previous.Font) == 0) &&
                        previous.Font.CompareTo(f) == 0 &&
                        !"".Equals(previous.Content.Trim()) &&
                        !"".Equals(c.Trim()))
                    {
                        previous.Append(c);
                        return(true);
                    }
                }
                catch {
                }
            }
            Chunk newChunk = new Chunk(c, f);

            newChunk.Attributes           = chunk.Attributes;
            newChunk.role                 = chunk.Role;
            newChunk.accessibleAttributes = chunk.GetAccessibleAttributes();
            if (hyphenation != null && newChunk.GetHyphenation() == null && !newChunk.IsEmpty())
            {
                newChunk.SetHyphenation(hyphenation);
            }
            base.Add(newChunk);
            return(true);
        }
Exemplo n.º 3
0
 private bool AddChunk(Chunk chunk)
 {
     if (!font.IsStandardFont())
     {
         chunk.Font = font.Difference(chunk.Font);
     }
     if (Count > 0 && !chunk.HasAttributes())
     {
         try {
             Chunk previous = (Chunk)this[Count - 1];
             if (!previous.HasAttributes() && previous.Font.CompareTo(chunk.Font) == 0 && !"".Equals(previous.Content.Trim()) && !"".Equals(chunk.Content.Trim()))
             {
                 previous.Append(chunk.Content);
                 return(true);
             }
         }
         catch {
         }
     }
     base.Add(chunk);
     return(true);
 }
Exemplo n.º 4
0
     /// <summary>
     /// Adds a Chunk.
     /// </summary>
     /// <remarks>
     /// This method is a hack to solve a problem I had with phrases that were split between chunks
     /// in the wrong place.
     /// </remarks>
     /// <param name="chunk">a Chunk</param>
     /// <returns>a bool</returns>
     protected bool AddChunk(Chunk chunk) {
 	    Font f = chunk.Font;
 	    String c = chunk.Content;
         if (font != null && !font.IsStandardFont()) {
             f = font.Difference(chunk.Font);
         }
         if (Count > 0 && !chunk.HasAttributes()) {
             try {
                 Chunk previous = (Chunk) this[Count - 1];
                 if (!previous.HasAttributes()
                         && (f == null
                         || f.CompareTo(previous.Font) == 0)
                         && previous.Font.CompareTo(f) == 0
                         && !"".Equals(previous.Content.Trim())
                         && !"".Equals(c.Trim())) {
                     previous.Append(c);
                     return true;
                 }
             }
             catch {
             }
         }
         Chunk newChunk = new Chunk(c, f);
         newChunk.Attributes = chunk.Attributes;
         if (hyphenation != null && newChunk.GetHyphenation() == null && !newChunk.IsEmpty()) {
             newChunk.SetHyphenation(hyphenation);
         }
         base.Add(newChunk);
         return true;
     }
Exemplo n.º 5
0
 private bool AddChunk(Chunk chunk)
 {
     if (!font.IsStandardFont()) {
         chunk.Font = font.Difference(chunk.Font);
     }
     if (Count > 0 && !chunk.HasAttributes()) {
         try {
             Chunk previous = (Chunk) this[Count - 1];
             if (!previous.HasAttributes() && previous.Font.CompareTo(chunk.Font) == 0 && !"".Equals(previous.Content.Trim()) && !"".Equals(chunk.Content.Trim())) {
                 previous.Append(chunk.Content);
                 return true;
             }
         }
         catch {
         }
     }
     base.Add(chunk);
     return true;
 }