EPUB meta data, export dialog and style resources
git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@81 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
parent
e02f738e85
commit
0dcc851a33
21 changed files with 920 additions and 139 deletions
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2010-11-22)
|
||||
* Version 1.2 (2010-12-21)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -28,8 +28,10 @@ package writer2latex.xhtml;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.HashSet;
|
||||
import java.util.ListIterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Set;
|
||||
import java.util.Vector;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
|
@ -82,8 +84,9 @@ public class Converter extends ConverterBase {
|
|||
// The template
|
||||
private XhtmlDocument template = null;
|
||||
|
||||
// The included style sheet
|
||||
// The included style sheet and associated resources
|
||||
private CssDocument styleSheet = null;
|
||||
private Set<ResourceDocument> resources = new HashSet<ResourceDocument>();
|
||||
|
||||
// The xhtml output file(s)
|
||||
protected int nType = XhtmlDocument.XHTML10; // the doctype
|
||||
|
@ -109,7 +112,7 @@ public class Converter extends ConverterBase {
|
|||
this.nType = nType;
|
||||
}
|
||||
|
||||
// override methods to read templates and style sheets
|
||||
// override methods to read templates, style sheets and resources
|
||||
@Override public void readTemplate(InputStream is) throws IOException {
|
||||
template = new XhtmlDocument("Template",nType);
|
||||
template.read(is);
|
||||
|
@ -129,6 +132,16 @@ public class Converter extends ConverterBase {
|
|||
@Override public void readStyleSheet(File file) throws IOException {
|
||||
readStyleSheet(new FileInputStream(file));
|
||||
}
|
||||
|
||||
@Override public void readResource(InputStream is, String sFileName, String sMediaType) throws IOException {
|
||||
ResourceDocument doc = new ResourceDocument(sFileName, sMediaType);
|
||||
doc.read(is);
|
||||
resources.add(doc);
|
||||
}
|
||||
|
||||
@Override public void readResource(File file, String sFileName, String sMediaType) throws IOException {
|
||||
readResource(new FileInputStream(file), sFileName, sMediaType);
|
||||
}
|
||||
|
||||
protected StyleConverter getStyleCv() { return styleCv; }
|
||||
|
||||
|
@ -252,7 +265,11 @@ public class Converter extends ConverterBase {
|
|||
|
||||
// Add included style sheet, if any - and we are creating OPS content
|
||||
if (bOPS && styleSheet!=null) {
|
||||
// TODO: Move to subfolder
|
||||
converterResult.addDocument(styleSheet);
|
||||
for (ResourceDocument doc : resources) {
|
||||
converterResult.addDocument(doc);
|
||||
}
|
||||
}
|
||||
|
||||
// Export styles (temp.)
|
||||
|
|
79
source/java/writer2latex/xhtml/ResourceDocument.java
Normal file
79
source/java/writer2latex/xhtml/ResourceDocument.java
Normal file
|
@ -0,0 +1,79 @@
|
|||
/************************************************************************
|
||||
*
|
||||
* ResourceDocument.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-12-21)
|
||||
*
|
||||
*/
|
||||
|
||||
package writer2latex.xhtml;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import writer2latex.api.OutputFile;
|
||||
import writer2latex.util.Misc;
|
||||
|
||||
/**
|
||||
* An implementation of <code>OutputFile</code> for resource documents.
|
||||
* (A resource document is an arbitrary binary file to include in the converter result)
|
||||
*/
|
||||
public class ResourceDocument implements OutputFile {
|
||||
|
||||
// Content
|
||||
private String sFileName;
|
||||
private String sMediaType;
|
||||
private byte[] content;
|
||||
|
||||
/**
|
||||
* Constructor (creates an empty document)
|
||||
* @param sFileName <code>Document</code> name.
|
||||
* @param sMediaType the media type
|
||||
*/
|
||||
public ResourceDocument(String sFileName, String sMediaType) {
|
||||
this.sFileName = sFileName;
|
||||
this.sMediaType = sMediaType;
|
||||
content = new byte[0];
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return sFileName;
|
||||
}
|
||||
|
||||
public String getMIMEType() {
|
||||
return sMediaType;
|
||||
}
|
||||
|
||||
public boolean isMasterDocument() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void write(OutputStream os) throws IOException {
|
||||
os.write(content);
|
||||
}
|
||||
|
||||
public void read(InputStream is) throws IOException {
|
||||
content = Misc.inputStreamToByteArray(is);
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue