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
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2012 by Henrik Just
|
||||
* Copyright: 2002-2014 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.4 (2012-03-26)
|
||||
* Version 1.4 (2012-03-28)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -34,7 +34,7 @@ import writer2latex.util.SimpleZipReader;
|
|||
public class EmbeddedBinaryObject extends EmbeddedObject {
|
||||
|
||||
/** The object's binary representation. */
|
||||
private byte[] objData = null;
|
||||
private byte[] blob = null;
|
||||
|
||||
/**
|
||||
* Package private constructor for use when reading an object from a
|
||||
|
@ -42,11 +42,12 @@ public class EmbeddedBinaryObject extends EmbeddedObject {
|
|||
*
|
||||
* @param sName The name of the object.
|
||||
* @param sType The MIME-type of the object.
|
||||
* @param doc The document containing the object.
|
||||
* @param source A <code>SimpleZipReader</code> containing the object
|
||||
*/
|
||||
protected EmbeddedBinaryObject(String sName, String sType, SimpleZipReader source) {
|
||||
super(sName,sType);
|
||||
objData = source.getEntry(sName);
|
||||
protected EmbeddedBinaryObject(String sName, String sType, OfficeDocument doc, SimpleZipReader source) {
|
||||
super(sName,sType,doc);
|
||||
blob = source.getEntry(sName);
|
||||
}
|
||||
|
||||
/** Get the binary data for this object
|
||||
|
@ -54,7 +55,12 @@ public class EmbeddedBinaryObject extends EmbeddedObject {
|
|||
* @return A <code>byte</code> array containing the object's data.
|
||||
*/
|
||||
public byte[] getBinaryData() {
|
||||
return objData;
|
||||
return blob;
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
blob = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2012 by Henrik Just
|
||||
* Copyright: 2002-2014 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.4 (2012-03-27)
|
||||
* Version 1.4 (2014-08-27)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -29,6 +29,7 @@ package writer2latex.office;
|
|||
/** This class represents and embedded object within an ODF package document
|
||||
*/
|
||||
public abstract class EmbeddedObject {
|
||||
private OfficeDocument doc;
|
||||
private String sName;
|
||||
private String sType;
|
||||
|
||||
|
@ -36,10 +37,12 @@ public abstract class EmbeddedObject {
|
|||
*
|
||||
* @param sName The name of the object.
|
||||
* @param sType The MIME-type of the object.
|
||||
* @param doc The document to which the object belongs.
|
||||
*/
|
||||
protected EmbeddedObject(String sName, String sType) {
|
||||
protected EmbeddedObject(String sName, String sType, OfficeDocument doc) {
|
||||
this.sName = sName;
|
||||
this.sType = sType;
|
||||
this.doc = doc;
|
||||
}
|
||||
|
||||
/** Get the name of the embedded object represented by this instance.
|
||||
|
@ -58,4 +61,12 @@ public abstract class EmbeddedObject {
|
|||
return sType;
|
||||
}
|
||||
|
||||
/** Dispose this <code>EmbeddedObject</code>. This implies that the content is nullified and the object
|
||||
* is removed from the collection in the <code>OfficeDocument</code>.
|
||||
*
|
||||
*/
|
||||
public void dispose() {
|
||||
doc.removeEmbeddedObject(sName);
|
||||
}
|
||||
|
||||
}
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.4 (2014-08-25)
|
||||
* Version 1.4 (2014-08-28)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -55,8 +55,8 @@ public class EmbeddedXMLObject extends EmbeddedObject {
|
|||
* @param sType The MIME-type of the object.
|
||||
* @param source A ZIP reader providing the contents of the package
|
||||
*/
|
||||
protected EmbeddedXMLObject(String sName, String sType, SimpleZipReader source) {
|
||||
super(sName, sType);
|
||||
protected EmbeddedXMLObject(String sName, String sType, OfficeDocument doc, SimpleZipReader source) {
|
||||
super(sName, sType, doc);
|
||||
// Read the bytes, but defer parsing until required (at that point, the bytes are nullified)
|
||||
contentBytes = source.getEntry(sName+"/"+OfficeDocument.CONTENTXML);
|
||||
stylesBytes = source.getEntry(sName+"/"+OfficeDocument.STYLESXML);
|
||||
|
@ -100,5 +100,13 @@ public class EmbeddedXMLObject extends EmbeddedObject {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public void dispose() {
|
||||
super.dispose();
|
||||
contentBytes = null;
|
||||
stylesBytes = null;
|
||||
contentDOM = null;
|
||||
stylesDOM = null;
|
||||
}
|
||||
|
||||
}
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.4 (2014-08-25)
|
||||
* Version 1.4 (2014-08-28)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -77,7 +77,7 @@ public class OfficeDocument {
|
|||
|
||||
/** Collection to keep track of the embedded objects in the document. */
|
||||
private Map<String, EmbeddedObject> embeddedObjects = null;
|
||||
|
||||
|
||||
/** Package or flat format?
|
||||
* @return true if the document is in package format, false if it's flat XML
|
||||
*/
|
||||
|
@ -145,13 +145,13 @@ public class OfficeDocument {
|
|||
if (sPath.endsWith("/")) { // Remove trailing slash
|
||||
sPath=sPath.substring(0, sPath.length()-1);
|
||||
}
|
||||
embeddedObjects.put(sPath, new EmbeddedXMLObject(sPath, sType, zip));
|
||||
embeddedObjects.put(sPath, new EmbeddedXMLObject(sPath, sType, this, zip));
|
||||
}
|
||||
}
|
||||
else if (!sType.equals("text/xml")) {
|
||||
// XML entries are either embedded ODF doc entries or main document entries, all other
|
||||
// entries are included as binary objects
|
||||
embeddedObjects.put(sPath, new EmbeddedBinaryObject(sPath, sType, zip));
|
||||
embeddedObjects.put(sPath, new EmbeddedBinaryObject(sPath, sType, this, zip));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -173,6 +173,12 @@ public class OfficeDocument {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void removeEmbeddedObject(String sName) {
|
||||
if (sName!=null && embeddedObjects!=null && embeddedObjects.containsKey(sName)) {
|
||||
embeddedObjects.remove(sName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the document from a DOM tree (flat XML format)
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.4 (2014-08-27)
|
||||
* Version 1.4 (2014-09-03)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -220,7 +220,7 @@ public class OfficeReader {
|
|||
return nCount;
|
||||
}
|
||||
|
||||
public String getTextContent(Node node) {
|
||||
public static String getTextContent(Node node) {
|
||||
String s = "";
|
||||
Node child = node.getFirstChild();
|
||||
while (child!=null) {
|
||||
|
@ -360,10 +360,10 @@ public class OfficeReader {
|
|||
private boolean bText = false;
|
||||
private boolean bSpreadsheet = false;
|
||||
private boolean bPresentation = false;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Various methods
|
||||
|
||||
|
||||
/** Checks whether or not this document is in package format
|
||||
* @return true if it's in package format
|
||||
*/
|
||||
|
@ -394,7 +394,14 @@ public class OfficeReader {
|
|||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Accessor methods
|
||||
|
||||
|
||||
/** Get an embedded object in this office document
|
||||
*
|
||||
*/
|
||||
public EmbeddedObject getEmbeddedObject(String sName) {
|
||||
return oooDoc.getEmbeddedObject(sName);
|
||||
}
|
||||
|
||||
/** <p>Get the collection of all font declarations.</p>
|
||||
* @return the <code>OfficeStyleFamily</code> of font declarations
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue