SVG support + merge spans + bugfixes
git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@170 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
parent
a336023983
commit
a0b76b3729
18 changed files with 212 additions and 130 deletions
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.4 (2014-08-27)
|
||||
* Version 1.4 (2014-09-05)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -262,7 +262,7 @@ public class Converter extends ConverterBase {
|
|||
imageConverter.addAcceptedFormat(MIMETypes.JPEG);
|
||||
imageConverter.addAcceptedFormat(MIMETypes.GIF);
|
||||
|
||||
if (nType==XhtmlDocument.HTML5 && config.useSVG()) { // HTML supports (inline) SVG as well
|
||||
if (nType==XhtmlDocument.HTML5) { // HTML supports SVG as well
|
||||
imageConverter.setDefaultVectorFormat(MIMETypes.SVG);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.4 (2014-09-03)
|
||||
* Version 1.4 (2014-09-05)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -128,7 +128,7 @@ public class DrawConverter extends ConverterHelper {
|
|||
nImageSize = config.imageSize();
|
||||
sImageSplit = config.imageSplit();
|
||||
bCoverImage = config.coverImage();
|
||||
bUseSVG = config.useSVG();
|
||||
bUseSVG = config.inlineSVG();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
@ -477,7 +477,7 @@ public class DrawConverter extends ConverterHelper {
|
|||
}
|
||||
else { // linked image
|
||||
if (!converter.isOPS()) { // Cannot have linked images in EPUB, ignore the image
|
||||
sFileName = bgd.getURL();
|
||||
sFileName = bgd.getFileName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -509,7 +509,7 @@ public class DrawConverter extends ConverterHelper {
|
|||
}
|
||||
else {
|
||||
// In all other cases, create an img element
|
||||
if (bgd!=null) { converter.addDocument(bgd); }
|
||||
if (bgd!=null && !bgd.isLinked() && !bgd.isRecycled()) { converter.addDocument(bgd); }
|
||||
Element image = converter.createElement("img");
|
||||
String sName = Misc.getAttribute(getFrame(onode),XMLString.DRAW_NAME);
|
||||
converter.addTarget(image,sName+"|graphic");
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.4 (2014-08-27)
|
||||
* Version 1.4 (2014-09-06)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -77,6 +77,8 @@ final class IndexData {
|
|||
Element hnode; // a div node where the index should be added
|
||||
}
|
||||
|
||||
/** This class handles text content
|
||||
*/
|
||||
public class TextConverter extends ConverterHelper {
|
||||
|
||||
// Data used to handle splitting over several files
|
||||
|
@ -1511,11 +1513,14 @@ public class TextConverter extends ConverterHelper {
|
|||
while (child!=null) {
|
||||
if (child.getNodeType()==Node.ELEMENT_NODE) {
|
||||
Element elm = (Element) child;
|
||||
String sTag = elm.getTagName();
|
||||
if (OfficeReader.isDrawElement(elm)) {
|
||||
elm = getDrawCv().getRealDrawElement(elm);
|
||||
String sAnchor = elm.getAttribute(XMLString.TEXT_ANCHOR_TYPE);
|
||||
if (Misc.isElement(elm, XMLString.DRAW_FRAME)) {
|
||||
elm = Misc.getFirstChildElement(elm);
|
||||
}
|
||||
if (elm!=null) {
|
||||
String sAnchor = elm.getAttribute(XMLString.TEXT_ANCHOR_TYPE);
|
||||
String sTag = elm.getTagName();
|
||||
// Convert only floating frames; text-boxes must always float
|
||||
if (!"as-char".equals(sAnchor)) {
|
||||
getDrawCv().handleDrawElement(elm,(Element)hnodeBlock,
|
||||
|
@ -2132,10 +2137,23 @@ public class TextConverter extends ConverterHelper {
|
|||
getTextSc().applyStyle(sStyleName,info);
|
||||
Element newNode = node;
|
||||
if (info.hasAttributes() || !"span".equals(info.sTagName)) {
|
||||
// We need to create a new element
|
||||
// We (probably) need to create a new element
|
||||
newNode = converter.createElement(info.sTagName);
|
||||
node.appendChild(newNode);
|
||||
applyStyle(info,newNode);
|
||||
// But we may want to merge it with the previous element
|
||||
Node prev = node.getLastChild();
|
||||
if (prev!=null && Misc.isElement(prev, info.sTagName)) {
|
||||
// The previous node is of the same type, compare attributes
|
||||
Element prevNode = (Element) prev;
|
||||
if (newNode.getAttribute("class").equals(prevNode.getAttribute("class")) &&
|
||||
newNode.getAttribute("style").equals(prevNode.getAttribute("style")) &&
|
||||
newNode.getAttribute("xml:lang").equals(prevNode.getAttribute("xml:lang")) &&
|
||||
newNode.getAttribute("dir").equals(prevNode.getAttribute("dir"))) {
|
||||
// Attribute style mapped elements are *not* merged, we will live with that
|
||||
return applyAttributes(prevNode,ofr.getTextStyle(sStyleName));
|
||||
}
|
||||
}
|
||||
node.appendChild(newNode);
|
||||
}
|
||||
return applyAttributes(newNode,ofr.getTextStyle(sStyleName));
|
||||
}
|
||||
|
@ -2149,5 +2167,3 @@ public class TextConverter extends ConverterHelper {
|
|||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.4 (2014-08-13)
|
||||
* Version 1.4 (2014-09-05)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -143,7 +143,7 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
|
|||
private static final int SPLIT_AFTER = 40;
|
||||
private static final int IMAGE_SPLIT = 41;
|
||||
private static final int COVER_IMAGE = 42;
|
||||
private static final int USE_SVG = 43;
|
||||
private static final int INLINE_SVG = 43;
|
||||
private static final int USE_MATHJAX = 44;
|
||||
private static final int CALC_SPLIT = 45;
|
||||
private static final int DISPLAY_HIDDEN_SHEETS = 46;
|
||||
|
@ -274,7 +274,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[USE_SVG] = new BooleanOption("use_svg","false");
|
||||
options[INLINE_SVG] = new BooleanOption("inline_svg","true");
|
||||
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");
|
||||
|
@ -401,7 +401,7 @@ public class XhtmlConfig extends writer2latex.base.ConfigBase {
|
|||
public int splitAfter() { return ((IntegerOption) options[SPLIT_AFTER]).getValue(); }
|
||||
public String imageSplit() { return options[IMAGE_SPLIT].getString(); }
|
||||
public boolean coverImage() { return ((BooleanOption) options[COVER_IMAGE]).getValue(); }
|
||||
public boolean useSVG() { return ((BooleanOption) options[USE_SVG]).getValue(); }
|
||||
public boolean inlineSVG() { return ((BooleanOption) options[INLINE_SVG]).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