Esempio n. 1
0
        /* ********** START implementation of POIFSReaderListener ********** */

        /**
         * Process a POIFSReaderEvent that this listener had registered
         * for
         *
         * @param evt the POIFSReaderEvent
         */

        public void ProcessPOIFSReaderEvent(POIFSReaderEvent evt)
        {
            DocumentInputStream istream = evt.Stream;
            POIFSDocumentPath path = evt.Path;
            String name = evt.Name;

            try
            {
                int size = (int)(istream.Length - istream.Position);
                byte[] data = new byte[size];

                istream.Read(data);
                DocumentDescriptor descriptor = new DocumentDescriptor(path,
                                                    name);

                Console.WriteLine("Adding document: " + descriptor + " (" + size
                                   + " bytes)");
                dataMap[descriptor] = data;
                int pathLength = path.Length;
                DirectoryEntry entry = root;

                for (int k = 0; k < path.Length; k++)
                {
                    String componentName = path.GetComponent(k);
                    Entry nextEntry = null;

                    try
                    {
                        nextEntry = entry.GetEntry(componentName);
                    }
                    catch (FileNotFoundException)
                    {
                        try
                        {
                            nextEntry = entry.CreateDirectory(componentName);
                        }
                        catch (IOException)
                        {
                            Console.WriteLine("Unable to Create directory");
                            //e.printStackTrace();
                            throw;
                        }
                    }
                    entry = (DirectoryEntry)nextEntry;
                }
                entry.CreateDocument(name, size, this);
            }
            catch (IOException)
            {
            }
        }
Esempio n. 2
0
        /**
         * Process a POIFSReaderEvent that this listener had registered
         * for
         *
         * @param evt the POIFSReaderEvent
         */

        public void ProcessPOIFSReaderEvent(POIFSReaderEvent evt)
        {
        }
Esempio n. 3
0
 public void ProcessPOIFSReaderEvent(POIFSReaderEvent e)
 {
     try
     {
         POIFile f = new POIFile();
         f.SetName(e.Name);
         f.SetPath(e.Path);
         Stream in1 = e.Stream;
         if (PropertySet.IsPropertySetStream(in1))
         {
             using (MemoryStream out1 = new MemoryStream())
             {
                 Util.Copy(in1, out1);
                 //out1.Close();
                 f.SetBytes(out1.ToArray());
                 files.Add(f);
             }
         }
     }
     catch (Exception ex)
     {
         throw new RuntimeException(ex);
     }
 }
Esempio n. 4
0
 public void ProcessPOIFSReaderEvent(POIFSReaderEvent evt)
 {
     try
     {
         POIFile f = new POIFile();
         f.SetName(evt.Name);
         f.SetPath(evt.Path);
         MemoryStream out1 =
             new MemoryStream();
         Util.Copy(evt.Stream, out1);
         out1.Close();
         f.SetBytes(out1.ToArray());
         files.Add(f);
     }
     catch (IOException ex)
     {
         throw new RuntimeException(ex.Message);
     }
 }
Esempio n. 5
0
 public void ProcessPOIFSReaderEvent(POIFSReaderEvent evt)
 {
     try
         {
             psa[0] = PropertySetFactory.Create(evt.Stream);
         }
         catch (Exception ex)
         {
             throw new RuntimeException(ex.Message);
             /* FIXME (2): Replace the previous line by the following
              * one once we no longer need JDK 1.3 compatibility. */
             // throw new RuntimeException(ex);
         }
 }
Esempio n. 6
0
 public void ProcessPOIFSReaderEvent(POIFSReaderEvent e)
 {
     try
     {
         psa[0] = PropertySetFactory.Create(e.Stream);
     }
     catch (Exception ex)
     {
         Assert.Fail(ex.Message);
     }
 }