public HyperlinkClickedTelemetryEvent(HyperlinkType hyperlinkType, ContractsItemFilter currentTab, bool isSolutionView) : base(HyperlinkClickedEventName) { base[HyperLinkTypePropertyName] = hyperlinkType; base[CurrentTabPropertyName] = currentTab; base[IsSolutionViewPropertyName] = isSolutionView; }
/// <summary> /// Initializes a new instance of the Hyperlink class with the type and text the hyperlink shall /// represent. /// </summary> internal Hyperlink(string name, HyperlinkType type, string text) : this() { this.Name = name; this.Type = type; this.Elements.AddText(text); }
/// <summary> /// Adds a new Hyperlink as a new paragraph. To insert a Hyperlink into a paragraph use the Hyperlink function of the paragraph. /// </summary> /// <param name="type">The type.</param> public MezHyperlink AddHyperLink(HyperlinkType type = HyperlinkType.Local) { var result = new MezHyperlink(new Hyperlink()).Type(type); Section.AddParagraph().Add(result); return(result); }
private HyperlinkType getType(HyperlinkRecord record) { HyperlinkType link_type; // Figure out the type if (record.IsFileLink) { link_type = HyperlinkType.File; } else if (record.IsDocumentLink) { link_type = HyperlinkType.Document; } else { if (record.Address != null && record.Address.StartsWith("mailto:")) { link_type = HyperlinkType.Email; } else { link_type = HyperlinkType.Url; } } return(link_type); }
/// <summary> /// Initializes a new instance of the Hyperlink class with the type and text the hyperlink shall /// represent. /// </summary> public Hyperlink(string name, HyperlinkType type, string text) : this() { Name = name; Type = type; Elements.AddText(text); }
public XSSFHyperlink(CT_Hyperlink ctHyperlink, PackageRelationship hyperlinkRel) { this._ctHyperlink = ctHyperlink; this._externalRel = hyperlinkRel; if (ctHyperlink.location != null) { this._type = HyperlinkType.DOCUMENT; this._location = ctHyperlink.location; } else if (this._externalRel == null) { if (ctHyperlink.id != null) { throw new InvalidOperationException("The hyperlink for cell " + ctHyperlink.@ref + " references relation " + ctHyperlink.id + ", but that didn't exist!"); } this._type = HyperlinkType.DOCUMENT; } else { this._location = this._externalRel.TargetUri.ToString(); if (this._location.StartsWith("http://") || this._location.StartsWith("https://") || this._location.StartsWith("ftp://")) { this._type = HyperlinkType.URL; } else if (this._location.StartsWith("mailto:")) { this._type = HyperlinkType.EMAIL; } else { this._type = HyperlinkType.FILE; } } }
private void VerifyHyperlink(ICell cell, HyperlinkType linkType, String ref1) { Assert.IsTrue(CellHasHyperlink(cell)); IHyperlink link = cell.Hyperlink; Assert.AreEqual(linkType, link.Type); Assert.AreEqual(ref1, link.Address); }
private void CreateHyperlink(ICreationHelper helper, ICell cell, HyperlinkType linkType, String ref1) { cell.SetCellValue(ref1); IHyperlink link = helper.CreateHyperlink(linkType); link.Address = (ref1); cell.Hyperlink = (link); }
internal DrawingOpt(string imageName, uint refIndex, string hyperLinkName, HyperlinkType hyperLinkType) : base(3, 5u, EscherType.MSOFBTOPT, 0u) { m_imageName = imageName; m_referenceIndex = refIndex; m_hyperLinkName = hyperLinkName; m_hyperLinkType = hyperLinkType; }
/// <summary> /// Initializes a new instance of the Hyperlink class with the type and text the hyperlink shall /// represent. /// </summary> internal Hyperlink(string bookmarkName, string filename, HyperlinkType type, string text) : this() { BookmarkName = bookmarkName; Filename = filename; Type = type; Elements.AddText(text); }
/// <summary> /// Adds a new Hyperlink /// </summary> public Hyperlink AddHyperlink(string name, HyperlinkType type) { Hyperlink hyperlink = new Hyperlink(); hyperlink.Name = name; hyperlink.Type = type; Add(hyperlink); return(hyperlink); }
/** * Create a XSSFHyperlink amd Initialize it from the supplied CTHyperlink bean and namespace relationship * * @param ctHyperlink the xml bean Containing xml properties * @param hyperlinkRel the relationship in the underlying OPC namespace which stores the actual link's Address */ public XSSFHyperlink(CT_Hyperlink ctHyperlink, PackageRelationship hyperlinkRel) { _ctHyperlink = ctHyperlink; _externalRel = hyperlinkRel; // Figure out the Hyperlink type and distination // If it has a location, it's internal if (ctHyperlink.location != null) { _type = HyperlinkType.Document; _location = ctHyperlink.location; } else { // Otherwise it's somehow external, check // the relation to see how if (_externalRel == null) { if (ctHyperlink.id != null) { throw new InvalidOperationException("The hyperlink for cell " + ctHyperlink.@ref + " references relation " + ctHyperlink.id + ", but that didn't exist!"); } // hyperlink is internal and is not related to other parts _type = HyperlinkType.Document; } else { Uri target = _externalRel.TargetUri; try { _location = target.ToString(); } catch (UriFormatException) { _location = target.OriginalString; } // Try to figure out the type if (_location.StartsWith("http://") || _location.StartsWith("https://") || _location.StartsWith("ftp://")) { _type = HyperlinkType.Url; } else if (_location.StartsWith("mailto:")) { _type = HyperlinkType.Email; } else { _type = HyperlinkType.File; } } } }
public Hyperlink(string text, string linkUrl) { linkType = HyperlinkType.URL; this.text = text; this.linkUrl = linkUrl; blob = new TextBlob(Shared.GetGameFont10, text, 390); // Need to set once we know the correct position. hitBox = new AABB2D(); }
public void CreateHyperlink(HyperlinkType linkType, string urlText, string url) { if (linkType != HyperlinkType.URL) { Debug.Assert(false, "We only support URLs"); return; } Hyperlink hyperlink = new Hyperlink(urlText, url); hyperlinkList.Add(hyperlink); }
/// <summary> /// Travel back to parent container to get hyperlink text /// </summary> /// <param name="hyperlink"></param> /// <returns></returns> internal static string GetPPTHyperlinkText(HyperlinkType hyperlink) { if (string.IsNullOrEmpty(hyperlink.InnerText)) { OpenXmlElement parent = hyperlink.Parent; while (string.IsNullOrEmpty(parent.InnerText)) { parent = parent.Parent; } return(parent.InnerText); } return(hyperlink.InnerText); }
protected HyperlinkType GetLinkType(string type) { HyperlinkType linkType = HyperlinkType.Unknown; if ("auto".Equals(type.ToLower())) { linkType = NPOIExcelUtil.GetLinkTypeByData(Address); linkType = linkType == HyperlinkType.Unknown ? HyperlinkType.Url : linkType; } else if (!Enum.TryParse(type, true, out linkType)) { //默认URL类型(Excel2003用Unknown时会报引用为空错误;Excel2007中如Address与LinkType不匹配会报错,即使调整为Unknown导出Excel打开异常) linkType = HyperlinkType.Url; //: HyperlinkType.Unknown; } return(linkType); }
public void CreateHyperlink(HyperlinkType linkType, int startIndex, int endIndex) { List <TextSegment> segmentList = new List <TextSegment>(); String linkText = tweetBlob.RawText.Substring(startIndex, endIndex - startIndex); tweetBlob.CreateSubstringSegments(startIndex, endIndex, ref segmentList); if (segmentList.Count > 0) { Hyperlink newLink = new Hyperlink(linkText, segmentList, linkType, startIndex, endIndex); hyperlinkList.Add(newLink); } // Sort the list after the new entry hyperlinkList.Sort(CompareLinksbyStartIndex); }
/** * Create a XSSFHyperlink amd Initialize it from the supplied CTHyperlink bean and namespace relationship * * @param ctHyperlink the xml bean Containing xml properties * @param hyperlinkRel the relationship in the underlying OPC namespace which stores the actual link's Address */ public XSSFHyperlink(CT_Hyperlink ctHyperlink, PackageRelationship hyperlinkRel) { _ctHyperlink = ctHyperlink; _externalRel = hyperlinkRel; // Figure out the Hyperlink type and distination // If it has a location, it's internal if (ctHyperlink.location != null) { _type = HyperlinkType.DOCUMENT; _location = ctHyperlink.location; } else { // Otherwise it's somehow external, check // the relation to see how if (_externalRel == null) { if (ctHyperlink.id != null) { throw new InvalidOperationException("The hyperlink for cell " + ctHyperlink.@ref + " references relation " + ctHyperlink.id + ", but that didn't exist!"); } throw new InvalidOperationException("A sheet hyperlink must either have a location, or a relationship. Found:\n" + ctHyperlink); } Uri target = _externalRel.TargetUri; _location = target.ToString(); // Try to figure out the type if (_location.StartsWith("http://") || _location.StartsWith("https://") || _location.StartsWith("ftp://")) { _type = HyperlinkType.URL; } else if (_location.StartsWith("mailto:")) { _type = HyperlinkType.EMAIL; } else { _type = HyperlinkType.FILE; } } }
/// <summary> /// 添加超链接 /// </summary> /// <param name="exCell">单元格</param> /// <param name="field">字段规则</param> /// <param name="addr">地址</param> public static void AddHyperLink(ICell exCell, HyperlinkType linkType, string addr) { IWorkbook book = exCell.Sheet.Workbook; IHyperlink link = book.GetCreationHelper().CreateHyperlink(linkType); link.Address = addr; exCell.Hyperlink = link; IFont linkFont = book.CreateFont(); linkFont.Underline = FontUnderlineType.Single; linkFont.Color = IndexedColors.Blue.Index; ICellStyle linkStyle = exCell.CellStyle ?? book.CreateCellStyle(); linkStyle.SetFont(linkFont); exCell.CellStyle = linkStyle; }
/// <summary> /// Initializes a new instance of the <see cref="HSSFHyperlink"/> class. /// </summary> /// <param name="type">The type of hyperlink to Create.</param> public HSSFHyperlink(HyperlinkType type) { this.link_type = (int)type; record = new HyperlinkRecord(); switch (type) { case HyperlinkType.Url: case HyperlinkType.Email: record.CreateUrlLink(); break; case HyperlinkType.File: record.CreateFileLink(); break; case HyperlinkType.Document: record.CreateDocumentLink(); break; } }
public HSSFHyperlink(IHyperlink other) { if (other is HSSFHyperlink) { HSSFHyperlink hlink = (HSSFHyperlink)other; record = hlink.record.Clone() as HyperlinkRecord; link_type = getType(record); } else { link_type = other.Type; record = new HyperlinkRecord(); FirstRow = (other.FirstRow); FirstColumn = (other.FirstColumn); LastRow = (other.LastRow); LastColumn = (other.LastColumn); } }
/// <summary> /// Initializes a new instance of the <see cref="HSSFHyperlink"/> class. /// </summary> /// <param name="type">The type of hyperlink to Create.</param> public HSSFHyperlink(HyperlinkType type) { this.link_type = (int)type; record = new HyperlinkRecord(); switch (type) { case HyperlinkType.URL: case HyperlinkType.EMAIL: record.CreateUrlLink(); break; case HyperlinkType.FILE: record.CreateFileLink(); break; case HyperlinkType.DOCUMENT: record.CreateDocumentLink(); break; } }
/** * Create a new XSSFHyperlink. This method is for Internal use only. * XSSFHyperlinks can be created by XSSFCreationHelper. * * @param type - the type of hyperlink to create, see {@link Hyperlink} */ //FIXME: change to protected if/when SXSSFHyperlink class is created public XSSFHyperlink(IHyperlink other) { if (other is XSSFHyperlink) { XSSFHyperlink xlink = (XSSFHyperlink)other; _type = xlink.Type; _location = xlink._location; _externalRel = xlink._externalRel; _ctHyperlink = xlink._ctHyperlink.Copy(); } else { _type = other.Type; _location = other.Address; _externalRel = null; _ctHyperlink = new CT_Hyperlink(); SetCellReference(new CellReference(other.FirstRow, other.FirstColumn)); } }
public void Render(ICell cell) { //NPOIExcelUtil.AddHyperLink(cell, GetLinkType(LinkType), Address); HyperlinkType linkType = GetLinkType(LinkType); IWorkbook book = cell.Sheet.Workbook; IHyperlink link = book.GetCreationHelper().CreateHyperlink(linkType); link.Address = Address; cell.Hyperlink = link; IFont linkFont = book.CreateFont(); linkFont.Underline = FontUnderlineType.Single; linkFont.Color = IndexedColors.Blue.Index; ICellStyle linkStyle = cell.CellStyle ?? book.CreateCellStyle(); linkStyle.SetFont(linkFont); cell.CellStyle = linkStyle; }
/// <summary> /// Initializes a new instance of the <see cref="HSSFHyperlink"/> class. /// </summary> /// <param name="type">The type of hyperlink to Create.</param> public HSSFHyperlink(HyperlinkType type) { link_type = (int)type; record = new HyperlinkRecord(); switch (type) { case HyperlinkType.Url: case HyperlinkType.Email: record.CreateUrlLink(); break; case HyperlinkType.File: record.CreateFileLink(); break; case HyperlinkType.Document: record.CreateDocumentLink(); break; } }
private void method_1() { int num = 1; string str = this.field_0.Value; switch (str) { case null: case string.Empty: return; } if (str.StartsWith(BookmarkStart.b("Ԧ䄨弪夬弮", num))) { this.hyperlinkType_0 = HyperlinkType.WebLink; this.string_1 = str; } else if (str.StartsWith(BookmarkStart.b("Ԧ䐨䨪䐬䌮䔰尲", num))) { this.hyperlinkType_0 = HyperlinkType.EMailLink; this.string_1 = str; } else if (!this.field_0.IsLocal && (this.field_0.FormattingString.IndexOf(BookmarkStart.b("䬦", num)) == -1)) { this.hyperlinkType_0 = HyperlinkType.FileLink; this.string_0 = str; } else { this.hyperlinkType_0 = HyperlinkType.Bookmark; if ((this.field_0.LocalReference != null) && (this.field_0.LocalReference != string.Empty)) { this.string_2 = this.field_0.LocalReference; this.string_0 = str; } else { this.string_2 = str; } } this.method_3(); }
/// <summary> /// 设置某单元格为超链接格式 /// </summary> /// <param name="iRow"></param> /// <param name="iColumn"></param> /// <param name="backColor"></param> public void SetCellsHyperlink(int iRow, int iColumn, HyperlinkType hyperlinkType) { IRow row = _activeSheet.GetRow(iRow); if (null == row) { row = _activeSheet.CreateRow(iRow); } ICell cell = row.GetCell(iColumn); if (null == cell) { cell = row.CreateCell(iColumn); } //设置超链接 HSSFHyperlink link = new HSSFHyperlink(hyperlinkType); link.Address = ReadstringCellValue(iRow, iColumn); cell.Hyperlink = link; }
/// <summary> /// Adds a new Hyperlink. /// </summary> public Hyperlink AddHyperlink(string name, HyperlinkType type) { if (type == HyperlinkType.Bookmark) { return(AddHyperlink(name)); } if (type == HyperlinkType.ExternalBookmark || type == HyperlinkType.EmbeddedDocument) { throw new NotSupportedException("No bookmarkName defined. " + "Please use AddHyperlink(string filename, string bookmarkName, bool? newWindow) " + "or one of the AddHyperlinkToEmbeddedDocument() functions."); } // HyperlinkTypes File and Web/Url: Hyperlink hyperlink = new Hyperlink(); hyperlink.Filename = name; hyperlink.Type = type; Add(hyperlink); return(hyperlink); }
/// <summary> /// Initializes a new instance of the <see cref="HSSFHyperlink"/> class. /// </summary> /// <param name="type">The type of hyperlink to Create.</param> public HSSFHyperlink(HyperlinkType type) { this.link_type = type; record = new HyperlinkRecord(); switch (type) { case HyperlinkType.Url: case HyperlinkType.Email: record.CreateUrlLink(); break; case HyperlinkType.File: record.CreateFileLink(); break; case HyperlinkType.Document: record.CreateDocumentLink(); break; default: throw new ArgumentException("Invalid type: " + type); } }
public void HyperlinkClicked_RoundTrip_Succeeds(HyperlinkType hyperlinkTab, ContractsItemFilter currentTab, bool isSolutionView, string searchQuery) { // Arrange var telemetrySession = new Mock <ITelemetrySession>(); TelemetryEvent lastTelemetryEvent = null; _ = telemetrySession .Setup(x => x.PostEvent(It.IsAny <TelemetryEvent>())) .Callback <TelemetryEvent>(x => lastTelemetryEvent = x); var service = new NuGetVSTelemetryService(telemetrySession.Object); var evt = new HyperlinkClickedTelemetryEvent(hyperlinkTab, currentTab, isSolutionView, searchQuery); // Act service.EmitTelemetryEvent(evt); // Assert Assert.NotNull(lastTelemetryEvent); Assert.Equal(hyperlinkTab, lastTelemetryEvent[HyperlinkClickedTelemetryEvent.HyperLinkTypePropertyName]); Assert.Equal(currentTab, lastTelemetryEvent[HyperlinkClickedTelemetryEvent.CurrentTabPropertyName]); Assert.Equal(isSolutionView, lastTelemetryEvent[HyperlinkClickedTelemetryEvent.IsSolutionViewPropertyName]); Assert.Equal(searchQuery, lastTelemetryEvent.GetPiiData().Where(x => x.Key == HyperlinkClickedTelemetryEvent.AlternativePackageIdPropertyName).Select(x => x.Value).First()); }
/// <summary> /// Adds a new Hyperlink /// </summary> public Hyperlink AddHyperlink(string name, HyperlinkType type) { return(this.Elements.AddHyperlink(name, type)); }
/// <summary> /// Adds a new Hyperlink /// </summary> public Hyperlink AddHyperlink(string name, HyperlinkType type) { return this.Elements.AddHyperlink(name, type); }
/// <summary> /// Adds a new Hyperlink /// </summary> public Hyperlink AddHyperlink(string name, HyperlinkType type) { Hyperlink hyperlink = new Hyperlink(); hyperlink.Name = name; hyperlink.Type = type; this.Add(hyperlink); return hyperlink; }
public IHyperlink CreateHyperlink(HyperlinkType type) { return new XSSFHyperlink(type); }
public NPOI.SS.UserModel.Hyperlink CreateHyperlink(HyperlinkType type) { return new HSSFHyperlink(type); }
/** * Create a new XSSFHyperlink. This method is protected to be used only by XSSFCreationHelper * * @param type - the type of hyperlink to create */ public XSSFHyperlink(HyperlinkType type) { _type = type; _ctHyperlink = new CT_Hyperlink(); }
public Zephyr.Utils.NPOI.SS.UserModel.IHyperlink CreateHyperlink(HyperlinkType type) { return new HSSFHyperlink(type); }