SlideShare a Scribd company logo
1 of 19
in 37 minutes Episode 22 Viewing the unviewable: Displaying additional image types in XMetaL Using the InPlaceControl interface to add custom viewer controls Tom Magliery, XML Technology Specialist 12 May 2011 Brought to you by XMetaL Technical Services
XMetaL can display images in several common graphics formats (full list in Help) For non-supported formats, XMetaL can use an ActiveX viewer control to display the images You have to supply the viewer You have to do some script customization Purpose of today: show you how to do the script customization Introduction
CTM file <OCXReplacement> Associates an ActiveX viewer control with an element Event macros _OnShouldCreate, _OnInitialize, _OnFocus, _OnSynchronize InPlaceControl interface Application.ActiveInPlaceControl gives access to the viewer control during these events Keys to this customization
Have an XML element solely dedicated to the special image type: <Visio_Image> Always use viewer control to display this element Need two bits of code: <OCXReplacement> in CTM file _OnInitialize macro Example 1
<OCXReplacement> <OCXReplacements> is an optional main element in the CTM file – like <ElementPropertiesList>, <Templates>, etc. Name of your image element Prefix to be used with event macros (can be whatever you want provided the resulting macro name is valid) ... <OCXReplacements>     <OCXReplacement>         <SelectorName>Visio_Image</SelectorName>         <MacroPrefix>VisioViewer</MacroPrefix>         <ProgID>VisioViewer.Viewer</ProgID>     </OCXReplacement> </OCXReplacements> ... ProgID of your ActiveX viewer control
_OnInitialize macro This macro is executed for each <Visio_Image> element in the document. ActiveInPlaceControl object exists for the duration of this macro. Name prefix matches what was in the CTM file. Sets the size for the control. <MACRO name="VisioViewer_OnInitialize" hide="true"  lang="JScript"><![CDATA[  varaipc = Application.ActiveInPlaceControl; aipc.Width = 500;	 aipc.Height = 300; var filename = aipc.Node.getAttribute("href"); aipc.Control.SRC = filename; ]]></MACRO> Node is the element being displayed with this control. Control property gives you access to the IDispatch interface of the viewer control. SRC is a property of the Visio Viewer control. Can also perform other initializations here using the control’s interface, via aipc.Control.*.
Use the same image element for built-in and a special image format Use viewer control for special image type <Dual_Purpose_Imagehref=“myVisioDiagram.vsd”/> Fall back to default XMetaL behavior otherwise <Dual_Purpose_Imagehref=“myJPG.jpg”/> Need same code bits as before, plus: <Image> in CTM file _OnShouldCreate macro Example 2
Same stuff from before <OCXReplacement> in the CTM – different element name, different macro prefix ... <OCXReplacements>     <OCXReplacement>         <SelectorName>Dual_Purpose_Image</SelectorName>         <MacroPrefix>VV2</MacroPrefix>         <ProgID>VisioViewer.Viewer</ProgID>     </OCXReplacement> </OCXReplacements> ... _OnInitialize macro does the same thing as before – it’s using the same viewer control <MACRO name="VV2_OnInitialize" hide="true"  lang="JScript"><![CDATA[  varaipc = Application.ActiveInPlaceControl; aipc.Width = 500;	 aipc.Height = 300; var filename = aipc.Node.getAttribute("href"); aipc.Control.SRC = filename; ]]></MACRO>
<Image> Handles the fall-back case of built-in image formats. <Dual_Purpose_Image> is designated as an image element in the CTM. ... <Image>     <Name>Dual_Purpose_Image</Name>     <Source-Attribute>href</Source-Attribute>     <Height-Attribute>height</Height-Attribute>     <Width-Attribute>width</Width-Attribute>     <AltText-Attribute>alt</AltText-Attribute> </Image> ...
_OnShouldCreate Use business logic to determine whether XMetaL should be displaying this element in the viewer control in this instance; store the outcome in the ShouldCreate property. Get the href attribute from the element to which this control is (tentatively) attached <MACRO name="VV2_OnShouldCreate" hide="true"  lang="JScript"><![CDATA[ varaipc = Application.ActiveInPlaceControl; varhref = aipc.Node.getAttribute("href"); vari = href.lastIndexOf(".vsd");     if (i != -1) { aipc.ShouldCreate = true;     } else { aipc.ShouldCreate = false;     } ]]></MACRO>  Look at the file extension to see if this is a Visio file Set the ShouldCreate property accordingly
Using _OnFocus event to manipulate the viewer control Our Visio viewer has APIs for turning on/off various features of the control Suppose we want toolbar, scrollbars, etc. only when the control has focus Example 3
_OnFocus This macro is executed both on focus and on blur – when the user clicks in or out of the viewer control. UserMovedIntoControl property is true on “focus” and false on “blur” <MACRO name="VisioViewer_OnFocus" hide="true" lang="JScript"><![CDATA[ varaipc = Application.ActiveInPlaceControl; aipc.Control.AlertsEnabled      = aipc.UserMovedIntoControl; aipc.Control.ScrollbarsVisible  = aipc.UserMovedIntoControl; aipc.Control.ToolbarVisible     = aipc.UserMovedIntoControl; aipc.Control.PageVisible        = aipc.UserMovedIntoControl; ]]></MACRO>
Using _OnSynchronize event to update the document and/or the control Useful when you need to update data in the viewer control because of changes in the document – or vice versa Bizarre hypothetical example: Suppose we have an element in our document that we wish to reflect the current “zoom” level of the Visio control Example 4
_OnSynchronize Macro is executed whenever the document changes and whenever focus leaves the viewer control. UpdateFromDocument=true if the control may need updating because the document state has changed; false if it’s the other way around. This is our bizarre “zoom” data element <MACRO name="VisioViewer_OnSynchronize" hide="true" lang="JScript"><![CDATA[ varaipc = Application.ActiveInPlaceControl; varndlist = aipc.Document.GetElementsByTagName("Author");     if (!aipc.UpdateFromDocument) { var zoom = aipc.Control.Zoom; ndlist.item(0).firstChild.nodeValue = zoom;     } else { var value = ndlist.item(0).firstChild.nodeValue; aipc.Control.Zoom = value;     } ]]></MACRO> Set document data based on the control Set control data based on the document
If your viewer control API includes events, you can write script in XMetaL to handle the events If your viewer has an event called “SomeEvent”, you can write a macro like this: When the viewer fires the event, XMetaL will execute this macro ActiveInPlaceControl.NextEventParam property allows you to access the arguments of the event Unfortunately no example to show today :-( (Non)-example:Events in the viewer control <MACRO name="VisioViewer_SomeEvent" hide="true" lang="JScript"><![CDATA[     // In here you do whatever you need to handle this event ]]></MACRO>
If you require more than one viewer control, and if all the image types use the same <Image> element, some additional scripting is required CTM file can only have one <OCXReplacement> for each DTD element But you can define additional OCXReplacements dynamically in script Relevant APIs: DOMDocumentType.addInPlaceControl() InPlaceControl.userData A little too much for an example here today! (Non)-example:More than one custom viewer
XMetaL DITA customization uses this technique – recursively! – to display SVG graphics XMetaL’s viewer control is Internet Explorer IE (through 8) does not natively support SVG either – requires you to install a plugin So XMetaL hands the image over to IE, which in turn hands it over to your SVG plugin SVG in DITA in XMetaL
XMetaL Community Forums http://forums.xmetal.com/ JustSystems Partner Center http://justpartnercenter.com/ Ask us for help (partner tech support) partnersupport-na@justsystems.com Resources
Thank you for attending! Q&A

More Related Content

What's hot

Basics of Ext JS
Basics of Ext JSBasics of Ext JS
Basics of Ext JS
ikhwanhayat
 
Java script frame window
Java script frame windowJava script frame window
Java script frame window
H K
 
Complex Data Binding
Complex Data BindingComplex Data Binding
Complex Data Binding
Doncho Minkov
 
Advisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScriptAdvisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScript
dominion
 
Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 ...
Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 ...Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 ...
Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 ...
Frédéric Harper
 

What's hot (20)

DOM and Events
DOM and EventsDOM and Events
DOM and Events
 
JavaScript: DOM and jQuery
JavaScript: DOM and jQueryJavaScript: DOM and jQuery
JavaScript: DOM and jQuery
 
Basics of Ext JS
Basics of Ext JSBasics of Ext JS
Basics of Ext JS
 
Jquery tutorial-beginners
Jquery tutorial-beginnersJquery tutorial-beginners
Jquery tutorial-beginners
 
WPF Concepts
WPF ConceptsWPF Concepts
WPF Concepts
 
Java script frame window
Java script frame windowJava script frame window
Java script frame window
 
Fundamental JavaScript [In Control 2009]
Fundamental JavaScript [In Control 2009]Fundamental JavaScript [In Control 2009]
Fundamental JavaScript [In Control 2009]
 
Complex Data Binding
Complex Data BindingComplex Data Binding
Complex Data Binding
 
Learn javascript easy steps
Learn javascript easy stepsLearn javascript easy steps
Learn javascript easy steps
 
INTRODUCTION TO CLIENT SIDE PROGRAMMING
INTRODUCTION TO CLIENT SIDE PROGRAMMINGINTRODUCTION TO CLIENT SIDE PROGRAMMING
INTRODUCTION TO CLIENT SIDE PROGRAMMING
 
Taking Advantage of XMetaL’s XInclude Support
Taking Advantage of XMetaL’s XInclude SupportTaking Advantage of XMetaL’s XInclude Support
Taking Advantage of XMetaL’s XInclude Support
 
jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture
 
Advisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScriptAdvisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScript
 
Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 ...
Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 ...Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 ...
Windows 8 Pure Imagination - 2012-11-25 - Extending Your Game with Windows 8 ...
 
Introduction to Polymer and Firebase - Simon Gauvin
Introduction to Polymer and Firebase - Simon GauvinIntroduction to Polymer and Firebase - Simon Gauvin
Introduction to Polymer and Firebase - Simon Gauvin
 
Sencha ExtJs Learning Part 2 - MVC And MVVM Architecture in ExtJs [ENGLISH]
Sencha ExtJs Learning Part 2 - MVC And MVVM Architecture in ExtJs [ENGLISH]Sencha ExtJs Learning Part 2 - MVC And MVVM Architecture in ExtJs [ENGLISH]
Sencha ExtJs Learning Part 2 - MVC And MVVM Architecture in ExtJs [ENGLISH]
 
Building Large Scale Javascript Application
Building Large Scale Javascript ApplicationBuilding Large Scale Javascript Application
Building Large Scale Javascript Application
 
Java script basics
Java script basicsJava script basics
Java script basics
 
GWT Training - Session 3/3
GWT Training - Session 3/3GWT Training - Session 3/3
GWT Training - Session 3/3
 
JavaScript Best Pratices
JavaScript Best PraticesJavaScript Best Pratices
JavaScript Best Pratices
 

Similar to Displaying additional image types in XMetaL

Getting Started with Appcelerator Alloy - Cross Platform Mobile Development -...
Getting Started with Appcelerator Alloy - Cross Platform Mobile Development -...Getting Started with Appcelerator Alloy - Cross Platform Mobile Development -...
Getting Started with Appcelerator Alloy - Cross Platform Mobile Development -...
Aaron Saunders
 
Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development
Mahmoud Hamed Mahmoud
 
Controllers & actions
Controllers & actionsControllers & actions
Controllers & actions
Eyal Vardi
 
JSF 2.0 (JavaEE Webinar)
JSF 2.0 (JavaEE Webinar)JSF 2.0 (JavaEE Webinar)
JSF 2.0 (JavaEE Webinar)
Roger Kitain
 
Devoxx 09 (Belgium)
Devoxx 09 (Belgium)Devoxx 09 (Belgium)
Devoxx 09 (Belgium)
Roger Kitain
 
Android Development with Flash Builder Burrito
Android Development with Flash Builder BurritoAndroid Development with Flash Builder Burrito
Android Development with Flash Builder Burrito
Jeff Bollinger
 

Similar to Displaying additional image types in XMetaL (20)

Developing ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller PatternDeveloping ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller Pattern
 
Getting Started with Appcelerator Alloy - Cross Platform Mobile Development -...
Getting Started with Appcelerator Alloy - Cross Platform Mobile Development -...Getting Started with Appcelerator Alloy - Cross Platform Mobile Development -...
Getting Started with Appcelerator Alloy - Cross Platform Mobile Development -...
 
Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development
 
Will your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry GervinWill your code blend? : Toronto Code Camp 2010 : Barry Gervin
Will your code blend? : Toronto Code Camp 2010 : Barry Gervin
 
Building AOL's High Performance, Enterprise Wide Mail Application With Silver...
Building AOL's High Performance, Enterprise Wide Mail Application With Silver...Building AOL's High Performance, Enterprise Wide Mail Application With Silver...
Building AOL's High Performance, Enterprise Wide Mail Application With Silver...
 
Application Frameworks - The Good, The Bad & The Ugly
Application Frameworks - The Good, The Bad & The UglyApplication Frameworks - The Good, The Bad & The Ugly
Application Frameworks - The Good, The Bad & The Ugly
 
DataFX 8 (JavaOne 2014)
DataFX 8 (JavaOne 2014)DataFX 8 (JavaOne 2014)
DataFX 8 (JavaOne 2014)
 
Controllers & actions
Controllers & actionsControllers & actions
Controllers & actions
 
JSF 2.0 (JavaEE Webinar)
JSF 2.0 (JavaEE Webinar)JSF 2.0 (JavaEE Webinar)
JSF 2.0 (JavaEE Webinar)
 
Lightning Components Workshop v2
Lightning Components Workshop v2Lightning Components Workshop v2
Lightning Components Workshop v2
 
I os 11
I os 11I os 11
I os 11
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
 
Devoxx 09 (Belgium)
Devoxx 09 (Belgium)Devoxx 09 (Belgium)
Devoxx 09 (Belgium)
 
MAX 2008 - Building your 1st AIR application
MAX 2008 - Building your 1st AIR applicationMAX 2008 - Building your 1st AIR application
MAX 2008 - Building your 1st AIR application
 
Java Web Programming [8/9] : JSF and AJAX
Java Web Programming [8/9] : JSF and AJAXJava Web Programming [8/9] : JSF and AJAX
Java Web Programming [8/9] : JSF and AJAX
 
27 - Panorama Necto 14 component mode & java script - visualization & data di...
27 - Panorama Necto 14 component mode & java script - visualization & data di...27 - Panorama Necto 14 component mode & java script - visualization & data di...
27 - Panorama Necto 14 component mode & java script - visualization & data di...
 
Asp.Net MVC Intro
Asp.Net MVC IntroAsp.Net MVC Intro
Asp.Net MVC Intro
 
Android Development with Flash Builder Burrito
Android Development with Flash Builder BurritoAndroid Development with Flash Builder Burrito
Android Development with Flash Builder Burrito
 
Mvc - Titanium
Mvc - TitaniumMvc - Titanium
Mvc - Titanium
 
Useful jQuery tips, tricks, and plugins with ASP.NET MVC
Useful jQuery tips, tricks, and plugins with ASP.NET MVCUseful jQuery tips, tricks, and plugins with ASP.NET MVC
Useful jQuery tips, tricks, and plugins with ASP.NET MVC
 

Displaying additional image types in XMetaL

  • 1. in 37 minutes Episode 22 Viewing the unviewable: Displaying additional image types in XMetaL Using the InPlaceControl interface to add custom viewer controls Tom Magliery, XML Technology Specialist 12 May 2011 Brought to you by XMetaL Technical Services
  • 2. XMetaL can display images in several common graphics formats (full list in Help) For non-supported formats, XMetaL can use an ActiveX viewer control to display the images You have to supply the viewer You have to do some script customization Purpose of today: show you how to do the script customization Introduction
  • 3. CTM file <OCXReplacement> Associates an ActiveX viewer control with an element Event macros _OnShouldCreate, _OnInitialize, _OnFocus, _OnSynchronize InPlaceControl interface Application.ActiveInPlaceControl gives access to the viewer control during these events Keys to this customization
  • 4. Have an XML element solely dedicated to the special image type: <Visio_Image> Always use viewer control to display this element Need two bits of code: <OCXReplacement> in CTM file _OnInitialize macro Example 1
  • 5. <OCXReplacement> <OCXReplacements> is an optional main element in the CTM file – like <ElementPropertiesList>, <Templates>, etc. Name of your image element Prefix to be used with event macros (can be whatever you want provided the resulting macro name is valid) ... <OCXReplacements> <OCXReplacement> <SelectorName>Visio_Image</SelectorName> <MacroPrefix>VisioViewer</MacroPrefix> <ProgID>VisioViewer.Viewer</ProgID> </OCXReplacement> </OCXReplacements> ... ProgID of your ActiveX viewer control
  • 6. _OnInitialize macro This macro is executed for each <Visio_Image> element in the document. ActiveInPlaceControl object exists for the duration of this macro. Name prefix matches what was in the CTM file. Sets the size for the control. <MACRO name="VisioViewer_OnInitialize" hide="true" lang="JScript"><![CDATA[ varaipc = Application.ActiveInPlaceControl; aipc.Width = 500; aipc.Height = 300; var filename = aipc.Node.getAttribute("href"); aipc.Control.SRC = filename; ]]></MACRO> Node is the element being displayed with this control. Control property gives you access to the IDispatch interface of the viewer control. SRC is a property of the Visio Viewer control. Can also perform other initializations here using the control’s interface, via aipc.Control.*.
  • 7. Use the same image element for built-in and a special image format Use viewer control for special image type <Dual_Purpose_Imagehref=“myVisioDiagram.vsd”/> Fall back to default XMetaL behavior otherwise <Dual_Purpose_Imagehref=“myJPG.jpg”/> Need same code bits as before, plus: <Image> in CTM file _OnShouldCreate macro Example 2
  • 8. Same stuff from before <OCXReplacement> in the CTM – different element name, different macro prefix ... <OCXReplacements> <OCXReplacement> <SelectorName>Dual_Purpose_Image</SelectorName> <MacroPrefix>VV2</MacroPrefix> <ProgID>VisioViewer.Viewer</ProgID> </OCXReplacement> </OCXReplacements> ... _OnInitialize macro does the same thing as before – it’s using the same viewer control <MACRO name="VV2_OnInitialize" hide="true" lang="JScript"><![CDATA[ varaipc = Application.ActiveInPlaceControl; aipc.Width = 500; aipc.Height = 300; var filename = aipc.Node.getAttribute("href"); aipc.Control.SRC = filename; ]]></MACRO>
  • 9. <Image> Handles the fall-back case of built-in image formats. <Dual_Purpose_Image> is designated as an image element in the CTM. ... <Image> <Name>Dual_Purpose_Image</Name> <Source-Attribute>href</Source-Attribute> <Height-Attribute>height</Height-Attribute> <Width-Attribute>width</Width-Attribute> <AltText-Attribute>alt</AltText-Attribute> </Image> ...
  • 10. _OnShouldCreate Use business logic to determine whether XMetaL should be displaying this element in the viewer control in this instance; store the outcome in the ShouldCreate property. Get the href attribute from the element to which this control is (tentatively) attached <MACRO name="VV2_OnShouldCreate" hide="true" lang="JScript"><![CDATA[ varaipc = Application.ActiveInPlaceControl; varhref = aipc.Node.getAttribute("href"); vari = href.lastIndexOf(".vsd"); if (i != -1) { aipc.ShouldCreate = true; } else { aipc.ShouldCreate = false; } ]]></MACRO> Look at the file extension to see if this is a Visio file Set the ShouldCreate property accordingly
  • 11. Using _OnFocus event to manipulate the viewer control Our Visio viewer has APIs for turning on/off various features of the control Suppose we want toolbar, scrollbars, etc. only when the control has focus Example 3
  • 12. _OnFocus This macro is executed both on focus and on blur – when the user clicks in or out of the viewer control. UserMovedIntoControl property is true on “focus” and false on “blur” <MACRO name="VisioViewer_OnFocus" hide="true" lang="JScript"><![CDATA[ varaipc = Application.ActiveInPlaceControl; aipc.Control.AlertsEnabled = aipc.UserMovedIntoControl; aipc.Control.ScrollbarsVisible = aipc.UserMovedIntoControl; aipc.Control.ToolbarVisible = aipc.UserMovedIntoControl; aipc.Control.PageVisible = aipc.UserMovedIntoControl; ]]></MACRO>
  • 13. Using _OnSynchronize event to update the document and/or the control Useful when you need to update data in the viewer control because of changes in the document – or vice versa Bizarre hypothetical example: Suppose we have an element in our document that we wish to reflect the current “zoom” level of the Visio control Example 4
  • 14. _OnSynchronize Macro is executed whenever the document changes and whenever focus leaves the viewer control. UpdateFromDocument=true if the control may need updating because the document state has changed; false if it’s the other way around. This is our bizarre “zoom” data element <MACRO name="VisioViewer_OnSynchronize" hide="true" lang="JScript"><![CDATA[ varaipc = Application.ActiveInPlaceControl; varndlist = aipc.Document.GetElementsByTagName("Author"); if (!aipc.UpdateFromDocument) { var zoom = aipc.Control.Zoom; ndlist.item(0).firstChild.nodeValue = zoom; } else { var value = ndlist.item(0).firstChild.nodeValue; aipc.Control.Zoom = value; } ]]></MACRO> Set document data based on the control Set control data based on the document
  • 15. If your viewer control API includes events, you can write script in XMetaL to handle the events If your viewer has an event called “SomeEvent”, you can write a macro like this: When the viewer fires the event, XMetaL will execute this macro ActiveInPlaceControl.NextEventParam property allows you to access the arguments of the event Unfortunately no example to show today :-( (Non)-example:Events in the viewer control <MACRO name="VisioViewer_SomeEvent" hide="true" lang="JScript"><![CDATA[ // In here you do whatever you need to handle this event ]]></MACRO>
  • 16. If you require more than one viewer control, and if all the image types use the same <Image> element, some additional scripting is required CTM file can only have one <OCXReplacement> for each DTD element But you can define additional OCXReplacements dynamically in script Relevant APIs: DOMDocumentType.addInPlaceControl() InPlaceControl.userData A little too much for an example here today! (Non)-example:More than one custom viewer
  • 17. XMetaL DITA customization uses this technique – recursively! – to display SVG graphics XMetaL’s viewer control is Internet Explorer IE (through 8) does not natively support SVG either – requires you to install a plugin So XMetaL hands the image over to IE, which in turn hands it over to your SVG plugin SVG in DITA in XMetaL
  • 18. XMetaL Community Forums http://forums.xmetal.com/ JustSystems Partner Center http://justpartnercenter.com/ Ask us for help (partner tech support) partnersupport-na@justsystems.com Resources
  • 19. Thank you for attending! Q&A