I’m trying to capture the current selection in a Writer doc, then test the end points for spaces. If they are spaces I want to trim the Selection back, until the endpoints are non-spaces.
I got this from OOo’s wiki:
oCurSelection = thisComponent.getCurrentSelection() if oCurSelection.supportsService("com.sun.star.text.TextRanges") then nCount = oCurSelection.Count if nCount = 1 then oTextRange = oCurSelection.getByIndex(0) 'Do some action on oTextRange else for i = 0 to nCount - 1 oTextRange = oCurSelection.getByIndex(i) 'Do some action on oTextRange next end if end if
The oTextRange variable contains the current Selection in its “String” component.
But I don’t have a clue how to go to the end points, test them for “spacehood” and trim them back if necessary.
I have consulted Andrew’s book, which unfortunately only makes me more confused. And I didn’t see anything online.