Esempio n. 1
0
        private void finalizeBook()
        {
            byte[] pageNumberData = new byte[(6 * m_nPageCount) + 4];
            byte[] bookPagesList  = new byte[(4 * m_nPageCount) + 2];
            pageNumberData[0] = bookPagesList[0] = (byte)(m_nPageCount & 0x00ff);
            pageNumberData[1] = bookPagesList[1] = (byte)((m_nPageCount >> 8) & 0x00ff);

            int pnIndex = 4;
            int bpIndex = 2;

            for (int i = 0; i < m_Book.Objects.Count; i++)
            {
                BBeBObject subFile = m_Book.Objects[i];
                if (subFile.Type == ObjectType.Page)
                {
                    pageNumberData[pnIndex]     = bookPagesList[bpIndex] = (byte)(subFile.ID & 0x00ff);
                    pageNumberData[pnIndex + 1] = bookPagesList[bpIndex + 1] = (byte)((subFile.ID >> 8) & 0x00ff);

                    // Set to say 1 page per page (a kludge for now)
                    pageNumberData[pnIndex + 4] = 1;
                    pageNumberData[pnIndex + 5] = 0;

                    pnIndex += 6;
                    bpIndex += 4;
                }
            }

            ObjectInfoObject objInfo = new ObjectInfoObject(GetNextObjId());

            objInfo.addPageNumbersTags(pageNumberData);
            m_Book.Objects.Add(objInfo);

            m_PageTree.setObjectInfoLink(objInfo.ID);
            m_PageTree.Tags.Add(new ByteArrayTag(TagId.PageList, bookPagesList));
        }
Esempio n. 2
0
        private void ConnectPage(PageObject page, BBeB book)
        {
            Debug.WriteLineIf(s_bDebugMode, "Connecting page: " + page.ID);

            UInt32ArrayTag childIDs = (UInt32ArrayTag)page.FindFirstTag(TagId.PageObjectIds);

            if (childIDs != null)
            {
                foreach (uint id in childIDs.Value)
                {
                    BBeBObject child = book.FindObject((ushort)id);
                    if (child == null)
                    {
                        throw new InvalidBookException("Can't find object id " + id);
                    }

                    Debug.Assert(child.ID == id);

                    Debug.WriteLineIf(s_bDebugMode, "   Child: " + child.GetType().ToString() + " - id:" + child.ID);
                    page.Children.Add(child);
                }
            }

            UInt32Tag objInfoTag = (UInt32Tag)page.FindFirstTag(TagId.ObjectInfoLink);

            if (objInfoTag != null)
            {
                page.InfoObj = book.FindObject((ushort)objInfoTag.Value);
                if (page.InfoObj == null)
                {
                    throw new InvalidBookException("Can't find info object id " + objInfoTag.Value);
                }
            }

            StreamTagGroup stream = (StreamTagGroup)page.FindFirstTag(TagId.StreamGroup);

            if (stream != null)
            {
                BBeBObject tempObj = new BBeBObject(0x0);

                page.StreamTags = BBeBTagFactory.ParseAllTags(tempObj, stream.Data);
            }

            UInt32Tag linkTag = (UInt32Tag)page.FindFirstTag(TagId.Link);

            if (linkTag != null)
            {
                BBeBObject linkedObj = book.FindObject((ushort)linkTag.Value);
                if (linkedObj == null)
                {
                    throw new InvalidBookException("Can't find object id " + linkTag.Value);
                }
                page.LinkObj = linkedObj;
            }
        }
Esempio n. 3
0
        private void SerializeObject(BBeBObject obj, BBeBinaryWriter writer)
        {
            writer.WriteObjectStart(obj);

            writer.Write((ushort)obj.ID);
            writer.Write((ushort)0x0);                  // All objects have this

            // Write object type
            writer.Write((ushort)obj.Type);

            SerializeTags(obj.Tags, writer);

            writer.WriteObjectEnd(obj);
        }
Esempio n. 4
0
        private void ConnectText(TextObject text, BBeB book)
        {
            UInt32Tag linkTag = (UInt32Tag)text.FindFirstTag(TagId.Link);

            if (linkTag == null)
            {
                throw new InvalidBookException("Can't find link for block " + text.ID);
            }

            BBeBObject LinkObj = book.FindObject((ushort)linkTag.Value);

            if (LinkObj == null)
            {
                throw new InvalidBookException("Can't find object id " + linkTag.Value);
            }
        }