[dev] drawing with Java2D inside Openoffice
Hello, I began an internship for my university. I have to start a new project from scratch. My Project is about "drawing rdf-document as easy understandable graphs". : RDF (Ressorce Description Framework) is a standard for representing metadata (for example in XML format). People from university wants me to do draw the graphs inside openoffice. (I don't know why they choose openoffice for it, thought...). I began to read the Developer Guide, but after searching a lot, I'm really not sure. Can I really draw _with_java_ inside of openoffice. So, My questions are : * Is it possible to draw with java inside openoffice ? (If yes, can you give me an hint, how to do it? Where should I begin too look at ?) * Is it possible easily ? (Where should I begin to look? Are there some demos, or some small applications demonstrating how I can do that?) * What should I use to draw, swing, swt, awt? I would like to use jgraph later in my project. I hope I can got some help here. Thank you in advance! Regards, Daniel - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [dev] drawing with Java2D inside Openoffice
Bernhard Haumacher wrote: Hi, that's not an answer, but an additional question. * Is it possible to draw with java inside openoffice ? (If yes, can you give me an hint, how to do it? Where should I begin too look at ?) I'd like to concretize "draw with java inside openoffice": Is it possible to write a Java component, that is responsible for painting (and getting events for) some area of a document. E.g. a (hypothetical) component that displays a geometric construction (almost like an image) but is able to respond to user input to make the construction interactive? Therefore, my (and possibly Daniel's) question is not about creating OpenDocument content by means of some API calls, but about a component that plugs into the document and takes responsibility for some part thereof. Best regards Bernhard Yes, that is exactely my problem :). Can someone help us ? Regards Daniel - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[dev] inserting graphicObject under a XTextViewCursor
Hello, Im trying to insert an image (a Gif image) under the cursor (the visual one, which the user uses for editing) inside the Writer of OpenOffice.org, but it seems to not work. Instead, the image is always pasted at the top of the Frame of OpenWriter. And, despite alle my investigation how to change it, I could archive to paste the image under the cursor . Even if I try to change the values inside of : xPropSet.setPropertyValue("HoriOrientPosition",1000); to xPropSet.setPropertyValue("HoriOrientPosition",5000); it also changes nothing. I don't know how to solve it. What am I doing wrong here ? Tank you a lot in advance ! Regards, - Daniel Here my code : //Creating GraphicObject Object oGraphic = xMultiServiceFactory.createInstance("com.sun.star.text.GraphicObject"); //getting actual Cursor XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, xComponent); XController xController = xModel.getCurrentController(); XTextViewCursorSupplier xViewCursorSupplier = (XTextViewCursorSupplier) UnoRuntime.queryInterface( XTextViewCursorSupplier.class, xController); XTextViewCursor xTextViewCursor = xViewCursorSupplier.getViewCursor(); // Getting the text com.sun.star.text.XText xText = xTextDocument.getText(); // Querying for the interface XTextContent on the GraphicObject com.sun.star.text.XTextContent xTextContent = (com.sun.star.text.XTextContent) UnoRuntime.queryInterface( com.sun.star.text.XTextContent.class, oGraphic); // Inserting the content xText.insertTextContent(xTextViewCursor, xTextContent, true); // Querying for the interface XPropertySet on GraphicObject com.sun.star.beans.XPropertySet xPropSet = (com.sun.star.beans.XPropertySet) UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, oGraphic); java.io.File sourceFile = new java.io.File("src/data/picture.gif"); xPropSet.setPropertyValue("AnchorType", com.sun.star.text.TextContentAnchorType.AT_PARAGRAPH); // Setting the graphic url xPropSet.setPropertyValue("GraphicURL", sUrl.toString()); System.out.println("(x,y): (" + xTextViewCursor.getPosition().X + "," + xTextViewCursor.getPosition().Y + ")"); // Setting the horizontal position xPropSet.setPropertyValue("HoriOrientPosition", new Integer(xTextViewCursor.getPosition().X)); // Setting the vertical position xPropSet.setPropertyValue("VertOrientPosition", new Integer(xTextViewCursor.getPosition().Y)); xPropSet.setPropertyValue("Width", new Integer(8000));xPropSet.setPropertyValue("Height", new Integer(4000)); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [dev] inserting graphicObject under a XTextViewCursor
Hello, First thank you Matt for your fast answer! I changed : xPropSet.setPropertyValue("AnchorType", com.sun.star.text.TextContentAnchorType.AT_PARAGRAPH); to xPropSet.setPropertyValue("AnchorType", com.sun.star.text.TextContentAnchorType.AS_CHARACTER); It works much better now. But then I insert an image now, it will be inserted at the beginning of the curently edited line. It looks as if the "X Coordinates" are ignored. I would like it to be inserted exactely at the point, where the user has got is cursor... thats much more natural. Daniel On Sun, 2005-10-09 at 16:34 +, Daniel Beck wrote: Hello, Im trying to insert an image (a Gif image) under the cursor (the visual one, which the user uses for editing) inside the Writer of OpenOffice.org, but it seems to not work. Instead, the image is always pasted at the top of the Frame of OpenWriter. And, despite alle my investigation how to change it, I could archive to paste the image under the cursor . Just a thought: What is the Anchor for the oGraphic set to? To achieve your desire, you probably need to set it to "as Character" or "to Character". Matt - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[dev] Calling function from ContextMenu
Hello , * I'm using Java, to access openOffice 2 UNO component. I'm trying to add items to the contextMenu inside OpenOffice - I used the example from sdk for that. *Then the user choses the Item "Search Word" from the contextMenu, I want my own function to be called. The problem is : I don't know how to do that. As I understand it, I have to use xMenuEntry.setPropertyValue("CommandURL", String). But which String to pass? Do I have to make an UNO component to call my own function from OpenOffice? Thanks in advance , Daniel *this is the example I took from sdk. It calls the help navigator. How to modify it, to call my own function, e.g. void foo() ? /**CODE/ // intialize help/content menu entry XPropertySet xMenuEntry = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, xMenuElementFactory.createInstance( "com.sun.star.ui.ActionTrigger")); xMenuEntry.setPropertyValue("Text", "Search Word"); xMenuEntry.setPropertyValue("CommandURL", "slot:5401"); xMenuEntry.setPropertyValue("HelpURL", "5401"); /END OF CODE/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[dev] inserting text in current Frame
Hello, I'm developping a java application, and I extended it (or at least tried to extend it) so that it can interpolate with openoffice. I can now insert text, image, diagrams and links inside openoffice, all that from my external java-programm. Thats really nice:) The strange thing is that it does that only on the Writer-frame that I opened first. I would like to also be able to insert things in a new opened docuemnt. And I would like to allow the user to edit several document with OpenOffice.org, and only operate (i.e. : insert Tex, images, diagramms or links) on the the frame, that is currently on top. so... What I am doing wrong ? Why can I only use the first opened frame ? (i.e.: How to get the frame that is currently "in use"?) I pasted the code in the Email. Thanks a lot for the answer in advance. Regards Daniel __Code__ //here is the code I used to open the first new writer frame : .. try { xComponent = xCompLoader.loadComponentFromURL("private:factory/swriter", "_blank", 0, new com.sun.star.beans.PropertyValue[0]); xTextDocument = (XTextDocument) UnoRuntime.queryInterface( XTextDocument.class, xComponent); } catch (com.sun.star.uno.Exception e) { System.out.println("uno Error!"); e.printStackTrace(); } //here is the code I use to insert text : void insertTest(String word){ xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, xComponent); XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, xComponent); // the controller gives us the TextViewCursor XController xController = xModel.getCurrentController(); XTextViewCursorSupplier xViewCursorSupplier = (XTextViewCursorSupplier) UnoRuntime.queryInterface( XTextViewCursorSupplier.class, xController); // create a model cursor from the viewcursor XTextViewCursor xViewCursor = xViewCursorSupplier.getViewCursor(); XText xDocumentText = xViewCursor.getText(); XTextCursor xModelCursor = xDocumentText.createTextCursorByRange( xViewCursor.getStart()); xModelCursor.setString(word); } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [dev] Saving the state of a component with a document
Hello, Sorry, I don't know the answer. What I wanted to say : I have a similar Problem. I want to tag some words (I'm Tagging Named Entities, e.g. person name, states, time...), and store these information in the XML stucture. What would fit best for me would be alternative 1. So, I'm also interested on opinions/hints about it. Thanks Daniel Hi all, I am developing a UNO component which needs to store its state, such as the values of input fields, radio boxes, list boxes etc. into a current document so that it can be saved with that file, and carried with that file. My question is, is there an elegant way of doing it? What I have in mind are: 1) Put the values into some type of a XML structure, and inject it into the zipped file structure (if that's even possible). 2) Put them as a macro basic comment (dunno if this is also possible) 3) Put them into the document itself as a content. 3 is the easiest, but I prefer not to alter the content of a current document. 2 may be better, but then the next time the user opens the document, s/he will get that macro security dialog (undesired effect). 1 is perfect, but I don't even know if it's possible. Has anybody done anything like this? Any opinions? Thanks, Kohei -- Kohei Yoshida OpenOffice.org Calc contributor http://kohei.us/ooo/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [dev] inserting text in current Frame
Hello Stephan, The problem is that I want to insert text in the document the user is actually editing, and not in the Frame the programm opened. Imagine the user opens an already existent file. This would open a new frame. Then inserting text from my java application, the text will appear in the Frame he opened first, and not in the frame he is actually editing - which is not the expected behaviour. So, I wanted to now how to get the current frame ... thanks, Daniel Hi Daniel, I can now insert text, image, diagrams and links inside openoffice, all that from my external java-programm. Thats really nice:) The strange thing is that it does that only on the Writer-frame that I opened first. I would like to also be able to insert things in a new opened docuemnt. And I would like to allow the user to edit several document with OpenOffice.org, and only operate (i.e. : insert Tex, images, diagramms or links) on the the frame, that is currently on top. so... What I am doing wrong ? Why can I only use the first opened frame ? (i.e.: How to get the frame that is currently "in use"?) mmm ... not sure what you try to achieve ... your code opens a text document and then inserts a text in this just opened document. Looks to me like the expected behaviour. Regards Stephan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [dev] inserting text in current Frame
Hi Stephan, First thanks - your solution worked beautifully! Danke! Everytime I want to insert text into StarOffice writer, I search now for the currently active StarOffice component. With it, I can just insert text, images, graphics into the right Frame. I have now a problem, that is very similar to the this one. I want to add now an item to the StarOffice context menu. I also, of course, want this context menu to be available from all openoffice windows/frame the user opened. But I were not able to do it. You see, then inserting text, it was easier, because I search for the currently active StarOffice component before inserting text. I created a ContextMenuInterceptorClass, that registers once, then starting openoffice, to the current frame. But then, it doesn't work then I opens a new frame, because I is registered, from the beginning on, at the first active StarOffice component. So ... Either 1)I register the ContextMenuInterceptor so that his notifyContextMenuExecute method will be called from what either frame a contextMenuEvent came from (Is that possible?), or 2) I have to register a new ContextMenuInterceptor each time I open a new Document, or change the current edited document. Can you perhaps give me an hint ? Here, this is how I'm doing to register the Context Menu /*** * Registration of the context menu interceptor by using the current controller. * This is done once, then openOffice starts. ***/ XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, xComponent); com.sun.star.frame.XFrame xFrame = xModel.getCurrentController().getFrame(); XController xController = xModel.getCurrentController(); //intercepts the XContextMenu, to add items in it com.sun.star.ui.XContextMenuInterception xContextMenuInterception = (com.sun.star.ui.XContextMenuInterception) UnoRuntime.queryInterface( com.sun.star.ui.XContextMenuInterception.class, xController); ContextMenuInterceptor aContextMenuInterceptor = new ContextMenuInterceptor(); com.sun.star.ui.XContextMenuInterceptor xContextMenuInterceptor = (com.sun.star.ui.XContextMenuInterceptor) UnoRuntime.queryInterface( com.sun.star.ui.XContextMenuInterceptor.class, aContextMenuInterceptor); xContextMenuInterception.registerContextMenuInterceptor(xContextMenuInterceptor); and here, a part of my ContextMenuInterceptor class, which adds items to a contextMenu. / * ContextMenuInterceptor, adds item to the openOffice contextMenu ***/ public class ContextMenuInterceptor implements XContextMenuInterceptor { public ContextMenuInterceptorAction notifyContextMenuExecute( com.sun.star.ui.ContextMenuExecuteEvent aEvent) throws RuntimeException { ... com.sun.star.container.XIndexContainer xContextMenu = aEvent.ActionTriggerContainer; com.sun.star.lang.XMultiServiceFactory xMenuElementFactory = (com.sun.star.lang.XMultiServiceFactory) UnoRuntime.queryInterface( com.sun.star.lang.XMultiServiceFactory.class, xContextMenu); if (xMenuElementFactory != null) { // create root menu entry and sub menu com.sun.star.beans.XPropertySet xRootMenuEntry = (XPropertySet) UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xMenuElementFactory.createInstance("com.sun.star.ui.ActionTrigger")); xRootMenuEntry.setPropertyValue("Text", "Ontology"); xRootMenuEntry.setPropertyValue("CommandURL", "slot:5410"); xRootMenuEntry.setPropertyValue("HelpURL", "5410"); Hi Daniel The problem is that I want to insert text in the document the user is actually editing, and not in the Frame the programm opened. Imagine the user opens an already existent file. This would open a new frame. Then inserting text from my java application, the text will appear in the Frame he opened first, and not in the frame he is actually editing - which is not the expected behaviour. So, I wanted to now how to get the current frame ... h, now the shades of confusion lift :-) You can query the XDesktop interface from an instance of the service "com.sun.star.frame.Desktop", which you can create at the MultiServiceFactory of the office. The interface XDesktop has a method "getCurrentComponent()" which should return the currently active StarOffice component. To ensure that the com
[dev] OOo developers guide
Hello, I would like to have the openoffice developers guide (i.e., the one found at http://api.openoffice.org/DevelopersGuide/DevelopersGuide.html ) as a textbook. I googled for it, and also looked at amazone, but apparently it is only possible to have it in electronical form. I write this email to ask if someone know if it is possible to buy it somewhere as textbook. Regards, Daniel - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[dev] how to catch events everytime a character is entered into the Wordprocessor?
Hello, I want to catch events from openoffice everytime someone enters a character in the Worprocessor text area, or everytime someone selects an element from the context menu (The one obtained then doing right-mouse click on the edited document) I think that I have to get the "XMenu" and the "XTextComponent" from some service from the Wordprocessor to register my XMenuListener and my XTextListener. I found no such services. My Question is: how to do to capture events from the wordprocessor everytime a user enters a carachter into the wordprocessor? I didn't found the answer, nether by googling for it, nor by looking into the examples from the Developer Guide, nor by reading hald of the Developer Guide (Btw, its really to long!) Regards, Daniel - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [dev] Can I listen for changes of the view cursor?
Hello OpenOffice Maillinglist. I'm forwarding my email contact with Matthias in the hope that someone can help us. There also exists the com.sun.star.awt.XMouseListener, which not only listens to mouseclicks events, but also to events like mouseEntered, mouseExited, mousePressed, mouseReleased But here I have a problem too: where must I register the XMouseHandler?/XMouseClickHandler? I tried to register it to the frame of the TextDocument, but that didn't do the Trick. currenActiveOfficeComponent = newDocComponent("swriter"); XTextDocument xTextDocument = (XTextDocument) UnoRuntime .queryInterface(XTextDocument.class, currenActiveOfficeComponent); XFrame textDocumentFrame= xTextDocument.getCurrentController().getFrame(); XWindow textFrameWindow = textDocumentFrame.getComponentWindow() testFrameWindow.addFrameActionListener(new MyMouseListener()); and this one doesn't work either: textDocumentFrame.addFrameActionListener(new MyFrameListener()); MyMouseListener and MyFrameListener only implements the method from the interface by adding System.out.println("some string") into each method. Sorry, no one has replied yet and I haven't found a solution myself. I guess I will use an XMouseClickHandler. That doesn't tell me when the user moved the cursor with the keyboard but it's better than nothing. I have a problem similar to your problem. Did you find out meanwhile how to get informed whenever the user moved the view cursor? I'm trying myself to declare listener and register them, but until now, nothing works. Regards, Daniel MSB I'd like to know if there's a way to get informed whenever the user has moved the view cursor. I've looked at the IDL and the dev guide but I can't seem to find a function/interface for this. Matthias - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [dev] OOo developers guide
Cool, I buy it...NOW! :-) Thanks! Daniel Jürgen Schmidt wrote: Daniel Beck wrote: Hello, I would like to have the openoffice developers guide (i.e., the one found at http://api.openoffice.org/DevelopersGuide/DevelopersGuide.html ) as a textbook. I googled for it, and also looked at amazone, but apparently it is only possible to have it in electronical form. I write this email to ask if someone know if it is possible to buy it somewhere as textbook. Because the Developer's Guide is a Sun product and it is part of the StarOffice SDK as well it is available online and you can buy a printed version http://docs.sun.com/app/docs/coll/1263.1?q=StarOffice+8&s=t For selling a printed version of the Developer's Guide you need the permission of Sun yet, it is only allowed for private usage. But we are thinking about open sourcing the guide completely and not only to provide a free version. Juergen Regards, Daniel - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [dev] Re: Can I listen for changes of the view cursor?
Hello, I think adding the SelectionChangeListener ist done as follow: This is how you got you XTextViewCursor: XTextViewCursorSupplier xViewCursorSupplier = (XTextViewCursorSupplier) UnoRuntime .queryInterface(XTextViewCursorSupplier.class, currentDesktopController); It is the case that the xViewCursorSupplier supports the Service "TextDocumentView", which include the service "OfficeDocumentView". OfficeDocumentView exports the interface "XSelectionSupplier". (Cf to the idl documentation). XSelection is the interface we need, since it defines the method addSelectionChangeListener() Thus, querying for XSelectionSupplier is done as follow: XSelectionSupplier xSelectionSupplier = (XSelectionSupplier) UnoRuntime .queryInterface(XSelectionSupplier.class, xViewCursorSupplier); Eventually add to the retrieved XSelectionSupplier your own SelectionChangeListener: xSelectionSupplier.addSelectionChangeListener(new MySelectionChangeListener()); (MySelectionChangeListener is a class that implements XSelectionChangeListener). I hope I made no mistakes. Regards, Daniel p.s.: On Staroffice 8, an event is catched then I press the keys "up arrow" or the "down arrow", but *not* then I press the "left" or the "right arrow". This is a bug, isn't it ? Matthias Benkmann wrote: On 8/18/06, Mathias Bauer <[EMAIL PROTECTED]> wrote: If the view cursor is moved the selection also changes, so registering as a SelectionChangedListener should be sufficient. Thanks. That works nicely. Can I ask where and how you add the listener? A few lines of code maybe? /W - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [dev] XTextRange Diff
Hello, I remember that I had once a similar problem. I solved it by creating a XTextRange ranging from "start" to "end" and then by getting the size of the text of that XTextRange. Here some pseudo code (I cannot post real code since I have no Java environment here) //Creates the XTextRange ranging from start to end xtextRange.goto(START) xtextRange.goto(END) //Returns the size of the XTextRange in number of characters: xtextRange.getText().getString().length(); I'm not sure if the returned size does match the number of characters under the windows OS if a line break happens to be in that XTextRange. A trick like this should solve the problem: String text =xtextRange.getText().getString().length(); if (System.getProperty("os.name").startsWith("Windows")) text = text.replaceAll(System.getProperty("line.separator"), "\n"); return text.length() I sadly found no easier way to count characters in a XTextRange. Regards, Daniel Hello Guys !!! I need some help... i have two XTextRange ... the Start and The END... exist way to return a position in the of this ranges ? ex: XTextRangeEND - XTextRangeSTART = 13 The Range have a 13 chars... exists way ? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]