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="Helpers" script:language="StarBasic">&apos; *** MODULE HELPERS ***
241ecadb57SMathias Bauer
251ecadb57SMathias Bauer&apos;=======================================================
261ecadb57SMathias Bauer&apos; Main
271ecadb57SMathias Bauer&apos;-------------------------------------------------------
281ecadb57SMathias Bauer&apos; Ensure that necessary library functions are available
291ecadb57SMathias Bauer&apos;=======================================================
301ecadb57SMathias BauerSub Main
311ecadb57SMathias Bauer	GlobalScope.BasicLibraries.loadLibrary(&quot;Tools&quot;)
321ecadb57SMathias BauerEnd Sub
331ecadb57SMathias Bauer
341ecadb57SMathias Bauer&apos;=======================================================
351ecadb57SMathias Bauer&apos; ShowProp
361ecadb57SMathias Bauer&apos;-------------------------------------------------------
371ecadb57SMathias Bauer&apos; Displays a dialog that shows the properties and
381ecadb57SMathias Bauer&apos; the methods of an object. Used for debugging.
391ecadb57SMathias Bauer&apos;=======================================================
401ecadb57SMathias BauerSub ShowProp(Elem As Object)
411ecadb57SMathias Bauer	dim oDialog As Object
421ecadb57SMathias Bauer
431ecadb57SMathias Bauer	BasicLibraries.LoadLibrary(&quot;HelpAuthoring&quot;)
441ecadb57SMathias Bauer	oDialog = LoadDialog(&quot;HelpAuthoring&quot;, &quot;dlgObjProp&quot;)
451ecadb57SMathias Bauer	oDialogModel = oDialog.Model
461ecadb57SMathias Bauer
471ecadb57SMathias Bauer	oTxtProp = oDialog.GetControl(&quot;txtProp&quot;)
481ecadb57SMathias Bauer	oTxtProp.Text = Join(Split(Elem.dbg_properties,&quot;;&quot;),chr(13))
491ecadb57SMathias Bauer
501ecadb57SMathias Bauer	oTxtMeth = oDialog.GetControl(&quot;txtMeth&quot;)
511ecadb57SMathias Bauer	oTxtMeth.Text = Join(Split(Elem.dbg_methods,&quot;;&quot;),chr(13))
521ecadb57SMathias Bauer
531ecadb57SMathias Bauer	oTxtInt = oDialog.GetControl(&quot;txtInt&quot;)
541ecadb57SMathias Bauer	oTxtInt.Text = Join(Split(Elem.dbg_supportedInterfaces,&quot;;&quot;),chr(13))
551ecadb57SMathias Bauer
561ecadb57SMathias Bauer	oDialog.Execute()
571ecadb57SMathias Bauer	oDialog.dispose
581ecadb57SMathias BauerEnd Sub
591ecadb57SMathias Bauer
601ecadb57SMathias Bauer&apos;=======================================================
611ecadb57SMathias Bauer&apos; AlphaNum
621ecadb57SMathias Bauer&apos;-------------------------------------------------------
631ecadb57SMathias Bauer&apos; Removes all invalid characters from a string
641ecadb57SMathias Bauer&apos;=======================================================
651ecadb57SMathias BauerFunction AlphaNum(Strg As String)
661ecadb57SMathias Bauer	dim OutStrg As String
671ecadb57SMathias Bauer	dim sValid As String
681ecadb57SMathias Bauer
691ecadb57SMathias Bauer	sValid = &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789&quot;
701ecadb57SMathias Bauer
711ecadb57SMathias Bauer	For i=1 to Len(Strg)
721ecadb57SMathias Bauer		If (Instr(sValid,LCase(Mid(Strg,i,1)))) Then
731ecadb57SMathias Bauer			OutStrg = OutStrg + Mid(Strg,i,1)
741ecadb57SMathias Bauer		End If
751ecadb57SMathias Bauer	Next i
761ecadb57SMathias Bauer	AlphaNum = OutStrg
771ecadb57SMathias BauerEnd Function
781ecadb57SMathias Bauer
791ecadb57SMathias Bauer&apos;=======================================================
801ecadb57SMathias Bauer&apos; Replace
811ecadb57SMathias Bauer&apos;-------------------------------------------------------
821ecadb57SMathias Bauer&apos; Replaces a character with another character in a string
831ecadb57SMathias Bauer&apos;=======================================================
841ecadb57SMathias BauerFunction Replace(txt As String, ReplaceFrom As String, ReplaceTo As String)
851ecadb57SMathias Bauer	dim OutStr As String
861ecadb57SMathias Bauer	For i=1 to len(txt)
871ecadb57SMathias Bauer		If LCase(mid(txt,i,1))=ReplaceFrom Then
881ecadb57SMathias Bauer			OutStr = OutStr + ReplaceTo
891ecadb57SMathias Bauer		Else
901ecadb57SMathias Bauer			OutStr = OutStr + mid(txt,i,1)
911ecadb57SMathias Bauer		End If
921ecadb57SMathias Bauer	Next i
931ecadb57SMathias Bauer	Replace = OutStr
941ecadb57SMathias BauerEnd Function
951ecadb57SMathias Bauer
961ecadb57SMathias Bauer
971ecadb57SMathias Bauer&apos;=======================================================
981ecadb57SMathias Bauer&apos; ReplaceAll
991ecadb57SMathias Bauer&apos;-------------------------------------------------------
1001ecadb57SMathias Bauer&apos; Replaces a character with another character in a string
1011ecadb57SMathias Bauer&apos;=======================================================
1021ecadb57SMathias BauerFunction ReplaceAll(txt As String, ReplaceFrom As String, ReplaceTo As String)
1031ecadb57SMathias Bauer	dim OutStr As String
1041ecadb57SMathias Bauer	For i=1 to len(txt)
1051ecadb57SMathias Bauer	    bFound = 0
1061ecadb57SMathias Bauer		For j=1 to len(ReplaceFrom)
1071ecadb57SMathias Bauer			If LCase(mid(txt,i,1))=LCase(mid(ReplaceFrom,j,1)) Then
1081ecadb57SMathias Bauer				bFound = 1
1091ecadb57SMathias Bauer				OutStr = OutStr + ReplaceTo
1101ecadb57SMathias Bauer				j = len(ReplaceFrom)
1111ecadb57SMathias Bauer			End If
1121ecadb57SMathias Bauer		Next j
1131ecadb57SMathias Bauer		If bFound=0 Then
1141ecadb57SMathias Bauer			OutStr = OutStr + mid(txt,i,1)
1151ecadb57SMathias Bauer		End If
1161ecadb57SMathias Bauer	Next i
1171ecadb57SMathias Bauer	ReplaceAll = OutStr
1181ecadb57SMathias BauerEnd Function
1191ecadb57SMathias Bauer
1201ecadb57SMathias Bauer
1211ecadb57SMathias Bauer
1221ecadb57SMathias Bauer&apos;=======================================================
1231ecadb57SMathias Bauer&apos; CreateID
1241ecadb57SMathias Bauer&apos;-------------------------------------------------------
1251ecadb57SMathias Bauer&apos; Creates a numerical randomized ID
1261ecadb57SMathias Bauer&apos;=======================================================
1271ecadb57SMathias BauerFunction CreateID
1281ecadb57SMathias Bauer	sDate = ReplaceAll(Date,&quot;/:. \&quot;,&quot;&quot;)
1291ecadb57SMathias Bauer    sTime = ReplaceAll(Time,&quot;/:. \AMP&quot;,&quot;&quot;)
1301ecadb57SMathias Bauer	Randomize
1311ecadb57SMathias Bauer	CreateID = sDate + sTime + Int(Rnd * 100)
1321ecadb57SMathias BauerEnd Function
1331ecadb57SMathias Bauer
1341ecadb57SMathias Bauer&apos;=======================================================
1351ecadb57SMathias Bauer&apos; InsertTag
1361ecadb57SMathias Bauer&apos;-------------------------------------------------------
1371ecadb57SMathias Bauer&apos; Inserts an inline tag (element) in the document at the
1381ecadb57SMathias Bauer&apos; current cursor position. It also sets the character
1391ecadb57SMathias Bauer&apos; format to hlp_aux_tag
1401ecadb57SMathias Bauer&apos;=======================================================
1411ecadb57SMathias BauerSub InsertTag (Element As String, Content As String)
1421ecadb57SMathias Bauer	dim document   as object
1431ecadb57SMathias Bauer	dim dispatcher as object
1441ecadb57SMathias Bauer
1451ecadb57SMathias Bauer	document   = ThisComponent.CurrentController.Frame
1461ecadb57SMathias Bauer	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
1471ecadb57SMathias Bauer
1481ecadb57SMathias Bauer	dim args(5) as new com.sun.star.beans.PropertyValue
1491ecadb57SMathias Bauer	args(0).Name = &quot;Type&quot;
1501ecadb57SMathias Bauer	args(0).Value = 8
1511ecadb57SMathias Bauer	args(1).Name = &quot;SubType&quot;
1521ecadb57SMathias Bauer	args(1).Value = 1
1531ecadb57SMathias Bauer	args(2).Name = &quot;Name&quot;
1541ecadb57SMathias Bauer	args(2).Value = Element
1551ecadb57SMathias Bauer	args(3).Name = &quot;Content&quot;
1561ecadb57SMathias Bauer	args(3).Value = Content
1571ecadb57SMathias Bauer	args(4).Name = &quot;Format&quot;
1581ecadb57SMathias Bauer	args(4).Value = -1
1591ecadb57SMathias Bauer	args(5).Name = &quot;Separator&quot;
1601ecadb57SMathias Bauer	args(5).Value = &quot; &quot;
1611ecadb57SMathias Bauer	SetCharStyle(&quot;hlp_aux_tag&quot;)
1621ecadb57SMathias Bauer	dispatcher.executeDispatch(document, &quot;.uno:InsertField&quot;, &quot;&quot;, 0, args())
1631ecadb57SMathias Bauer	SetCharStyle(&quot;Default&quot;)
1641ecadb57SMathias BauerEnd Sub
1651ecadb57SMathias Bauer
1661ecadb57SMathias Bauer&apos;=======================================================
1671ecadb57SMathias Bauer&apos; INSERTTAGCR
1681ecadb57SMathias Bauer&apos;-------------------------------------------------------
1691ecadb57SMathias Bauer&apos; Inserts a tag (element) in the document at the
1701ecadb57SMathias Bauer&apos; current cursor position in its own newly created paragraph.
1711ecadb57SMathias Bauer&apos; It also sets the character format to hlp_aux_tag and
1721ecadb57SMathias Bauer&apos; the paragraph to the specified value (should start with hlp_)
1731ecadb57SMathias Bauer&apos;=======================================================
1741ecadb57SMathias BauerSub InsertTagCR (Element As String, Content As String, Style As String)
1751ecadb57SMathias Bauer	dim document   as object
1761ecadb57SMathias Bauer	dim dispatcher as object
1771ecadb57SMathias Bauer
1781ecadb57SMathias Bauer	document   = ThisComponent.CurrentController.Frame
1791ecadb57SMathias Bauer	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
1801ecadb57SMathias Bauer
1811ecadb57SMathias Bauer	dim args(5) as new com.sun.star.beans.PropertyValue
1821ecadb57SMathias Bauer	args(0).Name = &quot;Type&quot;
1831ecadb57SMathias Bauer	args(0).Value = 8
1841ecadb57SMathias Bauer	args(1).Name = &quot;SubType&quot;
1851ecadb57SMathias Bauer	args(1).Value = 1
1861ecadb57SMathias Bauer	args(2).Name = &quot;Name&quot;
1871ecadb57SMathias Bauer	args(2).Value = Element
1881ecadb57SMathias Bauer	args(3).Name = &quot;Content&quot;
1891ecadb57SMathias Bauer	args(3).Value = Content
1901ecadb57SMathias Bauer	args(4).Name = &quot;Format&quot;
1911ecadb57SMathias Bauer	args(4).Value = -1
1921ecadb57SMathias Bauer	args(5).Name = &quot;Separator&quot;
1931ecadb57SMathias Bauer	args(5).Value = &quot; &quot;
1941ecadb57SMathias Bauer
1951ecadb57SMathias Bauer	CR
1961ecadb57SMathias Bauer	goUp(1)
1971ecadb57SMathias Bauer	SetParaStyle(Style)
1981ecadb57SMathias Bauer	SetCharStyle(&quot;hlp_aux_tag&quot;)
1991ecadb57SMathias Bauer	dispatcher.executeDispatch(document, &quot;.uno:InsertField&quot;, &quot;&quot;, 0, args())
2001ecadb57SMathias Bauer	SetCharStyle(&quot;Default&quot;)
2011ecadb57SMathias Bauer	goDown(1)
2021ecadb57SMathias BauerEnd Sub
2031ecadb57SMathias Bauer
2041ecadb57SMathias Bauer&apos;=======================================================
2051ecadb57SMathias Bauer&apos; InsertField
2061ecadb57SMathias Bauer&apos;-------------------------------------------------------
2071ecadb57SMathias Bauer&apos; Inserts a field in the document at the
2081ecadb57SMathias Bauer&apos; current cursor position.
2091ecadb57SMathias Bauer&apos;=======================================================
2101ecadb57SMathias BauerSub InsertField(Field as String, Content as String)
2111ecadb57SMathias Bauer	dim document   as object
2121ecadb57SMathias Bauer	dim dispatcher as object
2131ecadb57SMathias Bauer
2141ecadb57SMathias Bauer	document   = ThisComponent.CurrentController.Frame
2151ecadb57SMathias Bauer	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
2161ecadb57SMathias Bauer
2171ecadb57SMathias Bauer	dim args(5) as new com.sun.star.beans.PropertyValue
2181ecadb57SMathias Bauer	args(0).Name = &quot;Type&quot;
2191ecadb57SMathias Bauer	args(0).Value = 8
2201ecadb57SMathias Bauer	args(1).Name = &quot;SubType&quot;
2211ecadb57SMathias Bauer	args(1).Value = 1
2221ecadb57SMathias Bauer	args(2).Name = &quot;Name&quot;
2231ecadb57SMathias Bauer	args(2).Value = Field
2241ecadb57SMathias Bauer	args(3).Name = &quot;Content&quot;
2251ecadb57SMathias Bauer	args(3).Value = Content
2261ecadb57SMathias Bauer	args(4).Name = &quot;Format&quot;
2271ecadb57SMathias Bauer	args(4).Value = -1
2281ecadb57SMathias Bauer	args(5).Name = &quot;Separator&quot;
2291ecadb57SMathias Bauer	args(5).Value = &quot; &quot;
2301ecadb57SMathias Bauer
2311ecadb57SMathias Bauer	dispatcher.executeDispatch(document, &quot;.uno:InsertField&quot;, &quot;&quot;, 0, args())
2321ecadb57SMathias BauerEnd Sub
2331ecadb57SMathias Bauer
2341ecadb57SMathias Bauer&apos;=======================================================
2351ecadb57SMathias Bauer&apos; GoUp
2361ecadb57SMathias Bauer&apos;-------------------------------------------------------
2371ecadb57SMathias Bauer&apos; Simulates the CursorUp key
2381ecadb57SMathias Bauer&apos;=======================================================
2391ecadb57SMathias BauerSub goUp(Count As Integer, Optional bSelect As Boolean)
2401ecadb57SMathias Bauer	dim document   as object
2411ecadb57SMathias Bauer	dim dispatcher as object
2421ecadb57SMathias Bauer
2431ecadb57SMathias Bauer	document   = ThisComponent.CurrentController.Frame
2441ecadb57SMathias Bauer	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
2451ecadb57SMathias Bauer
2461ecadb57SMathias Bauer	dim args(1) as new com.sun.star.beans.PropertyValue
2471ecadb57SMathias Bauer	args(0).Name = &quot;Count&quot;
2481ecadb57SMathias Bauer	args(0).Value = Count
2491ecadb57SMathias Bauer	args(1).Name = &quot;Select&quot;
2501ecadb57SMathias Bauer	If IsMissing(bSelect) Then
2511ecadb57SMathias Bauer		args(1).Value = false
2521ecadb57SMathias Bauer	Else
2531ecadb57SMathias Bauer		args(1).Value = bSelect
2541ecadb57SMathias Bauer	End If
2551ecadb57SMathias Bauer
2561ecadb57SMathias Bauer	dispatcher.executeDispatch(document, &quot;.uno:GoUp&quot;, &quot;&quot;, 0, args())
2571ecadb57SMathias BauerEnd Sub
2581ecadb57SMathias Bauer
2591ecadb57SMathias Bauer&apos;=======================================================
2601ecadb57SMathias Bauer&apos; GoDown
2611ecadb57SMathias Bauer&apos;-------------------------------------------------------
2621ecadb57SMathias Bauer&apos; Simulates the CursorDown key
2631ecadb57SMathias Bauer&apos;=======================================================
2641ecadb57SMathias BauerSub goDown(Count As Integer, Optional bSelect As Boolean)
2651ecadb57SMathias Bauer	dim document   as object
2661ecadb57SMathias Bauer	dim dispatcher as object
2671ecadb57SMathias Bauer
2681ecadb57SMathias Bauer	document   = ThisComponent.CurrentController.Frame
2691ecadb57SMathias Bauer	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
2701ecadb57SMathias Bauer
2711ecadb57SMathias Bauer	dim args(1) as new com.sun.star.beans.PropertyValue
2721ecadb57SMathias Bauer	args(0).Name = &quot;Count&quot;
2731ecadb57SMathias Bauer	args(0).Value = Count
2741ecadb57SMathias Bauer	args(1).Name = &quot;Select&quot;
2751ecadb57SMathias Bauer	If IsMissing(bSelect) Then
2761ecadb57SMathias Bauer		args(1).Value = false
2771ecadb57SMathias Bauer	Else
2781ecadb57SMathias Bauer		args(1).Value = bSelect
2791ecadb57SMathias Bauer	End If
2801ecadb57SMathias Bauer
2811ecadb57SMathias Bauer	dispatcher.executeDispatch(document, &quot;.uno:GoDown&quot;, &quot;&quot;, 0, args())
2821ecadb57SMathias BauerEnd Sub
2831ecadb57SMathias Bauer
2841ecadb57SMathias Bauer
2851ecadb57SMathias Bauer&apos;=======================================================
2861ecadb57SMathias Bauer&apos; GoRight
2871ecadb57SMathias Bauer&apos;-------------------------------------------------------
2881ecadb57SMathias Bauer&apos; Simulates the CursorRight key
2891ecadb57SMathias Bauer&apos;=======================================================
2901ecadb57SMathias BauerSub goRight(Count As Integer, Optional bSelect As Boolean)
2911ecadb57SMathias Bauer	dim document   as object
2921ecadb57SMathias Bauer	dim dispatcher as object
2931ecadb57SMathias Bauer
2941ecadb57SMathias Bauer	document   = ThisComponent.CurrentController.Frame
2951ecadb57SMathias Bauer	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
2961ecadb57SMathias Bauer
2971ecadb57SMathias Bauer	dim args(1) as new com.sun.star.beans.PropertyValue
2981ecadb57SMathias Bauer	args(0).Name = &quot;Count&quot;
2991ecadb57SMathias Bauer	args(0).Value = Count
3001ecadb57SMathias Bauer	args(1).Name = &quot;Select&quot;
3011ecadb57SMathias Bauer	If IsMissing(bSelect) Then
3021ecadb57SMathias Bauer		args(1).Value = false
3031ecadb57SMathias Bauer	Else
3041ecadb57SMathias Bauer		args(1).Value = bSelect
3051ecadb57SMathias Bauer	End If
3061ecadb57SMathias Bauer
3071ecadb57SMathias Bauer	dispatcher.executeDispatch(document, &quot;.uno:GoRight&quot;, &quot;&quot;, 0, args())
3081ecadb57SMathias BauerEnd Sub
3091ecadb57SMathias Bauer
3101ecadb57SMathias Bauer&apos;=======================================================
3111ecadb57SMathias Bauer&apos; GoLeft
3121ecadb57SMathias Bauer&apos;-------------------------------------------------------
3131ecadb57SMathias Bauer&apos; Simulates the CursorLeft key
3141ecadb57SMathias Bauer&apos;=======================================================
3151ecadb57SMathias BauerSub goLeft(Count As Integer, optional bSelect As boolean)
3161ecadb57SMathias Bauer	dim document   as object
3171ecadb57SMathias Bauer	dim dispatcher as object
3181ecadb57SMathias Bauer
3191ecadb57SMathias Bauer	document   = ThisComponent.CurrentController.Frame
3201ecadb57SMathias Bauer	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
3211ecadb57SMathias Bauer
3221ecadb57SMathias Bauer	dim args(1) as new com.sun.star.beans.PropertyValue
3231ecadb57SMathias Bauer	args(0).Name = &quot;Count&quot;
3241ecadb57SMathias Bauer	args(0).Value = Count
3251ecadb57SMathias Bauer	args(1).Name = &quot;Select&quot;
3261ecadb57SMathias Bauer	If IsMissing(bSelect) Then
3271ecadb57SMathias Bauer		args(1).Value = false
3281ecadb57SMathias Bauer	Else
3291ecadb57SMathias Bauer		args(1).Value = bSelect
3301ecadb57SMathias Bauer	End If
3311ecadb57SMathias Bauer
3321ecadb57SMathias Bauer	dispatcher.executeDispatch(document, &quot;.uno:GoLeft&quot;, &quot;&quot;, 0, args())
3331ecadb57SMathias BauerEnd Sub
3341ecadb57SMathias Bauer
3351ecadb57SMathias Bauer&apos;=======================================================
3361ecadb57SMathias Bauer&apos; CR
3371ecadb57SMathias Bauer&apos;-------------------------------------------------------
3381ecadb57SMathias Bauer&apos; Inserts a Carriage Return (a new paragraph)
3391ecadb57SMathias Bauer&apos;=======================================================
3401ecadb57SMathias BauerSub CR
3411ecadb57SMathias Bauer	dim document   as object
3421ecadb57SMathias Bauer	dim dispatcher as object
3431ecadb57SMathias Bauer
3441ecadb57SMathias Bauer	document   = ThisComponent.CurrentController.Frame
3451ecadb57SMathias Bauer	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
3461ecadb57SMathias Bauer
3471ecadb57SMathias Bauer	oSel = thiscomponent.getcurrentcontroller.getselection
3481ecadb57SMathias Bauer	oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
3491ecadb57SMathias Bauer	oCur.gotoEndOfParagraph(0)
3501ecadb57SMathias Bauer	thiscomponent.getcurrentcontroller.select(oCur)
3511ecadb57SMathias Bauer
3521ecadb57SMathias Bauer	dispatcher.executeDispatch(document, &quot;.uno:InsertPara&quot;, &quot;&quot;, 0, Array())
3531ecadb57SMathias BauerEnd Sub
3541ecadb57SMathias Bauer
3551ecadb57SMathias Bauer&apos;=======================================================
3561ecadb57SMathias Bauer&apos; CR_before
3571ecadb57SMathias Bauer&apos;-------------------------------------------------------
3581ecadb57SMathias Bauer&apos; Inserts a Carriage Return (a new paragraph) before the current para
3591ecadb57SMathias Bauer&apos;=======================================================
3601ecadb57SMathias BauerSub CR_before
3611ecadb57SMathias Bauer	dim document   as object
3621ecadb57SMathias Bauer	dim dispatcher as object
3631ecadb57SMathias Bauer
3641ecadb57SMathias Bauer	document   = ThisComponent.CurrentController.Frame
3651ecadb57SMathias Bauer	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
3661ecadb57SMathias Bauer
3671ecadb57SMathias Bauer	oSel = thiscomponent.getcurrentcontroller.getselection
3681ecadb57SMathias Bauer	oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
3691ecadb57SMathias Bauer	oCur.gotoStartOfParagraph(0)
3701ecadb57SMathias Bauer	thiscomponent.getcurrentcontroller.select(oCur)
3711ecadb57SMathias Bauer
3721ecadb57SMathias Bauer	dispatcher.executeDispatch(document, &quot;.uno:InsertPara&quot;, &quot;&quot;, 0, Array())
3731ecadb57SMathias BauerEnd Sub
3741ecadb57SMathias Bauer
3751ecadb57SMathias Bauer&apos;=======================================================
3761ecadb57SMathias Bauer&apos; LF
3771ecadb57SMathias Bauer&apos;-------------------------------------------------------
3781ecadb57SMathias Bauer&apos; Inserts a line feed (manual line break)
3791ecadb57SMathias Bauer&apos;=======================================================
3801ecadb57SMathias Bauersub LF
3811ecadb57SMathias Bauer	dim document   as object
3821ecadb57SMathias Bauer	dim dispatcher as object
3831ecadb57SMathias Bauer	document   = ThisComponent.CurrentController.Frame
3841ecadb57SMathias Bauer	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
3851ecadb57SMathias Bauer
3861ecadb57SMathias Bauer	dispatcher.executeDispatch(document, &quot;.uno:InsertLinebreak&quot;, &quot;&quot;, 0, Array())
3871ecadb57SMathias Bauerend sub
3881ecadb57SMathias Bauer
3891ecadb57SMathias Bauer&apos;=======================================================
3901ecadb57SMathias Bauer&apos; SetParaStyle
3911ecadb57SMathias Bauer&apos;-------------------------------------------------------
3921ecadb57SMathias Bauer&apos; Sets the para style to the given value
3931ecadb57SMathias Bauer&apos;=======================================================
3941ecadb57SMathias BauerSub SetParaStyle(StyleName As String)
3951ecadb57SMathias Bauer	dim document   as object
3961ecadb57SMathias Bauer	dim dispatcher as object
3971ecadb57SMathias Bauer
3981ecadb57SMathias Bauer	document   = ThisComponent.CurrentController.Frame
3991ecadb57SMathias Bauer	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
4001ecadb57SMathias Bauer
4011ecadb57SMathias Bauer	dim args(1) as new com.sun.star.beans.PropertyValue
4021ecadb57SMathias Bauer	args(0).Name = &quot;Template&quot;
4031ecadb57SMathias Bauer	args(0).Value = StyleName
4041ecadb57SMathias Bauer	args(1).Name = &quot;Family&quot;
4051ecadb57SMathias Bauer	args(1).Value = 2
4061ecadb57SMathias Bauer
4071ecadb57SMathias Bauer	dispatcher.executeDispatch(document, &quot;.uno:StyleApply&quot;, &quot;&quot;, 0, args())
4081ecadb57SMathias Bauerend Sub
4091ecadb57SMathias Bauer
4101ecadb57SMathias Bauer&apos;=======================================================
4111ecadb57SMathias Bauer&apos; SetCharStyle
4121ecadb57SMathias Bauer&apos;-------------------------------------------------------
4131ecadb57SMathias Bauer&apos; Sets the character style to the given value
4141ecadb57SMathias Bauer&apos;=======================================================
4151ecadb57SMathias BauerSub SetCharStyle(StyleName As String)
4161ecadb57SMathias Bauer	dim document   as object
4171ecadb57SMathias Bauer	dim dispatcher as object
4181ecadb57SMathias Bauer
4191ecadb57SMathias Bauer	document   = ThisComponent.CurrentController.Frame
4201ecadb57SMathias Bauer	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
4211ecadb57SMathias Bauer
4221ecadb57SMathias Bauer	dim args(1) as new com.sun.star.beans.PropertyValue
4231ecadb57SMathias Bauer	args(0).Name = &quot;Template&quot;
4241ecadb57SMathias Bauer	args(0).Value = StyleName
4251ecadb57SMathias Bauer	args(1).Name = &quot;Family&quot;
4261ecadb57SMathias Bauer	args(1).Value = 1
4271ecadb57SMathias Bauer
4281ecadb57SMathias Bauer	dispatcher.executeDispatch(document, &quot;.uno:StyleApply&quot;, &quot;&quot;, 0, args())
4291ecadb57SMathias Bauerend Sub
4301ecadb57SMathias Bauer
4311ecadb57SMathias Bauer&apos;=======================================================
4321ecadb57SMathias Bauer&apos; InsertNewParaData
4331ecadb57SMathias Bauer&apos;-------------------------------------------------------
4341ecadb57SMathias Bauer&apos; Inserts a new ID for the paragraph
4351ecadb57SMathias Bauer&apos;=======================================================
4361ecadb57SMathias BauerSub InsertNewParaData
4371ecadb57SMathias Bauer
4381ecadb57SMathias Bauer		If not IsHelpFile Then
4391ecadb57SMathias Bauer		msgbox(strErr_NoHelpFile)
4401ecadb57SMathias Bauer		Exit Sub
4411ecadb57SMathias Bauer	End If
4421ecadb57SMathias Bauer
4431ecadb57SMathias Bauer	oSel = thiscomponent.getcurrentcontroller.getselection
4441ecadb57SMathias Bauer	oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
4451ecadb57SMathias Bauer
4461ecadb57SMathias Bauer	arParaData = GetParaData
4471ecadb57SMathias Bauer	sID = arParaData(0)
4481ecadb57SMathias Bauer	slocalize = arParaData(1)
4491ecadb57SMathias Bauer	sMsg = arParaData(2)
4501ecadb57SMathias Bauer
4511ecadb57SMathias Bauer	If sMsg &lt;&gt; &quot;&quot; Then
4521ecadb57SMathias Bauer		msgbox &quot;Cannot assign paragraph id:&quot;+chr(13)+sMsg,48,&quot;Error&quot;
4531ecadb57SMathias Bauer		Exit Sub
4541ecadb57SMathias Bauer	End If
4551ecadb57SMathias Bauer
4561ecadb57SMathias Bauer	If sID &lt;&gt; &quot;&quot; Then
4571ecadb57SMathias Bauer		msgbox &quot;Paragraph already has an ID.&quot;+chr(13)+&quot;If you want to assign a new ID delete the existing one first.&quot;,48,&quot;Error&quot;
4581ecadb57SMathias Bauer		Exit Sub
4591ecadb57SMathias Bauer	End If
4601ecadb57SMathias Bauer
4611ecadb57SMathias Bauer	oCur.gotoStartOfParagraph(0)
4621ecadb57SMathias Bauer
4631ecadb57SMathias Bauer	If (Left(oCur.ParaStyleName,8) = &quot;hlp_head&quot;) Then
4641ecadb57SMathias Bauer		id = &quot;hd_id&quot; + CreateID
4651ecadb57SMathias Bauer		thiscomponent.getcurrentcontroller.select(oCur)
4661ecadb57SMathias Bauer		MetaData = id
4671ecadb57SMathias Bauer		SetCharStyle(&quot;hlp_aux_parachanged&quot;)
4681ecadb57SMathias Bauer		InsertField(&quot;ID&quot;,MetaData)
4691ecadb57SMathias Bauer		SetCharStyle(&quot;Default&quot;)
4701ecadb57SMathias Bauer	Else
4711ecadb57SMathias Bauer		id = &quot;par_id&quot; + CreateID
4721ecadb57SMathias Bauer		thiscomponent.getcurrentcontroller.select(oCur)
4731ecadb57SMathias Bauer		MetaData = id
4741ecadb57SMathias Bauer		SetCharStyle(&quot;hlp_aux_parachanged&quot;)
4751ecadb57SMathias Bauer		InsertField(&quot;ID&quot;,MetaData)
4761ecadb57SMathias Bauer		SetCharStyle(&quot;Default&quot;)
4771ecadb57SMathias Bauer	End If
4781ecadb57SMathias Bauer
4791ecadb57SMathias Bauer
4801ecadb57SMathias BauerEnd Sub
4811ecadb57SMathias Bauer
4821ecadb57SMathias Bauer&apos;=======================================================
4831ecadb57SMathias Bauer&apos; LoadDialog
4841ecadb57SMathias Bauer&apos;-------------------------------------------------------
4851ecadb57SMathias Bauer&apos; Loads a BASIC dialog
4861ecadb57SMathias Bauer&apos;=======================================================
4871ecadb57SMathias BauerFunction LoadDialog(Libname as String, DialogName as String, Optional oLibContainer)
4881ecadb57SMathias Bauer	Dim oLib as Object
4891ecadb57SMathias Bauer	Dim oLibDialog as Object
4901ecadb57SMathias Bauer	Dim oRuntimeDialog as Object
4911ecadb57SMathias Bauer
4921ecadb57SMathias Bauer	If IsMissing(oLibContainer ) then
4931ecadb57SMathias Bauer		oLibContainer = DialogLibraries
4941ecadb57SMathias Bauer	End If
4951ecadb57SMathias Bauer
4961ecadb57SMathias Bauer	oLibContainer.LoadLibrary(LibName)
4971ecadb57SMathias Bauer	oLib = oLibContainer.GetByName(Libname)
4981ecadb57SMathias Bauer	oLibDialog = oLib.GetByName(DialogName)
4991ecadb57SMathias Bauer	oRuntimeDialog = CreateUnoDialog(oLibDialog)
5001ecadb57SMathias Bauer	LoadDialog() = oRuntimeDialog
5011ecadb57SMathias BauerEnd Function
5021ecadb57SMathias Bauer
5031ecadb57SMathias Bauer&apos;=======================================================
5041ecadb57SMathias Bauer&apos; Surprise
5051ecadb57SMathias Bauer&apos;-------------------------------------------------------
5061ecadb57SMathias Bauer&apos; D&apos;oh
5071ecadb57SMathias Bauer&apos;=======================================================
5081ecadb57SMathias BauerSub Surprise
5091ecadb57SMathias Bauer	msgbox &quot;This function is unsupported.&quot;+chr(13)+&quot;If you know how to implement this -- go ahead!&quot;,0,&quot;D&apos;oh!&quot;
5101ecadb57SMathias BauerEnd Sub
5111ecadb57SMathias Bauer
5121ecadb57SMathias Bauer&apos;=======================================================
5131ecadb57SMathias Bauer&apos; InsertNote
5141ecadb57SMathias Bauer&apos;-------------------------------------------------------
5151ecadb57SMathias Bauer&apos; Inserts a note (annotation) at the current position
5161ecadb57SMathias Bauer&apos;=======================================================
5171ecadb57SMathias Bauersub InsertNote(Content As String)
5181ecadb57SMathias Bauer	dim document   as object
5191ecadb57SMathias Bauer	dim dispatcher as object
5201ecadb57SMathias Bauer
5211ecadb57SMathias Bauer	document   = ThisComponent.CurrentController.Frame
5221ecadb57SMathias Bauer	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
5231ecadb57SMathias Bauer
5241ecadb57SMathias Bauer	dim args(2) as new com.sun.star.beans.PropertyValue
5251ecadb57SMathias Bauer	args(0).Name = &quot;Text&quot;
5261ecadb57SMathias Bauer	args(0).Value = Content
5271ecadb57SMathias Bauer	args(1).Name = &quot;Author&quot;
5281ecadb57SMathias Bauer	args(1).Value = &quot;Help Tooling - DO NOT EDIT&quot;
5291ecadb57SMathias Bauer	args(2).Name = &quot;Date&quot;
5301ecadb57SMathias Bauer	args(2).Value = &quot;02/27/2004&quot;
5311ecadb57SMathias Bauer
5321ecadb57SMathias Bauer	dispatcher.executeDispatch(document, &quot;.uno:InsertAnnotation&quot;, &quot;&quot;, 0, args())
5331ecadb57SMathias Bauerend sub
5341ecadb57SMathias Bauer
5351ecadb57SMathias Bauer&apos;=======================================================
5361ecadb57SMathias Bauer&apos; InsertText
5371ecadb57SMathias Bauer&apos;-------------------------------------------------------
5381ecadb57SMathias Bauer&apos; Inserts a string at the current position
5391ecadb57SMathias Bauer&apos;=======================================================
5401ecadb57SMathias BauerSub InsertText(strg As String)
5411ecadb57SMathias Bauer	oSel = thiscomponent.getcurrentcontroller.getselection
5421ecadb57SMathias Bauer	oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
5431ecadb57SMathias Bauer	oCur.String = strg
5441ecadb57SMathias BauerEnd Sub
5451ecadb57SMathias Bauer
5461ecadb57SMathias Bauer&apos;=======================================================
5471ecadb57SMathias Bauer&apos; ParaIsEmpty
5481ecadb57SMathias Bauer&apos;-------------------------------------------------------
5491ecadb57SMathias Bauer&apos; Evaluates if a paragraph is empty.
5501ecadb57SMathias Bauer&apos;=======================================================
5511ecadb57SMathias BauerFunction ParaIsEmpty
5521ecadb57SMathias Bauer	oSel = thiscomponent.getcurrentcontroller.getselection
5531ecadb57SMathias Bauer	oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
5541ecadb57SMathias Bauer	oCur.gotoStartOfParagraph(0)
5551ecadb57SMathias Bauer	ParaIsEmpty = oCur.IsEndOfParagraph
5561ecadb57SMathias BauerEnd Function
5571ecadb57SMathias Bauer
5581ecadb57SMathias Bauer&apos;=======================================================
5591ecadb57SMathias Bauer&apos; IsInBookmark
5601ecadb57SMathias Bauer&apos;-------------------------------------------------------
5611ecadb57SMathias Bauer&apos; Evaluates if the cursor is inside a &lt;bookmark&gt; &lt;/bookmark&gt; element
5621ecadb57SMathias Bauer&apos;=======================================================
5631ecadb57SMathias BauerFunction IsInBookmark
5641ecadb57SMathias Bauer	oSel = thiscomponent.getcurrentcontroller.getselection
5651ecadb57SMathias Bauer	oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
5661ecadb57SMathias Bauer
5671ecadb57SMathias Bauer	If ((oCur.ParaStyleName = &quot;hlp_aux_bookmark&quot;) AND (not(oCur.IsEndOfParagraph))) Then
5681ecadb57SMathias Bauer		oCur.GotoStartOfParagraph(0)
5691ecadb57SMathias Bauer		oCur.GotoEndOfParagraph(1)
5701ecadb57SMathias Bauer		sText = Left(oCur.GetString,Instr(oCur.GetString,&quot;&quot;&quot; id=&quot;&quot;&quot;)-1)
5711ecadb57SMathias Bauer		sText = Right(sText,Len(sText)-InStr(sText,&quot;&quot;&quot;&quot;))
5721ecadb57SMathias Bauer		Select Case Left(sText,3)
5731ecadb57SMathias Bauer			Case &quot;ind&quot;
5741ecadb57SMathias Bauer				IsInBookmark = 1
5751ecadb57SMathias Bauer			Case &quot;hid&quot;
5761ecadb57SMathias Bauer				IsInBookmark = 2
5771ecadb57SMathias Bauer			Case &quot;con&quot;
5781ecadb57SMathias Bauer				IsInBookmark = 3
5791ecadb57SMathias Bauer			Case Else
5801ecadb57SMathias Bauer				IsInBookmark = 0
5811ecadb57SMathias Bauer		End Select
5821ecadb57SMathias Bauer	Else
5831ecadb57SMathias Bauer		IsInBookmark = 0
5841ecadb57SMathias Bauer	End If
5851ecadb57SMathias BauerEnd Function
5861ecadb57SMathias Bauer
5871ecadb57SMathias Bauer&apos;=======================================================
5881ecadb57SMathias Bauer&apos; IsInTable
5891ecadb57SMathias Bauer&apos;-------------------------------------------------------
5901ecadb57SMathias Bauer&apos; Evaluates if the cursor is in a table
5911ecadb57SMathias Bauer&apos;=======================================================
5921ecadb57SMathias BauerFunction IsInTable
5931ecadb57SMathias Bauer	oSel = thiscomponent.getcurrentcontroller.getselection
5941ecadb57SMathias Bauer	oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
5951ecadb57SMathias Bauer
5961ecadb57SMathias Bauer	IsInTable = (VarType(oCur.TextTable) &lt;&gt; 0)
5971ecadb57SMathias BauerEnd Function
5981ecadb57SMathias Bauer
5991ecadb57SMathias Bauer&apos;=======================================================
6001ecadb57SMathias Bauer&apos; InsertLink
6011ecadb57SMathias Bauer&apos;-------------------------------------------------------
6021ecadb57SMathias Bauer&apos; Inserts a hyperlink at the current position
6031ecadb57SMathias Bauer&apos;=======================================================
6041ecadb57SMathias BauerSub InsertLink(sPath As String, sText As String, sName As String)
6051ecadb57SMathias Bauer	dim document   as object
6061ecadb57SMathias Bauer	dim dispatcher as object
6071ecadb57SMathias Bauer
6081ecadb57SMathias Bauer	document   = ThisComponent.CurrentController.Frame
6091ecadb57SMathias Bauer	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
6101ecadb57SMathias Bauer
6111ecadb57SMathias Bauer	dim args(4) as new com.sun.star.beans.PropertyValue
6121ecadb57SMathias Bauer	args(0).Name = &quot;Hyperlink.Text&quot;
6131ecadb57SMathias Bauer	args(0).Value = sText
6141ecadb57SMathias Bauer	args(1).Name = &quot;Hyperlink.URL&quot;
6151ecadb57SMathias Bauer	args(1).Value = sPath
6161ecadb57SMathias Bauer	args(2).Name = &quot;Hyperlink.Target&quot;
6171ecadb57SMathias Bauer	args(2).Value = &quot;&quot;
6181ecadb57SMathias Bauer	args(3).Name = &quot;Hyperlink.Name&quot;
6191ecadb57SMathias Bauer	args(3).Value = sName
6201ecadb57SMathias Bauer	args(4).Name = &quot;Hyperlink.Type&quot;
6211ecadb57SMathias Bauer	args(4).Value = 1
6221ecadb57SMathias Bauer
6231ecadb57SMathias Bauer	dispatcher.executeDispatch(document, &quot;.uno:SetHyperlink&quot;, &quot;&quot;, 0, args())
6241ecadb57SMathias Bauer	args(0).Name = &quot;Count&quot;
6251ecadb57SMathias Bauer	args(0).Value = 1
6261ecadb57SMathias Bauer	args(1).Name = &quot;Select&quot;
6271ecadb57SMathias Bauer	args(1).Value = false
6281ecadb57SMathias Bauer
6291ecadb57SMathias Bauer	dispatcher.executeDispatch(document, &quot;.uno:GoRight&quot;, &quot;&quot;, 0, args())
6301ecadb57SMathias Bauer
6311ecadb57SMathias BauerEnd Sub
6321ecadb57SMathias Bauer
6331ecadb57SMathias Bauer&apos;=======================================================
6341ecadb57SMathias Bauer&apos; AssignMissingIDs
6351ecadb57SMathias Bauer&apos;-------------------------------------------------------
6361ecadb57SMathias Bauer&apos; Assigns IDs to elements that miss them
6371ecadb57SMathias Bauer&apos;=======================================================
6381ecadb57SMathias BauerSub AssignMissingIDs
6391ecadb57SMathias Bauer&apos; NOT IMPLEMENTED YET
6401ecadb57SMathias Bauerend sub
6411ecadb57SMathias Bauer
6421ecadb57SMathias Bauer&apos;=======================================================
6431ecadb57SMathias Bauer&apos; CreateTable
6441ecadb57SMathias Bauer&apos;-------------------------------------------------------
6451ecadb57SMathias Bauer&apos; Creates a new table
6461ecadb57SMathias Bauer&apos;=======================================================
6471ecadb57SMathias BauerSub CreateTable(nRows as Integer, nCols as Integer, sID as String)
6481ecadb57SMathias Bauer	dim document   as object
6491ecadb57SMathias Bauer	dim dispatcher as object
6501ecadb57SMathias Bauer
6511ecadb57SMathias Bauer	document   = ThisComponent.CurrentController.Frame
6521ecadb57SMathias Bauer	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
6531ecadb57SMathias Bauer
6541ecadb57SMathias Bauer	dim args1(3) as new com.sun.star.beans.PropertyValue
6551ecadb57SMathias Bauer	args1(0).Name = &quot;TableName&quot;
6561ecadb57SMathias Bauer	args1(0).Value = sID
6571ecadb57SMathias Bauer	args1(1).Name = &quot;Columns&quot;
6581ecadb57SMathias Bauer	args1(1).Value = nCols
6591ecadb57SMathias Bauer	args1(2).Name = &quot;Rows&quot;
6601ecadb57SMathias Bauer	args1(2).Value = nRows
6611ecadb57SMathias Bauer	args1(3).Name = &quot;Flags&quot;
6621ecadb57SMathias Bauer	args1(3).Value = 9
6631ecadb57SMathias Bauer
6641ecadb57SMathias Bauer	dispatcher.executeDispatch(document, &quot;.uno:InsertTable&quot;, &quot;&quot;, 0, args1())
6651ecadb57SMathias Bauer
6661ecadb57SMathias Bauer	args1(0).Name = &quot;TopBottomMargin.TopMargin&quot;
6671ecadb57SMathias Bauer	args1(0).Value = 500
6681ecadb57SMathias Bauer	args1(1).Name = &quot;TopBottomMargin.BottomMargin&quot;
6691ecadb57SMathias Bauer	args1(1).Value = 0
6701ecadb57SMathias Bauer	args1(2).Name = &quot;TopBottomMargin.TopRelMargin&quot;
6711ecadb57SMathias Bauer	args1(2).Value = 100
6721ecadb57SMathias Bauer	args1(3).Name = &quot;TopBottomMargin.BottomRelMargin&quot;
6731ecadb57SMathias Bauer	args1(3).Value = 100
6741ecadb57SMathias Bauer
6751ecadb57SMathias Bauer	dispatcher.executeDispatch(document, &quot;.uno:TopBottomMargin&quot;, &quot;&quot;, 0, args1())
6761ecadb57SMathias Bauer	dispatcher.executeDispatch(document, &quot;.uno:SelectAll&quot;, &quot;&quot;, 0, Array())
6771ecadb57SMathias Bauer	SetParaStyle(&quot;hlp_tablecontent&quot;)
6781ecadb57SMathias Bauer	GoDown(1)
6791ecadb57SMathias Bauerend Sub
6801ecadb57SMathias Bauer
6811ecadb57SMathias Bauer&apos;=======================================================
6821ecadb57SMathias Bauer&apos; IsBlockImage
6831ecadb57SMathias Bauer&apos;-------------------------------------------------------
6841ecadb57SMathias Bauer&apos; Evaluates if the cursor is in a paragraph with
6851ecadb57SMathias Bauer&apos; a block image (image in its own paragraph)
6861ecadb57SMathias Bauer&apos;=======================================================
6871ecadb57SMathias BauerFunction IsBlockImage
6881ecadb57SMathias Bauer	oSel = thiscomponent.getcurrentcontroller.getselection
6891ecadb57SMathias Bauer	oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
6901ecadb57SMathias Bauer	oCur.gotoStartOfParagraph(0)
6911ecadb57SMathias Bauer	oCur.gotoEndOfParagraph(1)
6921ecadb57SMathias Bauer	sStr = Right(oCur.String,Len(oCur.String)-InStr(oCur.String,&quot; &quot;))  &apos;string must start with &lt;IMG and end with IMG with no &lt;IMG in between
6931ecadb57SMathias Bauer	IsBlockImage = (not(Left(sStr,4)=&quot;IMG&gt;&quot;) AND (Right(sStr,6)=&quot;&lt;/IMG&gt;&quot;))
6941ecadb57SMathias BauerEnd Function
6951ecadb57SMathias Bauer
6961ecadb57SMathias Bauer&apos;=======================================================
6971ecadb57SMathias Bauer&apos; HasCaption
6981ecadb57SMathias Bauer&apos;-------------------------------------------------------
6991ecadb57SMathias Bauer&apos; Evaluates if the current image has a caption element
7001ecadb57SMathias Bauer&apos;=======================================================
7011ecadb57SMathias BauerFunction HasCaption
7021ecadb57SMathias Bauer	oSel = thiscomponent.getcurrentcontroller.getselection
7031ecadb57SMathias Bauer	If oSel.ImplementationName = &quot;SwXTextGraphicObject&quot; Then
7041ecadb57SMathias Bauer		oCur = oSel(0).getAnchor.getText.createTextCursorByRange(oSel(0).getAnchor)
7051ecadb57SMathias Bauer	Else
7061ecadb57SMathias Bauer		oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
7071ecadb57SMathias Bauer	End If
7081ecadb57SMathias Bauer	oCur.gotoStartOfParagraph(0)
7091ecadb57SMathias Bauer	oCur.gotoEndOfParagraph(1)
7101ecadb57SMathias Bauer	HasCaption = (InStr(oCur.String,&quot;&lt;IMGCAPTION&quot;)&gt;0)
7111ecadb57SMathias BauerEnd Function
7121ecadb57SMathias Bauer
7131ecadb57SMathias Bauer&apos;=======================================================
7141ecadb57SMathias Bauer&apos; GetImageID
7151ecadb57SMathias Bauer&apos;-------------------------------------------------------
7161ecadb57SMathias Bauer&apos; Returns the ID of an image at the cursor position
7171ecadb57SMathias Bauer&apos;=======================================================
7181ecadb57SMathias BauerFunction GetImageID
7191ecadb57SMathias Bauer	oSel = thiscomponent.getcurrentcontroller.getselection
7201ecadb57SMathias Bauer	If oSel.ImplementationName = &quot;SwXTextGraphicObject&quot; Then
7211ecadb57SMathias Bauer		oCur = oSel(0).getAnchor.getText.createTextCursorByRange(oSel(0).getAnchor)
7221ecadb57SMathias Bauer	Else
7231ecadb57SMathias Bauer		oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
7241ecadb57SMathias Bauer	End If
7251ecadb57SMathias Bauer	oCur.gotoStartOfParagraph(0)
7261ecadb57SMathias Bauer	oCur.gotoEndOfParagraph(1)
7271ecadb57SMathias Bauer	sStr = Right(oCur.String,Len(oCur.String)-(InStr(oCur.String,&quot;IMG ID=&quot;&quot;&quot;)+7))
7281ecadb57SMathias Bauer	GetImageID = Left(sStr,InStr(sStr,&quot;&quot;&quot;&gt;&quot;)+1)  &apos;string must start with &lt;IMG and end with IMG with no &lt;IMG in between
7291ecadb57SMathias BauerEnd Function
7301ecadb57SMathias Bauer
7311ecadb57SMathias Bauer&apos;=======================================================
7321ecadb57SMathias Bauer&apos; SelAll
7331ecadb57SMathias Bauer&apos;-------------------------------------------------------
7341ecadb57SMathias Bauer&apos; Selects everything
7351ecadb57SMathias Bauer&apos;=======================================================
7361ecadb57SMathias BauerSub SelAll
7371ecadb57SMathias Bauer	dim document   as object
7381ecadb57SMathias Bauer	dim dispatcher as object
7391ecadb57SMathias Bauer
7401ecadb57SMathias Bauer	document   = ThisComponent.CurrentController.Frame
7411ecadb57SMathias Bauer	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
7421ecadb57SMathias Bauer
7431ecadb57SMathias Bauer	dispatcher.executeDispatch(document, &quot;.uno:SelectAll&quot;, &quot;&quot;, 0, Array())
7441ecadb57SMathias BauerEnd Sub
7451ecadb57SMathias Bauer
7461ecadb57SMathias Bauer&apos;=======================================================
7471ecadb57SMathias Bauer&apos; GetParaData
7481ecadb57SMathias Bauer&apos;-------------------------------------------------------
7491ecadb57SMathias Bauer&apos; Returns the Paragraph ID and localization status
7501ecadb57SMathias Bauer&apos;=======================================================
7511ecadb57SMathias BauerFunction GetParaData
7521ecadb57SMathias Bauer	arParaData = Array(&quot;&quot;,&quot;&quot;,&quot;&quot;) &apos; ID, localize, #message
7531ecadb57SMathias Bauer
7541ecadb57SMathias Bauer	oSel = thiscomponent.getcurrentcontroller.getselection
7551ecadb57SMathias Bauer	oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
7561ecadb57SMathias Bauer	oCur.gotoStartOfParagraph(0)
7571ecadb57SMathias Bauer	oCur.gotoEndOfParagraph(1)
7581ecadb57SMathias Bauer	sID = &quot;&quot;
7591ecadb57SMathias Bauer	Enum = oCur.createEnumeration
7601ecadb57SMathias Bauer	Fd = FALSE
7611ecadb57SMathias Bauer
7621ecadb57SMathias Bauer
7631ecadb57SMathias Bauer	TE = Enum.nextElement
7641ecadb57SMathias Bauer
7651ecadb57SMathias Bauer	TP = TE.createEnumeration
7661ecadb57SMathias Bauer	Ct = 0
7671ecadb57SMathias Bauer	posID = 0
7681ecadb57SMathias Bauer
7691ecadb57SMathias Bauer	Do While TP.hasmoreElements
7701ecadb57SMathias Bauer		Ct = Ct+1
7711ecadb57SMathias Bauer		TPE = TP.nextElement
7721ecadb57SMathias Bauer		If TPE.TextPortionType=&quot;TextField&quot; Then
7731ecadb57SMathias Bauer			If TPE.TextField.TextFieldMaster.Name=&quot;ID&quot; Then
7741ecadb57SMathias Bauer				sID = TPE.TextField.Content
7751ecadb57SMathias Bauer				Fd = TRUE
7761ecadb57SMathias Bauer				Exit Do
7771ecadb57SMathias Bauer			End If
7781ecadb57SMathias Bauer		End If
7791ecadb57SMathias Bauer		If TPE.String = &quot;&quot; Then
7801ecadb57SMathias Bauer			Ct = Ct-1
7811ecadb57SMathias Bauer		End If
7821ecadb57SMathias Bauer	Loop
7831ecadb57SMathias Bauer
7841ecadb57SMathias Bauer	If ((Left(oCur.ParaStyleName,8) = &quot;hlp_aux_&quot;) or (Left(oCur.ParaStyleName,4) &lt;&gt; &quot;hlp_&quot;)) Then
7851ecadb57SMathias Bauer		arParaData(2)=&quot;Invalid Paragraph Style&quot;
7861ecadb57SMathias Bauer		GetParaData = arParaData
7871ecadb57SMathias Bauer		Exit Function
7881ecadb57SMathias Bauer	End If
7891ecadb57SMathias Bauer
7901ecadb57SMathias Bauer	If sID = &quot;&quot; Then
7911ecadb57SMathias Bauer		GetParaData = arParaData
7921ecadb57SMathias Bauer		Exit Function
7931ecadb57SMathias Bauer	End If
7941ecadb57SMathias Bauer
7951ecadb57SMathias Bauer	If Right(sID,7) = &quot;_NOL10N&quot; Then
7961ecadb57SMathias Bauer		arParaData(0) = Left(sID,Len(sID)-7)
7971ecadb57SMathias Bauer		arParaData(1) = &quot;no&quot;
7981ecadb57SMathias Bauer	Else
7991ecadb57SMathias Bauer		arParaData(0) = sID
8001ecadb57SMathias Bauer		arParaData(1) = &quot;yes&quot;
8011ecadb57SMathias Bauer	End If
8021ecadb57SMathias Bauer
8031ecadb57SMathias Bauer	GetParaData = arParaData
8041ecadb57SMathias BauerEnd Function
8051ecadb57SMathias Bauer
8061ecadb57SMathias Bauer&apos;=======================================================
8071ecadb57SMathias Bauer&apos; SetsParaData
8081ecadb57SMathias Bauer&apos;-------------------------------------------------------
8091ecadb57SMathias Bauer&apos; Sets the Paragraph ID and localization status
8101ecadb57SMathias Bauer&apos;=======================================================
8111ecadb57SMathias Bauer
8121ecadb57SMathias BauerSub SetParaData(sID as String, sLocalize as String)
8131ecadb57SMathias Bauer
8141ecadb57SMathias Bauer	oSel = thiscomponent.getcurrentcontroller.getselection
8151ecadb57SMathias Bauer	oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
8161ecadb57SMathias Bauer	oCur.gotoStartOfParagraph(0)
8171ecadb57SMathias Bauer	oCur.gotoEndOfParagraph(1)
8181ecadb57SMathias Bauer	Enum = oCur.createEnumeration
8191ecadb57SMathias Bauer	Fd = FALSE
8201ecadb57SMathias Bauer
8211ecadb57SMathias Bauer
8221ecadb57SMathias Bauer	Do While Enum.hasMoreElements
8231ecadb57SMathias Bauer		TE = Enum.nextElement
8241ecadb57SMathias Bauer
8251ecadb57SMathias Bauer		TP = TE.createEnumeration
8261ecadb57SMathias Bauer		Ct = 0
8271ecadb57SMathias Bauer		posID = 0
8281ecadb57SMathias Bauer
8291ecadb57SMathias Bauer		Do While TP.hasmoreElements
8301ecadb57SMathias Bauer			Ct = Ct+1
8311ecadb57SMathias Bauer			TPE = TP.nextElement
8321ecadb57SMathias Bauer			If TPE.TextPortionType=&quot;TextField&quot; Then
8331ecadb57SMathias Bauer				If TPE.TextField.TextFieldMaster.Name=&quot;ID&quot; Then
8341ecadb57SMathias Bauer					posID = Ct
8351ecadb57SMathias Bauer					If sLocalize = &quot;no&quot; Then
8361ecadb57SMathias Bauer						TPE.TextField.Content = sID+&quot;_NOL10N&quot;
8371ecadb57SMathias Bauer						TPE.TextField.IsVisible = TRUE
8381ecadb57SMathias Bauer					ElseIf sLocalize = &quot;yes&quot; Then
8391ecadb57SMathias Bauer						TPE.TextField.Content = sID
8401ecadb57SMathias Bauer						TPE.TextField.IsVisible = TRUE
8411ecadb57SMathias Bauer					Else
8421ecadb57SMathias Bauer						msgbox &quot;Unknown localization parameter: &quot;+sLocalize,0,&quot;Error&quot;
8431ecadb57SMathias Bauer					End If
8441ecadb57SMathias Bauer					Fd = TRUE
8451ecadb57SMathias Bauer					Exit Do
8461ecadb57SMathias Bauer				End If
8471ecadb57SMathias Bauer			End If
8481ecadb57SMathias Bauer			If TPE.String = &quot;&quot; Then
8491ecadb57SMathias Bauer				Ct = Ct-1
8501ecadb57SMathias Bauer			End If
8511ecadb57SMathias Bauer		Loop
8521ecadb57SMathias Bauer		If Fd Then
8531ecadb57SMathias Bauer			Exit Do
8541ecadb57SMathias Bauer		End If
8551ecadb57SMathias Bauer	Loop
8561ecadb57SMathias Bauer
8571ecadb57SMathias Bauer	oCur.TextField.update
8581ecadb57SMathias Bauer	UpdateFields
8591ecadb57SMathias Bauer
8601ecadb57SMathias BauerEnd Sub
8611ecadb57SMathias Bauer
8621ecadb57SMathias Bauer
8631ecadb57SMathias Bauer&apos;=======================================================
8641ecadb57SMathias Bauer&apos; IsInList
8651ecadb57SMathias Bauer&apos;-------------------------------------------------------
8661ecadb57SMathias Bauer&apos; Evaluates if the cursor is inside a list (ordered or unordered)
8671ecadb57SMathias Bauer&apos;=======================================================
8681ecadb57SMathias BauerFunction IsInList
8691ecadb57SMathias Bauer	oSel = thiscomponent.getcurrentcontroller.getselection
8701ecadb57SMathias Bauer	oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
8711ecadb57SMathias Bauer	If oCur.NumberingStyleName = &quot;&quot;  Then
8721ecadb57SMathias Bauer		IsInList = false
8731ecadb57SMathias Bauer	ElseIf oCur.NumberingRules.NumberingIsOutline = true Then
8741ecadb57SMathias Bauer		IsInList = false
8751ecadb57SMathias Bauer	Else
8761ecadb57SMathias Bauer		IsInList = true
8771ecadb57SMathias Bauer	End If
8781ecadb57SMathias BauerEnd Function
8791ecadb57SMathias Bauer
8801ecadb57SMathias Bauer&apos;=======================================================
8811ecadb57SMathias Bauer&apos; TagFormatIsCorrect
8821ecadb57SMathias Bauer&apos;-------------------------------------------------------
8831ecadb57SMathias Bauer&apos; Checks for correct paragraph format for tags
8841ecadb57SMathias Bauer&apos;=======================================================
8851ecadb57SMathias BauerFunction TagFormatIsCorrect(sTN As String, sPS As String)
8861ecadb57SMathias Bauer
8871ecadb57SMathias Bauer	arTag = Array(&quot;BOOKMARK&quot;,&quot;SORT&quot;,&quot;SECTION&quot;,&quot;SWITCH&quot;,&quot;CASE&quot;,&quot;DEFAULT&quot;)
8881ecadb57SMathias Bauer	arTagFormat = Array(&quot;hlp_aux_bookmark&quot;,&quot;hlp_aux_sort&quot;,&quot;hlp_aux_section&quot;,&quot;hlp_aux_switch&quot;,&quot;hlp_aux_switch&quot;,&quot;hlp_aux_switch&quot;)
8891ecadb57SMathias Bauer
8901ecadb57SMathias Bauer	For n=0 to ubound(arTag)
8911ecadb57SMathias Bauer		If (sTN = arTag(n) AND sPS &lt;&gt; arTagFormat(n)) Then
8921ecadb57SMathias Bauer			TagFormatIsCorrect = arTagFormat(n)
8931ecadb57SMathias Bauer			Exit Function
8941ecadb57SMathias Bauer		End If
8951ecadb57SMathias Bauer		TagFormatIsCorrect = &quot;&quot;
8961ecadb57SMathias Bauer	Next n
8971ecadb57SMathias Bauer
8981ecadb57SMathias BauerEnd Function
8991ecadb57SMathias Bauer
9001ecadb57SMathias Bauer&apos;=======================================================
9011ecadb57SMathias Bauer&apos; GetFilePath
9021ecadb57SMathias Bauer&apos;-------------------------------------------------------
9031ecadb57SMathias Bauer&apos; look for the &quot;text/...&quot; part of the file name and separate it
9041ecadb57SMathias Bauer&apos;=======================================================
9051ecadb57SMathias BauerFunction GetFilePath(fname As String)
9061ecadb57SMathias Bauer
9071ecadb57SMathias Bauer	i = 1
9081ecadb57SMathias Bauer	Do
9091ecadb57SMathias Bauer		If (Mid(fname,i,5) = &quot;text/&quot;) Then
9101ecadb57SMathias Bauer			Strg = Mid(fname,i,Len(fname)-i+1)
9111ecadb57SMathias Bauer			Exit Do
9121ecadb57SMathias Bauer		Else
9131ecadb57SMathias Bauer			i = i+1
9141ecadb57SMathias Bauer			Strg = fname
9151ecadb57SMathias Bauer		End If
9161ecadb57SMathias Bauer	Loop While (i+5 &lt; Len(fname))
9171ecadb57SMathias Bauer	GetFilePath = Strg
9181ecadb57SMathias BauerEnd Function
9191ecadb57SMathias Bauer
9201ecadb57SMathias Bauer&apos;=======================================================
9211ecadb57SMathias Bauer&apos; OpenGraphics
9221ecadb57SMathias Bauer&apos;-------------------------------------------------------
9231ecadb57SMathias Bauer&apos; Calls the graphic open dialog for inserting an image
9241ecadb57SMathias Bauer&apos;=======================================================
9251ecadb57SMathias BauerFunction OpenGraphics(oDoc As Object)
9261ecadb57SMathias BauerDim ListAny(0) as Long
9271ecadb57SMathias BauerDim oStoreProperties(0) as New com.sun.star.beans.PropertyValue
9281ecadb57SMathias Bauer	GlobalScope.BasicLibraries.loadLibrary(&quot;Tools&quot;)
9291ecadb57SMathias Bauer	ListAny(0) = com.sun.star.ui.dialogs.TemplateDescription.FILEOPEN_SIMPLE
9301ecadb57SMathias Bauer&apos;	ListAny(0) = com.sun.star.ui.dialogs.TemplateDescription.FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE
9311ecadb57SMathias Bauer	oFileDialog = CreateUnoService(&quot;com.sun.star.ui.dialogs.FilePicker&quot;)
9321ecadb57SMathias Bauer	oFileDialog.Initialize(ListAny())
9331ecadb57SMathias Bauer
9341ecadb57SMathias Bauer	sLastImgDir = ReadConfig(&quot;LastImgDir&quot;)
9351ecadb57SMathias Bauer	If sLastImgDir &lt;&gt; &quot;&quot; Then
9361ecadb57SMathias Bauer		oFileDialog.setDisplayDirectory(sLastImgDir)
9371ecadb57SMathias Bauer	End If
9381ecadb57SMathias Bauer
9391ecadb57SMathias Bauer	oMasterKey = GetRegistryKeyContent(&quot;org.openoffice.TypeDetection.Types/&quot;)
9401ecadb57SMathias Bauer	oTypes() = oMasterKey.Types
9411ecadb57SMathias Bauer
9421ecadb57SMathias Bauer	oFileDialog.AppendFilter(oTypes.GetByName(&quot;gif_Graphics_Interchange&quot;).UIName, &quot;*.gif&quot;)
9431ecadb57SMathias Bauer	oFileDialog.AppendFilter(oTypes.GetByName(&quot;png_Portable_Network_Graphic&quot;).UIName, &quot;*.png&quot;)
9441ecadb57SMathias Bauer
9451ecadb57SMathias Bauer	oFileDialog.SetTitle(&quot;Insert Image&quot;)
9461ecadb57SMathias Bauer	iAccept = oFileDialog.Execute()
9471ecadb57SMathias Bauer	If iAccept = 1 Then
9481ecadb57SMathias Bauer		sPath = oFileDialog.Files(0)
9491ecadb57SMathias Bauer		WriteConfig(&quot;LastImgDir&quot;,oFileDialog.getDisplayDirectory)
9501ecadb57SMathias Bauer		UIFilterName = oFileDialog.GetCurrentFilter()
9511ecadb57SMathias Bauer		OpenGraphics = oFileDialog.Files(0)
9521ecadb57SMathias Bauer	Else
9531ecadb57SMathias Bauer		OpenGraphics = &quot;&quot;
9541ecadb57SMathias Bauer	End If
9551ecadb57SMathias Bauer	oFileDialog.Dispose()
9561ecadb57SMathias BauerEnd Function
9571ecadb57SMathias Bauer
9581ecadb57SMathias Bauer&apos;=======================================================
9591ecadb57SMathias Bauer&apos; WriteConfig
9601ecadb57SMathias Bauer&apos;-------------------------------------------------------
9611ecadb57SMathias Bauer&apos; Reads a parameter value from the config file
9621ecadb57SMathias Bauer&apos;=======================================================
9631ecadb57SMathias BauerFunction ReadConfig(Parm As String)
9641ecadb57SMathias Bauer	oPath = createUNOService(&quot;com.sun.star.util.PathSettings&quot;)
9651ecadb57SMathias Bauer	filename = oPath.UserConfig+&quot;/helpauthoring.cfg&quot;
9661ecadb57SMathias Bauer	iNumber = Freefile
9671ecadb57SMathias Bauer	bFound = false
9681ecadb57SMathias Bauer	If FileExists(filename) Then
9691ecadb57SMathias Bauer		Open filename For Input As iNumber
9701ecadb57SMathias Bauer		Do While (not eof(iNumber) AND not(bFound))
9711ecadb57SMathias Bauer			Line Input #iNumber, sLine
9721ecadb57SMathias Bauer			If InStr(sLine, &quot;=&quot;) &gt; 0 Then
9731ecadb57SMathias Bauer				arLine = split(sLine,&quot;=&quot;)
9741ecadb57SMathias Bauer				If arLine(0) = Parm Then
9751ecadb57SMathias Bauer					sResult = arLine(1)
9761ecadb57SMathias Bauer					bFound = true
9771ecadb57SMathias Bauer				End If
9781ecadb57SMathias Bauer			End If
9791ecadb57SMathias Bauer		Loop
9801ecadb57SMathias Bauer		Close #iNumber
9811ecadb57SMathias Bauer		If bFound Then
9821ecadb57SMathias Bauer			ReadConfig = sResult
9831ecadb57SMathias Bauer		Else
9841ecadb57SMathias Bauer			ReadConfig = &quot;&quot;
9851ecadb57SMathias Bauer		End If
9861ecadb57SMathias Bauer	Else
9871ecadb57SMathias Bauer		ReadConfig = &quot;&quot;
9881ecadb57SMathias Bauer	End If
9891ecadb57SMathias BauerEnd Function
9901ecadb57SMathias Bauer
9911ecadb57SMathias Bauer
9921ecadb57SMathias Bauer&apos;=======================================================
9931ecadb57SMathias Bauer&apos; WriteConfig
9941ecadb57SMathias Bauer&apos;-------------------------------------------------------
9951ecadb57SMathias Bauer&apos; Writes a parameter/value pair to the config file
9961ecadb57SMathias Bauer&apos;=======================================================
9971ecadb57SMathias BauerFunction WriteConfig(Parm As String, Value As String)
9981ecadb57SMathias Bauer	Dim arLines(0) As String
9991ecadb57SMathias Bauer	bFound = false
10001ecadb57SMathias Bauer	oPath = createUNOService(&quot;com.sun.star.util.PathSettings&quot;)
10011ecadb57SMathias Bauer	filename = oPath.UserConfig+&quot;/helpauthoring.cfg&quot;
10021ecadb57SMathias Bauer	iNumber = Freefile
10031ecadb57SMathias Bauer	If FileExists(filename) Then
10041ecadb57SMathias Bauer
10051ecadb57SMathias Bauer		Open filename For Input As iNumber
10061ecadb57SMathias Bauer		Do While (not eof(iNumber))
10071ecadb57SMathias Bauer			Line Input #iNumber, sLine
10081ecadb57SMathias Bauer			If InStr(sLine, &quot;=&quot;) &gt; 0 Then
10091ecadb57SMathias Bauer				sDim = ubound(arLines())+1
10101ecadb57SMathias Bauer				ReDim Preserve arLines(sDim)
10111ecadb57SMathias Bauer				arLines(sDim) = sLine
10121ecadb57SMathias Bauer			End If
10131ecadb57SMathias Bauer		Loop
10141ecadb57SMathias Bauer		Close #iNumber
10151ecadb57SMathias Bauer
10161ecadb57SMathias Bauer		nLine = 1
10171ecadb57SMathias Bauer		Do While (nLine &lt;= ubound(arLines())) and (not bFound)
10181ecadb57SMathias Bauer			arLine = split(arLines(nLine),&quot;=&quot;)
10191ecadb57SMathias Bauer			If arLine(0) = Parm Then
10201ecadb57SMathias Bauer				arLines(nLine) = Parm+&quot;=&quot;+Value
10211ecadb57SMathias Bauer				bFound = true
10221ecadb57SMathias Bauer			End If
10231ecadb57SMathias Bauer			nLine = nLine +1
10241ecadb57SMathias Bauer		Loop
10251ecadb57SMathias Bauer
10261ecadb57SMathias Bauer		nLine = 1
10271ecadb57SMathias Bauer		Open filename For Output As iNumber
10281ecadb57SMathias Bauer		Do While (nLine &lt;= ubound(arLines()))
10291ecadb57SMathias Bauer			Print #iNumber, arLines(nLine)
10301ecadb57SMathias Bauer			nLine = nLine + 1
10311ecadb57SMathias Bauer		Loop
10321ecadb57SMathias Bauer		If (not bFound) Then
10331ecadb57SMathias Bauer			Print #iNumber, Parm+&quot;=&quot;+Value
10341ecadb57SMathias Bauer		End If
10351ecadb57SMathias Bauer		Close #iNumber
10361ecadb57SMathias Bauer
10371ecadb57SMathias Bauer	Else
10381ecadb57SMathias Bauer		Open filename For Output As iNumber
10391ecadb57SMathias Bauer		Print #iNumber, Parm+&quot;=&quot;+Value
10401ecadb57SMathias Bauer		Close #iNumber
10411ecadb57SMathias Bauer	End If
10421ecadb57SMathias BauerEnd Function
10431ecadb57SMathias Bauer
10441ecadb57SMathias BauerFunction GetRelPath(sPath As String)
10451ecadb57SMathias Bauer	sHelpPrefix = ReadConfig(&quot;HelpPrefix&quot;)
10461ecadb57SMathias Bauer	If sHelpPrefix = &quot;&quot; Then
10471ecadb57SMathias Bauer		sHelpPrefix = SetDocumentRoot
10481ecadb57SMathias Bauer	End If
10491ecadb57SMathias Bauer	GetRelPath = Right(sPath, Len(sPath)-(InStr(sPath,sHelpPrefix) + Len(sHelpPrefix)-1))
10501ecadb57SMathias BauerEnd Function
10511ecadb57SMathias Bauer
10521ecadb57SMathias BauerFunction SetDocumentRoot
10531ecadb57SMathias Bauer	sHelpPrefix = ReadConfig(&quot;HelpPrefix&quot;)
10541ecadb57SMathias Bauer	oFolderDialog = CreateUnoService(&quot;com.sun.star.ui.dialogs.FolderPicker&quot;)
10551ecadb57SMathias Bauer	oFolderDialog.SetTitle(&quot;Select Document Root Folder&quot;)
10561ecadb57SMathias Bauer	If sHelpPrefix &gt; &quot;&quot; Then
10571ecadb57SMathias Bauer		oFolderDialog.setDisplayDirectory(sHelpPrefix)
10581ecadb57SMathias Bauer	End If
10591ecadb57SMathias Bauer	iAccept = oFolderDialog.Execute()
10601ecadb57SMathias Bauer
10611ecadb57SMathias Bauer	If iAccept = 1 Then
10621ecadb57SMathias Bauer		sHelpPrefix = oFolderDialog.getDirectory + &quot;/&quot;
10631ecadb57SMathias Bauer		WriteConfig(&quot;HelpPrefix&quot;,sHelpPrefix)
10641ecadb57SMathias Bauer	End If
10651ecadb57SMathias Bauer
10661ecadb57SMathias Bauer	SetDocumentRoot = sHelpPrefix
10671ecadb57SMathias BauerEnd Function
10681ecadb57SMathias Bauer
10691ecadb57SMathias BauerFunction MakeAbsPath(sPath As String)
10701ecadb57SMathias Bauer
10711ecadb57SMathias Bauer	sHelpPrefix = ReadConfig(&quot;HelpPrefix&quot;)
10721ecadb57SMathias Bauer	If sHelpPrefix = &quot;&quot; Then
10731ecadb57SMathias Bauer		sHelpPrefix = SetDocumentRoot
10741ecadb57SMathias Bauer	End If
10751ecadb57SMathias Bauer
10761ecadb57SMathias Bauer	If Right(sPath,4) &lt;&gt; &quot;.xhp&quot; Then
10771ecadb57SMathias Bauer		sPath=sPath+&quot;.xhp&quot;
10781ecadb57SMathias Bauer	End If
10791ecadb57SMathias Bauer	MakeAbsPath = sHelpPrefix+sPath
10801ecadb57SMathias BauerEnd Function
10811ecadb57SMathias Bauer
10821ecadb57SMathias Bauer
10831ecadb57SMathias BauerSub UpdateFields
10841ecadb57SMathias Bauer	dim document   as object
10851ecadb57SMathias Bauer	dim dispatcher as object
10861ecadb57SMathias Bauer	document   = ThisComponent.CurrentController.Frame
10871ecadb57SMathias Bauer	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
10881ecadb57SMathias Bauer
10891ecadb57SMathias Bauer	dispatcher.executeDispatch(document, &quot;.uno:UpdateFields&quot;, &quot;&quot;, 0, Array())
10901ecadb57SMathias BauerEnd Sub
10911ecadb57SMathias Bauer
10921ecadb57SMathias BauerFunction IsHelpFile
10931ecadb57SMathias Bauer	document = StarDesktop.CurrentComponent
10941ecadb57SMathias Bauer	IsHelpFile = (Right(GetFilePath(document.URL),4)=&quot;.xhp&quot;)
10951ecadb57SMathias BauerEnd Function
10961ecadb57SMathias Bauer
10971ecadb57SMathias BauerFunction GetUserFieldNumber(fn as String)
10981ecadb57SMathias Bauer	fnum = -1
10991ecadb57SMathias Bauer	For a=0 to document.DocumentInfo.getUserFieldCount - 1
11001ecadb57SMathias Bauer		If document.DocumentInfo.getUserFieldName(a) = fn Then
11011ecadb57SMathias Bauer			fnum = a
11021ecadb57SMathias Bauer			Exit for
11031ecadb57SMathias Bauer		End If
11041ecadb57SMathias Bauer	Next a
11051ecadb57SMathias Bauer	GetUserFieldNumber = fnum
11061ecadb57SMathias BauerEnd Function
1107*3e02b54dSAndrew Rist</script:module>
1108