Exemplo n.º 1
0
        public void TestReadAllFiles1()
        {
            //string dataDir = @"..\..\..\TestCases\HPSF\data\";
            POIDataSamples _samples = POIDataSamples.GetHPSFInstance();

            string[] files = _samples.GetFiles();

            try
            {
                for (int i = 0; i < files.Length; i++)
                {
                    if (files[i].EndsWith("1"))
                    {
                        continue;
                    }

                    FileStream f = new FileStream(files[i], FileMode.Open, FileAccess.Read);
                    /* Read the POI filesystem's property Set streams: */
                    POIFile[] psf1 = Util.ReadPropertySets(f);

                    for (int j = 0; j < psf1.Length; j++)
                    {
                        Stream in1 =
                            new MemoryStream(psf1[j].GetBytes());
                        PropertySet a = PropertySetFactory.Create(in1);
                    }
                    f.Close();
                }
            }
            catch (Exception t)
            {
                String s = t.ToString();
                Assert.Fail(s);
            }
        }
Exemplo n.º 2
0
        public void TestReadCustomPropertiesFromFiles()
        {
            POIDataSamples _samples = POIDataSamples.GetHPSFInstance();

            string[] files = _samples.GetFiles("Test*.*");

            for (int i = 0; i < files.Length; i++)
            {
                if (TestReadAllFiles.checkExclude(files[i]))
                {
                    continue;
                }
                using (FileStream file = new FileStream(files[i], FileMode.Open, FileAccess.Read))
                {
                    try
                    {
                        RunTest(file);
                    }
                    catch (Exception e)
                    {
                        throw new IOException("While handling file " + files[i], e);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void TestReadDocumentSummaryInformation()
        {
            POIDataSamples _samples = POIDataSamples.GetHPSFInstance();

            string[] files = _samples.GetFiles("Test*.*");

            for (int i = 0; i < files.Length; i++)
            {
                FileStream doc = new FileStream(files[i], FileMode.Open);
                Console.WriteLine("Reading file " + doc);

                /* Read a Test document <em>doc</em> into a POI filesystem. */
                POIFSFileSystem poifs    = new POIFSFileSystem(doc);
                DirectoryEntry  dir      = poifs.Root;
                DocumentEntry   dsiEntry = null;
                try
                {
                    dsiEntry = (DocumentEntry)dir.GetEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
                }
                catch (FileNotFoundException)
                {
                    /*
                     * A missing document summary information stream is not an error
                     * and therefore silently ignored here.
                     */
                }

                /*
                 * If there is a document summry information stream, Read it from
                 * the POI filesystem.
                 */
                if (dsiEntry != null)
                {
                    POIFSDocumentReader        dis = new POIFSDocumentReader(dsiEntry);
                    PropertySet                ps  = new PropertySet(dis);
                    DocumentSummaryInformation dsi = new DocumentSummaryInformation(ps);

                    /* Execute the Get... methods. */
                    Console.WriteLine(dsi.ByteCount);
                    Console.WriteLine(dsi.ByteOrder);
                    Console.WriteLine(dsi.Category);
                    Console.WriteLine(dsi.Company);
                    Console.WriteLine(dsi.CustomProperties);
                    // FIXME Console.WriteLine(dsi.Docparts);
                    // FIXME Console.WriteLine(dsi.HeadingPair);
                    Console.WriteLine(dsi.HiddenCount);
                    Console.WriteLine(dsi.LineCount);
                    Console.WriteLine(dsi.LinksDirty);
                    Console.WriteLine(dsi.Manager);
                    Console.WriteLine(dsi.MMClipCount);
                    Console.WriteLine(dsi.NoteCount);
                    Console.WriteLine(dsi.ParCount);
                    Console.WriteLine(dsi.PresentationFormat);
                    Console.WriteLine(dsi.Scale);
                    Console.WriteLine(dsi.SlideCount);
                }
            }
        }
Exemplo n.º 4
0
        public void TestReadCustomPropertiesFromFiles()
        {
            POIDataSamples _samples = POIDataSamples.GetHPSFInstance();

            string[] files = _samples.GetFiles("Test*.*");

            for (int i = 0; i < files.Length; i++)
            {
                FileStream file = new FileStream(files[i], FileMode.Open);

                RunTest(file);
            }
        }
Exemplo n.º 5
0
        public void TestRecreate()
        {
            string[] files = _samples.GetFiles();

            for (int i = 0; i < files.Length; i++)
            {
                if (files[i].EndsWith("1") ||
                    files[i].EndsWith("TestHPSFWritingFunctionality.doc"))
                {
                    continue;
                }

                TestRecreate(_samples.GetFile(files[i]));
            }
        }
Exemplo n.º 6
0
        public void TestRecreate()
        {
            string[] files = _samples.GetFiles();
            for (int i = 0; i < files.Length; i++)
            {
                string filename = Path.GetFileName(files[i]);
                if (filename.StartsWith("Test"))
                {
                    //if (files[i].EndsWith("1")
                    //    || files[i].EndsWith("TestHPSFWritingFunctionality.doc")
                    //    || files[i].EndsWith("excel_with_embeded.xls"))
                    //    continue;

                    TestRecreate(new FileInfo(files[i]));
                }
            }
        }
Exemplo n.º 7
0
        public void TestReadAllFiles1()
        {
            //string dataDir = @"..\..\..\TestCases\HPSF\data\";
            POIDataSamples _samples = POIDataSamples.GetHPSFInstance();

            string[] files = _samples.GetFiles();
            try
            {
                for (int i = 0; i < files.Length; i++)
                {
                    if (files[i].EndsWith("1") || !checkExclude(files[i]))
                    {
                        continue;
                    }

                    Console.WriteLine("Reading file \"" + files[i] + "\"");

                    using (FileStream f = new FileStream(files[i], FileMode.Open, FileAccess.Read))
                    {
                        /* Read the POI filesystem's property Set streams: */
                        POIFile[] psf1 = Util.ReadPropertySets(f);

                        for (int j = 0; j < psf1.Length; j++)
                        {
                            Stream in1 =
                                new ByteArrayInputStream(psf1[j].GetBytes());
                            try
                            {
                                PropertySet a = PropertySetFactory.Create(in1);
                            }
                            catch (Exception e)
                            {
                                throw new IOException("While handling file: " + files[i] + " at " + j, e);
                            }
                        }
                        f.Close();
                    }
                }
            }
            catch (Exception t)
            {
                string s = t.ToString();
                Assert.Fail(s);
            }
        }
Exemplo n.º 8
0
 public void TestRecreate()
 {
     string[] files = _samples.GetFiles();
     for (int i = 0; i < files.Length; i++)
     {
         string filename = Path.GetFileName(files[i]);
         if (filename.StartsWith("Test") && TestReadAllFiles.checkExclude(filename))
         {
             try
             {
                 TestRecreate(new FileInfo(files[i]));
             }
             catch (Exception e)
             {
                 throw new IOException("While handling file " + files[i], e);
             }
         }
     }
 }
Exemplo n.º 9
0
        public void TestRecreate()
        {
            string[] files = _samples.GetFiles();
            for (int i = 0; i < files.Length; i++)
            {
                string filename = Path.GetFileName(files[i]);
                if (filename.StartsWith("Test") && TestReadAllFiles.checkExclude(filename))
                {
                    //if (files[i].EndsWith("1")
                    //    || files[i].EndsWith("TestHPSFWritingFunctionality.doc")
                    //    || files[i].EndsWith("excel_with_embeded.xls"))
                    //    continue;

                    try
                    {
                        TestRecreate(new FileInfo(files[i]));
                    }
                    catch (Exception e)
                    {
                        throw new IOException("While handling file " + files[i], e);
                    }
                }
            }
        }
Exemplo n.º 10
0
        public void TestReadDocumentSummaryInformation()
        {
            POIDataSamples _samples = POIDataSamples.GetHPSFInstance();

            string[] files = _samples.GetFiles("Test*.*");

            for (int i = 0; i < files.Length; i++)
            {
                if (!TestReadAllFiles.checkExclude(files[i]))
                {
                    continue;
                }
                using (FileStream doc = new FileStream(files[i], FileMode.Open, FileAccess.Read))
                {
                    Console.WriteLine("Reading file " + doc);
                    try
                    {
                        /* Read a Test document <em>doc</em> into a POI filesystem. */
                        POIFSFileSystem poifs    = new POIFSFileSystem(doc);
                        DirectoryEntry  dir      = poifs.Root;
                        DocumentEntry   dsiEntry = null;
                        try
                        {
                            dsiEntry = (DocumentEntry)dir.GetEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
                        }
                        catch (FileNotFoundException)
                        {
                            /*
                             * A missing document summary information stream is not an error
                             * and therefore silently ignored here.
                             */
                        }
                        //catch (System.IO.IOException ex)
                        //{
                        //     // The process cannot access the file 'testcases\test-data\hpsf\TestUnicode.xls' because it is being used by another process.
                        //    Console.Error.WriteLine("Exception ignored (because some other test cases may read this file, too): " + ex.Message);
                        //}

                        /*
                         * If there is a document summry information stream, Read it from
                         * the POI filesystem.
                         */
                        if (dsiEntry != null)
                        {
                            DocumentInputStream        dis = new DocumentInputStream(dsiEntry);
                            PropertySet                ps  = new PropertySet(dis);
                            DocumentSummaryInformation dsi = new DocumentSummaryInformation(ps);

                            /* Execute the Get... methods. */
                            Console.WriteLine(dsi.ByteCount);
                            Console.WriteLine(dsi.ByteOrder);
                            Console.WriteLine(dsi.Category);
                            Console.WriteLine(dsi.Company);
                            Console.WriteLine(dsi.CustomProperties);
                            // FIXME Console.WriteLine(dsi.Docparts);
                            // FIXME Console.WriteLine(dsi.HeadingPair);
                            Console.WriteLine(dsi.HiddenCount);
                            Console.WriteLine(dsi.LineCount);
                            Console.WriteLine(dsi.LinksDirty);
                            Console.WriteLine(dsi.Manager);
                            Console.WriteLine(dsi.MMClipCount);
                            Console.WriteLine(dsi.NoteCount);
                            Console.WriteLine(dsi.ParCount);
                            Console.WriteLine(dsi.PresentationFormat);
                            Console.WriteLine(dsi.Scale);
                            Console.WriteLine(dsi.SlideCount);
                        }
                    }
                    catch (Exception e)
                    {
                        throw new IOException("While handling file " + files[i], e);
                    }
                }
            }
        }