KOffice and Embedded Objects Part 1
This is the first blog in a series of two. In this part I will explain how embedded objects are stored in the OpenDocument Format (ODF) and some progress that has been made in KOffice lately. In part 2 I will show what the future has in store.
Now, as you know, any decent office software can handle embedded objects. Such objects can be widely different, from the very simple to the complex. It is the more complex types that I am going to talk about here like charts, music scores or even complete embedded documents.
Here is KWord showing an example document with two embedded objects: a rectangle and a chart:

Let's look at how this is saved inside the odt (OpenDocument Text) file. An .odt file is just a zip archive, and can be unpacked with the normal unzip command:
Notice the difference between the two objects, the rectangle and the chart. The rectangle is completely defined inline while the chart is only defined as a frame with a pointer to the actual contents, which is the xlink:href within the draw:object. Right now we can leave the actual contents of the files inside Object_1. That is not relevant here.
The interesting thing in the OpenDocument specification is that you can have more than one object inside the draw:frame element. These objects can be of any of these types:
KOffice has been able to handle such object replacements for a long time. However all the formats that KOffice could handle were bitmap formats. Bitmaps are good because they are easy to handle, but they are bad because they don't scale well. They become grainy or blocky when they are scaled up and you lose precision.
When you are dealing with MS formats like DOC (MS Word) or PPT (MS Powerpoint), you will find that the same concept of Object Replacements exist there. Naturally MS use their own formats, and in this case the formats in question are WMF (Windows MetaFile) and EMF (Extended MetaFile). WMF is an older 16 bit format and EMF is the newer 32 bit format. Both are vector formats so they are easy to scale and will not lose precision.
I have worked on import of embedded objects a while now and specifically to be able to import and show WMF and EMF. Except for one bug that I know of, I am now done: KOffice can now show embedded objects with object replacements using either WMF or EMF. To import and convert all of the MS file formats is a very big task and I'm sure that in the long run the KOffice team will manage that as well. But already now the users will be able to view any embedded object provided that there is a suitable object replacement. This will be available from KOffice 2.2.
As a proof, I give you this screenshot of KWord compiled from trunk that imports a DOC file with an embedded chart (the bug I was talking about is the text displacement in the legend):

KOffice 2.2 is shaping up very nicely. But it will be even better than this, and that is the topic of part 2 of this series.
Edit: the bug is now fixed.
Now, as you know, any decent office software can handle embedded objects. Such objects can be widely different, from the very simple to the complex. It is the more complex types that I am going to talk about here like charts, music scores or even complete embedded documents.
Here is KWord showing an example document with two embedded objects: a rectangle and a chart:

Let's look at how this is saved inside the odt (OpenDocument Text) file. An .odt file is just a zip archive, and can be unpacked with the normal unzip command:
# unzip ../kword-embedded-objects.odtWe have 2 interesting things to look at here: content.xml that contains the document contents, and Object_1 that is a subdirectory that contains an embedded object. Let us start with looking at a part of content.xml. Note that I have applied some formatting on the XML to make it easier to read.
Archive: ../kword-embedded-objects.odt
extracting: mimetype
inflating: settings.xml
inflating: content.xml
inflating: styles.xml
inflating: Object_1/content.xml
inflating: Object_1/styles.xml
inflating: meta.xml
inflating: Thumbnails/thumbnail.png
inflating: META-INF/manifest.xml
<text:p text:style-name="P1">abc</text:p>
<text:p text:style-name="P2">
<draw:rect draw:style-name="gr1" draw:id="shape1" svg:width="21.36217608452pt" svg:height="31.96877753470pt" svg:y="-31.9688pt" text:anchor-type="as-char"/>
</text:p>
<text:p text:style-name="P2">def</text:p>
<text:p text:style-name="P2">
<draw:frame draw:style-name="gr2" draw:id="shape2" svg:width="226.33462363427pt" svg:height="141.45913977142pt"
svg:x="-57.00000000000pt" svg:y="-42.00000000000pt" text:anchor-type="as-char">
<draw:object xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad" xlink:href="./Object_1"/>
</draw:frame>
</text:p>
<text:p text:style-name="P2">xyz</text:p>
Notice the difference between the two objects, the rectangle and the chart. The rectangle is completely defined inline while the chart is only defined as a frame with a pointer to the actual contents, which is the xlink:href within the draw:object. Right now we can leave the actual contents of the files inside Object_1. That is not relevant here.
The interesting thing in the OpenDocument specification is that you can have more than one object inside the draw:frame element. These objects can be of any of these types:
- Text boxes
- Objects represented either in the OpenDocument format or in a object specific binary format
- Images
- Applets
- Plug-ins
- Floating frames
KOffice has been able to handle such object replacements for a long time. However all the formats that KOffice could handle were bitmap formats. Bitmaps are good because they are easy to handle, but they are bad because they don't scale well. They become grainy or blocky when they are scaled up and you lose precision.
When you are dealing with MS formats like DOC (MS Word) or PPT (MS Powerpoint), you will find that the same concept of Object Replacements exist there. Naturally MS use their own formats, and in this case the formats in question are WMF (Windows MetaFile) and EMF (Extended MetaFile). WMF is an older 16 bit format and EMF is the newer 32 bit format. Both are vector formats so they are easy to scale and will not lose precision.
I have worked on import of embedded objects a while now and specifically to be able to import and show WMF and EMF. Except for one bug that I know of, I am now done: KOffice can now show embedded objects with object replacements using either WMF or EMF. To import and convert all of the MS file formats is a very big task and I'm sure that in the long run the KOffice team will manage that as well. But already now the users will be able to view any embedded object provided that there is a suitable object replacement. This will be available from KOffice 2.2.
As a proof, I give you this screenshot of KWord compiled from trunk that imports a DOC file with an embedded chart (the bug I was talking about is the text displacement in the legend):

KOffice 2.2 is shaping up very nicely. But it will be even better than this, and that is the topic of part 2 of this series.
Edit: the bug is now fixed.

1 Comments:
Mobile Movies
Dubbed Mobile Movies
Hindi Dubbed Movies
Full Software Free Download
Post a Comment
<< Home