You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by jo...@apache.org on 2009/05/21 20:15:01 UTC
svn commit: r777204 [11/21] - in /poi/trunk/src/scratchpad:
examples/src/org/apache/poi/hslf/examples/
examples/src/org/apache/poi/hwpf/ src/org/apache/poi/hdf/event/
src/org/apache/poi/hdf/extractor/ src/org/apache/poi/hdf/extractor/data/
src/org/apac...
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Sound.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Sound.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Sound.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/Sound.java Thu May 21 18:12:22 2009
@@ -1,136 +1,137 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-package org.apache.poi.hslf.record;
-
-import org.apache.poi.util.POILogger;
-
-import java.io.OutputStream;
-import java.io.IOException;
-
-/**
- * A container holding information about a sound. It contains:
- * <p>
- * <li>1. CString (4026), Instance 0: Name of sound (e.g. "crash")
- * <li>2. CString (4026), Instance 1: Type of sound (e.g. ".wav")
- * <li>3. CString (4026), Instance 2: Reference id of sound in sound collection
- * <li>4. CString (4026), Instance 3, optional: Built-in id of sound, for sounds we ship. This is the id that?s in the reg file.
- * <li>5. SoundData (2023), optional
- * </p>
- *
- * @author Yegor Kozlov
- */
-public class Sound extends RecordContainer {
- /**
- * Record header data.
- */
- private byte[] _header;
-
- // Links to our more interesting children
- private CString _name;
- private CString _type;
- private SoundData _data;
-
-
- /**
- * Set things up, and find our more interesting children
- *
- * @param source the source data as a byte array.
- * @param start the start offset into the byte array.
- * @param len the length of the slice in the byte array.
- */
- protected Sound(byte[] source, int start, int len) {
- // Grab the header
- _header = new byte[8];
- System.arraycopy(source,start,_header,0,8);
-
- // Find our children
- _children = Record.findChildRecords(source,start+8,len-8);
- findInterestingChildren();
- }
-
- private void findInterestingChildren() {
- // First child should be the ExHyperlinkAtom
- if(_children[0] instanceof CString) {
- _name = (CString)_children[0];
- } else {
- logger.log(POILogger.ERROR, "First child record wasn't a CString, was of type " + _children[0].getRecordType());
- }
-
- // Second child should be the ExOleObjAtom
- if (_children[1] instanceof CString) {
- _type = (CString)_children[1];
- } else {
- logger.log(POILogger.ERROR, "Second child record wasn't a CString, was of type " + _children[1].getRecordType());
- }
-
- for (int i = 2; i < _children.length; i++) {
- if(_children[i] instanceof SoundData){
- _data = (SoundData)_children[i];
- break;
- }
- }
-
- }
-
- /**
- * Returns the type (held as a little endian in bytes 3 and 4)
- * that this class handles.
- *
- * @return the record type.
- */
- public long getRecordType() {
- return RecordTypes.Sound.typeID;
- }
-
- /**
- * Have the contents printer out into an OutputStream, used when
- * writing a file back out to disk.
- *
- * @param out the output stream.
- * @throws java.io.IOException if there was an error writing to the stream.
- */
- public void writeOut(OutputStream out) throws IOException {
- writeOut(_header[0],_header[1],getRecordType(),_children,out);
- }
-
- /**
- * Name of the sound (e.g. "crash")
- *
- * @return name of the sound
- */
- public String getSoundName(){
- return _name.getText();
- }
-
- /**
- * Type of the sound (e.g. ".wav")
- *
- * @return type of the sound
- */
- public String getSoundType(){
- return _type.getText();
- }
-
- /**
- * The sound data
- *
- * @return the sound data.
- */
- public byte[] getSoundData(){
- return _data == null ? null : _data.getData();
- }
-}
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.record;
+
+import org.apache.poi.util.POILogger;
+
+import java.io.OutputStream;
+import java.io.IOException;
+
+/**
+ * A container holding information about a sound. It contains:
+ * <p>
+ * <li>1. CString (4026), Instance 0: Name of sound (e.g. "crash")
+ * <li>2. CString (4026), Instance 1: Type of sound (e.g. ".wav")
+ * <li>3. CString (4026), Instance 2: Reference id of sound in sound collection
+ * <li>4. CString (4026), Instance 3, optional: Built-in id of sound, for sounds we ship. This is the id that?s in the reg file.
+ * <li>5. SoundData (2023), optional
+ * </p>
+ *
+ * @author Yegor Kozlov
+ */
+public final class Sound extends RecordContainer {
+ /**
+ * Record header data.
+ */
+ private byte[] _header;
+
+ // Links to our more interesting children
+ private CString _name;
+ private CString _type;
+ private SoundData _data;
+
+
+ /**
+ * Set things up, and find our more interesting children
+ *
+ * @param source the source data as a byte array.
+ * @param start the start offset into the byte array.
+ * @param len the length of the slice in the byte array.
+ */
+ protected Sound(byte[] source, int start, int len) {
+ // Grab the header
+ _header = new byte[8];
+ System.arraycopy(source,start,_header,0,8);
+
+ // Find our children
+ _children = Record.findChildRecords(source,start+8,len-8);
+ findInterestingChildren();
+ }
+
+ private void findInterestingChildren() {
+ // First child should be the ExHyperlinkAtom
+ if(_children[0] instanceof CString) {
+ _name = (CString)_children[0];
+ } else {
+ logger.log(POILogger.ERROR, "First child record wasn't a CString, was of type " + _children[0].getRecordType());
+ }
+
+ // Second child should be the ExOleObjAtom
+ if (_children[1] instanceof CString) {
+ _type = (CString)_children[1];
+ } else {
+ logger.log(POILogger.ERROR, "Second child record wasn't a CString, was of type " + _children[1].getRecordType());
+ }
+
+ for (int i = 2; i < _children.length; i++) {
+ if(_children[i] instanceof SoundData){
+ _data = (SoundData)_children[i];
+ break;
+ }
+ }
+
+ }
+
+ /**
+ * Returns the type (held as a little endian in bytes 3 and 4)
+ * that this class handles.
+ *
+ * @return the record type.
+ */
+ public long getRecordType() {
+ return RecordTypes.Sound.typeID;
+ }
+
+ /**
+ * Have the contents printer out into an OutputStream, used when
+ * writing a file back out to disk.
+ *
+ * @param out the output stream.
+ * @throws java.io.IOException if there was an error writing to the stream.
+ */
+ public void writeOut(OutputStream out) throws IOException {
+ writeOut(_header[0],_header[1],getRecordType(),_children,out);
+ }
+
+ /**
+ * Name of the sound (e.g. "crash")
+ *
+ * @return name of the sound
+ */
+ public String getSoundName(){
+ return _name.getText();
+ }
+
+ /**
+ * Type of the sound (e.g. ".wav")
+ *
+ * @return type of the sound
+ */
+ public String getSoundType(){
+ return _type.getText();
+ }
+
+ /**
+ * The sound data
+ *
+ * @return the sound data.
+ */
+ public byte[] getSoundData(){
+ return _data == null ? null : _data.getData();
+ }
+}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SoundCollection.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SoundCollection.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SoundCollection.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SoundCollection.java Thu May 21 18:12:22 2009
@@ -1,73 +1,74 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-package org.apache.poi.hslf.record;
-
-import org.apache.poi.util.POILogger;
-
-import java.io.OutputStream;
-import java.io.IOException;
-
-/**
- * Is a container for all sound related atoms and containers. It contains:
- *<li>1. SoundCollAtom (2021)
- *<li>2. Sound (2022), for each sound, if any
- *
- * @author Yegor Kozlov
- */
-public class SoundCollection extends RecordContainer {
- /**
- * Record header data.
- */
- private byte[] _header;
-
- /**
- * Set things up, and find our more interesting children
- *
- * @param source the source data as a byte array.
- * @param start the start offset into the byte array.
- * @param len the length of the slice in the byte array.
- */
- protected SoundCollection(byte[] source, int start, int len) {
- // Grab the header
- _header = new byte[8];
- System.arraycopy(source,start,_header,0,8);
-
- // Find our children
- _children = Record.findChildRecords(source,start+8,len-8);
- }
-
- /**
- * Returns the type (held as a little endian in bytes 3 and 4)
- * that this class handles.
- *
- * @return the record type.
- */
- public long getRecordType() {
- return RecordTypes.SoundCollection.typeID;
- }
-
- /**
- * Have the contents printer out into an OutputStream, used when
- * writing a file back out to disk.
- *
- * @param out the output stream.
- * @throws java.io.IOException if there was an error writing to the stream.
- */
- public void writeOut(OutputStream out) throws IOException {
- writeOut(_header[0],_header[1],getRecordType(),_children,out);
- }
-}
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.record;
+
+import org.apache.poi.util.POILogger;
+
+import java.io.OutputStream;
+import java.io.IOException;
+
+/**
+ * Is a container for all sound related atoms and containers. It contains:
+ *<li>1. SoundCollAtom (2021)
+ *<li>2. Sound (2022), for each sound, if any
+ *
+ * @author Yegor Kozlov
+ */
+public final class SoundCollection extends RecordContainer {
+ /**
+ * Record header data.
+ */
+ private byte[] _header;
+
+ /**
+ * Set things up, and find our more interesting children
+ *
+ * @param source the source data as a byte array.
+ * @param start the start offset into the byte array.
+ * @param len the length of the slice in the byte array.
+ */
+ protected SoundCollection(byte[] source, int start, int len) {
+ // Grab the header
+ _header = new byte[8];
+ System.arraycopy(source,start,_header,0,8);
+
+ // Find our children
+ _children = Record.findChildRecords(source,start+8,len-8);
+ }
+
+ /**
+ * Returns the type (held as a little endian in bytes 3 and 4)
+ * that this class handles.
+ *
+ * @return the record type.
+ */
+ public long getRecordType() {
+ return RecordTypes.SoundCollection.typeID;
+ }
+
+ /**
+ * Have the contents printer out into an OutputStream, used when
+ * writing a file back out to disk.
+ *
+ * @param out the output stream.
+ * @throws java.io.IOException if there was an error writing to the stream.
+ */
+ public void writeOut(OutputStream out) throws IOException {
+ writeOut(_header[0],_header[1],getRecordType(),_children,out);
+ }
+}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SoundData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SoundData.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SoundData.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/SoundData.java Thu May 21 18:12:22 2009
@@ -1,103 +1,103 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.hslf.record;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.zip.InflaterInputStream;
-
-import org.apache.poi.util.LittleEndian;
-
-/**
- * Storage for embedded sounds.
- *
- * @author Yegor Kozlov
- */
-public class SoundData extends RecordAtom {
-
- /**
- * Record header.
- */
- private byte[] _header;
-
- /**
- * Record data.
- */
- private byte[] _data;
-
- /**
- * Constructs a new empty sound container.
- */
- protected SoundData() {
- _header = new byte[8];
- _data = new byte[0];
-
- LittleEndian.putShort(_header, 2, (short)getRecordType());
- LittleEndian.putInt(_header, 4, _data.length);
- }
-
- /**
- * Constructs the link related atom record from its
- * source data.
- *
- * @param source the source data as a byte array.
- * @param start the start offset into the byte array.
- * @param len the length of the slice in the byte array.
- */
- protected SoundData(byte[] source, int start, int len) {
- // Get the header.
- _header = new byte[8];
- System.arraycopy(source,start,_header,0,8);
-
- // Get the record data.
- _data = new byte[len-8];
- System.arraycopy(source,start+8,_data,0,len-8);
- }
-
- /**
- * Returns the sound data.
- *
- * @return the sound data
- */
- public byte[] getData() {
- return _data;
- }
-
- /**
- * Gets the record type.
- *
- * @return the record type.
- */
- public long getRecordType() {
- return RecordTypes.SoundData.typeID;
- }
-
- /**
- * Write the contents of the record back, so it can be written
- * to disk.
- *
- * @param out the output stream to write to.
- * @throws java.io.IOException if an error occurs.
- */
- public void writeOut(OutputStream out) throws IOException {
- out.write(_header);
- out.write(_data);
- }
-}
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.record;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.zip.InflaterInputStream;
+
+import org.apache.poi.util.LittleEndian;
+
+/**
+ * Storage for embedded sounds.
+ *
+ * @author Yegor Kozlov
+ */
+public final class SoundData extends RecordAtom {
+
+ /**
+ * Record header.
+ */
+ private byte[] _header;
+
+ /**
+ * Record data.
+ */
+ private byte[] _data;
+
+ /**
+ * Constructs a new empty sound container.
+ */
+ protected SoundData() {
+ _header = new byte[8];
+ _data = new byte[0];
+
+ LittleEndian.putShort(_header, 2, (short)getRecordType());
+ LittleEndian.putInt(_header, 4, _data.length);
+ }
+
+ /**
+ * Constructs the link related atom record from its
+ * source data.
+ *
+ * @param source the source data as a byte array.
+ * @param start the start offset into the byte array.
+ * @param len the length of the slice in the byte array.
+ */
+ protected SoundData(byte[] source, int start, int len) {
+ // Get the header.
+ _header = new byte[8];
+ System.arraycopy(source,start,_header,0,8);
+
+ // Get the record data.
+ _data = new byte[len-8];
+ System.arraycopy(source,start+8,_data,0,len-8);
+ }
+
+ /**
+ * Returns the sound data.
+ *
+ * @return the sound data
+ */
+ public byte[] getData() {
+ return _data;
+ }
+
+ /**
+ * Gets the record type.
+ *
+ * @return the record type.
+ */
+ public long getRecordType() {
+ return RecordTypes.SoundData.typeID;
+ }
+
+ /**
+ * Write the contents of the record back, so it can be written
+ * to disk.
+ *
+ * @param out the output stream to write to.
+ * @throws java.io.IOException if an error occurs.
+ */
+ public void writeOut(OutputStream out) throws IOException {
+ out.write(_header);
+ out.write(_data);
+ }
+}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hslf.record;
@@ -35,7 +33,7 @@
import org.apache.poi.util.HexDump;
/**
- * A StyleTextPropAtom (type 4001). Holds basic character properties
+ * A StyleTextPropAtom (type 4001). Holds basic character properties
* (bold, italic, underline, font size etc) and paragraph properties
* (alignment, line spacing etc) for the block of text (TextBytesAtom
* or TextCharsAtom) that this record follows.
@@ -51,7 +49,7 @@
* @author Yegor Kozlov
*/
-public class StyleTextPropAtom extends RecordAtom
+public final class StyleTextPropAtom extends RecordAtom
{
private byte[] _header;
private static long _type = 4001l;
@@ -59,13 +57,13 @@
private byte[] rawContents; // Holds the contents between write-outs
- /**
+ /**
* Only set to true once setParentTextSize(int) is called.
* Until then, no stylings will have been decoded
*/
private boolean initialised = false;
- /**
+ /**
* The list of all the different paragraph stylings we code for.
* Each entry is a TextPropCollection, which tells you how many
* Characters the paragraph covers, and also contains the TextProps
@@ -78,10 +76,10 @@
* paragraph stylings
*/
public void setParagraphStyles(LinkedList ps) { paragraphStyles = ps; }
- /**
+ /**
* The list of all the different character stylings we code for.
* Each entry is a TextPropCollection, which tells you how many
- * Characters the character styling covers, and also contains the
+ * Characters the character styling covers, and also contains the
* TextProps that actually define the styling of the characters.
*/
private LinkedList charStyles;
@@ -91,7 +89,7 @@
* character stylings
*/
public void setCharacterStyles(LinkedList cs) { charStyles = cs; }
-
+
/**
* Returns how many characters the paragraph's
* TextPropCollections cover.
@@ -334,7 +332,7 @@
// Save this properties set
charStyles.add(thisCollection);
-
+
// Handle extra 1 char styles at the end
if(pos < rawContents.length && textHandled == size) {
chsize++;
@@ -407,7 +405,7 @@
charStyles.add(tpc);
return tpc;
}
-
+
/* ************************************************************************ */
@@ -418,14 +416,14 @@
*/
public String toString(){
StringBuffer out = new StringBuffer();
-
+
out.append("StyleTextPropAtom:\n");
if (!initialised) {
out.append("Uninitialised, dumping Raw Style Data\n");
} else {
-
+
out.append("Paragraph properties\n");
-
+
for (Iterator it1 = getParagraphStyles().iterator(); it1.hasNext();) {
TextPropCollection pr = (TextPropCollection)it1.next();
out.append(" chars covered: " + pr.getCharactersCovered());
@@ -435,9 +433,9 @@
out.append(" " + p.getName() + " = " + p.getValue() );
out.append(" (0x" + HexDump.toHex(p.getValue()) + ")\n");
}
-
+
out.append(" para bytes that would be written: \n");
-
+
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
pr.writeOut(baos);
@@ -447,7 +445,7 @@
e.printStackTrace();
}
}
-
+
out.append("Character properties\n");
for (Iterator it1 = getCharacterStyles().iterator(); it1.hasNext();) {
TextPropCollection pr = (TextPropCollection)it1.next();
@@ -458,9 +456,9 @@
out.append(" " + p.getName() + " = " + p.getValue() );
out.append(" (0x" + HexDump.toHex(p.getValue()) + ")\n");
}
-
+
out.append(" char bytes that would be written: \n");
-
+
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
pr.writeOut(baos);
@@ -471,7 +469,7 @@
}
}
}
-
+
out.append(" original byte stream \n");
out.append( HexDump.dump(rawContents, 0, 0) );
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextBytesAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextBytesAtom.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextBytesAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextBytesAtom.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hslf.record;
@@ -27,14 +25,14 @@
/**
* A TextBytesAtom (type 4008). Holds text in ascii form (unknown
- * code page, for now assumed to be the default of
+ * code page, for now assumed to be the default of
* org.apache.poi.util.StringUtil, which is the Excel default).
* The trailing return character is always stripped from this
*
* @author Nick Burch
*/
-public class TextBytesAtom extends RecordAtom
+public final class TextBytesAtom extends RecordAtom
{
private byte[] _header;
private static long _type = 4008l;
@@ -43,12 +41,12 @@
private byte[] _text;
/** Grabs the text. Uses the default codepage */
- public String getText() {
+ public String getText() {
return StringUtil.getFromCompressedUnicode(_text,0,_text.length);
}
/** Updates the text in the Atom. Must be 8 bit ascii */
- public void setText(byte[] b) {
+ public void setText(byte[] b) {
// Set the text
_text = b;
@@ -58,7 +56,7 @@
/* *************** record code follows ********************** */
- /**
+ /**
* For the TextBytes Atom
*/
protected TextBytesAtom(byte[] source, int start, int len) {
@@ -73,7 +71,7 @@
_text = new byte[len-8];
System.arraycopy(source,start+8,_text,0,len-8);
}
-
+
/**
* Create an empty TextBytes Atom
*/
@@ -104,7 +102,7 @@
}
/**
- * dump debug info; use getText() to return a string
+ * dump debug info; use getText() to return a string
* representation of the atom
*/
public String toString() {
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextCharsAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextCharsAtom.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextCharsAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextCharsAtom.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hslf.record;
@@ -32,7 +30,7 @@
* @author Nick Burch
*/
-public class TextCharsAtom extends RecordAtom
+public final class TextCharsAtom extends RecordAtom
{
private byte[] _header;
private static long _type = 4000l;
@@ -41,7 +39,7 @@
private byte[] _text;
/** Grabs the text. */
- public String getText() {
+ public String getText() {
return StringUtil.getFromUnicodeLE(_text);
}
@@ -57,8 +55,8 @@
/* *************** record code follows ********************** */
- /**
- * For the TextChars Atom
+ /**
+ * For the TextChars Atom
*/
protected TextCharsAtom(byte[] source, int start, int len) {
// Sanity Checking
@@ -98,9 +96,9 @@
// Write out our text
out.write(_text);
}
-
+
/**
- * dump debug info; use getText() to return a string
+ * dump debug info; use getText() to return a string
* representation of the atom
*/
public String toString() {
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextHeaderAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextHeaderAtom.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextHeaderAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextHeaderAtom.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hslf.record;
@@ -31,7 +29,7 @@
* @author Nick Burch
*/
-public class TextHeaderAtom extends RecordAtom implements ParentAwareRecord
+public final class TextHeaderAtom extends RecordAtom implements ParentAwareRecord
{
private byte[] _header;
private static long _type = 3999l;
@@ -51,13 +49,13 @@
public int getTextType() { return textType; }
public void setTextType(int type) { textType = type; }
-
+
public RecordContainer getParentRecord() { return parentRecord; }
- public void setParentRecord(RecordContainer record) { this.parentRecord = record; }
+ public void setParentRecord(RecordContainer record) { this.parentRecord = record; }
/* *************** record code follows ********************** */
- /**
+ /**
* For the TextHeader Atom
*/
protected TextHeaderAtom(byte[] source, int start, int len) {
@@ -76,7 +74,7 @@
// Grab the type
textType = (int)LittleEndian.getInt(source,start+8);
}
-
+
/**
* Create a new TextHeader Atom, for an unknown type of text
*/
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextRulerAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextRulerAtom.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextRulerAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextRulerAtom.java Thu May 21 18:12:22 2009
@@ -1,209 +1,209 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-
-package org.apache.poi.hslf.record;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.zip.InflaterInputStream;
-
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogger;
-
-/**
- * Ruler of a text as it differs from the style's ruler settings.
- *
- * @author Yegor Kozlov
- */
-public class TextRulerAtom extends RecordAtom {
-
- /**
- * Record header.
- */
- private byte[] _header;
-
- /**
- * Record data.
- */
- private byte[] _data;
-
- //ruler internals
- private int defaultTabSize;
- private int numLevels;
- private int[] tabStops;
- private int[] bulletOffsets = new int[5];
- private int[] textOffsets = new int[5];
-
- /**
- * Constructs a new empty ruler atom.
- */
- public TextRulerAtom() {
- _header = new byte[8];
- _data = new byte[0];
-
- LittleEndian.putShort(_header, 2, (short)getRecordType());
- LittleEndian.putInt(_header, 4, _data.length);
- }
-
- /**
- * Constructs the ruler atom record from its
- * source data.
- *
- * @param source the source data as a byte array.
- * @param start the start offset into the byte array.
- * @param len the length of the slice in the byte array.
- */
- protected TextRulerAtom(byte[] source, int start, int len) {
- // Get the header.
- _header = new byte[8];
- System.arraycopy(source,start,_header,0,8);
-
- // Get the record data.
- _data = new byte[len-8];
- System.arraycopy(source,start+8,_data,0,len-8);
-
- try {
- read();
- } catch (Exception e){
- logger.log(POILogger.ERROR, "Failed to parse TextRulerAtom: " + e.getMessage());
- e.printStackTrace();
- }
- }
-
- /**
- * Gets the record type.
- *
- * @return the record type.
- */
- public long getRecordType() {
- return RecordTypes.TextRulerAtom.typeID;
- }
-
- /**
- * Write the contents of the record back, so it can be written
- * to disk.
- *
- * @param out the output stream to write to.
- * @throws java.io.IOException if an error occurs.
- */
- public void writeOut(OutputStream out) throws IOException {
- out.write(_header);
- out.write(_data);
- }
-
- /**
- * Read the record bytes and initialize the internal variables
- */
- private void read(){
- int pos = 0;
- short mask = LittleEndian.getShort(_data); pos += 4;
- short val;
- int[] bits = {1, 0, 2, 3, 8, 4, 9, 5, 10, 6, 11, 7, 12};
- for (int i = 0; i < bits.length; i++) {
- if((mask & 1 << bits[i]) != 0){
- switch (bits[i]){
- case 0:
- //defaultTabSize
- defaultTabSize = LittleEndian.getShort(_data, pos); pos += 2;
- break;
- case 1:
- //numLevels
- numLevels = LittleEndian.getShort(_data, pos); pos += 2;
- break;
- case 2:
- //tabStops
- val = LittleEndian.getShort(_data, pos); pos += 2;
- tabStops = new int[val*2];
- for (int j = 0; j < tabStops.length; j++) {
- tabStops[j] = LittleEndian.getUShort(_data, pos); pos += 2;
- }
- break;
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- //bullet.offset
- val = LittleEndian.getShort(_data, pos); pos += 2;
- bulletOffsets[bits[i]-3] = val;
- break;
- case 8:
- case 9:
- case 10:
- case 11:
- case 12:
- //text.offset
- val = LittleEndian.getShort(_data, pos); pos += 2;
- textOffsets[bits[i]-8] = val;
- break;
- }
- }
- }
- }
-
- /**
- * Default distance between tab stops, in master coordinates (576 dpi).
- */
- public int getDefaultTabSize(){
- return defaultTabSize;
- }
-
- /**
- * Number of indent levels (maximum 5).
- */
- public int getNumberOfLevels(){
- return numLevels;
- }
-
- /**
- * Default distance between tab stops, in master coordinates (576 dpi).
- */
- public int[] getTabStops(){
- return tabStops;
- }
-
- /**
- * Paragraph's distance from shape's left margin, in master coordinates (576 dpi).
- */
- public int[] getTextOffsets(){
- return textOffsets;
- }
-
- /**
- * First line of paragraph's distance from shape's left margin, in master coordinates (576 dpi).
- */
- public int[] getBulletOffsets(){
- return bulletOffsets;
- }
-
- public static TextRulerAtom getParagraphInstance(){
- byte[] data = new byte[] {
- 0x00, 0x00, (byte)0xA6, 0x0F, 0x0A, 0x00, 0x00, 0x00,
- 0x10, 0x03, 0x00, 0x00, (byte)0xF9, 0x00, 0x41, 0x01, 0x41, 0x01
- };
- TextRulerAtom ruler = new TextRulerAtom(data, 0, data.length);
- return ruler;
- }
-
- public void setParagraphIndent(short tetxOffset, short bulletOffset){
- LittleEndian.putShort(_data, 4, tetxOffset);
- LittleEndian.putShort(_data, 6, bulletOffset);
- LittleEndian.putShort(_data, 8, bulletOffset);
- }
-}
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.record;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.zip.InflaterInputStream;
+
+import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.POILogger;
+
+/**
+ * Ruler of a text as it differs from the style's ruler settings.
+ *
+ * @author Yegor Kozlov
+ */
+public final class TextRulerAtom extends RecordAtom {
+
+ /**
+ * Record header.
+ */
+ private byte[] _header;
+
+ /**
+ * Record data.
+ */
+ private byte[] _data;
+
+ //ruler internals
+ private int defaultTabSize;
+ private int numLevels;
+ private int[] tabStops;
+ private int[] bulletOffsets = new int[5];
+ private int[] textOffsets = new int[5];
+
+ /**
+ * Constructs a new empty ruler atom.
+ */
+ public TextRulerAtom() {
+ _header = new byte[8];
+ _data = new byte[0];
+
+ LittleEndian.putShort(_header, 2, (short)getRecordType());
+ LittleEndian.putInt(_header, 4, _data.length);
+ }
+
+ /**
+ * Constructs the ruler atom record from its
+ * source data.
+ *
+ * @param source the source data as a byte array.
+ * @param start the start offset into the byte array.
+ * @param len the length of the slice in the byte array.
+ */
+ protected TextRulerAtom(byte[] source, int start, int len) {
+ // Get the header.
+ _header = new byte[8];
+ System.arraycopy(source,start,_header,0,8);
+
+ // Get the record data.
+ _data = new byte[len-8];
+ System.arraycopy(source,start+8,_data,0,len-8);
+
+ try {
+ read();
+ } catch (Exception e){
+ logger.log(POILogger.ERROR, "Failed to parse TextRulerAtom: " + e.getMessage());
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Gets the record type.
+ *
+ * @return the record type.
+ */
+ public long getRecordType() {
+ return RecordTypes.TextRulerAtom.typeID;
+ }
+
+ /**
+ * Write the contents of the record back, so it can be written
+ * to disk.
+ *
+ * @param out the output stream to write to.
+ * @throws java.io.IOException if an error occurs.
+ */
+ public void writeOut(OutputStream out) throws IOException {
+ out.write(_header);
+ out.write(_data);
+ }
+
+ /**
+ * Read the record bytes and initialize the internal variables
+ */
+ private void read(){
+ int pos = 0;
+ short mask = LittleEndian.getShort(_data); pos += 4;
+ short val;
+ int[] bits = {1, 0, 2, 3, 8, 4, 9, 5, 10, 6, 11, 7, 12};
+ for (int i = 0; i < bits.length; i++) {
+ if((mask & 1 << bits[i]) != 0){
+ switch (bits[i]){
+ case 0:
+ //defaultTabSize
+ defaultTabSize = LittleEndian.getShort(_data, pos); pos += 2;
+ break;
+ case 1:
+ //numLevels
+ numLevels = LittleEndian.getShort(_data, pos); pos += 2;
+ break;
+ case 2:
+ //tabStops
+ val = LittleEndian.getShort(_data, pos); pos += 2;
+ tabStops = new int[val*2];
+ for (int j = 0; j < tabStops.length; j++) {
+ tabStops[j] = LittleEndian.getUShort(_data, pos); pos += 2;
+ }
+ break;
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ //bullet.offset
+ val = LittleEndian.getShort(_data, pos); pos += 2;
+ bulletOffsets[bits[i]-3] = val;
+ break;
+ case 8:
+ case 9:
+ case 10:
+ case 11:
+ case 12:
+ //text.offset
+ val = LittleEndian.getShort(_data, pos); pos += 2;
+ textOffsets[bits[i]-8] = val;
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * Default distance between tab stops, in master coordinates (576 dpi).
+ */
+ public int getDefaultTabSize(){
+ return defaultTabSize;
+ }
+
+ /**
+ * Number of indent levels (maximum 5).
+ */
+ public int getNumberOfLevels(){
+ return numLevels;
+ }
+
+ /**
+ * Default distance between tab stops, in master coordinates (576 dpi).
+ */
+ public int[] getTabStops(){
+ return tabStops;
+ }
+
+ /**
+ * Paragraph's distance from shape's left margin, in master coordinates (576 dpi).
+ */
+ public int[] getTextOffsets(){
+ return textOffsets;
+ }
+
+ /**
+ * First line of paragraph's distance from shape's left margin, in master coordinates (576 dpi).
+ */
+ public int[] getBulletOffsets(){
+ return bulletOffsets;
+ }
+
+ public static TextRulerAtom getParagraphInstance(){
+ byte[] data = new byte[] {
+ 0x00, 0x00, (byte)0xA6, 0x0F, 0x0A, 0x00, 0x00, 0x00,
+ 0x10, 0x03, 0x00, 0x00, (byte)0xF9, 0x00, 0x41, 0x01, 0x41, 0x01
+ };
+ TextRulerAtom ruler = new TextRulerAtom(data, 0, data.length);
+ return ruler;
+ }
+
+ public void setParagraphIndent(short tetxOffset, short bulletOffset){
+ LittleEndian.putShort(_data, 4, tetxOffset);
+ LittleEndian.putShort(_data, 6, bulletOffset);
+ LittleEndian.putShort(_data, 8, bulletOffset);
+ }
+}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java Thu May 21 18:12:22 2009
@@ -1,200 +1,201 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-package org.apache.poi.hslf.record;
-
-import org.apache.poi.util.LittleEndian;
-
-import java.io.OutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-
-/**
- * The special info runs contained in this text.
- * Special info runs consist of character properties which don?t follow styles.
- *
- * @author Yegor Kozlov
- */
-public class TextSpecInfoAtom extends RecordAtom {
- /**
- * Record header.
- */
- private byte[] _header;
-
- /**
- * Record data.
- */
- private byte[] _data;
-
- /**
- * Constructs the link related atom record from its
- * source data.
- *
- * @param source the source data as a byte array.
- * @param start the start offset into the byte array.
- * @param len the length of the slice in the byte array.
- */
- protected TextSpecInfoAtom(byte[] source, int start, int len) {
- // Get the header.
- _header = new byte[8];
- System.arraycopy(source,start,_header,0,8);
-
- // Get the record data.
- _data = new byte[len-8];
- System.arraycopy(source,start+8,_data,0,len-8);
-
- }
- /**
- * Gets the record type.
- * @return the record type.
- */
- public long getRecordType() { return RecordTypes.TextSpecInfoAtom.typeID; }
-
- /**
- * Write the contents of the record back, so it can be written
- * to disk
- *
- * @param out the output stream to write to.
- * @throws java.io.IOException if an error occurs.
- */
- public void writeOut(OutputStream out) throws IOException {
- out.write(_header);
- out.write(_data);
- }
-
- /**
- * Update the text length
- *
- * @param size the text length
- */
- public void setTextSize(int size){
- LittleEndian.putInt(_data, 0, size);
- }
-
- /**
- * Reset the content to one info run with the default values
- * @param size the site of parent text
- */
- public void reset(int size){
- _data = new byte[10];
- // 01 00 00 00
- LittleEndian.putInt(_data, 0, size);
- // 01 00 00 00
- LittleEndian.putInt(_data, 4, 1); //mask
- // 00 00
- LittleEndian.putShort(_data, 8, (short)0); //langId
-
- // Update the size (header bytes 5-8)
- LittleEndian.putInt(_header, 4, _data.length);
- }
-
- /**
- * Get the number of characters covered by this records
- *
- * @return the number of characters covered by this records
- */
- public int getCharactersCovered(){
- int covered = 0;
- TextSpecInfoRun[] runs = getTextSpecInfoRuns();
- for (int i = 0; i < runs.length; i++) covered += runs[i].len;
- return covered;
- }
-
- public TextSpecInfoRun[] getTextSpecInfoRuns(){
- ArrayList lst = new ArrayList();
- int pos = 0;
- int[] bits = {1, 0, 2};
- while(pos < _data.length) {
- TextSpecInfoRun run = new TextSpecInfoRun();
- run.len = LittleEndian.getInt(_data, pos); pos += 4;
- run.mask = LittleEndian.getInt(_data, pos); pos += 4;
- for (int i = 0; i < bits.length; i++) {
- if((run.mask & 1 << bits[i]) != 0){
- switch (bits[i]){
- case 0:
- run.spellInfo = LittleEndian.getShort(_data, pos); pos += 2;
- break;
- case 1:
- run.langId = LittleEndian.getShort(_data, pos); pos += 2;
- break;
- case 2:
- run.altLangId = LittleEndian.getShort(_data, pos); pos += 2;
- break;
- }
- }
- }
- lst.add(run);
- }
- return (TextSpecInfoRun[])lst.toArray(new TextSpecInfoRun[lst.size()]);
-
- }
-
- public static class TextSpecInfoRun {
- //Length of special info run.
- protected int len;
-
- //Special info mask of this run;
- protected int mask;
-
- // info fields as indicated by the mask.
- // -1 means the bit is not set
- protected short spellInfo = -1;
- protected short langId = -1;
- protected short altLangId = -1;
-
- /**
- * Spelling status of this text. See Spell Info table below.
- *
- * <p>Spell Info Types:</p>
- * <li>0 Unchecked
- * <li>1 Previously incorrect, needs rechecking
- * <li>2 Correct
- * <li>3 Incorrect
- *
- * @return Spelling status of this text
- */
- public short getSpellInfo(){
- return spellInfo;
- }
-
- /**
- * Windows LANGID for this text.
- *
- * @return Windows LANGID for this text.
- */
- public short getLangId(){
- return spellInfo;
- }
-
- /**
- * Alternate Windows LANGID of this text;
- * must be a valid non-East Asian LANGID if the text has an East Asian language,
- * otherwise may be an East Asian LANGID or language neutral (zero).
- *
- * @return Alternate Windows LANGID of this text
- */
- public short getAltLangId(){
- return altLangId;
- }
-
- /**
- * @return Length of special info run.
- */
- public int length(){
- return len;
- }
- }
-}
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.record;
+
+import org.apache.poi.util.LittleEndian;
+
+import java.io.OutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+
+/**
+ * The special info runs contained in this text.
+ * Special info runs consist of character properties which don?t follow styles.
+ *
+ * @author Yegor Kozlov
+ */
+public final class TextSpecInfoAtom extends RecordAtom {
+ /**
+ * Record header.
+ */
+ private byte[] _header;
+
+ /**
+ * Record data.
+ */
+ private byte[] _data;
+
+ /**
+ * Constructs the link related atom record from its
+ * source data.
+ *
+ * @param source the source data as a byte array.
+ * @param start the start offset into the byte array.
+ * @param len the length of the slice in the byte array.
+ */
+ protected TextSpecInfoAtom(byte[] source, int start, int len) {
+ // Get the header.
+ _header = new byte[8];
+ System.arraycopy(source,start,_header,0,8);
+
+ // Get the record data.
+ _data = new byte[len-8];
+ System.arraycopy(source,start+8,_data,0,len-8);
+
+ }
+ /**
+ * Gets the record type.
+ * @return the record type.
+ */
+ public long getRecordType() { return RecordTypes.TextSpecInfoAtom.typeID; }
+
+ /**
+ * Write the contents of the record back, so it can be written
+ * to disk
+ *
+ * @param out the output stream to write to.
+ * @throws java.io.IOException if an error occurs.
+ */
+ public void writeOut(OutputStream out) throws IOException {
+ out.write(_header);
+ out.write(_data);
+ }
+
+ /**
+ * Update the text length
+ *
+ * @param size the text length
+ */
+ public void setTextSize(int size){
+ LittleEndian.putInt(_data, 0, size);
+ }
+
+ /**
+ * Reset the content to one info run with the default values
+ * @param size the site of parent text
+ */
+ public void reset(int size){
+ _data = new byte[10];
+ // 01 00 00 00
+ LittleEndian.putInt(_data, 0, size);
+ // 01 00 00 00
+ LittleEndian.putInt(_data, 4, 1); //mask
+ // 00 00
+ LittleEndian.putShort(_data, 8, (short)0); //langId
+
+ // Update the size (header bytes 5-8)
+ LittleEndian.putInt(_header, 4, _data.length);
+ }
+
+ /**
+ * Get the number of characters covered by this records
+ *
+ * @return the number of characters covered by this records
+ */
+ public int getCharactersCovered(){
+ int covered = 0;
+ TextSpecInfoRun[] runs = getTextSpecInfoRuns();
+ for (int i = 0; i < runs.length; i++) covered += runs[i].len;
+ return covered;
+ }
+
+ public TextSpecInfoRun[] getTextSpecInfoRuns(){
+ ArrayList lst = new ArrayList();
+ int pos = 0;
+ int[] bits = {1, 0, 2};
+ while(pos < _data.length) {
+ TextSpecInfoRun run = new TextSpecInfoRun();
+ run.len = LittleEndian.getInt(_data, pos); pos += 4;
+ run.mask = LittleEndian.getInt(_data, pos); pos += 4;
+ for (int i = 0; i < bits.length; i++) {
+ if((run.mask & 1 << bits[i]) != 0){
+ switch (bits[i]){
+ case 0:
+ run.spellInfo = LittleEndian.getShort(_data, pos); pos += 2;
+ break;
+ case 1:
+ run.langId = LittleEndian.getShort(_data, pos); pos += 2;
+ break;
+ case 2:
+ run.altLangId = LittleEndian.getShort(_data, pos); pos += 2;
+ break;
+ }
+ }
+ }
+ lst.add(run);
+ }
+ return (TextSpecInfoRun[])lst.toArray(new TextSpecInfoRun[lst.size()]);
+
+ }
+
+ public static class TextSpecInfoRun {
+ //Length of special info run.
+ protected int len;
+
+ //Special info mask of this run;
+ protected int mask;
+
+ // info fields as indicated by the mask.
+ // -1 means the bit is not set
+ protected short spellInfo = -1;
+ protected short langId = -1;
+ protected short altLangId = -1;
+
+ /**
+ * Spelling status of this text. See Spell Info table below.
+ *
+ * <p>Spell Info Types:</p>
+ * <li>0 Unchecked
+ * <li>1 Previously incorrect, needs rechecking
+ * <li>2 Correct
+ * <li>3 Incorrect
+ *
+ * @return Spelling status of this text
+ */
+ public short getSpellInfo(){
+ return spellInfo;
+ }
+
+ /**
+ * Windows LANGID for this text.
+ *
+ * @return Windows LANGID for this text.
+ */
+ public short getLangId(){
+ return spellInfo;
+ }
+
+ /**
+ * Alternate Windows LANGID of this text;
+ * must be a valid non-East Asian LANGID if the text has an East Asian language,
+ * otherwise may be an East Asian LANGID or language neutral (zero).
+ *
+ * @return Alternate Windows LANGID of this text
+ */
+ public short getAltLangId(){
+ return altLangId;
+ }
+
+ /**
+ * @return Length of special info run.
+ */
+ public int length(){
+ return len;
+ }
+ }
+}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TxInteractiveInfoAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TxInteractiveInfoAtom.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TxInteractiveInfoAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TxInteractiveInfoAtom.java Thu May 21 18:12:22 2009
@@ -1,122 +1,123 @@
-/* ====================================================================
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-==================================================================== */
-package org.apache.poi.hslf.record;
-
-import org.apache.poi.util.LittleEndian;
-
-import java.io.OutputStream;
-import java.io.IOException;
-
-/**
- * Tne atom that holds starting and ending character positions of a hyperlink
- *
- * @author Yegor Kozlov
- */
-public class TxInteractiveInfoAtom extends RecordAtom {
- /**
- * Record header.
- */
- private byte[] _header;
-
- /**
- * Record data.
- */
- private byte[] _data;
-
- /**
- * Constructs a brand new link related atom record.
- */
- public TxInteractiveInfoAtom() {
- _header = new byte[8];
- _data = new byte[8];
-
- LittleEndian.putShort(_header, 2, (short)getRecordType());
- LittleEndian.putInt(_header, 4, _data.length);
- }
-
- /**
- * Constructs the link related atom record from its
- * source data.
- *
- * @param source the source data as a byte array.
- * @param start the start offset into the byte array.
- * @param len the length of the slice in the byte array.
- */
- protected TxInteractiveInfoAtom(byte[] source, int start, int len) {
- // Get the header.
- _header = new byte[8];
- System.arraycopy(source,start,_header,0,8);
-
- // Get the record data.
- _data = new byte[len-8];
- System.arraycopy(source,start+8,_data,0,len-8);
-
- }
-
- /**
- * Gets the beginning character position
- *
- * @return the beginning character position
- */
- public int getStartIndex() {
- return LittleEndian.getInt(_data, 0);
- }
-
- /**
- * Sets the beginning character position
- * @param idx the beginning character position
- */
- public void setStartIndex(int idx) {
- LittleEndian.putInt(_data, 0, idx);
- }
-
- /**
- * Gets the ending character position
- *
- * @return the ending character position
- */
- public int getEndIndex() {
- return LittleEndian.getInt(_data, 4);
- }
-
- /**
- * Sets the ending character position
- *
- * @param idx the ending character position
- */
- public void setEndIndex(int idx) {
- LittleEndian.putInt(_data, 4, idx);
- }
-
- /**
- * Gets the record type.
- * @return the record type.
- */
- public long getRecordType() { return RecordTypes.TxInteractiveInfoAtom.typeID; }
-
- /**
- * Write the contents of the record back, so it can be written
- * to disk
- *
- * @param out the output stream to write to.
- * @throws java.io.IOException if an error occurs.
- */
- public void writeOut(OutputStream out) throws IOException {
- out.write(_header);
- out.write(_data);
- }
-}
+/* ====================================================================
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+==================================================================== */
+
+package org.apache.poi.hslf.record;
+
+import org.apache.poi.util.LittleEndian;
+
+import java.io.OutputStream;
+import java.io.IOException;
+
+/**
+ * Tne atom that holds starting and ending character positions of a hyperlink
+ *
+ * @author Yegor Kozlov
+ */
+public final class TxInteractiveInfoAtom extends RecordAtom {
+ /**
+ * Record header.
+ */
+ private byte[] _header;
+
+ /**
+ * Record data.
+ */
+ private byte[] _data;
+
+ /**
+ * Constructs a brand new link related atom record.
+ */
+ public TxInteractiveInfoAtom() {
+ _header = new byte[8];
+ _data = new byte[8];
+
+ LittleEndian.putShort(_header, 2, (short)getRecordType());
+ LittleEndian.putInt(_header, 4, _data.length);
+ }
+
+ /**
+ * Constructs the link related atom record from its
+ * source data.
+ *
+ * @param source the source data as a byte array.
+ * @param start the start offset into the byte array.
+ * @param len the length of the slice in the byte array.
+ */
+ protected TxInteractiveInfoAtom(byte[] source, int start, int len) {
+ // Get the header.
+ _header = new byte[8];
+ System.arraycopy(source,start,_header,0,8);
+
+ // Get the record data.
+ _data = new byte[len-8];
+ System.arraycopy(source,start+8,_data,0,len-8);
+
+ }
+
+ /**
+ * Gets the beginning character position
+ *
+ * @return the beginning character position
+ */
+ public int getStartIndex() {
+ return LittleEndian.getInt(_data, 0);
+ }
+
+ /**
+ * Sets the beginning character position
+ * @param idx the beginning character position
+ */
+ public void setStartIndex(int idx) {
+ LittleEndian.putInt(_data, 0, idx);
+ }
+
+ /**
+ * Gets the ending character position
+ *
+ * @return the ending character position
+ */
+ public int getEndIndex() {
+ return LittleEndian.getInt(_data, 4);
+ }
+
+ /**
+ * Sets the ending character position
+ *
+ * @param idx the ending character position
+ */
+ public void setEndIndex(int idx) {
+ LittleEndian.putInt(_data, 4, idx);
+ }
+
+ /**
+ * Gets the record type.
+ * @return the record type.
+ */
+ public long getRecordType() { return RecordTypes.TxInteractiveInfoAtom.typeID; }
+
+ /**
+ * Write the contents of the record back, so it can be written
+ * to disk
+ *
+ * @param out the output stream to write to.
+ * @throws java.io.IOException if an error occurs.
+ */
+ public void writeOut(OutputStream out) throws IOException {
+ out.write(_header);
+ out.write(_data);
+ }
+}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TxMasterStyleAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TxMasterStyleAtom.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TxMasterStyleAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TxMasterStyleAtom.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -41,7 +40,7 @@
*
* @author Yegor Kozlov
*/
-public class TxMasterStyleAtom extends RecordAtom {
+public final class TxMasterStyleAtom extends RecordAtom {
/**
* Maximum number of indentatio levels allowed in PowerPoint documents
@@ -116,7 +115,7 @@
* Must be a constant defined in <code>TextHeaderAtom</code>
*
* @return type of the text
- * @see TextHeaderAtom
+ * @see TextHeaderAtom
*/
public int getTextType(){
//The atom instance value is the text type
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UnknownRecordPlaceholder.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UnknownRecordPlaceholder.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UnknownRecordPlaceholder.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UnknownRecordPlaceholder.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hslf.record;
@@ -31,12 +29,12 @@
* @author Nick Burch
*/
-public class UnknownRecordPlaceholder extends RecordAtom
+public final class UnknownRecordPlaceholder extends RecordAtom
{
private byte[] _contents;
private long _type;
- /**
+ /**
* Create a new holder for a record we don't grok
*/
protected UnknownRecordPlaceholder(byte[] source, int start, int len) {
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UserEditAtom.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UserEditAtom.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UserEditAtom.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/UserEditAtom.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,7 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.hslf.record;
@@ -35,7 +33,7 @@
* @author Nick Burch
*/
-public class UserEditAtom extends PositionDependentRecordAtom
+public final class UserEditAtom extends PositionDependentRecordAtom
{
public static final int LAST_VIEW_NONE = 0;
public static final int LAST_VIEW_SLIDE_VIEW = 1;
@@ -72,7 +70,7 @@
/* *************** record code follows ********************** */
- /**
+ /**
* For the UserEdit Atom
*/
protected UserEditAtom(byte[] source, int start, int len) {
@@ -90,12 +88,12 @@
pptVersion = (int)LittleEndian.getInt(source,start+4+8);
// Get the offset to the previous incremental save's UserEditAtom
- // This will be the byte offset on disk where the previous one
+ // This will be the byte offset on disk where the previous one
// starts, or 0 if this is the first one
lastUserEditAtomOffset = (int)LittleEndian.getInt(source,start+8+8);
// Get the offset to the persist pointers
- // This will be the byte offset on disk where the preceding
+ // This will be the byte offset on disk where the preceding
// PersistPtrFullBlock or PersistPtrIncrementalBlock starts
persistPointersOffset = (int)LittleEndian.getInt(source,start+12+8);
@@ -105,7 +103,7 @@
// Maximum number of persist objects written
maxPersistWritten = (int)LittleEndian.getInt(source,start+20+8);
-
+
// Last view type
lastViewType = (short)LittleEndian.getShort(source,start+24+8);
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/PictureData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/PictureData.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/PictureData.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/PictureData.java Thu May 21 18:12:22 2009
@@ -14,6 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
+
package org.apache.poi.hslf.usermodel;
import org.apache.poi.util.LittleEndian;
@@ -234,7 +235,7 @@
* Register ImagePainter for the specified image type
*
* @param type image type, must be one of the static constants defined in the <code>Picture<code> class.
- * @param painter
+ * @param painter
*/
public static void setImagePainter(int type, ImagePainter painter){
painters[type] = painter;
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java Thu May 21 18:12:22 2009
@@ -1,4 +1,3 @@
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -15,8 +14,6 @@
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
-
package org.apache.poi.hslf.usermodel;
@@ -38,22 +35,22 @@
/**
* Represents a run of text, all with the same style
- *
+ *
*/
-public class RichTextRun {
+public final class RichTextRun {
protected POILogger logger = POILogFactory.getLogger(this.getClass());
/** The TextRun we belong to */
private TextRun parentRun;
/** The SlideShow we belong to */
private SlideShow slideShow;
-
+
/** Where in the parent TextRun we start from */
private int startPos;
-
+
/** How long a string (in the parent TextRun) we represent */
private int length;
-
+
private String _fontname;
/**
* Our paragraph and character style.
@@ -84,7 +81,7 @@
* @param pShared The paragraph styles are shared with other runs
* @param cShared The character styles are shared with other runs
*/
- public RichTextRun(TextRun parent, int startAt, int len,
+ public RichTextRun(TextRun parent, int startAt, int len,
TextPropCollection pStyle, TextPropCollection cStyle,
boolean pShared, boolean cShared) {
parentRun = parent;
@@ -97,8 +94,8 @@
}
/**
- * Supply (normally default) textprops, and if they're shared,
- * when a run gets them
+ * Supply (normally default) textprops, and if they're shared,
+ * when a run gets them
*/
public void supplyTextProps(TextPropCollection pStyle, TextPropCollection cStyle, boolean pShared, boolean cShared) {
if(paragraphStyle != null || characterStyle != null) {
@@ -119,7 +116,7 @@
_fontname = null;
}
}
-
+
/**
* Get the length of the text
*/
@@ -157,7 +154,7 @@
public String getRawText() {
return parentRun.getRawText().substring(startPos, startPos+length);
}
-
+
/**
* Change the text
*/
@@ -165,7 +162,7 @@
String s = parentRun.normalize(text);
setRawText(s);
}
-
+
/**
* Change the text
*/
@@ -181,10 +178,10 @@
public void updateStartPosition(int startAt) {
startPos = startAt;
}
-
-
+
+
// --------------- Internal helpers on rich text properties -------
-
+
/**
* Fetch the value of the given flag in the CharFlagsTextProp.
* Returns false if the CharFlagsTextProp isn't present, since the
@@ -227,7 +224,7 @@
/**
* Set the value of the given flag in the CharFlagsTextProp, adding
- * it if required.
+ * it if required.
*/
private void setCharFlagsTextPropVal(int index, boolean value) {
if(getFlag(true, index) != value) setFlag(true, index, value);
@@ -268,11 +265,11 @@
}
return tp;
}
-
+
/**
- * Fetch the value of the given Character related TextProp.
- * Returns -1 if that TextProp isn't present.
- * If the TextProp isn't present, the value from the appropriate
+ * Fetch the value of the given Character related TextProp.
+ * Returns -1 if that TextProp isn't present.
+ * If the TextProp isn't present, the value from the appropriate
* Master Sheet will apply.
*/
private int getCharTextPropVal(String propName) {
@@ -315,7 +312,7 @@
return prop == null ? -1 : prop.getValue();
}
-
+
/**
* Sets the value of the given Character TextProp, add if required
* @param propName The name of the Character TextProp
@@ -327,7 +324,7 @@
parentRun.ensureStyleAtomPresent();
// paragraphStyle will now be defined
}
-
+
TextProp tp = fetchOrAddTextProp(paragraphStyle, propName);
tp.setValue(val);
}
@@ -342,12 +339,12 @@
parentRun.ensureStyleAtomPresent();
// characterStyle will now be defined
}
-
+
TextProp tp = fetchOrAddTextProp(characterStyle, propName);
tp.setValue(val);
}
-
-
+
+
// --------------- Friendly getters / setters on rich text properties -------
/**
@@ -363,7 +360,7 @@
public void setBold(boolean bold) {
setCharFlagsTextPropVal(CharFlagsTextProp.BOLD_IDX, bold);
}
-
+
/**
* Is the text italic?
*/
@@ -377,7 +374,7 @@
public void setItalic(boolean italic) {
setCharFlagsTextPropVal(CharFlagsTextProp.ITALIC_IDX, italic);
}
-
+
/**
* Is the text underlined?
*/
@@ -509,7 +506,7 @@
return slideShow.getFontCollection().getFontWithId(fontIdx);
}
}
-
+
/**
* @return font color as RGB value
* @see java.awt.Color
@@ -529,13 +526,13 @@
/**
* Sets color of the text, as a int bgr.
* (PowerPoint stores as BlueGreenRed, not the more
- * usual RedGreenBlue)
+ * usual RedGreenBlue)
* @see java.awt.Color
*/
public void setFontColor(int bgr) {
setCharTextPropVal("font.color", bgr);
}
-
+
/**
* Sets color of the text, as a java.awt.Color
*/
@@ -772,15 +769,15 @@
return val == -1 ? 0 : val;
}
// --------------- Internal HSLF methods, not intended for end-user use! -------
-
+
/**
* Internal Use Only - get the underlying paragraph style collection.
- * For normal use, use the friendly setters and getters
+ * For normal use, use the friendly setters and getters
*/
public TextPropCollection _getRawParagraphStyle() { return paragraphStyle; }
/**
* Internal Use Only - get the underlying character style collection.
- * For normal use, use the friendly setters and getters
+ * For normal use, use the friendly setters and getters
*/
public TextPropCollection _getRawCharacterStyle() { return characterStyle; }
/**
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java?rev=777204&r1=777203&r2=777204&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java Thu May 21 18:12:22 2009
@@ -49,7 +49,7 @@
* - figure out how to match notes to their correct sheet
* (will involve understanding DocSlideList and DocNotesList)
* - handle Slide creation cleaner
- *
+ *
* @author Nick Burch
* @author Yegor kozlov
*/
@@ -80,15 +80,15 @@
// For logging
private POILogger logger = POILogFactory.getLogger(this.getClass());
-
+
/* ===============================================================
* Setup Code
* ===============================================================
*/
-
+
/**
- * Constructs a Powerpoint document from the underlying
+ * Constructs a Powerpoint document from the underlying
* HSLFSlideShow object. Finds the model stuff from this
*
* @param hslfSlideShow the HSLFSlideShow to base on
@@ -97,7 +97,7 @@
// Get useful things from our base slideshow
_hslfSlideShow = hslfSlideShow;
_records = _hslfSlideShow.getRecords();
-
+
// Handle Parent-aware Reocrds
for(int i=0; i<_records.length; i++) {
handleParentAwareRecords(_records[i]);
@@ -105,11 +105,11 @@
// Find the versions of the core records we'll want to use
findMostRecentCoreRecords();
-
+
// Build up the model level Slides and Notes
buildSlidesAndNotes();
}
-
+
/**
* Constructs a new, empty, Powerpoint document.
*/
@@ -133,7 +133,7 @@
if(baseRecord instanceof RecordContainer) {
RecordContainer br = (RecordContainer)baseRecord;
Record[] childRecords = br.getChildRecords();
-
+
// Loop over child records, looking for interesting ones
for(int i=0; i<childRecords.length; i++) {
Record record = childRecords[i];
@@ -164,14 +164,14 @@
if(_records[i] instanceof PersistPtrHolder) {
PersistPtrHolder pph = (PersistPtrHolder)_records[i];
- // If we've already seen any of the "slide" IDs for this
+ // If we've already seen any of the "slide" IDs for this
// PersistPtr, remove their old positions
int[] ids = pph.getKnownSlideIDs();
for(int j=0; j<ids.length; j++) {
Integer id = new Integer(ids[j]);
if( mostRecentByBytes.containsKey(id)) {
mostRecentByBytes.remove(id);
- }
+ }
}
// Now, update the byte level locations with their latest values
@@ -186,7 +186,7 @@
// We now know how many unique special records we have, so init
// the array
_mostRecentCoreRecords = new Record[mostRecentByBytes.size()];
-
+
// We'll also want to be able to turn the slide IDs into a position
// in this array
_sheetIdToCoreRecordsLookup = new Hashtable();
@@ -214,24 +214,24 @@
if(thatRecordAt.equals(recordAt)) {
// Bingo. Now, where do we store it?
- Integer storeAtI =
+ Integer storeAtI =
(Integer)_sheetIdToCoreRecordsLookup.get(thisID);
int storeAt = storeAtI.intValue();
-
+
// Tell it its Sheet ID, if it cares
if(pdr instanceof PositionDependentRecordContainer) {
- PositionDependentRecordContainer pdrc =
+ PositionDependentRecordContainer pdrc =
(PositionDependentRecordContainer)_records[i];
pdrc.setSheetId(thisID.intValue());
}
-
+
// Finally, save the record
_mostRecentCoreRecords[storeAt] = _records[i];
}
}
}
}
-
+
// Now look for the interesting records in there
for(int i=0; i<_mostRecentCoreRecords.length; i++) {
// Check there really is a record at this number
@@ -247,7 +247,7 @@
}
}
}
-
+
/**
* For a given SlideAtomsSet, return the core record, based on the refID from the
* SlidePersistAtom
@@ -257,7 +257,7 @@
int refID = spa.getRefID();
return getCoreRecordForRefID(refID);
}
-
+
/**
* For a given refID (the internal, 0 based numbering scheme), return the
* core record
@@ -302,7 +302,7 @@
// Having indentified the masters, slides and notes + their orders,
// we have to go and find their matching records
// We always use the latest versions of these records, and use the
- // SlideAtom/NotesAtom to match them with the StyleAtomSet
+ // SlideAtom/NotesAtom to match them with the StyleAtomSet
SlideListWithText masterSLWT = _documentRecord.getMasterSlideListWithText();
SlideListWithText slidesSLWT = _documentRecord.getSlideSlideListWithText();
@@ -354,7 +354,7 @@
Hashtable slideIdToNotes = new Hashtable();
if(notesSLWT == null) {
// None
- notesRecords = new org.apache.poi.hslf.record.Notes[0];
+ notesRecords = new org.apache.poi.hslf.record.Notes[0];
} else {
// Match up the records and the SlideAtomSets
notesSets = notesSLWT.getSlideAtomsSets();
@@ -380,13 +380,13 @@
notesRecords = (org.apache.poi.hslf.record.Notes[])
notesRecordsL.toArray(notesRecords);
}
-
+
// Now, do the same thing for our slides
org.apache.poi.hslf.record.Slide[] slidesRecords;
SlideAtomsSet[] slidesSets = new SlideAtomsSet[0];
if(slidesSLWT == null) {
// None
- slidesRecords = new org.apache.poi.hslf.record.Slide[0];
+ slidesRecords = new org.apache.poi.hslf.record.Slide[0];
} else {
// Match up the records and the SlideAtomSets
slidesSets = slidesSLWT.getSlideAtomsSets();
@@ -394,7 +394,7 @@
for(int i=0; i<slidesSets.length; i++) {
// Get the right core record
Record r = getCoreRecordForSAS(slidesSets[i]);
-
+
// Ensure it really is a slide record
if(r instanceof org.apache.poi.hslf.record.Slide) {
slidesRecords[i] = (org.apache.poi.hslf.record.Slide)r;
@@ -403,7 +403,7 @@
}
}
}
-
+
// Finally, generate model objects for everything
// Notes first
_notes = new Notes[notesRecords.length];
@@ -449,7 +449,7 @@
* Accessor Code
* ===============================================================
*/
-
+
/**
* Returns an array of the most recent version of all the interesting
@@ -506,10 +506,10 @@
int pgy = (int)docatom.getSlideSizeY()*Shape.POINT_DPI/Shape.MASTER_DPI;
return new Dimension(pgx, pgy);
}
-
+
/**
* Change the current page size
- *
+ *
* @param pgsize page size (in points)
*/
public void setPageSize(Dimension pgsize){
@@ -517,7 +517,7 @@
docatom.setSlideSizeX(pgsize.width*Shape.MASTER_DPI/Shape.POINT_DPI);
docatom.setSlideSizeY(pgsize.height*Shape.MASTER_DPI/Shape.POINT_DPI);
}
-
+
/**
* Helper method for usermodel: Get the font collection
*/
@@ -527,13 +527,13 @@
*/
public Document getDocumentRecord() { return _documentRecord; }
-
+
/* ===============================================================
* Re-ordering Code
* ===============================================================
*/
-
-
+
+
/**
* Re-orders a slide, to a new position.
* @param oldSlideNumber The old slide number (1 based)
@@ -612,7 +612,7 @@
* Addition Code
* ===============================================================
*/
-
+
/**
* Create a blank <code>Slide</code>.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org