https://bugs.documentfoundation.org/show_bug.cgi?id=99541
Bug ID: 99541
Summary: '.uno:GoToCell' call selects an entire column IF the
target cell is in column C.
Product: LibreOffice
Version: 5.1.2.2 release
Hardware: x86-64 (AMD64)
OS: Linux (All)
Status: UNCONFIRMED
Severity: normal
Priority: medium
Component: Calc
Assignee: [email protected]
Reporter: [email protected]
Created attachment 124684
--> https://bugs.documentfoundation.org/attachment.cgi?id=124684&action=edit
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)
--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs