11ecadb57SMathias Bauer<?xml version="1.0" encoding="UTF-8"?>
21ecadb57SMathias Bauer<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3*3e02b54dSAndrew Rist<!--***********************************************************
4*3e02b54dSAndrew Rist *
5*3e02b54dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
6*3e02b54dSAndrew Rist * or more contributor license agreements.  See the NOTICE file
7*3e02b54dSAndrew Rist * distributed with this work for additional information
8*3e02b54dSAndrew Rist * regarding copyright ownership.  The ASF licenses this file
9*3e02b54dSAndrew Rist * to you under the Apache License, Version 2.0 (the
10*3e02b54dSAndrew Rist * "License"); you may not use this file except in compliance
11*3e02b54dSAndrew Rist * with the License.  You may obtain a copy of the License at
12*3e02b54dSAndrew Rist *
13*3e02b54dSAndrew Rist *   http://www.apache.org/licenses/LICENSE-2.0
14*3e02b54dSAndrew Rist *
15*3e02b54dSAndrew Rist * Unless required by applicable law or agreed to in writing,
16*3e02b54dSAndrew Rist * software distributed under the License is distributed on an
17*3e02b54dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18*3e02b54dSAndrew Rist * KIND, either express or implied.  See the License for the
19*3e02b54dSAndrew Rist * specific language governing permissions and limitations
20*3e02b54dSAndrew Rist * under the License.
21*3e02b54dSAndrew Rist *
22*3e02b54dSAndrew Rist ***********************************************************-->
231ecadb57SMathias Bauer<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Validate" script:language="StarBasic">
241ecadb57SMathias Bauer&apos;############################################
251ecadb57SMathias Bauer&apos;  VALIDATION ROUTINES
261ecadb57SMathias Bauer&apos;
271ecadb57SMathias Bauer&apos;  May, 19 2004 - fpe
281ecadb57SMathias Bauer&apos;############################################
291ecadb57SMathias Bauer
301ecadb57SMathias BauerDim sSwitchType As String
311ecadb57SMathias BauerDim sCellSwitchType As String
321ecadb57SMathias BauerDim sCaseType As String
331ecadb57SMathias BauerDim sCellCaseType As String
341ecadb57SMathias BauerDim sDefaultType As String
351ecadb57SMathias BauerDim sCellDefaultType As String
361ecadb57SMathias BauerDim bDefaultSet As Boolean
371ecadb57SMathias BauerDim bCellDefaultSet As Boolean
381ecadb57SMathias BauerDim bCaseSet As Boolean
391ecadb57SMathias BauerDim bCellCaseSet As Boolean
401ecadb57SMathias BauerDim aTagsOpen(0) As String
411ecadb57SMathias BauerDim aCellTagsOpen(0) As String
421ecadb57SMathias BauerDim bWarn As Boolean
431ecadb57SMathias BauerDim bWarnEmptyPara As Boolean
441ecadb57SMathias BauerDim bWarnParaNoID As Boolean
451ecadb57SMathias Bauer
461ecadb57SMathias Bauer
471ecadb57SMathias BauerSub ValidateXHP
481ecadb57SMathias Bauer	Validate
491ecadb57SMathias BauerEnd Sub
501ecadb57SMathias Bauer
511ecadb57SMathias BauerSub Validate
521ecadb57SMathias Bauer
531ecadb57SMathias Bauer	If not IsHelpFile Then
541ecadb57SMathias Bauer		msgbox(strErr_NoHelpFile)
551ecadb57SMathias Bauer		Exit Sub
561ecadb57SMathias Bauer	End If
571ecadb57SMathias Bauer
581ecadb57SMathias Bauer	oDoc = StarDesktop.CurrentComponent
591ecadb57SMathias Bauer	sSwitchType = &quot;&quot;
601ecadb57SMathias Bauer	sCaseType = &quot;&quot;
611ecadb57SMathias Bauer	sDefaultType = &quot;&quot;
621ecadb57SMathias Bauer	bWarn = TRUE
631ecadb57SMathias Bauer	bWarnEmptyPara = TRUE
641ecadb57SMathias Bauer	bWarnParaNoID = TRUE
651ecadb57SMathias Bauer
661ecadb57SMathias Bauer	CheckMetaData(oDoc)
671ecadb57SMathias Bauer	CheckHeading(oDoc)
681ecadb57SMathias Bauer
691ecadb57SMathias Bauer	Enum = oDoc.Text.createEnumeration
701ecadb57SMathias Bauer	Do While Enum.hasMoreElements
711ecadb57SMathias Bauer
721ecadb57SMathias Bauer		TextElement = Enum.nextElement
731ecadb57SMathias Bauer		If TextElement.supportsService(&quot;com.sun.star.text.Paragraph&quot;) Then		&apos; we are a paragraph
741ecadb57SMathias Bauer
751ecadb57SMathias Bauer			CheckSwitches(TextElement)
761ecadb57SMathias Bauer			CheckParaID(TextElement)
771ecadb57SMathias Bauer			CheckParaFormat(TextElement)
781ecadb57SMathias Bauer			CheckTags(TextElement)
791ecadb57SMathias Bauer			CheckInlineTags(TextElement)
801ecadb57SMathias Bauer
811ecadb57SMathias Bauer		ElseIf	TextElement.supportsService(&quot;com.sun.star.text.TextTable&quot;) Then
821ecadb57SMathias Bauer
831ecadb57SMathias Bauer			If sSwitchType &lt;&gt; &quot;&quot; AND (sCaseType = &quot;&quot; AND sDefaultType = &quot;&quot;) Then &apos;&lt;------
841ecadb57SMathias Bauer				Terminate(&quot;Switch must be closed or case/default must be opened before a table starts.&quot;,tmpCellElement)
851ecadb57SMathias Bauer			End If
861ecadb57SMathias Bauer
871ecadb57SMathias Bauer			CheckCell(TextElement)
881ecadb57SMathias Bauer		End If
891ecadb57SMathias Bauer	Loop
901ecadb57SMathias Bauer
911ecadb57SMathias Bauer	If sCaseType &lt;&gt; &quot;&quot; Then
921ecadb57SMathias Bauer		Terminate(&quot;Previous case (&quot;+sCaseType+&quot;) not closed!&quot;,TextElement)
931ecadb57SMathias Bauer	End If
941ecadb57SMathias Bauer
951ecadb57SMathias Bauer	If sDefaultType &lt;&gt; &quot;&quot; Then
961ecadb57SMathias Bauer		Terminate(&quot;Previous default not closed!&quot;,TextElement)
971ecadb57SMathias Bauer	End If
981ecadb57SMathias Bauer
991ecadb57SMathias Bauer	If sSwitchType &lt;&gt; &quot;&quot; Then
1001ecadb57SMathias Bauer		Terminate(&quot;Previous switch (&quot;+sSwitchType+&quot;) not closed!&quot;,TextElement)
1011ecadb57SMathias Bauer	End If
1021ecadb57SMathias Bauer
1031ecadb57SMathias Bauer	If ubound(aTagsOpen()) &gt; 0 Then
1041ecadb57SMathias Bauer		Terminate(&quot;Element &quot;+aTagsOpen(ubound(aTagsOpen()))+&quot; not closed&quot;,TextElement)
1051ecadb57SMathias Bauer	End If
1061ecadb57SMathias Bauer
1071ecadb57SMathias Bauer	msgbox(&quot;Validation finished.&quot;)
1081ecadb57SMathias Bauer
1091ecadb57SMathias BauerEnd Sub
1101ecadb57SMathias Bauer
1111ecadb57SMathias Bauer&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1121ecadb57SMathias Bauer&apos; CHECKCELL
1131ecadb57SMathias Bauer&apos; checks a table cell contents
1141ecadb57SMathias Bauer&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1151ecadb57SMathias Bauer
1161ecadb57SMathias BauerSub CheckCell(TE As Object)
1171ecadb57SMathias Bauer	On Local Error Goto ERRHANDLE:
1181ecadb57SMathias Bauer
1191ecadb57SMathias Bauer	CellName = &quot;A1&quot;
1201ecadb57SMathias Bauer	Cell = TE.getCellByName(CellName)
1211ecadb57SMathias Bauer	tmpCellEnum = Cell.createEnumeration
1221ecadb57SMathias Bauer	tmpCellElement = tmpCellEnum.nextElement
1231ecadb57SMathias Bauer
1241ecadb57SMathias Bauer	Rows = TE.getRows
1251ecadb57SMathias Bauer	Cols = TE.getColumns
1261ecadb57SMathias Bauer
1271ecadb57SMathias Bauer	ReDim aCellTagsOpen(0)
1281ecadb57SMathias Bauer
1291ecadb57SMathias Bauer	For RowIndex = 1 to Rows.getCount()
1301ecadb57SMathias Bauer
1311ecadb57SMathias Bauer		For ColIndex = 1 to Cols.getCount()
1321ecadb57SMathias Bauer
1331ecadb57SMathias Bauer			CellName = Chr(64 + ColIndex) &amp; RowIndex
1341ecadb57SMathias Bauer			Cell = TE.getCellByName(CellName)
1351ecadb57SMathias Bauer			CellEnum = Cell.createEnumeration
1361ecadb57SMathias Bauer
1371ecadb57SMathias Bauer			Do While CellEnum.hasMoreElements
1381ecadb57SMathias Bauer
1391ecadb57SMathias Bauer				CellElement = CellEnum.nextElement		&apos; &lt;-- MODIFY, check closed switches within cells
1401ecadb57SMathias Bauer
1411ecadb57SMathias Bauer				If CellElement.supportsService(&quot;com.sun.star.text.Paragraph&quot;) Then
1421ecadb57SMathias Bauer					CheckSwitchesInCell(CellElement)
1431ecadb57SMathias Bauer					CheckParaID(CellElement)
1441ecadb57SMathias Bauer					CheckParaFormat(CellElement)
1451ecadb57SMathias Bauer					CheckTagsInCell(CellElement)
1461ecadb57SMathias Bauer					CheckInlineTags(CellElement)
1471ecadb57SMathias Bauer				EndIf
1481ecadb57SMathias Bauer
1491ecadb57SMathias Bauer			Loop
1501ecadb57SMathias Bauer
1511ecadb57SMathias Bauer			If sCellCaseType &lt;&gt; &quot;&quot; Then
1521ecadb57SMathias Bauer				Terminate(&quot;Previous case (&quot;+sCellCaseType+&quot;) not closed!&quot;,CellElement)
1531ecadb57SMathias Bauer			End If
1541ecadb57SMathias Bauer
1551ecadb57SMathias Bauer			If sCellSwitchType &lt;&gt; &quot;&quot; Then
1561ecadb57SMathias Bauer				Terminate(&quot;Previous switch (&quot;+sCellSwitchType+&quot;) not closed!&quot;,CellElement)
1571ecadb57SMathias Bauer			End If
1581ecadb57SMathias Bauer
1591ecadb57SMathias Bauer			If ubound(aCellTagsOpen()) &gt; 0 Then
1601ecadb57SMathias Bauer				Terminate(&quot;Element &quot;+aCellTagsOpen(ubound(aCellTagsOpen()))+&quot; not closed&quot;,CellElement)
1611ecadb57SMathias Bauer			End If
1621ecadb57SMathias Bauer
1631ecadb57SMathias Bauer		Next
1641ecadb57SMathias Bauer	Next
1651ecadb57SMathias Bauer
1661ecadb57SMathias Bauer	ERRHANDLE:
1671ecadb57SMathias Bauer		If Err &lt;&gt; 0 Then
1681ecadb57SMathias Bauer			msgbox &quot;Error: &quot;+chr(13)+ Error$,48,&quot;D&apos;oh!&quot;
1691ecadb57SMathias Bauer		End If
1701ecadb57SMathias BauerEnd Sub
1711ecadb57SMathias Bauer
1721ecadb57SMathias Bauer&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1731ecadb57SMathias Bauer&apos; CHECK PARA ID
1741ecadb57SMathias Bauer&apos; checks a paragraph for an ID
1751ecadb57SMathias Bauer&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1761ecadb57SMathias Bauer
1771ecadb57SMathias BauerSub CheckParaID(TE As Object)
1781ecadb57SMathias Bauer
1791ecadb57SMathias Bauer	If Left(TE.ParaStyleName,4) = &quot;hlp_&quot; AND Not(Left(TE.ParaStyleName,8) = &quot;hlp_aux_&quot;) Then
1801ecadb57SMathias Bauer
1811ecadb57SMathias Bauer		sText = TE.GetString
1821ecadb57SMathias Bauer
1831ecadb57SMathias Bauer		If sText = &quot;&quot; Then
1841ecadb57SMathias Bauer			If bWarnEmptyPara Then
1851ecadb57SMathias Bauer				Warn(&quot;Empty Paragraph&quot;,&quot;Empty paragraphs should be avoided. Do not use empty paragraphs for formatting purpose.&quot;,TE)
1861ecadb57SMathias Bauer				bWarnEmptyPara = FALSE
1871ecadb57SMathias Bauer			End If
1881ecadb57SMathias Bauer		Else
1891ecadb57SMathias Bauer
1901ecadb57SMathias Bauer			TP = TE.createEnumeration
1911ecadb57SMathias Bauer			Ct = 0
1921ecadb57SMathias Bauer			posID = 0
1931ecadb57SMathias Bauer
1941ecadb57SMathias Bauer			While TP.hasmoreElements
1951ecadb57SMathias Bauer				Ct = Ct+1
1961ecadb57SMathias Bauer				TPE = TP.nextElement
1971ecadb57SMathias Bauer				If TPE.TextPortionType=&quot;TextField&quot; Then
1981ecadb57SMathias Bauer					If TPE.TextField.TextFieldMaster.Name=&quot;ID&quot; Then
1991ecadb57SMathias Bauer						posID = Ct
2001ecadb57SMathias Bauer					End If
2011ecadb57SMathias Bauer				End If
2021ecadb57SMathias Bauer				&apos; Lets cheat and allow empty strings before the ID -- otherwise we&apos;ll get
2031ecadb57SMathias Bauer				&apos; a validation error if a paragraph starts at the top of a page after
2041ecadb57SMathias Bauer				&apos; a page break (for whatever reason)
2051ecadb57SMathias Bauer				If TPE.String = &quot;&quot; Then
2061ecadb57SMathias Bauer					Ct = Ct-1
2071ecadb57SMathias Bauer				End If
2081ecadb57SMathias Bauer			Wend
2091ecadb57SMathias Bauer
2101ecadb57SMathias Bauer			If posID = 0 Then
2111ecadb57SMathias Bauer				If bWarnParaNoID Then
2121ecadb57SMathias Bauer	 				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)
2131ecadb57SMathias Bauer	 				bWarnParaNoID = FALSE
2141ecadb57SMathias Bauer					InsertNewParaData
2151ecadb57SMathias Bauer	 			Else
2161ecadb57SMathias Bauer	 				oCur = TE.getText.createTextCursorByRange(TE)
2171ecadb57SMathias Bauer					thiscomponent.getcurrentcontroller.select(oCur)
2181ecadb57SMathias Bauer					InsertNewParaData
2191ecadb57SMathias Bauer	 			End If
2201ecadb57SMathias Bauer			ElseIf posID &gt; 1 Then
2211ecadb57SMathias Bauer				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)
2221ecadb57SMathias Bauer			End If
2231ecadb57SMathias Bauer
2241ecadb57SMathias Bauer		End If
2251ecadb57SMathias Bauer
2261ecadb57SMathias Bauer	End If
2271ecadb57SMathias BauerEnd Sub
2281ecadb57SMathias Bauer
2291ecadb57SMathias Bauer&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2301ecadb57SMathias Bauer&apos; CHECK PARA FORMAT
2311ecadb57SMathias Bauer&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2321ecadb57SMathias BauerSub CheckParaFormat(TE As Object)
2331ecadb57SMathias Bauer
2341ecadb57SMathias Bauer	sText = TE.GetString
2351ecadb57SMathias Bauer	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
2361ecadb57SMathias Bauer		Warn(&quot;Invalid paragraph format. Contents will be lost.&quot;,_
2371ecadb57SMathias Bauer		     &quot;Use only the paragraph styles starting with &quot;&quot;hlp_&quot;&quot;.&quot;+_
2381ecadb57SMathias Bauer		     &quot; Paragraphs in other formats will be lost on export&quot;,TE)
2391ecadb57SMathias Bauer	End If
2401ecadb57SMathias Bauer
2411ecadb57SMathias BauerEnd Sub
2421ecadb57SMathias Bauer
2431ecadb57SMathias Bauer&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2441ecadb57SMathias Bauer&apos; CHECK SWITCHES
2451ecadb57SMathias Bauer&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2461ecadb57SMathias BauerSub CheckSwitches(TE As Object)
2471ecadb57SMathias Bauer
2481ecadb57SMathias Bauer	If TE.ParaStyleName=&quot;hlp_aux_switch&quot; Then					&apos; we are a switch or case or default
2491ecadb57SMathias Bauer		sText = TE.GetString									&apos; get the switch contents
2501ecadb57SMathias Bauer
2511ecadb57SMathias Bauer		If Left(sText,8) = &quot;&lt;SWITCH &quot; Then								&apos; an opening switch tag
2521ecadb57SMathias Bauer
2531ecadb57SMathias Bauer			If sSwitchType = &quot;&quot; Then									&apos; no other switch is open
2541ecadb57SMathias Bauer				sSwitchType = Right(sText,Len(sText)-16)
2551ecadb57SMathias Bauer				sSwitchType = Left(sSwitchType,InStr(sSwitchType,&quot;&quot;&quot;&quot;)-1)
2561ecadb57SMathias Bauer
2571ecadb57SMathias Bauer				If (sSwitchType &lt;&gt; &quot;sys&quot; AND sSwitchType &lt;&gt; &quot;appl&quot; AND sSwitchType &lt;&gt; &quot;distrib&quot;) Then
2581ecadb57SMathias Bauer					Terminate(&quot;Unknown switch type &quot;&quot;&quot;+sSwitchType+&quot;&quot;&quot;&quot;,TE)
2591ecadb57SMathias Bauer				End If
2601ecadb57SMathias Bauer
2611ecadb57SMathias Bauer			Else
2621ecadb57SMathias Bauer				Terminate(&quot;Previous switch (&quot;+sSwitchType+&quot;) not closed!&quot;,TE)
2631ecadb57SMathias Bauer			End If
2641ecadb57SMathias Bauer
2651ecadb57SMathias Bauer		End If	&apos; OPENING SWITCH
2661ecadb57SMathias Bauer
2671ecadb57SMathias Bauer		If Left(sText,8) = &quot;&lt;/SWITCH&quot; Then								&apos; a closing switch tag
2681ecadb57SMathias Bauer
2691ecadb57SMathias Bauer			If sSwitchType = &quot;&quot; Then									&apos; there was no switch open
2701ecadb57SMathias Bauer				Terminate(&quot;No switch open!&quot;,TE)
2711ecadb57SMathias Bauer			Else
2721ecadb57SMathias Bauer				If not(bCaseSet OR bDefaultSet) Then
2731ecadb57SMathias Bauer					Terminate(&quot;Empty switch&quot;,TE)
2741ecadb57SMathias Bauer				End If
2751ecadb57SMathias Bauer
2761ecadb57SMathias Bauer				If sCaseType &lt;&gt; &quot;&quot; Then									&apos; there is still a case open
2771ecadb57SMathias Bauer					Terminate(&quot;Previous case (&quot;+sCaseType+&quot;) not closed!&quot;,TE)
2781ecadb57SMathias Bauer				End If
2791ecadb57SMathias Bauer				sSwitchType = &quot;&quot;
2801ecadb57SMathias Bauer				bDefaultSet = FALSE
2811ecadb57SMathias Bauer				bCaseSet = FALSE
2821ecadb57SMathias Bauer			End If
2831ecadb57SMathias Bauer
2841ecadb57SMathias Bauer		End If  &apos; CLOSING SWITCH
2851ecadb57SMathias Bauer
2861ecadb57SMathias Bauer		If Left(sText,6) = &quot;&lt;CASE &quot; Then								&apos; an opening case tag
2871ecadb57SMathias Bauer
2881ecadb57SMathias Bauer			If bDefaultSet Then
2891ecadb57SMathias Bauer				Terminate(&quot;No case after default allowed.&quot;,TE)
2901ecadb57SMathias Bauer			End If
2911ecadb57SMathias Bauer
2921ecadb57SMathias Bauer			If sCaseType = &quot;&quot; Then
2931ecadb57SMathias Bauer				sCaseType = Right(sText,Len(sText)-14)
2941ecadb57SMathias Bauer				sCaseType = Left(sCaseType,InStr(sCaseType,&quot;&quot;&quot;&quot;)-1)
2951ecadb57SMathias Bauer				bCaseSet = TRUE
2961ecadb57SMathias Bauer				If sSwitchType = &quot;&quot; Then
2971ecadb57SMathias Bauer					Terminate(&quot;Case without switch&quot;,TE)
2981ecadb57SMathias Bauer				End If
2991ecadb57SMathias Bauer			Else
3001ecadb57SMathias Bauer				Terminate(&quot;Previous case (&quot;+sCaseType+&quot;) not closed!&quot;,TE)
3011ecadb57SMathias Bauer			End If
3021ecadb57SMathias Bauer
3031ecadb57SMathias Bauer		End If  &apos; OPENING CASE
3041ecadb57SMathias Bauer
3051ecadb57SMathias Bauer		If Left(sText,6) = &quot;&lt;/CASE&quot; Then								&apos; a closing case tag
3061ecadb57SMathias Bauer
3071ecadb57SMathias Bauer			If sCaseType = &quot;&quot; Then
3081ecadb57SMathias Bauer				Terminate(&quot;No case open!&quot;,TE)
3091ecadb57SMathias Bauer			Else
3101ecadb57SMathias Bauer				sCaseType = &quot;&quot;
3111ecadb57SMathias Bauer			End If
3121ecadb57SMathias Bauer
3131ecadb57SMathias Bauer		End If  &apos; CLOSING  CASE
3141ecadb57SMathias Bauer
3151ecadb57SMathias Bauer		If Left(sText,8) = &quot;&lt;DEFAULT&quot; Then								&apos; an opening default tag
3161ecadb57SMathias Bauer
3171ecadb57SMathias Bauer			If sCaseType = &quot;&quot; Then
3181ecadb57SMathias Bauer				If (sDefaultType &lt;&gt; &quot;&quot; OR bDefaultSet) Then
3191ecadb57SMathias Bauer					Terminate(&quot;Multiple default not allowed.&quot;,TE)
3201ecadb57SMathias Bauer				Else
3211ecadb57SMathias Bauer					sDefaultType = &quot;DEFAULT&quot;
3221ecadb57SMathias Bauer
3231ecadb57SMathias Bauer					If sSwitchType = &quot;&quot; Then
3241ecadb57SMathias Bauer						Terminate(&quot;Default without switch&quot;,TE)
3251ecadb57SMathias Bauer					End If
3261ecadb57SMathias Bauer				End If
3271ecadb57SMathias Bauer				sDefaultType = &quot;DEFAULT&quot;
3281ecadb57SMathias Bauer				bDefaultSet = TRUE
3291ecadb57SMathias Bauer			Else
3301ecadb57SMathias Bauer				Terminate(&quot;Previous case (&quot;+sCaseType+&quot;) not closed!&quot;,TE)
3311ecadb57SMathias Bauer			End If
3321ecadb57SMathias Bauer
3331ecadb57SMathias Bauer		End If  &apos; OPENING CASE
3341ecadb57SMathias Bauer
3351ecadb57SMathias Bauer		If Left(sText,9) = &quot;&lt;/DEFAULT&quot; Then								&apos; a closing default tag
3361ecadb57SMathias Bauer
3371ecadb57SMathias Bauer			If sDefaultType &lt;&gt; &quot;DEFAULT&quot; Then
3381ecadb57SMathias Bauer				Terminate(&quot;No default open!&quot;,TE)
3391ecadb57SMathias Bauer			Else
3401ecadb57SMathias Bauer				sDefaultType = &quot;&quot;
3411ecadb57SMathias Bauer			End If
3421ecadb57SMathias Bauer
3431ecadb57SMathias Bauer		End If  &apos; CLOSING  CASE
3441ecadb57SMathias Bauer	Else  &apos; We are not hlp_aux_switch
3451ecadb57SMathias Bauer		If (sSwitchType &lt;&gt; &quot;&quot; AND sCaseType = &quot;&quot; AND sDefaultType = &quot;&quot;) Then
3461ecadb57SMathias Bauer			Terminate(&quot;Nothing allowed between switch and case or default or /case or /default and /switch&quot;, TE)
3471ecadb57SMathias Bauer		End If
3481ecadb57SMathias Bauer	End If
3491ecadb57SMathias Bauer
3501ecadb57SMathias BauerEnd Sub
3511ecadb57SMathias Bauer
3521ecadb57SMathias Bauer&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3531ecadb57SMathias Bauer&apos; CHECK SWITCHES IN A CELL
3541ecadb57SMathias Bauer&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3551ecadb57SMathias BauerSub CheckSwitchesInCell(CE As Object)
3561ecadb57SMathias Bauer
3571ecadb57SMathias Bauer	If CE.ParaStyleName=&quot;hlp_aux_switch&quot; Then					&apos; we are a switch or case or default
3581ecadb57SMathias Bauer		sText = CE.GetString									&apos; get the switch contents
3591ecadb57SMathias Bauer
3601ecadb57SMathias Bauer		If Left(sText,8) = &quot;&lt;SWITCH &quot; Then								&apos; an opening switch tag
3611ecadb57SMathias Bauer
3621ecadb57SMathias Bauer			If sCellSwitchType = &quot;&quot; Then									&apos; no other switch is open
3631ecadb57SMathias Bauer				sCellSwitchType = Right(sText,Len(sText)-16)
3641ecadb57SMathias Bauer				sCellSwitchType = Left(sCellSwitchType,InStr(sCellSwitchType,&quot;&quot;&quot;&quot;)-1)
3651ecadb57SMathias Bauer
3661ecadb57SMathias Bauer				If (sCellSwitchType &lt;&gt; &quot;sys&quot; AND sCellSwitchType &lt;&gt; &quot;appl&quot; AND sCellSwitchType &lt;&gt; &quot;distrib&quot;) Then
3671ecadb57SMathias Bauer					Terminate(&quot;Unknown switch type &quot;&quot;&quot;+sCellSwitchType+&quot;&quot;&quot;&quot;,CE)
3681ecadb57SMathias Bauer				End If
3691ecadb57SMathias Bauer
3701ecadb57SMathias Bauer			Else
3711ecadb57SMathias Bauer				Terminate(&quot;Previous switch (&quot;+sCellSwitchType+&quot;) not closed!&quot;,CE)
3721ecadb57SMathias Bauer			End If
3731ecadb57SMathias Bauer
3741ecadb57SMathias Bauer		End If	&apos; OPENING SWITCH
3751ecadb57SMathias Bauer
3761ecadb57SMathias Bauer		If Left(sText,8) = &quot;&lt;/SWITCH&quot; Then								&apos; a closing switch tag
3771ecadb57SMathias Bauer
3781ecadb57SMathias Bauer			If sCellSwitchType = &quot;&quot; Then									&apos; there was no switch open
3791ecadb57SMathias Bauer				Terminate(&quot;No switch open!&quot;,CE)
3801ecadb57SMathias Bauer			Else
3811ecadb57SMathias Bauer				If not(bCellCaseSet OR bCellDefaultSet) Then
3821ecadb57SMathias Bauer					Terminate(&quot;Empty switch&quot;,CE)
3831ecadb57SMathias Bauer				End If
3841ecadb57SMathias Bauer
3851ecadb57SMathias Bauer				If sCellCaseType &lt;&gt; &quot;&quot; Then									&apos; there is still a case open
3861ecadb57SMathias Bauer					Terminate(&quot;Previous case (&quot;+sCellCaseType+&quot;) not closed!&quot;,CE)
3871ecadb57SMathias Bauer				End If
3881ecadb57SMathias Bauer				sCellSwitchType = &quot;&quot;
3891ecadb57SMathias Bauer				bCellDefaultSet = FALSE
3901ecadb57SMathias Bauer				bCellCaseSet = FALSE
3911ecadb57SMathias Bauer			End If
3921ecadb57SMathias Bauer
3931ecadb57SMathias Bauer		End If  &apos; CLOSING SWITCH
3941ecadb57SMathias Bauer
3951ecadb57SMathias Bauer		If Left(sText,6) = &quot;&lt;CASE &quot; Then								&apos; an opening case tag
3961ecadb57SMathias Bauer
3971ecadb57SMathias Bauer			If bCellDefaultSet Then
3981ecadb57SMathias Bauer				Terminate(&quot;No case after default allowed.&quot;,CE)
3991ecadb57SMathias Bauer			End If
4001ecadb57SMathias Bauer
4011ecadb57SMathias Bauer			If sCellCaseType = &quot;&quot; Then
4021ecadb57SMathias Bauer				sCellCaseType = Right(sText,Len(sText)-14)
4031ecadb57SMathias Bauer				sCellCaseType = Left(sCellCaseType,InStr(sCellCaseType,&quot;&quot;&quot;&quot;)-1)
4041ecadb57SMathias Bauer				bCellCaseSet = TRUE
4051ecadb57SMathias Bauer				If sCellSwitchType = &quot;&quot; Then
4061ecadb57SMathias Bauer					Terminate(&quot;Case without switch&quot;,CE)
4071ecadb57SMathias Bauer				End If
4081ecadb57SMathias Bauer			Else
4091ecadb57SMathias Bauer				Terminate(&quot;Previous case (&quot;+sCellCaseType+&quot;) not closed!&quot;,CE)
4101ecadb57SMathias Bauer			End If
4111ecadb57SMathias Bauer
4121ecadb57SMathias Bauer		End If  &apos; OPENING CASE
4131ecadb57SMathias Bauer
4141ecadb57SMathias Bauer		If Left(sText,6) = &quot;&lt;/CASE&quot; Then								&apos; a closing case tag
4151ecadb57SMathias Bauer
4161ecadb57SMathias Bauer			If sCellCaseType = &quot;&quot; Then
4171ecadb57SMathias Bauer				Terminate(&quot;No case open!&quot;,CE)
4181ecadb57SMathias Bauer			Else
4191ecadb57SMathias Bauer				sCellCaseType = &quot;&quot;
4201ecadb57SMathias Bauer			End If
4211ecadb57SMathias Bauer
4221ecadb57SMathias Bauer		End If  &apos; CLOSING  CASE
4231ecadb57SMathias Bauer
4241ecadb57SMathias Bauer		If Left(sText,8) = &quot;&lt;DEFAULT&quot; Then								&apos; an opening default tag
4251ecadb57SMathias Bauer
4261ecadb57SMathias Bauer			If sCellCaseType = &quot;&quot; Then
4271ecadb57SMathias Bauer				If (sCellDefaultType &lt;&gt; &quot;&quot; OR bCellDefaultSet) Then
4281ecadb57SMathias Bauer					Terminate(&quot;Multiple default not allowed.&quot;,CE)
4291ecadb57SMathias Bauer				Else
4301ecadb57SMathias Bauer					sCellDefaultType = &quot;DEFAULT&quot;
4311ecadb57SMathias Bauer
4321ecadb57SMathias Bauer					If sCellSwitchType = &quot;&quot; Then
4331ecadb57SMathias Bauer						Terminate(&quot;Default without switch&quot;,CE)
4341ecadb57SMathias Bauer					End If
4351ecadb57SMathias Bauer				End If
4361ecadb57SMathias Bauer				sCellDefaultType = &quot;DEFAULT&quot;
4371ecadb57SMathias Bauer				bCellDefaultSet = TRUE
4381ecadb57SMathias Bauer			Else
4391ecadb57SMathias Bauer				Terminate(&quot;Previous case (&quot;+sCellCaseType+&quot;) not closed!&quot;,CE)
4401ecadb57SMathias Bauer			End If
4411ecadb57SMathias Bauer
4421ecadb57SMathias Bauer		End If  &apos; OPENING CASE
4431ecadb57SMathias Bauer
4441ecadb57SMathias Bauer		If Left(sText,9) = &quot;&lt;/DEFAULT&quot; Then								&apos; a closing default tag
4451ecadb57SMathias Bauer
4461ecadb57SMathias Bauer			If sCellDefaultType &lt;&gt; &quot;DEFAULT&quot; Then
4471ecadb57SMathias Bauer				Terminate(&quot;No default open!&quot;,CE)
4481ecadb57SMathias Bauer			Else
4491ecadb57SMathias Bauer				sCellDefaultType = &quot;&quot;
4501ecadb57SMathias Bauer			End If
4511ecadb57SMathias Bauer
4521ecadb57SMathias Bauer		End If  &apos; CLOSING  CASE
4531ecadb57SMathias Bauer	Else  &apos; We are not hlp_aux_switch
4541ecadb57SMathias Bauer		If (sCellSwitchType &lt;&gt; &quot;&quot; AND sCellCaseType = &quot;&quot; AND sCellDefaultType = &quot;&quot;) Then
4551ecadb57SMathias Bauer			Terminate(&quot;Nothing allowed between switch and case or default or /case or /default and /switch&quot;, CE)
4561ecadb57SMathias Bauer		End If
4571ecadb57SMathias Bauer	End If
4581ecadb57SMathias Bauer
4591ecadb57SMathias Bauer
4601ecadb57SMathias BauerEnd Sub
4611ecadb57SMathias Bauer
4621ecadb57SMathias Bauer
4631ecadb57SMathias Bauer&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4641ecadb57SMathias Bauer&apos; TERMINATE VALIDATION WITH AN ERROR MESSAGE
4651ecadb57SMathias Bauer&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4661ecadb57SMathias BauerSub Terminate(sStr As String, TE As Object)
4671ecadb57SMathias Bauer
4681ecadb57SMathias Bauer	oCur = TE.getText.createTextCursorByRange(TE)
4691ecadb57SMathias Bauer	thiscomponent.getcurrentcontroller.select(oCur)
4701ecadb57SMathias Bauer	msgbox sStr,48,&quot;D&apos;oh!&quot;
4711ecadb57SMathias Bauer	Stop
4721ecadb57SMathias Bauer
4731ecadb57SMathias BauerEnd Sub
4741ecadb57SMathias Bauer
4751ecadb57SMathias Bauer&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4761ecadb57SMathias Bauer&apos; SHOW A WARNING
4771ecadb57SMathias Bauer&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4781ecadb57SMathias BauerSub Warn(sWarn As String, sSolv As String, Optional TE As Object)
4791ecadb57SMathias Bauer
4801ecadb57SMathias Bauer	If bWarn Then
4811ecadb57SMathias Bauer		BasicLibraries.LoadLibrary(&quot;HelpAuthoring&quot;)
4821ecadb57SMathias Bauer		oDialog = LoadDialog(&quot;HelpAuthoring&quot;, &quot;dlgWarn&quot;)
4831ecadb57SMathias Bauer		oTxtWarn = oDialog.GetControl(&quot;txtWarning&quot;)
4841ecadb57SMathias Bauer		oTxtWarn.Text = sWarn
4851ecadb57SMathias Bauer		oTxtSolv = oDialog.GetControl(&quot;txtSolution&quot;)
4861ecadb57SMathias Bauer		oTxtSolv.Text = sSolv
4871ecadb57SMathias Bauer
4881ecadb57SMathias Bauer		If not(IsMissing(TE)) Then
4891ecadb57SMathias Bauer			oCur = TE.getText.createTextCursorByRange(TE)
4901ecadb57SMathias Bauer			thiscomponent.getcurrentcontroller.select(oCur)
4911ecadb57SMathias Bauer		End If
4921ecadb57SMathias Bauer
4931ecadb57SMathias Bauer		If oDialog.Execute() = 1 Then
4941ecadb57SMathias Bauer			oCbWarn = oDialog.GetControl(&quot;cbWarn&quot;)
4951ecadb57SMathias Bauer			If oCbWarn.State = 1 Then
4961ecadb57SMathias Bauer				bWarn = FALSE
4971ecadb57SMathias Bauer			End If
4981ecadb57SMathias Bauer			Exit Sub
4991ecadb57SMathias Bauer		Else
5001ecadb57SMathias Bauer			Stop
5011ecadb57SMathias Bauer		End If
5021ecadb57SMathias Bauer	End If
5031ecadb57SMathias BauerEnd Sub
5041ecadb57SMathias Bauer
5051ecadb57SMathias Bauer&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5061ecadb57SMathias Bauer&apos; CHECK DOCUMENT META DATA
5071ecadb57SMathias Bauer&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5081ecadb57SMathias BauerSub CheckMetaData(oDoc As Object)
5091ecadb57SMathias Bauer
5101ecadb57SMathias Bauer	sTopicID = oDoc.DocumentInfo.GetUserFieldValue(1)
5111ecadb57SMathias Bauer
5121ecadb57SMathias Bauer	If sTopicID &lt;&gt; AlphaNum(sTopicID) OR sTopicID=&quot;&quot; Then
5131ecadb57SMathias Bauer		sTopicID = &quot;topic_&quot;+CreateID &apos; create a topic id
5141ecadb57SMathias Bauer	End If
5151ecadb57SMathias Bauer
5161ecadb57SMathias Bauer	oDoc.DocumentInfo.SetUserFieldValue(1,sTopicID)
5171ecadb57SMathias Bauer	sCreated = oDoc.DocumentInfo.GetUserFieldValue(2)
5181ecadb57SMathias Bauer	sEdited = oDoc.DocumentInfo.GetUserFieldValue(3)
5191ecadb57SMathias Bauer	sTitle = oDoc.DocumentInfo.Title
5201ecadb57SMathias Bauer
5211ecadb57SMathias Bauer	If sTitle=&quot;&quot; OR sTitle=&quot;&lt;Set Topic Title&gt;&quot; Then
5221ecadb57SMathias Bauer		Enum = document.Text.createEnumeration
5231ecadb57SMathias Bauer		Do While Enum.hasMoreElements
5241ecadb57SMathias Bauer			TextElement = Enum.nextElement
5251ecadb57SMathias Bauer			If TextElement.supportsService(&quot;com.sun.star.text.Paragraph&quot;) Then
5261ecadb57SMathias Bauer				If Left(TextElement.ParaStyleName,8)=&quot;hlp_head&quot; Then
5271ecadb57SMathias Bauer					Enum2 = TextElement.createEnumeration
5281ecadb57SMathias Bauer					While Enum2.hasMoreElements
5291ecadb57SMathias Bauer						TextPortion = Enum2.nextElement
5301ecadb57SMathias Bauer						If Not(TextPortion.TextPortionType=&quot;TextField&quot;) Then
5311ecadb57SMathias Bauer							strg = strg + TextPortion.String
5321ecadb57SMathias Bauer						End If
5331ecadb57SMathias Bauer					Wend
5341ecadb57SMathias Bauer					document.DocumentInfo.Title = strg
5351ecadb57SMathias Bauer					Exit Do
5361ecadb57SMathias Bauer				End If
5371ecadb57SMathias Bauer			End If
5381ecadb57SMathias Bauer		Loop
5391ecadb57SMathias Bauer	End If
5401ecadb57SMathias Bauer
5411ecadb57SMathias Bauer	sIndex = oDoc.DocumentInfo.GetUserFieldValue(0)
5421ecadb57SMathias Bauer
5431ecadb57SMathias BauerEnd Sub
5441ecadb57SMathias Bauer
5451ecadb57SMathias Bauer&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5461ecadb57SMathias Bauer&apos; CHECK IF HEADING EXISTS
5471ecadb57SMathias Bauer&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5481ecadb57SMathias BauerSub CheckHeading(oDoc As Object)
5491ecadb57SMathias Bauer
5501ecadb57SMathias BauerEnd Sub
5511ecadb57SMathias Bauer
5521ecadb57SMathias Bauer&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5531ecadb57SMathias Bauer&apos; CHECK FOR CORRECT INLINE TAGS
5541ecadb57SMathias Bauer&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5551ecadb57SMathias BauerSub CheckInlineTags(TE As Object)
5561ecadb57SMathias Bauer
5571ecadb57SMathias Bauer
5581ecadb57SMathias Bauer
5591ecadb57SMathias Bauer	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
5601ecadb57SMathias Bauer
5611ecadb57SMathias Bauer		Dim aTokens(0) As Object
5621ecadb57SMathias Bauer		Dim aInlineTagsOpen(0) As String
5631ecadb57SMathias Bauer		TP = TE.createEnumeration
5641ecadb57SMathias Bauer
5651ecadb57SMathias Bauer		While TP.hasmoreElements
5661ecadb57SMathias Bauer			sDim = ubound(aTokens())+1
5671ecadb57SMathias Bauer			ReDim Preserve aTokens(sDim) As Object
5681ecadb57SMathias Bauer			aTokens(sDim) = TP.nextElement
5691ecadb57SMathias Bauer		Wend
5701ecadb57SMathias Bauer
5711ecadb57SMathias Bauer		For i=1 to ubound(aTokens())
5721ecadb57SMathias Bauer			Token = aTokens(i)
5731ecadb57SMathias Bauer
5741ecadb57SMathias Bauer			If Token.supportsService(&quot;com.sun.star.text.TextField&quot;) Then
5751ecadb57SMathias Bauer				sTag = Token.TextField.TextFieldMaster.Name
5761ecadb57SMathias Bauer
5771ecadb57SMathias Bauer				If Right(sTag,1)=&quot;_&quot; Then   &apos; a tag starts
5781ecadb57SMathias Bauer
5791ecadb57SMathias Bauer					sTagName = Left(sTag,Len(sTag)-1)
5801ecadb57SMathias Bauer
5811ecadb57SMathias Bauer					&apos; check for forbidden tags in paragraphs
5821ecadb57SMathias Bauer					sTagFormat = TagFormatIsCorrect(sTagName, TE.ParaStyleName)
5831ecadb57SMathias Bauer					If sTagFormat &lt;&gt; &quot;&quot; Then
5841ecadb57SMathias Bauer						Terminate(sTagName+&quot; element has wrong paragraph style (&quot;+TE.ParaStyleName+&quot;).&quot;+chr(13)+&quot;Must be &quot;+sTagFormat,Token)
5851ecadb57SMathias Bauer					End If
5861ecadb57SMathias Bauer
5871ecadb57SMathias Bauer					sDim = ubound(aInlineTagsOpen())+1
5881ecadb57SMathias Bauer					Redim Preserve aInlineTagsOpen(sDim) as String
5891ecadb57SMathias Bauer					aInlineTagsOpen(sDim)=sTagName
5901ecadb57SMathias Bauer
5911ecadb57SMathias Bauer				ElseIf Left(sTag,1)=&quot;_&quot; Then  &apos; a tag ends, all other cases are empty tags
5921ecadb57SMathias Bauer
5931ecadb57SMathias Bauer					sTagName = Right(sTag,Len(sTag)-1)
5941ecadb57SMathias Bauer
5951ecadb57SMathias Bauer					&apos; check for forbidden tags in paragraphs
5961ecadb57SMathias Bauer					sTagFormat = TagFormatIsCorrect(sTagName, TE.ParaStyleName)
5971ecadb57SMathias Bauer					If sTagFormat &lt;&gt; &quot;&quot; Then
5981ecadb57SMathias Bauer						Terminate(sTagName+&quot; element has wrong paragraph style (&quot;+TE.ParaStyleName+&quot;).&quot;+chr(13)+&quot;Must be &quot;+sTagFormat,Token)
5991ecadb57SMathias Bauer					End If
6001ecadb57SMathias Bauer
6011ecadb57SMathias Bauer					If ubound(aInlineTagsOpen()) &gt; 0 Then
6021ecadb57SMathias Bauer						If aInlineTagsOpen(ubound(aInlineTagsOpen())) &lt;&gt; sTagName Then
6031ecadb57SMathias Bauer							Terminate(&quot;Inline Element &quot;+aInlineTagsOpen(ubound(aInlineTagsOpen()))+&quot; not closed&quot;,Token)
6041ecadb57SMathias Bauer						End If
6051ecadb57SMathias Bauer						sDim = ubound(aInlineTagsOpen())-1
6061ecadb57SMathias Bauer					Else
6071ecadb57SMathias Bauer						Terminate(&quot;No opening tag for &quot;+sTagName,Token)
6081ecadb57SMathias Bauer					End If
6091ecadb57SMathias Bauer					Redim Preserve aInlineTagsOpen(sDim) as String
6101ecadb57SMathias Bauer
6111ecadb57SMathias Bauer				Else &apos; empty tag
6121ecadb57SMathias Bauer					sTagName = sTag
6131ecadb57SMathias Bauer					sTagFormat = TagFormatIsCorrect(sTagName, TE.ParaStyleName)
6141ecadb57SMathias Bauer					If sTagFormat &lt;&gt; &quot;&quot; Then
6151ecadb57SMathias Bauer						Terminate(sTagName+&quot; element has wrong paragraph style (&quot;+TE.ParaStyleName+&quot;).&quot;+chr(13)+&quot;Must be &quot;+sTagFormat,Token)
6161ecadb57SMathias Bauer					End If
6171ecadb57SMathias Bauer
6181ecadb57SMathias Bauer				EndIf
6191ecadb57SMathias Bauer			ElseIf (i &gt; 1) AND (Trim(Token.String) &lt;&gt; &quot;&quot;) Then
6201ecadb57SMathias Bauer				If aInlineTagsOpen(ubound(aInlineTagsOpen())) = &quot;SWITCHINLINE&quot; Then
6211ecadb57SMathias Bauer					Terminate(&quot;No text allowed here.&quot;,Token)
6221ecadb57SMathias Bauer				End If
6231ecadb57SMathias Bauer			End If
6241ecadb57SMathias Bauer		Next
6251ecadb57SMathias Bauer
6261ecadb57SMathias Bauer	If ubound(aInlineTagsOpen()) &gt; 0 Then
6271ecadb57SMathias Bauer		Terminate(&quot;Inline Element &quot;+aInlineTagsOpen(ubound(aInlineTagsOpen()))+&quot; not closed&quot;,Token)
6281ecadb57SMathias Bauer	End If
6291ecadb57SMathias Bauer
6301ecadb57SMathias Bauer	End If
6311ecadb57SMathias BauerEnd Sub
6321ecadb57SMathias Bauer
6331ecadb57SMathias Bauer&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6341ecadb57SMathias Bauer&apos; CHECK FOR CORRECT TAGS
6351ecadb57SMathias Bauer&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6361ecadb57SMathias BauerSub CheckTags(TE As Object)
6371ecadb57SMathias Bauer	If (Left(TE.ParaStyleName,8) = &quot;hlp_aux_&quot; AND TE.ParaStyleName &lt;&gt; &quot;hlp_aux_bookmark&quot;) Then
6381ecadb57SMathias Bauer
6391ecadb57SMathias Bauer	TP = TE.createEnumeration
6401ecadb57SMathias Bauer
6411ecadb57SMathias Bauer	While TP.hasmoreElements
6421ecadb57SMathias Bauer		TPE = TP.nextElement
6431ecadb57SMathias Bauer
6441ecadb57SMathias Bauer		If TPE.supportsService(&quot;com.sun.star.text.TextField&quot;) Then
6451ecadb57SMathias Bauer			sTag = TPE.TextField.TextFieldMaster.Name
6461ecadb57SMathias Bauer			If Right(sTag,1)=&quot;_&quot; Then   &apos; a tag starts
6471ecadb57SMathias Bauer
6481ecadb57SMathias Bauer				sTagName = Left(sTag,Len(sTag)-1)
6491ecadb57SMathias Bauer				sDim = ubound(aTagsOpen())+1
6501ecadb57SMathias Bauer				Redim Preserve aTagsOpen(sDim) as String
6511ecadb57SMathias Bauer				aTagsOpen(sDim)=sTagName
6521ecadb57SMathias Bauer
6531ecadb57SMathias Bauer			ElseIf Left(sTag,1)=&quot;_&quot; Then  &apos; a tag ends, all other cases are empty tags
6541ecadb57SMathias Bauer
6551ecadb57SMathias Bauer				sTagName = Right(sTag,Len(sTag)-1)
6561ecadb57SMathias Bauer				If ubound(aTagsOpen()) &gt; 0 Then
6571ecadb57SMathias Bauer					If aTagsOpen(ubound(aTagsOpen())) &lt;&gt; sTagName Then
6581ecadb57SMathias Bauer						Terminate(&quot;No close tag for &quot;+aTagsOpen(ubound(aTagsOpen())),TPE)
6591ecadb57SMathias Bauer					Else
6601ecadb57SMathias Bauer						sDim = ubound(aTagsOpen())-1
6611ecadb57SMathias Bauer					End If
6621ecadb57SMathias Bauer				Else
6631ecadb57SMathias Bauer					Terminate(&quot;No opening tag for &quot;+sTagName,TPE)
6641ecadb57SMathias Bauer				End If
6651ecadb57SMathias Bauer				Redim Preserve aTagsOpen(sDim) as String
6661ecadb57SMathias Bauer
6671ecadb57SMathias Bauer			Else &apos; empty tags
6681ecadb57SMathias Bauer
6691ecadb57SMathias Bauer			EndIf
6701ecadb57SMathias Bauer		End If
6711ecadb57SMathias Bauer	Wend
6721ecadb57SMathias Bauer	End If
6731ecadb57SMathias BauerEnd Sub
6741ecadb57SMathias Bauer
6751ecadb57SMathias Bauer&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6761ecadb57SMathias Bauer&apos; CHECK FOR CORRECT TAGS IN A TABLE CELL
6771ecadb57SMathias Bauer&apos;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6781ecadb57SMathias BauerSub CheckTagsInCell(CE As Object)
6791ecadb57SMathias Bauer	If (Left(CE.ParaStyleName,8) = &quot;hlp_aux_&quot; AND CE.ParaStyleName &lt;&gt; &quot;hlp_aux_bookmark&quot;) Then
6801ecadb57SMathias Bauer
6811ecadb57SMathias Bauer	CP = CE.createEnumeration
6821ecadb57SMathias Bauer
6831ecadb57SMathias Bauer	While CP.hasmoreElements
6841ecadb57SMathias Bauer		CPE = CP.nextElement
6851ecadb57SMathias Bauer
6861ecadb57SMathias Bauer		If CPE.supportsService(&quot;com.sun.star.text.TextField&quot;) Then
6871ecadb57SMathias Bauer			sTag = CPE.TextField.TextFieldMaster.Name
6881ecadb57SMathias Bauer			If Right(sTag,1)=&quot;_&quot; Then   &apos; a tag starts
6891ecadb57SMathias Bauer
6901ecadb57SMathias Bauer				sTagName = Left(sTag,Len(sTag)-1)
6911ecadb57SMathias Bauer				sDim = ubound(aCellTagsOpen())+1
6921ecadb57SMathias Bauer				Redim Preserve aCellTagsOpen(sDim) as String
6931ecadb57SMathias Bauer				aCellTagsOpen(sDim)=sTagName
6941ecadb57SMathias Bauer
6951ecadb57SMathias Bauer			ElseIf Left(sTag,1)=&quot;_&quot; Then  &apos; a tag ends, all other cases are empty tags
6961ecadb57SMathias Bauer
6971ecadb57SMathias Bauer				sTagName = Right(sTag,Len(sTag)-1)
6981ecadb57SMathias Bauer				If ubound(aCellTagsOpen()) &gt; 0 Then
6991ecadb57SMathias Bauer					If aCellTagsOpen(ubound(aCellTagsOpen())) &lt;&gt; sTagName Then
7001ecadb57SMathias Bauer						Terminate(&quot;No close tag for &quot;+aCellTagsOpen(ubound(aCellTagsOpen())),CPE)
7011ecadb57SMathias Bauer					Else
7021ecadb57SMathias Bauer						sDim = ubound(aCellTagsOpen())-1
7031ecadb57SMathias Bauer					End If
7041ecadb57SMathias Bauer				Else
7051ecadb57SMathias Bauer					Terminate(&quot;No opening tag for &quot;+sTagName,CPE)
7061ecadb57SMathias Bauer				End If
7071ecadb57SMathias Bauer				Redim Preserve aCellTagsOpen(sDim) as String
7081ecadb57SMathias Bauer
7091ecadb57SMathias Bauer			EndIf
7101ecadb57SMathias Bauer		End If
7111ecadb57SMathias Bauer	Wend
7121ecadb57SMathias Bauer	End If
7131ecadb57SMathias BauerEnd Sub
7141ecadb57SMathias Bauer
715*3e02b54dSAndrew Rist</script:module>
716