For MapScript, exactly the same the msInsertStyle */
| 1022 | |
| 1023 | /* For MapScript, exactly the same the msInsertStyle */ |
| 1024 | int msInsertLabelStyle(labelObj *label, styleObj *style, int nStyleIndex) { |
| 1025 | int i; |
| 1026 | |
| 1027 | if (!style) |
| 1028 | { |
| 1029 | msSetError(MS_CHILDERR, "Can't insert a NULL Style", "msInsertLabelStyle()"); |
| 1030 | return -1; |
| 1031 | } |
| 1032 | |
| 1033 | /* Ensure there is room for a new style */ |
| 1034 | if (msGrowLabelStyles(label) == NULL) { |
| 1035 | return -1; |
| 1036 | } |
| 1037 | /* Catch attempt to insert past end of styles array */ |
| 1038 | else if (nStyleIndex >= label->numstyles) { |
| 1039 | msSetError(MS_CHILDERR, "Cannot insert style beyond index %d", "insertLabelStyle()", label->numstyles-1); |
| 1040 | return -1; |
| 1041 | } |
| 1042 | else if (nStyleIndex < 0) { /* Insert at the end by default */ |
| 1043 | label->styles[label->numstyles]=style; |
| 1044 | MS_REFCNT_INCR(style); |
| 1045 | label->numstyles++; |
| 1046 | return label->numstyles-1; |
| 1047 | } |
| 1048 | else if (nStyleIndex >= 0 && nStyleIndex < label->numstyles) { |
| 1049 | /* Move styles existing at the specified nStyleIndex or greater */ |
| 1050 | /* to a higher nStyleIndex */ |
| 1051 | for (i=label->numstyles-1; i>=nStyleIndex; i--) { |
| 1052 | label->styles[i+1] = label->styles[i]; |
| 1053 | } |
| 1054 | label->styles[nStyleIndex]=style; |
| 1055 | MS_REFCNT_INCR(style); |
| 1056 | label->numstyles++; |
| 1057 | return nStyleIndex; |
| 1058 | } |
| 1059 | else { |
| 1060 | msSetError(MS_CHILDERR, "Invalid nStyleIndex", "insertLabelStyle()"); |
| 1061 | return -1; |
| 1062 | } |
| 1063 | } |
| 1064 | |
| 1065 | /** |
| 1066 | * Move the style up inside the array of styles. |
nothing calls this directly
no test coverage detected