@@ -1161,49 +1161,136 @@ $elementSkin
1161
1161
!global $propTableCaption = ""
1162
1162
!global $propColCaption = "= "
1163
1163
1164
+ !global $isFirstProp = 1
1165
+ !global $firstPropCol = 1
1166
+ !global $lastPropCol = 1
1167
+
1168
+ !function $fillMissing ($col , $colNext )
1169
+ !if ($col == "" && $colNext != "")
1170
+ !return " "
1171
+ !endif
1172
+ !return $col
1173
+ !endfunction
1174
+
1175
+ !function $updatePropColumns ($colIdx )
1176
+ !if ($isFirstProp == 1 && $colIdx > $firstPropCol )
1177
+ !$firstPropCol = $colIdx
1178
+ !endif
1179
+ !if ($isFirstProp == 0 && $colIdx > $lastPropCol )
1180
+ !$lastPropCol = $colIdx
1181
+ !endif
1182
+ !return ""
1183
+ !endfunction
1184
+
1185
+ ' add missing header columns, if a following row has more columns
1186
+ ' (fixed in PlantUML v1.2025.1beta9; only required in older versions)
1187
+ !function $fixHeaderColumns ()
1188
+ ' the number of displayed columns considers only the first row
1189
+ ' if another row has more columns the first has to be filled with missing columns
1190
+ !if ($lastPropCol > $firstPropCol )
1191
+ !$delta = $lastPropCol - $firstPropCol
1192
+ !$delta = $delta * 2
1193
+ !$fix = %substr (" | | | |", 0 , $delta )
1194
+
1195
+ ' basically the line break \n should be the split
1196
+ ' but \n is not encoded (anymore?) therefore split only via
1197
+ ' \ and remove the last obsolete \ (changed order with add
1198
+ ' \ at the beginning is not working).
1199
+ ' "\n" would split \ and n ==> n would be an unwanted line break
1200
+ !$lines = %splitstr ($propTable , "\")
1201
+ ' !$lines = %splitstr_regex($propTable, "(?=[\x000A])")
1202
+ !$first = 1
1203
+ !$newTab = ""
1204
+ !foreach $item in $lines
1205
+ !if ($first == 1 )
1206
+ !$item = $item + $fix
1207
+ !$first = 0
1208
+ !endif
1209
+ !$newTab = $newTab + $item + "\"
1210
+ !endfor
1211
+
1212
+ !$fixLen = %strlen ($newTab ) - 1
1213
+ !$newTab = %substr ($newTab , 0 , $fixLen )
1214
+
1215
+ !$propTable = $newTab
1216
+ !endif
1217
+
1218
+ !$isFirstProp = 1
1219
+ !$firstPropCol = 1
1220
+ !$lastPropCol = 1
1221
+
1222
+ !return ""
1223
+ !endfunction
1224
+
1164
1225
!unquoted function SetPropertyHeader ($col1Name , $col2Name = "", $col3Name = "", $col4Name = "")
1226
+ !$col3Name = $fillMissing ($col3Name , $col4Name )
1227
+ !$col2Name = $fillMissing ($col2Name , $col3Name )
1228
+ !$col1Name = $fillMissing ($col1Name , $col2Name )
1229
+
1165
1230
!$propColCaption = ""
1166
1231
!$propTableCaption = "|= " + $col1Name + " |"
1167
1232
!if ($col2Name != "")
1168
1233
!$propTableCaption = $propTableCaption + "= " + $col2Name + " |"
1234
+ $updatePropColumns (2 )
1169
1235
!endif
1170
1236
!if ($col3Name != "")
1171
1237
!$propTableCaption = $propTableCaption + "= " + $col3Name + " |"
1238
+ $updatePropColumns (3 )
1172
1239
!endif
1173
1240
!if ($col4Name != "")
1174
1241
!$propTableCaption = $propTableCaption + "= " + $col4Name + " |"
1242
+ $updatePropColumns (4 )
1175
1243
!endif
1244
+
1245
+ !$isFirstProp = 0
1176
1246
!return ""
1177
1247
!endfunction
1178
1248
1179
1249
!unquoted function WithoutPropertyHeader ()
1180
1250
!$propTableCaption = ""
1181
1251
!$propColCaption = "= "
1252
+
1253
+ !$isFirstProp = 1
1254
+ !$firstPropCol = 1
1255
+ !$lastPropCol = 1
1256
+
1182
1257
!return ""
1183
1258
!endfunction
1184
1259
1185
1260
!unquoted function AddProperty ($col1 , $col2 = "", $col3 = "", $col4 = "")
1261
+ !$col3 = $fillMissing ($col3 , $col4 )
1262
+ !$col2 = $fillMissing ($col2 , $col3 )
1263
+ !$col1 = $fillMissing ($col1 , $col2 )
1264
+
1186
1265
!if ($propTable == "")
1187
1266
!if ($propTableCaption != "")
1188
1267
!$propTable = $propTableCaption + "\n "
1189
1268
!endif
1190
1269
!else
1191
1270
!$propTable = $propTable + "\n "
1192
1271
!endif
1272
+
1193
1273
!$propTable = $propTable + "| " + $col1 + " |"
1194
1274
!if ($col2 != "")
1195
1275
!$propTable = $propTable + $propColCaption + " " + $col2 + " |"
1276
+ $updatePropColumns (2 )
1196
1277
!endif
1197
1278
!if ($col3 != "")
1198
1279
!$propTable = $propTable + " " + $col3 + " |"
1280
+ $updatePropColumns (3 )
1199
1281
!endif
1200
1282
!if ($col4 != "")
1201
1283
!$propTable = $propTable + " " + $col4 + " |"
1284
+ $updatePropColumns (4 )
1202
1285
!endif
1286
+
1287
+ !$isFirstProp = 0
1203
1288
!return ""
1204
1289
!endfunction
1205
1290
1206
1291
!unquoted function $getProps ($alignedNL = "\n ")
1292
+ $fixHeaderColumns ()
1293
+
1207
1294
!if ($propTable != "")
1208
1295
!$retTable = $alignedNL + $propTable
1209
1296
!$propTable = ""
0 commit comments