| View previous topic :: View next topic |
| Author |
Message |
vdoser General User

Joined: 24 Feb 2005 Posts: 32
|
Posted: Thu Feb 24, 2005 10:52 am Post subject: Remote control of a running OO instance |
|
|
I'm developing a VC++ app which should detect a running instance of OO or/and MS Office, connect to it and control/select its annotating tools (such as freeform , ellipse, etc.) and its properties (color, width, fill).
I implemented this for MS Office.
As for OO I was able to find how to do the connect part in the docs,
but still puzzled with how to get access to the drawing tools/properies and how to identify what OO type(Writer, Calc, etc) I'm connected to.
Any help/tips/snippets would be greatly appreciated. |
|
| Back to top |
|
 |
SergeM Super User

Joined: 09 Sep 2003 Posts: 3211 Location: Troyes France
|
|
| Back to top |
|
 |
vdoser General User

Joined: 24 Feb 2005 Posts: 32
|
Posted: Thu Feb 24, 2005 1:11 pm Post subject: |
|
|
| the default focused... |
|
| Back to top |
|
 |
hol.sten Super User


Joined: 14 Nov 2004 Posts: 3532 Location: Hamburg, Germany
|
|
| Back to top |
|
 |
vdoser General User

Joined: 24 Feb 2005 Posts: 32
|
Posted: Thu Feb 24, 2005 1:54 pm Post subject: |
|
|
Thanks a lot!
Any ideas on how to control/navigate to the drawing tools objects? |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Sat Feb 26, 2005 11:43 am Post subject: |
|
|
I am not an expert at Writer. That said, here are some hints.
OOo's API is the same in any language.
Try learning the API using OOo's built in Basic. It is very easy to experiment and learn the API. Try studying past examples. Lots of examples can be found in the Code Snippets section of OOoForum.
If you want to create drawing shapes in OOo Writer, you would do something like this....
1. Create a writer document
2. Get the drawing page of the document.
3. Using the XMultiServiceFactory of the document, create, say, an EllipseShape object.
4. Add the shape to the drawing page.
5. Manipulate the shape's properties.
Here is a Basic language example (using OOo's built in Basic)...
| Code: | Sub Main
' Create an empty Writer doc.
oDoc = StarDesktop.loadComponentFromURL( "private:factory/swriter", "_blank", 0, Array() )
' Get the writer document's drawing page.
' There is only one (huge) draw page for the entire multi-page word processor doc.
oDrawPage = oDoc.getDrawPage()
' Create an EllipseShape object
oShape = oDoc.createInstance( "com.sun.star.drawing.EllipseShape" )
' Set some of the shape's properties.
oShape.Position = MakePoint( 2000, 3000 )
oShape.Size = MakeSize( 5000, 1000 )
' Add the shape to the draw page
oDrawPage.add( oShape )
End Sub
Function MakePoint( ByVal x As Long, ByVal y As Long ) As com.sun.star.awt.Point
oPoint = createUnoStruct( "com.sun.star.awt.Point" )
oPoint.X = x
oPoint.Y = y
MakePoint = oPoint
End Function
Function MakeSize( ByVal width As Long, ByVal height As Long ) As com.sun.star.awt.Size
oSize = createUnoStruct( "com.sun.star.awt.Size" )
oSize.Width = width
oSize.Height = height
MakeSize = oSize
End Function
|
The API is the same in your language (VC++). You just need to figure out how to use the API from that language.
It may be the case that on every object you have to queryInterface for the right interface of the object, as Java programmers must do.
In OOo Basic, Visual Basic, and Python, this is unnecessary. Thus, on the writer document, I was able to call createInstance() method without first having to first query the writer document for its XMultiServiceFactory interface.
Now try adding this line
| Code: | | oShape.FillColor = RGB( 255, 220, 220 ) |
right after the assignment of oShape.Size = MakeSize( 5000, 1000 ). _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
vdoser General User

Joined: 24 Feb 2005 Posts: 32
|
Posted: Mon Feb 28, 2005 7:01 am Post subject: |
|
|
Thank you for the reply.
But my question is how to find the drawing toolbar and its tools in the objects hieratchy of a running OOo instance ; not how to create shapes.
I perused the API for a while and could not find the answer... . |
|
| Back to top |
|
 |
|