AddStyleSheetIfMissing() public méthode

public AddStyleSheetIfMissing ( string path ) : void
path string
Résultat void
Exemple #1
0
        public static void AddStylesheetFromAnotherBook(HtmlDom sourceBookDom, HtmlDom targetBookDom)
        {
            var addedModifiedStyleSheets = new List<string>();
            //This was refactored from book, where there was these notes:
            //     NB: at this point this code can't handle the "userModifiedStyles" from children, it'll ignore them (they would conflict with each other)
            //     NB: at this point custom styles (e.g. larger/smaller font rules) from children will be lost.

            //At this point, this addedModifiedStyleSheets is just used as a place to track which stylesheets we already have
            foreach(string sheetName in sourceBookDom.GetTemplateStyleSheets())
            {
                if(!addedModifiedStyleSheets.Contains(sheetName))
                    //nb: if two books have stylesheets with the same name, we'll only be grabbing the 1st one.
                {
                    addedModifiedStyleSheets.Add(sheetName);
                    targetBookDom.AddStyleSheetIfMissing(sheetName);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// used when this book is a "master"/"folio" book that is used to bring together a number of other books in the collection
        /// </summary>
        /// <param name="printingDom"></param>
        /// <param name="currentBookCollection"></param>
        /// <param name="bookServer"></param>
        private void AddChildBookContentsToFolio(HtmlDom printingDom, BookCollection currentBookCollection, BookServer bookServer)
        {
            XmlNode currentLastContentPage = GetLastPageForInsertingNewContent(printingDom);

            //currently we have no way of filtering them, we just take them all
            foreach (var bookInfo in currentBookCollection.GetBookInfos())
            {
                if (bookInfo.IsFolio)
                    continue;
                var childBook =bookServer.GetBookFromBookInfo(bookInfo);

                //add links to the template css needed by the children.
                //NB: at this point this code can't hand the "customBookStyles" from children, it'll ignore them (they woul conflict with each other)
                //NB: at this point custom styles (e.g. larger/smaller font rules) from children will be lost.
                var customStyleSheets = new List<string>();
                foreach (string sheetName in childBook.OurHtmlDom.GetTemplateStyleSheets())
                {
                    if (!customStyleSheets.Contains(sheetName)) //nb: if two books have stylesheets with the same name, we'll only be grabbing the 1st one.
                    {
                        customStyleSheets.Add(sheetName);
                        printingDom.AddStyleSheetIfMissing("file://"+Path.Combine(childBook.FolderPath,sheetName));
                    }
                }
                printingDom.SortStyleSheetLinks();

                foreach (XmlElement pageDiv in childBook.OurHtmlDom.RawDom.SafeSelectNodes("/html/body/div[contains(@class, 'bloom-page') and not(contains(@class,'bloom-frontMatter')) and not(contains(@class,'bloom-backMatter'))]"))
                {
                    XmlElement importedPage = (XmlElement) printingDom.RawDom.ImportNode(pageDiv, true);
                    currentLastContentPage.ParentNode.InsertAfter(importedPage, currentLastContentPage);
                    currentLastContentPage = importedPage;

                    ImageUpdater.MakeImagePathsOfImportedPagePointToOriginalLocations(importedPage, bookInfo.FolderPath);
                }
            }
        }