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