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

--- Comment #8 from Mateusz Wlazłowski <mateusz....@gmail.com> ---
I asked chatgpt to generate me a python script to insert rows below using
ExecuteDispatch(".uno:InsertRowsBefore");. Added those files in
~/.config/libreoffice/4/user/Scripts/python (for windows the path is similar).
Opened Calc, and ran them both from Tools > Macros > Organize Macros... >
Python and I saw no issues ; Calc inserted 100 rows before without pause


In order for me to confirm it please include :
1- A project which can be used to build the c++ code. The aim is to be able to
click on "build" and the executable will be built to reproduce the issue.
Include only the bare minimum of code in order to reproduce the code. The aim
is not to loose time understanding how your entire project is made, nor take
the time how it works. I'm thinking notably about UNO_ExecuteDispatch
2- Include the executable from said project and say how to use it along with
the file to automate. In the end, it is possible to quickly reproduce the issue
without spending too much time installing and configuring Visual Studio, or
dealing with the additional space it requires
I have a VM of windows so downloading executables like this is not an issue for
me



insert2.py
def insert_100_rows_before_row_3_dispatch():
    doc = XSCRIPTCONTEXT.getDocument()
    sheet = doc.Sheets[0]
    controller = doc.getCurrentController()
    frame = controller.getFrame()

    # Select row 3 (index 2 in UNO)
    cell = sheet.getCellByPosition(0, 2)  # Column A, Row 3
    controller.select(cell)

    # Prepare dispatcher
    ctx = XSCRIPTCONTEXT.getComponentContext()
    dispatcher = ctx.ServiceManager.createInstanceWithContext(
        "com.sun.star.frame.DispatchHelper", ctx
    )

    # Execute InsertRowsBefore 100 times
    for _ in range(100):
        dispatcher.executeDispatch(frame, ".uno:InsertRowsBefore", "", 0, ())


insert.py
def insert_100_rows_before_row_3():
    doc = XSCRIPTCONTEXT.getDocument()
    sheet = doc.Sheets[0]  # Access the first sheet (you can change index if
needed)

    row_index = 2  # Row 3 in user terms (0-based index)
    num_rows_to_insert = 100

    sheet.Rows.insertByIndex(row_index, num_rows_to_insert)


Version: 25.2.2.1 (X86_64) / LibreOffice Community
Build ID: 38d746d66d9b82fa248a2e90142b9dd3ddd1d6cd
CPU threads: 8; OS: Linux 6.11; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to