Apache OpenOffice (AOO) Bugzilla – Issue 20864
Poor Macro performance...
Last modified: 2013-08-07 14:38:26 UTC
I am trying to edit a 120 page document and I have created a small macro to search for a text string and then delete a number of files. I then assigned the F4 key to it to repeat it manually many times. The macro runs OK, but 2 things: 1. I told it to delete X lines and it only deletes X-1 lines 2. It runs very sporadically. Often with no problems but over half of the F4 presses have resulted in pauses, where it starts, then stops, and then starts again. I have posted a copy of the macro below. ================================================================================ REM ***** BASIC ***** Sub Main End Sub sub Test1 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 = "IRONBARK" 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(1) as new com.sun.star.beans.PropertyValue args2(0).Name = "Count" args2(0).Value = 1 args2(1).Name = "Select" args2(1).Value = true dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args2()) rem ---------------------------------------------------------------------- dim args3(1) as new com.sun.star.beans.PropertyValue args3(0).Name = "Count" args3(0).Value = 1 args3(1).Name = "Select" args3(1).Value = true dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args3()) rem ---------------------------------------------------------------------- dim args4(1) as new com.sun.star.beans.PropertyValue args4(0).Name = "Count" args4(0).Value = 1 args4(1).Name = "Select" args4(1).Value = true dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args4()) rem ---------------------------------------------------------------------- dim args5(1) as new com.sun.star.beans.PropertyValue args5(0).Name = "Count" args5(0).Value = 1 args5(1).Name = "Select" args5(1).Value = true dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args5()) rem ---------------------------------------------------------------------- dim args6(1) as new com.sun.star.beans.PropertyValue args6(0).Name = "Count" args6(0).Value = 1 args6(1).Name = "Select" args6(1).Value = true dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args6()) rem ---------------------------------------------------------------------- dim args7(1) as new com.sun.star.beans.PropertyValue args7(0).Name = "Count" args7(0).Value = 1 args7(1).Name = "Select" args7(1).Value = true dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args7()) rem ---------------------------------------------------------------------- dim args8(1) as new com.sun.star.beans.PropertyValue args8(0).Name = "Count" args8(0).Value = 1 args8(1).Name = "Select" args8(1).Value = true dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args8()) rem ---------------------------------------------------------------------- dim args9(1) as new com.sun.star.beans.PropertyValue args9(0).Name = "Count" args9(0).Value = 1 args9(1).Name = "Select" args9(1).Value = true dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args9()) rem ---------------------------------------------------------------------- dim args10(1) as new com.sun.star.beans.PropertyValue args10(0).Name = "Count" args10(0).Value = 1 args10(1).Name = "Select" args10(1).Value = true dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args10()) rem ---------------------------------------------------------------------- dim args11(1) as new com.sun.star.beans.PropertyValue args11(0).Name = "Count" args11(0).Value = 1 args11(1).Name = "Select" args11(1).Value = true dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args11()) rem ---------------------------------------------------------------------- dim args12(1) as new com.sun.star.beans.PropertyValue args12(0).Name = "Count" args12(0).Value = 1 args12(1).Name = "Select" args12(1).Value = true dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args12()) rem ---------------------------------------------------------------------- dim args13(1) as new com.sun.star.beans.PropertyValue args13(0).Name = "Count" args13(0).Value = 1 args13(1).Name = "Select" args13(1).Value = true dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args13()) rem ---------------------------------------------------------------------- dim args14(1) as new com.sun.star.beans.PropertyValue args14(0).Name = "Count" args14(0).Value = 1 args14(1).Name = "Select" args14(1).Value = true dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args14()) rem ---------------------------------------------------------------------- dim args15(1) as new com.sun.star.beans.PropertyValue args15(0).Name = "Count" args15(0).Value = 1 args15(1).Name = "Select" args15(1).Value = true dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args15()) rem ---------------------------------------------------------------------- dim args16(1) as new com.sun.star.beans.PropertyValue args16(0).Name = "Count" args16(0).Value = 1 args16(1).Name = "Select" args16(1).Value = true dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args16()) rem ---------------------------------------------------------------------- dim args17(1) as new com.sun.star.beans.PropertyValue args17(0).Name = "Count" args17(0).Value = 1 args17(1).Name = "Select" args17(1).Value = true dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args17()) rem ---------------------------------------------------------------------- dim args18(1) as new com.sun.star.beans.PropertyValue args18(0).Name = "Count" args18(0).Value = 1 args18(1).Name = "Select" args18(1).Value = true dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args18()) rem ---------------------------------------------------------------------- dim args19(1) as new com.sun.star.beans.PropertyValue args19(0).Name = "Count" args19(0).Value = 1 args19(1).Name = "Select" args19(1).Value = true dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args19()) rem ---------------------------------------------------------------------- dim args20(1) as new com.sun.star.beans.PropertyValue args20(0).Name = "Count" args20(0).Value = 1 args20(1).Name = "Select" args20(1).Value = true dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args20()) rem ---------------------------------------------------------------------- dim args21(1) as new com.sun.star.beans.PropertyValue args21(0).Name = "Count" args21(0).Value = 1 args21(1).Name = "Select" args21(1).Value = true dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args21()) rem ---------------------------------------------------------------------- dim args22(1) as new com.sun.star.beans.PropertyValue args22(0).Name = "Count" args22(0).Value = 1 args22(1).Name = "Select" args22(1).Value = true dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args22()) rem ---------------------------------------------------------------------- dim args23(1) as new com.sun.star.beans.PropertyValue args23(0).Name = "Count" args23(0).Value = 1 args23(1).Name = "Select" args23(1).Value = true dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args23()) rem ---------------------------------------------------------------------- dim args24(1) as new com.sun.star.beans.PropertyValue args24(0).Name = "Count" args24(0).Value = 1 args24(1).Name = "Select" args24(1).Value = true dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args24()) rem ---------------------------------------------------------------------- dim args25(1) as new com.sun.star.beans.PropertyValue args25(0).Name = "Count" args25(0).Value = 1 args25(1).Name = "Select" args25(1).Value = true dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args25()) rem ---------------------------------------------------------------------- dim args26(1) as new com.sun.star.beans.PropertyValue args26(0).Name = "Count" args26(0).Value = 1 args26(1).Name = "Select" args26(1).Value = true dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args26()) rem ---------------------------------------------------------------------- dim args27(1) as new com.sun.star.beans.PropertyValue args27(0).Name = "Count" args27(0).Value = 1 args27(1).Name = "Select" args27(1).Value = true dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args27()) rem ---------------------------------------------------------------------- dim args28(1) as new com.sun.star.beans.PropertyValue args28(0).Name = "Count" args28(0).Value = 1 args28(1).Name = "Select" args28(1).Value = true dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args28()) rem ---------------------------------------------------------------------- dispatcher.executeDispatch(document, ".uno:EndOfLineSel", "", 0, Array()) rem ---------------------------------------------------------------------- dispatcher.executeDispatch(document, ".uno:Delete", "", 0, Array()) rem ---------------------------------------------------------------------- dispatcher.executeDispatch(document, ".uno:SwBackspace", "", 0, Array()) rem ---------------------------------------------------------------------- dispatcher.executeDispatch(document, ".uno:SwBackspace", "", 0, Array()) rem ---------------------------------------------------------------------- dispatcher.executeDispatch(document, ".uno:SwBackspace", "", 0, Array()) rem ---------------------------------------------------------------------- dispatcher.executeDispatch(document, ".uno:SwBackspace", "", 0, Array()) rem ---------------------------------------------------------------------- dispatcher.executeDispatch(document, ".uno:SwBackspace", "", 0, Array()) rem ---------------------------------------------------------------------- dispatcher.executeDispatch(document, ".uno:SwBackspace", "", 0, Array()) rem ---------------------------------------------------------------------- dispatcher.executeDispatch(document, ".uno:SwBackspace", "", 0, Array()) end sub ================================================================================
please discuss this in the mailing list, maybe there is somebody can help/confirm
I have given up on OOo for this document and gone back to Word 97 and it works OK. I have discovered something else about macros though. In Word, you create your macro - which is just a collection of keystrokes - that you wish to perform. Then you map it to a key and hit the key to run the macro. In this case, with such a large document, I have mapped it to the F4 key, and just held the key down to auto-repeat the macro and it zooms through the document, making the required changes. I tried the same thing in OOo and because of the previously mentioned delays I could only hit the F4 key every second or two. If I tried to hit it more frequently, OOo seemed to lose it's way and start the next macro (with the next F4 depression) before the first one was completed and so it cut the wrong lines out of the document. If I hold the F4 key down (as in MS Word), it cut the document to pieces. I have tried this on two different PCs (both with MS Office 97 and OOo 1.1RC5 installed) and have created some more, simpler, macros - like remove a tab, step down a line and then delete that next line - and OOo suffers in the same way, cutting up the document as the next macro iteration starts before the first one has completed, while MS Word works perfectly.
reassigend to sw can you please take a look on this issue?
SW->CN: please take a look at this
I've created a bugdoc which shows the effect very easily. Open bugdoc and go to end of document. Assign the macro of the document to a keyboard-key you like. The macro deletes the word "Hallo" so only "Welt" should stay. If you hold down your key you will see some "mistakes"
cn->ab: maybe it's an problem with rescheduling. Fixable with new scripting framework?
cn->ab: sorry for submitting late, but handling of issuzilla sometimes make trouble ;-)
grrr
Has to be evaluated...
ab->cn: Marcro events now are executed using the Scripting Framework. The Basic ScriptProvider prevents multiple calls to Basic. So if this was the problem it should be fixed now. I tested capstone737's macro and it seemed to work ok. Where is your bugdoc? There's no attachment and I didn't find it on Q: either. Could you please have a look and close this task if you also think the problem is fixed.
ok in src680_m124
close