EPUB export + Writer2LaTeX help content
git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@59 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
parent
93d1e472c6
commit
a1102046c3
13 changed files with 532 additions and 81 deletions
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2010-04-12)
|
||||
* Version 1.2 (2010-04-16)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class ConverterFactory {
|
|||
|
||||
// Version information
|
||||
private static final String VERSION = "1.1.2";
|
||||
private static final String DATE = "2010-04-12";
|
||||
private static final String DATE = "2010-04-16";
|
||||
|
||||
/** Return the Writer2LaTeX version in the form
|
||||
* (major version).(minor version).(patch level)<br/>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2010-03-28)
|
||||
* Version 1.2 (2010-04-13)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -62,31 +62,49 @@ public interface ConverterResult {
|
|||
*/
|
||||
public List<ContentEntry> getContent();
|
||||
|
||||
/** Get the entry which contains the table of contents
|
||||
/** Get the entry which contains the table page
|
||||
*
|
||||
* @return the entry or null if there is no title page
|
||||
*/
|
||||
public ContentEntry getTitlePageFile();
|
||||
|
||||
/** Get the entry which contains the start of the actual text (the first chapter, or simply the start of
|
||||
* the document if there are no headings)
|
||||
*
|
||||
* @return the entry
|
||||
*/
|
||||
public ContentEntry getTextFile();
|
||||
|
||||
/** Get the entry which contains the table of contents
|
||||
*
|
||||
* @return the entry or null if a table of content does not exist
|
||||
*/
|
||||
public ContentEntry getTocFile();
|
||||
|
||||
|
||||
|
||||
/** Get the entry which contains the list of tables
|
||||
*
|
||||
* @return the entry
|
||||
* @return the entry or null if a list of tables does not exist
|
||||
*/
|
||||
public ContentEntry getLotFile();
|
||||
|
||||
/** Get the entry which contains the list of figures
|
||||
*
|
||||
* @return the entry
|
||||
* @return the entry or null if a list of figures does not exist
|
||||
*/
|
||||
public ContentEntry getLofFile();
|
||||
|
||||
/** Get the entry which contains the alphabetical index
|
||||
*
|
||||
* @return the entry
|
||||
* @return the entry or null if an alphabetical index does not exist
|
||||
*/
|
||||
public ContentEntry getIndexFile();
|
||||
|
||||
/** Get the entry which contains the bibliography
|
||||
*
|
||||
* @return the entry or null if a bibliography does not exist
|
||||
*/
|
||||
public ContentEntry getBibliographyFile();
|
||||
|
||||
/** Write all files of the <code>ConverterResult</code> to a directory.
|
||||
* Subdirectories are created as required by the individual
|
||||
* <code>OutputFile</code>s.
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2010-03-28)
|
||||
* Version 1.2 (2010-04-13)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -46,10 +46,13 @@ public class ConverterResultImpl implements ConverterResult {
|
|||
private List<OutputFile> files;
|
||||
|
||||
private List<ContentEntry> content;
|
||||
private ContentEntry titlePageFile;
|
||||
private ContentEntry textFile;
|
||||
private ContentEntry tocFile;
|
||||
private ContentEntry lofFile;
|
||||
private ContentEntry lotFile;
|
||||
private ContentEntry indexFile;
|
||||
private ContentEntry bibliographyFile;
|
||||
|
||||
private MetaData metaData = null;
|
||||
|
||||
|
@ -67,10 +70,13 @@ public class ConverterResultImpl implements ConverterResult {
|
|||
public void reset() {
|
||||
files = new Vector<OutputFile>();
|
||||
content = new Vector<ContentEntry>();
|
||||
titlePageFile = null;
|
||||
textFile = null;
|
||||
tocFile = null;
|
||||
lofFile = null;
|
||||
lotFile = null;
|
||||
indexFile = null;
|
||||
bibliographyFile = null;
|
||||
metaData = null;
|
||||
nMasterCount = 0;
|
||||
}
|
||||
|
@ -119,6 +125,30 @@ public class ConverterResultImpl implements ConverterResult {
|
|||
return Collections.unmodifiableList(content);
|
||||
}
|
||||
|
||||
/** Define the entry which contains the title page
|
||||
*
|
||||
* @param entry the entry
|
||||
*/
|
||||
public void setTitlePageFile(ContentEntry entry) {
|
||||
titlePageFile = entry;
|
||||
}
|
||||
|
||||
public ContentEntry getTitlePageFile() {
|
||||
return titlePageFile;
|
||||
}
|
||||
|
||||
/** Define the entry which contains the main text file
|
||||
*
|
||||
* @param entry the entry
|
||||
*/
|
||||
public void setTextFile(ContentEntry entry) {
|
||||
textFile = entry;
|
||||
}
|
||||
|
||||
public ContentEntry getTextFile() {
|
||||
return textFile;
|
||||
}
|
||||
|
||||
/** Define the entry which contains the table of contents
|
||||
*
|
||||
* @param entry the entry
|
||||
|
@ -167,6 +197,18 @@ public class ConverterResultImpl implements ConverterResult {
|
|||
return indexFile;
|
||||
}
|
||||
|
||||
/** Define the entry which contains the bibliography
|
||||
*
|
||||
* @param entry the entry
|
||||
*/
|
||||
public void setBibliographyFile(ContentEntry entry) {
|
||||
bibliographyFile = entry;
|
||||
}
|
||||
|
||||
public ContentEntry getBibliographyFile() {
|
||||
return bibliographyFile;
|
||||
}
|
||||
|
||||
/** Set the meta data of this <code>ConverterResult</code>
|
||||
*
|
||||
* @param metaData the meta data
|
||||
|
|
|
@ -129,15 +129,13 @@ public class OPFWriter extends NewDOMDocument {
|
|||
// The guide may contain references to some fundamental structural components
|
||||
Element guide = contentDOM.createElement("guide");
|
||||
pack.appendChild(guide);
|
||||
addGuideReference(contentDOM,guide,"title-page",cr.getTitlePageFile());
|
||||
addGuideReference(contentDOM,guide,"text",cr.getTextFile());
|
||||
addGuideReference(contentDOM,guide,"toc",cr.getTocFile());
|
||||
addGuideReference(contentDOM,guide,"index",cr.getIndexFile());
|
||||
addGuideReference(contentDOM,guide,"loi",cr.getLofFile());
|
||||
addGuideReference(contentDOM,guide,"lot",cr.getLotFile());
|
||||
// TODO addGuideReference(contentDOM,guide,"bibliography",cr.getBibliographyile());
|
||||
List<ContentEntry> contents = cr.getContent();
|
||||
if (contents.size()>0) {
|
||||
addGuideReference(contentDOM,guide,"text",contents.get(0));
|
||||
}
|
||||
addGuideReference(contentDOM,guide,"bibliography",cr.getBibliographyFile());
|
||||
|
||||
setContentDOM(contentDOM);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2010-04-12)
|
||||
* Version 1.2 (2010-04-13)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -44,6 +44,7 @@ import org.w3c.dom.NodeList;
|
|||
import org.w3c.dom.Text;
|
||||
|
||||
import writer2latex.api.Config;
|
||||
import writer2latex.api.ContentEntry;
|
||||
import writer2latex.api.ConverterFactory;
|
||||
//import writer2latex.api.ConverterResult;
|
||||
import writer2latex.base.ContentEntryImpl;
|
||||
|
@ -209,7 +210,6 @@ public class Converter extends ConverterBase {
|
|||
}
|
||||
}
|
||||
|
||||
//NodeList list;
|
||||
// Traverse the body
|
||||
Element body = ofr.getContent();
|
||||
if (ofr.isSpreadsheet()) { tableCv.convertTableContent(body); }
|
||||
|
@ -219,6 +219,21 @@ public class Converter extends ConverterBase {
|
|||
// Add footnotes and endnotes
|
||||
textCv.insertFootnotes(htmlDoc.getContentNode());
|
||||
textCv.insertEndnotes(htmlDoc.getContentNode());
|
||||
|
||||
// Set the title page and text page entries
|
||||
if (converterResult.getContent().isEmpty()) {
|
||||
// No headings in the document: There is no title page and the text page is the first page
|
||||
converterResult.setTextFile(new ContentEntryImpl("Text", 1, outFiles.get(0), null));
|
||||
// We also have to add a toc entry (the ncx file cannot be empty)
|
||||
converterResult.addContentEntry(new ContentEntryImpl("Text", 1, outFiles.get(0), null));
|
||||
}
|
||||
else {
|
||||
// The title page is the first page
|
||||
converterResult.setTitlePageFile(new ContentEntryImpl("Title page", 1, outFiles.get(0), null));
|
||||
// The text page is the one containing the first heading
|
||||
ContentEntry firstHeading = converterResult.getContent().get(0);
|
||||
converterResult.setTextFile(new ContentEntryImpl("Text", 1, firstHeading.getFile(), firstHeading.getTarget()));
|
||||
}
|
||||
|
||||
// Resolve links
|
||||
ListIterator<LinkDescriptor> iter = links.listIterator();
|
||||
|
@ -237,8 +252,8 @@ public class Converter extends ConverterBase {
|
|||
}
|
||||
}
|
||||
|
||||
// Add included style sheet, if any
|
||||
if (styleSheet!=null) {
|
||||
// Add included style sheet, if any - and we are creating OPS content
|
||||
if (bOPS && styleSheet!=null) {
|
||||
converterResult.addDocument(styleSheet);
|
||||
}
|
||||
|
||||
|
@ -529,42 +544,45 @@ public class Converter extends ConverterBase {
|
|||
meta.setAttribute("content","text/html; charset="+htmlDoc.getEncoding().toLowerCase());
|
||||
htmlDoc.getHeadNode().appendChild(meta);
|
||||
}
|
||||
|
||||
// "Traditional" meta data
|
||||
//createMeta("generator","Writer2LaTeX "+Misc.VERSION);
|
||||
createMeta("description",metaData.getDescription());
|
||||
createMeta("keywords",metaData.getKeywords());
|
||||
|
||||
// Add meta data (for EPUB the meta data belongs to the .opf file)
|
||||
if (!bOPS) {
|
||||
// "Traditional" meta data
|
||||
//createMeta("generator","Writer2LaTeX "+Misc.VERSION);
|
||||
createMeta("description",metaData.getDescription());
|
||||
createMeta("keywords",metaData.getKeywords());
|
||||
|
||||
// Dublin core meta data (optional)
|
||||
// Format as recommended on dublincore.org
|
||||
// Declare meta data profile
|
||||
if (config.xhtmlUseDublinCore()) {
|
||||
htmlDoc.getHeadNode().setAttribute("profile","http://dublincore.org/documents/dcq-html/");
|
||||
// Add link to declare namespace
|
||||
Element dclink = htmlDOM.createElement("link");
|
||||
dclink.setAttribute("rel","schema.DC");
|
||||
dclink.setAttribute("href","http://purl.org/dc/elements/1.1/");
|
||||
htmlDoc.getHeadNode().appendChild(dclink);
|
||||
// Insert the actual meta data
|
||||
createMeta("DC.title",metaData.getTitle());
|
||||
// DC.subject actually contains subject+keywords, so we merge them
|
||||
String sDCSubject = "";
|
||||
if (metaData.getSubject()!=null && metaData.getSubject().length()>0) {
|
||||
sDCSubject = metaData.getSubject();
|
||||
}
|
||||
if (metaData.getKeywords()!=null && metaData.getKeywords().length()>0) {
|
||||
if (sDCSubject.length()>0) { sDCSubject+=", "; }
|
||||
sDCSubject += metaData.getKeywords();
|
||||
}
|
||||
createMeta("DC.subject",sDCSubject);
|
||||
createMeta("DC.description",metaData.getDescription());
|
||||
createMeta("DC.creator",metaData.getCreator());
|
||||
createMeta("DC.date",metaData.getDate());
|
||||
createMeta("DC.language",metaData.getLanguage());
|
||||
// Dublin core meta data (optional)
|
||||
// Format as recommended on dublincore.org
|
||||
// Declare meta data profile
|
||||
if (config.xhtmlUseDublinCore()) {
|
||||
htmlDoc.getHeadNode().setAttribute("profile","http://dublincore.org/documents/dcq-html/");
|
||||
// Add link to declare namespace
|
||||
Element dclink = htmlDOM.createElement("link");
|
||||
dclink.setAttribute("rel","schema.DC");
|
||||
dclink.setAttribute("href","http://purl.org/dc/elements/1.1/");
|
||||
htmlDoc.getHeadNode().appendChild(dclink);
|
||||
// Insert the actual meta data
|
||||
createMeta("DC.title",metaData.getTitle());
|
||||
// DC.subject actually contains subject+keywords, so we merge them
|
||||
String sDCSubject = "";
|
||||
if (metaData.getSubject()!=null && metaData.getSubject().length()>0) {
|
||||
sDCSubject = metaData.getSubject();
|
||||
}
|
||||
if (metaData.getKeywords()!=null && metaData.getKeywords().length()>0) {
|
||||
if (sDCSubject.length()>0) { sDCSubject+=", "; }
|
||||
sDCSubject += metaData.getKeywords();
|
||||
}
|
||||
createMeta("DC.subject",sDCSubject);
|
||||
createMeta("DC.description",metaData.getDescription());
|
||||
createMeta("DC.creator",metaData.getCreator());
|
||||
createMeta("DC.date",metaData.getDate());
|
||||
createMeta("DC.language",metaData.getLanguage());
|
||||
}
|
||||
}
|
||||
|
||||
// Add link to stylesheet
|
||||
if (config.xhtmlCustomStylesheet().length()>0) {
|
||||
// Add link to stylesheet, if producing nomral XHTML
|
||||
if (!bOPS && config.xhtmlCustomStylesheet().length()>0) {
|
||||
Element htmlStyle = htmlDOM.createElement("link");
|
||||
htmlStyle.setAttribute("rel","stylesheet");
|
||||
htmlStyle.setAttribute("type","text/css");
|
||||
|
@ -583,8 +601,8 @@ public class Converter extends ConverterBase {
|
|||
}*/
|
||||
// Note: For single output file, styles are exported to the doc at the end.
|
||||
|
||||
// Add link to included style sheet
|
||||
if (styleSheet!=null) {
|
||||
// Add link to included style sheet if producing OPS content
|
||||
if (bOPS && styleSheet!=null) {
|
||||
Element sty = htmlDOM.createElement("link");
|
||||
sty.setAttribute("rel", "stylesheet");
|
||||
sty.setAttribute("type", "text/css");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue