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

[Solved] add brackets to selected test

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
Tommy27
OOo Advocate
OOo Advocate


Joined: 18 Nov 2006
Posts: 302

PostPosted: Mon Feb 09, 2009 10:01 am    Post subject: [Solved] add brackets to selected test Reply with quote

I need a macro that adds brackets at the beginning and at the end of a selected text in OOo Writer.

This is an example:

“ this a template text line in writer ”

i select with my mouse the words “text line”

then i run the macro, and it turns into:

“ this a template [text line] in writer ”

do u undestand what i mean and think this can be done?


Last edited by Tommy27 on Sun Mar 08, 2009 3:41 pm; edited 1 time in total
Back to top
View user's profile Send private message
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Mon Feb 09, 2009 10:10 am    Post subject: Reply with quote

What language and what OS ?
Do you know how to retrieve the selected text ? If not have a look at :
http://wiki.services.openoffice.org/wiki/Programming_OooWriter#Going_further_with_Inspector
If you don't read C++ there is a link with the corresponding OOoBasic problem below the figure.
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
Tommy27
OOo Advocate
OOo Advocate


Joined: 18 Nov 2006
Posts: 302

PostPosted: Mon Feb 09, 2009 11:50 am    Post subject: Reply with quote

well i need this macro in any language i write....

my O/S in Win VIsta 64but SP1

thanks for the link but unfortunatately i'm pretty analphabet about macro code.
Back to top
View user's profile Send private message
Tommy27
OOo Advocate
OOo Advocate


Joined: 18 Nov 2006
Posts: 302

PostPosted: Tue Feb 10, 2009 11:39 am    Post subject: Reply with quote

i got the right suggestion from the Italian OOo Google Groups (thanks to Roberto Montaruli).

i just started the macro recorder with a selected word
then hit Ctrl-X,
then type [
then Ctrl-V,
then type ]
stop the macro recorder


here's the final code

Code:
sub ParentesiQuadre
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Cut", "", 0, Array())

rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "Text"
args2(0).Value = "["

dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args2())

rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())

rem ----------------------------------------------------------------------
dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = "Text"
args4(0).Value = "]"

dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args4())


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 Macros and API 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