incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mba...@apache.org
Subject svn commit: r1172372 [2/6] - in /incubator/ooo/trunk/main/helpauthoring: ./ HelpAuthoring/ META-INF/ filter/ help/ help/en-US/ help/en-US/org.openoffice.helpauthoring/
Date Sun, 18 Sep 2011 21:34:42 GMT
Added: incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/Helpers.xba
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/Helpers.xba?rev=1172372&view=auto
==============================================================================
--- incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/Helpers.xba (added)
+++ incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/Helpers.xba Sun Sep 18 21:34:39 2011
@@ -0,0 +1,1087 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
+<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Helpers" script:language="StarBasic">&apos; *** MODULE HELPERS ***
+
+&apos;=======================================================
+&apos; Main
+&apos;-------------------------------------------------------
+&apos; Ensure that necessary library functions are available
+&apos;=======================================================
+Sub Main
+	GlobalScope.BasicLibraries.loadLibrary(&quot;Tools&quot;)
+End Sub
+
+&apos;=======================================================
+&apos; ShowProp
+&apos;-------------------------------------------------------
+&apos; Displays a dialog that shows the properties and
+&apos; the methods of an object. Used for debugging.
+&apos;=======================================================
+Sub ShowProp(Elem As Object)
+	dim oDialog As Object
+	
+	BasicLibraries.LoadLibrary(&quot;HelpAuthoring&quot;)
+	oDialog = LoadDialog(&quot;HelpAuthoring&quot;, &quot;dlgObjProp&quot;)
+	oDialogModel = oDialog.Model
+		
+	oTxtProp = oDialog.GetControl(&quot;txtProp&quot;)
+	oTxtProp.Text = Join(Split(Elem.dbg_properties,&quot;;&quot;),chr(13))
+	
+	oTxtMeth = oDialog.GetControl(&quot;txtMeth&quot;)
+	oTxtMeth.Text = Join(Split(Elem.dbg_methods,&quot;;&quot;),chr(13))
+	
+	oTxtInt = oDialog.GetControl(&quot;txtInt&quot;)
+	oTxtInt.Text = Join(Split(Elem.dbg_supportedInterfaces,&quot;;&quot;),chr(13))
+	
+	oDialog.Execute()
+	oDialog.dispose
+End Sub
+
+&apos;=======================================================
+&apos; AlphaNum
+&apos;-------------------------------------------------------
+&apos; Removes all invalid characters from a string
+&apos;=======================================================
+Function AlphaNum(Strg As String)
+	dim OutStrg As String
+	dim sValid As String
+
+	sValid = &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789&quot;
+
+	For i=1 to Len(Strg)
+		If (Instr(sValid,LCase(Mid(Strg,i,1)))) Then
+			OutStrg = OutStrg + Mid(Strg,i,1)
+		End If
+	Next i
+	AlphaNum = OutStrg
+End Function
+
+&apos;=======================================================
+&apos; Replace
+&apos;-------------------------------------------------------
+&apos; Replaces a character with another character in a string
+&apos;=======================================================
+Function Replace(txt As String, ReplaceFrom As String, ReplaceTo As String)
+	dim OutStr As String
+	For i=1 to len(txt)
+		If LCase(mid(txt,i,1))=ReplaceFrom Then
+			OutStr = OutStr + ReplaceTo
+		Else
+			OutStr = OutStr + mid(txt,i,1)
+		End If
+	Next i
+	Replace = OutStr
+End Function
+
+
+&apos;=======================================================
+&apos; ReplaceAll
+&apos;-------------------------------------------------------
+&apos; Replaces a character with another character in a string
+&apos;=======================================================
+Function ReplaceAll(txt As String, ReplaceFrom As String, ReplaceTo As String)
+	dim OutStr As String
+	For i=1 to len(txt)
+	    bFound = 0
+		For j=1 to len(ReplaceFrom)
+			If LCase(mid(txt,i,1))=LCase(mid(ReplaceFrom,j,1)) Then
+				bFound = 1
+				OutStr = OutStr + ReplaceTo
+				j = len(ReplaceFrom)
+			End If
+		Next j
+		If bFound=0 Then
+			OutStr = OutStr + mid(txt,i,1)
+		End If
+	Next i
+	ReplaceAll = OutStr
+End Function
+
+
+
+&apos;=======================================================
+&apos; CreateID
+&apos;-------------------------------------------------------
+&apos; Creates a numerical randomized ID
+&apos;=======================================================
+Function CreateID
+	sDate = ReplaceAll(Date,&quot;/:. \&quot;,&quot;&quot;)
+    sTime = ReplaceAll(Time,&quot;/:. \AMP&quot;,&quot;&quot;)
+	Randomize
+	CreateID = sDate + sTime + Int(Rnd * 100)
+End Function
+
+&apos;=======================================================
+&apos; InsertTag
+&apos;-------------------------------------------------------
+&apos; Inserts an inline tag (element) in the document at the
+&apos; current cursor position. It also sets the character
+&apos; format to hlp_aux_tag
+&apos;=======================================================
+Sub InsertTag (Element As String, Content As String)
+	dim document   as object
+	dim dispatcher as object
+
+	document   = ThisComponent.CurrentController.Frame
+	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
+	
+	dim args(5) as new com.sun.star.beans.PropertyValue
+	args(0).Name = &quot;Type&quot;
+	args(0).Value = 8
+	args(1).Name = &quot;SubType&quot;
+	args(1).Value = 1
+	args(2).Name = &quot;Name&quot;
+	args(2).Value = Element
+	args(3).Name = &quot;Content&quot;
+	args(3).Value = Content
+	args(4).Name = &quot;Format&quot;
+	args(4).Value = -1
+	args(5).Name = &quot;Separator&quot;
+	args(5).Value = &quot; &quot;
+	SetCharStyle(&quot;hlp_aux_tag&quot;)
+	dispatcher.executeDispatch(document, &quot;.uno:InsertField&quot;, &quot;&quot;, 0, args())
+	SetCharStyle(&quot;Default&quot;)
+End Sub
+
+&apos;=======================================================
+&apos; INSERTTAGCR
+&apos;-------------------------------------------------------
+&apos; Inserts a tag (element) in the document at the
+&apos; current cursor position in its own newly created paragraph.
+&apos; It also sets the character format to hlp_aux_tag and 
+&apos; the paragraph to the specified value (should start with hlp_)
+&apos;=======================================================
+Sub InsertTagCR (Element As String, Content As String, Style As String)
+	dim document   as object
+	dim dispatcher as object
+
+	document   = ThisComponent.CurrentController.Frame
+	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
+	
+	dim args(5) as new com.sun.star.beans.PropertyValue
+	args(0).Name = &quot;Type&quot;
+	args(0).Value = 8
+	args(1).Name = &quot;SubType&quot;
+	args(1).Value = 1
+	args(2).Name = &quot;Name&quot;
+	args(2).Value = Element
+	args(3).Name = &quot;Content&quot;
+	args(3).Value = Content
+	args(4).Name = &quot;Format&quot;
+	args(4).Value = -1
+	args(5).Name = &quot;Separator&quot;
+	args(5).Value = &quot; &quot;
+
+	CR
+	goUp(1)
+	SetParaStyle(Style)
+	SetCharStyle(&quot;hlp_aux_tag&quot;)
+	dispatcher.executeDispatch(document, &quot;.uno:InsertField&quot;, &quot;&quot;, 0, args())
+	SetCharStyle(&quot;Default&quot;)
+	goDown(1)
+End Sub
+
+&apos;=======================================================
+&apos; InsertField
+&apos;-------------------------------------------------------
+&apos; Inserts a field in the document at the
+&apos; current cursor position.
+&apos;=======================================================
+Sub InsertField(Field as String, Content as String)
+	dim document   as object
+	dim dispatcher as object
+
+	document   = ThisComponent.CurrentController.Frame
+	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
+	
+	dim args(5) as new com.sun.star.beans.PropertyValue
+	args(0).Name = &quot;Type&quot;
+	args(0).Value = 8
+	args(1).Name = &quot;SubType&quot;
+	args(1).Value = 1
+	args(2).Name = &quot;Name&quot;
+	args(2).Value = Field
+	args(3).Name = &quot;Content&quot;
+	args(3).Value = Content
+	args(4).Name = &quot;Format&quot;
+	args(4).Value = -1
+	args(5).Name = &quot;Separator&quot;
+	args(5).Value = &quot; &quot;
+
+	dispatcher.executeDispatch(document, &quot;.uno:InsertField&quot;, &quot;&quot;, 0, args())
+End Sub
+
+&apos;=======================================================
+&apos; GoUp
+&apos;-------------------------------------------------------
+&apos; Simulates the CursorUp key
+&apos;=======================================================
+Sub goUp(Count As Integer, Optional bSelect As Boolean)
+	dim document   as object
+	dim dispatcher as object
+	
+	document   = ThisComponent.CurrentController.Frame
+	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
+	
+	dim args(1) as new com.sun.star.beans.PropertyValue
+	args(0).Name = &quot;Count&quot;
+	args(0).Value = Count
+	args(1).Name = &quot;Select&quot;
+	If IsMissing(bSelect) Then
+		args(1).Value = false
+	Else
+		args(1).Value = bSelect
+	End If
+
+	dispatcher.executeDispatch(document, &quot;.uno:GoUp&quot;, &quot;&quot;, 0, args())
+End Sub
+
+&apos;=======================================================
+&apos; GoDown
+&apos;-------------------------------------------------------
+&apos; Simulates the CursorDown key
+&apos;=======================================================
+Sub goDown(Count As Integer, Optional bSelect As Boolean)
+	dim document   as object
+	dim dispatcher as object
+	
+	document   = ThisComponent.CurrentController.Frame
+	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
+	
+	dim args(1) as new com.sun.star.beans.PropertyValue
+	args(0).Name = &quot;Count&quot;
+	args(0).Value = Count
+	args(1).Name = &quot;Select&quot;
+	If IsMissing(bSelect) Then
+		args(1).Value = false
+	Else
+		args(1).Value = bSelect
+	End If
+
+	dispatcher.executeDispatch(document, &quot;.uno:GoDown&quot;, &quot;&quot;, 0, args())
+End Sub
+
+
+&apos;=======================================================
+&apos; GoRight
+&apos;-------------------------------------------------------
+&apos; Simulates the CursorRight key
+&apos;=======================================================
+Sub goRight(Count As Integer, Optional bSelect As Boolean)
+	dim document   as object
+	dim dispatcher as object
+	
+	document   = ThisComponent.CurrentController.Frame
+	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
+	
+	dim args(1) as new com.sun.star.beans.PropertyValue
+	args(0).Name = &quot;Count&quot;
+	args(0).Value = Count
+	args(1).Name = &quot;Select&quot;
+	If IsMissing(bSelect) Then
+		args(1).Value = false
+	Else
+		args(1).Value = bSelect
+	End If
+
+	dispatcher.executeDispatch(document, &quot;.uno:GoRight&quot;, &quot;&quot;, 0, args())
+End Sub
+
+&apos;=======================================================
+&apos; GoLeft
+&apos;-------------------------------------------------------
+&apos; Simulates the CursorLeft key
+&apos;=======================================================
+Sub goLeft(Count As Integer, optional bSelect As boolean)
+	dim document   as object
+	dim dispatcher as object
+	
+	document   = ThisComponent.CurrentController.Frame
+	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
+	
+	dim args(1) as new com.sun.star.beans.PropertyValue
+	args(0).Name = &quot;Count&quot;
+	args(0).Value = Count
+	args(1).Name = &quot;Select&quot;
+	If IsMissing(bSelect) Then
+		args(1).Value = false
+	Else
+		args(1).Value = bSelect
+	End If
+
+	dispatcher.executeDispatch(document, &quot;.uno:GoLeft&quot;, &quot;&quot;, 0, args())
+End Sub
+
+&apos;=======================================================
+&apos; CR
+&apos;-------------------------------------------------------
+&apos; Inserts a Carriage Return (a new paragraph)
+&apos;=======================================================
+Sub CR
+	dim document   as object
+	dim dispatcher as object
+	
+	document   = ThisComponent.CurrentController.Frame
+	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
+	
+	oSel = thiscomponent.getcurrentcontroller.getselection
+	oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+	oCur.gotoEndOfParagraph(0)
+	thiscomponent.getcurrentcontroller.select(oCur)
+	
+	dispatcher.executeDispatch(document, &quot;.uno:InsertPara&quot;, &quot;&quot;, 0, Array())
+End Sub
+
+&apos;=======================================================
+&apos; CR_before
+&apos;-------------------------------------------------------
+&apos; Inserts a Carriage Return (a new paragraph) before the current para
+&apos;=======================================================
+Sub CR_before
+	dim document   as object
+	dim dispatcher as object
+	
+	document   = ThisComponent.CurrentController.Frame
+	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
+	
+	oSel = thiscomponent.getcurrentcontroller.getselection
+	oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+	oCur.gotoStartOfParagraph(0)
+	thiscomponent.getcurrentcontroller.select(oCur)
+	
+	dispatcher.executeDispatch(document, &quot;.uno:InsertPara&quot;, &quot;&quot;, 0, Array())
+End Sub
+
+&apos;=======================================================
+&apos; LF
+&apos;-------------------------------------------------------
+&apos; Inserts a line feed (manual line break)
+&apos;=======================================================
+sub LF
+	dim document   as object
+	dim dispatcher as object
+	document   = ThisComponent.CurrentController.Frame
+	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
+
+	dispatcher.executeDispatch(document, &quot;.uno:InsertLinebreak&quot;, &quot;&quot;, 0, Array())
+end sub
+
+&apos;=======================================================
+&apos; SetParaStyle
+&apos;-------------------------------------------------------
+&apos; Sets the para style to the given value
+&apos;=======================================================
+Sub SetParaStyle(StyleName As String)
+	dim document   as object
+	dim dispatcher as object
+	
+	document   = ThisComponent.CurrentController.Frame
+	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
+	
+	dim args(1) as new com.sun.star.beans.PropertyValue
+	args(0).Name = &quot;Template&quot;
+	args(0).Value = StyleName
+	args(1).Name = &quot;Family&quot;
+	args(1).Value = 2
+
+	dispatcher.executeDispatch(document, &quot;.uno:StyleApply&quot;, &quot;&quot;, 0, args())
+end Sub
+
+&apos;=======================================================
+&apos; SetCharStyle
+&apos;-------------------------------------------------------
+&apos; Sets the character style to the given value
+&apos;=======================================================
+Sub SetCharStyle(StyleName As String)
+	dim document   as object
+	dim dispatcher as object
+	
+	document   = ThisComponent.CurrentController.Frame
+	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
+	
+	dim args(1) as new com.sun.star.beans.PropertyValue
+	args(0).Name = &quot;Template&quot;
+	args(0).Value = StyleName
+	args(1).Name = &quot;Family&quot;
+	args(1).Value = 1
+
+	dispatcher.executeDispatch(document, &quot;.uno:StyleApply&quot;, &quot;&quot;, 0, args())
+end Sub
+
+&apos;=======================================================
+&apos; InsertNewParaData
+&apos;-------------------------------------------------------
+&apos; Inserts a new ID for the paragraph
+&apos;=======================================================
+Sub InsertNewParaData
+	
+		If not IsHelpFile Then
+		msgbox(strErr_NoHelpFile)
+		Exit Sub
+	End If
+	
+	oSel = thiscomponent.getcurrentcontroller.getselection
+	oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+
+	arParaData = GetParaData
+	sID = arParaData(0)
+	slocalize = arParaData(1)
+	sMsg = arParaData(2)
+
+	If sMsg &lt;&gt; &quot;&quot; Then
+		msgbox &quot;Cannot assign paragraph id:&quot;+chr(13)+sMsg,48,&quot;Error&quot;
+		Exit Sub
+	End If
+	
+	If sID &lt;&gt; &quot;&quot; Then
+		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;
+		Exit Sub
+	End If
+	
+	oCur.gotoStartOfParagraph(0)
+	
+	If (Left(oCur.ParaStyleName,8) = &quot;hlp_head&quot;) Then
+		id = &quot;hd_id&quot; + CreateID
+		thiscomponent.getcurrentcontroller.select(oCur)
+		MetaData = id
+		SetCharStyle(&quot;hlp_aux_parachanged&quot;)
+		InsertField(&quot;ID&quot;,MetaData)
+		SetCharStyle(&quot;Default&quot;)
+	Else
+		id = &quot;par_id&quot; + CreateID
+		thiscomponent.getcurrentcontroller.select(oCur)
+		MetaData = id
+		SetCharStyle(&quot;hlp_aux_parachanged&quot;)
+		InsertField(&quot;ID&quot;,MetaData)
+		SetCharStyle(&quot;Default&quot;)
+	End If
+	
+
+End Sub
+
+&apos;=======================================================
+&apos; LoadDialog
+&apos;-------------------------------------------------------
+&apos; Loads a BASIC dialog
+&apos;=======================================================
+Function LoadDialog(Libname as String, DialogName as String, Optional oLibContainer)
+	Dim oLib as Object
+	Dim oLibDialog as Object
+	Dim oRuntimeDialog as Object
+	
+	If IsMissing(oLibContainer ) then
+		oLibContainer = DialogLibraries
+	End If
+
+	oLibContainer.LoadLibrary(LibName)
+	oLib = oLibContainer.GetByName(Libname)
+	oLibDialog = oLib.GetByName(DialogName)
+	oRuntimeDialog = CreateUnoDialog(oLibDialog)
+	LoadDialog() = oRuntimeDialog
+End Function
+
+&apos;=======================================================
+&apos; Surprise
+&apos;-------------------------------------------------------
+&apos; D&apos;oh
+&apos;=======================================================
+Sub Surprise
+	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;
+End Sub
+
+&apos;=======================================================
+&apos; InsertNote
+&apos;-------------------------------------------------------
+&apos; Inserts a note (annotation) at the current position
+&apos;=======================================================
+sub InsertNote(Content As String)
+	dim document   as object
+	dim dispatcher as object
+
+	document   = ThisComponent.CurrentController.Frame
+	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
+
+	dim args(2) as new com.sun.star.beans.PropertyValue
+	args(0).Name = &quot;Text&quot;
+	args(0).Value = Content
+	args(1).Name = &quot;Author&quot;
+	args(1).Value = &quot;Help Tooling - DO NOT EDIT&quot;
+	args(2).Name = &quot;Date&quot;
+	args(2).Value = &quot;02/27/2004&quot;
+
+	dispatcher.executeDispatch(document, &quot;.uno:InsertAnnotation&quot;, &quot;&quot;, 0, args())
+end sub
+
+&apos;=======================================================
+&apos; InsertText
+&apos;-------------------------------------------------------
+&apos; Inserts a string at the current position
+&apos;=======================================================
+Sub InsertText(strg As String)
+	oSel = thiscomponent.getcurrentcontroller.getselection
+	oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+	oCur.String = strg
+End Sub
+
+&apos;=======================================================
+&apos; ParaIsEmpty
+&apos;-------------------------------------------------------
+&apos; Evaluates if a paragraph is empty.
+&apos;=======================================================
+Function ParaIsEmpty
+	oSel = thiscomponent.getcurrentcontroller.getselection
+	oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+	oCur.gotoStartOfParagraph(0)
+	ParaIsEmpty = oCur.IsEndOfParagraph
+End Function
+
+&apos;=======================================================
+&apos; IsInBookmark
+&apos;-------------------------------------------------------
+&apos; Evaluates if the cursor is inside a &lt;bookmark&gt; &lt;/bookmark&gt; element
+&apos;=======================================================
+Function IsInBookmark
+	oSel = thiscomponent.getcurrentcontroller.getselection
+	oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+	
+	If ((oCur.ParaStyleName = &quot;hlp_aux_bookmark&quot;) AND (not(oCur.IsEndOfParagraph))) Then
+		oCur.GotoStartOfParagraph(0)
+		oCur.GotoEndOfParagraph(1)
+		sText = Left(oCur.GetString,Instr(oCur.GetString,&quot;&quot;&quot; id=&quot;&quot;&quot;)-1)
+		sText = Right(sText,Len(sText)-InStr(sText,&quot;&quot;&quot;&quot;))
+		Select Case Left(sText,3)
+			Case &quot;ind&quot;
+				IsInBookmark = 1
+			Case &quot;hid&quot;
+				IsInBookmark = 2
+			Case &quot;con&quot;
+				IsInBookmark = 3
+			Case Else
+				IsInBookmark = 0
+		End Select
+	Else
+		IsInBookmark = 0
+	End If
+End Function
+
+&apos;=======================================================
+&apos; IsInTable
+&apos;-------------------------------------------------------
+&apos; Evaluates if the cursor is in a table
+&apos;=======================================================
+Function IsInTable
+	oSel = thiscomponent.getcurrentcontroller.getselection
+	oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+
+	IsInTable = (VarType(oCur.TextTable) &lt;&gt; 0)
+End Function
+
+&apos;=======================================================
+&apos; InsertLink
+&apos;-------------------------------------------------------
+&apos; Inserts a hyperlink at the current position
+&apos;=======================================================
+Sub InsertLink(sPath As String, sText As String, sName As String)
+	dim document   as object
+	dim dispatcher as object
+
+	document   = ThisComponent.CurrentController.Frame
+	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
+	
+	dim args(4) as new com.sun.star.beans.PropertyValue
+	args(0).Name = &quot;Hyperlink.Text&quot;
+	args(0).Value = sText
+	args(1).Name = &quot;Hyperlink.URL&quot;
+	args(1).Value = sPath
+	args(2).Name = &quot;Hyperlink.Target&quot;
+	args(2).Value = &quot;&quot;
+	args(3).Name = &quot;Hyperlink.Name&quot;
+	args(3).Value = sName
+	args(4).Name = &quot;Hyperlink.Type&quot;
+	args(4).Value = 1
+
+	dispatcher.executeDispatch(document, &quot;.uno:SetHyperlink&quot;, &quot;&quot;, 0, args())
+	args(0).Name = &quot;Count&quot;
+	args(0).Value = 1
+	args(1).Name = &quot;Select&quot;
+	args(1).Value = false
+
+	dispatcher.executeDispatch(document, &quot;.uno:GoRight&quot;, &quot;&quot;, 0, args())
+
+End Sub
+
+&apos;=======================================================
+&apos; AssignMissingIDs
+&apos;-------------------------------------------------------
+&apos; Assigns IDs to elements that miss them
+&apos;=======================================================
+Sub AssignMissingIDs
+&apos; NOT IMPLEMENTED YET
+end sub
+
+&apos;=======================================================
+&apos; CreateTable
+&apos;-------------------------------------------------------
+&apos; Creates a new table
+&apos;=======================================================
+Sub CreateTable(nRows as Integer, nCols as Integer, sID as String)
+	dim document   as object
+	dim dispatcher as object
+
+	document   = ThisComponent.CurrentController.Frame
+	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
+
+	dim args1(3) as new com.sun.star.beans.PropertyValue
+	args1(0).Name = &quot;TableName&quot;
+	args1(0).Value = sID
+	args1(1).Name = &quot;Columns&quot;
+	args1(1).Value = nCols
+	args1(2).Name = &quot;Rows&quot;
+	args1(2).Value = nRows
+	args1(3).Name = &quot;Flags&quot;
+	args1(3).Value = 9
+	
+	dispatcher.executeDispatch(document, &quot;.uno:InsertTable&quot;, &quot;&quot;, 0, args1())
+	
+	args1(0).Name = &quot;TopBottomMargin.TopMargin&quot;
+	args1(0).Value = 500
+	args1(1).Name = &quot;TopBottomMargin.BottomMargin&quot;
+	args1(1).Value = 0
+	args1(2).Name = &quot;TopBottomMargin.TopRelMargin&quot;
+	args1(2).Value = 100
+	args1(3).Name = &quot;TopBottomMargin.BottomRelMargin&quot;
+	args1(3).Value = 100
+
+	dispatcher.executeDispatch(document, &quot;.uno:TopBottomMargin&quot;, &quot;&quot;, 0, args1())
+	dispatcher.executeDispatch(document, &quot;.uno:SelectAll&quot;, &quot;&quot;, 0, Array())
+	SetParaStyle(&quot;hlp_tablecontent&quot;)
+	GoDown(1)
+end Sub
+
+&apos;=======================================================
+&apos; IsBlockImage
+&apos;-------------------------------------------------------
+&apos; Evaluates if the cursor is in a paragraph with
+&apos; a block image (image in its own paragraph)
+&apos;=======================================================
+Function IsBlockImage
+	oSel = thiscomponent.getcurrentcontroller.getselection
+	oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+	oCur.gotoStartOfParagraph(0)
+	oCur.gotoEndOfParagraph(1)
+	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
+	IsBlockImage = (not(Left(sStr,4)=&quot;IMG&gt;&quot;) AND (Right(sStr,6)=&quot;&lt;/IMG&gt;&quot;))
+End Function
+
+&apos;=======================================================
+&apos; HasCaption
+&apos;-------------------------------------------------------
+&apos; Evaluates if the current image has a caption element
+&apos;=======================================================
+Function HasCaption
+	oSel = thiscomponent.getcurrentcontroller.getselection
+	If oSel.ImplementationName = &quot;SwXTextGraphicObject&quot; Then
+		oCur = oSel(0).getAnchor.getText.createTextCursorByRange(oSel(0).getAnchor)
+	Else
+		oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+	End If
+	oCur.gotoStartOfParagraph(0)
+	oCur.gotoEndOfParagraph(1)
+	HasCaption = (InStr(oCur.String,&quot;&lt;IMGCAPTION&quot;)&gt;0)
+End Function
+
+&apos;=======================================================
+&apos; GetImageID
+&apos;-------------------------------------------------------
+&apos; Returns the ID of an image at the cursor position
+&apos;=======================================================
+Function GetImageID
+	oSel = thiscomponent.getcurrentcontroller.getselection
+	If oSel.ImplementationName = &quot;SwXTextGraphicObject&quot; Then
+		oCur = oSel(0).getAnchor.getText.createTextCursorByRange(oSel(0).getAnchor)
+	Else
+		oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+	End If
+	oCur.gotoStartOfParagraph(0)
+	oCur.gotoEndOfParagraph(1)
+	sStr = Right(oCur.String,Len(oCur.String)-(InStr(oCur.String,&quot;IMG ID=&quot;&quot;&quot;)+7))
+	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
+End Function
+
+&apos;=======================================================
+&apos; SelAll
+&apos;-------------------------------------------------------
+&apos; Selects everything
+&apos;=======================================================
+Sub SelAll
+	dim document   as object
+	dim dispatcher as object
+
+	document   = ThisComponent.CurrentController.Frame
+	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
+
+	dispatcher.executeDispatch(document, &quot;.uno:SelectAll&quot;, &quot;&quot;, 0, Array())
+End Sub
+
+&apos;=======================================================
+&apos; GetParaData
+&apos;-------------------------------------------------------
+&apos; Returns the Paragraph ID and localization status
+&apos;=======================================================
+Function GetParaData
+	arParaData = Array(&quot;&quot;,&quot;&quot;,&quot;&quot;) &apos; ID, localize, #message
+	
+	oSel = thiscomponent.getcurrentcontroller.getselection
+	oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+	oCur.gotoStartOfParagraph(0)
+	oCur.gotoEndOfParagraph(1)
+	sID = &quot;&quot;
+	Enum = oCur.createEnumeration
+	Fd = FALSE
+
+
+	TE = Enum.nextElement
+		
+	TP = TE.createEnumeration
+	Ct = 0
+	posID = 0
+
+	Do While TP.hasmoreElements
+		Ct = Ct+1
+		TPE = TP.nextElement
+		If TPE.TextPortionType=&quot;TextField&quot; Then
+			If TPE.TextField.TextFieldMaster.Name=&quot;ID&quot; Then
+				sID = TPE.TextField.Content
+				Fd = TRUE
+				Exit Do
+			End If
+		End If
+		If TPE.String = &quot;&quot; Then
+			Ct = Ct-1
+		End If
+	Loop
+
+	If ((Left(oCur.ParaStyleName,8) = &quot;hlp_aux_&quot;) or (Left(oCur.ParaStyleName,4) &lt;&gt; &quot;hlp_&quot;)) Then
+		arParaData(2)=&quot;Invalid Paragraph Style&quot;
+		GetParaData = arParaData
+		Exit Function
+	End If
+
+	If sID = &quot;&quot; Then
+		GetParaData = arParaData
+		Exit Function
+	End If
+
+	If Right(sID,7) = &quot;_NOL10N&quot; Then
+		arParaData(0) = Left(sID,Len(sID)-7)
+		arParaData(1) = &quot;no&quot;
+	Else
+		arParaData(0) = sID
+		arParaData(1) = &quot;yes&quot;
+	End If
+
+	GetParaData = arParaData
+End Function
+
+&apos;=======================================================
+&apos; SetsParaData
+&apos;-------------------------------------------------------
+&apos; Sets the Paragraph ID and localization status
+&apos;=======================================================
+
+Sub SetParaData(sID as String, sLocalize as String)
+	
+	oSel = thiscomponent.getcurrentcontroller.getselection
+	oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+	oCur.gotoStartOfParagraph(0)
+	oCur.gotoEndOfParagraph(1)
+	Enum = oCur.createEnumeration
+	Fd = FALSE
+	
+
+	Do While Enum.hasMoreElements
+		TE = Enum.nextElement
+		
+		TP = TE.createEnumeration
+		Ct = 0
+		posID = 0
+
+		Do While TP.hasmoreElements
+			Ct = Ct+1
+			TPE = TP.nextElement
+			If TPE.TextPortionType=&quot;TextField&quot; Then
+				If TPE.TextField.TextFieldMaster.Name=&quot;ID&quot; Then
+					posID = Ct
+					If sLocalize = &quot;no&quot; Then
+						TPE.TextField.Content = sID+&quot;_NOL10N&quot;
+						TPE.TextField.IsVisible = TRUE
+					ElseIf sLocalize = &quot;yes&quot; Then
+						TPE.TextField.Content = sID
+						TPE.TextField.IsVisible = TRUE
+					Else
+						msgbox &quot;Unknown localization parameter: &quot;+sLocalize,0,&quot;Error&quot;
+					End If
+					Fd = TRUE
+					Exit Do
+				End If
+			End If
+			If TPE.String = &quot;&quot; Then
+				Ct = Ct-1
+			End If
+		Loop
+		If Fd Then
+			Exit Do
+		End If
+	Loop	
+
+	oCur.TextField.update
+	UpdateFields
+
+End Sub
+
+
+&apos;=======================================================
+&apos; IsInList
+&apos;-------------------------------------------------------
+&apos; Evaluates if the cursor is inside a list (ordered or unordered)
+&apos;=======================================================
+Function IsInList
+	oSel = thiscomponent.getcurrentcontroller.getselection
+	oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+	If oCur.NumberingStyleName = &quot;&quot;  Then
+		IsInList = false
+	ElseIf oCur.NumberingRules.NumberingIsOutline = true Then
+		IsInList = false
+	Else
+		IsInList = true
+	End If
+End Function
+
+&apos;=======================================================
+&apos; TagFormatIsCorrect
+&apos;-------------------------------------------------------
+&apos; Checks for correct paragraph format for tags
+&apos;=======================================================
+Function TagFormatIsCorrect(sTN As String, sPS As String)
+
+	arTag = Array(&quot;BOOKMARK&quot;,&quot;SORT&quot;,&quot;SECTION&quot;,&quot;SWITCH&quot;,&quot;CASE&quot;,&quot;DEFAULT&quot;)
+	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;)
+	
+	For n=0 to ubound(arTag)
+		If (sTN = arTag(n) AND sPS &lt;&gt; arTagFormat(n)) Then
+			TagFormatIsCorrect = arTagFormat(n)
+			Exit Function
+		End If
+		TagFormatIsCorrect = &quot;&quot;
+	Next n
+	
+End Function
+
+&apos;=======================================================
+&apos; GetFilePath
+&apos;-------------------------------------------------------
+&apos; look for the &quot;text/...&quot; part of the file name and separate it 
+&apos;=======================================================
+Function GetFilePath(fname As String)
+
+	i = 1
+	Do
+		If (Mid(fname,i,5) = &quot;text/&quot;) Then
+			Strg = Mid(fname,i,Len(fname)-i+1)
+			Exit Do
+		Else
+			i = i+1
+			Strg = fname
+		End If
+	Loop While (i+5 &lt; Len(fname))
+	GetFilePath = Strg
+End Function
+
+&apos;=======================================================
+&apos; OpenGraphics
+&apos;-------------------------------------------------------
+&apos; Calls the graphic open dialog for inserting an image
+&apos;=======================================================
+Function OpenGraphics(oDoc As Object)
+Dim ListAny(0) as Long
+Dim oStoreProperties(0) as New com.sun.star.beans.PropertyValue
+	GlobalScope.BasicLibraries.loadLibrary(&quot;Tools&quot;)
+	ListAny(0) = com.sun.star.ui.dialogs.TemplateDescription.FILEOPEN_SIMPLE
+&apos;	ListAny(0) = com.sun.star.ui.dialogs.TemplateDescription.FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE
+	oFileDialog = CreateUnoService(&quot;com.sun.star.ui.dialogs.FilePicker&quot;)
+	oFileDialog.Initialize(ListAny())
+	
+	sLastImgDir = ReadConfig(&quot;LastImgDir&quot;)
+	If sLastImgDir &lt;&gt; &quot;&quot; Then
+		oFileDialog.setDisplayDirectory(sLastImgDir)
+	End If
+	
+	oMasterKey = GetRegistryKeyContent(&quot;org.openoffice.TypeDetection.Types/&quot;)
+	oTypes() = oMasterKey.Types
+
+	oFileDialog.AppendFilter(oTypes.GetByName(&quot;gif_Graphics_Interchange&quot;).UIName, &quot;*.gif&quot;)
+	oFileDialog.AppendFilter(oTypes.GetByName(&quot;png_Portable_Network_Graphic&quot;).UIName, &quot;*.png&quot;)
+
+	oFileDialog.SetTitle(&quot;Insert Image&quot;)
+	iAccept = oFileDialog.Execute()
+	If iAccept = 1 Then
+		sPath = oFileDialog.Files(0)
+		WriteConfig(&quot;LastImgDir&quot;,oFileDialog.getDisplayDirectory)
+		UIFilterName = oFileDialog.GetCurrentFilter()
+		OpenGraphics = oFileDialog.Files(0)
+	Else
+		OpenGraphics = &quot;&quot;
+	End If
+	oFileDialog.Dispose()
+End Function
+
+&apos;=======================================================
+&apos; WriteConfig
+&apos;-------------------------------------------------------
+&apos; Reads a parameter value from the config file
+&apos;=======================================================
+Function ReadConfig(Parm As String)
+	oPath = createUNOService(&quot;com.sun.star.util.PathSettings&quot;)	
+	filename = oPath.UserConfig+&quot;/helpauthoring.cfg&quot;
+	iNumber = Freefile
+	bFound = false
+	If FileExists(filename) Then
+		Open filename For Input As iNumber
+		Do While (not eof(iNumber) AND not(bFound))
+			Line Input #iNumber, sLine
+			If InStr(sLine, &quot;=&quot;) &gt; 0 Then
+				arLine = split(sLine,&quot;=&quot;)
+				If arLine(0) = Parm Then
+					sResult = arLine(1)
+					bFound = true
+				End If
+			End If
+		Loop
+		Close #iNumber
+		If bFound Then
+			ReadConfig = sResult
+		Else
+			ReadConfig = &quot;&quot;
+		End If
+	Else
+		ReadConfig = &quot;&quot;
+	End If
+End Function
+
+
+&apos;=======================================================
+&apos; WriteConfig
+&apos;-------------------------------------------------------
+&apos; Writes a parameter/value pair to the config file
+&apos;=======================================================
+Function WriteConfig(Parm As String, Value As String)
+	Dim arLines(0) As String
+	bFound = false
+	oPath = createUNOService(&quot;com.sun.star.util.PathSettings&quot;)	
+	filename = oPath.UserConfig+&quot;/helpauthoring.cfg&quot;
+	iNumber = Freefile
+	If FileExists(filename) Then
+
+		Open filename For Input As iNumber
+		Do While (not eof(iNumber))
+			Line Input #iNumber, sLine
+			If InStr(sLine, &quot;=&quot;) &gt; 0 Then
+				sDim = ubound(arLines())+1
+				ReDim Preserve arLines(sDim)
+				arLines(sDim) = sLine
+			End If
+		Loop
+		Close #iNumber
+		
+		nLine = 1
+		Do While (nLine &lt;= ubound(arLines())) and (not bFound)
+			arLine = split(arLines(nLine),&quot;=&quot;)
+			If arLine(0) = Parm Then
+				arLines(nLine) = Parm+&quot;=&quot;+Value
+				bFound = true
+			End If
+			nLine = nLine +1
+		Loop
+
+		nLine = 1
+		Open filename For Output As iNumber
+		Do While (nLine &lt;= ubound(arLines()))
+			Print #iNumber, arLines(nLine)
+			nLine = nLine + 1
+		Loop
+		If (not bFound) Then
+			Print #iNumber, Parm+&quot;=&quot;+Value
+		End If
+		Close #iNumber
+	
+	Else
+		Open filename For Output As iNumber
+		Print #iNumber, Parm+&quot;=&quot;+Value
+		Close #iNumber
+	End If
+End Function
+
+Function GetRelPath(sPath As String)
+	sHelpPrefix = ReadConfig(&quot;HelpPrefix&quot;)
+	If sHelpPrefix = &quot;&quot; Then
+		sHelpPrefix = SetDocumentRoot
+	End If
+	GetRelPath = Right(sPath, Len(sPath)-(InStr(sPath,sHelpPrefix) + Len(sHelpPrefix)-1))
+End Function
+
+Function SetDocumentRoot
+	sHelpPrefix = ReadConfig(&quot;HelpPrefix&quot;)
+	oFolderDialog = CreateUnoService(&quot;com.sun.star.ui.dialogs.FolderPicker&quot;)
+	oFolderDialog.SetTitle(&quot;Select Document Root Folder&quot;)
+	If sHelpPrefix &gt; &quot;&quot; Then
+		oFolderDialog.setDisplayDirectory(sHelpPrefix)
+	End If
+	iAccept = oFolderDialog.Execute()
+		
+	If iAccept = 1 Then
+		sHelpPrefix = oFolderDialog.getDirectory + &quot;/&quot;
+		WriteConfig(&quot;HelpPrefix&quot;,sHelpPrefix)
+	End If
+	
+	SetDocumentRoot = sHelpPrefix
+End Function
+
+Function MakeAbsPath(sPath As String)
+	
+	sHelpPrefix = ReadConfig(&quot;HelpPrefix&quot;)
+	If sHelpPrefix = &quot;&quot; Then
+		sHelpPrefix = SetDocumentRoot
+	End If
+
+	If Right(sPath,4) &lt;&gt; &quot;.xhp&quot; Then
+		sPath=sPath+&quot;.xhp&quot;
+	End If
+	MakeAbsPath = sHelpPrefix+sPath
+End Function
+
+
+Sub UpdateFields
+	dim document   as object
+	dim dispatcher as object
+	document   = ThisComponent.CurrentController.Frame
+	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
+
+	dispatcher.executeDispatch(document, &quot;.uno:UpdateFields&quot;, &quot;&quot;, 0, Array())
+End Sub
+
+Function IsHelpFile
+	document = StarDesktop.CurrentComponent
+	IsHelpFile = (Right(GetFilePath(document.URL),4)=&quot;.xhp&quot;)
+End Function
+
+Function GetUserFieldNumber(fn as String)
+	fnum = -1
+	For a=0 to document.DocumentInfo.getUserFieldCount - 1 
+		If document.DocumentInfo.getUserFieldName(a) = fn Then
+			fnum = a
+			Exit for
+		End If
+	Next a
+	GetUserFieldNumber = fnum
+End Function
+</script:module>
\ No newline at end of file

Added: incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/IND.xba
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/IND.xba?rev=1172372&view=auto
==============================================================================
--- incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/IND.xba (added)
+++ incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/IND.xba Sun Sep 18 21:34:39 2011
@@ -0,0 +1,161 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
+<script:module xmlns:script="http://openoffice.org/2000/script" script:name="IND" script:language="StarBasic">REM  *****  BASIC  *****
+
+Dim oDialog AS Object
+Dim document AS Object
+
+Sub Main
+
+	If not IsHelpFile Then
+		msgbox(strErr_NoHelpFile)
+		Exit Sub
+	End If
+
+	document = StarDesktop.CurrentComponent
+
+	BasicLibraries.LoadLibrary(&quot;HelpAuthoring&quot;)
+	oDialog = LoadDialog(&quot;HelpAuthoring&quot;, &quot;dlgIND&quot;)
+	ocbAddTag = oDialog.GetControl(&quot;cbAddTag&quot;)
+
+	&apos; Check if bookmarks are allowed here
+	If IsInList Then
+		msgbox &quot;No Bookmarks allowed inside a list.&quot;, 48, &quot;D&apos;oh!&quot;
+		Exit Sub
+	End If
+
+	
+	nBookmarkType = IsInBookmark
+	If nBookmarkType = 1 Then &apos; inside INDEX bookmark
+		ocbAddTag.State = 0
+	End If
+		
+	oDialogModel = oDialog.Model
+	
+	If oDialog.Execute() = 1 Then
+		&apos; Insert the bookmark construction
+		olbIND = oDialog.GetControl(&quot;lbIND&quot;)
+
+		If nBookmarkType = 0 Then&apos; not in a bookmark, always add parent tags
+			bmid = CreateID
+			&apos; now check if we are in a para with text (this wouldn&apos;t be valid)
+			If Not(ParaIsEmpty) Then
+				CR
+			End If
+			InsertTag(&quot;BOOKMARK_&quot;,&quot;&lt;BOOKMARK branch=&quot;&quot;index&quot;&quot; id=&quot;&quot;bm_id&quot; + bmid + &quot;&quot;&quot;&gt;&quot;,&quot;hlp_aux_bookmark&quot;)
+
+			For i=0 to ubound(olbIND.Items)
+				LF
+				InsertTag(&quot;BOOKMARKVALUE_&quot;,&quot;&lt;BOOKMARKVALUE&gt;&quot;)
+				InsertField(&quot;BOOKMARKVALUE&quot;,olbIND.Items(i))
+				InsertTag(&quot;_BOOKMARKVALUE&quot;,&quot;&lt;/BOOKMARKVALUE&gt;&quot;)
+			Next i
+			LF
+			InsertTagCR(&quot;_BOOKMARK&quot;,&quot;&lt;/BOOKMARK&gt;&quot;,&quot;hlp_aux_bookmark&quot;)
+
+		ElseIf nBookmarkType = 1 Then &apos; in a correct bookmark type
+			If ocbAddTag.State = 1 Then
+				If Not(ParaIsEmpty) Then
+					CR
+				End If
+				InsertTag(&quot;BOOKMARK_&quot;,&quot;&lt;BOOKMARK branch=&quot;&quot;index&quot;&quot; id=&quot;&quot;bm_id&quot; + bmid + &quot;&quot;&quot;&gt;&quot;,&quot;hlp_aux_bookmark&quot;)
+				For i=0 to ubound(olbIND.Items)
+					LF
+					InsertTag(&quot;BOOKMARKVALUE_&quot;,&quot;&lt;BOOKMARKVALUE&gt;&quot;)
+					InsertField(&quot;BOOKMARKVALUE&quot;,olbIND.Items(i))
+					InsertTag(&quot;_BOOKMARKVALUE&quot;,&quot;&lt;/BOOKMARKVALUE&gt;&quot;)
+				Next i
+				If ocbAddTag.State = 1 Then
+					LF
+					InsertTagCR(&quot;_BOOKMARK&quot;,&quot;&lt;/BOOKMARK&gt;&quot;,&quot;hlp_aux_bookmark&quot;)
+				End If
+			Else
+				For i=0 to ubound(olbIND.Items)
+					LF
+					InsertTag(&quot;BOOKMARKVALUE_&quot;,&quot;&lt;BOOKMARKVALUE&gt;&quot;)
+					InsertField(&quot;BOOKMARKVALUE&quot;,olbIND.Items(i))
+					InsertTag(&quot;_BOOKMARKVALUE&quot;,&quot;&lt;/BOOKMARKVALUE&gt;&quot;)
+				Next i
+			End If
+		Else	&apos; in a wrong bookmark type
+			If Not(ParaIsEmpty) Then
+				CR
+			End If
+			InsertTag(&quot;BOOKMARK_&quot;,&quot;&lt;BOOKMARK branch=&quot;&quot;index&quot;&quot; id=&quot;&quot;bm_id&quot; + bmid + &quot;&quot;&quot;&gt;&quot;,&quot;hlp_aux_bookmark&quot;)
+			For i=0 to ubound(olbIND.Items)
+				LF
+				InsertTag(&quot;BOOKMARKVALUE_&quot;,&quot;&lt;BOOKMARKVALUE&gt;&quot;)
+				InsertField(&quot;BOOKMARKVALUE&quot;,olbIND.Items(i))
+				InsertTag(&quot;_BOOKMARKVALUE&quot;,&quot;&lt;/BOOKMARKVALUE&gt;&quot;)
+			Next i
+			LF
+			InsertTagCR(&quot;_BOOKMARK&quot;,&quot;&lt;/BOOKMARK&gt;&quot;,&quot;hlp_aux_bookmark&quot;)
+		End If
+	End If
+		
+	oDialog.dispose
+
+End Sub
+
+Sub AddKeyStroke(Event As Object)
+	Select Case Event.KeyCode
+		Case com.sun.star.awt.Key.RETURN
+			AddIndexEntry
+		Case com.sun.star.awt.Key.SPACE
+			AddIndexEntry
+	End Select
+End Sub
+
+Sub AddIndexEntry
+	
+		oTxtLevel1 = oDialog.GetControl(&quot;txtLevel1&quot;)
+		oTxtLevel2 = oDialog.GetControl(&quot;txtLevel2&quot;)
+	
+		If oTxtLevel2.Text &lt;&gt; &quot;&quot; Then
+			IndexEntry = oTxtLevel1.Text + &quot;;&quot; + oTxtLevel2.Text
+		Else
+			IndexEntry = oTxtLevel1.Text
+		End If
+	
+		If ((oTxtLevel1.Text = &quot;&quot;) OR (IndexEntry = &quot;&lt;Level 1&gt;;&lt;Level 2&gt;&quot;)) Then
+			msgbox &quot;Enter an index entry first.&quot;
+		Else
+			&apos; Insert the index entry into the list
+			olbIND = oDialog.GetControl(&quot;lbIND&quot;)
+			olbIND.addItem(IndexEntry,0)
+		End If
+	
+End Sub
+
+Sub RemoveKeyStroke(Event As Object)
+	Select Case Event.KeyCode
+		Case com.sun.star.awt.Key.RETURN
+			RemoveIndexEntry
+		Case com.sun.star.awt.Key.SPACE
+			RemoveIndexEntry
+	End Select
+End Sub
+
+
+Sub RemoveIndexEntry
+	olbIND = oDialog.GetControl(&quot;lbIND&quot;)
+	ItemsPos = olbIND.getSelectedItemsPos
+	For i=0 to ubound(ItemsPos)
+		olbIND.removeItems(ItemsPos(i)-i,1)
+	Next i
+End Sub
+
+Sub KeyPressedAdd(Event As Object)
+	Select Case Event.KeyCode
+		Case com.sun.star.awt.Key.INSERT
+			AddIndexEntry
+	End Select
+End Sub
+
+Sub KeyPressedRemove(Event As Object)
+	Select Case Event.KeyCode
+		Case com.sun.star.awt.Key.DELETE
+		RemoveIndexEntry
+	End Select
+End Sub
+</script:module>
\ No newline at end of file

Added: incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/Link.xba
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/Link.xba?rev=1172372&view=auto
==============================================================================
--- incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/Link.xba (added)
+++ incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/Link.xba Sun Sep 18 21:34:39 2011
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
+<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Link" script:language="StarBasic">REM  *****  BASIC  *****
+
+Dim oDialog AS Object
+Dim document AS Object
+
+
+
+Sub Main
+
+	If not IsHelpFile Then
+		msgbox(strErr_NoHelpFile)
+		Exit Sub
+	End If
+
+	BasicLibraries.LoadLibrary(&quot;HelpAuthoring&quot;)
+	GlobalScope.BasicLibraries.loadLibrary(&quot;Tools&quot;)
+	Dim ListAny(0) as Long
+
+	DocRoot = ReadConfig(&quot;HelpPrefix&quot;)
+	sLastLinkDir = ReadConfig(&quot;LastLinkDir&quot;)
+	sLastLinkFile = ReadConfig(&quot;LastLinkFile&quot;)
+
+	ListAny(0) = com.sun.star.ui.dialogs.TemplateDescription.FILEOPEN_SIMPLE
+	oFileDialog = CreateUnoService(&quot;com.sun.star.ui.dialogs.FilePicker&quot;)
+	oFileDialog.Initialize(ListAny())
+
+	
+	If IsSubDir(sLastLinkDir,DocRoot) Then
+		oFileDialog.setDisplayDirectory(sLastLinkDir)
+		If sLastLinkFile &lt;&gt; &quot;&quot; AND Dir(sLastLinkDir+sLastLinkFile) &gt; &quot;&quot; Then
+			oFileDialog.setDefaultName(sLastLinkFile)
+		End If
+	Else
+		oFileDialog.setDisplayDirectory(DocRoot)
+	End If
+	
+	oMasterKey = GetRegistryKeyContent(&quot;org.openoffice.TypeDetection.Types/&quot;)
+	oTypes() = oMasterKey.Types
+	oFileDialog.AppendFilter(&quot;Help&quot;, &quot;*.xhp&quot;)
+
+	oFileDialog.SetTitle(&quot;Link to Help File&quot;)
+	iAccept = oFileDialog.Execute()
+	
+	If iAccept = 1 Then
+		sPath = oFileDialog.Files(0) 
+		sCurDir = oFileDialog.getDisplayDirectory +&quot;/&quot;
+		WriteConfig(&quot;LastLinkDir&quot;,sCurDir)
+		LastFile = Right(sPath, Len(sPath) - Len(sCurDir))
+		WriteConfig(&quot;LastLinkFile&quot;,LastFile)
+
+		If IsSubDir(sCurDir,DocRoot) Then
+			RelPath = GetRelPath(sPath, DocRoot)
+		Else
+			RelPath = sPath
+			msgbox(&quot;File is outside of your Document Root&quot;,48,&quot;Warning&quot;)
+		End If
+		
+		oSel = thiscomponent.getcurrentcontroller.getselection
+		oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+	
+		oStart = oCur.getStart
+		oCurStart = oStart.getText.createTextCursorByRange(oStart)
+			
+		oEnd = oCur.getEnd
+		oCurEnd = oEnd.getText.createTextCursorByRange(oEnd)
+		
+		thiscomponent.getcurrentcontroller.select(oCurStart)
+		InsertTag(&quot;LINK_&quot;,&quot;&lt;LINK href=&quot;&quot;&quot; + RelPath + &quot;&quot;&quot;&gt;&quot;,&quot;hlp_aux_tag&quot;)
+			
+		thiscomponent.getcurrentcontroller.select(oCurEnd)
+		InsertTag(&quot;_LINK&quot;,&quot;&lt;/LINK&gt;&quot;,&quot;hlp_aux_tag&quot;)
+	
+		SetCharStyle(&quot;Default&quot;)
+		
+	End If
+
+
+End Sub
+
+
+</script:module>
\ No newline at end of file

Added: incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/Meta.xba
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/Meta.xba?rev=1172372&view=auto
==============================================================================
--- incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/Meta.xba (added)
+++ incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/Meta.xba Sun Sep 18 21:34:39 2011
@@ -0,0 +1,173 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
+<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Meta" script:language="StarBasic">REM  *****  BASIC  *****
+
+Dim oDialog AS Object
+Dim document AS Object
+
+&apos; Fetches the meta values from the document and executes the dialog
+Sub Main
+
+	If not IsHelpFile Then
+		msgbox(strErr_NoHelpFile)
+		Exit Sub
+	End If
+
+	document = StarDesktop.CurrentComponent
+
+	BasicLibraries.LoadLibrary(&quot;HelpAuthoring&quot;)
+	oDialog = LoadDialog(&quot;HelpAuthoring&quot;, &quot;dlgMeta&quot;)
+	oDialogModel = oDialog.Model
+	
+	&apos;oTxtFName = oDialog.GetControl(&quot;txtFileName&quot;)
+	&apos;oTxtFName.Text = document.DocumentInfo.PropertyValues(29).Value
+	&apos;oTxtFName.Text = document.DocumentInfo.GetPropertyValue(&quot;Description&quot;)
+	
+&apos;	If oTxtFName.Text = &quot;&quot; Then
+&apos;		msgbox &quot;The document must be saved first.&quot;+chr(13)+&quot;Please save the document and call this dialog again.&quot;
+&apos;		oDialog.dispose
+&apos;		Exit Sub
+&apos;	End If
+	
+	oTxtTitle = oDialog.GetControl(&quot;txtTitle&quot;)
+	oTxtTitle.Text = document.DocumentInfo.Title
+	
+	oOpIndInc = oDialog.GetControl(&quot;opIndexInclude&quot;)
+	oOpIndExc = oDialog.GetControl(&quot;opIndexExclude&quot;)
+	
+	
+	&apos;oCbFileStatus = oDialog.GetControl(&quot;cbFileStatus&quot;)
+	&apos;arItems = Array(&quot;DRAFT&quot;,&quot;FINAL&quot;,&quot;PUBLISH&quot;,&quot;STALLED&quot;,&quot;DEPRECATED&quot;)
+	&apos;oCbFileStatus.AddItems(arItems,ubound(arItems))
+	&apos;sStatus = document.DocumentInfo.GetPropertyValue(&quot;Keywords&quot;)
+	&apos;If (InStr(&quot;DRAFT FINAL PUBLISH STALLED DEPRECATED&quot;,sStatus)=0) Then
+	&apos;	oCbFileStatus.SetText(&quot;DRAFT&quot;)
+	&apos;Else
+	&apos;	oCbFileStatus.SetText(sStatus)
+	&apos;End If
+	
+
+	If document.DocumentInfo.GetUserFieldValue(GetUserFieldNumber(&quot;Indexer&quot;)) = &quot;exclude&quot; then
+		oOpIndExc.State = True
+	Else
+		oOpIndInc.State = True
+	End If
+	
+	&apos;oTxtTopicID = oDialog.GetControl(&quot;txtTopicID&quot;)
+	&apos;oTxtTopicID.Text = document.DocumentInfo.GetUserFieldValue(1)
+	
+	&apos;oTxtComment = oDialog.GetControl(&quot;txtComment&quot;)
+	&apos;oTxtComment.Text = document.DocumentInfo.GetUserFieldValue(GetUserFieldNumber(&quot;Comment&quot;))
+	
+	&apos;oTxtEdited = oDialog.GetControl(&quot;txtLastEdited&quot;)
+	&apos;oTxtEdited.Text = document.DocumentInfo.GetUserFieldValue(3)
+	
+	If oDialog.Execute() = 1 Then &apos; update the meta data
+		document.DocumentInfo.Title = oTxtTitle.Text
+		&apos;document.DocumentInfo.SetUserFieldValue(1,oTxtTopicID.Text)
+		&apos;document.DocumentInfo.SetUserFieldValue(GetUserFieldNumber(&quot;Comment&quot;),oTxtComment.Text)	
+		&apos;document.DocumentInfo.SetUserFieldValue(3,oTxtEdited.Text)
+		&apos;document.DocumentInfo.SetPropertyValue(&quot;Keywords&quot;,oCbFileStatus.Text)
+		
+		&apos;If (oCbFileStatus.Text = &quot;PUBLISH&quot;) Then
+			REM... Check for paras without ID: If there are any, this cannot be PUBLISH!
+		
+		&apos;End If
+		
+		If oOpIndExc.State = True Then
+			document.DocumentInfo.SetUserFieldValue(GetUserFieldNumber(&quot;Indexer&quot;),&quot;exclude&quot;)
+		Else
+			document.DocumentInfo.SetUserFieldValue(GetUserFieldNumber(&quot;Indexer&quot;),&quot;include&quot;)
+		End If
+	End If
+	oDialog.dispose
+end sub
+
+&apos; Normalizes the values for title and topic id 
+&apos; (if the fields are empty or contain invalid values)
+Sub NormalizeMeta (Event As Object)
+	Select Case Event.Source.Model.Name
+		Case &quot;txtTitle&quot;:
+			If Event.Source.Text = &quot;&quot; Then
+				msgbox &quot;Topic title must not be empty!&quot;+chr(13)+&quot;Resetting to default value.&quot;
+			End If
+			SetTopicTitle(Event.Source.Text)
+		Case &quot;txtTopicID&quot;:
+			If Event.Source.Text = &quot;&quot; Then
+				msgbox &quot;Topic ID must not be empty!&quot;+chr(13)+&quot;Resetting to default value.&quot;
+			End If
+			SetTopicID(Event.Source.Text)
+	End Select
+End Sub
+
+&apos; Sets the value in the Topic ID dialog field
+Sub SetTopicID(txt As String)
+	oTxtTopicID = oDialog.GetControl(&quot;txtTopicID&quot;)
+	If txt = &quot;&quot; Then
+		oTxtTopicID.Text = AlphaNum(document.DocumentInfo.PropertyValues(29).Value)
+	Else
+		oTxtTopicID.Text = AlphaNum(txt)
+	End If
+End Sub
+
+Sub Test
+	On Error Resume Next
+	document = StarDesktop.CurrentComponent
+&apos;	showprop document
+	msgbox document.URL
+
+End Sub
+
+&apos; Sets the value in the Topic title dialog field
+Sub SetTopicTitle(txt As String)
+	dim strg As String
+	oTxtTitle = oDialog.GetControl(&quot;txtTitle&quot;)
+
+	If txt =&quot;&quot; Then
+		Enum = document.Text.createEnumeration
+
+		Do While Enum.hasMoreElements
+			TextElement = Enum.nextElement
+			If TextElement.supportsService(&quot;com.sun.star.text.Paragraph&quot;) Then
+				If Left(TextElement.ParaStyleName,8)=&quot;hlp_head&quot; Then
+					Enum2 = TextElement.createEnumeration
+					While Enum2.hasMoreElements
+						TextPortion = Enum2.nextElement
+						If Not(TextPortion.TextPortionType=&quot;TextField&quot;) Then
+							strg = strg + TextPortion.String
+						End If
+					Wend
+					oTxtTitle.Text = strg
+					Exit Do
+				End If
+			End If
+		Loop
+	Else
+		oTxtTitle.Text = txt
+	End If	
+End Sub
+
+&apos; Sets the value in the Topic title field when
+&apos; &quot;Fetch&quot; button is pressed
+Sub FetchTopicTitle
+	SetTopicTitle(&quot;&quot;)
+	
+End Sub
+
+&apos; Sets the value in the Topic ID dialog field when
+&apos; &quot;Suggest&quot; button is pressed
+Sub SuggestTopicID
+	SetTopicID(&quot;&quot;)
+End Sub
+
+Sub ChangeStatus
+	oCbFileStatus = oDialog.GetControl(&quot;cbFileStatus&quot;)
+	sStatus = document.DocumentInfo.GetPropertyValue(&quot;Keywords&quot;)
+	If (oCbFileStatus.Text = &quot;PUBLISH&quot;) Then
+		nNoID = 0 &apos; DEBUG
+		If nNoID &lt;&gt; 0 Then
+			msgbox &quot;There are &quot;+nNoID+&quot; new paragraphs in the file.&quot;+chr(13)+&quot;File status PUBLISH invalid.&quot;+chr(13)+&quot;Setting back to &quot;+sStatus, 48, &quot;D&apos;oh!&quot;
+		End If
+	End If
+End Sub
+</script:module>
\ No newline at end of file

Added: incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/Module1.xba
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/Module1.xba?rev=1172372&view=auto
==============================================================================
--- incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/Module1.xba (added)
+++ incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/Module1.xba Sun Sep 18 21:34:39 2011
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
+<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Module1" script:language="StarBasic">REM  HELPAUTHORING STRUCTURE
+
+
+</script:module>
\ No newline at end of file

Added: incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/OtherElements.xba
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/OtherElements.xba?rev=1172372&view=auto
==============================================================================
--- incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/OtherElements.xba (added)
+++ incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/OtherElements.xba Sun Sep 18 21:34:39 2011
@@ -0,0 +1,497 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
+<script:module xmlns:script="http://openoffice.org/2000/script" script:name="OtherElements" script:language="StarBasic">REM  *****  BASIC  *****
+
+Sub Main
+
+End Sub
+
+Sub InsertVariable
+
+	If not IsHelpFile Then
+		msgbox(strErr_NoHelpFile)
+		Exit Sub
+	End If
+
+	oSel = thiscomponent.getcurrentcontroller.getselection
+	oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+	oStart = oCur.getStart
+	oCurStart = oStart.getText.createTextCursorByRange(oStart)
+	oEnd = oCur.getEnd
+	oCurEnd = oEnd.getText.createTextCursorByRange(oEnd)
+	
+	ID = inputbox(&quot;Enter an identifier for the variable element:&quot;,&quot;Enter Variable ID&quot;)
+	
+	If ID=&quot;&quot; Then
+		Exit Sub
+	End If
+	
+	thiscomponent.getcurrentcontroller.select(oCurStart)
+	InsertTag(&quot;VAR_&quot;,&quot;&lt;VAR ID=&quot;&quot;&quot;+ID+&quot;&quot;&quot;&gt;&quot;)
+	thiscomponent.getcurrentcontroller.select(oCurEnd)
+	InsertTag(&quot;_VAR&quot;,&quot;&lt;/VAR&gt;&quot;)
+End Sub
+
+Sub InsertInlineGraphic
+	If not IsHelpFile Then
+		msgbox(strErr_NoHelpFile)
+		Exit Sub
+	End If
+	sFName = OpenGraphics
+	If sFName &lt;&gt; &quot;&quot; Then
+		sAlt = InputBox(&quot;Enter an alternative Text for the graphical element.&quot;+chr(13)+&quot;This can be changed later in the image properties.&quot;,&quot;ALT description&quot;,&quot;&lt;ALT DESCRIPTION&gt;&quot;)
+		sID = &quot;img_id&quot;+CreateID
+		InsertTag(&quot;IMG_&quot;,&quot;&lt;IMG ID=&quot;&quot;&quot;+sID+&quot;&quot;&quot;&gt;&quot;)
+		InsertGraphicFile(sFName,sID,sAlt)
+		InsertTag(&quot;_IMG&quot;,&quot;&lt;/IMG&gt;&quot;)
+	End If
+End Sub
+
+Sub InsertGraphic
+
+	If not IsHelpFile Then
+		msgbox(strErr_NoHelpFile)
+		Exit Sub
+	End If
+
+	GlobalScope.BasicLibraries.loadLibrary(&quot;Tools&quot;)
+	sFName = OpenGraphics
+	If sFName &lt;&gt; &quot;&quot; Then
+		DocRoot = ReadConfig(&quot;HelpPrefix&quot;)
+&apos;		msgbox(&quot;DocRoot &quot;+DocRoot+chr(13)+&quot;FName &quot;+sFName)
+		
+		If not(IsSubDir(sFName,DocRoot)) Then
+			msgbox(&quot;Image is located outside of your Document Root&quot;+chr(13)+DocRoot,48,&quot;Warning&quot;)
+		End If
+	
+		sAlt = InputBox(&quot;Enter an alternative Text for the graphical element.&quot;+chr(13)+&quot;This can be changed later in the image properties.&quot;,&quot;ALT description&quot;,&quot;&lt;ALT DESCRIPTION&gt;&quot;)
+&apos;		sCap = InputBox(&quot;Enter a caption for the image (optional)&quot;,&quot;Caption&quot;,&quot;&quot;)
+		sID = CreateID
+		CR
+		InsertTag(&quot;IMG_&quot;,&quot;&lt;IMG ID=&quot;&quot;&quot;+&quot;img_id&quot;+sID+&quot;&quot;&quot;&gt;&quot;)
+		InsertGraphicFile(sFName,&quot;img_id&quot;+sID,sAlt)
+&apos;		If sCap &lt;&gt; &quot;&quot; Then
+&apos;			InsertCaption(sCap,&quot;cap_id&quot;+sID)
+&apos;		End If
+		InsertTag(&quot;_IMG&quot;,&quot;&lt;/IMG&gt;&quot;)
+	End If
+End Sub
+
+
+Sub InsertGraphicFile(sURL As String, sName As String, sAlt As String)
+	oSel = thiscomponent.getcurrentcontroller.getselection
+	oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+	oDoc = StarDesktop.CurrentComponent
+	oGrp = oDoc.createInstance(&quot;com.sun.star.text.GraphicObject&quot;)
+	oGrp.GraphicURL = sURL
+	oGrp.AnchorType = 1
+	oGrp.Name = sName
+	oGrp.Title = sAlt
+	oCur.Text.InsertTextContent(oCur,oGrp,true)
+End Sub
+
+Sub SpecifyCaption
+	&apos;check if the image allows captions
+	If thiscomponent.getcurrentcontroller.getselection.ImplementationName = &quot;SwXTextGraphicObject&quot; Then
+		msgbox &quot;Please press ESCAPE to deselect the image and recall the menu item&quot;
+		Exit Sub
+	End If
+	If IsBlockImage Then
+		If not(HasCaption) Then
+			sCap = InputBox(&quot;Enter a caption for the image (optional)&quot;,&quot;Caption&quot;,&quot;&quot;)
+			If sCap &lt;&gt; &quot;&quot; Then
+				sID = GetImageID
+				sID = &quot;cap&quot;+right(sID, Len(sID)-3)
+				GoLeft(1)
+				InsertCaption(sCap, sID)
+			End If
+		Else
+			msgbox &quot;Image has a caption already.&quot;,0,&quot;D&apos;oh!&quot;
+		End If
+	Else
+		msgbox &quot;Only block images may have captions.&quot;,0,&quot;D&apos;oh!&quot;
+	End If
+End Sub
+
+Sub InsertCaption(sCap As String, sID as String)
+		InsertTag(&quot;IMGCAPTION_&quot;,&quot;&lt;IMGCAPTION id=&quot;&quot;&quot;+sID+&quot;&quot;&quot;&gt;&quot;)
+		InsertText(sCap)
+		InsertTag(&quot;_IMGCAPTION&quot;,&quot;&lt;/IMGCAPTION&gt;&quot;)
+End Sub
+
+Sub InsertExtendedTip
+
+	If not IsHelpFile Then
+		msgbox(strErr_NoHelpFile)
+		Exit Sub
+	End If
+
+	oSel = thiscomponent.getcurrentcontroller.getselection
+	oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+	oStart = oCur.getStart
+	oCurStart = oStart.getText.createTextCursorByRange(oStart)
+	oEnd = oCur.getEnd
+	oCurEnd = oEnd.getText.createTextCursorByRange(oEnd)
+	
+	Ret = msgbox (&quot;Create a hidden tip?&quot;,3+32,&quot;Extended Tip&quot;)
+	
+	If Ret=2 or Ret=3 Then
+		Exit Sub
+	End If
+	
+	thiscomponent.getcurrentcontroller.select(oCurStart)
+	If Ret=6 Then
+		InsertTag(&quot;AHID_&quot;,&quot;&lt;AHID hid=&quot;&quot;&quot;+ID+&quot;&quot;&quot;&gt;&quot;)
+	ElseIf Ret=7 Then
+		InsertTag(&quot;AVIS_&quot;,&quot;&lt;AVIS hid=&quot;&quot;&quot;+ID+&quot;&quot;&quot;&gt;&quot;)
+	End If
+	thiscomponent.getcurrentcontroller.select(oCurEnd)
+	If Ret=6 Then
+		InsertTag(&quot;_AHID&quot;,&quot;&lt;/AHID&gt;&quot;)
+	ElseIf Ret=7 Then
+		InsertTag(&quot;_AVIS&quot;,&quot;&lt;/AVIS&gt;&quot;)
+	End If
+End Sub
+
+Sub InsertSort
+	CR
+	SetParaStyle(&quot;hlp_aux_sort&quot;)
+	InsertTag(&quot;SORT_&quot;,&quot;&lt;SORT order=&quot;&quot;asc&quot;&quot;&gt;&quot;,&quot;hlp_aux_sort&quot;)
+	GoLeft(1)
+	GoDown(1)
+	msgbox &quot;Remember to also specify the closing SORT tag!&quot;,48,&quot;Don&apos;t forget to close the tag&quot;	
+End Sub
+
+Sub CloseSort
+	CR
+	SetParaStyle(&quot;hlp_aux_sort&quot;)
+	InsertTag(&quot;_SORT&quot;,&quot;&lt;/SORT&gt;&quot;,&quot;hlp_aux_sort&quot;)
+	GoLeft(1)
+	GoDown(1)
+End Sub
+
+sub InsertSection
+
+
+	If not IsHelpFile Then
+		msgbox(strErr_NoHelpFile)
+		Exit Sub
+	End If
+
+	dim document   as object
+	dim dispatcher as object
+
+	oSel = thiscomponent.getcurrentcontroller.getselection
+	oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+	oStart = oCur.getStart
+	oCurStart = oStart.getText.createTextCursorByRange(oStart)
+	oEnd = oCur.getEnd
+	oCurEnd = oEnd.getText.createTextCursorByRange(oEnd)
+	
+	sSectionName = AlphaNum(inputbox(&quot;Please specify a section name/identifier:&quot;))
+	
+	If sSectionName = &quot;&quot; Then
+		Exit Sub
+	End If
+
+	If sSectionName = &quot;&quot; Then
+		msgbox &quot;No (valid) identifier -- no section.&quot;+chr(13)+&quot;Hint: Use only A-Z,a-z,0-9 and _&quot;,48,&quot;D&apos;oh!&quot;
+		Exit Sub
+	End If
+
+	document   = ThisComponent.CurrentController.Frame
+	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
+
+	dim args(6) as new com.sun.star.beans.PropertyValue
+	args(0).Name = &quot;RegionName&quot;
+	args(0).Value = sSectionName
+	args(1).Name = &quot;RegionCondition&quot;
+	args(1).Value = &quot;&quot;
+	args(2).Name = &quot;RegionHidden&quot;
+	args(2).Value = false
+	args(3).Name = &quot;RegionProtect&quot;
+	args(3).Value = false
+	args(4).Name = &quot;LinkName&quot;
+	args(4).Value = &quot;&quot;
+	args(5).Name = &quot;FilterName&quot;
+	args(5).Value = &quot;&quot;
+	args(6).Name = &quot;SubRegion&quot;
+	args(6).Value = &quot;&quot;
+
+	dispatcher.executeDispatch(document, &quot;.uno:InsertSection&quot;, &quot;&quot;, 0, args())
+
+	If oCur.GetString &lt;&gt; &quot;&quot; Then
+		thiscomponent.getcurrentcontroller.select(oCurStart)
+		CR_before
+		GoUp(1)
+		InsertTag(&quot;SECTION_&quot;,&quot;&lt;SECTION id=&quot;&quot;&quot;+sSectionName+&quot;&quot;&quot;&gt;&quot;)
+		SetParaStyle(&quot;hlp_aux_section&quot;)
+	
+		thiscomponent.getcurrentcontroller.select(oCurEnd)
+		CR
+		SetParaStyle(&quot;hlp_aux_section&quot;)
+		InsertTag(&quot;_SECTION&quot;,&quot;&lt;/SECTION&gt;&quot;)
+	Else
+		GoUp(1)
+		InsertTagCR(&quot;SECTION_&quot;,&quot;&lt;SECTION id=&quot;&quot;&quot;+sSectionName+&quot;&quot;&quot;&gt;&quot;,&quot;hlp_aux_section&quot;)
+		CR 
+		SetParaStyle(&quot;hlp_aux_section&quot;)
+		InsertTag(&quot;_SECTION&quot;,&quot;&lt;/SECTION&gt;&quot;)
+		GoUp(1)
+		SetParaStyle(&quot;hlp_default&quot;)
+	End If	
+	
+end sub
+
+Sub ToggleParaL10NStatus
+
+	If not IsHelpFile Then
+		msgbox(strErr_NoHelpFile)
+		Exit Sub
+	End If
+
+	oSel = thiscomponent.getcurrentcontroller.getselection
+	oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+
+	oCur.gotoStartOfParagraph(0)
+	CharStyle = oCur.charStyleName
+
+	arParaData = GetParaData
+	sID = arParaData(0)
+	slocalize = arParaData(1)
+	sMsg = arParaData(2)
+
+	If sMsg &lt;&gt; &quot;&quot; Then
+		msgbox &quot;Error in paragraph status:&quot;+chr(13)+sMsg,48,&quot;Error&quot;
+		Exit Sub
+	End If
+
+
+	If (sID = &quot;&quot;) Then
+		msgbox &quot;Paragraph has no ID. Assigning ID.&quot;,48,&quot;Info&quot;
+		InsertNewParaData
+		thiscomponent.getcurrentcontroller.select(oSel(0))
+		arParaData = GetParaData
+		sID = arParaData(0)
+		slocalize = arParaData(1)
+		sMsg = arParaData(2)
+	End If
+
+	If slocalize = &quot;no&quot; Then
+		SetParaData(sID,&quot;yes&quot;)
+	Else
+		SetParaData(sID,&quot;no&quot;)
+	End If
+	
+	thiscomponent.getcurrentcontroller.select(oSel(0))
+	
+End Sub
+
+
+Sub LocalizeImage
+	oSel = thiscomponent.getcurrentcontroller.getselection
+	If oSel(0).ImplementationName &lt;&gt; &quot;SwXTextGraphicObject&quot; Then
+		msgbox &quot;Please select an image&quot;
+	Else
+		If Instr(oSel(0).Name,&quot; &quot;)&gt;0 Then
+			oSel(0).Name = Left(oSel(0).Name,Instr(oSel(0).Name,&quot; &quot;)-1)
+		End If
+		oSel(0).Name = oSel(0).Name + &quot; localize=&quot;&quot;true&quot;&quot;&quot;
+	End If
+	SetBorder
+End Sub
+
+
+Sub UnLocalizeImage
+	oSel = thiscomponent.getcurrentcontroller.getselection
+	If oSel(0).ImplementationName &lt;&gt; &quot;SwXTextGraphicObject&quot; Then
+		msgbox &quot;Please select an image&quot;
+	Else
+
+		If Instr(oSel(0).Name,&quot; &quot;)&gt;0 Then
+			oSel(0).Name = Left(oSel(0).Name,Instr(oSel(0).Name,&quot; &quot;)-1)
+		End If
+		UnsetBorder
+	End If
+	
+End Sub
+
+
+Sub ResetAllParaStatusValues
+	REM ... to be done
+End Sub
+
+Sub InsertHowToGet
+
+	If not IsHelpFile Then
+		msgbox(strErr_NoHelpFile)
+		Exit Sub
+	End If
+
+	document   = ThisComponent.CurrentController.Frame
+	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
+
+	dim args(6) as new com.sun.star.beans.PropertyValue
+	args(0).Name = &quot;RegionName&quot;
+	args(0).Value = &quot;howtoget&quot;
+	args(1).Name = &quot;RegionCondition&quot;
+	args(1).Value = &quot;&quot;
+	args(2).Name = &quot;RegionHidden&quot;
+	args(2).Value = false
+	args(3).Name = &quot;RegionProtect&quot;
+	args(3).Value = false
+	args(4).Name = &quot;LinkName&quot;
+	args(4).Value = &quot;&quot;
+	args(5).Name = &quot;FilterName&quot;
+	args(5).Value = &quot;&quot;
+	args(6).Name = &quot;SubRegion&quot;
+	args(6).Value = &quot;&quot;
+
+	dispatcher.executeDispatch(document, &quot;.uno:InsertSection&quot;, &quot;&quot;, 0, args())
+	GoUp(1)
+	InsertTagCR(&quot;SECTION_&quot;,&quot;&lt;SECTION id=&quot;&quot;howtoget&quot;&quot;&gt;&quot;,&quot;hlp_aux_section&quot;)
+	CR 
+	SetParaStyle(&quot;hlp_aux_section&quot;)
+	InsertTag(&quot;_SECTION&quot;,&quot;&lt;/SECTION&gt;&quot;)
+	GoUp(1)
+	SetParaStyle(&quot;hlp_default&quot;)
+&apos;	Embed.Main(false)
+End Sub
+
+Sub InsertRelatedTopics
+
+	If not IsHelpFile Then
+		msgbox(strErr_NoHelpFile)
+		Exit Sub
+	End If
+
+	document   = ThisComponent.CurrentController.Frame
+	dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
+
+	dim args(6) as new com.sun.star.beans.PropertyValue
+	args(0).Name = &quot;RegionName&quot;
+	args(0).Value = &quot;relatedtopics&quot;
+	args(1).Name = &quot;RegionCondition&quot;
+	args(1).Value = &quot;&quot;
+	args(2).Name = &quot;RegionHidden&quot;
+	args(2).Value = false
+	args(3).Name = &quot;RegionProtect&quot;
+	args(3).Value = false
+	args(4).Name = &quot;LinkName&quot;
+	args(4).Value = &quot;&quot;
+	args(5).Name = &quot;FilterName&quot;
+	args(5).Value = &quot;&quot;
+	args(6).Name = &quot;SubRegion&quot;
+	args(6).Value = &quot;&quot;
+
+	dispatcher.executeDispatch(document, &quot;.uno:InsertSection&quot;, &quot;&quot;, 0, args())
+	GoUp(1)
+	InsertTagCR(&quot;SECTION_&quot;,&quot;&lt;SECTION id=&quot;&quot;relatedtopics&quot;&quot;&gt;&quot;,&quot;hlp_aux_section&quot;)
+	CR 
+	SetParaStyle(&quot;hlp_aux_section&quot;)
+	InsertTag(&quot;_SECTION&quot;,&quot;&lt;/SECTION&gt;&quot;)
+	GoUp(1)
+	SetParaStyle(&quot;hlp_default&quot;)
+End Sub
+
+
+sub UnsetBorder
+rem ----------------------------------------------------------------------
+rem define variables
+dim document   as object
+dim dispatcher as object
+rem ----------------------------------------------------------------------
+rem get access to the document
+document   = ThisComponent.CurrentController.Frame
+dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
+
+rem ----------------------------------------------------------------------
+dim args1(7) as new com.sun.star.beans.PropertyValue
+args1(0).Name = &quot;BorderOuter.LeftBorder&quot;
+args1(0).Value = Array(0,0,0,0)
+args1(1).Name = &quot;BorderOuter.LeftDistance&quot;
+args1(1).Value = 10
+args1(2).Name = &quot;BorderOuter.RightBorder&quot;
+args1(2).Value = Array(0,0,0,0)
+args1(3).Name = &quot;BorderOuter.RightDistance&quot;
+args1(3).Value = 0
+args1(4).Name = &quot;BorderOuter.TopBorder&quot;
+args1(4).Value = Array(0,0,0,0)
+args1(5).Name = &quot;BorderOuter.TopDistance&quot;
+args1(5).Value = 0
+args1(6).Name = &quot;BorderOuter.BottomBorder&quot;
+args1(6).Value = Array(0,0,0,0)
+args1(7).Name = &quot;BorderOuter.BottomDistance&quot;
+args1(7).Value = 0
+
+dispatcher.executeDispatch(document, &quot;.uno:BorderOuter&quot;, &quot;&quot;, 0, args1())
+
+rem ----------------------------------------------------------------------
+dim args2(4) as new com.sun.star.beans.PropertyValue
+args2(0).Name = &quot;BorderInner.Horizontal&quot;
+args2(0).Value = Array(0,0,0,0)
+args2(1).Name = &quot;BorderInner.Vertical&quot;
+args2(1).Value = Array(0,0,0,0)
+args2(2).Name = &quot;BorderInner.Flags&quot;
+args2(2).Value = 2
+args2(3).Name = &quot;BorderInner.ValidFlags&quot;
+args2(3).Value = 63
+args2(4).Name = &quot;BorderInner.DefaultDistance&quot;
+args2(4).Value = 0
+
+dispatcher.executeDispatch(document, &quot;.uno:BorderInner&quot;, &quot;&quot;, 0, args2())
+
+
+end sub
+
+
+
+sub SetBorder
+rem ----------------------------------------------------------------------
+rem define variables
+dim document   as object
+dim dispatcher as object
+rem ----------------------------------------------------------------------
+rem get access to the document
+document   = ThisComponent.CurrentController.Frame
+dispatcher = createUnoService(&quot;com.sun.star.frame.DispatchHelper&quot;)
+
+rem ----------------------------------------------------------------------
+dim args1(7) as new com.sun.star.beans.PropertyValue
+args1(0).Name = &quot;BorderOuter.LeftBorder&quot;
+args1(0).Value = Array(15167232,0,88,0)
+args1(1).Name = &quot;BorderOuter.LeftDistance&quot;
+args1(1).Value = 101
+args1(2).Name = &quot;BorderOuter.RightBorder&quot;
+args1(2).Value = Array(15167232,0,88,0)
+args1(3).Name = &quot;BorderOuter.RightDistance&quot;
+args1(3).Value = 101
+args1(4).Name = &quot;BorderOuter.TopBorder&quot;
+args1(4).Value = Array(15167232,0,88,0)
+args1(5).Name = &quot;BorderOuter.TopDistance&quot;
+args1(5).Value = 101
+args1(6).Name = &quot;BorderOuter.BottomBorder&quot;
+args1(6).Value = Array(15167232,0,88,0)
+args1(7).Name = &quot;BorderOuter.BottomDistance&quot;
+args1(7).Value = 101
+
+dispatcher.executeDispatch(document, &quot;.uno:BorderOuter&quot;, &quot;&quot;, 0, args1())
+
+rem ----------------------------------------------------------------------
+dim args2(4) as new com.sun.star.beans.PropertyValue
+args2(0).Name = &quot;BorderInner.Horizontal&quot;
+args2(0).Value = Array(0,0,0,0)
+args2(1).Name = &quot;BorderInner.Vertical&quot;
+args2(1).Value = Array(0,0,0,0)
+args2(2).Name = &quot;BorderInner.Flags&quot;
+args2(2).Value = 2
+args2(3).Name = &quot;BorderInner.ValidFlags&quot;
+args2(3).Value = 127
+args2(4).Name = &quot;BorderInner.DefaultDistance&quot;
+args2(4).Value = 0
+
+dispatcher.executeDispatch(document, &quot;.uno:BorderInner&quot;, &quot;&quot;, 0, args2())
+
+
+end sub
+</script:module>
\ No newline at end of file

Added: incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/Switch.xba
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/Switch.xba?rev=1172372&view=auto
==============================================================================
--- incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/Switch.xba (added)
+++ incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/Switch.xba Sun Sep 18 21:34:39 2011
@@ -0,0 +1,318 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
+<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Switch" script:language="StarBasic">REM  *****  BASIC  *****
+
+Dim oDialog AS Object
+Dim document AS Object
+
+Sub Main
+End Sub
+
+Sub InsertSwitch
+	InsertSwitchTag(FALSE)
+End Sub
+
+Sub InsertSwitchInline
+	InsertSwitchTag(TRUE)
+End Sub
+
+Sub InsertSwitchTag(bInline As Boolean)
+	document = StarDesktop.CurrentComponent
+	Dim oCur as Object
+
+	BasicLibraries.LoadLibrary(&quot;HelpAuthoring&quot;)
+
+	oDialog = LoadDialog(&quot;HelpAuthoring&quot;, &quot;dlgSwitch&quot;)
+	oDialogModel = oDialog.Model
+	
+	oOptSys = oDialog.GetControl(&quot;opSwitchSystem&quot;)
+	oOptAppl = oDialog.GetControl(&quot;opSwitchAppl&quot;)
+	oOptDistrib = oDialog.GetControl(&quot;opSwitchDistrib&quot;)
+	
+	If oDialog.Execute() = 1 Then
+		If oOptSys.State Then
+			sType = &quot;sys&quot;
+		ElseIf oOptAppl.State Then
+			sType = &quot;appl&quot;
+		ElseIf oOptDistrib.State Then
+			sType = &quot;distrib&quot;
+		End If
+	Else
+	End If
+	oDialog.Dispose
+
+	If bInline Then
+		oSel = thiscomponent.getcurrentcontroller.getselection
+		oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+		
+		oStart = oCur.getStart
+		oCurStart = oStart.getText.createTextCursorByRange(oStart)
+			
+		oEnd = oCur.getEnd
+		oCurEnd = oEnd.getText.createTextCursorByRange(oEnd)
+		
+		thiscomponent.getcurrentcontroller.select(oCurStart)
+		InsertTag(&quot;SWITCHINLINE_&quot;,&quot;&lt;SWITCHINLINE select=&quot;&quot;&quot; + sType + &quot;&quot;&quot;&gt;&quot;,&quot;hlp_aux_switch&quot;)
+		InsertCase(sType,TRUE,oCur)
+		thiscomponent.getcurrentcontroller.select(oCurEnd)
+		CloseSwitchInline
+		GoLeft(1)
+	Else
+		CR_before
+		GoUp(1)
+		SetParaStyle(&quot;hlp_aux_switch&quot;)
+		InsertTag(&quot;SWITCH_&quot;,&quot;&lt;SWITCH select=&quot;&quot;&quot; + sType + &quot;&quot;&quot;&gt;&quot;,&quot;hlp_aux_switch&quot;)
+		GoLeft(1)
+		GoDown(1)
+		SetCharStyle(&quot;Default&quot;)
+		CloseSwitch
+		GoUp(1)
+		InsertCase(sType,FALSE,oCur)
+	End If
+End Sub
+
+Sub InsertCaseElement
+	document = StarDesktop.CurrentComponent
+	Dim oCur as Object
+	BasicLibraries.LoadLibrary(&quot;HelpAuthoring&quot;)
+
+	oDialog = LoadDialog(&quot;HelpAuthoring&quot;, &quot;dlgSwitch&quot;)
+	oDialogModel = oDialog.Model
+	
+	oOptSys = oDialog.GetControl(&quot;opSwitchSystem&quot;)
+	oOptAppl = oDialog.GetControl(&quot;opSwitchAppl&quot;)
+	oOptDistrib = oDialog.GetControl(&quot;opSwitchDistrib&quot;)
+	
+	If oDialog.Execute() = 1 Then
+		If oOptSys.State Then
+			sType = &quot;sys&quot;
+		ElseIf oOptAppl.State Then
+			sType = &quot;appl&quot;
+		ElseIf oOptDistrib.State Then
+			sType = &quot;distrib&quot;
+		End If
+	Else
+	End If
+	oDialog.Dispose
+
+	InsertCase(sType,FALSE,oCur)
+
+End Sub
+
+Sub InsertDefaultElement
+	document = StarDesktop.CurrentComponent
+	BasicLibraries.LoadLibrary(&quot;HelpAuthoring&quot;)
+	
+	InsertDefault
+End Sub
+
+Sub InsertCaseInlineElement
+	document = StarDesktop.CurrentComponent
+	Dim oCur as Object
+	BasicLibraries.LoadLibrary(&quot;HelpAuthoring&quot;)
+
+	oDialog = LoadDialog(&quot;HelpAuthoring&quot;, &quot;dlgSwitch&quot;)
+	oDialogModel = oDialog.Model
+	
+	oOptSys = oDialog.GetControl(&quot;opSwitchSystem&quot;)
+	oOptAppl = oDialog.GetControl(&quot;opSwitchAppl&quot;)
+	oOptDistrib = oDialog.GetControl(&quot;opSwitchDistrib&quot;)
+	
+	If oDialog.Execute() = 1 Then
+		If oOptSys.State Then
+			sType = &quot;sys&quot;
+		ElseIf oOptAppl.State Then
+			sType = &quot;appl&quot;
+		ElseIf oOptDistrib.State Then
+			sType = &quot;distrib&quot;
+		End If
+	Else
+	End If
+	oDialog.Dispose
+
+	oSel = thiscomponent.getcurrentcontroller.getselection
+	oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+		
+	oStart = oCur.getStart
+	oCurStart = oStart.getText.createTextCursorByRange(oStart)
+			
+	oEnd = oCur.getEnd
+	oCurEnd = oEnd.getText.createTextCursorByRange(oEnd)
+		
+	InsertCase(sType,TRUE,oCur)
+	GoLeft(1)
+End Sub
+
+Sub InsertDefaultInlineElement
+	document = StarDesktop.CurrentComponent
+	BasicLibraries.LoadLibrary(&quot;HelpAuthoring&quot;)
+
+	oSel = thiscomponent.getcurrentcontroller.getselection
+	oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+		
+	oStart = oCur.getStart
+	oCurStart = oStart.getText.createTextCursorByRange(oStart)
+			
+	oEnd = oCur.getEnd
+	oCurEnd = oEnd.getText.createTextCursorByRange(oEnd)
+		
+	InsertDefaultInline(oCur)
+	GoLeft(1)
+End Sub
+
+
+Sub InsertCaseSys
+	InsertCase(&quot;sys&quot;,FALSE)
+End Sub
+
+Sub InsertCaseAppl
+	InsertCase(&quot;appl&quot;,FALSE)
+End Sub
+
+Sub InsertCaseDistrib
+	InsertCase(&quot;distrib&quot;,FALSE)
+End Sub
+
+Sub InsertCaseInlineSys
+	InsertCase(&quot;sys&quot;,TRUE)
+End Sub
+
+Sub InsertCaseInlineAppl
+	InsertCase(&quot;appl&quot;,TRUE)
+End Sub
+
+Sub InsertCaseInlineDistrib
+	InsertCase(&quot;distrib&quot;,TRUE)
+End Sub
+
+Sub InsertDefaultInline(oCur as Object)
+	oSel = thiscomponent.getcurrentcontroller.getselection
+	&apos;oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+	
+	oStart = oCur.getStart
+	oCurStart = oStart.getText.createTextCursorByRange(oStart)
+			
+	oEnd = oCur.getEnd
+	oCurEnd = oEnd.getText.createTextCursorByRange(oEnd)
+		
+	thiscomponent.getcurrentcontroller.select(oCurStart)
+	InsertTag(&quot;DEFAULTINLINE_&quot;,&quot;&lt;DEFAULTINLINE&gt;&quot;)
+		
+	thiscomponent.getcurrentcontroller.select(oCurEnd)
+	InsertTag(&quot;_DEFAULTINLINE&quot;,&quot;&lt;/DEFAULTINLINE&gt;&quot;)
+End Sub
+
+Sub InsertCase(sType As String, bInline As Boolean,oCur As Object)
+	document = StarDesktop.CurrentComponent
+
+	BasicLibraries.LoadLibrary(&quot;HelpAuthoring&quot;)
+	oDialog = LoadDialog(&quot;HelpAuthoring&quot;, &quot;dlgCase&quot;)
+	oDialogModel = oDialog.Model
+	
+	oOptPredefined = oDialog.GetControl(&quot;opPredefined&quot;)
+	oCbPredefined = oDialog.GetControl(&quot;cbPredefined&quot;)
+	oOptSpecify = oDialog.GetControl(&quot;opSpecify&quot;)
+	oTxtSpecify = oDialog.GetControl(&quot;txtSpecify&quot;)
+	oTxtSpecify.setVisible(FALSE)
+	
+	If sType = &quot;sys&quot; Then
+		arItems = Array(&quot;WIN&quot;,&quot;UNIX&quot;,&quot;MAC&quot;)
+	ElseIf sType = &quot;appl&quot; Then
+		arItems = Array(&quot;CALC&quot;,&quot;CHART&quot;,&quot;DRAW&quot;,&quot;IMPRESS&quot;,&quot;MATH&quot;,&quot;WRITER&quot;,&quot;BASIC&quot;)
+	ElseIf sType = &quot;distrib&quot; Then
+		arItems = Array(&quot;OPENSOURCE&quot;,&quot;COMMERCIAL&quot;)
+	Else
+		msgbox &quot;Unknown Case. Go tell Frank about this&quot;,0,&quot;D&apos;oh!&quot;
+		Exit Sub
+	End If
+
+	oCbPredefined.AddItems(arItems,ubound(arItems))
+	oCbPredefined.SetText(arItems(0))
+	
+	If oDialog.Execute() = 1 Then
+
+		If oOptPredefined.State Then
+			sSelect = oCbPredefined.GetText
+		Else
+			sSelect = oTxtSpecify.Text
+		End If
+	
+		If bInline Then
+			oSel = thiscomponent.getcurrentcontroller.getselection
+			&apos;oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+			
+			oStart = oCur.getStart
+			oCurStart = oStart.getText.createTextCursorByRange(oStart)
+			
+			oEnd = oCur.getEnd
+			oCurEnd = oEnd.getText.createTextCursorByRange(oEnd)
+		
+			thiscomponent.getcurrentcontroller.select(oCurStart)
+			InsertTag(&quot;CASEINLINE_&quot;,&quot;&lt;CASEINLINE select=&quot;&quot;&quot;+sSelect+&quot;&quot;&quot;&gt;&quot;)
+		
+			thiscomponent.getcurrentcontroller.select(oCurEnd)
+			InsertTag(&quot;_CASEINLINE&quot;,&quot;&lt;/CASEINLINE&gt;&quot;)
+		Else
+			CR_before
+			GoUp(1)
+			SetParaStyle(&quot;hlp_aux_switch&quot;)
+			InsertTag(&quot;CASE_&quot;,&quot;&lt;CASE select=&quot;&quot;&quot; + sSelect+&quot;&quot;&quot;&gt;&quot;,&quot;hlp_aux_switch&quot;)
+			GoLeft(1)
+			GoDown(1)
+			SetCharStyle(&quot;Default&quot;)
+			CloseCase
+			GoUp(1)
+		End If
+	End If
+	oDialog.dispose
+End Sub
+
+Sub StatusChange
+	oOptPredefined = oDialog.GetControl(&quot;opPredefined&quot;)
+	oCbPredefined = oDialog.GetControl(&quot;cbPredefined&quot;)
+	oOptSpecify = oDialog.GetControl(&quot;opSpecify&quot;)
+	oTxtSpecify = oDialog.GetControl(&quot;txtSpecify&quot;)
+	
+	If oOptPredefined.State Then
+		oCbPredefined.setVisible(TRUE)
+		oTxtSpecify.setVisible(FALSE)
+	ElseIf oOptSpecify.State Then
+		oCbPredefined.setVisible(FALSE)
+		oTxtSpecify.setVisible(TRUE)
+	End If
+End Sub
+
+Sub CloseCase
+	CR
+	SetParaStyle(&quot;hlp_aux_switch&quot;)
+	InsertTag(&quot;_CASE&quot;,&quot;&lt;/CASE&gt;&quot;,&quot;hlp_aux_switch&quot;)
+End Sub
+
+Sub InsertDefault
+	CR_before
+	GoUp(1)
+	SetParaStyle(&quot;hlp_aux_switch&quot;)
+	InsertTag(&quot;DEFAULT_&quot;,&quot;&lt;DEFAULT&gt;&quot;,&quot;hlp_aux_switch&quot;)
+	GoLeft(1)
+	GoDown(1)
+	SetCharStyle(&quot;Default&quot;)
+	CloseDefault
+	GoUp(1)
+End Sub
+
+Sub CloseDefault
+	CR
+	SetParaStyle(&quot;hlp_aux_switch&quot;)
+	InsertTag(&quot;_DEFAULT&quot;,&quot;&lt;/DEFAULT&gt;&quot;,&quot;hlp_aux_switch&quot;)
+End Sub
+
+Sub CloseSwitch
+	CR
+	SetParaStyle(&quot;hlp_aux_switch&quot;)
+	InsertTag(&quot;_SWITCH&quot;,&quot;&lt;/SWITCH&gt;&quot;,&quot;hlp_aux_switch&quot;)
+End Sub
+
+Sub CloseSwitchInline
+	InsertTag(&quot;_SWITCHINLINE&quot;,&quot;&lt;/SWITCHINLINE&gt;&quot;)
+End Sub
+</script:module>
\ No newline at end of file

Added: incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/TOC.xba
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/TOC.xba?rev=1172372&view=auto
==============================================================================
--- incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/TOC.xba (added)
+++ incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/TOC.xba Sun Sep 18 21:34:39 2011
@@ -0,0 +1,136 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
+<script:module xmlns:script="http://openoffice.org/2000/script" script:name="TOC" script:language="StarBasic">REM  *****  BASIC  *****
+
+Dim oDialog AS Object
+Dim document AS Object
+
+Sub Main
+	document = StarDesktop.CurrentComponent
+
+	BasicLibraries.LoadLibrary(&quot;HelpAuthoring&quot;)
+	oDialog = LoadDialog(&quot;HelpAuthoring&quot;, &quot;dlgTOC&quot;)
+	oDialogModel = oDialog.Model
+	
+	ocbAddTag = oDialog.GetControl(&quot;cbAddTag&quot;)
+	
+	&apos; Check if bookmarks are allowed here
+	If IsInList Then
+		msgbox &quot;No Bookmarks allowed inside a list.&quot;, 48, &quot;D&apos;oh!&quot;
+		Exit Sub
+	End If
+	
+	nBookmarkType = IsInBookmark
+	If nBookmarkType = 3 Then &apos; inside TOC bookmark
+		ocbAddTag.State = 0
+	End If
+	
+	If oDialog.Execute() = 1 Then
+		&apos; Insert the bookmark construction
+		olbTOC = oDialog.GetControl(&quot;lbTOC&quot;)
+
+		If nBookmarkType = 0 Then&apos; not in a bookmark, always add parent tags
+			bmid = CreateID
+			&apos; now check if we are in a para with text (this wouldn&apos;t be valid)
+			If Not(ParaIsEmpty) Then
+				CR
+			End If
+			InsertTag(&quot;BOOKMARK_&quot;,&quot;&lt;BOOKMARK branch=&quot;&quot;contents&quot;&quot; id=&quot;&quot;bm_id&quot; + bmid + &quot;&quot;&quot;&gt;&quot;,&quot;hlp_aux_bookmark&quot;)
+			For i=0 to ubound(olbTOC.Items)
+				LF
+				InsertTag(&quot;BOOKMARKVALUE_&quot;,&quot;&lt;BOOKMARKVALUE&gt;&quot;)
+				InsertField(&quot;BOOKMARKVALUE&quot;,olbTOC.Items(i))
+				InsertTag(&quot;_BOOKMARKVALUE&quot;,&quot;&lt;/BOOKMARKVALUE&gt;&quot;)
+			Next i
+			LF
+			InsertTagCR(&quot;_BOOKMARK&quot;,&quot;&lt;/BOOKMARK&gt;&quot;,&quot;hlp_aux_bookmark&quot;)
+	
+		ElseIf nBookmarkType = 3 Then &apos; correct bookmark type
+			If ocbAddTag.State = 1 Then
+				bmid = CreateID
+				&apos; now check if we are in a para with text (this wouldn&apos;t be valid)
+				If Not(ParaIsEmpty) Then
+					CR
+				End If
+				InsertTag(&quot;BOOKMARK_&quot;,&quot;&lt;BOOKMARK branch=&quot;&quot;contents&quot;&quot; id=&quot;&quot;bm_id&quot; + bmid + &quot;&quot;&quot;&gt;&quot;,&quot;hlp_aux_bookmark&quot;)
+			End If
+			For i=0 to ubound(olbTOC.Items)
+				LF
+				InsertTag(&quot;BOOKMARKVALUE_&quot;,&quot;&lt;BOOKMARKVALUE&gt;&quot;)
+				InsertField(&quot;BOOKMARKVALUE&quot;,olbTOC.Items(i))
+				InsertTag(&quot;_BOOKMARKVALUE&quot;,&quot;&lt;/BOOKMARKVALUE&gt;&quot;)
+			Next i
+			If ocbAddTag.State = 1 Then
+				LF
+				InsertTagCR(&quot;_BOOKMARK&quot;,&quot;&lt;/BOOKMARK&gt;&quot;,&quot;hlp_aux_bookmark&quot;)
+			End If
+		Else	&apos; wrong bookmark type
+			bmid = CreateID
+			&apos; now check if we are in a para with text (this wouldn&apos;t be valid)
+			If Not(ParaIsEmpty) Then
+				CR
+			End If
+			InsertTag(&quot;BOOKMARK_&quot;,&quot;&lt;BOOKMARK branch=&quot;&quot;contents&quot;&quot; id=&quot;&quot;bm_id&quot; + bmid + &quot;&quot;&quot;&gt;&quot;,&quot;hlp_aux_bookmark&quot;)
+			For i=0 to ubound(olbTOC.Items)
+				LF
+				InsertTag(&quot;BOOKMARKVALUE_&quot;,&quot;&lt;BOOKMARKVALUE&gt;&quot;)
+				InsertField(&quot;BOOKMARKVALUE&quot;,olbTOC.Items(i))
+				InsertTag(&quot;_BOOKMARKVALUE&quot;,&quot;&lt;/BOOKMARKVALUE&gt;&quot;)
+			Next i
+			LF
+			InsertTagCR(&quot;_BOOKMARK&quot;,&quot;&lt;/BOOKMARK&gt;&quot;,&quot;hlp_aux_bookmark&quot;)
+		End If
+
+	End If
+	oDialog.dispose
+
+End Sub
+
+Sub RemoveKeyStroke(Event As Object)
+	Select Case Event.KeyCode
+		Case com.sun.star.awt.Key.RETURN
+			RemoveIndexEntry
+		Case com.sun.star.awt.Key.SPACE
+			RemoveIndexEntry
+	End Select
+End Sub
+
+
+Sub RemoveTOCEntry
+	olbTOC = oDialog.GetControl(&quot;lbTOC&quot;)
+	ItemsPos = olbTOC.getSelectedItemsPos
+	For i=0 to ubound(ItemsPos)
+		olbTOC.removeItems(ItemsPos(i)-i,1)
+	Next i
+End Sub
+
+Sub KeyPressedRemove(Event As Object)
+	Select Case Event.KeyCode
+		Case com.sun.star.awt.Key.DELETE
+		RemoveTOCEntry
+	End Select
+End Sub
+
+Sub AddKeyStroke(Event As Object)
+	Select Case Event.KeyCode 
+		Case com.sun.star.awt.Key.RETURN
+			AddTOCEntry
+		Case com.sun.star.awt.Key.SPACE
+			AddTOCEntry
+	End Select
+End Sub
+
+Sub AddTOCEntry
+		oTxtTOC = oDialog.GetControl(&quot;txtTOC&quot;)
+		If (oTxtTOC.Text = &quot;&quot;) Then
+			msgbox &quot;Enter a TOC entry first.&quot;
+		Else
+			&apos; Insert the index entry into the list
+			olbTOC = oDialog.GetControl(&quot;lbTOC&quot;)
+			olbTOC.addItem(oTxtTOC.Text,0)
+		End If
+	
+End Sub
+
+
+</script:module>
\ No newline at end of file

Added: incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/Table.xba
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/Table.xba?rev=1172372&view=auto
==============================================================================
--- incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/Table.xba (added)
+++ incubator/ooo/trunk/main/helpauthoring/HelpAuthoring/Table.xba Sun Sep 18 21:34:39 2011
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
+<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Table" script:language="StarBasic">REM  *****  BASIC  *****
+
+Dim oDialog AS Object
+Dim document AS Object
+
+Sub Main
+	document = StarDesktop.CurrentComponent
+
+	BasicLibraries.LoadLibrary(&quot;HelpAuthoring&quot;)
+	CR
+	CreateTable(2, 2, &quot;tbl_&quot;+CreateID)
+End Sub
+
+
+
+</script:module>
\ No newline at end of file



Mime
View raw message