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
|
@ -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