OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Problem with javascript's macro in OO Calc

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
Frost87
Newbie
Newbie


Joined: 13 Apr 2012
Posts: 4

PostPosted: Fri Apr 13, 2012 4:04 am    Post subject: Problem with javascript's macro in OO Calc Reply with quote

Hello! I need help with my macro. My macro is wirttable in javascript, but i don't know what parameter i need for get the xAccessible of the Spreadsheet.

My code:

importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.sheet.XSpreadsheetDocument);
importClass(Packages.com.sun.star.sheet.XSpreadsheets);
importClass(Packages.com.sun.star.table.XCellRange);
importClass(Packages.com.sun.star.accessibility.XAccessibleContext);
importClass(Packages.com.sun.star.accessibility.XAccessibleTable);
importClass(Packages.com.sun.star.accessibility.XAccessible);
importClass(Packages.com.sun.star.container.XIndexAccess);


oDoc = XSCRIPTCONTEXT.getDocument();
xSpreadsheetDocument = UnoRuntime.queryInterface(XSpreadsheetDocument, oDoc);
xSpreadsheets = xSpreadsheetDocument.getSheets();
xIndexAccess = UnoRuntime.queryInterface(XIndexAccess, xSpreadsheets);
oSheet = xIndexAccess.getByIndex(0);

xAccessible = UnoRuntime.queryInterface(XAccessible, ???);
xAccessibleContext = xAccessible.getAccessibleContext();
xAccessibleTable = UnoRuntime.queryInterface(XAccessibleTable, xAccessibleContext);
columns = xAccessibleTable.getAccessibleColumnCount();

xCell = xCellRange.getCellByPosition(5, 5);
xCell.setValue(columns);


Somebody knows the solution? Thanks for all!
Back to top
View user's profile Send private message
hanya
Super User
Super User


Joined: 04 May 2005
Posts: 543
Location: Japan

PostPosted: Fri Apr 13, 2012 4:33 am    Post subject: Reply with quote

Try to get it from the component window.
Back to top
View user's profile Send private message
Frost87
Newbie
Newbie


Joined: 13 Apr 2012
Posts: 4

PostPosted: Fri Apr 13, 2012 4:38 am    Post subject: Reply with quote

hanya wrote:
Try to get it from the component window.


How?
Back to top
View user's profile Send private message
Frost87
Newbie
Newbie


Joined: 13 Apr 2012
Posts: 4

PostPosted: Fri Apr 13, 2012 4:49 am    Post subject: Reply with quote

Sorry for double post

Ok, i try to get the parameter of window and i wrote this, but i fail

importClass(Packages.com.sun.star.uno.UnoRuntime);
importClass(Packages.com.sun.star.sheet.XSpreadsheetDocument);
importClass(Packages.com.sun.star.sheet.XSpreadsheets);
importClass(Packages.com.sun.star.table.XCellRange);
importClass(Packages.com.sun.star.accessibility.XAccessibleContext);
importClass(Packages.com.sun.star.accessibility.XAccessibleTable);
importClass(Packages.com.sun.star.accessibility.XAccessible);
importClass(Packages.com.sun.star.container.XIndexAccess);
importClass(Packages.com.sun.star.awt.XWindow);


oDoc = XSCRIPTCONTEXT.getDocument();
xSpreadsheetDocument = UnoRuntime.queryInterface(XSpreadsheetDocument, oDoc);
xSpreadsheets = xSpreadsheetDocument.getSheets();
xIndexAccess = UnoRuntime.queryInterface(XIndexAccess, xSpreadsheets);
oSheet = xIndexAccess.getByIndex(0);

parentWindow = oDoc.getCurrentController().getFrame().getContainerWindow();

xAccessible = UnoRuntime.queryInterface(XAccessible, parentWindow);
xAccessibleContext = xAccessible.getAccessibleContext();
xAccessibleTable = UnoRuntime.queryInterface(XAccessibleTable, xAccessibleContext);
columns = xAccessibleTable.getAccessibleColumnCount();

xCell = xCellRange.getCellByPosition(5, 5);
xCell.setValue(columns);
Back to top
View user's profile Send private message
hanya
Super User
Super User


Joined: 04 May 2005
Posts: 543
Location: Japan

PostPosted: Fri Apr 13, 2012 5:39 am    Post subject: Reply with quote

You have to find the specific accessible child from the tree of the accessible window.
But what do you want to do with it? It seems you want to call getAccessibleColumnCount method of it, so is not enough to get the used cell range using cell cursor?
Back to top
View user's profile Send private message
Frost87
Newbie
Newbie


Joined: 13 Apr 2012
Posts: 4

PostPosted: Fri Apr 13, 2012 6:04 am    Post subject: Reply with quote

I need to get the number of columns with data in the OO calc.

I think that is the best way for get it, but if you know other option, I will be grateful.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group