public static string ToHtml(this DocumentPart part) { var visitor = new ToHtmlVisitor(); part.Accept(visitor); return(visitor.HtmlText); }
public override void SetDocumentPart(DocumentPart documentPart) { DeleteTempFile(); if (documentPart is InternalDocumentPart) { _tempFilename = Path.Combine(Path.GetTempPath(), Path.GetFileName(documentPart.Uri)); using (Stream stream = ((InternalDocumentPart)documentPart).GetStream()) { using (FileStream fileStream = new FileStream(_tempFilename, FileMode.Create, FileAccess.Write)) { byte[] buffer = new byte[1024]; int bytesRead = stream.Read(buffer, 0, 1024); while (bytesRead > 0) { fileStream.Write(buffer, 0, bytesRead); bytesRead = stream.Read(buffer, 0, 1024); } } _browser.Navigate(_tempFilename); } } else if (documentPart is ExternalDocumentPart) { _browser.Navigate(documentPart.Uri); } }
public static string ToPlainText(this DocumentPart part) { var visitor = new ToPlainTextVisitor(); part.Accept(visitor); return(visitor.PlainTextString); }
public static string ToLaTeX(this DocumentPart part) { var visitor = new ToLaTeXVisitor(); part.Accept(visitor); return(visitor.LaTeX); }
private string GetTextToIndex(DocumentPart part) { var mediaPart = ((ContentItem)part.ContentItem).As <MediaPart>(); var textToIndex = String.Empty; if (mediaPart != null) { var extension = Path.GetExtension(mediaPart.FileName); if (AllowedExtension(extension)) { var document = _storageProvider.GetFile(Path.Combine(mediaPart.FolderPath, mediaPart.FileName)); var documentStream = document.OpenRead(); if (documentStream == null) { return(textToIndex); } byte[] data = StreamHelper.ReadToEnd(documentStream); if (data == null) { return(textToIndex); } // Text Extraction var extractor = new TextExtractor(); var contentResult = extractor.Extract(data); textToIndex = contentResult.Text; } } return(textToIndex); }
public void CloseDocumentPart(DocumentPart documentPart) { if (_tabPages.ContainsKey(documentPart)) { TabPages.Remove(_tabPages[documentPart]); _tabPages.Remove(documentPart); } }
/// <summary> /// Removes all parts and sets given part the only part. /// </summary> /// <param name="part">the document part</param> public void setPart(DocumentPart part) { if (this.documentParts.ContainsKey(part.PartName)) { this.documentParts[part.PartName].Clear(); } addPart(part.PartName, part.PartValue); }
/// <summary> /// Add a part to the list of parts /// </summary> /// <param name="part">the document part</param> public void addPart(DocumentPart part) { if (!this.documentParts.ContainsKey(part.PartName)) { this.documentParts[part.PartName] = new List <DocumentPart>(); } this.documentParts[part.PartName].Add(part); }
internal PackagePart CreateDefaultNumberingPart() { var packagePartUri = new Uri("/word/numbering.xml", UriKind.Relative); var part = package.CreatePart(packagePartUri, ContentTypes.Numbering, CompressionOption.Normal); DocumentPart.CreateRelationship(packagePartUri, TargetMode.Internal, RelationshipTypes.Numbering); var content = XmlResourceHelper.GetXmlResource("Wordroller.Packages.Defaults.numbering.xml"); PackagePartHelper.SavePackagePart(part, content); return(part); }
public override string Convert(DocumentPart elem) { IDocumentPartConverter converter; if (Converters.TryGetValue(elem.GetType(), out converter)) { return(converter.Convert(elem)); } throw new InvalidOperationException($"can't find a converter for the {nameof(elem)}"); }
private void addStringToDocument(DocumentPart part) { FormFields fields = this.document.FormFields; foreach (FormField field in fields) { if (field.Name == part.PartName) { field.Range.Text += "\n" + part.PartValue; } } }
public (PackagePart, PackageRelationship) AddFooterPart() { var safePartIndex = package.GetParts().Count() + 1; var partUri = new Uri($"/word/footer{safePartIndex}.xml", UriKind.Relative); var part = package.CreatePart(partUri, ContentTypes.Footer, CompressionOption.Normal); var content = XmlResourceHelper.GetXmlResource("Wordroller.Packages.Defaults.footer.xml"); PackagePartHelper.SavePackagePart(part, content); var relationship = DocumentPart.CreateRelationship(part.Uri, TargetMode.Internal, RelationshipTypes.Footer); return(part, relationship); }
protected override void OnBeforeExpand(TreeViewCancelEventArgs e) { foreach (TreeNode node in e.Node.Nodes) { DocumentPart part = (DocumentPart)node.Tag; foreach (DocumentPart childPart in part.DocumentParts) { node.Nodes.Add(CreatePartNode(childPart)); } } base.OnBeforeExpand(e); }
public override void SetDocumentPart(DocumentPart documentPart) { InternalDocumentPart internalPart = documentPart as InternalDocumentPart; if (internalPart != null) { Image image = null; using (Stream stream = CreateImageStream(internalPart)) { image = Image.FromStream(stream); } _picture.Image = image; } }
private void addPictureToDocument(DocumentPart part) { FormFields fields = this.document.FormFields; foreach (FormField field in fields) { if (field.Name == part.PartName) { object msoTrue = Microsoft.Office.Core.MsoTriState.msoTrue; object missing = Missing.Value; field.Range.InlineShapes.AddPicture(part.PartValue, ref msoTrue, ref msoTrue, ref missing); field.Range.InsertAfter("\n"); } } }
void UpdateNodeText(TreeNode node) { DocumentPart part = (DocumentPart)node.Tag; if (_displayRelations) { node.Text = String.Format("{0} - {1}", part.RelationshipID, part.Name); } else { node.Text = part.Name; } foreach (TreeNode childNode in node.Nodes) { UpdateNodeText(childNode); } }
/// <summary> /// Covert document part. /// </summary> /// <param name="documentPart">document part</param> public string Convert(DocumentPart documentPart) { if (documentPart.GetType() == typeof(Hyperlink)) { return($"{ConvertHyperlink((Hyperlink) documentPart)}\n"); } if (documentPart.GetType() == typeof(PlainText)) { return($"{ConvertPlainText((PlainText) documentPart)}\n"); } if (documentPart.GetType() == typeof(BoldText)) { return($"{ConvertBoldText((BoldText) documentPart)}\n"); } return(""); }
public string Get(DocumentPart part) { if (part is BoldText) { return(Get(part as BoldText)); } if (part is PlainText) { return(Get(part as PlainText)); } if (part is Hyperlink) { return(Get(part as Hyperlink)); } return(string.Empty); }
TreeNode CreatePartNode(DocumentPart part) { TreeNode node = new TreeNode(); node.Name = part.Uri; Debug.WriteLine(part.Uri); node.Tag = part; if (part is PackageDocumentPart) { node.ImageIndex = 0; node.SelectedImageIndex = 0; } else { node.ImageIndex = 1; node.SelectedImageIndex = 1; } UpdateNodeText(node); return(node); }
public void OpenDocumentPart(DocumentPart documentPart) { TabPage page = null; if (_tabPages.ContainsKey(documentPart)) { page = _tabPages[documentPart]; } else { page = new TabPage(documentPart.Name); page.Tag = documentPart; DocumentPartViewer viewControl = CreateViewControl(documentPart); viewControl.SetDocumentPart(documentPart); viewControl.Dock = DockStyle.Fill; page.Controls.Add((Control)viewControl); TabPages.Add(page); _tabPages.Add(documentPart, page); } SelectedTab = page; }
DocumentPartViewer CreateViewControl(DocumentPart part) { PackageExplorerSection config = (PackageExplorerSection)ConfigurationManager.GetSection("packageExplorer"); PartViewerSettings settings = null; foreach (PartViewerSettings partViewer in config.PartViewers) { foreach (string contentType in partViewer.ContentTypes.Split('|')) { if (String.Equals(part.ContentType, contentType, StringComparison.InvariantCultureIgnoreCase)) { settings = partViewer; } } } if (settings == null) { settings = config.PartViewers[config.DefaultViewer]; } return((DocumentPartViewer)Activator.CreateInstance(Type.GetType(settings.Type))); }
/// <summary> /// Removes all parts with a certain value /// </summary> /// <param name="part">the document part</param> public void removePart(DocumentPart part) { if (!this.documentParts.ContainsKey(part.PartName)) { return; } DocumentPart target = new DocumentPart(part.PartName, part.PartValue); List <DocumentPart> parts = this.documentParts[part.PartName].FindAll(target.Equals); foreach (DocumentPart partToRemove in parts) { this.documentParts[part.PartName].Remove(partToRemove); } if (this.documentParts[part.PartName].Count == 0) { this.documentParts.Remove(part.PartName); } }
public int ContentCount(DocumentPart documentPart) { return ContentCount(documentPart, VersionOptions.Published); }
public int ContentCount(DocumentPart documentPart, VersionOptions versionOptions) { return GetDocumentQuery(documentPart, versionOptions).Count(); }
public static string DocumentForAdmin(this UrlHelper urlHelper, DocumentPart documentPart) { return urlHelper.Action("Item", "DocumentAdmin", new { documentId = documentPart.Id, area = "Infusion.Documents" }); }
public static string DocumentContentCreate(this UrlHelper urlHelper, DocumentPart documentPart) { return urlHelper.Action("Create", "DocumentContentAdmin", new { documentId = documentPart.Id, area = "Infusion.Documents" }); }
//public void addSnapshot(string snap) //{ // myMinutes.snapshots = myMinutes.snapshots + ";" + snap; //} //public void addParticipant(string part) //{ // myMinutes.participants = myMinutes.participants + "\n" + part; //} private void addPartsToDocument(DocumentPart[] parts) { foreach (DocumentPart part in parts) { switch (part.PartType) { case DocumentPartType.String: addStringToDocument(part); break; case DocumentPartType.Picture: addPictureToDocument(part); break; } } }
public static string ToPlainText(this DocumentPart documentPart) => ToPlainText((dynamic)documentPart);
public void DynamicVisit(DocumentPart part) => Visit((dynamic)part);
public static string ToHtml(this DocumentPart documentPart) => ToHtml((dynamic)documentPart);
public DocumentPartModifiedEventArgs(DocumentPart affectedDocumentPart, string propertyName, DocumentPartModificationType modificationType) { this.propertyName = propertyName; this.affectedDocumentPart = affectedDocumentPart; this.modificationType = modificationType; }
public string Convert(DocumentPart elem) { BoldText target = (BoldText)elem; return("<b>" + target.Text + "</b>");; }
public static string ToLaTeX(this DocumentPart documentPart) => ToLaTeX((dynamic)documentPart);
public string Visit(DocumentPart documentPart) => Visit((dynamic)documentPart);
public void SetDocumentPart(DocumentPart documentPart) { _contentTypeField.Text = documentPart.ContentType; _relationshipTypeField.Text = documentPart.RelationshipType; _documentPartNameField.Text = documentPart.Name; }
/// <summary> /// Removes all parts with a certain value /// </summary> /// <param name="part">the document part</param> public void removePart(DocumentPart part) { if (!this.documentParts.ContainsKey(part.PartName)) return; DocumentPart target = new DocumentPart(part.PartName, part.PartValue); List<DocumentPart> parts = this.documentParts[part.PartName].FindAll(target.Equals); foreach (DocumentPart partToRemove in parts) this.documentParts[part.PartName].Remove(partToRemove); if (this.documentParts[part.PartName].Count == 0) this.documentParts.Remove(part.PartName); }
/// <summary> /// Add a part to the list of parts /// </summary> /// <param name="part">the document part</param> public void addPart(DocumentPart part) { if (!this.documentParts.ContainsKey(part.PartName)) { this.documentParts[part.PartName] = new List<DocumentPart>(); } this.documentParts[part.PartName].Add(part); }
public override string Accept(DocumentPart visitor) { return(visitor.ToHtml()); }
/// <summary> /// Removes all parts and sets given part the only part. /// </summary> /// <param name="part">the document part</param> public void setPart(DocumentPart part) { if (this.documentParts.ContainsKey(part.PartName)) this.documentParts[part.PartName].Clear(); addPart(part.PartName, part.PartValue); }