Sometimes Calc seems to stop responding when doing a Pivot table operation. For example, I start an app which used to work, to create a cash break down summary. Sheet 1, is the raw data, Sheet 2 is the pivot sheet. The first run, with LibreOffice closed works fine. The 2nd run, with LibreOffice already open just freezes up completely. The calling process also freezes too. If LibreOffice is killed with the task manager (tskill) and the calling process unfreezes. If an attempt to generate the report is made, just like the first time, with no LibreOffice open, the system works fine. It seems UNO_ExecuteDispatch(".uno:InsertRowsBefore") Is the culprit. If I put a 125 ms sleep in between successive InsertRowsBefore, the problem goes away. For example: for(int i=0;i<100;i++) UNO_ExecuteDispatch(".uno:InsertRowsBefore"); Causes Calc to freeze. If we do this: for(int i=0;i<100;i++){ Sleep(125); UNO_ExecuteDispatch(".uno:InsertRowsBefore"); } all is good, albeit a little slower.
Could you provide us an example file for us to reproduce ? Also, please check in safe mode in Help > Restart in Safe Mode and paste here the info of you libreoffice from help > About Libreoffice. There is an icon which paste the info into the clipboard Thanks
Version: 25.2.2.2 (X86_64) / LibreOffice Community Build ID: 7370d4be9e3cf6031a51beef54ff3bda878e3fac CPU threads: 20; OS: Windows 10 X86_64 (10.0 build 20348); UI render: default; VCL: win Locale: en-CA (en_CA); UI: en-US Calc: threaded
It's not a particular file that has issues, it seems, when I am automating LibreOffice from a C++ application, LibreOffice (LO) often just freezes all of a sudden. This happens for both Calc and Writer. I have noticed if I purposely throttle things, then the problem of freezing goes away. For example, we generate jewelry labels in Writer to be printer on a label printer. Normally, we can generate 100 labels that have a data matrix barcode, price, description, etc. That will happen without a problem, but now, sometimes randomly after any unpredictable number of labels, LO just freezes. We have to kill LO from the Windows Task manager. I have tried putting in a Sleep of 400ms in between each label generation, which mostly helps -- not less chances of freezing, but occasionally it freezes. LO 24.8 and prior didn't have these issues. It's a new issue in 25.2.2.2
Created attachment 200705 [details] Labels that work sometimes but freezes at others This is an example file where we generated labels and they actually worked. At other times, a label will just stop mid-way. For example, the price won't come and LibreOffice (LO) just freezes before outputting the price and proceeding onto the rest of the labels to add to the document.
I'm not familiar with the UNO_ExecuteDispatch, but I can compile the c++ code if you provide the minimal example how you use it Could you also provide a file that you automate from the c++ code
Created attachment 200708 [details] UNO_ExecuteDispatch C++ This is a small example of how UNO_ExecuteDispatch works. In our main application, we've built a wrapper class around it and it would be too large to post to illustrate a point.
We have essentially wrapped LibreOffice's executeDispatch function, which we call UNO_ExecuteDispatch, so it resembles the VBA-like macro LibreOffice creates when using the Macro Recorder. For example to create a table in Writer, the VBA would look like this: 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(3) as new com.sun.star.beans.PropertyValue args1(0).Name = "TableName" args1(0).Value = "" args1(1).Name = "Columns" args1(1).Value = 40 args1(2).Name = "Rows" args1(2).Value = 4 args1(3).Name = "Flags" args1(3).Value = 9 dispatcher.executeDispatch(document, ".uno:InsertTable", "", 0, args1()) Our with our C++ wrappers it looks like this: void InsertTable(int iRows, int iCols) { Sequence<PropertyValue> args1(4); UNO_SeqArgMaker(args1[0], "TableName", ""); UNO_SeqArgMaker(args1[1], "Columns", ( sal_Int32 ) iCols); UNO_SeqArgMaker(args1[2], "Rows", ( sal_Int32 ) iRows); UNO_SeqArgMaker(args1[3], "Flags", ( sal_Int8 ) 9); UNO_ExecuteDispatch(".uno:InsertTable", "", 0, &args1); } ----------------------------------------------------------------------- bool UNO_ExecuteDispatch( std::string strUNOCommandURL, std::string TargetFrameName, ::sal_Int32 SearchFlags, const::css::uno::Sequence<::css::beans::PropertyValue>* arguments) { try { const::css::uno::Sequence<::css::beans::PropertyValue> array(0); if ( arguments == nullptr ) arguments = &array; m_rDispatchService->executeDispatch(m_rDispatchReceivingWindow, StringToOUString(strUNOCommandURL), StringToOUString(TargetFrameName), SearchFlags, *arguments); return true; } catch ( ... ) { return false; } } // SEQUENCE ARRAY HELPER FUNCTIONS void UNO_SeqArgMaker(com::sun::star::beans::PropertyValue &argIndexValue, std::string name, sal_Int32 value) { argIndexValue.Name = StringToOUString(name); argIndexValue.Value <<= value; } void UNO_SeqArgMaker(com::sun::star::beans::PropertyValue &argIndexValue, std::string name, sal_Int16 value) { argIndexValue.Name = StringToOUString(name); argIndexValue.Value <<= value; } void UNO_SeqArgMaker(com::sun::star::beans::PropertyValue &argIndexValue, std::string name, sal_Int8 value) { argIndexValue.Name = StringToOUString(name); argIndexValue.Value <<= value; } void UNO_SeqArgMaker(com::sun::star::beans::PropertyValue &argIndexValue, std::string name, sal_Bool value) { argIndexValue.Name = StringToOUString(name); argIndexValue.Value <<= value; } void UNO_SeqArgMaker(com::sun::star::beans::PropertyValue &argIndexValue, std::string name, std::string value) { argIndexValue.Name = StringToOUString(name); argIndexValue.Value <<= StringToOUString(value); }
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
1) I am going to try 25.2.3.2 to see if that fixes the issue. 2) I can not seem to reproduce it on my workstation, but on 4 x Windows server 2022 session hosts, the current freezing problem still exists. This includes mainly generating labels in Writer, but problem of information too fast also present in Calc. 3) If the problem persists after 25.2.3.2 -- which is a production environment, I will downgrade to 24.8, since it's a production environment (user's complaining if things keep breaking.)
25.2.3.2 - Still having freeze issues. I had no choice but to downgrade to 24.8. When I downgraded the problem went away. The environment is a Windows server 2022 - Remote Desktop Session host. We have 4 hosts and all them them experienced the exact same issues with 25.2.x. There must be something specific to the server editions that's happening. The same issues doesn't happen on my Windows 10 Pro workstation.