' *** MODULE FIND ***
Dim oDialog AS Object
Dim document AS Object
Dim Found(0) As Object
Dim nPos As Integer
'=======================================================
' Main
'-------------------------------------------------------
' Calls the Find routine to search in fields
'=======================================================
Sub Main
If not IsHelpFile Then
msgbox(strErr_NoHelpFile)
Exit Sub
End If
BasicLibraries.LoadLibrary("HelpAuthoring")
oDialog = LoadDialog("HelpAuthoring", "dlgFind")
oDoc = StarDesktop.CurrentComponent
Enum = oDoc.Text.createEnumeration
LastSearchTerm = ReadConfig("SearchTerm")
If LastSearchTerm <> "" Then
oTxtFind = oDialog.GetControl("txtFind")
oTxtFind.Text = LastSearchTerm
End If
If oDialog.execute() = 1 Then
oTxtFind = oDialog.GetControl("txtFind")
sFind = oTxtFind.Text
WriteConfig("SearchTerm",sFind)
Do While Enum.hasMoreElements
TE = Enum.nextElement
If TE.supportsService("com.sun.star.text.Paragraph") Then
TP = TE.createEnumeration
While TP.hasmoreElements
TPE = TP.nextElement
If TPE.supportsService("com.sun.star.text.TextField") Then
If Instr(TPE.String, sFind) Then
sDim = ubound(Found())+1
Redim Preserve Found(sDim) As Object
Found(sDim) = TPE.TextField.getAnchor.getText.createTextCursorbyRange(TPE.TextField.getAnchor)
End If
End If
Wend
ElseIf TE.supportsService("com.sun.star.text.TextTable") Then
CellName = "A1"
Cell = TE.getCellByName(CellName)
tmpCellEnum = Cell.createEnumeration
tmpCellElement = tmpCellEnum.nextElement
Rows = TE.getRows
Cols = TE.getColumns
For RowIndex = 1 to Rows.getCount()
For ColIndex = 1 to Cols.getCount()
CellName = Chr(64 + ColIndex) & RowIndex
Cell = TE.getCellByName(CellName)
CellEnum = Cell.createEnumeration
Do While CellEnum.hasMoreElements
CellElement = CellEnum.nextElement
If CellElement.supportsService("com.sun.star.text.Paragraph") Then
TP = CellElement.createEnumeration
While TP.hasmoreElements
TPE = TP.nextElement
If TPE.supportsService("com.sun.star.text.TextField") Then
If Instr(TPE.String, sFind) Then
sDim = ubound(Found())+1
Redim Preserve Found(sDim) As Object
Found(sDim) = TPE.TextField.getAnchor.getText.createTextCursorbyRange(TPE.TextField.getAnchor)
End If
End If
Wend
EndIf
Loop
Next
Next
EndIf
Loop
If ubound(Found()) < 1 Then
msgbox "Nothing found"
ElseIf ubound(Found()) > 1 Then
nPos = 1
thiscomponent.getcurrentcontroller.select(Found(1))
oDialog = LoadDialog("HelpAuthoring", "dlgRepeatFind")
oPrev = oDialog.GetControl("butPrev")
oPrev.Enable = FALSE
oDialog.Execute()
Else
thiscomponent.getcurrentcontroller.select(Found(1))
End If
End If
End Sub
'=======================================================
' FindNext
'-------------------------------------------------------
' Goes to the next search result position.
'=======================================================
Sub FindNext
If nPos < ubound(Found()) Then
nPos = nPos + 1
thiscomponent.getcurrentcontroller.select(Found(nPos))
If nPos = ubound(Found()) Then
oNext = oDialog.GetControl("butNext")
oNext.Enable = FALSE
End If
If nPos > 1 Then
oPrev = oDialog.GetControl("butPrev")
oPrev.Enable = TRUE
End If
End If
End Sub
'=======================================================
' FindPrev
'-------------------------------------------------------
' Goes to the previous search result position.
'=======================================================
Sub FindPrev
If nPos > 1 Then
nPos = nPos - 1
thiscomponent.getcurrentcontroller.select(Found(nPos))
If nPos = 1 Then
oPrev = oDialog.GetControl("butPrev")
oPrev.Enable = FALSE
End If
If nPos < ubound(Found()) Then
oNext = oDialog.GetControl("butNext")
oNext.Enable = TRUE
End If
End If
End Sub
' *** MODULE FIND ***
Dim oDialog AS Object
Dim document AS Object
Dim Found(0) As Object
Dim nPos As Integer
'=======================================================
' Main
'-------------------------------------------------------
' Calls the Find routine to search in fields
'=======================================================
Sub Main
If not IsHelpFile Then
msgbox(strErr_NoHelpFile)
Exit Sub
End If
BasicLibraries.LoadLibrary("HelpAuthoring")
oDialog = LoadDialog("HelpAuthoring", "dlgFind")
oDoc = StarDesktop.CurrentComponent
Enum = oDoc.Text.createEnumeration
LastSearchTerm = ReadConfig("SearchTerm")
If LastSearchTerm <> "" Then
oTxtFind = oDialog.GetControl("txtFind")
oTxtFind.Text = LastSearchTerm
End If
If oDialog.execute() = 1 Then
oTxtFind = oDialog.GetControl("txtFind")
sFind = oTxtFind.Text
WriteConfig("SearchTerm",sFind)
Do While Enum.hasMoreElements
TE = Enum.nextElement
If TE.supportsService("com.sun.star.text.Paragraph") Then
TP = TE.createEnumeration
While TP.hasmoreElements
TPE = TP.nextElement
If TPE.supportsService("com.sun.star.text.TextField") Then
If Instr(TPE.String, sFind) Then
sDim = ubound(Found())+1
Redim Preserve Found(sDim) As Object
Found(sDim) = TPE.TextField.getAnchor.getText.createTextCursorbyRange(TPE.TextField.getAnchor)
End If
End If
Wend
ElseIf TE.supportsService("com.sun.star.text.TextTable") Then
CellName = "A1"
Cell = TE.getCellByName(CellName)
tmpCellEnum = Cell.createEnumeration
tmpCellElement = tmpCellEnum.nextElement
Rows = TE.getRows
Cols = TE.getColumns
For RowIndex = 1 to Rows.getCount()
For ColIndex = 1 to Cols.getCount()
CellName = Chr(64 + ColIndex) & RowIndex
Cell = TE.getCellByName(CellName)
CellEnum = Cell.createEnumeration
Do While CellEnum.hasMoreElements
CellElement = CellEnum.nextElement
If CellElement.supportsService("com.sun.star.text.Paragraph") Then
TP = CellElement.createEnumeration
While TP.hasmoreElements
TPE = TP.nextElement
If TPE.supportsService("com.sun.star.text.TextField") Then
If Instr(TPE.String, sFind) Then
sDim = ubound(Found())+1
Redim Preserve Found(sDim) As Object
Found(sDim) = TPE.TextField.getAnchor.getText.createTextCursorbyRange(TPE.TextField.getAnchor)
End If
End If
Wend
EndIf
Loop
Next
Next
EndIf
Loop
If ubound(Found()) < 1 Then
msgbox "Nothing found"
ElseIf ubound(Found()) > 1 Then
nPos = 1
thiscomponent.getcurrentcontroller.select(Found(1))
oDialog = LoadDialog("HelpAuthoring", "dlgRepeatFind")
oPrev = oDialog.GetControl("butPrev")
oPrev.Enable = FALSE
oDialog.Execute()
Else
thiscomponent.getcurrentcontroller.select(Found(1))
End If
End If
End Sub
'=======================================================
' FindNext
'-------------------------------------------------------
' Goes to the next search result position.
'=======================================================
Sub FindNext
If nPos < ubound(Found()) Then
nPos = nPos + 1
thiscomponent.getcurrentcontroller.select(Found(nPos))
If nPos = ubound(Found()) Then
oNext = oDialog.GetControl("butNext")
oNext.Enable = FALSE
End If
If nPos > 1 Then
oPrev = oDialog.GetControl("butPrev")
oPrev.Enable = TRUE
End If
End If
End Sub
'=======================================================
' FindPrev
'-------------------------------------------------------
' Goes to the previous search result position.
'=======================================================
Sub FindPrev
If nPos > 1 Then
nPos = nPos - 1
thiscomponent.getcurrentcontroller.select(Found(nPos))
If nPos = 1 Then
oPrev = oDialog.GetControl("butPrev")
oPrev.Enable = FALSE
End If
If nPos < ubound(Found()) Then
oNext = oDialog.GetControl("butNext")
oNext.Enable = TRUE
End If
End If
End Sub