Beispiel #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 xnl = doc.GetElementsByTagName("VL:version-entry");
         if (xnl != null && xnl.Count != 0)
         {
             foreach (XmlNode xn in xnl)
             {
                 OldVersionsItem vai = new OldVersionsItem();
                 vai.Comments = xn.Attributes["VL:comment"].Value;
                 vai.Author   = xn.Attributes["VL:creator"].Value;
                 //Añadimos el usuario de la versión antigua a los usuarios del documento
                 FoundUsers.AddUniqueItem(vai.Author, false, "VL:creator");
                 DateTime d;
                 if (DateTime.TryParse(xn.Attributes["dc:date-time"].Value.Replace('T', ' '), out d))
                 {
                     vai.SpecificDate = true;
                     vai.Date         = d;
                 }
                 String strFile = "Versions/" + xn.Attributes["VL:title"].Value;
                 if (zip.EntryFileNames.Contains(strFile))
                 {
                     //Se analiza la versión antigua embebida al completo
                     using (Stream stmXML = new MemoryStream())
                     {
                         zip.Extract(strFile, stmXML);
                         stmXML.Seek(0, SeekOrigin.Begin);
                         OpenOfficeDocument ooDoc = new OpenOfficeDocument(stmXML, strExtlo);
                         ooDoc.analyzeFile();
                         dicOldVersions.Add(xn.Attributes["VL:title"].Value, ooDoc);
                         ooDoc.Close();
                     }
                 }
                 FoundOldVersions.Items.Add(vai);
             }
         }
     }
     catch (Exception e)
     {
         System.Diagnostics.Debug.WriteLine(String.Format("Error reading file content.xml ({0}).", e.ToString()));
     }
 }
Beispiel #2
0
        public static MetaExtractor Create(string extension, Stream file)
        {
            if (String.IsNullOrWhiteSpace(extension))
            {
                throw new ArgumentNullException(nameof(extension));
            }

            if (file == null)
            {
                throw new ArgumentNullException(nameof(file));
            }

            MetaExtractor document = null;

            switch (extension.ToLowerInvariant().Trim())
            {
            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 allowed", nameof(extension));
            }
            return(document);
        }
Beispiel #3
0
        public static MetaExtractor Create(string extension, Stream file)
        {
            if (file == null)
            {
                throw new ArgumentNullException(nameof(file));
            }

            string normalizedExtension = NormalizeExtension(extension);

            if (IsSupportedExtension(normalizedExtension))
            {
                MetaExtractor 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));
            }
        }