summaryrefslogtreecommitdiff
path: root/xmerge
diff options
context:
space:
mode:
authorRüdiger Timm <rt@openoffice.org>2005-01-11 12:27:56 +0000
committerRüdiger Timm <rt@openoffice.org>2005-01-11 12:27:56 +0000
commitedfaf86a67fd3785766e924c79f360a7e6e52652 (patch)
tree8171fa6190dff0375a311a00529e919fbcb23492 /xmerge
parent1f43c5aec136296948cf0b645dd13db5350bcf25 (diff)
INTEGRATION: CWS monaleenfilterteam30 (1.14.2); FILE MERGED
2005/01/05 10:57:05 jmarmion 1.14.2.2: #i33702# - use lastIndexOf to get the real eof marker Issue number: Submitted by: Reviewed by: 2004/11/23 14:16:14 jmarmion 1.14.2.1: Issue number: Submitted by: Reviewed by:
Diffstat (limited to 'xmerge')
-rw-r--r--xmerge/java/org/openoffice/xmerge/converter/xml/OfficeDocument.java35
1 files changed, 34 insertions, 1 deletions
diff --git a/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeDocument.java b/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeDocument.java
index 75abe4671ebd..72dccc805f7a 100644
--- a/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeDocument.java
+++ b/xmerge/java/org/openoffice/xmerge/converter/xml/OfficeDocument.java
@@ -561,7 +561,10 @@ public abstract class OfficeDocument
//System.out.println("\nParsing Input stream, validating?: "+builder.isValidating());
//contentDoc= builder.parse((InputStream)is);
- org.w3c.dom.Document newDoc = builder.parse((InputStream)is);
+ Reader r = secondHack(is);
+ InputSource ins = new InputSource(r);
+ org.w3c.dom.Document newDoc = builder.parse(ins);
+ //org.w3c.dom.Document newDoc = builder.parse((InputStream)is);
Element rootElement=newDoc.getDocumentElement();
NodeList nodeList;
@@ -1133,6 +1136,36 @@ public abstract class OfficeDocument
return r;
}
+ /**
+ * <p>Transform the InputStream to a Reader Stream.</p>
+ *
+ * <p>This hacked code needs to be changed later on.</p>
+ *
+ * <p>Issue: the new oasis input file stream means
+ * that the old input stream fails. see #i33702# </p>
+ *
+ * @param is <code>InputStream</code> to be filtered.
+ *
+ * @return Reader value of the InputStream().
+ *
+ * @throws IOException If any I/O error occurs.
+ */
+ private static Reader secondHack(InputStream is) throws IOException {
+
+ BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+ char[] charArray = new char[is.available()];
+
+ br.read(charArray,0,is.available());
+ String sStr = new String(charArray);
+ StringBuffer sBuf = new StringBuffer(is.available());
+ // ensure there is no trailing garbage after the end of the stream.
+ int sIndex = sStr.lastIndexOf("</office:document>");
+ sBuf.append(sStr.substring(0, sIndex));
+ sBuf.append("</office:document>");
+ StringReader r = new StringReader(sBuf.toString());
+ return r;
+ }
+
/**
* Method to return the MIME type of the document.