Exemple #1
0
        private void Dispose(bool bDisposing)
        {
            if (!bDisposed)
            {
                bDisposed = true;

                if (oChunk != null)
                {
                    oChunk.Dispose();
                    oChunk = null;
                }

                if (sText != null)
                {
                    sText.Dispose();
                    sText = null;
                }

                bHTML = null;

                if (oE != null)
                {
                    oE.Dispose();
                    oE = null;
                }

                if (oTP != null)
                {
                    oTP.Dispose();
                    oTP = null;
                }
            }
        }
Exemple #2
0
        private void Dispose(bool bDisposing)
        {
            if (!bDisposed)
            {
                bDisposed = true;

                bHTML  = null;
                oChunk = null;
                sText  = null;
                oE     = null;
                oP     = null;
            }
        }
Exemple #3
0
        /// <summary>
        /// Inits tag parser
        /// </summary>
        /// <param name="p_oChunk"></param>
        /// <param name="p_sText"></param>
        internal void Init(HtmlParser p_oP, HTMLchunk p_oChunk, DynaString p_sText, byte[] p_bHTML, int p_iDataLength, HTMLentities p_oE, HTMLheuristics p_oHE)
        {
            oP          = p_oP;
            oChunk      = p_oChunk;
            sText       = p_sText;
            bHTML       = p_bHTML;
            iDataLength = p_iDataLength;

            // we don't want to be too close to end of data when dealing with heuristics
            iMaxHeuDataLength = iDataLength - MIN_DATA_SIZE_FOR_HEURISTICS;

            oE  = p_oE;
            oHE = p_oHE;
        }
Exemple #4
0
 /// <summary>
 /// This function will decode any entities found in a string - not fast!
 /// </summary>
 internal static string DecodeEntities(string text)
 {
     return(HTMLentities.DecodeEntities(text));
 }
Exemple #5
0
        public int Parse(string content, ArrayList lines)
        {
            lines.Clear();
            result = lines;
            HtmlParser parser = new HtmlParser();

            parser.SetChunkHashMode(true);

            parser.Init(content);
            parser.SetEncoding(System.Text.Encoding.UTF8);


            HTMLchunk chunk = null;

            Start();


            while (!finished && (chunk = parser.ParseNext()) != null)
            {
                switch (chunk.oType)
                {
                case HTMLchunkType.OpenTag:
                    HandleTag(chunk);
                    break;

                case HTMLchunkType.CloseTag:
                    HandleClosure(chunk.sTag);
                    break;

                case HTMLchunkType.Text:
                    offset = chunk.iChunkOffset;
                    string text = ClearExtraBlanks(chunk.oHTML);
                    text = HTMLentities.DecodeEntities(text);
                    HandleWords(text);
                    break;
                }
            }


            NewLine(true);
            if (!finished)
            {
                TextLine textLine = new TextLine();

                /* Raffaele Russo - 19/04/2011 - Start - Modificato l'argomento del costruttore TextSegment, il quarto parametro
                 * da "context.Font.Height" è stato modificato in "context.Font.GetHeight(96)" */
                textLine.SetSegments(new ArrayList(line), context.Font.GetHeight(96));
                // Raffaele Russo - 19/04/2011 - End

                textLine.Alignment = context.Alignment;
                if (height + textLine.Height <= bounds.Height)
                {
                    result.Add(textLine);
                }
                previousLine = null;
            }


            byte[] b = new byte[parser.iCurPos];
            Array.Copy(parser.bHTML, 0, b, 0, parser.iCurPos);
            int a = System.Text.Encoding.UTF8.GetString(b).Length;

            return(a);
        }