EPUB 3 preparations + embed HTML images as base 64
git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@226 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
parent
951bcc0f85
commit
53c84ca717
21 changed files with 209 additions and 61 deletions
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2014 by Henrik Just
|
||||
* Copyright: 2002-2015 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.4 (2014-09-24)
|
||||
* Version 1.6 (2015-01-14)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -47,6 +47,8 @@ import java.util.Vector;
|
|||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
|
@ -100,6 +102,7 @@ public class DrawConverter extends ConverterHelper {
|
|||
private String sImageSplit;
|
||||
private boolean bCoverImage;
|
||||
private boolean bEmbedSVG;
|
||||
private boolean bEmbedImg;
|
||||
|
||||
// Embedded SVG images for recycling are collected here
|
||||
private HashMap<String,Element> svgImages = new HashMap<String,Element>();
|
||||
|
@ -113,7 +116,7 @@ public class DrawConverter extends ConverterHelper {
|
|||
private Vector<Element> fullscreenFrames = new Vector<Element>();
|
||||
// This flag determines whether to collect full screen images or insert them immediately
|
||||
private boolean bCollectFullscreenFrames = true;
|
||||
|
||||
|
||||
public DrawConverter(OfficeReader ofr, XhtmlConfig config, Converter converter) {
|
||||
super(ofr,config,converter);
|
||||
// We can only handle one form; pick an arbitrary one.
|
||||
|
@ -130,6 +133,7 @@ public class DrawConverter extends ConverterHelper {
|
|||
sImageSplit = config.imageSplit();
|
||||
bCoverImage = config.coverImage();
|
||||
bEmbedSVG = config.embedSVG();
|
||||
bEmbedImg = config.embedImg();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
@ -516,21 +520,28 @@ public class DrawConverter extends ConverterHelper {
|
|||
}
|
||||
}
|
||||
else {
|
||||
// In all other cases, create an img element
|
||||
if (bgd!=null && !bgd.isLinked() && !bgd.isRecycled()) { converter.addDocument(bgd); }
|
||||
// In all other cases, create an img element
|
||||
if (bgd!=null && !bgd.isLinked() && !bgd.isRecycled() && !bEmbedImg) { converter.addDocument(bgd); }
|
||||
Element image = converter.createElement("img");
|
||||
String sName = Misc.getAttribute(getFrame(onode),XMLString.DRAW_NAME);
|
||||
converter.addTarget(image,sName+"|graphic");
|
||||
image.setAttribute("src",sFileName);
|
||||
|
||||
if (!bEmbedImg || bgd.isLinked()) {
|
||||
image.setAttribute("src",sFileName);
|
||||
}
|
||||
else {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("data:").append(bgd.getMIMEType()).append(";base64,")
|
||||
.append(DatatypeConverter.printBase64Binary(bgd.getData()));
|
||||
image.setAttribute("src", buf.toString());
|
||||
}
|
||||
// Add alternative text, using either alt.text, name or file name
|
||||
Element desc = Misc.getChildByTagName(frame,XMLString.SVG_DESC);
|
||||
if (desc==null) {
|
||||
desc = Misc.getChildByTagName(frame,XMLString.SVG_TITLE);
|
||||
desc = Misc.getChildByTagName(frame,XMLString.SVG_TITLE);
|
||||
}
|
||||
String sAltText = desc!=null ? Misc.getPCDATA(desc) : (sName!=null ? sName : sFileName);
|
||||
image.setAttribute("alt",sAltText);
|
||||
imageElement = image;
|
||||
imageElement = image;
|
||||
}
|
||||
|
||||
if (imageElement!=null) {
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2014 by Henrik Just
|
||||
* Copyright: 2002-2015 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.6 (2014-10-24)
|
||||
* Version 1.6 (2015-01-14)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -41,7 +41,7 @@ import writer2latex.util.Misc;
|
|||
|
||||
public class XhtmlConfig extends writer2latex.base.ConfigBase {
|
||||
// Implement configuration methods
|
||||
protected int getOptionCount() { return 56; }
|
||||
protected int getOptionCount() { return 57; }
|
||||
protected String getDefaultConfigPath() { return "/writer2latex/xhtml/config/"; }
|
||||
|
||||
// Override setOption: To be backwards compatible, we must accept options
|
||||
|
@ -144,18 +144,19 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
|
|||
private static final int IMAGE_SPLIT = 41;
|
||||
private static final int COVER_IMAGE = 42;
|
||||
private static final int EMBED_SVG = 43;
|
||||
private static final int USE_MATHJAX = 44;
|
||||
private static final int CALC_SPLIT = 45;
|
||||
private static final int DISPLAY_HIDDEN_SHEETS = 46;
|
||||
private static final int DISPLAY_HIDDEN_ROWS_COLS = 47;
|
||||
private static final int DISPLAY_FILTERED_ROWS_COLS = 48;
|
||||
private static final int APPLY_PRINT_RANGES = 49;
|
||||
private static final int USE_TITLE_AS_HEADING = 50;
|
||||
private static final int USE_SHEET_NAMES_AS_HEADINGS = 51;
|
||||
private static final int SAVE_IMAGES_IN_SUBDIR = 52;
|
||||
private static final int UPLINK = 53;
|
||||
private static final int DIRECTORY_ICON = 54;
|
||||
private static final int DOCUMENT_ICON = 55;
|
||||
private static final int EMBED_IMG = 44;
|
||||
private static final int USE_MATHJAX = 45;
|
||||
private static final int CALC_SPLIT = 46;
|
||||
private static final int DISPLAY_HIDDEN_SHEETS = 47;
|
||||
private static final int DISPLAY_HIDDEN_ROWS_COLS = 48;
|
||||
private static final int DISPLAY_FILTERED_ROWS_COLS = 49;
|
||||
private static final int APPLY_PRINT_RANGES = 50;
|
||||
private static final int USE_TITLE_AS_HEADING = 51;
|
||||
private static final int USE_SHEET_NAMES_AS_HEADINGS = 52;
|
||||
private static final int SAVE_IMAGES_IN_SUBDIR = 53;
|
||||
private static final int UPLINK = 54;
|
||||
private static final int DIRECTORY_ICON = 55;
|
||||
private static final int DOCUMENT_ICON = 56;
|
||||
|
||||
protected ComplexOption xheading = addComplexOption("heading-map");
|
||||
protected ComplexOption xpar = addComplexOption("paragraph-map");
|
||||
|
@ -274,6 +275,7 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
|
|||
options[IMAGE_SPLIT] = new Option("image_split","none");
|
||||
options[COVER_IMAGE] = new BooleanOption("cover_image","false");
|
||||
options[EMBED_SVG] = new BooleanOption("embed_svg","false");
|
||||
options[EMBED_IMG] = new BooleanOption("embed_img","false");
|
||||
options[USE_MATHJAX] = new BooleanOption("use_mathjax","false");
|
||||
options[CALC_SPLIT] = new BooleanOption("calc_split","false");
|
||||
options[DISPLAY_HIDDEN_SHEETS] = new BooleanOption("display_hidden_sheets", "false");
|
||||
|
@ -413,6 +415,7 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
|
|||
public String imageSplit() { return options[IMAGE_SPLIT].getString(); }
|
||||
public boolean coverImage() { return ((BooleanOption) options[COVER_IMAGE]).getValue(); }
|
||||
public boolean embedSVG() { return ((BooleanOption) options[EMBED_SVG]).getValue(); }
|
||||
public boolean embedImg() { return ((BooleanOption) options[EMBED_IMG]).getValue(); }
|
||||
public boolean useMathJax() { return ((BooleanOption) options[USE_MATHJAX]).getValue(); }
|
||||
public boolean xhtmlCalcSplit() { return ((BooleanOption) options[CALC_SPLIT]).getValue(); }
|
||||
public boolean xhtmlDisplayHiddenSheets() { return ((BooleanOption) options[DISPLAY_HIDDEN_SHEETS]).getValue(); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue