Attachment seems to be deleted by mail-list http://www.unet.univie.ac.at/~a0828302/MidiCSDextImpl.java
-----Ursprüngliche Nachricht----- Von: Ariel Constenla-Haile [mailto:ariel.constenla.ha...@googlemail.com] Gesendet: Samstag, 22. Mai 2010 18:54 An: dev@api.openoffice.org Betreff: Re: [api-dev] java-macro: Not able to access CurrentComponent? Hello Martin, On Saturday 22 May 2010, 06:24, Martin Dobiasch wrote: > Hi! > I'm running into trubles when my macro-code is invoked at calc-startup. > Running the samecode after calc-startup (document opened+loaded) same > Code works without anyproblems. > Is there a way to get Currentcomponent which should be a > XSpreadsheetDocument? > > The macro should gain access to one sheet. So if there is another way to > get access to the sheets ... > > code: can you please post (or upload somewhere the complete code as a Java source file (*.java)? The way posted here is hard to follow, though... > try > { > Object desktop=null; > desktop = > x_xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", m_xContext); where does m_xContext come from? > xd= (XDesktop) > UnoRuntime.queryInterface(com.sun.star.frame.XDesktop.class, desktop); > } > catch (Exception e1) > { > Debug.showMessage("Exception"); > e1.printStackTrace(); > return "error"; > } > > XComponent document = xd.getCurrentComponent(); > Debug.showMessage("document != null?: " + (document != null) ); > > XModel xmodel = (XModel) UnoRuntime.queryInterface(XModel.class, > document); > > xSpreadsheetDocument= (XSpreadsheetDocument) UnoRuntime.queryInterface( > XSpreadsheetDocument.class, xmodel); > > XSpreadsheets xss = xSpreadsheetDocument.getSheets(); > > try > { > Object o= xss.getByName( sheetname ); > xs= (XSpreadsheet) > UnoRuntime.queryInterface(XSpreadsheet.class, o); > } > catch (NoSuchElementException e) > { > Debug.showMessage( "NoSuchElement " + e.getMessage() ); > e.printStackTrace(); > } > catch (WrappedTargetException e) > { > Debug.showMessage( "WrappedTarget: " + e.getMessage() ); > e.printStackTrace(); > } > > > Running this code at startup I geht the message document != null?: false > But if I invoke the macro later its true > > Thanks for any Help, Regards -- Ariel Constenla-Haile La Plata, Argentina --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org For additional commands, e-mail: dev-h...@api.openoffice.org