internal CompoundFileStorage(CompoundFileSystem system, uint streamID, IEnumerable<uint> ancestors)
        {
            this.system = system;
            this.streamID = streamID;
            this.ancestors = ancestors;

            Initialize();
        }
Esempio n. 2
0
 private static void ListContent(string filename)
 {
     CompoundFileSystem compoundFile = new CompoundFileSystem(filename);
     Console.WriteLine("Content of '{0}': ", filename);
     Console.WriteLine();
     Console.WriteLine("Type\tModified\tLength\tName");
     int i = 0;
     foreach (KeyValuePair<string, CompoundFileStorage> pair in
         ListStorage(compoundFile.GetRootStorage(), "/"))
     {
         Console.WriteLine("{0}\t{1}\t{2}\t\"{3}\"",
             pair.Value.ObjectType, pair.Value.Modified, pair.Value.Length, pair.Key);
         ++i;
     }
     Console.WriteLine("{0} item(s) found", i);
 }
Esempio n. 3
0
 private static void ExtractContext(string filename, string itemName, string target)
 {
     Console.WriteLine("Extracting stream \'{1}\' from of '{0}'", filename, itemName);
     CompoundFileSystem compoundFile = new CompoundFileSystem(filename);
     CompoundFileStorage storage = null;
     foreach (KeyValuePair<string, CompoundFileStorage> pair in
         ListStorage(compoundFile.GetRootStorage(), "/"))
     {
         if (pair.Key == itemName) storage = pair.Value;
     }
     if (storage != null)
     {
         storage.CopyToFile(target);
         Console.WriteLine("The {0} bytes were saved to '{1}'", storage.Length, target);
     }
     else
         Console.WriteLine("The stream was not found");
 }
Esempio n. 4
0
        static void Main(string[] args)
        {
            if(args.Length == 0)
            {
                Console.WriteLine("USAGE: WordFileDrop.exe <doc-file>");
                return;
            }

            string filename = args[0];
            using (CompoundFileSystem system = new CompoundFileSystem(filename))
            {
                WordDocument doc = new WordDocument();
                doc.Load(system);

                foreach (Paragraph p in doc.Paragraphs)
                {
                    string text = p.GetText();
                    Console.WriteLine("{0}/{1}, {3}: {2}",
                        p.Offset, p.Length, Escape(text),
                        p.Style.Name);
                }
                Console.WriteLine();
                foreach (StyleDefinition s in doc.StyleDefinitions)
                {
                    Console.WriteLine("Style {0}: {1}", s.Name, s.IsTextStyle);

                }
                Console.WriteLine();
                foreach (CharacterFormatting f in doc.Formattings)
                {
                    string text = f.GetText();
                    StyleDefinition style = f.Style;
                    Console.WriteLine("Format {0}/{1}, {3}: {2}",
                        f.Offset, f.Length, Escape(text),
                        style != null ? style.Name : "-");
                }
            }
        }
Esempio n. 5
0
        public void Load(CompoundFileSystem system)
        {
            const string WordDocumentStreamName = "WordDocument";
            CompoundFileStorage wordDocumentStorage = system.GetRootStorage().FindStorage(WordDocumentStreamName);
            wordDocumentStorage.CopyToFile("wd.bin");
            using (Stream wordDocumentStream = wordDocumentStorage.CreateStream())
            {
                Fib fib;
                fib = FibStructuresReader.ReadFib(wordDocumentStream);

                string tableStreamName = GetTableStreamName(fib);
                CompoundFileStorage tableStorage = system.GetRootStorage().FindStorage(tableStreamName);
                tableStorage.CopyToFile(tableStreamName + ".bin");
                using (Stream tableStream = tableStorage.CreateStream())
                {
                    LoadContent(wordDocumentStream, tableStream, fib);
                }
            }
        }