<?xml version="1.0" ?>
<!DOCTYPE MACROS SYSTEM "macros.dtd">
<MACROS>

<!--
     Copyright 2006 Justsystems Canada, Inc.
 
     This XMetaL extension is the property of Justsystems Canada Inc.
     and its licensors and is protected by copyright.   Modifications of
     this extension may invalidate any support that you may be entitled to.
     Any reproduction in whole or in part is strictly prohibited. 
-->

<!-- DOCUMENT-EVENT-BOUND DITA DOCUMENT OPERATIONS -->
<!-- DOCUMENT-EVENT-BOUND DITA DOCUMENT OPERATIONS -->
<!-- DOCUMENT-EVENT-BOUND DITA DOCUMENT OPERATIONS -->

<MACRO name="On_Macro_File_Load" lang="JScript" hide="true"><![CDATA[

  //========================================================================
  // FUNCTIONS: Dita doc-level convience functions.  Functions must be
  //   doc-level in order to be visible for XMAX-DITA systems.
  //========================================================================
  function __XM_DITA_GetDitaAppHandler__()
  {
    var xmsMgr = ActiveDocument.Host.QueryService("XMSERVICEMGR");
    if (!xmsMgr) { 
      return null;
    }
    return xmsMgr.FindByType("DITAAPP");
  }
  //========================================================================
  function __XM_DITA_GetDitaDocHandler__()
  {
    var ditaApp = __XM_DITA_GetDitaAppHandler__();
    if (!ditaApp) {
      return null;
    }
    return ditaApp.getDitaDocHandler(ActiveDocument);
  }
  //========================================================================
  function __XM_DITA_GetXMAppService__()
  {
    var xmsMgr = ActiveDocument.Host.QueryService("XMSERVICEMGR");
    if (!xmsMgr) { 
      return null;
    }
    return xmsMgr.FindByType("XMAPPLICATION");
  }
  //========================================================================
  function __XM_DITA_InjectSpecializationExtender__()
  {
    // Auto-load specialization Jscript extension into the scope of THIS
    // doc-level script engine...binding-by-rules-name for factory functor
    // and implementation in filename in same location as the rules/dtd

    var xmApp = __XM_DITA_GetXMAppService__();
    if (!xmApp)
      return null;
    var ditaApp = __XM_DITA_GetDitaAppHandler__();
    if (!ditaApp)
      return null;
    
    
    // DitaApp has standard algorithm for generating the factory functor
    // name expected for the DitaSpecializationExtender instance and even
    // determines if implementation is available...
    
    var dspDetails = ditaApp.getDitaSpecExtenderDetails(ActiveDocument);
    if (!dspDetails)
      return null;
      
    var hdlrExtFile    = dspDetails.hdlrExtFile;
    var hdlrExtFactory = dspDetails.hdlrExtFactory;
    var hdlrExtSrc     = dspDetails.hdlrExtSrc;


    // Inject extender impl and get reference to extender functor
    // but guard against script errors...
    
    var hdlrExtClass = null;
    try {
      eval(hdlrExtSrc);                                // Load impl
      eval("hdlrExtClass = " + hdlrExtFactory + ";");  // Get functor
    } catch (e) {
      hdlrExtClass = null;
      xmApp.MessageService.Alert("Failed to parse specialization extender, \n\n\""
                               + hdlrExtFile + "\".\n\n"
                               + "Some features or functions may be disabled. Please contact your DITA customizer.");
    }


    // Return extender factory function
    return hdlrExtClass;
  }
  //========================================================================

var OCX_XMAX = {};
	
OCX_XMAX.OnShouldCreateAsSVG = function(AIPC, xmDoc, attrName)
{
	if (!AIPC || !attrName)
		return;
    
	try {
		// Only create for objects's with .svg extensions otherwise
		// default to CTM prescribed behavior...
		AIPC.ShouldCreate = false;
		var domnode = AIPC.Node;
		if (domnode != null) {
			var attrnode = domnode.attributes.getNamedItem(attrName);
			if (attrnode != null && attrnode.value != null) {				
				var SVGpath = attrnode.value; //no drp involved
				// TODO: File-Ext may not be indicative for CRCL resources
				// ...but it is all we have to use for now.
				var isSVG = (SVGpath.lastIndexOf(".svg") > 0) ? true : false;
				if (isSVG) {
					ActiveDocument.Host.Alert("Displaying SVG is not supported.");
					AIPC.ShouldCreate = false;
					//AIPC.ShouldCreate = true;
				}
			}
		}
	} catch(e) {
		//ActiveDocument.Host.Alert(e.description);
	}
}

OCX_XMAX.OnInitializeAsSVG = function(AIPC, xmDoc, attrName)
{
	if (!AIPC || !attrName)
		return;
    
	// Set Internet Explorer's "FileName" property from the <image> element "href"
	// attribute. IE needs an absolute filepath, user must use an absolute path
	// (this could be code differently below)

	var domnode = AIPC.Node;
	attrnode = domnode.attributes.getNamedItem(attrName);
	if (attrnode != null) {
		var SVGpath = "";
		if (attrnode.value.indexOf("/") < 0 && attrnode.value.indexOf("\\") < 0) {
			//only filename
			SVGpath = xmDoc.Path + "\\" + attrnode.value;
		} else {
			SVGpath = attrnode.value;			
		}
		var msie = AIPC.Control;
		if (msie != null) {
			msie.Navigate(SVGpath, 2);
		}
	}
      
	// Following sets the control height and width to the same values
	// as those found in the width and height attribute values read from the SVG file.
	// It is assumed that the SVG height and width attrs are specified *without* units.
	// If SVG dimensions are specified with units (ie: "in" or "cm") then a more
	// robust script will be required.
	// Issues: MSXML complains about the SVG DTDs containing errors.
	//   Removing the document type declaration from the SVG file is a workaround for now.

	var xmlDoc = new ActiveXObject("Msxml.DOMDocument");
	xmlDoc.async           = false;
	xmlDoc.validateOnParse = false;
	xmlDoc.load(SVGpath);
	if (xmlDoc.parseError.errorCode != 0) {
		var myErr = xmlDoc.parseError;
		//ActiveDocument.Host.Alert("Error reading SVG file: " + myErr.reason + "\r Line: " + myErr.line + "\r Position: " + myErr.linePos);    
	} else {
		var svgNode = xmlDoc.selectSingleNode("//svg");
		var SVGwidth  = svgNode.getAttribute("width");
		var SVGheight = svgNode.getAttribute("height");
    
		// If there are units, convert it to pixels assuming 96dpi
		if (SVGwidth.indexOf("in") > 0) {
			SVGwidth  = parseInt(parseFloat(SVGwidth) * 96.0);
		} else if (SVGwidth.indexOf("cm") > 0) {
			SVGwidth  = parseInt(parseFloat(SVGwidth) * 96.0 / 2.54);
		}
		if (SVGheight.indexOf("in") > 0) {
			SVGheight = parseInt(parseFloat(SVGheight) * 96.0);
		} else if (SVGheight.indexOf("cm") > 0) {
			SVGheight = parseInt(parseFloat(SVGheight) * 96.0 / 2.54);
		}
          
		// Set width of control (pixels) from SVG file's root element (SVG) "width" attribute
		AIPC.Width = SVGwidth > 0 ? SVGwidth : 200;
    
		// Set height of control (pixels) from SVG file's root element (SVG) "height" attribute
		AIPC.Height = SVGheight > 0 ? SVGheight : 200;
	}
}

// OCXReplacement HOOKs for <object> > as XFT
OCX_XMAX.OnShouldCreateAsXFT = function(AIPC, xmDoc, attrName)
{
	if (!AIPC || !attrName)
    		return;  

	// Only create for objects's WITHOUT .svg extensions...see OnShouldCreateSVG
  	// which must be mutually-exclusive in setting of AIPC.ShouldCreate boolean
  	try {
    		AIPC.ShouldCreate = true;
    		var domnode = AIPC.Node;
    		if (domnode) {
      		var attrnode = domnode.attributes.getNamedItem(attrName);
      		if (attrnode && attrnode.value) {
        			if (attrnode.value.lastIndexOf(".svg") > 0) {
          				AIPC.ShouldCreate = false;
        			}
      		}
    		}
  	} catch(e) {
    		//ActiveDocument.Host.Alert(e.description);
  	}
}

OCX_XMAX.OnInitializeAsXFT = function(AIPC, xmDoc, attrName)
{
	if (!AIPC || !attrName)
    		return;
	
	try {    
  		var domnode  = AIPC.Node;
	  	var xfr      = AIPC.Control;
		var docPath = xmDoc.Path;

		var baseDir = xmDoc.docType.systemId;
		var prefixIdx = baseDir.indexOf("file:");
		var prefixEndIdx = 0;
		if (prefixIdx == 0) {
			prefixEndIdx = 5; //skip "file:"
		}
		var lastSlashIdx = baseDir.lastIndexOf("/");

  		var formPath = "object_embedded.xft";
		if (prefixEndIdx == 5 && lastSlashIdx > 0) {
			formPath = baseDir.substring(prefixEndIdx, lastSlashIdx) + "\\" + "object_embedded.xft";
			formPath = unescape(formPath).replace(/\//g, "\\");		
		}
      
	  	xfr.AddTopLevelObject("ActiveDocument", xmDoc);
  		xfr.StartFormNoDisp(formPath, 1); // 0 : Modal // 1 : Embedded // 2 : Modeless
	  	AIPC.Width  = 66;
  		AIPC.Height = 62;
	} catch (e) {
		//ActiveDocument.Host.Alert(e.message);
	}
}

function xmax_toggleInline(elemName)
{
	if (ActiveDocument.ViewType != 0 && ActiveDocument.ViewType != 1) {
		ActiveDocument.Host.Alert("Change to Tags On or Normal view to run macros.")
		return;
	}

	if (!elemName || elemName == "") {
		return;
	}
	
	var rng = ActiveDocument.Range; 
	   
	// Change the values here...
	var blnsideInline = rng.IsParentElement(elemName);
	   
	// Depending on context collapse the range and check
	// if you can insert or surround with inline element...
	var rng2 = ActiveDocument.Range; 
	if (!rng2.IsInsertionPoint)
		rng2.Collapse();

	if (!blnsideInline && !rng2.CanInsert(elemName) && !rng2.CanSurround(elemName)) {
		return; // Cannot toggle inline element here...
	}
	
	// Do toggle...
	Selection.ToggleInline(elemName);
}

function xmax_style_conrefs()
{
  // Replace conref elements with some display-text "[Referenced content]".
  // This will apply to any element that has a "conref" attribute set.
  // Applied at document-load time, view changes and first draw.
  if (ActiveDocument.ViewType != 0 && ActiveDocument.ViewType != 1) {
    return;
  }

  var conref_nodes = ActiveDocument.GetNodesByXPath("//*[@conref]");
  for (var i=0; i<conref_nodes.length; i++) {
    var rng = ActiveDocument.Range;
    rng.SelectNodeContents(conref_nodes.item(i));
    ActiveDocument.SetRenderedContent(conref_nodes.item(i), "[Referenced content]");
  }
}

]]></MACRO>

<MACRO name="On_CommandBars_Load_Complete" lang="JScript" hide="true"><![CDATA[

  //========================================================================
  // Inform DitaApp that doc-level commandbars are loaded so we can give
  // the specializer an opportunity to add/remove items. 
  // DITA.REFACTOR.TODO - This event will only fire for XMAU
  // DITA.REFACTOR.TODO - Why not a DitaDocHandler method?
  //========================================================================
  
  var ditaApp = __XM_DITA_GetDitaAppHandler__();
  if (ditaApp) { 
    ditaApp.OnCommandBarsLoadComplete(ActiveDocument);
  }
  ditaApp = null;
  //========================================================================

]]></MACRO>

<MACRO name="On_Document_Open_Complete" lang="JScript" hide="true"><![CDATA[

  //========================================================================
  // BOOTSTRAP: Inform DitaApp service of Dita XML instance open now
  //   for editing (and create DitaDocHandler) 
  //========================================================================
  
  // DITA.REFACTOR.TODO - Variation based on DTD/Rules is all we need...
  // ...could pass just ActiveDocument and let DitaAppHandler work it out
  // the details.
  
  var ditaApp = __XM_DITA_GetDitaAppHandler__();
  if (ditaApp) { 
    ditaApp.OnDocumentOpenComplete(ActiveDocument, __XM_DITA_InjectSpecializationExtender__());
  }
  ditaApp = null;
  //========================================================================

]]></MACRO>

<MACRO name="On_Before_Document_Preview" lang="JScript" hide="true"><![CDATA[

  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
    ditaDoc.OnBeforeDocumentPreview();
  }
  ditaDoc = null;

]]></MACRO>

<MACRO name="On_Before_Document_Save" lang="JScript" hide="true"><![CDATA[

  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
    ditaDoc.OnBeforeDocumentSave();
  }
  ditaDoc = null;

]]></MACRO>

<MACRO name="On_Start_Document_SaveAs" lang="JScript" hide="true"><![CDATA[

  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
    ditaDoc.OnStartDocumentSaveAs();
  }
  ditaDoc = null;

]]></MACRO>

<MACRO name="On_Before_Document_SaveAs" lang="JScript" hide="true"><![CDATA[

  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
    ditaDoc.OnBeforeDocumentSaveAs();
  }
  ditaDoc = null;

]]></MACRO>

<MACRO name="On_Before_Document_Validate" lang="JScript" hide="true"><![CDATA[

  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
    ditaDoc.OnBeforeDocumentValidate();
  } else {
	var root = ActiveDocument.documentElement;
	try {
		var date = new Date();
		var id = root.getAttribute("id");
		if (!id) {
			root.setAttribute("id", root.nodeName + "_" + date.getTime()); 
		}
	} catch (e) {}	
  }
  ditaDoc = null;

]]></MACRO>

<MACRO name="On_Click" lang="JScript" hide="true"><![CDATA[

  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
    ditaDoc.OnClick();
  }
  ditaDoc = null;

]]></MACRO>

<MACRO name="On_Context_Menu" lang="JScript" hide="true"><![CDATA[

  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
    ditaDoc.OnContextMenu();
  }
  ditaDoc = null;

]]></MACRO>

<MACRO name="On_Document_After_DropText" lang="JScript" hide="true"><![CDATA[

  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
    ditaDoc.OnDocumentAfterDropText();
  }
  ditaDoc = null;

]]></MACRO>

<MACRO name="On_Document_Before_DropText" lang="JScript" desc="Called when text is dropped into a document, but before it is rendered. Used to modify strings that are moved or copied with copy-and-paste or drag-and-drop operations in a document." hide="true"><![CDATA[

  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
    ditaDoc.OnDocumentBeforeDropText();
  }
  ditaDoc = null;

]]></MACRO>

<MACRO name="On_Document_Close" lang="JScript" hide="true"><![CDATA[

  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
    ditaDoc.OnDocumentClose();
  }
  ditaDoc = null;

]]></MACRO>

<MACRO name="On_Document_First_Draw" lang="JScript" hide="true"><![CDATA[

  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
    ditaDoc.OnDocumentFirstDraw();
  } else {
    xmax_style_conrefs();
  }
  ditaDoc = null;

]]></MACRO>

<MACRO name="On_Drop_Files" lang="JScript" hide="true"><![CDATA[

  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
    ditaDoc.OnDropFiles();
  }
  ditaDoc = null;

]]></MACRO>

<MACRO name="On_ElementList_Insert" lang="JScript" hide="true"><![CDATA[

  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
    ditaDoc.OnElementListInsert();
  }
  ditaDoc = null;

]]></MACRO>

<MACRO name="On_Update_ElementList" lang="JScript" hide="true"><![CDATA[

  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
    ditaDoc.OnUpdateElementList();
  }
  ditaDoc = null;

]]></MACRO>

<MACRO name="On_Update_UI" lang="JScript" desc="Called when XMetaL Author starts up; the first document is opened in XMetaL Author; a different document becomes the active document in XMetaL Author; the last open document is closed in XMetaL Author; the selection moves to a different element; a command is executed; or the first character is typed into an element." hide="true"><![CDATA[

  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
    ditaDoc.OnUpdateUI();
  }
  ditaDoc = null;

]]></MACRO>

<MACRO name="On_View_Change" lang="JScript" hide="true"><![CDATA[

  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
    ditaDoc.OnViewChange();
  } else {
    xmax_style_conrefs();
  }
  ditaDoc = null;

]]></MACRO>

<MACRO name="On_After_Set_Attribute_From_AI" lang="JScript" hide="true"><![CDATA[

  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
    ditaDoc.OnAfterSetAttributeFromAI();
  }
  ditaDoc = null;

]]></MACRO>


<!-- SHORTCUT-BOUND DITA DOCUMENT OPERATIONS -->
<!-- SHORTCUT-BOUND DITA DOCUMENT OPERATIONS -->
<!-- SHORTCUT-BOUND DITA DOCUMENT OPERATIONS -->

<MACRO name="__XMDITA_CurrentElementHelp__" lang="JScript" key="Alt+F1" hide="true"><![CDATA[

  // Delegate to DitaApp to show help topic for current element...
  var ditaApp = __XM_DITA_GetDitaAppHandler__();
  if (ditaApp) {
    ditaApp.doCurrentElementHelp(ActiveDocument.Range);
  }
  ditaApp = null;

]]></MACRO>

<MACRO name="AltEnterKeyOverride" lang="JScript" key="Alt+Enter" hide="true"><![CDATA[

  // DITA.REFACTOR.TODO - Change macro name to "__XM_DITA_ALTENTERKEYOVERRIDE__" + TBR stuff
  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
    ditaDoc.doAltEnterKey();
  }
  ditaDoc = null;

]]></MACRO>

<MACRO name="EnterKeyOverride" lang="JScript" key="Enter" hide="true"><![CDATA[

  // DITA.REFACTOR.TODO - Change macro name to "__XM_DITA_ENTERKEYOVERRIDE__" + TBR stuff
  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
    ditaDoc.doEnterKey();
  }
  else {
	var ieVer = ActiveDocument.CustomProperties.Item("IEVersion");
      if (ieVer && ieVer.Value == "IE6") {
		Selection.TypingSplit();
	}
  }
  ditaDoc = null;

]]></MACRO>

<MACRO name="TabKeyOverride" lang="JScript" hide="true"><![CDATA[

  // DITA.REFACTOR.TODO - Intentionally turned OFF shortcut key='Tab' because of poor
  //    performance in Tables and Lists...see PROD00024539
  // DITA.REFACTOR.TODO - Change macro name to "__XM_DITA_ENTERKEYOVERRIDE__" + TBR stuff
  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
    ditaDoc.doTabKey();
  }
  ditaDoc = null;

]]></MACRO>

<MACRO name="Index Marker" lang="JScript" key="Alt+Shift+X" desc="Index Marker" hide="true"><![CDATA[
  
  // DITA.REFACTOR.TODO - Change macro name to "__XM_DITA_INDEXMARKER__" + TBR stuff
  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
    ditaDoc.doIndexMarker();
  }
  ditaDoc = null;

]]></MACRO>

<MACRO name="ToggleBold" lang="JScript" key="Ctrl+B" desc="Bold (Ctrl+B)" hide="true"><![CDATA[

  // DITA.REFACTOR.TODO - Change macro name to "__XM_DITA_TOGGLEBOLD__" + TBR stuff
  // DITA.REFACTOR.TODO - Use class attribute
  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
    ditaDoc.doToggleInline("b");
  }
  else {
	xmax_toggleInline("b");
  }
  ditaDoc = null;

]]></MACRO>

<MACRO name="ToggleItalic" lang="JScript" key="Ctrl+I" desc="Italic (Ctrl+I)" hide="true"><![CDATA[

  // DITA.REFACTOR.TODO - Change macro name to "__XM_DITA_TOGGLEITALIC__" + TBR stuff
  // DITA.REFACTOR.TODO - Use class attribute
  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
    ditaDoc.doToggleInline("i");
  }
  else {
	xmax_toggleInline("i");
  }
  ditaDoc = null;

]]></MACRO>

<MACRO name="ToggleUnderline" lang="JScript" key="Ctrl+U" desc="Underline (Ctrl+U)" hide="true"><![CDATA[

  // DITA.REFACTOR.TODO - Change macro name to "__XM_DITA_TOGGLEUNDERLINE__" + TBR stuff
  // DITA.REFACTOR.TODO - Use class attribute
  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
    ditaDoc.doToggleInline("u");
  }
  else {
	xmax_toggleInline("u");
  }
  ditaDoc = null;

]]></MACRO>

<MACRO name="Update_All_References" lang="JScript" hide="true" key="F11"><![CDATA[

  // DITA.REFACTOR.TODO - Change macro name to "__XM_UPDATE_ALL_REFERENCES__" + TBR stuff
  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
    ditaDoc.doUpdateAllReferences(ActiveDocument);
  }
  ditaDoc = null;

]]></MACRO>


<!-- ATOMIC-UNDOABLE DITA DOCUMENT OPERATION DISPATCHER -->
<!-- ATOMIC-UNDOABLE DITA DOCUMENT OPERATION DISPATCHER -->
<!-- ATOMIC-UNDOABLE DITA DOCUMENT OPERATION DISPATCHER -->

<MACRO name="__XM_DITA_DISPATCHER__" lang="JScript" hide="true"><![CDATA[

  // DISPATCHER: Macro is intended to be used by the XM-DITA application
  //   to execute a Dita document mutation and whereby such mutations need
  //   to be atomic (i.e. undoable). 
  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  try {
    eval("ditaDoc." + ditaDoc.getDispatcherOpStr());
  } catch (e) {
    // TODO:
  }
  ditaDoc = null;
  
]]></MACRO>

<MACRO name="ImageAsSVG_OnShouldCreate" lang="JScript" hide="true"><![CDATA[
  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
	if (OCX) {
		OCX.OnShouldCreateAsSVG(Application.ActiveInPlaceControl, ActiveDocument, "href");
	}
  } else { 
	if (OCX_XMAX) {
		OCX_XMAX.OnShouldCreateAsSVG(ActiveDocument.ActiveInPlaceControl, ActiveDocument, "href");
	}  
  }
  ditaDoc = null;  
]]></MACRO>

<MACRO name="ImageAsSVG_OnInitialize" lang="JScript" hide="true"><![CDATA[
  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
	if (OCX) {
		OCX.OnInitializeAsSVG(Application.ActiveInPlaceControl, ActiveDocument, "href");
	}
  } else {
	if (OCX_XMAX) {
		OCX_XMAX.OnInitializeAsSVG(ActiveDocument.ActiveInPlaceControl, ActiveDocument, "href");
	}
  }
  ditaDoc = null;    
]]></MACRO>

<MACRO name="ObjectAsSVG_OnShouldCreate" lang="JScript" hide="true"><![CDATA[
  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
	if (OCX) {
		OCX.OnShouldCreateAsSVG(Application.ActiveInPlaceControl, ActiveDocument, "href");
	}
  } else { 
	if (OCX_XMAX) {
		OCX_XMAX.OnShouldCreateAsSVG(ActiveDocument.ActiveInPlaceControl, ActiveDocument, "href");
	}  
  }
  ditaDoc = null;  
]]></MACRO>

<MACRO name="ObjectAsSVG_OnInitialize" lang="JScript" hide="true"><![CDATA[
  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
	if (OCX) {
		OCX.OnInitializeAsSVG(Application.ActiveInPlaceControl, ActiveDocument, "href");
	}
  } else {
	if (OCX_XMAX) {
		OCX_XMAX.OnInitializeAsSVG(ActiveDocument.ActiveInPlaceControl, ActiveDocument, "href");
	}
  }
  ditaDoc = null;    
]]></MACRO>

<MACRO name="ObjectAsXFT_OnShouldCreate" lang="JScript" hide="true"><![CDATA[
  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
	if (OCX) {
    		OCX.OnShouldCreateAsXFT(Application.ActiveInPlaceControl, ActiveDocument, "data");
  	}
  } else {
	if (OCX_XMAX) {
		OCX_XMAX.OnShouldCreateAsXFT(ActiveDocument.ActiveInPlaceControl, ActiveDocument, "data");
	}
  }	
  ditaDoc = null;
]]></MACRO>

<MACRO name="ObjectAsXFT_OnInitialize" lang="JScript" hide="true"><![CDATA[
  var ditaDoc = __XM_DITA_GetDitaDocHandler__();
  if (ditaDoc) {
  	if (OCX) {
    		OCX.OnInitializeAsXFT(Application.ActiveInPlaceControl, ActiveDocument, "data");
  	}
  } else {
	if (OCX_XMAX) {
		OCX_XMAX.OnInitializeAsXFT(ActiveDocument.ActiveInPlaceControl, ActiveDocument, "data");
	}	
  }	
  ditaDoc = null;
]]></MACRO>

</MACROS>
