* For each macro module that is found, the module's name and code are
* added to <tt>modules<tt>.
*
- * @param dir
- * @param modules
- * @throws IOException
+ * @param dir The directory of entries to look at
+ * @param modules The resulting map of modules
+ * @throws IOException If reading the VBA module fails
* @since 3.15-beta2
*/
protected void findMacros(DirectoryNode dir, ModuleMap modules) throws IOException {
* @param length number of bytes to read from stream
* @param charset the character set encoding of the bytes in the stream
* @return a java String in the supplied character set
- * @throws IOException
+ * @throws IOException If reading from the stream fails
*/
private static String readString(InputStream stream, int length, Charset charset) throws IOException {
byte[] buffer = new byte[length];
* @param in the run-length encoded input stream to read from
* @param streamName the stream name of the module
* @param modules a map to store the modules
- * @throws IOException
+ * @throws IOException If reading data from the stream or from modules fails
*/
private static void readModule(RLEDecompressingInputStream in, String streamName, ModuleMap modules) throws IOException {
int moduleOffset = in.readInt();
/**
* Skips <tt>n</tt> bytes in an input stream, throwing IOException if the
* number of bytes skipped is different than requested.
- * @throws IOException
+ * @throws IOException If skipping would exceed the available data or skipping did not work.
*/
private static void trySkip(InputStream in, long n) throws IOException {
long skippedBytes = in.skip(n);
// Constants from MS-OVBA: https://msdn.microsoft.com/en-us/library/office/cc313094(v=office.12).aspx
private static final int EOF = -1;
private static final int VERSION_INDEPENDENT_TERMINATOR = 0x0010;
+ @SuppressWarnings("unused")
private static final int VERSION_DEPENDENT_TERMINATOR = 0x002B;
private static final int PROJECTVERSION = 0x0009;
private static final int PROJECTCODEPAGE = 0x0003;
private static final int STREAMNAME = 0x001A;
private static final int MODULEOFFSET = 0x0031;
+ @SuppressWarnings("unused")
private static final int MODULETYPE_PROCEDURAL = 0x0021;
+ @SuppressWarnings("unused")
private static final int MODULETYPE_DOCUMENT_CLASS_OR_DESIGNER = 0x0022;
+ @SuppressWarnings("unused")
private static final int PROJECTLCID = 0x0002;
+ @SuppressWarnings("unused")
private static final int MODULE_NAME = 0x0019;
+ @SuppressWarnings("unused")
private static final int MODULE_NAME_UNICODE = 0x0047;
+ @SuppressWarnings("unused")
private static final int MODULE_DOC_STRING = 0x001c;
private static final int STREAMNAME_RESERVED = 0x0032;
// process DIR
RLEDecompressingInputStream in = new RLEDecompressingInputStream(dis);
String streamName = null;
- String streamNameUnicode = null;
int recordId = 0;
try {
while (true) {
Integer.toHexString(reserved));
}
int unicodeNameRecordLength = in.readInt();
- streamNameUnicode = readUnicodeString(in, unicodeNameRecordLength);
- //do something with this at some point
+ readUnicodeString(in, unicodeNameRecordLength);
+ // do something with this at some point
break;
case MODULEOFFSET:
readModule(in, streamName, modules);
* @author Marc Johnson (mjohnson at apache dot org)
*/
-public interface Child
-{
-
+public interface Child {
/**
* Get the next Child, if any
*
*/
public void setPreviousChild(final Child child);
-} // end public interface Child
-
+}
/**
* Trivial extension of Property for POIFSDocuments
*/
-
-public class DocumentProperty
- extends Property
-{
-
+public class DocumentProperty extends Property {
// the POIFSDocument this property is associated with
private OPOIFSDocument _document;
* @param array byte data
* @param offset offset into byte data
*/
-
protected DocumentProperty(final int index, final byte [] array,
final int offset)
{
*
* @param doc the associated POIFSDocument
*/
-
public void setDocument(OPOIFSDocument doc)
{
_document = doc;
*
* @return the associated document
*/
-
public OPOIFSDocument getDocument()
{
return _document;
*
* @return true if this property should use small blocks
*/
-
public boolean shouldUseSmallBlocks()
{
return super.shouldUseSmallBlocks();
/**
* @return true if a directory type Property
*/
-
public boolean isDirectory()
{
return false;
* Perform whatever activities need to be performed prior to
* writing
*/
-
protected void preWrite()
{
}
/* ********** END extension of Property ********** */
-} // end public class DocumentProperty
-
+}
_bigBigBlockSize = headerBlock.getBigBlockSize();
}
- /**
- * Builds
- * @param startAt
- * @param filesystem
- * @throws IOException
- */
private static List<Property> buildProperties(final Iterator<ByteBuffer> dataSource,
final POIFSBigBlockSize bigBlockSize) throws IOException
{
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
-
package org.apache.poi.poifs.property;
*
* @author Marc Johnson27591@hotmail.com
*/
-
public interface Parent
extends Child
{
*/
public void setNextChild(final Child child);
-
- /** *** end methods from interface Child *** */
-
-} // end public interface Parent
-
+}
-
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
limitations under the License.
==================================================================== */
-
package org.apache.poi.poifs.property;
import java.io.IOException;
*
* @return short description
*/
- public String getShortDescription()
- {
- StringBuffer buffer = new StringBuffer();
-
- buffer.append("Property: \"").append(getName()).append("\"");
- return buffer.toString();
+ public String getShortDescription() {
+ return "Property: \"" + getName() + "\"";
}
}
public static final byte DIRECTORY_TYPE = 1;
public static final byte DOCUMENT_TYPE = 2;
public static final byte ROOT_TYPE = 5;
-} // end public interface PropertyConstants
-
+}
* @author Marc Johnson (mjohnson at apache dot org)
*/
-class PropertyFactory
-{
+class PropertyFactory {
// no need for an accessible constructor
private PropertyFactory()
{
{
List<Property> properties = new ArrayList<Property>();
- for (int j = 0; j < blocks.length; j++) {
- byte[] data = blocks[ j ].getData();
+ for (ListManagedBlock block : blocks) {
+ byte[] data = block.getData();
convertToProperties(data, properties);
}
return properties;
offset += POIFSConstants.PROPERTY_SIZE;
}
}
-
-} // end package scope class PropertyFactory
-
+}
_blocks = PropertyBlock.createPropertyBlockArray(_bigBigBlockSize, _properties);
// prepare each property for writing
- for (int k = 0; k < properties.length; k++)
- {
- properties[ k ].preWrite();
+ for (Property property : properties) {
+ property.preWrite();
}
}
{
if (_blocks != null)
{
- for (int j = 0; j < _blocks.length; j++)
- {
- _blocks[ j ].writeBlocks(stream);
+ for (BlockWritable _block : _blocks) {
+ _block.writeBlocks(stream);
}
}
}