OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

how can we know non-printing characters, when using cursor

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Writer
View previous topic :: View next topic  
Author Message
naveen_srma
General User
General User


Joined: 15 Nov 2005
Posts: 36
Location: gurgaon,india

PostPosted: Thu Feb 23, 2006 9:05 pm    Post subject: how can we know non-printing characters, when using cursor Reply with quote

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
View user's profile Send private message
Westland
Super User
Super User


Joined: 03 Feb 2006
Posts: 562

PostPosted: Fri Feb 24, 2006 1:33 am    Post subject: Reply with quote

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
View user's profile Send private message
naveen_srma
General User
General User


Joined: 15 Nov 2005
Posts: 36
Location: gurgaon,india

PostPosted: Sun Feb 26, 2006 8:55 pm    Post subject: Reply with quote

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
View user's profile Send private message
Robert Tucker
Moderator
Moderator


Joined: 16 Aug 2004
Posts: 3407
Location: Manchester UK

PostPosted: Sun Feb 26, 2006 11:41 pm    Post subject: Reply with quote

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
View user's profile Send private message
JohnV
Administrator
Administrator


Joined: 07 Mar 2003
Posts: 9183
Location: Lexinton, Kentucky, USA

PostPosted: Mon Feb 27, 2006 7:15 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Writer All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group