Download it now!
Bug 99317 - Python UNO sort hangs in Calc
Summary: Python UNO sort hangs in Calc
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
5.1.1.3 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Macro-Python
  Show dependency treegraph
 
Reported: 2016-04-15 09:36 UTC by Quinton
Modified: 2019-12-04 11:37 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Sample SRC XLS file (11.00 KB, application/vnd.ms-excel)
2016-04-15 09:36 UTC, Quinton
Details
Python Sort Sample script (6.02 KB, text/x-python)
2016-04-15 11:39 UTC, Quinton
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Quinton 2016-04-15 09:36:08 UTC
Created attachment 124356 [details]
Sample SRC XLS file

Libre Calc hangs when doing a sort via the UNO API.

This worked in Calc all versions prior to 5.1.
This previously also affected the GUI but was fixed after bug report 99208.

Here is sample python code that triggers the problem.

"""
frame = SRCXLSDoc.CurrentController.getFrame()
	dispHelper = context.ServiceManager.createInstance("com.sun.star.frame.DispatchHelper")
	sortproptuple=()
	
	PropVal = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
	PropVal.Name = 'ByRows'
	PropVal.Value = True
	sortproptuple+=(PropVal,)
	
	PropVal = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
	PropVal.Name = 'HasHeader'
	PropVal.Value = True
	sortproptuple+=(PropVal,)
	
	PropVal = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
	PropVal.Name = 'CaseSensitive'
	PropVal.Value = False
	sortproptuple+=(PropVal,)
	
	PropVal = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
	PropVal.Name = 'NaturalSort'
	PropVal.Value = True
	sortproptuple+=(PropVal,)
	
	PropVal = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
	PropVal.Name = 'IncludeAttribs'
	PropVal.Value = True
	sortproptuple+=(PropVal,)
	
	PropVal = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
	PropVal.Name = 'UserDefIndex'
	PropVal.Value = 0
	sortproptuple+=(PropVal,)
	
	PropVal = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
	PropVal.Name = 'Col1'
	PropVal.Value = Sortbycolnum
	sortproptuple+=(PropVal,)
	
	PropVal = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
	PropVal.Name = 'Ascending1'
	PropVal.Value = True
	sortproptuple+=(PropVal,)
	#This datasort freezes libre >=5.1
	dispHelper.executeDispatch(frame, ".uno:DataSort","", 0, (sortproptuple))
"""
Comment 1 Julien Nabet 2016-04-15 10:46:12 UTC
How to use the Python code to trigger this?
Indeed, I can't add a macro in Python (the "Create" button is disabled, bug?).
Comment 2 Quinton 2016-04-15 11:39:22 UTC
Created attachment 124360 [details]
Python Sort Sample script

Here is a sample python script that sorts the previously attached XLS file.
Comment 3 Quinton 2016-04-15 11:40:33 UTC
(In reply to Julien Nabet from comment #1)
> How to use the Python code to trigger this?
> Indeed, I can't add a macro in Python (the "Create" button is disabled,
> bug?).

Hi Julian,

I have attached a sample Python sort script.
Comment 4 Julien Nabet 2016-04-16 14:16:39 UTC
Quinton: thank you for your feedback. However, it seems a script for Windows env so I can't help here. Certainly someone with all your info may give a try and help.
Comment 5 raal 2016-04-17 17:19:00 UTC
Tested with LO 5.0.5 and 5.1.2 and I doesn't see a difference>

file "XA003-800000A_BOM.xls" I copied  into C:\Program Files\LibreOffice 5\program and to the same directory as python_sort_sample.py is.



Win7;5.1.2(64):
C:\Program Files\LibreOffice 5\program>python.exe \\VBOXSVR\tmp\python_sort_samp
le.py
Closing SOffice.exe instances
Attempting to open an UNO socket, count: 0
Processing Source Files.
Traceback (most recent call last):
  File "\\VBOXSVR\tmp\python_sort_sample.py", line 170, in <module>
    runProgram()
  File "\\VBOXSVR\tmp\python_sort_sample.py", line 164, in runProgram
    tmpQColNumDictBOM=fileCheckSortSave97Xls(desktop,"file:///"+os.path.abspath(
"XA003-800000A_BOM.xls").replace("\\","/"),"21",context)
  File "\\VBOXSVR\tmp\python_sort_sample.py", line 153, in fileCheckSortSave97Xl
s
    SRCXLSDoc.storeAsURL(filenameurl,(propval,))
__main__.ErrorCodeIOException: SfxBaseModel::storeSelf: 0x4c0c

5.0.5(64):
C:\Program Files\LibreOffice 5\program>python.exe \\VBOXSVR\tmp\python_sort_samp
le.py
Closing SOffice.exe instances
Attempting to open an UNO socket, count: 0
Processing Source Files.
Traceback (most recent call last):
  File "\\VBOXSVR\tmp\python_sort_sample.py", line 170, in <module>
    runProgram()
  File "\\VBOXSVR\tmp\python_sort_sample.py", line 164, in runProgram
    tmpQColNumDictBOM=fileCheckSortSave97Xls(desktop,"file:///"+os.path.abspath(
"XA003-800000A_BOM.xls").replace("\\","/"),"21",context)
  File "\\VBOXSVR\tmp\python_sort_sample.py", line 153, in fileCheckSortSave97Xl
s
    SRCXLSDoc.storeAsURL(filenameurl,(propval,))
__main__.ErrorCodeIOException: SfxBaseModel::storeSelf: 0x4c0c
Comment 6 Quinton 2016-04-18 05:29:25 UTC
(In reply to raal from comment #5)
> Tested with LO 5.0.5 and 5.1.2 and I doesn't see a difference>
> 
> file "XA003-800000A_BOM.xls" I copied  into C:\Program Files\LibreOffice
> 5\program and to the same directory as python_sort_sample.py is.
> 
> 
> 
> Win7;5.1.2(64):
> C:\Program Files\LibreOffice 5\program>python.exe
> \\VBOXSVR\tmp\python_sort_samp
> le.py
> Closing SOffice.exe instances
> Attempting to open an UNO socket, count: 0
> Processing Source Files.
> Traceback (most recent call last):
>   File "\\VBOXSVR\tmp\python_sort_sample.py", line 170, in <module>
>     runProgram()
>   File "\\VBOXSVR\tmp\python_sort_sample.py", line 164, in runProgram
>    
> tmpQColNumDictBOM=fileCheckSortSave97Xls(desktop,"file:///"+os.path.abspath(
> "XA003-800000A_BOM.xls").replace("\\","/"),"21",context)
>   File "\\VBOXSVR\tmp\python_sort_sample.py", line 153, in
> fileCheckSortSave97Xl
> s
>     SRCXLSDoc.storeAsURL(filenameurl,(propval,))
> __main__.ErrorCodeIOException: SfxBaseModel::storeSelf: 0x4c0c
> 
> 5.0.5(64):
> C:\Program Files\LibreOffice 5\program>python.exe
> \\VBOXSVR\tmp\python_sort_samp
> le.py
> Closing SOffice.exe instances
> Attempting to open an UNO socket, count: 0
> Processing Source Files.
> Traceback (most recent call last):
>   File "\\VBOXSVR\tmp\python_sort_sample.py", line 170, in <module>
>     runProgram()
>   File "\\VBOXSVR\tmp\python_sort_sample.py", line 164, in runProgram
>    
> tmpQColNumDictBOM=fileCheckSortSave97Xls(desktop,"file:///"+os.path.abspath(
> "XA003-800000A_BOM.xls").replace("\\","/"),"21",context)
>   File "\\VBOXSVR\tmp\python_sort_sample.py", line 153, in
> fileCheckSortSave97Xl
> s
>     SRCXLSDoc.storeAsURL(filenameurl,(propval,))
> __main__.ErrorCodeIOException: SfxBaseModel::storeSelf: 0x4c0c

Hi Raal,

Thank you for having a look.

A SMB type path("\\VBOXSVR\tmp") will most likely not open.
If you copy the file to the windows OS drive like "c:\tmp" it should work better.

We first noticed the freeze occur on a Windows 7 64bit PC. 

The script I run is a bit different, but the one I gave you should be able to trigger the problem.

Here is sample output from my script run on three different Libre installs;

Using SOfficeBin(5.0.5.2): C:\Program Files\LibreOffice 5\program\soffice.exe
Closing SOffice.exe instances
Generating odt docs: 'Title not defined', 'XA003-150000' 'None' 'A'

Attempting to open an UNO socket, count: 0
Processing Source Files.
freeze expected
freeze avoided
freeze expected
freeze avoided
freeze expected
freeze avoided
freeze expected
freeze avoided
freeze expected
freeze avoided
freeze expected
freeze avoided
freeze expected
freeze avoided
freeze expected
freeze avoided
Creating BOM
...

###
Using SOfficeBin(5.2.0.0.alpha0): C:\Program Files\LibreOfficeDev 5\program\soffice.exe
Closing SOffice.exe instances
Generating odt docs: 'Title not defined', 'XA003-150000' 'None' 'A'

Attempting to open an UNO socket, count: 0
Attempting to open an UNO socket, count: 1
Processing Source Files.
freeze expected

###
Using SOfficeBin(5.1.2.2): C:\Program Files\LibreOffice 5\program\soffice.exe
Closing SOffice.exe instances
Generating odt docs: 'Title not defined', 'XA003-150000' 'None' 'A'

Attempting to open an UNO socket, count: 0
Attempting to open an UNO socket, count: 1
Attempting to open an UNO socket, count: 2
Processing Source Files.
Comment 7 Quinton 2016-04-18 05:32:28 UTC
###
Using SOfficeBin(5.1.2.2): C:\Program Files\LibreOffice 5\program\soffice.exe
Closing SOffice.exe instances
Generating odt docs: 'Title not defined', 'XA003-150000' 'None' 'A'

Attempting to open an UNO socket, count: 0
Processing Source Files.
freeze expected
Comment 8 Quinton 2016-04-18 05:37:16 UTC
The freeze happens at the end of this func.
###
def SortSheetBy(context,SRCXLSDoc,mysheet,Sortbycolnum):
	frame = SRCXLSDoc.CurrentController.getFrame()
	#print(frame)
	dispHelper = context.ServiceManager.createInstance("com.sun.star.frame.DispatchHelper")
	#print(dispHelper)
	sortproptuple=()
	
	PropVal = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
	PropVal.Name = 'ByRows'
	PropVal.Value = True
	sortproptuple+=(PropVal,)
	
	PropVal = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
	PropVal.Name = 'HasHeader'
	PropVal.Value = True
	sortproptuple+=(PropVal,)
	
	PropVal = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
	PropVal.Name = 'CaseSensitive'
	PropVal.Value = False
	sortproptuple+=(PropVal,)
	
	PropVal = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
	PropVal.Name = 'NaturalSort'
	PropVal.Value = True
	sortproptuple+=(PropVal,)
	
	PropVal = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
	PropVal.Name = 'IncludeAttribs'
	PropVal.Value = True
	sortproptuple+=(PropVal,)
	
	PropVal = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
	PropVal.Name = 'UserDefIndex'
	PropVal.Value = 0
	sortproptuple+=(PropVal,)
	
	PropVal = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
	PropVal.Name = 'Col1'
	PropVal.Value = Sortbycolnum
	sortproptuple+=(PropVal,)
	
	PropVal = uno.createUnoStruct('com.sun.star.beans.PropertyValue')
	PropVal.Name = 'Ascending1'
	PropVal.Value = True
	sortproptuple+=(PropVal,)
	print("freeze expected")
	#This datasort freezes libre >=5.1
	dispHelper.executeDispatch(frame, ".uno:DataSort","", 0, (sortproptuple))
	print("freeze avoided")
Comment 9 Buovjaga 2016-05-04 07:22:11 UTC
I let it run for several minutes and then decided it is frozen.
Only output was:
Attempting to open an UNO socket, count: 0
Processing Source Files.

Win 7 Pro 64-bit, Version: 5.1.2.2 (x64)
Build ID: d3bf12ecb743fc0d20e0be0c58ca359301eb705f
CPU Threads: 4; OS Version: Windows 6.1; UI Render: default; 
Locale: fi-FI (fi_FI)
Comment 10 Quinton 2016-05-04 07:38:41 UTC
(In reply to Buovjaga from comment #9)
> I let it run for several minutes and then decided it is frozen.
> Only output was:
> Attempting to open an UNO socket, count: 0
> Processing Source Files.
> 
> Win 7 Pro 64-bit, Version: 5.1.2.2 (x64)
> Build ID: d3bf12ecb743fc0d20e0be0c58ca359301eb705f
> CPU Threads: 4; OS Version: Windows 6.1; UI Render: default; 
> Locale: fi-FI (fi_FI)

The py sample script I attached that was used to run your test can be changed at line 119 from
"""
dispHelper.executeDispatch(frame, ".uno:DataSort","", 0, (sortproptuple))
"""
to the following to illustrate where the script freezes.
"""
print("freeze expected")
#This datasort freezes libre >=5.1
dispHelper.executeDispatch(frame, ".uno:DataSort","", 0, (sortproptuple))
print("freeze avoided")
"""
This worked in Libre versions >=5.0.

Regards,

Quinton
Comment 11 QA Administrators 2017-05-22 13:39:18 UTC Comment hidden (obsolete)
Comment 12 QA Administrators 2019-12-03 15:00:43 UTC
Dear Quinton,

To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year.

There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present.

If you have time, please do the following:

Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/

If the bug is present, please leave a comment that includes the information from Help - About LibreOffice.
 
If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice.

Please DO NOT

Update the version field
Reply via email (please reply directly on the bug tracker)
Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not 
appropriate in this case)


If you want to do more to help you can test to see if your issue is a REGRESSION. To do so:
1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from http://downloadarchive.documentfoundation.org/libreoffice/old/

2. Test your bug
3. Leave a comment with your results.
4a. If the bug was present with 3.3 - set version to 'inherited from OOo';
4b. If the bug was not present in 3.3 - add 'regression' to keyword


Feel free to come ask questions or to say hello in our QA chat: https://kiwiirc.com/nextclient/irc.freenode.net/#libreoffice-qa

Thank you for helping us make LibreOffice even better for everyone!

Warm Regards,
QA Team

MassPing-UntouchedBug