/// <summary>
 /// Create an InputStream from the specified Document
 /// </summary>
 /// <param name="document">the Document to be read</param>
 public POIFSDocumentReader(POIFSDocument document)
 {
     this._current_offset = 0;
     this._document_size = document.Size;
     this._closed = false;
     this._tiny_buffer = null;
     this._document = document;
 }
예제 #2
0
 /// <summary>
 /// Create an InputStream from the specified Document
 /// </summary>
 /// <param name="document">the Document to be read</param>
 public POIFSDocumentReader(POIFSDocument document)
 {
     this._current_offset = 0;
     this._document_size  = document.Size;
     this._closed         = false;
     this._tiny_buffer    = null;
     this._document       = document;
 }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DocumentProperty"/> class.
 /// </summary>
 /// <param name="name">POIFSDocument name</param>
 /// <param name="size">POIFSDocument size</param>
 public DocumentProperty(String name, int size)
 {
     _document = null;
     
     this.Name=name;
     this.Size=size;
     this.NodeColor=_NODE_BLACK;   // simplification
     this.PropertyType=PropertyConstants.DOCUMENT_TYPE;
 }
 /**
  * Create an InputStream from the specified Document
  *
  * @param document the Document to be read
  */
 public ODocumentInputStream(POIFSDocument document)
 {
     _current_offset = 0;
     _marked_offset  = 0;
     _document_size  = document.Size;
     _closed         = false;
     _document       = document;
     _currentBlock   = GetDataInputBlock(0);
 }
 /// <summary>
 /// Create an InputStream from the specified DocumentEntry
 /// </summary>
 /// <param name="document">the DocumentEntry to be read</param>
 public POIFSDocumentReader(DocumentEntry document)
 {
     this._current_offset = 0;
     this._document_size = document.Size;
     this._closed = false;
     this._tiny_buffer = null;
     if (!(document is DocumentNode))
     {
         throw new IOException("Cannot open internal document storage");
     }
     this._document = ((DocumentNode)document).Document;
 }
예제 #6
0
 /// <summary>
 /// Create an InputStream from the specified DocumentEntry
 /// </summary>
 /// <param name="document">the DocumentEntry to be read</param>
 public POIFSDocumentReader(DocumentEntry document)
 {
     this._current_offset = 0;
     this._document_size  = document.Size;
     this._closed         = false;
     this._tiny_buffer    = null;
     if (!(document is DocumentNode))
     {
         throw new IOException("Cannot open internal document storage");
     }
     this._document = ((DocumentNode)document).Document;
 }
예제 #7
0
        /// <summary>
        /// Create a new DocumentEntry; the data will be provided later
        /// </summary>
        /// <param name="name">the name of the new DocumentEntry</param>
        /// <param name="size">the size of the new DocumentEntry</param>
        /// <returns>the new DocumentEntry</returns>
        public DocumentEntry CreateDocument(POIFSDocument document)
        {
            DocumentProperty property = document.DocumentProperty;
            DocumentNode     rval     = new DocumentNode(property, this);

            ((DirectoryProperty)Property).AddChild(property);
            _oFilesSystem.AddDocument(document);

            _entries.Add(rval);
            _byname.Add(property.Name, rval);

            return(rval);
        }
예제 #8
0
        private void ProcessProperties(BlockList small_blocks,
                                       BlockList big_blocks,
                                       IEnumerator properties,
                                       DirectoryNode dir,
                                       int headerPropertiesStartAt)
        {
            while (properties.MoveNext())
            {
                Property      property = ( Property )properties.Current;
                String        name     = property.Name;
                DirectoryNode parent   = (dir == null)
                                         ? (( DirectoryNode )this.Root)
                                         : dir;

                if (property.IsDirectory)
                {
                    DirectoryNode new_dir =
                        ( DirectoryNode )parent.CreateDirectory(name);

                    new_dir.StorageClsid = property.StorageClsid;

                    ProcessProperties(
                        small_blocks, big_blocks,
                        ((DirectoryProperty)property).Children, new_dir, headerPropertiesStartAt);
                }
                else
                {
                    int           startBlock = property.StartBlock;
                    int           size       = property.Size;
                    POIFSDocument document   = null;

                    if (property.ShouldUseSmallBlocks)
                    {
                        document =
                            new POIFSDocument(name, small_blocks
                                              .FetchBlocks(startBlock, headerPropertiesStartAt), size);
                    }
                    else
                    {
                        document =
                            new POIFSDocument(name,
                                              big_blocks.FetchBlocks(startBlock, headerPropertiesStartAt),
                                              size);
                    }
                    parent.CreateDocument(document);
                }
            }
        }
        /**
         * Create an InputStream from the specified DocumentEntry
         * 
         * @param document the DocumentEntry to be read
         * 
         * @exception IOException if the DocumentEntry cannot be opened (like, maybe it has
         *                been deleted?)
         */
        public ODocumentInputStream(DocumentEntry document)
        {
            if (!(document is DocumentNode))
            {
                throw new IOException("Cannot open internal document storage");
            }
            DocumentNode documentNode = (DocumentNode)document;
            if (documentNode.Document == null)
            {
                throw new IOException("Cannot open internal document storage");
            }

            _current_offset = 0;
            _marked_offset = 0;
            _document_size = document.Size;
            _closed = false;
            _document = documentNode.Document;
            _currentBlock = GetDataInputBlock(0);
        }
        /**
         * Create an InputStream from the specified DocumentEntry
         *
         * @param document the DocumentEntry to be read
         *
         * @exception IOException if the DocumentEntry cannot be opened (like, maybe it has
         *                been deleted?)
         */
        public ODocumentInputStream(DocumentEntry document)
        {
            if (!(document is DocumentNode))
            {
                throw new IOException("Cannot open internal document storage");
            }
            DocumentNode documentNode = (DocumentNode)document;

            if (documentNode.Document == null)
            {
                throw new IOException("Cannot open internal document storage");
            }

            _current_offset = 0;
            _marked_offset  = 0;
            _document_size  = document.Size;
            _closed         = false;
            _document       = documentNode.Document;
            _currentBlock   = GetDataInputBlock(0);
        }
 public POIFSReaderEventArgs(string name, POIFSDocumentPath path, POIFSDocument document)
 {
     this.name = name;
     this.path = path;
     this.document = document;
 }
예제 #12
0
        /**
         * create a DocumentNode. This method Is not public by design; it
         * Is intended strictly for the internal use of this package
         *
         * @param property the DocumentProperty for this DocumentEntry
         * @param parent the parent of this entry
         */

        public DocumentNode(DocumentProperty property, DirectoryNode parent) : base(property, parent)
        {
            _document = property.Document;
        }
예제 #13
0
        private void ProcessProperties(BlockList small_blocks,
                                       BlockList big_blocks,
                                       IEnumerator properties,
                                       DirectoryNode dir,
                                       int headerPropertiesStartAt)
        {
            while (properties.MoveNext())
            {
                Property      property = ( Property ) properties.Current;
                String        name     = property.Name;
                DirectoryNode parent   = (dir == null)
                                         ? (( DirectoryNode ) this.Root)
                                         : dir;

                if (property.IsDirectory)
                {
                    DirectoryNode new_dir =
                        ( DirectoryNode ) parent.CreateDirectory(name);

                    new_dir.StorageClsid=property.StorageClsid ;

                    ProcessProperties(
                        small_blocks, big_blocks,
                        ((DirectoryProperty)property).Children, new_dir, headerPropertiesStartAt);
                }
                else
                {
                    int           startBlock = property.StartBlock;
                    int           size       = property.Size;
                    POIFSDocument document   = null;

                    if (property.ShouldUseSmallBlocks)
                    {
                        document =
                            new POIFSDocument(name, small_blocks
                                .FetchBlocks(startBlock, headerPropertiesStartAt), size);
                    }
                    else
                    {
                        document =
                            new POIFSDocument(name,
                                              big_blocks.FetchBlocks(startBlock,headerPropertiesStartAt),
                                              size);
                    }
                    parent.CreateDocument(document);
                }
            }
        }
예제 #14
0
 /**
  * Create an InputStream from the specified Document
  *
  * @param document the Document to be read
  */
 public DocumentInputStream(POIFSDocument document)
 {
     delegate1 = new ODocumentInputStream(document);
 }
 /**
  * Create an InputStream from the specified Document
  * 
  * @param document the Document to be read
  */
 public DocumentInputStream(POIFSDocument document)
 {
     delegate1 = new ODocumentInputStream(document);
 }
예제 #16
0
        /**
         * create a DocumentNode. This method Is not public by design; it
         * Is intended strictly for the internal use of this package
         *
         * @param property the DocumentProperty for this DocumentEntry
         * @param parent the parent of this entry
         */

        public DocumentNode(DocumentProperty property, DirectoryNode parent):base(property, parent)
        {
            _document = property.Document;
        }
 /**
  * Create an InputStream from the specified Document
  * 
  * @param document the Document to be read
  */
 public ODocumentInputStream(POIFSDocument document)
 {
     _current_offset = 0;
     _marked_offset = 0;
     _document_size = document.Size;
     _closed = false;
     _document = document;
     _currentBlock = GetDataInputBlock(0);
 }
예제 #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DocumentProperty"/> class.
 /// </summary>
 /// <param name="index">index number</param>
 /// <param name="array">byte data</param>
 /// <param name="offset">offset into byte data</param> 
 public DocumentProperty(int index, byte [] array, int offset):base(index, array, offset)
 {
     
     _document = null;
 }
예제 #19
0
        /// <summary>
        /// Processes the properties.
        /// </summary>
        /// <param name="small_blocks">The small_blocks.</param>
        /// <param name="big_blocks">The big_blocks.</param>
        /// <param name="properties">The properties.</param>
        /// <param name="path">The path.</param>
        /// <returns></returns>
        private List<DocumentDescriptor> ProcessProperties(BlockList small_blocks,
                                       BlockList big_blocks,
                                       IEnumerator properties,
                                       POIFSDocumentPath path)
        {
            List<DocumentDescriptor> documents =
                new List<DocumentDescriptor>();

            while (properties.MoveNext())
            {
                Property property = (Property)properties.Current;
                String name = property.Name;

                if (property.IsDirectory)
                {
                    POIFSDocumentPath new_path = new POIFSDocumentPath(path,
                                                     new String[]
                {
                    name
                });

                    ProcessProperties(
                        small_blocks, big_blocks,
                        ((DirectoryProperty)property).Children, new_path);
                }
                else
                {
                    int startBlock = property.StartBlock;
                    IEnumerator listeners = registry.GetListeners(path, name);
                    POIFSDocument document = null;
                    if (listeners.MoveNext())
                    {
                        int size = property.Size;
                        

                        if (property.ShouldUseSmallBlocks)
                        {
                            document =
                                new POIFSDocument(name, small_blocks
                                    .FetchBlocks(startBlock, -1), size);
                        }
                        else
                        {
                            document =
                                new POIFSDocument(name, big_blocks
                                    .FetchBlocks(startBlock, -1), size);
                        }
                        POIFSReaderListener listener =
                                (POIFSReaderListener)listeners.Current;
                        listener.ProcessPOIFSReaderEvent(
                                new POIFSReaderEvent(
                                    new DocumentInputStream(document), path,
                                    name));
                        while (listeners.MoveNext())
                        {
                            listener =
                                (POIFSReaderListener)listeners.Current;
                            listener.ProcessPOIFSReaderEvent(
                                new POIFSReaderEvent(
                                    new DocumentInputStream(document), path,
                                    name));
                        }
                    }
                    else
                    {
                        // consume the document's data and discard it
                        if (property.ShouldUseSmallBlocks)
                        {
                            small_blocks.FetchBlocks(startBlock, -1);
                        }
                        else
                        {
                            big_blocks.FetchBlocks(startBlock, -1);
                        }
                        documents.Add(
                                new DocumentDescriptor(path, name));
                        //fire event
                        //OnStreamReaded(new POIFSReaderEventArgs(name, path, document));
                    }
                }
            }
            return documents;
        }
예제 #20
0
        /// <summary>
        /// open a document in the root entry's list of entries
        /// </summary>
        /// <param name="documentName">the name of the document to be opened</param>
        /// <returns>a newly opened POIFSDocumentReader</returns>
        //public DocumentReader CreatePOIFSDocumentReader(
        //        String documentName)
        //{
        //    return this.Root.CreatePOIFSDocumentReader(documentName);
        //}

        /// <summary>
        /// Add a new POIFSDocument
        /// </summary>
        /// <param name="document">the POIFSDocument being Added</param>
        public void AddDocument(POIFSDocument document)
        {
            _documents.Add(document);
            _property_table.AddProperty(document.DocumentProperty);
        }
예제 #21
0
        /// <summary>
        /// open a document in the root entry's list of entries
        /// </summary>
        /// <param name="documentName">the name of the document to be opened</param>
        /// <returns>a newly opened POIFSDocumentReader</returns>
        //public DocumentReader CreatePOIFSDocumentReader(
        //        String documentName)
        //{
        //    return this.Root.CreatePOIFSDocumentReader(documentName);
        //}

        /// <summary>
        /// Add a new POIFSDocument
        /// </summary>
        /// <param name="document">the POIFSDocument being Added</param>
        public void AddDocument(POIFSDocument document)
        {
            _documents.Add(document);
            _property_table.AddProperty(document.DocumentProperty);
        }