You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by mb...@apache.org on 2011/09/18 23:34:42 UTC
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/
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">' *** MODULE HELPERS ***
+
+'=======================================================
+' Main
+'-------------------------------------------------------
+' Ensure that necessary library functions are available
+'=======================================================
+Sub Main
+ GlobalScope.BasicLibraries.loadLibrary("Tools")
+End Sub
+
+'=======================================================
+' ShowProp
+'-------------------------------------------------------
+' Displays a dialog that shows the properties and
+' the methods of an object. Used for debugging.
+'=======================================================
+Sub ShowProp(Elem As Object)
+ dim oDialog As Object
+
+ BasicLibraries.LoadLibrary("HelpAuthoring")
+ oDialog = LoadDialog("HelpAuthoring", "dlgObjProp")
+ oDialogModel = oDialog.Model
+
+ oTxtProp = oDialog.GetControl("txtProp")
+ oTxtProp.Text = Join(Split(Elem.dbg_properties,";"),chr(13))
+
+ oTxtMeth = oDialog.GetControl("txtMeth")
+ oTxtMeth.Text = Join(Split(Elem.dbg_methods,";"),chr(13))
+
+ oTxtInt = oDialog.GetControl("txtInt")
+ oTxtInt.Text = Join(Split(Elem.dbg_supportedInterfaces,";"),chr(13))
+
+ oDialog.Execute()
+ oDialog.dispose
+End Sub
+
+'=======================================================
+' AlphaNum
+'-------------------------------------------------------
+' Removes all invalid characters from a string
+'=======================================================
+Function AlphaNum(Strg As String)
+ dim OutStrg As String
+ dim sValid As String
+
+ sValid = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789"
+
+ 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
+
+'=======================================================
+' Replace
+'-------------------------------------------------------
+' Replaces a character with another character in a string
+'=======================================================
+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
+
+
+'=======================================================
+' ReplaceAll
+'-------------------------------------------------------
+' Replaces a character with another character in a string
+'=======================================================
+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
+
+
+
+'=======================================================
+' CreateID
+'-------------------------------------------------------
+' Creates a numerical randomized ID
+'=======================================================
+Function CreateID
+ sDate = ReplaceAll(Date,"/:. \","")
+ sTime = ReplaceAll(Time,"/:. \AMP","")
+ Randomize
+ CreateID = sDate + sTime + Int(Rnd * 100)
+End Function
+
+'=======================================================
+' InsertTag
+'-------------------------------------------------------
+' Inserts an inline tag (element) in the document at the
+' current cursor position. It also sets the character
+' format to hlp_aux_tag
+'=======================================================
+Sub InsertTag (Element As String, Content As String)
+ dim document as object
+ dim dispatcher as object
+
+ document = ThisComponent.CurrentController.Frame
+ dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
+
+ dim args(5) as new com.sun.star.beans.PropertyValue
+ args(0).Name = "Type"
+ args(0).Value = 8
+ args(1).Name = "SubType"
+ args(1).Value = 1
+ args(2).Name = "Name"
+ args(2).Value = Element
+ args(3).Name = "Content"
+ args(3).Value = Content
+ args(4).Name = "Format"
+ args(4).Value = -1
+ args(5).Name = "Separator"
+ args(5).Value = " "
+ SetCharStyle("hlp_aux_tag")
+ dispatcher.executeDispatch(document, ".uno:InsertField", "", 0, args())
+ SetCharStyle("Default")
+End Sub
+
+'=======================================================
+' INSERTTAGCR
+'-------------------------------------------------------
+' Inserts a tag (element) in the document at the
+' current cursor position in its own newly created paragraph.
+' It also sets the character format to hlp_aux_tag and
+' the paragraph to the specified value (should start with hlp_)
+'=======================================================
+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("com.sun.star.frame.DispatchHelper")
+
+ dim args(5) as new com.sun.star.beans.PropertyValue
+ args(0).Name = "Type"
+ args(0).Value = 8
+ args(1).Name = "SubType"
+ args(1).Value = 1
+ args(2).Name = "Name"
+ args(2).Value = Element
+ args(3).Name = "Content"
+ args(3).Value = Content
+ args(4).Name = "Format"
+ args(4).Value = -1
+ args(5).Name = "Separator"
+ args(5).Value = " "
+
+ CR
+ goUp(1)
+ SetParaStyle(Style)
+ SetCharStyle("hlp_aux_tag")
+ dispatcher.executeDispatch(document, ".uno:InsertField", "", 0, args())
+ SetCharStyle("Default")
+ goDown(1)
+End Sub
+
+'=======================================================
+' InsertField
+'-------------------------------------------------------
+' Inserts a field in the document at the
+' current cursor position.
+'=======================================================
+Sub InsertField(Field as String, Content as String)
+ dim document as object
+ dim dispatcher as object
+
+ document = ThisComponent.CurrentController.Frame
+ dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
+
+ dim args(5) as new com.sun.star.beans.PropertyValue
+ args(0).Name = "Type"
+ args(0).Value = 8
+ args(1).Name = "SubType"
+ args(1).Value = 1
+ args(2).Name = "Name"
+ args(2).Value = Field
+ args(3).Name = "Content"
+ args(3).Value = Content
+ args(4).Name = "Format"
+ args(4).Value = -1
+ args(5).Name = "Separator"
+ args(5).Value = " "
+
+ dispatcher.executeDispatch(document, ".uno:InsertField", "", 0, args())
+End Sub
+
+'=======================================================
+' GoUp
+'-------------------------------------------------------
+' Simulates the CursorUp key
+'=======================================================
+Sub goUp(Count As Integer, Optional bSelect As Boolean)
+ dim document as object
+ dim dispatcher as object
+
+ document = ThisComponent.CurrentController.Frame
+ dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
+
+ dim args(1) as new com.sun.star.beans.PropertyValue
+ args(0).Name = "Count"
+ args(0).Value = Count
+ args(1).Name = "Select"
+ If IsMissing(bSelect) Then
+ args(1).Value = false
+ Else
+ args(1).Value = bSelect
+ End If
+
+ dispatcher.executeDispatch(document, ".uno:GoUp", "", 0, args())
+End Sub
+
+'=======================================================
+' GoDown
+'-------------------------------------------------------
+' Simulates the CursorDown key
+'=======================================================
+Sub goDown(Count As Integer, Optional bSelect As Boolean)
+ dim document as object
+ dim dispatcher as object
+
+ document = ThisComponent.CurrentController.Frame
+ dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
+
+ dim args(1) as new com.sun.star.beans.PropertyValue
+ args(0).Name = "Count"
+ args(0).Value = Count
+ args(1).Name = "Select"
+ If IsMissing(bSelect) Then
+ args(1).Value = false
+ Else
+ args(1).Value = bSelect
+ End If
+
+ dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args())
+End Sub
+
+
+'=======================================================
+' GoRight
+'-------------------------------------------------------
+' Simulates the CursorRight key
+'=======================================================
+Sub goRight(Count As Integer, Optional bSelect As Boolean)
+ dim document as object
+ dim dispatcher as object
+
+ document = ThisComponent.CurrentController.Frame
+ dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
+
+ dim args(1) as new com.sun.star.beans.PropertyValue
+ args(0).Name = "Count"
+ args(0).Value = Count
+ args(1).Name = "Select"
+ If IsMissing(bSelect) Then
+ args(1).Value = false
+ Else
+ args(1).Value = bSelect
+ End If
+
+ dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args())
+End Sub
+
+'=======================================================
+' GoLeft
+'-------------------------------------------------------
+' Simulates the CursorLeft key
+'=======================================================
+Sub goLeft(Count As Integer, optional bSelect As boolean)
+ dim document as object
+ dim dispatcher as object
+
+ document = ThisComponent.CurrentController.Frame
+ dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
+
+ dim args(1) as new com.sun.star.beans.PropertyValue
+ args(0).Name = "Count"
+ args(0).Value = Count
+ args(1).Name = "Select"
+ If IsMissing(bSelect) Then
+ args(1).Value = false
+ Else
+ args(1).Value = bSelect
+ End If
+
+ dispatcher.executeDispatch(document, ".uno:GoLeft", "", 0, args())
+End Sub
+
+'=======================================================
+' CR
+'-------------------------------------------------------
+' Inserts a Carriage Return (a new paragraph)
+'=======================================================
+Sub CR
+ dim document as object
+ dim dispatcher as object
+
+ document = ThisComponent.CurrentController.Frame
+ dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
+
+ oSel = thiscomponent.getcurrentcontroller.getselection
+ oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+ oCur.gotoEndOfParagraph(0)
+ thiscomponent.getcurrentcontroller.select(oCur)
+
+ dispatcher.executeDispatch(document, ".uno:InsertPara", "", 0, Array())
+End Sub
+
+'=======================================================
+' CR_before
+'-------------------------------------------------------
+' Inserts a Carriage Return (a new paragraph) before the current para
+'=======================================================
+Sub CR_before
+ dim document as object
+ dim dispatcher as object
+
+ document = ThisComponent.CurrentController.Frame
+ dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
+
+ oSel = thiscomponent.getcurrentcontroller.getselection
+ oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+ oCur.gotoStartOfParagraph(0)
+ thiscomponent.getcurrentcontroller.select(oCur)
+
+ dispatcher.executeDispatch(document, ".uno:InsertPara", "", 0, Array())
+End Sub
+
+'=======================================================
+' LF
+'-------------------------------------------------------
+' Inserts a line feed (manual line break)
+'=======================================================
+sub LF
+ dim document as object
+ dim dispatcher as object
+ document = ThisComponent.CurrentController.Frame
+ dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
+
+ dispatcher.executeDispatch(document, ".uno:InsertLinebreak", "", 0, Array())
+end sub
+
+'=======================================================
+' SetParaStyle
+'-------------------------------------------------------
+' Sets the para style to the given value
+'=======================================================
+Sub SetParaStyle(StyleName As String)
+ dim document as object
+ dim dispatcher as object
+
+ document = ThisComponent.CurrentController.Frame
+ dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
+
+ dim args(1) as new com.sun.star.beans.PropertyValue
+ args(0).Name = "Template"
+ args(0).Value = StyleName
+ args(1).Name = "Family"
+ args(1).Value = 2
+
+ dispatcher.executeDispatch(document, ".uno:StyleApply", "", 0, args())
+end Sub
+
+'=======================================================
+' SetCharStyle
+'-------------------------------------------------------
+' Sets the character style to the given value
+'=======================================================
+Sub SetCharStyle(StyleName As String)
+ dim document as object
+ dim dispatcher as object
+
+ document = ThisComponent.CurrentController.Frame
+ dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
+
+ dim args(1) as new com.sun.star.beans.PropertyValue
+ args(0).Name = "Template"
+ args(0).Value = StyleName
+ args(1).Name = "Family"
+ args(1).Value = 1
+
+ dispatcher.executeDispatch(document, ".uno:StyleApply", "", 0, args())
+end Sub
+
+'=======================================================
+' InsertNewParaData
+'-------------------------------------------------------
+' Inserts a new ID for the paragraph
+'=======================================================
+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 <> "" Then
+ msgbox "Cannot assign paragraph id:"+chr(13)+sMsg,48,"Error"
+ Exit Sub
+ End If
+
+ If sID <> "" Then
+ msgbox "Paragraph already has an ID."+chr(13)+"If you want to assign a new ID delete the existing one first.",48,"Error"
+ Exit Sub
+ End If
+
+ oCur.gotoStartOfParagraph(0)
+
+ If (Left(oCur.ParaStyleName,8) = "hlp_head") Then
+ id = "hd_id" + CreateID
+ thiscomponent.getcurrentcontroller.select(oCur)
+ MetaData = id
+ SetCharStyle("hlp_aux_parachanged")
+ InsertField("ID",MetaData)
+ SetCharStyle("Default")
+ Else
+ id = "par_id" + CreateID
+ thiscomponent.getcurrentcontroller.select(oCur)
+ MetaData = id
+ SetCharStyle("hlp_aux_parachanged")
+ InsertField("ID",MetaData)
+ SetCharStyle("Default")
+ End If
+
+
+End Sub
+
+'=======================================================
+' LoadDialog
+'-------------------------------------------------------
+' Loads a BASIC dialog
+'=======================================================
+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
+
+'=======================================================
+' Surprise
+'-------------------------------------------------------
+' D'oh
+'=======================================================
+Sub Surprise
+ msgbox "This function is unsupported."+chr(13)+"If you know how to implement this -- go ahead!",0,"D'oh!"
+End Sub
+
+'=======================================================
+' InsertNote
+'-------------------------------------------------------
+' Inserts a note (annotation) at the current position
+'=======================================================
+sub InsertNote(Content As String)
+ dim document as object
+ dim dispatcher as object
+
+ document = ThisComponent.CurrentController.Frame
+ dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
+
+ dim args(2) as new com.sun.star.beans.PropertyValue
+ args(0).Name = "Text"
+ args(0).Value = Content
+ args(1).Name = "Author"
+ args(1).Value = "Help Tooling - DO NOT EDIT"
+ args(2).Name = "Date"
+ args(2).Value = "02/27/2004"
+
+ dispatcher.executeDispatch(document, ".uno:InsertAnnotation", "", 0, args())
+end sub
+
+'=======================================================
+' InsertText
+'-------------------------------------------------------
+' Inserts a string at the current position
+'=======================================================
+Sub InsertText(strg As String)
+ oSel = thiscomponent.getcurrentcontroller.getselection
+ oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+ oCur.String = strg
+End Sub
+
+'=======================================================
+' ParaIsEmpty
+'-------------------------------------------------------
+' Evaluates if a paragraph is empty.
+'=======================================================
+Function ParaIsEmpty
+ oSel = thiscomponent.getcurrentcontroller.getselection
+ oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+ oCur.gotoStartOfParagraph(0)
+ ParaIsEmpty = oCur.IsEndOfParagraph
+End Function
+
+'=======================================================
+' IsInBookmark
+'-------------------------------------------------------
+' Evaluates if the cursor is inside a <bookmark> </bookmark> element
+'=======================================================
+Function IsInBookmark
+ oSel = thiscomponent.getcurrentcontroller.getselection
+ oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+
+ If ((oCur.ParaStyleName = "hlp_aux_bookmark") AND (not(oCur.IsEndOfParagraph))) Then
+ oCur.GotoStartOfParagraph(0)
+ oCur.GotoEndOfParagraph(1)
+ sText = Left(oCur.GetString,Instr(oCur.GetString,""" id=""")-1)
+ sText = Right(sText,Len(sText)-InStr(sText,""""))
+ Select Case Left(sText,3)
+ Case "ind"
+ IsInBookmark = 1
+ Case "hid"
+ IsInBookmark = 2
+ Case "con"
+ IsInBookmark = 3
+ Case Else
+ IsInBookmark = 0
+ End Select
+ Else
+ IsInBookmark = 0
+ End If
+End Function
+
+'=======================================================
+' IsInTable
+'-------------------------------------------------------
+' Evaluates if the cursor is in a table
+'=======================================================
+Function IsInTable
+ oSel = thiscomponent.getcurrentcontroller.getselection
+ oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+
+ IsInTable = (VarType(oCur.TextTable) <> 0)
+End Function
+
+'=======================================================
+' InsertLink
+'-------------------------------------------------------
+' Inserts a hyperlink at the current position
+'=======================================================
+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("com.sun.star.frame.DispatchHelper")
+
+ dim args(4) as new com.sun.star.beans.PropertyValue
+ args(0).Name = "Hyperlink.Text"
+ args(0).Value = sText
+ args(1).Name = "Hyperlink.URL"
+ args(1).Value = sPath
+ args(2).Name = "Hyperlink.Target"
+ args(2).Value = ""
+ args(3).Name = "Hyperlink.Name"
+ args(3).Value = sName
+ args(4).Name = "Hyperlink.Type"
+ args(4).Value = 1
+
+ dispatcher.executeDispatch(document, ".uno:SetHyperlink", "", 0, args())
+ args(0).Name = "Count"
+ args(0).Value = 1
+ args(1).Name = "Select"
+ args(1).Value = false
+
+ dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args())
+
+End Sub
+
+'=======================================================
+' AssignMissingIDs
+'-------------------------------------------------------
+' Assigns IDs to elements that miss them
+'=======================================================
+Sub AssignMissingIDs
+' NOT IMPLEMENTED YET
+end sub
+
+'=======================================================
+' CreateTable
+'-------------------------------------------------------
+' Creates a new table
+'=======================================================
+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("com.sun.star.frame.DispatchHelper")
+
+ dim args1(3) as new com.sun.star.beans.PropertyValue
+ args1(0).Name = "TableName"
+ args1(0).Value = sID
+ args1(1).Name = "Columns"
+ args1(1).Value = nCols
+ args1(2).Name = "Rows"
+ args1(2).Value = nRows
+ args1(3).Name = "Flags"
+ args1(3).Value = 9
+
+ dispatcher.executeDispatch(document, ".uno:InsertTable", "", 0, args1())
+
+ args1(0).Name = "TopBottomMargin.TopMargin"
+ args1(0).Value = 500
+ args1(1).Name = "TopBottomMargin.BottomMargin"
+ args1(1).Value = 0
+ args1(2).Name = "TopBottomMargin.TopRelMargin"
+ args1(2).Value = 100
+ args1(3).Name = "TopBottomMargin.BottomRelMargin"
+ args1(3).Value = 100
+
+ dispatcher.executeDispatch(document, ".uno:TopBottomMargin", "", 0, args1())
+ dispatcher.executeDispatch(document, ".uno:SelectAll", "", 0, Array())
+ SetParaStyle("hlp_tablecontent")
+ GoDown(1)
+end Sub
+
+'=======================================================
+' IsBlockImage
+'-------------------------------------------------------
+' Evaluates if the cursor is in a paragraph with
+' a block image (image in its own paragraph)
+'=======================================================
+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," ")) 'string must start with <IMG and end with IMG with no <IMG in between
+ IsBlockImage = (not(Left(sStr,4)="IMG>") AND (Right(sStr,6)="</IMG>"))
+End Function
+
+'=======================================================
+' HasCaption
+'-------------------------------------------------------
+' Evaluates if the current image has a caption element
+'=======================================================
+Function HasCaption
+ oSel = thiscomponent.getcurrentcontroller.getselection
+ If oSel.ImplementationName = "SwXTextGraphicObject" 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,"<IMGCAPTION")>0)
+End Function
+
+'=======================================================
+' GetImageID
+'-------------------------------------------------------
+' Returns the ID of an image at the cursor position
+'=======================================================
+Function GetImageID
+ oSel = thiscomponent.getcurrentcontroller.getselection
+ If oSel.ImplementationName = "SwXTextGraphicObject" 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,"IMG ID=""")+7))
+ GetImageID = Left(sStr,InStr(sStr,""">")+1) 'string must start with <IMG and end with IMG with no <IMG in between
+End Function
+
+'=======================================================
+' SelAll
+'-------------------------------------------------------
+' Selects everything
+'=======================================================
+Sub SelAll
+ dim document as object
+ dim dispatcher as object
+
+ document = ThisComponent.CurrentController.Frame
+ dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
+
+ dispatcher.executeDispatch(document, ".uno:SelectAll", "", 0, Array())
+End Sub
+
+'=======================================================
+' GetParaData
+'-------------------------------------------------------
+' Returns the Paragraph ID and localization status
+'=======================================================
+Function GetParaData
+ arParaData = Array("","","") ' ID, localize, #message
+
+ oSel = thiscomponent.getcurrentcontroller.getselection
+ oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+ oCur.gotoStartOfParagraph(0)
+ oCur.gotoEndOfParagraph(1)
+ sID = ""
+ 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="TextField" Then
+ If TPE.TextField.TextFieldMaster.Name="ID" Then
+ sID = TPE.TextField.Content
+ Fd = TRUE
+ Exit Do
+ End If
+ End If
+ If TPE.String = "" Then
+ Ct = Ct-1
+ End If
+ Loop
+
+ If ((Left(oCur.ParaStyleName,8) = "hlp_aux_") or (Left(oCur.ParaStyleName,4) <> "hlp_")) Then
+ arParaData(2)="Invalid Paragraph Style"
+ GetParaData = arParaData
+ Exit Function
+ End If
+
+ If sID = "" Then
+ GetParaData = arParaData
+ Exit Function
+ End If
+
+ If Right(sID,7) = "_NOL10N" Then
+ arParaData(0) = Left(sID,Len(sID)-7)
+ arParaData(1) = "no"
+ Else
+ arParaData(0) = sID
+ arParaData(1) = "yes"
+ End If
+
+ GetParaData = arParaData
+End Function
+
+'=======================================================
+' SetsParaData
+'-------------------------------------------------------
+' Sets the Paragraph ID and localization status
+'=======================================================
+
+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="TextField" Then
+ If TPE.TextField.TextFieldMaster.Name="ID" Then
+ posID = Ct
+ If sLocalize = "no" Then
+ TPE.TextField.Content = sID+"_NOL10N"
+ TPE.TextField.IsVisible = TRUE
+ ElseIf sLocalize = "yes" Then
+ TPE.TextField.Content = sID
+ TPE.TextField.IsVisible = TRUE
+ Else
+ msgbox "Unknown localization parameter: "+sLocalize,0,"Error"
+ End If
+ Fd = TRUE
+ Exit Do
+ End If
+ End If
+ If TPE.String = "" Then
+ Ct = Ct-1
+ End If
+ Loop
+ If Fd Then
+ Exit Do
+ End If
+ Loop
+
+ oCur.TextField.update
+ UpdateFields
+
+End Sub
+
+
+'=======================================================
+' IsInList
+'-------------------------------------------------------
+' Evaluates if the cursor is inside a list (ordered or unordered)
+'=======================================================
+Function IsInList
+ oSel = thiscomponent.getcurrentcontroller.getselection
+ oCur = oSel(0).getText.createTextCursorByRange(oSel(0))
+ If oCur.NumberingStyleName = "" Then
+ IsInList = false
+ ElseIf oCur.NumberingRules.NumberingIsOutline = true Then
+ IsInList = false
+ Else
+ IsInList = true
+ End If
+End Function
+
+'=======================================================
+' TagFormatIsCorrect
+'-------------------------------------------------------
+' Checks for correct paragraph format for tags
+'=======================================================
+Function TagFormatIsCorrect(sTN As String, sPS As String)
+
+ arTag = Array("BOOKMARK","SORT","SECTION","SWITCH","CASE","DEFAULT")
+ arTagFormat = Array("hlp_aux_bookmark","hlp_aux_sort","hlp_aux_section","hlp_aux_switch","hlp_aux_switch","hlp_aux_switch")
+
+ For n=0 to ubound(arTag)
+ If (sTN = arTag(n) AND sPS <> arTagFormat(n)) Then
+ TagFormatIsCorrect = arTagFormat(n)
+ Exit Function
+ End If
+ TagFormatIsCorrect = ""
+ Next n
+
+End Function
+
+'=======================================================
+' GetFilePath
+'-------------------------------------------------------
+' look for the "text/..." part of the file name and separate it
+'=======================================================
+Function GetFilePath(fname As String)
+
+ i = 1
+ Do
+ If (Mid(fname,i,5) = "text/") Then
+ Strg = Mid(fname,i,Len(fname)-i+1)
+ Exit Do
+ Else
+ i = i+1
+ Strg = fname
+ End If
+ Loop While (i+5 < Len(fname))
+ GetFilePath = Strg
+End Function
+
+'=======================================================
+' OpenGraphics
+'-------------------------------------------------------
+' Calls the graphic open dialog for inserting an image
+'=======================================================
+Function OpenGraphics(oDoc As Object)
+Dim ListAny(0) as Long
+Dim oStoreProperties(0) as New com.sun.star.beans.PropertyValue
+ GlobalScope.BasicLibraries.loadLibrary("Tools")
+ ListAny(0) = com.sun.star.ui.dialogs.TemplateDescription.FILEOPEN_SIMPLE
+' ListAny(0) = com.sun.star.ui.dialogs.TemplateDescription.FILEOPEN_LINK_PREVIEW_IMAGE_TEMPLATE
+ oFileDialog = CreateUnoService("com.sun.star.ui.dialogs.FilePicker")
+ oFileDialog.Initialize(ListAny())
+
+ sLastImgDir = ReadConfig("LastImgDir")
+ If sLastImgDir <> "" Then
+ oFileDialog.setDisplayDirectory(sLastImgDir)
+ End If
+
+ oMasterKey = GetRegistryKeyContent("org.openoffice.TypeDetection.Types/")
+ oTypes() = oMasterKey.Types
+
+ oFileDialog.AppendFilter(oTypes.GetByName("gif_Graphics_Interchange").UIName, "*.gif")
+ oFileDialog.AppendFilter(oTypes.GetByName("png_Portable_Network_Graphic").UIName, "*.png")
+
+ oFileDialog.SetTitle("Insert Image")
+ iAccept = oFileDialog.Execute()
+ If iAccept = 1 Then
+ sPath = oFileDialog.Files(0)
+ WriteConfig("LastImgDir",oFileDialog.getDisplayDirectory)
+ UIFilterName = oFileDialog.GetCurrentFilter()
+ OpenGraphics = oFileDialog.Files(0)
+ Else
+ OpenGraphics = ""
+ End If
+ oFileDialog.Dispose()
+End Function
+
+'=======================================================
+' WriteConfig
+'-------------------------------------------------------
+' Reads a parameter value from the config file
+'=======================================================
+Function ReadConfig(Parm As String)
+ oPath = createUNOService("com.sun.star.util.PathSettings")
+ filename = oPath.UserConfig+"/helpauthoring.cfg"
+ 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, "=") > 0 Then
+ arLine = split(sLine,"=")
+ If arLine(0) = Parm Then
+ sResult = arLine(1)
+ bFound = true
+ End If
+ End If
+ Loop
+ Close #iNumber
+ If bFound Then
+ ReadConfig = sResult
+ Else
+ ReadConfig = ""
+ End If
+ Else
+ ReadConfig = ""
+ End If
+End Function
+
+
+'=======================================================
+' WriteConfig
+'-------------------------------------------------------
+' Writes a parameter/value pair to the config file
+'=======================================================
+Function WriteConfig(Parm As String, Value As String)
+ Dim arLines(0) As String
+ bFound = false
+ oPath = createUNOService("com.sun.star.util.PathSettings")
+ filename = oPath.UserConfig+"/helpauthoring.cfg"
+ iNumber = Freefile
+ If FileExists(filename) Then
+
+ Open filename For Input As iNumber
+ Do While (not eof(iNumber))
+ Line Input #iNumber, sLine
+ If InStr(sLine, "=") > 0 Then
+ sDim = ubound(arLines())+1
+ ReDim Preserve arLines(sDim)
+ arLines(sDim) = sLine
+ End If
+ Loop
+ Close #iNumber
+
+ nLine = 1
+ Do While (nLine <= ubound(arLines())) and (not bFound)
+ arLine = split(arLines(nLine),"=")
+ If arLine(0) = Parm Then
+ arLines(nLine) = Parm+"="+Value
+ bFound = true
+ End If
+ nLine = nLine +1
+ Loop
+
+ nLine = 1
+ Open filename For Output As iNumber
+ Do While (nLine <= ubound(arLines()))
+ Print #iNumber, arLines(nLine)
+ nLine = nLine + 1
+ Loop
+ If (not bFound) Then
+ Print #iNumber, Parm+"="+Value
+ End If
+ Close #iNumber
+
+ Else
+ Open filename For Output As iNumber
+ Print #iNumber, Parm+"="+Value
+ Close #iNumber
+ End If
+End Function
+
+Function GetRelPath(sPath As String)
+ sHelpPrefix = ReadConfig("HelpPrefix")
+ If sHelpPrefix = "" Then
+ sHelpPrefix = SetDocumentRoot
+ End If
+ GetRelPath = Right(sPath, Len(sPath)-(InStr(sPath,sHelpPrefix) + Len(sHelpPrefix)-1))
+End Function
+
+Function SetDocumentRoot
+ sHelpPrefix = ReadConfig("HelpPrefix")
+ oFolderDialog = CreateUnoService("com.sun.star.ui.dialogs.FolderPicker")
+ oFolderDialog.SetTitle("Select Document Root Folder")
+ If sHelpPrefix > "" Then
+ oFolderDialog.setDisplayDirectory(sHelpPrefix)
+ End If
+ iAccept = oFolderDialog.Execute()
+
+ If iAccept = 1 Then
+ sHelpPrefix = oFolderDialog.getDirectory + "/"
+ WriteConfig("HelpPrefix",sHelpPrefix)
+ End If
+
+ SetDocumentRoot = sHelpPrefix
+End Function
+
+Function MakeAbsPath(sPath As String)
+
+ sHelpPrefix = ReadConfig("HelpPrefix")
+ If sHelpPrefix = "" Then
+ sHelpPrefix = SetDocumentRoot
+ End If
+
+ If Right(sPath,4) <> ".xhp" Then
+ sPath=sPath+".xhp"
+ End If
+ MakeAbsPath = sHelpPrefix+sPath
+End Function
+
+
+Sub UpdateFields
+ dim document as object
+ dim dispatcher as object
+ document = ThisComponent.CurrentController.Frame
+ dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
+
+ dispatcher.executeDispatch(document, ".uno:UpdateFields", "", 0, Array())
+End Sub
+
+Function IsHelpFile
+ document = StarDesktop.CurrentComponent
+ IsHelpFile = (Right(GetFilePath(document.URL),4)=".xhp")
+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("HelpAuthoring")
+ oDialog = LoadDialog("HelpAuthoring", "dlgIND")
+ ocbAddTag = oDialog.GetControl("cbAddTag")
+
+ ' Check if bookmarks are allowed here
+ If IsInList Then
+ msgbox "No Bookmarks allowed inside a list.", 48, "D'oh!"
+ Exit Sub
+ End If
+
+
+ nBookmarkType = IsInBookmark
+ If nBookmarkType = 1 Then ' inside INDEX bookmark
+ ocbAddTag.State = 0
+ End If
+
+ oDialogModel = oDialog.Model
+
+ If oDialog.Execute() = 1 Then
+ ' Insert the bookmark construction
+ olbIND = oDialog.GetControl("lbIND")
+
+ If nBookmarkType = 0 Then' not in a bookmark, always add parent tags
+ bmid = CreateID
+ ' now check if we are in a para with text (this wouldn't be valid)
+ If Not(ParaIsEmpty) Then
+ CR
+ End If
+ InsertTag("BOOKMARK_","<BOOKMARK branch=""index"" id=""bm_id" + bmid + """>","hlp_aux_bookmark")
+
+ For i=0 to ubound(olbIND.Items)
+ LF
+ InsertTag("BOOKMARKVALUE_","<BOOKMARKVALUE>")
+ InsertField("BOOKMARKVALUE",olbIND.Items(i))
+ InsertTag("_BOOKMARKVALUE","</BOOKMARKVALUE>")
+ Next i
+ LF
+ InsertTagCR("_BOOKMARK","</BOOKMARK>","hlp_aux_bookmark")
+
+ ElseIf nBookmarkType = 1 Then ' in a correct bookmark type
+ If ocbAddTag.State = 1 Then
+ If Not(ParaIsEmpty) Then
+ CR
+ End If
+ InsertTag("BOOKMARK_","<BOOKMARK branch=""index"" id=""bm_id" + bmid + """>","hlp_aux_bookmark")
+ For i=0 to ubound(olbIND.Items)
+ LF
+ InsertTag("BOOKMARKVALUE_","<BOOKMARKVALUE>")
+ InsertField("BOOKMARKVALUE",olbIND.Items(i))
+ InsertTag("_BOOKMARKVALUE","</BOOKMARKVALUE>")
+ Next i
+ If ocbAddTag.State = 1 Then
+ LF
+ InsertTagCR("_BOOKMARK","</BOOKMARK>","hlp_aux_bookmark")
+ End If
+ Else
+ For i=0 to ubound(olbIND.Items)
+ LF
+ InsertTag("BOOKMARKVALUE_","<BOOKMARKVALUE>")
+ InsertField("BOOKMARKVALUE",olbIND.Items(i))
+ InsertTag("_BOOKMARKVALUE","</BOOKMARKVALUE>")
+ Next i
+ End If
+ Else ' in a wrong bookmark type
+ If Not(ParaIsEmpty) Then
+ CR
+ End If
+ InsertTag("BOOKMARK_","<BOOKMARK branch=""index"" id=""bm_id" + bmid + """>","hlp_aux_bookmark")
+ For i=0 to ubound(olbIND.Items)
+ LF
+ InsertTag("BOOKMARKVALUE_","<BOOKMARKVALUE>")
+ InsertField("BOOKMARKVALUE",olbIND.Items(i))
+ InsertTag("_BOOKMARKVALUE","</BOOKMARKVALUE>")
+ Next i
+ LF
+ InsertTagCR("_BOOKMARK","</BOOKMARK>","hlp_aux_bookmark")
+ 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("txtLevel1")
+ oTxtLevel2 = oDialog.GetControl("txtLevel2")
+
+ If oTxtLevel2.Text <> "" Then
+ IndexEntry = oTxtLevel1.Text + ";" + oTxtLevel2.Text
+ Else
+ IndexEntry = oTxtLevel1.Text
+ End If
+
+ If ((oTxtLevel1.Text = "") OR (IndexEntry = "<Level 1>;<Level 2>")) Then
+ msgbox "Enter an index entry first."
+ Else
+ ' Insert the index entry into the list
+ olbIND = oDialog.GetControl("lbIND")
+ 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("lbIND")
+ 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("HelpAuthoring")
+ GlobalScope.BasicLibraries.loadLibrary("Tools")
+ Dim ListAny(0) as Long
+
+ DocRoot = ReadConfig("HelpPrefix")
+ sLastLinkDir = ReadConfig("LastLinkDir")
+ sLastLinkFile = ReadConfig("LastLinkFile")
+
+ ListAny(0) = com.sun.star.ui.dialogs.TemplateDescription.FILEOPEN_SIMPLE
+ oFileDialog = CreateUnoService("com.sun.star.ui.dialogs.FilePicker")
+ oFileDialog.Initialize(ListAny())
+
+
+ If IsSubDir(sLastLinkDir,DocRoot) Then
+ oFileDialog.setDisplayDirectory(sLastLinkDir)
+ If sLastLinkFile <> "" AND Dir(sLastLinkDir+sLastLinkFile) > "" Then
+ oFileDialog.setDefaultName(sLastLinkFile)
+ End If
+ Else
+ oFileDialog.setDisplayDirectory(DocRoot)
+ End If
+
+ oMasterKey = GetRegistryKeyContent("org.openoffice.TypeDetection.Types/")
+ oTypes() = oMasterKey.Types
+ oFileDialog.AppendFilter("Help", "*.xhp")
+
+ oFileDialog.SetTitle("Link to Help File")
+ iAccept = oFileDialog.Execute()
+
+ If iAccept = 1 Then
+ sPath = oFileDialog.Files(0)
+ sCurDir = oFileDialog.getDisplayDirectory +"/"
+ WriteConfig("LastLinkDir",sCurDir)
+ LastFile = Right(sPath, Len(sPath) - Len(sCurDir))
+ WriteConfig("LastLinkFile",LastFile)
+
+ If IsSubDir(sCurDir,DocRoot) Then
+ RelPath = GetRelPath(sPath, DocRoot)
+ Else
+ RelPath = sPath
+ msgbox("File is outside of your Document Root",48,"Warning")
+ 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("LINK_","<LINK href=""" + RelPath + """>","hlp_aux_tag")
+
+ thiscomponent.getcurrentcontroller.select(oCurEnd)
+ InsertTag("_LINK","</LINK>","hlp_aux_tag")
+
+ SetCharStyle("Default")
+
+ 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
+
+' 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("HelpAuthoring")
+ oDialog = LoadDialog("HelpAuthoring", "dlgMeta")
+ oDialogModel = oDialog.Model
+
+ 'oTxtFName = oDialog.GetControl("txtFileName")
+ 'oTxtFName.Text = document.DocumentInfo.PropertyValues(29).Value
+ 'oTxtFName.Text = document.DocumentInfo.GetPropertyValue("Description")
+
+' If oTxtFName.Text = "" Then
+' msgbox "The document must be saved first."+chr(13)+"Please save the document and call this dialog again."
+' oDialog.dispose
+' Exit Sub
+' End If
+
+ oTxtTitle = oDialog.GetControl("txtTitle")
+ oTxtTitle.Text = document.DocumentInfo.Title
+
+ oOpIndInc = oDialog.GetControl("opIndexInclude")
+ oOpIndExc = oDialog.GetControl("opIndexExclude")
+
+
+ 'oCbFileStatus = oDialog.GetControl("cbFileStatus")
+ 'arItems = Array("DRAFT","FINAL","PUBLISH","STALLED","DEPRECATED")
+ 'oCbFileStatus.AddItems(arItems,ubound(arItems))
+ 'sStatus = document.DocumentInfo.GetPropertyValue("Keywords")
+ 'If (InStr("DRAFT FINAL PUBLISH STALLED DEPRECATED",sStatus)=0) Then
+ ' oCbFileStatus.SetText("DRAFT")
+ 'Else
+ ' oCbFileStatus.SetText(sStatus)
+ 'End If
+
+
+ If document.DocumentInfo.GetUserFieldValue(GetUserFieldNumber("Indexer")) = "exclude" then
+ oOpIndExc.State = True
+ Else
+ oOpIndInc.State = True
+ End If
+
+ 'oTxtTopicID = oDialog.GetControl("txtTopicID")
+ 'oTxtTopicID.Text = document.DocumentInfo.GetUserFieldValue(1)
+
+ 'oTxtComment = oDialog.GetControl("txtComment")
+ 'oTxtComment.Text = document.DocumentInfo.GetUserFieldValue(GetUserFieldNumber("Comment"))
+
+ 'oTxtEdited = oDialog.GetControl("txtLastEdited")
+ 'oTxtEdited.Text = document.DocumentInfo.GetUserFieldValue(3)
+
+ If oDialog.Execute() = 1 Then ' update the meta data
+ document.DocumentInfo.Title = oTxtTitle.Text
+ 'document.DocumentInfo.SetUserFieldValue(1,oTxtTopicID.Text)
+ 'document.DocumentInfo.SetUserFieldValue(GetUserFieldNumber("Comment"),oTxtComment.Text)
+ 'document.DocumentInfo.SetUserFieldValue(3,oTxtEdited.Text)
+ 'document.DocumentInfo.SetPropertyValue("Keywords",oCbFileStatus.Text)
+
+ 'If (oCbFileStatus.Text = "PUBLISH") Then
+ REM... Check for paras without ID: If there are any, this cannot be PUBLISH!
+
+ 'End If
+
+ If oOpIndExc.State = True Then
+ document.DocumentInfo.SetUserFieldValue(GetUserFieldNumber("Indexer"),"exclude")
+ Else
+ document.DocumentInfo.SetUserFieldValue(GetUserFieldNumber("Indexer"),"include")
+ End If
+ End If
+ oDialog.dispose
+end sub
+
+' Normalizes the values for title and topic id
+' (if the fields are empty or contain invalid values)
+Sub NormalizeMeta (Event As Object)
+ Select Case Event.Source.Model.Name
+ Case "txtTitle":
+ If Event.Source.Text = "" Then
+ msgbox "Topic title must not be empty!"+chr(13)+"Resetting to default value."
+ End If
+ SetTopicTitle(Event.Source.Text)
+ Case "txtTopicID":
+ If Event.Source.Text = "" Then
+ msgbox "Topic ID must not be empty!"+chr(13)+"Resetting to default value."
+ End If
+ SetTopicID(Event.Source.Text)
+ End Select
+End Sub
+
+' Sets the value in the Topic ID dialog field
+Sub SetTopicID(txt As String)
+ oTxtTopicID = oDialog.GetControl("txtTopicID")
+ If txt = "" 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
+' showprop document
+ msgbox document.URL
+
+End Sub
+
+' Sets the value in the Topic title dialog field
+Sub SetTopicTitle(txt As String)
+ dim strg As String
+ oTxtTitle = oDialog.GetControl("txtTitle")
+
+ If txt ="" Then
+ Enum = document.Text.createEnumeration
+
+ Do While Enum.hasMoreElements
+ TextElement = Enum.nextElement
+ If TextElement.supportsService("com.sun.star.text.Paragraph") Then
+ If Left(TextElement.ParaStyleName,8)="hlp_head" Then
+ Enum2 = TextElement.createEnumeration
+ While Enum2.hasMoreElements
+ TextPortion = Enum2.nextElement
+ If Not(TextPortion.TextPortionType="TextField") 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
+
+' Sets the value in the Topic title field when
+' "Fetch" button is pressed
+Sub FetchTopicTitle
+ SetTopicTitle("")
+
+End Sub
+
+' Sets the value in the Topic ID dialog field when
+' "Suggest" button is pressed
+Sub SuggestTopicID
+ SetTopicID("")
+End Sub
+
+Sub ChangeStatus
+ oCbFileStatus = oDialog.GetControl("cbFileStatus")
+ sStatus = document.DocumentInfo.GetPropertyValue("Keywords")
+ If (oCbFileStatus.Text = "PUBLISH") Then
+ nNoID = 0 ' DEBUG
+ If nNoID <> 0 Then
+ msgbox "There are "+nNoID+" new paragraphs in the file."+chr(13)+"File status PUBLISH invalid."+chr(13)+"Setting back to "+sStatus, 48, "D'oh!"
+ 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("Enter an identifier for the variable element:","Enter Variable ID")
+
+ If ID="" Then
+ Exit Sub
+ End If
+
+ thiscomponent.getcurrentcontroller.select(oCurStart)
+ InsertTag("VAR_","<VAR ID="""+ID+""">")
+ thiscomponent.getcurrentcontroller.select(oCurEnd)
+ InsertTag("_VAR","</VAR>")
+End Sub
+
+Sub InsertInlineGraphic
+ If not IsHelpFile Then
+ msgbox(strErr_NoHelpFile)
+ Exit Sub
+ End If
+ sFName = OpenGraphics
+ If sFName <> "" Then
+ sAlt = InputBox("Enter an alternative Text for the graphical element."+chr(13)+"This can be changed later in the image properties.","ALT description","<ALT DESCRIPTION>")
+ sID = "img_id"+CreateID
+ InsertTag("IMG_","<IMG ID="""+sID+""">")
+ InsertGraphicFile(sFName,sID,sAlt)
+ InsertTag("_IMG","</IMG>")
+ End If
+End Sub
+
+Sub InsertGraphic
+
+ If not IsHelpFile Then
+ msgbox(strErr_NoHelpFile)
+ Exit Sub
+ End If
+
+ GlobalScope.BasicLibraries.loadLibrary("Tools")
+ sFName = OpenGraphics
+ If sFName <> "" Then
+ DocRoot = ReadConfig("HelpPrefix")
+' msgbox("DocRoot "+DocRoot+chr(13)+"FName "+sFName)
+
+ If not(IsSubDir(sFName,DocRoot)) Then
+ msgbox("Image is located outside of your Document Root"+chr(13)+DocRoot,48,"Warning")
+ End If
+
+ sAlt = InputBox("Enter an alternative Text for the graphical element."+chr(13)+"This can be changed later in the image properties.","ALT description","<ALT DESCRIPTION>")
+' sCap = InputBox("Enter a caption for the image (optional)","Caption","")
+ sID = CreateID
+ CR
+ InsertTag("IMG_","<IMG ID="""+"img_id"+sID+""">")
+ InsertGraphicFile(sFName,"img_id"+sID,sAlt)
+' If sCap <> "" Then
+' InsertCaption(sCap,"cap_id"+sID)
+' End If
+ InsertTag("_IMG","</IMG>")
+ 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("com.sun.star.text.GraphicObject")
+ oGrp.GraphicURL = sURL
+ oGrp.AnchorType = 1
+ oGrp.Name = sName
+ oGrp.Title = sAlt
+ oCur.Text.InsertTextContent(oCur,oGrp,true)
+End Sub
+
+Sub SpecifyCaption
+ 'check if the image allows captions
+ If thiscomponent.getcurrentcontroller.getselection.ImplementationName = "SwXTextGraphicObject" Then
+ msgbox "Please press ESCAPE to deselect the image and recall the menu item"
+ Exit Sub
+ End If
+ If IsBlockImage Then
+ If not(HasCaption) Then
+ sCap = InputBox("Enter a caption for the image (optional)","Caption","")
+ If sCap <> "" Then
+ sID = GetImageID
+ sID = "cap"+right(sID, Len(sID)-3)
+ GoLeft(1)
+ InsertCaption(sCap, sID)
+ End If
+ Else
+ msgbox "Image has a caption already.",0,"D'oh!"
+ End If
+ Else
+ msgbox "Only block images may have captions.",0,"D'oh!"
+ End If
+End Sub
+
+Sub InsertCaption(sCap As String, sID as String)
+ InsertTag("IMGCAPTION_","<IMGCAPTION id="""+sID+""">")
+ InsertText(sCap)
+ InsertTag("_IMGCAPTION","</IMGCAPTION>")
+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 ("Create a hidden tip?",3+32,"Extended Tip")
+
+ If Ret=2 or Ret=3 Then
+ Exit Sub
+ End If
+
+ thiscomponent.getcurrentcontroller.select(oCurStart)
+ If Ret=6 Then
+ InsertTag("AHID_","<AHID hid="""+ID+""">")
+ ElseIf Ret=7 Then
+ InsertTag("AVIS_","<AVIS hid="""+ID+""">")
+ End If
+ thiscomponent.getcurrentcontroller.select(oCurEnd)
+ If Ret=6 Then
+ InsertTag("_AHID","</AHID>")
+ ElseIf Ret=7 Then
+ InsertTag("_AVIS","</AVIS>")
+ End If
+End Sub
+
+Sub InsertSort
+ CR
+ SetParaStyle("hlp_aux_sort")
+ InsertTag("SORT_","<SORT order=""asc"">","hlp_aux_sort")
+ GoLeft(1)
+ GoDown(1)
+ msgbox "Remember to also specify the closing SORT tag!",48,"Don't forget to close the tag"
+End Sub
+
+Sub CloseSort
+ CR
+ SetParaStyle("hlp_aux_sort")
+ InsertTag("_SORT","</SORT>","hlp_aux_sort")
+ 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("Please specify a section name/identifier:"))
+
+ If sSectionName = "" Then
+ Exit Sub
+ End If
+
+ If sSectionName = "" Then
+ msgbox "No (valid) identifier -- no section."+chr(13)+"Hint: Use only A-Z,a-z,0-9 and _",48,"D'oh!"
+ Exit Sub
+ End If
+
+ document = ThisComponent.CurrentController.Frame
+ dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
+
+ dim args(6) as new com.sun.star.beans.PropertyValue
+ args(0).Name = "RegionName"
+ args(0).Value = sSectionName
+ args(1).Name = "RegionCondition"
+ args(1).Value = ""
+ args(2).Name = "RegionHidden"
+ args(2).Value = false
+ args(3).Name = "RegionProtect"
+ args(3).Value = false
+ args(4).Name = "LinkName"
+ args(4).Value = ""
+ args(5).Name = "FilterName"
+ args(5).Value = ""
+ args(6).Name = "SubRegion"
+ args(6).Value = ""
+
+ dispatcher.executeDispatch(document, ".uno:InsertSection", "", 0, args())
+
+ If oCur.GetString <> "" Then
+ thiscomponent.getcurrentcontroller.select(oCurStart)
+ CR_before
+ GoUp(1)
+ InsertTag("SECTION_","<SECTION id="""+sSectionName+""">")
+ SetParaStyle("hlp_aux_section")
+
+ thiscomponent.getcurrentcontroller.select(oCurEnd)
+ CR
+ SetParaStyle("hlp_aux_section")
+ InsertTag("_SECTION","</SECTION>")
+ Else
+ GoUp(1)
+ InsertTagCR("SECTION_","<SECTION id="""+sSectionName+""">","hlp_aux_section")
+ CR
+ SetParaStyle("hlp_aux_section")
+ InsertTag("_SECTION","</SECTION>")
+ GoUp(1)
+ SetParaStyle("hlp_default")
+ 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 <> "" Then
+ msgbox "Error in paragraph status:"+chr(13)+sMsg,48,"Error"
+ Exit Sub
+ End If
+
+
+ If (sID = "") Then
+ msgbox "Paragraph has no ID. Assigning ID.",48,"Info"
+ InsertNewParaData
+ thiscomponent.getcurrentcontroller.select(oSel(0))
+ arParaData = GetParaData
+ sID = arParaData(0)
+ slocalize = arParaData(1)
+ sMsg = arParaData(2)
+ End If
+
+ If slocalize = "no" Then
+ SetParaData(sID,"yes")
+ Else
+ SetParaData(sID,"no")
+ End If
+
+ thiscomponent.getcurrentcontroller.select(oSel(0))
+
+End Sub
+
+
+Sub LocalizeImage
+ oSel = thiscomponent.getcurrentcontroller.getselection
+ If oSel(0).ImplementationName <> "SwXTextGraphicObject" Then
+ msgbox "Please select an image"
+ Else
+ If Instr(oSel(0).Name," ")>0 Then
+ oSel(0).Name = Left(oSel(0).Name,Instr(oSel(0).Name," ")-1)
+ End If
+ oSel(0).Name = oSel(0).Name + " localize=""true"""
+ End If
+ SetBorder
+End Sub
+
+
+Sub UnLocalizeImage
+ oSel = thiscomponent.getcurrentcontroller.getselection
+ If oSel(0).ImplementationName <> "SwXTextGraphicObject" Then
+ msgbox "Please select an image"
+ Else
+
+ If Instr(oSel(0).Name," ")>0 Then
+ oSel(0).Name = Left(oSel(0).Name,Instr(oSel(0).Name," ")-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("com.sun.star.frame.DispatchHelper")
+
+ dim args(6) as new com.sun.star.beans.PropertyValue
+ args(0).Name = "RegionName"
+ args(0).Value = "howtoget"
+ args(1).Name = "RegionCondition"
+ args(1).Value = ""
+ args(2).Name = "RegionHidden"
+ args(2).Value = false
+ args(3).Name = "RegionProtect"
+ args(3).Value = false
+ args(4).Name = "LinkName"
+ args(4).Value = ""
+ args(5).Name = "FilterName"
+ args(5).Value = ""
+ args(6).Name = "SubRegion"
+ args(6).Value = ""
+
+ dispatcher.executeDispatch(document, ".uno:InsertSection", "", 0, args())
+ GoUp(1)
+ InsertTagCR("SECTION_","<SECTION id=""howtoget"">","hlp_aux_section")
+ CR
+ SetParaStyle("hlp_aux_section")
+ InsertTag("_SECTION","</SECTION>")
+ GoUp(1)
+ SetParaStyle("hlp_default")
+' Embed.Main(false)
+End Sub
+
+Sub InsertRelatedTopics
+
+ If not IsHelpFile Then
+ msgbox(strErr_NoHelpFile)
+ Exit Sub
+ End If
+
+ document = ThisComponent.CurrentController.Frame
+ dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
+
+ dim args(6) as new com.sun.star.beans.PropertyValue
+ args(0).Name = "RegionName"
+ args(0).Value = "relatedtopics"
+ args(1).Name = "RegionCondition"
+ args(1).Value = ""
+ args(2).Name = "RegionHidden"
+ args(2).Value = false
+ args(3).Name = "RegionProtect"
+ args(3).Value = false
+ args(4).Name = "LinkName"
+ args(4).Value = ""
+ args(5).Name = "FilterName"
+ args(5).Value = ""
+ args(6).Name = "SubRegion"
+ args(6).Value = ""
+
+ dispatcher.executeDispatch(document, ".uno:InsertSection", "", 0, args())
+ GoUp(1)
+ InsertTagCR("SECTION_","<SECTION id=""relatedtopics"">","hlp_aux_section")
+ CR
+ SetParaStyle("hlp_aux_section")
+ InsertTag("_SECTION","</SECTION>")
+ GoUp(1)
+ SetParaStyle("hlp_default")
+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("com.sun.star.frame.DispatchHelper")
+
+rem ----------------------------------------------------------------------
+dim args1(7) as new com.sun.star.beans.PropertyValue
+args1(0).Name = "BorderOuter.LeftBorder"
+args1(0).Value = Array(0,0,0,0)
+args1(1).Name = "BorderOuter.LeftDistance"
+args1(1).Value = 10
+args1(2).Name = "BorderOuter.RightBorder"
+args1(2).Value = Array(0,0,0,0)
+args1(3).Name = "BorderOuter.RightDistance"
+args1(3).Value = 0
+args1(4).Name = "BorderOuter.TopBorder"
+args1(4).Value = Array(0,0,0,0)
+args1(5).Name = "BorderOuter.TopDistance"
+args1(5).Value = 0
+args1(6).Name = "BorderOuter.BottomBorder"
+args1(6).Value = Array(0,0,0,0)
+args1(7).Name = "BorderOuter.BottomDistance"
+args1(7).Value = 0
+
+dispatcher.executeDispatch(document, ".uno:BorderOuter", "", 0, args1())
+
+rem ----------------------------------------------------------------------
+dim args2(4) as new com.sun.star.beans.PropertyValue
+args2(0).Name = "BorderInner.Horizontal"
+args2(0).Value = Array(0,0,0,0)
+args2(1).Name = "BorderInner.Vertical"
+args2(1).Value = Array(0,0,0,0)
+args2(2).Name = "BorderInner.Flags"
+args2(2).Value = 2
+args2(3).Name = "BorderInner.ValidFlags"
+args2(3).Value = 63
+args2(4).Name = "BorderInner.DefaultDistance"
+args2(4).Value = 0
+
+dispatcher.executeDispatch(document, ".uno:BorderInner", "", 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("com.sun.star.frame.DispatchHelper")
+
+rem ----------------------------------------------------------------------
+dim args1(7) as new com.sun.star.beans.PropertyValue
+args1(0).Name = "BorderOuter.LeftBorder"
+args1(0).Value = Array(15167232,0,88,0)
+args1(1).Name = "BorderOuter.LeftDistance"
+args1(1).Value = 101
+args1(2).Name = "BorderOuter.RightBorder"
+args1(2).Value = Array(15167232,0,88,0)
+args1(3).Name = "BorderOuter.RightDistance"
+args1(3).Value = 101
+args1(4).Name = "BorderOuter.TopBorder"
+args1(4).Value = Array(15167232,0,88,0)
+args1(5).Name = "BorderOuter.TopDistance"
+args1(5).Value = 101
+args1(6).Name = "BorderOuter.BottomBorder"
+args1(6).Value = Array(15167232,0,88,0)
+args1(7).Name = "BorderOuter.BottomDistance"
+args1(7).Value = 101
+
+dispatcher.executeDispatch(document, ".uno:BorderOuter", "", 0, args1())
+
+rem ----------------------------------------------------------------------
+dim args2(4) as new com.sun.star.beans.PropertyValue
+args2(0).Name = "BorderInner.Horizontal"
+args2(0).Value = Array(0,0,0,0)
+args2(1).Name = "BorderInner.Vertical"
+args2(1).Value = Array(0,0,0,0)
+args2(2).Name = "BorderInner.Flags"
+args2(2).Value = 2
+args2(3).Name = "BorderInner.ValidFlags"
+args2(3).Value = 127
+args2(4).Name = "BorderInner.DefaultDistance"
+args2(4).Value = 0
+
+dispatcher.executeDispatch(document, ".uno:BorderInner", "", 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("HelpAuthoring")
+
+ oDialog = LoadDialog("HelpAuthoring", "dlgSwitch")
+ oDialogModel = oDialog.Model
+
+ oOptSys = oDialog.GetControl("opSwitchSystem")
+ oOptAppl = oDialog.GetControl("opSwitchAppl")
+ oOptDistrib = oDialog.GetControl("opSwitchDistrib")
+
+ If oDialog.Execute() = 1 Then
+ If oOptSys.State Then
+ sType = "sys"
+ ElseIf oOptAppl.State Then
+ sType = "appl"
+ ElseIf oOptDistrib.State Then
+ sType = "distrib"
+ 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("SWITCHINLINE_","<SWITCHINLINE select=""" + sType + """>","hlp_aux_switch")
+ InsertCase(sType,TRUE,oCur)
+ thiscomponent.getcurrentcontroller.select(oCurEnd)
+ CloseSwitchInline
+ GoLeft(1)
+ Else
+ CR_before
+ GoUp(1)
+ SetParaStyle("hlp_aux_switch")
+ InsertTag("SWITCH_","<SWITCH select=""" + sType + """>","hlp_aux_switch")
+ GoLeft(1)
+ GoDown(1)
+ SetCharStyle("Default")
+ CloseSwitch
+ GoUp(1)
+ InsertCase(sType,FALSE,oCur)
+ End If
+End Sub
+
+Sub InsertCaseElement
+ document = StarDesktop.CurrentComponent
+ Dim oCur as Object
+ BasicLibraries.LoadLibrary("HelpAuthoring")
+
+ oDialog = LoadDialog("HelpAuthoring", "dlgSwitch")
+ oDialogModel = oDialog.Model
+
+ oOptSys = oDialog.GetControl("opSwitchSystem")
+ oOptAppl = oDialog.GetControl("opSwitchAppl")
+ oOptDistrib = oDialog.GetControl("opSwitchDistrib")
+
+ If oDialog.Execute() = 1 Then
+ If oOptSys.State Then
+ sType = "sys"
+ ElseIf oOptAppl.State Then
+ sType = "appl"
+ ElseIf oOptDistrib.State Then
+ sType = "distrib"
+ End If
+ Else
+ End If
+ oDialog.Dispose
+
+ InsertCase(sType,FALSE,oCur)
+
+End Sub
+
+Sub InsertDefaultElement
+ document = StarDesktop.CurrentComponent
+ BasicLibraries.LoadLibrary("HelpAuthoring")
+
+ InsertDefault
+End Sub
+
+Sub InsertCaseInlineElement
+ document = StarDesktop.CurrentComponent
+ Dim oCur as Object
+ BasicLibraries.LoadLibrary("HelpAuthoring")
+
+ oDialog = LoadDialog("HelpAuthoring", "dlgSwitch")
+ oDialogModel = oDialog.Model
+
+ oOptSys = oDialog.GetControl("opSwitchSystem")
+ oOptAppl = oDialog.GetControl("opSwitchAppl")
+ oOptDistrib = oDialog.GetControl("opSwitchDistrib")
+
+ If oDialog.Execute() = 1 Then
+ If oOptSys.State Then
+ sType = "sys"
+ ElseIf oOptAppl.State Then
+ sType = "appl"
+ ElseIf oOptDistrib.State Then
+ sType = "distrib"
+ 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("HelpAuthoring")
+
+ 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("sys",FALSE)
+End Sub
+
+Sub InsertCaseAppl
+ InsertCase("appl",FALSE)
+End Sub
+
+Sub InsertCaseDistrib
+ InsertCase("distrib",FALSE)
+End Sub
+
+Sub InsertCaseInlineSys
+ InsertCase("sys",TRUE)
+End Sub
+
+Sub InsertCaseInlineAppl
+ InsertCase("appl",TRUE)
+End Sub
+
+Sub InsertCaseInlineDistrib
+ InsertCase("distrib",TRUE)
+End Sub
+
+Sub InsertDefaultInline(oCur 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)
+
+ thiscomponent.getcurrentcontroller.select(oCurStart)
+ InsertTag("DEFAULTINLINE_","<DEFAULTINLINE>")
+
+ thiscomponent.getcurrentcontroller.select(oCurEnd)
+ InsertTag("_DEFAULTINLINE","</DEFAULTINLINE>")
+End Sub
+
+Sub InsertCase(sType As String, bInline As Boolean,oCur As Object)
+ document = StarDesktop.CurrentComponent
+
+ BasicLibraries.LoadLibrary("HelpAuthoring")
+ oDialog = LoadDialog("HelpAuthoring", "dlgCase")
+ oDialogModel = oDialog.Model
+
+ oOptPredefined = oDialog.GetControl("opPredefined")
+ oCbPredefined = oDialog.GetControl("cbPredefined")
+ oOptSpecify = oDialog.GetControl("opSpecify")
+ oTxtSpecify = oDialog.GetControl("txtSpecify")
+ oTxtSpecify.setVisible(FALSE)
+
+ If sType = "sys" Then
+ arItems = Array("WIN","UNIX","MAC")
+ ElseIf sType = "appl" Then
+ arItems = Array("CALC","CHART","DRAW","IMPRESS","MATH","WRITER","BASIC")
+ ElseIf sType = "distrib" Then
+ arItems = Array("OPENSOURCE","COMMERCIAL")
+ Else
+ msgbox "Unknown Case. Go tell Frank about this",0,"D'oh!"
+ 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
+ '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("CASEINLINE_","<CASEINLINE select="""+sSelect+""">")
+
+ thiscomponent.getcurrentcontroller.select(oCurEnd)
+ InsertTag("_CASEINLINE","</CASEINLINE>")
+ Else
+ CR_before
+ GoUp(1)
+ SetParaStyle("hlp_aux_switch")
+ InsertTag("CASE_","<CASE select=""" + sSelect+""">","hlp_aux_switch")
+ GoLeft(1)
+ GoDown(1)
+ SetCharStyle("Default")
+ CloseCase
+ GoUp(1)
+ End If
+ End If
+ oDialog.dispose
+End Sub
+
+Sub StatusChange
+ oOptPredefined = oDialog.GetControl("opPredefined")
+ oCbPredefined = oDialog.GetControl("cbPredefined")
+ oOptSpecify = oDialog.GetControl("opSpecify")
+ oTxtSpecify = oDialog.GetControl("txtSpecify")
+
+ 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("hlp_aux_switch")
+ InsertTag("_CASE","</CASE>","hlp_aux_switch")
+End Sub
+
+Sub InsertDefault
+ CR_before
+ GoUp(1)
+ SetParaStyle("hlp_aux_switch")
+ InsertTag("DEFAULT_","<DEFAULT>","hlp_aux_switch")
+ GoLeft(1)
+ GoDown(1)
+ SetCharStyle("Default")
+ CloseDefault
+ GoUp(1)
+End Sub
+
+Sub CloseDefault
+ CR
+ SetParaStyle("hlp_aux_switch")
+ InsertTag("_DEFAULT","</DEFAULT>","hlp_aux_switch")
+End Sub
+
+Sub CloseSwitch
+ CR
+ SetParaStyle("hlp_aux_switch")
+ InsertTag("_SWITCH","</SWITCH>","hlp_aux_switch")
+End Sub
+
+Sub CloseSwitchInline
+ InsertTag("_SWITCHINLINE","</SWITCHINLINE>")
+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("HelpAuthoring")
+ oDialog = LoadDialog("HelpAuthoring", "dlgTOC")
+ oDialogModel = oDialog.Model
+
+ ocbAddTag = oDialog.GetControl("cbAddTag")
+
+ ' Check if bookmarks are allowed here
+ If IsInList Then
+ msgbox "No Bookmarks allowed inside a list.", 48, "D'oh!"
+ Exit Sub
+ End If
+
+ nBookmarkType = IsInBookmark
+ If nBookmarkType = 3 Then ' inside TOC bookmark
+ ocbAddTag.State = 0
+ End If
+
+ If oDialog.Execute() = 1 Then
+ ' Insert the bookmark construction
+ olbTOC = oDialog.GetControl("lbTOC")
+
+ If nBookmarkType = 0 Then' not in a bookmark, always add parent tags
+ bmid = CreateID
+ ' now check if we are in a para with text (this wouldn't be valid)
+ If Not(ParaIsEmpty) Then
+ CR
+ End If
+ InsertTag("BOOKMARK_","<BOOKMARK branch=""contents"" id=""bm_id" + bmid + """>","hlp_aux_bookmark")
+ For i=0 to ubound(olbTOC.Items)
+ LF
+ InsertTag("BOOKMARKVALUE_","<BOOKMARKVALUE>")
+ InsertField("BOOKMARKVALUE",olbTOC.Items(i))
+ InsertTag("_BOOKMARKVALUE","</BOOKMARKVALUE>")
+ Next i
+ LF
+ InsertTagCR("_BOOKMARK","</BOOKMARK>","hlp_aux_bookmark")
+
+ ElseIf nBookmarkType = 3 Then ' correct bookmark type
+ If ocbAddTag.State = 1 Then
+ bmid = CreateID
+ ' now check if we are in a para with text (this wouldn't be valid)
+ If Not(ParaIsEmpty) Then
+ CR
+ End If
+ InsertTag("BOOKMARK_","<BOOKMARK branch=""contents"" id=""bm_id" + bmid + """>","hlp_aux_bookmark")
+ End If
+ For i=0 to ubound(olbTOC.Items)
+ LF
+ InsertTag("BOOKMARKVALUE_","<BOOKMARKVALUE>")
+ InsertField("BOOKMARKVALUE",olbTOC.Items(i))
+ InsertTag("_BOOKMARKVALUE","</BOOKMARKVALUE>")
+ Next i
+ If ocbAddTag.State = 1 Then
+ LF
+ InsertTagCR("_BOOKMARK","</BOOKMARK>","hlp_aux_bookmark")
+ End If
+ Else ' wrong bookmark type
+ bmid = CreateID
+ ' now check if we are in a para with text (this wouldn't be valid)
+ If Not(ParaIsEmpty) Then
+ CR
+ End If
+ InsertTag("BOOKMARK_","<BOOKMARK branch=""contents"" id=""bm_id" + bmid + """>","hlp_aux_bookmark")
+ For i=0 to ubound(olbTOC.Items)
+ LF
+ InsertTag("BOOKMARKVALUE_","<BOOKMARKVALUE>")
+ InsertField("BOOKMARKVALUE",olbTOC.Items(i))
+ InsertTag("_BOOKMARKVALUE","</BOOKMARKVALUE>")
+ Next i
+ LF
+ InsertTagCR("_BOOKMARK","</BOOKMARK>","hlp_aux_bookmark")
+ 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("lbTOC")
+ 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("txtTOC")
+ If (oTxtTOC.Text = "") Then
+ msgbox "Enter a TOC entry first."
+ Else
+ ' Insert the index entry into the list
+ olbTOC = oDialog.GetControl("lbTOC")
+ 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("HelpAuthoring")
+ CR
+ CreateTable(2, 2, "tbl_"+CreateID)
+End Sub
+
+
+
+</script:module>
\ No newline at end of file