public void AddSubNavPoint(IBaseXHTMLFile subcontent, string name) { if (subcontent.NavigationParent == null) { throw new ArgumentException(@"Can't add subpoint without a parent","subcontent"); } var newPoint = new NavPointV3 { Content = subcontent.PathInEPUB.GetRelativePath(NAVFilePath, subcontent.FlatStructure), Name = name, Id = subcontent.Id }; var parentPoint = _documentNavigationMap.Find(x => (x.Id == subcontent.NavigationParent.Id)); if (parentPoint != null) { parentPoint.SubPoints.Add(newPoint); } else { // iterate all top level content foreach (var element in _documentNavigationMap) { // here "AllContent) will return all the sub elements (any depth) of given top level element // so we look for parent in all this elements parentPoint = element.AllContent().Find(x => (x.Id == subcontent.NavigationParent.Id)); if (parentPoint != null) { parentPoint.SubPoints.Add(newPoint); return; } } throw new Exception("no such point to add sub point"); } }
private RegistrationNode GenerateNewRegistration(IBaseXHTMLFile section) { List <long> idLevels = new List <long>(); long ownCount; if (section.NavigationParent != null) { if (!_sectionMapping.ContainsKey(section.NavigationParent)) { throw new ArgumentException("Section to add has a parent, but parent not added, add parent first"); } _sectionMapping[section.NavigationParent].ChildrenCount++; // increase number of children ownCount = _sectionMapping[section.NavigationParent].ChildrenCount; idLevels.AddRange(_sectionMapping[section.NavigationParent].IdLevels); } else { ownCount = _topLevelCounter++; } idLevels.Add(ownCount); return(new RegistrationNode(idLevels) { ChildrenCount = 0 }); }
public void AddXHTMLTextItem(IBaseXHTMLFile baseXhtmlFile) { var bookItem = new ManifestItemV3 { HRef = baseXhtmlFile.HRef, ID = baseXhtmlFile.Id, MediaType = EPubCoreMediaType.ApplicationXhtmlXml }; _manifest.Add(bookItem); if (baseXhtmlFile.GuideRole != GuideTypeEnum.Ignore) // we do not add objects that to be ignored { var bookSpine = new SpineItemV3 { Name = baseXhtmlFile.Id }; if (V3StandardChecker.IsRenditionFlowAllowedByStandard(_standard)) { bookSpine.Flow = SpineItemV3.FlowOptions.Auto; //TODO: make this optional, based on settings to define look and find best properties for defaults } _spine.Add(bookSpine); } _guide.AddDocumentToNavigation(baseXhtmlFile); }
private void AddBookContentSection(IBaseXHTMLFile subsection) { subsection.Id = _sectionIDTracker.GenerateSectionId(subsection); _content.AddXHTMLTextItem(subsection); _navigationManager.AddBookSubsection(subsection, _commonSettings.TransliterateToc? Rus2Lat.Instance.Translate(subsection.PageTitle, _translitMode):subsection.PageTitle); }
public void AddSubNavPoint(IBaseXHTMLFile subcontent, string name) { var newPoint = new NavPoint { Content = subcontent.PathInEPUB.GetRelativePath(DefaultInternalPaths.TOCFilePath, subcontent.FlatStructure), Name = name }; var parentPoint = _navMap.Find(x => (x.Content == subcontent.NavigationParent.PathInEPUB.GetRelativePath(DefaultInternalPaths.TOCFilePath, subcontent.NavigationParent.FlatStructure))); if (parentPoint != null) { parentPoint.SubPoints.Add(newPoint); } else { foreach (var element in _navMap) { parentPoint = element.AllContent().Find(x => (x.Content == subcontent.NavigationParent.PathInEPUB.GetRelativePath(DefaultInternalPaths.TOCFilePath, subcontent.NavigationParent.FlatStructure))); if (parentPoint != null) { parentPoint.SubPoints.Add(newPoint); return; } } throw new Exception("no such point to add sub point"); } }
public void AddSubNavPoint(IBaseXHTMLFile subcontent, string name) { if (subcontent.NavigationParent == null) { throw new ArgumentException(@"Can't add subpoint without a parent", "subcontent"); } var newPoint = new NavPointV3 { Content = subcontent.PathInEPUB.GetRelativePath(NAVFilePath, subcontent.FlatStructure), Name = name, Id = subcontent.Id }; var parentPoint = _documentNavigationMap.Find(x => (x.Id == subcontent.NavigationParent.Id)); if (parentPoint != null) { parentPoint.SubPoints.Add(newPoint); } else { // iterate all top level content foreach (var element in _documentNavigationMap) { // here "AllContent) will return all the sub elements (any depth) of given top level element // so we look for parent in all this elements parentPoint = element.AllContent().Find(x => (x.Id == subcontent.NavigationParent.Id)); if (parentPoint != null) { parentPoint.SubPoints.Add(newPoint); return; } } throw new Exception("no such point to add sub point"); } }
public string GenerateSectionId(IBaseXHTMLFile section) { if (!_sectionMapping.ContainsKey(section)) { _sectionMapping.Add(section, GenerateNewRegistration(section)); } return(_sectionMapping[section].ID); }
public string GenerateSectionId(IBaseXHTMLFile section) { if (!_sectionMapping.ContainsKey(section)) { _sectionMapping.Add(section,GenerateNewRegistration(section)); } return _sectionMapping[section].ID; }
public void AddNavPoint(IBaseXHTMLFile content, string name) { var bookPoint = new NavPoint { Content = content.PathInEPUB.GetRelativePath(DefaultInternalPaths.TOCFilePath, content.FlatStructure), Name = name }; _navMap.Add(bookPoint); }
public void AddXHTMLFile(IBaseXHTMLFile file) { file.StyleFiles.Add(_mainCss); if (_v2Settings.EnableAdobeTemplate) { file.StyleFiles.Add(_adobeTemplate); } _sections.Add(file); }
public void AddBookSubsection(IBaseXHTMLFile subsection, string name) { if (!subsection.NotPartOfNavigation) { if (subsection.NavigationLevel <= 1) { _tableOfContentFile.AddNavPoint(subsection, name); } else { _tableOfContentFile.AddSubNavPoint(subsection, name); } } }
public void AddTOCNavPoint(IBaseXHTMLFile content, string name) { if (string.IsNullOrEmpty(name)) { return; } var bookPoint = new NavPointV3 { Content = content.PathInEPUB.GetRelativePath(NAVFilePath, content.FlatStructure), Name = name, Id = content.Id }; _documentNavigationMap.Add(bookPoint); }
public void AddXHTMLTextItem(IBaseXHTMLFile baseXhtmlFile) { var bookItem = new ManifestItemV2 { HRef = baseXhtmlFile.HRef, ID = baseXhtmlFile.Id, MediaType = EPubCoreMediaType.ApplicationXhtmlXml }; _manifest.Add(bookItem); if (baseXhtmlFile.GuideRole != GuideTypeEnum.Ignore) // we do not add objects that to be ignored { var bookSpine = new SpineItemV2 { Name = baseXhtmlFile.Id }; _spine.Add(bookSpine); } _guide.AddDocumentToNavigation(baseXhtmlFile); }
private int SplitAndAddSubSections(ZipOutputStream stream, IBaseXHTMLFile section, int count) { int newCount = count; XDocument document = section.Generate(); ulong docSize = document.EstimateSize(); if (docSize >= section.MaxSize) { // This case is not for converter // after converter the files should be in right size already int subCount = 0; var baseXHTMLFileV3 = section as BaseXHTMLFileV3; if (baseXHTMLFileV3 == null) { throw new ArgumentException("The section passed has to be BaseXHTMLFileV3"); } foreach (var subsection in baseXHTMLFileV3.Split()) { subsection.FlatStructure = _commonSettings.FlatStructure; subsection.EmbedStyles = _commonSettings.EmbedStyles; subsection.FileName = string.Format("{0}_{1}.xhtml", Path.GetFileNameWithoutExtension(section.FileName), subCount); CreateFileEntryInZip(stream, subsection); subsection.Write(stream); AddBookContentSection(subsection); subCount++; } newCount++; } else { CreateFileEntryInZip(stream, section); section.Write(stream); AddBookContentSection(section); newCount++; } return(newCount); }
private RegistrationNode GenerateNewRegistration(IBaseXHTMLFile section) { List<long> idLevels = new List<long>(); long ownCount; if (section.NavigationParent != null) { if (!_sectionMapping.ContainsKey(section.NavigationParent)) { throw new ArgumentException("Section to add has a parent, but parent not added, add parent first"); } _sectionMapping[section.NavigationParent].ChildrenCount++; // increase number of children ownCount = _sectionMapping[section.NavigationParent].ChildrenCount; idLevels.AddRange(_sectionMapping[section.NavigationParent].IdLevels); } else { ownCount = _topLevelCounter++; } idLevels.Add(ownCount); return new RegistrationNode(idLevels) {ChildrenCount = 0}; }
private void PutPageToFile(ZipOutputStream stream, IBaseXHTMLFile xhtmlFile) { xhtmlFile.FlatStructure = _commonSettings.FlatStructure; xhtmlFile.EmbedStyles = _commonSettings.EmbedStyles; xhtmlFile.StyleFiles.Add(_mainCss); if (_v2Settings.EnableAdobeTemplate) { xhtmlFile.StyleFiles.Add(_adobeTemplate); } xhtmlFile.Write(stream); }
/// <summary> /// Add new document to be a part of navigation /// </summary> /// <param name="baseXhtmlFile"></param> public void AddDocumentToNavigation(IBaseXHTMLFile baseXhtmlFile) { AddGuideItem(baseXhtmlFile.HRef, baseXhtmlFile.Id, baseXhtmlFile.GuideRole); }
///// <summary> ///// Assign image (by id) to be cover image ///// </summary> ///// <param name="imageRef">image reference name</param> //public void AddCoverImage(string imageRef) //{ // _coverImage = imageRef; //} public void AddXHTMLFile(IBaseXHTMLFile file) { file.StyleFiles.Add(_mainCss); _sections.Add(file); }
public void AddXHTMLTextItem(IBaseXHTMLFile baseXhtmlFile) { var bookItem = new ManifestItemV2 { HRef = baseXhtmlFile.HRef, ID = baseXhtmlFile.Id, MediaType = EPubCoreMediaType.ApplicationXhtmlXml }; _manifest.Add(bookItem); if (baseXhtmlFile.GuideRole != GuideTypeEnum.Ignore) // we do not add objects that to be ignored { var bookSpine = new SpineItemV2 {Name = baseXhtmlFile.Id}; _spine.Add(bookSpine); } _guide.AddDocumentToNavigation(baseXhtmlFile); }
public void AddXHTMLFile(IBaseXHTMLFile file) { file.StyleFiles.Add(_mainCss); _sections.Add(file); }
private int SplitAndAddSubSections(ZipOutputStream stream, IBaseXHTMLFile section, int count) { int newCount = count; XDocument document = section.Generate(); ulong docSize = document.EstimateSize(); if (docSize >= section.MaxSize) { // This case is not for converter // after converter the files should be in right size already int subCount = 0; var baseXHTMLFileV2 = section as BaseXHTMLFileV2; if (baseXHTMLFileV2 == null) { throw new ArgumentException("The section passed has to be BaseXHTMLFileV2"); } foreach (var subsection in baseXHTMLFileV2.Split()) { subsection.FlatStructure = _commonSettings.FlatStructure; subsection.EmbedStyles = _commonSettings.EmbedStyles; subsection.FileName = string.Format("{0}_{1}.xhtml", Path.GetFileNameWithoutExtension(section.FileName), subCount); CreateFileEntryInZip(stream, subsection); subsection.Write(stream); AddBookContentSection(subsection); subCount++; } newCount++; } else { CreateFileEntryInZip(stream, section); section.Write(stream); AddBookContentSection(section); newCount++; } return newCount; }
public void AddTOCNavPoint(IBaseXHTMLFile content, string name) { if (string.IsNullOrEmpty(name)) { return; } var bookPoint = new NavPointV3 { Content = content.PathInEPUB.GetRelativePath(NAVFilePath, content.FlatStructure), Name = name, Id = content.Id}; _documentNavigationMap.Add(bookPoint); }