From 45f09af98f54631da8f4973e473f1b899a0e7aaa Mon Sep 17 00:00:00 2001 From: Paddy Xu Date: Sun, 2 Sep 2018 15:08:39 +0300 Subject: [PATCH] move epubviewer to plugin --- .../BookHtmlContent.cs | 107 ----- .../EpubReader/Entities/EpubBook.cs | 33 -- .../Entities/EpubByteContentFile.cs | 24 -- .../EpubReader/Entities/EpubChapter.cs | 35 -- .../EpubReader/Entities/EpubContent.cs | 30 -- .../EpubReader/Entities/EpubContentFile.cs | 26 -- .../EpubReader/Entities/EpubContentType.cs | 37 -- .../EpubReader/Entities/EpubSchema.cs | 28 -- .../Entities/EpubTextContentFile.cs | 24 -- .../EpubReader/EpubReader.cs | 244 ----------- .../EpubReader/Readers/BookCoverReader.cs | 47 --- .../EpubReader/Readers/ChapterReader.cs | 67 --- .../EpubReader/Readers/ContentReader.cs | 132 ------ .../EpubReader/Readers/NavigationReader.cs | 386 ----------------- .../EpubReader/Readers/PackageReader.cs | 391 ------------------ .../EpubReader/Readers/RootFilePathReader.cs | 48 --- .../EpubReader/Readers/SchemaReader.cs | 39 -- .../EpubReader/RefEntities/EpubBookRef.cs | 85 ---- .../RefEntities/EpubByteContentFileRef.cs | 39 -- .../EpubReader/RefEntities/EpubChapterRef.cs | 53 --- .../RefEntities/EpubContentFileRef.cs | 98 ----- .../EpubReader/RefEntities/EpubContentRef.cs | 30 -- .../RefEntities/EpubTextContentFileRef.cs | 39 -- .../Schema/Navigation/EpubNavigation.cs | 31 -- .../Navigation/EpubNavigationContent.cs | 30 -- .../Navigation/EpubNavigationDocAuthor.cs | 25 -- .../Navigation/EpubNavigationDocTitle.cs | 25 -- .../Schema/Navigation/EpubNavigationHead.cs | 25 -- .../Navigation/EpubNavigationHeadMeta.cs | 26 -- .../Schema/Navigation/EpubNavigationLabel.cs | 29 -- .../Schema/Navigation/EpubNavigationList.cs | 29 -- .../Schema/Navigation/EpubNavigationMap.cs | 25 -- .../Navigation/EpubNavigationPageList.cs | 25 -- .../Navigation/EpubNavigationPageTarget.cs | 32 -- .../EpubNavigationPageTargetType.cs | 26 -- .../Schema/Navigation/EpubNavigationPoint.cs | 36 -- .../Schema/Navigation/EpubNavigationTarget.cs | 31 -- .../EpubReader/Schema/Opf/EpubGuide.cs | 25 -- .../Schema/Opf/EpubGuideReference.cs | 31 -- .../EpubReader/Schema/Opf/EpubManifest.cs | 25 -- .../EpubReader/Schema/Opf/EpubManifestItem.cs | 35 -- .../EpubReader/Schema/Opf/EpubMetadata.cs | 41 -- .../Schema/Opf/EpubMetadataContributor.cs | 26 -- .../Schema/Opf/EpubMetadataCreator.cs | 26 -- .../EpubReader/Schema/Opf/EpubMetadataDate.cs | 25 -- .../Schema/Opf/EpubMetadataIdentifier.cs | 26 -- .../EpubReader/Schema/Opf/EpubMetadataMeta.cs | 29 -- .../EpubReader/Schema/Opf/EpubPackage.cs | 28 -- .../EpubReader/Schema/Opf/EpubSpine.cs | 26 -- .../EpubReader/Schema/Opf/EpubSpineItemRef.cs | 30 -- .../EpubReader/Schema/Opf/EpubVersion.cs | 25 -- .../EpubReader/Utils/XmlUtils.cs | 45 -- .../EpubReader/Utils/ZipPathUtils.cs | 37 -- .../EpubViewerControl.xaml | 28 -- .../EpubViewerControl.xaml.cs | 150 ------- .../QuickLook.Plugin.EpubViewer/Plugin.cs | 82 ---- .../Properties/AssemblyInfo.cs | 50 --- .../QuickLook.Plugin.EpubViewer.csproj | 135 ------ .../packages.config | 8 - QuickLook.sln | 12 - 60 files changed, 3382 deletions(-) delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/BookHtmlContent.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubBook.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubByteContentFile.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubChapter.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubContent.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubContentFile.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubContentType.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubSchema.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubTextContentFile.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/EpubReader.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/BookCoverReader.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/ChapterReader.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/ContentReader.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/NavigationReader.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/PackageReader.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/RootFilePathReader.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/SchemaReader.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/RefEntities/EpubBookRef.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/RefEntities/EpubByteContentFileRef.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/RefEntities/EpubChapterRef.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/RefEntities/EpubContentFileRef.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/RefEntities/EpubContentRef.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/RefEntities/EpubTextContentFileRef.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigation.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationContent.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationDocAuthor.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationDocTitle.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationHead.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationHeadMeta.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationLabel.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationList.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationMap.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationPageList.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationPageTarget.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationPageTargetType.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationPoint.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationTarget.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubGuide.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubGuideReference.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubManifest.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubManifestItem.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubMetadata.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubMetadataContributor.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubMetadataCreator.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubMetadataDate.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubMetadataIdentifier.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubMetadataMeta.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubPackage.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubSpine.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubSpineItemRef.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubVersion.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Utils/XmlUtils.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Utils/ZipPathUtils.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubViewerControl.xaml delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubViewerControl.xaml.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/Plugin.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/Properties/AssemblyInfo.cs delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/QuickLook.Plugin.EpubViewer.csproj delete mode 100644 QuickLook.Plugin/QuickLook.Plugin.EpubViewer/packages.config diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/BookHtmlContent.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/BookHtmlContent.cs deleted file mode 100644 index 7511523..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/BookHtmlContent.cs +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System.Diagnostics; -using System.IO; -using System.Windows; -using System.Windows.Media.Imaging; -using TheArtOfDev.HtmlRenderer.Core.Entities; -using TheArtOfDev.HtmlRenderer.WPF; -using VersOne.Epub; - -namespace QuickLook.Plugin.EpubViewer -{ - public class BookHtmlContent : HtmlPanel - { - public static readonly DependencyProperty ChapterRefProperty = DependencyProperty.Register("ChapterRef", - typeof(EpubChapterRef), typeof(BookHtmlContent), new PropertyMetadata(OnChapterRefChanged)); - - public static readonly DependencyProperty EpubBookProperty = DependencyProperty.Register("EpubBook", - typeof(EpubBookRef), typeof(BookHtmlContent), new PropertyMetadata(null)); - - public EpubChapterRef ChapterRef - { - get => (EpubChapterRef) GetValue(ChapterRefProperty); - set => SetValue(ChapterRefProperty, value); - } - - public EpubBookRef EpubBook - { - get => (EpubBookRef) GetValue(EpubBookProperty); - set => SetValue(EpubBookProperty, value); - } - - protected override void OnStylesheetLoad(HtmlStylesheetLoadEventArgs args) - { - var styleSheetFilePath = GetFullPath(ChapterRef.ContentFileName, args.Src); - if (EpubBook.Content.Css.TryGetValue(styleSheetFilePath, out var styleSheetContent)) - args.SetStyleSheet = styleSheetContent.ReadContentAsText(); - } - - protected override async void OnImageLoad(HtmlImageLoadEventArgs args) - { - var imageFilePath = ChapterRef != null ? GetFullPath(ChapterRef.ContentFileName, args.Src) : null; - byte[] imageBytes = null; - if (args.Src == "COVER") - imageBytes = await EpubBook.ReadCoverAsync(); - else if (EpubBook.Content.Images.TryGetValue(imageFilePath, out var imageContent)) - imageBytes = await imageContent.ReadContentAsBytesAsync(); - - if (imageBytes != null) - using (var imageStream = new MemoryStream(imageBytes)) - { - try - { - var bitmapImage = new BitmapImage(); - bitmapImage.BeginInit(); - bitmapImage.StreamSource = imageStream; - bitmapImage.CacheOption = BitmapCacheOption.OnLoad; - bitmapImage.EndInit(); - bitmapImage.Freeze(); - args.Callback(bitmapImage); - args.Handled = true; - } - catch - { - Debug.WriteLine($"Failed to load image: {args.Src}"); - } - } - } - - private string GetFullPath(string htmlFilePath, string relativePath) - { - if (relativePath.StartsWith("/")) return relativePath.Length > 1 ? relativePath.Substring(1) : string.Empty; - var basePath = Path.GetDirectoryName(htmlFilePath); - while (relativePath.StartsWith("../")) - { - relativePath = relativePath.Length > 3 ? relativePath.Substring(3) : string.Empty; - basePath = Path.GetDirectoryName(basePath); - } - - var fullPath = string.Concat(basePath.Replace('\\', '/'), '/', relativePath); - return fullPath.StartsWith("/") ? fullPath.Length > 1 ? fullPath.Substring(1) : string.Empty : fullPath; - } - - private static async void OnChapterRefChanged(DependencyObject dependencyObject, - DependencyPropertyChangedEventArgs e) - { - if (!(dependencyObject is BookHtmlContent bookHtmlContent) || bookHtmlContent.ChapterRef == null) - return; - bookHtmlContent.Text = await bookHtmlContent.ChapterRef.ReadHtmlContentAsync(); - } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubBook.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubBook.cs deleted file mode 100644 index ce63e79..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubBook.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System.Collections.Generic; - -namespace VersOne.Epub -{ - public class EpubBook - { - public string FilePath { get; set; } - public string Title { get; set; } - public string Author { get; set; } - public List AuthorList { get; set; } - public EpubSchema Schema { get; set; } - public EpubContent Content { get; set; } - public byte[] CoverImage { get; set; } - public List Chapters { get; set; } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubByteContentFile.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubByteContentFile.cs deleted file mode 100644 index a9c81da..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubByteContentFile.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -namespace VersOne.Epub -{ - public class EpubByteContentFile : EpubContentFile - { - public byte[] Content { get; set; } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubChapter.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubChapter.cs deleted file mode 100644 index 0c7cab7..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubChapter.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System.Collections.Generic; - -namespace VersOne.Epub -{ - public class EpubChapter - { - public string Title { get; set; } - public string ContentFileName { get; set; } - public string Anchor { get; set; } - public string HtmlContent { get; set; } - public List SubChapters { get; set; } - - public override string ToString() - { - return string.Format("Title: {0}, Subchapter count: {1}", Title, SubChapters.Count); - } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubContent.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubContent.cs deleted file mode 100644 index 1ae5536..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubContent.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System.Collections.Generic; - -namespace VersOne.Epub -{ - public class EpubContent - { - public Dictionary Html { get; set; } - public Dictionary Css { get; set; } - public Dictionary Images { get; set; } - public Dictionary Fonts { get; set; } - public Dictionary AllFiles { get; set; } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubContentFile.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubContentFile.cs deleted file mode 100644 index 0a3ed54..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubContentFile.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -namespace VersOne.Epub -{ - public abstract class EpubContentFile - { - public string FileName { get; set; } - public EpubContentType ContentType { get; set; } - public string ContentMimeType { get; set; } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubContentType.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubContentType.cs deleted file mode 100644 index eeb8c95..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubContentType.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -namespace VersOne.Epub -{ - public enum EpubContentType - { - XHTML_1_1 = 1, - DTBOOK, - DTBOOK_NCX, - OEB1_DOCUMENT, - XML, - CSS, - OEB1_CSS, - IMAGE_GIF, - IMAGE_JPEG, - IMAGE_PNG, - IMAGE_SVG, - FONT_TRUETYPE, - FONT_OPENTYPE, - OTHER - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubSchema.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubSchema.cs deleted file mode 100644 index 8368744..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubSchema.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using VersOne.Epub.Schema; - -namespace VersOne.Epub -{ - public class EpubSchema - { - public EpubPackage Package { get; set; } - public EpubNavigation Navigation { get; set; } - public string ContentDirectoryPath { get; set; } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubTextContentFile.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubTextContentFile.cs deleted file mode 100644 index 3b6d538..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Entities/EpubTextContentFile.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -namespace VersOne.Epub -{ - public class EpubTextContentFile : EpubContentFile - { - public string Content { get; set; } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/EpubReader.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/EpubReader.cs deleted file mode 100644 index 973d618..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/EpubReader.cs +++ /dev/null @@ -1,244 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System.Collections.Generic; -using System.IO; -using System.IO.Compression; -using System.Linq; -using System.Threading.Tasks; -using VersOne.Epub.Internal; - -namespace VersOne.Epub -{ - public static class EpubReader - { - /// - /// Opens the book synchronously without reading its whole content. Holds the handle to the EPUB file. - /// - /// path to the EPUB file - /// - public static EpubBookRef OpenBook(string filePath) - { - return OpenBookAsync(filePath).Result; - } - - /// - /// Opens the book synchronously without reading its whole content. - /// - /// path to the EPUB file - /// - public static EpubBookRef OpenBook(Stream stream) - { - return OpenBookAsync(stream).Result; - } - - /// - /// Opens the book asynchronously without reading its whole content. Holds the handle to the EPUB file. - /// - /// path to the EPUB file - /// - public static Task OpenBookAsync(string filePath) - { - if (!File.Exists(filePath)) throw new FileNotFoundException("Specified epub file not found.", filePath); - return OpenBookAsync(GetZipArchive(filePath)); - } - - /// - /// Opens the book asynchronously without reading its whole content. - /// - /// path to the EPUB file - /// - public static Task OpenBookAsync(Stream stream) - { - return OpenBookAsync(GetZipArchive(stream)); - } - - /// - /// Opens the book synchronously and reads all of its content into the memory. Does not hold the handle to the EPUB - /// file. - /// - /// path to the EPUB file - /// - public static EpubBook ReadBook(string filePath) - { - return ReadBookAsync(filePath).Result; - } - - /// - /// Opens the book synchronously and reads all of its content into the memory. Does not hold the handle to the EPUB - /// file. - /// - /// path to the EPUB file - /// - public static EpubBook ReadBook(Stream stream) - { - return ReadBookAsync(stream).Result; - } - - /// - /// Opens the book asynchronously and reads all of its content into the memory. Does not hold the handle to the EPUB - /// file. - /// - /// path to the EPUB file - /// - public static async Task ReadBookAsync(string filePath) - { - var epubBookRef = await OpenBookAsync(filePath).ConfigureAwait(false); - return await ReadBookAsync(epubBookRef).ConfigureAwait(false); - } - - /// - /// Opens the book asynchronously and reads all of its content into the memory. - /// - /// path to the EPUB file - /// - public static async Task ReadBookAsync(Stream stream) - { - var epubBookRef = await OpenBookAsync(stream).ConfigureAwait(false); - return await ReadBookAsync(epubBookRef).ConfigureAwait(false); - } - - private static async Task OpenBookAsync(ZipArchive zipArchive, string filePath = null) - { - EpubBookRef result = null; - try - { - result = new EpubBookRef(zipArchive); - result.FilePath = filePath; - result.Schema = await SchemaReader.ReadSchemaAsync(zipArchive).ConfigureAwait(false); - result.Title = result.Schema.Package.Metadata.Titles.FirstOrDefault() ?? string.Empty; - result.AuthorList = result.Schema.Package.Metadata.Creators.Select(creator => creator.Creator).ToList(); - result.Author = string.Join(", ", result.AuthorList); - result.Content = await Task.Run(() => ContentReader.ParseContentMap(result)).ConfigureAwait(false); - return result; - } - catch - { - result?.Dispose(); - throw; - } - } - - private static async Task ReadBookAsync(EpubBookRef epubBookRef) - { - var result = new EpubBook(); - using (epubBookRef) - { - result.FilePath = epubBookRef.FilePath; - result.Schema = epubBookRef.Schema; - result.Title = epubBookRef.Title; - result.AuthorList = epubBookRef.AuthorList; - result.Author = epubBookRef.Author; - result.Content = await ReadContent(epubBookRef.Content).ConfigureAwait(false); - result.CoverImage = await epubBookRef.ReadCoverAsync().ConfigureAwait(false); - var chapterRefs = await epubBookRef.GetChaptersAsync().ConfigureAwait(false); - result.Chapters = await ReadChapters(chapterRefs).ConfigureAwait(false); - } - - return result; - } - - private static ZipArchive GetZipArchive(string filePath) - { - return ZipFile.OpenRead(filePath); - } - - private static ZipArchive GetZipArchive(Stream stream) - { - return new ZipArchive(stream, ZipArchiveMode.Read); - } - - private static async Task ReadContent(EpubContentRef contentRef) - { - var result = new EpubContent(); - result.Html = await ReadTextContentFiles(contentRef.Html).ConfigureAwait(false); - result.Css = await ReadTextContentFiles(contentRef.Css).ConfigureAwait(false); - result.Images = await ReadByteContentFiles(contentRef.Images).ConfigureAwait(false); - result.Fonts = await ReadByteContentFiles(contentRef.Fonts).ConfigureAwait(false); - result.AllFiles = new Dictionary(); - foreach (var textContentFile in result.Html.Concat(result.Css)) - result.AllFiles.Add(textContentFile.Key, textContentFile.Value); - foreach (var byteContentFile in result.Images.Concat(result.Fonts)) - result.AllFiles.Add(byteContentFile.Key, byteContentFile.Value); - foreach (var contentFileRef in contentRef.AllFiles) - if (!result.AllFiles.ContainsKey(contentFileRef.Key)) - result.AllFiles.Add(contentFileRef.Key, - await ReadByteContentFile(contentFileRef.Value).ConfigureAwait(false)); - return result; - } - - private static async Task> ReadTextContentFiles( - Dictionary textContentFileRefs) - { - var result = new Dictionary(); - foreach (var textContentFileRef in textContentFileRefs) - { - var textContentFile = new EpubTextContentFile - { - FileName = textContentFileRef.Value.FileName, - ContentType = textContentFileRef.Value.ContentType, - ContentMimeType = textContentFileRef.Value.ContentMimeType - }; - textContentFile.Content = await textContentFileRef.Value.ReadContentAsTextAsync().ConfigureAwait(false); - result.Add(textContentFileRef.Key, textContentFile); - } - - return result; - } - - private static async Task> ReadByteContentFiles( - Dictionary byteContentFileRefs) - { - var result = new Dictionary(); - foreach (var byteContentFileRef in byteContentFileRefs) - result.Add(byteContentFileRef.Key, - await ReadByteContentFile(byteContentFileRef.Value).ConfigureAwait(false)); - return result; - } - - private static async Task ReadByteContentFile(EpubContentFileRef contentFileRef) - { - var result = new EpubByteContentFile - { - FileName = contentFileRef.FileName, - ContentType = contentFileRef.ContentType, - ContentMimeType = contentFileRef.ContentMimeType - }; - result.Content = await contentFileRef.ReadContentAsBytesAsync().ConfigureAwait(false); - return result; - } - - private static async Task> ReadChapters(List chapterRefs) - { - var result = new List(); - foreach (var chapterRef in chapterRefs) - { - var chapter = new EpubChapter - { - Title = chapterRef.Title, - ContentFileName = chapterRef.ContentFileName, - Anchor = chapterRef.Anchor - }; - chapter.HtmlContent = await chapterRef.ReadHtmlContentAsync().ConfigureAwait(false); - chapter.SubChapters = await ReadChapters(chapterRef.SubChapters).ConfigureAwait(false); - result.Add(chapter); - } - - return result; - } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/BookCoverReader.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/BookCoverReader.cs deleted file mode 100644 index 73d60df..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/BookCoverReader.cs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System; -using System.Linq; -using System.Threading.Tasks; - -namespace VersOne.Epub.Internal -{ - internal static class BookCoverReader - { - public static async Task ReadBookCoverAsync(EpubBookRef bookRef) - { - var metaItems = bookRef.Schema.Package.Metadata.MetaItems; - if (metaItems == null || !metaItems.Any()) return null; - var coverMetaItem = metaItems.FirstOrDefault(metaItem => - string.Compare(metaItem.Name, "cover", StringComparison.OrdinalIgnoreCase) == 0); - if (coverMetaItem == null) return null; - if (string.IsNullOrEmpty(coverMetaItem.Content)) - throw new Exception("Incorrect EPUB metadata: cover item content is missing."); - var coverManifestItem = bookRef.Schema.Package.Manifest.FirstOrDefault(manifestItem => - string.Compare(manifestItem.Id, coverMetaItem.Content, StringComparison.OrdinalIgnoreCase) == 0); - if (coverManifestItem == null) - throw new Exception(string.Format("Incorrect EPUB manifest: item with ID = \"{0}\" is missing.", - coverMetaItem.Content)); - if (!bookRef.Content.Images.TryGetValue(coverManifestItem.Href, out var coverImageContentFileRef)) - throw new Exception(string.Format("Incorrect EPUB manifest: item with href = \"{0}\" is missing.", - coverManifestItem.Href)); - var coverImageContent = await coverImageContentFileRef.ReadContentAsBytesAsync().ConfigureAwait(false); - return coverImageContent; - } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/ChapterReader.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/ChapterReader.cs deleted file mode 100644 index d002521..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/ChapterReader.cs +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using VersOne.Epub.Schema; - -namespace VersOne.Epub.Internal -{ - internal static class ChapterReader - { - public static List GetChapters(EpubBookRef bookRef) - { - return GetChapters(bookRef, bookRef.Schema.Package.Spine, bookRef.Schema.Navigation.NavMap); - } - - public static List GetChapters(EpubBookRef bookRef, EpubSpine spine, - List navigationPoints) - { - var result = new List(); - for (var s = 0; s < spine.Count; s++) - { - var itemRef = spine[s]; - string contentFileName; - string anchor; - contentFileName = WebUtility.UrlDecode(bookRef.Schema.Package.Manifest - .FirstOrDefault(e => e.Id == itemRef.IdRef)?.Href); - anchor = null; - if (!bookRef.Content.Html.TryGetValue(contentFileName, out var htmlContentFileRef)) - throw new Exception(string.Format("Incorrect EPUB manifest: item with href = \"{0}\" is missing.", - contentFileName)); - var chapterRef = new EpubChapterRef(htmlContentFileRef); - chapterRef.ContentFileName = contentFileName; - chapterRef.Anchor = anchor; - chapterRef.Parent = null; - var navPoint = navigationPoints.LastOrDefault(nav => - spine.Take(s + 1) - .Select(sp => bookRef.Schema.Package.Manifest.FirstOrDefault(e => e.Id == sp.IdRef)?.Href) - .Contains(nav.Content.Source.Split('#')[0])); - if (navPoint != null) - chapterRef.Title = navPoint.NavigationLabels.First().Text; - else - chapterRef.Title = $"Chapter {s + 1}"; - chapterRef.SubChapters = new List(); - result.Add(chapterRef); - } - - return result; - } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/ContentReader.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/ContentReader.cs deleted file mode 100644 index a05b540..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/ContentReader.cs +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System.Collections.Generic; - -namespace VersOne.Epub.Internal -{ - internal static class ContentReader - { - public static EpubContentRef ParseContentMap(EpubBookRef bookRef) - { - var result = new EpubContentRef - { - Html = new Dictionary(), - Css = new Dictionary(), - Images = new Dictionary(), - Fonts = new Dictionary(), - AllFiles = new Dictionary() - }; - foreach (var manifestItem in bookRef.Schema.Package.Manifest) - { - var fileName = manifestItem.Href; - var contentMimeType = manifestItem.MediaType; - var contentType = GetContentTypeByContentMimeType(contentMimeType); - switch (contentType) - { - case EpubContentType.XHTML_1_1: - case EpubContentType.CSS: - case EpubContentType.OEB1_DOCUMENT: - case EpubContentType.OEB1_CSS: - case EpubContentType.XML: - case EpubContentType.DTBOOK: - case EpubContentType.DTBOOK_NCX: - var epubTextContentFile = new EpubTextContentFileRef(bookRef) - { - FileName = fileName, - ContentMimeType = contentMimeType, - ContentType = contentType - }; - switch (contentType) - { - case EpubContentType.XHTML_1_1: - result.Html[fileName] = epubTextContentFile; - break; - case EpubContentType.CSS: - result.Css[fileName] = epubTextContentFile; - break; - } - - result.AllFiles[fileName] = epubTextContentFile; - break; - default: - var epubByteContentFile = new EpubByteContentFileRef(bookRef) - { - FileName = fileName, - ContentMimeType = contentMimeType, - ContentType = contentType - }; - switch (contentType) - { - case EpubContentType.IMAGE_GIF: - case EpubContentType.IMAGE_JPEG: - case EpubContentType.IMAGE_PNG: - case EpubContentType.IMAGE_SVG: - result.Images[fileName] = epubByteContentFile; - break; - case EpubContentType.FONT_TRUETYPE: - case EpubContentType.FONT_OPENTYPE: - result.Fonts[fileName] = epubByteContentFile; - break; - } - - result.AllFiles[fileName] = epubByteContentFile; - break; - } - } - - return result; - } - - private static EpubContentType GetContentTypeByContentMimeType(string contentMimeType) - { - switch (contentMimeType.ToLowerInvariant()) - { - case "application/xhtml+xml": - return EpubContentType.XHTML_1_1; - case "application/x-dtbook+xml": - return EpubContentType.DTBOOK; - case "application/x-dtbncx+xml": - return EpubContentType.DTBOOK_NCX; - case "text/x-oeb1-document": - return EpubContentType.OEB1_DOCUMENT; - case "application/xml": - return EpubContentType.XML; - case "text/css": - return EpubContentType.CSS; - case "text/x-oeb1-css": - return EpubContentType.OEB1_CSS; - case "image/gif": - return EpubContentType.IMAGE_GIF; - case "image/jpeg": - return EpubContentType.IMAGE_JPEG; - case "image/png": - return EpubContentType.IMAGE_PNG; - case "image/svg+xml": - return EpubContentType.IMAGE_SVG; - case "font/truetype": - return EpubContentType.FONT_TRUETYPE; - case "font/opentype": - return EpubContentType.FONT_OPENTYPE; - case "application/vnd.ms-opentype": - return EpubContentType.FONT_OPENTYPE; - default: - return EpubContentType.OTHER; - } - } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/NavigationReader.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/NavigationReader.cs deleted file mode 100644 index 3ebc4cb..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/NavigationReader.cs +++ /dev/null @@ -1,386 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System; -using System.Collections.Generic; -using System.IO.Compression; -using System.Linq; -using System.Threading.Tasks; -using System.Xml.Linq; -using VersOne.Epub.Schema; - -namespace VersOne.Epub.Internal -{ - internal static class NavigationReader - { - public static async Task ReadNavigationAsync(ZipArchive epubArchive, - string contentDirectoryPath, EpubPackage package) - { - var result = new EpubNavigation(); - var tocId = package.Spine.Toc; - if (string.IsNullOrEmpty(tocId)) throw new Exception("EPUB parsing error: TOC ID is empty."); - var tocManifestItem = package.Manifest.FirstOrDefault(item => - string.Compare(item.Id, tocId, StringComparison.OrdinalIgnoreCase) == 0); - if (tocManifestItem == null) - throw new Exception( - string.Format("EPUB parsing error: TOC item {0} not found in EPUB manifest.", tocId)); - var tocFileEntryPath = ZipPathUtils.Combine(contentDirectoryPath, tocManifestItem.Href); - var tocFileEntry = epubArchive.GetEntry(tocFileEntryPath); - if (tocFileEntry == null) - throw new Exception(string.Format("EPUB parsing error: TOC file {0} not found in archive.", - tocFileEntryPath)); - if (tocFileEntry.Length > int.MaxValue) - throw new Exception(string.Format("EPUB parsing error: TOC file {0} is larger than 2 Gb.", - tocFileEntryPath)); - XDocument containerDocument; - using (var containerStream = tocFileEntry.Open()) - { - containerDocument = await XmlUtils.LoadDocumentAsync(containerStream).ConfigureAwait(false); - } - - XNamespace ncxNamespace = "http://www.daisy.org/z3986/2005/ncx/"; - var ncxNode = containerDocument.Element(ncxNamespace + "ncx"); - if (ncxNode == null) throw new Exception("EPUB parsing error: TOC file does not contain ncx element."); - var headNode = ncxNode.Element(ncxNamespace + "head"); - if (headNode == null) throw new Exception("EPUB parsing error: TOC file does not contain head element."); - var navigationHead = ReadNavigationHead(headNode); - result.Head = navigationHead; - var docTitleNode = ncxNode.Element(ncxNamespace + "docTitle"); - if (docTitleNode == null) - throw new Exception("EPUB parsing error: TOC file does not contain docTitle element."); - var navigationDocTitle = ReadNavigationDocTitle(docTitleNode); - result.DocTitle = navigationDocTitle; - result.DocAuthors = new List(); - foreach (var docAuthorNode in ncxNode.Elements(ncxNamespace + "docAuthor")) - { - var navigationDocAuthor = ReadNavigationDocAuthor(docAuthorNode); - result.DocAuthors.Add(navigationDocAuthor); - } - - var navMapNode = ncxNode.Element(ncxNamespace + "navMap"); - if (navMapNode == null) - throw new Exception("EPUB parsing error: TOC file does not contain navMap element."); - var navMap = ReadNavigationMap(navMapNode); - result.NavMap = navMap; - var pageListNode = ncxNode.Element(ncxNamespace + "pageList"); - if (pageListNode != null) - { - var pageList = ReadNavigationPageList(pageListNode); - result.PageList = pageList; - } - - result.NavLists = new List(); - foreach (var navigationListNode in ncxNode.Elements(ncxNamespace + "navList")) - { - var navigationList = ReadNavigationList(navigationListNode); - result.NavLists.Add(navigationList); - } - - return result; - } - - private static EpubNavigationHead ReadNavigationHead(XElement headNode) - { - var result = new EpubNavigationHead(); - foreach (var metaNode in headNode.Elements()) - if (string.Compare(metaNode.Name.LocalName, "meta", StringComparison.OrdinalIgnoreCase) == 0) - { - var meta = new EpubNavigationHeadMeta(); - foreach (var metaNodeAttribute in metaNode.Attributes()) - { - var attributeValue = metaNodeAttribute.Value; - switch (metaNodeAttribute.Name.LocalName.ToLowerInvariant()) - { - case "name": - meta.Name = attributeValue; - break; - case "content": - meta.Content = attributeValue; - break; - case "scheme": - meta.Scheme = attributeValue; - break; - } - } - - if (string.IsNullOrWhiteSpace(meta.Name)) - throw new Exception("Incorrect EPUB navigation meta: meta name is missing."); - if (meta.Content == null) - throw new Exception("Incorrect EPUB navigation meta: meta content is missing."); - result.Add(meta); - } - - return result; - } - - private static EpubNavigationDocTitle ReadNavigationDocTitle(XElement docTitleNode) - { - var result = new EpubNavigationDocTitle(); - foreach (var textNode in docTitleNode.Elements()) - if (string.Compare(textNode.Name.LocalName, "text", StringComparison.OrdinalIgnoreCase) == 0) - result.Add(textNode.Value); - return result; - } - - private static EpubNavigationDocAuthor ReadNavigationDocAuthor(XElement docAuthorNode) - { - var result = new EpubNavigationDocAuthor(); - foreach (var textNode in docAuthorNode.Elements()) - if (string.Compare(textNode.Name.LocalName, "text", StringComparison.OrdinalIgnoreCase) == 0) - result.Add(textNode.Value); - return result; - } - - private static EpubNavigationMap ReadNavigationMap(XElement navigationMapNode) - { - var result = new EpubNavigationMap(); - foreach (var navigationPointNode in navigationMapNode.Elements()) - if (string.Compare(navigationPointNode.Name.LocalName, "navPoint", - StringComparison.OrdinalIgnoreCase) == 0) - { - var navigationPoint = ReadNavigationPoint(navigationPointNode); - result.Add(navigationPoint); - } - - return result; - } - - private static EpubNavigationPoint ReadNavigationPoint(XElement navigationPointNode) - { - var result = new EpubNavigationPoint(); - foreach (var navigationPointNodeAttribute in navigationPointNode.Attributes()) - { - var attributeValue = navigationPointNodeAttribute.Value; - switch (navigationPointNodeAttribute.Name.LocalName.ToLowerInvariant()) - { - case "id": - result.Id = attributeValue; - break; - case "class": - result.Class = attributeValue; - break; - case "playOrder": - result.PlayOrder = attributeValue; - break; - } - } - - if (string.IsNullOrWhiteSpace(result.Id)) - throw new Exception("Incorrect EPUB navigation point: point ID is missing."); - result.NavigationLabels = new List(); - result.ChildNavigationPoints = new List(); - foreach (var navigationPointChildNode in navigationPointNode.Elements()) - switch (navigationPointChildNode.Name.LocalName.ToLowerInvariant()) - { - case "navlabel": - var navigationLabel = ReadNavigationLabel(navigationPointChildNode); - result.NavigationLabels.Add(navigationLabel); - break; - case "content": - var content = ReadNavigationContent(navigationPointChildNode); - result.Content = content; - break; - case "navpoint": - var childNavigationPoint = ReadNavigationPoint(navigationPointChildNode); - result.ChildNavigationPoints.Add(childNavigationPoint); - break; - } - if (!result.NavigationLabels.Any()) - throw new Exception(string.Format( - "EPUB parsing error: navigation point {0} should contain at least one navigation label.", - result.Id)); - if (result.Content == null) - throw new Exception(string.Format("EPUB parsing error: navigation point {0} should contain content.", - result.Id)); - return result; - } - - private static EpubNavigationLabel ReadNavigationLabel(XElement navigationLabelNode) - { - var result = new EpubNavigationLabel(); - var navigationLabelTextNode = navigationLabelNode.Element(navigationLabelNode.Name.Namespace + "text"); - if (navigationLabelTextNode == null) - throw new Exception("Incorrect EPUB navigation label: label text element is missing."); - result.Text = navigationLabelTextNode.Value; - return result; - } - - private static EpubNavigationContent ReadNavigationContent(XElement navigationContentNode) - { - var result = new EpubNavigationContent(); - foreach (var navigationContentNodeAttribute in navigationContentNode.Attributes()) - { - var attributeValue = navigationContentNodeAttribute.Value; - switch (navigationContentNodeAttribute.Name.LocalName.ToLowerInvariant()) - { - case "id": - result.Id = attributeValue; - break; - case "src": - result.Source = attributeValue; - break; - } - } - - if (string.IsNullOrWhiteSpace(result.Source)) - throw new Exception("Incorrect EPUB navigation content: content source is missing."); - return result; - } - - private static EpubNavigationPageList ReadNavigationPageList(XElement navigationPageListNode) - { - var result = new EpubNavigationPageList(); - foreach (var pageTargetNode in navigationPageListNode.Elements()) - if (string.Compare(pageTargetNode.Name.LocalName, "pageTarget", StringComparison.OrdinalIgnoreCase) == - 0) - { - var pageTarget = ReadNavigationPageTarget(pageTargetNode); - result.Add(pageTarget); - } - - return result; - } - - private static EpubNavigationPageTarget ReadNavigationPageTarget(XElement navigationPageTargetNode) - { - var result = new EpubNavigationPageTarget(); - foreach (var navigationPageTargetNodeAttribute in navigationPageTargetNode.Attributes()) - { - var attributeValue = navigationPageTargetNodeAttribute.Value; - switch (navigationPageTargetNodeAttribute.Name.LocalName.ToLowerInvariant()) - { - case "id": - result.Id = attributeValue; - break; - case "value": - result.Value = attributeValue; - break; - case "type": - EpubNavigationPageTargetType type; - if (!Enum.TryParse(attributeValue, out type)) - throw new Exception(string.Format( - "Incorrect EPUB navigation page target: {0} is incorrect value for page target type.", - attributeValue)); - result.Type = type; - break; - case "class": - result.Class = attributeValue; - break; - case "playOrder": - result.PlayOrder = attributeValue; - break; - } - } - - if (result.Type == default(EpubNavigationPageTargetType)) - throw new Exception("Incorrect EPUB navigation page target: page target type is missing."); - foreach (var navigationPageTargetChildNode in navigationPageTargetNode.Elements()) - switch (navigationPageTargetChildNode.Name.LocalName.ToLowerInvariant()) - { - case "navlabel": - var navigationLabel = ReadNavigationLabel(navigationPageTargetChildNode); - result.NavigationLabels.Add(navigationLabel); - break; - case "content": - var content = ReadNavigationContent(navigationPageTargetChildNode); - result.Content = content; - break; - } - if (!result.NavigationLabels.Any()) - throw new Exception( - "Incorrect EPUB navigation page target: at least one navLabel element is required."); - return result; - } - - private static EpubNavigationList ReadNavigationList(XElement navigationListNode) - { - var result = new EpubNavigationList(); - foreach (var navigationListNodeAttribute in navigationListNode.Attributes()) - { - var attributeValue = navigationListNodeAttribute.Value; - switch (navigationListNodeAttribute.Name.LocalName.ToLowerInvariant()) - { - case "id": - result.Id = attributeValue; - break; - case "class": - result.Class = attributeValue; - break; - } - } - - foreach (var navigationListChildNode in navigationListNode.Elements()) - switch (navigationListChildNode.Name.LocalName.ToLowerInvariant()) - { - case "navlabel": - var navigationLabel = ReadNavigationLabel(navigationListChildNode); - result.NavigationLabels.Add(navigationLabel); - break; - case "navTarget": - var navigationTarget = ReadNavigationTarget(navigationListChildNode); - result.NavigationTargets.Add(navigationTarget); - break; - } - if (!result.NavigationLabels.Any()) - throw new Exception( - "Incorrect EPUB navigation page target: at least one navLabel element is required."); - return result; - } - - private static EpubNavigationTarget ReadNavigationTarget(XElement navigationTargetNode) - { - var result = new EpubNavigationTarget(); - foreach (var navigationPageTargetNodeAttribute in navigationTargetNode.Attributes()) - { - var attributeValue = navigationPageTargetNodeAttribute.Value; - switch (navigationPageTargetNodeAttribute.Name.LocalName.ToLowerInvariant()) - { - case "id": - result.Id = attributeValue; - break; - case "value": - result.Value = attributeValue; - break; - case "class": - result.Class = attributeValue; - break; - case "playOrder": - result.PlayOrder = attributeValue; - break; - } - } - - if (string.IsNullOrWhiteSpace(result.Id)) - throw new Exception("Incorrect EPUB navigation target: navigation target ID is missing."); - foreach (var navigationTargetChildNode in navigationTargetNode.Elements()) - switch (navigationTargetChildNode.Name.LocalName.ToLowerInvariant()) - { - case "navlabel": - var navigationLabel = ReadNavigationLabel(navigationTargetChildNode); - result.NavigationLabels.Add(navigationLabel); - break; - case "content": - var content = ReadNavigationContent(navigationTargetChildNode); - result.Content = content; - break; - } - if (!result.NavigationLabels.Any()) - throw new Exception("Incorrect EPUB navigation target: at least one navLabel element is required."); - return result; - } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/PackageReader.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/PackageReader.cs deleted file mode 100644 index 2961afc..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/PackageReader.cs +++ /dev/null @@ -1,391 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System; -using System.Collections.Generic; -using System.IO.Compression; -using System.Threading.Tasks; -using System.Xml.Linq; -using VersOne.Epub.Schema; - -namespace VersOne.Epub.Internal -{ - internal static class PackageReader - { - public static async Task ReadPackageAsync(ZipArchive epubArchive, string rootFilePath) - { - var rootFileEntry = epubArchive.GetEntry(rootFilePath); - if (rootFileEntry == null) throw new Exception("EPUB parsing error: root file not found in archive."); - XDocument containerDocument; - using (var containerStream = rootFileEntry.Open()) - { - containerDocument = await XmlUtils.LoadDocumentAsync(containerStream).ConfigureAwait(false); - } - - XNamespace opfNamespace = "http://www.idpf.org/2007/opf"; - var packageNode = containerDocument.Element(opfNamespace + "package"); - var result = new EpubPackage(); - var epubVersionValue = packageNode.Attribute("version").Value; - if (epubVersionValue == "2.0") - result.EpubVersion = EpubVersion.EPUB_2; - else if (epubVersionValue == "3.0") - result.EpubVersion = EpubVersion.EPUB_3; - else - throw new Exception(string.Format("Unsupported EPUB version: {0}.", epubVersionValue)); - var metadataNode = packageNode.Element(opfNamespace + "metadata"); - if (metadataNode == null) throw new Exception("EPUB parsing error: metadata not found in the package."); - var metadata = ReadMetadata(metadataNode, result.EpubVersion); - result.Metadata = metadata; - var manifestNode = packageNode.Element(opfNamespace + "manifest"); - if (manifestNode == null) throw new Exception("EPUB parsing error: manifest not found in the package."); - var manifest = ReadManifest(manifestNode); - result.Manifest = manifest; - var spineNode = packageNode.Element(opfNamespace + "spine"); - if (spineNode == null) throw new Exception("EPUB parsing error: spine not found in the package."); - var spine = ReadSpine(spineNode); - result.Spine = spine; - var guideNode = packageNode.Element(opfNamespace + "guide"); - if (guideNode != null) - { - var guide = ReadGuide(guideNode); - result.Guide = guide; - } - - return result; - } - - private static EpubMetadata ReadMetadata(XElement metadataNode, EpubVersion epubVersion) - { - var result = new EpubMetadata - { - Titles = new List(), - Creators = new List(), - Subjects = new List(), - Publishers = new List(), - Contributors = new List(), - Dates = new List(), - Types = new List(), - Formats = new List(), - Identifiers = new List(), - Sources = new List(), - Languages = new List(), - Relations = new List(), - Coverages = new List(), - Rights = new List(), - MetaItems = new List() - }; - foreach (var metadataItemNode in metadataNode.Elements()) - { - var innerText = metadataItemNode.Value; - switch (metadataItemNode.Name.LocalName.ToLowerInvariant()) - { - case "title": - result.Titles.Add(innerText); - break; - case "creator": - var creator = ReadMetadataCreator(metadataItemNode); - result.Creators.Add(creator); - break; - case "subject": - result.Subjects.Add(innerText); - break; - case "description": - result.Description = innerText; - break; - case "publisher": - result.Publishers.Add(innerText); - break; - case "contributor": - var contributor = ReadMetadataContributor(metadataItemNode); - result.Contributors.Add(contributor); - break; - case "date": - var date = ReadMetadataDate(metadataItemNode); - result.Dates.Add(date); - break; - case "type": - result.Types.Add(innerText); - break; - case "format": - result.Formats.Add(innerText); - break; - case "identifier": - var identifier = ReadMetadataIdentifier(metadataItemNode); - result.Identifiers.Add(identifier); - break; - case "source": - result.Sources.Add(innerText); - break; - case "language": - result.Languages.Add(innerText); - break; - case "relation": - result.Relations.Add(innerText); - break; - case "coverage": - result.Coverages.Add(innerText); - break; - case "rights": - result.Rights.Add(innerText); - break; - case "meta": - if (epubVersion == EpubVersion.EPUB_2) - { - var meta = ReadMetadataMetaVersion2(metadataItemNode); - result.MetaItems.Add(meta); - } - else if (epubVersion == EpubVersion.EPUB_3) - { - var meta = ReadMetadataMetaVersion3(metadataItemNode); - result.MetaItems.Add(meta); - } - - break; - } - } - - return result; - } - - private static EpubMetadataCreator ReadMetadataCreator(XElement metadataCreatorNode) - { - var result = new EpubMetadataCreator(); - foreach (var metadataCreatorNodeAttribute in metadataCreatorNode.Attributes()) - { - var attributeValue = metadataCreatorNodeAttribute.Value; - switch (metadataCreatorNodeAttribute.Name.LocalName.ToLowerInvariant()) - { - case "role": - result.Role = attributeValue; - break; - case "file-as": - result.FileAs = attributeValue; - break; - } - } - - result.Creator = metadataCreatorNode.Value; - return result; - } - - private static EpubMetadataContributor ReadMetadataContributor(XElement metadataContributorNode) - { - var result = new EpubMetadataContributor(); - foreach (var metadataContributorNodeAttribute in metadataContributorNode.Attributes()) - { - var attributeValue = metadataContributorNodeAttribute.Value; - switch (metadataContributorNodeAttribute.Name.LocalName.ToLowerInvariant()) - { - case "role": - result.Role = attributeValue; - break; - case "file-as": - result.FileAs = attributeValue; - break; - } - } - - result.Contributor = metadataContributorNode.Value; - return result; - } - - private static EpubMetadataDate ReadMetadataDate(XElement metadataDateNode) - { - var result = new EpubMetadataDate(); - var eventAttribute = metadataDateNode.Attribute(metadataDateNode.Name.Namespace + "event"); - if (eventAttribute != null) result.Event = eventAttribute.Value; - result.Date = metadataDateNode.Value; - return result; - } - - private static EpubMetadataIdentifier ReadMetadataIdentifier(XElement metadataIdentifierNode) - { - var result = new EpubMetadataIdentifier(); - foreach (var metadataIdentifierNodeAttribute in metadataIdentifierNode.Attributes()) - { - var attributeValue = metadataIdentifierNodeAttribute.Value; - switch (metadataIdentifierNodeAttribute.Name.LocalName.ToLowerInvariant()) - { - case "id": - result.Id = attributeValue; - break; - case "opf:scheme": - result.Scheme = attributeValue; - break; - } - } - - result.Identifier = metadataIdentifierNode.Value; - return result; - } - - private static EpubMetadataMeta ReadMetadataMetaVersion2(XElement metadataMetaNode) - { - var result = new EpubMetadataMeta(); - foreach (var metadataMetaNodeAttribute in metadataMetaNode.Attributes()) - { - var attributeValue = metadataMetaNodeAttribute.Value; - switch (metadataMetaNodeAttribute.Name.LocalName.ToLowerInvariant()) - { - case "name": - result.Name = attributeValue; - break; - case "content": - result.Content = attributeValue; - break; - } - } - - return result; - } - - private static EpubMetadataMeta ReadMetadataMetaVersion3(XElement metadataMetaNode) - { - var result = new EpubMetadataMeta(); - foreach (var metadataMetaNodeAttribute in metadataMetaNode.Attributes()) - { - var attributeValue = metadataMetaNodeAttribute.Value; - switch (metadataMetaNodeAttribute.Name.LocalName.ToLowerInvariant()) - { - case "id": - result.Id = attributeValue; - break; - case "refines": - result.Refines = attributeValue; - break; - case "property": - result.Property = attributeValue; - break; - case "scheme": - result.Scheme = attributeValue; - break; - } - } - - result.Content = metadataMetaNode.Value; - return result; - } - - private static EpubManifest ReadManifest(XElement manifestNode) - { - var result = new EpubManifest(); - foreach (var manifestItemNode in manifestNode.Elements()) - if (string.Compare(manifestItemNode.Name.LocalName, "item", StringComparison.OrdinalIgnoreCase) == 0) - { - var manifestItem = new EpubManifestItem(); - foreach (var manifestItemNodeAttribute in manifestItemNode.Attributes()) - { - var attributeValue = manifestItemNodeAttribute.Value; - switch (manifestItemNodeAttribute.Name.LocalName.ToLowerInvariant()) - { - case "id": - manifestItem.Id = attributeValue; - break; - case "href": - manifestItem.Href = Uri.UnescapeDataString(attributeValue); - break; - case "media-type": - manifestItem.MediaType = attributeValue; - break; - case "required-namespace": - manifestItem.RequiredNamespace = attributeValue; - break; - case "required-modules": - manifestItem.RequiredModules = attributeValue; - break; - case "fallback": - manifestItem.Fallback = attributeValue; - break; - case "fallback-style": - manifestItem.FallbackStyle = attributeValue; - break; - } - } - - if (string.IsNullOrWhiteSpace(manifestItem.Id)) - throw new Exception("Incorrect EPUB manifest: item ID is missing"); - if (string.IsNullOrWhiteSpace(manifestItem.Href)) - throw new Exception("Incorrect EPUB manifest: item href is missing"); - if (string.IsNullOrWhiteSpace(manifestItem.MediaType)) - throw new Exception("Incorrect EPUB manifest: item media type is missing"); - result.Add(manifestItem); - } - - return result; - } - - private static EpubSpine ReadSpine(XElement spineNode) - { - var result = new EpubSpine(); - var tocAttribute = spineNode.Attribute("toc"); - if (tocAttribute == null || string.IsNullOrWhiteSpace(tocAttribute.Value)) - throw new Exception("Incorrect EPUB spine: TOC is missing"); - result.Toc = tocAttribute.Value; - foreach (var spineItemNode in spineNode.Elements()) - if (string.Compare(spineItemNode.Name.LocalName, "itemref", StringComparison.OrdinalIgnoreCase) == 0) - { - var spineItemRef = new EpubSpineItemRef(); - var idRefAttribute = spineItemNode.Attribute("idref"); - if (idRefAttribute == null || string.IsNullOrWhiteSpace(idRefAttribute.Value)) - throw new Exception("Incorrect EPUB spine: item ID ref is missing"); - spineItemRef.IdRef = idRefAttribute.Value; - var linearAttribute = spineItemNode.Attribute("linear"); - spineItemRef.IsLinear = linearAttribute == null || - string.Compare(linearAttribute.Value, "no", - StringComparison.OrdinalIgnoreCase) != 0; - result.Add(spineItemRef); - } - - return result; - } - - private static EpubGuide ReadGuide(XElement guideNode) - { - var result = new EpubGuide(); - foreach (var guideReferenceNode in guideNode.Elements()) - if (string.Compare(guideReferenceNode.Name.LocalName, "reference", - StringComparison.OrdinalIgnoreCase) == 0) - { - var guideReference = new EpubGuideReference(); - foreach (var guideReferenceNodeAttribute in guideReferenceNode.Attributes()) - { - var attributeValue = guideReferenceNodeAttribute.Value; - switch (guideReferenceNodeAttribute.Name.LocalName.ToLowerInvariant()) - { - case "type": - guideReference.Type = attributeValue; - break; - case "title": - guideReference.Title = attributeValue; - break; - case "href": - guideReference.Href = Uri.UnescapeDataString(attributeValue); - break; - } - } - - if (string.IsNullOrWhiteSpace(guideReference.Type)) - throw new Exception("Incorrect EPUB guide: item type is missing"); - if (string.IsNullOrWhiteSpace(guideReference.Href)) - throw new Exception("Incorrect EPUB guide: item href is missing"); - result.Add(guideReference); - } - - return result; - } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/RootFilePathReader.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/RootFilePathReader.cs deleted file mode 100644 index 16a24aa..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/RootFilePathReader.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System; -using System.IO.Compression; -using System.Threading.Tasks; -using System.Xml.Linq; - -namespace VersOne.Epub.Internal -{ - internal static class RootFilePathReader - { - public static async Task GetRootFilePathAsync(ZipArchive epubArchive) - { - const string EPUB_CONTAINER_FILE_PATH = "META-INF/container.xml"; - var containerFileEntry = epubArchive.GetEntry(EPUB_CONTAINER_FILE_PATH); - if (containerFileEntry == null) - throw new Exception(string.Format("EPUB parsing error: {0} file not found in archive.", - EPUB_CONTAINER_FILE_PATH)); - XDocument containerDocument; - using (var containerStream = containerFileEntry.Open()) - { - containerDocument = await XmlUtils.LoadDocumentAsync(containerStream).ConfigureAwait(false); - } - - XNamespace cnsNamespace = "urn:oasis:names:tc:opendocument:xmlns:container"; - var fullPathAttribute = containerDocument.Element(cnsNamespace + "container") - ?.Element(cnsNamespace + "rootfiles")?.Element(cnsNamespace + "rootfile")?.Attribute("full-path"); - if (fullPathAttribute == null) - throw new Exception("EPUB parsing error: root file path not found in the EPUB container."); - return fullPathAttribute.Value; - } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/SchemaReader.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/SchemaReader.cs deleted file mode 100644 index f699f42..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Readers/SchemaReader.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System.IO.Compression; -using System.Threading.Tasks; - -namespace VersOne.Epub.Internal -{ - internal static class SchemaReader - { - public static async Task ReadSchemaAsync(ZipArchive epubArchive) - { - var result = new EpubSchema(); - var rootFilePath = await RootFilePathReader.GetRootFilePathAsync(epubArchive).ConfigureAwait(false); - var contentDirectoryPath = ZipPathUtils.GetDirectoryPath(rootFilePath); - result.ContentDirectoryPath = contentDirectoryPath; - var package = await PackageReader.ReadPackageAsync(epubArchive, rootFilePath).ConfigureAwait(false); - result.Package = package; - var navigation = await NavigationReader.ReadNavigationAsync(epubArchive, contentDirectoryPath, package) - .ConfigureAwait(false); - result.Navigation = navigation; - return result; - } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/RefEntities/EpubBookRef.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/RefEntities/EpubBookRef.cs deleted file mode 100644 index 41d998a..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/RefEntities/EpubBookRef.cs +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System; -using System.Collections.Generic; -using System.IO.Compression; -using System.Threading.Tasks; -using VersOne.Epub.Internal; - -namespace VersOne.Epub -{ - public class EpubBookRef : IDisposable - { - private bool isDisposed; - - public EpubBookRef(ZipArchive epubArchive) - { - EpubArchive = epubArchive; - isDisposed = false; - } - - public string FilePath { get; set; } - public string Title { get; set; } - public string Author { get; set; } - public List AuthorList { get; set; } - public EpubSchema Schema { get; set; } - public EpubContentRef Content { get; set; } - - internal ZipArchive EpubArchive { get; } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - ~EpubBookRef() - { - Dispose(false); - } - - public byte[] ReadCover() - { - return ReadCoverAsync().Result; - } - - public async Task ReadCoverAsync() - { - return await BookCoverReader.ReadBookCoverAsync(this).ConfigureAwait(false); - } - - public List GetChapters() - { - return GetChaptersAsync().Result; - } - - public async Task> GetChaptersAsync() - { - return await Task.Run(() => ChapterReader.GetChapters(this)).ConfigureAwait(false); - } - - protected virtual void Dispose(bool disposing) - { - if (!isDisposed) - { - if (disposing) EpubArchive?.Dispose(); - isDisposed = true; - } - } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/RefEntities/EpubByteContentFileRef.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/RefEntities/EpubByteContentFileRef.cs deleted file mode 100644 index 2865d39..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/RefEntities/EpubByteContentFileRef.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System.Threading.Tasks; - -namespace VersOne.Epub -{ - public class EpubByteContentFileRef : EpubContentFileRef - { - public EpubByteContentFileRef(EpubBookRef epubBookRef) - : base(epubBookRef) - { - } - - public byte[] ReadContent() - { - return ReadContentAsBytes(); - } - - public Task ReadContentAsync() - { - return ReadContentAsBytesAsync(); - } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/RefEntities/EpubChapterRef.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/RefEntities/EpubChapterRef.cs deleted file mode 100644 index 173e516..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/RefEntities/EpubChapterRef.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace VersOne.Epub -{ - public class EpubChapterRef - { - private readonly EpubTextContentFileRef epubTextContentFileRef; - - public EpubChapterRef(EpubTextContentFileRef epubTextContentFileRef) - { - this.epubTextContentFileRef = epubTextContentFileRef; - } - - public string Title { get; set; } - public string ContentFileName { get; set; } - public string Anchor { get; set; } - public List SubChapters { get; set; } - public EpubChapterRef Parent { get; set; } - - public string ReadHtmlContent() - { - return ReadHtmlContentAsync().Result; - } - - public Task ReadHtmlContentAsync() - { - return epubTextContentFileRef.ReadContentAsTextAsync(); - } - - public override string ToString() - { - return string.Format("Title: {0}, Subchapter count: {1}", Title, SubChapters.Count); - } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/RefEntities/EpubContentFileRef.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/RefEntities/EpubContentFileRef.cs deleted file mode 100644 index 5a08775..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/RefEntities/EpubContentFileRef.cs +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System; -using System.IO; -using System.IO.Compression; -using System.Threading.Tasks; -using VersOne.Epub.Internal; - -namespace VersOne.Epub -{ - public abstract class EpubContentFileRef - { - private readonly EpubBookRef epubBookRef; - - public EpubContentFileRef(EpubBookRef epubBookRef) - { - this.epubBookRef = epubBookRef; - } - - public string FileName { get; set; } - public EpubContentType ContentType { get; set; } - public string ContentMimeType { get; set; } - - public byte[] ReadContentAsBytes() - { - return ReadContentAsBytesAsync().Result; - } - - public async Task ReadContentAsBytesAsync() - { - var contentFileEntry = GetContentFileEntry(); - var content = new byte[(int) contentFileEntry.Length]; - using (var contentStream = OpenContentStream(contentFileEntry)) - using (var memoryStream = new MemoryStream(content)) - { - await contentStream.CopyToAsync(memoryStream).ConfigureAwait(false); - } - - return content; - } - - public string ReadContentAsText() - { - return ReadContentAsTextAsync().Result; - } - - public async Task ReadContentAsTextAsync() - { - using (var contentStream = GetContentStream()) - using (var streamReader = new StreamReader(contentStream)) - { - return await streamReader.ReadToEndAsync().ConfigureAwait(false); - } - } - - public Stream GetContentStream() - { - return OpenContentStream(GetContentFileEntry()); - } - - private ZipArchiveEntry GetContentFileEntry() - { - var contentFilePath = ZipPathUtils.Combine(epubBookRef.Schema.ContentDirectoryPath, FileName); - var contentFileEntry = epubBookRef.EpubArchive.GetEntry(contentFilePath); - if (contentFileEntry == null) - throw new Exception( - string.Format("EPUB parsing error: file {0} not found in archive.", contentFilePath)); - if (contentFileEntry.Length > int.MaxValue) - throw new Exception(string.Format("EPUB parsing error: file {0} is bigger than 2 Gb.", - contentFilePath)); - return contentFileEntry; - } - - private Stream OpenContentStream(ZipArchiveEntry contentFileEntry) - { - var contentStream = contentFileEntry.Open(); - if (contentStream == null) - throw new Exception(string.Format( - "Incorrect EPUB file: content file \"{0}\" specified in manifest is not found.", FileName)); - return contentStream; - } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/RefEntities/EpubContentRef.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/RefEntities/EpubContentRef.cs deleted file mode 100644 index aca3745..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/RefEntities/EpubContentRef.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System.Collections.Generic; - -namespace VersOne.Epub -{ - public class EpubContentRef - { - public Dictionary Html { get; set; } - public Dictionary Css { get; set; } - public Dictionary Images { get; set; } - public Dictionary Fonts { get; set; } - public Dictionary AllFiles { get; set; } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/RefEntities/EpubTextContentFileRef.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/RefEntities/EpubTextContentFileRef.cs deleted file mode 100644 index 39d3ff6..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/RefEntities/EpubTextContentFileRef.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System.Threading.Tasks; - -namespace VersOne.Epub -{ - public class EpubTextContentFileRef : EpubContentFileRef - { - public EpubTextContentFileRef(EpubBookRef epubBookRef) - : base(epubBookRef) - { - } - - public string ReadContent() - { - return ReadContentAsText(); - } - - public Task ReadContentAsync() - { - return ReadContentAsTextAsync(); - } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigation.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigation.cs deleted file mode 100644 index 40af42e..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigation.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System.Collections.Generic; - -namespace VersOne.Epub.Schema -{ - public class EpubNavigation - { - public EpubNavigationHead Head { get; set; } - public EpubNavigationDocTitle DocTitle { get; set; } - public List DocAuthors { get; set; } - public EpubNavigationMap NavMap { get; set; } - public EpubNavigationPageList PageList { get; set; } - public List NavLists { get; set; } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationContent.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationContent.cs deleted file mode 100644 index 3772db5..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationContent.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -namespace VersOne.Epub.Schema -{ - public class EpubNavigationContent - { - public string Id { get; set; } - public string Source { get; set; } - - public override string ToString() - { - return string.Concat("Source: " + Source); - } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationDocAuthor.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationDocAuthor.cs deleted file mode 100644 index 0bb4102..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationDocAuthor.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System.Collections.Generic; - -namespace VersOne.Epub.Schema -{ - public class EpubNavigationDocAuthor : List - { - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationDocTitle.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationDocTitle.cs deleted file mode 100644 index 56318d5..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationDocTitle.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System.Collections.Generic; - -namespace VersOne.Epub.Schema -{ - public class EpubNavigationDocTitle : List - { - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationHead.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationHead.cs deleted file mode 100644 index 590f183..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationHead.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System.Collections.Generic; - -namespace VersOne.Epub.Schema -{ - public class EpubNavigationHead : List - { - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationHeadMeta.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationHeadMeta.cs deleted file mode 100644 index c869263..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationHeadMeta.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -namespace VersOne.Epub.Schema -{ - public class EpubNavigationHeadMeta - { - public string Name { get; set; } - public string Content { get; set; } - public string Scheme { get; set; } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationLabel.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationLabel.cs deleted file mode 100644 index d2407c5..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationLabel.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -namespace VersOne.Epub.Schema -{ - public class EpubNavigationLabel - { - public string Text { get; set; } - - public override string ToString() - { - return Text; - } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationList.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationList.cs deleted file mode 100644 index d68b76e..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationList.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System.Collections.Generic; - -namespace VersOne.Epub.Schema -{ - public class EpubNavigationList - { - public string Id { get; set; } - public string Class { get; set; } - public List NavigationLabels { get; set; } - public List NavigationTargets { get; set; } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationMap.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationMap.cs deleted file mode 100644 index 14f7a27..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationMap.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System.Collections.Generic; - -namespace VersOne.Epub.Schema -{ - public class EpubNavigationMap : List - { - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationPageList.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationPageList.cs deleted file mode 100644 index 3e59a3a..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationPageList.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System.Collections.Generic; - -namespace VersOne.Epub.Schema -{ - public class EpubNavigationPageList : List - { - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationPageTarget.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationPageTarget.cs deleted file mode 100644 index 19effb7..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationPageTarget.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System.Collections.Generic; - -namespace VersOne.Epub.Schema -{ - public class EpubNavigationPageTarget - { - public string Id { get; set; } - public string Value { get; set; } - public EpubNavigationPageTargetType Type { get; set; } - public string Class { get; set; } - public string PlayOrder { get; set; } - public List NavigationLabels { get; set; } - public EpubNavigationContent Content { get; set; } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationPageTargetType.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationPageTargetType.cs deleted file mode 100644 index 2a31bb6..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationPageTargetType.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -namespace VersOne.Epub.Schema -{ - public enum EpubNavigationPageTargetType - { - FRONT = 1, - NORMAL, - SPECIAL - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationPoint.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationPoint.cs deleted file mode 100644 index ab4115b..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationPoint.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System.Collections.Generic; - -namespace VersOne.Epub.Schema -{ - public class EpubNavigationPoint - { - public string Id { get; set; } - public string Class { get; set; } - public string PlayOrder { get; set; } - public List NavigationLabels { get; set; } - public EpubNavigationContent Content { get; set; } - public List ChildNavigationPoints { get; set; } - - public override string ToString() - { - return string.Format("Id: {0}, Content.Source: {1}", Id, Content.Source); - } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationTarget.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationTarget.cs deleted file mode 100644 index a035020..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Navigation/EpubNavigationTarget.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System.Collections.Generic; - -namespace VersOne.Epub.Schema -{ - public class EpubNavigationTarget - { - public string Id { get; set; } - public string Class { get; set; } - public string Value { get; set; } - public string PlayOrder { get; set; } - public List NavigationLabels { get; set; } - public EpubNavigationContent Content { get; set; } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubGuide.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubGuide.cs deleted file mode 100644 index cd505ce..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubGuide.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System.Collections.Generic; - -namespace VersOne.Epub.Schema -{ - public class EpubGuide : List - { - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubGuideReference.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubGuideReference.cs deleted file mode 100644 index 6a3fef1..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubGuideReference.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -namespace VersOne.Epub.Schema -{ - public class EpubGuideReference - { - public string Type { get; set; } - public string Title { get; set; } - public string Href { get; set; } - - public override string ToString() - { - return string.Format("Type: {0}, Href: {1}", Type, Href); - } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubManifest.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubManifest.cs deleted file mode 100644 index e29d87b..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubManifest.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System.Collections.Generic; - -namespace VersOne.Epub.Schema -{ - public class EpubManifest : List - { - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubManifestItem.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubManifestItem.cs deleted file mode 100644 index b047810..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubManifestItem.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -namespace VersOne.Epub.Schema -{ - public class EpubManifestItem - { - public string Id { get; set; } - public string Href { get; set; } - public string MediaType { get; set; } - public string RequiredNamespace { get; set; } - public string RequiredModules { get; set; } - public string Fallback { get; set; } - public string FallbackStyle { get; set; } - - public override string ToString() - { - return string.Format("Id: {0}, Href = {1}, MediaType = {2}", Id, Href, MediaType); - } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubMetadata.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubMetadata.cs deleted file mode 100644 index 98465e4..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubMetadata.cs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System.Collections.Generic; - -namespace VersOne.Epub.Schema -{ - public class EpubMetadata - { - public List Titles { get; set; } - public List Creators { get; set; } - public List Subjects { get; set; } - public string Description { get; set; } - public List Publishers { get; set; } - public List Contributors { get; set; } - public List Dates { get; set; } - public List Types { get; set; } - public List Formats { get; set; } - public List Identifiers { get; set; } - public List Sources { get; set; } - public List Languages { get; set; } - public List Relations { get; set; } - public List Coverages { get; set; } - public List Rights { get; set; } - public List MetaItems { get; set; } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubMetadataContributor.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubMetadataContributor.cs deleted file mode 100644 index 1108fc2..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubMetadataContributor.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -namespace VersOne.Epub.Schema -{ - public class EpubMetadataContributor - { - public string Contributor { get; set; } - public string FileAs { get; set; } - public string Role { get; set; } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubMetadataCreator.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubMetadataCreator.cs deleted file mode 100644 index c391578..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubMetadataCreator.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -namespace VersOne.Epub.Schema -{ - public class EpubMetadataCreator - { - public string Creator { get; set; } - public string FileAs { get; set; } - public string Role { get; set; } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubMetadataDate.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubMetadataDate.cs deleted file mode 100644 index 816aed5..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubMetadataDate.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -namespace VersOne.Epub.Schema -{ - public class EpubMetadataDate - { - public string Date { get; set; } - public string Event { get; set; } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubMetadataIdentifier.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubMetadataIdentifier.cs deleted file mode 100644 index c46699f..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubMetadataIdentifier.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -namespace VersOne.Epub.Schema -{ - public class EpubMetadataIdentifier - { - public string Id { get; set; } - public string Scheme { get; set; } - public string Identifier { get; set; } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubMetadataMeta.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubMetadataMeta.cs deleted file mode 100644 index 6a3eda3..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubMetadataMeta.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -namespace VersOne.Epub.Schema -{ - public class EpubMetadataMeta - { - public string Name { get; set; } - public string Content { get; set; } - public string Id { get; set; } - public string Refines { get; set; } - public string Property { get; set; } - public string Scheme { get; set; } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubPackage.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubPackage.cs deleted file mode 100644 index 75d1723..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubPackage.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -namespace VersOne.Epub.Schema -{ - public class EpubPackage - { - public EpubVersion EpubVersion { get; set; } - public EpubMetadata Metadata { get; set; } - public EpubManifest Manifest { get; set; } - public EpubSpine Spine { get; set; } - public EpubGuide Guide { get; set; } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubSpine.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubSpine.cs deleted file mode 100644 index 5a8502f..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubSpine.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System.Collections.Generic; - -namespace VersOne.Epub.Schema -{ - public class EpubSpine : List - { - public string Toc { get; set; } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubSpineItemRef.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubSpineItemRef.cs deleted file mode 100644 index 5d87d77..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubSpineItemRef.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -namespace VersOne.Epub.Schema -{ - public class EpubSpineItemRef - { - public string IdRef { get; set; } - public bool IsLinear { get; set; } - - public override string ToString() - { - return string.Concat("IdRef: ", IdRef); - } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubVersion.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubVersion.cs deleted file mode 100644 index 3b7b927..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Schema/Opf/EpubVersion.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -namespace VersOne.Epub.Schema -{ - public enum EpubVersion - { - EPUB_2 = 2, - EPUB_3 - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Utils/XmlUtils.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Utils/XmlUtils.cs deleted file mode 100644 index 0c5dade..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Utils/XmlUtils.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System.IO; -using System.Threading.Tasks; -using System.Xml; -using System.Xml.Linq; - -namespace VersOne.Epub.Internal -{ - internal static class XmlUtils - { - public static async Task LoadDocumentAsync(Stream stream) - { - using (var memoryStream = new MemoryStream()) - { - await stream.CopyToAsync(memoryStream).ConfigureAwait(false); - memoryStream.Position = 0; - var xmlReaderSettings = new XmlReaderSettings - { - DtdProcessing = DtdProcessing.Ignore, - Async = true - }; - using (var xmlReader = XmlReader.Create(memoryStream, xmlReaderSettings)) - { - return await Task.Run(() => XDocument.Load(memoryStream)).ConfigureAwait(false); - } - } - } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Utils/ZipPathUtils.cs b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Utils/ZipPathUtils.cs deleted file mode 100644 index 1432750..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubReader/Utils/ZipPathUtils.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright © 2018 Marco Gavelli and Paddy Xu -// -// This file is part of QuickLook program. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -namespace VersOne.Epub.Internal -{ - internal static class ZipPathUtils - { - public static string GetDirectoryPath(string filePath) - { - var lastSlashIndex = filePath.LastIndexOf('/'); - if (lastSlashIndex == -1) - return string.Empty; - return filePath.Substring(0, lastSlashIndex); - } - - public static string Combine(string directory, string fileName) - { - if (string.IsNullOrEmpty(directory)) - return fileName; - return string.Concat(directory, "/", fileName); - } - } -} \ No newline at end of file diff --git a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubViewerControl.xaml b/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubViewerControl.xaml deleted file mode 100644 index 558096d..0000000 --- a/QuickLook.Plugin/QuickLook.Plugin.EpubViewer/EpubViewerControl.xaml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - -