Tales of LibreOffice interoperability: shape effects

We continue introducing features that will be part of the 4.3.0 release of LibreOffice, which is coming soon. After having worked in the preservation of color in shapes, we worked on the different effects that can be applied to shapes and bitmaps.

There are three types of effects that are managed separately in the DrawingML specification.

General shape effects

Examples of these effects are inner or outer shadows, reflections, glow… They can be applied both to vectorial shapes or bitmaps, and several of them can be applied at the same time.

Shape effects sample

These effects are indicated with the a:effectLst tag inside the shape properties tag spPr. I won’t explain their specification in detail because you can find a very good description in this website, but you can get an idea by taking a look at the following example where three effects are applied: glow, inner shadow and reflection:

[code language=”xml”]
<a:glow rad="63500">
<a:schemeClr val="accent2">
<a:satMod val="175000" />
<a:alpha val="40000" />
<a:innerShdw blurRad="63500" dist="50800"
<a:prstClr val="black">
<a:alpha val="50000" />
<a:reflection blurRad="6350" stA="52000"
endA="300" endPos="35000" dir="5400000"
sy="-100000" algn="bl"
rotWithShape="0" />

Notice that some effects only have some attributes while others contain color specifications as child elements like the ones explained in the previous post.

3D effects

Shapes and bitmaps can be transformed into 3D objects and get lighting and camera modifications applied to them.

Shape 3D effects sample

These effects are basically controlled by two children tags of spPr. One of them is a:scene3d and controls the camera and lighting, and the other one is a:sp3d which controls the transformation of the shape in a 3D object adding extrusion, bevels and a material effect to the surface. In the same website I linked before, you can read a description of scene3d and sp3d tags and their children. Find an example of their combined use below:

[code language=”xml”]
<a:camera prst="perspectiveRelaxedModerately"
<a:rot lat="19490639" lon="0"
rev="12900001" />
<a:lightRig rig="threePt" dir="t">
<a:rot lat="0" lon="0" rev="4800000" />
<a:sp3d z="488950" extrusionH="63500"
<a:bevelT w="165100" prst="coolSlant" />
<a:schemeClr val="tx2" />

Artistic effects

Effects from the last category act like the filters found in image manipulation programs (blur, grain or background removal among others) and that’s why they only can be applied to bitmaps. This is actually not a part of DrawingML spec but an extension over it.

There is an important difference with other filters; these ones come pre-calculated in the document. The bitmap linked by the DrawingML shape already comes with the effect, and the effect specification links a second bitmap that contains the original picture so the effect can be undone. This second bitmap is saved in the relatively new loss-less Windows Media Photo format.

Writer screenshot showing artistic effects

Check the following example of a blip-filled shape; the actual filling comes from the file linked as rId6, while the effect definition is linked to rId7 which is a copy of the original image before the filter was applied:

[code language=”xml”]
<a:blip r:embed="rId6" cstate="print">
<a:ext uri="{BEBA8EAE-BF5A-486C-A8C5-ECC9F3942E4B}">
<a14:imgProps xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main">
<a14:imgLayer r:embed="rId7">
<a14:artisticLightScreen trans="10000" gridSize="6" />

These are the relations between the ids and the files contained in the document, as specified at document.xml.rels:

[code language=”xml”]
<Relationship Id="rId6"
Target="media/image2.png" />
<Relationship Id="rId7"
Target="media/hdphoto1.wdp" />

The funny thing of this approach is that LO was able to render these effects with no effort, although the program was not aware of the effect parameters or the original bitmap and these were being lost on save.


We use again the grab bag technique to save all the tags and attributes related with the effects as a hidden property that will be used later in the export phase to re-build the effect definitions. In the case of artistic effects, we additionally need to make sure that the original bitmap is preserved; LibreOffice doesn’t support the Windows Media Photo format yet, but we can keep the raw stream of data and output it to a properly named file in the exported document. A small cache table is maintained by the exporter code to prevent that the same original file is saved more than once when two or more pictures apply effects to the same image.

We have finished with the improvements related to shapes and pictures, but there are a few interoperability features not yet mentioned which will be covered in a future post. Like the current and previous ones, they were developed by Igalia and sponsored by CloudOn.

Happy hacking!

3 thoughts on “Tales of LibreOffice interoperability: shape effects

  1. Pingback: Hot accessibility for LibreOffice 4.3.0 | [jacobo@igalia ~]

  2. Do I understand correctly: these effects are now preserved on import, but there is no UI in LO to edit them? I was trying on LO 4.3 to apply a blurred shadow to an object and failed…?

    • Indeed, the goal for this iteration of LibreOffice was preserving the effects when a document is imported and exported back to .docx. This is a first step towards full support to edit these effects, which unfortunately will still require some time to be achieved.

Leave a Reply

Your email address will not be published. Required fields are marked *