Esempio n. 1
0
 public void RemapAnchors(EPubFileV2 epubFile)
 {
     foreach (var link in _references)
     {
         if (!ReferencesUtils.IsExternalLink(link.Key))
         {
             string          idString   = ReferencesUtils.GetIdFromLink(link.Key);
             BaseXHTMLFileV2 iDDocument = GetIDParentDocument(epubFile, _ids[idString]);
             if (iDDocument != null)
             {
                 int count = 0;
                 foreach (var anchor in link.Value)
                 {
                     BaseXHTMLFileV2 idDocument     = GetIDParentDocument(epubFile, anchor);
                     var             referencedItem = _ids[(string)anchor.HRef.Value];
                     var             newParent      = DetectParentContainer(referencedItem);
                     if (newParent == null)
                     {
                         continue;
                     }
                     var newAnchor = new Anchor(newParent.HTMLStandard);
                     if (idDocument == iDDocument)
                     {
                         anchor.HRef.Value    = string.Format("#{0}", idString);
                         newAnchor.HRef.Value = string.Format("#{0}", anchor.GlobalAttributes.ID.Value);
                     }
                     else
                     {
                         anchor.HRef.Value = string.Format("{0}#{1}", iDDocument.FileName, idString);
                         if (idDocument == null)
                         {
                             continue;
                         }
                         newAnchor.HRef.Value = string.Format("{0}#{1}", idDocument.FileName, anchor.GlobalAttributes.ID.Value);
                     }
                     if (iDDocument.Type == SectionTypeEnum.Links)  // if it's FBE notes section
                     {
                         newAnchor.GlobalAttributes.Class.Value = ElementStylesV2.NoteAnchor;
                         newParent.Add(new EmptyLine(newParent.HTMLStandard));
                         newParent.Add(newAnchor);
                         count++;
                         newAnchor.Add(new SimpleHTML5Text(newAnchor.HTMLStandard)
                         {
                             Text = (link.Value.Count > 1) ? string.Format("(<< back {0})  ", count) : string.Format("(<< back)  ")
                         });
                     }
                 }
             }
             else
             {
                 //throw new Exception("Internal consistency error - Used ID has to be in one of the book documents objects");
                 Logger.Log.Error("Internal consistency error - Used ID has to be in one of the book documents objects");
                 //continue;
             }
         }
     }
 }
Esempio n. 2
0
 private void PassCoverImageFromFB2(CoverPage coverPage, EPubFileV3 epubFile)
 {
     // if we have at least one coverpage image
     if ((coverPage != null) && (coverPage.HasImages()) && (coverPage.CoverpageImages[0].HRef != null))
     {
         var coverPageFile = new CoverPageFileV3(coverPage.CoverpageImages[0], _referencesManager);
         StructureManager.AddCoverPage(coverPageFile);
         Images.ImageIdUsed(coverPage.CoverpageImages[0].HRef);
         epubFile.SetCoverImageID(ReferencesUtils.GetIdFromLink(coverPage.CoverpageImages[0].HRef));
     }
 }
Esempio n. 3
0
 public LinkReMapperV2(KeyValuePair <string, List <Anchor> > link, Dictionary <string, IHTMLItem> ids, BookStructureManager structureManager)
 {
     _link               = link;
     _structureManager   = structureManager;
     _idString           = ReferencesUtils.GetIdFromLink(link.Key);                // Get ID of a link target;
     _linkTargetItem     = ids[_idString];                                         // get object targeted by link
     _linkTargetDocument = GetIDParentDocument(structureManager, _linkTargetItem); // get parent document (file) containing targeted object
     if (_linkTargetDocument != null)
     {
         _linkParentContainer = DetectItemParentContainer(_linkTargetItem); // get parent container of link target item
     }
 }
Esempio n. 4
0
 public LinkReMapperV3(KeyValuePair <string, List <Anchor> > link, IDictionary <string, HTMLItem> ids, BookStructureManager structureManager, IEPubV3Settings v3Settings)
 {
     _link               = link;
     _ids                = ids;
     _v3Settings         = v3Settings;
     _structureManager   = structureManager;
     _idString           = ReferencesUtils.GetIdFromLink(link.Key);         // Get ID of a link target;
     _linkTargetItem     = ids[_idString];                                  // get object targeted by link
     _linkTargetDocument = GetItemParentDocument(_linkTargetItem);          // get parent document (file) containing targeted object
     if (_linkTargetDocument != null)                                       // if link target container document (document containing item with ID we jump to) found
     {
         _linkParentContainer = DetectItemParentContainer(_linkTargetItem); // get parent container of link target item
     }
 }