#64004 - Replace clone() with copy constructor - mainly HWPF classes

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1871938 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2019-12-24 11:56:42 +00:00
parent 93a7b81ed9
commit 03fe2ded64
54 changed files with 1632 additions and 1194 deletions

View File

@ -18,33 +18,34 @@ package org.apache.poi.hwpf.model;
import java.util.Objects; import java.util.Objects;
import org.apache.poi.common.Duplicatable;
import org.apache.poi.hwpf.model.types.BKFAbstractType; import org.apache.poi.hwpf.model.types.BKFAbstractType;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.Removal;
@Internal @Internal
public final class BookmarkFirstDescriptor extends BKFAbstractType implements public final class BookmarkFirstDescriptor extends BKFAbstractType implements Duplicatable {
Cloneable public BookmarkFirstDescriptor() { }
{
public BookmarkFirstDescriptor() public BookmarkFirstDescriptor(BookmarkFirstDescriptor other) {
{ super(other);
} }
public BookmarkFirstDescriptor( byte[] data, int offset ) public BookmarkFirstDescriptor( byte[] data, int offset ) {
{
fillFields( data, offset ); fillFields( data, offset );
} }
@Override @Override
protected BookmarkFirstDescriptor clone() @SuppressWarnings("squid:S2975")
{ @Deprecated
try @Removal(version = "5.0.0")
{ protected BookmarkFirstDescriptor clone() {
return (BookmarkFirstDescriptor) super.clone(); return copy();
}
catch ( CloneNotSupportedException e )
{
throw new RuntimeException( e );
} }
@Override
public BookmarkFirstDescriptor copy() {
return new BookmarkFirstDescriptor(this);
} }
@Override @Override

View File

@ -27,14 +27,18 @@ package org.apache.poi.hwpf.model;
* @deprecated byte positions shall not be saved in memory * @deprecated byte positions shall not be saved in memory
*/ */
@Deprecated @Deprecated
public abstract class BytePropertyNode<T extends BytePropertyNode<T>> extends public abstract class BytePropertyNode<T extends BytePropertyNode<T>> extends PropertyNode<T> {
PropertyNode<T>
{
private final int startBytes; private final int startBytes;
private final int endBytes; private final int endBytes;
public BytePropertyNode( int charStart, int charEnd, Object buf ) protected BytePropertyNode( BytePropertyNode other ) {
{ super(other);
startBytes = other.startBytes;
endBytes = other.endBytes;
}
protected BytePropertyNode( int charStart, int charEnd, Object buf ) {
super( charStart, charEnd, buf ); super( charStart, charEnd, buf );
if ( charStart > charEnd ) if ( charStart > charEnd )

View File

@ -172,7 +172,7 @@ public class CHPBinTable
} }
List<CHPX> oldChpxSortedByStartPos = new ArrayList<>(_textRuns); List<CHPX> oldChpxSortedByStartPos = new ArrayList<>(_textRuns);
oldChpxSortedByStartPos.sort(PropertyNode.StartComparator.instance); oldChpxSortedByStartPos.sort(PropertyNode.StartComparator);
logger.log( POILogger.DEBUG, "CHPX sorted by start position in ", logger.log( POILogger.DEBUG, "CHPX sorted by start position in ",
Long.valueOf( System.currentTimeMillis() - start ), " ms" ); Long.valueOf( System.currentTimeMillis() - start ), " ms" );

View File

@ -28,13 +28,15 @@ import org.apache.poi.util.Internal;
* Make sure you call getStart() / getEnd() when you want characters * Make sure you call getStart() / getEnd() when you want characters
* (normal use), but getStartByte() / getEndByte() when you're * (normal use), but getStartByte() / getEndByte() when you're
* reading in / writing out! * reading in / writing out!
*
* @author Ryan Ackley
*/ */
@Internal @Internal
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public final class CHPX extends BytePropertyNode<CHPX> { public final class CHPX extends BytePropertyNode<CHPX> {
public CHPX(CHPX other) {
super(other);
}
CHPX(int charStart, int charEnd, SprmBuffer buf) { CHPX(int charStart, int charEnd, SprmBuffer buf) {
super(charStart, charEnd, buf); super(charStart, charEnd, buf);
} }
@ -62,4 +64,9 @@ public final class CHPX extends BytePropertyNode<CHPX> {
return "CHPX from " + getStart() + " to " + getEnd() + return "CHPX from " + getStart() + " to " + getEnd() +
" (in bytes " + getStartBytes() + " to " + getEndBytes() + ")"; " (in bytes " + getStartBytes() + " to " + getEndBytes() + ")";
} }
@Override
public CHPX copy() {
return new CHPX(this);
}
} }

View File

@ -16,17 +16,17 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hwpf.model; package org.apache.poi.hwpf.model;
import org.apache.poi.common.Duplicatable;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.Removal;
/** /**
* 24-bit color structure * 24-bit color structure
*
* @author Sergey Vladimirov (vlsergey {at} gmail {dot} com)
*/ */
@Internal @Internal
public class Colorref implements Cloneable public class Colorref implements Duplicatable {
{
public static Colorref valueOfIco( int ico ) public static Colorref valueOfIco( int ico )
{ {
@ -71,25 +71,33 @@ public class Colorref implements Cloneable
private int value; private int value;
public Colorref() public Colorref() {
{
this.value = -1; this.value = -1;
} }
public Colorref( byte[] data, int offset ) public Colorref(Colorref other) {
{ value = other.value;
}
public Colorref( byte[] data, int offset ) {
this.value = LittleEndian.getInt( data, offset ); this.value = LittleEndian.getInt( data, offset );
} }
public Colorref( int value ) public Colorref( int value ) {
{
this.value = value; this.value = value;
} }
@Override @Override
public Colorref clone() throws CloneNotSupportedException @SuppressWarnings("squid:S2975")
{ @Deprecated
return (Colorref)super.clone(); @Removal(version = "5.0.0")
public Colorref clone() {
return copy();
}
@Override
public Colorref copy() {
return new Colorref(this);
} }
@Override @Override

View File

@ -18,33 +18,34 @@ package org.apache.poi.hwpf.model;
import java.util.Objects; import java.util.Objects;
import org.apache.poi.common.Duplicatable;
import org.apache.poi.hwpf.model.types.FRDAbstractType; import org.apache.poi.hwpf.model.types.FRDAbstractType;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.Removal;
@Internal @Internal
public final class FootnoteReferenceDescriptor extends FRDAbstractType public final class FootnoteReferenceDescriptor extends FRDAbstractType implements Duplicatable {
implements Cloneable public FootnoteReferenceDescriptor() { }
{
public FootnoteReferenceDescriptor() public FootnoteReferenceDescriptor(FootnoteReferenceDescriptor other) {
{ super(other);
} }
public FootnoteReferenceDescriptor( byte[] data, int offset ) public FootnoteReferenceDescriptor( byte[] data, int offset ) {
{
fillFields( data, offset ); fillFields( data, offset );
} }
@Override @Override
protected FootnoteReferenceDescriptor clone() @SuppressWarnings("squid:S2975")
{ @Deprecated
try @Removal(version = "5.0.0")
{ protected FootnoteReferenceDescriptor clone() {
return (FootnoteReferenceDescriptor) super.clone(); return copy();
}
catch ( CloneNotSupportedException e )
{
throw new RuntimeException( e );
} }
@Override
public FootnoteReferenceDescriptor copy() {
return new FootnoteReferenceDescriptor(this);
} }
@Override @Override

View File

@ -20,11 +20,13 @@ package org.apache.poi.hwpf.model;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
@Internal @Internal
public final class GenericPropertyNode public final class GenericPropertyNode extends PropertyNode<GenericPropertyNode> {
extends PropertyNode<GenericPropertyNode>
{ public GenericPropertyNode(GenericPropertyNode other) {
public GenericPropertyNode(int start, int end, byte[] buf) super(other);
{ }
public GenericPropertyNode(int start, int end, byte[] buf) {
super(start, end, buf); super(start, end, buf);
} }
@ -44,4 +46,9 @@ public final class GenericPropertyNode
+ ( getBytes() != null ? getBytes().length + " byte(s)" + ( getBytes() != null ? getBytes().length + " byte(s)"
: "null" ); : "null" );
} }
@Override
public GenericPropertyNode copy() {
return new GenericPropertyNode(this);
}
} }

View File

@ -19,41 +19,41 @@ package org.apache.poi.hwpf.model;
import java.util.Objects; import java.util.Objects;
import org.apache.poi.common.Duplicatable;
import org.apache.poi.hwpf.model.types.HRESIAbstractType; import org.apache.poi.hwpf.model.types.HRESIAbstractType;
import org.apache.poi.hwpf.usermodel.CharacterProperties; import org.apache.poi.hwpf.usermodel.CharacterProperties;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.Removal;
/** /**
* Hyphenation. Substructure of the {@link CharacterProperties}. * Hyphenation. Substructure of the {@link CharacterProperties}.
*
* @author Sergey Vladimirov ( vlsergey {at} gmail {dot} com )
*/ */
@Internal @Internal
public final class Hyphenation extends HRESIAbstractType implements Cloneable public final class Hyphenation extends HRESIAbstractType implements Duplicatable {
{ public Hyphenation() {}
public Hyphenation()
{ public Hyphenation(Hyphenation other) {
super(); super(other);
} }
public Hyphenation( short hres ) public Hyphenation( short hres ) {
{
byte[] data = new byte[2]; byte[] data = new byte[2];
LittleEndian.putShort( data, 0, hres ); LittleEndian.putShort( data, 0, hres );
fillFields( data, 0 ); fillFields( data, 0 );
} }
public Hyphenation clone() @Override
{ @SuppressWarnings("squid:S2975")
try @Deprecated
{ @Removal(version = "5.0.0")
return (Hyphenation) super.clone(); public Hyphenation clone() {
} return copy();
catch ( CloneNotSupportedException e )
{
throw new RuntimeException( e );
} }
@Override
public Hyphenation copy() {
return new Hyphenation(this);
} }
@Override @Override

View File

@ -63,6 +63,6 @@ public final class OldCHPBinTable extends CHPBinTable
_textRuns.add( chpx ); _textRuns.add( chpx );
} }
} }
_textRuns.sort(PropertyNode.StartComparator.instance); _textRuns.sort(PropertyNode.StartComparator);
} }
} }

View File

@ -79,6 +79,6 @@ public final class OldSectionTable extends SectionTable
_sections.add( sepx ); _sections.add( sepx );
} }
_sections.sort(PropertyNode.StartComparator.instance); _sections.sort(PropertyNode.StartComparator);
} }
} }

View File

@ -34,6 +34,12 @@ public class OldTextPiece extends TextPiece {
private final byte[] rawBytes; private final byte[] rawBytes;
public OldTextPiece(OldTextPiece other) {
super(other);
rawBytes = (other.rawBytes == null) ? null : other.rawBytes.clone();
}
/** /**
* @param start Beginning offset in main document stream, in characters. * @param start Beginning offset in main document stream, in characters.
* @param end Ending offset in main document stream, in characters. * @param end Ending offset in main document stream, in characters.
@ -115,4 +121,8 @@ public class OldTextPiece extends TextPiece {
+ getPieceDescriptor() + ")"; + getPieceDescriptor() + ")";
} }
@Override
public OldTextPiece copy() {
return new OldTextPiece(this);
}
} }

View File

@ -39,8 +39,6 @@ import org.apache.poi.util.POILogger;
* This class represents the bin table of Word document but it also serves as a * This class represents the bin table of Word document but it also serves as a
* holder for all of the paragraphs of document that have been loaded into * holder for all of the paragraphs of document that have been loaded into
* memory. * memory.
*
* @author Ryan Ackley
*/ */
@Internal @Internal
public class PAPBinTable public class PAPBinTable
@ -158,7 +156,7 @@ public class PAPBinTable
} }
List<PAPX> oldPapxSortedByEndPos = new ArrayList<>(paragraphs); List<PAPX> oldPapxSortedByEndPos = new ArrayList<>(paragraphs);
oldPapxSortedByEndPos.sort(PropertyNode.EndComparator.instance); oldPapxSortedByEndPos.sort(PropertyNode.EndComparator);
logger.log( POILogger.DEBUG, "PAPX sorted by end position in ", logger.log( POILogger.DEBUG, "PAPX sorted by end position in ",
Long.valueOf( System.currentTimeMillis() - start ), " ms" ); Long.valueOf( System.currentTimeMillis() - start ), " ms" );
@ -262,7 +260,7 @@ public class PAPBinTable
continue; continue;
if ( sprmBuffer == null ) { if ( sprmBuffer == null ) {
sprmBuffer = papx.getSprmBuf().clone(); sprmBuffer = papx.getSprmBuf().copy();
} else { } else {
sprmBuffer.append( papx.getGrpprl(), 2 ); sprmBuffer.append( papx.getGrpprl(), 2 );
} }
@ -299,7 +297,7 @@ public class PAPBinTable
PAPX currentPap = _paragraphs.get(listIndex); PAPX currentPap = _paragraphs.get(listIndex);
if (currentPap != null && currentPap.getStart() < cpStart) if (currentPap != null && currentPap.getStart() < cpStart)
{ {
SprmBuffer clonedBuf = currentPap.getSprmBuf().clone(); SprmBuffer clonedBuf = currentPap.getSprmBuf().copy();
// Copy the properties of the one before to afterwards // Copy the properties of the one before to afterwards
// Will go: // Will go:

View File

@ -31,8 +31,6 @@ import org.apache.poi.util.LittleEndian;
* Make sure you call getStart() / getEnd() when you want characters * Make sure you call getStart() / getEnd() when you want characters
* (normal use), but getStartByte() / getEndByte() when you're * (normal use), but getStartByte() / getEndByte() when you're
* reading in / writing out! * reading in / writing out!
*
* @author Ryan Ackley
*/ */
@Internal @Internal
@SuppressWarnings( "deprecation" ) @SuppressWarnings( "deprecation" )
@ -40,6 +38,11 @@ public final class PAPX extends BytePropertyNode<PAPX> {
private ParagraphHeight _phe; private ParagraphHeight _phe;
public PAPX(PAPX other) {
super(other);
_phe = (other._phe == null) ? null : other._phe.copy();
}
public PAPX( int charStart, int charEnd, byte[] papx, ParagraphHeight phe, public PAPX( int charStart, int charEnd, byte[] papx, ParagraphHeight phe,
byte[] dataStream ) byte[] dataStream )
{ {
@ -156,4 +159,9 @@ public final class PAPX extends BytePropertyNode<PAPX> {
return "PAPX from " + getStart() + " to " + getEnd() + " (in bytes " return "PAPX from " + getStart() + " to " + getEnd() + " (in bytes "
+ getStartBytes() + " to " + getEndBytes() + ")"; + getStartBytes() + " to " + getEndBytes() + ")";
} }
@Override
public PAPX copy() {
return new PAPX(this);
}
} }

View File

@ -20,25 +20,35 @@ package org.apache.poi.hwpf.model;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import org.apache.poi.common.Duplicatable;
import org.apache.poi.util.BitField; import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory; import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
@Internal @Internal
public final class ParagraphHeight public final class ParagraphHeight implements Duplicatable {
{ private static final BitField fSpare = BitFieldFactory.getInstance(0x0001);
private static final BitField fUnk = BitFieldFactory.getInstance(0x0002);
private static final BitField fDiffLines = BitFieldFactory.getInstance(0x0004);
private static final BitField clMac = BitFieldFactory.getInstance(0xff00);
private short infoField; private short infoField;
private BitField fSpare = BitFieldFactory.getInstance(0x0001);
private BitField fUnk = BitFieldFactory.getInstance(0x0002);
private BitField fDiffLines = BitFieldFactory.getInstance(0x0004);
private BitField clMac = BitFieldFactory.getInstance(0xff00);
private short reserved; private short reserved;
private int dxaCol; private int dxaCol;
private int dymLineOrHeight; private int dymLineOrHeight;
public ParagraphHeight(byte[] buf, int offset) public ParagraphHeight() {}
{
public ParagraphHeight(ParagraphHeight other) {
infoField = other.infoField;
reserved = other.reserved;
dxaCol = other.dxaCol;
dymLineOrHeight = other.dymLineOrHeight;
}
public ParagraphHeight(byte[] buf, int offset) {
infoField = LittleEndian.getShort(buf, offset); infoField = LittleEndian.getShort(buf, offset);
offset += LittleEndian.SHORT_SIZE; offset += LittleEndian.SHORT_SIZE;
reserved = LittleEndian.getShort(buf, offset); reserved = LittleEndian.getShort(buf, offset);
@ -48,11 +58,6 @@ public final class ParagraphHeight
dymLineOrHeight = LittleEndian.getInt(buf, offset); dymLineOrHeight = LittleEndian.getInt(buf, offset);
} }
public ParagraphHeight()
{
}
public void write(OutputStream out) public void write(OutputStream out)
throws IOException throws IOException
{ {
@ -89,4 +94,8 @@ public final class ParagraphHeight
return 42; // any arbitrary constant will do return 42; // any arbitrary constant will do
} }
@Override
public ParagraphHeight copy() {
return new ParagraphHeight(this);
}
} }

View File

@ -20,18 +20,27 @@ package org.apache.poi.hwpf.model;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.util.Objects; import java.util.Objects;
import org.apache.poi.common.Duplicatable;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.StringUtil; import org.apache.poi.util.StringUtil;
@Internal @Internal
public final class PieceDescriptor { public final class PieceDescriptor implements Duplicatable {
private final short descriptor; private final short descriptor;
int fc; // used from the outside?!? int fc; // used from the outside?!?
private final PropertyModifier prm; private final PropertyModifier prm;
private final boolean unicode; private final boolean unicode;
private final Charset charset; private final Charset charset;
public PieceDescriptor(PieceDescriptor other) {
descriptor = other.descriptor;
fc = other.fc;
prm = (other.prm == null) ? null : other.prm.copy();
unicode = other.unicode;
charset = other.charset;
}
public PieceDescriptor(byte[] buf, int offset) { public PieceDescriptor(byte[] buf, int offset) {
this(buf, offset, null); this(buf, offset, null);
} }
@ -155,4 +164,9 @@ public final class PieceDescriptor {
+ (isUnicode() ? "unicode" : "non-unicode") + "; prm: " + (isUnicode() ? "unicode" : "non-unicode") + "; prm: "
+ getPrm() + ")"; + getPrm() + ")";
} }
@Override
public PieceDescriptor copy() {
return new PieceDescriptor(this);
}
} }

View File

@ -18,43 +18,54 @@ package org.apache.poi.hwpf.model;
import java.util.Objects; import java.util.Objects;
import org.apache.poi.common.Duplicatable;
import org.apache.poi.util.BitField; import org.apache.poi.util.BitField;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.Removal;
@Internal @Internal
public final class PropertyModifier implements Cloneable public final class PropertyModifier implements Duplicatable {
{
/** /**
* <li>"Set to 0 for variant 1" <li>"Set to 1 for variant 2" * <li>"Set to 0 for variant 1" <li>"Set to 1 for variant 2"
*/ */
private static BitField _fComplex = new BitField( 0x0001 ); private static final BitField _fComplex = new BitField( 0x0001 );
/** /**
* "Index to a grpprl stored in CLX portion of file" * "Index to a grpprl stored in CLX portion of file"
*/ */
private static BitField _figrpprl = new BitField( 0xfffe ); private static final BitField _figrpprl = new BitField( 0xfffe );
/** /**
* "Index to entry into rgsprmPrm" * "Index to entry into rgsprmPrm"
*/ */
private static BitField _fisprm = new BitField( 0x00fe ); private static final BitField _fisprm = new BitField( 0x00fe );
/** /**
* "sprm's operand" * "sprm's operand"
*/ */
private static BitField _fval = new BitField( 0xff00 ); private static final BitField _fval = new BitField( 0xff00 );
private short value; private short value;
public PropertyModifier( short value ) public PropertyModifier( short value ) {
{
this.value = value; this.value = value;
} }
public PropertyModifier( PropertyModifier other ) {
value = other.value;
}
@Override @Override
protected PropertyModifier clone() throws CloneNotSupportedException @SuppressWarnings("squid:S2975")
{ @Deprecated
return new PropertyModifier( value ); @Removal(version = "5.0.0")
protected PropertyModifier clone() {
return copy();
}
@Override
public PropertyModifier copy() {
return new PropertyModifier(this);
} }
@Override @Override

View File

@ -21,9 +21,11 @@ import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.Objects; import java.util.Objects;
import org.apache.poi.common.Duplicatable;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger; import org.apache.poi.util.POILogger;
import org.apache.poi.util.Removal;
/** /**
* Represents a lightweight node in the Trees used to store content * Represents a lightweight node in the Trees used to store content
@ -31,35 +33,17 @@ import org.apache.poi.util.POILogger;
* This only ever works in characters. For the few odd cases when * This only ever works in characters. For the few odd cases when
* the start and end aren't in characters (eg PAPX and CHPX), use * the start and end aren't in characters (eg PAPX and CHPX), use
* {@link BytePropertyNode} between you and this. * {@link BytePropertyNode} between you and this.
*
* @author Ryan Ackley
*/ */
@Internal @Internal
public abstract class PropertyNode<T extends PropertyNode<T>> implements Comparable<T>, Cloneable { public abstract class PropertyNode<T extends PropertyNode<T>> implements Comparable<T>, Duplicatable {
public static final class EndComparator implements public static final Comparator<PropertyNode<?>> EndComparator = Comparator.comparingInt(PropertyNode::getEnd);
Comparator<PropertyNode<?>> {
public static final EndComparator instance = new EndComparator();
public int compare(PropertyNode<?> o1, PropertyNode<?> o2) { public static final Comparator<PropertyNode<?>> StartComparator = Comparator.comparingInt(PropertyNode::getStart);
int thisVal = o1.getEnd();
int anotherVal = o2.getEnd();
return (Integer.compare(thisVal, anotherVal));
}
}
public static final class StartComparator implements private static final POILogger _logger = POILogFactory.getLogger(PropertyNode.class);
Comparator<PropertyNode<?>> {
public static final StartComparator instance = new StartComparator();
public int compare(PropertyNode<?> o1, PropertyNode<?> o2) {
int thisVal = o1.getStart();
int anotherVal = o2.getStart();
return (Integer.compare(thisVal, anotherVal));
}
}
private final static POILogger _logger = POILogFactory.getLogger(PropertyNode.class);
protected Object _buf; protected Object _buf;
/** /**
* The start, in characters * The start, in characters
@ -70,6 +54,13 @@ public abstract class PropertyNode<T extends PropertyNode<T>> implements Compara
*/ */
private int _cpEnd; private int _cpEnd;
protected PropertyNode(PropertyNode<T> other) {
// TODO: clone _buf?
_buf = other._buf;
_cpStart = other._cpStart;
_cpEnd = other._cpEnd;
}
/** /**
* @param fcStart The start of the text for this property, in characters. * @param fcStart The start of the text for this property, in characters.
@ -118,9 +109,6 @@ public abstract class PropertyNode<T extends PropertyNode<T>> implements Compara
/** /**
* Adjust for a deletion that can span multiple PropertyNodes. * Adjust for a deletion that can span multiple PropertyNodes.
*
* @param start
* @param length
*/ */
public void adjustForDelete(int start, int length) { public void adjustForDelete(int start, int length) {
int end = start + length; int end = start + length;
@ -164,16 +152,21 @@ public abstract class PropertyNode<T extends PropertyNode<T>> implements Compara
return false; return false;
} }
@SuppressWarnings("unchecked") @Override
public T clone() throws CloneNotSupportedException { @Deprecated
return (T) super.clone(); @Removal(version = "5.0.0")
@SuppressWarnings({"unchecked","squid:S2975"})
public T clone() {
return (T) copy();
} }
@Override
public abstract PropertyNode<?> copy();
/** /**
* Used for sorting in collections. * Used for sorting in collections.
*/ */
public int compareTo(T o) { public int compareTo(T o) {
int cpEnd = o.getEnd(); return Integer.compare(_cpEnd, o.getEnd());
return Integer.compare(_cpEnd, cpEnd);
} }
} }

View File

@ -24,13 +24,20 @@ import org.apache.poi.hwpf.usermodel.SectionProperties;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
@Internal @Internal
public final class SEPX extends PropertyNode<SEPX> public final class SEPX extends PropertyNode<SEPX> {
{
SectionProperties sectionProperties; SectionProperties sectionProperties;
SectionDescriptor _sed; SectionDescriptor _sed;
public SEPX( SEPX other ) {
super(other);
sectionProperties = (other.sectionProperties == null) ? null : other.sectionProperties.copy();
_sed = (other._sed == null) ? null : other._sed.copy();
}
public SEPX( SectionDescriptor sed, int start, int end, byte[] grpprl ) public SEPX( SectionDescriptor sed, int start, int end, byte[] grpprl )
{ {
super( start, end, new SprmBuffer( grpprl, 0 ) ); super( start, end, new SprmBuffer( grpprl, 0 ) );
@ -86,4 +93,9 @@ public final class SEPX extends PropertyNode<SEPX>
{ {
return "SEPX from " + getStart() + " to " + getEnd(); return "SEPX from " + getStart() + " to " + getEnd();
} }
@Override
public SEPX copy() {
return new SEPX(this);
}
} }

View File

@ -17,6 +17,7 @@
package org.apache.poi.hwpf.model; package org.apache.poi.hwpf.model;
import org.apache.poi.common.Duplicatable;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
@ -26,8 +27,7 @@ import org.apache.poi.util.LittleEndian;
* See page 186 for details. * See page 186 for details.
*/ */
@Internal @Internal
public final class SectionDescriptor public final class SectionDescriptor implements Duplicatable {
{
/** /**
* "Used internally by Word" * "Used internally by Word"
@ -52,8 +52,13 @@ public final class SectionDescriptor
*/ */
private int fcMpr; private int fcMpr;
public SectionDescriptor() public SectionDescriptor() {}
{
public SectionDescriptor(SectionDescriptor other) {
fn = other.fn;
fcSepx = other.fcSepx;
fnMpr = other.fnMpr;
fcMpr = other.fcMpr;
} }
public SectionDescriptor(byte[] buf, int offset) public SectionDescriptor(byte[] buf, int offset)
@ -113,4 +118,9 @@ public final class SectionDescriptor
return "[SED] (fn: " + fn + "; fcSepx: " + fcSepx + "; fnMpr: " + fnMpr return "[SED] (fn: " + fn + "; fcSepx: " + fcSepx + "; fnMpr: " + fnMpr
+ "; fcMpr: " + fcMpr + ")"; + "; fcMpr: " + fcMpr + ")";
} }
@Override
public SectionDescriptor copy() {
return new SectionDescriptor(this);
}
} }

View File

@ -29,9 +29,6 @@ import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger; import org.apache.poi.util.POILogger;
/**
* @author Ryan Ackley
*/
@Internal @Internal
public class SectionTable public class SectionTable
{ {
@ -117,7 +114,7 @@ public class SectionTable
} }
} }
_sections.sort(PropertyNode.StartComparator.instance); _sections.sort(PropertyNode.StartComparator);
} }
public void adjustForInsert(int listIndex, int length) public void adjustForInsert(int listIndex, int length)

View File

@ -20,11 +20,12 @@ import org.apache.poi.util.Internal;
import org.apache.poi.util.StringUtil; import org.apache.poi.util.StringUtil;
@Internal @Internal
public class SinglentonTextPiece extends TextPiece public class SinglentonTextPiece extends TextPiece {
{ public SinglentonTextPiece(SinglentonTextPiece other) {
super(other);
}
public SinglentonTextPiece( StringBuilder buffer ) public SinglentonTextPiece( StringBuilder buffer ) {
{
super( 0, buffer.length(), StringUtil.getToUnicodeLE(buffer.toString()), new PieceDescriptor( new byte[8], 0 ) ); super( 0, buffer.length(), StringUtil.getToUnicodeLE(buffer.toString()), new PieceDescriptor( new byte[8], 0 ) );
} }
@ -62,4 +63,9 @@ public class SinglentonTextPiece extends TextPiece
{ {
return "SinglentonTextPiece (" + characterLength() + " chars)"; return "SinglentonTextPiece (" + characterLength() + " chars)";
} }
@Override
public SinglentonTextPiece copy() {
return new SinglentonTextPiece(this);
}
} }

View File

@ -16,23 +16,22 @@
==================================================================== */ ==================================================================== */
package org.apache.poi.hwpf.model; package org.apache.poi.hwpf.model;
import org.apache.poi.common.Duplicatable;
import org.apache.poi.hwpf.model.types.TBDAbstractType; import org.apache.poi.hwpf.model.types.TBDAbstractType;
import org.apache.poi.hwpf.usermodel.ParagraphProperties; import org.apache.poi.hwpf.usermodel.ParagraphProperties;
/** /**
* Tab descriptor. Part of {@link ParagraphProperties}. * Tab descriptor. Part of {@link ParagraphProperties}.
*
* @author vlsergey
*/ */
public class TabDescriptor extends TBDAbstractType public class TabDescriptor extends TBDAbstractType implements Duplicatable {
{
public TabDescriptor() public TabDescriptor() {}
{
public TabDescriptor(TabDescriptor other) {
super(other);
} }
public TabDescriptor( byte[] bytes, int offset ) public TabDescriptor( byte[] bytes, int offset ) {
{
fillFields( bytes, offset ); fillFields( bytes, offset );
} }
@ -43,4 +42,8 @@ public class TabDescriptor extends TBDAbstractType
return buf; return buf;
} }
@Override
public TabDescriptor copy() {
return new TabDescriptor(this);
}
} }

View File

@ -29,8 +29,6 @@ import org.apache.poi.util.StringUtil;
* Works in the character domain, not the byte domain, so you * Works in the character domain, not the byte domain, so you
* need to have turned byte references into character * need to have turned byte references into character
* references before getting here. * references before getting here.
*
* @author Ryan Ackley
*/ */
@Internal @Internal
public class TextPiece extends PropertyNode<TextPiece> { public class TextPiece extends PropertyNode<TextPiece> {
@ -38,6 +36,12 @@ public class TextPiece extends PropertyNode<TextPiece> {
private PieceDescriptor _pd; private PieceDescriptor _pd;
public TextPiece(TextPiece other) {
super(other);
_usesUnicode = other._usesUnicode;
_pd = (other._pd == null) ? null : other._pd.copy();
}
/** /**
* @param start Beginning offset in main document stream, in characters. * @param start Beginning offset in main document stream, in characters.
* @param end Ending offset in main document stream, in characters. * @param end Ending offset in main document stream, in characters.
@ -212,4 +216,8 @@ public class TextPiece extends PropertyNode<TextPiece> {
+ getPieceDescriptor() + ")"; + getPieceDescriptor() + ")";
} }
@Override
public TextPiece copy() {
return new TextPiece(this);
}
} }

View File

@ -26,26 +26,23 @@ import org.apache.poi.util.LittleEndian;
* <p> * <p>
* Class and fields descriptions are quoted from Microsoft Office Word 97-2007 * Class and fields descriptions are quoted from Microsoft Office Word 97-2007
* Binary File Format (.doc) Specification * Binary File Format (.doc) Specification
*
* NOTE: This source is automatically generated please do not modify this file.
* Either subclass or remove the record in src/types/definitions.
*
* @author Sergey Vladimirov; according to Microsoft Office Word 97-2007 Binary
* File Format (.doc) Specification
*/ */
@Internal @Internal
public abstract class BKFAbstractType public abstract class BKFAbstractType {
{
private static final BitField itcFirst = new BitField( 0x007F );
private static final BitField fPub = new BitField( 0x0080 );
private static final BitField itcLim = new BitField( 0x7F00 );
private static final BitField fCol = new BitField( 0x8000 );
protected short field_1_ibkl; protected short field_1_ibkl;
protected short field_2_bkf_flags; protected short field_2_bkf_flags;
/**/private static BitField itcFirst = new BitField( 0x007F );
/**/private static BitField fPub = new BitField( 0x0080 );
/**/private static BitField itcLim = new BitField( 0x7F00 );
/**/private static BitField fCol = new BitField( 0x8000 );
protected BKFAbstractType() protected BKFAbstractType() {}
{
protected BKFAbstractType(BKFAbstractType other) {
field_1_ibkl = other.field_1_ibkl;
field_2_bkf_flags = other.field_2_bkf_flags;
} }
protected void fillFields( byte[] data, int offset ) protected void fillFields( byte[] data, int offset )
@ -189,4 +186,4 @@ public abstract class BKFAbstractType
return fCol.isSet(field_2_bkf_flags); return fCol.isSet(field_2_bkf_flags);
} }
} // END OF CLASS }

View File

@ -30,53 +30,111 @@ import org.apache.poi.util.Internal;
/** /**
* Character Properties. * Character Properties.
* <p>
* NOTE: This source is automatically generated please do not modify this file. Either subclass or
* remove the record in src/types/definitions.
* <p>
* This class is internal. It content or properties may change without notice
* due to changes in our knowledge of internal Microsoft Word binary structures.
* @author S. Ryan Ackley
*/ */
@SuppressWarnings("unused")
@Internal @Internal
public abstract class CHPAbstractType public abstract class CHPAbstractType {
{
private static final BitField fBold = new BitField(0x00000001);
private static final BitField fItalic = new BitField(0x00000002);
private static final BitField fRMarkDel = new BitField(0x00000004);
private static final BitField fOutline = new BitField(0x00000008);
private static final BitField fFldVanish = new BitField(0x00000010);
private static final BitField fSmallCaps = new BitField(0x00000020);
private static final BitField fCaps = new BitField(0x00000040);
private static final BitField fVanish = new BitField(0x00000080);
private static final BitField fRMark = new BitField(0x00000100);
private static final BitField fSpec = new BitField(0x00000200);
private static final BitField fStrike = new BitField(0x00000400);
private static final BitField fObj = new BitField(0x00000800);
private static final BitField fShadow = new BitField(0x00001000);
private static final BitField fLowerCase = new BitField(0x00002000);
private static final BitField fData = new BitField(0x00004000);
private static final BitField fOle2 = new BitField(0x00008000);
private static final BitField fEmboss = new BitField(0x00010000);
private static final BitField fImprint = new BitField(0x00020000);
private static final BitField fDStrike = new BitField(0x00040000);
private static final BitField fUsePgsuSettings = new BitField(0x00080000);
private static final BitField fBoldBi = new BitField(0x00100000);
private static final BitField fComplexScripts = new BitField(0x00100000);
private static final BitField fItalicBi = new BitField(0x00200000);
private static final BitField fBiDi = new BitField(0x00400000);
private static final BitField fIcoBi = new BitField(0x00800000);
private static final BitField fNonGlyph = new BitField(0x01000000);
private static final BitField fBoldOther = new BitField(0x02000000);
private static final BitField fItalicOther = new BitField(0x04000000);
private static final BitField fNoProof = new BitField(0x08000000);
private static final BitField fWebHidden = new BitField(0x10000000);
private static final BitField fFitText = new BitField(0x20000000);
private static final BitField fCalc = new BitField(0x40000000);
private static final BitField fFmtLineProp = new BitField(0x80000000);
protected static final byte SFXTTEXT_NO = 0;
protected static final byte SFXTTEXT_LAS_VEGAS_LIGHTS = 1;
protected static final byte SFXTTEXT_BACKGROUND_BLINK = 2;
protected static final byte SFXTTEXT_SPARKLE_TEXT = 3;
protected static final byte SFXTTEXT_MARCHING_ANTS = 4;
protected static final byte SFXTTEXT_MARCHING_RED_ANTS = 5;
protected static final byte SFXTTEXT_SHIMMER = 6;
protected static final byte KCD_NON = 0;
protected static final byte KCD_DOT = 1;
protected static final byte KCD_COMMA = 2;
protected static final byte KCD_CIRCLE = 3;
protected static final byte KCD_UNDER_DOT = 4;
protected static final byte KUL_NONE = 0;
protected static final byte KUL_SINGLE = 1;
protected static final byte KUL_BY_WORD = 2;
protected static final byte KUL_DOUBLE = 3;
protected static final byte KUL_DOTTED = 4;
protected static final byte KUL_HIDDEN = 5;
protected static final byte KUL_THICK = 6;
protected static final byte KUL_DASH = 7;
protected static final byte KUL_DOT = 8;
protected static final byte KUL_DOT_DASH = 9;
protected static final byte KUL_DOT_DOT_DASH = 10;
protected static final byte KUL_WAVE = 11;
protected static final byte KUL_DOTTED_HEAVY = 20;
protected static final byte KUL_DASHED_HEAVY = 23;
protected static final byte KUL_DOT_DASH_HEAVY = 25;
protected static final byte KUL_DOT_DOT_DASH_HEAVY = 26;
protected static final byte KUL_WAVE_HEAVY = 27;
protected static final byte KUL_DASH_LONG = 39;
protected static final byte KUL_WAVE_DOUBLE = 43;
protected static final byte KUL_DASH_LONG_HEAVY = 55;
protected static final byte ISS_NONE = 0;
protected static final byte ISS_SUPERSCRIPTED = 1;
protected static final byte ISS_SUBSCRIPTED = 2;
private static final BitField itypFELayout = new BitField(0x00ff);
private static final BitField fTNY = new BitField(0x0100);
private static final BitField fWarichu = new BitField(0x0200);
private static final BitField fKumimoji = new BitField(0x0400);
private static final BitField fRuby = new BitField(0x0800);
private static final BitField fLSFitText = new BitField(0x1000);
private static final BitField spare = new BitField(0xe000);
private static final BitField iWarichuBracket = new BitField(0x07);
private static final BitField fWarichuNoOpenBracket = new BitField(0x08);
private static final BitField fTNYCompress = new BitField(0x10);
private static final BitField fTNYFetchTxm = new BitField(0x20);
private static final BitField fCellFitText = new BitField(0x40);
private static final BitField unused = new BitField(0x80);
private static final BitField icoHighlight = new BitField(0x001f);
private static final BitField fHighlight = new BitField(0x0020);
private static final BitField fChsDiff = new BitField(0x0001);
private static final BitField fMacChs = new BitField(0x0020);
protected static final byte LBRCRJ_NONE = 0;
protected static final byte LBRCRJ_LEFT = 1;
protected static final byte LBRCRJ_RIGHT = 2;
protected static final byte LBRCRJ_BOTH = 3;
protected int field_1_grpfChp; protected int field_1_grpfChp;
/**/private static final BitField fBold = new BitField(0x00000001);
/**/private static final BitField fItalic = new BitField(0x00000002);
/**/private static final BitField fRMarkDel = new BitField(0x00000004);
/**/private static final BitField fOutline = new BitField(0x00000008);
/**/private static final BitField fFldVanish = new BitField(0x00000010);
/**/private static final BitField fSmallCaps = new BitField(0x00000020);
/**/private static final BitField fCaps = new BitField(0x00000040);
/**/private static final BitField fVanish = new BitField(0x00000080);
/**/private static final BitField fRMark = new BitField(0x00000100);
/**/private static final BitField fSpec = new BitField(0x00000200);
/**/private static final BitField fStrike = new BitField(0x00000400);
/**/private static final BitField fObj = new BitField(0x00000800);
/**/private static final BitField fShadow = new BitField(0x00001000);
/**/private static final BitField fLowerCase = new BitField(0x00002000);
/**/private static final BitField fData = new BitField(0x00004000);
/**/private static final BitField fOle2 = new BitField(0x00008000);
/**/private static final BitField fEmboss = new BitField(0x00010000);
/**/private static final BitField fImprint = new BitField(0x00020000);
/**/private static final BitField fDStrike = new BitField(0x00040000);
/**/private static final BitField fUsePgsuSettings = new BitField(0x00080000);
/**/private static final BitField fBoldBi = new BitField(0x00100000);
/**/private static final BitField fComplexScripts = new BitField(0x00100000);
/**/private static final BitField fItalicBi = new BitField(0x00200000);
/**/private static final BitField fBiDi = new BitField(0x00400000);
/**/private static final BitField fIcoBi = new BitField(0x00800000);
/**/private static final BitField fNonGlyph = new BitField(0x01000000);
/**/private static final BitField fBoldOther = new BitField(0x02000000);
/**/private static final BitField fItalicOther = new BitField(0x04000000);
/**/private static final BitField fNoProof = new BitField(0x08000000);
/**/private static final BitField fWebHidden = new BitField(0x10000000);
/**/private static final BitField fFitText = new BitField(0x20000000);
/**/private static final BitField fCalc = new BitField(0x40000000);
/**/private static final BitField fFmtLineProp = new BitField(0x80000000);
protected int field_2_hps; protected int field_2_hps;
protected int field_3_ftcAscii; protected int field_3_ftcAscii;
protected int field_4_ftcFE; protected int field_4_ftcFE;
@ -89,40 +147,12 @@ public abstract class CHPAbstractType
protected int field_11_lidDefault; protected int field_11_lidDefault;
protected int field_12_lidFE; protected int field_12_lidFE;
protected byte field_13_kcd; protected byte field_13_kcd;
/**/protected final static byte KCD_NON = 0;
/**/protected final static byte KCD_DOT = 1;
/**/protected final static byte KCD_COMMA = 2;
/**/protected final static byte KCD_CIRCLE = 3;
/**/protected final static byte KCD_UNDER_DOT = 4;
protected boolean field_14_fUndetermine; protected boolean field_14_fUndetermine;
protected byte field_15_iss; protected byte field_15_iss;
/**/protected final static byte ISS_NONE = 0;
/**/protected final static byte ISS_SUPERSCRIPTED = 1;
/**/protected final static byte ISS_SUBSCRIPTED = 2;
protected boolean field_16_fSpecSymbol; protected boolean field_16_fSpecSymbol;
protected byte field_17_idct; protected byte field_17_idct;
protected byte field_18_idctHint; protected byte field_18_idctHint;
protected byte field_19_kul; protected byte field_19_kul;
/**/protected final static byte KUL_NONE = 0;
/**/protected final static byte KUL_SINGLE = 1;
/**/protected final static byte KUL_BY_WORD = 2;
/**/protected final static byte KUL_DOUBLE = 3;
/**/protected final static byte KUL_DOTTED = 4;
/**/protected final static byte KUL_HIDDEN = 5;
/**/protected final static byte KUL_THICK = 6;
/**/protected final static byte KUL_DASH = 7;
/**/protected final static byte KUL_DOT = 8;
/**/protected final static byte KUL_DOT_DASH = 9;
/**/protected final static byte KUL_DOT_DOT_DASH = 10;
/**/protected final static byte KUL_WAVE = 11;
/**/protected final static byte KUL_DOTTED_HEAVY = 20;
/**/protected final static byte KUL_DASHED_HEAVY = 23;
/**/protected final static byte KUL_DOT_DASH_HEAVY = 25;
/**/protected final static byte KUL_DOT_DOT_DASH_HEAVY = 26;
/**/protected final static byte KUL_WAVE_HEAVY = 27;
/**/protected final static byte KUL_DASH_LONG = 39;
/**/protected final static byte KUL_WAVE_DOUBLE = 43;
/**/protected final static byte KUL_DASH_LONG_HEAVY = 55;
protected Hyphenation field_20_hresi; protected Hyphenation field_20_hresi;
protected int field_21_hpsKern; protected int field_21_hpsKern;
protected short field_22_hpsPos; protected short field_22_hpsPos;
@ -130,30 +160,10 @@ public abstract class CHPAbstractType
protected BorderCode field_24_brc; protected BorderCode field_24_brc;
protected int field_25_ibstRMark; protected int field_25_ibstRMark;
protected byte field_26_sfxtText; protected byte field_26_sfxtText;
/**/protected final static byte SFXTTEXT_NO = 0;
/**/protected final static byte SFXTTEXT_LAS_VEGAS_LIGHTS = 1;
/**/protected final static byte SFXTTEXT_BACKGROUND_BLINK = 2;
/**/protected final static byte SFXTTEXT_SPARKLE_TEXT = 3;
/**/protected final static byte SFXTTEXT_MARCHING_ANTS = 4;
/**/protected final static byte SFXTTEXT_MARCHING_RED_ANTS = 5;
/**/protected final static byte SFXTTEXT_SHIMMER = 6;
protected boolean field_27_fDblBdr; protected boolean field_27_fDblBdr;
protected boolean field_28_fBorderWS; protected boolean field_28_fBorderWS;
protected short field_29_ufel; protected short field_29_ufel;
/**/private static final BitField itypFELayout = new BitField(0x00ff);
/**/private static final BitField fTNY = new BitField(0x0100);
/**/private static final BitField fWarichu = new BitField(0x0200);
/**/private static final BitField fKumimoji = new BitField(0x0400);
/**/private static final BitField fRuby = new BitField(0x0800);
/**/private static final BitField fLSFitText = new BitField(0x1000);
/**/private static final BitField spare = new BitField(0xe000);
protected byte field_30_copt; protected byte field_30_copt;
/**/private static final BitField iWarichuBracket = new BitField(0x07);
/**/private static final BitField fWarichuNoOpenBracket = new BitField(0x08);
/**/private static final BitField fTNYCompress = new BitField(0x10);
/**/private static final BitField fTNYFetchTxm = new BitField(0x20);
/**/private static final BitField fCellFitText = new BitField(0x40);
/**/private static final BitField unused = new BitField(0x80);
protected int field_31_hpsAsci; protected int field_31_hpsAsci;
protected int field_32_hpsFE; protected int field_32_hpsFE;
protected int field_33_hpsBi; protected int field_33_hpsBi;
@ -172,11 +182,7 @@ public abstract class CHPAbstractType
protected int field_46_idslReasonDel; protected int field_46_idslReasonDel;
protected int field_47_cpg; protected int field_47_cpg;
protected short field_48_Highlight; protected short field_48_Highlight;
/**/private static final BitField icoHighlight = new BitField(0x001f);
/**/private static final BitField fHighlight = new BitField(0x0020);
protected short field_49_CharsetFlags; protected short field_49_CharsetFlags;
/**/private static final BitField fChsDiff = new BitField(0x0001);
/**/private static final BitField fMacChs = new BitField(0x0020);
protected short field_50_chse; protected short field_50_chse;
protected boolean field_51_fPropRMark; protected boolean field_51_fPropRMark;
protected int field_52_ibstPropRMark; protected int field_52_ibstPropRMark;
@ -192,36 +198,101 @@ public abstract class CHPAbstractType
protected byte[] field_62_xstDispFldRMark; protected byte[] field_62_xstDispFldRMark;
protected int field_63_fcObjp; protected int field_63_fcObjp;
protected byte field_64_lbrCRJ; protected byte field_64_lbrCRJ;
/**/protected final static byte LBRCRJ_NONE = 0;
/**/protected final static byte LBRCRJ_LEFT = 1;
/**/protected final static byte LBRCRJ_RIGHT = 2;
/**/protected final static byte LBRCRJ_BOTH = 3;
protected boolean field_65_fSpecVanish; protected boolean field_65_fSpecVanish;
protected boolean field_66_fHasOldProps; protected boolean field_66_fHasOldProps;
protected boolean field_67_fSdtVanish; protected boolean field_67_fSdtVanish;
protected int field_68_wCharScale; protected int field_68_wCharScale;
protected CHPAbstractType() protected CHPAbstractType() {
{ field_2_hps = 20;
this.field_2_hps = 20; field_8_cv = new Colorref();
this.field_8_cv = new Colorref(); field_11_lidDefault = 0x0400;
this.field_11_lidDefault = 0x0400; field_12_lidFE = 0x0400;
this.field_12_lidFE = 0x0400; field_20_hresi = new Hyphenation();
this.field_20_hresi = new Hyphenation(); field_23_shd = new ShadingDescriptor();
this.field_23_shd = new ShadingDescriptor(); field_24_brc = new BorderCode();
this.field_24_brc = new BorderCode(); field_36_fcPic = -1;
this.field_36_fcPic = -1; field_40_hresiOld = new Hyphenation();
this.field_40_hresiOld = new Hyphenation(); field_42_dttmRMark = new DateAndTime();
this.field_42_dttmRMark = new DateAndTime(); field_43_dttmRMarkDel = new DateAndTime();
this.field_43_dttmRMarkDel = new DateAndTime(); field_44_istd = 10;
this.field_44_istd = 10; field_53_dttmPropRMark = new DateAndTime();
this.field_53_dttmPropRMark = new DateAndTime(); field_58_dttmConflict = new DateAndTime();
this.field_58_dttmConflict = new DateAndTime(); field_61_dttmDispFldRMark = new DateAndTime();
this.field_61_dttmDispFldRMark = new DateAndTime(); field_62_xstDispFldRMark = new byte[32];
this.field_62_xstDispFldRMark = new byte[32]; field_68_wCharScale = 100;
this.field_68_wCharScale = 100;
} }
protected CHPAbstractType(CHPAbstractType other) {
field_1_grpfChp = other.field_1_grpfChp;
field_2_hps = other.field_2_hps;
field_3_ftcAscii = other.field_3_ftcAscii;
field_4_ftcFE = other.field_4_ftcFE;
field_5_ftcOther = other.field_5_ftcOther;
field_6_ftcBi = other.field_6_ftcBi;
field_7_dxaSpace = other.field_7_dxaSpace;
field_8_cv = (other.field_8_cv == null) ? null : other.field_8_cv.copy();
field_9_ico = other.field_9_ico;
field_10_pctCharWidth = other.field_10_pctCharWidth;
field_11_lidDefault = other.field_11_lidDefault;
field_12_lidFE = other.field_12_lidFE;
field_13_kcd = other.field_13_kcd;
field_14_fUndetermine = other.field_14_fUndetermine;
field_15_iss = other.field_15_iss;
field_16_fSpecSymbol = other.field_16_fSpecSymbol;
field_17_idct = other.field_17_idct;
field_18_idctHint = other.field_18_idctHint;
field_19_kul = other.field_19_kul;
field_20_hresi = (other.field_20_hresi == null) ? null : other.field_20_hresi.copy();
field_21_hpsKern = other.field_21_hpsKern;
field_22_hpsPos = other.field_22_hpsPos;
field_23_shd = (other.field_23_shd == null) ? null : other.field_23_shd.copy();
field_24_brc = (other.field_24_brc == null) ? null : other.field_24_brc.copy();
field_25_ibstRMark = other.field_25_ibstRMark;
field_26_sfxtText = other.field_26_sfxtText;
field_27_fDblBdr = other.field_27_fDblBdr;
field_28_fBorderWS = other.field_28_fBorderWS;
field_29_ufel = other.field_29_ufel;
field_30_copt = other.field_30_copt;
field_31_hpsAsci = other.field_31_hpsAsci;
field_32_hpsFE = other.field_32_hpsFE;
field_33_hpsBi = other.field_33_hpsBi;
field_34_ftcSym = other.field_34_ftcSym;
field_35_xchSym = other.field_35_xchSym;
field_36_fcPic = other.field_36_fcPic;
field_37_fcObj = other.field_37_fcObj;
field_38_lTagObj = other.field_38_lTagObj;
field_39_fcData = other.field_39_fcData;
field_40_hresiOld = (other.field_40_hresiOld == null) ? null : other.field_40_hresiOld.copy();
field_41_ibstRMarkDel = other.field_41_ibstRMarkDel;
field_42_dttmRMark = (other.field_42_dttmRMark == null) ? null : other.field_42_dttmRMark.copy();
field_43_dttmRMarkDel = (other.field_43_dttmRMarkDel == null) ? null : other.field_43_dttmRMarkDel.copy();
field_44_istd = other.field_44_istd;
field_45_idslRMReason = other.field_45_idslRMReason;
field_46_idslReasonDel = other.field_46_idslReasonDel;
field_47_cpg = other.field_47_cpg;
field_48_Highlight = other.field_48_Highlight;
field_49_CharsetFlags = other.field_49_CharsetFlags;
field_50_chse = other.field_50_chse;
field_51_fPropRMark = other.field_51_fPropRMark;
field_52_ibstPropRMark = other.field_52_ibstPropRMark;
field_53_dttmPropRMark = (other.field_53_dttmPropRMark == null) ? null : other.field_53_dttmPropRMark.copy();
field_54_fConflictOrig = other.field_54_fConflictOrig;
field_55_fConflictOtherDel = other.field_55_fConflictOtherDel;
field_56_wConflict = other.field_56_wConflict;
field_57_IbstConflict = other.field_57_IbstConflict;
field_58_dttmConflict = (other.field_58_dttmConflict == null) ? null : other.field_58_dttmConflict.copy();
field_59_fDispFldRMark = other.field_59_fDispFldRMark;
field_60_ibstDispFldRMark = other.field_60_ibstDispFldRMark;
field_61_dttmDispFldRMark = (other.field_61_dttmDispFldRMark == null) ? null : other.field_61_dttmDispFldRMark.copy();
field_62_xstDispFldRMark = (other.field_62_xstDispFldRMark == null) ? null : other.field_62_xstDispFldRMark.clone();
field_63_fcObjp = other.field_63_fcObjp;
field_64_lbrCRJ = other.field_64_lbrCRJ;
field_65_fSpecVanish = other.field_65_fSpecVanish;
field_66_fHasOldProps = other.field_66_fHasOldProps;
field_67_fSdtVanish = other.field_67_fSdtVanish;
field_68_wCharScale = other.field_68_wCharScale;
}
@Override @Override
public boolean equals( Object obj ) public boolean equals( Object obj )

View File

@ -24,21 +24,16 @@ import org.apache.poi.util.LittleEndian;
* <p> * <p>
* Class and fields descriptions are quoted from Microsoft Office Word 97-2007 * Class and fields descriptions are quoted from Microsoft Office Word 97-2007
* Binary File Format (.doc) Specification * Binary File Format (.doc) Specification
*
* NOTE: This source is automatically generated please do not modify this file.
* Either subclass or remove the record in src/types/definitions.
*
* @author Sergey Vladimirov; according to Microsoft Office Word 97-2007 Binary
* File Format (.doc) Specification
*/ */
@Internal @Internal
public abstract class FRDAbstractType public abstract class FRDAbstractType {
{
protected short field_1_nAuto; protected short field_1_nAuto;
protected FRDAbstractType() protected FRDAbstractType() {}
{
protected FRDAbstractType(FRDAbstractType other) {
field_1_nAuto = other.field_1_nAuto;
} }
protected void fillFields( byte[] data, int offset ) protected void fillFields( byte[] data, int offset )

View File

@ -24,29 +24,25 @@ import org.apache.poi.util.Internal;
* <p> * <p>
* Class and fields descriptions are quoted from Microsoft Office Word 97-2007 * Class and fields descriptions are quoted from Microsoft Office Word 97-2007
* Binary File Format (.doc) Specification * Binary File Format (.doc) Specification
*
* NOTE: This source is automatically generated please do not modify this file.
* Either subclass or remove the record in src/types/definitions.
*
* @author Sergey Vladimirov; according to Microsoft Office Word 97-2007 Binary
* File Format (.doc) Specification
*/ */
@Internal @Internal
public abstract class HRESIAbstractType public abstract class HRESIAbstractType {
{ public static final byte HRES_NO = 0;
public static final byte HRES_NORMAL = 1;
public static final byte HRES_ADD_LETTER_BEFORE = 2;
public static final byte HRES_CHANGE_LETTER_BEFORE = 3;
public static final byte HRES_DELETE_LETTER_BEFORE = 4;
public static final byte HRES_CHANGE_LETTER_AFTER = 5;
public static final byte HRES_DELETE_BEFORE_CHANGE_BEFORE = 6;
protected byte field_1_hres; protected byte field_1_hres;
/**/public final static byte HRES_NO = 0;
/**/public final static byte HRES_NORMAL = 1;
/**/public final static byte HRES_ADD_LETTER_BEFORE = 2;
/**/public final static byte HRES_CHANGE_LETTER_BEFORE = 3;
/**/public final static byte HRES_DELETE_LETTER_BEFORE = 4;
/**/public final static byte HRES_CHANGE_LETTER_AFTER = 5;
/**/public final static byte HRES_DELETE_BEFORE_CHANGE_BEFORE = 6;
protected byte field_2_chHres; protected byte field_2_chHres;
protected HRESIAbstractType() protected HRESIAbstractType() {}
{
protected HRESIAbstractType(HRESIAbstractType other) {
field_1_hres = other.field_1_hres;
field_2_chHres = other.field_2_chHres;
} }
protected void fillFields( byte[] data, int offset ) protected void fillFields( byte[] data, int offset )

View File

@ -19,6 +19,7 @@ package org.apache.poi.hwpf.model.types;
import java.util.Arrays; import java.util.Arrays;
import java.util.stream.Stream;
import org.apache.poi.hwpf.model.TabDescriptor; import org.apache.poi.hwpf.model.TabDescriptor;
import org.apache.poi.hwpf.usermodel.BorderCode; import org.apache.poi.hwpf.usermodel.BorderCode;
@ -31,18 +32,34 @@ import org.apache.poi.util.Internal;
/** /**
* Paragraph Properties. * Paragraph Properties.
* <p>
* NOTE: This source is automatically generated please do not modify this file. Either subclass or
* remove the record in src/types/definitions.
* <p>
* This class is internal. It content or properties may change without notice
* due to changes in our knowledge of internal Microsoft Word binary structures.
* @author S. Ryan Ackley
*/ */
@SuppressWarnings("unused")
@Internal @Internal
public abstract class PAPAbstractType public abstract class PAPAbstractType {
{
protected static final byte BRCL_SINGLE = 0;
protected static final byte BRCL_THICK = 1;
protected static final byte BRCL_DOUBLE = 2;
protected static final byte BRCL_SHADOW = 3;
protected static final byte BRCP_NONE = 0;
protected static final byte BRCP_BORDER_ABOVE = 1;
protected static final byte BRCP_BORDER_BELOW = 2;
protected static final byte BRCP_BOX_AROUND = 15;
protected static final byte BRCP_BAR_TO_LEFT_OF_PARAGRAPH = 16;
protected static final boolean FMINHEIGHT_EXACT = false;
protected static final boolean FMINHEIGHT_AT_LEAST = true;
protected static final byte WALIGNFONT_HANGING = 0;
protected static final byte WALIGNFONT_CENTERED = 1;
protected static final byte WALIGNFONT_ROMAN = 2;
protected static final byte WALIGNFONT_VARIABLE = 3;
protected static final byte WALIGNFONT_AUTO = 4;
private static final BitField fVertical = new BitField(0x0001);
private static final BitField fBackward = new BitField(0x0002);
private static final BitField fRotateFont = new BitField(0x0004);
protected int field_1_istd; protected int field_1_istd;
protected boolean field_2_fSideBySide; protected boolean field_2_fSideBySide;
@ -50,16 +67,7 @@ public abstract class PAPAbstractType
protected boolean field_4_fKeepFollow; protected boolean field_4_fKeepFollow;
protected boolean field_5_fPageBreakBefore; protected boolean field_5_fPageBreakBefore;
protected byte field_6_brcl; protected byte field_6_brcl;
/**/protected final static byte BRCL_SINGLE = 0;
/**/protected final static byte BRCL_THICK = 1;
/**/protected final static byte BRCL_DOUBLE = 2;
/**/protected final static byte BRCL_SHADOW = 3;
protected byte field_7_brcp; protected byte field_7_brcp;
/**/protected final static byte BRCP_NONE = 0;
/**/protected final static byte BRCP_BORDER_ABOVE = 1;
/**/protected final static byte BRCP_BORDER_BELOW = 2;
/**/protected final static byte BRCP_BOX_AROUND = 15;
/**/protected final static byte BRCP_BAR_TO_LEFT_OF_PARAGRAPH = 16;
protected byte field_8_ilvl; protected byte field_8_ilvl;
protected int field_9_ilfo; protected int field_9_ilfo;
protected boolean field_10_fNoLnn; protected boolean field_10_fNoLnn;
@ -80,8 +88,6 @@ public abstract class PAPAbstractType
protected boolean field_25_fNoAutoHyph; protected boolean field_25_fNoAutoHyph;
protected int field_26_dyaHeight; protected int field_26_dyaHeight;
protected boolean field_27_fMinHeight; protected boolean field_27_fMinHeight;
/**/protected final static boolean FMINHEIGHT_EXACT = false;
/**/protected final static boolean FMINHEIGHT_AT_LEAST = true;
protected DropCapSpecifier field_28_dcs; protected DropCapSpecifier field_28_dcs;
protected int field_29_dyaFromText; protected int field_29_dyaFromText;
protected int field_30_dxaFromText; protected int field_30_dxaFromText;
@ -94,15 +100,7 @@ public abstract class PAPAbstractType
protected boolean field_37_fAutoSpaceDE; protected boolean field_37_fAutoSpaceDE;
protected boolean field_38_fAutoSpaceDN; protected boolean field_38_fAutoSpaceDN;
protected int field_39_wAlignFont; protected int field_39_wAlignFont;
/**/protected final static byte WALIGNFONT_HANGING = 0;
/**/protected final static byte WALIGNFONT_CENTERED = 1;
/**/protected final static byte WALIGNFONT_ROMAN = 2;
/**/protected final static byte WALIGNFONT_VARIABLE = 3;
/**/protected final static byte WALIGNFONT_AUTO = 4;
protected short field_40_fontAlign; protected short field_40_fontAlign;
/**/private static BitField fVertical = new BitField(0x0001);
/**/private static BitField fBackward = new BitField(0x0002);
/**/private static BitField fRotateFont = new BitField(0x0004);
protected byte field_41_lvl; protected byte field_41_lvl;
protected boolean field_42_fBiDi; protected boolean field_42_fBiDi;
protected boolean field_43_fNumRMIns; protected boolean field_43_fNumRMIns;
@ -143,29 +141,111 @@ public abstract class PAPAbstractType
protected long field_78_ipgp; protected long field_78_ipgp;
protected long field_79_rsid; protected long field_79_rsid;
protected PAPAbstractType() protected PAPAbstractType() {
{ field_11_lspd = new LineSpacingDescriptor();
this.field_11_lspd = new LineSpacingDescriptor(); field_11_lspd = new LineSpacingDescriptor();
this.field_11_lspd = new LineSpacingDescriptor(); field_28_dcs = new DropCapSpecifier();
this.field_28_dcs = new DropCapSpecifier(); field_32_fWidowControl = true;
this.field_32_fWidowControl = true; field_41_lvl = 9;
this.field_41_lvl = 9; field_60_brcTop = new BorderCode();
this.field_60_brcTop = new BorderCode(); field_61_brcLeft = new BorderCode();
this.field_61_brcLeft = new BorderCode(); field_62_brcBottom = new BorderCode();
this.field_62_brcBottom = new BorderCode(); field_63_brcRight = new BorderCode();
this.field_63_brcRight = new BorderCode(); field_64_brcBetween = new BorderCode();
this.field_64_brcBetween = new BorderCode(); field_65_brcBar = new BorderCode();
this.field_65_brcBar = new BorderCode(); field_66_shd = new ShadingDescriptor();
this.field_66_shd = new ShadingDescriptor(); field_67_anld = new byte[0];
this.field_67_anld = new byte[0]; field_68_phe = new byte[0];
this.field_68_phe = new byte[0]; field_71_dttmPropRMark = new DateAndTime();
this.field_71_dttmPropRMark = new DateAndTime(); field_73_rgdxaTab = new int[0];
this.field_73_rgdxaTab = new int[0]; field_74_rgtbd = new TabDescriptor[0];
this.field_74_rgtbd = new TabDescriptor[0]; field_75_numrm = new byte[0];
this.field_75_numrm = new byte[0]; field_76_ptap = new byte[0];
this.field_76_ptap = new byte[0];
} }
protected PAPAbstractType(PAPAbstractType other) {
field_1_istd = other.field_1_istd;
field_2_fSideBySide = other.field_2_fSideBySide;
field_3_fKeep = other.field_3_fKeep;
field_4_fKeepFollow = other.field_4_fKeepFollow;
field_5_fPageBreakBefore = other.field_5_fPageBreakBefore;
field_6_brcl = other.field_6_brcl;
field_7_brcp = other.field_7_brcp;
field_8_ilvl = other.field_8_ilvl;
field_9_ilfo = other.field_9_ilfo;
field_10_fNoLnn = other.field_10_fNoLnn;
field_11_lspd = (other.field_11_lspd == null) ? null : other.field_11_lspd.copy();
field_12_dyaBefore = other.field_12_dyaBefore;
field_13_dyaAfter = other.field_13_dyaAfter;
field_14_fInTable = other.field_14_fInTable;
field_15_finTableW97 = other.field_15_finTableW97;
field_16_fTtp = other.field_16_fTtp;
field_17_dxaAbs = other.field_17_dxaAbs;
field_18_dyaAbs = other.field_18_dyaAbs;
field_19_dxaWidth = other.field_19_dxaWidth;
field_20_fBrLnAbove = other.field_20_fBrLnAbove;
field_21_fBrLnBelow = other.field_21_fBrLnBelow;
field_22_pcVert = other.field_22_pcVert;
field_23_pcHorz = other.field_23_pcHorz;
field_24_wr = other.field_24_wr;
field_25_fNoAutoHyph = other.field_25_fNoAutoHyph;
field_26_dyaHeight = other.field_26_dyaHeight;
field_27_fMinHeight = other.field_27_fMinHeight;
field_28_dcs = (other.field_28_dcs == null) ? null : other.field_28_dcs.copy();
field_29_dyaFromText = other.field_29_dyaFromText;
field_30_dxaFromText = other.field_30_dxaFromText;
field_31_fLocked = other.field_31_fLocked;
field_32_fWidowControl = other.field_32_fWidowControl;
field_33_fKinsoku = other.field_33_fKinsoku;
field_34_fWordWrap = other.field_34_fWordWrap;
field_35_fOverflowPunct = other.field_35_fOverflowPunct;
field_36_fTopLinePunct = other.field_36_fTopLinePunct;
field_37_fAutoSpaceDE = other.field_37_fAutoSpaceDE;
field_38_fAutoSpaceDN = other.field_38_fAutoSpaceDN;
field_39_wAlignFont = other.field_39_wAlignFont;
field_40_fontAlign = other.field_40_fontAlign;
field_41_lvl = other.field_41_lvl;
field_42_fBiDi = other.field_42_fBiDi;
field_43_fNumRMIns = other.field_43_fNumRMIns;
field_44_fCrLf = other.field_44_fCrLf;
field_45_fUsePgsuSettings = other.field_45_fUsePgsuSettings;
field_46_fAdjustRight = other.field_46_fAdjustRight;
field_47_itap = other.field_47_itap;
field_48_fInnerTableCell = other.field_48_fInnerTableCell;
field_49_fOpenTch = other.field_49_fOpenTch;
field_50_fTtpEmbedded = other.field_50_fTtpEmbedded;
field_51_dxcRight = other.field_51_dxcRight;
field_52_dxcLeft = other.field_52_dxcLeft;
field_53_dxcLeft1 = other.field_53_dxcLeft1;
field_54_fDyaBeforeAuto = other.field_54_fDyaBeforeAuto;
field_55_fDyaAfterAuto = other.field_55_fDyaAfterAuto;
field_56_dxaRight = other.field_56_dxaRight;
field_57_dxaLeft = other.field_57_dxaLeft;
field_58_dxaLeft1 = other.field_58_dxaLeft1;
field_59_jc = other.field_59_jc;
field_60_brcTop = (other.field_60_brcTop == null) ? null : other.field_60_brcTop.copy();
field_61_brcLeft = (other.field_61_brcLeft == null) ? null : other.field_61_brcLeft.copy();
field_62_brcBottom = (other.field_62_brcBottom == null) ? null : other.field_62_brcBottom.copy();
field_63_brcRight = (other.field_63_brcRight == null) ? null : other.field_63_brcRight.copy();
field_64_brcBetween = (other.field_64_brcBetween == null) ? null : other.field_64_brcBetween.copy();
field_65_brcBar = (other.field_65_brcBar == null) ? null : other.field_65_brcBar.copy();
field_66_shd = (other.field_66_shd == null) ? null : other.field_66_shd.copy();
field_67_anld = (other.field_67_anld == null) ? null : other.field_67_anld.clone();
field_68_phe = (other.field_68_phe == null) ? null : other.field_68_phe.clone();
field_69_fPropRMark = other.field_69_fPropRMark;
field_70_ibstPropRMark = other.field_70_ibstPropRMark;
field_71_dttmPropRMark = (other.field_71_dttmPropRMark == null) ? null : other.field_71_dttmPropRMark.copy();
field_72_itbdMac = other.field_72_itbdMac;
field_73_rgdxaTab = (other.field_73_rgdxaTab == null) ? null : other.field_73_rgdxaTab.clone();
field_74_rgtbd = (other.field_74_rgtbd == null) ? null
: Stream.of(other.field_74_rgtbd).map(TabDescriptor::copy).toArray(TabDescriptor[]::new);
field_75_numrm = (other.field_75_numrm == null) ? null : other.field_75_numrm.clone();
field_76_ptap = (other.field_76_ptap == null) ? null : other.field_76_ptap.clone();
field_77_fNoAllowOverlap = other.field_77_fNoAllowOverlap;
field_78_ipgp = other.field_78_ipgp;
field_79_rsid = other.field_79_rsid;
}
public String toString() public String toString()
{ {

View File

@ -26,39 +26,40 @@ import org.apache.poi.util.Internal;
/** /**
* Section Properties. * Section Properties.
* NOTE: This source is automatically generated please do not modify this file. Either subclass or
* remove the record in src/records/definitions.
*
* @author S. Ryan Ackley
*/ */
@Internal @Internal
public abstract class SEPAbstractType public abstract class SEPAbstractType {
{
/** No break */
public static final byte BKC_NO_BREAK = 0;
/** New column */
public static final byte BKC_NEW_COLUMN = 1;
/** New page */
public static final byte BKC_NEW_PAGE = 2;
/** Even page */
public static final byte BKC_EVEN_PAGE = 3;
/** Odd page */
public static final byte BKC_ODD_PAGE = 4;
/** Arabic */
public static final byte NFCPGN_ARABIC = 0;
/** Roman (upper case) */
public static final byte NFCPGN_ROMAN_UPPER_CASE = 1;
/** Roman (lower case) */
public static final byte NFCPGN_ROMAN_LOWER_CASE = 2;
/** Letter (upper case) */
public static final byte NFCPGN_LETTER_UPPER_CASE = 3;
/** Letter (lower case) */
public static final byte NFCPGN_LETTER_LOWER_CASE = 4;
public static final boolean DMORIENTPAGE_LANDSCAPE = false;
public static final boolean DMORIENTPAGE_PORTRAIT = true;
protected byte field_1_bkc; protected byte field_1_bkc;
/** No break */
/**/public final static byte BKC_NO_BREAK = 0;
/** New column */
/**/public final static byte BKC_NEW_COLUMN = 1;
/** New page */
/**/public final static byte BKC_NEW_PAGE = 2;
/** Even page */
/**/public final static byte BKC_EVEN_PAGE = 3;
/** Odd page */
/**/public final static byte BKC_ODD_PAGE = 4;
protected boolean field_2_fTitlePage; protected boolean field_2_fTitlePage;
protected boolean field_3_fAutoPgn; protected boolean field_3_fAutoPgn;
protected byte field_4_nfcPgn; protected byte field_4_nfcPgn;
/** Arabic */
/**/public final static byte NFCPGN_ARABIC = 0;
/** Roman (upper case) */
/**/public final static byte NFCPGN_ROMAN_UPPER_CASE = 1;
/** Roman (lower case) */
/**/public final static byte NFCPGN_ROMAN_LOWER_CASE = 2;
/** Letter (upper case) */
/**/public final static byte NFCPGN_LETTER_UPPER_CASE = 3;
/** Letter (lower case) */
/**/public final static byte NFCPGN_LETTER_LOWER_CASE = 4;
protected boolean field_5_fUnlocked; protected boolean field_5_fUnlocked;
protected byte field_6_cnsPgn; protected byte field_6_cnsPgn;
protected boolean field_7_fPgnRestart; protected boolean field_7_fPgnRestart;
@ -86,8 +87,6 @@ public abstract class SEPAbstractType
protected int field_29_clm; protected int field_29_clm;
protected int field_30_unused2; protected int field_30_unused2;
protected boolean field_31_dmOrientPage; protected boolean field_31_dmOrientPage;
/**/public final static boolean DMORIENTPAGE_LANDSCAPE = false;
/**/public final static boolean DMORIENTPAGE_PORTRAIT = true;
protected byte field_32_iHeadingPgn; protected byte field_32_iHeadingPgn;
protected int field_33_pgnStart; protected int field_33_pgnStart;
protected int field_34_lnnMin; protected int field_34_lnnMin;
@ -117,8 +116,7 @@ public abstract class SEPAbstractType
protected short field_58_unused6; protected short field_58_unused6;
protected byte[] field_59_olstAnm; protected byte[] field_59_olstAnm;
protected SEPAbstractType() protected SEPAbstractType() {
{
this.field_1_bkc = 2; this.field_1_bkc = 2;
this.field_8_fEndNote = true; this.field_8_fEndNote = true;
this.field_13_dxaPgn = 720; this.field_13_dxaPgn = 720;
@ -139,6 +137,68 @@ public abstract class SEPAbstractType
this.field_53_dxaColumns = 720; this.field_53_dxaColumns = 720;
} }
protected SEPAbstractType(SEPAbstractType other) {
field_1_bkc = other.field_1_bkc;
field_2_fTitlePage = other.field_2_fTitlePage;
field_3_fAutoPgn = other.field_3_fAutoPgn;
field_4_nfcPgn = other.field_4_nfcPgn;
field_5_fUnlocked = other.field_5_fUnlocked;
field_6_cnsPgn = other.field_6_cnsPgn;
field_7_fPgnRestart = other.field_7_fPgnRestart;
field_8_fEndNote = other.field_8_fEndNote;
field_9_lnc = other.field_9_lnc;
field_10_grpfIhdt = other.field_10_grpfIhdt;
field_11_nLnnMod = other.field_11_nLnnMod;
field_12_dxaLnn = other.field_12_dxaLnn;
field_13_dxaPgn = other.field_13_dxaPgn;
field_14_dyaPgn = other.field_14_dyaPgn;
field_15_fLBetween = other.field_15_fLBetween;
field_16_vjc = other.field_16_vjc;
field_17_dmBinFirst = other.field_17_dmBinFirst;
field_18_dmBinOther = other.field_18_dmBinOther;
field_19_dmPaperReq = other.field_19_dmPaperReq;
field_20_brcTop = (other.field_20_brcTop == null) ? null : other.field_20_brcTop.copy();
field_21_brcLeft = (other.field_21_brcLeft == null) ? null : other.field_21_brcLeft.copy();
field_22_brcBottom = (other.field_22_brcBottom == null) ? null : other.field_22_brcBottom.copy();
field_23_brcRight = (other.field_23_brcRight == null) ? null : other.field_23_brcRight.copy();
field_24_fPropMark = other.field_24_fPropMark;
field_25_ibstPropRMark = other.field_25_ibstPropRMark;
field_26_dttmPropRMark = (other.field_26_dttmPropRMark == null) ? null : other.field_26_dttmPropRMark.copy();
field_27_dxtCharSpace = other.field_27_dxtCharSpace;
field_28_dyaLinePitch = other.field_28_dyaLinePitch;
field_29_clm = other.field_29_clm;
field_30_unused2 = other.field_30_unused2;
field_31_dmOrientPage = other.field_31_dmOrientPage;
field_32_iHeadingPgn = other.field_32_iHeadingPgn;
field_33_pgnStart = other.field_33_pgnStart;
field_34_lnnMin = other.field_34_lnnMin;
field_35_wTextFlow = other.field_35_wTextFlow;
field_36_unused3 = other.field_36_unused3;
field_37_pgbProp = other.field_37_pgbProp;
field_38_unused4 = other.field_38_unused4;
field_39_xaPage = other.field_39_xaPage;
field_40_yaPage = other.field_40_yaPage;
field_41_xaPageNUp = other.field_41_xaPageNUp;
field_42_yaPageNUp = other.field_42_yaPageNUp;
field_43_dxaLeft = other.field_43_dxaLeft;
field_44_dxaRight = other.field_44_dxaRight;
field_45_dyaTop = other.field_45_dyaTop;
field_46_dyaBottom = other.field_46_dyaBottom;
field_47_dzaGutter = other.field_47_dzaGutter;
field_48_dyaHdrTop = other.field_48_dyaHdrTop;
field_49_dyaHdrBottom = other.field_49_dyaHdrBottom;
field_50_ccolM1 = other.field_50_ccolM1;
field_51_fEvenlySpaced = other.field_51_fEvenlySpaced;
field_52_unused5 = other.field_52_unused5;
field_53_dxaColumns = other.field_53_dxaColumns;
field_54_rgdxaColumn = (other.field_54_rgdxaColumn == null) ? null : other.field_54_rgdxaColumn.clone();
field_55_dxaColumnWidth = other.field_55_dxaColumnWidth;
field_56_dmOrientFirst = other.field_56_dmOrientFirst;
field_57_fLayout = other.field_57_fLayout;
field_58_unused6 = other.field_58_unused6;
field_59_olstAnm = (other.field_59_olstAnm == null) ? null : other.field_59_olstAnm.clone();
}
public String toString() public String toString()
{ {
@ -1250,4 +1310,4 @@ public abstract class SEPAbstractType
this.field_59_olstAnm = field_59_olstAnm; this.field_59_olstAnm = field_59_olstAnm;
} }
} // END OF CLASS }

View File

@ -24,32 +24,24 @@ import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
/** /**
* The Shd80 structure specifies the colors and pattern that are used for background * The Shd80 structure specifies the colors and pattern that are used for background shading.
shading. As an exception to the constraints that are specified by Ico and Ipat, a Shd80 can * As an exception to the constraints that are specified by Ico and Ipat,
be set to Shd80Nil and specifies that no shading is applied. <p>Class and fields * a Shd80 can be set to Shd80Nil and specifies that no shading is applied.
descriptions are quoted from Word (.doc) Binary File Format by Microsoft Corporation
* <p>
* NOTE: This source is automatically generated please do not modify this file. Either subclass or
* remove the record in src/types/definitions.
* <p>
* This class is internal. It content or properties may change without notice
* due to changes in our knowledge of internal Microsoft Word binary structures.
* @author Sergey Vladimirov; according to Word (.doc) Binary File Format by Microsoft Corporation.
*/ */
@SuppressWarnings("unused")
@Internal @Internal
public abstract class SHD80AbstractType public abstract class SHD80AbstractType {
{
private static final BitField icoFore = new BitField(0x001F);
private static final BitField icoBack = new BitField(0x03E0);
private static final BitField ipat = new BitField(0xFC00);
protected short field_1_value; protected short field_1_value;
/**/private static final BitField icoFore = new BitField(0x001F);
/**/private static final BitField icoBack = new BitField(0x03E0);
/**/private static final BitField ipat = new BitField(0xFC00);
protected SHD80AbstractType() protected SHD80AbstractType() { }
{
protected SHD80AbstractType(SHD80AbstractType other) {
field_1_value = other.field_1_value;
} }
protected void fillFields( byte[] data, int offset ) protected void fillFields( byte[] data, int offset )
@ -189,4 +181,4 @@ public abstract class SHD80AbstractType
return ( byte )ipat.getValue(field_1_value); return ( byte )ipat.getValue(field_1_value);
} }
} // END OF CLASS }

View File

@ -25,32 +25,24 @@ import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
/** /**
* The Shd structure specifies the colors and pattern that are used for background shading. <p>Class * The Shd structure specifies the colors and pattern that are used for background shading.
and
fields descriptions are quoted from Word (.doc) Binary File Format by Microsoft Corporation
* <p>
* NOTE: This source is automatically generated please do not modify this file. Either subclass or
* remove the record in src/types/definitions.
* <p>
* This class is internal. It content or properties may change without notice
* due to changes in our knowledge of internal Microsoft Word binary structures.
* @author Sergey Vladimirov; according to Word (.doc) Binary File Format by Microsoft Corporation.
*/ */
@Internal @Internal
public abstract class SHDAbstractType public abstract class SHDAbstractType {
{
protected Colorref field_1_cvFore; protected Colorref field_1_cvFore;
protected Colorref field_2_cvBack; protected Colorref field_2_cvBack;
protected int field_3_ipat; protected int field_3_ipat;
protected SHDAbstractType() protected SHDAbstractType() {
{ field_1_cvFore = new Colorref();
this.field_1_cvFore = new Colorref(); field_2_cvBack = new Colorref();
this.field_2_cvBack = new Colorref(); }
protected SHDAbstractType(SHDAbstractType other) {
field_1_cvFore = (other.field_1_cvFore == null) ? null : other.field_1_cvFore.copy();
field_2_cvBack = (other.field_2_cvBack == null) ? null : other.field_2_cvBack.copy();
field_3_ipat = other.field_3_ipat;
} }
protected void fillFields( byte[] data, int offset ) protected void fillFields( byte[] data, int offset )
@ -175,4 +167,4 @@ public abstract class SHDAbstractType
this.field_3_ipat = field_3_ipat; this.field_3_ipat = field_3_ipat;
} }
} // END OF CLASS }

View File

@ -19,6 +19,7 @@ package org.apache.poi.hwpf.model.types;
import java.util.Arrays; import java.util.Arrays;
import java.util.stream.Stream;
import org.apache.poi.hwpf.usermodel.BorderCode; import org.apache.poi.hwpf.usermodel.BorderCode;
import org.apache.poi.hwpf.usermodel.ShadingDescriptor; import org.apache.poi.hwpf.usermodel.ShadingDescriptor;
@ -28,21 +29,39 @@ import org.apache.poi.util.BitField;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
/** /**
* Table Properties. Properties descriptions quoted from official 97-2007 binary file * Table Properties
format specification.
* <p>
* NOTE: This source is automatically generated please do not modify this file. Either subclass or
* remove the record in src/types/definitions.
* <p>
* This class is internal. It content or properties may change without notice
* due to changes in our knowledge of internal Microsoft Word binary structures.
* @author S. Ryan Ackley
*/ */
@SuppressWarnings("unused")
@Internal @Internal
public abstract class TAPAbstractType public abstract class TAPAbstractType {
{ private static final BitField fAutofit = new BitField(0x00000001);
private static final BitField fKeepFollow = new BitField(0x00000002);
private static final BitField ftsWidth = new BitField(0x0000001c);
private static final BitField ftsWidthIndent = new BitField(0x000000e0);
private static final BitField ftsWidthBefore = new BitField(0x00000700);
private static final BitField ftsWidthAfter = new BitField(0x00003800);
private static final BitField fNeverBeenAutofit = new BitField(0x00004000);
private static final BitField fInvalAutofit = new BitField(0x00008000);
private static final BitField widthAndFitsFlags_empty1 = new BitField(0x00070000);
private static final BitField fVert = new BitField(0x00080000);
private static final BitField pcVert = new BitField(0x00300000);
private static final BitField pcHorz = new BitField(0x00c00000);
private static final BitField widthAndFitsFlags_empty2 = new BitField(0xff000000);
private static final BitField fFirstRow = new BitField(0x0001);
private static final BitField fLastRow = new BitField(0x0002);
private static final BitField fOutline = new BitField(0x0004);
private static final BitField fOrigWordTableRules = new BitField(0x0008);
private static final BitField fCellSpacing = new BitField(0x0010);
private static final BitField grpfTap_unused = new BitField(0xffe0);
private static final BitField fWrapToWwd = new BitField(0x0001);
private static final BitField fNotPageView = new BitField(0x0002);
private static final BitField viewFlags_unused1 = new BitField(0x0004);
private static final BitField fWebView = new BitField(0x0008);
private static final BitField fAdjusted = new BitField(0x0010);
private static final BitField viewFlags_unused2 = new BitField(0xffe0);
protected short field_1_istd; protected short field_1_istd;
protected short field_2_jc; protected short field_2_jc;
@ -57,19 +76,6 @@ public abstract class TAPAbstractType
protected short field_11_wWidthBefore; protected short field_11_wWidthBefore;
protected short field_12_wWidthAfter; protected short field_12_wWidthAfter;
protected int field_13_widthAndFitsFlags; protected int field_13_widthAndFitsFlags;
/**/private static BitField fAutofit = new BitField(0x00000001);
/**/private static BitField fKeepFollow = new BitField(0x00000002);
/**/private static BitField ftsWidth = new BitField(0x0000001c);
/**/private static BitField ftsWidthIndent = new BitField(0x000000e0);
/**/private static BitField ftsWidthBefore = new BitField(0x00000700);
/**/private static BitField ftsWidthAfter = new BitField(0x00003800);
/**/private static BitField fNeverBeenAutofit = new BitField(0x00004000);
/**/private static BitField fInvalAutofit = new BitField(0x00008000);
/**/private static BitField widthAndFitsFlags_empty1 = new BitField(0x00070000);
/**/private static BitField fVert = new BitField(0x00080000);
/**/private static BitField pcVert = new BitField(0x00300000);
/**/private static BitField pcHorz = new BitField(0x00c00000);
/**/private static BitField widthAndFitsFlags_empty2 = new BitField(0xff000000);
protected int field_14_dxaAbs; protected int field_14_dxaAbs;
protected int field_15_dyaAbs; protected int field_15_dyaAbs;
protected int field_16_dxaFromText; protected int field_16_dxaFromText;
@ -82,12 +88,6 @@ public abstract class TAPAbstractType
protected byte field_23_fSpare; protected byte field_23_fSpare;
protected int field_24_grpfTap; protected int field_24_grpfTap;
protected int field_25_internalFlags; protected int field_25_internalFlags;
/**/private static BitField fFirstRow = new BitField(0x0001);
/**/private static BitField fLastRow = new BitField(0x0002);
/**/private static BitField fOutline = new BitField(0x0004);
/**/private static BitField fOrigWordTableRules = new BitField(0x0008);
/**/private static BitField fCellSpacing = new BitField(0x0010);
/**/private static BitField grpfTap_unused = new BitField(0xffe0);
protected short field_26_itcMac; protected short field_26_itcMac;
protected int field_27_dxaAdjust; protected int field_27_dxaAdjust;
protected int field_28_dxaWebView; protected int field_28_dxaWebView;
@ -95,12 +95,6 @@ public abstract class TAPAbstractType
protected int field_30_dxaColWidthWwd; protected int field_30_dxaColWidthWwd;
protected short field_31_pctWwd; protected short field_31_pctWwd;
protected int field_32_viewFlags; protected int field_32_viewFlags;
/**/private static BitField fWrapToWwd = new BitField(0x0001);
/**/private static BitField fNotPageView = new BitField(0x0002);
/**/private static BitField viewFlags_unused1 = new BitField(0x0004);
/**/private static BitField fWebView = new BitField(0x0008);
/**/private static BitField fAdjusted = new BitField(0x0010);
/**/private static BitField viewFlags_unused2 = new BitField(0xffe0);
protected short[] field_33_rgdxaCenter; protected short[] field_33_rgdxaCenter;
protected short[] field_34_rgdxaCenterPrint; protected short[] field_34_rgdxaCenterPrint;
protected ShadingDescriptor field_35_shdTable; protected ShadingDescriptor field_35_shdTable;
@ -151,8 +145,7 @@ public abstract class TAPAbstractType
protected BorderCode field_80_rgbrcInsideDefault_0; protected BorderCode field_80_rgbrcInsideDefault_0;
protected BorderCode field_81_rgbrcInsideDefault_1; protected BorderCode field_81_rgbrcInsideDefault_1;
protected TAPAbstractType() protected TAPAbstractType() {
{
this.field_8_tlp = new TableAutoformatLookSpecifier(); this.field_8_tlp = new TableAutoformatLookSpecifier();
this.field_33_rgdxaCenter = new short[0]; this.field_33_rgdxaCenter = new short[0];
this.field_34_rgdxaCenterPrint = new short[0]; this.field_34_rgdxaCenterPrint = new short[0];
@ -169,6 +162,91 @@ public abstract class TAPAbstractType
this.field_81_rgbrcInsideDefault_1 = new BorderCode(); this.field_81_rgbrcInsideDefault_1 = new BorderCode();
} }
protected TAPAbstractType(TAPAbstractType other) {
field_1_istd = other.field_1_istd;
field_2_jc = other.field_2_jc;
field_3_dxaGapHalf = other.field_3_dxaGapHalf;
field_4_dyaRowHeight = other.field_4_dyaRowHeight;
field_5_fCantSplit = other.field_5_fCantSplit;
field_6_fCantSplit90 = other.field_6_fCantSplit90;
field_7_fTableHeader = other.field_7_fTableHeader;
field_8_tlp = (other.field_8_tlp == null) ? null : other.field_8_tlp.copy();
field_9_wWidth = other.field_9_wWidth;
field_10_wWidthIndent = other.field_10_wWidthIndent;
field_11_wWidthBefore = other.field_11_wWidthBefore;
field_12_wWidthAfter = other.field_12_wWidthAfter;
field_13_widthAndFitsFlags = other.field_13_widthAndFitsFlags;
field_14_dxaAbs = other.field_14_dxaAbs;
field_15_dyaAbs = other.field_15_dyaAbs;
field_16_dxaFromText = other.field_16_dxaFromText;
field_17_dyaFromText = other.field_17_dyaFromText;
field_18_dxaFromTextRight = other.field_18_dxaFromTextRight;
field_19_dyaFromTextBottom = other.field_19_dyaFromTextBottom;
field_20_fBiDi = other.field_20_fBiDi;
field_21_fRTL = other.field_21_fRTL;
field_22_fNoAllowOverlap = other.field_22_fNoAllowOverlap;
field_23_fSpare = other.field_23_fSpare;
field_24_grpfTap = other.field_24_grpfTap;
field_25_internalFlags = other.field_25_internalFlags;
field_26_itcMac = other.field_26_itcMac;
field_27_dxaAdjust = other.field_27_dxaAdjust;
field_28_dxaWebView = other.field_28_dxaWebView;
field_29_dxaRTEWrapWidth = other.field_29_dxaRTEWrapWidth;
field_30_dxaColWidthWwd = other.field_30_dxaColWidthWwd;
field_31_pctWwd = other.field_31_pctWwd;
field_32_viewFlags = other.field_32_viewFlags;
field_33_rgdxaCenter = (other.field_33_rgdxaCenter == null) ? null : other.field_33_rgdxaCenter.clone();
field_34_rgdxaCenterPrint = (other.field_34_rgdxaCenterPrint == null) ? null : other.field_34_rgdxaCenterPrint.clone();
field_35_shdTable = (other.field_35_shdTable == null) ? null : other.field_35_shdTable.copy();
field_36_brcBottom = (other.field_36_brcBottom == null) ? null : other.field_36_brcBottom.copy();
field_37_brcTop = (other.field_37_brcTop == null) ? null : other.field_37_brcTop.copy();
field_38_brcLeft = (other.field_38_brcLeft == null) ? null : other.field_38_brcLeft.copy();
field_39_brcRight = (other.field_39_brcRight == null) ? null : other.field_39_brcRight.copy();
field_40_brcVertical = (other.field_40_brcVertical == null) ? null : other.field_40_brcVertical.copy();
field_41_brcHorizontal = (other.field_41_brcHorizontal == null) ? null : other.field_41_brcHorizontal.copy();
field_42_wCellPaddingDefaultTop = other.field_42_wCellPaddingDefaultTop;
field_43_wCellPaddingDefaultLeft = other.field_43_wCellPaddingDefaultLeft;
field_44_wCellPaddingDefaultBottom = other.field_44_wCellPaddingDefaultBottom;
field_45_wCellPaddingDefaultRight = other.field_45_wCellPaddingDefaultRight;
field_46_ftsCellPaddingDefaultTop = other.field_46_ftsCellPaddingDefaultTop;
field_47_ftsCellPaddingDefaultLeft = other.field_47_ftsCellPaddingDefaultLeft;
field_48_ftsCellPaddingDefaultBottom = other.field_48_ftsCellPaddingDefaultBottom;
field_49_ftsCellPaddingDefaultRight = other.field_49_ftsCellPaddingDefaultRight;
field_50_wCellSpacingDefaultTop = other.field_50_wCellSpacingDefaultTop;
field_51_wCellSpacingDefaultLeft = other.field_51_wCellSpacingDefaultLeft;
field_52_wCellSpacingDefaultBottom = other.field_52_wCellSpacingDefaultBottom;
field_53_wCellSpacingDefaultRight = other.field_53_wCellSpacingDefaultRight;
field_54_ftsCellSpacingDefaultTop = other.field_54_ftsCellSpacingDefaultTop;
field_55_ftsCellSpacingDefaultLeft = other.field_55_ftsCellSpacingDefaultLeft;
field_56_ftsCellSpacingDefaultBottom = other.field_56_ftsCellSpacingDefaultBottom;
field_57_ftsCellSpacingDefaultRight = other.field_57_ftsCellSpacingDefaultRight;
field_58_wCellPaddingOuterTop = other.field_58_wCellPaddingOuterTop;
field_59_wCellPaddingOuterLeft = other.field_59_wCellPaddingOuterLeft;
field_60_wCellPaddingOuterBottom = other.field_60_wCellPaddingOuterBottom;
field_61_wCellPaddingOuterRight = other.field_61_wCellPaddingOuterRight;
field_62_ftsCellPaddingOuterTop = other.field_62_ftsCellPaddingOuterTop;
field_63_ftsCellPaddingOuterLeft = other.field_63_ftsCellPaddingOuterLeft;
field_64_ftsCellPaddingOuterBottom = other.field_64_ftsCellPaddingOuterBottom;
field_65_ftsCellPaddingOuterRight = other.field_65_ftsCellPaddingOuterRight;
field_66_wCellSpacingOuterTop = other.field_66_wCellSpacingOuterTop;
field_67_wCellSpacingOuterLeft = other.field_67_wCellSpacingOuterLeft;
field_68_wCellSpacingOuterBottom = other.field_68_wCellSpacingOuterBottom;
field_69_wCellSpacingOuterRight = other.field_69_wCellSpacingOuterRight;
field_70_ftsCellSpacingOuterTop = other.field_70_ftsCellSpacingOuterTop;
field_71_ftsCellSpacingOuterLeft = other.field_71_ftsCellSpacingOuterLeft;
field_72_ftsCellSpacingOuterBottom = other.field_72_ftsCellSpacingOuterBottom;
field_73_ftsCellSpacingOuterRight = other.field_73_ftsCellSpacingOuterRight;
field_74_rgtc = (other.field_74_rgtc == null) ? null
: Stream.of(other.field_74_rgtc).map(TableCellDescriptor::copy).toArray(TableCellDescriptor[]::new);
field_75_rgshd = (other.field_75_rgshd == null) ? null
: Stream.of(other.field_75_rgshd).map(ShadingDescriptor::copy).toArray(ShadingDescriptor[]::new);
field_76_fPropRMark = other.field_76_fPropRMark;
field_77_fHasOldProps = other.field_77_fHasOldProps;
field_78_cHorzBands = other.field_78_cHorzBands;
field_79_cVertBands = other.field_79_cVertBands;
field_80_rgbrcInsideDefault_0 = (other.field_80_rgbrcInsideDefault_0 == null) ? null : other.field_80_rgbrcInsideDefault_0.copy();
field_81_rgbrcInsideDefault_1 = (other.field_81_rgbrcInsideDefault_1 == null) ? null : other.field_81_rgbrcInsideDefault_1.copy();
}
public String toString() public String toString()
{ {

View File

@ -22,33 +22,23 @@ import org.apache.poi.util.BitField;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
/** /**
* The TBD is a substructure of the PAP. <p>Class and fields descriptions are quoted from * The TBD is a substructure of the PAP.
Microsoft Office Word 97-2007 Binary File Format
* <p>
* NOTE: This source is automatically generated please do not modify this file. Either subclass or
* remove the record in src/types/definitions.
* <p>
* This class is internal. It content or properties may change without notice
* due to changes in our knowledge of internal Microsoft Word binary structures.
* @author Sergey Vladimirov; according to Microsoft Office Word 97-2007 Binary File Format
Specification [*.doc]
*/ */
@Internal @Internal
public abstract class TBDAbstractType public abstract class TBDAbstractType {
{ private static final BitField jc = new BitField(0x07);
private static final BitField tlc = new BitField(0x38);
private static final BitField reserved = new BitField(0xc0);
protected byte field_1_value; protected byte field_1_value;
/**/private static BitField jc = new BitField(0x07);
/**/private static BitField tlc = new BitField(0x38);
/**/private static BitField reserved = new BitField(0xc0);
protected TBDAbstractType() protected TBDAbstractType() { }
{
protected TBDAbstractType(TBDAbstractType other) {
field_1_value = other.field_1_value;
} }
protected void fillFields( byte[] data, int offset ) protected void fillFields( byte[] data, int offset )
{ {
field_1_value = data[ 0x0 + offset ]; field_1_value = data[ 0x0 + offset ];

View File

@ -18,39 +18,30 @@
package org.apache.poi.hwpf.model.types; package org.apache.poi.hwpf.model.types;
import org.apache.poi.hwpf.usermodel.*; import org.apache.poi.hwpf.usermodel.BorderCode;
import org.apache.poi.util.*; import org.apache.poi.hwpf.usermodel.ShadingDescriptor;
import org.apache.poi.util.BitField;
import org.apache.poi.util.Internal;
/** /**
* Table Cell Descriptor. * Table Cell Descriptor.
* <p>
* NOTE: This source is automatically generated please do not modify this file. Either subclass or
* remove the record in src/types/definitions.
* <p>
* This class is internal. It content or properties may change without notice
* due to changes in our knowledge of internal Microsoft Word binary structures.
* @author S. Ryan Ackley. Field descriptions are quoted from Microsoft Office Word 97-2007 Binary
File Format (.doc) Specification
*/ */
@Internal @Internal
public abstract class TCAbstractType public abstract class TCAbstractType {
{ private static final BitField fFirstMerged = new BitField(0x0001);
private static final BitField fMerged = new BitField(0x0002);
private static final BitField fVertical = new BitField(0x0004);
private static final BitField fBackward = new BitField(0x0008);
private static final BitField fRotateFont = new BitField(0x0010);
private static final BitField fVertMerge = new BitField(0x0020);
private static final BitField fVertRestart = new BitField(0x0040);
private static final BitField vertAlign = new BitField(0x0180);
private static final BitField ftsWidth = new BitField(0x0E00);
private static final BitField fFitText = new BitField(0x1000);
private static final BitField fNoWrap = new BitField(0x2000);
private static final BitField fUnused = new BitField(0xC000);
protected short field_1_rgf; protected short field_1_rgf;
/**/private static BitField fFirstMerged = new BitField(0x0001);
/**/private static BitField fMerged = new BitField(0x0002);
/**/private static BitField fVertical = new BitField(0x0004);
/**/private static BitField fBackward = new BitField(0x0008);
/**/private static BitField fRotateFont = new BitField(0x0010);
/**/private static BitField fVertMerge = new BitField(0x0020);
/**/private static BitField fVertRestart = new BitField(0x0040);
/**/private static BitField vertAlign = new BitField(0x0180);
/**/private static BitField ftsWidth = new BitField(0x0E00);
/**/private static BitField fFitText = new BitField(0x1000);
/**/private static BitField fNoWrap = new BitField(0x2000);
/**/private static BitField fUnused = new BitField(0xC000);
protected short field_2_wWidth; protected short field_2_wWidth;
protected ShadingDescriptor field_3_shd; protected ShadingDescriptor field_3_shd;
protected short field_4_wCellPaddingLeft; protected short field_4_wCellPaddingLeft;
@ -74,8 +65,7 @@ public abstract class TCAbstractType
protected BorderCode field_22_brcBottom; protected BorderCode field_22_brcBottom;
protected BorderCode field_23_brcRight; protected BorderCode field_23_brcRight;
protected TCAbstractType() protected TCAbstractType() {
{
this.field_3_shd = new ShadingDescriptor(); this.field_3_shd = new ShadingDescriptor();
this.field_20_brcTop = new BorderCode(); this.field_20_brcTop = new BorderCode();
this.field_21_brcLeft = new BorderCode(); this.field_21_brcLeft = new BorderCode();
@ -83,6 +73,31 @@ public abstract class TCAbstractType
this.field_23_brcRight = new BorderCode(); this.field_23_brcRight = new BorderCode();
} }
protected TCAbstractType(TCAbstractType other) {
field_1_rgf = other.field_1_rgf;
field_2_wWidth = other.field_2_wWidth;
field_3_shd = (other.field_3_shd == null) ? null : other.field_3_shd.copy();
field_4_wCellPaddingLeft = other.field_4_wCellPaddingLeft;
field_5_wCellPaddingTop = other.field_5_wCellPaddingTop;
field_6_wCellPaddingBottom = other.field_6_wCellPaddingBottom;
field_7_wCellPaddingRight = other.field_7_wCellPaddingRight;
field_8_ftsCellPaddingLeft = other.field_8_ftsCellPaddingLeft;
field_9_ftsCellPaddingTop = other.field_9_ftsCellPaddingTop;
field_10_ftsCellPaddingBottom = other.field_10_ftsCellPaddingBottom;
field_11_ftsCellPaddingRight = other.field_11_ftsCellPaddingRight;
field_12_wCellSpacingLeft = other.field_12_wCellSpacingLeft;
field_13_wCellSpacingTop = other.field_13_wCellSpacingTop;
field_14_wCellSpacingBottom = other.field_14_wCellSpacingBottom;
field_15_wCellSpacingRight = other.field_15_wCellSpacingRight;
field_16_ftsCellSpacingLeft = other.field_16_ftsCellSpacingLeft;
field_17_ftsCellSpacingTop = other.field_17_ftsCellSpacingTop;
field_18_ftsCellSpacingBottom = other.field_18_ftsCellSpacingBottom;
field_19_ftsCellSpacingRight = other.field_19_ftsCellSpacingRight;
field_20_brcTop = (other.field_20_brcTop == null) ? null : other.field_20_brcTop.copy();
field_21_brcLeft = (other.field_21_brcLeft == null) ? null : other.field_21_brcLeft.copy();
field_22_brcBottom = (other.field_22_brcBottom == null) ? null : other.field_22_brcBottom.copy();
field_23_brcRight = (other.field_23_brcRight == null) ? null : other.field_23_brcRight.copy();
}
public String toString() public String toString()
{ {

View File

@ -23,22 +23,10 @@ import org.apache.poi.util.LittleEndian;
/** /**
* Table Autoformat Look sPecifier (TLP). * Table Autoformat Look sPecifier (TLP).
* <p>
* Class and fields descriptions are quoted from Microsoft Office Word 97-2007
* Binary File Format
*
* NOTE: This source is automatically generated please do not modify this file.
* Either subclass or remove the record in src/records/definitions.
*
* @author Sergey Vladimirov; according to Microsoft Office Word 97-2007 Binary
* File Format Specification [*.doc]
*/ */
@SuppressWarnings("unused")
@Internal @Internal
public abstract class TLPAbstractType public abstract class TLPAbstractType {
{
protected short field_1_itl;
protected byte field_2_tlp_flags;
private static final BitField fBorders = new BitField( 0x0001 ); private static final BitField fBorders = new BitField( 0x0001 );
private static final BitField fShading = new BitField( 0x0002 ); private static final BitField fShading = new BitField( 0x0002 );
private static final BitField fFont = new BitField( 0x0004 ); private static final BitField fFont = new BitField( 0x0004 );
@ -47,9 +35,14 @@ public abstract class TLPAbstractType
private static final BitField fHdrRows = new BitField( 0x0020 ); private static final BitField fHdrRows = new BitField( 0x0020 );
private static final BitField fLastRow = new BitField( 0x0040 ); private static final BitField fLastRow = new BitField( 0x0040 );
public TLPAbstractType() protected short field_1_itl;
{ protected byte field_2_tlp_flags;
public TLPAbstractType() {}
public TLPAbstractType(TLPAbstractType other) {
field_1_itl = other.field_1_itl;
field_2_tlp_flags = other.field_2_tlp_flags;
} }
protected void fillFields( byte[] data, int offset ) protected void fillFields( byte[] data, int offset )

View File

@ -51,15 +51,7 @@ public final class ParagraphSprmUncompressor
byte[] grpprl, byte[] grpprl,
int offset) int offset)
{ {
ParagraphProperties newProperties = null; ParagraphProperties newProperties = parent.copy();
try
{
newProperties = (ParagraphProperties) parent.clone();
}
catch (CloneNotSupportedException cnse)
{
throw new RuntimeException("There is no way this exception should happen!!");
}
SprmIterator sprmIt = new SprmIterator(grpprl, offset); SprmIterator sprmIt = new SprmIterator(grpprl, offset);
while (sprmIt.hasNext()) while (sprmIt.hasNext())

View File

@ -19,12 +19,14 @@ package org.apache.poi.hwpf.sprm;
import java.util.Arrays; import java.util.Arrays;
import org.apache.poi.common.Duplicatable;
import org.apache.poi.util.IOUtils; import org.apache.poi.util.IOUtils;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.Removal;
@Internal @Internal
public final class SprmBuffer implements Cloneable { public final class SprmBuffer implements Duplicatable {
//arbitrarily selected; may need to increase //arbitrarily selected; may need to increase
private static final int MAX_RECORD_LENGTH = 100_000; private static final int MAX_RECORD_LENGTH = 100_000;
@ -35,6 +37,13 @@ public final class SprmBuffer implements Cloneable {
private final int _sprmsStartOffset; private final int _sprmsStartOffset;
public SprmBuffer(SprmBuffer other) {
_buf = (other._buf == null) ? null : other._buf.clone();
_istd = other._istd;
_offset = other._offset;
_sprmsStartOffset = other._sprmsStartOffset;
}
public SprmBuffer(byte[] buf, boolean istd, int sprmsStartOffset) { public SprmBuffer(byte[] buf, boolean istd, int sprmsStartOffset) {
_offset = buf.length; _offset = buf.length;
_buf = buf; _buf = buf;
@ -97,15 +106,17 @@ public final class SprmBuffer implements Cloneable {
_offset += grpprl.length - offset; _offset += grpprl.length - offset;
} }
@Override
@SuppressWarnings("squid:S2975")
@Deprecated
@Removal(version = "5.0.0")
public SprmBuffer clone() { public SprmBuffer clone() {
try { return copy();
SprmBuffer retVal = (SprmBuffer) super.clone();
retVal._buf = new byte[_buf.length];
System.arraycopy(_buf, 0, retVal._buf, 0, _buf.length);
return retVal;
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
} }
@Override
public SprmBuffer copy() {
return new SprmBuffer(this);
} }
private void ensureCapacity(int addition) { private void ensureCapacity(int addition) {
@ -215,4 +226,6 @@ public final class SprmBuffer implements Cloneable {
} }
return stringBuilder.toString(); return stringBuilder.toString();
} }
} }

View File

@ -243,7 +243,7 @@ public class BookmarksImpl implements Bookmarks
indices[counter++] = entry.getKey().intValue(); indices[counter++] = entry.getKey().intValue();
List<GenericPropertyNode> updated = new ArrayList<>( List<GenericPropertyNode> updated = new ArrayList<>(
entry.getValue()); entry.getValue());
updated.sort(PropertyNode.EndComparator.instance); updated.sort(PropertyNode.EndComparator);
entry.setValue( updated ); entry.setValue( updated );
} }
Arrays.sort( indices ); Arrays.sort( indices );

View File

@ -17,31 +17,36 @@
package org.apache.poi.hwpf.usermodel; package org.apache.poi.hwpf.usermodel;
import org.apache.poi.common.Duplicatable;
import org.apache.poi.util.BitField; import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory; import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.Removal;
/** /**
* Mapping class for BRC80 structure (Border Code for Word 97) * Mapping class for BRC80 structure (Border Code for Word 97)
*
* <p>Comments are copied out from the binary format specification.
*/ */
public final class BorderCode implements Cloneable { public final class BorderCode implements Duplicatable {
public static final int SIZE = 4; public static final int SIZE = 4;
private short _info;
private static final BitField _dptLineWidth = BitFieldFactory.getInstance(0x00ff); private static final BitField _dptLineWidth = BitFieldFactory.getInstance(0x00ff);
private static final BitField _brcType = BitFieldFactory.getInstance(0xff00); private static final BitField _brcType = BitFieldFactory.getInstance(0xff00);
private short _info2;
private static final BitField _ico = BitFieldFactory.getInstance(0x00ff); private static final BitField _ico = BitFieldFactory.getInstance(0x00ff);
private static final BitField _dptSpace = BitFieldFactory.getInstance(0x1f00); private static final BitField _dptSpace = BitFieldFactory.getInstance(0x1f00);
private static final BitField _fShadow = BitFieldFactory.getInstance(0x2000); private static final BitField _fShadow = BitFieldFactory.getInstance(0x2000);
private static final BitField _fFrame = BitFieldFactory.getInstance(0x4000); private static final BitField _fFrame = BitFieldFactory.getInstance(0x4000);
public BorderCode() private short _info;
{ private short _info2;
public BorderCode() {}
public BorderCode(BorderCode other) {
_info = other._info;
_info2 = other._info2;
} }
public BorderCode(byte[] buf, int offset) public BorderCode(byte[] buf, int offset)
@ -82,10 +87,17 @@ public final class BorderCode implements Cloneable {
return 42; // any arbitrary constant will do return 42; // any arbitrary constant will do
} }
public Object clone() @Override
throws CloneNotSupportedException @SuppressWarnings("squid:S2975")
{ @Deprecated
return super.clone(); @Removal(version = "5.0.0")
public BorderCode clone() {
return copy();
}
@Override
public BorderCode copy() {
return new BorderCode(this);
} }
/** /**

View File

@ -17,80 +17,81 @@
package org.apache.poi.hwpf.usermodel; package org.apache.poi.hwpf.usermodel;
import org.apache.poi.common.Duplicatable;
import org.apache.poi.hwpf.model.Colorref; import org.apache.poi.hwpf.model.Colorref;
import org.apache.poi.hwpf.model.types.CHPAbstractType; import org.apache.poi.hwpf.model.types.CHPAbstractType;
import org.apache.poi.util.Removal;
/** @SuppressWarnings("unused")
* @author Ryan Ackley public final class CharacterProperties extends CHPAbstractType implements Duplicatable {
*/ public static final short SPRM_FRMARKDEL = (short)0x0800;
public final class CharacterProperties public static final short SPRM_FRMARK = 0x0801;
extends CHPAbstractType implements Cloneable public static final short SPRM_FFLDVANISH = 0x0802;
{ public static final short SPRM_PICLOCATION = 0x6A03;
public final static short SPRM_FRMARKDEL = (short)0x0800; public static final short SPRM_IBSTRMARK = 0x4804;
public final static short SPRM_FRMARK = 0x0801; public static final short SPRM_DTTMRMARK = 0x6805;
public final static short SPRM_FFLDVANISH = 0x0802; public static final short SPRM_FDATA = 0x0806;
public final static short SPRM_PICLOCATION = 0x6A03; public static final short SPRM_SYMBOL = 0x6A09;
public final static short SPRM_IBSTRMARK = 0x4804; public static final short SPRM_FOLE2 = 0x080A;
public final static short SPRM_DTTMRMARK = 0x6805; public static final short SPRM_HIGHLIGHT = 0x2A0C;
public final static short SPRM_FDATA = 0x0806; public static final short SPRM_OBJLOCATION = 0x680E;
public final static short SPRM_SYMBOL = 0x6A09; public static final short SPRM_ISTD = 0x4A30;
public final static short SPRM_FOLE2 = 0x080A; public static final short SPRM_FBOLD = 0x0835;
public final static short SPRM_HIGHLIGHT = 0x2A0C; public static final short SPRM_FITALIC = 0x0836;
public final static short SPRM_OBJLOCATION = 0x680E; public static final short SPRM_FSTRIKE = 0x0837;
public final static short SPRM_ISTD = 0x4A30; public static final short SPRM_FOUTLINE = 0x0838;
public final static short SPRM_FBOLD = 0x0835; public static final short SPRM_FSHADOW = 0x0839;
public final static short SPRM_FITALIC = 0x0836; public static final short SPRM_FSMALLCAPS = 0x083A;
public final static short SPRM_FSTRIKE = 0x0837; public static final short SPRM_FCAPS = 0x083B;
public final static short SPRM_FOUTLINE = 0x0838; public static final short SPRM_FVANISH = 0x083C;
public final static short SPRM_FSHADOW = 0x0839; public static final short SPRM_KUL = 0x2A3E;
public final static short SPRM_FSMALLCAPS = 0x083A; public static final short SPRM_DXASPACE = (short)0x8840;
public final static short SPRM_FCAPS = 0x083B; public static final short SPRM_LID = 0x4A41;
public final static short SPRM_FVANISH = 0x083C; public static final short SPRM_ICO = 0x2A42;
public final static short SPRM_KUL = 0x2A3E; public static final short SPRM_HPS = 0x4A43;
public final static short SPRM_DXASPACE = (short)0x8840; public static final short SPRM_HPSPOS = 0x4845;
public final static short SPRM_LID = 0x4A41; public static final short SPRM_ISS = 0x2A48;
public final static short SPRM_ICO = 0x2A42; public static final short SPRM_HPSKERN = 0x484B;
public final static short SPRM_HPS = 0x4A43; public static final short SPRM_YSRI = 0x484E;
public final static short SPRM_HPSPOS = 0x4845; public static final short SPRM_RGFTCASCII = 0x4A4F;
public final static short SPRM_ISS = 0x2A48; public static final short SPRM_RGFTCFAREAST = 0x4A50;
public final static short SPRM_HPSKERN = 0x484B; public static final short SPRM_RGFTCNOTFAREAST = 0x4A51;
public final static short SPRM_YSRI = 0x484E; public static final short SPRM_CHARSCALE = 0x4852;
public final static short SPRM_RGFTCASCII = 0x4A4F; public static final short SPRM_FDSTRIKE = 0x2A53;
public final static short SPRM_RGFTCFAREAST = 0x4A50; public static final short SPRM_FIMPRINT = 0x0854;
public final static short SPRM_RGFTCNOTFAREAST = 0x4A51; public static final short SPRM_FSPEC = 0x0855;
public final static short SPRM_CHARSCALE = 0x4852; public static final short SPRM_FOBJ = 0x0856;
public final static short SPRM_FDSTRIKE = 0x2A53; public static final short SPRM_PROPRMARK = (short)0xCA57;
public final static short SPRM_FIMPRINT = 0x0854; public static final short SPRM_FEMBOSS = 0x0858;
public final static short SPRM_FSPEC = 0x0855; public static final short SPRM_SFXTEXT = 0x2859;
public final static short SPRM_FOBJ = 0x0856;
public final static short SPRM_PROPRMARK = (short)0xCA57;
public final static short SPRM_FEMBOSS = 0x0858;
public final static short SPRM_SFXTEXT = 0x2859;
/* /*
* Microsoft Office Word 97-2007 Binary File Format (.doc) Specification; * Microsoft Office Word 97-2007 Binary File Format (.doc) Specification;
* Page 60 of 210 * Page 60 of 210
*/ */
public final static short SPRM_DISPFLDRMARK = (short)0xCA62; public static final short SPRM_DISPFLDRMARK = (short)0xCA62;
public final static short SPRM_IBSTRMARKDEL = 0x4863; public static final short SPRM_IBSTRMARKDEL = 0x4863;
public final static short SPRM_DTTMRMARKDEL = 0x6864; public static final short SPRM_DTTMRMARKDEL = 0x6864;
public final static short SPRM_BRC = 0x6865; public static final short SPRM_BRC = 0x6865;
public final static short SPRM_SHD = 0x4866; public static final short SPRM_SHD = 0x4866;
public final static short SPRM_IDSIRMARKDEL = 0x4867; public static final short SPRM_IDSIRMARKDEL = 0x4867;
public final static short SPRM_CPG = 0x486B; public static final short SPRM_CPG = 0x486B;
public final static short SPRM_NONFELID = 0x486D; public static final short SPRM_NONFELID = 0x486D;
public final static short SPRM_FELID = 0x486E; public static final short SPRM_FELID = 0x486E;
public final static short SPRM_IDCTHINT = 0x286F; public static final short SPRM_IDCTHINT = 0x286F;
/** /**
* change chp.cv * change chp.cv
*/ */
public final static short SPRM_CCV = 0x6870; public static final short SPRM_CCV = 0x6870;
public CharacterProperties() public CharacterProperties() {
{
setFUsePgsuSettings( true ); setFUsePgsuSettings( true );
setXstDispFldRMark( new byte[36] ); setXstDispFldRMark( new byte[36] );
} }
public CharacterProperties(CharacterProperties other) {
super(other);
}
public boolean isMarkedDeleted() public boolean isMarkedDeleted()
{ {
return isFRMarkDel(); return isFRMarkDel();
@ -370,27 +371,16 @@ public final class CharacterProperties
setCv( new Colorref( colour24 & 0xFFFFFF ) ); setCv( new Colorref( colour24 & 0xFFFFFF ) );
} }
public CharacterProperties clone() @Override
{ @SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"})
try @Deprecated
{ @Removal(version = "5.0.0")
CharacterProperties cp = (CharacterProperties) super.clone(); public CharacterProperties clone() {
return copy();
cp.setCv( getCv().clone() );
cp.setDttmRMark( (DateAndTime) getDttmRMark().clone() );
cp.setDttmRMarkDel( (DateAndTime) getDttmRMarkDel().clone() );
cp.setDttmPropRMark( (DateAndTime) getDttmPropRMark().clone() );
cp.setDttmDispFldRMark( (DateAndTime) getDttmDispFldRMark().clone() );
cp.setXstDispFldRMark( getXstDispFldRMark().clone() );
cp.setShd( getShd().clone() );
cp.setBrc( (BorderCode) getBrc().clone() );
return cp;
}
catch ( CloneNotSupportedException exc )
{
throw new UnsupportedOperationException(
"Impossible CloneNotSupportedException occured", exc );
} }
@Override
public CharacterProperties copy() {
return new CharacterProperties(this);
} }
} }

View File

@ -17,6 +17,7 @@
package org.apache.poi.hwpf.usermodel; package org.apache.poi.hwpf.usermodel;
import org.apache.poi.common.Duplicatable;
import org.apache.poi.hwpf.HWPFDocument; import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.HWPFOldDocument; import org.apache.poi.hwpf.HWPFOldDocument;
import org.apache.poi.hwpf.model.CHPX; import org.apache.poi.hwpf.model.CHPX;
@ -25,63 +26,62 @@ import org.apache.poi.hwpf.model.Ffn;
import org.apache.poi.hwpf.model.NilPICFAndBinData; import org.apache.poi.hwpf.model.NilPICFAndBinData;
import org.apache.poi.hwpf.model.StyleSheet; import org.apache.poi.hwpf.model.StyleSheet;
import org.apache.poi.hwpf.sprm.SprmBuffer; import org.apache.poi.hwpf.sprm.SprmBuffer;
import org.apache.poi.util.Removal;
/** /**
* This class represents a run of text that share common properties. * This class represents a run of text that share common properties.
*/ */
public final class CharacterRun extends Range public final class CharacterRun extends Range implements Duplicatable, org.apache.poi.wp.usermodel.CharacterRun {
implements Cloneable, org.apache.poi.wp.usermodel.CharacterRun public static final short SPRM_FRMARKDEL = (short)0x0800;
{ public static final short SPRM_FRMARK = 0x0801;
public final static short SPRM_FRMARKDEL = (short)0x0800; public static final short SPRM_FFLDVANISH = 0x0802;
public final static short SPRM_FRMARK = 0x0801; public static final short SPRM_PICLOCATION = 0x6A03;
public final static short SPRM_FFLDVANISH = 0x0802; public static final short SPRM_IBSTRMARK = 0x4804;
public final static short SPRM_PICLOCATION = 0x6A03; public static final short SPRM_DTTMRMARK = 0x6805;
public final static short SPRM_IBSTRMARK = 0x4804; public static final short SPRM_FDATA = 0x0806;
public final static short SPRM_DTTMRMARK = 0x6805; public static final short SPRM_SYMBOL = 0x6A09;
public final static short SPRM_FDATA = 0x0806; public static final short SPRM_FOLE2 = 0x080A;
public final static short SPRM_SYMBOL = 0x6A09; public static final short SPRM_HIGHLIGHT = 0x2A0C;
public final static short SPRM_FOLE2 = 0x080A; public static final short SPRM_OBJLOCATION = 0x680E;
public final static short SPRM_HIGHLIGHT = 0x2A0C; public static final short SPRM_ISTD = 0x4A30;
public final static short SPRM_OBJLOCATION = 0x680E; public static final short SPRM_FBOLD = 0x0835;
public final static short SPRM_ISTD = 0x4A30; public static final short SPRM_FITALIC = 0x0836;
public final static short SPRM_FBOLD = 0x0835; public static final short SPRM_FSTRIKE = 0x0837;
public final static short SPRM_FITALIC = 0x0836; public static final short SPRM_FOUTLINE = 0x0838;
public final static short SPRM_FSTRIKE = 0x0837; public static final short SPRM_FSHADOW = 0x0839;
public final static short SPRM_FOUTLINE = 0x0838; public static final short SPRM_FSMALLCAPS = 0x083A;
public final static short SPRM_FSHADOW = 0x0839; public static final short SPRM_FCAPS = 0x083B;
public final static short SPRM_FSMALLCAPS = 0x083A; public static final short SPRM_FVANISH = 0x083C;
public final static short SPRM_FCAPS = 0x083B; public static final short SPRM_KUL = 0x2A3E;
public final static short SPRM_FVANISH = 0x083C; public static final short SPRM_DXASPACE = (short)0x8840;
public final static short SPRM_KUL = 0x2A3E; public static final short SPRM_LID = 0x4A41;
public final static short SPRM_DXASPACE = (short)0x8840; public static final short SPRM_ICO = 0x2A42;
public final static short SPRM_LID = 0x4A41; public static final short SPRM_HPS = 0x4A43;
public final static short SPRM_ICO = 0x2A42; public static final short SPRM_HPSPOS = 0x4845;
public final static short SPRM_HPS = 0x4A43; public static final short SPRM_ISS = 0x2A48;
public final static short SPRM_HPSPOS = 0x4845; public static final short SPRM_HPSKERN = 0x484B;
public final static short SPRM_ISS = 0x2A48; public static final short SPRM_YSRI = 0x484E;
public final static short SPRM_HPSKERN = 0x484B; public static final short SPRM_RGFTCASCII = 0x4A4F;
public final static short SPRM_YSRI = 0x484E; public static final short SPRM_RGFTCFAREAST = 0x4A50;
public final static short SPRM_RGFTCASCII = 0x4A4F; public static final short SPRM_RGFTCNOTFAREAST = 0x4A51;
public final static short SPRM_RGFTCFAREAST = 0x4A50; public static final short SPRM_CHARSCALE = 0x4852;
public final static short SPRM_RGFTCNOTFAREAST = 0x4A51; public static final short SPRM_FDSTRIKE = 0x2A53;
public final static short SPRM_CHARSCALE = 0x4852; public static final short SPRM_FIMPRINT = 0x0854;
public final static short SPRM_FDSTRIKE = 0x2A53; public static final short SPRM_FSPEC = 0x0855;
public final static short SPRM_FIMPRINT = 0x0854; public static final short SPRM_FOBJ = 0x0856;
public final static short SPRM_FSPEC = 0x0855; public static final short SPRM_PROPRMARK = (short)0xCA57;
public final static short SPRM_FOBJ = 0x0856; public static final short SPRM_FEMBOSS = 0x0858;
public final static short SPRM_PROPRMARK = (short)0xCA57; public static final short SPRM_SFXTEXT = 0x2859;
public final static short SPRM_FEMBOSS = 0x0858; public static final short SPRM_DISPFLDRMARK = (short)0xCA62;
public final static short SPRM_SFXTEXT = 0x2859; public static final short SPRM_IBSTRMARKDEL = 0x4863;
public final static short SPRM_DISPFLDRMARK = (short)0xCA62; public static final short SPRM_DTTMRMARKDEL = 0x6864;
public final static short SPRM_IBSTRMARKDEL = 0x4863; public static final short SPRM_BRC = 0x6865;
public final static short SPRM_DTTMRMARKDEL = 0x6864; public static final short SPRM_SHD = 0x4866;
public final static short SPRM_BRC = 0x6865; public static final short SPRM_IDSIRMARKDEL = 0x4867;
public final static short SPRM_SHD = 0x4866; public static final short SPRM_CPG = 0x486B;
public final static short SPRM_IDSIRMARKDEL = 0x4867; public static final short SPRM_NONFELID = 0x486D;
public final static short SPRM_CPG = 0x486B; public static final short SPRM_FELID = 0x486E;
public final static short SPRM_NONFELID = 0x486D; public static final short SPRM_IDCTHINT = 0x286F;
public final static short SPRM_FELID = 0x486E;
public final static short SPRM_IDCTHINT = 0x286F;
protected short _istd; protected short _istd;
protected SprmBuffer _chpx; protected SprmBuffer _chpx;
@ -102,6 +102,13 @@ public final class CharacterRun extends Range
_istd = istd; _istd = istd;
} }
CharacterRun(CharacterRun other) {
super(other);
_istd = other._istd;
_chpx = (other._chpx == null) ? null : other._chpx.copy();
_props = (other._props == null) ? null : other._props.copy();
}
/** /**
* Here for runtime type determination using a switch statement convenient. * Here for runtime type determination using a switch statement convenient.
* *
@ -551,21 +558,18 @@ public final class CharacterRun extends Range
* Used to create a deep copy of this object. * Used to create a deep copy of this object.
* *
* @return A deep copy. * @return A deep copy.
* @throws CloneNotSupportedException never
*/ */
public Object clone() @Override
throws CloneNotSupportedException @SuppressWarnings("squid:S2975")
{ @Deprecated
CharacterRun cp = (CharacterRun)super.clone(); @Removal(version = "5.0.0")
cp._props.setDttmRMark((DateAndTime)_props.getDttmRMark().clone()); public CharacterRun clone() {
cp._props.setDttmRMarkDel((DateAndTime)_props.getDttmRMarkDel().clone()); return copy();
cp._props.setDttmPropRMark((DateAndTime)_props.getDttmPropRMark().clone()); }
cp._props.setDttmDispFldRMark((DateAndTime)_props.getDttmDispFldRMark().
clone());
cp._props.setXstDispFldRMark(_props.getXstDispFldRMark().clone());
cp._props.setShd(_props.getShd().clone());
return cp; @Override
public CharacterRun copy() {
return new CharacterRun(this);
} }
/** /**

View File

@ -19,35 +19,36 @@ package org.apache.poi.hwpf.usermodel;
import java.util.Calendar; import java.util.Calendar;
import org.apache.poi.common.Duplicatable;
import org.apache.poi.util.BitField; import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory; import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.LocaleUtil; import org.apache.poi.util.LocaleUtil;
import org.apache.poi.util.Removal;
/** /**
* This class is used to represent a date and time in a Word document. * This class is used to represent a date and time in a Word document.
*
* @author Ryan Ackley
*/ */
public final class DateAndTime public final class DateAndTime implements Duplicatable {
implements Cloneable
{
public static final int SIZE = 4; public static final int SIZE = 4;
private short _info;
private static final BitField _minutes = BitFieldFactory.getInstance(0x3f); private static final BitField _minutes = BitFieldFactory.getInstance(0x3f);
private static final BitField _hours = BitFieldFactory.getInstance(0x7c0); private static final BitField _hours = BitFieldFactory.getInstance(0x7c0);
private static final BitField _dom = BitFieldFactory.getInstance(0xf800); private static final BitField _dom = BitFieldFactory.getInstance(0xf800);
private short _info2;
private static final BitField _months = BitFieldFactory.getInstance(0xf); private static final BitField _months = BitFieldFactory.getInstance(0xf);
private static final BitField _years = BitFieldFactory.getInstance(0x1ff0); private static final BitField _years = BitFieldFactory.getInstance(0x1ff0);
// private static final BitField _weekday = BitFieldFactory.getInstance(0xe000); // private static final BitField _weekday = BitFieldFactory.getInstance(0xe000);
public DateAndTime() private short _info;
{ private short _info2;
public DateAndTime() {}
public DateAndTime(DateAndTime other) {
_info = other._info;
_info2 = other._info2;
} }
public DateAndTime(byte[] buf, int offset) public DateAndTime(byte[] buf, int offset) {
{
_info = LittleEndian.getShort(buf, offset); _info = LittleEndian.getShort(buf, offset);
_info2 = LittleEndian.getShort(buf, offset + LittleEndian.SHORT_SIZE); _info2 = LittleEndian.getShort(buf, offset + LittleEndian.SHORT_SIZE);
} }
@ -84,10 +85,17 @@ public final class DateAndTime
return 42; // any arbitrary constant will do return 42; // any arbitrary constant will do
} }
public Object clone() @Override
throws CloneNotSupportedException @SuppressWarnings("squid:S2975")
{ @Deprecated
return super.clone(); @Removal(version = "5.0.0")
public DateAndTime clone() {
return copy();
}
@Override
public DateAndTime copy() {
return new DateAndTime(this);
} }
public boolean isEmpty() public boolean isEmpty()

View File

@ -17,42 +17,50 @@
package org.apache.poi.hwpf.usermodel; package org.apache.poi.hwpf.usermodel;
import org.apache.poi.common.Duplicatable;
import org.apache.poi.util.BitField; import org.apache.poi.util.BitField;
import org.apache.poi.util.BitFieldFactory; import org.apache.poi.util.BitFieldFactory;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.Removal;
/** /**
* This data structure is used by a paragraph to determine how it should drop * This data structure is used by a paragraph to determine how it should drop
* its first letter. I think its the visual effect that will show a giant first * its first letter. I think its the visual effect that will show a giant first
* letter to a paragraph. I've seen this used in the first paragraph of a book * letter to a paragraph. I've seen this used in the first paragraph of a book
*
* @author Ryan Ackley
*/ */
public final class DropCapSpecifier implements Cloneable public final class DropCapSpecifier implements Duplicatable {
{ private static final BitField _lines = BitFieldFactory.getInstance( 0xf8 );
private short _fdct; private static final BitField _type = BitFieldFactory.getInstance( 0x07 );
private static BitField _lines = BitFieldFactory.getInstance( 0xf8 );
private static BitField _type = BitFieldFactory.getInstance( 0x07 );
public DropCapSpecifier() private short _fdct;
{
this._fdct = 0; public DropCapSpecifier() {
_fdct = 0;
} }
public DropCapSpecifier( byte[] buf, int offset ) public DropCapSpecifier(DropCapSpecifier other) {
{ _fdct = other._fdct;
}
public DropCapSpecifier( byte[] buf, int offset ) {
this( LittleEndian.getShort( buf, offset ) ); this( LittleEndian.getShort( buf, offset ) );
} }
public DropCapSpecifier( short fdct ) public DropCapSpecifier( short fdct ) {
{
this._fdct = fdct; this._fdct = fdct;
} }
@Override @Override
public DropCapSpecifier clone() @SuppressWarnings("squid:S2975")
{ @Deprecated
return new DropCapSpecifier( _fdct ); @Removal(version = "5.0.0")
public DropCapSpecifier clone() {
return copy();
}
@Override
public DropCapSpecifier copy() {
return new DropCapSpecifier(this);
} }
@Override @Override

View File

@ -17,36 +17,44 @@
package org.apache.poi.hwpf.usermodel; package org.apache.poi.hwpf.usermodel;
import org.apache.poi.common.Duplicatable;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.Removal;
/** /**
* This class is used to determine line spacing for a paragraph. * This class is used to determine line spacing for a paragraph.
*
* @author Ryan Ackley
*/ */
public final class LineSpacingDescriptor public final class LineSpacingDescriptor implements Duplicatable {
implements Cloneable
{
short _dyaLine; short _dyaLine;
short _fMultiLinespace; short _fMultiLinespace;
public LineSpacingDescriptor() public LineSpacingDescriptor() {
{
//see page 181
_dyaLine = 240; _dyaLine = 240;
_fMultiLinespace = 1; _fMultiLinespace = 1;
} }
public LineSpacingDescriptor(byte[] buf, int offset) public LineSpacingDescriptor(LineSpacingDescriptor other) {
{ _dyaLine = other._dyaLine;
_fMultiLinespace = other._fMultiLinespace;
}
public LineSpacingDescriptor(byte[] buf, int offset) {
_dyaLine = LittleEndian.getShort(buf, offset); _dyaLine = LittleEndian.getShort(buf, offset);
_fMultiLinespace = LittleEndian.getShort(buf, offset + LittleEndian.SHORT_SIZE); _fMultiLinespace = LittleEndian.getShort(buf, offset + LittleEndian.SHORT_SIZE);
} }
public Object clone() @Override
throws CloneNotSupportedException @SuppressWarnings("squid:S2975")
{ @Deprecated
return super.clone(); @Removal(version = "5.0.0")
public LineSpacingDescriptor clone() {
return copy();
}
@Override
public LineSpacingDescriptor copy() {
return new LineSpacingDescriptor(this);
} }
public void setMultiLinespace(short fMultiLinespace) public void setMultiLinespace(short fMultiLinespace)

View File

@ -19,6 +19,7 @@ package org.apache.poi.hwpf.usermodel;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import org.apache.poi.common.Duplicatable;
import org.apache.poi.hwpf.HWPFDocumentCore; import org.apache.poi.hwpf.HWPFDocumentCore;
import org.apache.poi.hwpf.model.LFO; import org.apache.poi.hwpf.model.LFO;
import org.apache.poi.hwpf.model.ListLevel; import org.apache.poi.hwpf.model.ListLevel;
@ -31,67 +32,68 @@ import org.apache.poi.hwpf.sprm.TableSprmCompressor;
import org.apache.poi.util.Internal; import org.apache.poi.util.Internal;
import org.apache.poi.util.POILogFactory; import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger; import org.apache.poi.util.POILogger;
import org.apache.poi.util.Removal;
public class Paragraph extends Range implements Cloneable { public class Paragraph extends Range implements Duplicatable {
private final static POILogger log = POILogFactory.getLogger( Paragraph.class ); private static final POILogger log = POILogFactory.getLogger( Paragraph.class );
public final static short SPRM_JC = 0x2403; public static final short SPRM_JC = 0x2403;
public final static short SPRM_FSIDEBYSIDE = 0x2404; public static final short SPRM_FSIDEBYSIDE = 0x2404;
public final static short SPRM_FKEEP = 0x2405; public static final short SPRM_FKEEP = 0x2405;
public final static short SPRM_FKEEPFOLLOW = 0x2406; public static final short SPRM_FKEEPFOLLOW = 0x2406;
public final static short SPRM_FPAGEBREAKBEFORE = 0x2407; public static final short SPRM_FPAGEBREAKBEFORE = 0x2407;
public final static short SPRM_BRCL = 0x2408; public static final short SPRM_BRCL = 0x2408;
public final static short SPRM_BRCP = 0x2409; public static final short SPRM_BRCP = 0x2409;
public final static short SPRM_ILVL = 0x260A; public static final short SPRM_ILVL = 0x260A;
public final static short SPRM_ILFO = 0x460B; public static final short SPRM_ILFO = 0x460B;
public final static short SPRM_FNOLINENUMB = 0x240C; public static final short SPRM_FNOLINENUMB = 0x240C;
public final static short SPRM_CHGTABSPAPX = (short)0xC60D; public static final short SPRM_CHGTABSPAPX = (short)0xC60D;
public final static short SPRM_DXARIGHT = (short)0x840E; public static final short SPRM_DXARIGHT = (short)0x840E;
public final static short SPRM_DXALEFT = (short)0x840F; public static final short SPRM_DXALEFT = (short)0x840F;
public final static short SPRM_DXALEFT1 = (short)0x8411; public static final short SPRM_DXALEFT1 = (short)0x8411;
public final static short SPRM_DYALINE = 0x6412; public static final short SPRM_DYALINE = 0x6412;
public final static short SPRM_DYABEFORE = (short)0xA413; public static final short SPRM_DYABEFORE = (short)0xA413;
public final static short SPRM_DYAAFTER = (short)0xA414; public static final short SPRM_DYAAFTER = (short)0xA414;
public final static short SPRM_CHGTABS = (short)0xC615; public static final short SPRM_CHGTABS = (short)0xC615;
public final static short SPRM_FINTABLE = 0x2416; public static final short SPRM_FINTABLE = 0x2416;
public final static short SPRM_FTTP = 0x2417; public static final short SPRM_FTTP = 0x2417;
public final static short SPRM_DXAABS = (short)0x8418; public static final short SPRM_DXAABS = (short)0x8418;
public final static short SPRM_DYAABS = (short)0x8419; public static final short SPRM_DYAABS = (short)0x8419;
public final static short SPRM_DXAWIDTH = (short)0x841A; public static final short SPRM_DXAWIDTH = (short)0x841A;
public final static short SPRM_PC = 0x261B; public static final short SPRM_PC = 0x261B;
public final static short SPRM_WR = 0x2423; public static final short SPRM_WR = 0x2423;
public final static short SPRM_BRCTOP = 0x6424; public static final short SPRM_BRCTOP = 0x6424;
public final static short SPRM_BRCLEFT = 0x6425; public static final short SPRM_BRCLEFT = 0x6425;
public final static short SPRM_BRCBOTTOM = 0x6426; public static final short SPRM_BRCBOTTOM = 0x6426;
public final static short SPRM_BRCRIGHT = 0x6427; public static final short SPRM_BRCRIGHT = 0x6427;
public final static short SPRM_BRCBAR = 0x6629; public static final short SPRM_BRCBAR = 0x6629;
public final static short SPRM_FNOAUTOHYPH = 0x242A; public static final short SPRM_FNOAUTOHYPH = 0x242A;
public final static short SPRM_WHEIGHTABS = 0x442B; public static final short SPRM_WHEIGHTABS = 0x442B;
public final static short SPRM_DCS = 0x442C; public static final short SPRM_DCS = 0x442C;
public final static short SPRM_SHD80 = 0x442D; public static final short SPRM_SHD80 = 0x442D;
public final static short SPRM_SHD = (short)0xC64D; public static final short SPRM_SHD = (short)0xC64D;
public final static short SPRM_DYAFROMTEXT = (short)0x842E; public static final short SPRM_DYAFROMTEXT = (short)0x842E;
public final static short SPRM_DXAFROMTEXT = (short)0x842F; public static final short SPRM_DXAFROMTEXT = (short)0x842F;
public final static short SPRM_FLOCKED = 0x2430; public static final short SPRM_FLOCKED = 0x2430;
public final static short SPRM_FWIDOWCONTROL = 0x2431; public static final short SPRM_FWIDOWCONTROL = 0x2431;
public final static short SPRM_RULER = (short)0xC632; public static final short SPRM_RULER = (short)0xC632;
public final static short SPRM_FKINSOKU = 0x2433; public static final short SPRM_FKINSOKU = 0x2433;
public final static short SPRM_FWORDWRAP = 0x2434; public static final short SPRM_FWORDWRAP = 0x2434;
public final static short SPRM_FOVERFLOWPUNCT = 0x2435; public static final short SPRM_FOVERFLOWPUNCT = 0x2435;
public final static short SPRM_FTOPLINEPUNCT = 0x2436; public static final short SPRM_FTOPLINEPUNCT = 0x2436;
public final static short SPRM_AUTOSPACEDE = 0x2437; public static final short SPRM_AUTOSPACEDE = 0x2437;
public final static short SPRM_AUTOSPACEDN = 0x2438; public static final short SPRM_AUTOSPACEDN = 0x2438;
public final static short SPRM_WALIGNFONT = 0x4439; public static final short SPRM_WALIGNFONT = 0x4439;
public final static short SPRM_FRAMETEXTFLOW = 0x443A; public static final short SPRM_FRAMETEXTFLOW = 0x443A;
public final static short SPRM_ANLD = (short)0xC63E; public static final short SPRM_ANLD = (short)0xC63E;
public final static short SPRM_PROPRMARK = (short)0xC63F; public static final short SPRM_PROPRMARK = (short)0xC63F;
public final static short SPRM_OUTLVL = 0x2640; public static final short SPRM_OUTLVL = 0x2640;
public final static short SPRM_FBIDI = 0x2441; public static final short SPRM_FBIDI = 0x2441;
public final static short SPRM_FNUMRMLNS = 0x2443; public static final short SPRM_FNUMRMLNS = 0x2443;
public final static short SPRM_CRLF = 0x2444; public static final short SPRM_CRLF = 0x2444;
public final static short SPRM_NUMRM = (short)0xC645; public static final short SPRM_NUMRM = (short)0xC645;
public final static short SPRM_USEPGSUSETTINGS = 0x2447; public static final short SPRM_USEPGSUSETTINGS = 0x2447;
public final static short SPRM_FADJUSTRIGHT = 0x2448; public static final short SPRM_FADJUSTRIGHT = 0x2448;
@Internal @Internal
public static Paragraph newParagraph( Range parent, PAPX papx ) public static Paragraph newParagraph( Range parent, PAPX papx )
@ -169,6 +171,13 @@ public class Paragraph extends Range implements Cloneable {
_istd = papx.getIstd(); _istd = papx.getIstd();
} }
Paragraph(Paragraph other) {
super(other);
_istd = other._istd;
_props = (other._props == null) ? null : other._props.copy();
_papx = (other._papx == null) ? null : other._papx.copy();
}
/** /**
* Returns the index of the style which applies to this * Returns the index of the style which applies to this
* Paragraph. Details of the style can be looked up * Paragraph. Details of the style can be looked up
@ -580,20 +589,20 @@ public class Paragraph extends Range implements Cloneable {
* another Paragraph. * another Paragraph.
*/ */
public ParagraphProperties cloneProperties() { public ParagraphProperties cloneProperties() {
try { return _props.copy();
return (ParagraphProperties)_props.clone();
} catch (Exception e) {
throw new RuntimeException(e);
}
} }
public Object clone() throws CloneNotSupportedException @Override
{ @SuppressWarnings("squid:S2975")
Paragraph p = (Paragraph)super.clone(); @Deprecated
p._props = (ParagraphProperties)_props.clone(); @Removal(version = "5.0.0")
//p._baseStyle = _baseStyle; public Paragraph clone() {
p._papx = new SprmBuffer(0); return copy();
return p; }
@Override
public Paragraph copy() {
return new Paragraph(this);
} }
private short getFrameTextFlow() private short getFrameTextFlow()

View File

@ -17,35 +17,36 @@
package org.apache.poi.hwpf.usermodel; package org.apache.poi.hwpf.usermodel;
import org.apache.poi.common.Duplicatable;
import org.apache.poi.hwpf.model.types.PAPAbstractType; import org.apache.poi.hwpf.model.types.PAPAbstractType;
import org.apache.poi.util.Removal;
public final class ParagraphProperties extends PAPAbstractType implements @SuppressWarnings("unused")
Cloneable public final class ParagraphProperties extends PAPAbstractType implements Duplicatable {
{
private boolean jcLogical; private boolean jcLogical;
public ParagraphProperties() public ParagraphProperties() {
{ setAnld(new byte[84]);
setAnld( new byte[84] ); setPhe(new byte[12]);
setPhe( new byte[12] );
} }
public Object clone() throws CloneNotSupportedException public ParagraphProperties(ParagraphProperties other) {
{ super(other);
ParagraphProperties pp = (ParagraphProperties) super.clone(); jcLogical = other.jcLogical;
pp.setAnld( getAnld().clone() ); }
pp.setBrcTop( (BorderCode) getBrcTop().clone() );
pp.setBrcLeft( (BorderCode) getBrcLeft().clone() ); @Override
pp.setBrcBottom( (BorderCode) getBrcBottom().clone() ); @SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"})
pp.setBrcRight( (BorderCode) getBrcRight().clone() ); @Deprecated
pp.setBrcBetween( (BorderCode) getBrcBetween().clone() ); @Removal(version = "5.0.0")
pp.setBrcBar( (BorderCode) getBrcBar().clone() ); public ParagraphProperties clone() {
pp.setDcs( getDcs().clone() ); return copy();
pp.setLspd( (LineSpacingDescriptor) getLspd().clone() ); }
pp.setShd( getShd().clone() );
pp.setPhe( getPhe().clone() ); @Override
return pp; public ParagraphProperties copy() {
return new ParagraphProperties(this);
} }
public BorderCode getBarBorder() public BorderCode getBarBorder()
@ -332,3 +333,4 @@ public final class ParagraphProperties extends PAPAbstractType implements
} }
} }

View File

@ -17,6 +17,8 @@
package org.apache.poi.hwpf.usermodel; package org.apache.poi.hwpf.usermodel;
import static java.util.stream.Collectors.toList;
import java.util.List; import java.util.List;
import org.apache.poi.hwpf.HWPFDocument; import org.apache.poi.hwpf.HWPFDocument;
@ -47,12 +49,10 @@ import org.apache.poi.util.POILogger;
* Ranges are only valid if there hasn't been an insert in a prior Range since * Ranges are only valid if there hasn't been an insert in a prior Range since
* the Range's creation. Once an element (text, paragraph, etc.) has been * the Range's creation. Once an element (text, paragraph, etc.) has been
* inserted into a Range, subsequent Ranges become unstable. * inserted into a Range, subsequent Ranges become unstable.
*
* @author Ryan Ackley
*/ */
public class Range { // TODO -instantiable superclass public class Range {
private POILogger logger = POILogFactory.getLogger( Range.class ); private static final POILogger logger = POILogFactory.getLogger( Range.class );
/** /**
* @deprecated POI 3.8 beta 5 * @deprecated POI 3.8 beta 5
@ -151,12 +151,9 @@ public class Range { // TODO -instantiable superclass
* create a Range that spans the whole document, or at least one whole part * create a Range that spans the whole document, or at least one whole part
* of the document (eg main text, header, comment) * of the document (eg main text, header, comment)
* *
* @param start * @param start Starting character offset of the range.
* Starting character offset of the range. * @param end Ending character offset of the range.
* @param end * @param doc The HWPFDocument the range is based on.
* Ending character offset of the range.
* @param doc
* The HWPFDocument the range is based on.
*/ */
public Range(int start, int end, HWPFDocumentCore doc) { public Range(int start, int end, HWPFDocumentCore doc) {
_start = start; _start = start;
@ -174,12 +171,9 @@ public class Range { // TODO -instantiable superclass
/** /**
* Used to create Ranges that are children of other Ranges. * Used to create Ranges that are children of other Ranges.
* *
* @param start * @param start Starting character offset of the range.
* Starting character offset of the range. * @param end Ending character offset of the range.
* @param end * @param parent The parent this range belongs to.
* Ending character offset of the range.
* @param parent
* The parent this range belongs to.
*/ */
protected Range(int start, int end, Range parent) { protected Range(int start, int end, Range parent) {
_start = start; _start = start;
@ -195,6 +189,26 @@ public class Range { // TODO -instantiable superclass
sanityCheck(); sanityCheck();
} }
protected Range(Range other) {
_parent = other._parent;
_start = other._start;
_end = other._end;
_doc = other._doc;
_sectionRangeFound = other._sectionRangeFound;
_sections = (other._sections == null) ? null : other._sections.stream().map(SEPX::copy).collect(toList());
_sectionStart = other._sectionStart;
_sectionEnd = other._sectionEnd;
_parRangeFound = other._parRangeFound;
_paragraphs = (other._paragraphs == null) ? null : other._paragraphs.stream().map(PAPX::copy).collect(toList());
_parStart = other._parStart;
_parEnd = other._parEnd;
_charRangeFound = other._charRangeFound;
_characters = (other._characters == null) ? null : other._characters.stream().map(CHPX::copy).collect(toList());
_charStart = other._charStart;
_charEnd = other._charEnd;
_text = (other._text == null) ? null : new StringBuilder(other._text);
}
/** /**
* Ensures that the start and end were were given are actually valid, to * Ensures that the start and end were were given are actually valid, to

View File

@ -17,17 +17,21 @@
package org.apache.poi.hwpf.usermodel; package org.apache.poi.hwpf.usermodel;
import org.apache.poi.common.Duplicatable;
import org.apache.poi.hwpf.HWPFOldDocument; import org.apache.poi.hwpf.HWPFOldDocument;
import org.apache.poi.hwpf.model.SEPX; import org.apache.poi.hwpf.model.SEPX;
import org.apache.poi.util.Removal;
public final class Section extends Range public final class Section extends Range implements Duplicatable {
{ private final SectionProperties _props;
private SectionProperties _props;
public Section( SEPX sepx, Range parent ) public Section(Section other) {
{ super(other);
super( Math.max( parent._start, sepx.getStart() ), Math.min( _props = other._props.copy();
parent._end, sepx.getEnd() ), parent ); }
public Section( SEPX sepx, Range parent ) {
super( Math.max( parent._start, sepx.getStart() ), Math.min(parent._end, sepx.getEnd() ), parent );
// XXX: temporary workaround for old Word95 document // XXX: temporary workaround for old Word95 document
if ( parent.getDocument() instanceof HWPFOldDocument ) if ( parent.getDocument() instanceof HWPFOldDocument )
@ -36,11 +40,17 @@ public final class Section extends Range
_props = sepx.getSectionProperties(); _props = sepx.getSectionProperties();
} }
public Object clone() throws CloneNotSupportedException @Override
{ @SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"})
Section s = (Section) super.clone(); @Deprecated
s._props = (SectionProperties) _props.clone(); @Removal(version = "5.0.0")
return s; public Section clone() {
return copy();
}
@Override
public Section copy() {
return new Section(this);
} }
/** /**

View File

@ -17,20 +17,22 @@
package org.apache.poi.hwpf.usermodel; package org.apache.poi.hwpf.usermodel;
import org.apache.poi.common.Duplicatable;
import org.apache.poi.hwpf.model.types.SEPAbstractType; import org.apache.poi.hwpf.model.types.SEPAbstractType;
import org.apache.poi.util.Removal;
public final class SectionProperties extends SEPAbstractType implements Cloneable public final class SectionProperties extends SEPAbstractType implements Duplicatable {
{
private short field_60_rncftn; private short field_60_rncftn;
private short field_61_rncedn; private short field_61_rncedn;
private int field_62_nftn; private int field_62_nftn;
// initialize with default value; msonfcArabic
@SuppressWarnings("RedundantFieldInitialization") @SuppressWarnings("RedundantFieldInitialization")
private int field_63_nfcftnref = 0x00; // initialize with default value; msonfcArabic private int field_63_nfcftnref = 0x00;
private int field_64_nedn; private int field_64_nedn;
private int field_65_nfcednref = 0x02; // initialize with default value; msonfcLCRoman // initialize with default value; msonfcLCRoman
private int field_65_nfcednref = 0x02;
public SectionProperties() public SectionProperties() {
{
field_20_brcTop = new BorderCode(); field_20_brcTop = new BorderCode();
field_21_brcLeft = new BorderCode(); field_21_brcLeft = new BorderCode();
field_22_brcBottom = new BorderCode(); field_22_brcBottom = new BorderCode();
@ -38,18 +40,27 @@ public final class SectionProperties extends SEPAbstractType implements Cloneabl
field_26_dttmPropRMark = new DateAndTime(); field_26_dttmPropRMark = new DateAndTime();
} }
@Override public SectionProperties(SectionProperties other) {
public Object clone() throws CloneNotSupportedException super(other);
{ field_60_rncftn = other.field_60_rncftn;
SectionProperties copy = (SectionProperties) super.clone(); field_61_rncedn = other.field_61_rncedn;
copy.field_20_brcTop = (BorderCode) field_20_brcTop.clone(); field_62_nftn = other.field_62_nftn;
copy.field_21_brcLeft = (BorderCode) field_21_brcLeft.clone(); field_63_nfcftnref = other.field_63_nfcftnref;
copy.field_22_brcBottom = (BorderCode) field_22_brcBottom.clone(); field_64_nedn = other.field_64_nedn;
copy.field_23_brcRight = (BorderCode) field_23_brcRight.clone(); field_65_nfcednref = other.field_65_nfcednref;
copy.field_26_dttmPropRMark = (DateAndTime) field_26_dttmPropRMark }
.clone();
return copy; @Override
@SuppressWarnings("squid:S2975")
@Deprecated
@Removal(version = "5.0.0")
public SectionProperties clone() {
return copy();
}
@Override
public SectionProperties copy() {
return new SectionProperties(this);
} }
/** /**

View File

@ -17,30 +17,36 @@
package org.apache.poi.hwpf.usermodel; package org.apache.poi.hwpf.usermodel;
import org.apache.poi.common.Duplicatable;
import org.apache.poi.hwpf.model.types.SHDAbstractType; import org.apache.poi.hwpf.model.types.SHDAbstractType;
import org.apache.poi.util.Removal;
/** /**
* The SHD is a substructure of the CHP, PAP, and TC for Word 2000. * The SHD is a substructure of the CHP, PAP, and TC for Word 2000.
*
* @author vlsergey
*/ */
public final class ShadingDescriptor extends SHDAbstractType implements public final class ShadingDescriptor extends SHDAbstractType implements Duplicatable {
Cloneable
{
public ShadingDescriptor() public ShadingDescriptor() {}
{
public ShadingDescriptor(ShadingDescriptor other) {
super(other);
} }
public ShadingDescriptor( byte[] buf, int offset ) public ShadingDescriptor( byte[] buf, int offset ) {
{
super();
fillFields( buf, offset ); fillFields( buf, offset );
} }
public ShadingDescriptor clone() throws CloneNotSupportedException @Override
{ @SuppressWarnings("squid:S2975")
return (ShadingDescriptor) super.clone(); @Deprecated
@Removal(version = "5.0.0")
public ShadingDescriptor clone() {
return copy();
}
@Override
public ShadingDescriptor copy() {
return new ShadingDescriptor(this);
} }
public boolean isEmpty() public boolean isEmpty()

View File

@ -17,36 +17,42 @@
package org.apache.poi.hwpf.usermodel; package org.apache.poi.hwpf.usermodel;
import org.apache.poi.common.Duplicatable;
import org.apache.poi.hwpf.model.Colorref; import org.apache.poi.hwpf.model.Colorref;
import org.apache.poi.hwpf.model.types.SHD80AbstractType; import org.apache.poi.hwpf.model.types.SHD80AbstractType;
import org.apache.poi.util.Removal;
/** /**
* The SHD80 is a substructure of the CHP and PAP, and TC for Word 97. * The SHD80 is a substructure of the CHP and PAP, and TC for Word 97.
*/ */
public final class ShadingDescriptor80 extends SHD80AbstractType implements @SuppressWarnings("unused")
Cloneable public final class ShadingDescriptor80 extends SHD80AbstractType implements Duplicatable {
{
public ShadingDescriptor80() public ShadingDescriptor80() {}
{
public ShadingDescriptor80(ShadingDescriptor80 other) {
super(other);
} }
public ShadingDescriptor80( byte[] buf, int offset ) public ShadingDescriptor80( byte[] buf, int offset ) {
{
super();
fillFields( buf, offset ); fillFields( buf, offset );
} }
public ShadingDescriptor80( short value ) public ShadingDescriptor80( short value ) {
{
super();
field_1_value = value; field_1_value = value;
} }
public ShadingDescriptor80 clone() throws CloneNotSupportedException @Override
{ @SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"})
return (ShadingDescriptor80) super.clone(); @Deprecated
@Removal(version = "5.0.0")
public ShadingDescriptor80 clone() {
return copy();
}
@Override
public ShadingDescriptor80 copy() {
return new ShadingDescriptor80(this);
} }
public boolean isEmpty() public boolean isEmpty()

View File

@ -18,35 +18,34 @@ package org.apache.poi.hwpf.usermodel;
import java.util.Objects; import java.util.Objects;
import org.apache.poi.common.Duplicatable;
import org.apache.poi.hwpf.model.types.TLPAbstractType; import org.apache.poi.hwpf.model.types.TLPAbstractType;
import org.apache.poi.util.Removal;
public class TableAutoformatLookSpecifier extends TLPAbstractType implements public class TableAutoformatLookSpecifier extends TLPAbstractType implements Duplicatable {
Cloneable
{
public static final int SIZE = 4; public static final int SIZE = 4;
public TableAutoformatLookSpecifier() public TableAutoformatLookSpecifier() {}
{
super(); public TableAutoformatLookSpecifier(TableAutoformatLookSpecifier other) {
super(other);
} }
public TableAutoformatLookSpecifier( byte[] data, int offset ) public TableAutoformatLookSpecifier( byte[] data, int offset ) {
{
super();
fillFields( data, offset ); fillFields( data, offset );
} }
@Override @Override
public TableAutoformatLookSpecifier clone() @SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"})
{ @Deprecated
try @Removal(version = "5.0.0")
{ public TableAutoformatLookSpecifier clone() {
return (TableAutoformatLookSpecifier) super.clone(); return copy();
}
catch ( CloneNotSupportedException e )
{
throw new Error( e.getMessage(), e );
} }
@Override
public TableAutoformatLookSpecifier copy() {
return new TableAutoformatLookSpecifier(this);
} }
@Override @Override

View File

@ -17,16 +17,18 @@
package org.apache.poi.hwpf.usermodel; package org.apache.poi.hwpf.usermodel;
import org.apache.poi.common.Duplicatable;
import org.apache.poi.hwpf.model.types.TCAbstractType; import org.apache.poi.hwpf.model.types.TCAbstractType;
import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndian;
import org.apache.poi.util.Removal;
public final class TableCellDescriptor extends TCAbstractType implements public final class TableCellDescriptor extends TCAbstractType implements Duplicatable {
Cloneable
{
public static final int SIZE = 20; public static final int SIZE = 20;
public TableCellDescriptor() public TableCellDescriptor() {}
{
public TableCellDescriptor(TableCellDescriptor other) {
super(other);
} }
protected void fillFields(byte[] data, int offset) protected void fillFields(byte[] data, int offset)
@ -49,16 +51,17 @@ public final class TableCellDescriptor extends TCAbstractType implements
getBrcRight().serialize(data, 0x10 + offset); getBrcRight().serialize(data, 0x10 + offset);
} }
public Object clone() @Override
throws CloneNotSupportedException @SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"})
{ @Deprecated
TableCellDescriptor tc = (TableCellDescriptor)super.clone(); @Removal(version = "5.0.0")
tc.setShd( getShd().clone() ); public TableCellDescriptor clone() {
tc.setBrcTop((BorderCode)getBrcTop().clone()); return copy();
tc.setBrcLeft((BorderCode)getBrcLeft().clone()); }
tc.setBrcBottom((BorderCode)getBrcBottom().clone());
tc.setBrcRight((BorderCode)getBrcRight().clone()); @Override
return tc; public TableCellDescriptor copy() {
return new TableCellDescriptor(this);
} }
public static TableCellDescriptor convertBytesToTC(byte[] buf, int offset) public static TableCellDescriptor convertBytesToTC(byte[] buf, int offset)

View File

@ -17,33 +17,34 @@
package org.apache.poi.hwpf.usermodel; package org.apache.poi.hwpf.usermodel;
import org.apache.poi.common.Duplicatable;
import org.apache.poi.hwpf.model.types.TAPAbstractType; import org.apache.poi.hwpf.model.types.TAPAbstractType;
import org.apache.poi.util.Removal;
public final class TableProperties extends TAPAbstractType implements Cloneable public final class TableProperties extends TAPAbstractType implements Duplicatable {
{
public TableProperties() public TableProperties() {
{ setTlp(new TableAutoformatLookSpecifier());
setTlp( new TableAutoformatLookSpecifier() ); setShdTable(new ShadingDescriptor());
setShdTable( new ShadingDescriptor() ); setBrcBottom(new BorderCode());
setBrcBottom( new BorderCode() ); setBrcHorizontal(new BorderCode());
setBrcHorizontal( new BorderCode() ); setBrcLeft(new BorderCode());
setBrcLeft( new BorderCode() ); setBrcRight(new BorderCode());
setBrcRight( new BorderCode() ); setBrcTop(new BorderCode());
setBrcTop( new BorderCode() ); setBrcVertical(new BorderCode());
setBrcVertical( new BorderCode() ); setRgbrcInsideDefault_0(new BorderCode());
setRgbrcInsideDefault_0( new BorderCode() ); setRgbrcInsideDefault_1(new BorderCode());
setRgbrcInsideDefault_1( new BorderCode() ); setRgdxaCenter(new short[0]);
setRgdxaCenter( new short[0] ); setRgdxaCenterPrint(new short[0]);
setRgdxaCenterPrint( new short[0] ); setRgshd(new ShadingDescriptor[0]);
setRgshd( new ShadingDescriptor[0] ); setRgtc(new TableCellDescriptor[0]);
setRgtc( new TableCellDescriptor[0] );
} }
public TableProperties( short columns ) public TableProperties(TableProperties other) {
{ super(other);
this(); }
public TableProperties( short columns ) {
setItcMac( columns ); setItcMac( columns );
setRgshd( new ShadingDescriptor[columns] ); setRgshd( new ShadingDescriptor[columns] );
@ -63,40 +64,16 @@ public final class TableProperties extends TAPAbstractType implements Cloneable
setRgdxaCenterPrint( new short[columns] ); setRgdxaCenterPrint( new short[columns] );
} }
public Object clone() throws CloneNotSupportedException @Override
{ @SuppressWarnings({"squid:S2975", "MethodDoesntCallSuperMethod"})
TableProperties tap = (TableProperties) super.clone(); @Deprecated
@Removal(version = "5.0.0")
tap.setTlp( getTlp().clone() ); public TableProperties clone() {
tap.setRgshd( new ShadingDescriptor[getRgshd().length] ); return copy();
for ( int x = 0; x < getRgshd().length; x++ )
{
tap.getRgshd()[x] = getRgshd()[x].clone();
} }
tap.setBrcBottom( (BorderCode) getBrcBottom().clone() ); @Override
tap.setBrcHorizontal( (BorderCode) getBrcHorizontal().clone() ); public TableProperties copy() {
tap.setBrcLeft( (BorderCode) getBrcLeft().clone() ); return new TableProperties(this);
tap.setBrcRight( (BorderCode) getBrcRight().clone() );
tap.setBrcTop( (BorderCode) getBrcTop().clone() );
tap.setBrcVertical( (BorderCode) getBrcVertical().clone() );
tap.setShdTable( getShdTable().clone() );
tap.setRgbrcInsideDefault_0( (BorderCode) getRgbrcInsideDefault_0()
.clone() );
tap.setRgbrcInsideDefault_1( (BorderCode) getRgbrcInsideDefault_1()
.clone() );
tap.setRgdxaCenter( getRgdxaCenter().clone() );
tap.setRgdxaCenterPrint( getRgdxaCenterPrint().clone() );
tap.setRgtc( new TableCellDescriptor[getRgtc().length] );
for ( int x = 0; x < getRgtc().length; x++ )
{
tap.getRgtc()[x] = (TableCellDescriptor) getRgtc()[x].clone();
} }
return tap;
}
} }