| View previous topic :: View next topic |
| Author |
Message |
Frost87 Newbie

Joined: 13 Apr 2012 Posts: 4
|
Posted: Fri Apr 13, 2012 4:04 am Post subject: Problem with javascript's macro in OO Calc |
|
|
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 |
|
 |
hanya Super User

Joined: 04 May 2005 Posts: 543 Location: Japan
|
Posted: Fri Apr 13, 2012 4:33 am Post subject: |
|
|
| Try to get it from the component window. |
|
| Back to top |
|
 |
Frost87 Newbie

Joined: 13 Apr 2012 Posts: 4
|
Posted: Fri Apr 13, 2012 4:38 am Post subject: |
|
|
| hanya wrote: | | Try to get it from the component window. |
How? |
|
| Back to top |
|
 |
Frost87 Newbie

Joined: 13 Apr 2012 Posts: 4
|
Posted: Fri Apr 13, 2012 4:49 am Post subject: |
|
|
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 |
|
 |
hanya Super User

Joined: 04 May 2005 Posts: 543 Location: Japan
|
Posted: Fri Apr 13, 2012 5:39 am Post subject: |
|
|
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 |
|
 |
Frost87 Newbie

Joined: 13 Apr 2012 Posts: 4
|
Posted: Fri Apr 13, 2012 6:04 am Post subject: |
|
|
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 |
|
 |
|