Ejemplo n.º 1
0
        public VbaStorage(CompoundFile VbaBinFile)
        {
            this.m_disposable = VbaBinFile;

            // _VBA_PROJECT stream
            var VBAStorage = VbaBinFile.RootStorage.GetStorage("VBA");

            this._VBA_PROJECTStream = ReadVbaProjectStream(VBAStorage);

            // DIR STREAM -------------------------
            CFStream thisWorkbookStream = VBAStorage.GetStream("dir");

            Byte[] compressedData = thisWorkbookStream.GetData();
            Byte[] uncompressed   = XlCompressionAlgorithm.Decompress(compressedData);

            var uncompressedDataReader = new XlBinaryReader(ref uncompressed);

            this.DirStream = new DirStream(uncompressedDataReader);

            // MODULE STREAMS ----------------------------------------
            this._ModuleStreams = new Dictionary <string, ModuleStream>(DirStream.ModulesRecord.Modules.Length);
            this.ModuleStreams  = new ReadOnlyDictionary <string, ModuleStream>(this._ModuleStreams);

            foreach (var module in DirStream.ModulesRecord.Modules)
            {
                var streamName  = module.StreamNameRecord.GetStreamNameAsString();
                var stream      = VBAStorage.GetStream(streamName).GetData();
                var localreader = new XlBinaryReader(ref stream);

                var moduleStream = new ModuleStream(DirStream.InformationRecord, module, localreader);

                this._ModuleStreams.Add(streamName, moduleStream);
            }

            // PROJECT stream
            CFStream ProjectStorage = VbaBinFile.RootStorage.GetStream("PROJECT");

            this.ProjectStream = ReadProjectStream(ProjectStorage, this.DirStream.InformationRecord.CodePageRecord);
        }
Ejemplo n.º 2
0
 internal VbaStorage(IDictionary <string, ModuleStream> ModuleStreams, DirStream DirStream)
 {
     this._ModuleStreams = ModuleStreams;
     this.ModuleStreams  = new ReadOnlyDictionary <string, ModuleStream>(ModuleStreams);
 }