String name = ole.getInstanceName();\r
if ("Worksheet".equals(name)) {\r
\r
- //save xls on disk\r
- FileOutputStream out = new FileOutputStream(name + "-("+(j)+").xls");\r
- InputStream dis = data.getData();\r
- byte[] chunk = new byte[2048];\r
- int count;\r
- while ((count = dis.read(chunk)) >= 0) {\r
- out.write(chunk,0,count);\r
- }\r
- is.close();\r
- out.close();\r
+ //read xls\r
+ HSSFWorkbook wb = new HSSFWorkbook(data.getData());\r
+\r
} else if ("Document".equals(name)) {\r
HWPFDocument doc = new HWPFDocument(data.getData());\r
//read the word document\r
doc.write(out);\r
out.close();\r
} else {\r
- System.err.println("Processing " + name);\r
+ FileOutputStream out = new FileOutputStream(ole.getProgID() + "-"+(j+1)+".dat");\r
+ InputStream dis = data.getData();\r
+ byte[] chunk = new byte[2048];\r
+ int count;\r
+ while ((count = dis.read(chunk)) >= 0) {\r
+ out.write(chunk,0,count);\r
+ }\r
+ is.close();\r
+ out.close();\r
}\r
}\r
\r
case ShapeTypes.TextBox:
shape = new TextBox(spContainer, parent);
break;
+ case ShapeTypes.HostControl:
case ShapeTypes.PictureFrame: {
EscherOptRecord opt = (EscherOptRecord)Shape.getEscherChild(spContainer, EscherOptRecord.RECORD_ID);
EscherProperty prop = Shape.getEscherProperty(opt, EscherProperties.BLIP__PICTUREID);
--- /dev/null
+/* ====================================================================\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+ contributor license agreements. See the NOTICE file distributed with\r
+ this work for additional information regarding copyright ownership.\r
+ The ASF licenses this file to You under the Apache License, Version 2.0\r
+ (the "License"); you may not use this file except in compliance with\r
+ the License. You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+==================================================================== */\r
+\r
+package org.apache.poi.hslf.record;\r
+\r
+import java.io.OutputStream;\r
+import java.io.IOException;\r
+\r
+import org.apache.poi.util.LittleEndian;\r
+import org.apache.poi.util.POILogger;\r
+\r
+/**\r
+ * Container for OLE Control object. It contains:\r
+ * <p>\r
+ * 1. ExControlAtom (4091)\r
+ * 2. ExOleObjAtom (4035)\r
+ * 3. CString (4026), Instance MenuName (1) used for menus and the Links dialog box.\r
+ * 4. CString (4026), Instance ProgID (2) that stores the OLE Programmatic Identifier.\r
+ * A ProgID is a string that uniquely identifies a given object.\r
+ * 5. CString (4026), Instance ClipboardName (3) that appears in the paste special dialog.\r
+ * 6. MetaFile( 4033), optional\r
+ * </p>\r
+ *\r
+ *\r
+ * @author Yegor kozlov\r
+ */\r
+public class ExControl extends ExEmbed {\r
+\r
+ // Links to our more interesting children\r
+ private ExControlAtom ctrlAtom;\r
+\r
+ /**\r
+ * Set things up, and find our more interesting children\r
+ *\r
+ * @param source the source data as a byte array.\r
+ * @param start the start offset into the byte array.\r
+ * @param len the length of the slice in the byte array.\r
+ */\r
+ protected ExControl(byte[] source, int start, int len) {\r
+ super(source, start, len);\r
+ }\r
+\r
+ /**\r
+ * Create a new ExEmbed, with blank fields\r
+ */\r
+ public ExControl() {\r
+ super();\r
+\r
+ _children[0] = ctrlAtom = new ExControlAtom();\r
+ }\r
+\r
+ /**\r
+ * Gets the {@link ExControlAtom}.\r
+ *\r
+ * @return the {@link ExControlAtom}.\r
+ */\r
+ public ExControlAtom getExControlAtom()\r
+ {\r
+ return ctrlAtom;\r
+ }\r
+\r
+ /**\r
+ * Returns the type (held as a little endian in bytes 3 and 4)\r
+ * that this class handles.\r
+ *\r
+ * @return the record type.\r
+ */\r
+ public long getRecordType() {\r
+ return RecordTypes.ExControl.typeID;\r
+ }\r
+\r
+ protected RecordAtom getEmbedAtom(Record[] children){\r
+ RecordAtom atom = null;\r
+ if(_children[0] instanceof ExControlAtom) {\r
+ atom = (ExControlAtom)_children[0];\r
+ } else {\r
+ logger.log(POILogger.ERROR, "First child record wasn't a ExControlAtom, was of type " + _children[0].getRecordType());\r
+ }\r
+ return atom;\r
+ }\r
+}\r
--- /dev/null
+/* ====================================================================\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+ contributor license agreements. See the NOTICE file distributed with\r
+ this work for additional information regarding copyright ownership.\r
+ The ASF licenses this file to You under the Apache License, Version 2.0\r
+ (the "License"); you may not use this file except in compliance with\r
+ the License. You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+==================================================================== */\r
+\r
+package org.apache.poi.hslf.record;\r
+\r
+import java.io.IOException;\r
+import java.io.OutputStream;\r
+\r
+import org.apache.poi.util.LittleEndian;\r
+\r
+/**\r
+ * Contains a long integer, slideID, which stores the unique slide identifier of the slide\r
+ * where this control resides.\r
+ *\r
+ * @author Yegor Kozlov\r
+ */\r
+public class ExControlAtom extends RecordAtom {\r
+\r
+\r
+ /**\r
+ * Record header.\r
+ */\r
+ private byte[] _header;\r
+\r
+ /**\r
+ * slideId.\r
+ */\r
+ private int _id;\r
+\r
+ /**\r
+ * Constructs a brand new embedded object atom record.\r
+ */\r
+ protected ExControlAtom() {\r
+ _header = new byte[8];\r
+\r
+ LittleEndian.putShort(_header, 2, (short) getRecordType());\r
+ LittleEndian.putInt(_header, 4, 4);\r
+\r
+ }\r
+\r
+ /**\r
+ * Constructs the ExControlAtom record from its source data.\r
+ *\r
+ * @param source the source data as a byte array.\r
+ * @param start the start offset into the byte array.\r
+ * @param len the length of the slice in the byte array.\r
+ */\r
+ protected ExControlAtom(byte[] source, int start, int len) {\r
+ // Get the header.\r
+ _header = new byte[8];\r
+ System.arraycopy(source, start, _header, 0, 8);\r
+\r
+ _id = LittleEndian.getInt(source, start + 8);\r
+ }\r
+\r
+ public int getSlideId() {\r
+ return _id;\r
+ }\r
+\r
+ /**\r
+ * Gets the record type.\r
+ * @return the record type.\r
+ */\r
+ public long getRecordType() {\r
+ return RecordTypes.ExControlAtom.typeID;\r
+ }\r
+\r
+ /**\r
+ * Write the contents of the record back, so it can be written\r
+ * to disk\r
+ *\r
+ * @param out the output stream to write to.\r
+ * @throws java.io.IOException if an error occurs.\r
+ */\r
+ public void writeOut(OutputStream out) throws IOException {\r
+ out.write(_header);\r
+ byte[] data = new byte[4];\r
+ LittleEndian.putInt(data, _id);\r
+ out.write(data);\r
+ }\r
+\r
+}\r
private byte[] _header;
// Links to our more interesting children
- private ExEmbedAtom embedAtom;
+ private RecordAtom embedAtom;
private ExOleObjAtom oleObjAtom;
private CString menuName;
private CString progId;
private void findInterestingChildren() {
// First child should be the ExHyperlinkAtom
- if(_children[0] instanceof ExEmbedAtom) {
- embedAtom = (ExEmbedAtom)_children[0];
- } else {
- logger.log(POILogger.ERROR, "First child record wasn't a ExEmbedAtom, was of type " + _children[0].getRecordType());
- }
+ embedAtom = getEmbedAtom(_children);
// Second child should be the ExOleObjAtom
if (_children[1] instanceof ExOleObjAtom) {
}
}
+ protected RecordAtom getEmbedAtom(Record[] children){
+ RecordAtom atom = null;
+ if(_children[0] instanceof ExEmbedAtom) {
+ atom = (ExEmbedAtom)_children[0];
+ } else {
+ logger.log(POILogger.ERROR, "First child record wasn't a ExEmbedAtom, was of type " + _children[0].getRecordType());
+ }
+ return atom;
+ }
+
/**
* Gets the {@link ExEmbedAtom}.
*
*/
public ExEmbedAtom getExEmbedAtom()
{
- return embedAtom;
+ return (ExEmbedAtom)embedAtom;
}
/**
package org.apache.poi.hslf.record;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
+import java.io.*;
import java.util.zip.InflaterInputStream;
+import java.util.zip.DeflaterOutputStream;
import org.apache.poi.util.LittleEndian;
return new InflaterInputStream(compressedStream);
}
+ public void setData(byte[] data) throws IOException {
+ ByteArrayOutputStream out = new ByteArrayOutputStream(data.length);
+ DeflaterOutputStream def = new DeflaterOutputStream(out);
+ def.write(data, 0, data.length);
+ def.finish();
+ _data = out.toByteArray();
+ LittleEndian.putInt(_header, 4, _data.length);
+ }
+
/**
* Gets the record type.
*
public static final Type RecolorInfoAtom = new Type(4071,null);
public static final Type ExQuickTimeMovie = new Type(4074,null);
public static final Type ExQuickTimeMovieData = new Type(4075,null);
- public static final Type ExControl = new Type(4078,null);
+ public static final Type ExControl = new Type(4078,ExControl.class);
public static final Type SlideListWithText = new Type(4080,SlideListWithText.class);
public static final Type InteractiveInfo = new Type(4082,InteractiveInfo.class);
public static final Type InteractiveInfoAtom = new Type(4083,InteractiveInfoAtom.class);