Beispiel #1
0
        /// <summary>
        /// Check whether a resource name is already used in the context of this resource dictionary.
        /// PDF4NET uses GUIDs as resource names, but I think this weapon is to heavy.
        /// </summary>
        internal bool ExistsResourceNames(string name)
        {
            // TODO: more precise: is this page imported and is PageOptions != Replace
            // BUG:
            //if (!Owner.IsImported)
            //  return false;

            // Collect all resouce names of all imported resources.
            if (_importedResourceNames == null)
            {
                _importedResourceNames = new Dictionary <string, object>();

                if (Elements[Keys.Font] != null)
                {
                    Fonts.CollectResourceNames(_importedResourceNames);
                }

                if (Elements[Keys.XObject] != null)
                {
                    XObjects.CollectResourceNames(_importedResourceNames);
                }

                if (Elements[Keys.ExtGState] != null)
                {
                    ExtGStates.CollectResourceNames(_importedResourceNames);
                }

                if (Elements[Keys.ColorSpace] != null)
                {
                    ColorSpaces.CollectResourceNames(_importedResourceNames);
                }

                if (Elements[Keys.Pattern] != null)
                {
                    Patterns.CollectResourceNames(_importedResourceNames);
                }

                if (Elements[Keys.Shading] != null)
                {
                    Shadings.CollectResourceNames(_importedResourceNames);
                }

                if (Elements[Keys.Properties] != null)
                {
                    Properties.CollectResourceNames(_importedResourceNames);
                }
            }
            return(_importedResourceNames.ContainsKey(name));
            // This is superfluous because PDFsharp resource names cannot be double.
            // importedResourceNames.Add(name, null);
        }