incubator-ooo-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From XiuLi Xu <susan.dongd...@gmail.com>
Subject Re: Macro or its equivalent to replace double spaces with single space.
Date Tue, 17 Jul 2012 05:58:09 GMT
In OpenOffice developer guide, there is a section "First Steps with
OpenOffice.org Basic" which is a step by step tutorial to describes the
necessary steps to write and debug a program in the Basic IDE.
http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Basic/First_Steps_with_OpenOffice.org_Basic
This guide can answer most of your questions.

On Tue, Jul 17, 2012 at 12:47 PM, Doug <dmcgarrett@optonline.net> wrote:

> On 07/17/2012 12:10 AM, XiuLi Xu wrote:
>
>> In OpenOffice, you can also write macro to implement any function you
>> want.
>> I use this code to replace double spaces with single space for the current
>> open document.
>>
>>
>> REM  *****  BASIC  *****
>>
>>
>> sub Main
>> 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 ------------------------------**------------------------------**
>> ----------
>> dim args1(18) as new com.sun.star.beans.**PropertyValue
>> args1(0).Name = "SearchItem.StyleFamily"
>> args1(0).Value = 2
>> args1(1).Name = "SearchItem.CellType"
>> args1(1).Value = 0
>> args1(2).Name = "SearchItem.RowDirection"
>> args1(2).Value = true
>> args1(3).Name = "SearchItem.AllTables"
>> args1(3).Value = false
>> args1(4).Name = "SearchItem.Backward"
>> args1(4).Value = false
>> args1(5).Name = "SearchItem.Pattern"
>> args1(5).Value = false
>> args1(6).Name = "SearchItem.Content"
>> args1(6).Value = false
>> args1(7).Name = "SearchItem.AsianOptions"
>> args1(7).Value = false
>> args1(8).Name = "SearchItem.AlgorithmType"
>> args1(8).Value = 0
>> args1(9).Name = "SearchItem.SearchFlags"
>> args1(9).Value = 65536
>> args1(10).Name = "SearchItem.SearchString"
>> args1(10).Value = "  "
>> args1(11).Name = "SearchItem.ReplaceString"
>> args1(11).Value = " "
>> args1(12).Name = "SearchItem.Locale"
>> args1(12).Value = 255
>> args1(13).Name = "SearchItem.ChangedChars"
>> args1(13).Value = 2
>> args1(14).Name = "SearchItem.DeletedChars"
>> args1(14).Value = 2
>> args1(15).Name = "SearchItem.InsertedChars"
>> args1(15).Value = 2
>> args1(16).Name = "SearchItem.**TransliterateFlags"
>> args1(16).Value = 1280
>> args1(17).Name = "SearchItem.Command"
>> args1(17).Value = 0
>> args1(18).Name = "Quiet"
>> args1(18).Value = true
>>
>> dispatcher.executeDispatch(**document, ".uno:ExecuteSearch", "", 0,
>> args1())
>>
>> rem ------------------------------**------------------------------**
>> ----------
>> dim args2(18) as new com.sun.star.beans.**PropertyValue
>> args2(0).Name = "SearchItem.StyleFamily"
>> args2(0).Value = 2
>> args2(1).Name = "SearchItem.CellType"
>> args2(1).Value = 0
>> args2(2).Name = "SearchItem.RowDirection"
>> args2(2).Value = true
>> args2(3).Name = "SearchItem.AllTables"
>> args2(3).Value = false
>> args2(4).Name = "SearchItem.Backward"
>> args2(4).Value = false
>> args2(5).Name = "SearchItem.Pattern"
>> args2(5).Value = false
>> args2(6).Name = "SearchItem.Content"
>> args2(6).Value = false
>> args2(7).Name = "SearchItem.AsianOptions"
>> args2(7).Value = false
>> args2(8).Name = "SearchItem.AlgorithmType"
>> args2(8).Value = 0
>> args2(9).Name = "SearchItem.SearchFlags"
>> args2(9).Value = 65536
>> args2(10).Name = "SearchItem.SearchString"
>> args2(10).Value = "  "
>> args2(11).Name = "SearchItem.ReplaceString"
>> args2(11).Value = " "
>> args2(12).Name = "SearchItem.Locale"
>> args2(12).Value = 255
>> args2(13).Name = "SearchItem.ChangedChars"
>> args2(13).Value = 2
>> args2(14).Name = "SearchItem.DeletedChars"
>> args2(14).Value = 2
>> args2(15).Name = "SearchItem.InsertedChars"
>> args2(15).Value = 2
>> args2(16).Name = "SearchItem.**TransliterateFlags"
>> args2(16).Value = 1280
>> args2(17).Name = "SearchItem.Command"
>> args2(17).Value = 3
>> args2(18).Name = "Quiet"
>> args2(18).Value = true
>>
>> dispatcher.executeDispatch(**document, ".uno:ExecuteSearch", "", 0,
>> args2())
>>
>>
>> end sub
>>
>>
>>  I am even newer to this macro stuff than the op.  I could use this
> capability
> that you show above.  Some questions:
> 1. How can I import this code, or must I copy it in by hand?
>
If the code is contained in another file, you can import the code from the
file to your library.  Open the OpenOffice.org Basic Macro Organizer
dialog, under Libraries tab, click Import...
Otherwise, I think you must write the code by hand.

2. I assume there is a way to name this macro, but the name doesn't
> appear in the code; what is it called? (I'm unfamiliar with macro naming
> conventions.)
>
You can create model, sub, or function with any name you want except using
keyword as the name.

3. Once imported and a macro made out of it, is it then available for any
> document you might open? (I also assume it is saved on the drive,
> somewhere.)
>
Yes. You can specify the document path in Macro code, and call macro API to
open the document.

4. How do you call it?
>
You can calling a Sub from the User Interface.  Please refer to
http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/Basic/Calling_a_Sub_from_the_User_Interface

5. Would you expect the same code to work in Symphony?  I prefer this close
> cousin of OO as it seems more user-friendly to me.
>
Yes, the same code works in Symphony.

>
> --doug
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: ooo-users-unsubscribe@**incubator.apache.org<ooo-users-unsubscribe@incubator.apache.org>
> For additional commands, e-mail: ooo-users-help@incubator.**apache.org<ooo-users-help@incubator.apache.org>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message