Esempio n. 1
0
        /// <summary>
        /// This constructor loads a Word document from a specific point in a POIFSFileSystem, probably not the default.Used typically to open embeded documents.
        /// </summary>
        /// <param name="directory">The POIFSFileSystem that Contains the Word document.</param>
        /// <param name="pfilesystem">If there is an unexpected IOException from the passed in POIFSFileSystem.</param>
        public HWPFDocumentCore(DirectoryNode directory)
            : base(directory)
        {
            // Sort out the hpsf properties


            // read in the main stream.
            DocumentEntry documentProps = (DocumentEntry)
               directory.GetEntry(STREAM_WORD_DOCUMENT);
            _mainStream = new byte[documentProps.Size];

            directory.CreatePOIFSDocumentReader(STREAM_WORD_DOCUMENT).Read(_mainStream);

            // Create our FIB, and check for the doc being encrypted
            _fib = new FileInformationBlock(_mainStream);
            if (_fib.IsFEncrypted())
            {
                throw new EncryptedDocumentException("Cannot process encrypted word files!");
            }

            DirectoryEntry objectPoolEntry;
            try
            {
                objectPoolEntry = (DirectoryEntry)directory.GetEntry(STREAM_OBJECT_POOL);
            }
            catch (FileNotFoundException exc)
            {
                objectPoolEntry = null;
            }
            _objectPool = new ObjectPoolImpl(objectPoolEntry);
        }