mirror of https://github.com/apache/poi.git
Added Apache License text to files where it was missing. Also fixed some compiler warnings in those files.
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@745976 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b339adbe7d
commit
6f1a7911c9
|
@ -43,7 +43,7 @@ public class EscherContainerRecord extends EscherRecord
|
|||
public static final short SP_CONTAINER = (short)0xF004;
|
||||
public static final short SOLVER_CONTAINER = (short)0xF005;
|
||||
|
||||
private List childRecords = new ArrayList();
|
||||
private final List<EscherRecord> _childRecords = new ArrayList<EscherRecord>();
|
||||
|
||||
public int fillFields( byte[] data, int offset, EscherRecordFactory recordFactory )
|
||||
{
|
||||
|
@ -110,7 +110,7 @@ public class EscherContainerRecord extends EscherRecord
|
|||
{
|
||||
EscherRecord r = (EscherRecord) iterator.next();
|
||||
if(r.getRecordId() == recordId) {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -120,9 +120,8 @@ public class EscherContainerRecord extends EscherRecord
|
|||
* Returns a list of all the child (escher) records
|
||||
* of the container.
|
||||
*/
|
||||
public List getChildRecords()
|
||||
{
|
||||
return childRecords;
|
||||
public List<EscherRecord> getChildRecords() {
|
||||
return _childRecords;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -131,7 +130,7 @@ public class EscherContainerRecord extends EscherRecord
|
|||
* 2 or 3)
|
||||
*/
|
||||
public List getChildContainers() {
|
||||
List containers = new ArrayList();
|
||||
List containers = new ArrayList();
|
||||
for ( Iterator iterator = getChildRecords().iterator(); iterator.hasNext(); )
|
||||
{
|
||||
EscherRecord r = (EscherRecord) iterator.next();
|
||||
|
@ -142,15 +141,13 @@ public class EscherContainerRecord extends EscherRecord
|
|||
return containers;
|
||||
}
|
||||
|
||||
public void setChildRecords( List childRecords )
|
||||
{
|
||||
this.childRecords = childRecords;
|
||||
public void setChildRecords(List<EscherRecord> childRecords) {
|
||||
_childRecords.clear();
|
||||
_childRecords.addAll(childRecords);
|
||||
}
|
||||
|
||||
public String getRecordName()
|
||||
{
|
||||
switch ((short)getRecordId())
|
||||
{
|
||||
public String getRecordName() {
|
||||
switch (getRecordId()) {
|
||||
case DGG_CONTAINER:
|
||||
return "DggContainer";
|
||||
case BSTORE_CONTAINER:
|
||||
|
@ -171,16 +168,15 @@ public class EscherContainerRecord extends EscherRecord
|
|||
public void display( PrintWriter w, int indent )
|
||||
{
|
||||
super.display( w, indent );
|
||||
for ( Iterator iterator = childRecords.iterator(); iterator.hasNext(); )
|
||||
for (Iterator iterator = _childRecords.iterator(); iterator.hasNext();)
|
||||
{
|
||||
EscherRecord escherRecord = (EscherRecord) iterator.next();
|
||||
escherRecord.display( w, indent + 1 );
|
||||
}
|
||||
}
|
||||
|
||||
public void addChildRecord( EscherRecord record )
|
||||
{
|
||||
this.childRecords.add( record );
|
||||
public void addChildRecord(EscherRecord record) {
|
||||
_childRecords.add( record );
|
||||
}
|
||||
|
||||
public String toString()
|
||||
|
@ -226,7 +222,7 @@ public class EscherContainerRecord extends EscherRecord
|
|||
|
||||
public EscherSpRecord getChildById( short recordId )
|
||||
{
|
||||
for ( Iterator iterator = childRecords.iterator(); iterator.hasNext(); )
|
||||
for ( Iterator iterator = _childRecords.iterator(); iterator.hasNext(); )
|
||||
{
|
||||
EscherRecord escherRecord = (EscherRecord) iterator.next();
|
||||
if (escherRecord.getRecordId() == recordId)
|
||||
|
@ -241,7 +237,7 @@ public class EscherContainerRecord extends EscherRecord
|
|||
* @param out - list to store found records
|
||||
*/
|
||||
public void getRecordsById(short recordId, List out){
|
||||
for(Iterator it = childRecords.iterator(); it.hasNext();) {
|
||||
for(Iterator it = _childRecords.iterator(); it.hasNext();) {
|
||||
Object er = it.next();
|
||||
EscherRecord r = (EscherRecord)er;
|
||||
if(r instanceof EscherContainerRecord) {
|
||||
|
|
|
@ -30,16 +30,15 @@ import java.util.List;
|
|||
*
|
||||
* @author Glen Stampoultzis
|
||||
*/
|
||||
abstract public class EscherRecord
|
||||
{
|
||||
private short options;
|
||||
private short recordId;
|
||||
public abstract class EscherRecord {
|
||||
private short _options;
|
||||
private short _recordId;
|
||||
|
||||
/**
|
||||
* Create a new instance
|
||||
*/
|
||||
public EscherRecord()
|
||||
{
|
||||
public EscherRecord() {
|
||||
// fields uninitialised
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -73,11 +72,10 @@ abstract public class EscherRecord
|
|||
* @return the number of bytes remaining in this record. This
|
||||
* may include the children if this is a container.
|
||||
*/
|
||||
protected int readHeader( byte[] data, int offset )
|
||||
{
|
||||
protected int readHeader( byte[] data, int offset ) {
|
||||
EscherRecordHeader header = EscherRecordHeader.readHeader(data, offset);
|
||||
options = header.getOptions();
|
||||
recordId = header.getRecordId();
|
||||
_options = header.getOptions();
|
||||
_recordId = header.getRecordId();
|
||||
return header.getRemainingBytes();
|
||||
}
|
||||
|
||||
|
@ -86,26 +84,23 @@ abstract public class EscherRecord
|
|||
* field.
|
||||
* @return true is this is a container field.
|
||||
*/
|
||||
public boolean isContainerRecord()
|
||||
{
|
||||
return (options & (short)0x000f) == (short)0x000f;
|
||||
public boolean isContainerRecord() {
|
||||
return (_options & (short)0x000f) == (short)0x000f;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The options field for this record. All records have one.
|
||||
*/
|
||||
public short getOptions()
|
||||
{
|
||||
return options;
|
||||
public short getOptions() {
|
||||
return _options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the options this this record. Container records should have the
|
||||
* last nibble set to 0xF.
|
||||
*/
|
||||
public void setOptions( short options )
|
||||
{
|
||||
this.options = options;
|
||||
public void setOptions( short options ) {
|
||||
_options = options;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -164,17 +159,15 @@ abstract public class EscherRecord
|
|||
*
|
||||
* @return The 16 bit record id.
|
||||
*/
|
||||
public short getRecordId()
|
||||
{
|
||||
return recordId;
|
||||
public short getRecordId() {
|
||||
return _recordId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the record id for this record.
|
||||
*/
|
||||
public void setRecordId( short recordId )
|
||||
{
|
||||
this.recordId = recordId;
|
||||
public void setRecordId( short recordId ) {
|
||||
_recordId = recordId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -184,7 +177,7 @@ abstract public class EscherRecord
|
|||
*
|
||||
* @see EscherContainerRecord
|
||||
*/
|
||||
public List getChildRecords() { return Collections.EMPTY_LIST; }
|
||||
public List<EscherRecord> getChildRecords() { return Collections.emptyList(); }
|
||||
|
||||
/**
|
||||
* Sets the child records for this record. By default this will throw
|
||||
|
@ -192,7 +185,9 @@ abstract public class EscherRecord
|
|||
*
|
||||
* @param childRecords Not used in base implementation.
|
||||
*/
|
||||
public void setChildRecords( List childRecords ) { throw new IllegalArgumentException("This record does not support child records."); }
|
||||
public void setChildRecords(List<EscherRecord> childRecords) {
|
||||
throw new UnsupportedOperationException("This record does not support child records.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Escher records may need to be clonable in the future.
|
||||
|
@ -205,9 +200,8 @@ abstract public class EscherRecord
|
|||
/**
|
||||
* Returns the indexed child record.
|
||||
*/
|
||||
public EscherRecord getChild( int index )
|
||||
{
|
||||
return (EscherRecord) getChildRecords().get(index);
|
||||
public EscherRecord getChild( int index ) {
|
||||
return getChildRecords().get(index);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -233,9 +227,8 @@ abstract public class EscherRecord
|
|||
*
|
||||
* @return The instance part of the record
|
||||
*/
|
||||
public short getInstance()
|
||||
{
|
||||
return (short) ( options >> 4 );
|
||||
public short getInstance() {
|
||||
return (short) ( _options >> 4 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -247,8 +240,8 @@ abstract public class EscherRecord
|
|||
private short recordId;
|
||||
private int remainingBytes;
|
||||
|
||||
private EscherRecordHeader()
|
||||
{
|
||||
private EscherRecordHeader() {
|
||||
// fields uninitialised
|
||||
}
|
||||
|
||||
public static EscherRecordHeader readHeader( byte[] data, int offset )
|
||||
|
@ -284,8 +277,5 @@ abstract public class EscherRecord
|
|||
", remainingBytes=" + remainingBytes +
|
||||
"}";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,27 @@
|
|||
/* ====================================================================
|
||||
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.hssf.record.formula.eval;
|
||||
|
||||
/**
|
||||
* Common base class for implementors of {@link RefEval}
|
||||
*
|
||||
* @author Josh Micich
|
||||
*/
|
||||
public abstract class RefEvalBase implements RefEval {
|
||||
|
||||
private final int _rowIndex;
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/* ====================================================================
|
||||
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.xssf.usermodel;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -9,43 +26,47 @@ import org.apache.poi.xssf.model.XSSFWritableModel;
|
|||
import org.apache.poi.POIXMLException;
|
||||
import org.apache.poi.openxml4j.opc.PackagePart;
|
||||
|
||||
public class XSSFActiveXData implements PictureData, XSSFWritableModel {
|
||||
/**
|
||||
*
|
||||
* @author Nick Burch
|
||||
*/
|
||||
public final class XSSFActiveXData implements PictureData, XSSFWritableModel {
|
||||
|
||||
private PackagePart packagePart;
|
||||
private String originalId;
|
||||
private final PackagePart _packagePart;
|
||||
private final String _originalId;
|
||||
|
||||
public XSSFActiveXData(PackagePart packagePart, String originalId) {
|
||||
this(packagePart);
|
||||
this.originalId = originalId;
|
||||
}
|
||||
|
||||
public XSSFActiveXData(PackagePart packagePart) {
|
||||
this.packagePart = packagePart;
|
||||
}
|
||||
|
||||
public String getOriginalId() {
|
||||
return originalId;
|
||||
}
|
||||
|
||||
public PackagePart getPart() {
|
||||
return packagePart;
|
||||
}
|
||||
|
||||
public void writeTo(OutputStream out) throws IOException {
|
||||
IOUtils.copy(packagePart.getInputStream(), out);
|
||||
public XSSFActiveXData(PackagePart packagePart, String originalId) {
|
||||
_packagePart = packagePart;
|
||||
_originalId = originalId;
|
||||
}
|
||||
|
||||
public byte[] getData() {
|
||||
// TODO - is this right?
|
||||
// Are there headers etc?
|
||||
try {
|
||||
return IOUtils.toByteArray(packagePart.getInputStream());
|
||||
} catch(IOException e) {
|
||||
throw new POIXMLException(e);
|
||||
}
|
||||
}
|
||||
public XSSFActiveXData(PackagePart packagePart) {
|
||||
this(packagePart, null);
|
||||
}
|
||||
|
||||
public String suggestFileExtension() {
|
||||
return packagePart.getPartName().getExtension();
|
||||
}
|
||||
public String getOriginalId() {
|
||||
return _originalId;
|
||||
}
|
||||
|
||||
public PackagePart getPart() {
|
||||
return _packagePart;
|
||||
}
|
||||
|
||||
public void writeTo(OutputStream out) throws IOException {
|
||||
IOUtils.copy(_packagePart.getInputStream(), out);
|
||||
}
|
||||
|
||||
public byte[] getData() {
|
||||
// TODO - is this right?
|
||||
// Are there headers etc?
|
||||
try {
|
||||
return IOUtils.toByteArray(_packagePart.getInputStream());
|
||||
} catch(IOException e) {
|
||||
throw new POIXMLException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public String suggestFileExtension() {
|
||||
return _packagePart.getPartName().getExtension();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/* ====================================================================
|
||||
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.xssf.usermodel;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
@ -105,7 +122,7 @@ public final class TestXSSFFont extends TestCase{
|
|||
assertEquals(11,xssfFont.getFontHeight());
|
||||
|
||||
xssfFont.setFontHeight((short)20);
|
||||
assertEquals(new Double(20).doubleValue(),ctFont.getSzArray(0).getVal());
|
||||
assertEquals(20.0, ctFont.getSzArray(0).getVal(), 0.0);
|
||||
}
|
||||
|
||||
public void testFontHeightInPoint() {
|
||||
|
@ -118,7 +135,7 @@ public final class TestXSSFFont extends TestCase{
|
|||
assertEquals(14,xssfFont.getFontHeightInPoints());
|
||||
|
||||
xssfFont.setFontHeightInPoints((short)20);
|
||||
assertEquals(new Double(20).doubleValue(),ctFont.getSzArray(0).getVal());
|
||||
assertEquals(20.0, ctFont.getSzArray(0).getVal(), 0.0);
|
||||
}
|
||||
|
||||
public void testUnderline() {
|
||||
|
@ -353,8 +370,8 @@ public final class TestXSSFFont extends TestCase{
|
|||
XSSFSheet s = wb.createSheet();
|
||||
s.createRow(0);
|
||||
s.createRow(1);
|
||||
XSSFCell c1 = s.getRow(0).createCell(0);
|
||||
XSSFCell c2 = s.getRow(1).createCell(0);
|
||||
s.getRow(0).createCell(0);
|
||||
s.getRow(1).createCell(0);
|
||||
|
||||
assertEquals(1, wb.getNumberOfFonts());
|
||||
|
||||
|
@ -364,10 +381,7 @@ public final class TestXSSFFont extends TestCase{
|
|||
// Check that asking for the same font
|
||||
// multiple times gives you the same thing.
|
||||
// Otherwise, our tests wouldn't work!
|
||||
assertEquals(
|
||||
wb.getFontAt((short)0),
|
||||
wb.getFontAt((short)0)
|
||||
);
|
||||
assertEquals(wb.getFontAt((short)0), wb.getFontAt((short)0));
|
||||
|
||||
// Look for a new font we have
|
||||
// yet to add
|
||||
|
@ -396,15 +410,8 @@ public final class TestXSSFFont extends TestCase{
|
|||
assertEquals(2, wb.getNumberOfFonts());
|
||||
assertEquals(nf, wb.getFontAt((short)1));
|
||||
|
||||
assertEquals(
|
||||
wb.getFontAt((short)1),
|
||||
wb.getFontAt((short)1)
|
||||
);
|
||||
assertTrue(
|
||||
wb.getFontAt((short)0)
|
||||
!=
|
||||
wb.getFontAt((short)1)
|
||||
);
|
||||
assertEquals(wb.getFontAt((short)1), wb.getFontAt((short)1));
|
||||
assertTrue(wb.getFontAt((short)0) != wb.getFontAt((short)1));
|
||||
|
||||
// Find it now
|
||||
assertNotNull(
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/* ====================================================================
|
||||
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.model;
|
||||
|
||||
import org.apache.poi.ddf.*;
|
||||
|
@ -15,7 +32,7 @@ import java.util.Iterator;
|
|||
* TODO: finish
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public class ActiveXShape extends Picture {
|
||||
public final class ActiveXShape extends Picture {
|
||||
public static final int DEFAULT_ACTIVEX_THUMBNAIL = -1;
|
||||
|
||||
/**
|
||||
|
@ -83,8 +100,8 @@ public class ActiveXShape extends Picture {
|
|||
*/
|
||||
public void setActiveXIndex(int idx){
|
||||
EscherContainerRecord spContainer = getSpContainer();
|
||||
for (Iterator it = spContainer.getChildRecords().iterator(); it.hasNext();) {
|
||||
EscherRecord obj = (EscherRecord) it.next();
|
||||
for (Iterator<EscherRecord> it = spContainer.getChildRecords().iterator(); it.hasNext();) {
|
||||
EscherRecord obj = it.next();
|
||||
if (obj.getRecordId() == EscherClientDataRecord.RECORD_ID) {
|
||||
EscherClientDataRecord clientRecord = (EscherClientDataRecord)obj;
|
||||
byte[] recdata = clientRecord.getRemainingData();
|
||||
|
|
|
@ -1,54 +1,75 @@
|
|||
/* ====================================================================
|
||||
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.model;
|
||||
|
||||
import org.apache.poi.hslf.record.Comment2000;
|
||||
|
||||
public class Comment {
|
||||
private Comment2000 comment2000;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Nick Burch
|
||||
*/
|
||||
public final class Comment {
|
||||
private Comment2000 _comment2000;
|
||||
|
||||
public Comment(Comment2000 comment2000) {
|
||||
this.comment2000 = comment2000;
|
||||
_comment2000 = comment2000;
|
||||
}
|
||||
|
||||
|
||||
protected Comment2000 getComment2000() {
|
||||
return comment2000;
|
||||
return _comment2000;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the Author of this comment
|
||||
*/
|
||||
public String getAuthor() {
|
||||
return comment2000.getAuthor();
|
||||
return _comment2000.getAuthor();
|
||||
}
|
||||
/**
|
||||
* Set the Author of this comment
|
||||
*/
|
||||
public void setAuthor(String author) {
|
||||
comment2000.setAuthor(author);
|
||||
_comment2000.setAuthor(author);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Author's Initials of this comment
|
||||
*/
|
||||
public String getAuthorInitials() {
|
||||
return comment2000.getAuthorInitials();
|
||||
return _comment2000.getAuthorInitials();
|
||||
}
|
||||
/**
|
||||
* Set the Author's Initials of this comment
|
||||
*/
|
||||
public void setAuthorInitials(String initials) {
|
||||
comment2000.setAuthorInitials(initials);
|
||||
_comment2000.setAuthorInitials(initials);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the text of this comment
|
||||
*/
|
||||
public String getText() {
|
||||
return comment2000.getText();
|
||||
return _comment2000.getText();
|
||||
}
|
||||
/**
|
||||
* Set the text of this comment
|
||||
*/
|
||||
public void setText(String text) {
|
||||
comment2000.setText(text);
|
||||
_comment2000.setText(text);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,37 @@
|
|||
/* ====================================================================
|
||||
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.model;
|
||||
|
||||
import org.apache.poi.ddf.*;
|
||||
import org.apache.poi.hslf.record.*;
|
||||
import org.apache.poi.hslf.exceptions.HSLFException;
|
||||
import org.apache.poi.hslf.usermodel.SlideShow;
|
||||
import org.apache.poi.util.LittleEndian;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.poi.ddf.EscherClientDataRecord;
|
||||
import org.apache.poi.ddf.EscherContainerRecord;
|
||||
import org.apache.poi.ddf.EscherProperties;
|
||||
import org.apache.poi.hslf.exceptions.HSLFException;
|
||||
import org.apache.poi.hslf.record.*;
|
||||
import org.apache.poi.hslf.usermodel.SlideShow;
|
||||
|
||||
/**
|
||||
* Represents a movie in a PowerPoint document.
|
||||
*
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public class MovieShape extends Picture {
|
||||
public final class MovieShape extends Picture {
|
||||
public static final int DEFAULT_MOVIE_THUMBNAIL = -1;
|
||||
|
||||
public static final int MOVIE_MPEG = 1;
|
||||
|
|
|
@ -1,7 +1,19 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
/* ====================================================================
|
||||
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.hwpf.model;
|
||||
|
||||
|
@ -14,103 +26,97 @@ import org.apache.poi.ddf.EscherRecord;
|
|||
import org.apache.poi.ddf.EscherRecordFactory;
|
||||
|
||||
/**
|
||||
* Based on AbstractEscherRecordHolder fomr HSSF.
|
||||
* Based on AbstractEscherRecordHolder from HSSF.
|
||||
*
|
||||
* @author Squeeself
|
||||
*/
|
||||
public class EscherRecordHolder
|
||||
{
|
||||
protected ArrayList escherRecords = new ArrayList();
|
||||
|
||||
public EscherRecordHolder()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public EscherRecordHolder(byte[] data, int offset, int size)
|
||||
{
|
||||
fillEscherRecords(data, offset, size);
|
||||
}
|
||||
|
||||
private void fillEscherRecords(byte[] data, int offset, int size)
|
||||
{
|
||||
EscherRecordFactory recordFactory = new DefaultEscherRecordFactory();
|
||||
int pos = offset;
|
||||
while ( pos < offset + size)
|
||||
{
|
||||
EscherRecord r = recordFactory.createRecord(data, pos);
|
||||
escherRecords.add(r);
|
||||
int bytesRead = r.fillFields(data, pos, recordFactory);
|
||||
pos += bytesRead + 1; // There is an empty byte between each top-level record in a Word doc
|
||||
}
|
||||
}
|
||||
|
||||
public List getEscherRecords()
|
||||
{
|
||||
return escherRecords;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
public final class EscherRecordHolder {
|
||||
private final ArrayList<EscherRecord> escherRecords;
|
||||
|
||||
public EscherRecordHolder() {
|
||||
escherRecords = new ArrayList<EscherRecord>();
|
||||
}
|
||||
|
||||
public EscherRecordHolder(byte[] data, int offset, int size) {
|
||||
this();
|
||||
fillEscherRecords(data, offset, size);
|
||||
}
|
||||
|
||||
private void fillEscherRecords(byte[] data, int offset, int size)
|
||||
{
|
||||
EscherRecordFactory recordFactory = new DefaultEscherRecordFactory();
|
||||
int pos = offset;
|
||||
while ( pos < offset + size)
|
||||
{
|
||||
EscherRecord r = recordFactory.createRecord(data, pos);
|
||||
escherRecords.add(r);
|
||||
int bytesRead = r.fillFields(data, pos, recordFactory);
|
||||
pos += bytesRead + 1; // There is an empty byte between each top-level record in a Word doc
|
||||
}
|
||||
}
|
||||
|
||||
public List<EscherRecord> getEscherRecords() {
|
||||
return escherRecords;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
||||
final String nl = System.getProperty("line.separator");
|
||||
if (escherRecords.size() == 0)
|
||||
buffer.append("No Escher Records Decoded" + nl);
|
||||
for ( Iterator iterator = escherRecords.iterator(); iterator.hasNext(); )
|
||||
{
|
||||
EscherRecord r = (EscherRecord) iterator.next();
|
||||
buffer.append(r.toString());
|
||||
}
|
||||
if (escherRecords.size() == 0) {
|
||||
buffer.append("No Escher Records Decoded").append("\n");
|
||||
}
|
||||
Iterator<EscherRecord> iterator = escherRecords.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
EscherRecord r = iterator.next();
|
||||
buffer.append(r.toString());
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* If we have a EscherContainerRecord as one of our
|
||||
* children (and most top level escher holders do),
|
||||
* then return that.
|
||||
*/
|
||||
public EscherContainerRecord getEscherContainer() {
|
||||
for(Iterator<EscherRecord> it = escherRecords.iterator(); it.hasNext();) {
|
||||
Object er = it.next();
|
||||
if(er instanceof EscherContainerRecord) {
|
||||
return (EscherContainerRecord)er;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* If we have a EscherContainerRecord as one of our
|
||||
* children (and most top level escher holders do),
|
||||
* then return that.
|
||||
*/
|
||||
public EscherContainerRecord getEscherContainer() {
|
||||
for(Iterator it = escherRecords.iterator(); it.hasNext();) {
|
||||
Object er = it.next();
|
||||
if(er instanceof EscherContainerRecord) {
|
||||
return (EscherContainerRecord)er;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Descends into all our children, returning the
|
||||
* first EscherRecord with the given id, or null
|
||||
* if none found
|
||||
*/
|
||||
public EscherRecord findFirstWithId(short id) {
|
||||
return findFirstWithId(id, getEscherRecords());
|
||||
}
|
||||
private EscherRecord findFirstWithId(short id, List records) {
|
||||
// Check at our level
|
||||
for(Iterator it = records.iterator(); it.hasNext();) {
|
||||
EscherRecord r = (EscherRecord)it.next();
|
||||
if(r.getRecordId() == id) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
// Then check our children in turn
|
||||
for(Iterator it = records.iterator(); it.hasNext();) {
|
||||
EscherRecord r = (EscherRecord)it.next();
|
||||
if(r.isContainerRecord()) {
|
||||
EscherRecord found =
|
||||
findFirstWithId(id, r.getChildRecords());
|
||||
if(found != null) {
|
||||
return found;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Not found in this lot
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Descends into all our children, returning the
|
||||
* first EscherRecord with the given id, or null
|
||||
* if none found
|
||||
*/
|
||||
public EscherRecord findFirstWithId(short id) {
|
||||
return findFirstWithId(id, getEscherRecords());
|
||||
}
|
||||
private static EscherRecord findFirstWithId(short id, List<EscherRecord> records) {
|
||||
// Check at our level
|
||||
for(Iterator<EscherRecord> it = records.iterator(); it.hasNext();) {
|
||||
EscherRecord r = it.next();
|
||||
if(r.getRecordId() == id) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
// Then check our children in turn
|
||||
for(Iterator<EscherRecord> it = records.iterator(); it.hasNext();) {
|
||||
EscherRecord r = it.next();
|
||||
if(r.isContainerRecord()) {
|
||||
EscherRecord found = findFirstWithId(id, r.getChildRecords());
|
||||
if(found != null) {
|
||||
return found;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Not found in this lot
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/* ====================================================================
|
||||
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.hssf.usermodel;
|
||||
|
||||
import junit.framework.AssertionFailedError;
|
||||
|
@ -5,7 +22,7 @@ import junit.framework.TestCase;
|
|||
|
||||
import org.apache.poi.hssf.HSSFTestDataSamples;
|
||||
/**
|
||||
* Tests for LinkTable
|
||||
* Tests for {@link LinkTable}
|
||||
*
|
||||
* @author Josh Micich
|
||||
*/
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/* ====================================================================
|
||||
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.poifs.property;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
@ -11,7 +28,7 @@ import junit.framework.TestSuite;
|
|||
public final class AllPOIFSPropertyTests {
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite result = new TestSuite("Tests for org.apache.poi.poifs.property");
|
||||
TestSuite result = new TestSuite(AllPOIFSPropertyTests.class.getName());
|
||||
result.addTestSuite(TestDirectoryProperty.class);
|
||||
result.addTestSuite(TestDocumentProperty.class);
|
||||
result.addTestSuite(TestPropertyFactory.class);
|
||||
|
|
Loading…
Reference in New Issue