https://bugs.documentfoundation.org/show_bug.cgi?id=92872

C. Andrews Lavarre <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |UNCONFIRMED
     Ever confirmed|1                           |0

--- Comment #3 from C. Andrews Lavarre <[email protected]> ---
The bug is repeatable. Attached is a spreadsheet that I use.

There are two buttons at the top of columns J and K:  Process and Arrange.

"Process" runs the macro "f2b_proc" (see below). "Arrange" runs the macro
d2b_fix.

The procedure is the following:

I manually copy text in two columns from a terminal window in this form:
     21 117.21.0.0
     22 50.63.0.0
     31 218.87.0.0
     33 218.65.0.0
     51 61.160.0.0
     67 43.229.0.0
    101 221.229.0.0
    139 58.218.0.0
    143 222.186.0.0
    521 43.255.0.0
(these are data from fail2ban on number of failed attempts by the indicated IP
subnet). 

1. I paste the data, which invokes the "Data > Text to Columns" routine  to
parse the text into two columns in the current row at columns E and F.

2. I run "Process" (f2b_proc) to sort them DESCENDING on the first column (E),
then cut and paste TRANSPOSE to current row, column J. The first time I run
"Process" it correctly sorts, but the cut and paste fail. If I run "Process"
again it succeeds.

3. Now the data are transposed in the two-row form
521    143    139    101    67    51    33    31    22    21
43.255.0.0    222.186.0.0    58.218.0.0    221.229.0.0    43.229.0.0   
61.160.0.0    218.65.0.0    218.87.0.0    50.63.0.0    117.21.0.0

beginning at current row, column J.

4. I click Arrange (f2b_fix) to move column K

143
222.186.0.0

two columns to the right to column M.

I have added wait 1000 statements at various spots in both routines to have
them work (sort of) but it still fails. The 143 column is cut, the array is
properly opened and moved, but the paste fails.

===== 
Not a huge deal, but interesting. There seems to be some kind of unseen process
messing up the timing since inserting wait statements definitely does affect
the behaviour for the better.

Thanks again.

==================== Macro Language ====================
sub f2b_proc
' This routine was updated 7/19/2015 by C. Andrews Lavarre.
'    It sorts an array of data and moves it to the desired location 
' Define variables
    dim document   as Object
    dim dispatcher as object
    dim osheet as object
    dim ocell as object
    dim irow As Integer
'    Multi-dimensional argument arrays
    dim args0(0) as new com.sun.star.beans.PropertyValue
    dim args1(1) as new com.sun.star.beans.PropertyValue
    dim args5(5) as new com.sun.star.beans.PropertyValue
    dim args7(7) as new com.sun.star.beans.PropertyValue
    Dim saddr As String    'The cell address in $A$1 format    
' Get access to the document
    document   = ThisComponent.CurrentController.Frame
    dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
'Save the start point
    oCell = ThisComponent.getCurrentSelection()
    irow = oCell.CellAddress.Row + 1
    saddr = "$E$" & CStr(irow)
' Load the argument:
    args0(0).Name = "By"
    args0(0).Value = 1
' Select the entire array    
    dispatcher.executeDispatch(document, ".uno:GoRightSel", "", 0, args0())
    dispatcher.executeDispatch(document, ".uno:GoDownToEndOfDataSel", "", 0,
args0())
'Sort Descending
    args7(0).Name = "ByRows"
    args7(0).Value = true
    args7(1).Name = "HasHeader"
    args7(1).Value = false
    args7(2).Name = "CaseSensitive"
    args7(2).Value = false
    args7(3).Name = "NaturalSort"
    args7(3).Value = false
    args7(4).Name = "IncludeAttribs"
    args7(4).Value = true
    args7(5).Name = "UserDefIndex"
    args7(5).Value = 0
    args7(6).Name = "Col1"
    args7(6).Value = 5
    args7(7).Name = "Ascending1"
    args7(7).Value = false
    dispatcher.executeDispatch(document, ".uno:DataSort", "", 0, args7())
    dispatcher.executeDispatch(document, ".uno:Cut", "", 0, Array())
'Go right five cells
    saddr = "$J" &"$" & CStr(irow)
    args0(0).Name = "ToPoint"
    args0(0).Value = saddr
    dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args0())
    wait 1000
' Paste transposed
    args5(0).Name = "Flags"
    args5(0).Value = "A"
    args5(1).Name = "FormulaCommand"
    args5(1).Value = 0
    args5(2).Name = "SkipEmptyCells"
    args5(2).Value = false
    args5(3).Name = "Transpose"
    args5(3).Value = true
    args5(4).Name = "AsLink"
    args5(4).Value = false
    args5(5).Name = "MoveMode"
    args5(5).Value = 4
    dispatcher.executeDispatch(document, ".uno:InsertContents", "", 0, args5())
' Deselect
    dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args0())
end Sub

sub f2b_fix
' This routine was updated 7/22/15 by C. Andrews Lavarre.
'    It splits an array to move an element to a given column.
' define variables
    dim document   as Object
    dim dispatcher as object
' ----------------------------------------------------------------------
' get access to the document
    document   = ThisComponent.CurrentController.Frame    
    dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
' Declare multidimensional arguments
    dim args0(0) as new com.sun.star.beans.PropertyValue
    dim args1(1) as new com.sun.star.beans.PropertyValue
' Go right four cells
    args1(0).Name = "By"
    args1(0).Value = 4
    args1(1).Name = "Sel"
    args1(1).Value = false
    dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args1())
' Split the array
    args0(0).Name = "By"
    args0(0).Value = 1
    dispatcher.executeDispatch(document, ".uno:GoDownSel", "", 0, args0())
    args0(0).Name = "Flags"
    args0(0).Value = ">"
    dispatcher.executeDispatch(document, ".uno:InsertCell", "", 0, args0())
' Go back three cells
    args1(0).Name = "By"
    args1(0).Value = 3
    args1(1).Name = "Sel"
    args1(1).Value = false
    dispatcher.executeDispatch(document, ".uno:GoLeft", "", 0, args1())
' Cut the cells
    args0(0).Name = "By"
    args0(0).Value = 1
    dispatcher.executeDispatch(document, ".uno:GoDownSel", "", 0, args0())
    dispatcher.executeDispatch(document, ".uno:Cut", "", 0, Array())
    wait 1000
' Go right three cells
    args1(0).Name = "By"
    args1(0).Value = 3
    args1(1).Name = "Sel"
    args1(1).Value = false
    dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args1())
' Paste them
    dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())
    wait 1000
' Go back three cells
    args1(0).Name = "By"
    args1(0).Value = 3
    args1(1).Name = "Sel"
    args1(1).Value = false
    dispatcher.executeDispatch(document, ".uno:GoLeft", "", 0, args1())
' Close up the array
    args0(0).Name = "By"
    args0(0).Value = 1
    dispatcher.executeDispatch(document, ".uno:GoDownSel", "", 0, args0())
    args0(0).Name = "Flags"
    args0(0).Value = "L"
    dispatcher.executeDispatch(document, ".uno:DeleteCell", "", 0, args0())
' Go to the start of the IP row
    args1(0).Name = "By"
    args1(0).Value = 1
    args1(1).Name = "Sel"
    args1(1).Value = false
    dispatcher.executeDispatch(document, ".uno:GoLeft", "", 0, args1())
    dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args1())
' Delete the row
    dispatcher.executeDispatch(document, ".uno:SelectRow", "", 0, Array())
    args0(0).Name = "Flags"
    args0(0).Value = "R"
    dispatcher.executeDispatch(document, ".uno:DeleteCell", "", 0, args0())
end sub

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to