Exemplo n.º 1
0
        public VbaStorage(CFStorage VBAStorage)
        {
            // DIR STREAM -------------------------
            CFStream thisWorkbookStream = VBAStorage.GetStream("dir");

            Byte[] compressedData = thisWorkbookStream.GetData();

            var reader    = new XlBinaryReader(ref compressedData);
            var container = new CompressedContainer(reader);

            // Decompress
            var buffer = new DecompressedBuffer();

            container.Decompress(buffer);
            Byte[] uncompressed = buffer.GetData();

            var uncompressedDataReader = new XlBinaryReader(ref uncompressed);

            this.DirStream = new DirStream(uncompressedDataReader);

            // MODULE STREAMS ----------------------------------------
            this.ModuleStreams = new Dictionary <string, ModuleStream>(DirStream.ModulesRecord.Modules.Length);
            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);
            }
        }
Exemplo n.º 2
0
        public ModuleStream(PROJECTINFORMATION ProjectInformation, MODULE module, XlBinaryReader Data)
        {
            this.ProjectInformation = ProjectInformation;

            this.PerformanceCache = Data.ReadBytes(module.OffsetRecord.TextOffset);

            Byte[] rest      = Data.GetUnreadData();
            var    reader    = new XlBinaryReader(ref rest);
            var    container = new CompressedContainer(reader);
            var    buffer    = new DecompressedBuffer();

            container.Decompress(buffer);
            this.UncompressedSourceCode = buffer.GetData();
        }
Exemplo n.º 3
0
        public void DecompressionTest()
        {
            Byte[] CompressedData = TestData.CompressedData;
            var    reader         = new XlBinaryReader(ref CompressedData);

            reader.OutputAllAsBinary();

            var container = new CompressedContainer(reader);
            var buffer    = new DecompressedBuffer();

            container.Decompress(buffer);
            Byte[] uncompressed = buffer.GetData();

            bool success = Enumerable.SequenceEqual(uncompressed, TestData.UncompressedData);

            Assert.IsTrue(success, "Uncompressed byte sequence not equal to expected byte sequence");
        }