EPUB changes: Revised internal structure of document, changed some defaults and started meta data editor
git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@89 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
parent
2887a53143
commit
a524ca933d
23 changed files with 381 additions and 264 deletions
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2011-02-14)
|
||||
* Version 1.2 (2011-02-20)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -32,8 +32,8 @@ package writer2latex.api;
|
|||
public class ConverterFactory {
|
||||
|
||||
// Version information
|
||||
private static final String VERSION = "1.1.6";
|
||||
private static final String DATE = "2011-02-14";
|
||||
private static final String VERSION = "1.1.7";
|
||||
private static final String DATE = "2011-02-20";
|
||||
|
||||
/** Return the Writer2LaTeX version in the form
|
||||
* (major version).(minor version).(patch level)<br/>
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2010 by Henrik Just
|
||||
* Copyright: 2002-2011 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2010-12-21)
|
||||
* Version 1.2 (2011-02-19)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -97,7 +97,7 @@ public abstract class ConverterBase implements Converter {
|
|||
odDoc.read(is);
|
||||
ofr = new OfficeReader(odDoc,false);
|
||||
metaData = new MetaData(odDoc);
|
||||
imageLoader = new ImageLoader(odDoc,sTargetFileName,true);
|
||||
imageLoader = new ImageLoader(odDoc,true);
|
||||
imageLoader.setGraphicConverter(graphicConverter);
|
||||
|
||||
// Prepare output
|
||||
|
|
|
@ -45,7 +45,7 @@ public final class EPUBConverter extends Xhtml11Converter {
|
|||
|
||||
@Override public ConverterResult convert(InputStream is, String sTargetFileName) throws IOException {
|
||||
setOPS(true);
|
||||
ConverterResult xhtmlResult = super.convert(is, sTargetFileName);
|
||||
ConverterResult xhtmlResult = super.convert(is, "chapter");
|
||||
|
||||
ConverterResultImpl epubResult = new ConverterResultImpl();
|
||||
epubResult.addDocument(new EPUBWriter(xhtmlResult,sTargetFileName,getXhtmlConfig()));
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2001-2010 by Henrik Just
|
||||
* Copyright: 2001-2011 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* version 1.2 (2010-12-20)
|
||||
* version 1.2 (2011-02-17)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -89,7 +89,7 @@ public class EPUBWriter implements OutputFile {
|
|||
zos.closeEntry();
|
||||
|
||||
// Then manifest
|
||||
OPFWriter manifest = new OPFWriter(xhtmlResult, config.xhtmlUseDublinCore());
|
||||
OPFWriter manifest = new OPFWriter(xhtmlResult, config.xhtmlUseDublinCore(), config.useCustomMetadata());
|
||||
ZipEntry manifestEntry = new ZipEntry("OEBPS/book.opf");
|
||||
zos.putNextEntry(manifestEntry);
|
||||
writeZipEntry(manifest,zos);
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2001-2010 by Henrik Just
|
||||
* Copyright: 2001-2011 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* version 1.2 (2010-12-20)
|
||||
* version 1.2 (2011-02-17)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -51,7 +51,7 @@ import writer2latex.xmerge.NewDOMDocument;
|
|||
public class OPFWriter extends NewDOMDocument {
|
||||
private String sUID=null;
|
||||
|
||||
public OPFWriter(ConverterResult cr, boolean bUseDublinCore) {
|
||||
public OPFWriter(ConverterResult cr, boolean bUseDublinCore, boolean bUseCustomMetadata) {
|
||||
super("book", "opf");
|
||||
|
||||
// create DOM
|
||||
|
@ -108,84 +108,86 @@ public class OPFWriter extends NewDOMDocument {
|
|||
boolean bHasIdentifier = false;
|
||||
boolean bHasCreator = false;
|
||||
boolean bHasDate = false;
|
||||
// First rearrange the user-defined meta data
|
||||
Map<String,String> userDefinedMetaData = cr.getMetaData().getUserDefinedMetaData();
|
||||
Map<String,String[]> dc = new HashMap<String,String[]>();
|
||||
for (String sKey : userDefinedMetaData.keySet()) {
|
||||
if (sKey.length()>0) {
|
||||
String[] sValue = new String[2];
|
||||
sValue[0] = userDefinedMetaData.get(sKey);
|
||||
String sNewKey;
|
||||
int nDot = sKey.indexOf(".");
|
||||
if (nDot>0) {
|
||||
sNewKey = sKey.substring(0, nDot).toLowerCase();
|
||||
sValue[1] = sKey.substring(nDot+1);
|
||||
}
|
||||
else {
|
||||
sNewKey = sKey.toLowerCase();
|
||||
sValue[1] = null;
|
||||
}
|
||||
dc.put(sNewKey, sValue);
|
||||
}
|
||||
}
|
||||
// Then export it
|
||||
String[] sKeys = Misc.sortStringSet(dc.keySet());
|
||||
for (String sKey : sKeys) {
|
||||
String sValue = dc.get(sKey)[0];
|
||||
String sAttributeValue = dc.get(sKey)[1];
|
||||
if (sKey.startsWith("identifier")) {
|
||||
Element identifier = appendElement(contentDOM, metadata, "dc:identifier", sValue);
|
||||
if (!bHasIdentifier) { // The first identifier is the unique ID
|
||||
identifier.setAttribute("id", "BookId");
|
||||
sUID = sValue;
|
||||
}
|
||||
if (sAttributeValue!=null) {
|
||||
identifier.setAttribute("opf:scheme", sAttributeValue);
|
||||
}
|
||||
bHasIdentifier = true;
|
||||
}
|
||||
else if (sKey.startsWith("creator")) {
|
||||
Element creator = appendElement(contentDOM, metadata, "dc:creator", sValue);
|
||||
if (sAttributeValue!=null) {
|
||||
creator.setAttribute("opf:role", sAttributeValue);
|
||||
}
|
||||
bHasCreator = true;
|
||||
}
|
||||
else if (sKey.startsWith("contributor")) {
|
||||
Element contributor = appendElement(contentDOM, metadata, "dc:contributor", sValue);
|
||||
if (sAttributeValue!=null) {
|
||||
contributor.setAttribute("opf:role", sAttributeValue);
|
||||
if (bUseCustomMetadata) {
|
||||
// First rearrange the user-defined meta data
|
||||
Map<String,String> userDefinedMetaData = cr.getMetaData().getUserDefinedMetaData();
|
||||
Map<String,String[]> dc = new HashMap<String,String[]>();
|
||||
for (String sKey : userDefinedMetaData.keySet()) {
|
||||
if (sKey.length()>0) {
|
||||
String[] sValue = new String[2];
|
||||
sValue[0] = userDefinedMetaData.get(sKey);
|
||||
String sNewKey;
|
||||
int nDot = sKey.indexOf(".");
|
||||
if (nDot>0) {
|
||||
sNewKey = sKey.substring(0, nDot).toLowerCase();
|
||||
sValue[1] = sKey.substring(nDot+1);
|
||||
}
|
||||
else {
|
||||
sNewKey = sKey.toLowerCase();
|
||||
sValue[1] = null;
|
||||
}
|
||||
dc.put(sNewKey, sValue);
|
||||
}
|
||||
}
|
||||
else if (sKey.startsWith("date")) {
|
||||
Element date = appendElement(contentDOM, metadata, "dc:date", sValue);
|
||||
if (sAttributeValue!=null) {
|
||||
date.setAttribute("opf:event", sAttributeValue);
|
||||
// Then export it
|
||||
String[] sKeys = Misc.sortStringSet(dc.keySet());
|
||||
for (String sKey : sKeys) {
|
||||
String sValue = dc.get(sKey)[0];
|
||||
String sAttributeValue = dc.get(sKey)[1];
|
||||
if (sKey.startsWith("identifier")) {
|
||||
Element identifier = appendElement(contentDOM, metadata, "dc:identifier", sValue);
|
||||
if (!bHasIdentifier) { // The first identifier is the unique ID
|
||||
identifier.setAttribute("id", "BookId");
|
||||
sUID = sValue;
|
||||
}
|
||||
if (sAttributeValue!=null) {
|
||||
identifier.setAttribute("opf:scheme", sAttributeValue);
|
||||
}
|
||||
bHasIdentifier = true;
|
||||
}
|
||||
bHasDate = true;
|
||||
}
|
||||
// Remaining properties must be unique and has not attributes, hence
|
||||
else if (sAttributeValue==null) {
|
||||
if ("publisher".equals(sKey)) {
|
||||
appendElement(contentDOM, metadata, "dc:publisher", sValue);
|
||||
else if (sKey.startsWith("creator")) {
|
||||
Element creator = appendElement(contentDOM, metadata, "dc:creator", sValue);
|
||||
if (sAttributeValue!=null) {
|
||||
creator.setAttribute("opf:role", sAttributeValue);
|
||||
}
|
||||
bHasCreator = true;
|
||||
}
|
||||
else if ("type".equals(sKey)) {
|
||||
appendElement(contentDOM, metadata, "dc:type", sValue);
|
||||
else if (sKey.startsWith("contributor")) {
|
||||
Element contributor = appendElement(contentDOM, metadata, "dc:contributor", sValue);
|
||||
if (sAttributeValue!=null) {
|
||||
contributor.setAttribute("opf:role", sAttributeValue);
|
||||
}
|
||||
}
|
||||
else if ("format".equals(sKey)) {
|
||||
appendElement(contentDOM, metadata, "dc:format", sValue);
|
||||
else if (sKey.startsWith("date")) {
|
||||
Element date = appendElement(contentDOM, metadata, "dc:date", sValue);
|
||||
if (sAttributeValue!=null) {
|
||||
date.setAttribute("opf:event", sAttributeValue);
|
||||
}
|
||||
bHasDate = true;
|
||||
}
|
||||
else if ("source".equals(sKey)) {
|
||||
appendElement(contentDOM, metadata, "dc:source", sValue);
|
||||
}
|
||||
else if ("relation".equals(sKey)) {
|
||||
appendElement(contentDOM, metadata, "dc:relation", sValue);
|
||||
}
|
||||
else if ("coverage".equals(sKey)) {
|
||||
appendElement(contentDOM, metadata, "dc:coverage", sValue);
|
||||
}
|
||||
else if ("rights".equals(sKey)) {
|
||||
appendElement(contentDOM, metadata, "dc:rights", sValue);
|
||||
// Remaining properties must be unique and has not attributes, hence
|
||||
else if (sAttributeValue==null) {
|
||||
if ("publisher".equals(sKey)) {
|
||||
appendElement(contentDOM, metadata, "dc:publisher", sValue);
|
||||
}
|
||||
else if ("type".equals(sKey)) {
|
||||
appendElement(contentDOM, metadata, "dc:type", sValue);
|
||||
}
|
||||
else if ("format".equals(sKey)) {
|
||||
appendElement(contentDOM, metadata, "dc:format", sValue);
|
||||
}
|
||||
else if ("source".equals(sKey)) {
|
||||
appendElement(contentDOM, metadata, "dc:source", sValue);
|
||||
}
|
||||
else if ("relation".equals(sKey)) {
|
||||
appendElement(contentDOM, metadata, "dc:relation", sValue);
|
||||
}
|
||||
else if ("coverage".equals(sKey)) {
|
||||
appendElement(contentDOM, metadata, "dc:coverage", sValue);
|
||||
}
|
||||
else if ("rights".equals(sKey)) {
|
||||
appendElement(contentDOM, metadata, "dc:rights", sValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2010 by Henrik Just
|
||||
* Copyright: 2002-2011 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2010-11-21)
|
||||
* Version 1.2 (2011-02-19)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -124,9 +124,11 @@ public final class ConverterPalette extends ConverterBase {
|
|||
// fill out inner converter method
|
||||
public void convertInner() throws IOException {
|
||||
sTargetFileName = Misc.trimDocumentName(sTargetFileName,".tex");
|
||||
imageLoader.setOutFileName(new ExportNameCollection(true).getExportName(sTargetFileName));
|
||||
|
||||
imageLoader.setUseSubdir(config.saveImagesInSubdir());
|
||||
String sSafeTargetFileName = new ExportNameCollection(true).getExportName(sTargetFileName);
|
||||
imageLoader.setBaseFileName(sSafeTargetFileName+"-img");
|
||||
if (config.saveImagesInSubdir()) {
|
||||
imageLoader.setUseSubdir(sSafeTargetFileName+"-img");
|
||||
}
|
||||
|
||||
// Set graphics formats depending on backend
|
||||
if (config.getBackend()==LaTeXConfig.PDFTEX || config.getBackend()==LaTeXConfig.XETEX) {
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2009 by Henrik Just
|
||||
* Copyright: 2002-2011 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2009-12-07)
|
||||
* Version 1.2 (2011-02-19)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -55,8 +55,8 @@ public final class ImageLoader {
|
|||
private OfficeDocument oooDoc;
|
||||
|
||||
// Data for file name generation
|
||||
private String sOutFileName;
|
||||
private boolean bUseSubdir = false;
|
||||
private String sBaseFileName = "";
|
||||
private String sSubDirName = "";
|
||||
private int nImageCount = 0;
|
||||
private NumberFormat formatter;
|
||||
|
||||
|
@ -70,17 +70,16 @@ public final class ImageLoader {
|
|||
private String sDefaultVectorFormat = null;
|
||||
private HashSet<String> acceptedFormats = new HashSet<String>();
|
||||
|
||||
public ImageLoader(OfficeDocument oooDoc, String sOutFileName, boolean bExtractEPS) {
|
||||
public ImageLoader(OfficeDocument oooDoc, boolean bExtractEPS) {
|
||||
this.oooDoc = oooDoc;
|
||||
this.sOutFileName = sOutFileName;
|
||||
this.bExtractEPS = bExtractEPS;
|
||||
this.formatter = new DecimalFormat("000");
|
||||
}
|
||||
|
||||
public void setOutFileName(String sOutFileName) { this.sOutFileName = sOutFileName; }
|
||||
public void setBaseFileName(String sBaseFileName) { this.sBaseFileName = sBaseFileName; }
|
||||
|
||||
public void setUseSubdir(String sSubDirName) { this.sSubDirName = sSubDirName+"/"; }
|
||||
|
||||
public void setUseSubdir(boolean bUseSubdir) { this.bUseSubdir = bUseSubdir; }
|
||||
|
||||
public void setAcceptOtherFormats(boolean b) { bAcceptOtherFormats = b; }
|
||||
|
||||
public void setDefaultFormat(String sMime) {
|
||||
|
@ -146,8 +145,7 @@ public final class ImageLoader {
|
|||
if (blob==null) { return null; }
|
||||
|
||||
// Assign a name (without extension)
|
||||
String sName = sOutFileName+"-img"+formatter.format(++nImageCount);
|
||||
if (bUseSubdir) { sName = sOutFileName + "-img/" + sName; }
|
||||
String sName = sSubDirName+sBaseFileName+formatter.format(++nImageCount);
|
||||
|
||||
BinaryGraphicsDocument bgd = null;
|
||||
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2010 by Henrik Just
|
||||
* Copyright: 2002-2011 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2010-12-21)
|
||||
* Version 1.2 (2011-02-19)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -60,7 +60,7 @@ import writer2latex.util.ExportNameCollection;
|
|||
import writer2latex.util.Misc;
|
||||
|
||||
/**
|
||||
* <p>This class converts an OpenDocument file to an XHTML(+MathML) document.</p>
|
||||
* <p>This class converts an OpenDocument file to an XHTML(+MathML) or EPUB document.</p>
|
||||
*
|
||||
*/
|
||||
public class Converter extends ConverterBase {
|
||||
|
@ -87,7 +87,7 @@ public class Converter extends ConverterBase {
|
|||
// 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
|
||||
private boolean bOPS = false; // Do we need to be OPS conforming?
|
||||
|
@ -124,7 +124,7 @@ public class Converter extends ConverterBase {
|
|||
|
||||
@Override public void readStyleSheet(InputStream is) throws IOException {
|
||||
if (styleSheet==null) {
|
||||
styleSheet = new CssDocument("styles.css");
|
||||
styleSheet = new CssDocument("styles/styles.css");
|
||||
}
|
||||
styleSheet.read(is);
|
||||
}
|
||||
|
@ -201,7 +201,16 @@ public class Converter extends ConverterBase {
|
|||
|
||||
l10n = new L10n();
|
||||
|
||||
imageLoader.setUseSubdir(config.saveImagesInSubdir());
|
||||
if (isOPS()) {
|
||||
imageLoader.setBaseFileName("image");
|
||||
imageLoader.setUseSubdir("images");
|
||||
}
|
||||
else {
|
||||
imageLoader.setBaseFileName(sTargetFileName+"-img");
|
||||
if (config.saveImagesInSubdir()) {
|
||||
imageLoader.setUseSubdir(sTargetFileName+"-img");
|
||||
}
|
||||
}
|
||||
|
||||
imageLoader.setDefaultFormat(MIMETypes.PNG);
|
||||
imageLoader.addAcceptedFormat(MIMETypes.JPEG);
|
||||
|
@ -272,13 +281,15 @@ public class Converter extends ConverterBase {
|
|||
}
|
||||
}
|
||||
|
||||
// Export styles (temp.)
|
||||
for (int i=0; i<=nOutFileIndex; i++) {
|
||||
Element head = outFiles.get(i).getHeadNode();
|
||||
if (head!=null) {
|
||||
Node styles = styleCv.exportStyles(outFiles.get(i).getContentDOM());
|
||||
if (styles!=null) {
|
||||
head.appendChild(styles);
|
||||
// Export styles (XHTML)
|
||||
if (!isOPS()) {
|
||||
for (int i=0; i<=nOutFileIndex; i++) {
|
||||
Element head = outFiles.get(i).getHeadNode();
|
||||
if (head!=null) {
|
||||
Node styles = styleCv.exportStyles(outFiles.get(i).getContentDOM());
|
||||
if (styles!=null) {
|
||||
head.appendChild(styles);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -407,6 +418,12 @@ public class Converter extends ConverterBase {
|
|||
}
|
||||
}
|
||||
|
||||
// Export styles (EPUB)
|
||||
if (isOPS()) {
|
||||
CssDocument cssDoc = new CssDocument("styles/styles1.css");
|
||||
cssDoc.read(styleCv.exportStyles(false));
|
||||
converterResult.addDocument(cssDoc);
|
||||
}
|
||||
}
|
||||
|
||||
private void addNavigationLink(Document dom, Node node, String s, int nIndex) {
|
||||
|
@ -617,7 +634,7 @@ public class Converter extends ConverterBase {
|
|||
}
|
||||
}
|
||||
|
||||
// Add link to stylesheet, if producing nomral XHTML
|
||||
// Add link to custom stylesheet, if producing normal XHTML
|
||||
if (!bOPS && config.xhtmlCustomStylesheet().length()>0) {
|
||||
Element htmlStyle = htmlDOM.createElement("link");
|
||||
htmlStyle.setAttribute("rel","stylesheet");
|
||||
|
@ -626,26 +643,28 @@ public class Converter extends ConverterBase {
|
|||
htmlStyle.setAttribute("href",config.xhtmlCustomStylesheet());
|
||||
head.appendChild(htmlStyle);
|
||||
}
|
||||
/* later....
|
||||
if (nSplit>0 && !config.xhtmlIgnoreStyles()) {
|
||||
Element htmlStyle = htmlDOM.createElement("link");
|
||||
htmlStyle.setAttribute("rel","stylesheet");
|
||||
htmlStyle.setAttribute("type","text/css");
|
||||
htmlStyle.setAttribute("media","all");
|
||||
htmlStyle.setAttribute("href",oooDoc.getName()+"-styles.css");
|
||||
htmlHead.appendChild(htmlStyle);
|
||||
}*/
|
||||
// Note: For single output file, styles are exported to the doc at the end.
|
||||
|
||||
|
||||
// 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");
|
||||
sty.setAttribute("media", "all");
|
||||
sty.setAttribute("href", styleSheet.getFileName());
|
||||
sty.setAttribute("href", "stylesheet/"+styleSheet.getFileName());
|
||||
head.appendChild(sty);
|
||||
}
|
||||
|
||||
// Add link to generated stylesheet if producing OPS content
|
||||
if (isOPS() && config.xhtmlFormatting()>XhtmlConfig.IGNORE_STYLES) {
|
||||
Element htmlStyle = htmlDOM.createElement("link");
|
||||
htmlStyle.setAttribute("rel","stylesheet");
|
||||
htmlStyle.setAttribute("type","text/css");
|
||||
htmlStyle.setAttribute("media","all");
|
||||
htmlStyle.setAttribute("href","styles/styles1.css");
|
||||
head.appendChild(htmlStyle);
|
||||
}
|
||||
// Note: For XHTML, generated styles are exported to the doc at the end.
|
||||
|
||||
}
|
||||
|
||||
// Recreate nested sections, if any
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2010 by Henrik Just
|
||||
* Copyright: 2002-2011 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2010-04-12)
|
||||
* Version 1.2 (2011-02-17)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -82,6 +82,10 @@ public class CssDocument implements OutputFile {
|
|||
}
|
||||
sContent = buf.toString();
|
||||
}
|
||||
|
||||
public void read(String s) {
|
||||
sContent = s;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2010 by Henrik Just
|
||||
* Copyright: 2002-2011 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2010-12-29)
|
||||
* Version 1.2 (2011-02-17)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -121,11 +121,10 @@ class StyleConverter extends ConverterHelper {
|
|||
applyStyle(info,node);
|
||||
}
|
||||
}
|
||||
|
||||
// Export used styles to CSS
|
||||
public Node exportStyles(Document htmlDOM) {
|
||||
String sIndent = config.prettyPrint() ? " " : "";
|
||||
|
||||
|
||||
public String exportStyles(boolean bIndent) {
|
||||
String sIndent = bIndent ? " " : "";
|
||||
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
// Export default style
|
||||
|
@ -163,21 +162,26 @@ class StyleConverter extends ConverterHelper {
|
|||
buf.append(getFrameSc().getStyleDeclarations(sIndent));
|
||||
buf.append(getPresentationSc().getStyleDeclarations(sIndent));
|
||||
buf.append(getPageSc().getStyleDeclarations(sIndent));
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
// Export used styles to CSS
|
||||
public Node exportStyles(Document htmlDOM) {
|
||||
String sStyles = exportStyles(config.prettyPrint());
|
||||
|
||||
// Create node
|
||||
if (buf.length()>0) {
|
||||
if (sStyles.length()>0) {
|
||||
Element htmlStyle = htmlDOM.createElement("style");
|
||||
htmlStyle.setAttribute("media","all");
|
||||
htmlStyle.setAttribute("type","text/css");
|
||||
htmlStyle.appendChild(htmlDOM.createTextNode(config.prettyPrint() ? "\n" : " "));
|
||||
htmlStyle.appendChild(htmlDOM.createTextNode(buf.toString()));
|
||||
htmlStyle.appendChild(htmlDOM.createTextNode(sStyles));
|
||||
if (config.prettyPrint()) { htmlStyle.appendChild(htmlDOM.createTextNode(" ")); }
|
||||
return htmlStyle;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2010 by Henrik Just
|
||||
* Copyright: 2002-2011 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2010-12-28)
|
||||
* Version 1.2 (2011-02-17)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -41,7 +41,7 @@ import writer2latex.util.Misc;
|
|||
|
||||
public class XhtmlConfig extends writer2latex.base.ConfigBase {
|
||||
// Implement configuration methods
|
||||
protected int getOptionCount() { return 53; }
|
||||
protected int getOptionCount() { return 54; }
|
||||
protected String getDefaultConfigPath() { return "/writer2latex/xhtml/config/"; }
|
||||
|
||||
// Override setOption: To be backwards compatible, we must accept options
|
||||
|
@ -106,36 +106,37 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
|
|||
private static final int USE_DEFAULT_FONT = 20;
|
||||
private static final int DEFAULT_FONT_NAME = 21;
|
||||
private static final int USE_DUBLIN_CORE = 22;
|
||||
private static final int NOTES = 23;
|
||||
private static final int DISPLAY_HIDDEN_TEXT = 24;
|
||||
private static final int CONVERT_TO_PX = 25;
|
||||
private static final int SCALING = 26;
|
||||
private static final int COLUMN_SCALING = 27;
|
||||
private static final int RELATIVE_FONT_SIZE = 28;
|
||||
private static final int FONT_SCALING = 29;
|
||||
private static final int FLOAT_OBJECTS = 30;
|
||||
private static final int TABSTOP_STYLE = 31;
|
||||
private static final int FORMULAS = 32;
|
||||
private static final int ENDNOTES_HEADING = 33;
|
||||
private static final int EXTERNAL_TOC_DEPTH = 34;
|
||||
private static final int INCLUDE_TOC = 35;
|
||||
private static final int SPLIT_LEVEL = 36;
|
||||
private static final int REPEAT_LEVELS = 37;
|
||||
private static final int PAGE_BREAK_SPLIT = 38;
|
||||
private static final int SPLIT_AFTER = 39;
|
||||
private static final int CALC_SPLIT = 40;
|
||||
private static final int DISPLAY_HIDDEN_SHEETS = 41;
|
||||
private static final int DISPLAY_HIDDEN_ROWS_COLS = 42;
|
||||
private static final int DISPLAY_FILTERED_ROWS_COLS = 43;
|
||||
private static final int APPLY_PRINT_RANGES = 44;
|
||||
private static final int USE_TITLE_AS_HEADING = 45;
|
||||
private static final int USE_SHEET_NAMES_AS_HEADINGS = 46;
|
||||
private static final int XSLT_PATH = 47;
|
||||
private static final int SAVE_IMAGES_IN_SUBDIR = 48;
|
||||
private static final int UPLINK = 49;
|
||||
private static final int DIRECTORY_ICON = 50;
|
||||
private static final int DOCUMENT_ICON = 51;
|
||||
private static final int ZEN_HACK = 52; // temporary hack for ePub Zen Garden styles
|
||||
private static final int USE_CUSTOM_METADATA = 23;
|
||||
private static final int NOTES = 24;
|
||||
private static final int DISPLAY_HIDDEN_TEXT = 25;
|
||||
private static final int CONVERT_TO_PX = 26;
|
||||
private static final int SCALING = 27;
|
||||
private static final int COLUMN_SCALING = 28;
|
||||
private static final int RELATIVE_FONT_SIZE = 29;
|
||||
private static final int FONT_SCALING = 30;
|
||||
private static final int FLOAT_OBJECTS = 31;
|
||||
private static final int TABSTOP_STYLE = 32;
|
||||
private static final int FORMULAS = 33;
|
||||
private static final int ENDNOTES_HEADING = 34;
|
||||
private static final int EXTERNAL_TOC_DEPTH = 35;
|
||||
private static final int INCLUDE_TOC = 36;
|
||||
private static final int SPLIT_LEVEL = 37;
|
||||
private static final int REPEAT_LEVELS = 38;
|
||||
private static final int PAGE_BREAK_SPLIT = 39;
|
||||
private static final int SPLIT_AFTER = 40;
|
||||
private static final int CALC_SPLIT = 41;
|
||||
private static final int DISPLAY_HIDDEN_SHEETS = 42;
|
||||
private static final int DISPLAY_HIDDEN_ROWS_COLS = 43;
|
||||
private static final int DISPLAY_FILTERED_ROWS_COLS = 44;
|
||||
private static final int APPLY_PRINT_RANGES = 45;
|
||||
private static final int USE_TITLE_AS_HEADING = 46;
|
||||
private static final int USE_SHEET_NAMES_AS_HEADINGS = 47;
|
||||
private static final int XSLT_PATH = 48;
|
||||
private static final int SAVE_IMAGES_IN_SUBDIR = 49;
|
||||
private static final int UPLINK = 50;
|
||||
private static final int DIRECTORY_ICON = 51;
|
||||
private static final int DOCUMENT_ICON = 52;
|
||||
private static final int ZEN_HACK = 53; // temporary hack for ePub Zen Garden styles
|
||||
|
||||
protected ComplexOption xheading = addComplexOption("heading-map");
|
||||
protected ComplexOption xpar = addComplexOption("paragraph-map");
|
||||
|
@ -174,9 +175,10 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
|
|||
else { nValue = CSS1; }
|
||||
}
|
||||
};
|
||||
options[USE_DEFAULT_FONT] = new BooleanOption("use_default_font","true");
|
||||
options[USE_DEFAULT_FONT] = new BooleanOption("use_default_font","false");
|
||||
options[DEFAULT_FONT_NAME] = new BooleanOption("default_font_name","");
|
||||
options[USE_DUBLIN_CORE] = new BooleanOption("use_dublin_core","true");
|
||||
options[USE_CUSTOM_METADATA] = new BooleanOption("use_custom_metadata","true");
|
||||
options[NOTES] = new BooleanOption("notes","true");
|
||||
options[DISPLAY_HIDDEN_TEXT] = new BooleanOption("display_hidden_text", "false");
|
||||
options[CONVERT_TO_PX] = new BooleanOption("convert_to_px","true");
|
||||
|
@ -187,7 +189,7 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
|
|||
options[FLOAT_OBJECTS] = new BooleanOption("float_objects","true");
|
||||
options[TABSTOP_STYLE] = new Option("tabstop_style","");
|
||||
options[ENDNOTES_HEADING] = new Option("endnotes_heading","");
|
||||
options[FORMULAS] = new IntegerOption("formulas","starmath") {
|
||||
options[FORMULAS] = new IntegerOption("formulas","image+starmath") {
|
||||
@Override public void setString(String sValue) {
|
||||
super.setString(sValue);
|
||||
if ("latex".equals(sValue)) { nValue = LATEX; }
|
||||
|
@ -341,6 +343,7 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
|
|||
public boolean useDefaultFont() { return ((BooleanOption) options[USE_DEFAULT_FONT]).getValue(); }
|
||||
public String defaultFontName() { return options[DEFAULT_FONT_NAME].getString(); }
|
||||
public boolean xhtmlUseDublinCore() { return ((BooleanOption) options[USE_DUBLIN_CORE]).getValue(); }
|
||||
public boolean useCustomMetadata() { return ((BooleanOption) options[USE_CUSTOM_METADATA]).getValue(); }
|
||||
public boolean xhtmlNotes() { return ((BooleanOption) options[NOTES]).getValue(); }
|
||||
public boolean displayHiddenText() { return ((BooleanOption) options[DISPLAY_HIDDEN_TEXT]).getValue(); }
|
||||
public boolean xhtmlConvertToPx() { return ((BooleanOption) options[CONVERT_TO_PX]).getValue(); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue