Exemple #1
0
        /// <summary>
        /// Returns a deep copy of this object.
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            TBookmark Result = (TBookmark)MemberwiseClone();

            if (FDestination != null)
            {
                Result.FDestination = (TPdfDestination)FDestination.Clone();
            }
            Result.FChildren = (TBookmarkList)FChildren.Clone();
            return(Result);
        }
Exemple #2
0
 /// <summary>
 /// Adds a new child of this bookmark on the outline.
 /// </summary>
 /// <param name="child">Child bookmark to add.</param>
 public void AddChild(TBookmark child)
 {
     FChildren.Add(child);
 }
Exemple #3
0
        internal void SaveBookmarkObjects(TPdfStream DataStream, TXRefSection XRef, TBookmarkList bmks, int ParentId, int ObjectId, ref int FirstId, ref int LastId, ref int AllOpenCount)
        {
            int PreviousId = -1;

            for (int i = 0; i < bmks.Count; i++)
            {
                TBookmark b = bmks[i];
                AllOpenCount++;

                int NextId = -1;
                if (i < bmks.Count - 1)
                {
                    NextId = XRef.GetNewObject(DataStream);
                }
                LastId = ObjectId;
                if (FirstId == -1)
                {
                    FirstId = ObjectId;
                }

                int FirstChildId   = -1;
                int LastChildId    = -1;
                int ChildOpenCount = 0;
                if (b.FChildren.Count > 0)
                {
                    FirstChildId = XRef.GetNewObject(DataStream);
                    int ChildLastId = -1;
                    SaveBookmarkObjects(DataStream, XRef, b.FChildren, ObjectId, FirstChildId, ref FirstId, ref ChildLastId, ref ChildOpenCount);
                    if (!b.ChildrenCollapsed)
                    {
                        AllOpenCount += ChildOpenCount;
                    }
                    LastChildId = ChildLastId;
                }


                XRef.SetObjectOffset(ObjectId, DataStream);
                TIndirectRecord.SaveHeader(DataStream, ObjectId);
                TDictionaryRecord.BeginDictionary(DataStream);
                TDictionaryRecord.SaveUnicodeKey(DataStream, TPdfToken.TitleName, b.Title);
                TDictionaryRecord.SaveKey(DataStream, TPdfToken.ParentName, TIndirectRecord.GetCallObj(ParentId));
                if (PreviousId >= 0)
                {
                    TDictionaryRecord.SaveKey(DataStream, TPdfToken.PrevName, TIndirectRecord.GetCallObj(PreviousId));
                }

                if (NextId >= 0)
                {
                    TDictionaryRecord.SaveKey(DataStream, TPdfToken.NextName, TIndirectRecord.GetCallObj(NextId));
                }

                if (FirstChildId >= 0)
                {
                    TDictionaryRecord.SaveKey(DataStream, TPdfToken.FirstName, TIndirectRecord.GetCallObj(FirstChildId));
                }

                if (LastChildId >= 0)
                {
                    TDictionaryRecord.SaveKey(DataStream, TPdfToken.LastName, TIndirectRecord.GetCallObj(LastChildId));
                }
                if (ChildOpenCount > 0)
                {
                    if (b.ChildrenCollapsed)
                    {
                        TDictionaryRecord.SaveKey(DataStream, TPdfToken.CountName, -ChildOpenCount);
                    }
                    else
                    {
                        TDictionaryRecord.SaveKey(DataStream, TPdfToken.CountName, ChildOpenCount);
                    }
                }


                if (b.Destination != null)
                {
                    TDictionaryRecord.SaveKey(DataStream, TPdfToken.DestName, GetDestStr(b.Destination));
                }

                if (b.TextColor.R != 0 || b.TextColor.G != 0 || b.TextColor.B != 0)
                {
                    TDictionaryRecord.SaveKey(DataStream, TPdfToken.CName, TPdfTokens.GetString(TPdfToken.OpenArray) + PdfConv.ToString(b.TextColor) + TPdfTokens.GetString(TPdfToken.CloseArray));
                }

                if (b.TextStyle != TBookmarkStyle.None)
                {
                    int k = 0;
                    if ((b.TextStyle & TBookmarkStyle.Italic) != 0)
                    {
                        k |= 1;
                    }
                    if ((b.TextStyle & TBookmarkStyle.Bold) != 0)
                    {
                        k |= 2;
                    }
                    TDictionaryRecord.SaveKey(DataStream, TPdfToken.FName, k);
                }

                TDictionaryRecord.EndDictionary(DataStream);
                TIndirectRecord.SaveTrailer(DataStream);

                PreviousId = ObjectId;
                ObjectId   = NextId;
            }
        }