Exemple #1
0
        public void Convert(Stream sourceStream, Stream destinationStream)
        {
            if (destinationStream == null)
            {
                throw new ArgumentNullException("destinationStream");
            }



            Stream converter = new ConverterStream(sourceStream, this, ConverterStreamAccess.Read);

            var buf = new byte[outputBufferSize];

            while (true)
            {
                var cnt = converter.Read(buf, 0, buf.Length);
                if (0 == cnt)
                {
                    break;
                }

                destinationStream.Write(buf, 0, cnt);
            }

            destinationStream.Flush();
        }
        // Token: 0x06000E89 RID: 3721 RVA: 0x00073040 File Offset: 0x00071240
        internal override IProducerConsumer CreatePullChain(Stream input, ConverterStream converterStream)
        {
            ConverterInput input2 = new ConverterDecodingInput(input, false, this.inputEncoding, this.detectEncodingFromByteOrderMark, this.testMaxHtmlTagSize, this.testMaxHtmlRestartOffset, base.InputStreamBufferSize, this.testBoundaryConditions, this, converterStream);
            FormatOutput   output = new RtfFormatOutput(converterStream, false, true, this.testBoundaryConditions, this, this.imageRenderingCallback, this.testFormatTraceStream, this.testFormatOutputTraceStream, this.inputEncoding);

            return(this.CreateChain(input2, output, converterStream));
        }
Exemple #3
0
        internal override IProducerConsumer CreatePushChain(ConverterStream converterStream, TextWriter output)
        {
            if (this.inputEncoding == null)
            {
                throw new InvalidOperationException(Strings.InputEncodingRequired);
            }

            this.outputEncoding = Encoding.Unicode;

            ConverterInput converterIn = new ConverterDecodingInput(
                converterStream,
                true,
                this.inputEncoding,
                this.detectEncodingFromByteOrderMark,
                this.maxHtmlTagSize,
                this.testMaxHtmlRestartOffset,
                this.InputStreamBufferSize,
                this.TestBoundaryConditions,
                this as IResultsFeedback,
                null);

            ConverterOutput converterOut = new ConverterUnicodeOutput(
                output,
                true,
                true);

            return(CreateChain(converterIn, converterOut, converterStream as IProgressMonitor));
        }
Exemple #4
0
        internal override IProducerConsumer CreatePullChain(Stream input, ConverterStream converterStream)
        {
            if (this.inputEncoding == null)
            {
                throw new InvalidOperationException(Strings.InputEncodingRequired);
            }

            ConverterInput converterIn = new ConverterDecodingInput(
                input,
                false,
                this.inputEncoding,
                this.detectEncodingFromByteOrderMark,
                this.maxHtmlTagSize,
                this.testMaxHtmlRestartOffset,
                this.InputStreamBufferSize,
                this.TestBoundaryConditions,
                this as IResultsFeedback,
                converterStream as IProgressMonitor);

            ConverterOutput converterOut = new ConverterEncodingOutput(
                converterStream,
                false,
                true,
                this.outputEncodingSameAsInput ? this.inputEncoding : this.outputEncoding,
                this.outputEncodingSameAsInput,
                this.TestBoundaryConditions,
                this as IResultsFeedback);

            return(CreateChain(converterIn, converterOut, converterStream as IProgressMonitor));
        }
Exemple #5
0
        internal override IProducerConsumer CreatePullChain(Stream input, ConverterStream converterStream)
        {
            ConverterInput input2 = new ConverterDecodingInput(input, false, this.inputEncoding, this.detectEncodingFromByteOrderMark, 4096, 0, base.InputStreamBufferSize, this.testBoundaryConditions, this, converterStream);
            FormatOutput   output = new RtfFormatOutput(converterStream, false, false, this.testBoundaryConditions, this, null, this.testFormatTraceStream, this.testFormatOutputTraceStream, this.inputEncoding);

            return(this.CreateChain(input2, output, converterStream));
        }
Exemple #6
0
        internal override IProducerConsumer CreatePullChain(TextReader input, ConverterStream converterStream)
        {
            this.inputEncoding = Encoding.Unicode;
            ConverterInput input2 = new ConverterUnicodeInput(input, false, 4096, this.testBoundaryConditions, converterStream);
            FormatOutput   output = new RtfFormatOutput(converterStream, false, false, this.testBoundaryConditions, this, null, this.testFormatTraceStream, this.testFormatOutputTraceStream, null);

            return(this.CreateChain(input2, output, converterStream));
        }
Exemple #7
0
        internal override IProducerConsumer CreatePullChain(TextReader input, ConverterStream converterStream)
        {
            this.inputEncoding = Encoding.Unicode;
            ConverterInput  input2 = new ConverterUnicodeInput(input, false, 4096, this.testBoundaryConditions, converterStream);
            ConverterOutput output = new ConverterEncodingOutput(converterStream, false, false, this.outputEncodingSameAsInput ? Encoding.UTF8 : this.outputEncoding, this.outputEncodingSameAsInput, this.testBoundaryConditions, this);

            return(this.CreateChain(input2, output, converterStream));
        }
        public ConverterDecodingInput(
            Stream source,
            bool push,
            System.Text.Encoding encoding,
            bool detectEncodingFromByteOrderMark,
            int maxParseToken,
            int restartMax,
            int inputBufferSize,
            bool testBoundaryConditions,
            IResultsFeedback resultFeedback,
            IProgressMonitor progressMonitor) :
            base(progressMonitor)
        {
            this.resultFeedback = resultFeedback;

            this.restartMax = restartMax;

            if (push)
            {
                InternalDebug.Assert(source is ConverterStream);

                this.pushSource = source as ConverterStream;
            }
            else
            {
                InternalDebug.Assert(source.CanRead);

                this.pullSource = source;
            }

            this.detectEncodingFromByteOrderMark = detectEncodingFromByteOrderMark;

            this.minDecodeBytes = testBoundaryConditions ? 1 : 64;

            this.originalEncoding = encoding;
            this.SetNewEncoding(encoding);

            InternalDebug.Assert(this.minDecodeBytes == 1 || this.minDecodeBytes >= Math.Max(4, this.preamble.Length));

            this.maxTokenSize = (maxParseToken == Int32.MaxValue) ?
                                maxParseToken :
                                testBoundaryConditions?
maxParseToken:
                                (maxParseToken + 1023) / 1024 * 1024;

            this.parseBuffer = new char[testBoundaryConditions ? 55 : Math.Min(4096, (long)this.maxTokenSize + (this.minDecodeChars + 1))];

            if (this.pushSource != null)
            {
                this.readBuffer = new byte[Math.Max(this.minDecodeBytes * 2, 8)];
            }
            else
            {
                int size = Math.Max(this.CalculateMaxBytes(this.parseBuffer.Length), inputBufferSize);

                this.readBuffer = new byte[size];
            }
        }
Exemple #9
0
        // Token: 0x06000FA6 RID: 4006 RVA: 0x0007505C File Offset: 0x0007325C
        internal override IProducerConsumer CreatePushChain(ConverterStream converterStream, Stream output)
        {
            if (this.inputEncoding == null)
            {
                throw new InvalidOperationException(TextConvertersStrings.InputEncodingRequired);
            }
            ConverterInput  input   = new ConverterDecodingInput(converterStream, true, this.inputEncoding, this.detectEncodingFromByteOrderMark, this.testMaxHtmlTagSize, this.testMaxHtmlRestartOffset, base.InputStreamBufferSize, this.testBoundaryConditions, this, null);
            ConverterOutput output2 = new ConverterEncodingOutput(output, true, true, this.outputEncodingSameAsInput ? this.inputEncoding : this.outputEncoding, this.outputEncodingSameAsInput, this.testBoundaryConditions, this);

            return(this.CreateChain(input, output2, converterStream));
        }
Exemple #10
0
        internal override IProducerConsumer CreatePullChain(Stream input, ConverterStream converterStream)
        {
            if (this.inputEncoding == null)
            {
                throw new InvalidOperationException(TextConvertersStrings.InputEncodingRequired);
            }
            ConverterInput  input2 = new ConverterDecodingInput(input, false, this.inputEncoding, this.detectEncodingFromByteOrderMark, 4096, 0, base.InputStreamBufferSize, this.testBoundaryConditions, this, converterStream);
            ConverterOutput output = new ConverterEncodingOutput(converterStream, false, true, this.outputEncodingSameAsInput ? this.inputEncoding : this.outputEncoding, this.outputEncodingSameAsInput, this.testBoundaryConditions, this);

            return(this.CreateChain(input2, output, converterStream));
        }
Exemple #11
0
        internal override IProducerConsumer CreatePushChain(ConverterStream converterStream, TextWriter output)
        {
            if (this.inputEncoding == null)
            {
                throw new InvalidOperationException(TextConvertersStrings.InputEncodingRequired);
            }
            this.outputEncoding = Encoding.Unicode;
            ConverterInput  input   = new ConverterDecodingInput(converterStream, true, this.inputEncoding, this.detectEncodingFromByteOrderMark, 4096, 0, base.InputStreamBufferSize, this.testBoundaryConditions, this, null);
            ConverterOutput output2 = new ConverterUnicodeOutput(output, true, true);

            return(this.CreateChain(input, output2, converterStream));
        }
        public ConverterEncodingOutput(
            Stream destination,
            bool push,
            bool restartable,
            System.Text.Encoding encoding,
            bool encodingSameAsInput,
            bool testBoundaryConditions,
            IResultsFeedback resultFeedback)
        {
            this.resultFeedback = resultFeedback;

            if (!push)
            {
                this.pullSink = destination as ConverterStream;
                InternalDebug.Assert(this.pullSink != null);

                this.pullSink.SetSource(this);
            }
            else
            {
                InternalDebug.Assert(destination.CanWrite);

                this.pushSink = destination;

                if (restartable && destination.CanSeek && destination.Position == destination.Length)
                {
                    this.restartablePushSink = true;
                    this.restartPosition     = destination.Position;
                }
            }

            this.restartable = this.canRestart = restartable;

            this.lineBuffer = new char[4096];

            this.minCharsEncode = testBoundaryConditions ? 1 : 256;

            this.encodingSameAsInput = encodingSameAsInput;

            this.originalEncoding = encoding;
            this.ChangeEncoding(encoding);

            if (this.resultFeedback != null)
            {
                this.resultFeedback.Set(ConfigParameter.OutputEncoding, this.encoding);
            }
        }
        protected override void Dispose()
        {
            if (cache != null && cache is IDisposable)
            {
                ((IDisposable)cache).Dispose();
            }

            cache       = null;
            pushSink    = null;
            pullSink    = null;
            lineBuffer  = null;
            encoding    = null;
            encoder     = null;
            codePageMap = null;

            base.Dispose();
        }
        protected override void Dispose()
        {
            if (this.cache != null && this.cache is IDisposable)
            {
                ((IDisposable)this.cache).Dispose();
            }

            this.cache       = null;
            this.pushSink    = null;
            this.pullSink    = null;
            this.lineBuffer  = null;
            this.encoding    = null;
            this.encoder     = null;
            this.codePageMap = null;

            base.Dispose();
        }
        protected override void Dispose()
        {
            if (this.restartCache != null && this.restartCache is IDisposable)
            {
                ((IDisposable)this.restartCache).Dispose();
            }

            this.restartCache    = null;
            this.pullSource      = null;
            this.pushSource      = null;
            this.parseBuffer     = null;
            this.readBuffer      = null;
            this.pushChunkBuffer = null;
            this.preamble        = null;
            this.restartConsumer = null;

            base.Dispose();
        }
Exemple #16
0
        protected override void Dispose()
        {
            if (restartCache != null && restartCache is IDisposable)
            {
                ((IDisposable)restartCache).Dispose();
            }

            restartCache    = null;
            pullSource      = null;
            pushSource      = null;
            parseBuffer     = null;
            readBuffer      = null;
            pushChunkBuffer = null;
            preamble        = null;
            restartConsumer = null;

            base.Dispose();
        }
Exemple #17
0
        public void Convert(Stream sourceStream, Stream destinationStream)
        {
            if (destinationStream == null)
            {
                throw new ArgumentNullException("destinationStream");
            }
            Stream stream = new ConverterStream(sourceStream, this, ConverterStreamAccess.Read);

            byte[] array = new byte[this.outputBufferSize];
            for (;;)
            {
                int num = stream.Read(array, 0, array.Length);
                if (num == 0)
                {
                    break;
                }
                destinationStream.Write(array, 0, num);
            }
            destinationStream.Flush();
        }
Exemple #18
0
        internal override IProducerConsumer CreatePullChain(TextReader input, ConverterStream converterStream)
        {
            this.inputEncoding = Encoding.Unicode;

            ConverterInput converterIn = new ConverterUnicodeInput(
                input,
                false,
                this.maxHtmlTagSize,
                this.TestBoundaryConditions,
                converterStream as IProgressMonitor);

            ConverterOutput converterOut = new ConverterEncodingOutput(
                converterStream,
                false,
                false,
                this.outputEncodingSameAsInput ? System.Text.Encoding.UTF8 : this.outputEncoding,
                this.outputEncodingSameAsInput,
                this.TestBoundaryConditions,
                this as IResultsFeedback);

            return(CreateChain(converterIn, converterOut, converterStream as IProgressMonitor));
        }
Exemple #19
0
        /// <summary>
        /// Converts the specified source reader.
        /// </summary>
        /// <param name="sourceReader">The source reader.</param>
        /// <param name="destinationStream">The destination stream.</param>
        public void Convert(TextReader sourceReader, Stream destinationStream)
        {
            if (destinationStream == null)
            {
                throw new ArgumentNullException(nameof(destinationStream));
            }

            Stream converter = new ConverterStream(sourceReader, this);

            byte[] buf = new byte[this.outputBufferSize];

            while (true)
            {
                int cnt = converter.Read(buf, 0, buf.Length);
                if (0 == cnt)
                {
                    break;
                }

                destinationStream.Write(buf, 0, cnt);
            }

            destinationStream.Flush();
        }
Exemple #20
0
 // Token: 0x06000FBB RID: 4027 RVA: 0x00075530 File Offset: 0x00073730
 internal override IProducerConsumer CreatePullChain(Stream input, ConverterStream converterStream)
 {
     return(new RtfCompressConverter(input, false, converterStream, this.compressionMode, base.InputStreamBufferSize, base.OutputStreamBufferSize));
 }
Exemple #21
0
 // Token: 0x06000FBC RID: 4028 RVA: 0x0007554C File Offset: 0x0007374C
 internal override IProducerConsumer CreatePullChain(TextReader input, ConverterStream converterStream)
 {
     throw new NotSupportedException(TextConvertersStrings.TextReaderUnsupported);
 }
Exemple #22
0
 // Token: 0x06000FB8 RID: 4024 RVA: 0x0007550C File Offset: 0x0007370C
 internal override IProducerConsumer CreatePushChain(ConverterStream converterStream, TextWriter output)
 {
     throw new NotSupportedException(TextConvertersStrings.TextWriterUnsupported);
 }
Exemple #23
0
 // Token: 0x06000FB7 RID: 4023 RVA: 0x000754F0 File Offset: 0x000736F0
 internal override IProducerConsumer CreatePushChain(ConverterStream converterStream, Stream output)
 {
     return(new RtfCompressConverter(converterStream, true, output, this.compressionMode, base.InputStreamBufferSize, base.OutputStreamBufferSize));
 }
Exemple #24
0
 internal override IProducerConsumer CreatePullChain(Stream input, ConverterStream converterStream)
 {
     return(this.CreateChain(input, converterStream, false, converterStream));
 }
Exemple #25
0
 internal override IProducerConsumer CreatePushChain(ConverterStream converterStream, Stream output)
 {
     return(new RtfDecompressConverter(converterStream, true, output, this.testDisableFastLoop, this, base.InputStreamBufferSize, base.OutputStreamBufferSize));
 }
Exemple #26
0
 internal abstract IProducerConsumer CreatePullChain(TextReader input, ConverterStream converterStream);
Exemple #27
0
 internal abstract IProducerConsumer CreatePushChain(ConverterStream converterStream, TextWriter output);
        // Token: 0x06000EF5 RID: 3829 RVA: 0x0007395C File Offset: 0x00071B5C
        internal override IProducerConsumer CreatePullChain(Stream input, ConverterStream converterStream)
        {
            ConverterOutput output = new ConverterEncodingOutput(converterStream, false, false, this.outputEncodingSameAsInput ? Encoding.GetEncoding("Windows-1252") : this.outputEncoding, this.outputEncodingSameAsInput, this.testBoundaryConditions, this);

            return(this.CreateChain(input, false, output, converterStream));
        }
Exemple #29
0
 internal override IProducerConsumer CreatePullChain(Stream input, ConverterStream converterStream)
 {
     return(new RtfDecompressConverter(input, false, converterStream, this.testDisableFastLoop, this, base.InputStreamBufferSize, base.OutputStreamBufferSize));
 }
        // Token: 0x06000EF2 RID: 3826 RVA: 0x00073924 File Offset: 0x00071B24
        internal override IProducerConsumer CreatePushChain(ConverterStream converterStream, TextWriter output)
        {
            ConverterOutput output2 = new ConverterUnicodeOutput(output, true, false);

            return(this.CreateChain(converterStream, true, output2, converterStream));
        }