1<?xml version="1.0" encoding="UTF-8"?> 2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 3<!--*********************************************************** 4 * 5 * Licensed to the Apache Software Foundation (ASF) under one 6 * or more contributor license agreements. See the NOTICE file 7 * distributed with this work for additional information 8 * regarding copyright ownership. The ASF licenses this file 9 * to you under the Apache License, Version 2.0 (the 10 * "License"); you may not use this file except in compliance 11 * with the License. You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, 16 * software distributed under the License is distributed on an 17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 18 * KIND, either express or implied. See the License for the 19 * specific language governing permissions and limitations 20 * under the License. 21 * 22 ***********************************************************--> 23<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Validate" script:language="StarBasic"> 24'############################################ 25' VALIDATION ROUTINES 26' 27' May, 19 2004 - fpe 28'############################################ 29 30Dim sSwitchType As String 31Dim sCellSwitchType As String 32Dim sCaseType As String 33Dim sCellCaseType As String 34Dim sDefaultType As String 35Dim sCellDefaultType As String 36Dim bDefaultSet As Boolean 37Dim bCellDefaultSet As Boolean 38Dim bCaseSet As Boolean 39Dim bCellCaseSet As Boolean 40Dim aTagsOpen(0) As String 41Dim aCellTagsOpen(0) As String 42Dim bWarn As Boolean 43Dim bWarnEmptyPara As Boolean 44Dim bWarnParaNoID As Boolean 45 46 47Sub ValidateXHP 48 Validate 49End Sub 50 51Sub Validate 52 53 If not IsHelpFile Then 54 msgbox(strErr_NoHelpFile) 55 Exit Sub 56 End If 57 58 oDoc = StarDesktop.CurrentComponent 59 sSwitchType = "" 60 sCaseType = "" 61 sDefaultType = "" 62 bWarn = TRUE 63 bWarnEmptyPara = TRUE 64 bWarnParaNoID = TRUE 65 66 CheckMetaData(oDoc) 67 CheckHeading(oDoc) 68 69 Enum = oDoc.Text.createEnumeration 70 Do While Enum.hasMoreElements 71 72 TextElement = Enum.nextElement 73 If TextElement.supportsService("com.sun.star.text.Paragraph") Then ' we are a paragraph 74 75 CheckSwitches(TextElement) 76 CheckParaID(TextElement) 77 CheckParaFormat(TextElement) 78 CheckTags(TextElement) 79 CheckInlineTags(TextElement) 80 81 ElseIf TextElement.supportsService("com.sun.star.text.TextTable") Then 82 83 If sSwitchType <> "" AND (sCaseType = "" AND sDefaultType = "") Then '<------ 84 Terminate("Switch must be closed or case/default must be opened before a table starts.",tmpCellElement) 85 End If 86 87 CheckCell(TextElement) 88 End If 89 Loop 90 91 If sCaseType <> "" Then 92 Terminate("Previous case ("+sCaseType+") not closed!",TextElement) 93 End If 94 95 If sDefaultType <> "" Then 96 Terminate("Previous default not closed!",TextElement) 97 End If 98 99 If sSwitchType <> "" Then 100 Terminate("Previous switch ("+sSwitchType+") not closed!",TextElement) 101 End If 102 103 If ubound(aTagsOpen()) > 0 Then 104 Terminate("Element "+aTagsOpen(ubound(aTagsOpen()))+" not closed",TextElement) 105 End If 106 107 msgbox("Validation finished.") 108 109End Sub 110 111'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 112' CHECKCELL 113' checks a table cell contents 114'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 115 116Sub CheckCell(TE As Object) 117 On Local Error Goto ERRHANDLE: 118 119 CellName = "A1" 120 Cell = TE.getCellByName(CellName) 121 tmpCellEnum = Cell.createEnumeration 122 tmpCellElement = tmpCellEnum.nextElement 123 124 Rows = TE.getRows 125 Cols = TE.getColumns 126 127 ReDim aCellTagsOpen(0) 128 129 For RowIndex = 1 to Rows.getCount() 130 131 For ColIndex = 1 to Cols.getCount() 132 133 CellName = Chr(64 + ColIndex) & RowIndex 134 Cell = TE.getCellByName(CellName) 135 CellEnum = Cell.createEnumeration 136 137 Do While CellEnum.hasMoreElements 138 139 CellElement = CellEnum.nextElement ' <-- MODIFY, check closed switches within cells 140 141 If CellElement.supportsService("com.sun.star.text.Paragraph") Then 142 CheckSwitchesInCell(CellElement) 143 CheckParaID(CellElement) 144 CheckParaFormat(CellElement) 145 CheckTagsInCell(CellElement) 146 CheckInlineTags(CellElement) 147 EndIf 148 149 Loop 150 151 If sCellCaseType <> "" Then 152 Terminate("Previous case ("+sCellCaseType+") not closed!",CellElement) 153 End If 154 155 If sCellSwitchType <> "" Then 156 Terminate("Previous switch ("+sCellSwitchType+") not closed!",CellElement) 157 End If 158 159 If ubound(aCellTagsOpen()) > 0 Then 160 Terminate("Element "+aCellTagsOpen(ubound(aCellTagsOpen()))+" not closed",CellElement) 161 End If 162 163 Next 164 Next 165 166 ERRHANDLE: 167 If Err <> 0 Then 168 msgbox "Error: "+chr(13)+ Error$,48,"D'oh!" 169 End If 170End Sub 171 172'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 173' CHECK PARA ID 174' checks a paragraph for an ID 175'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 176 177Sub CheckParaID(TE As Object) 178 179 If Left(TE.ParaStyleName,4) = "hlp_" AND Not(Left(TE.ParaStyleName,8) = "hlp_aux_") Then 180 181 sText = TE.GetString 182 183 If sText = "" Then 184 If bWarnEmptyPara Then 185 Warn("Empty Paragraph","Empty paragraphs should be avoided. Do not use empty paragraphs for formatting purpose.",TE) 186 bWarnEmptyPara = FALSE 187 End If 188 Else 189 190 TP = TE.createEnumeration 191 Ct = 0 192 posID = 0 193 194 While TP.hasmoreElements 195 Ct = Ct+1 196 TPE = TP.nextElement 197 If TPE.TextPortionType="TextField" Then 198 If TPE.TextField.TextFieldMaster.Name="ID" Then 199 posID = Ct 200 End If 201 End If 202 ' Lets cheat and allow empty strings before the ID -- otherwise we'll get 203 ' a validation error if a paragraph starts at the top of a page after 204 ' a page break (for whatever reason) 205 If TPE.String = "" Then 206 Ct = Ct-1 207 End If 208 Wend 209 210 If posID = 0 Then 211 If bWarnParaNoID Then 212 Warn("Paragraph has no id.","IDs will be assigned on safe. You can also assign an ID using the Assign Paragraph ID menu item",TPE) 213 bWarnParaNoID = FALSE 214 InsertNewParaData 215 Else 216 oCur = TE.getText.createTextCursorByRange(TE) 217 thiscomponent.getcurrentcontroller.select(oCur) 218 InsertNewParaData 219 End If 220 ElseIf posID > 1 Then 221 Terminate("Paragraph ID not at the start of the paragraph. The paragraph ID must be the first element of a paragraph. Move the ID to the beginning of the paragraph",TPE) 222 End If 223 224 End If 225 226 End If 227End Sub 228 229'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 230' CHECK PARA FORMAT 231'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 232Sub CheckParaFormat(TE As Object) 233 234 sText = TE.GetString 235 If Left(TE.ParaStyleName,4) <> "hlp_" AND sText <> "" Then ' just disregard empty paras in wrong formats 236 Warn("Invalid paragraph format. Contents will be lost.",_ 237 "Use only the paragraph styles starting with ""hlp_""."+_ 238 " Paragraphs in other formats will be lost on export",TE) 239 End If 240 241End Sub 242 243'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 244' CHECK SWITCHES 245'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 246Sub CheckSwitches(TE As Object) 247 248 If TE.ParaStyleName="hlp_aux_switch" Then ' we are a switch or case or default 249 sText = TE.GetString ' get the switch contents 250 251 If Left(sText,8) = "<SWITCH " Then ' an opening switch tag 252 253 If sSwitchType = "" Then ' no other switch is open 254 sSwitchType = Right(sText,Len(sText)-16) 255 sSwitchType = Left(sSwitchType,InStr(sSwitchType,"""")-1) 256 257 If (sSwitchType <> "sys" AND sSwitchType <> "appl" AND sSwitchType <> "distrib") Then 258 Terminate("Unknown switch type """+sSwitchType+"""",TE) 259 End If 260 261 Else 262 Terminate("Previous switch ("+sSwitchType+") not closed!",TE) 263 End If 264 265 End If ' OPENING SWITCH 266 267 If Left(sText,8) = "</SWITCH" Then ' a closing switch tag 268 269 If sSwitchType = "" Then ' there was no switch open 270 Terminate("No switch open!",TE) 271 Else 272 If not(bCaseSet OR bDefaultSet) Then 273 Terminate("Empty switch",TE) 274 End If 275 276 If sCaseType <> "" Then ' there is still a case open 277 Terminate("Previous case ("+sCaseType+") not closed!",TE) 278 End If 279 sSwitchType = "" 280 bDefaultSet = FALSE 281 bCaseSet = FALSE 282 End If 283 284 End If ' CLOSING SWITCH 285 286 If Left(sText,6) = "<CASE " Then ' an opening case tag 287 288 If bDefaultSet Then 289 Terminate("No case after default allowed.",TE) 290 End If 291 292 If sCaseType = "" Then 293 sCaseType = Right(sText,Len(sText)-14) 294 sCaseType = Left(sCaseType,InStr(sCaseType,"""")-1) 295 bCaseSet = TRUE 296 If sSwitchType = "" Then 297 Terminate("Case without switch",TE) 298 End If 299 Else 300 Terminate("Previous case ("+sCaseType+") not closed!",TE) 301 End If 302 303 End If ' OPENING CASE 304 305 If Left(sText,6) = "</CASE" Then ' a closing case tag 306 307 If sCaseType = "" Then 308 Terminate("No case open!",TE) 309 Else 310 sCaseType = "" 311 End If 312 313 End If ' CLOSING CASE 314 315 If Left(sText,8) = "<DEFAULT" Then ' an opening default tag 316 317 If sCaseType = "" Then 318 If (sDefaultType <> "" OR bDefaultSet) Then 319 Terminate("Multiple default not allowed.",TE) 320 Else 321 sDefaultType = "DEFAULT" 322 323 If sSwitchType = "" Then 324 Terminate("Default without switch",TE) 325 End If 326 End If 327 sDefaultType = "DEFAULT" 328 bDefaultSet = TRUE 329 Else 330 Terminate("Previous case ("+sCaseType+") not closed!",TE) 331 End If 332 333 End If ' OPENING CASE 334 335 If Left(sText,9) = "</DEFAULT" Then ' a closing default tag 336 337 If sDefaultType <> "DEFAULT" Then 338 Terminate("No default open!",TE) 339 Else 340 sDefaultType = "" 341 End If 342 343 End If ' CLOSING CASE 344 Else ' We are not hlp_aux_switch 345 If (sSwitchType <> "" AND sCaseType = "" AND sDefaultType = "") Then 346 Terminate("Nothing allowed between switch and case or default or /case or /default and /switch", TE) 347 End If 348 End If 349 350End Sub 351 352'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 353' CHECK SWITCHES IN A CELL 354'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 355Sub CheckSwitchesInCell(CE As Object) 356 357 If CE.ParaStyleName="hlp_aux_switch" Then ' we are a switch or case or default 358 sText = CE.GetString ' get the switch contents 359 360 If Left(sText,8) = "<SWITCH " Then ' an opening switch tag 361 362 If sCellSwitchType = "" Then ' no other switch is open 363 sCellSwitchType = Right(sText,Len(sText)-16) 364 sCellSwitchType = Left(sCellSwitchType,InStr(sCellSwitchType,"""")-1) 365 366 If (sCellSwitchType <> "sys" AND sCellSwitchType <> "appl" AND sCellSwitchType <> "distrib") Then 367 Terminate("Unknown switch type """+sCellSwitchType+"""",CE) 368 End If 369 370 Else 371 Terminate("Previous switch ("+sCellSwitchType+") not closed!",CE) 372 End If 373 374 End If ' OPENING SWITCH 375 376 If Left(sText,8) = "</SWITCH" Then ' a closing switch tag 377 378 If sCellSwitchType = "" Then ' there was no switch open 379 Terminate("No switch open!",CE) 380 Else 381 If not(bCellCaseSet OR bCellDefaultSet) Then 382 Terminate("Empty switch",CE) 383 End If 384 385 If sCellCaseType <> "" Then ' there is still a case open 386 Terminate("Previous case ("+sCellCaseType+") not closed!",CE) 387 End If 388 sCellSwitchType = "" 389 bCellDefaultSet = FALSE 390 bCellCaseSet = FALSE 391 End If 392 393 End If ' CLOSING SWITCH 394 395 If Left(sText,6) = "<CASE " Then ' an opening case tag 396 397 If bCellDefaultSet Then 398 Terminate("No case after default allowed.",CE) 399 End If 400 401 If sCellCaseType = "" Then 402 sCellCaseType = Right(sText,Len(sText)-14) 403 sCellCaseType = Left(sCellCaseType,InStr(sCellCaseType,"""")-1) 404 bCellCaseSet = TRUE 405 If sCellSwitchType = "" Then 406 Terminate("Case without switch",CE) 407 End If 408 Else 409 Terminate("Previous case ("+sCellCaseType+") not closed!",CE) 410 End If 411 412 End If ' OPENING CASE 413 414 If Left(sText,6) = "</CASE" Then ' a closing case tag 415 416 If sCellCaseType = "" Then 417 Terminate("No case open!",CE) 418 Else 419 sCellCaseType = "" 420 End If 421 422 End If ' CLOSING CASE 423 424 If Left(sText,8) = "<DEFAULT" Then ' an opening default tag 425 426 If sCellCaseType = "" Then 427 If (sCellDefaultType <> "" OR bCellDefaultSet) Then 428 Terminate("Multiple default not allowed.",CE) 429 Else 430 sCellDefaultType = "DEFAULT" 431 432 If sCellSwitchType = "" Then 433 Terminate("Default without switch",CE) 434 End If 435 End If 436 sCellDefaultType = "DEFAULT" 437 bCellDefaultSet = TRUE 438 Else 439 Terminate("Previous case ("+sCellCaseType+") not closed!",CE) 440 End If 441 442 End If ' OPENING CASE 443 444 If Left(sText,9) = "</DEFAULT" Then ' a closing default tag 445 446 If sCellDefaultType <> "DEFAULT" Then 447 Terminate("No default open!",CE) 448 Else 449 sCellDefaultType = "" 450 End If 451 452 End If ' CLOSING CASE 453 Else ' We are not hlp_aux_switch 454 If (sCellSwitchType <> "" AND sCellCaseType = "" AND sCellDefaultType = "") Then 455 Terminate("Nothing allowed between switch and case or default or /case or /default and /switch", CE) 456 End If 457 End If 458 459 460End Sub 461 462 463'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 464' TERMINATE VALIDATION WITH AN ERROR MESSAGE 465'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 466Sub Terminate(sStr As String, TE As Object) 467 468 oCur = TE.getText.createTextCursorByRange(TE) 469 thiscomponent.getcurrentcontroller.select(oCur) 470 msgbox sStr,48,"D'oh!" 471 Stop 472 473End Sub 474 475'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 476' SHOW A WARNING 477'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 478Sub Warn(sWarn As String, sSolv As String, Optional TE As Object) 479 480 If bWarn Then 481 BasicLibraries.LoadLibrary("HelpAuthoring") 482 oDialog = LoadDialog("HelpAuthoring", "dlgWarn") 483 oTxtWarn = oDialog.GetControl("txtWarning") 484 oTxtWarn.Text = sWarn 485 oTxtSolv = oDialog.GetControl("txtSolution") 486 oTxtSolv.Text = sSolv 487 488 If not(IsMissing(TE)) Then 489 oCur = TE.getText.createTextCursorByRange(TE) 490 thiscomponent.getcurrentcontroller.select(oCur) 491 End If 492 493 If oDialog.Execute() = 1 Then 494 oCbWarn = oDialog.GetControl("cbWarn") 495 If oCbWarn.State = 1 Then 496 bWarn = FALSE 497 End If 498 Exit Sub 499 Else 500 Stop 501 End If 502 End If 503End Sub 504 505'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 506' CHECK DOCUMENT META DATA 507'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 508Sub CheckMetaData(oDoc As Object) 509 510 sTopicID = oDoc.DocumentInfo.GetUserFieldValue(1) 511 512 If sTopicID <> AlphaNum(sTopicID) OR sTopicID="" Then 513 sTopicID = "topic_"+CreateID ' create a topic id 514 End If 515 516 oDoc.DocumentInfo.SetUserFieldValue(1,sTopicID) 517 sCreated = oDoc.DocumentInfo.GetUserFieldValue(2) 518 sEdited = oDoc.DocumentInfo.GetUserFieldValue(3) 519 sTitle = oDoc.DocumentInfo.Title 520 521 If sTitle="" OR sTitle="<Set Topic Title>" Then 522 Enum = document.Text.createEnumeration 523 Do While Enum.hasMoreElements 524 TextElement = Enum.nextElement 525 If TextElement.supportsService("com.sun.star.text.Paragraph") Then 526 If Left(TextElement.ParaStyleName,8)="hlp_head" Then 527 Enum2 = TextElement.createEnumeration 528 While Enum2.hasMoreElements 529 TextPortion = Enum2.nextElement 530 If Not(TextPortion.TextPortionType="TextField") Then 531 strg = strg + TextPortion.String 532 End If 533 Wend 534 document.DocumentInfo.Title = strg 535 Exit Do 536 End If 537 End If 538 Loop 539 End If 540 541 sIndex = oDoc.DocumentInfo.GetUserFieldValue(0) 542 543End Sub 544 545'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 546' CHECK IF HEADING EXISTS 547'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 548Sub CheckHeading(oDoc As Object) 549 550End Sub 551 552'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 553' CHECK FOR CORRECT INLINE TAGS 554'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 555Sub CheckInlineTags(TE As Object) 556 557 558 559 If Left(TE.ParaStyleName,4)="hlp_" AND (Left(TE.ParaStyleName,8)<>"hlp_aux_" OR TE.ParaStyleName="hlp_aux_bookmark") Then 560 561 Dim aTokens(0) As Object 562 Dim aInlineTagsOpen(0) As String 563 TP = TE.createEnumeration 564 565 While TP.hasmoreElements 566 sDim = ubound(aTokens())+1 567 ReDim Preserve aTokens(sDim) As Object 568 aTokens(sDim) = TP.nextElement 569 Wend 570 571 For i=1 to ubound(aTokens()) 572 Token = aTokens(i) 573 574 If Token.supportsService("com.sun.star.text.TextField") Then 575 sTag = Token.TextField.TextFieldMaster.Name 576 577 If Right(sTag,1)="_" Then ' a tag starts 578 579 sTagName = Left(sTag,Len(sTag)-1) 580 581 ' check for forbidden tags in paragraphs 582 sTagFormat = TagFormatIsCorrect(sTagName, TE.ParaStyleName) 583 If sTagFormat <> "" Then 584 Terminate(sTagName+" element has wrong paragraph style ("+TE.ParaStyleName+")."+chr(13)+"Must be "+sTagFormat,Token) 585 End If 586 587 sDim = ubound(aInlineTagsOpen())+1 588 Redim Preserve aInlineTagsOpen(sDim) as String 589 aInlineTagsOpen(sDim)=sTagName 590 591 ElseIf Left(sTag,1)="_" Then ' a tag ends, all other cases are empty tags 592 593 sTagName = Right(sTag,Len(sTag)-1) 594 595 ' check for forbidden tags in paragraphs 596 sTagFormat = TagFormatIsCorrect(sTagName, TE.ParaStyleName) 597 If sTagFormat <> "" Then 598 Terminate(sTagName+" element has wrong paragraph style ("+TE.ParaStyleName+")."+chr(13)+"Must be "+sTagFormat,Token) 599 End If 600 601 If ubound(aInlineTagsOpen()) > 0 Then 602 If aInlineTagsOpen(ubound(aInlineTagsOpen())) <> sTagName Then 603 Terminate("Inline Element "+aInlineTagsOpen(ubound(aInlineTagsOpen()))+" not closed",Token) 604 End If 605 sDim = ubound(aInlineTagsOpen())-1 606 Else 607 Terminate("No opening tag for "+sTagName,Token) 608 End If 609 Redim Preserve aInlineTagsOpen(sDim) as String 610 611 Else ' empty tag 612 sTagName = sTag 613 sTagFormat = TagFormatIsCorrect(sTagName, TE.ParaStyleName) 614 If sTagFormat <> "" Then 615 Terminate(sTagName+" element has wrong paragraph style ("+TE.ParaStyleName+")."+chr(13)+"Must be "+sTagFormat,Token) 616 End If 617 618 EndIf 619 ElseIf (i > 1) AND (Trim(Token.String) <> "") Then 620 If aInlineTagsOpen(ubound(aInlineTagsOpen())) = "SWITCHINLINE" Then 621 Terminate("No text allowed here.",Token) 622 End If 623 End If 624 Next 625 626 If ubound(aInlineTagsOpen()) > 0 Then 627 Terminate("Inline Element "+aInlineTagsOpen(ubound(aInlineTagsOpen()))+" not closed",Token) 628 End If 629 630 End If 631End Sub 632 633'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 634' CHECK FOR CORRECT TAGS 635'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 636Sub CheckTags(TE As Object) 637 If (Left(TE.ParaStyleName,8) = "hlp_aux_" AND TE.ParaStyleName <> "hlp_aux_bookmark") Then 638 639 TP = TE.createEnumeration 640 641 While TP.hasmoreElements 642 TPE = TP.nextElement 643 644 If TPE.supportsService("com.sun.star.text.TextField") Then 645 sTag = TPE.TextField.TextFieldMaster.Name 646 If Right(sTag,1)="_" Then ' a tag starts 647 648 sTagName = Left(sTag,Len(sTag)-1) 649 sDim = ubound(aTagsOpen())+1 650 Redim Preserve aTagsOpen(sDim) as String 651 aTagsOpen(sDim)=sTagName 652 653 ElseIf Left(sTag,1)="_" Then ' a tag ends, all other cases are empty tags 654 655 sTagName = Right(sTag,Len(sTag)-1) 656 If ubound(aTagsOpen()) > 0 Then 657 If aTagsOpen(ubound(aTagsOpen())) <> sTagName Then 658 Terminate("No close tag for "+aTagsOpen(ubound(aTagsOpen())),TPE) 659 Else 660 sDim = ubound(aTagsOpen())-1 661 End If 662 Else 663 Terminate("No opening tag for "+sTagName,TPE) 664 End If 665 Redim Preserve aTagsOpen(sDim) as String 666 667 Else ' empty tags 668 669 EndIf 670 End If 671 Wend 672 End If 673End Sub 674 675'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 676' CHECK FOR CORRECT TAGS IN A TABLE CELL 677'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 678Sub CheckTagsInCell(CE As Object) 679 If (Left(CE.ParaStyleName,8) = "hlp_aux_" AND CE.ParaStyleName <> "hlp_aux_bookmark") Then 680 681 CP = CE.createEnumeration 682 683 While CP.hasmoreElements 684 CPE = CP.nextElement 685 686 If CPE.supportsService("com.sun.star.text.TextField") Then 687 sTag = CPE.TextField.TextFieldMaster.Name 688 If Right(sTag,1)="_" Then ' a tag starts 689 690 sTagName = Left(sTag,Len(sTag)-1) 691 sDim = ubound(aCellTagsOpen())+1 692 Redim Preserve aCellTagsOpen(sDim) as String 693 aCellTagsOpen(sDim)=sTagName 694 695 ElseIf Left(sTag,1)="_" Then ' a tag ends, all other cases are empty tags 696 697 sTagName = Right(sTag,Len(sTag)-1) 698 If ubound(aCellTagsOpen()) > 0 Then 699 If aCellTagsOpen(ubound(aCellTagsOpen())) <> sTagName Then 700 Terminate("No close tag for "+aCellTagsOpen(ubound(aCellTagsOpen())),CPE) 701 Else 702 sDim = ubound(aCellTagsOpen())-1 703 End If 704 Else 705 Terminate("No opening tag for "+sTagName,CPE) 706 End If 707 Redim Preserve aCellTagsOpen(sDim) as String 708 709 EndIf 710 End If 711 Wend 712 End If 713End Sub 714 715</script:module> 716