Scribus Epub Export Plugin
epubexportStructure.h
1 /***************************************************************************
2  * *
3  * This program is free software; you can redistribute it and/or modify *
4  * it under the terms of the GNU General Public License as published by *
5  * the Free Software Foundation; either version 2 of the License, or *
6  * (at your option) any later version. *
7  * *
8  ***************************************************************************/
9 
10 #ifndef EPUBEXPORTSTRUCTURE_H
11 #define EPUBEXPORTSTRUCTURE_H
12 
13 #include <QObject>
14 #include <QDebug>
15 
16 #include "scribusapi.h" // for SCRIBUS_API
17 
18 #include "plugins/scribusAPI/scribusAPIDocument.h"
19 
20 /*
21 struct EpubExportStructureMetadata
22 {
23  QString title;
24  // Publications with multiple co-authors should provide multiple creator elements,
25  // each containing one author. The order of creator elements is presumed
26  // to define the order in which the creators' names should be presented by the Reading System.
27  //
28  // This specification recommends that the content of the creator elements hold the text
29  // for a single name as it would be presented to the Reader.
30  //
31  // This specification adds to the creator element two optional attributes: role and file-as.
32  // The set of values for role are identical to those defined in Section 2.2.6
33  // for the contributor element. The file-as attribute should be used
34  // to specify a normalized form of the contents, suitable for machine processing.
35  QString author;
36  QString subject; // multiple instances are allowed
37  QString date;
38  // <URN> ::= "urn:" <NID> ":" <NSS>
39  // <dc:identifier id="bookid">urn:uuid:ba151a94-2581-dbd1-144a-3ae968f738c7</dc:identifier>
40  // <dc:identifier id="BookId" opf:scheme="ISBN">123456789X</dc:identifier>
41  // TODO: add scheme to settings (http://en.wikipedia.org/wiki/Uniform_resource_name)
42  QString id;
43  QString language;
44  // it seems that keywords are treated as subjects in epub...
45  // sould we separate the keywords by ","? (ale/20120912)
46  QString keywords;
47  QString description; // labelled as description in scribus
48  QString publisher;
49  QString contributor; // A party whose contribution to the publication is secondary to those named in creator elements.
50  QString type;
51  QString format; // should be one of: event, image, interactive resource, moving image, physical object, service, software, sound, still image, text
52  QString source; // Information regarding a prior resource from which the publication was derived;
53  QString relation;
54  QString coverage; // space and time covered by the work
55  QString rights; // A statement about rights, or a reference to one. In this specification, the copyright notice and any further rights description should appear directly.
56  EpubExportStructureMetadata()
57  {
58  title = "";
59  author = "";
60  subject = "";
61  date = "";
62  id = "";
63  language = "";
64  keywords = "";
65  description = "";
66  publisher = "";
67  contributor = "";
68  type = "";
69  format = "";
70  source = "";
71  relation = "";
72  coverage = "";
73  rights = "";
74  }
75 };
76 */
77 
82 {
83  QString id;
84  QString href;
85  QString mediatype;
86  int section; // TODO: not filled yet: fill this instead of xhtmlFile
87  QString title; // TODO: not filled yet: fill this instead of xhtmlFile
88  QString filename; // TODO: not filled yet: fill this instead of xhtmlFile
90  {
91  id = "";
92  filename = "";
93  mediatype = "";
94  title = "";
95  section = 0;
96  href = "";
97  }
98 };
99 
100 
104 class EpubExportStructure : public QObject
105 {
106  Q_OBJECT
107 
108 public:
111 
112  void readMetadata(ScribusAPIDocumentMetadata metadata);
113  ScribusAPIDocumentMetadata getMetadata() {return metadata;}
114 
115  void setFilename(QString filename) {this->filename = filename;}
119  void addToManifest(EpubExportStructureManifestItem item) {this->manifest.append(item);}
120  void addToManifest(QString id, QString path, QString mediatype);
121  void addToToc(QString id, QString path, QString title);
125  void addToToc(EpubExportStructureManifestItem item) {this->toc.append(item);}
126  QString getOPF();
127  QString getNCX();
128  QString getContainer();
132  void setCover(QByteArray cover) {this->cover = cover;}
133  bool hasCover() {return !this->cover.isEmpty();}
134  QByteArray getCover();
135 private:
136  ScribusAPIDocumentMetadata metadata;
137  QString filename;
138  QVector<EpubExportStructureManifestItem> manifest;
139  QVector<EpubExportStructureManifestItem> toc;
140  QByteArray cover; // byte representation of the cover image
141 };
142 
143 QDebug operator<<(QDebug dbg, const EpubExportStructure &structure);
144 // QDebug operator<<(QDebug dbg, const EpubExportStructureMetadata &metadata);
145 QDebug operator<<(QDebug dbg, const EpubExportStructureManifestItem &item);
146 
147 #endif // EPUBEXPORTSTRUCTURE_H
void setCover(QByteArray cover)
Definition: epubexportStructure.h:132
void addToManifest(EpubExportStructureManifestItem item)
add an EpubExportStructureManifestItem to the manifest.
Definition: epubexportStructure.h:119
void addToToc(EpubExportStructureManifestItem item)
add an EpubExportStructureManifestItem to the table of contents.
Definition: epubexportStructure.h:125
Data structure collecting the information for a manifest item.
Definition: epubexportStructure.h:81
Contains the structure data of the Epub file (metadata, manifest, cover, Xml files, ...)
Definition: epubexportStructure.h:104