//Добавление комментария public void AddCommentOnParagraph(DocumentFormat.OpenXml.Wordprocessing.Paragraph comPar, string comment) { DocumentFormat.OpenXml.Wordprocessing.Comments comments = null; string id = "0"; // Verify that the document contains a // WordProcessingCommentsPart part; if not, add a new one. if (document.MainDocumentPart.GetPartsCountOfType<WordprocessingCommentsPart>() > 0) { comments = document.MainDocumentPart.WordprocessingCommentsPart.Comments; if (comments.HasChildren == true) { // Obtain an unused ID. id = comments.Descendants<DocumentFormat.OpenXml.Wordprocessing.Comment>().Select(e => e.Id.Value).Max() + 1; } } else { // No WordprocessingCommentsPart part exists, so add one to the package. WordprocessingCommentsPart commentPart = document.MainDocumentPart.AddNewPart<WordprocessingCommentsPart>(); commentPart.Comments = new DocumentFormat.OpenXml.Wordprocessing.Comments(); comments = commentPart.Comments; } // Compose a new Comment and add it to the Comments part. DocumentFormat.OpenXml.Wordprocessing.Paragraph p = new DocumentFormat.OpenXml.Wordprocessing.Paragraph(new DocumentFormat.OpenXml.Wordprocessing.Run(new Text(comment))); DocumentFormat.OpenXml.Wordprocessing.Comment cmt = new DocumentFormat.OpenXml.Wordprocessing.Comment() { Id = id, Author = "FRChecking System", Date = DateTime.Now }; cmt.AppendChild(p); comments.AppendChild(cmt); comments.Save(); // Specify the text range for the Comment. // Insert the new CommentRangeStart before the first run of paragraph. comPar.InsertBefore(new CommentRangeStart() { Id = id }, comPar.GetFirstChild<DocumentFormat.OpenXml.Wordprocessing.Run>()); // Insert the new CommentRangeEnd after last run of paragraph. var cmtEnd = comPar.InsertAfter(new CommentRangeEnd() { Id = id }, comPar.Elements<DocumentFormat.OpenXml.Wordprocessing.Run>().Last()); // Compose a run with CommentReference and insert it. comPar.InsertAfter(new DocumentFormat.OpenXml.Wordprocessing.Run(new CommentReference() { Id = id }), cmtEnd); }
public static void SetCell(WorksheetPart worksheetPart, string text, string columnName, DocumentFormat.OpenXml.Spreadsheet.Row row, out Cell cell) { cell = GetCell(worksheetPart.Worksheet, columnName, row); cell.CellValue = new CellValue(string.IsNullOrWhiteSpace(text) ? "" : text); cell.DataType = new EnumValue<CellValues>(CellValues.String); }
public static void SetCellDate(WorksheetPart worksheetPart, DateTime value, string columnName, DocumentFormat.OpenXml.Spreadsheet.Row row) { Cell cell = GetCell(worksheetPart.Worksheet, columnName, row); cell.CellValue = new CellValue(value.ToOADate().ToString("0")); cell.DataType = new EnumValue<CellValues>(CellValues.Number); }
public DeleteFormatFromDocumentDescriptor( DocumentDescriptorId aggregateId, DocumentFormat documentFormat) : base(aggregateId) { if (aggregateId == null) throw new ArgumentNullException("aggregateId"); DocumentFormat = documentFormat; }
public void Start(Int32 pollingTimeInMs) { var jobDataMap = context.JobDetail.JobDataMap; PipelineId = new PipelineId(jobDataMap.GetString(JobKeys.PipelineId)); InputDocumentId = new DocumentId(jobDataMap.GetString(JobKeys.DocumentId)); InputBlobId = new BlobId(jobDataMap.GetString(JobKeys.BlobId)); InputDocumentFormat = new DocumentFormat(jobDataMap.GetString(JobKeys.Format)); if (TenantId == null) throw new Exception("tenant not set!"); _workingFolder = Path.Combine( ConfigService.GetWorkingFolder(TenantId, InputBlobId), GetType().Name ); OnExecute(context); try { if (Directory.Exists(_workingFolder)) Directory.Delete(_workingFolder, true); } catch (Exception ex) { Logger.ErrorFormat(ex, "Error deleting {0}", _workingFolder); } pollingTimer = new Timer(pollingTimeInMs); pollingTimer.Elapsed += pollingTimer_Elapsed; pollingTimer.Start(); }
/// <summary> /// Stream to file /// </summary> /// <param name="inputStream"></param> /// <param name="outputFile"></param> /// <param name="fileMode"></param> /// <param name="sourceRectangle"></param> /// <returns></returns> public static string StreamToFile(Stream inputStream, string outputFile, FileMode fileMode, DocumentFormat.OpenXml.Drawing.SourceRectangle sourceRectangle) { try { if (inputStream == null) throw new ArgumentNullException("inputStream"); if (String.IsNullOrEmpty(outputFile)) throw new ArgumentException("Argument null or empty.", "outputFile"); if (Path.GetExtension(outputFile).ToLower() == ".emf" || Path.GetExtension(outputFile).ToLower() == ".wmf") { System.Drawing.Imaging.Metafile emf = new System.Drawing.Imaging.Metafile(inputStream); System.Drawing.Rectangle cropRectangle; double leftPercentage = (sourceRectangle != null && sourceRectangle.Left != null) ? ToPercentage(sourceRectangle.Left.Value) : 0; double topPercentage = (sourceRectangle != null && sourceRectangle.Top != null) ? ToPercentage(sourceRectangle.Top.Value) : 0; double rightPercentage = (sourceRectangle != null && sourceRectangle.Left != null) ? ToPercentage(sourceRectangle.Right.Value) : 0; double bottomPercentage = (sourceRectangle != null && sourceRectangle.Left != null) ? ToPercentage(sourceRectangle.Bottom.Value) : 0; cropRectangle = new System.Drawing.Rectangle( (int)(emf.Width * leftPercentage), (int)(emf.Height * topPercentage), (int)(emf.Width - emf.Width * (leftPercentage + rightPercentage)), (int)(emf.Height - emf.Height * (bottomPercentage + topPercentage))); System.Drawing.Bitmap newBmp = new System.Drawing.Bitmap(cropRectangle.Width, cropRectangle.Height); using (System.Drawing.Graphics graphic = System.Drawing.Graphics.FromImage(newBmp)) { graphic.Clear(System.Drawing.Color.White); graphic.DrawImage(emf, new System.Drawing.Rectangle(0, 0, cropRectangle.Width, cropRectangle.Height), cropRectangle, System.Drawing.GraphicsUnit.Pixel); } outputFile = outputFile.Replace(".emf", ".jpg"); newBmp.Save(outputFile, System.Drawing.Imaging.ImageFormat.Jpeg); return outputFile; } else { if (!File.Exists(outputFile)) { using (FileStream outputStream = new FileStream(outputFile, fileMode, FileAccess.Write)) { int cnt = 0; const int LEN = 4096; byte[] buffer = new byte[LEN]; while ((cnt = inputStream.Read(buffer, 0, LEN)) != 0) outputStream.Write(buffer, 0, cnt); } } return outputFile; } } catch (Exception ex) { throw ex; } }
public void FindPluginsTest1() { DocumentFormat documentFormat = new DocumentFormat(); // TODO: Initialize to an appropriate value IEnumerable<IPlugin> expected = null; // TODO: Initialize to an appropriate value IEnumerable<IPlugin> actual; actual = PluginManager.FindPlugins(documentFormat); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
private static string GetCellValue(SharedStringTable sharedStrings, DocumentFormat.OpenXml.Spreadsheet.Cell cell) { return cell.DataType != null && cell.DataType.HasValue && cell.DataType == CellValues.SharedString ? sharedStrings.ChildElements[ int.Parse(cell.CellValue.InnerText)].InnerText : cell.CellValue.InnerText; }
public override IEnumerable<OpenXmlElement> ToOpenXmlElements(DocumentFormat.OpenXml.Packaging.MainDocumentPart mainDocumentPart) { var result = new List<OpenXmlElement>(); ForEachChild(x => { Debug.Assert(x is ListItemFormattedElement); result.AddRange(x.ToOpenXmlElements(mainDocumentPart)); }); return result; }
public override IEnumerable<OpenXmlElement> ToOpenXmlElements(DocumentFormat.OpenXml.Packaging.MainDocumentPart mainDocumentPart) { TableRow result = new TableRow(); ForEachChild(x => { Debug.Assert(x is TableCellFormattedElement); result.Append(x.ToOpenXmlElements(mainDocumentPart)); }); return new List<OpenXmlElement> { result }; }
public AddFormatToDocumentDescriptor( DocumentDescriptorId aggregateId, DocumentFormat documentFormat, BlobId blobId, PipelineId createdById) : base(aggregateId) { if (aggregateId == null) throw new ArgumentNullException("aggregateId"); DocumentFormat = documentFormat; BlobId = blobId; CreatedBy = createdById; }
public override IEnumerable<OpenXmlElement> ToOpenXmlElements(DocumentFormat.OpenXml.Packaging.MainDocumentPart mainDocumentPart) { var result = new DocumentFormat.OpenXml.Wordprocessing.Run(); var runProperties = new DocumentFormat.OpenXml.Wordprocessing.RunProperties(); var boldProperty = new DocumentFormat.OpenXml.Wordprocessing.Bold(); runProperties.Append(boldProperty); result.Append(runProperties); ForEachChild(x => result.Append(x.ToOpenXmlElements(mainDocumentPart))); return new List<OpenXmlElement> { result }; }
public override IEnumerable<OpenXmlElement> ToOpenXmlElements(DocumentFormat.OpenXml.Packaging.MainDocumentPart mainDocumentPart) { var result = new DocumentFormat.OpenXml.Wordprocessing.Paragraph(); var paragraphProperties = new ParagraphProperties(); var numberingProperties = new NumberingProperties(); var numberingLevelReference = new NumberingLevelReference() { Val = 0 }; NumberingId numberingId; ParagraphStyleId paragraphStyleId; if (Parent is OrderedListFormattedElement) { paragraphStyleId = new ParagraphStyleId() { Val = "NumberedList" }; numberingId = new NumberingId() { Val = ((OrderedListFormattedElement)Parent).NumberingInstanceId }; var indentation = new Indentation() { Left = "1440", Hanging = "720" }; paragraphProperties.Append(indentation); } else { paragraphStyleId = new ParagraphStyleId() { Val = "UnorderedListStyle" }; numberingId = new NumberingId() { Val = 3 }; } numberingProperties.Append(numberingLevelReference); numberingProperties.Append(numberingId); var spacingBetweenLines= new SpacingBetweenLines() { After = "100", AfterAutoSpacing = true }; paragraphProperties.Append(paragraphStyleId); paragraphProperties.Append(numberingProperties); paragraphProperties.Append(spacingBetweenLines); result.Append(paragraphProperties); ForEachChild(x => { if (x is TextFormattedElement) { result.Append( new DocumentFormat.OpenXml.Wordprocessing.Run(x.ToOpenXmlElements(mainDocumentPart)) ); } else { result.Append(x.ToOpenXmlElements(mainDocumentPart)); } }); return new List<OpenXmlElement> { result }; }
public override IEnumerable<OpenXmlElement> ToOpenXmlElements(DocumentFormat.OpenXml.Packaging.MainDocumentPart mainDocumentPart) { var result = new List<OpenXmlElement>(); ForEachChild(x => { if (x is ParagraphFormattedElement) { result.AddRange(x.ToOpenXmlElements(mainDocumentPart)); } }); return result; }
public static void SetCellValue(WorksheetPart worksheetPart, decimal? value, string columnName, DocumentFormat.OpenXml.Spreadsheet.Row row, out Cell cell) { cell = GetCell(worksheetPart.Worksheet, columnName, row); if (value.HasValue) { cell.CellValue = new CellValue(value.ToString()); cell.DataType = new EnumValue<CellValues>(CellValues.Number); } else { cell.CellValue = new CellValue(); cell.DataType = new EnumValue<CellValues>(CellValues.InlineString); } }
/// <summary> /// Get the current default file extension for a document type. The method is not aware of the MS Compatibilty pack in 2003 or below /// </summary> /// <param name="type">target document type</param> /// <returns>default extension for document type</returns> public string FileExtension(DocumentFormat type) { switch (type) { case DocumentFormat.Normal: return _owner.ApplicationIs2007OrHigher ? "docx" : "doc"; case DocumentFormat.Macros: return _owner.ApplicationIs2007OrHigher ? "docm" : "doc"; case DocumentFormat.Template: return _owner.ApplicationIs2007OrHigher ? "dotx" : "dot"; case DocumentFormat.TemplateMacros: return _owner.ApplicationIs2007OrHigher ? "dotm" : "dot"; default: throw new ArgumentOutOfRangeException("type"); } }
public static byte[] GetByteArrayFromDocument(RichEditControl pRichEdit, DocumentFormat pDocFormat) { byte[] resultByteArray = null; try { using (MemoryStream memStream = new MemoryStream()) { pRichEdit.SaveDocument(memStream, pDocFormat); resultByteArray = memStream.ToArray(); } } catch (Exception e) { } return resultByteArray; }
public override IEnumerable<OpenXmlElement> ToOpenXmlElements(DocumentFormat.OpenXml.Packaging.MainDocumentPart mainDocumentPart) { var result = new DocumentFormat.OpenXml.Wordprocessing.Paragraph(); ForEachChild(x => { if (x is TextFormattedElement) { result.Append( new DocumentFormat.OpenXml.Wordprocessing.Run(x.ToOpenXmlElements(mainDocumentPart)) ); } else { result.Append(x.ToOpenXmlElements(mainDocumentPart)); } }); return new List<OpenXmlElement> { result }; }
/// <summary> /// Get the current default file extension for a document type. The method is not aware of the MS Compatibilty pack in 2003 or below /// </summary> /// <param name="type">target document type</param> /// <returns>default extension for document type</returns> public string FileExtension(DocumentFormat type) { switch (type) { case DocumentFormat.Normal: return _owner.ApplicationIs2007OrHigher ? "xlsx" : "xls"; case DocumentFormat.Macros: return _owner.ApplicationIs2007OrHigher ? "xlsm" : "xls"; case DocumentFormat.Template: return _owner.ApplicationIs2007OrHigher ? "xltx" : "xlt"; case DocumentFormat.TemplateMacros: return _owner.ApplicationIs2007OrHigher ? "xltm" : "xlt"; case DocumentFormat.Binary: return "xlb"; case DocumentFormat.AddinMacros: return _owner.ApplicationIs2007OrHigher ? "xlam" : "xla"; default: throw new ArgumentOutOfRangeException("type"); } }
/* External Service vs Internal Implementation Cross-Reference * Web API Architecture: * ConfirmationsManager.svc.getConfirmTemplates = ConfirmDocsAPIDal.GetTemplates * ConfirmationsManager.svc.getPermissionKeys = ConfirmMgrAPIDal.GetPermissionKeys * ConfirmationsManager.svc.tradeConfirmationStatusChange = ConfirmMgrAPIDal... * * GetDocument.svc.getConfirmation = ConfirmDocsAPIDal.GetConfirm * GetDocument.svc.getDealsheet = DealsheetAPIDal.GetDealsheet * ********************************************************************************** * CounterParty.svc.getAgreementList = CptyInfoAPIDal... * CounterParty.svc.getDocumentSendTo = CptyInfoAPIDal... * CounterParty.svc.storeDocumentSendTo = CptyInfoAPIDal... * * ConfirmManager Architecture: * ConfirmDocsAPIDal.GetTemplates = ConfirmationsManager.svc.getConfirmTemplates * ConfirmDocsAPIDal.GetConfirm = GetDocument.svc.getConfirmation * * ConfirmMgrAPIDal.GetPermissionKeys = ConfirmationsManager.svc.getPermissionKeys * ConfirmMgrAPIDal... = ConfirmationsManager.svc.tradeConfirmationStatusChange * * DealsheetAPIDal.GetDealsheet = GetDocument.svc.getDealsheet * ********************************************************************************** * CptyInfoAPIDal... = CounterParty.svc.getAgreementList * CptyInfoAPIDal... = CounterParty.svc.getDocumentSendTo * CptyInfoAPIDal... = CounterParty.svc.storeDocumentSendTo * */ public static bool SaveByteArrayAsPdfFile(byte[] pByteArray, DocumentFormat pDocFormat, string pFileName) { bool isConversionOk = false; RichEditControl richEdit = new RichEditControl(); try { using (MemoryStream memStream = new MemoryStream(pByteArray)) { richEdit.LoadDocument(memStream, pDocFormat); richEdit.ExportToPdf(pFileName); } isConversionOk = true; } catch (Exception e) { isConversionOk = false; } return isConversionOk; }
internal static void Extract(DocumentFormat.OpenXml.Packaging.ThemePart themes, DocumentFormat.OpenXml.Packaging.StyleDefinitionsPart styleDefinitionsPart) { using (TextWriter css = new StreamWriter(File.OpenWrite("CSS\\generated.css"))) { css.Write("body{ "); Extract(styleDefinitionsPart.Styles.DocDefaults.ParagraphPropertiesDefault.ParagraphPropertiesBaseStyle, css); Extract(styleDefinitionsPart.Styles.DocDefaults.RunPropertiesDefault.RunPropertiesBaseStyle, css); Write(css, "font-family", themes.Theme.FirstChild.ChildElements.OfType<DocumentFormat.OpenXml.Drawing.FontScheme>().SelectMany(f => f.ChildElements).OfType<DocumentFormat.OpenXml.Drawing.MajorFont>().SelectMany(f => f.ChildElements).OfType<DocumentFormat.OpenXml.Drawing.LatinFont>().FirstOrDefault().Typeface + ", Arial"); css.WriteLine("}"); foreach (OpenXmlElement oxe in styleDefinitionsPart.Styles.ChildElements) { Style style = oxe as Style; if (style == null) continue; css.Write("." + style.StyleId.Value); if (style.LinkedStyle != null && style.LinkedStyle.Val != null && style.LinkedStyle.Val.HasValue) css.Write(", ." + style.LinkedStyle.Val.Value); css.Write("{ "); Extract(themes, css, style); css.WriteLine("}"); } } }
public override IEnumerable<OpenXmlElement> ToOpenXmlElements(DocumentFormat.OpenXml.Packaging.MainDocumentPart mainDocumentPart) { // Creates a new numbered instance for each Ordered list. NumberingInstanceId = IdHelper.GenerateIntId(); var numberingDefinition = FindOrCreateNumberingDefinitionPart(mainDocumentPart); var numbering = new Numbering(); numberingDefinition.Numbering = numbering; NumberingInstance numberingInstance = new NumberingInstance() { NumberID = NumberingInstanceId }; numbering.Append(numberingInstance); AbstractNumId abstractNumId = new AbstractNumId() { Val = 0 }; numberingInstance.Append(abstractNumId); var result = new List<OpenXmlElement>(); ForEachChild(x => { Debug.Assert(x is ListItemFormattedElement); result.AddRange(x.ToOpenXmlElements(mainDocumentPart)); }); return result; }
/// <summary> /// Adds a new worksheet to the workbook /// </summary> /// <param name="spreadsheet">Spreadsheet to use</param> /// <param name="name">Name of the worksheet</param> /// <returns>True if succesful</returns> public static bool AddWorksheet(DocumentFormat.OpenXml.Packaging.SpreadsheetDocument spreadsheet, string name) { DocumentFormat.OpenXml.Spreadsheet.Sheets sheets = spreadsheet.WorkbookPart.Workbook.GetFirstChild<DocumentFormat.OpenXml.Spreadsheet.Sheets>(); DocumentFormat.OpenXml.Spreadsheet.Sheet sheet; DocumentFormat.OpenXml.Packaging.WorksheetPart worksheetPart; // Add the worksheetpart worksheetPart = spreadsheet.WorkbookPart.AddNewPart<DocumentFormat.OpenXml.Packaging.WorksheetPart>(); worksheetPart.Worksheet = new DocumentFormat.OpenXml.Spreadsheet.Worksheet(new DocumentFormat.OpenXml.Spreadsheet.SheetData()); worksheetPart.Worksheet.Save(); // Add the sheet and make relation to workbook sheet = new DocumentFormat.OpenXml.Spreadsheet.Sheet() { Id = spreadsheet.WorkbookPart.GetIdOfPart(worksheetPart), SheetId = (uint)(spreadsheet.WorkbookPart.Workbook.Sheets.Count() + 1), Name = name }; sheets.Append(sheet); spreadsheet.WorkbookPart.Workbook.Save(); return true; }
private static IEnumerable<OpenXmlElement> CreateTopicText(DocumentFormat.OpenXml.Packaging.MainDocumentPart mainDocumentPart, FormattedContent formattedContent) { var formattedContentParagraphs = formattedContent.ToOpenXmlElements(mainDocumentPart); foreach (var para in formattedContentParagraphs) { if (para is Paragraph) { if (((Paragraph)para).ParagraphProperties == null) { ParagraphProperties paragraphProperties22 = new ParagraphProperties(); ParagraphStyleId paragraphStyleId22 = new ParagraphStyleId() { Val = "StyleAfter0pt" }; SpacingBetweenLines spacingBetweenLines16 = new SpacingBetweenLines() { After = "360" }; paragraphProperties22.Append(paragraphStyleId22); paragraphProperties22.Append(spacingBetweenLines16); para.InsertAt(paragraphProperties22, 0); } } } return formattedContentParagraphs; }
public override IEnumerable<OpenXmlElement> ToOpenXmlElements(DocumentFormat.OpenXml.Packaging.MainDocumentPart mainDocumentPart) { TableCell result = new TableCell(); var cellProperties = new TableCellProperties(); if (!Width.IsEmpty) { var cellWidth = UnitHelper.Convert(Width).To<TableCellWidth>(); cellProperties.Append(cellWidth); } if (Colspan.HasValue) { var gridSpan = new GridSpan() { Val = Colspan }; cellProperties.Append(gridSpan); } result.Append(cellProperties); var paraContent = new Paragraph(); ForEachChild(x => { if (x is TextFormattedElement) { paraContent.Append( new Run(x.ToOpenXmlElements(mainDocumentPart)) ); } else { paraContent.Append(x.ToOpenXmlElements(mainDocumentPart)); } }); result.Append(paraContent); return new List<OpenXmlElement> { result }; }
public override IEnumerable<OpenXmlElement> ToOpenXmlElements(DocumentFormat.OpenXml.Packaging.MainDocumentPart mainDocumentPart) { Table result = new Table(); var tableProperties = new TableProperties(); var tableStyle = new TableStyle() { Val = "GrilledutableauSimpleTable" }; var tableWidth = UnitHelper.Convert(Width).To<TableWidth>(); var tableIndentation = new TableIndentation() { Width = 534, Type = TableWidthUnitValues.Dxa }; var tableLook = new TableLook() { Val = "04A0" }; tableProperties.Append(tableStyle); tableProperties.Append(tableWidth); tableProperties.Append(tableIndentation); tableProperties.Append(tableLook); result.Append(tableProperties); ForEachChild(x => { Debug.Assert(x is TableRowFormattedElement); result.Append(x.ToOpenXmlElements(mainDocumentPart)); }); return new List<OpenXmlElement> { result }; }
/// <summary> /// Get the current default file extension for a document type. The method is not aware of the MS Compatibilty pack in 2003 or below /// </summary> /// <param name="type">target document type</param> /// <returns>default extension for document type</returns> public string FileExtension(DocumentFormat type) { switch (type) { case DocumentFormat.Normal: return _owner.ApplicationIs2007OrHigher ? "accdb" : "mdb"; case DocumentFormat.Compiled: return _owner.ApplicationIs2007OrHigher ? "accde" : "mde"; case DocumentFormat.Runtime: return "accdr"; case DocumentFormat.Template: return _owner.ApplicationIs2007OrHigher ? "accdt" : "mdt"; case DocumentFormat.Addin: return _owner.ApplicationIs2007OrHigher ? "accda" : "mda"; case DocumentFormat.Assistant: return "mdz"; case DocumentFormat.FieldDescription: return "accdf"; case DocumentFormat.WorkgroupSecurity: return "mdw"; default: throw new ArgumentOutOfRangeException("type"); } }
public static SymbolTable LoadIntrinsic(List <string> paths, DocumentFormat intrinsicDocumentFormat, EventHandler <DiagnosticsErrorEvent> diagEvent) { var parser = new Parser(); var diagnostics = new List <Diagnostic>(); var table = new SymbolTable(null, SymbolTable.Scope.Intrinsic); var instrincicFiles = new List <string>(); foreach (string path in paths) { instrincicFiles.AddRange(FileSystem.GetFiles(path, parser.Extensions, false)); } foreach (string path in instrincicFiles) { try { parser.Init(path, new TypeCobolOptions { ExecToStep = ExecutionStep.CrossCheck }, intrinsicDocumentFormat); parser.Parse(path); diagnostics.AddRange(parser.Results.AllDiagnostics()); if (diagEvent != null && diagnostics.Count > 0) { diagnostics.ForEach(d => diagEvent(null, new DiagnosticsErrorEvent() { Path = path, Diagnostic = d })); } if (parser.Results.ProgramClassDocumentSnapshot.Root.Programs == null || parser.Results.ProgramClassDocumentSnapshot.Root.Programs.Count() == 0) { throw new CopyLoadingException("Your Intrisic types/functions are not included into a program.", path, null, logged: true, needMail: false); } foreach (var program in parser.Results.ProgramClassDocumentSnapshot.Root.Programs) { var symbols = program.SymbolTable.GetTableFromScope(SymbolTable.Scope.Declarations); if (symbols.Types.Count == 0 && symbols.Functions.Count == 0) { diagEvent?.Invoke(null, new DiagnosticsErrorEvent() { Path = path, Diagnostic = new ParserDiagnostic("No types and no procedures/functions found", 1, 1, 1, null, MessageCode.Warning) }); continue; } table.CopyAllTypes(symbols.Types); table.CopyAllFunctions(symbols.Functions); } } catch (CopyLoadingException copyException) { throw copyException; } catch (Exception e) { throw new CopyLoadingException(e.Message + "\n" + e.StackTrace, path, e, logged: true, needMail: true); } } return(table); }
public static SymbolTable LoadDependencies([NotNull] List <string> paths, DocumentFormat format, SymbolTable intrinsicTable, [NotNull] List <string> inputFiles, List <string> copyFolders, EventHandler <DiagnosticsErrorEvent> diagEvent) { var parser = new Parser(intrinsicTable); var diagnostics = new List <Diagnostic>(); var table = new SymbolTable(intrinsicTable, SymbolTable.Scope.Namespace); //Generate a table of NameSPace containing the dependencies programs based on the previously created intrinsic table. var dependencies = new List <string>(); string[] extensions = { ".tcbl", ".cbl", ".cpy" }; foreach (var path in paths) { var dependenciesFound = Tools.FileSystem.GetFiles(path, extensions, true); //Issue #668, warn if dependencies path are invalid if (diagEvent != null && dependenciesFound.Count == 0) { diagEvent(null, new DiagnosticsErrorEvent() { Path = path, Diagnostic = new ParserDiagnostic(path + ", no dependencies found", 1, 1, 1, null, MessageCode.DependenciesLoading) }); } dependencies.AddRange(dependenciesFound); //Get File by name or search the directory for all files } #if EUROINFO_RULES //Create list of inputFileName according to our naming convention in the case of an usage with RDZ var programsNames = new List <string>(); foreach (var inputFile in inputFiles) { string PgmName = null; foreach (var line in File.ReadLines(inputFile)) { if (line.StartsWith(" PROGRAM-ID.", StringComparison.InvariantCultureIgnoreCase)) { PgmName = line.Split('.')[1].Trim(); break; } } programsNames.Add(PgmName); } #endif foreach (string path in dependencies) { #if EUROINFO_RULES //Issue #583, ignore a dependency if the same file will be parsed as an input file just after string depFileNameRaw = Path.GetFileNameWithoutExtension(path).Trim(); if (depFileNameRaw != null) { // substring in case of MYPGM.rdz.tcbl var depFileName = depFileNameRaw.Substring(0, depFileNameRaw.IndexOf(".", StringComparison.Ordinal) != -1 ? depFileNameRaw.IndexOf(".", StringComparison.Ordinal) : depFileNameRaw.Length ); if (programsNames.Any(inputFileName => String.Compare(depFileName, inputFileName, StringComparison.OrdinalIgnoreCase) == 0)) { continue; } } #endif try { parser.CustomSymbols = table; //Update SymbolTable parser.Init(path, new TypeCobolOptions { ExecToStep = ExecutionStep.SemanticCheck }, format, copyFolders); parser.Parse(path); //Parse the dependency file diagnostics.AddRange(parser.Results.AllDiagnostics()); if (diagEvent != null && diagnostics.Count > 0) { diagnostics.ForEach(d => diagEvent(null, new DiagnosticsErrorEvent() { Path = path, Diagnostic = d })); } if (parser.Results.TemporaryProgramClassDocumentSnapshot.Root.Programs == null || !parser.Results.TemporaryProgramClassDocumentSnapshot.Root.Programs.Any()) { throw new DepedenciesLoadingException("Your dependency file is not included into a program", path, null, logged: true, needMail: false); } foreach (var program in parser.Results.TemporaryProgramClassDocumentSnapshot.Root.Programs) { var declarationTable = program.SymbolTable.GetTableFromScope(SymbolTable.Scope.Declarations); var globalTable = program.SymbolTable.GetTableFromScope(SymbolTable.Scope.Global); var previousPrograms = table.GetPrograms(); foreach (var previousProgram in previousPrograms) { previousProgram.SymbolTable.GetTableFromScope(SymbolTable.Scope.Namespace).AddProgram(program); } //If there is no public types or functions, then call diagEvent if (diagEvent != null && !globalTable.Types.Values.Any(tds => tds.Any(td => td.CodeElement().Visibility == AccessModifier.Public)) && //No Public Types in Global table !declarationTable.Types.Values.Any(tds => tds.Any(td => td.CodeElement().Visibility == AccessModifier.Public)) && //No Public Types in Declaration table !declarationTable.Functions.Values.Any(fds => fds.Any(fd => fd.CodeElement().Visibility == AccessModifier.Public))) //No Public Functions in Declaration table { diagEvent(null, new DiagnosticsErrorEvent() { Path = path, Diagnostic = new ParserDiagnostic(string.Format("No public types or procedures/functions found in {0}", program.Name), 1, 1, 1, null, MessageCode.Warning) }); continue; } table.AddProgram(program); //Add program to Namespace symbol table } } catch (DepedenciesLoadingException depLoadingEx) { throw depLoadingEx; } catch (Exception e) { throw new DepedenciesLoadingException(e.Message + "\n" + e.StackTrace, path, e); } } //Reset symbolTable of all dependencies return(table); }
protected internal virtual void LoadDocumentCore(Stream stream, DocumentFormat documentFormat, string sourceUri);
/// <summary> In this file-based implementation, streams are emulated using temporary files.</summary> protected internal override void ConvertInternal(Stream inputStream, DocumentFormat inputFormat, Stream outputStream, DocumentFormat outputFormat) { FileInfo inputFile = null; FileInfo outputFile = null; try { inputFile = new FileInfo(string.Format("document.{0}", inputFormat.FileExtension)) { Attributes = FileAttributes.Temporary }; Stream inputFileStream = new FileStream(inputFile.FullName, FileMode.Create); IOUtils.Copy(inputStream, inputFileStream); outputFile = new FileInfo(string.Format("document.{0}", outputFormat.FileExtension)) { Attributes = FileAttributes.Temporary }; Convert(inputFile, inputFormat, outputFile, outputFormat); Stream outputFileStream = null; try { outputFileStream = new FileStream(outputFile.FullName, FileMode.Open, FileAccess.Read); IOUtils.Copy(outputFileStream, outputStream); } finally { //IOUtils.closeQuietly(outputFileStream); if (outputFileStream != null) { outputFileStream.Close(); } } } catch (IOException ioException) { throw new OpenOfficeException("conversion failed", ioException); } finally { if (inputFile != null) { if (File.Exists(inputFile.FullName)) { File.Delete(inputFile.FullName); } else if (Directory.Exists(inputFile.FullName)) { Directory.Delete(inputFile.FullName); } } if (outputFile != null) { if (File.Exists(outputFile.FullName)) { File.Delete(outputFile.FullName); } else if (Directory.Exists(outputFile.FullName)) { Directory.Delete(outputFile.FullName); } } } }
public static void Check_ASCIICobolFile_FreeTextFormat() { DocumentFormat docFormat = DocumentFormat.FreeTextFormat; SourceFileProvider fileProvider = new SourceFileProvider(); fileProvider.AddLocalDirectoryLibrary( PlatformUtils.GetPathForProjectFile(@"Compiler\File\Samples"), false, new string[] { ".cpy" }, docFormat.Encoding, docFormat.EndOfLineDelimiter, docFormat.FixedLineLength); DummyTextSourceListener textSourceListener = new DummyTextSourceListener(); CobolFile cobolFile; if (fileProvider.TryGetFile("AsciiFreeFormat", out cobolFile)) { // Load the CobolFile in a TextDocument ReadOnlyTextDocument textDocument = new ReadOnlyTextDocument("AsciiFreeFormat.cpy", docFormat.Encoding, docFormat.ColumnsLayout, cobolFile.ReadChars()); // Send all text lines in one batch to the test observer textDocument.TextChanged += textSourceListener.OnTextChanged; textDocument.StartSendingChangeEvents(); } TextChangeMap tce1 = new TextChangeMap(textSourceListener.LastTextChangedEvent.TextChanges.First <TextChange>(), docFormat.ColumnsLayout); if (tce1.LineIndex != 0 || tce1.Type != TextChangeType.LineInserted || tce1.NewLineMap.SequenceNumberText != null || tce1.NewLineMap.IndicatorChar != '/' || tce1.NewLineMap.SourceText != "----------------------------------------------------------------" || tce1.NewLineMap.CommentText != null) { throw new Exception("Error reading line 1 of the ASCII text source (free text format)"); } TextChangeMap tce2 = new TextChangeMap(textSourceListener.LastTextChangedEvent.TextChanges[4], docFormat.ColumnsLayout); if (tce2.LineIndex != 4 || tce2.Type != TextChangeType.LineInserted || tce2.NewLineMap.SequenceNumberText != null || tce2.NewLineMap.IndicatorChar != '*' || tce2.NewLineMap.SourceText != " Comportant TAGs (ou BALISEs) standards/normalisés apposées via commentaires standards à respecter " || tce2.NewLineMap.CommentText != null) { throw new Exception("Error reading line 5 of the ASCII text source (free text format)"); } TextChangeMap tce3 = new TextChangeMap(textSourceListener.LastTextChangedEvent.TextChanges[7], docFormat.ColumnsLayout); if (tce3.LineIndex != 7 || tce3.Type != TextChangeType.LineInserted || tce3.NewLineMap.SequenceNumberText != null || tce3.NewLineMap.IndicatorChar != ' ' || tce3.NewLineMap.SourceText != " 10 PIC X(008) VALUE " || tce3.NewLineMap.CommentText != null) { throw new Exception("Error reading line 8 of the ASCII text source (free text format)"); } TextChangeMap tce4 = new TextChangeMap(textSourceListener.LastTextChangedEvent.TextChanges[8], docFormat.ColumnsLayout); if (tce4.LineIndex != 8 || tce4.Type != TextChangeType.LineInserted || tce4.NewLineMap.SequenceNumberText != null || tce4.NewLineMap.IndicatorChar != ' ' || tce4.NewLineMap.SourceText != " 'MSVCINP '. " || tce4.NewLineMap.CommentText != null) { throw new Exception("Error reading line 9 of the ASCII text source (free text format)"); } TextChangeMap tce5 = new TextChangeMap(textSourceListener.LastTextChangedEvent.TextChanges[13], docFormat.ColumnsLayout); if (tce5.LineIndex != 13 || tce5.Type != TextChangeType.LineInserted || tce5.NewLineMap.SequenceNumberText != null || tce5.NewLineMap.IndicatorChar != 'D' || tce5.NewLineMap.SourceText != " 15 :MSVCINP:-AppSessnId PIC X(064). " || tce5.NewLineMap.CommentText != null) { throw new Exception("Error reading line 14 of the ASCII text source (free text format)"); } TextChangeMap tce6 = new TextChangeMap(textSourceListener.LastTextChangedEvent.TextChanges[18], docFormat.ColumnsLayout); if (tce6.LineIndex != 18 || tce6.Type != TextChangeType.LineInserted || tce6.NewLineMap.SequenceNumberText != null || tce6.NewLineMap.IndicatorChar != ' ' || tce6.NewLineMap.SourceText != " 05 FILLER PIC X(499). " || tce6.NewLineMap.CommentText != null) { throw new Exception("Error reading line 19 of the ASCII text source (free text format)"); } TextChangeMap tce7 = new TextChangeMap(textSourceListener.LastTextChangedEvent.TextChanges.Last <TextChange>(), docFormat.ColumnsLayout); if (tce7.LineIndex != 27 || tce7.Type != TextChangeType.LineInserted || tce7.NewLineMap.SequenceNumberText != null || tce7.NewLineMap.IndicatorChar != 'd' || tce7.NewLineMap.SourceText != " 05 PIC X(008) VALUE '/MSVCINP'. " || tce7.NewLineMap.CommentText != null) { throw new Exception("Error reading line 28 of the ASCII text source (free text format)"); } }
private void ReadWord(string pathName, DocumentFormat df) { this.richEditControl1.LoadDocument(pathName, df); DeleteFile(pathName); }
public ConvertLdDialog(IOcrDocument ocrDocument, DocumentWriter docWriter, DocumentFormat initialFormat, string initialLdFileName, bool viewDocument) { InitializeComponent(); _ocrDocument = ocrDocument; _docWriter = docWriter; // Get the formats // This is the order of importance, show these first then the rest as they come along DocumentFormat[] importantFormats = { DocumentFormat.Pdf, DocumentFormat.Docx, DocumentFormat.Rtf, DocumentFormat.Text, DocumentFormat.Doc, DocumentFormat.Xls, DocumentFormat.Html }; List <DocumentFormat> formatsToAdd = new List <DocumentFormat>(); Array temp = Enum.GetValues(typeof(DocumentFormat)); List <DocumentFormat> allFormats = new List <DocumentFormat>(); foreach (DocumentFormat format in temp) { allFormats.Add(format); } // Add important once first: foreach (DocumentFormat format in importantFormats) { formatsToAdd.Add(format); allFormats.Remove(format); } // Add rest formatsToAdd.AddRange(allFormats); MyFormat pdfFormat = null; foreach (DocumentFormat format in formatsToAdd) { bool addFormat = true; // If this is the "User" or Engines format, only add it if the OCR engine supports them if (format == DocumentFormat.User || format == DocumentFormat.Ltd) { addFormat = false; } if (addFormat) { string friendlyName = DocumentWriter.GetFormatFriendlyName(format); string extension = DocumentWriter.GetFormatFileExtension(format).ToUpper(); MyFormat mf = new MyFormat(format, friendlyName, extension); _formatComboBox.Items.Add(mf); if (mf.Format == initialFormat) { _formatComboBox.SelectedItem = mf; } else if (mf.Format == DocumentFormat.Pdf) { pdfFormat = mf; } switch (format) { case DocumentFormat.Pdf: // Update the PDF options page { PdfDocumentOptions pdfOptions = docWriter.GetOptions(DocumentFormat.Pdf) as PdfDocumentOptions; // Clone it in case we change it in the Advance PDF options dialog _pdfOptions = pdfOptions.Clone() as PdfDocumentOptions; Array a = Enum.GetValues(typeof(PdfDocumentType)); foreach (PdfDocumentType i in a) { _pdfDocumentTypeComboBox.Items.Add(i); } _pdfDocumentTypeComboBox.SelectedItem = _pdfOptions.DocumentType; _pdfImageOverTextCheckBox.Checked = _pdfOptions.ImageOverText; _pdfLinearizedCheckBox.Checked = _pdfOptions.Linearized; if (string.IsNullOrEmpty(_pdfOptions.Creator)) { _pdfOptions.Creator = "LEADTOOLS PDFWriter"; } if (string.IsNullOrEmpty(_pdfOptions.Producer)) { _pdfOptions.Producer = "LEAD Technologies, Inc."; } } break; case DocumentFormat.Doc: // Update the DOC options page { DocDocumentOptions docOptions = docWriter.GetOptions(DocumentFormat.Doc) as DocDocumentOptions; _cbFramedDoc.Checked = (docOptions.TextMode == DocumentTextMode.Framed) ? true : false; } break; case DocumentFormat.Docx: // Update the DOCX options page { DocxDocumentOptions docxOptions = docWriter.GetOptions(DocumentFormat.Docx) as DocxDocumentOptions; _cbFramedDocX.Checked = (docxOptions.TextMode == DocumentTextMode.Framed) ? true : false; } break; case DocumentFormat.Rtf: // Update the RTF options page { RtfDocumentOptions rtfOptions = docWriter.GetOptions(DocumentFormat.Rtf) as RtfDocumentOptions; _cbFramedRtf.Checked = (rtfOptions.TextMode == DocumentTextMode.Framed) ? true : false; } break; case DocumentFormat.Html: // Update the HTML options page { HtmlDocumentOptions htmlOptions = docWriter.GetOptions(DocumentFormat.Html) as HtmlDocumentOptions; Array a = Enum.GetValues(typeof(DocumentFontEmbedMode)); foreach (DocumentFontEmbedMode i in a) { _htmlEmbedFontModeComboBox.Items.Add(i); } _htmlEmbedFontModeComboBox.SelectedItem = htmlOptions.FontEmbedMode; _htmlUseBackgroundColorCheckBox.Checked = htmlOptions.UseBackgroundColor; _htmlBackgroundColorValueLabel.BackColor = MainForm.ConvertColor(htmlOptions.BackgroundColor); _htmlBackgroundColorLabel.Enabled = _htmlUseBackgroundColorCheckBox.Checked; _htmlBackgroundColorValueLabel.Enabled = _htmlUseBackgroundColorCheckBox.Checked; _htmlBackgroundColorButton.Enabled = _htmlUseBackgroundColorCheckBox.Checked; } break; case DocumentFormat.Text: // Update the TEXT options page { TextDocumentOptions textOptions = docWriter.GetOptions(DocumentFormat.Text) as TextDocumentOptions; Array a = Enum.GetValues(typeof(TextDocumentType)); foreach (TextDocumentType i in a) { _textDocumentTypeComboBox.Items.Add(i); } _textDocumentTypeComboBox.SelectedItem = textOptions.DocumentType; _textAddPageNumberCheckBox.Checked = textOptions.AddPageNumber; _textAddPageBreakCheckBox.Checked = textOptions.AddPageBreak; _textFormattedCheckBox.Checked = textOptions.Formatted; } break; case DocumentFormat.AltoXml: // Update the ALTOXML options page { AltoXmlDocumentOptions altoXmlOptions = docWriter.GetOptions(DocumentFormat.AltoXml) as AltoXmlDocumentOptions; _altoXmlFileNameTextBox.Text = altoXmlOptions.FileName; _altoXmlSoftwareCreatorTextBox.Text = altoXmlOptions.SoftwareCreator; _altoXmlSoftwareNameTextBox.Text = altoXmlOptions.SoftwareName; _altoXmlApplicationDescriptionTextBox.Text = altoXmlOptions.ApplicationDescription; _altoXmlFormattedCheckBox.Checked = altoXmlOptions.Formatted; _altoXmlIndentationTextBox.Text = altoXmlOptions.Indentation; _altoXmlSort.Checked = altoXmlOptions.Sort; _altoXmlPlainText.Checked = altoXmlOptions.PlainText; _altoXmlShowGlyphInfo.Checked = altoXmlOptions.ShowGlyphInfo; _altoXmlShowGlyphVariants.Checked = altoXmlOptions.ShowGlyphVariants; Array a = Enum.GetValues(typeof(AltoXmlMeasurementUnit)); foreach (AltoXmlMeasurementUnit i in a) { _altoXmlMeasurementUnit.Items.Add(i); } _altoXmlMeasurementUnit.SelectedItem = altoXmlOptions.MeasurementUnit; } break; case DocumentFormat.Emf: case DocumentFormat.Xls: case DocumentFormat.Pub: case DocumentFormat.Mob: case DocumentFormat.Svg: default: // These formats have no options break; } } } // Remove all the tab pages _optionsTabControl.TabPages.Clear(); // If no format is selected, default to PDF if (_formatComboBox.SelectedIndex == -1) { if (pdfFormat != null) { _formatComboBox.SelectedItem = pdfFormat; } else { _formatComboBox.SelectedIndex = -1; } } _viewDocumentCheckBox.Checked = viewDocument; _formatComboBox_SelectedIndexChanged(this, EventArgs.Empty); if (!string.IsNullOrEmpty(initialLdFileName)) { _ldFileNameTextBox.Text = initialLdFileName; UpdateOutputFileName(); } UpdateUIState(); }
public DocumentFormatHasBeenDeleted(DocumentFormat documentFormat) { DocumentFormat = documentFormat; }
public virtual void SaveDocument(string fileName, DocumentFormat documentFormat);
protected internal override void ConvertInternal(FileInfo inputFile, DocumentFormat inputFormat, FileInfo outputFile, DocumentFormat outputFormat) { Stream inputStream = null; Stream outputStream = null; try { inputStream = new FileStream(inputFile.FullName, FileMode.Open, FileAccess.Read); outputStream = new FileStream(outputFile.FullName, FileMode.Create); Convert(inputStream, inputFormat, outputStream, outputFormat); } catch (FileNotFoundException fileNotFoundException) { throw new ArgumentException(fileNotFoundException.Message); } finally { if (inputStream != null) { inputStream.Close(); } if (outputStream != null) { outputStream.Close(); } } }
protected internal override void ConvertInternal(FileInfo inputFile, DocumentFormat inputFormat, FileInfo outputFile, DocumentFormat outputFormat) { IDictionary loadProperties = new Hashtable(); SupportClass.MapSupport.PutAll(loadProperties, DefaultLoadProperties); SupportClass.MapSupport.PutAll(loadProperties, inputFormat.ImportOptions); IDictionary storeProperties = outputFormat.GetExportOptions(inputFormat.Family); lock (OpenOfficeConnection) { XFileIdentifierConverter fileContentProvider = OpenOfficeConnection.FileContentProvider; String inputUrl = fileContentProvider.getFileURLFromSystemPath("", inputFile.FullName); String outputUrl = fileContentProvider.getFileURLFromSystemPath("", outputFile.FullName); LoadAndExport(inputUrl, loadProperties, outputUrl, storeProperties); } }
public static WorksheetPart WorkSheet(this SpreadsheetDocument spreadsheet, DocumentFormat.OpenXml.Spreadsheet.Sheet oXmlSheet) { return spreadsheet.WorkbookPart.GetPartById(oXmlSheet.Id) as WorksheetPart; }
public virtual void LoadDocument(Stream stream, DocumentFormat documentFormat);
public static CompilationDocument ScanCobolFile(string relativePath, string textName, DocumentFormat documentFormat) { DirectoryInfo localDirectory = new DirectoryInfo(PlatformUtils.GetPathForProjectFile(relativePath)); if (!localDirectory.Exists) { throw new Exception(String.Format("Directory : {0} does not exist", relativePath)); } CompilationProject project = new CompilationProject("test", localDirectory.FullName, new string[] { ".cbl", ".cpy" }, documentFormat.Encoding, documentFormat.EndOfLineDelimiter, documentFormat.FixedLineLength, documentFormat.ColumnsLayout, new TypeCobolOptions()); FileCompiler compiler = new FileCompiler(null, textName, project.SourceFileProvider, project, documentFormat.ColumnsLayout, new TypeCobolOptions(), null, true, project); compiler.CompileOnce(); return(compiler.CompilationResultsForCopy); }
private void _okButton_Click(object sender, EventArgs e) { // Save the options MyFormat mf = _formatComboBox.SelectedItem as MyFormat; // Update the options DocumentOptions documentOptions = _docWriter.GetOptions(mf.Format); switch (mf.Format) { case DocumentFormat.Pdf: // Update the PDF options { PdfDocumentOptions pdfOptions = documentOptions as PdfDocumentOptions; pdfOptions.DocumentType = (PdfDocumentType)_pdfDocumentTypeComboBox.SelectedItem; pdfOptions.ImageOverText = _pdfImageOverTextCheckBox.Checked; pdfOptions.Linearized = _pdfLinearizedCheckBox.Checked; pdfOptions.PageRestriction = DocumentPageRestriction.Relaxed; // Description options pdfOptions.Title = _pdfOptions.Title; pdfOptions.Subject = _pdfOptions.Subject; pdfOptions.Keywords = _pdfOptions.Keywords; pdfOptions.Author = _pdfOptions.Author; pdfOptions.Creator = _pdfOptions.Creator; pdfOptions.Producer = _pdfOptions.Producer; // Fonts options pdfOptions.FontEmbedMode = _pdfOptions.FontEmbedMode; // Security options pdfOptions.Protected = _pdfOptions.Protected; if (pdfOptions.Protected) { pdfOptions.UserPassword = _pdfOptions.UserPassword; pdfOptions.OwnerPassword = _pdfOptions.OwnerPassword; pdfOptions.EncryptionMode = _pdfOptions.EncryptionMode; pdfOptions.PrintEnabled = _pdfOptions.PrintEnabled; pdfOptions.HighQualityPrintEnabled = _pdfOptions.HighQualityPrintEnabled; pdfOptions.CopyEnabled = _pdfOptions.CopyEnabled; pdfOptions.EditEnabled = _pdfOptions.EditEnabled; pdfOptions.AnnotationsEnabled = _pdfOptions.AnnotationsEnabled; pdfOptions.AssemblyEnabled = _pdfOptions.AssemblyEnabled; } // Compression options pdfOptions.OneBitImageCompression = _pdfOptions.OneBitImageCompression; pdfOptions.ColoredImageCompression = _pdfOptions.ColoredImageCompression; pdfOptions.QualityFactor = _pdfOptions.QualityFactor; pdfOptions.ImageOverTextSize = _pdfOptions.ImageOverTextSize; pdfOptions.ImageOverTextMode = _pdfOptions.ImageOverTextMode; // Initial View Options pdfOptions.PageModeType = _pdfOptions.PageModeType; pdfOptions.PageLayoutType = _pdfOptions.PageLayoutType; pdfOptions.PageFitType = _pdfOptions.PageFitType; pdfOptions.ZoomPercent = _pdfOptions.ZoomPercent; pdfOptions.InitialPageNumber = _pdfOptions.InitialPageNumber; pdfOptions.FitWindow = _pdfOptions.FitWindow; pdfOptions.CenterWindow = _pdfOptions.CenterWindow; pdfOptions.DisplayDocTitle = _pdfOptions.DisplayDocTitle; pdfOptions.HideMenubar = _pdfOptions.HideMenubar; pdfOptions.HideToolbar = _pdfOptions.HideToolbar; pdfOptions.HideWindowUI = _pdfOptions.HideWindowUI; } break; case DocumentFormat.Doc: // Update the DOC options { DocDocumentOptions docOptions = documentOptions as DocDocumentOptions; docOptions.TextMode = (_cbFramedDoc.Checked) ? DocumentTextMode.Framed : DocumentTextMode.NonFramed; } break; case DocumentFormat.Docx: // Update the DOCX options { DocxDocumentOptions docxOptions = documentOptions as DocxDocumentOptions; docxOptions.TextMode = (_cbFramedDocX.Checked) ? DocumentTextMode.Framed : DocumentTextMode.NonFramed; } break; case DocumentFormat.Rtf: // Update the RTF options { RtfDocumentOptions rtfOptions = documentOptions as RtfDocumentOptions; rtfOptions.TextMode = (_cbFramedRtf.Checked) ? DocumentTextMode.Framed : DocumentTextMode.NonFramed; } break; case DocumentFormat.Html: // Update the HTML options { HtmlDocumentOptions htmlOptions = documentOptions as HtmlDocumentOptions; htmlOptions.FontEmbedMode = (DocumentFontEmbedMode)_htmlEmbedFontModeComboBox.SelectedItem; htmlOptions.UseBackgroundColor = _htmlUseBackgroundColorCheckBox.Checked; htmlOptions.BackgroundColor = MainForm.ConvertColor(_htmlBackgroundColorValueLabel.BackColor); } break; case DocumentFormat.Text: // Update the TEXT options { TextDocumentOptions textOptions = documentOptions as TextDocumentOptions; textOptions.DocumentType = (TextDocumentType)_textDocumentTypeComboBox.SelectedItem; textOptions.AddPageNumber = _textAddPageNumberCheckBox.Checked; textOptions.AddPageBreak = _textAddPageBreakCheckBox.Checked; textOptions.Formatted = _textFormattedCheckBox.Checked; } break; case DocumentFormat.AltoXml: // Update the ALTOXML options { AltoXmlDocumentOptions altoXmlOptions = documentOptions as AltoXmlDocumentOptions; altoXmlOptions.FileName = _altoXmlFileNameTextBox.Text; altoXmlOptions.SoftwareCreator = _altoXmlSoftwareCreatorTextBox.Text; altoXmlOptions.SoftwareName = _altoXmlSoftwareNameTextBox.Text; altoXmlOptions.ApplicationDescription = _altoXmlApplicationDescriptionTextBox.Text; altoXmlOptions.Formatted = _altoXmlFormattedCheckBox.Checked; altoXmlOptions.Indentation = (altoXmlOptions.Formatted) ? _altoXmlIndentationTextBox.Text : ""; altoXmlOptions.Sort = _altoXmlSort.Checked; altoXmlOptions.PlainText = _altoXmlPlainText.Checked; altoXmlOptions.ShowGlyphInfo = _altoXmlShowGlyphInfo.Checked; altoXmlOptions.ShowGlyphVariants = _altoXmlShowGlyphVariants.Checked; altoXmlOptions.MeasurementUnit = (AltoXmlMeasurementUnit)_altoXmlMeasurementUnit.SelectedItem; } break; case DocumentFormat.Emf: case DocumentFormat.Xls: case DocumentFormat.Pub: case DocumentFormat.Mob: case DocumentFormat.Svg: default: // These formats have no options break; } if (documentOptions != null) { _docWriter.SetOptions(mf.Format, documentOptions); } // Get the save paramters _selectedInputFileName = _ldFileNameTextBox.Text; _selectedFormat = mf.Format; _selectedOutputFileName = _outputFileNameTextBox.Text; _selectedViewDocument = _viewDocumentCheckBox.Checked; }
private SkylineVersion(Func <String> getLabelFunc, String versionName, CacheFormatVersion cacheFormatVersion, DocumentFormat srmDocumentVersion) { _getLabelFunc = getLabelFunc; InvariantVersionName = versionName; CacheFormatVersion = cacheFormatVersion; SrmDocumentVersion = srmDocumentVersion; }
public MyFormat(DocumentFormat f, string n, string e) { Format = f; FriendlyName = n; Extension = e; }
private SkylineVersion(Func <String> getLabelFunc, String versionName, CacheFormatVersion cacheFormatVersion, DocumentFormat srmDocumentVersion) : base(versionName, getLabelFunc) { CacheFormatVersion = cacheFormatVersion; SrmDocumentVersion = srmDocumentVersion; }
/// <summary> /// This is the real function that save a stream to the destination /// file and create the descriptor /// </summary> /// <param name="format"></param> /// <param name="fileName"></param> /// <param name="sourceStream"></param> /// <returns></returns> private FileSystemBlobDescriptor SaveStream(DocumentFormat format, FileNameWithExtension fileName, Stream sourceStream) { var blobId = new BlobId(format, _counterService.GetNext(format)); return(InnerPersistOfBlob(blobId, fileName, sourceStream)); }
/// <summary> /// Combines 2 arguments and document type to valid file path /// </summary> /// <param name="directoryPath">target directory path</param> /// <param name="fileName">target file name</param> /// <param name="type">target document format</param> /// <returns>Combined file path</returns> public string Combine(string directoryPath, string fileName, DocumentFormat type) { string dotSeperator = fileName.EndsWith(".", StringComparison.InvariantCultureIgnoreCase) ? String.Empty : "."; return(System.IO.Path.Combine(directoryPath, fileName + dotSeperator + FileExtension(type))); }
private void SendToFaxGateway(string AFaxTelexInd, string AFaxTelexNumbers, string AConfirmLabel, byte[] AContractBody, DocumentFormat ADocFormat, string ARecipient, Int32 ATradeId, string ATradeSysTicket, Int32 ARqmtId, Int32 AConfirmId, bool ARtf, string AFromAddress, string ASubject, string AEmailBody, bool ACoverPage) { try { if (AFaxTelexNumbers != null) { string[] AFaxTelexNumbersList = AFaxTelexNumbers.Split(';'); foreach (string AFaxTelexNumber in AFaxTelexNumbersList) { if (AContractBody == null) { XtraMessageBox.Show("Confirm Data was not found. Send/Resend was cancelled.", "Confirm Not Found", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!InboundSettings.IsProductionSystem) { var destination = new TransmitDestination(AFaxTelexNumber); if (!destination.IsValidNonProdSendToAddress()) { XtraMessageBox.Show("Please enter a valid Non-Production EMail Address or Fax Number.", "Non-Production Address Verification", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } this.Cursor = Cursors.WaitCursor; string faxTelexNumber = AFaxTelexNumber; //5/21/09 Israel -- Create a new folder for each fax transmission. string folderName = ATradeId.ToString() + "_" + String.Format("{0:yyMMddHHmmss}", DateTime.Now); //string faxDir = tempFaxDir + folderName; string faxDir = Path.Combine(tempFaxDir, folderName); System.IO.Directory.CreateDirectory(faxDir); faxDir += "\\"; string xmlFileNameOnly = "request.xml"; string xmlFileNameWithPath = faxDir + xmlFileNameOnly; string rtfFileNameOnly = "Contract.rtf"; string rtfFileNameWithPath = faxDir + rtfFileNameOnly; string pdfDocFileNameOnly = "Contract.pdf"; string pdfDocFileNameWithPath = faxDir + pdfDocFileNameOnly; //Israel 9/3/2015 -- Replace PDFMetamorphosis with DevExpress RichEditControl //SaveRtfAsPdfDoc(rtfFileNameWithPath, pdfDocFileNameWithPath); WSUtils.SaveByteArrayAsPdfFile(AContractBody, ADocFormat, pdfDocFileNameWithPath); //1/28/2015 Israel - Replaced DB name with system setting //if (barStaticDBName.Caption.ToLower() != PROD_DB_NAME) //Israel 10/26/15 Removed TestFaxNumber //if (!Properties.Settings.Default.IsProductionSystem) // faxTelexNumber = Properties.Settings.Default.TestFaxNumber; //PDF isn't handling E. European languages properly so send them as rtf. string docFileName = pdfDocFileNameOnly; string bookingCoSn = GetTradeSummaryData(ATradeId, "BookingCoSn"); string cdtyCode = GetTradeSummaryData(ATradeId, "CdtyCode"); // bool isFreightDeal = (cdtyCode == "FRGHT"); string cptySn = GetTradeSummaryData(ATradeId, "CptySn"); //5/20/09 Israel - Handle RTF override parm if (ARtf) docFileName = rtfFileNameOnly; string docFileNameWithPath = faxDir + docFileName; TransmitDestinationType transDestType; if (AFaxTelexNumber.Contains("@")) transDestType = TransmitDestinationType.EMAIL; else transDestType = TransmitDestinationType.FAX; IXmitRequestDal xmitRequestDal = new XmitRequestDal(sqlConnectionStr); int xmitRequestId = xmitRequestDal.SaveTradeRqmtConfirmXmitRequest(AConfirmId, transDestType, AFaxTelexNumber, Utils.GetUserNameWithoutDomain(p_UserId)); string xmlText = GetFaxSubmitXML(ATradeId.ToString(),ATradeSysTicket, docFileName, AFaxTelexInd, AFaxTelexNumber, ARecipient, ARqmtId.ToString(), AConfirmId.ToString(), AConfirmLabel, ASubject, AEmailBody, ACoverPage, xmitRequestId.ToString()); System.IO.File.WriteAllText(xmlFileNameWithPath, xmlText); string emailToAddress = Properties.Settings.Default.TransmissionGatewayEmailToAddress; //string emailToAddress = "*****@*****.**"; //Israel 9/28/2015 //string emailFromAddress = toolbarOrWindowsUserId + "@" + Properties.Settings.Default.EMailDomain; //Israel 10/26/15 -- Removed FaxGatewayEmailFromAddress string emailFromAddress = ""; //Properties.Settings.Default.FaxGatewayEmailFromAddress; if (AFromAddress.Length > 2) emailFromAddress = AFromAddress; else emailFromAddress = emailToAddress; string emailSubject = "Confirmation of Trade: " + ATradeSysTicket; if (ASubject.Length > 2) emailSubject = ASubject; //Changed variable name for doc file. SendEmail(emailFromAddress, emailToAddress, emailSubject, AEmailBody, xmlFileNameWithPath, docFileNameWithPath); string faxDocRefCode = ""; string templateName = "**Template Name**"; //Log submission in case it becomes necessary to trace it //Israel 11/13/2015 -- Removed as part of move to XmitRequest/XmitResult //CallInsertToFaxLogSent(ATradeId, AFaxTelexInd, AFaxTelexNumber, faxDocRefCode); if (AConfirmLabel == CONFIRM_LABEL_CONFIRM && ARqmtId > 0) { string reference = GetTradeRqmtData(ARqmtId, "Reference"); string cmt = GetTradeRqmtData(ARqmtId, "Cmt"); CallUpdateTradeRqmts(ATradeId, ARqmtId, SEMPRA_RQMT, "SENT", DateTime.Today, reference, cmt, true); } else if (AConfirmId > 0) { string confirmCmt = GetConfirmData(AConfirmId, "ConfirmCmt"); UpdateTradeRqmtConfirmRow(AConfirmId, ATradeId, Convert.ToInt32(ARqmtId), templateName, AFaxTelexInd, AFaxTelexNumber, AConfirmLabel, confirmCmt, "SENT", "Y"); } string trdSysCode = GetTradeSummaryData(ATradeId, "TrdSysCode"); if (trdSysCode.Length > 0) { trdSysCode = trdSysCode.Substring(0, 1); //string cdtyGrpCode = GetTradeSummaryData(ATradeId, "CdtyGrpCode"); string sttlType = GetTradeSummaryData(ATradeId, "SttlType"); DateTime dtTradeDt = GetTradeSummaryDate(ATradeId, "TradeDt"); string strTradeDt = dtTradeDt.ToString("MM/dd/yyyy"); string strToday = DateTime.Today.ToString("MM/dd/yyyy"); } } } } catch (Exception ex) { throw new Exception("An error occurred while attempting to send a document to the Transmission Gateway using the following values:" + Environment.NewLine + "Transmission Method: " + AFaxTelexInd + ", Transmission Send-To Address: " + AFaxTelexNumbers + ", Document Format: " + ADocFormat.ToString() + ", Recipient: " + ARecipient + Environment.NewLine + "Trade Id: " + ATradeId.ToString() + "Rqmt Id: " + ARqmtId.ToString() + "Confirm Id: " + AConfirmId.ToString() + ", IsRtf?: " + ARtf + Environment.NewLine + "From Address: " + AFromAddress + ", Subject: " + ASubject + ", EMail Body: " + AEmailBody + ", IncludeCoverPage?: " + ACoverPage + Environment.NewLine + "Error CNF-145 in " + FORM_NAME + ".SendToFaxGateway([14 parms]): " + ex.Message); } finally { this.Cursor = Cursors.Default; } }
protected internal override void ConvertInternal(Stream inputStream, DocumentFormat inputFormat, Stream outputStream, DocumentFormat outputFormat) { IDictionary exportOptions = outputFormat.GetExportOptions(inputFormat.Family); try { lock (OpenOfficeConnection) { LoadAndExport(inputStream, inputFormat.ImportOptions, outputStream, exportOptions); } } catch (OpenOfficeException) { throw; } catch (Exception throwable) { throw new OpenOfficeException("conversion failed", throwable); } }
/// <summary> /// Whether this part is available in a specific version of Office Application. /// </summary> /// <param name="version">The Office file format version.</param> /// <returns>Returns true if the part is defined in the specified version.</returns> internal override bool IsInVersion(DocumentFormat.OpenXml.FileFormatVersions version) { if(version == FileFormatVersions.Office2013) { return true; } return false; }
protected override Stream GetPreviewImagesDocumentStream(Content content, IEnumerable <SNCR.Image> previewImages, DocumentFormat documentFormat, RestrictionType?restrictionType = null) { if (documentFormat == DocumentFormat.NonDefined) { documentFormat = GetFormatByName(content.Name); } // Unfortunately we need to create a new memory stream here // instead of writing into the output stream directly, because // Aspose needs to Seek the stream during document creation, // which is not supported by the Http Response output stream. switch (documentFormat) { case DocumentFormat.Doc: case DocumentFormat.Docx: return(GetPreviewImagesWordStream(content, previewImages, restrictionType)); case DocumentFormat.NonDefined: case DocumentFormat.Pdf: return(GetPreviewImagesPdfStream(content, previewImages, restrictionType)); case DocumentFormat.Ppt: case DocumentFormat.Pptx: return(GetPreviewImagesPowerPointStream(content, previewImages, restrictionType)); case DocumentFormat.Xls: case DocumentFormat.Xlsx: return(GetPreviewImagesExcelStream(content, previewImages, restrictionType)); } return(null); }
public DocumentFormatItem(DocumentFormat f, string n) { Format = f; _name = n; }
/// <summary> /// Add all Cobol files contained in a local directory, filtered by a set of extensions, to the default text library /// </summary> /// <param name="rootPath">Local directory containing all the Cobol files of this library</param> /// <param name="includeSubdirectories">Does this library also includes the files contained in all the subdirectories found below the root path ?</param> /// <param name="fileExtensions">File extensions which should be optionnaly appended to the text name to find corresponding Cobol files (for example : { ".cbl",".cpy" })</param> /// <param name="documentFormat">For of the document (RDZ, FreeFormat)</param> public LocalDirectoryLibrary AddLocalDirectoryLibrary(string rootPath, bool includeSubdirectories, string[] fileExtensions, [NotNull] DocumentFormat documentFormat) { return(AddLocalDirectoryLibrary(DEFAULT_LIBRARY_NAME, rootPath, includeSubdirectories, fileExtensions, documentFormat.Encoding, documentFormat.EndOfLineDelimiter, documentFormat.FixedLineLength)); }