Hey I got the solution for getting current active cell in spreadsheet. Its as following...
com.sun.star.sheet.XSpreadsheetDocument rSheetDoc = (XSpreadsheetDocument) UnoRuntime.queryInterface(XSpreadsheetDocument.class, m_xFrame.getController().getModel()); XMultiComponentFactory xMCF = m_xContext.getServiceManager(); Object desktop=null; try { desktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", m_xContext); } catch (com.sun.star.uno.Exception ex) { ex.printStackTrace(); } XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, desktop); XComponent xComponent = xDesktop.getCurrentComponent(); XInterface doc = (XInterface)UnoRuntime.queryInterface( XInterface.class, xComponent ); XSpreadsheetDocument xSheetDocument = (XSpreadsheetDocument) UnoRuntime.queryInterface(XSpreadsheetDocument.class, doc); XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, xSheetDocument); XCell xCell = (XCell) UnoRuntime.queryInterface(XCell.class,xModel.getCurrentSelection()); xCell is the current active cell in spreadsheet. On Thu, Jul 10, 2008 at 11:45 AM, Dinesh Chothe <[EMAIL PROTECTED]> wrote: > Hello *Andrew ,* > * I *have been using java as programming > language so I have not > found any CurrentSelection() method associated with > xSpreadsheet object. > The example you have provided seems to really good but I > have not found > any such using java. > > oOldSelection = ThisComponent.CurrentSelection > > What is "ThisComponent" in above line, How would this in > using java? > > On 7/10/08, Andrew Douglas Pitonyak <[EMAIL PROTECTED]> wrote: >> >> If only one cell is selected, then you can simply obtain the >> CurrentSelection property from the document. Things are more complicated if >> you must worry about multiple things being selected... it looks like you can >> also grab the selection property from the current controller. >> >> If you want only the cell that contains the cursor, and you want to ignore >> the rest, you can tell the controller to select an empty range that was >> created by the document. The following subroutine does the following: >> 1.Save the current selection. This is useful if more than a single cell is >> active. >> 2.Select an empty range so that only the cell with the cursor is selected. >> The cell is selected with an outline around the cell, but it is not >> completely blacked out. If you use the controller to select a range, this >> method can also be used to change the selection from a completely selected >> cell, to merely an active cell. >> 3.Use the CellAddressConversion service to obtain the address of the >> active cell. This is new to 1.1.1, part of the "linked controls" >> implementation. >> Listing 2.12: Find the active cell. >> REM Author: Paolo Mantovani >> REM email: [EMAIL PROTECTED] >> Sub RetrieveTheActiveCell() >> Dim oOldSelection 'The original selection of cell ranges >> Dim oRanges 'A blank range created by the document >> Dim oActiveCell 'The current active cell >> Dim oConv 'The cell addres conversion service >> REM store the current selection >> oOldSelection = ThisComponent.CurrentSelection >> >> oRanges = >> ThisComponent.createInstance("com.sun.star.sheet.SheetCellRanges") >> ThisComponent.CurrentController.Select(oRanges) >> 'get the active cell! >> oActiveCell = ThisComponent.CurrentSelection >> >> REM a nice service I've just found!! :-) >> oConv = >> ThisComponent.createInstance("com.sun.star.table.CellAddressConversion") >> oConv.Address = oActiveCell.getCellAddress >> Print oConv.UserInterfaceRepresentation >> Print oConv.PersistentRepresentation >> >> 'restore the old selection (but loosing the previous active cell) >> ThisComponent.CurrentController.Select(oOldSelection) >> End Sub >> >> >> >> >> Dinesh Chothe wrote: >> >>> XTextViewCursorSupplier xViewCursorSupplier = >>> ( XTextViewCursorSupplier )UnoRuntime.queryInterface ( >>> XTextViewCursorSupplier.class, xTextDocument ); >>> For getting current position from current document I did as >>> above. >>> Now while doing this same for spreadsheet it doesnt work by >>> passing >>> xSpreadsheet instead of xTextDocument. >>> How would I access current active cell in spreadsheet? >>> >>> On Tue, Jul 8, 2008 at 5:26 PM, Andrew Douglas Pitonyak < >>> [EMAIL PROTECTED]> >>> wrote: >>> >>> >>> >>>> Dinesh Chothe wrote: >>>> >>>> >>>> >>>>> Hello, >>>>> I want to get current position of cursor from documents XTable >>>>> or >>>>> XTextDocument >>>>> also for calc I want to get current cells position. How do I? >>>>> I am using OoSDK2.3 and java... >>>>> >>>>> >>>>> >>>>> >>>> I believe that the view cursor has a property TextTable and a property >>>> Cell. The cell has a property CellName. >>>> >>>> -- >>>> Andrew Pitonyak >>>> My Macro Document: http://www.pitonyak.org/AndrewMacro.odt >>>> My Book: http://www.hentzenwerke.com/catalog/oome.htm >>>> Info: http://www.pitonyak.org/oo.php >>>> See Also: http://documentation.openoffice.org/HOW_TO/index.html >>>> >>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: [EMAIL PROTECTED] >>>> For additional commands, e-mail: [EMAIL PROTECTED] >>>> >>>> >>>> >>>> >>> >>> >>> >>> >> >> -- >> Andrew Pitonyak >> My Macro Document: http://www.pitonyak.org/AndrewMacro.odt >> My Book: http://www.hentzenwerke.com/catalog/oome.htm >> Info: http://www.pitonyak.org/oo.php >> See Also: http://documentation.openoffice.org/HOW_TO/index.html >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > > -- > Thanks and Regards, > > > > Dinesh -- Thanks and Regards, Dinesh