private VBBaseModule CreateModule(SourceFileTypeEnum fileType, VisualBasic6Parser.ModuleContext context) { VBBaseModule result; switch (fileType) { case SourceFileTypeEnum.Unknown: throw new Exception("Unknown VB6 file type."); case SourceFileTypeEnum.Class: result = new VBClassModule(_vb6Lexer, _vb6Parser, _commonTokenStream, context); break; case SourceFileTypeEnum.Module: result = new VBStandardModule(_vb6Lexer, _vb6Parser, _commonTokenStream, context); break; case SourceFileTypeEnum.UserControl: throw new NotImplementedException("UserControl"); //break; case SourceFileTypeEnum.Form: throw new NotImplementedException("Form"); //break; case SourceFileTypeEnum.PropertyPage: throw new NotImplementedException("PropertyPage"); //break; default: throw new Exception("Unsupported VB6 file type."); } return(result); }
public VB6ModuleCodeModelFactory(SourceFileTypeEnum fileType, VisualBasic6Lexer vb6Lexer, VisualBasic6Parser vb6Parser, CommonTokenStream commonTokenStream) { _fileType = fileType; _vb6Lexer = vb6Lexer; _vb6Parser = vb6Parser; _commonTokenStream = commonTokenStream; }
private SourceFileTypeEnum getValueOfType(string str) { // set default value SourceFileTypeEnum key = SourceFileTypeEnum.Unrecognized; // search for matches foreach (var p in primary_patterns) { if (System.Text.RegularExpressions.Regex.Matches(str, p.Value).Count > 0) { key = p.Key; } if (key == SourceFileTypeEnum.Motion) { break; } } // search for foldout in brief (probably can wrap into Regex in future) if (key != SourceFileTypeEnum.Unrecognized) { if (str.Contains("br")) { if (key == SourceFileTypeEnum.App_Foldout) { key = SourceFileTypeEnum.Brief_Foldout; } else if (key == SourceFileTypeEnum.App_ZFold) { key = SourceFileTypeEnum.Brief_ZFold; } } } return(key); }
// SECONDARY METHOD: // USED FOR COMBINED PDF public CockleFilePdf(string filename, string atty, int?ticket, SourceFileTypeEnum file_type, string file_type_code, int?len_cover) { this.FullName = filename; this.TicketNumber = ticket; this.Attorney = atty; this.FileType = file_type; this.FileTypeCode = file_type_code; this.Version = null; // set cover length if (this.FileType == SourceFileTypeEnum.Cover) { this.CoverLength = len_cover; } else { this.CoverLength = null; } // get page ranges PageRange = new PageRangePdf(this.FullName, this.FileType); // initialize properties that need more info this.Rank = -1; this.NeedsBlankPage = false; }
// SECONDARY METHOD: // USED FOR FILES CAPTURED FROM CAMERA READY, DOCS READY TO PRINT, ETC public CockleFilePdf(string filename, SourceFileTypeEnum type = SourceFileTypeEnum.Unrecognized) { this.FullName = filename; this.FileType = type; this.FileTypeCode = ""; parseFileNameCollectedFromScratch(); //this.FileType = type; // incomplete here: use for files straight for current of camera ready }
public CockleFilePdf(string fileName, CockleFilePdf originalCockleFilePdf, SourceFileTypeEnum type) { this.FullName = fileName; this.Attorney = originalCockleFilePdf.Attorney; this.CoverLength = originalCockleFilePdf.CoverLength; this.FileType = type; this.FileTypeCode = originalCockleFilePdf.FileTypeCode; this.PageRange = originalCockleFilePdf.PageRange; this.Rank = originalCockleFilePdf.Rank; this.TicketNumber = originalCockleFilePdf.TicketNumber; this.Version = originalCockleFilePdf.Version; }
public PageRangePdf(string src, SourceFileTypeEnum type) { this.FirstPage = -1; this.LastPage = -1; this.Rotation = ROTATE_ENUM.NONE; if (type == SourceFileTypeEnum.Cover || type == SourceFileTypeEnum.InsideCv) { using (PdfReader reader = new PdfReader(src)) { this.TotalPages = reader.NumberOfPages; if (this.TotalPages == 1) { this.FirstPage = 1; this.LastPage = 1; } else if (this.TotalPages > 1) { this.FirstPage = 1; this.LastPage = this.TotalPages; } else { this.TotalPages = -1; } } } else if (type == SourceFileTypeEnum.Combined_Pdf || type == SourceFileTypeEnum.Combined_Pdf_No_FOs) { using (PdfReader reader = new PdfReader(src)) { TotalPages = reader.NumberOfPages; FirstPage = null; LastPage = null; } } else { using (PdfReader reader = new PdfReader(src)) { this.TotalPages = reader.NumberOfPages; this.Pages = new int[this.TotalPages + 1]; PdfReaderContentParser parser = new PdfReaderContentParser(reader); for (int i = 1; i <= reader.NumberOfPages; i++) { SimpleTextExtractionStrategy extract = new SimpleTextExtractionStrategy(); var extractedText = parser.ProcessContent(i, extract); string textFromPage = extractedText.GetResultantText(); // here, check for blank page: means it's a divider page if (System.Text.RegularExpressions.Regex.Matches(textFromPage, @"\S").Count == 0) { this.Pages[i] = -2; // -2 indicates blank page } else { int posNewLine = textFromPage.IndexOf('\n'); string strPageNum = ""; string firstLine = ""; int j = 0; while (strPageNum.Equals("") && Pages[i] == 0) { // test for classic page number if (j == 0) { firstLine = textFromPage.Substring(0, posNewLine); strPageNum = new String(firstLine.Where(Char.IsDigit).ToArray()); } // test for roman numeral else if (j == 1) { firstLine = textFromPage.Substring(0, posNewLine); char[] removeNewlineAndSpace = firstLine.Replace(" ", "").Replace("\n", "").ToArray(); int n = Roman_Parse(removeNewlineAndSpace); if (n != 0) { Pages[i] = n; } } // search for App. on page else if (j == 2) { var matches = System.Text.RegularExpressions.Regex.Matches(textFromPage, @"(App.?)( *)(\d+)"); if (matches.Count > 0) { strPageNum = matches[0].Groups[3].Value; } } // test alternative foldout numbering style else if (j == 3) { var matches = System.Text.RegularExpressions.Regex.Matches(textFromPage, @"(\d+)([Aa])"); if (matches.Count > 0) { strPageNum = matches[0].Groups[1].Value; } } else if (j == 4) { if (type == SourceFileTypeEnum.App_Foldout || type == SourceFileTypeEnum.App_ZFold || type == SourceFileTypeEnum.Brief_Foldout || type == SourceFileTypeEnum.Brief_ZFold) { while (!textFromPage.Equals("") && !Char.IsDigit(textFromPage[0])) { textFromPage = textFromPage.Substring(1, textFromPage.Length - 1); } string digits = String.Empty; int k = 0; while (!textFromPage.Equals("") && Char.IsDigit(textFromPage[k])) { digits = digits + textFromPage[k++]; } strPageNum = new String(digits.Where(Char.IsDigit).ToArray()); } } else { break; } j++; } // end while if (Pages[i] == 0) { int intPageNum; if (int.TryParse(strPageNum, out intPageNum)) { Pages[i] = intPageNum; } } // end parse number // GET LOCATION OF FIRST LINE FOR FOLDOUTS // THIS WILL GIVE US ROTATION THAT IS NEEDED TO GET PAGE NUMBER ON TOP if (type == SourceFileTypeEnum.App_Foldout || type == SourceFileTypeEnum.App_ZFold || type == SourceFileTypeEnum.Brief_Foldout || type == SourceFileTypeEnum.Brief_ZFold) { // attempt to get location, if foldout, of number found MyLocationTextExtractionStrategy extract_loc = new MyLocationTextExtractionStrategy(); var extractedText_loc = parser.ProcessContent(i, extract_loc); string textFromPage_loc = extractedText_loc.GetResultantText(); var ex = PdfTextExtractor.GetTextFromPage(reader, 1, extract_loc); float llx = float.NaN; float urx = float.NaN; float ury = float.NaN; float lly = float.NaN; foreach (var p in extract_loc.myPoints) { var a = p.Text; if (this.Pages[i] > 0 && a.Contains(this.Pages[i].ToString())) { llx = p.Rect.Left; lly = p.Rect.Bottom; ury = p.Rect.Top; urx = p.Rect.Right; } } // get page dimensions var page_size = reader.GetPageSize(i); var page_width = page_size.Width; var page_height = page_size.Height; // find which side if (page_height > page_width) { float mid_point = page_width / 2; if (llx < mid_point && lly < mid_point && urx < mid_point && ury < mid_point) { this.Rotation = ROTATE_ENUM.CLOCKWISE; } else if (llx > mid_point && lly > mid_point && urx > mid_point && ury > mid_point) { this.Rotation = ROTATE_ENUM.COUNTERCLOCKWISE; } else { // do nothing this.Rotation = ROTATE_ENUM.NONE; } } } } // end else } // end for loop for reader // CAPTURE FIRST AND LAST PAGE NUMBER // capture first page number (base 1) this.FirstPage = Pages[1]; // capture first page for files with first page number blank if (this.Pages[1] == 0) { // check second page if (this.TotalPages > 1 && this.Pages[2] > 0) { this.Pages[1] = this.Pages[2] - 1; } } // skip actual first page, if a divider page if (this.Pages[1] == -2 && this.TotalPages > 1 && this.Pages[2] > 0) { this.FirstPage = this.Pages[2]; } else { this.FirstPage = this.Pages[1]; } this.LastPage = Pages[TotalPages]; } // end using statement } }