From Apache OpenOffice Wiki
Revision as of 14:20, 6 April 2013 by Adailton (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

VML is a language for defining graphical objects in cases where DrawingML does not apply in Office Open XML, such as text boxes and shapes in WordprocessingML and comments and controls in SpreadsheetML.

VML is a legacy format originally introduced with Office 2000 and is existing mainly for backwards compatibility reasons. The DrawingML format is a newer and richer format created with the goal of eventually replacing any uses of VML in the Office Open XML formats.

VML Usage in the Office Open XML Format

WordprocessingML OfficeArt Shapes

Office Art shape is defined as a template-based shape in VML.

For example: We have 2 shapes in Word 2007, as below:


And the OOXML description for this part is as below:


In the OOXML file, the <v:shapetype> defines the shape's path information, and the <v:shape> defines style related information. And also the property type defined in <v:shape> means current shape refer to which of the shape type definition. And also, different shape in one document may refer to the same shape type if they have same layout, but with different style only.

WordprocessingML Text Box

Text Box created in MS Office 2007/2010 are described as VML format also, with the text information embeded in VML shape description.

For example, we have a file with a text box in it:


And the VML format saved in OOXML files is as blow:


From the OOXML definition above, the <v:textbox> part hold the text information and also format information in it to mark that it's a VML text box in the file

SpreadsheetML Comments

Comments created by Excel 2007/2010 are described as VML format in MS OOXML, and separated from SpreadsheetML.

For example, we have a xlsx file with a comment in as below:


And the comments information saved in the zip file as package\xl\comment[1].xml, and the drawing's information saved in the path as below:


VML Parser data structure

VML shape parser and VML shape model under OOX

We can get the VML parser under \oox\source\vml, there are several parts for VML shape handler. Including:

   vmldrawing.cxx          -   Including: class Drawing, the VML drawing page that contains this shape
   vmldrawingfragment.cxx  -   Including: class DrawingFragment, used to handle the vml shape context
   vmlformatting.cxx       -    
   vmlinputstream.cxx      -
   vmlshape.cxx            -   Including: class ShapeBase, used to handle vml shape related properties and create XShape
   vmlshapecontainer.cxx   -   Including: class ShapeContainer, used to hold all vml related information, like: shape types in shape and shapes in group shape
   vmlshapecontext.cxx     -   Including: class ShapeContext, used to be as vml shape context handler to parser vml shape properties from ooxml file
   vmltextbox.cxx          -   Including: class TextBox, used to handle textbox related information
   vmltextboxcontext.cxx   -   Including: class TextBoxContext, used to be as vml textbox context handler to parser vml textbox properties from ooxml file

The main Shape model in filter is as below, and the vml shape related properties will be save in Shape Container, and be held under OOX.

From the picture below, there are 3 main parts for shape model:

   ShapeContainer - Hold the ShapeTypeVector and ShapeBaseVector reference for vml shape related information
   ShapeType      - Hold the ShapeTypeModel which used to save all shape type related properties
   ShapeBase      - Hold the ShapeModel which used to save sall shape related properties


Another part is about the vml shape context handler, which used to parser VML shape from OOXML file, and called as ShapeContextHandler, and the connections between the ShapeContextHandler and the Shape properties model is as blow:

From the picture blow, there are several class for Shape properties handler:

   ShapeContexthandler - It's the root Shape Context interface under OOX namespace to process VML shape properties through call for direct handler
   ShapeContextBase    - It's the base context handler that process each part of VML shape
   ShapeTypeContext    - Inherited from ShapeContextBase to process Shape Type related properties
   GroupShapeContext   - Inherited from ShapeContextBase to process Group Shape related properties
   ShapeContext        - Inherited from ShapeTypeContext to process Shape related properties


VML Shape parser under writerfilter

VML Shape used in docx file will be parsered under writerfilter, so there are also vml shape context handler defined under writerfilter.

   OOXMLFastContextHandlerShape   - VML Shape Context Handler
   OOXMLFastContextHandlerWrapper - The Wrapper for VML Shape context Handler under OOX


The sequence for VML Shape parser process

To parse the VML Shape from docx file, we need to use the VML Shape Context Handler defined both under writerfilter and under oox. And there is a wrapper under writerfilter for ShapeContextHandler under oox, which is a connections betweent the 2 different model.

We can see from below diagram that: 1> OOXMLFastContextHandlerShape is the root handler for VML shape in docx; 2> Create ShapeContextHandler under oox when we create child context handler; 3> After the creation of ShapeContextHandler, will create OOXMLFastContextHandlerWrapper as the wrapper for ShapeContextHandler, and which is used for later track for more vml tokens defined.


Personal tools