var SelectSingleNode = parent.SelectSingleNode; var SelectNodes = parent.SelectNodes; var MSIE = parent.MSIE var strShapeName = "Shape Name"; var strShapeText = "Shape Text"; var strProps = "Shape Data"; var strResults = "Search results for:"; var strShape = "Shape Name:"; var strNoCustomPropertiesToDisplayText = "CTRL+click a shape in the drawing to view details."; var FindShapeXML = parent.FindShapeXML; var Unquote = parent.Unquote; var put_Location = parent.put_Location; var strChkBox = "Chkbox"; var strPropChkBox = "PropChkbox"; function doExpando(xxx,yyy){ if (xxx.style.display=="none"){ xxx.style.display = "" yyy.src = up.src; }else{ xxx.style.display = "none" yyy.src = down.src; } } function doExp(xxx,yyy){ if (xxx.style.display=="none"){ xxx.style.display = "" yyy.src = "minus.gif"; }else{ xxx.style.display = "none" yyy.src = "plus.gif"; } } function FindOnClick() { var count, indexOfString; var fieldsToSearchArray = new Array(); if (parent.xmlData != null && document.theForm[strProps + strChkBox].checked) { for( count=0; count < document.theForm.length; count++ ) { indexOfString = document.theForm[count].name.indexOf(strPropChkBox); if( -1 != indexOfString && document.theForm[count].checked ) { fieldsToSearchArray[ fieldsToSearchArray.length ] = document.theForm[count].name.slice(0, indexOfString); } } } var searchTokensArray = CreateSearchTokens (document.theForm.findString.value); if (searchTokensArray.length > 0) { var findArray = Find(searchTokensArray, fieldsToSearchArray); var ArrayLength = findArray.length; var strResultsHTML = "No matches found."; var lastPageID = null; var shapeID; if(ArrayLength > 0) { strResultsHTML = strResults + ' '+ parent.HTMLEscape(document.theForm.findString.value) +''; for ( count = 0; count < ArrayLength; count++) { if( lastPageID != findArray[count].PageID ) { lastPageID = findArray[count].PageID; } shapeID = findArray[count].ShapeID; strResultsHTML += '

Shows/hides shape details\n' strResultsHTML += '

\n' strResultsHTML += '\n'; strResultsHTML += '\n' } } var divAdvSrch = document.getElementById("hideAdvSrch"); var imgAS0 = document.getElementById("as0"); var tmpObj = document.getElementById("hideResults"); if( tmpObj != null ) { tmpObj.innerHTML = strResultsHTML; tmpObj.open = "true"; tmpObj.style.display = "block"; } } } function CreateSearchTokens (strUserString) { var searchTokensArray = new Array(); var strToken = ""; var chCurChar; for (var count = 0; count < strUserString.length; count++) { chCurChar = strUserString.charAt(count); if (chCurChar == '"') { var nNextQuote = strUserString.indexOf('"', count + 1); if (nNextQuote >= 0) { strToken = strUserString.slice(count + 1, nNextQuote); searchTokensArray[searchTokensArray.length] = strToken; strToken = ""; count = nNextQuote; } } else if (chCurChar == ' ') { if (strToken.length > 0) { searchTokensArray[searchTokensArray.length] = strToken; } strToken = ""; } else { strToken += chCurChar; } } if (strToken.length > 0) { searchTokensArray[searchTokensArray.length] = strToken; } return searchTokensArray; } function populateSearchResultDetails( divID, pageID, shapeID ) { var tmpShape = FindShapeXML (pageID, shapeID); var strOutput = CreatePropTable( tmpShape ); var tmpObj = document.getElementById(divID); if( tmpObj != null ) { tmpObj.innerHTML = strOutput; } } function makeAdvancedFindCheckboxes(div) { if (parent.xmlData) { var strOutput = ""; strOutput += "
\n"; strOutput += "
\n"; strOutput += "
\n"; strOutput += "
"; var objNodes = SelectNodes(parent.xmlData, ".//Shape/Prop/Label"); var filter = ""; var boolFirstPass = true; var tmpPropName; while( objNodes.length > 0) { if (objNodes[0].text) tmpPropName = objNodes[0].text; else tmpPropName = objNodes[0].textContent; if(null == tmpPropName) tmpPropName = ""; var escapedPropName = parent.EscapeString(tmpPropName); if( true == boolFirstPass ) { filter = ". != '" + escapedPropName + "'"; boolFirstPass = false; } else { filter += " and . != '" + escapedPropName + "'"; } tmpPropName = parent.HTMLEscape (tmpPropName); strOutput += "
\n"; objNodes = SelectNodes(parent.xmlData, ".//Shape/Prop/Label/text()[" + filter + "]"); } strOutput += "
" div.innerHTML = strOutput; } } function AdvSearchCustomPropCheck () { for( count=0; count < document.theForm.length; count++ ) { indexOfString = document.theForm[count].name.indexOf(strPropChkBox); if( -1 != indexOfString ) { document.theForm[count].disabled = !document.theForm[strProps + strChkBox].checked; } } } function CResultItem(title, pageID, shapeID, pinX, pinY) { this["Title"] = title; this["PageID"] = pageID; this["ShapeID"] = shapeID; this["PinX"] = pinX; this["PinY"] = pinY; } function FindParentPage(nodeObject) { if(nodeObject == null) { return null; } if(nodeObject.nodeName == "Page") return nodeObject; else return FindParentPage(nodeObject.parentNode); } function QueryStringForMatch(shapeNode, regTextForFind, filterString) { if (filterString.length > 0) { var nodesToCheck = SelectNodes(shapeNode, filterString); var nodeCount = nodesToCheck.length; var stringToParse; for(var ncount = 0; ncount < nodeCount; ncount++) { stringToParse = nodesToCheck[ncount].nodeValue; stringToParse = stringToParse.toLowerCase (); if(stringToParse.indexOf(regTextForFind) > -1) { return true; } } } return false; } function GetShapeTitle(shapeNode) { var objTempTextElement = SelectSingleNode(shapeNode, "./Text/text()"); if(objTempTextElement != null) { var objText = objTempTextElement.nodeValue; if (objText) { return parent.HTMLEscape(objText); } } var objTempName = SelectSingleNode(shapeNode, "./@Name"); if(objTempName && objTempName.nodeValue) { return parent.HTMLEscape(objTempName.nodeValue); } return ""; } function GetPageTitle(pageID) { var pagesObj = SelectSingleNode(parent.xmlData, "VisioDocument/Pages"); if(!pagesObj) { return ""; } var pageQuerryString = './/Page[@ID = "' + pageID + '"]'; var pageObj = SelectSingleNode(pagesObj, pageQuerryString); if(!pageObj) { return ""; } var pageNameNode = SelectSingleNode(pageObj, "@Name"); if(!pageNameNode) { return ""; } return pageNameNode.text; } function Find(searchTokensArray, propsToSearchArray) { var bXMLNotValid = false; var findArray = new Array(); var findIndex = 0; if (parent.xmlData != null && searchTokensArray.length > 0) { var fieldsToSearchArray = new Array(); var filterString = ""; if( null != propsToSearchArray && propsToSearchArray.length > 0 ) { var propFilterString = ""; for( var count=0; count< propsToSearchArray.length; count++ ) { if( count == 0 ) { propFilterString = "[. = '" + parent.EscapeString (propsToSearchArray[count]) + "'"; } else { propFilterString += " or . = '"+ parent.EscapeString (propsToSearchArray[count]) + "'"; } } propFilterString += "]"; fieldsToSearchArray[fieldsToSearchArray.length] = "Prop[Label"+ propFilterString +"]/Value"; } if (document.theForm[strShapeText + strChkBox].checked) { fieldsToSearchArray[fieldsToSearchArray.length] = "Text"; } if (fieldsToSearchArray.length > 0) { filterString = ".//"; for (var fieldCount = 0; fieldCount < fieldsToSearchArray.length; fieldCount++) { if (fieldCount != 0) { filterString += "/text() | .//"; } filterString += fieldsToSearchArray[fieldCount]; } filterString += "/text()"; } var objShapeNodes; if (document.theForm[strShapeName + strChkBox].checked) { if (filterString.length > 0) { filterString += " | "; } filterString += "@Name"; objShapeNodes = SelectNodes(parent.xmlData, ".//Shape"); } else { objShapeNodes = SelectNodes(parent.xmlData, ".//Shape[(Prop/Value | Prop/Label | Text)]"); } var shapeCount = objShapeNodes.length; var objTempData = new CResultItem("A Label","PageID","ShapeID","PinX","PinY"); var objTempShape = null; for (count = 0; count < shapeCount; count++) { objTempShape = objShapeNodes[count]; var objParentPageNode = FindParentPage(objTempShape); if (objParentPageNode == null) { continue; } //Find out the drawing scale of the page in which the shape belongs var pageDrawScale = FindPageDrawingScale(objParentPageNode); var pageID = SelectSingleNode(objParentPageNode, "@ID").nodeValue; var pageIndex = parent.PageIndexFromID (pageID); if (pageIndex < 0) { continue; } // Verifies that the shape is inside at least one visible layer, otherwise skip it var objLayerMember = SelectSingleNode(objTempShape, "LayerMem/LayerMember"); if (objLayerMember != null) { if (objLayerMember.text) var layerText = objLayerMember.text; else var layerText = objLayerMember.textContent; if (layerText && layerText.length > 0) { var layerArray = layerText.split (';'); var visibleLayer = false; for (var layerCount = 0; (layerCount < layerArray.length) && !visibleLayer; layerCount++) { var objLayerVisible = SelectSingleNode(objParentPageNode, "Layer[@IX=" + layerArray[layerCount] + "]/Visible"); if (objLayerVisible != null) { if (objLayerVisible.text) visibleLayer = (objLayerVisible.text != 0); else visibleLayer = (objLayerVisible.textContent != 0); if (visibleLayer) break; } } if (!visibleLayer) { continue; } } } for (var tokenCount = 0; tokenCount < searchTokensArray.length; tokenCount++) { var textToFind = searchTokensArray[tokenCount].toLowerCase (); if (QueryStringForMatch(objTempShape, textToFind, filterString)) { objTempData.Title = GetShapeTitle(objTempShape); objTempData.PageID = pageID; objTempData.ShapeID = SelectSingleNode(objTempShape, "@ID").nodeValue; objPinXNode = SelectSingleNode(objTempShape, "XForm/PinX/text()"); if(objPinXNode == null) { bXMLNotValid = true; break; } objTempData.PinX = objPinXNode.nodeValue; objPinYNode = SelectSingleNode(objTempShape, "XForm/PinY/text()"); if(objPinYNode == null) { bXMLNotValid = true; break; } objTempData.PinY = objPinYNode.nodeValue; // the pinX and pinY values that we are passing here are transofrmed according to the drawing scale findArray[findIndex] = new CResultItem(objTempData.Title, objTempData.PageID, objTempData.ShapeID, objTempData.PinX * pageDrawScale, objTempData.PinY * pageDrawScale); findIndex++; break; } } } if(bXMLNotValid) { findArray.length = 0; } } return findArray; } function FindQuerySelect(pageID, shapeID, pinX, pinY) { if ((!widgets.GoTo && parent.g_FileList.length > 1) || (widgets.GoTo && parent.g_FileList[document.getElementById("Select1").value].PageID != pageID)) { parent.g_callBackFunctionArray[parent.g_callBackFunctionArray.length] = function () { parent.viewMgr.put_Location (pageID, shapeID, pinX, pinY); }; parent.GoToPageByID(pageID); } else { if (parent.viewMgr != null) { parent.viewMgr.put_Location (pageID, shapeID, pinX, pinY); } } } function TreeSelect(pageID, shapeID) { var shapeNode = FindShapeXML (pageID, shapeID); if (shapeNode != null) { var pinXNode = SelectSingleNode(shapeNode, "XForm/PinX/text()"); var pinYNode = SelectSingleNode(shapeNode, "XForm/PinY/text()"); if (pinXNode != null && pinYNode != null) { var parentPageNode = FindParentPage(shapeNode); var pageDrawScale = FindPageDrawingScale(parentPageNode); var pinX = pinXNode.nodeValue * pageDrawScale;//Scale both pinX and pinY values as per the drawing scale used for the page var pinY = pinYNode.nodeValue * pageDrawScale; FindQuerySelect (pageID, shapeID, pinX, pinY); } } } // Takes page node and returns drawing scale of the page function FindPageDrawingScale(pageNode) { var pageDrawScale = 1; if(pageNode != null) { var drawingScaleNode = SelectSingleNode(pageNode,"PageProps/DrawingScale/text()"); var pageScaleNode = SelectSingleNode(pageNode,"PageProps/PageScale/text()"); if(drawingScaleNode != null && pageScaleNode != null) { var drawingScale = drawingScaleNode.nodeValue; var pageScale = pageScaleNode.nodeValue; if(drawingScale != null && pageScale != null && pageScale != 0 && drawingScale != 0) { pageDrawScale = pageScale/drawingScale; } } } return pageDrawScale; } var g_RowStyleList = parent.g_RowStyleList; var FillPropPane = parent.FillPropPane; var CreatePropTable = parent.CreatePropTable;