Пример #1
0
 /// <summary>
 /// Analiza las versiones antiguas de un documento OpenOffice
 /// </summary>
 /// <param name="stm">Stream que contiene el fichero VersionList.xml</param>
 /// <param name="zip">Fichero zip que contiene las versiones antiguas embebidas</param>
 private void AnalizeFileVersionList(Stream stm, ZipFile zip)
 {
     try
     {
         XmlDocument doc = new XmlDocument();
         doc.XmlResolver = null;
         doc.Load(stm);
         XmlNodeList xml = doc.GetElementsByTagName("VL:version-entry");
         if (xml != null && xml.Count != 0)
         {
             foreach (XmlNode xn in xml)
             {
                 OldVersion vai = new OldVersion(xn.Attributes["VL:title"].Value, xn.Attributes["VL:creator"].Value, xn.Attributes["VL:comment"].Value);
                 //Añadimos el usuario de la versión antigua a los usuarios del documento
                 this.foundMetadata.Add(new User(vai.Author, false, "VL:creator"));
                 DateTime d;
                 if (DateTime.TryParse(xn.Attributes["dc:date-time"].Value.Replace('T', ' '), out d))
                 {
                     vai.Date = d;
                 }
                 String strFile = "Versions/" + xn.Attributes["VL:title"].Value;
                 if (zip.EntryFileNames.Contains(strFile))
                 {
                     using (Stream stmXML = new MemoryStream())
                     {
                         zip.Extract(strFile, stmXML);
                         stmXML.Seek(0, SeekOrigin.Begin);
                         using (OpenOfficeDocument ooDoc = new OpenOfficeDocument(stmXML, strExtlo))
                         {
                             vai.Metadata = ooDoc.AnalyzeFile();
                         }
                     }
                 }
                 this.foundMetadata.Add(vai);
             }
         }
     }
     catch (Exception e)
     {
         System.Diagnostics.Debug.WriteLine(String.Format("Error reading file content.xml ({0}).", e.ToString()));
     }
 }
Пример #2
0
        public static DocumentExtractor Create(string extension, Stream file)
        {
            if (file == null)
            {
                throw new ArgumentNullException(nameof(file));
            }
            string normalizedExtension = NormalizeExtension(extension);

            if (IsSupportedExtension(normalizedExtension))
            {
                DocumentExtractor document = null;
                switch (normalizedExtension)
                {
                case ".sxw":
                case ".odt":
                case ".ods":
                case ".odg":
                case ".odp":
                    document = new OpenOfficeDocument(file, extension);
                    break;

                case ".docx":
                case ".xlsx":
                case ".pptx":
                case ".ppsx":
                    document = new OfficeOpenXMLDocument(file, extension);
                    break;

                case ".doc":
                case ".xls":
                case ".ppt":
                case ".pps":
                    document = new Office972003(file);
                    break;

                case ".pdf":
                    document = new PDFDocument(file);
                    break;

                case ".wpd":
                    document = new WPDDocument(file);
                    break;

                case ".raw":
                case ".cr2":
                case ".crw":
                case ".jpg":
                case ".jpeg":
                    document = new EXIFDocument(file, extension);
                    break;

                case ".svg":
                case ".svgz":
                    document = new SVGDocument(file);
                    break;

                case ".indd":
                    document = new InDDDocument(file);
                    break;

                case ".rdp":
                    document = new RDPDocument(file);
                    break;

                case ".ica":
                    document = new ICADocument(file);
                    break;

                default:
                    throw new ArgumentException("Extension not supported", nameof(extension));
                }
                return(document);
            }
            else
            {
                throw new ArgumentException("Extension not supported", nameof(extension));
            }
        }