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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
If itapPrev is less than itap, then cpFirst is the desired output. Leave the algorithm.
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.
Set cp to cpPrev. Go to step 1.