OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Remote control of a running OO instance

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
vdoser
General User
General User


Joined: 24 Feb 2005
Posts: 32

PostPosted: Thu Feb 24, 2005 10:52 am    Post subject: Remote control of a running OO instance Reply with quote

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
View user's profile Send private message
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Thu Feb 24, 2005 11:29 am    Post subject: Reply with quote

When you are connected with OOo, you choose yourself the application you want to work with. You haven't to detect it Or you work with the default focused document ?
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
vdoser
General User
General User


Joined: 24 Feb 2005
Posts: 32

PostPosted: Thu Feb 24, 2005 1:11 pm    Post subject: Reply with quote

the default focused...
Back to top
View user's profile Send private message
hol.sten
Super User
Super User


Joined: 14 Nov 2004
Posts: 3533
Location: Hamburg, Germany

PostPosted: Thu Feb 24, 2005 1:28 pm    Post subject: Re: Remote control of a running OO instance Reply with quote

vdoser wrote:
how to identify what OO type(Writer, Calc, etc) I'm connected to.

That was already discussed here: http://www.oooforum.org/forum/viewtopic.phtml?t=4391&highlight=identify+type. I haven't tried it, but perhaps it is what you are looking for.

With kind regards
hol.sten
Back to top
View user's profile Send private message
vdoser
General User
General User


Joined: 24 Feb 2005
Posts: 32

PostPosted: Thu Feb 24, 2005 1:54 pm    Post subject: Reply with quote

Thanks a lot!
Any ideas on how to control/navigate to the drawing tools objects?
Back to top
View user's profile Send private message
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Sat Feb 26, 2005 11:43 am    Post subject: Reply with quote

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
View user's profile Send private message
vdoser
General User
General User


Joined: 24 Feb 2005
Posts: 32

PostPosted: Mon Feb 28, 2005 7:01 am    Post subject: Reply with quote

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... Sad.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group