Writer2xhtml custom config ui + preparing for EPUB
git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@54 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
parent
e0cb22dd2e
commit
a58ea7fa19
26 changed files with 783 additions and 120 deletions
|
@ -98,7 +98,7 @@ public interface Config {
|
|||
/** Get a complex option
|
||||
*
|
||||
* @param sName the name of the complex option
|
||||
* @return
|
||||
* @return the option
|
||||
*/
|
||||
public ComplexOption getComplexOption(String sName);
|
||||
|
||||
|
|
61
source/java/writer2latex/api/ContentEntry.java
Normal file
61
source/java/writer2latex/api/ContentEntry.java
Normal file
|
@ -0,0 +1,61 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* ContentEntry.java
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2010 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2010-03-15)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.api;
|
||||
|
||||
/** This interface represents a content entry, that is a named reference
|
||||
* to a position within the output document.
|
||||
*/
|
||||
public interface ContentEntry {
|
||||
/** Get the outline level of this <code>ContentEntry</code>.
|
||||
* The top level is 1 (entries corresponding to indexes are considered
|
||||
* top level).
|
||||
* Note that intermediate levels may be missing (e.g. a heading of
|
||||
* level 3 may follow immediately after a heading of level 1).
|
||||
*
|
||||
* @return the outline level
|
||||
*/
|
||||
public int getLevel();
|
||||
|
||||
/** Get the title for this entry
|
||||
*
|
||||
* @return the title
|
||||
*/
|
||||
public String getTitle();
|
||||
|
||||
/** Get the file associated with the entry
|
||||
*
|
||||
* @return the output file
|
||||
*/
|
||||
public OutputFile getFile();
|
||||
|
||||
/** Get the name of a target within the file, if any
|
||||
*
|
||||
* @return the target name, or null if no target is needed
|
||||
*/
|
||||
public String getTarget();
|
||||
|
||||
}
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2008 by Henrik Just
|
||||
* Copyright: 2002-2010 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.0 (2008-11-24)
|
||||
* Version 1.2 (2010-03-16)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -46,6 +46,11 @@ public interface ConverterResult {
|
|||
*/
|
||||
public Iterator<OutputFile> iterator();
|
||||
|
||||
/** Get the meta data associated with the source document
|
||||
* @return the meta data
|
||||
*/
|
||||
public MetaData getMetaData();
|
||||
|
||||
/** Write all files of the <code>ConverterResult</code> to a directory.
|
||||
* Subdirectories are created as required by the individual
|
||||
* <code>OutputFile</code>s.
|
||||
|
|
45
source/java/writer2latex/api/MetaData.java
Normal file
45
source/java/writer2latex/api/MetaData.java
Normal file
|
@ -0,0 +1,45 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* MetaData.java
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2010 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2010-03-15)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.api;
|
||||
|
||||
/** This interface provides access to the predefined meta data of the
|
||||
* source document (currently incomplete)
|
||||
*/
|
||||
public interface MetaData {
|
||||
/** Get the title of the source document
|
||||
*
|
||||
* @return the title (may return an empty string)
|
||||
*/
|
||||
public String getTitle();
|
||||
|
||||
/** Get the (main) language of the document
|
||||
*
|
||||
* @return the language
|
||||
*/
|
||||
public String getLanguage();
|
||||
|
||||
}
|
|
@ -52,17 +52,8 @@ public interface OutputFile {
|
|||
|
||||
/** Get the MIME type of the <code>OutputFile</code>.
|
||||
*
|
||||
* @return string reprensentation of the MIME type
|
||||
* @return string representation of the MIME type
|
||||
*/
|
||||
public String getMIMEType();
|
||||
|
||||
/** Get the sequence number of this <code>OutputFile</code>.
|
||||
* The master document has the sequence number 0.
|
||||
* Other files which are part of the main document flow has a unique, positive sequence number.
|
||||
* Auxiliary files like images always has the sequence number -1.
|
||||
*
|
||||
* @return the sequence number
|
||||
*/
|
||||
public int getSequenceNumber();
|
||||
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ import writer2latex.office.ImageLoader;
|
|||
import writer2latex.office.MetaData;
|
||||
import writer2latex.office.OfficeReader;
|
||||
import writer2latex.xmerge.EmbeddedObject;
|
||||
import writer2latex.xmerge.ConvertData;
|
||||
import writer2latex.xmerge.OfficeDocument;
|
||||
|
||||
/**<p>Abstract base implementation of <code>writer2latex.api.Converter</code></p>
|
||||
|
@ -58,12 +57,12 @@ public abstract class ConverterBase implements Converter {
|
|||
|
||||
// The output file(s)
|
||||
protected String sTargetFileName;
|
||||
protected ConvertData convertData;
|
||||
protected ConverterResultImpl convertData;
|
||||
|
||||
// Constructor
|
||||
public ConverterBase() {
|
||||
graphicConverter = null;
|
||||
convertData = new ConvertData();
|
||||
convertData = new ConverterResultImpl();
|
||||
}
|
||||
|
||||
// Implement the interface
|
||||
|
|
|
@ -1,46 +1,30 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
*
|
||||
* - GNU Lesser General Public License Version 2.1
|
||||
*
|
||||
* Sun Microsystems Inc., October, 2000
|
||||
*
|
||||
* GNU Lesser General Public License Version 2.1
|
||||
* =============================================
|
||||
* Copyright 2000 by Sun Microsystems, Inc.
|
||||
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
||||
*
|
||||
* Copyright: 2000 by Sun Microsystems, Inc.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): _______________________________________
|
||||
*
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
// This version is adapted for Writer2LaTeX
|
||||
// Change: The first document added will become the "master document" 2006/10/05
|
||||
// Version 1.0 (2008-11-24)
|
||||
*
|
||||
* ConverterResultImpl.java
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2010 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2010-03-22)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.xmerge;
|
||||
package writer2latex.base;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
|
@ -49,6 +33,7 @@ import java.util.Vector;
|
|||
import java.util.Iterator;
|
||||
|
||||
import writer2latex.api.ConverterResult;
|
||||
import writer2latex.api.MetaData;
|
||||
import writer2latex.api.OutputFile;
|
||||
|
||||
/**
|
||||
|
@ -58,9 +43,10 @@ import writer2latex.api.OutputFile;
|
|||
* name and a <code>Vector</code> of <code>OutputFile</code> objects.</p>
|
||||
*
|
||||
* @author Martin Maher
|
||||
* TODO: Rewrite to support extended API
|
||||
*/
|
||||
public class ConvertData implements ConverterResult {
|
||||
|
||||
public class ConverterResultImpl implements ConverterResult {
|
||||
|
||||
/**
|
||||
* Vector of <code>OutputFile</code> objects.
|
||||
*/
|
||||
|
@ -74,6 +60,8 @@ public class ConvertData implements ConverterResult {
|
|||
*/
|
||||
private String name;
|
||||
|
||||
private MetaData metaData = null;
|
||||
|
||||
|
||||
/**
|
||||
* Resets ConvertData. This empties all <code>OutputFile</code>
|
||||
|
@ -141,6 +129,14 @@ public class ConvertData implements ConverterResult {
|
|||
return v.iterator();
|
||||
}
|
||||
|
||||
public MetaData getMetaData() {
|
||||
return metaData;
|
||||
}
|
||||
|
||||
public void setMetaData(MetaData metaData) {
|
||||
this.metaData = metaData;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the number of <code>OutputFile</code> objects currently stored
|
|
@ -106,10 +106,6 @@ public class BibTeXDocument implements Document {
|
|||
return MIMETypes.BIBTEX;
|
||||
}
|
||||
|
||||
public int getSequenceNumber() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Writes out the <code>Document</code> content to the specified
|
||||
* <code>OutputStream</code>.</p>
|
||||
|
|
13
source/java/writer2latex/epub/Package.html
Normal file
13
source/java/writer2latex/epub/Package.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>The package writer2latex.epub</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<p>This package contains EPUB specific code.</p>
|
||||
<p>It contains a <code>writerlatex.api.Converter</code> implementation for
|
||||
conversion into EPUB.</p>
|
||||
</body>
|
||||
</html>
|
|
@ -174,7 +174,7 @@ public final class ConverterPalette extends ConverterBase {
|
|||
info = new Info(ofr,config,this);
|
||||
|
||||
// Create master document and add this
|
||||
this.texDoc = new LaTeXDocument(sTargetFileName,config.getWrapLinesAfter(),0);
|
||||
this.texDoc = new LaTeXDocument(sTargetFileName,config.getWrapLinesAfter());
|
||||
if (config.getBackend()!=LaTeXConfig.XETEX) {
|
||||
texDoc.setEncoding(ClassicI18n.writeJavaEncoding(config.getInputencoding()));
|
||||
}
|
||||
|
|
|
@ -49,8 +49,6 @@ public class LaTeXDocument implements Document {
|
|||
|
||||
private LaTeXDocumentPortion contents;
|
||||
|
||||
private int nSequenceNumber = -1;
|
||||
|
||||
/**
|
||||
* <p>Constructs a new LaTeX Document.</p>
|
||||
*
|
||||
|
@ -59,12 +57,10 @@ public class LaTeXDocument implements Document {
|
|||
*
|
||||
* @param sName The name of the <code>LaTeXDocument</code>.
|
||||
* @param nWrap Lines should be wrapped after this position
|
||||
* @param nSequenceNumber this file has this sequence number in the result
|
||||
*/
|
||||
public LaTeXDocument(String sName,int nWrap, int nSequenceNumber) {
|
||||
public LaTeXDocument(String sName,int nWrap) {
|
||||
this.nWrap = nWrap;
|
||||
this.sName = trimDocumentName(sName);
|
||||
this.nSequenceNumber = nSequenceNumber;
|
||||
contents = new LaTeXDocumentPortion(true);
|
||||
}
|
||||
|
||||
|
@ -104,10 +100,6 @@ public class LaTeXDocument implements Document {
|
|||
return MIMETypes.LATEX;
|
||||
}
|
||||
|
||||
public int getSequenceNumber() {
|
||||
return nSequenceNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Writes out the <code>Document</code> content to the specified
|
||||
* <code>OutputStream</code>.</p>
|
||||
|
|
|
@ -46,9 +46,6 @@ public class SectionConverter extends ConverterHelper {
|
|||
// Filenames for external sections
|
||||
private ExportNameCollection fileNames = new ExportNameCollection(true);
|
||||
|
||||
// Current sequence number (until this class creates further LaTeX files, the master file is the only document)
|
||||
private int nSequenceNumber = 0;
|
||||
|
||||
/** <p>Constructs a new <code>SectionStyleConverter</code>.</p>
|
||||
*/
|
||||
public SectionConverter(OfficeReader ofr, LaTeXConfig config,
|
||||
|
@ -83,7 +80,7 @@ public class SectionConverter extends ConverterHelper {
|
|||
|
||||
LaTeXDocumentPortion sectionLdp = ldp;
|
||||
if (sFileName!=null) {
|
||||
LaTeXDocument newDoc = new LaTeXDocument(sFileName,config.getWrapLinesAfter(),++nSequenceNumber);
|
||||
LaTeXDocument newDoc = new LaTeXDocument(sFileName,config.getWrapLinesAfter());
|
||||
if (config.getBackend()!=LaTeXConfig.XETEX) {
|
||||
newDoc.setEncoding(ClassicI18n.writeJavaEncoding(config.getInputencoding()));
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2008 by Henrik Just
|
||||
* Copyright: 2002-2010 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.0 (2008-11-23)
|
||||
* Version 1.2 (2010-03-15)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -38,7 +38,7 @@ import writer2latex.xmerge.OfficeDocument;
|
|||
/**
|
||||
* <p>This class represents the metadata of an OOo Writer document.</p>
|
||||
*/
|
||||
public class MetaData {
|
||||
public class MetaData implements writer2latex.api.MetaData {
|
||||
// Dublin Core
|
||||
private String sTitle = "";
|
||||
private String sCreator = "";
|
||||
|
|
|
@ -69,7 +69,7 @@ public class BatchConverterImpl extends BatchConverterBase {
|
|||
}
|
||||
|
||||
public void readTemplate(InputStream is) throws IOException {
|
||||
template = new XhtmlDocument("Template",XhtmlDocument.XHTML10,-1);
|
||||
template = new XhtmlDocument("Template",XhtmlDocument.XHTML10);
|
||||
try {
|
||||
template.read(is);
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ public class BatchConverterImpl extends BatchConverterBase {
|
|||
|
||||
public OutputFile createIndexFile(String sHeading, IndexPageEntry[] entries) {
|
||||
// Create the index page (with header/footer or from template)
|
||||
XhtmlDocument htmlDoc = new XhtmlDocument("index",XhtmlDocument.XHTML10,0);
|
||||
XhtmlDocument htmlDoc = new XhtmlDocument("index",XhtmlDocument.XHTML10);
|
||||
htmlDoc.setConfig(config);
|
||||
if (template!=null) { htmlDoc.readFromTemplate(template); }
|
||||
else { htmlDoc.createHeaderFooter(); }
|
||||
|
|
|
@ -102,7 +102,7 @@ public class Converter extends ConverterBase {
|
|||
|
||||
// override
|
||||
public void readTemplate(InputStream is) throws IOException {
|
||||
template = new XhtmlDocument("Template",nType,-1);
|
||||
template = new XhtmlDocument("Template",nType);
|
||||
template.read(is);
|
||||
}
|
||||
|
||||
|
@ -441,7 +441,7 @@ public class Converter extends ConverterBase {
|
|||
// Prepare next output file
|
||||
public Element nextOutFile() {
|
||||
if (nOutFileIndex>=0) { textCv.insertFootnotes(htmlDoc.getContentNode()); }
|
||||
htmlDoc = new XhtmlDocument(getOutFileName(++nOutFileIndex,false),nType,nOutFileIndex);
|
||||
htmlDoc = new XhtmlDocument(getOutFileName(++nOutFileIndex,false),nType);
|
||||
htmlDoc.setConfig(config);
|
||||
if (template!=null) { htmlDoc.readFromTemplate(template); }
|
||||
else if (bNeedHeaderFooter) { htmlDoc.createHeaderFooter(); }
|
||||
|
|
|
@ -79,9 +79,6 @@ public class XhtmlDocument extends DOMDocument {
|
|||
// Type of document
|
||||
private int nType;
|
||||
|
||||
// Sequence number
|
||||
private int nSequenceNumber;
|
||||
|
||||
// Configuration
|
||||
private String sEncoding = "UTF-8";
|
||||
private boolean bUseNamedEntities = false;
|
||||
|
@ -115,12 +112,10 @@ public class XhtmlDocument extends DOMDocument {
|
|||
* writer2latex.xmerge.DOMDocument.
|
||||
* @param name <code>Document</code> name.
|
||||
* @param nType the type of document
|
||||
* @param nSequenceNumber the sequence number of this file in the export
|
||||
*/
|
||||
public XhtmlDocument(String name, int nType, int nSequenceNumber) {
|
||||
public XhtmlDocument(String name, int nType) {
|
||||
super(name,sExtension[nType]);
|
||||
this.nType = nType;
|
||||
this.nSequenceNumber = nSequenceNumber;
|
||||
// Define publicId and systemId
|
||||
String sPublicId = null;
|
||||
String sSystemId = null;
|
||||
|
@ -178,10 +173,6 @@ public class XhtmlDocument extends DOMDocument {
|
|||
return "";
|
||||
}
|
||||
|
||||
@Override public int getSequenceNumber() {
|
||||
return nSequenceNumber;
|
||||
}
|
||||
|
||||
public Element getHeadNode() { return headNode; }
|
||||
|
||||
public Element getBodyNode() { return bodyNode; }
|
||||
|
|
|
@ -166,10 +166,5 @@ public class BinaryGraphicsDocument implements Document {
|
|||
public String getMIMEType() {
|
||||
return sMimeType;
|
||||
}
|
||||
|
||||
|
||||
public int getSequenceNumber() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
|
@ -393,15 +393,11 @@ public class DOMDocument
|
|||
return doc;
|
||||
}
|
||||
|
||||
// TODO: We need these because we implement OutputFile (don't do that..)
|
||||
// We need this because we implement OutputFile
|
||||
public String getMIMEType() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public int getSequenceNumber() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ public class OfficeDocument
|
|||
/** DOM <code>Document</code> of content.xml. */
|
||||
private Document styleDoc = null;
|
||||
|
||||
/** DOM <code>Docuemtn</code> of META-INF/manifest.xml. */
|
||||
/** DOM <code>Document</code> of META-INF/manifest.xml. */
|
||||
private Document manifestDoc = null;
|
||||
|
||||
private String documentName = null;
|
||||
|
@ -1288,9 +1288,5 @@ public class OfficeDocument
|
|||
return "";
|
||||
}
|
||||
|
||||
|
||||
public int getSequenceNumber() {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue