blob: aa19a3609a6988e45e4c3132c897b929e3992f81 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<!--***********************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
***********************************************************-->
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Validate" script:language="StarBasic">
&apos;############################################
&apos; VALIDATION ROUTINES
&apos;
&apos; May, 19 2004 - fpe
&apos;############################################
Dim sSwitchType As String
Dim sCellSwitchType As String
Dim sCaseType As String
Dim sCellCaseType As String
Dim sDefaultType As String
Dim sCellDefaultType As String
Dim bDefaultSet As Boolean
Dim bCellDefaultSet As Boolean
Dim bCaseSet As Boolean
Dim bCellCaseSet As Boolean
Dim aTagsOpen(0) As String
Dim aCellTagsOpen(0) As String
Dim bWarn As Boolean
Dim bWarnEmptyPara As Boolean
Dim bWarnParaNoID As Boolean
Sub ValidateXHP
Validate
End Sub
Sub Validate
If not IsHelpFile Then
msgbox(strErr_NoHelpFile)
Exit Sub
End If
oDoc = StarDesktop.CurrentComponent
sSwitchType = &quot;&quot;
sCaseType = &quot;&quot;
sDefaultType = &quot;&quot;
bWarn = TRUE
bWarnEmptyPara = TRUE
bWarnParaNoID = TRUE
CheckMetaData(oDoc)
CheckHeading(oDoc)
Enum = oDoc.Text.createEnumeration
Do While Enum.hasMoreElements
TextElement = Enum.nextElement
If TextElement.supportsService(&quot;com.sun.star.text.Paragraph&quot;) Then &apos; we are a paragraph
CheckSwitches(TextElement)
CheckParaID(TextElement)
CheckParaFormat(TextElement)
CheckTags(TextElement)
CheckInlineTags(TextElement)
ElseIf TextElement.supportsService(&quot;com.sun.star.text.TextTable&quot;) Then
If sSwitchType &lt;&gt; &quot;&quot; AND (sCaseType = &quot;&quot; AND sDefaultType = &quot;&quot;) Then &apos;&lt;------
Terminate(&quot;Switch must be closed or case/default must be opened before a table starts.&quot;,tmpCellElement)
End If
CheckCell(TextElement)
End If
Loop
If sCaseType &lt;&gt; &quot;&quot; Then
Terminate(&quot;Previous case (&quot;+sCaseType+&quot;) not closed!&quot;,TextElement)
End If
If sDefaultType &lt;&gt; &quot;&quot; Then
Terminate(&quot;Previous default not closed!&quot;,TextElement)
End If
If sSwitchType &lt;&gt; &quot;&quot; Then
Terminate(&quot;Previous switch (&quot;+sSwitchType+&quot;) not closed!&quot;,TextElement)
End If
If ubound(aTagsOpen()) &gt; 0 Then
Terminate(&quot;Element &quot;+aTagsOpen(ubound(aTagsOpen()))+&quot; not closed&quot;,TextElement)
End If
msgbox(&quot;Validation finished.&quot;)
End Sub
&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
&apos; CHECKCELL
&apos; checks a table cell contents
&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Sub CheckCell(TE As Object)
On Local Error Goto ERRHANDLE:
CellName = &quot;A1&quot;
Cell = TE.getCellByName(CellName)
tmpCellEnum = Cell.createEnumeration
tmpCellElement = tmpCellEnum.nextElement
Rows = TE.getRows
Cols = TE.getColumns
ReDim aCellTagsOpen(0)
For RowIndex = 1 to Rows.getCount()
For ColIndex = 1 to Cols.getCount()
CellName = Chr(64 + ColIndex) &amp; RowIndex
Cell = TE.getCellByName(CellName)
CellEnum = Cell.createEnumeration
Do While CellEnum.hasMoreElements
CellElement = CellEnum.nextElement &apos; &lt;-- MODIFY, check closed switches within cells
If CellElement.supportsService(&quot;com.sun.star.text.Paragraph&quot;) Then
CheckSwitchesInCell(CellElement)
CheckParaID(CellElement)
CheckParaFormat(CellElement)
CheckTagsInCell(CellElement)
CheckInlineTags(CellElement)
EndIf
Loop
If sCellCaseType &lt;&gt; &quot;&quot; Then
Terminate(&quot;Previous case (&quot;+sCellCaseType+&quot;) not closed!&quot;,CellElement)
End If
If sCellSwitchType &lt;&gt; &quot;&quot; Then
Terminate(&quot;Previous switch (&quot;+sCellSwitchType+&quot;) not closed!&quot;,CellElement)
End If
If ubound(aCellTagsOpen()) &gt; 0 Then
Terminate(&quot;Element &quot;+aCellTagsOpen(ubound(aCellTagsOpen()))+&quot; not closed&quot;,CellElement)
End If
Next
Next
ERRHANDLE:
If Err &lt;&gt; 0 Then
msgbox &quot;Error: &quot;+chr(13)+ Error$,48,&quot;D&apos;oh!&quot;
End If
End Sub
&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
&apos; CHECK PARA ID
&apos; checks a paragraph for an ID
&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Sub CheckParaID(TE As Object)
If Left(TE.ParaStyleName,4) = &quot;hlp_&quot; AND Not(Left(TE.ParaStyleName,8) = &quot;hlp_aux_&quot;) Then
sText = TE.GetString
If sText = &quot;&quot; Then
If bWarnEmptyPara Then
Warn(&quot;Empty Paragraph&quot;,&quot;Empty paragraphs should be avoided. Do not use empty paragraphs for formatting purpose.&quot;,TE)
bWarnEmptyPara = FALSE
End If
Else
TP = TE.createEnumeration
Ct = 0
posID = 0
While TP.hasmoreElements
Ct = Ct+1
TPE = TP.nextElement
If TPE.TextPortionType=&quot;TextField&quot; Then
If TPE.TextField.TextFieldMaster.Name=&quot;ID&quot; Then
posID = Ct
End If
End If
&apos; Lets cheat and allow empty strings before the ID -- otherwise we&apos;ll get
&apos; a validation error if a paragraph starts at the top of a page after
&apos; a page break (for whatever reason)
If TPE.String = &quot;&quot; Then
Ct = Ct-1
End If
Wend
If posID = 0 Then
If bWarnParaNoID Then
Warn(&quot;Paragraph has no id.&quot;,&quot;IDs will be assigned on safe. You can also assign an ID using the Assign Paragraph ID menu item&quot;,TPE)
bWarnParaNoID = FALSE
InsertNewParaData
Else
oCur = TE.getText.createTextCursorByRange(TE)
thiscomponent.getcurrentcontroller.select(oCur)
InsertNewParaData
End If
ElseIf posID &gt; 1 Then
Terminate(&quot;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&quot;,TPE)
End If
End If
End If
End Sub
&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
&apos; CHECK PARA FORMAT
&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Sub CheckParaFormat(TE As Object)
sText = TE.GetString
If Left(TE.ParaStyleName,4) &lt;&gt; &quot;hlp_&quot; AND sText &lt;&gt; &quot;&quot; Then &apos; just disregard empty paras in wrong formats
Warn(&quot;Invalid paragraph format. Contents will be lost.&quot;,_
&quot;Use only the paragraph styles starting with &quot;&quot;hlp_&quot;&quot;.&quot;+_
&quot; Paragraphs in other formats will be lost on export&quot;,TE)
End If
End Sub
&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
&apos; CHECK SWITCHES
&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Sub CheckSwitches(TE As Object)
If TE.ParaStyleName=&quot;hlp_aux_switch&quot; Then &apos; we are a switch or case or default
sText = TE.GetString &apos; get the switch contents
If Left(sText,8) = &quot;&lt;SWITCH &quot; Then &apos; an opening switch tag
If sSwitchType = &quot;&quot; Then &apos; no other switch is open
sSwitchType = Right(sText,Len(sText)-16)
sSwitchType = Left(sSwitchType,InStr(sSwitchType,&quot;&quot;&quot;&quot;)-1)
If (sSwitchType &lt;&gt; &quot;sys&quot; AND sSwitchType &lt;&gt; &quot;appl&quot; AND sSwitchType &lt;&gt; &quot;distrib&quot;) Then
Terminate(&quot;Unknown switch type &quot;&quot;&quot;+sSwitchType+&quot;&quot;&quot;&quot;,TE)
End If
Else
Terminate(&quot;Previous switch (&quot;+sSwitchType+&quot;) not closed!&quot;,TE)
End If
End If &apos; OPENING SWITCH
If Left(sText,8) = &quot;&lt;/SWITCH&quot; Then &apos; a closing switch tag
If sSwitchType = &quot;&quot; Then &apos; there was no switch open
Terminate(&quot;No switch open!&quot;,TE)
Else
If not(bCaseSet OR bDefaultSet) Then
Terminate(&quot;Empty switch&quot;,TE)
End If
If sCaseType &lt;&gt; &quot;&quot; Then &apos; there is still a case open
Terminate(&quot;Previous case (&quot;+sCaseType+&quot;) not closed!&quot;,TE)
End If
sSwitchType = &quot;&quot;
bDefaultSet = FALSE
bCaseSet = FALSE
End If
End If &apos; CLOSING SWITCH
If Left(sText,6) = &quot;&lt;CASE &quot; Then &apos; an opening case tag
If bDefaultSet Then
Terminate(&quot;No case after default allowed.&quot;,TE)
End If
If sCaseType = &quot;&quot; Then
sCaseType = Right(sText,Len(sText)-14)
sCaseType = Left(sCaseType,InStr(sCaseType,&quot;&quot;&quot;&quot;)-1)
bCaseSet = TRUE
If sSwitchType = &quot;&quot; Then
Terminate(&quot;Case without switch&quot;,TE)
End If
Else
Terminate(&quot;Previous case (&quot;+sCaseType+&quot;) not closed!&quot;,TE)
End If
End If &apos; OPENING CASE
If Left(sText,6) = &quot;&lt;/CASE&quot; Then &apos; a closing case tag
If sCaseType = &quot;&quot; Then
Terminate(&quot;No case open!&quot;,TE)
Else
sCaseType = &quot;&quot;
End If
End If &apos; CLOSING CASE
If Left(sText,8) = &quot;&lt;DEFAULT&quot; Then &apos; an opening default tag
If sCaseType = &quot;&quot; Then
If (sDefaultType &lt;&gt; &quot;&quot; OR bDefaultSet) Then
Terminate(&quot;Multiple default not allowed.&quot;,TE)
Else
sDefaultType = &quot;DEFAULT&quot;
If sSwitchType = &quot;&quot; Then
Terminate(&quot;Default without switch&quot;,TE)
End If
End If
sDefaultType = &quot;DEFAULT&quot;
bDefaultSet = TRUE
Else
Terminate(&quot;Previous case (&quot;+sCaseType+&quot;) not closed!&quot;,TE)
End If
End If &apos; OPENING CASE
If Left(sText,9) = &quot;&lt;/DEFAULT&quot; Then &apos; a closing default tag
If sDefaultType &lt;&gt; &quot;DEFAULT&quot; Then
Terminate(&quot;No default open!&quot;,TE)
Else
sDefaultType = &quot;&quot;
End If
End If &apos; CLOSING CASE
Else &apos; We are not hlp_aux_switch
If (sSwitchType &lt;&gt; &quot;&quot; AND sCaseType = &quot;&quot; AND sDefaultType = &quot;&quot;) Then
Terminate(&quot;Nothing allowed between switch and case or default or /case or /default and /switch&quot;, TE)
End If
End If
End Sub
&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
&apos; CHECK SWITCHES IN A CELL
&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Sub CheckSwitchesInCell(CE As Object)
If CE.ParaStyleName=&quot;hlp_aux_switch&quot; Then &apos; we are a switch or case or default
sText = CE.GetString &apos; get the switch contents
If Left(sText,8) = &quot;&lt;SWITCH &quot; Then &apos; an opening switch tag
If sCellSwitchType = &quot;&quot; Then &apos; no other switch is open
sCellSwitchType = Right(sText,Len(sText)-16)
sCellSwitchType = Left(sCellSwitchType,InStr(sCellSwitchType,&quot;&quot;&quot;&quot;)-1)
If (sCellSwitchType &lt;&gt; &quot;sys&quot; AND sCellSwitchType &lt;&gt; &quot;appl&quot; AND sCellSwitchType &lt;&gt; &quot;distrib&quot;) Then
Terminate(&quot;Unknown switch type &quot;&quot;&quot;+sCellSwitchType+&quot;&quot;&quot;&quot;,CE)
End If
Else
Terminate(&quot;Previous switch (&quot;+sCellSwitchType+&quot;) not closed!&quot;,CE)
End If
End If &apos; OPENING SWITCH
If Left(sText,8) = &quot;&lt;/SWITCH&quot; Then &apos; a closing switch tag
If sCellSwitchType = &quot;&quot; Then &apos; there was no switch open
Terminate(&quot;No switch open!&quot;,CE)
Else
If not(bCellCaseSet OR bCellDefaultSet) Then
Terminate(&quot;Empty switch&quot;,CE)
End If
If sCellCaseType &lt;&gt; &quot;&quot; Then &apos; there is still a case open
Terminate(&quot;Previous case (&quot;+sCellCaseType+&quot;) not closed!&quot;,CE)
End If
sCellSwitchType = &quot;&quot;
bCellDefaultSet = FALSE
bCellCaseSet = FALSE
End If
End If &apos; CLOSING SWITCH
If Left(sText,6) = &quot;&lt;CASE &quot; Then &apos; an opening case tag
If bCellDefaultSet Then
Terminate(&quot;No case after default allowed.&quot;,CE)
End If
If sCellCaseType = &quot;&quot; Then
sCellCaseType = Right(sText,Len(sText)-14)
sCellCaseType = Left(sCellCaseType,InStr(sCellCaseType,&quot;&quot;&quot;&quot;)-1)
bCellCaseSet = TRUE
If sCellSwitchType = &quot;&quot; Then
Terminate(&quot;Case without switch&quot;,CE)
End If
Else
Terminate(&quot;Previous case (&quot;+sCellCaseType+&quot;) not closed!&quot;,CE)
End If
End If &apos; OPENING CASE
If Left(sText,6) = &quot;&lt;/CASE&quot; Then &apos; a closing case tag
If sCellCaseType = &quot;&quot; Then
Terminate(&quot;No case open!&quot;,CE)
Else
sCellCaseType = &quot;&quot;
End If
End If &apos; CLOSING CASE
If Left(sText,8) = &quot;&lt;DEFAULT&quot; Then &apos; an opening default tag
If sCellCaseType = &quot;&quot; Then
If (sCellDefaultType &lt;&gt; &quot;&quot; OR bCellDefaultSet) Then
Terminate(&quot;Multiple default not allowed.&quot;,CE)
Else
sCellDefaultType = &quot;DEFAULT&quot;
If sCellSwitchType = &quot;&quot; Then
Terminate(&quot;Default without switch&quot;,CE)
End If
End If
sCellDefaultType = &quot;DEFAULT&quot;
bCellDefaultSet = TRUE
Else
Terminate(&quot;Previous case (&quot;+sCellCaseType+&quot;) not closed!&quot;,CE)
End If
End If &apos; OPENING CASE
If Left(sText,9) = &quot;&lt;/DEFAULT&quot; Then &apos; a closing default tag
If sCellDefaultType &lt;&gt; &quot;DEFAULT&quot; Then
Terminate(&quot;No default open!&quot;,CE)
Else
sCellDefaultType = &quot;&quot;
End If
End If &apos; CLOSING CASE
Else &apos; We are not hlp_aux_switch
If (sCellSwitchType &lt;&gt; &quot;&quot; AND sCellCaseType = &quot;&quot; AND sCellDefaultType = &quot;&quot;) Then
Terminate(&quot;Nothing allowed between switch and case or default or /case or /default and /switch&quot;, CE)
End If
End If
End Sub
&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
&apos; TERMINATE VALIDATION WITH AN ERROR MESSAGE
&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Sub Terminate(sStr As String, TE As Object)
oCur = TE.getText.createTextCursorByRange(TE)
thiscomponent.getcurrentcontroller.select(oCur)
msgbox sStr,48,&quot;D&apos;oh!&quot;
Stop
End Sub
&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
&apos; SHOW A WARNING
&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Sub Warn(sWarn As String, sSolv As String, Optional TE As Object)
If bWarn Then
BasicLibraries.LoadLibrary(&quot;HelpAuthoring&quot;)
oDialog = LoadDialog(&quot;HelpAuthoring&quot;, &quot;dlgWarn&quot;)
oTxtWarn = oDialog.GetControl(&quot;txtWarning&quot;)
oTxtWarn.Text = sWarn
oTxtSolv = oDialog.GetControl(&quot;txtSolution&quot;)
oTxtSolv.Text = sSolv
If not(IsMissing(TE)) Then
oCur = TE.getText.createTextCursorByRange(TE)
thiscomponent.getcurrentcontroller.select(oCur)
End If
If oDialog.Execute() = 1 Then
oCbWarn = oDialog.GetControl(&quot;cbWarn&quot;)
If oCbWarn.State = 1 Then
bWarn = FALSE
End If
Exit Sub
Else
Stop
End If
End If
End Sub
&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
&apos; CHECK DOCUMENT META DATA
&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Sub CheckMetaData(oDoc As Object)
sTopicID = oDoc.DocumentInfo.GetUserFieldValue(1)
If sTopicID &lt;&gt; AlphaNum(sTopicID) OR sTopicID=&quot;&quot; Then
sTopicID = &quot;topic_&quot;+CreateID &apos; create a topic id
End If
oDoc.DocumentInfo.SetUserFieldValue(1,sTopicID)
sCreated = oDoc.DocumentInfo.GetUserFieldValue(2)
sEdited = oDoc.DocumentInfo.GetUserFieldValue(3)
sTitle = oDoc.DocumentInfo.Title
If sTitle=&quot;&quot; OR sTitle=&quot;&lt;Set Topic Title&gt;&quot; Then
Enum = document.Text.createEnumeration
Do While Enum.hasMoreElements
TextElement = Enum.nextElement
If TextElement.supportsService(&quot;com.sun.star.text.Paragraph&quot;) Then
If Left(TextElement.ParaStyleName,8)=&quot;hlp_head&quot; Then
Enum2 = TextElement.createEnumeration
While Enum2.hasMoreElements
TextPortion = Enum2.nextElement
If Not(TextPortion.TextPortionType=&quot;TextField&quot;) Then
strg = strg + TextPortion.String
End If
Wend
document.DocumentInfo.Title = strg
Exit Do
End If
End If
Loop
End If
sIndex = oDoc.DocumentInfo.GetUserFieldValue(0)
End Sub
&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
&apos; CHECK IF HEADING EXISTS
&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Sub CheckHeading(oDoc As Object)
End Sub
&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
&apos; CHECK FOR CORRECT INLINE TAGS
&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Sub CheckInlineTags(TE As Object)
If Left(TE.ParaStyleName,4)=&quot;hlp_&quot; AND (Left(TE.ParaStyleName,8)&lt;&gt;&quot;hlp_aux_&quot; OR TE.ParaStyleName=&quot;hlp_aux_bookmark&quot;) Then
Dim aTokens(0) As Object
Dim aInlineTagsOpen(0) As String
TP = TE.createEnumeration
While TP.hasmoreElements
sDim = ubound(aTokens())+1
ReDim Preserve aTokens(sDim) As Object
aTokens(sDim) = TP.nextElement
Wend
For i=1 to ubound(aTokens())
Token = aTokens(i)
If Token.supportsService(&quot;com.sun.star.text.TextField&quot;) Then
sTag = Token.TextField.TextFieldMaster.Name
If Right(sTag,1)=&quot;_&quot; Then &apos; a tag starts
sTagName = Left(sTag,Len(sTag)-1)
&apos; check for forbidden tags in paragraphs
sTagFormat = TagFormatIsCorrect(sTagName, TE.ParaStyleName)
If sTagFormat &lt;&gt; &quot;&quot; Then
Terminate(sTagName+&quot; element has wrong paragraph style (&quot;+TE.ParaStyleName+&quot;).&quot;+chr(13)+&quot;Must be &quot;+sTagFormat,Token)
End If
sDim = ubound(aInlineTagsOpen())+1
Redim Preserve aInlineTagsOpen(sDim) as String
aInlineTagsOpen(sDim)=sTagName
ElseIf Left(sTag,1)=&quot;_&quot; Then &apos; a tag ends, all other cases are empty tags
sTagName = Right(sTag,Len(sTag)-1)
&apos; check for forbidden tags in paragraphs
sTagFormat = TagFormatIsCorrect(sTagName, TE.ParaStyleName)
If sTagFormat &lt;&gt; &quot;&quot; Then
Terminate(sTagName+&quot; element has wrong paragraph style (&quot;+TE.ParaStyleName+&quot;).&quot;+chr(13)+&quot;Must be &quot;+sTagFormat,Token)
End If
If ubound(aInlineTagsOpen()) &gt; 0 Then
If aInlineTagsOpen(ubound(aInlineTagsOpen())) &lt;&gt; sTagName Then
Terminate(&quot;Inline Element &quot;+aInlineTagsOpen(ubound(aInlineTagsOpen()))+&quot; not closed&quot;,Token)
End If
sDim = ubound(aInlineTagsOpen())-1
Else
Terminate(&quot;No opening tag for &quot;+sTagName,Token)
End If
Redim Preserve aInlineTagsOpen(sDim) as String
Else &apos; empty tag
sTagName = sTag
sTagFormat = TagFormatIsCorrect(sTagName, TE.ParaStyleName)
If sTagFormat &lt;&gt; &quot;&quot; Then
Terminate(sTagName+&quot; element has wrong paragraph style (&quot;+TE.ParaStyleName+&quot;).&quot;+chr(13)+&quot;Must be &quot;+sTagFormat,Token)
End If
EndIf
ElseIf (i &gt; 1) AND (Trim(Token.String) &lt;&gt; &quot;&quot;) Then
If aInlineTagsOpen(ubound(aInlineTagsOpen())) = &quot;SWITCHINLINE&quot; Then
Terminate(&quot;No text allowed here.&quot;,Token)
End If
End If
Next
If ubound(aInlineTagsOpen()) &gt; 0 Then
Terminate(&quot;Inline Element &quot;+aInlineTagsOpen(ubound(aInlineTagsOpen()))+&quot; not closed&quot;,Token)
End If
End If
End Sub
&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
&apos; CHECK FOR CORRECT TAGS
&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Sub CheckTags(TE As Object)
If (Left(TE.ParaStyleName,8) = &quot;hlp_aux_&quot; AND TE.ParaStyleName &lt;&gt; &quot;hlp_aux_bookmark&quot;) Then
TP = TE.createEnumeration
While TP.hasmoreElements
TPE = TP.nextElement
If TPE.supportsService(&quot;com.sun.star.text.TextField&quot;) Then
sTag = TPE.TextField.TextFieldMaster.Name
If Right(sTag,1)=&quot;_&quot; Then &apos; a tag starts
sTagName = Left(sTag,Len(sTag)-1)
sDim = ubound(aTagsOpen())+1
Redim Preserve aTagsOpen(sDim) as String
aTagsOpen(sDim)=sTagName
ElseIf Left(sTag,1)=&quot;_&quot; Then &apos; a tag ends, all other cases are empty tags
sTagName = Right(sTag,Len(sTag)-1)
If ubound(aTagsOpen()) &gt; 0 Then
If aTagsOpen(ubound(aTagsOpen())) &lt;&gt; sTagName Then
Terminate(&quot;No close tag for &quot;+aTagsOpen(ubound(aTagsOpen())),TPE)
Else
sDim = ubound(aTagsOpen())-1
End If
Else
Terminate(&quot;No opening tag for &quot;+sTagName,TPE)
End If
Redim Preserve aTagsOpen(sDim) as String
Else &apos; empty tags
EndIf
End If
Wend
End If
End Sub
&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
&apos; CHECK FOR CORRECT TAGS IN A TABLE CELL
&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Sub CheckTagsInCell(CE As Object)
If (Left(CE.ParaStyleName,8) = &quot;hlp_aux_&quot; AND CE.ParaStyleName &lt;&gt; &quot;hlp_aux_bookmark&quot;) Then
CP = CE.createEnumeration
While CP.hasmoreElements
CPE = CP.nextElement
If CPE.supportsService(&quot;com.sun.star.text.TextField&quot;) Then
sTag = CPE.TextField.TextFieldMaster.Name
If Right(sTag,1)=&quot;_&quot; Then &apos; a tag starts
sTagName = Left(sTag,Len(sTag)-1)
sDim = ubound(aCellTagsOpen())+1
Redim Preserve aCellTagsOpen(sDim) as String
aCellTagsOpen(sDim)=sTagName
ElseIf Left(sTag,1)=&quot;_&quot; Then &apos; a tag ends, all other cases are empty tags
sTagName = Right(sTag,Len(sTag)-1)
If ubound(aCellTagsOpen()) &gt; 0 Then
If aCellTagsOpen(ubound(aCellTagsOpen())) &lt;&gt; sTagName Then
Terminate(&quot;No close tag for &quot;+aCellTagsOpen(ubound(aCellTagsOpen())),CPE)
Else
sDim = ubound(aCellTagsOpen())-1
End If
Else
Terminate(&quot;No opening tag for &quot;+sTagName,CPE)
End If
Redim Preserve aCellTagsOpen(sDim) as String
EndIf
End If
Wend
End If
End Sub
</script:module>