| View previous topic :: View next topic |
| Author |
Message |
naveen_srma General User


Joined: 15 Nov 2005 Posts: 36 Location: gurgaon,india
|
Posted: Thu Feb 23, 2006 9:05 pm Post subject: how can we know non-printing characters, when using cursor |
|
|
hi,
Im using a view cursor, and when i select a character one by one i want to know if its a non-printing character or not. Like i want to know if its a tab, newline. etc.
cursor dont tell this thing, any way i can know about non-printing characters.
plz tell.
Thanks. |
|
| Back to top |
|
 |
Westland Super User


Joined: 03 Feb 2006 Posts: 562
|
Posted: Fri Feb 24, 2006 1:33 am Post subject: |
|
|
What do you mean with this ?
| Quote: | | Im using a view cursor |
Control+F10 lets you view/hide nonprinting-chracters. _________________ "Do one thing every day that scares you" |
|
| Back to top |
|
 |
naveen_srma General User


Joined: 15 Nov 2005 Posts: 36 Location: gurgaon,india
|
Posted: Sun Feb 26, 2006 8:55 pm Post subject: |
|
|
Actually i want know non printing character through text cursor (tha i will convert by getViewCursor) one by one when i moved current cursor position on left or right at that time cursor tell me its a non printing character.
So i think u can understand what i want.......... |
|
| Back to top |
|
 |
Robert Tucker Moderator


Joined: 16 Aug 2004 Posts: 3367 Location: Manchester UK
|
Posted: Sun Feb 26, 2006 11:41 pm Post subject: |
|
|
I've not tried it, but can you not do something along the lines of creating a text cursor:
"get the current cursor position in the GUI and create a text cursor from it"
http://api.openoffice.org/docs/DevelopersGuide/BasicAndDialogs/BasicAndDialogs.xhtml
moving the cursor across the character:
oCursor.goRight(1,FALSE)
oCursor.goLeft(1,FALSE)
and getting it to print out the one character "string". |
|
| Back to top |
|
 |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 8979 Location: Lexinton, Kentucky, USA
|
Posted: Mon Feb 27, 2006 7:15 am Post subject: |
|
|
You need to examine the ASCII value of the character captured by the cursor.
Do While cursor.goRight(1,true)
Print ASC(cursor.String)
cursor.collapseToEnd
Loop
Here is a macro that will find all nonprinting except paragraph breaks. | Code: | Sub Main
oDoc = ThisComponent
FandR = oDoc.createReplaceDescriptor
FandR.searchRegularExpression = true
FandR.setSearchString("([:cntrl:])")
Find = oDoc.FindFirst(FandR)'Search from beginning of document.
'oVC = oDoc.CurrentController.getViewCursor 'Search from
'Find = oDoc.FindNext(oVC.End,FandR) 'position of view cursor.
While Not isNull(Find)
Select Case Asc(Find.String)
Case 9 : Print "Tab"
'Find.String = " " 'Change to space
Case 10 : Print "Line break"
Case Else : Print Acs(Find.String)
End Select
Find = oDoc.FindNext(Find.End,FandR)
Wend
End Sub
|
|
|
| Back to top |
|
 |
|