Posting as an answer to this comment:
I am unable to reset the tabs to a single tab
Here is a macro from Andrew Pitonyak’s Useful Macro Information for OpenOffice.org to remove empty space, including squeezing multiple tabs to a single one:
Function IsAnythingSelected(oDoc As Object) As Boolean
Dim oSels 'All of the selections
Dim oSel 'A single selection
Dim oCursor 'A temporary cursor
IsAnythingSelected = False
If IsNull(oDoc) Then Exit Function
' The current selection in the current controller.
'If there is no current controller, it returns NULL.
oSels = oDoc.getCurrentSelection()
If IsNull(oSels) Then Exit Function
REM I have never seen a selection count of zero
If oSels.getCount() = 0 Then Exit Function
REM If there are multiple selections, then certainly
REM something is selected
If oSels.getCount() > 1 Then
IsAnythingSelected = True
Else
REM If only one thing is selected, however, then check to see
REM if the selection is collapsed. In other words, see if the
REM end location is the same as the starting location.
REM Notice that I use the text object from the selection object
REM because it is safer than assuming that it is the same as the
REM documents text object.
oSel = oSels.getByIndex(0)
oCursor = oSel.getText().CreateTextCursorByRange(oSel)
If Not oCursor.IsCollapsed() Then IsAnythingSelected = True
End If
End Function
Function GetLeftMostCursor(oSel As Object) As Object
Dim oRange 'Left most range.
Dim oCursor 'Cursor at the left most range.
If oSel.getText().compareRegionStarts(oSel.getEnd(), oSel) >= 0 Then
oRange = oSel.getEnd()
Else
oRange = oSel.getStart()
End If
oCursor = oSel.getText().CreateTextCursorByRange(oRange)
oCursor.goRight(0, False)
GetLeftMostCursor = oCursor
End Function
Function GetRightMostCursor(oSel As Object) As Object
Dim oRange 'Right most range.
Dim oCursor 'Cursor at the right most range.
If oSel.getText().compareRegionStarts(oSel.getEnd(), oSel) >= 0 Then
oRange = oSel.getStart()
Else
oRange = oSel.getEnd()
End If
oCursor = oSel.getText().CreateTextCursorByRange(oRange)
oCursor.goLeft(0, False)
GetRightMostCursor = oCursor
End Function
Function CreateSelectedTextIterator(oDoc As Object, sPrompt As String, oCurs()) As Boolean
Dim lSelCount As Long 'Number of selected sections.
Dim lWhichSelection As Long 'Current selection item.
Dim oSels 'All of the selections
Dim oSel 'A single selection.
Dim oLCurs 'Cursor to the left of the current selection.
Dim oRCurs 'Cursor to the right of the current selection.
CreateSelectedTextIterator = True
If Not IsAnythingSelected(ThisComponent) Then
Dim i%
i% = MsgBox("No text selected!" + Chr(13) + sPrompt, _
1 OR 32 OR 256, "Warning")
If i% = 1 Then
oLCurs = oDoc.getText().createTextCursor()
oLCurs.gotoStart(False)
oRCurs = oDoc.getText().createTextCursor()
oRCurs.gotoEnd(False)
oCurs = DimArray(0, 1)
oCurs(0, 0) = oLCurs
oCurs(0, 1) = oRCurs
Else
oCurs = DimArray()
CreateSelectedTextIterator = False
End If
Else
oSels = ThisComponent.getCurrentSelection()
lSelCount = oSels.getCount()
oCurs = DimArray(lSelCount - 1, 1)
For lWhichSelection = 0 To lSelCount - 1
oSel = oSels.getByIndex(lWhichSelection)
REM If I want to know if NO text is selected, I could
REM do the following:
REM oLCurs = oSel.getText().CreateTextCursorByRange(oSel)
REM If oLCurs.isCollapsed() Then ...
oLCurs = GetLeftMostCursor(oSel)
oRCurs = GetRightMostCursor(oSel)
oCurs(lWhichSelection, 0) = oLCurs
oCurs(lWhichSelection, 1) = oRCurs
Next
End If
End Function
Function IsWhiteSpace(iChar As Integer) As Boolean
Select Case iChar
Case 9, 10, 13, 32, 160
IsWhiteSpace = True
Case Else
IsWhiteSpace = False
End Select
End Function
Function RankChar(iPrevChar, iCurChar) As Integer
If Not IsWhiteSpace(iCurChar) Then 'The current char is not white space, ignore it
RankChar = 0
ElseIf iPrevChar = 0 Then 'Start of a line and current char is white space
RankChar = 1 'so delete the current character.
ElseIf Not IsWhiteSpace(iPrevChar) Then 'Current char is white space but previous is not
RankChar = 0 'so ignore the current charcter.
ElseIf iPrevChar = 13 Then 'Previous char is highest ranked white space
RankChar = 1 'so delete the current character.
ElseIf iCurChar = 13 Then 'Current character is highest ranked white space
RankChar = -1 'so delete the previous character.
ElseIf iPrevChar = 10 Then 'No new Pars so see if previous char is new line
RankChar = 1 'so delete the current character.
ElseIf iCurChar = 10 Then 'No new Pars so see if the current char is new line
RankChar = -1 'so delete the previous character.
ElseIf iPrevChar = 9 Then 'No new Lines so see if the previous char is tab
RankChar = 1 'so delete the current character.
ElseIf iCurChar = 9 Then 'No new Lines so see if the current char is a tab
RankChar = -1 'so delete the previous character.
ElseIf iPrevChar = 160 Then 'No Tabs so check previous char for a hard space
RankChar = 1 'so delete the current character.
ElseIf iCurChar = 160 Then 'No Tabs so check current char for a hard space
RankChar = -1 'so delete the previous character.
ElseIf iPrevChar = 32 Then 'No hard spaces so check previous for a space
RankChar = 1 'so delete the current character.
ElseIf iCurChar = 32 Then 'No hard spaces so check current for a space
RankChar = -1 'so delete the previous character.
Else 'Should probably not get here
RankChar = 0 'so simply ignore it!
End If
End Function
Sub RemoveEmptySpace
Dim oCurs(), i%
If Not CreateSelectedTextIterator(ThisComponent, _
"ALL empty space will be removed from the ENTIRE document?", oCurs()) Then Exit Sub
For i% = LBOUND(oCurs()) To UBOUND(oCurs())
RemoveEmptySpaceWorker (oCurs(i%, 0), oCurs(i%, 1))
Next i%
MsgBox "Farite"
End Sub
Sub RemoveEmptySpaceWorker(oLCurs As Object, oRCurs As Object)
Dim sParText As String, i As Integer
Dim oText
oText = oLCurs.getText()
If IsNull(oLCurs) Or IsNull(oRCurs) Or IsNull(oText) Then Exit Sub
If oText.compareRegionEnds(oLCurs, oRCurs) <= 0 Then Exit Sub
Dim iLastChar As Integer, iThisChar As Integer, iRank As Integer
iLastChar = 0
iThisChar = 0
oLCurs.goRight(0, False)
Do While oLCurs.goRight(1, True)
iThisChar = Asc(oLCurs.getString())
i = oText.compareRegionEnds(oLCurs, oRCurs)
'If at the last character!
'Then always remove white space
If i = 0 Then
If IsWhiteSpace(iThisChar) Then oLCurs.setString("")
Exit Do
End If
'If went past the end then get out
If i < 0 Then Exit Do
iRank = RankChar(iLastChar, iThisChar)
If iRank = 1 Then
'I am about to delete this character.
'I do not change iLastChar because it did not change!
'Print "Deleting Current with " + iLastChar + " and " + iThisChar
oLCurs.setString("")
ElseIf iRank = -1 Then
'This will deselect the selected character and then select one
'more to the left.
oLCurs.goLeft(2, True)
'Print "Deleting to the left with " + iLastChar + " and " + iThisChar
oLCurs.setString("")
oLCurs.goRight(1, False)
iLastChar = iThisChar
Else
oLCurs.goRight(0, False)
iLastChar = iThisChar
End If
Loop
End Sub
Run RemoveEmptySpace() on a selection or for the entire text.