// This sets the cursor to the beggining on the next Tag public static void authentic_GotoNextTag(AxXMLSPYPLUGINLib.AxAuthentic axTargetAuthenticObject) { if(axTargetAuthenticObject.AuthenticView.Selection.SelectNext(XMLSPYPLUGINLib.SPYAuthenticElementKind.spyAuthenticTag) != null) { axTargetAuthenticObject.AuthenticView.Selection.SelectNext(XMLSPYPLUGINLib.SPYAuthenticElementKind.spyAuthenticTag).Select(); } axTargetAuthenticObject.SelectionSet(axTargetAuthenticObject.CurrentSelection.Start,0,null,0); }
public static void authentic_SelectPreviousTag(AxXMLSPYPLUGINLib.AxAuthentic axTargetAuthenticObject) { try { axTargetAuthenticObject.AuthenticView.Selection.SelectPrevious(XMLSPYPLUGINLib.SPYAuthenticElementKind.spyAuthenticTag).Select(); } catch { } }
public static void authentic_SelectNextWord(AxXMLSPYPLUGINLib.AxAuthentic axTargetAuthenticObject) { try { axTargetAuthenticObject.AuthenticView.Selection.SelectNext(XMLSPYPLUGINLib.SPYAuthenticElementKind.spyAuthenticWord).Select(); } catch { } }
// This sets the cursor to the beggining on the previous Tag public static void authentic_GotoPreviousTag(AxXMLSPYPLUGINLib.AxAuthentic axTargetAuthenticObject) { try { axTargetAuthenticObject.AuthenticView.Selection.SelectPrevious(XMLSPYPLUGINLib.SPYAuthenticElementKind.spyAuthenticTag).Select(); axTargetAuthenticObject.SelectionSet(axTargetAuthenticObject.CurrentSelection.Start, 0, null, 0); } catch { } }
static XMLSPYPLUGINLib.XMLData findXmlDataRecursively(AxXMLSPYPLUGINLib.AxAuthentic axTargetAuthenticObject, string strElementToFind) { XMLSPYPLUGINLib.XMLData xdXmlData = axTargetAuthenticObject.AuthenticView.WholeDocument.FirstXMLData; while (xdXmlData.Name != strElementToFind) { xdXmlData = xdXmlData.Parent; } return xdXmlData; }
public static void setCurrentSelectedText(AxXMLSPYPLUGINLib.AxAuthentic axTargetAuthenticObject, string strTextToSet) { // We need to handle the case when the text that is being added // has newlines in it. We want to preserve the user's formatting // when it goes onto the altova control. if (strTextToSet.IndexOf(Environment.NewLine) > -1) { string strText = strTextToSet; while (strText.IndexOf(Environment.NewLine) > -1) { int newlinePos = strText.IndexOf(Environment.NewLine); string tmp = strText.Substring(0, newlinePos); // We need to remove the newline as well from the current string strText = strText.Remove(0, newlinePos + Environment.NewLine.Length); setCurrentSelectedText(axTargetAuthenticObject, tmp); authentic.authentic_InsertNewLine(axTargetAuthenticObject); } // Add the last line if (!strText.Trim().Equals("")) { setCurrentSelectedText(axTargetAuthenticObject, strText); } } else { axTargetAuthenticObject.AuthenticView.Selection.Text = strTextToSet; } }
public static void loadXmlFileInTargetAuthenticView(AxXMLSPYPLUGINLib.AxAuthentic axTargetAuthenticObject,string urlToXml,string urlToXsd,string urlToSps) { try { if (File.Exists(urlToXml) && File.Exists(urlToXsd) && File.Exists(urlToSps)) { axTargetAuthenticObject.SchemaLoadObject.URL = urlToXsd; axTargetAuthenticObject.DesignDataLoadObject.URL = urlToSps; axTargetAuthenticObject.XMLDataLoadObject.URL = urlToXml; axTargetAuthenticObject.XMLDataSaveUrl = urlToXml; axTargetAuthenticObject.EntryHelpersEnabled = true; axTargetAuthenticObject.AllowDrop = true; axTargetAuthenticObject.StartEditing(); axTargetAuthenticObject.Visible = true; } else { axTargetAuthenticObject.Visible = false; } } catch (Exception ex) { MessageBox.Show(string.Format("Error in loadXmlFileInTargetAuthenticView: {0}",ex.Message)); } }
public static string getCurrentSelectedText(AxXMLSPYPLUGINLib.AxAuthentic axTargetAuthenticObject) { return axTargetAuthenticObject.AuthenticView.Selection.Text; }
private void insertTextFromClipboard(AxXMLSPYPLUGINLib.AxAuthentic axActiveAuthenticControl) { string strClipboardString = utils.clipboard.getStringWithClipboardData(); // encode clipboard content System.IO.MemoryStream msClipboardData = new System.IO.MemoryStream(); // populate msClipboardData with strClipboardString contents XmlTextWriter xtwClipboardData = new XmlTextWriter(msClipboardData, null); xtwClipboardData.WriteString(strClipboardString); xtwClipboardData.Close(); string strTransformedClipboardString = System.Text.ASCIIEncoding.ASCII.GetString(msClipboardData.ToArray()); // new XmlTextReader(xtwClipboardData).ReadInnerXml(); // at the moment because I am not able to directly inject the newline element in the middle of this string, I have to add it manual to the selected text (with the user having to Save are reload the page) // when doing this transformation we also have to clean the clipboard so that we don't get two pastes // we also check to see if the encoding changed anything if (strClipboardString.IndexOf(Environment.NewLine) > -1 || strTransformedClipboardString != strClipboardString) { authentic.setCurrentSelectedText(axActiveAuthenticControl, strTransformedClipboardString); utils.clipboard.SetClipboardData(""); // we have to clean it or the Authentic control will paste the content } else utils.clipboard.SetClipboardData(strClipboardString); // under normal circuntances there is no need to clear the clipboard and we can just paste the (normalized) string }
public static void authentic_InsertImage(AxXMLSPYPLUGINLib.AxAuthentic axTargetAuthenticObject, string strPathToImage) { if ("" != axTargetAuthenticObject.AuthenticView.Selection.Text) // if there is some text selected, we have to select the next item { // move this into a method call authentic_ClearCurrentSelection axTargetAuthenticObject.AuthenticView.Selection = axTargetAuthenticObject.AuthenticView.Selection.GotoNextCursorPosition(); } // XMLSPYPLUGINLib.AuthenticRange ar = axTargetAuthenticObject.AuthenticView.Selection; if (true == authentic_InsertElementInCurrentSelectionPos_spyAuthenticInsertBefore(axTargetAuthenticObject, "img") && (axTargetAuthenticObject.AuthenticView.Selection.FirstXMLData.Name == "src")) { axTargetAuthenticObject.AuthenticView.Selection.FirstXMLData.TextValue = strPathToImage; authentic.authentic_GotoNextTag(axTargetAuthenticObject); // this authentic_GotoNextTag is sort of working since it is removing the focus from the img's src tag entry area, but it is not putting the focus after it } else { MessageBox.Show("Could not paste image due to a bug in the code. Please select some text and try again"); //this bit is not working //authentic_SelectNextTag(axTargetAuthenticObject); // it now needs to be SelectNextTag due to changes in the 2007 Altova component //axTargetAuthenticObject.AuthenticView.Selection.Text = strPathToImage; } }
private void loadXmlFileInTargetAuthenticView(AxXMLSPYPLUGINLib.AxAuthentic axTargetAuthenticObject,string urlToXml,string urlToXsd,string urlToSps) { axTargetAuthenticObject.SchemaLoadObject.URL = urlToXsd; axTargetAuthenticObject.DesignDataLoadObject.URL = urlToSps; axTargetAuthenticObject.XMLDataLoadObject.URL = urlToXml; axTargetAuthenticObject.XMLDataSaveUrl = urlToXml; axTargetAuthenticObject.EntryHelpersEnabled = true; axTargetAuthenticObject.AllowDrop = true; axTargetAuthenticObject.StartEditing(); }
public static void authentic_InsertNewLine(AxXMLSPYPLUGINLib.AxAuthentic axTargetAuthenticObject) { authentic_InsertElementInCurrentSelectionPos(axTargetAuthenticObject, "newline"); axTargetAuthenticObject.SelectionSet(axTargetAuthenticObject.CurrentSelection.Start, 0, null, 0); }
public static void authentic_InsertImage(AxXMLSPYPLUGINLib.AxAuthentic axTargetAuthenticObject, string strPathToImage) { authentic_InsertElementInCurrentSelectionPos(axTargetAuthenticObject, "img"); authentic_SelectPreviousTag(axTargetAuthenticObject); axTargetAuthenticObject.AuthenticView.Selection.Text = strPathToImage; }
private void checkForCtrlVandInsertDataFromClipboard(AxXMLSPYPLUGINLib.AxAuthentic axActiveAuthenticControl,char cKeyPressed, bool bCheckForImages) { if (0x56 == cKeyPressed) // 0x56 (86) V { if (bLeftCtrlDown) // if the left control key is pressed { if (true == bCheckForImages && true == utils.clipboard.isClipboardDataAnBitmap()) insertImageFromClipboard(); else { insertTextFromClipboard(axActiveAuthenticControl); } } } }
/// <summary> /// Description: This method is used to add a newline into the specified authentic object /// /// History: /// 11/25/2006 - Mike : Fixed a bug where the cursor wasn't going to the added newline /// </summary> /// <param name="axTargetAuthenticObject"></param> public static void authentic_InsertNewLine(AxXMLSPYPLUGINLib.AxAuthentic axTargetAuthenticObject) { XMLSPYPLUGINLib.AuthenticRange ar = axTargetAuthenticObject.AuthenticView.Selection; authentic_InsertElementInCurrentSelectionPos_spyAuthenticInsertAt(axTargetAuthenticObject,"newline"); axTargetAuthenticObject.AuthenticView.Selection = ar; axTargetAuthenticObject.AuthenticView.Selection = axTargetAuthenticObject.AuthenticView.Selection.GotoNextCursorPosition(); }
private void checkForEnterAndInsertNewLine(AxXMLSPYPLUGINLib.AxAuthentic axActiveAuthenticControl,char cKeyPressed) { if (0x0d == cKeyPressed) // 0x0d (13) Enter utils.authentic.authentic_InsertNewLine(axActiveAuthenticControl); }
public static void authentic_SelectNextTag(AxXMLSPYPLUGINLib.AxAuthentic axTargetAuthenticObject) { if (axTargetAuthenticObject.AuthenticView.Selection.SelectNext(XMLSPYPLUGINLib.SPYAuthenticElementKind.spyAuthenticTag) != null) { axTargetAuthenticObject.AuthenticView.Selection.SelectNext(XMLSPYPLUGINLib.SPYAuthenticElementKind.spyAuthenticTag).Select(); } }
private void processAuthenticKeyboardEvent(AxXMLSPYPLUGINLib.AxAuthentic axActiveAuthenticControl, char cKeyPressed, utils.LocalWindowsHook lwhSender) { try { // find out which control is currently selected string strCurrentSelectedControl = ""; if (axActiveAuthenticControl.AuthenticView.Selection.FirstXMLData.kind != XMLSPYPLUGINLib.SPYXMLDataKind.spyXMLDataText) strCurrentSelectedControl = axActiveAuthenticControl.AuthenticView.Selection.FirstXMLData.Name; else if (axActiveAuthenticControl.AuthenticView.Selection.FirstXMLData.Parent.kind != XMLSPYPLUGINLib.SPYXMLDataKind.spyXMLDataText) strCurrentSelectedControl = axActiveAuthenticControl.AuthenticView.Selection.FirstXMLData.Parent.Name; else strCurrentSelectedControl = "Error in recognizing SPYXMLDataKind"; // apply Gui Funcionality switch (strCurrentSelectedControl) { case "value": // this could be the Target DNS or IP string strParentControl = axActiveAuthenticControl.AuthenticView.Selection.FirstXMLData.Parent.Name; if (cKeyPressed == 0x0d) { // 05-Feb-07: [Dinis], This is a hack to make the Enter work with the DnsName and IP elements (which use an attribute for its value and don't work in the new version of the Authentic component) // get the value of the current element which should be either DnsValue or IP string strValueOfCurrentElement = axActiveAuthenticControl.AuthenticView.Selection.FirstXMLData.TextValue ; // get the parent.parent object which should be a 'Target' Element XMLSPYPLUGINLib.XMLData xdData = axActiveAuthenticControl.AuthenticView.Selection.FirstXMLData.Parent.Parent; if (xdData.Name == "Target") { // Now we are going to create manually either the 'DnsValue' or the 'IP' Element (the name we need is conveiniently in strParentControl) XMLSPYPLUGINLib.XMLData xdXmlDataElement = axActiveAuthenticControl.CreateChild(XMLSPYPLUGINLib.SPYXMLDataKind.spyXMLDataElement); xdXmlDataElement.Name = strParentControl; // create the atribute 'value' XMLSPYPLUGINLib.XMLData xdXmlDataAttribute = axActiveAuthenticControl.CreateChild(XMLSPYPLUGINLib.SPYXMLDataKind.spyXMLDataAttr); xdXmlDataAttribute.Name = "value"; // add addit it to the xdXmlDataElement xdXmlDataElement.AppendChild(xdXmlDataAttribute); // now that we have an 'DnsValue' or 'IP' element ready we need to find the correct location to insert it (note that due to the current xsd you cannot append it at the end) // Get first Child XMLSPYPLUGINLib.XMLData xdChild = xdData.GetFirstChild(XMLSPYPLUGINLib.SPYXMLDataKind.spyXMLDataElement); // and go though all childs until we find the current one for (int iChildId = 0; iChildId < xdData.CountChildren(); iChildId++) { // at lack of better choise we will use the 'value' attribute to try to fing the location to insert (the only problem will happen if there is a duplicate 'value' (which would be a mistake in this case)) if (xdChild.Name == strParentControl && getAttributeFromElement(xdChild, "value") == strValueOfCurrentElement) { // This will place the new Element before the current one xdData.InsertChild(xdXmlDataElement); // xdData.AppendChild(xdXmlDataElement); /// this one doesn't work since it all puts it at the end break; } // move to the next child (we need to do this so that the InsertChild works as expected if (iChildId < xdData.CountChildren() - 1) // don't go to the next child if we are on the last one xdChild = xdData.GetNextChild(); } } } break; switch (strParentControl) { case "DnsName": authentic.authentic_GotoNextTag(axActiveAuthenticControl); authentic.authentic_GotoNextTag(axActiveAuthenticControl); authentic.authentic_GotoNextTag(axActiveAuthenticControl); authentic.authentic_GotoNextTag(axActiveAuthenticControl); ///string strText = string strParentContol2 = axActiveAuthenticControl.AuthenticView.Selection.FirstXMLData.Name; // bool bResulta = authentic.authentic_InsertElementInCurrentSelectionPos_spyAuthenticInsertBefore(axActiveAuthenticControl, "DnsName"); break; case "IP": break; } break; case "level2": case "level3": checkForCtrlVandInsertDataFromClipboard(axActiveAuthenticControl,cKeyPressed, false); checkForEnterAndInsertNewLine(axActiveAuthenticControl,cKeyPressed); //if (0x0d == cKeyPressed) // 0x0d (13) Enter // utils.authentic.authentic_InsertNewLine(axActiveAuthenticControl); break; case "AdittionalDetails": checkForCtrlVandInsertDataFromClipboard(axActiveAuthenticControl,cKeyPressed, true); if (0x08 == cKeyPressed) // 0x08 (08) Del break; checkForEnterAndInsertNewLine(axActiveAuthenticControl, cKeyPressed); //if (0x0d == cKeyPressed) // 0x0d (13) Enter // utils.authentic.authentic_InsertNewLine(axActiveAuthenticControl); break; } } catch (Exception ex) { MessageBox.Show(ex.Message); // this was being thrown during normal ORG usage } }
public static XMLSPYPLUGINLib.AuthenticRangeClass authentic_SelectPreviousTag(AxXMLSPYPLUGINLib.AxAuthentic axTargetAuthenticObject) { try { XMLSPYPLUGINLib.AuthenticRangeClass arcSelectedObject = (XMLSPYPLUGINLib.AuthenticRangeClass)axTargetAuthenticObject.AuthenticView.Selection.SelectPrevious(XMLSPYPLUGINLib.SPYAuthenticElementKind.spyAuthenticTag); arcSelectedObject.Select(); return arcSelectedObject; } catch {} return null; }
public static bool authentic_InsertElementInCurrentSelectionPos_spyAuthenticInsertAt(AxXMLSPYPLUGINLib.AxAuthentic axTargetAuthenticObject, string strElementToInsert) { return axTargetAuthenticObject.AuthenticView.Selection.PerformAction(XMLSPYPLUGINLib.SpyAuthenticActions.spyAuthenticInsertAt,strElementToInsert); }
/// <summary> /// Method to load a Dummy xml file in the an Authentic object due to several race conditions with this control which cause an handle to be locked by the authentic control /// Ideally we should tell the Authentic control to unload the XML file, but the current version doesn't seem to have that funcionality /// </summary> /// <param name="axAuthentic_ToProcess"></param> private void loadDummyXmlFileInAuthenticControl(AxXMLSPYPLUGINLib.AxAuthentic axAuthentic_ToProcess) { utils.authentic.loadXmlFileInTargetAuthenticView(axAuthentic_ToProcess, obpPaths.EmptyProjectFilePath, obpPaths.ProjectSchemaPath, strSpsTemplateToUseToEditFindings); lbUnsavedData.Visible = false; axAuthentic_Findings.SetUnmodified(); }