Beispiel #1
0
        private IEnumerable <OXmlElement> Text(HtmlDocNodeText text)
        {
            if (_imageHorizontalPosition != 0)
            {
                //yield return new OXmlElement { Type = OXmlElementType.Paragraph };
                yield return(new OXmlParagraphElement());

                _imageHorizontalPosition = 0;
            }
            yield return(new OXmlTextElement {
                Text = text.Text
            });
        }
Beispiel #2
0
        private IEnumerable <OXmlElement> Text(HtmlDocNodeText text)
        {
            //if (_imageHorizontalPosition != 0)
            //{
            //    yield return new OXmlParagraphElement();
            //    _imageHorizontalPosition = 0;
            //}

            //if (_trace)
            //    Trace.WriteLine("Text() :");

            string text2 = text.Text;

            if (_textRemoveBlank)
            {
                text2 = text2.Trim();
            }
            if (_textRemoveLine)
            {
                text2 = text2.Replace("\r", "");
                text2 = text2.Replace("\n", "");
            }
            if (text2.Length == 0)
            {
                yield break;
            }

            bool image = false;

            foreach (OXmlElement imageElement in GetImages())
            {
                yield return(imageElement);

                image = true;
            }
            if (image)
            {
                if (_line != null)
                {
                    if (_trace)
                    {
                        pb.Trace.WriteLine("Text()          : remove stored new line");
                    }
                    _line = null;
                }
                if (_paragraph != null)
                {
                    if (_trace)
                    {
                        pb.Trace.WriteLine("Text()          : send stored paragraph       after image");
                    }
                    yield return(_paragraph);

                    _paragraph = null;
                }
                else
                {
                    if (_trace)
                    {
                        pb.Trace.WriteLine("Text()          : send paragraph              after image");
                    }
                    yield return(new OXmlParagraphElement());
                }
            }
            else if (_paragraph != null)
            {
                if (_trace)
                {
                    pb.Trace.WriteLine("Text()          : send stored paragraph");
                }
                yield return(_paragraph);

                _paragraph = null;
            }
            else if (_line != null)
            {
                if (_trace)
                {
                    pb.Trace.WriteLine("Text()          : send stored new line");
                }
                yield return(_line);

                _line = null;
            }
            if (_trace)
            {
                pb.Trace.WriteLine($"Text()          : send text                   \"{zstr.left(text.Text, 20)}\"");
            }
            //_removeBlank _removeLine
            //string text2 = text.Text;
            //if (_textRemoveBlank)
            //    text2 = text2.Trim();
            //if (_textRemoveLine)
            //{
            //    text2 = text2.Replace("\r", "");
            //    text2 = text2.Replace("\n", "");
            //}
            yield return(new OXmlTextElement {
                Text = text2
            });
        }