2
votes

I am looking for some references on how to implement the following feature:

ability to embed objects (e.g. diagrams) into word processors and being able to edit them in their respective "mother" application

For example, MS Word and Visio work like this together, allowing the user to easily edit/tweak the diagrams after adding them to the word processor.

I am interested in how this is done on the following platforms:

  • Microsoft Word
  • OpenOffice

So far I know that:

  • Microsoft Word uses OLE/COM
  • Open Office uses UNO

Can you point me to any references, examples, books on how to approach this?

2
Just a note: OpenOffice.org uses UNO for automation purposes, but to embed objects of other applications it uses OLE as well, see wiki.services.openoffice.org/wiki/Documentation/….Dirk Vollmar
Aditional to comment of @DirkVollmar : The OLE bridge (UNO-COM only for OLE) openoffice.org/udk/common/man/spec/ole_bridge.htmluser2006656

2 Answers

3
votes

Since OLE is an almost pre-historic technology (still of use) you have to dig a bit deeper in MSDN. The article linked below describes a sample application that can be embedded into container applications such as IE, Word, or OpenOffice. The sample is based on VC6, so I don't know how much luck you will have to get it running with current versions of Visual Studio.

Creating an OLE Server

Probably the most simple option to create an OLE control (.ocx) is to use the old Visual Basic 6. This is described here:

How To Create and Use a Minimal ActiveX Component in VB

It is also possible to write a control in managed code like C#, but I assume this is not recommended1 as it might lead to conflicts if the current process is already running another version of the CLR (Up to now, only one version of the CLR can exist in a process, .NET 4.0 will introduce side-by-side execution of the CLR). I found the following tutorial:

Create ActiveX in .NET Step by Step

1See the warning at the bottom of this article by Andrew Whitechapel.

1
votes

This can still be quite easily done in Word using COM (or OLE but it's the same thing with a new name). Depending on what language you are intending to do it in you will go about it differently. Essentially you need to create a particular kind of ActiveX control.

In Delphi (the easiest language to do this in) you would create an ActiveXForm in a COM dll and then you would be able to embed this in your word document. You could make your application do whatever you wanted inside Word (talking to Word is a bit more involved but possible).

I have no idea what to do in OpenOffice I'm afraid.

I think you need to come back with more specific questions.