Refactoring image conversion + some math bugfixes
git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@168 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
parent
9babea1b6c
commit
74d7599b11
19 changed files with 533 additions and 369 deletions
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.4 (2014-08-26)
|
||||
* Version 1.4 (2014-09-03)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -466,30 +466,22 @@ public class DrawConverter extends ConverterHelper {
|
|||
// Get the image from the ImageLoader
|
||||
BinaryGraphicsDocument bgd = null;
|
||||
String sFileName = null;
|
||||
String sHref = Misc.getAttribute(onode,XMLString.XLINK_HREF);
|
||||
if (sHref!=null && sHref.length()>0 && !ofr.isInPackage(sHref)) {
|
||||
// Linked image is not yet handled by ImageLoader. This is a temp.
|
||||
// solution (will go away when ImageLoader is finished)
|
||||
if (!converter.isOPS()) { // Cannot have linked images in EPUB, ignore the image
|
||||
sFileName = sHref;
|
||||
// In OpenDocument *package* format ../ means "leave the package"
|
||||
if (ofr.isOpenDocument() && ofr.isPackageFormat() && sFileName.startsWith("../")) {
|
||||
sFileName=sFileName.substring(3);
|
||||
}
|
||||
//String sExt = sHref.substring(sHref.lastIndexOf(".")).toLowerCase();
|
||||
}
|
||||
}
|
||||
else { // embedded or base64 encoded image
|
||||
bgd = converter.getImageCv().getImage(onode);
|
||||
if (bgd!=null) {
|
||||
bgd = converter.getImageCv().getImage(onode);
|
||||
if (bgd!=null) {
|
||||
if (!bgd.isLinked()) { // embedded image
|
||||
sFileName = bgd.getFileName();
|
||||
// If this is the cover image, add it to the converter result
|
||||
if (bCoverImage && onode==ofr.getFirstImage()) {
|
||||
converter.setCoverImageFile(bgd,null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else { // linked image
|
||||
if (!converter.isOPS()) { // Cannot have linked images in EPUB, ignore the image
|
||||
sFileName = bgd.getURL();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sFileName==null) { return; } // TODO: Add warning?
|
||||
|
||||
// Create the image (sFileName contains the file name)
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.4 (2014-08-26)
|
||||
* Version 1.4 (2014-09-01)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class MathConverter extends ConverterHelper {
|
|||
* @param onode the math node
|
||||
* @param hnode the xhtml node to which content should be added
|
||||
*/
|
||||
public void convert(Node image, Element onode, Node hnode, boolean bAllowDisplayStyle) {
|
||||
public void convert(Element image, Element onode, Node hnode, boolean bAllowDisplayStyle) {
|
||||
if (bSupportMathML) {
|
||||
convertAsMathML(onode,hnode,bAllowDisplayStyle);
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ public class MathConverter extends ConverterHelper {
|
|||
|
||||
|
||||
// For plain xhtml: Convert the formula as an image or as plain text
|
||||
private void convertAsImageOrText(Node image, Node onode, Node hnode) {
|
||||
private void convertAsImageOrText(Element image, Node onode, Node hnode) {
|
||||
NodeList annotationList = ((Element) onode).getElementsByTagName(XMLString.ANNOTATION); // Since OOo 3.2
|
||||
if (annotationList.getLength()==0) {
|
||||
annotationList = ((Element) onode).getElementsByTagName(XMLString.MATH_ANNOTATION);
|
||||
|
@ -153,7 +153,7 @@ public class MathConverter extends ConverterHelper {
|
|||
if (sHref==null || sHref.length()==0 || ofr.isInPackage(sHref)) {
|
||||
BinaryGraphicsDocument bgd = converter.getImageCv().getImage(image);
|
||||
if (bgd!=null) {
|
||||
String sMIME = bgd.getDocumentMIMEType();
|
||||
String sMIME = bgd.getMIMEType();
|
||||
if (MIMETypes.PNG.equals(sMIME) || MIMETypes.JPEG.equals(sMIME) || MIMETypes.GIF.equals(sMIME)) {
|
||||
converter.addDocument(bgd);
|
||||
// Create the image and add the StarMath/LaTeX formula as alternative text
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue