]> source.dussan.org Git - poi.git/commitdiff
use autogenerated LFO type definition
authorSergey Vladimirov <sergey@apache.org>
Sun, 24 Jul 2011 19:23:20 +0000 (19:23 +0000)
committerSergey Vladimirov <sergey@apache.org>
Sun, 24 Jul 2011 19:23:20 +0000 (19:23 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1150475 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hwpf/model/ListFormatOverride.java
src/scratchpad/src/org/apache/poi/hwpf/model/types/LFOAbstractType.java [new file with mode: 0644]
src/types/definitions/lfo_type.xml [new file with mode: 0644]

index bd5c123583c4b663bb5b9467d13a972d7b7949ce..0e8ed8b2215c7d9bf8c4fe1295a2e4571606034d 100644 (file)
 
 package org.apache.poi.hwpf.model;
 
-import org.apache.poi.util.LittleEndian;
+import org.apache.poi.hwpf.model.types.LFOAbstractType;
 
-import java.util.Arrays;
-
-public final class ListFormatOverride
+public final class ListFormatOverride extends LFOAbstractType
 {
-  int _lsid;
-  int _reserved1;
-  int _reserved2;
-  byte _clfolvl;
-  byte[] _reserved3 = new byte[3];
-  ListFormatOverrideLevel[] _levelOverrides;
-
-  public ListFormatOverride(int lsid)
-  {
-    _lsid = lsid;
-    _levelOverrides = new ListFormatOverrideLevel[0];
-  }
+    private ListFormatOverrideLevel[] _levelOverrides;
 
-  public ListFormatOverride(byte[] buf, int offset)
-  {
-    _lsid = LittleEndian.getInt(buf, offset);
-    offset += LittleEndian.INT_SIZE;
-    _reserved1 = LittleEndian.getInt(buf, offset);
-    offset += LittleEndian.INT_SIZE;
-    _reserved2 = LittleEndian.getInt(buf, offset);
-    offset += LittleEndian.INT_SIZE;
-    _clfolvl = buf[offset++];
-    System.arraycopy(buf, offset, _reserved3, 0, _reserved3.length);
-    _levelOverrides = new ListFormatOverrideLevel[_clfolvl];
-  }
-
-  public int numOverrides()
-  {
-    return _clfolvl;
-  }
+    public ListFormatOverride( byte[] buf, int offset )
+    {
+        fillFields( buf, offset );
 
-  public int getLsid()
-  {
-    return _lsid;
-  }
+        _levelOverrides = new ListFormatOverrideLevel[getClfolvl()];
+    }
 
-  void setLsid(int lsid)
-  {
-    _lsid = lsid;
-  }
+    public ListFormatOverride( int lsid )
+    {
+        setLsid( lsid );
+        _levelOverrides = new ListFormatOverrideLevel[0];
+    }
 
-  public ListFormatOverrideLevel[] getLevelOverrides()
-  {
-    return _levelOverrides;
-  }
+    public ListFormatOverrideLevel[] getLevelOverrides()
+    {
+        return _levelOverrides;
+    }
 
-  public void setOverride(int index, ListFormatOverrideLevel lfolvl)
-  {
-    _levelOverrides[index] = lfolvl;
-  }
+    public ListFormatOverrideLevel getOverrideLevel( int level )
+    {
 
-  public ListFormatOverrideLevel getOverrideLevel(int level)
-  {
+        ListFormatOverrideLevel retLevel = null;
 
-    ListFormatOverrideLevel retLevel = null;
+        for ( int x = 0; x < _levelOverrides.length; x++ )
+        {
+            if ( _levelOverrides[x].getLevelNum() == level )
+            {
+                retLevel = _levelOverrides[x];
+            }
+        }
+        return retLevel;
+    }
 
-    for(int x = 0; x < _levelOverrides.length; x++)
+    public int numOverrides()
     {
-      if (_levelOverrides[x].getLevelNum() == level)
-      {
-        retLevel = _levelOverrides[x];
-      }
+        return getClfolvl();
     }
-    return retLevel;
-  }
 
-  public boolean equals(Object obj)
-  {
-    if (obj == null)
+    public void setOverride( int index, ListFormatOverrideLevel lfolvl )
     {
-      return false;
+        _levelOverrides[index] = lfolvl;
     }
 
-    ListFormatOverride lfo = (ListFormatOverride)obj;
-    return lfo._clfolvl == _clfolvl && lfo._lsid == _lsid &&
-      lfo._reserved1 == _reserved1 && lfo._reserved2 == _reserved2 &&
-      Arrays.equals(lfo._reserved3, _reserved3) &&
-      Arrays.equals(lfo._levelOverrides, _levelOverrides);
-  }
-
-  public byte[] toByteArray()
-  {
-    byte[] buf = new byte[16];
-    int offset = 0;
-    LittleEndian.putInt(buf, offset, _lsid);
-    offset += LittleEndian.INT_SIZE;
-    LittleEndian.putInt(buf, offset, _reserved1);
-    offset += LittleEndian.INT_SIZE;
-    LittleEndian.putInt(buf, offset, _reserved2);
-    offset += LittleEndian.INT_SIZE;
-    buf[offset++] = _clfolvl;
-    System.arraycopy(_reserved3, 0, buf, offset, 3);
-
-    return buf;
-  }
+    public byte[] toByteArray()
+    {
+        byte[] bs = new byte[getSize()];
+        serialize( bs, 0 );
+        return bs;
+    }
 }
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/types/LFOAbstractType.java b/src/scratchpad/src/org/apache/poi/hwpf/model/types/LFOAbstractType.java
new file mode 100644 (file)
index 0000000..339be51
--- /dev/null
@@ -0,0 +1,395 @@
+/* ====================================================================\r
+   Licensed to the Apache Software Foundation (ASF) under one or more\r
+   contributor license agreements.  See the NOTICE file distributed with\r
+   this work for additional information regarding copyright ownership.\r
+   The ASF licenses this file to You under the Apache License, Version 2.0\r
+   (the "License"); you may not use this file except in compliance with\r
+   the License.  You may obtain a copy of the License at\r
+\r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+==================================================================== */\r
+package org.apache.poi.hwpf.model.types;\r
+\r
+import org.apache.poi.util.BitField;\r
+import org.apache.poi.util.LittleEndian;\r
+\r
+/**\r
+ * List Format Override (LFO).\r
+ * <p>\r
+ * Class and fields descriptions are quoted from Microsoft Office Word 97-2007\r
+ * Binary File Format\r
+ * \r
+ * NOTE: This source is automatically generated please do not modify this file.\r
+ * Either subclass or remove the record in src/types/definitions.\r
+ * \r
+ * @author Sergey Vladimirov; according to Microsoft Office Word 97-2007 Binary\r
+ *         File Format Specification [*.doc]\r
+ */\r
+public abstract class LFOAbstractType\r
+{\r
+\r
+    protected int field_1_lsid;\r
+    protected int field_2_reserved1;\r
+    protected int field_3_reserved2;\r
+    protected byte field_4_clfolvl;\r
+    protected byte field_5_ibstFltAutoNum;\r
+    protected byte field_6_grfhic;\r
+    /**/private static BitField fHtmlChecked = new BitField( 0x01 );\r
+    /**/private static BitField fHtmlUnsupported = new BitField( 0x02 );\r
+    /**/private static BitField fHtmlListTextNotSharpDot = new BitField( 0x04 );\r
+    /**/private static BitField fHtmlNotPeriod = new BitField( 0x08 );\r
+    /**/private static BitField fHtmlFirstLineMismatch = new BitField( 0x10 );\r
+    /**/private static BitField fHtmlTabLeftIndentMismatch = new BitField(\r
+            0x20 );\r
+    /**/private static BitField fHtmlHangingIndentBeneathNumber = new BitField(\r
+            0x40 );\r
+    /**/private static BitField fHtmlBuiltInBullet = new BitField( 0x80 );\r
+    protected byte field_7_reserved3;\r
+\r
+    protected LFOAbstractType()\r
+    {\r
+    }\r
+\r
+    protected void fillFields( byte[] data, int offset )\r
+    {\r
+        field_1_lsid = LittleEndian.getInt( data, 0x0 + offset );\r
+        field_2_reserved1 = LittleEndian.getInt( data, 0x4 + offset );\r
+        field_3_reserved2 = LittleEndian.getInt( data, 0x8 + offset );\r
+        field_4_clfolvl = data[0xc + offset];\r
+        field_5_ibstFltAutoNum = data[0xd + offset];\r
+        field_6_grfhic = data[0xe + offset];\r
+        field_7_reserved3 = data[0xf + offset];\r
+    }\r
+\r
+    public void serialize( byte[] data, int offset )\r
+    {\r
+        LittleEndian.putInt( data, 0x0 + offset, field_1_lsid );\r
+        LittleEndian.putInt( data, 0x4 + offset, field_2_reserved1 );\r
+        LittleEndian.putInt( data, 0x8 + offset, field_3_reserved2 );\r
+        data[0xc + offset] = field_4_clfolvl;\r
+        data[0xd + offset] = field_5_ibstFltAutoNum;\r
+        data[0xe + offset] = field_6_grfhic;\r
+        data[0xf + offset] = field_7_reserved3;\r
+    }\r
+\r
+    /**\r
+     * Size of record\r
+     */\r
+    public static int getSize()\r
+    {\r
+        return 0 + 4 + 4 + 4 + 1 + 1 + 1 + 1;\r
+    }\r
+\r
+    public String toString()\r
+    {\r
+        StringBuilder builder = new StringBuilder();\r
+        builder.append( "[LFO]\n" );\r
+        builder.append( "    .lsid                 = " );\r
+        builder.append( " (" ).append( getLsid() ).append( " )\n" );\r
+        builder.append( "    .reserved1            = " );\r
+        builder.append( " (" ).append( getReserved1() ).append( " )\n" );\r
+        builder.append( "    .reserved2            = " );\r
+        builder.append( " (" ).append( getReserved2() ).append( " )\n" );\r
+        builder.append( "    .clfolvl              = " );\r
+        builder.append( " (" ).append( getClfolvl() ).append( " )\n" );\r
+        builder.append( "    .ibstFltAutoNum       = " );\r
+        builder.append( " (" ).append( getIbstFltAutoNum() ).append( " )\n" );\r
+        builder.append( "    .grfhic               = " );\r
+        builder.append( " (" ).append( getGrfhic() ).append( " )\n" );\r
+        builder.append( "         .fHtmlChecked             = " )\r
+                .append( isFHtmlChecked() ).append( '\n' );\r
+        builder.append( "         .fHtmlUnsupported         = " )\r
+                .append( isFHtmlUnsupported() ).append( '\n' );\r
+        builder.append( "         .fHtmlListTextNotSharpDot     = " )\r
+                .append( isFHtmlListTextNotSharpDot() ).append( '\n' );\r
+        builder.append( "         .fHtmlNotPeriod           = " )\r
+                .append( isFHtmlNotPeriod() ).append( '\n' );\r
+        builder.append( "         .fHtmlFirstLineMismatch     = " )\r
+                .append( isFHtmlFirstLineMismatch() ).append( '\n' );\r
+        builder.append( "         .fHtmlTabLeftIndentMismatch     = " )\r
+                .append( isFHtmlTabLeftIndentMismatch() ).append( '\n' );\r
+        builder.append( "         .fHtmlHangingIndentBeneathNumber     = " )\r
+                .append( isFHtmlHangingIndentBeneathNumber() ).append( '\n' );\r
+        builder.append( "         .fHtmlBuiltInBullet       = " )\r
+                .append( isFHtmlBuiltInBullet() ).append( '\n' );\r
+        builder.append( "    .reserved3            = " );\r
+        builder.append( " (" ).append( getReserved3() ).append( " )\n" );\r
+\r
+        builder.append( "[/LFO]\n" );\r
+        return builder.toString();\r
+    }\r
+\r
+    /**\r
+     * List ID of corresponding LSTF (see LSTF).\r
+     */\r
+    public int getLsid()\r
+    {\r
+        return field_1_lsid;\r
+    }\r
+\r
+    /**\r
+     * List ID of corresponding LSTF (see LSTF).\r
+     */\r
+    public void setLsid( int field_1_lsid )\r
+    {\r
+        this.field_1_lsid = field_1_lsid;\r
+    }\r
+\r
+    /**\r
+     * Reserved.\r
+     */\r
+    public int getReserved1()\r
+    {\r
+        return field_2_reserved1;\r
+    }\r
+\r
+    /**\r
+     * Reserved.\r
+     */\r
+    public void setReserved1( int field_2_reserved1 )\r
+    {\r
+        this.field_2_reserved1 = field_2_reserved1;\r
+    }\r
+\r
+    /**\r
+     * Reserved.\r
+     */\r
+    public int getReserved2()\r
+    {\r
+        return field_3_reserved2;\r
+    }\r
+\r
+    /**\r
+     * Reserved.\r
+     */\r
+    public void setReserved2( int field_3_reserved2 )\r
+    {\r
+        this.field_3_reserved2 = field_3_reserved2;\r
+    }\r
+\r
+    /**\r
+     * Count of levels whose format is overridden (see LFOLVL).\r
+     */\r
+    public byte getClfolvl()\r
+    {\r
+        return field_4_clfolvl;\r
+    }\r
+\r
+    /**\r
+     * Count of levels whose format is overridden (see LFOLVL).\r
+     */\r
+    public void setClfolvl( byte field_4_clfolvl )\r
+    {\r
+        this.field_4_clfolvl = field_4_clfolvl;\r
+    }\r
+\r
+    /**\r
+     * Used for AUTONUM field emulation.\r
+     */\r
+    public byte getIbstFltAutoNum()\r
+    {\r
+        return field_5_ibstFltAutoNum;\r
+    }\r
+\r
+    /**\r
+     * Used for AUTONUM field emulation.\r
+     */\r
+    public void setIbstFltAutoNum( byte field_5_ibstFltAutoNum )\r
+    {\r
+        this.field_5_ibstFltAutoNum = field_5_ibstFltAutoNum;\r
+    }\r
+\r
+    /**\r
+     * HTML compatibility flags.\r
+     */\r
+    public byte getGrfhic()\r
+    {\r
+        return field_6_grfhic;\r
+    }\r
+\r
+    /**\r
+     * HTML compatibility flags.\r
+     */\r
+    public void setGrfhic( byte field_6_grfhic )\r
+    {\r
+        this.field_6_grfhic = field_6_grfhic;\r
+    }\r
+\r
+    /**\r
+     * Reserved.\r
+     */\r
+    public byte getReserved3()\r
+    {\r
+        return field_7_reserved3;\r
+    }\r
+\r
+    /**\r
+     * Reserved.\r
+     */\r
+    public void setReserved3( byte field_7_reserved3 )\r
+    {\r
+        this.field_7_reserved3 = field_7_reserved3;\r
+    }\r
+\r
+    /**\r
+     * Sets the fHtmlChecked field value. Checked\r
+     */\r
+    public void setFHtmlChecked( boolean value )\r
+    {\r
+        field_6_grfhic = (byte) fHtmlChecked.setBoolean( field_6_grfhic, value );\r
+    }\r
+\r
+    /**\r
+     * Checked\r
+     * \r
+     * @return the fHtmlChecked field value.\r
+     */\r
+    public boolean isFHtmlChecked()\r
+    {\r
+        return fHtmlChecked.isSet( field_6_grfhic );\r
+    }\r
+\r
+    /**\r
+     * Sets the fHtmlUnsupported field value. The numbering sequence or format\r
+     * is unsupported (includes tab & size)\r
+     */\r
+    public void setFHtmlUnsupported( boolean value )\r
+    {\r
+        field_6_grfhic = (byte) fHtmlUnsupported.setBoolean( field_6_grfhic,\r
+                value );\r
+    }\r
+\r
+    /**\r
+     * The numbering sequence or format is unsupported (includes tab & size)\r
+     * \r
+     * @return the fHtmlUnsupported field value.\r
+     */\r
+    public boolean isFHtmlUnsupported()\r
+    {\r
+        return fHtmlUnsupported.isSet( field_6_grfhic );\r
+    }\r
+\r
+    /**\r
+     * Sets the fHtmlListTextNotSharpDot field value. The list text is not "#."\r
+     */\r
+    public void setFHtmlListTextNotSharpDot( boolean value )\r
+    {\r
+        field_6_grfhic = (byte) fHtmlListTextNotSharpDot.setBoolean(\r
+                field_6_grfhic, value );\r
+    }\r
+\r
+    /**\r
+     * The list text is not "#."\r
+     * \r
+     * @return the fHtmlListTextNotSharpDot field value.\r
+     */\r
+    public boolean isFHtmlListTextNotSharpDot()\r
+    {\r
+        return fHtmlListTextNotSharpDot.isSet( field_6_grfhic );\r
+    }\r
+\r
+    /**\r
+     * Sets the fHtmlNotPeriod field value. Something other than a period is\r
+     * used\r
+     */\r
+    public void setFHtmlNotPeriod( boolean value )\r
+    {\r
+        field_6_grfhic = (byte) fHtmlNotPeriod.setBoolean( field_6_grfhic,\r
+                value );\r
+    }\r
+\r
+    /**\r
+     * Something other than a period is used\r
+     * \r
+     * @return the fHtmlNotPeriod field value.\r
+     */\r
+    public boolean isFHtmlNotPeriod()\r
+    {\r
+        return fHtmlNotPeriod.isSet( field_6_grfhic );\r
+    }\r
+\r
+    /**\r
+     * Sets the fHtmlFirstLineMismatch field value. First line indent mismatch\r
+     */\r
+    public void setFHtmlFirstLineMismatch( boolean value )\r
+    {\r
+        field_6_grfhic = (byte) fHtmlFirstLineMismatch.setBoolean(\r
+                field_6_grfhic, value );\r
+    }\r
+\r
+    /**\r
+     * First line indent mismatch\r
+     * \r
+     * @return the fHtmlFirstLineMismatch field value.\r
+     */\r
+    public boolean isFHtmlFirstLineMismatch()\r
+    {\r
+        return fHtmlFirstLineMismatch.isSet( field_6_grfhic );\r
+    }\r
+\r
+    /**\r
+     * Sets the fHtmlTabLeftIndentMismatch field value. The list tab and the\r
+     * dxaLeft don't match (need table?)\r
+     */\r
+    public void setFHtmlTabLeftIndentMismatch( boolean value )\r
+    {\r
+        field_6_grfhic = (byte) fHtmlTabLeftIndentMismatch.setBoolean(\r
+                field_6_grfhic, value );\r
+    }\r
+\r
+    /**\r
+     * The list tab and the dxaLeft don't match (need table?)\r
+     * \r
+     * @return the fHtmlTabLeftIndentMismatch field value.\r
+     */\r
+    public boolean isFHtmlTabLeftIndentMismatch()\r
+    {\r
+        return fHtmlTabLeftIndentMismatch.isSet( field_6_grfhic );\r
+    }\r
+\r
+    /**\r
+     * Sets the fHtmlHangingIndentBeneathNumber field value. The hanging indent\r
+     * falls beneath the number (need plain text)\r
+     */\r
+    public void setFHtmlHangingIndentBeneathNumber( boolean value )\r
+    {\r
+        field_6_grfhic = (byte) fHtmlHangingIndentBeneathNumber.setBoolean(\r
+                field_6_grfhic, value );\r
+    }\r
+\r
+    /**\r
+     * The hanging indent falls beneath the number (need plain text)\r
+     * \r
+     * @return the fHtmlHangingIndentBeneathNumber field value.\r
+     */\r
+    public boolean isFHtmlHangingIndentBeneathNumber()\r
+    {\r
+        return fHtmlHangingIndentBeneathNumber.isSet( field_6_grfhic );\r
+    }\r
+\r
+    /**\r
+     * Sets the fHtmlBuiltInBullet field value. A built-in HTML bullet\r
+     */\r
+    public void setFHtmlBuiltInBullet( boolean value )\r
+    {\r
+        field_6_grfhic = (byte) fHtmlBuiltInBullet.setBoolean( field_6_grfhic,\r
+                value );\r
+    }\r
+\r
+    /**\r
+     * A built-in HTML bullet\r
+     * \r
+     * @return the fHtmlBuiltInBullet field value.\r
+     */\r
+    public boolean isFHtmlBuiltInBullet()\r
+    {\r
+        return fHtmlBuiltInBullet.isSet( field_6_grfhic );\r
+    }\r
+\r
+} // END OF CLASS\r
diff --git a/src/types/definitions/lfo_type.xml b/src/types/definitions/lfo_type.xml
new file mode 100644 (file)
index 0000000..03dc7d1
--- /dev/null
@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<!--
+    ====================================================================
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements. See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License. You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+    ====================================================================
+-->
+<record fromfile="true" name="LFO" package="org.apache.poi.hwpf.model.types">
+    <suffix>AbstractType</suffix>
+    <extends>HDFType</extends>
+    <description>List Format Override (LFO). &lt;p&gt;Class and fields descriptions are quoted from
+        Microsoft Office Word 97-2007 Binary File Format
+    </description>
+    <author>Sergey Vladimirov; according to Microsoft Office Word 97-2007 Binary File Format
+        Specification [*.doc]
+    </author>
+    <fields>
+        <field type="int" size="4" name="lsid" description="List ID of corresponding LSTF (see LSTF)"/>
+        <field type="int" size="4" name="reserved1" description="Reserved"/>
+        <field type="int" size="4" name="reserved2" description="Reserved"/>
+        <field type="byte" size="1" name="clfolvl"
+            description="Count of levels whose format is overridden (see LFOLVL)"/>
+        <field type="byte" size="1" name="ibstFltAutoNum" description="Used for AUTONUM field emulation"/>
+        <field type="byte" size="1" name="grfhic" description="HTML compatibility flags">
+            <bit number="0" mask="0x01" name="fHtmlChecked" description="Checked"/>
+            <bit number="1" mask="0x02" name="fHtmlUnsupported"
+                description="The numbering sequence or format is unsupported (includes tab &amp; size)"/>
+            <bit number="2" mask="0x04" name="fHtmlListTextNotSharpDot" description="The list text is not &quot;#.&quot;"/>
+            <bit number="3" mask="0x08" name="fHtmlNotPeriod" description="Something other than a period is used"/>
+            <bit number="4" mask="0x10" name="fHtmlFirstLineMismatch" description="First line indent mismatch"/>
+            <bit number="5" mask="0x20" name="fHtmlTabLeftIndentMismatch"
+                description="The list tab and the dxaLeft don't match (need table?)"/>
+            <bit number="6" mask="0x40" name="fHtmlHangingIndentBeneathNumber"
+                description="The hanging indent falls beneath the number (need plain text)"/>
+            <bit number="7" mask="0x80" name="fHtmlBuiltInBullet" description="A built-in HTML bullet"/>
+        </field>
+        <field type="byte" size="1" name="reserved3" description="Reserved"/>
+    </fields>
+</record>