Exemple #1
0
        public void DjbzChunkTest()
        {
            Mock <IDjvuReader> readerMock = new Mock <IDjvuReader>();

            readerMock.Setup(x => x.Position).Returns(1024);

            DjbzChunk unk = new DjbzChunk(readerMock.Object, null, null, null, 0);

            Assert.Equal <ChunkType>(ChunkType.Djbz, unk.ChunkType);
            Assert.Equal(ChunkType.Djbz.ToString(), unk.Name);
            Assert.Equal <long>(1024, unk.DataOffset);
        }
Exemple #2
0
        public void ShapeDictionaryTest()
        {
            Mock <IDjvuReader> readerMock = new Mock <IDjvuReader>();

            readerMock.Setup(x => x.Position).Returns(1024);

            DjbzChunk unk = new DjbzChunk(readerMock.Object, null, null, null, 0);

            Assert.Equal <ChunkType>(ChunkType.Djbz, unk.ChunkType);
            Assert.Equal(ChunkType.Djbz.ToString(), unk.Name);
            Assert.Equal <long>(1024, unk.DataOffset);

            JB2.JB2Dictionary dictionary = new JB2.JB2Dictionary();
            unk.ShapeDictionary = dictionary;
            Assert.NotNull(unk.ShapeDictionary);
            Assert.Same(dictionary, unk.ShapeDictionary);
        }
Exemple #3
0
        public static IDjvuNode CreateEncodedDjvuNode(IDjvuWriter writer, IDjvuElement parent, ChunkType chunkType, long length)
        {
            IDjvuNode result = null;

            switch (chunkType)
            {
            case ChunkType.Djvm:
                result = new DjvmChunk(writer, parent, length);
                break;

            case ChunkType.Djvu:
                result = new DjvuChunk(writer, parent, length);
                break;

            case ChunkType.Djvi:
                result = new DjviChunk(writer, parent, length);
                break;

            case ChunkType.Thum:
                result = new ThumChunk(writer, parent, length);
                break;

            case ChunkType.Dirm:
                result = new DirmChunk(writer, parent, length);
                break;

            case ChunkType.Navm:
                result = new NavmChunk(writer, parent, length);
                break;

            case ChunkType.Anta:
                result = new AntaChunk(writer, parent, length);
                break;

            case ChunkType.Antz:
                result = new AntzChunk(writer, parent, length);
                break;

            case ChunkType.Txta:
                result = new TxtaChunk(writer, parent, length);
                break;

            case ChunkType.Txtz:
                result = new TxtzChunk(writer, parent, length);
                break;

            case ChunkType.Djbz:
                result = new DjbzChunk(writer, parent, length);
                break;

            case ChunkType.Sjbz:
                result = new SjbzChunk(writer, parent, length);
                break;

            case ChunkType.FG44:
                result = new FG44Chunk(writer, parent, length);
                break;

            case ChunkType.BG44:
                result = new BG44Chunk(writer, parent, length);
                break;

            case ChunkType.TH44:
                result = new TH44Chunk(writer, parent, length);
                break;

            case ChunkType.BM44:
                result = new BM44Chunk(writer, parent, length);
                break;

            case ChunkType.BM44Form:
                result = new BM44Form(writer, parent, length);
                break;

            case ChunkType.PM44:
                result = new PM44Chunk(writer, parent, length);
                break;

            case ChunkType.PM44Form:
                result = new PM44Form(writer, parent, length);
                break;

            case ChunkType.Wmrm:
                result = new WmrmChunk(writer, parent, length);
                break;

            case ChunkType.FGbz:
                result = new FGbzChunk(writer, parent, length);
                break;

            case ChunkType.Info:
                result = new InfoChunk(writer, parent, length);
                break;

            case ChunkType.Incl:
                result = new InclChunk(writer, parent, length);
                break;

            case ChunkType.BGjp:
                result = new BGjpChunk(writer, parent, length);
                break;

            case ChunkType.FGjp:
                result = new FGjpChunk(writer, parent, length);
                break;

            case ChunkType.Smmr:
                result = new SmmrChunk(writer, parent, length);
                break;

            default:
                throw new DjvuInvalidOperationException($"Chunk type is not supported in encoding. ChunkType: {chunkType}");
            }

            return(result);
        }
Exemple #4
0
        /// <summary>
        /// Builds the appropriate chunk for the ID
        /// </summary>
        /// <returns></returns>
        public static IDjvuNode CreateDecodedDjvuNode(IDjvuReader reader, IDjvuDocument rootDocument,
                                                      IDjvuElement parent, ChunkType chunkType,
                                                      string chunkID = "", long length = 0)
        {
            IDjvuNode result = null;

            switch (chunkType)
            {
            case ChunkType.Djvm:
                result = new DjvmChunk(reader, parent, rootDocument, chunkID, length);
                break;

            case ChunkType.Djvu:
                result = new DjvuChunk(reader, parent, rootDocument, chunkID, length);
                break;

            case ChunkType.Djvi:
                result = new DjviChunk(reader, parent, rootDocument, chunkID, length);
                break;

            case ChunkType.Thum:
                result = new ThumChunk(reader, parent, rootDocument, chunkID, length);
                break;

            case ChunkType.Dirm:
                result = new DirmChunk(reader, parent, rootDocument, chunkID, length);
                break;

            case ChunkType.Navm:
                result = new NavmChunk(reader, parent, rootDocument, chunkID, length);
                break;

            case ChunkType.Anta:
                result = new AntaChunk(reader, parent, rootDocument, chunkID, length);
                break;

            case ChunkType.Antz:
                result = new AntzChunk(reader, parent, rootDocument, chunkID, length);
                break;

            case ChunkType.Txta:
                result = new TxtaChunk(reader, parent, rootDocument, chunkID, length);
                break;

            case ChunkType.Txtz:
                result = new TxtzChunk(reader, parent, rootDocument, chunkID, length);
                break;

            case ChunkType.Djbz:
                result = new DjbzChunk(reader, parent, rootDocument, chunkID, length);
                break;

            case ChunkType.Sjbz:
                result = new SjbzChunk(reader, parent, rootDocument, chunkID, length);
                break;

            case ChunkType.FG44:
                result = new FG44Chunk(reader, parent, rootDocument, chunkID, length);
                break;

            case ChunkType.BG44:
                result = new BG44Chunk(reader, parent, rootDocument, chunkID, length);
                break;

            case ChunkType.TH44:
                result = new TH44Chunk(reader, parent, rootDocument, chunkID, length);
                break;

            case ChunkType.BM44:
                result = new BM44Chunk(reader, parent, rootDocument, chunkID, length);
                break;

            case ChunkType.BM44Form:
                result = new BM44Form(reader, parent, rootDocument, chunkID, length);
                break;

            case ChunkType.PM44:
                result = new PM44Chunk(reader, parent, rootDocument, chunkID, length);
                break;

            case ChunkType.PM44Form:
                result = new PM44Form(reader, parent, rootDocument, chunkID, length);
                break;

            case ChunkType.Wmrm:
                result = new WmrmChunk(reader, parent, rootDocument, chunkID, length);
                break;

            case ChunkType.FGbz:
                result = new FGbzChunk(reader, parent, rootDocument, chunkID, length);
                break;

            case ChunkType.Info:
                result = new InfoChunk(reader, parent, rootDocument, chunkID, length);
                break;

            case ChunkType.Incl:
                result = new InclChunk(reader, parent, rootDocument, chunkID, length);
                break;

            case ChunkType.BGjp:
                result = new BGjpChunk(reader, parent, rootDocument, chunkID, length);
                break;

            case ChunkType.FGjp:
                result = new FGjpChunk(reader, parent, rootDocument, chunkID, length);
                break;

            case ChunkType.Smmr:
                result = new SmmrChunk(reader, parent, rootDocument, chunkID, length);
                break;

            case ChunkType.Cida:
                result = new CidaChunk(reader, parent, rootDocument, chunkID, length);
                break;

            default:
                result = new UnknownChunk(reader, parent, rootDocument, chunkID, length);
                break;
            }

            return(result);
        }