From: Sergey Vladimirov Date: Tue, 5 Jul 2011 01:51:15 +0000 (+0000) Subject: add isEmpty() method to TALS and handle it by SPRM 0x740a compressor to preserve... X-Git-Tag: REL_3_8_BETA4~323 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e837dce1018e6991f4ff25478dd52990f09e0391;p=poi.git add isEmpty() method to TALS and handle it by SPRM 0x740a compressor to preserve old behavior: do not add 0x740a SPRM if TALS is empty git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1142874 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/scratchpad/src/org/apache/poi/hwpf/sprm/TableSprmCompressor.java b/src/scratchpad/src/org/apache/poi/hwpf/sprm/TableSprmCompressor.java index 31888f2e28..195fed5653 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/sprm/TableSprmCompressor.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/sprm/TableSprmCompressor.java @@ -101,7 +101,7 @@ public final class TableSprmCompressor // size += SprmUtils.addSpecialSprm((short)0xD609, buf, sprmList); } - if ( newTAP.getTlp() != null ) + if ( newTAP.getTlp() != null && !newTAP.getTlp().isEmpty() ) { byte[] buf = new byte[TableAutoformatLookSpecifier.SIZE]; newTAP.getTlp().serialize( buf, 0 ); diff --git a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableAutoformatLookSpecifier.java b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableAutoformatLookSpecifier.java index affa476693..229b92dc9f 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableAutoformatLookSpecifier.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableAutoformatLookSpecifier.java @@ -23,4 +23,36 @@ public class TableAutoformatLookSpecifier extends TLPAbstractType { return (TableAutoformatLookSpecifier) super.clone(); } + + @Override + public boolean equals( Object obj ) + { + if ( this == obj ) + return true; + if ( obj == null ) + return false; + if ( getClass() != obj.getClass() ) + return false; + TableAutoformatLookSpecifier other = (TableAutoformatLookSpecifier) obj; + if ( field_1_itl != other.field_1_itl ) + return false; + if ( field_2_tlp_flags != other.field_2_tlp_flags ) + return false; + return true; + } + + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + result = prime * result + field_1_itl; + result = prime * result + field_2_tlp_flags; + return result; + } + + public boolean isEmpty() + { + return field_1_itl == 0 && field_2_tlp_flags == 0; + } }