private void addPageText(PageObject page, TextObject text, BlockObject block, TextAttrObject attr, uint wExtraTagId, uint width, uint height) { // Add our TextObject m_Book.Objects.Add(text); // Refer the block to the text object block.ObjectLink = text.ID; ObjectInfoObject objInfo = new ObjectInfoObject(GetNextObjId()); objInfo.addLayoutTags(block.ID); if (wExtraTagId != 0x0) { objInfo.addLayoutTags(wExtraTagId); } m_Book.Objects.Add(objInfo); page.InfoObj = objInfo; // Now add out objects to the page page.Children.Add(attr); page.Children.Add(text); page.Children.Add(block); page.StreamTags.Add(new UInt32Tag(TagId.Link, block.ID)); }
private void createDefaultAttributeObjects(ushort width, ushort height) { // Root Object BookAttrObject bookAttr = new BookAttrObject(GetNextObjId()); bookAttr.createDefaultTags(); m_Book.Objects.Add(bookAttr); m_Book.Header.dwRootObjectId = bookAttr.ID; // Create an empty table of contents. m_TocObject = new TocObject(GetNextObjId()); m_Book.Objects.Add(m_TocObject); m_Book.Header.dwTocObjectId = m_TocObject.ID; m_MainBodyTextAttr = new TextAttrObject(GetNextObjId()); m_MainBodyTextAttr.createDefaultTags(BlockAlignment.Left); m_Book.Objects.Add(m_MainBodyTextAttr); m_CenteredTextAttr = new TextAttrObject(GetNextObjId()); m_CenteredTextAttr.createDefaultTags(BlockAlignment.Center); m_Book.Objects.Add(m_CenteredTextAttr); // Fill this one in later need id now for the BookAttrObject m_PageTree = new PageTreeObject(GetNextObjId()); m_Book.Objects.Add(m_PageTree); bookAttr.Tags.Add(new UInt32Tag(TagId.ChildPageTree, m_PageTree.ID)); m_PageAttr = new PageAttrObject(GetNextObjId()); m_PageAttr.createDefaultTags(); m_Book.Objects.Add(m_PageAttr); m_BlockAttr = new BlockAttrObject(GetNextObjId()); m_BlockAttr.createDefaultTags(width, height); m_Book.Objects.Add(m_BlockAttr); }
/// <summary> /// Create a new text block object. /// </summary> /// <param name="page">The page to put the new text block into</param> /// <param name="text">The text object to place in the new block</param> /// <param name="attr">The text attributes.</param> /// <returns>The newly created text block.</returns> private BlockObject createTextBlock(PageObject page, TextObject text, TextAttrObject attr) { // Create a block Object BlockObject block = new BlockObject(GetNextObjId()); block.BlockLink = m_BlockAttr.ID; m_Book.Objects.Add(block); addPageText(page, text, block, attr, 0x0, BBeB.ReaderPageWidth, BBeB.ReaderPageHeight); // Now that we've created the text block we can associate // it with the HTML DOM Node that created it. We need this // association for TOC creation. if (m_TextObjectIdHeadingNode.ContainsKey(text.ID)) { IHTMLDOMNode node = m_TextObjectIdHeadingNode[text.ID]; m_HeadingNodeTextBlockId[node] = block.ID; } return(block); }
/// <summary> /// If the TextBlockBuilder has any text then create a new text block and text object - /// adding it to the page. If not then do nothing /// </summary> /// <param name="page"></param> /// <param name="tbBuilder"></param> /// <param name="attr"></param> /// <returns>The new text block object, or null if there was no text.</returns> private BlockObject FlushTextToBlock(PageObject page, TextBlockBuilder tbBuilder, TextAttrObject attr) { if (tbBuilder.HasText) { TextObject text = tbBuilder.CreateTextObject(attr.ID); BlockObject block = createTextBlock(page, text, attr); if (m_StartReadingBlock == null) { m_StartReadingBlock = block; m_StartReadingPage = page; } return(block); } else { return(null); } }