コード例 #1
0
ファイル: ModelFolder.cs プロジェクト: dmitrynogin/insight
 public ModelFolder(IFolder folder, CsvReaderFactory csvReader, ZipFactory zip, SvmFactory svm)
 {
     Folder    = folder;
     CsvReader = csvReader;
     Zip       = zip;
     Svm       = svm;
 }
コード例 #2
0
        public static byte[] Pack(byte[] datas, IList <byte[]> serverKeys, bool seedCreated)
        {
            seedCreated = false;

            //先压缩 在加密
            var compress = true ? ZipFactory.GetZip().Compress(datas) : datas;

            var d = seedCreated ? CryptoFactory.GetCrypto(1).Encode(compress, serverKeys[0]) : compress;

            var cryptoByte = new byte[1];

            cryptoByte[0] = seedCreated ? (byte)128 : (byte)0;

            var zipByte = new byte[1];

            zipByte[0] = true ? (byte)128 : (byte)0;

            using (var stream = new MemoryStream())
            {
                stream.Write(BitConverter.GetBytes(d.Length + 6), 0, 4);
                stream.Write(zipByte, 0, 1);
                stream.Write(cryptoByte, 0, 1);
                stream.Write(d, 0, d.Length);

                return(stream.ToArray());
            }
        }
コード例 #3
0
 public void CreateInstanceWithoutZipSettings()
 {
     //arrange
     //act
     //assert
     IZipFactory zipFactory = new ZipFactory(null);
 }
コード例 #4
0
        public void Open(string fileName)
        {
            if (_zipOutputStream != null || _delegateWriter != null)
            {
                this.Close();
            }

            _zipOutputStream = ZipFactory.CreateArchive(fileName);
        }
コード例 #5
0
        /// <summary>
        ///  main transform which needs the orginal File
        /// </summary>
        /// <param name="directionXSL">transform direction</param>
        /// <param name="resourceResolver">xsl location</param>
        /// <param name="originalFile">original File</param>
        /// <param name="inputFile">File after pretreatment</param>
        /// <param name="outputFile">output file</param>
        protected void MainTransform(string directionXSL, XmlUrlResolver resourceResolver, string originalFile, string inputFile, string outputFile)
        {
            XPathDocument     xslDoc;
            XmlReaderSettings xrs            = new XmlReaderSettings();
            XmlReader         source         = null;
            XmlWriter         writer         = null;
            OoxZipResolver    zipResolver    = null;
            string            zipXMLFileName = "input.xml";

            try
            {
                //xrs.ProhibitDtd = true;

                xslDoc          = new XPathDocument(((ResourceResolver)resourceResolver).GetInnerStream(directionXSL));
                xrs.XmlResolver = resourceResolver;
                string    sr      = ZipXMLFile(inputFile);
                ZipReader archive = ZipFactory.OpenArchive(sr);
                source = XmlReader.Create(archive.GetEntry(zipXMLFileName));

                XslCompiledTransform xslt     = new XslCompiledTransform();
                XsltSettings         settings = new XsltSettings(true, false);
                xslt.Load(xslDoc, settings, resourceResolver);

                if (!originalFile.Equals(string.Empty))
                {
                    zipResolver = new OoxZipResolver(originalFile, resourceResolver);
                }
                XsltArgumentList parameters = new XsltArgumentList();
                parameters.XsltMessageEncountered += new XsltMessageEncounteredEventHandler(MessageCallBack);

                // zip format
                parameters.AddParam("outputFile", "", outputFile);
                // writer = new OoxZipWriter(inputFile);
                writer = new UofZipWriter(outputFile);

                if (zipResolver != null)
                {
                    xslt.Transform(source, parameters, writer, zipResolver);
                }
                else
                {
                    xslt.Transform(source, parameters, writer);
                }
            }
            finally
            {
                if (writer != null)
                {
                    writer.Close();
                }
                if (source != null)
                {
                    source.Close();
                }
            }
        }
コード例 #6
0
        public void GetZipInstance()
        {
            //arrange
            IZipFactory zipFactory = new ZipFactory(new ZipSettings {
                Password = string.Empty
            });
            //act
            ICompressor instance = zipFactory.Get();

            //assert
            Assert.AreEqual(typeof(Zip), instance.GetType());
        }
コード例 #7
0
        public void GetZipPasswordProtectedInstance()
        {
            //arrange
            IZipFactory zipFactory = new ZipFactory(new ZipSettings {
                Password = "******"
            });
            //act
            ICompressor instance = zipFactory.Get();

            //assert
            Assert.AreEqual(typeof(PasswordProtectedZip), instance.GetType());
        }
コード例 #8
0
        private static Entity CreateZippedEntity(Directory directory, string path)
        {
            var zippedDir = directory as ZippedFolder;

            if (zippedDir.Zip.IsFile(path))
            {
                if (File.IsArchive(path))
                {
                    return(ZipFactory.GetZippedFolder(path, DirectoryType.Zipped, zippedDir));
                }
                return(new ZippedFile(zippedDir.Zip, zippedDir.GetEntry(path)));
            }

            return(new ZippedFolder(zippedDir.Zip, path, directory));
        }
コード例 #9
0
        public XmlContainer(BinaryReader _reader, uint size, uint typeCode, uint version, uint instance)
            : base(_reader, size, typeCode, version, instance)
        {
            // Note: XmlContainers contain the data of a partial "unfinished"
            // OOXML file (.zip based) as their body.
            //
            // I really don't like writing the data to a temp file just to
            // be able to open it via ZipUtils.
            //
            // Possible alternatives:
            // 1) Using System.IO.Compression -- supports inflation, but can't parse Zip header data
            // 2) Modifying zlib + minizlib + ZipLib so I can pass in bytes, possible, but not worth the effort

            string tempPath = Path.GetTempFileName();

            try
            {
                using (FileStream fs = new FileStream(tempPath, FileMode.Create))
                {
                    using (BinaryWriter tempStream = new BinaryWriter(fs))
                    {
                        int    count = (int)this.Reader.BaseStream.Length;
                        byte[] bytes = this.Reader.ReadBytes(count);

                        tempStream.Write(bytes);

                        tempStream.Flush();
                        fs.Flush();

                        tempStream.Close();
                        fs.Close();
                    }
                }

                using (ZipReader zipReader = ZipFactory.OpenArchive(tempPath))
                {
                    this.XmlDocumentElement = ExtractDocumentElement(zipReader, GetRelations(zipReader, ""));
                }
            }
            finally
            {
                try
                {
                    File.Delete(tempPath);
                }
                catch (IOException) { /* OK */ }
            }
        }
コード例 #10
0
        private void GetSearchbleFromFolder(string sourcePath)
        {
            var filesPath = Entries.Directory.GetAllFiles(sourcePath);

            foreach (var fPath in filesPath)
            {
                if (Entries.File.IsArchive(fPath))
                {
                    _listOfPath.AddRange(ZipFactory.GetZipEntries(fPath));
                }
                else
                {
                    _listOfPath.Add(new Entries.File(fPath));
                }
            }
        }
コード例 #11
0
ファイル: XmlContainer.cs プロジェクト: ztahlis/b2xtranslator
        public XmlContainer(BinaryReader _reader, uint size, uint typeCode, uint version, uint instance)
            : base(_reader, size, typeCode, version, instance)
        {
            // Note: XmlContainers contain the data of a partial "unfinished" OOXML file (.zip based) as their body.
            //
            // I really don't like writing the data to a temp file just to be able to open it via ZipUtils.
            //
            // Possible alternatives:
            // 1) Using System.IO.Compression -- supports inflation, but can't parse Zip header data
            // 2) Modifying zlib + minizlib + ZipLib so I can pass in bytes, possible, but not worth the effort

            // KH - I've left the original comment above, but I've ported this to use option (1) as the IZipLib result can't read headers anyway - it can only open entries.

            using (var zipReader = ZipFactory.OpenArchive(this.Reader.BaseStream))
                this.XmlDocumentElement = ExtractDocumentElement(zipReader, GetRelations(zipReader, ""));
        }
コード例 #12
0
        private static Entity CreateFileSystemEntity(Directory directory, string path)
        {
            if (System.IO.Directory.Exists(path))
            {
                return(new Folder(path));
            }

            if (System.IO.File.Exists(path))
            {
                if (File.IsArchive(path))
                {
                    return(ZipFactory.GetZippedFolder(path, DirectoryType.System, directory));
                }
                return(new File(path));
            }
            throw new ArgumentException("This entity is superfluous.");
        }
コード例 #13
0
        public static byte[] Unpack(byte[] datas, IList <byte[]> clientKeys)
        {
            byte[] dataBytes = null;
            var    zipBit    = new byte[1];
            var    cryptoBit = new byte[1];

            using (var stream = new MemoryStream(datas))
            {
                var lenBytes = new byte[4];

                stream.Read(lenBytes, 0, 4);
                stream.Read(zipBit, 0, 1);
                stream.Read(cryptoBit, 0, 1);

                var len = BitConverter.ToInt32(lenBytes, 0) - 6;
                dataBytes = new byte[len];
                stream.Read(dataBytes, 0, len);
            }

            for (var i = 0; i < 8; i++)
            {
                var v = Utils.GetbitValue(cryptoBit[0], i);
                if (v == 1)
                {
                    dataBytes = CryptoFactory.GetCrypto((byte)(7 - i)).Decode(dataBytes, clientKeys[7 - i]);
                }
            }

            if (true)
            {
                for (int i = 0; i < 8; i++)
                {
                    var v = Utils.GetbitValue(zipBit[0], i);
                    if (v == 1)
                    {
                        dataBytes = ZipFactory.GetZip().Decompress(dataBytes);
                    }
                }
            }
            return(dataBytes);
        }
コード例 #14
0
        private void DoUofToOoxTransform(string inputFile, string outputFile, string resourceDir)
        {
            guid = Guid.NewGuid();
            if (!IsUof(inputFile))
            {
                throw new NotAnUofDocumentException(inputFile + " 不是UOF文件");
            }

            LinkedList <IProcessor> .Enumerator enumer = uof2ooxPreProcessors.GetEnumerator();
            string outputPath = Path.GetTempPath().ToString() + guid.ToString();
            string output     = outputPath + Path.DirectorySeparatorChar + "tmpDoc";

            if (!Directory.Exists(outputPath))
            {
                Directory.CreateDirectory(outputPath);
            }
            //  string input = EIPicturePre(inputFile, outputPath);

            ZipReader archive = ZipFactory.OpenArchive(inputFile);

            archive.ExtractUOFDocument(inputFile, outputPath);

            string input = inputFile;

            int i = 0;

            while (enumer.MoveNext())
            {
                i++;
                enumer.Current.OriginalFilename = inputFile;
                enumer.Current.InputFilename    = input;
                enumer.Current.OutputFilename   = output + i + ".xml";
                enumer.Current.transform();
                input = enumer.Current.OutputFilename;
            }

            DoUofToOoxMainTransform(enumer.Current.OutputFilename, outputFile, resourceDir);
            //  Directory.Delete(outputPath, true);
        }
コード例 #15
0
        //[Test]
        public void IntegrationTest()
        {
            const string templatePath            = @"..\..\Test Templates\Modeled Basic Template.odt";
            const string reportPath              = @"..\..\Generated Reports\Very Basic Report.odt";
            const string expectedReportPath      = @"..\..\Expected Report Outputs\Very Basic Report.odt";
            var          templateFactory         = new TemplateFactory();
            var          zipFactory              = new ZipFactory();
            var          readerFactory           = new StreamReaderWrapperFactory();
            var          zipHandlerService       = new ZipHandlerService(readerFactory);
            var          buildOdfMetadataService = new BuildOdfMetadataService();
            var          xmlNamespaceService     = new XmlNamespaceService();
            var          xDocumentParserService  = new XDocumentParserService();
            var          odfHandlerService       = new OdfHandlerService(zipFactory, zipHandlerService, buildOdfMetadataService,
                                                                         xmlNamespaceService, xDocumentParserService);

            var templateService = new TemplateBuilderService(templateFactory, odfHandlerService,
                                                             xmlNamespaceService, xDocumentParserService);
            var document = File.ReadAllBytes(templatePath);

            var template             = templateService.BuildTemplate(document);
            var razorTemplateService = new TemplateService();
            var compileService       = new CompileService(razorTemplateService);

            compileService.Compile(template, "Template 1");

            var reportService = new ReportGeneratorService(new ZipFactory(), razorTemplateService);

            using (var report = new FileStream(reportPath, FileMode.Create))
            {
                reportService.BuildReport(template, new BasicModel {
                    Name = "Fancypants McSnooterson"
                }, report);
            }
            var diffs = GetDifferences(expectedReportPath, reportPath);
            var thereAreDifferences = diffs.HasDifferences();

            Assert.That(!thereAreDifferences);
        }
コード例 #16
0
        public override bool transform()
        {
            FileStream    fs          = null;
            XmlTextReader txtReader   = null;
            string        extractPath = Path.GetDirectoryName(outputFile) + "\\";
            ZipReader     archive     = ZipFactory.OpenArchive(inputFile);

            archive.ExtractOfficeDocument(inputFile, extractPath);
            string   prefix = this.GetType().Namespace + "." + TranslatorConstants.RESOURCE_LOCATION + ".Powerpoint.oox2uof";//路径
            Assembly asm    = Assembly.GetExecutingAssembly();

            foreach (string name in asm.GetManifestResourceNames())
            {
                if (name.StartsWith(prefix))
                {
                    string     filename   = name.Substring(prefix.Length + 1);
                    FileStream writer     = new FileStream(extractPath + filename, FileMode.Create);
                    Stream     baseStream = asm.GetManifestResourceStream(name);
                    int        Length     = 10240;
                    Byte[]     buffer     = new Byte[Length];
                    int        bytesRead  = baseStream.Read(buffer, 0, Length);
                    while (bytesRead > 0)
                    {
                        writer.Write(buffer, 0, bytesRead);
                        bytesRead = baseStream.Read(buffer, 0, Length);
                    }
                    baseStream.Close();
                    writer.Close();
                }
            }
            bool isSuccess = true;

            try
            {
                // add theme rels
                AddThemeRels(extractPath);

                File.Copy(extractPath + "pre1.xsl", extractPath + @"\ppt\pre1.xsl", true);
                XPathDocument        doc       = new XPathDocument(extractPath + @"\ppt\presentation.xml");
                XslCompiledTransform transFrom = new XslCompiledTransform();
                XsltSettings         setting   = new XsltSettings(true, false);
                XmlUrlResolver       xur       = new XmlUrlResolver();
                transFrom.Load(extractPath + @"\ppt\pre1.xsl", setting, xur);
                XPathNavigator nav = ((IXPathNavigable)doc).CreateNavigator();
                fs = new FileStream(extractPath + "pre1tmp.xml", FileMode.Create);
                transFrom.Transform(nav, null, fs);
                fs.Close();
                doc = new XPathDocument(extractPath + "pre1tmp.xml");
                nav = ((IXPathNavigable)doc).CreateNavigator();
                fs  = new FileStream(extractPath + "pre2tmp.xml", FileMode.Create);
                Assembly ass = Assembly.Load("ppt_oox2uof");//使用预编译后的xslt
                Type     t   = ass.GetType("pre2");
                transFrom.Load(t);

                transFrom.Transform(nav, null, fs);
                fs.Close();
                xmlDoc    = new XmlDocument();
                txtReader = new XmlTextReader(extractPath + "pre2tmp.xml");
                xmlDoc.Load(txtReader);
                txtReader.Close();
                setNSManager();            //
                string currentPath = "//p:sp";
                purifyMethod(currentPath); //

                //2011-01-12罗文甜:阴影预处理
                XmlNodeList shapeShadeList = xmlDoc.SelectNodes("//a:outerShdw", nm);
                if (shapeShadeList != null)
                {
                    foreach (XmlNode shapeShade in shapeShadeList)
                    {
                        double dist, dir;
                        if (((XmlElement)shapeShade).HasAttribute("dist"))
                        {
                            dist = Convert.ToDouble(shapeShade.Attributes.GetNamedItem("dist").Value) / 12700;
                        }
                        else
                        {
                            dist = 0.0;
                        }
                        if (((XmlElement)shapeShade).HasAttribute("dir"))
                        {
                            dir = (Convert.ToDouble(shapeShade.Attributes.GetNamedItem("dir").Value) * 3.1415) / (180 * 60000);
                        }
                        else
                        {
                            dir = 0.0;
                        }
                        double     xValue = dist * Math.Cos(dir);
                        double     yValue = dist * Math.Sin(dir);
                        XmlElement x      = xmlDoc.CreateElement("x");
                        x.InnerText = Convert.ToString(xValue);
                        shapeShade.AppendChild(x);
                        XmlElement y = xmlDoc.CreateElement("y");
                        y.InnerText = Convert.ToString(yValue);
                        shapeShade.AppendChild(y);
                    }
                }
                resultWriter = new XmlTextWriter(outputFile, System.Text.Encoding.UTF8);
                xmlDoc.Save(resultWriter);
                resultWriter.Close();

                string tmpFile = extractPath + "tmpID.xml";
                ChangeIDVal(outputFile, tmpFile);//
            }
            catch (Exception e)
            {
                logger.Error("Fail in OoxToUofPreProcessorOnePresentation: " + e.Message);
                logger.Error(e.StackTrace);
                isSuccess = false;
                throw new Exception("Fail in OoxToUofPreProcessorOnePresentation");
            }
            finally
            {
                if (resultWriter != null)
                {
                    resultWriter.Close();
                }
                if (fs != null)
                {
                    fs.Close();
                }
                if (txtReader != null)
                {
                    txtReader.Close();
                }
            }

            return(isSuccess);
        }
コード例 #17
0
        /// <summary>
        /// Check the validity of an Office Open XML file.
        /// </summary>
        /// <param name="fileName">The path of the docx file.</param>
        public void validate(string fileName)
        {
            // 0. The file must exist and be a valid Zip archive
            ZipReader reader = null;

            try
            {
                reader = ZipFactory.OpenArchive(fileName);
            }
            catch (Exception e)
            {
                throw new ValidationException("Problem opening the docx file : " + e.Message);
            }

            // 1. [Content_Types].xml must be present and valid
            Stream contentTypes = null;

            try
            {
                contentTypes = reader.GetEntry(OOX_CONTENT_TYPE_FILE);
            }
            catch (Exception)
            {
                throw new ValidationException("The docx package must have a \"/[Content_Types].xml\" file");
            }
            this.validateXml(contentTypes);

            // 2. _rels/.rels must be present and valid
            Stream relationShips = null;

            try
            {
                relationShips = reader.GetEntry(OOX_RELATIONSHIP_FILE);
            }
            catch (Exception)
            {
                throw new ValidationException("The docx package must have a \"/_rels/.rels\" file");
            }
            this.validateXml(relationShips);

            // 3. _rel/.rels must contain a relationship of type openDocument
            relationShips = reader.GetEntry(OOX_RELATIONSHIP_FILE);
            XmlReader r         = XmlReader.Create(relationShips);
            String    docTarget = null;

            while (r.Read() && docTarget == null)
            {
                if (r.NodeType == XmlNodeType.Element && r.GetAttribute("Type") == OOX_DOCUMENT_RELATIONSHIP_TYPE)
                {
                    docTarget = r.GetAttribute("Target");
                }
            }
            if (docTarget == null)
            {
                throw new ValidationException("openDocument relation not found in \"/_rels/.rels\"");
            }

            // 4. For each item in _rels/.rels
            relationShips = reader.GetEntry(OOX_RELATIONSHIP_FILE);
            r             = XmlReader.Create(relationShips);
            while (r.Read())
            {
                if (r.NodeType == XmlNodeType.Element && r.LocalName == "Relationship")
                {
                    String target = r.GetAttribute("Target");



                    // 4.1. The target item must exist in the package
                    Stream item = null;
                    try
                    {
                        item = reader.GetEntry(target);
                    }
                    catch (Exception)
                    {
                        throw new ValidationException("The file \"" + target + "\" is described in the \"/_rels/.rels\" file but does not exist in the package.");
                    }

                    // 4.2. A content type can be found in [Content_Types].xml file
                    String ct = this.findContentType(reader, "/" + target);

                    // 4.3. If it's an xml file, it has to be valid
                    if (ct.EndsWith("+xml"))
                    {
                        this.validateXml(item);
                    }
                }
            }

            // Does a part relationship exist ?
            Stream partRel       = null;
            String partDir       = docTarget.Substring(0, docTarget.IndexOf("/"));
            String partRelPath   = partDir + "/_rels/" + docTarget.Substring(docTarget.IndexOf("/") + 1) + ".rels";
            bool   partRelExists = true;

            try
            {
                partRel = reader.GetEntry(partRelPath);
            }
            catch (Exception)
            {
                partRelExists = false;
            }

            if (partRelExists)
            {
                this.validateXml(partRel);

                // 5. For each item in /word/_rels/document.xml.rels
                partRel = reader.GetEntry(partRelPath);
                r       = XmlReader.Create(partRel);
                while (r.Read())
                {
                    if (r.NodeType == XmlNodeType.Element && r.LocalName == "Relationship")
                    {
                        String target = partDir + "/" + r.GetAttribute("Target");

                        // Is the target item exist in the package ?
                        Stream item       = null;
                        bool   fileExists = true;
                        try
                        {
                            item = reader.GetEntry(target);
                        }
                        catch (Exception)
                        {
                            //throw new OoxValidatorException("The file \"" + target + "\" is described in the \"/word/_rels/document.xml.rels\" file but does not exist in the package.");
                            fileExists = false;
                        }

                        if (fileExists)
                        {
                            // 5.1. A content type can be found in [Content_Types].xml file
                            String ct = this.findContentType(reader, "/" + target);

                            // 5.2. If it's an xml file, it has to be valid
                            if (ct.EndsWith("+xml"))
                            {
                                this.validateXml(item);
                            }
                        }
                    }
                }
            }

            // 6. do all referenced relationships exist in the part relationship file

            // retrieve all ids referenced in the document

            Stream doc = reader.GetEntry(docTarget);

            r = XmlReader.Create(doc);
            ArrayList ids = new ArrayList();

            while (r.Read())
            {
                if (r.NodeType == XmlNodeType.Element && r.GetAttribute("id", OOX_DOC_REL_NS) != null)
                {
                    ids.Add(r.GetAttribute("id", OOX_DOC_REL_NS));
                }
            }

            // check if each id exists in the partRel file

            if (ids.Count != 0)
            {
                if (!partRelExists)
                {
                    throw new ValidationException("Referenced id exist but no part relationship file found");
                }
                relationShips = reader.GetEntry(partRelPath);
                r             = XmlReader.Create(relationShips);
                while (r.Read())
                {
                    if (r.NodeType == XmlNodeType.Element && r.LocalName == "Relationship")
                    {
                        if (ids.Contains(r.GetAttribute("Id")))
                        {
                            ids.Remove(r.GetAttribute("Id"));
                        }
                    }
                }
                if (ids.Count != 0)
                {
                    throw new ValidationException("One or more relationship id have not been found in the partRelationship file : " + ids[0]);
                }
            }
        }
コード例 #18
0
        ///// <summary>
        ///// Initialize according to the input file type
        ///// </summary>
        ///// <param name="inputFileType">DocType of input file</param>
        ///// <returns>return IUOFTranslator</returns>
        //public static IUOFTranslator CheckFileType(DocType inputFileType)
        //{
        //    switch (inputFileType)
        //    {
        //        case DocType.Word: return new WordTranslator();
        //        case DocType.Powerpoint: return new PresentationTranslator();
        //        case DocType.Excel: return new SpreadsheetTranslator();
        //        default: throw new Exception("not an office 2010 file");
        //    }
        //}

        /// <summary>
        /// check Microsoft file type
        /// </summary>
        /// <param name="srcFileName">source file name</param>
        /// <returns>document type</returns>
        public static MSDocType CheckMSFileType(string srcFileName)
        {
            FileInfo fi = new FileInfo(srcFileName);

            if (File.Exists(srcFileName))
            {
                XmlReader source  = null;
                ZipReader archive = ZipFactory.OpenArchive(srcFileName);

                // get the main entry xml file
                string entry = string.Empty;
                switch (fi.Extension.ToLower())
                {
                case ".docx": entry = TranslatorMgrConstants.WordDocument_xml; break;

                case ".pptx": entry = TranslatorMgrConstants.PresentationDocument_xml; break;

                case ".xlsx": entry = TranslatorMgrConstants.SpreadsheetDocument_xml; break;
                }
                source = XmlReader.Create(archive.GetEntry(entry));

                XmlDocument xdoc = new XmlDocument();
                xdoc.Load(source);

                // namespace of strict document
                XmlNamespaceManager nm = new XmlNamespaceManager(xdoc.NameTable);
                nm.AddNamespace("w", TranslatorMgrConstants.XMLNS_W);
                nm.AddNamespace("p", TranslatorMgrConstants.XMLNS_P);
                nm.AddNamespace("ws", TranslatorMgrConstants.XMLNS_WS);

                switch (fi.Extension.ToLower())
                {
                case ".docx":
                {
                    // @w:conformance
                    if (xdoc.SelectSingleNode("w:document", nm) != null)
                    {
                        return(MSDocType.StrictWord);
                    }
                    else
                    {
                        return(MSDocType.TransitionalWord);
                    }
                }

                case ".pptx":
                {
                    if (xdoc.SelectSingleNode("p:presentation", nm) != null)
                    {
                        return(MSDocType.StrictPowerpoint);
                    }
                    else
                    {
                        return(MSDocType.TransitionalPowerpoint);
                    }
                }

                case ".xlsx":
                {
                    if (xdoc.SelectSingleNode("ws:workbook", nm) != null)
                    {
                        return(MSDocType.StrictExcel);
                    }
                    else
                    {
                        return(MSDocType.TransitionalExcel);
                    }
                }

                default: return(MSDocType.Unknown);
                }
            }
            else
            {
                return(MSDocType.Unknown);
            }
        }
コード例 #19
0
        protected override void DoOoxToUofMainTransform(string originalFile, string inputFile, string outputFile, string resourceDir)
        {
            string wordPrePath   = Path.GetDirectoryName(inputFile) + Path.DirectorySeparatorChar;
            string grpTmp        = Path.GetDirectoryName(inputFile) + "\\" + "grpTmp.xml";//把grpTmp.xml放在temp下的缓存文件夹下
            string drawingRelTmp = Path.GetDirectoryName(inputFile) + "\\" + "drawingRelTmp.xml";
            string picture_xml   = "ppt\\media";
            string mediaPath     = wordPrePath + picture_xml;

            XmlDocument xdoc = new XmlDocument();

            xdoc.Load(inputFile);//tempdoc1.xml
            XmlNamespaceManager nm = new XmlNamespaceManager(xdoc.NameTable);

            nm.AddNamespace("p", TranslatorConstants.XMLNS_P);
            nm.AddNamespace("a", TranslatorConstants.XMLNS_A);
            nm.AddNamespace("w", TranslatorConstants.XMLNS_W);
            nm.AddNamespace("dsp", TranslatorConstants.XMLNS_DSP);
            FileStream fs = new FileStream(grpTmp, FileMode.Create);

            try
            {
                GrpShPre(xdoc, nm, "p", fs);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
            }

            // chart转换成图片
            string charts_xml = wordPrePath + "ppt\\charts";

            if (Directory.Exists(charts_xml))
            {
                string[] charts = Directory.GetFiles(charts_xml, "chart*");
                if (charts.Length > 0)
                {
                    if (!Directory.Exists(mediaPath))
                    {
                        Directory.CreateDirectory(mediaPath);
                    }
                }
                foreach (string chartXMLFile in charts)
                {
                    SaveChartAsPic(chartXMLFile, mediaPath + Path.AltDirectorySeparatorChar + Path.GetFileName(chartXMLFile) + ".jpg", System.Windows.Forms.DataVisualization.Charting.ChartImageFormat.Jpeg);
                }
            }

            //ole对象处理lyy
            string tmpPic = wordPrePath + "tmpOle.xml";

            if (Directory.Exists(wordPrePath + "ppt\\embeddings"))
            {
                xdoc.Load(grpTmp);
                xdoc = OlePretreatment(xdoc, "p:presentation", wordPrePath, nm);
                xdoc.Save(tmpPic);
                grpTmp = tmpPic;
            }
            // 图片预处理

            tmpPic = wordPrePath + "tmpPic.xml";
            if (Directory.Exists(mediaPath))
            {
                xdoc.Load(grpTmp);
                xdoc = PicPretreatment(xdoc, "p:presentation", mediaPath, nm);
                xdoc.Save(tmpPic);
                grpTmp = tmpPic;
            }
            //ole对象处理
            AddDrawingRel(xdoc, nm, drawingRelTmp);

            XmlReaderSettings xrs    = new XmlReaderSettings();
            XmlReader         source = null;

            string toMainSheet    = ZipXMLFile(drawingRelTmp);
            string zipXMLFileName = "input.xml";

            //string sr = ZipXMLFile(inputFile);
            ZipReader archive = ZipFactory.OpenArchive(toMainSheet);

            source = XmlReader.Create(archive.GetEntry(zipXMLFileName));

            //xdoc.Load(drawingRelTmp);

            XslCompiledTransform transFrom = new XslCompiledTransform();
            XsltSettings         setting   = new XsltSettings(true, false);
            XmlUrlResolver       xur       = new XmlUrlResolver();
            XPathNavigator       nav       = ((IXPathNavigable)xdoc).CreateNavigator();//root

            fs = null;
            string mainOutputFile = Path.GetDirectoryName(inputFile) + "\\" + "mainOutputFile.xml";//缓存文件中保存mainOutputFile.xml


            fs = new FileStream(mainOutputFile, FileMode.Create);
            string mainSheet = Path.GetDirectoryName(inputFile).ToString() + "\\" + TranslatorConstants.OOXToUOF_XSL;//从缓存中调用oox2uof.xsl

            transFrom.Load(mainSheet, setting, xur);
            //Assembly ass = Assembly.Load("ppt_oox2uof");//调用ppt_oox2uof.dll程序集
            //Type t = ass.GetType("oox2uof");//name=oox2uof.xslt
            //transFrom.Load(t);
            //transFrom.Transform(nav, null, fs);

            transFrom.Transform(source, null, fs);
            fs.Close();
            mainOutput = mainOutputFile;


            //XmlUrlResolver resourceResolver = null;

            //try
            //{

            //    resourceResolver = new ResourceResolver(Assembly.GetExecutingAssembly(),
            //        this.GetType().Namespace + "." + TranslatorConstants.RESOURCE_LOCATION + "." + "Powerpoint.oox2uof");
            // MainTransform(TranslatorConstants.OOXToUOF_XSL, resourceResolver, originalFile, grpTmp, outputFile);

            ////}
            //catch (Exception ex)
            //{
            //    logger.Warn(ex.Message);
            //}
        }
コード例 #20
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="filename">Absolute path to the Zip package</param>
 public ZipResolver(String filename)
 {
     archive = ZipFactory.OpenArchive(filename);
     // initialize hash table of odf resource file names
     entries = new Hashtable();
 }
コード例 #21
0
 public OoxZipResolver(String filename, XmlUrlResolver resourceResolver)
 {
     archive = ZipFactory.OpenArchive(filename);
     entries = new Hashtable();
     this.resourceResolver = resourceResolver;
 }
コード例 #22
0
        // TODO: throw an exception if "target" attribute not set
        public override void WriteString(string text)
        {
            Node elt = (Node)elements.Peek();

            if (!elt.Ns.Equals(ZIP_POST_PROCESS_NAMESPACE))
            {
                if (delegateWriter != null)
                {
                    delegateWriter.WriteString(text);
                }
            }
            else
            {
                // Pick up the target attribute
                if (attributes.Count > 0)
                {
                    Node attr = (Node)attributes.Peek();
                    if (attr.Ns.Equals(ZIP_POST_PROCESS_NAMESPACE))
                    {
                        switch (elt.Name)
                        {
                        case ARCHIVE_ELEMENT:
                            // Prevent nested archive creation
                            if (processingState == ProcessingState.None && attr.Name.Equals("target"))
                            {
                                Debug.WriteLine("creating archive : " + text);

                                // 输出包的路径放在式样单中间文档元素<archive Target="包路径名">中了,
                                // 从中提取即可,当然也可以直接传递过来
                                zipOutputStream = ZipFactory.CreateArchive(text);
                                processingState = ProcessingState.EntryWaiting;
                                binaries        = new Hashtable();
                            }
                            break;

                        case PART_ELEMENT:
                            // Prevent nested entry creation
                            if (processingState == ProcessingState.EntryWaiting && attr.Name.Equals("target"))
                            {
                                Debug.WriteLine("creating new part : " + text);

                                //此处的text是entry的target属性的值,也就是文件的路径
                                zipOutputStream.AddEntry(text);
                                delegateWriter  = XmlWriter.Create(zipOutputStream, delegateSettings);
                                processingState = ProcessingState.EntryStarted;
                                delegateWriter.WriteStartDocument();
                            }
                            break;

                        case COPY_ELEMENT:
                            if (processingState != ProcessingState.None)
                            {
                                if (attr.Name.Equals("source"))
                                {
                                    // binarySource是存放base64数据的标识符值
                                    // <uof:其他对象 uof:locID="u0036"
                                    //      uof:attrList="标识符 内嵌 公共类型 私有类型"
                                    //      uof:标识符="OBJ00002" uof:内嵌="false" uof:公共类型="png">
                                    // 即OBJ00002,该标识符唯一确定一个其他对象,进而得到其中的base64数据
                                    binarySource += text;
                                    Debug.WriteLine("copy source=" + binarySource);
                                }
                                if (attr.Name.Equals("target"))
                                {
                                    // binaryTarget存放二进制图片在OOX包中的位置
                                    binaryTarget += text;
                                    Debug.WriteLine("copy target=" + binaryTarget);
                                }
                            }
                            break;
                        }
                    }
                }
            }
        }
コード例 #23
0
        // TODO: throw an exception if "target" attribute not set
        public override void WriteString(string text)
        {
            Node elt = (Node)elements.Peek();

            if (!elt.Ns.Equals(ZIP_POST_PROCESS_NAMESPACE) && !elt.Ns.Equals(PIC_POST_PROCESS_NAMESPACE) && !elt.Ns.Equals(OLE_POST_PROCESS_NAMESPACE))
            {
                if (delegateWriter != null)
                {
                    delegateWriter.WriteString(text);
                }
            }
            else
            {
                // Pick up the target attribute
                if (attributes.Count > 0)
                {
                    Node attr = (Node)attributes.Peek();
                    if (attr.Ns.Equals(ZIP_POST_PROCESS_NAMESPACE) || attr.Ns.Equals(PIC_POST_PROCESS_NAMESPACE) || attr.Ns.Equals(OLE_POST_PROCESS_NAMESPACE))
                    {
                        switch (elt.Name)
                        {
                        case ARCHIVE_ELEMENT:    //archive
                            // Prevent nested archive creation
                            if (processingState == ProcessingState.None && attr.Name.Equals("target"))
                            {
                                logger.Info("creating archive : " + text);

                                // 输出包的路径放在式样单中间文档元素<archive Target="包路径名">中了,
                                // 从中提取即可,当然也可以直接传递过来
                                zipOutputStream = ZipFactory.CreateArchive(text);
                                processingState = ProcessingState.EntryWaiting;
                            }
                            break;

                        case PART_ELEMENT:    //entry
                            // Prevent nested entry creation
                            if (processingState == ProcessingState.EntryWaiting && attr.Name.Equals("target"))
                            {
                                logger.Info("creating new part : " + text);

                                //此处的text是entry的target属性的值,也就是文件的路径
                                zipOutputStream.AddEntry(text);
                                delegateWriter  = XmlWriter.Create(zipOutputStream, delegateSettings);
                                processingState = ProcessingState.EntryStarted;
                                delegateWriter.WriteStartDocument();
                            }
                            break;

                        case OLE_DRAW:
                        case OLE_DRAWRELS:
                        case OLE_EMBEDDING:  //ole
                        case PIC_ELEMENT:    //picture
                            if (processingState != ProcessingState.None)
                            {
                                if (attr.Name.Equals("target"))
                                {
                                    binarySource += text;
                                    logger.Info("picture: target=" + binarySource);
                                }
                            }
                            break;
                        }
                    }
                }
            }
        }
コード例 #24
0
        public override bool transform()
        {
            //string Document_xml = "word/document.xml";//word下的doucument.xml文档
            string picture_xml = "word\\media";
            // string tmpFile = Path.GetTempPath() + "tmpDoc.xml";
            // string tmpFile2 = Path.GetTempPath() + "sndtmpDoc.xml";
            // Guid gPath = Guid.NewGuid();
            // string wordPrePath = Path.GetTempPath() + gPath.ToString() + "\\";
            //   if (!Directory.Exists(wordPrePath))
            //     Directory.CreateDirectory(wordPrePath);
            string wordPrePath = Path.GetDirectoryName(outputFile) + "\\";//输出文档路径
            string mediaPath   = wordPrePath + picture_xml;

            string tblVtcl           = wordPrePath + "tblVertical.xml";
            string tmpFile           = wordPrePath + "tmpDoc.xml";
            string tmpFile2          = wordPrePath + "sndtmpDoc.xml"; //预处理中的中间文档
            string tmpFile3          = wordPrePath + "thrtmpDoc.xml"; //预处理中的中间文档
            string preOutputFileName = wordPrePath + "tempdoc.xml";   //预处理出来的中间文档

            XmlReader source  = null;
            XmlWriter writer  = null;
            ZipReader archive = ZipFactory.OpenArchive(inputFile);

            archive.ExtractOfficeDocument(inputFile, wordPrePath);
            //archive.ExtractUOFDocument(inputFile, wordPrePath);
            bool isSuccess = true;

            try
            {
                OoxToUofTableProcessing tableProcessing2 = new OoxToUofTableProcessing(wordPrePath + "word" + Path.AltDirectorySeparatorChar + "document.xml");
                tableProcessing2.Processing(tblVtcl);

                //找到预处理第一步的式样单pretreatmentStep1.xsl
                XPathDocument        xpdoc = UOFTranslator.GetXPathDoc(TranslatorConstants.OOXToUOF_PRETREAT_STEP1_XSL, TranslatorConstants.OOXToUOF_WORD_LOCATION);
                XslCompiledTransform xslt  = new XslCompiledTransform();
                xslt.Load(xpdoc);

                // source = XmlReader.Create(archive.GetEntry(Document_xml));//解压,得到document.xml文档
                source = XmlReader.Create(tblVtcl);
                writer = new XmlTextWriter(tmpFile, Encoding.UTF8); //tmpDoc.xml
                xslt.Transform(source, writer);                     //document.xml--经过预处理.xsl--tmpDoc.xml
                if (writer != null)
                {
                    writer.Close();
                }
                if (source != null)
                {
                    source.Close();
                }

                //第二步预处理
                xpdoc = UOFTranslator.GetXPathDoc(TranslatorConstants.OOXToUOF_PRETREAT_STEP2_XSL, TranslatorConstants.OOXToUOF_WORD_LOCATION);
                xslt  = new XslCompiledTransform();
                xslt.Load(xpdoc);
                writer = new XmlTextWriter(tmpFile2, Encoding.UTF8); //sndtemDoc.xml
                xslt.Transform(tmpFile, writer);                     //tmpDoc--经过预处理2.xsl--sndtemDoc.xml
                if (writer != null)
                {
                    writer.Close();
                }

                //第三步预处理
                xpdoc = UOFTranslator.GetXPathDoc(TranslatorConstants.OOXToUOF_PRETREAT_STEP3_XSL, TranslatorConstants.OOXToUOF_WORD_LOCATION);
                xslt  = new XslCompiledTransform();
                xslt.Load(xpdoc);
                // xslt.Transform(tmpFile2, outputFile);
                xslt.Transform(tmpFile2, tmpFile3);//经过预处理3--tempdoc.xml

                //2011/6/17zhaobj:阴影预处理
                XmlNamespaceManager nms = null;
                XmlDocument         xmlDoc;
                XmlTextWriter       resultWriter = null;
                xmlDoc = new XmlDocument();
                xmlDoc.Load(tmpFile3);

                nms = new XmlNamespaceManager(xmlDoc.NameTable);
                nms.AddNamespace("a", TranslatorConstants.XMLNS_A);
                nms.AddNamespace("w", TranslatorConstants.XMLNS_W);

                XmlNodeList shapeShadeList = xmlDoc.SelectNodes("//a:outerShdw", nms);
                if (shapeShadeList != null)
                {
                    foreach (XmlNode shapeShade in shapeShadeList)
                    {
                        double dist, dir;
                        if (((XmlElement)shapeShade).HasAttribute("dist"))
                        {
                            dist = Convert.ToDouble(shapeShade.Attributes.GetNamedItem("dist").Value) / 12700;
                        }
                        else
                        {
                            dist = 0.0;
                        }
                        if (((XmlElement)shapeShade).HasAttribute("dir"))
                        {
                            dir = (Convert.ToDouble(shapeShade.Attributes.GetNamedItem("dir").Value) * 3.1415) / (180 * 60000);
                        }
                        else
                        {
                            dir = 0.0;
                        }
                        double     xValue = dist * Math.Cos(dir);
                        double     yValue = dist * Math.Sin(dir);
                        XmlElement x      = xmlDoc.CreateElement("x");
                        x.InnerText = Convert.ToString(xValue);
                        shapeShade.AppendChild(x);
                        XmlElement y = xmlDoc.CreateElement("y");
                        y.InnerText = Convert.ToString(yValue);
                        shapeShade.AppendChild(y);
                    }
                }


                resultWriter = new XmlTextWriter(preOutputFileName, System.Text.Encoding.UTF8);
                xmlDoc.Save(resultWriter);
                resultWriter.Close();

                /*
                 *
                 *
                 *
                 */

                OutputFilename = preOutputFileName;

                //图片预处理
                //if (Directory.Exists(wordPrePath + picture_xml))
                //{
                //    xmlDoc.Load(preOutputFileName);
                //    DirectoryInfo mediaInfo = new DirectoryInfo(wordPrePath + picture_xml);
                //    FileInfo[] medias = mediaInfo.GetFiles();
                //    XmlNode root = xmlDoc.SelectSingleNode("w:document", nms);
                //    XmlElement mediaNode=xmlDoc.CreateElement("w","media",TranslatorConstants.XMLNS_W);
                //    foreach (FileInfo media in medias)
                //    {
                //        XmlElement mediaFileNode = xmlDoc.CreateElement("u2opic", "picture", "urn:u2opic:xmlns:post-processings:special");
                //        mediaFileNode.SetAttribute("target", "urn:u2opic:xmlns:post-processings:special", media.FullName);
                //        mediaNode.AppendChild(mediaFileNode);
                //    }
                //    root.AppendChild(mediaNode);
                //    xmlDoc.Save(tmpPic);
                //    OutputFilename = tmpPic;
                //}
            }
            catch (Exception e)
            {
                logger.Error("Fail in OoxToUofPreProcessorOneWord: " + e.Message);
                logger.Error(e.StackTrace);
                isSuccess = false;
            }
            finally
            {
                if (writer != null)
                {
                    writer.Close();
                }
                if (source != null)
                {
                    source.Close();
                }
                if (archive != null)
                {
                    archive.Close();
                }
                if (File.Exists(tmpFile2))
                {
                    File.Delete((tmpFile2));
                }
            }
            return(isSuccess);
        }
コード例 #25
0
        /// <summary>
        /// Check the validity of an Office Open XML file.
        /// </summary>
        /// <param name="fileName">The path of the docx file.</param>
        public void validate(String fileName)
        {
            // 0. The file must exist and be a valid Zip archive

            try
            {
                reader = ZipFactory.OpenArchive(fileName);
            }
            catch (ZipException e)
            {
                throw new NotAnOoxDocumentException("Problem opening the pptx file : " + e.Message);
            }
            catch (Exception e)
            {
                throw new PptxValidatorException("Problem opening the pptx file : " + e.Message);
            }

            // 1. [Content_Types].xml must be present and valid
            Stream contentTypes = null;

            try
            {
                contentTypes = reader.GetEntry(OOX_CONTENT_TYPE_FILE);
            }
            catch (Exception)
            {
                //modified by lohith - to display user friendly message
                throw new NotAnOoxDocumentException("The pptx package must have a \"/[Content_Types].xml\" file");
                //throw new PptxValidatorException("The pptx package must have a \"/[Content_Types].xml\" file");
            }
            this.validateXml(contentTypes);

            // Code to verify whether a file is valid pptx file or not
            //bug no. 1698280
            //Code chcanges 1 of 2
            if (!this.validatePptx(reader))
            {
                throw new NotAnOoxDocumentException("The pptx package must have a Presentation.xml file");
            }

            // End



            // 2. _rels/.rels must be present and valid
            Stream relationShips = null;

            try
            {
                relationShips = reader.GetEntry(OOX_RELATIONSHIP_FILE);
            }
            catch (Exception)
            {
                //modified by lohith - to display user friendly message
                throw new NotAnOoxDocumentException("The pptx package must have a a \"/_rels/.rels\" file");

                //throw new PptxValidatorException("The pptx package must have a \"/_rels/.rels\" file");
            }
            this.validateXml(relationShips);

            // 3. _rel/.rels must contain a relationship of type openDocument
            relationShips = reader.GetEntry(OOX_RELATIONSHIP_FILE);
            XmlReader r         = XmlReader.Create(relationShips);
            String    docTarget = null;

            while (r.Read() && docTarget == null)
            {
                if (r.NodeType == XmlNodeType.Element && r.GetAttribute("Type") == OOX_DOCUMENT_RELATIONSHIP_TYPE)
                {
                    docTarget = r.GetAttribute("Target");
                }
            }
            if (docTarget == null)
            {
                //modified by lohith - to display user friendly message
                throw new NotAnOoxDocumentException("openDocument relation not found in \"/_rels/.rels\"");

                //throw new PptxValidatorException("openDocument relation not found in \"/_rels/.rels\"");
            }


            // 4. For each item in _rels/.rels
            relationShips = reader.GetEntry(OOX_RELATIONSHIP_FILE);
            r             = XmlReader.Create(relationShips);
            while (r.Read())
            {
                if (r.NodeType == XmlNodeType.Element && r.LocalName == "Relationship")
                {
                    String target = r.GetAttribute("Target");

                    // 4.1. The target item must exist in the package
                    Stream item = null;
                    try
                    {
                        item = reader.GetEntry(target);
                    }
                    catch (Exception)
                    {
                        //modified by lohith - to display user friendly message
                        throw new NotAnOoxDocumentException("The file \"" + target + "\" is described in the \"/_rels/.rels\" file but does not exist in the package.");

                        //throw new PptxValidatorException("The file \"" + target + "\" is described in the \"/_rels/.rels\" file but does not exist in the package.");
                    }

                    // 4.2. A content type can be found in [Content_Types].xml file
                    String ct = this.findContentType(reader, "/" + target);

                    // 4.3. If it's an xml file, it has to be valid
                    if (ct.EndsWith("+xml"))
                    {
                        this.validateXml(item);
                    }
                }
            }

            Stream partRel       = null;
            String partDir       = docTarget.Substring(0, docTarget.IndexOf("/"));
            String partRelPath   = partDir + "/_rels/" + docTarget.Substring(docTarget.IndexOf("/") + 1) + ".rels";
            bool   partRelExists = true;

            try
            {
                partRel = reader.GetEntry(partRelPath);
            }
            catch (Exception)
            {
                partRelExists = false;
            }

            if (partRelExists)
            {
                this.validateXml(partRel);

                // 5. For each item in /ppt/_rels/presentation.xml.rels
                partRel = reader.GetEntry(partRelPath);
                r       = XmlReader.Create(partRel);
                ValidateRels(partDir, r);

                //retrieve all ids referenced in the document
                r.Close();
                Stream doc = reader.GetEntry(docTarget);
                r = XmlReader.Create(doc);
                ArrayList ids = new ArrayList();
                while (r.Read())
                {
                    if (r.LocalName == "custShow")
                    {
                        r.Skip();
                    }
                    else
                    {
                        if (r.NodeType == XmlNodeType.Element && r.GetAttribute("id", OOX_DOC_REL_NS) != null)
                        {
                            ids.Add(r.GetAttribute("id", OOX_DOC_REL_NS));
                        }
                    }
                }

                // check if each id exists in the partRel file
                if (ids.Count != 0)
                {
                    if (!partRelExists)
                    {
                        //modified by lohith - to display user friendly message
                        throw new NotAnOoxDocumentException("Referenced id exist but no part relationship file found");

                        //throw new PptxValidatorException("Referenced id exist but no part relationship file found");
                    }
                    relationShips = reader.GetEntry(partRelPath);
                    r             = XmlReader.Create(relationShips);
                    while (r.Read())
                    {
                        if (r.NodeType == XmlNodeType.Element && r.LocalName == "Relationship")
                        {
                            if (ids.Contains(r.GetAttribute("Id")))
                            {
                                ids.Remove(r.GetAttribute("Id"));
                            }
                        }
                    }
                    if (ids.Count != 0)
                    {
                        //modified by lohith - to display user friendly message
                        throw new NotAnOoxDocumentException("One or more relationship id have not been found in the partRelationship file : " + ids[0]);

                        //throw new PptxValidatorException("One or more relationship id have not been found in the partRelationship file : " + ids[0]);
                    }
                }
            }

            //6. For each item in /ppt/slideMasters/_rels/slideMasters.xml.rels
            docTarget = null;
            partRel   = reader.GetEntry(partRelPath);
            r         = XmlReader.Create(partRel);
            while (r.Read() && docTarget == null)
            {
                if (r.NodeType == XmlNodeType.Element && r.GetAttribute("Type") == OOX_SIDEMASTER_RELATIONSHIP_TYPE)
                {
                    docTarget   = r.GetAttribute("Target");
                    partDir     = OOX_SIDEMASTER_RELATIONSHIP_FILE;
                    partRelPath = partDir + "/_rels/" + docTarget.Substring(docTarget.IndexOf("/") + 1) + ".rels";

                    partRel = reader.GetEntry(partRelPath);
                    r       = XmlReader.Create(partRel);
                    ValidateRels(partDir, r);
                }
            }

            //7. Validation for SlideLayouts if required will be added here.

            //8. For each slide in a presentation, validation needs to be added here

            //9. During developement required validations for pptx feature e.g notes master, numbering etc. will be added.

            //10. are all referenced relationships exist in the part relationship file
        }