Bugzilla – Attachment 124706 Details for
Bug 99541
'.uno:GoToCell' call selects an entire column IF the target cell is in column C.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
macro suitable for launching from macro menu inside calc
example_menu_launch.py (text/plain), 2.25 KB, created by
Fred Hamilton
on 2016-04-28 20:21:21 UTC
(
hide
)
Description:
macro suitable for launching from macro menu inside calc
Filename:
MIME Type:
Creator:
Fred Hamilton
Created:
2016-04-28 20:21:21 UTC
Size:
2.25 KB
patch
obsolete
>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(): > 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 cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 99541
:
124684
|
124705
| 124706