Bug 99541 - '.uno:GoToCell' call selects an entire column IF the target cell is in column C.
Summary: '.uno:GoToCell' call selects an entire column IF the target cell is in column C.
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
5.1.2.2 release
Hardware: x86-64 (AMD64) Linux (All)
: medium minor
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Cell-Selection
  Show dependency treegraph
 
Reported: 2016-04-27 21:49 UTC by Fred Hamilton
Modified: 2023-12-04 03:17 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
buggy output on top, expected output on bottom (38.87 KB, image/png)
2016-04-27 21:49 UTC, Fred Hamilton
Details
python code to reproduce column bug in calc (2.26 KB, text/plain)
2016-04-28 20:04 UTC, Fred Hamilton
Details
macro suitable for launching from macro menu inside calc (2.25 KB, text/plain)
2016-04-28 20:21 UTC, Fred Hamilton
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Fred Hamilton 2016-04-27 21:49:26 UTC
Created attachment 124684 [details]
buggy output on top, expected output on bottom

Discovered while working on a python macro inside Calc (Ubuntu and Win10).  I have no idea whether it's a Calc bug or an uno bug or a...

Using Dispatcher to select a cell pointed to by string newcell (i.e. newcell = 'A3' for first column, third row) and then write the newcell value to the selected cell.  Snippet:

  # move pointer to cell 'newcell'
  oProp.Name = 'ToPoint' 
  oProp.Value = newcell
  properties = (oProp,) 
  dispatcher.executeDispatch( frame, '.uno:GoToCell', '', 0, properties )
		
  # Writes the (intended) cell location to that cell
  oProp.Name = 'StringName' 
  oProp.Value = newcell
  properties = (oProp,) 
  dispatcher.executeDispatch( frame, '.uno:EnterString', '', 0, properties )

If 'newcell' points to a cell in any column except column C (A3, B17, D2, etc.) then that cell is selected and the code works exactly as you'd expect.  

But if newcell points to any location in column C, an entire column is selected, and that column is determined by newcell's *row*.  So newcell = 'A3' selects cell A3.  But newcell = 'C1' selects *all* of column A.  newcell = 'C4' selects *all* of column D, etc.  It only appears to be column C (though I haven't tested it past column F).

Bug appears on LO 5.1.2.2 on both Ubuntu 16.04 and Windows 10, both 64 bit.

The full python macro (to be launched from inside calc) is below and I've attached the output it produces.  There's additional code below (not in the snippet above) that is supposed to change 5 cells in the selected row to $xx.xx currency format.  The output shows that the call to column C caused entire rows (B-F) to change to $xx.xx format.

########################################################################

from com.sun.star.beans import PropertyValue
# import uno  # doesn't seem necessary

# I confess I still don't really understand the structures 
# in the next 6 lines - I just hacked away until it all worked.
desktop = XSCRIPTCONTEXT.getDesktop()
ThisComponent = XSCRIPTCONTEXT.getDocument()
sheet = ThisComponent.getSheets().getByIndex(0)
frame = ThisComponent.getCurrentController().getFrame()
ctx = XSCRIPTCONTEXT.getComponentContext() 
dispatcher = ctx.ServiceManager.createInstanceWithContext( 'com.sun.star.frame.DispatchHelper', ctx )

########################################################################
def StartHere(dummy):
	for i in range(0,7): # generate a block of unformatted numbers
		for j in range (7, 10):
			sheet.getCellByPosition(i, j).setValue(42) 
 
	FormatColumn("A")	
	FormatColumn("B")	
	FormatColumn("C")
	FormatColumn("D")
	FormatColumn("E")
	
	# If column C is run last, you can see the entire column is selected
	# FormatColumn("C")
########################################################################

########################################################################
# Originally this routine formatted some columns to $xx.xx
# I changed it so it writes desired cell location instead.
def FormatColumn(column):
	for i in range(2,7):
		# create newcell, e.g. 'A3'
		newcell = column+str(i)

		# Can't find another way to do this except dispatcher.  Ugh.
		oProp = PropertyValue()
		
		# move "cursor" to cell locaton 'newcell' 
		# However if newcell points to column C, the row number
		# becomes the column number, and the entire column is 
		# selected.  For example, "C2" selects the entire B column,
		# C3 -> C column, C4 -> D column, etc.
		oProp.Name = 'ToPoint' 
		oProp.Value = newcell
		properties = (oProp,) 
		dispatcher.executeDispatch( frame, '.uno:GoToCell', '', 0, properties )

		# Idea was to set $xx.xx format for selected cell, but
		# if cell is Ci, it changes the entire column to $xx.xx
		oProp.Name = 'NumberFormatValue'
		oProp.Value = 21 # currency
		properties = (oProp,)
		dispatcher.executeDispatch( frame, '.uno:NumberFormatValue', '', 0, properties )
		
		# Writes the (intended) cell location to that cell
		oProp.Name = 'StringName' 
		oProp.Value = newcell
		properties = (oProp,) 
		dispatcher.executeDispatch( frame, '.uno:EnterString', '', 0, properties )

if __name__ == '__main__':
    StartHere(1)
Comment 1 raal 2016-04-28 06:51:47 UTC
Hello,

Thank you for filing the bug. Please send us a sample document, as this makes it easier for us to verify the bug. 
I have set the bug's status to 'NEEDINFO', so please do change it back to 'UNCONFIRMED' once you have attached a document.
(Please note that the attachment will be public, remove any sensitive information before attaching it.)
How can I eliminate confidential data from a sample document?
https://wiki.documentfoundation.org/QA/FAQ#How_can_I_eliminate_confidential_data_from_a_sample_document.3F
Thank you
Comment 2 Fred Hamilton 2016-04-28 20:04:20 UTC
Created attachment 124705 [details]
python code to reproduce column bug in calc

I'm not sure what you asked for by "sample document".  I've attached the python file that will cause this problem (same as in the text of my original submission - probably bad form but I couldn't see how to attach two files when I submitted).

Steps to reproduce:
1) put file in ~/.config/libreoffice/4/user/Scripts/python directory
2) open up an empty/new calc document
3) run this script as a macro (Tools/Macro/Run Macro/Macro Selector/My Macros/example/StartHere)

Step 1 is for linux - for Win/OS X put it in appropriate macro directory.
Comment 3 Fred Hamilton 2016-04-28 20:05:04 UTC
Changed status to unconfirmed.
Comment 4 Fred Hamilton 2016-04-28 20:18:23 UTC
The instructions for reproducing the bug will not work with the original example.py.  I was launching from a button on my toolbar.  When launched from toolbar, main function needs an argument: def StartHere(dummy):

When launched via menu, main function requires no argument: def StartHere():

To reproduce, use new example_menu_launch.py file
Steps to reproduce:
1) put example_menu_launch.py in ~/.config/libreoffice/4/user/Scripts/python directory
2) open up an empty/new calc document
3) run this script as a macro (Tools/Macro/Run Macro/Macro Selector/My Macros/example_menu_launch/StartHere)
Comment 5 Fred Hamilton 2016-04-28 20:21:21 UTC
Created attachment 124706 [details]
macro suitable for launching from macro menu inside calc

example_menu_launch.py will reproduce bug when launched via macro menu in calc.

example.py (earlier attachment) does not work when launched via macro menu in calc.
Comment 6 Buovjaga 2016-05-06 13:09:54 UTC
Confirmed.

Arch Linux 64-bit, KDE Plasma 5
Version: 5.2.0.0.alpha1+
Build ID: 540fee2dc7553152914f7f1d8a41921e765087ef
CPU Threads: 8; OS Version: Linux 4.5; UI Render: default; 
Locale: fi-FI (fi_FI.UTF-8)
Built on April 30th 2016
Comment 7 QA Administrators 2017-05-22 13:38:52 UTC Comment hidden (obsolete)
Comment 8 QA Administrators 2019-12-03 15:01:21 UTC Comment hidden (obsolete)
Comment 9 QA Administrators 2021-12-03 04:46:39 UTC Comment hidden (obsolete)
Comment 10 QA Administrators 2023-12-04 03:17:57 UTC
Dear Fred Hamilton,

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 https://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://web.libera.chat/?settings=#libreoffice-qa

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

Warm Regards,
QA Team

MassPing-UntouchedBug