Browse DevX
Sign up for e-mail newsletters from DevX


Designing Smart Documents in Office 2003 : Page 6

Today, most organizations have a wealth of Office documents that contain critical information, but finding, extracting, and reusing that information programmatically remains a largely unrealized goal. Fortunately, that's changing as XML processing in Microsoft Office 2003 grows up.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Implementing XMLType Definitions
At this point you have created all the XMLTypes and their associated ISmartControl instances. Note that so far, there's been no rendering or creation of physical controls.

After initialization the API calls the SmartXMLTypeCount method of the ISmartDocument interface within CustomerDocument.vb. In this case, because you have three types the return value should be 3. The types Hashtable contains the list of these types so a simple Count function returns the number of items stored in the collection.

Public Shared Function Count() As Integer Return types.Count End Function

Next, the API calls the SmartDocXmlTypeName and SmartDocXmlTypeCaption for each type. In these methods you make calls to DocumentUtils.Name and DocumentUtils.Caption.

In each of these cases the XMLTypeID used will be iterative. The order of the calls follows the sequence shown in Table 3.

Table 3. Method Call Sequence. The Office API calls these methods in sequence for the three XmlTypes defined in the sample application.
Method XMLTypeID Value
SmartDocXmlTypeName 1 http://Officesamples/Customer/2004#documentRoot
SmartDocXmlTypeCaption 1 Root content
SmartDocXmlTypeName 2 http://Officesamples/Customer/2004#region
SmartDocXmlTypeCaption 2 Region selection
SmartDocXmlTypeName 3 http://Officesamples/Customer/2004#itemname
SmartDocXmlTypeCaption 3 Item Selection

Remember that the SmartType stores the return values for Caption and Name while initializing each XmlType instance.

Public Shared Function Name( _ ByVal XMLTypeId As Integer) As String Dim XMLTypeName As String = GetTypeName(XMLTypeId) If types.ContainsKey(XMLTypeName) Then Return XMLTypeName End If End Function

The preceding snippet uses the GetTypeName(XMLTypeId) call to fetch the XMLTypeName for the XMLTypeID. The XMLTypeName is the key for the types hashtable, from which you retrieve the appropriate SmartNode and its corresponding Caption/Name.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date