Changes in Smart Tags in Office 2003


Smart tags have been significantly enhanced in Office 2003. First and foremost, PowerPoint, Access, and the new Research task panes feature in Office 2003 have smart tag support. Smart tags also have new object model capabilities. I'll describe the object model changes later in the chapter. First, we'll look at some of the other changes.

Universal Exception and Supplement Lists

If you've ever typed MSN into a Word document that has the financial symbol smart tag enabled, you know that Word recognizes MSN as a stock symbol. This behavior is probably not what you want on your client machines, so Office 2003 supports a universal exception list in which you specify terms that should never be recognized by certain smart tag recognizers. You can also turn off recognizers through the user interface, as shown in Figure 9-9.

click to expand
Figure 9-9: Turning off smart tag recognition through the Office interface

When you disable recognition through the user interface, a file named ignore.xml is created in the Documents and Settings\ username \Application Data\Microsoft\Smart Tags\Exceptions folder. You can create your own exception list and place it in Program Files\Common Files\Microsoft Shared\Smart Tag\Exceptions. You can direct Office to look in other directories for an exception list by creating a string value in the registry at HKCU\Software\Microsoft \Office\Common\Smart Tag\exceptionListDirectory. An exception list is simply an XML document that describes your exceptions. The following shows the format of an XML exception list. This exception list ignores CDO and MSN as stock symbols and ignores CDOEX as an overall smart tag.

 <ST:smarttagsupplementallist xmlns:ST="urn:schemas-microsoft-com:smarttags:list">     <ST:Item>         <ST:String>Frank Murphy</ST:String>         <ST:SmartTagTypeList>             <ST:SmartTagType>                 urn:schemas-microsoft-com:office:smarttags#personname             </ST:SmartTagType>         </ST:SmartTagTypeList>     </ST:Item>     <ST:Item>         <ST:String>ACME</ST:String>         <ST:SmartTagTypeList>             <ST:SmartTagType>                 urn:schemas-microsoft-com:office:smarttags#date             </ST:SmartTagType>         </ST:SmartTagTypeList>     </ST:Item> </ST:smarttagsupplementallist> 

As you can see, you list the term and the recognizer that you want to have ignore the term as a smart tag. If you do not pass the recognizer in the SmartTagType node, all smart tags will ignore the term.

In addition to a universal exception list, you might want a universal supplemental list in case Office does not tag words that you know should be smart tags. For example, Office might not tag some names that you know are valid, which means you can't quickly send e-mail to these people because they are not recognized as smart tags. For example, if a name has a unique spelling or is a unique name , Office might not have it in its default list of names . To create a supplemental list, you use a format similar to the exception list. Instead of tagging the list as an exception, however, you tag it in the first node of the XML document as a supplemental list. You store your supplemental lists in the same directories as your exception lists. The following supplemental list adds Tom Rizzo as a person and ACME Corporation as a date to show you how you can add any sort of term to a recognizer:

 <ST:smarttagsupplementallist xmlns:ST="urn:schemas-microsoft-com:smarttags:list">     <ST:Item>         <ST:String>Tom Rizzo</ST:String>         <ST:SmartTagTypeList>             <ST:SmartTagType>                 urn:schemas-microsoft-com:office:smarttags#personname             </ST:SmartTagType>         </ST:SmartTagTypeList>     </ST:Item>     <ST:Item>         <ST:String>ACME</ST:String>         <ST:SmartTagTypeList>             <ST:SmartTagType>                 urn:schemas-microsoft-com:office:smarttags#date             </ST:SmartTagType>         </ST:SmartTagTypeList>     </ST:Item> </ST:smarttagsupplementallist> 

MOSTL Improvements

Next I'll describe some of the improvements to MOSTL in Office 2003.

Localization Support

The first big improvement in MOSTL is support for localization. You can specify in any of the tags in MOSTL the LCID attribute and pass in a comma-delimited list of languages that are supported. If you specify an LCID in a parent element, all children elements will use that LCID. If no LCID is specified, all languages are assumed to be supported.

elementaction Tag

Another big improvement in MOSTL is the addition of the elementaction tag. Using this tag, you can add auto text for a smart tag or add XML fragments or documents. The following MOSTL file shows how to use the new elementaction capabilities.

 <FL:smarttaglist xmlns:FL="urn:schemas-microsoft-com:smarttags:list">   <FL:name>Sample</FL:name>   <FL:lcid>1033</FL:lcid>   <FL:description>A sample XML file that recognizes new elementaction</FL:description>   <FL:lastcheckpoint>100</FL:lastcheckpoint>   <FL:lastupdate>5123942</FL:lastupdate>   <FL:updateurl></FL:updateurl>   <FL:updateable>false</FL:updateable>   <FL:updatefrequency>10080</FL:updatefrequency>   <FL:autoupdate>false</FL:autoupdate>   <FL:smarttag type="urn:schemas-xml-com:document#fragment">     <FL:caption>DocFrag Rec</FL:caption>     <FL:terms>       <FL:termlist>         DocFrag       </FL:termlist>     </FL:terms>     <FL:actions>     <FL:action id="InsFrag">       <FL:caption>Insert fragment</FL:caption>         <FL:elementaction>           <FL:insertdocfragment>c:\Lists\docfrag.xml</FL:insertdocfragment>         </FL:elementaction>     </FL:action>     <FL:action id="InsXML">       <FL:caption>Insert XML</FL:caption>         <FL:elementaction>           <FL:insertXML>"<contact>Tom Rizzo</contact>"</FL:insertXML>         </FL:elementaction>     </FL:action>          <FL:action id="InsAutoText">       <FL:caption>Insert AutoText</FL:caption>         <FL:elementaction>           <FL:insertautotextentry>Autotext:</FL:insertautotextentry>         </FL:elementaction>     </FL:action>          </FL:actions>   </FL:smarttag> </FL:smarttaglist> 

Cascading Menus

Another major improvement in MOSTL is support for cascading menus in smart tags. (You will see how to support cascading menus programmatically later in this chapter when we implement some custom actions.) MOSTL provides cascading menus by using a triple slash ( /// ) in the caption property. The following sample MOSTL file displays cascading menus when you type the term cascade in a smart tag host. Figure 9-10 shows a cascading menu for a smart tag.

click to expand
Figure 9-10: Cascading menus in smart tags
 <FL:smarttaglist xmlns:FL="urn:schemas-microsoft-com:smarttags:list">   <FL:name>Sample</FL:name>   <FL:lcid>1033</FL:lcid>   <FL:description>A sample XML file that recognizes cascade</FL:description>   <FL:lastcheckpoint>100</FL:lastcheckpoint>   <FL:lastupdate>5123942</FL:lastupdate>   <FL:updateurl></FL:updateurl>   <FL:updateable>false</FL:updateable>   <FL:updatefrequency>10080</FL:updatefrequency>   <FL:autoupdate>false</FL:autoupdate>   <FL:smarttag type="urn:schemas-microsoft-com:office:smarttag#cascade">     <FL:caption>Cascading Menus</FL:caption>     <FL:terms>       <FL:termlist>         cascade       </FL:termlist>     </FL:terms>     <FL:actions>     <FL:action id="cascading">       <FL:url>http://localhost/</FL:url>                         <FL:caption>Cascade Menu///Home</FL:caption>     </FL:action>     <FL:action id="second menu">       <FL:url>http://localhost/</FL:url>                         <FL:caption>Cascade Menu///Option 2</FL:caption>     </FL:action>     <FL:action id="third menu">       <FL:url>http://localhost/</FL:url>                         <FL:caption>Cascade Menu///Option 3</FL:caption>     </FL:action>     <FL:action id="cascading2">       <FL:url>http://localhost/</FL:url>                         <FL:caption>Cascade Menu 2///Home</FL:caption>     </FL:action>     <FL:action id="second menu2">       <FL:url>http://localhost/</FL:url>                         <FL:caption>Cascade Menu 2///Option 2</FL:caption>     </FL:action>     <FL:action id="third menu2">       <FL:url>http://localhost/</FL:url>                         <FL:caption>Cascade Menu 2///Option 3</FL:caption>     </FL:action>     </FL:actions>   </FL:smarttag> </FL:smarttaglist> 

Running an Action on Recognition

MOSTL now has the ability to automatically run an action on recognition of a term. You might want to take advantage of this feature to launch a Web browser that points the user to a particular Web site when the user types a particular term in a document. The following sample shows how to use the runAction term to run an action on recognition. The sample launches the browser to the Microsoft Press Web site when you type the term Exchange or Outlook .

 <FL:smarttaglist xmlns:FL="urn:schemas-microsoft-com:smarttags:list" xmlns:o="http://schemas.microsoft.com/office/smarttags/2003/mostl">   <FL:name>Sample</FL:name>   <FL:lcid>1033</FL:lcid>   <FL:description>A Sample RunAction</FL:description>   <FL:lastcheckpoint>100</FL:lastcheckpoint>   <FL:lastupdate>5123942</FL:lastupdate>   <FL:updateurl></FL:updateurl>   <FL:updateable>false</FL:updateable>   <FL:updatefrequency>10080</FL:updatefrequency>   <FL:autoupdate>false</FL:autoupdate>   <FL:smarttag type="urn:schemas-ms-com:thomriz#auto">     <FL:caption>Autoaction Recognizer</FL:caption>     <FL:terms>       <FL:termlistwithprops>         <FL:prop o:runAction="MSPress"/>         <FL:t>Exchange</FL:t>         <FL:t>Outlook</FL:t>       </FL:termlistwithprops>     </FL:terms>     <FL:actions>     <FL:action id="MSPress">       <FL:url>http://mspress.microsoft.com/</FL:url>                         <FL:caption>MSPress website</FL:caption>     </FL:action>     </FL:actions>   </FL:smarttag> </FL:smarttaglist> 

Property Page Support

Building on the previous sample, you can see how to add a property page to your smart tag via the new PropertyPage tag. This tag takes a URL where you provide more information about the smart tag. Unfortunately, you cannot provide customization of your smart tag from your Web application using this property unless your Web page writes out configuration information to a location and your smart tag can be configured dynamically. Figure 9-11 shows the new Properties button in Word.

click to expand
Figure 9-11: The new Properties button on the Smart Tags tab of the AutoCorrect dialog box in Word
 <FL:smarttaglist xmlns:FL="urn:schemas-microsoft-com:smarttags:list" xmlns:o="http://schemas.microsoft.com/office/smarttags/2003/mostl">   <FL:name>Sample Proppage</FL:name>   <FL:lcid>1033</FL:lcid>   <FL:description>A Sample RunAction with Proppage</FL:description>   <FL:lastcheckpoint>100</FL:lastcheckpoint>   <FL:lastupdate>5123942</FL:lastupdate>   <FL:updateurl></FL:updateurl>   <FL:updateable>false</FL:updateable>   <FL:updatefrequency>10080</FL:updatefrequency>   <FL:autoupdate>false</FL:autoupdate>   <FL:smarttag type="urn:schemas-ms-com:thomriz#autorunwithproppage">     <FL:PropertyPage>http://localhost/myproppage</FL:PropertyPage>     <FL:caption>Autoaction Recognizer with Proppage</FL:caption>     <FL:terms>       <FL:termlistwithprops>         <FL:prop o:runAction="MSPress"/>         <FL:t>Exchange</FL:t>         <FL:t>Outlook</FL:t>       </FL:termlistwithprops>     </FL:terms>     <FL:actions>     <FL:action id="MSPress">       <FL:url>http://mspress.microsoft.com/</FL:url>                         <FL:caption>MSPress website</FL:caption>     </FL:action>     </FL:actions>   </FL:smarttag> </FL:smarttaglist> 

New Types of Smart Tags: Expiring, Transitory , and Temporary

To support more diverse smart tag scenarios, Office includes three new types of smart tags. The first is an expiring smart tag. Say you have a term that you want recognized, but only for a limited time. For example, you might want to garner feedback on a document titled Charney v. Charney but you know that the feedback won't be valid after a certain date. You can add a property called exp to your term list. To this property you pass the year, month, day, hour, and minute (for example, 2003:10:01:10:00, which sets an expiration for the year 2003, month 10, day 01, hour 10, minute 00). The time is set in a 24- hour clock format. For example, you can pass just 2003:10:01, which expires the recognition of the term on October 1, 2003, right at midnight. The following sample expires the term Charney v. Charney using this new property:

 <FL:smarttaglist xmlns:FL="urn:schemas-microsoft-com:smarttags:list" xmlns:o="http://schemas.microsoft.com/office/smarttags/2003/mostl">   <FL:name>Sample Expiry</FL:name>   <FL:lcid>1033</FL:lcid>   <FL:description>A Sample Expiry Action</FL:description>   <FL:lastcheckpoint>100</FL:lastcheckpoint>   <FL:lastupdate>5123942</FL:lastupdate>   <FL:updateurl></FL:updateurl>   <FL:updateable>false</FL:updateable>   <FL:updatefrequency>10080</FL:updatefrequency>   <FL:autoupdate>false</FL:autoupdate>   <FL:smarttag type="urn:schemas-ms-com:sample#exp">     <FL:caption>Expiring Recognizer</FL:caption>     <FL:terms>       <FL:termlistwithprops>         <FL:prop o:exp="2002:12:04:13:14"/>         <FL:t>Charney v. Charney</FL:t>       </FL:termlistwithprops>     </FL:terms>     <FL:actions>     <FL:action id="Legal">       <FL:url>http://Legalnet</FL:url>                         <FL:caption>LegalNet website</FL:caption>     </FL:action>     </FL:actions>   </FL:smarttag> </FL:smarttaglist> 

The second new type of smart tag is the transitory smart tag, which is useful when a multiple word phrase is recognized as a smart tag and that the smart tag disappears as users type in the paragraph. For example, say you recognize the word transitory and also the phrase transitory recognition . If a user pauses long enough after typing transitory and then types recognition , both the word and the phrase will be smart tagged. You might prefer that the smart tag underlining disappear as soon as the user starts typing after the word transitory so the application can see whether the user is typing recognition or something else after transitory . To use transitory smart tags, you add the ls ”short for lifespan ”property to your termlist element, as shown in the following code:

 <FL:smarttaglist xmlns:FL="urn:schemas-microsoft-com:smarttags:list" xmlns:o="http://schemas.microsoft.com/office/smarttags/2003/mostl">   <FL:name>Sample</FL:name>   <FL:lcid>1033</FL:lcid>   <FL:description>A Sample TransAction</FL:description>   <FL:lastcheckpoint>100</FL:lastcheckpoint>   <FL:lastupdate>5123942</FL:lastupdate>   <FL:updateurl></FL:updateurl>   <FL:updateable>false</FL:updateable>   <FL:updatefrequency>10080</FL:updatefrequency>   <FL:autoupdate>false</FL:autoupdate>   <FL:smarttag type="urn:schemas-ms-com:thomriz#transitory">     <FL:caption>Transitory recognizer</FL:caption>     <FL:terms>       <FL:termlistwithprops>         <FL:prop o:ls="trans"/>         <FL:t>Trans</FL:t>         <FL:t>Trans Recognition</FL:t>         <FL:t>Transitory</FL:t>         <FL:t>Transitory Recognition</FL:t>         <FL:t>Recognition</FL:t>       </FL:termlistwithprops>     </FL:terms>     <FL:actions>     <FL:action id="Link">       <FL:url>http://Localhost</FL:url>                         <FL:caption>Link to website</FL:caption>     </FL:action>     </FL:actions>   </FL:smarttag> </FL:smarttaglist> 

The third new type of smart tag is the temporary smart tag. Regular smart tags can be saved and embedded in documents, but temporary smart tags cannot be saved, which stops people from accidentally sending sensitive information as a smart tag outside an organization. To make a temporary smart tag, you just add an ls property to your termlist and set that property to temp , as shown in the following code:

 <FL:smarttaglist xmlns:FL="urn:schemas-microsoft-com:smarttags:list" xmlns:o="http://schemas.microsoft.com/office/smarttags/2003/mostl">   <FL:name>Sample</FL:name>   <FL:lcid>1033</FL:lcid>   <FL:description>A Sample TempAction</FL:description>   <FL:lastcheckpoint>100</FL:lastcheckpoint>   <FL:lastupdate>5123942</FL:lastupdate>   <FL:updateurl></FL:updateurl>   <FL:updateable>false</FL:updateable>   <FL:updatefrequency>10080</FL:updatefrequency>   <FL:autoupdate>false</FL:autoupdate>   <FL:smarttag type="urn:schemas-ms-com:thomriz#temp">     <FL:caption>Temporary recognizer</FL:caption>     <FL:terms>       <FL:termlistwithprops>         <FL:prop o:ls="temp"/>         <FL:t>Temp</FL:t>       </FL:termlistwithprops>     </FL:terms>     <FL:actions>     <FL:action id="Link">       <FL:url>http://localhost</FL:url>                         <FL:caption>Link to website</FL:caption>     </FL:action>     </FL:actions>   </FL:smarttag> </FL:smarttaglist> 

Hiding the Smart Tag Underlining in the User Interface

Sometimes you might not want the smart tag underlining to appear in the user interface. Suppose you receive a large document with a section that is known to be a recognized term. Rather than have the entire section underlined in purple, you can hide the user interface for smart tags. The icon for the smart tag will appear, but the purple underline will not. You can set this option by using the ShowSmartTagIndicator tag and setting it to False . By default, or by setting this tag to True , the purple underline will appear. Here's a sample that uses this tag:

 <FL:smarttaglist xmlns:FL="urn:schemas-microsoft-com:smarttags:list">   <FL:name>NoUI</FL:name>   <FL:lcid>1033,0</FL:lcid>   <FL:description>This shows how to not show ST UI</FL:description>   <FL:smarttag type="urn:schemas-microsoft-com:office:smarttags#NoUI">     <FL:PropertyPage>http://office.microsoft.com</FL:PropertyPage>     <FL:caption>NoUI Smart Tag</FL:caption>     <FL:terms>       <FL:termlist>NoUI</FL:termlist>     </FL:terms>     <FL:actions>       <FL:action id="NoUIAction">         <FL:caption>This is no UI</FL:caption>         <FL:ShowSmartTagIndicator>False</FL:ShowSmartTagIndicator>         <FL:url>http://noui</FL:url>       </FL:action>     </FL:actions>   </FL:smarttag> </FL:smarttaglist> 

Regular Expression Support

A welcome improvement in MOSTL is the addition of regular expression/context-free grammar support. The regular expression support in MOSTL is similar to regular expressions in PERL. The regular expression rules are too complex to explain here, but you can find the PERL regular expression documentation at http://www.perldoc.com/perl5.6/pod/perlre.html . The date, phone, and time MOSTL files included with Office are good examples of how regular expressions are used in MOSTL. Here is another sample, which uses regular expressions to match Customer ID: some number or Customer ID some number . It passes the customer ID along with the query string to a Web page to look up the customer.

 <FL:smarttaglist xmlns:FL="urn:schemas-microsoft- com:smarttags:list" xmlns:o="urn:schemas-microsoft-com:office:office">   <FL:name>Customer IDs</FL:name>   <FL:lcid>1033,0</FL:lcid>   <FL:description>     Recognizes Customer IDs in format Customer ID: 123 or Customer ID 123   </FL:description>   <FL:moreinfourl>http://yourwebsite</FL:moreinfourl>   <FL:updateable>false</FL:updateable>   <FL:smarttag type="urn:schemas-microsoft-com:Customers#CustomerID">     <FL:caption>Regular Expression for Customer IDs</FL:caption>     <FL:re>       <FL:exp>         <FL:prop o:runAction="CustomerID:openInIE" CustomerID="" />         Customer:*\s*ID*:*\s*(\d+)       </FL:exp>     </FL:re>     <FL:actions>       <FL:action id="CustomerID:openInIE">         <FL:url>           http://localhost/somepage.asp?CustomerID={PROP:CUSTOMERID}         </FL:url>         <FL:caption>&amp;CustomerID///Open &amp;Customer...</FL:caption>       </FL:action>     </FL:actions>   </FL:smarttag> </FL:smarttaglist> 

You can also put the regular expression in an includes file, as the following code shows:

 <FL:smarttag type="urn:schemas:Microsoft.com#myre>     <FL:includefile>C:\myre\re.xml</FL:includefile>    

Context-free grammar (CFG) is grammar that follows rules you set out in your MOSTL file. Because you can set a number of options for CFG, I'll refer you to the smart tag SDK. However, here is an example of CFG in a MOSTL file. This sample recognizes emoticons in your documents and links to an image.

 <FL:smarttaglist xmlns:FL="urn:schemas-microsoft-com:smarttags:list">   <FL:name>CFG Example emoticon</FL:name>   <FL:lcid>1033</FL:lcid>   <FL:description>This recognizer recognizes emoticons</FL:description>   <FL:moreinfourl>http://microsoft.com</FL:moreinfourl>   <FL:lastcheckpoint>1</FL:lastcheckpoint>   <FL:lastupdate>4123942</FL:lastupdate>   <FL:updateable>false</FL:updateable>   <FL:updatefrequency>10080</FL:updatefrequency>   <FL:autoupdate>false</FL:autoupdate>   <FL:smarttag type="urn:schemas-microsoft-com:tools#smiley">     <FL:caption>Emoticon Recognizer</FL:caption>     <FL:cfg topRule="smiley">       <FL:rule name="smiley">         <FL:ruleref ref="eyes"/>         <FL:ruleref ref="nose"/>         <FL:ruleref ref="mouth"/>       </FL:rule>            <FL:rule name="eyes">         <FL:l>           <FL:p>:</FL:p>           <FL:p>=</FL:p>           <FL:p>8</FL:p>           <FL:p>;</FL:p>         </FL:l>       </FL:rule>            <FL:rule name="nose">         <FL:o>           <FL:l>             <FL:p>-</FL:p>             <FL:p>^</FL:p>           </FL:l>         </FL:o>       </FL:rule>            <FL:rule name="mouth">         <FL:l>           <FL:p>)</FL:p>           <FL:p></FL:p>           <FL:p>(</FL:p>         </FL:l>       </FL:rule>     </FL:cfg>          <FL:actions>       <FL:action id="Smile!">         <FL:url>http://localhost/smile.gif</FL:url>         <FL:caption>Smile!</FL:caption>       </FL:action>     </FL:actions>   </FL:smarttag> </FL:smarttaglist> 

Support for Arbitrary Properties in Items

The last enhancement to MOSTL that I'll discuss is the ability to add arbitrary properties to your items in a list of terms. The following MOSTL file shows how to do this using the prop tag:

 <FL:smarttaglist xmlns:FL="urn:schemas-microsoft-com:smarttags:list" xmlns:o="urn:schemas-microsoft-com:office:office">   <FL:name>First Names</FL:name>   <FL:lcid>1033,0</FL:lcid>   <FL:description>Recognizes a few first names.</FL:description>   <FL:updateable>false</FL:updateable>   <FL:smarttag type="urn:schemas-microsoft-com:office:smarttags#firstName">     <FL:caption>First Name</FL:caption>     <FL:terms>       <FL:termlistwithprops>         <FL:prop RecognizedByMOSTLList="True" />         <FL:t>Bob</FL:t>         <FL:t>Sally</FL:t>         <FL:t>Mary</FL:t>       </FL:termlistwithprops>     </FL:terms>   </FL:smarttag> </FL:smarttaglist> 



Programming Microsoft Outlook and Microsoft Exchange 2003
Programming MicrosoftВ® OutlookВ® and Microsoft Exchange 2003, Third Edition (Pro-Developer)
ISBN: 0735614644
EAN: 2147483647
Year: 2003
Pages: 227
Authors: Thomas Rizzo

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net