<?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 id="0x101B" name="TAP" package="org.apache.poi.hwpf.model.types">
    <suffix>AbstractType</suffix>
    <extends>HDFType</extends>
    <description>Table Properties. Properties descriptions quoted from official 97-2007 binary file
        format specification.
    </description>
    <author>S. Ryan Ackley</author>
    <fields>
        <!-- page 198 -->
        <field type="short" size="2" name="istd" description="Table style for the Table"/>
        <field type="short" size="2" name="jc"
            description="Justification code. specifies how table row should be justified within its column. 0 -- left justify, 1 -- center, 2 -- right justify"/>
        <field type="int" size="4" name="dxaGapHalf"
            description="Measures half of the white space that will be maintained between text in adjacent columns of a table row. A dxaGapHalf width of white space will be maintained on both sides of a column boundary."/>
        <field type="int" size="4" name="dyaRowHeight"
            description="When greater than 0, guarantees that the height of the table will be at least dyaRowHeight high. When less than 0, guarantees that the height of the table will be exactly absolute value of dyaRowHeight high. When 0, table will be given a height large enough to represent all of the text in all of the cells of the table. Cells with vertical text flow make no contribution to the computation of the height of rows with auto or at least height. Neither do vertically merged cells, except in the last row of the vertical merge. If an auto height row consists entirely of cells which have vertical text direction or are vertically merged, and the row does not contain the last cell in any vertical cell merge, then the row is given height equal to that of the end of cell mark in the first cell."/>
        <field type="boolean" size="0" name="fCantSplit"
            description="When 1, table row may not be split across page bounds"/>
        <field type="boolean" size="0" name="fCantSplit90"
            description="When 1, table row may not be split across page bounds. Used for Word 2000 and Word 97."/>
        <field type="boolean" size="0" name="fTableHeader"
            description="When 1, table row is to be used as the header of the table"/>

        <field type="TableAutoformatLookSpecifier" size="4" name="tlp" description="Table look specifier"/>

        <field type="short" size="2" name="wWidth" description="Preferred table width"/>
        <field type="short" size="2" name="wWidthIndent" description="Left Indent"/>
        <field type="short" size="2" name="wWidthBefore"
            description="Width of invisible cell (used for layout purposes) before the first visible cell in the row."/>
        <field type="short" size="2" name="wWidthAfter"
            description="Width of invisible cell (used for layout purposes) after the last visible cell in the row."/>

        <field type="int" size="4" name="widthAndFitsFlags">
            <bit number="0" mask="0x00000001" name="fAutofit" description="When set to 1, AutoFit this table"/>
            <!-- page 199 -->
            <bit number="1" mask="0x00000002" name="fKeepFollow"
                description="When set to 1, keep this row with the following row"/>

            <bit number="2" mask="0x0000001c" name="ftsWidth"
                description="Units for wWidth: 0 -- null; 1 -- auto, ignores wWidth, 2 -- percentage (in 50ths of a percent), 3 -- twips"/>
            <bit number="3" mask="0x000000e0" name="ftsWidthIndent"
                description="Units for wWidthIndent: 0 -- null; 1 -- auto, ignores wWidthIndent, 2 -- percentage (in 50ths of a percent), 3 -- twips"/>
            <bit number="4" mask="0x00000700" name="ftsWidthBefore"
                description="Units for wWidthBefore: 0 -- null; 1 -- auto, ignores wWidthBefore, 2 -- percentage (in 50ths of a percent), 3 -- twips"/>
            <bit number="5" mask="0x00003800" name="ftsWidthAfter"
                description="Units for wWidthAfter: 0 -- null; 1 -- auto, ignores wWidthAfter, 2 -- percentage (in 50ths of a percent), 3 -- twips"/>

            <bit number="6" mask="0x00004000" name="fNeverBeenAutofit" description="When 1, table has never been autofit"/>
            <bit number="7" mask="0x00008000" name="fInvalAutofit"
                description="When 1, TAP is still valid, but autofit properties aren't"/>
            <bit number="8" mask="0x00070000" name="widthAndFitsFlags_empty1" description="Not used"/>
            <bit number="9" mask="0x00080000" name="fVert" description="When 1, positioned in vertical text flow"/>
            <bit number="10" mask="0x00300000" name="pcVert"
                description="Vertical position code. Specifies coordinate frame to use when paragraphs are absolutely positioned. 0 -- vertical position coordinates are relative to margin; 1 -- coordinates are relative to page; 2 -- coordinates are relative to text. This means: relative to where the next non-APO text would have been placed if this APO did not exist."/>
            <bit number="11" mask="0x00c00000" name="pcHorz"
                description="Horizontal position code. Specifies coordinate frame to use when paragraphs are absolutely positioned. 0 -- horizontal position coordinates are relative to column; 1 -- coordinates are relative to margin; 2 -- coordinates are relative to page"/>
            <bit number="12" mask="0xff000000" name="widthAndFitsFlags_empty2" description="Not used"/>
        </field>

        <field type="int" size="4" name="dxaAbs" description="Absolute horizontal position"/>
        <field type="int" size="4" name="dyaAbs" description="Absolute vertical position"/>
        <field type="int" size="4" name="dxaFromText"
            description="Left distance from surrounding text when absolutely positioned"/>
        <field type="int" size="4" name="dyaFromText"
            description="Top distance from surrounding text when absolutely positioned"/>
        <field type="int" size="4" name="dxaFromTextRight"
            description="Right distance from surrounding text when absolutely positioned"/>
        <field type="int" size="4" name="dyaFromTextBottom"
            description="Bottom distance from surrounding text when absolutely positioned"/>

        <field type="byte" size="1" name="fBiDi"
            description="When 1, table is right-to-left. Logical right-to-left table: The CP stream of a right-to-left table is meant to be displayed from right to left. So for example the first table cell is displayed on the right side of the table instead of the left."/>
        <field type="byte" size="1" name="fRTL"
            description="Word 2000 style right-to-left table. Visual right-to-left table: The CP stream of a right-to-left table is displayed from left to right just as for a ―normal‖ table. So, the text which is meant to be in the ―first‖ (rightmost) table cell must be placed in the last table cell in the CP stream."/>
        <field type="byte" size="1" name="fNoAllowOverlap"
            description="When set to 1, do not allow absolutely positioned table to overlap with other tables"/>
        <field type="byte" size="1" name="fSpare" description="Not used"/>

        <field type="int" size="2" name="grpfTap" description="Used internally by Word"/>

        <field type="int" size="2" name="internalFlags" description="Used internally by Word">
            <bit number="1" mask="0x0001" name="fFirstRow" description="Used internally by Word: first row"/>
            <bit number="2" mask="0x0002" name="fLastRow" description="Used internally by Word: last row"/>
            <bit number="3" mask="0x0004" name="fOutline"
                description="Used internally by Word: row was cached for outline mode"/>
            <bit number="4" mask="0x0008" name="fOrigWordTableRules"
                description="Used internally by Word: table combining like Word 5.x for the Macintosh and WinWord 1.x"/>
            <bit number="5" mask="0x0010" name="fCellSpacing"
                description="Used internally by Word: When set to 1 cell spacing is allowed"/>
            <bit number="6" mask="0xffe0" name="grpfTap_unused" description="Not used"/>
        </field>

        <field type="short" size="2" name="itcMac"
            description="Count of cells defined for this row. itcMac must be >= 0 and less than or equal to 64."/>

        <field type="int" size="4" name="dxaAdjust" description="Used internally by Word"/>
        <field type="int" size="4" name="dxaWebView" description="Used internally by Word"/>
        <field type="int" size="4" name="dxaRTEWrapWidth" description="Used internally by Word"/>
        <field type="int" size="4" name="dxaColWidthWwd" description="Used internally by Word"/>

        <field type="short" size="2" name="pctWwd"
            description="Used internally by Word: percent of Window size for AutoFit in WebView"/>

        <field type="int" size="2" name="viewFlags" description="Used internally by Word">
            <bit number="1" mask="0x0001" name="fWrapToWwd"
                description="Used internally by Word: Wrap to window is on when set to 1"/>
            <bit number="2" mask="0x0002" name="fNotPageView"
                description="Used internally by Word: when set to 1 we are not in Page View"/>
            <bit number="3" mask="0x0004" name="viewFlags_unused1" description="Not used"/>
            <bit number="4" mask="0x0008" name="fWebView"
                description="Used internally by Word: Web View is on when set to 1"/>
            <bit number="5" mask="0x0010" name="fAdjusted" description="Used internally by Word"/>
            <bit number="6" mask="0xffe0" name="viewFlags_unused2" description="Not used"/>
        </field>

        <field type="short[]" size="130" name="rgdxaCenter"
            description="rgdxaCenter[0] is the left boundary of cell 0 measured relative to margin rgdxaCenter[tap.itcMac - 1] is left boundary of last cell rgdxaCenter[tap.itcMac] is right boundary of last cell."/>
        <field type="short[]" size="130" name="rgdxaCenterPrint" description="Used internally by Word"/>

        <field type="ShadingDescriptor" size="10" name="shdTable" description="Table shading"/>

        <!-- rgbrcTable[ibrcTableMax]; Array of borders; ibrcTableMax==6 -->
        <field type="BorderCode" size="4" name="brcBottom"/>
        <field type="BorderCode" size="4" name="brcTop"/>
        <field type="BorderCode" size="4" name="brcLeft"/>
        <field type="BorderCode" size="4" name="brcRight"/>
        <field type="BorderCode" size="4" name="brcVertical"/>
        <field type="BorderCode" size="4" name="brcHorizontal"/>

        <!-- mpibrcwCellPaddingDefault[cbrcTc]; Array of default cell margins. Index into the next four
            properties. -->
        <field type="short" size="2" name="wCellPaddingDefaultTop" description="Default top cell margin/padding"/>
        <field type="short" size="2" name="wCellPaddingDefaultLeft" description="Default left cell margin/padding"/>
        <field type="short" size="2" name="wCellPaddingDefaultBottom" description="Default bottom cell margin/padding"/>
        <field type="short" size="2" name="wCellPaddingDefaultRight" description="Default right cell margin/padding"/>

        <!-- mpibrcftsCellPaddingDefault[cbrcTc]; Array of default cell margin units. Index into the
            next four properties -->
        <field type="byte" size="1" name="ftsCellPaddingDefaultTop"
            description="Default top cell margin/padding units. 0 -- null; 1-2 -- not relevant; 3 -- twips."/>
        <field type="byte" size="1" name="ftsCellPaddingDefaultLeft"
            description="Default left cell margin/padding units. 0 -- null; 1-2 -- not relevant; 3 -- twips."/>
        <field type="byte" size="1" name="ftsCellPaddingDefaultBottom"
            description="Default bottom cell margin/padding units. 0 -- null; 1-2 -- not relevant; 3 -- twips."/>
        <field type="byte" size="1" name="ftsCellPaddingDefaultRight"
            description="Default right cell margin/padding units. 0 -- null; 1-2 -- not relevant; 3 -- twips."/>

        <!-- mpibrcwCellSpacingDefault[cbrcTc]; Array of default cell spacing. Index into the next four
            properties -->
        <field type="short" size="2" name="wCellSpacingDefaultTop" description="Default top cell spacings"/>
        <field type="short" size="2" name="wCellSpacingDefaultLeft" description="Default left cell spacings"/>
        <field type="short" size="2" name="wCellSpacingDefaultBottom" description="Default bottom cell spacings"/>
        <field type="short" size="2" name="wCellSpacingDefaultRight" description="Default right cell spacings"/>

        <!-- mpibrcftsCellSpacingDefault[cbrcTc]; Array of default cell spacing units. Index into the
            next four properties -->
        <field type="byte" size="1" name="ftsCellSpacingDefaultTop"
            description="Default top cell spacings units. 0 -- null; 1-2 -- not relevant; 3 -- twips."/>
        <field type="byte" size="1" name="ftsCellSpacingDefaultLeft"
            description="Default left cell spacings units. 0 -- null; 1-2 -- not relevant; 3 -- twips."/>
        <field type="byte" size="1" name="ftsCellSpacingDefaultBottom"
            description="Default bottom cell spacings units. 0 -- null; 1-2 -- not relevant; 3 -- twips."/>
        <field type="byte" size="1" name="ftsCellSpacingDefaultRight"
            description="Default right cell spacings units. 0 -- null; 1-2 -- not relevant; 3 -- twips."/>

        <!-- mpibrcwCellPaddingOuter[cbrcTc]; Array of default outer cell margins. Index into the next
            four properties. -->
        <field type="short" size="2" name="wCellPaddingOuterTop" description="Default outer top cell margin/padding"/>
        <field type="short" size="2" name="wCellPaddingOuterLeft" description="Default outer left cell margin/padding"/>
        <field type="short" size="2" name="wCellPaddingOuterBottom" description="Default outer bottom cell margin/padding"/>
        <field type="short" size="2" name="wCellPaddingOuterRight" description="Default outer right cell margin/padding"/>

        <!-- mpibrcftsCellPaddingOuter[cbrcTc]; Array of default outer cell margin units. Index into
            the next four properties -->
        <field type="byte" size="1" name="ftsCellPaddingOuterTop"
            description="Default outer top cell margin/padding units. 0 -- null; 1-2 -- not relevant; 3 -- twips."/>
        <field type="byte" size="1" name="ftsCellPaddingOuterLeft"
            description="Default outer left cell margin/padding units. 0 -- null; 1-2 -- not relevant; 3 -- twips."/>
        <field type="byte" size="1" name="ftsCellPaddingOuterBottom"
            description="Default outer bottom cell margin/padding units. 0 -- null; 1-2 -- not relevant; 3 -- twips."/>
        <field type="byte" size="1" name="ftsCellPaddingOuterRight"
            description="Default outer right cell margin/padding units. 0 -- null; 1-2 -- not relevant; 3 -- twips."/>

        <!-- mpibrcwCellSpacingOuter[cbrcTc]; Array of default outer cell spacing. Index into the next
            four properties. -->
        <field type="short" size="2" name="wCellSpacingOuterTop" description="Default outer top cell spacing"/>
        <field type="short" size="2" name="wCellSpacingOuterLeft" description="Default outer left cell spacing"/>
        <field type="short" size="2" name="wCellSpacingOuterBottom" description="Default outer bottom cell spacing"/>
        <field type="short" size="2" name="wCellSpacingOuterRight" description="Default outer right cell spacing"/>

        <!-- mpibrcftsCellSpacingOuter[cbrcTc]; Array of default outer cell spacing units. Index into
            the next four properties. -->
        <field type="byte" size="1" name="ftsCellSpacingOuterTop"
            description="Default outer top cell spacings units. 0 -- null; 1-2 -- not relevant; 3 -- twips."/>
        <field type="byte" size="1" name="ftsCellSpacingOuterLeft"
            description="Default outer left cell spacings units. 0 -- null; 1-2 -- not relevant; 3 -- twips."/>
        <field type="byte" size="1" name="ftsCellSpacingOuterBottom"
            description="Default outer bottom cell spacings units. 0 -- null; 1-2 -- not relevant; 3 -- twips."/>
        <field type="byte" size="1" name="ftsCellSpacingOuterRight"
            description="Default outer right cell spacings units. 0 -- null; 1-2 -- not relevant; 3 -- twips."/>

        <field type="TableCellDescriptor[]" size="0" name="rgtc"/>
        <field type="ShadingDescriptor[]" size="0" name="rgshd"/>

        <field type="byte" size="1" name="fPropRMark" description="Set to 1 if property revision"/>
        <!-- TODO: ibstPropRMark -->
        <!-- TODO: dttmPropRMark -->
        <field type="byte" size="1" name="fHasOldProps" description="Has old properties"/>

        <!-- TODO: ipgp -->
        <!-- TODO: hplcnf -->
        <!-- TODO: rsid -->
        <!-- TODO: tcDefault -->

        <field type="short" size="1" name="cHorzBands"
            description="Size of each horizontal style band, in number of rows"/>
        <field type="short" size="1" name="cVertBands"
            description="Size of a vertical style band, in number of columns"/>

        <field type="BorderCode" size="8" name="rgbrcInsideDefault_0"
            description="Border definition for inside horizontal borders"/>
        <field type="BorderCode" size="8" name="rgbrcInsideDefault_1" description="Border definition for inside vertical borders"/>

    </fields>
</record>
