Bloom.Book.Layout.UpdatePageSplitMode C# (CSharp) Method

UpdatePageSplitMode() public method

public UpdatePageSplitMode ( XmlNode node ) : void
node System.Xml.XmlNode
return void
        public void UpdatePageSplitMode(XmlNode node)
        {
            //NB: this can currently only split pages, not move them together. Doable, just not called for by the UI or unit tested yet.

            if (ElementDistribution == ElementDistributionChoices.CombinedPages)
                return;

            var combinedPages = node.SafeSelectNodes("descendant-or-self::div[contains(@class,'bloom-combinedPage')]");
            foreach (XmlElement pageDiv in combinedPages)
            {
                XmlElement trailer = (XmlElement) pageDiv.CloneNode(true);
                pageDiv.ParentNode.InsertAfter(trailer, pageDiv);

                pageDiv.SetAttribute("class", pageDiv.GetAttribute("class").Replace("bloom-combinedPage", "bloom-leadingPage"));
                var leader = pageDiv;
                trailer.SetAttribute("class", trailer.GetAttribute("class").Replace("bloom-combinedPage", "bloom-trailingPage"));

                //give all new ids to both pages

                leader.SetAttribute("id", Guid.NewGuid().ToString());
                trailer.SetAttribute("id", Guid.NewGuid().ToString());

                //now split the elements

                leader.DeleteNodes("descendant-or-self::*[contains(@class, 'bloom-trailingElement')]");
                trailer.DeleteNodes("descendant-or-self::*[contains(@class, 'bloom-leadingElement')]");
            }
        }

Usage Example

Example #1
0
        public void UpdatePageSplitMode_WasCombined_IndividualPagesHaveOwnIds()
        {
            var dom = new XmlDocument();
            dom.LoadXml(@"<html ><body><div id='foo'></div><div id='1' class='bloom-page A5Landscape bloom-combinedPage'></div></body></html>");
            var layout = new Layout() { ElementDistribution = Layout.ElementDistributionChoices.SplitAcrossPages };
            layout.UpdatePageSplitMode(dom);

            AssertThatXmlIn.Dom(dom).HasSpecifiedNumberOfMatchesForXpath("//div[@id=1]", 0);
        }
All Usage Examples Of Bloom.Book.Layout::UpdatePageSplitMode