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.
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:
<a:satMod val="175000" />
<a:alpha val="40000" />
<a:innerShdw blurRad="63500" dist="50800"
<a:alpha val="50000" />
<a:reflection blurRad="6350" stA="52000"
endA="300" endPos="35000" dir="5400000"
Notice that some effects only have some attributes while others contain color specifications as child elements like the ones explained in the previous post.
Shapes and bitmaps can be transformed into 3D objects and get lighting and camera modifications applied to them.
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:
<a:rot lat="19490639" lon="0"
<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" />
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.
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:
<a:blip r:embed="rId6" cstate="print">
<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:
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.