ParCommand Method |
[Top] [Chapter] [Previous] [Next] |
Applies to Declaration int ParCommand(int ComID, int param, int param2); Description Execute special commands for this paragraph, cell or table row. ComID = 1: (check if empty) Check wether the paragraph is empty. The result is 1 if it is empty, 0 if it is not, -1 the operation was not possible. if param is 1 white space will be ignored.
param2 is a bitfield to ignore certain object types: 1: merge fields 2: hyperlinks 4: bookmarks 8: text protection codes (reserved) 16: span styles 32: custom codes (reserved) 64: text objects, such as a page number or a symbol object 128: references, used by the table of contents 256: reserved 512: reserved 1024: footnotes 2048: images 4096: horizontal line
ComID = 2: (height of paragraph) This command reads the row height of the current table row in twips. It can also be used with cell paragraphs. In case there is no table row, the result is -1. param2 is used to enable the examination not only of the current row but of all rows in the current table: 0: return current row height 1: return the smallest row height in the table 2: return the tallest row height in the table 3: return the average row height in the table else return row of all rows (sum)
Unless the complete table is modified the result value is the applied value in twips. In case the complete table is modified the result value is the count of modified rows.
ComID = 3: (height of paragraph) This command applies the height value "param" to the current row.
param2 is used as a bitfield to control how the value is applied. If param2=0 the minimum height of the current row is changed.
1: Also set maximum height (WPAT_BoxMaxHeight) 2: Do not set minimum height (WPAT_BoxMinHeight) 4: Apply value to all rows in the current table 8: The value "param" is added to the current actual row height is used as input. This can be used to "lock in" the height.
ComID = 4: (paragraph state flags) Work with the paragraph state flags:
param=0 clears the flag, param=1 sets the flag, param=-1 only reads the flag
param2 selects the flag:
0: paragraph is hidden (flag is also used by DeleteParWithCondition ) 1: paragraph is hidden (alternative flag) 2: user flag 1 3: user flag 2 4: user flag 3 5: user flag 4 6: protects tab stops
You need to call ReformatAll to update the screen
ComID = 5: ("move" CurrPar interface) locate the paragraph at Position "param". Returns -1 if a paragraph was not found (value too large), otherwise the position within the paragraph.
ComID = 6: (trim) Trim function - removes whitespace from start and end of this paragraph / cell.
ComID = 7: (find attributes)
Search in current paragraph for certain character attributes.
Starts to search from position Param2 and returns -1 if nothing was found, or the position is stored in the high word and the length in the low word of the result text. (This restricts paragraphs not to exceed 64K characters)
Param selects the attribute in the high byte of the 32 bit parameter. (Actually You can use the first 16 WPAT codes here)
The low 3 bytes are the parameter.
The following values are useful in the highest byte: 1: The Font Nr 3: The font size * 100 7: The character style. The low byte selects the style. 8: The color nr. Use the same values as in IWPAttrInterface.IncludeStyles and IWPAttrInterface.ExcludeStyles:
The lower 3 bytes are the desired value. They have to match exactly, except for the character style comparison. In this case the given bits have to be set.
This method can also be used to search special flags. In this case "Param" may have this values 16+1: - locates hyphen marker for manual hyphenation 16+2: - locates text which was spell checked already 16+3: - locates text which was marked to misspelled by the spell-as-you-go feature 16+4: - the alternative misspell marker (green) 16+5: - reserved 16+6: - reserved 16+7: - highlighted text (on the fly highlights, not background color) 16+8: - marked for deletion
ComID = 8: (set attributes)
Assigns new attributes to part of the text. This is the counter part to the search command 7. Param2 is the position and the length, high/low word. Param selects the attribute.
1: The Font Nr 3: The font size * 100 7: Adds a character style like IWPAttrInterface.IncludeStyles 6: Removes a character styles like IWPAttrInterface.ExcludeStyles.
also see: EnumParagraphs
ComID = 8: (get pos on screen)
Param = position within paragraph (=posinpar)
If the result value = -1, the text at this position is not visible Otherwise the highword = the x coordinate, the low word = y coordinate.
ComID = 9: (get X, y position of text in paragraph)
This Function can be used in the EnumParOrStyle event.
param = position in paragraph param2 can have this values: 0 : check if the character is visible. If not, the return 0, if yes return = 1 1 : return x coordinate inside editor 2 : return y coordinate inside editor 3 : return x coordinate relative to screen 4 : return y coordinate relative to screen
a = Par.ParCommand(7, (7 << 24) + 0, p); if (a>=0) { p = (a >> 16) + (a & 0xFFFF); // Calculate Next position if (Par.ParCommand(9, a >> 16, 0)==0) { Par.ParCommand(8, (8 << 24) + 1, a); // Selects red } }
ComID = 10
Calculate the line number of the character at the position param. If param2<>0 it will favors the end of a line, otherwise the start.
ComID = 11
This Function returns the start offset of the line with number param (range 0..).
ComID = 12
This Function returns the length of the line with number param.
ComID = 13
This Function returns the value of various internal variables depending on param:
0 : pagenr - the logical page number the first character is printed on 1 : Number - the number which would be used when numbering the text 2 : NumGroup - the number level 3 : SectionID - the SectionID of the section this paragraph starts (IF it starts a section!) 4 : lastpagenr - the page number the last line of this paragraph was printed 5 : lasty - the last Y position 6 : LoadedCharAttr - the character attr index this paragraph defaults 7 : Level - the level of this paragraph (nesting!) 8 : SiblingCount - the count of siblings 9 : SiblingNr - the number within the siblings (i.e. column nr) 10 : IsFirstTextPar - 1 if this is the first paragraph, 0 if not 11 : par.IsLastTextPar - 1 if this is the last paragraph, 0 if not 12 : par.HasChildren - 1 if this paragraph has children, such as a table 13 : MinCHeight - height of smallest character 14 : IDPTR - a unique ID
15: CharCount but not counting objects
|