2.4.5 Determining Row Boundaries

This section describes an algorithm to find the boundaries of the innermost table row containing a given character position or to determine that the given character position is not in a table row. Every valid character position in a document belongs to a paragraph, so table depth can be computed for each paragraph. If a paragraph is found to be at depth zero, then that paragraph is not in a table row.

This algorithm is the same as Determining Cell Boundaries except that only TTP marks cause a termination, not cell marks.

Given character position cp, use the following algorithm to determine if cp is in a table.

  1. Follow the procedure from Direct Paragraph Formatting to find the paragraph properties for the paragraph that contains cp. Apply the properties and determine the table depth as specified in Overview of Tables. Call this itap.

  2. If itap is zero, then this paragraph is not in a table row. Leave the algorithm.

Given a character position cp known to be at table depth itap, which is greater than 0, follow this procedure to determine the character position of the TTP mark of the row that contains cp.

  1. Determine the character position of the last character in the paragraph that contains cp, as specified in Determining Paragraph Boundaries. Let this position be called cpLast.

  2. Follow the procedure from Direct Paragraph Formatting to find the paragraph properties for the paragraph that contains cpLast. Apply the properties and determine the table depth as specified in Overview of Tables. Call this itap'. It is invalid for itap' to be less than itap. If itap' is less than itap, leave the algorithm.

  3. If itap' is equal to itap, determine the text at character position cpLast, as specified in Retrieving Text. If this character is a TTP mark as specified in Overview of Tables, then cpLast is the desired output. Leave the algorithm.

  4. Let cp be cpLast + 1 and go to step 1.

Given a character position cp known to be at table depth itap, which is greater than 0, follow this procedure to determine the character position of the first character in the innermost table row that contains cp.

  1. Determine the character position of the first character in the paragraph that contains cp as specified in Determining Paragraph Boundaries. Let this character position be called cpFirst.

  2. If cpFirst is zero, then this is the desired output. Leave the algorithm. Negative values for cpFirst are invalid. If cpFirst is negative leave the algorithm.

  3. Let cpPrev be cpFirst – 1. Follow the procedure from Direct Paragraph Formatting to find the paragraph properties for the paragraph that contains cpPrev. Apply the properties, and determine the table depth as specified in Overview of Tables. Call this itapPrev.

  4. If itapPrev is less than itap, then cpFirst is the desired output. Leave the algorithm.

  5. If itapPrev is equal to itap, determine the text at character position cpPrev, as specified in Retrieving Text. If this character is a TTP mark as specified in Overview of Tables, then cpFirst is the desired output. Leave the algorithm.

  6. Set cp to cpPrev. Go to step 1.